@ailog/cli 0.1.1 → 0.1.3
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/README.md +2 -2
- package/dist/bin/cli.js +70 -3
- package/dist/standalone/.next/BUILD_ID +1 -1
- package/dist/standalone/.next/build-manifest.json +2 -2
- package/dist/standalone/.next/server/app/_global-error.html +2 -2
- package/dist/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/api/[[...route]]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/index.html +1 -1
- package/dist/standalone/.next/server/app/index.rsc +1 -1
- package/dist/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/standalone/.next/server/chunks/[root-of-the-server]__a0f47697._.js +1 -1
- package/dist/standalone/.next/server/chunks/ssr/node_modules__bun_4bd60410._.js +1 -1
- package/dist/standalone/.next/server/pages/404.html +1 -1
- package/dist/standalone/.next/server/pages/500.html +2 -2
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +5 -4
- package/dist/standalone/dist/standalone/dist/standalone/package.json +3 -3
- package/dist/standalone/dist/standalone/package.json +3 -3
- package/dist/standalone/package.json +3 -3
- package/package.json +3 -3
- package/dist/standalone/.env +0 -0
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +0 -3
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +0 -238
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +0 -224
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +0 -283
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +0 -274
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +0 -24
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +0 -65
- package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +0 -34
- /package/dist/standalone/.next/static/{8H5ZwnsPRw0PovUUXMbkb → ePLfvIxIoteKYr9bTCkF7}/_buildManifest.js +0 -0
- /package/dist/standalone/.next/static/{8H5ZwnsPRw0PovUUXMbkb → ePLfvIxIoteKYr9bTCkF7}/_clientMiddlewareManifest.json +0 -0
- /package/dist/standalone/.next/static/{8H5ZwnsPRw0PovUUXMbkb → ePLfvIxIoteKYr9bTCkF7}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports=[80253,30314,e=>{"use strict";var t=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=t?.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};e.s(["HTTPException",()=>t],80253);var r=e=>{let t=e.split("/");return""===t[0]&&t.shift(),t},a=e=>{let{groups:t,path:a}=i(e);return s(r(a),t)},i=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,r)=>{let a=`@${r}`;return t.push([a,e]),a}),{groups:t,path:e}},s=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[a]=t[r];for(let i=e.length-1;i>=0;i--)if(e[i].includes(a)){e[i]=e[i].replace(a,t[r][1]);break}}return e},n={},o=(e,t)=>{if("*"===e)return"*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let a=`${e}#${t}`;return n[a]||(r[2]?n[a]=t&&":"!==t[0]&&"*"!==t[0]?[a,r[1],RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],RegExp(`^${r[2]}$`)]:n[a]=[e,r[1],!0]),n[a]}return null},p=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},d=e=>p(e,decodeURI),l=e=>{let t=e.url,r=t.indexOf("/",t.indexOf(":")+4),a=r;for(;a<t.length;a++){let e=t.charCodeAt(a);if(37===e){let e=t.indexOf("?",a),i=t.slice(r,-1===e?void 0:e);return d(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}if(63===e)break}return t.slice(r,a)},c=e=>{let t=l(e);return t.length>1&&"/"===t.at(-1)?t.slice(0,-1):t},u=(e,t,...r)=>(r.length&&(t=u(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${"/"===t?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),h=e=>{if(63!==e.charCodeAt(e.length-1)||!e.includes(":"))return null;let t=e.split("/"),r=[],a="";return t.forEach(e=>{if(""===e||/\:/.test(e)){if(/\:/.test(e))if(/\?/.test(e)){0===r.length&&""===a?r.push("/"):r.push(a);let t=e.replace("?","");a+="/"+t,r.push(a)}else a+="/"+e}else a+="/"+e}),r.filter((e,t,r)=>r.indexOf(e)===t)},m=e=>/[%+]/.test(e)?(-1!==e.indexOf("+")&&(e=e.replace(/\+/g," ")),-1!==e.indexOf("%")?p(e,v):e):e,f=(e,t,r)=>{let a;if(!r&&t&&!/[%+]/.test(t)){let r=e.indexOf("?",8);if(-1===r)return;for(e.startsWith(t,r+1)||(r=e.indexOf(`&${t}`,r+1));-1!==r;){let a=e.charCodeAt(r+t.length+1);if(61===a){let a=r+t.length+2,i=e.indexOf("&",a);return m(e.slice(a,-1===i?void 0:i))}if(38==a||isNaN(a))return"";r=e.indexOf(`&${t}`,r+1)}if(!(a=/[%+]/.test(e)))return}let i={};a??=/[%+]/.test(e);let s=e.indexOf("?",8);for(;-1!==s;){let t,n=e.indexOf("&",s+1),o=e.indexOf("=",s);o>n&&-1!==n&&(o=-1);let p=e.slice(s+1,-1===o?-1===n?void 0:n:o);a&&(p=m(p)),s=n,""!==p&&(-1===o?t="":(t=e.slice(o+1,-1===n?void 0:n),a&&(t=m(t))),r?(i[p]&&Array.isArray(i[p])||(i[p]=[]),i[p].push(t)):i[p]??=t)}return t?i[t]:i},g=(e,t)=>f(e,t,!0),v=decodeURIComponent;e.s(["checkOptionalParameter",()=>h,"decodeURIComponent_",()=>v,"getPath",()=>l,"getPathNoStrict",()=>c,"getPattern",()=>o,"getQueryParam",()=>f,"getQueryParams",()=>g,"mergePath",()=>u,"splitPath",()=>r,"splitRoutingPath",()=>a,"tryDecode",()=>p],30314)},26481,e=>{"use strict";var t=(e,t,r)=>(a,i)=>{let s=-1;return n(0);async function n(o){let p,d;if(o<=s)throw Error("next() called multiple times");s=o;let l=!1;if(e[o]?(d=e[o][0][0],a.req.routeIndex=o):d=o===e.length&&i||void 0,d)try{p=await d(a,()=>n(o+1))}catch(e){if(e instanceof Error&&t)a.error=e,p=await t(e,a),l=!0;else throw e}else!1===a.finalized&&r&&(p=await r(a));return p&&(!1===a.finalized||l)&&(a.res=p),a}};e.i(80253);var r=Symbol(),a=async(e,t=Object.create(null))=>{let{all:r=!1,dot:a=!1}=t,s=(e instanceof d?e.raw.headers:e.headers).get("Content-Type");return s?.startsWith("multipart/form-data")||s?.startsWith("application/x-www-form-urlencoded")?i(e,{all:r,dot:a}):{}};async function i(e,t){var r,a;let i,o=await e.formData();return o?(r=o,a=t,i=Object.create(null),r.forEach((e,t)=>{a.all||t.endsWith("[]")?s(i,t,e):i[t]=e}),a.dot&&Object.entries(i).forEach(([e,t])=>{e.includes(".")&&(n(i,e,t),delete i[e])}),i):{}}var s=(e,t,r)=>{void 0!==e[t]?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r},n=(e,t,r)=>{let a=e,i=t.split(".");i.forEach((e,t)=>{t===i.length-1?a[e]=r:((!a[e]||"object"!=typeof a[e]||Array.isArray(a[e])||a[e]instanceof File)&&(a[e]=Object.create(null)),a=a[e])})},o=e.i(30314),p=e=>(0,o.tryDecode)(e,o.decodeURIComponent_),d=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#t=r,this.#e={}}param(e){return e?this.#r(e):this.#a()}#r(e){let t=this.#t[0][this.routeIndex][1][e],r=this.#i(t);return r&&/\%/.test(r)?p(r):r}#a(){let e={};for(let t of Object.keys(this.#t[0][this.routeIndex][1])){let r=this.#i(this.#t[0][this.routeIndex][1][t]);void 0!==r&&(e[t]=/\%/.test(r)?p(r):r)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return(0,o.getQueryParam)(this.url,e)}queries(e){return(0,o.getQueryParams)(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,r)=>{t[r]=e}),t}async parseBody(e){return this.bodyCache.parsedBody??=await a(this,e)}#s=e=>{let{bodyCache:t,raw:r}=this,a=t[e];if(a)return a;let i=Object.keys(t)[0];return i?t[i].then(t=>("json"===i&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=r[e]()};json(){return this.#s("text").then(e=>JSON.parse(e))}text(){return this.#s("text")}arrayBuffer(){return this.#s("arrayBuffer")}blob(){return this.#s("blob")}formData(){return this.#s("formData")}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[r](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},l=async(e,t,r,a,i)=>{var s;let n;"object"==typeof e&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let o=e.callbacks;if(!o?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let p=Promise.all(o.map(e=>e({phase:t,buffer:i,context:a}))).then(e=>Promise.all(e.filter(Boolean).map(e=>l(e,t,!1,a,i))).then(()=>i[0]));if(!r)return p;return s=await p,(n=new String(s)).isEscaped=!0,n.callbacks=o,n},c=(e,t)=>({"Content-Type":e,...t}),u=class{#n;#o;env={};#p;finalized=!1;error;#d;#l;#c;#u;#h;#m;#f;#t;#g;constructor(e,t){this.#n=e,t&&(this.#l=t.executionCtx,this.env=t.env,this.#m=t.notFoundHandler,this.#g=t.path,this.#t=t.matchResult)}get req(){return this.#o??=new d(this.#n,this.#g,this.#t),this.#o}get event(){if(this.#l&&"respondWith"in this.#l)return this.#l;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#l)return this.#l;throw Error("This context has no ExecutionContext")}get res(){return this.#c||=new Response(null,{headers:this.#f??=new Headers})}set res(e){if(this.#c&&e){for(let[t,r]of(e=new Response(e.body,e),this.#c.headers.entries()))if("content-type"!==t)if("set-cookie"===t){let t=this.#c.headers.getSetCookie();for(let r of(e.headers.delete("set-cookie"),t))e.headers.append("set-cookie",r)}else e.headers.set(t,r)}this.#c=e,this.finalized=!0}render=(...e)=>(this.#h??=e=>this.html(e),this.#h(...e));setLayout=e=>this.#u=e;getLayout=()=>this.#u;setRenderer=e=>{this.#h=e};header=(e,t,r)=>{this.finalized&&(this.#c=new Response(this.#c.body,this.#c));let a=this.#c?this.#c.headers:this.#f??=new Headers;void 0===t?a.delete(e):r?.append?a.append(e,t):a.set(e,t)};status=e=>{this.#d=e};set=(e,t)=>{this.#p??=new Map,this.#p.set(e,t)};get=e=>this.#p?this.#p.get(e):void 0;get var(){return this.#p?Object.fromEntries(this.#p):{}}#v(e,t,r){let a=this.#c?new Headers(this.#c.headers):this.#f??new Headers;if("object"==typeof t&&"headers"in t)for(let[e,r]of t.headers instanceof Headers?t.headers:new Headers(t.headers))"set-cookie"===e.toLowerCase()?a.append(e,r):a.set(e,r);if(r)for(let[e,t]of Object.entries(r))if("string"==typeof t)a.set(e,t);else for(let r of(a.delete(e),t))a.append(e,r);return new Response(e,{status:"number"==typeof t?t:t?.status??this.#d,headers:a})}newResponse=(...e)=>this.#v(...e);body=(e,t,r)=>this.#v(e,t,r);text=(e,t,r)=>this.#f||this.#d||t||r||this.finalized?this.#v(e,t,c("text/plain; charset=UTF-8",r)):new Response(e);json=(e,t,r)=>this.#v(JSON.stringify(e),t,c("application/json",r));html=(e,t,r)=>{let a=e=>this.#v(e,t,c("text/html; charset=UTF-8",r));return"object"==typeof e?l(e,1,!1,{}).then(a):a(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#m??=()=>new Response,this.#m(this))},h=["get","post","put","delete","options","patch"],m="Can not add a route since the matcher is already built.",f=class extends Error{},g=e=>e.text("404 Not Found",404),v=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},y=class e{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#g="/";routes=[];constructor(e={}){[...h,"all"].forEach(e=>{this[e]=(t,...r)=>("string"==typeof t?this.#g=t:this.#y(e,this.#g,t),r.forEach(t=>{this.#y(e,this.#g,t)}),this)}),this.on=(e,t,...r)=>{for(let a of[t].flat())for(let t of(this.#g=a,[e].flat()))r.map(e=>{this.#y(t.toUpperCase(),this.#g,e)});return this},this.use=(e,...t)=>("string"==typeof e?this.#g=e:(this.#g="*",t.unshift(e)),t.forEach(e=>{this.#y("ALL",this.#g,e)}),this);const{strict:t,...r}=e;Object.assign(this,r),this.getPath=t??!0?e.getPath??o.getPath:o.getPathNoStrict}#w(){let t=new e({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#m=this.#m,t.routes=this.routes,t}#m=g;errorHandler=v;route(e,r){let a=this.basePath(e);return r.routes.map(e=>{let i;r.errorHandler===v?i=e.handler:(i=async(a,i)=>(await t([],r.errorHandler)(a,()=>e.handler(a,i))).res).__COMPOSED_HANDLER=e.handler,a.#y(e.method,e.path,i)}),this}basePath(e){let t=this.#w();return t._basePath=(0,o.mergePath)(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#m=e,this);mount(e,t,r){let a,i,s,n;r&&("function"==typeof r?i=r:(i=r.optionHandler,a=!1===r.replaceRequest?e=>e:r.replaceRequest));let p=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};a||=(n="/"===(s=(0,o.mergePath)(this._basePath,e))?0:s.length,e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||"/",new Request(t,e)});let d=async(e,r)=>{let i=await t(a(e.req.raw),...p(e));if(i)return i;await r()};return this.#y("ALL",(0,o.mergePath)(e,"*"),d),this}#y(e,t,r){e=e.toUpperCase(),t=(0,o.mergePath)(this._basePath,t);let a={basePath:this._basePath,path:t,method:e,handler:r};this.router.add(e,t,[r,a]),this.routes.push(a)}#b(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#_(e,r,a,i){if("HEAD"===i)return(async()=>new Response(null,await this.#_(e,r,a,"GET")))();let s=this.getPath(e,{env:a}),n=this.router.match(i,s),o=new u(e,{path:s,matchResult:n,env:a,executionCtx:r,notFoundHandler:this.#m});if(1===n[0].length){let e;try{e=n[0][0][0][0](o,async()=>{o.res=await this.#m(o)})}catch(e){return this.#b(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#m(o))).catch(e=>this.#b(e,o)):e??this.#m(o)}let p=t(n[0],this.errorHandler,this.#m);return(async()=>{try{let e=await p(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#b(e,o)}})()}fetch=(e,...t)=>this.#_(e,t[1],t[0],e.method);request=(e,t,r,a)=>e instanceof Request?this.fetch(t?new Request(e,t):e,r,a):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${(0,o.mergePath)("/",e)}`,t),r,a));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#_(e.request,e,void 0,e.request.method))})}},w=[];function b(e,t){let r=this.buildAllMatchers(),a=(e,t)=>{let a=r[e]||r.ALL,i=a[2][t];if(i)return i;let s=t.match(a[0]);if(!s)return[[],w];let n=s.indexOf("",1);return[a[1][n],s]};return this.match=a,a(e,t)}var _="[^/]+",x="(?:|/.*)",N=Symbol(),T=new Set(".\\+*[^]$()");function E(e,t){return 1===e.length?1===t.length?e<t?-1:1:-1:1===t.length||".*"===e||e===x?1:".*"===t||t===x?-1:e===_?1:t===_?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var A=class e{#x;#N;#T=Object.create(null);insert(t,r,a,i,s){let n;if(0===t.length){if(void 0!==this.#x)throw N;if(s)return;this.#x=r;return}let[o,...p]=t,d="*"===o?0===p.length?["","",".*"]:["","",_]:"/*"===o?["","",x]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(d){let t=d[1],r=d[2]||_;if(t&&d[2]&&(".*"===r||(r=r.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(r))))throw N;if(!(n=this.#T[r])){if(Object.keys(this.#T).some(e=>".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[r]=new e,""!==t&&(n.#N=i.varIndex++)}s||""===t||a.push([t,n.#N])}else if(!(n=this.#T[o])){if(Object.keys(this.#T).some(e=>e.length>1&&".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[o]=new e}n.insert(p,r,a,i,s)}buildRegExpStr(){let e=Object.keys(this.#T).sort(E).map(e=>{let t=this.#T[e];return("number"==typeof t.#N?`(${e})@${t.#N}`:T.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return("number"==typeof this.#x&&e.unshift(`#${this.#x}`),0===e.length)?"":1===e.length?e[0]:"(?:"+e.join("|")+")"}},S=class{#E={varIndex:0};#A=new A;insert(e,t,r){let a=[],i=[];for(let t=0;;){let r=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let a=`@\\${t}`;return i[t]=[a,e],t++,r=!0,a}),!r)break}let s=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let r=s.length-1;r>=0;r--)if(-1!==s[r].indexOf(t)){s[r]=s[r].replace(t,i[e][1]);break}}return this.#A.insert(s,t,a,this.#E,r),a}buildRegExp(){let e=this.#A.buildRegExpStr();if(""===e)return[/^$/,[],[]];let t=0,r=[],a=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,s)=>void 0!==i?(r[++t]=Number(i),"$()"):(void 0!==s&&(a[Number(s)]=++t),"")),[RegExp(`^${e}`),r,a]}},k=[/^$/,[],Object.create(null)],O=Object.create(null);function C(e){return O[e]??=new RegExp("*"===e?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`)}function I(e,t){if(e){for(let r of Object.keys(e).sort((e,t)=>t.length-e.length))if(C(r).test(t))return[...e[r]]}}var R=class{name="RegExpRouter";#S;#k;constructor(){this.#S={ALL:Object.create(null)},this.#k={ALL:Object.create(null)}}add(e,t,r){let a=this.#S,i=this.#k;if(!a||!i)throw Error(m);a[e]||[a,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t.ALL).forEach(r=>{t[e][r]=[...t.ALL[r]]})}),"/*"===t&&(t="*");let s=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let n=C(t);"ALL"===e?Object.keys(a).forEach(e=>{a[e][t]||=I(a[e],t)||I(a.ALL,t)||[]}):a[e][t]||=I(a[e],t)||I(a.ALL,t)||[],Object.keys(a).forEach(t=>{("ALL"===e||e===t)&&Object.keys(a[t]).forEach(e=>{n.test(e)&&a[t][e].push([r,s])})}),Object.keys(i).forEach(t=>{("ALL"===e||e===t)&&Object.keys(i[t]).forEach(e=>n.test(e)&&i[t][e].push([r,s]))});return}let n=(0,o.checkOptionalParameter)(t)||[t];for(let t=0,o=n.length;t<o;t++){let p=n[t];Object.keys(i).forEach(n=>{("ALL"===e||e===n)&&(i[n][p]||=[...I(a[n],p)||I(a.ALL,p)||[]],i[n][p].push([r,s-o+t+1]))})}}match=b;buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#k).concat(Object.keys(this.#S)).forEach(t=>{e[t]||=this.#O(t)}),this.#S=this.#k=void 0,O=Object.create(null),e}#O(e){let t=[],r="ALL"===e;return([this.#S,this.#k].forEach(a=>{let i=a[e]?Object.keys(a[e]).map(t=>[t,a[e][t]]):[];0!==i.length?(r||=!0,t.push(...i)):"ALL"!==e&&t.push(...Object.keys(a.ALL).map(e=>[e,a.ALL[e]]))}),r)?function(e){let t=new S,r=[];if(0===e.length)return k;let a=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[r,a])=>e?1:r?-1:t.length-a.length),i=Object.create(null);for(let e=0,s=-1,n=a.length;e<n;e++){let n,[o,p,d]=a[e];o?i[p]=[d.map(([e])=>[e,Object.create(null)]),w]:s++;try{n=t.insert(p,s,o)}catch(e){throw e===N?new f(p):e}o||(r[s]=d.map(([e,t])=>{let r=Object.create(null);for(t-=1;t>=0;t--){let[e,a]=n[t];r[e]=a}return[e,r]}))}let[s,n,o]=t.buildRegExp();for(let e=0,t=r.length;e<t;e++)for(let t=0,a=r[e].length;t<a;t++){let a=r[e][t]?.[1];if(!a)continue;let i=Object.keys(a);for(let e=0,t=i.length;e<t;e++)a[i[e]]=o[a[i[e]]]}let p=[];for(let e in n)p[e]=r[n[e]];return[s,p,i]}(t):null}},D=class{name="SmartRouter";#C=[];#k=[];constructor(e){this.#C=e.routers}add(e,t,r){if(!this.#k)throw Error(m);this.#k.push([e,t,r])}match(e,t){let r;if(!this.#k)throw Error("Fatal error");let a=this.#C,i=this.#k,s=a.length,n=0;for(;n<s;n++){let s=a[n];try{for(let e=0,t=i.length;e<t;e++)s.add(...i[e]);r=s.match(e,t)}catch(e){if(e instanceof f)continue;throw e}this.match=s.match.bind(s),this.#C=[s],this.#k=void 0;break}if(n===s)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,r}get activeRouter(){if(this.#k||1!==this.#C.length)throw Error("No active router has been determined yet.");return this.#C[0]}},P=Object.create(null),j=class e{#I;#T;#R;#D=0;#P=P;constructor(e,t,r){if(this.#T=r||Object.create(null),this.#I=[],e&&t){const r=Object.create(null);r[e]={handler:t,possibleKeys:[],score:0},this.#I=[r]}this.#R=[]}insert(t,r,a){this.#D=++this.#D;let i=this,s=(0,o.splitRoutingPath)(r),n=[];for(let t=0,r=s.length;t<r;t++){let r=s[t],a=s[t+1],p=(0,o.getPattern)(r,a),d=Array.isArray(p)?p[0]:r;if(d in i.#T){i=i.#T[d],p&&n.push(p[1]);continue}i.#T[d]=new e,p&&(i.#R.push(p),n.push(p[1])),i=i.#T[d]}return i.#I.push({[t]:{handler:a,possibleKeys:n.filter((e,t,r)=>r.indexOf(e)===t),score:this.#D}}),i}#j(e,t,r,a){let i=[];for(let s=0,n=e.#I.length;s<n;s++){let n=e.#I[s],o=n[t]||n.ALL,p={};if(void 0!==o&&(o.params=Object.create(null),i.push(o),r!==P||a&&a!==P))for(let e=0,t=o.possibleKeys.length;e<t;e++){let t=o.possibleKeys[e],i=p[o.score];o.params[t]=a?.[t]&&!i?a[t]:r[t]??a?.[t],p[o.score]=!0}}return i}search(e,t){let r=[];this.#P=P;let a=[this],i=(0,o.splitPath)(t),s=[];for(let t=0,n=i.length;t<n;t++){let o=i[t],p=t===n-1,d=[];for(let n=0,l=a.length;n<l;n++){let l=a[n],c=l.#T[o];c&&(c.#P=l.#P,p?(c.#T["*"]&&r.push(...this.#j(c.#T["*"],e,l.#P)),r.push(...this.#j(c,e,l.#P))):d.push(c));for(let a=0,n=l.#R.length;a<n;a++){let n=l.#R[a],c=l.#P===P?{}:{...l.#P};if("*"===n){let t=l.#T["*"];t&&(r.push(...this.#j(t,e,l.#P)),t.#P=c,d.push(t));continue}let[u,h,m]=n;if(!o&&!(m instanceof RegExp))continue;let f=l.#T[u],g=i.slice(t).join("/");if(m instanceof RegExp){let t=m.exec(g);if(t){if(c[h]=t[0],r.push(...this.#j(f,e,l.#P,c)),Object.keys(f.#T).length){f.#P=c;let e=t[0].match(/\//)?.length??0;(s[e]||=[]).push(f)}continue}}(!0===m||m.test(o))&&(c[h]=o,p?(r.push(...this.#j(f,e,c,l.#P)),f.#T["*"]&&r.push(...this.#j(f.#T["*"],e,c,l.#P))):(f.#P=c,d.push(f)))}}a=d.concat(s.shift()??[])}return r.length>1&&r.sort((e,t)=>e.score-t.score),[r.map(({handler:e,params:t})=>[e,t])]}},q=class{name="TrieRouter";#q;constructor(){this.#q=new j}add(e,t,r){let a=(0,o.checkOptionalParameter)(t);if(a){for(let t=0,i=a.length;t<i;t++)this.#q.insert(e,a[t],r);return}this.#q.insert(e,t,r)}match(e,t){return this.#q.search(e,t)}},L=class extends y{constructor(e={}){super(e),this.router=e.router??new D({routers:[new R,new q]})}};e.s(["Hono",()=>L],26481)},19991,e=>{"use strict";e.i(26481),e.s([])},66349,e=>{"use strict";var t=e=>t=>e.fetch(t);e.s(["handle",()=>t])},66587,e=>{"use strict";e.i(66349),e.s([],66587)},7805,e=>{"use strict";var t=e=>{var t;let r={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...e},a=(e=>{if("string"==typeof e)if("*"===e)return()=>e;else return t=>e===t?t:null;return"function"==typeof e?e:t=>e.includes(t)?t:null})(r.origin),i="function"==typeof(t=r.allowMethods)?t:Array.isArray(t)?()=>t:()=>[];return async function(e,t){function s(t,r){e.res.headers.set(t,r)}let n=await a(e.req.header("origin")||"",e);if(n&&s("Access-Control-Allow-Origin",n),r.credentials&&s("Access-Control-Allow-Credentials","true"),r.exposeHeaders?.length&&s("Access-Control-Expose-Headers",r.exposeHeaders.join(",")),"OPTIONS"===e.req.method){"*"!==r.origin&&s("Vary","Origin"),null!=r.maxAge&&s("Access-Control-Max-Age",r.maxAge.toString());let t=await i(e.req.header("origin")||"",e);t.length&&s("Access-Control-Allow-Methods",t.join(","));let a=r.allowHeaders;if(!a?.length){let t=e.req.header("Access-Control-Request-Headers");t&&(a=t.split(/\s*,\s*/))}return a?.length&&(s("Access-Control-Allow-Headers",a.join(",")),e.res.headers.append("Vary","Access-Control-Request-Headers")),e.res.headers.delete("Content-Length"),e.res.headers.delete("Content-Type"),new Response(null,{headers:e.res.headers,status:204,statusText:"No Content"})}await t(),"*"!==r.origin&&e.header("Vary","Origin",{append:!0})}};e.s(["cors",()=>t])},39768,e=>{"use strict";e.s([],39768)},79296,e=>{"use strict";function t(e,t,r){function a(r,a){var i;for(let s in Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(i=r._zod).traits??(i.traits=new Set),r._zod.traits.add(e),t(r,a),n.prototype)s in r||Object.defineProperty(r,s,{value:n.prototype[s].bind(r)});r._zod.constr=n,r._zod.def=a}let i=r?.Parent??Object;class s extends i{}function n(e){var t;let i=r?.Parent?new s:this;for(let r of(a(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}function r(e,t){return"bigint"==typeof t?t.toString():t}Object.freeze({status:"aborted"}),Symbol("zod_brand"),Error.captureStackTrace||((...e)=>{}),()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}};let a=t("$ZodError",(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,r,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})}),i=t("ZodError",(e,t)=>{a.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>{let r,a,i;return r=t||function(e){return e.message},a={_errors:[]},(i=e=>{for(let t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>i({issues:e}));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)a._errors.push(r(t));else{let e=a,i=0;for(;i<t.path.length;){let a=t.path[i];i===t.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(r(t))):e[a]=e[a]||{_errors:[]},e=e[a],i++}}})(e),a}},flatten:{value:t=>(function(e,t=e=>e.message){let r={},a=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}})(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})});e.s(["ZodError",0,i],79296)},16172,e=>{"use strict";let t;e.s([],44057),e.i(44057),(to=tl||(tl={})).assertEqual=e=>{},to.assertIs=function(e){},to.assertNever=function(e){throw Error()},to.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},to.getValidEnumValues=e=>{let t=to.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let a of t)r[a]=e[a];return to.objectValues(r)},to.objectValues=e=>to.objectKeys(e).map(function(t){return e[t]}),to.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},to.find=(e,t)=>{for(let r of e)if(t(r))return r},to.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,to.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},to.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(tc||(tc={})).mergeShapes=(e,t)=>({...e,...t});let r=tl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return r.undefined;case"string":return r.string;case"number":return Number.isNaN(e)?r.nan:r.number;case"boolean":return r.boolean;case"function":return r.function;case"bigint":return r.bigint;case"symbol":return r.symbol;case"object":if(Array.isArray(e))return r.array;if(null===e)return r.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return r.promise;if("undefined"!=typeof Map&&e instanceof Map)return r.map;if("undefined"!=typeof Set&&e instanceof Set)return r.set;if("undefined"!=typeof Date&&e instanceof Date)return r.date;return r.object;default:return r.unknown}};e.s(["ZodParsedType",0,r,"getParsedType",0,a,"objectUtil",()=>tc,"util",()=>tl],57500);let i=tl.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),s=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},a=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(a);else if("invalid_return_type"===i.code)a(i.returnTypeError);else if("invalid_arguments"===i.code)a(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,a=0;for(;a<i.path.length;){let r=i.path[a];a===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tl.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];t[r]=t[r]||[],t[r].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}n.create=e=>new n(e),e.s(["ZodError",()=>n,"ZodIssueCode",0,i,"quotelessJson",0,s],21466);let o=(e,t)=>{let a;switch(e.code){case i.invalid_type:a=e.received===r.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,tl.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${tl.joinValues(e.keys,", ")}`;break;case i.invalid_union:a="Invalid input";break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${tl.joinValues(e.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${tl.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:a="Invalid function arguments";break;case i.invalid_return_type:a="Invalid function return type";break;case i.invalid_date:a="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:tl.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case i.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case i.custom:a="Invalid input";break;case i.invalid_intersection_types:a="Intersection results could not be merged";break;case i.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:a="Number must be finite";break;default:a=t.defaultError,tl.assertNever(e)}return{message:a}},p=o;function d(e){p=e}function l(){return p}e.s(["getErrorMap",()=>l,"setErrorMap",()=>d],13981),e.i(13981),e.s(["defaultErrorMap",0,o,"getErrorMap",()=>l,"setErrorMap",()=>d],87672),e.i(87672);let c=e=>{let{data:t,path:r,errorMaps:a,issueData:i}=e,s=[...r,...i.path||[]],n={...i,path:s};if(void 0!==i.message)return{...i,path:s,message:i.message};let o="";for(let e of a.filter(e=>!!e).slice().reverse())o=e(n,{data:t,defaultError:o}).message;return{...i,path:s,message:o}},u=[];function h(e,t){let r=p,a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===o?void 0:o].filter(e=>!!e)});e.common.issues.push(a)}class m{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if("aborted"===a.status)return f;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,a=await e.value;r.push({key:t,value:a})}return m.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:t,value:i}=a;if("aborted"===t.status||"aborted"===i.status)return f;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||a.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let f=Object.freeze({status:"aborted"}),g=e=>({status:"dirty",value:e}),v=e=>({status:"valid",value:e}),y=e=>"aborted"===e.status,w=e=>"dirty"===e.status,b=e=>"valid"===e.status,_=e=>"undefined"!=typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"OK",0,v,"ParseStatus",()=>m,"addIssueToContext",()=>h,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"makeIssue",0,c],58216),e.i(58216),e.s([],28032),e.i(28032),e.i(57500),(tp=tu||(tu={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},tp.toString=e=>"string"==typeof e?e:e?.message;class x{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let N=(e,t)=>{if(b(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new n(e.common.issues);return this._error=t,this._error}}};function T(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=e;if(t&&(r||a))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:s}=e;return"invalid_enum_value"===t.code?{message:s??i.defaultError}:void 0===i.data?{message:s??a??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:s??r??i.defaultError}},description:i}}class E{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new m,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(_(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parseSync({data:e,path:r.path,parent:r});return N(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return b(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>b(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parse({data:e,path:r.path,parent:r});return N(r,await (_(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,a)=>{let s=e(r),n=()=>a.addIssue({code:i.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(n(),!1)):!!s||(n(),!1)})}refinement(e,t){return this._refinement((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1))}_refinement(e){return new ew({schema:this,typeName:th.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return eb.create(this,this._def)}nullable(){return e_.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this)}promise(){return ey.create(this,this._def)}or(e){return ei.create([this,e],this._def)}and(e){return eo.create(this,e,this._def)}transform(e){return new ew({...T(this._def),schema:this,typeName:th.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new ex({...T(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:th.ZodDefault})}brand(){return new eA({typeName:th.ZodBranded,type:this,...T(this._def)})}catch(e){return new eN({...T(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:th.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eS.create(this,e)}readonly(){return ek.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let A=/^c[^\s-]{8,}$/i,S=/^[0-9a-z]+$/,k=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,R=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,D=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,P=/^(?:(?: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])$/,j=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,q=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\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])))",B=RegExp(`^${U}$`);function V(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function z(e){let t=`${U}T${V(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class W extends E{_parse(e){var a,s,n,o;let p;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.string,received:t.parsedType}),f}let d=new m;for(let r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("max"===r.kind)e.data.length>r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("length"===r.kind){let t=e.data.length>r.value,a=e.data.length<r.value;(t||a)&&(p=this._getOrReturnCtx(e,p),t?h(p,{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&h(p,{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),d.dirty())}else if("email"===r.kind)D.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"email",code:i.invalid_string,message:r.message}),d.dirty());else if("emoji"===r.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"emoji",code:i.invalid_string,message:r.message}),d.dirty());else if("uuid"===r.kind)O.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"uuid",code:i.invalid_string,message:r.message}),d.dirty());else if("nanoid"===r.kind)C.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"nanoid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid"===r.kind)A.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid2"===r.kind)S.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid2",code:i.invalid_string,message:r.message}),d.dirty());else if("ulid"===r.kind)k.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"ulid",code:i.invalid_string,message:r.message}),d.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{h(p=this._getOrReturnCtx(e,p),{validation:"url",code:i.invalid_string,message:r.message}),d.dirty()}else"regex"===r.kind?(r.regex.lastIndex=0,r.regex.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"regex",code:i.invalid_string,message:r.message}),d.dirty())):"trim"===r.kind?e.data=e.data.trim():"includes"===r.kind?e.data.includes(r.value,r.position)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),d.dirty()):"toLowerCase"===r.kind?e.data=e.data.toLowerCase():"toUpperCase"===r.kind?e.data=e.data.toUpperCase():"startsWith"===r.kind?e.data.startsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{startsWith:r.value},message:r.message}),d.dirty()):"endsWith"===r.kind?e.data.endsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{endsWith:r.value},message:r.message}),d.dirty()):"datetime"===r.kind?z(r).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"datetime",message:r.message}),d.dirty()):"date"===r.kind?B.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"date",message:r.message}),d.dirty()):"time"===r.kind?RegExp(`^${V(r)}$`).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"time",message:r.message}),d.dirty()):"duration"===r.kind?R.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"duration",code:i.invalid_string,message:r.message}),d.dirty()):"ip"===r.kind?(a=e.data,!(("v4"===(s=r.version)||!s)&&P.test(a)||("v6"===s||!s)&&q.test(a))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"ip",code:i.invalid_string,message:r.message}),d.dirty())):"jwt"===r.kind?!function(e,t){if(!I.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,r.alg)&&(h(p=this._getOrReturnCtx(e,p),{validation:"jwt",code:i.invalid_string,message:r.message}),d.dirty()):"cidr"===r.kind?(n=e.data,!(("v4"===(o=r.version)||!o)&&j.test(n)||("v6"===o||!o)&&L.test(n))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"cidr",code:i.invalid_string,message:r.message}),d.dirty())):"base64"===r.kind?M.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64",code:i.invalid_string,message:r.message}),d.dirty()):"base64url"===r.kind?F.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64url",code:i.invalid_string,message:r.message}),d.dirty()):tl.assertNever(r);return{status:d.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...tu.errToObj(r)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tu.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tu.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tu.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tu.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tu.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tu.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tu.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tu.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tu.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tu.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tu.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tu.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tu.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...tu.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...tu.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tu.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tu.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tu.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tu.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tu.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tu.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tu.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tu.errToObj(t)})}nonempty(e){return this.min(1,tu.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}W.create=e=>new W({checks:[],typeName:th.ZodString,coerce:e?.coerce??!1,...T(e)});class $ extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==r.number){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.number,received:t.parsedType}),f}let a=new m;for(let r of this._def.checks)"int"===r.kind?tl.isInteger(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"multipleOf"===r.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.not_finite,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tu.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tu.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tu.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tu.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&tl.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}$.create=e=>new $({checks:[],typeName:th.ZodNumber,coerce:e?.coerce||!1,...T(e)});class G extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let a=new m;for(let r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}G.create=e=>new G({checks:[],typeName:th.ZodBigInt,coerce:e?.coerce??!1,...T(e)});class H extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.boolean,received:t.parsedType}),f}return v(e.data)}}H.create=e=>new H({typeName:th.ZodBoolean,coerce:e?.coerce||!1,...T(e)});class K extends E{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.date,received:t.parsedType}),f}if(Number.isNaN(e.data.getTime()))return h(this._getOrReturnCtx(e),{code:i.invalid_date}),f;let a=new m;for(let r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),a.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),a.dirty()):tl.assertNever(r);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tu.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tu.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}K.create=e=>new K({checks:[],coerce:e?.coerce||!1,typeName:th.ZodDate,...T(e)});class J extends E{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.symbol,received:t.parsedType}),f}return v(e.data)}}J.create=e=>new J({typeName:th.ZodSymbol,...T(e)});class Z extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.undefined,received:t.parsedType}),f}return v(e.data)}}Z.create=e=>new Z({typeName:th.ZodUndefined,...T(e)});class Q extends E{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.null,received:t.parsedType}),f}return v(e.data)}}Q.create=e=>new Q({typeName:th.ZodNull,...T(e)});class Y extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return v(e.data)}}Y.create=e=>new Y({typeName:th.ZodAny,...T(e)});class X extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return v(e.data)}}X.create=e=>new X({typeName:th.ZodUnknown,...T(e)});class ee extends E{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.never,received:t.parsedType}),f}}ee.create=e=>new ee({typeName:th.ZodNever,...T(e)});class et extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.void,received:t.parsedType}),f}return v(e.data)}}et.create=e=>new et({typeName:th.ZodVoid,...T(e)});class er extends E{_parse(e){let{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==r.array)return h(t,{code:i.invalid_type,expected:r.array,received:t.parsedType}),f;if(null!==s.exactLength){let e=t.data.length>s.exactLength.value,r=t.data.length<s.exactLength.value;(e||r)&&(h(t,{code:e?i.too_big:i.too_small,minimum:r?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(h(t,{code:i.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(h(t,{code:i.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>s.type._parseAsync(new x(t,e,t.path,r)))).then(e=>m.mergeArray(a,e));let n=[...t.data].map((e,r)=>s.type._parseSync(new x(t,e,t.path,r)));return m.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new er({...this._def,minLength:{value:e,message:tu.toString(t)}})}max(e,t){return new er({...this._def,maxLength:{value:e,message:tu.toString(t)}})}length(e,t){return new er({...this._def,exactLength:{value:e,message:tu.toString(t)}})}nonempty(e){return this.min(1,e)}}er.create=(e,t)=>new er({type:e,minLength:null,maxLength:null,exactLength:null,typeName:th.ZodArray,...T(t)});class ea extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=tl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f}let{status:t,ctx:a}=this._processInputParams(e),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof ee&&"strip"===this._def.unknownKeys))for(let e in a.data)n.includes(e)||o.push(e);let p=[];for(let e of n){let t=s[e],r=a.data[e];p.push({key:{status:"valid",value:e},value:t._parse(new x(a,r,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ee){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of o)p.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(h(a,{code:i.unrecognized_keys,keys:o}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of o){let r=a.data[t];p.push({key:{status:"valid",value:t},value:e._parse(new x(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of p){let r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>m.mergeObjectSync(t,e)):m.mergeObjectSync(t,p)}get shape(){return this._def.shape()}strict(e){return tu.errToObj,new ea({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let a=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:tu.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ea({...this._def,unknownKeys:"strip"})}passthrough(){return new ea({...this._def,unknownKeys:"passthrough"})}extend(e){return new ea({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ea({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:th.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ea({...this._def,catchall:e})}pick(e){let t={};for(let r of tl.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}omit(e){let t={};for(let r of tl.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ea){let r={};for(let a in t.shape){let i=t.shape[a];r[a]=eb.create(e(i))}return new ea({...t._def,shape:()=>r})}if(t instanceof er)return new er({...t._def,type:e(t.element)});if(t instanceof eb)return eb.create(e(t.unwrap()));if(t instanceof e_)return e_.create(e(t.unwrap()));if(t instanceof ep)return ep.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of tl.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new ea({...this._def,shape:()=>t})}required(e){let t={};for(let r of tl.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof eb;)e=e._def.innerType;t[r]=e}return new ea({...this._def,shape:()=>t})}keyof(){return ef(tl.objectKeys(this.shape))}}ea.create=(e,t)=>new ea({shape:()=>e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.strictCreate=(e,t)=>new ea({shape:()=>e,unknownKeys:"strict",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.lazycreate=(e,t)=>new ea({shape:e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)});class ei extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new n(e.ctx.common.issues));return h(t,{code:i.invalid_union,unionErrors:r}),f});{let e,a=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},s=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===s.status)return s;"dirty"!==s.status||e||(e={result:s,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let s=a.map(e=>new n(e));return h(t,{code:i.invalid_union,unionErrors:s}),f}}get options(){return this._def.options}}ei.create=(e,t)=>new ei({options:e,typeName:th.ZodUnion,...T(t)});let es=e=>{if(e instanceof eh)return es(e.schema);if(e instanceof ew)return es(e.innerType());if(e instanceof em)return[e.value];if(e instanceof eg)return e.options;if(e instanceof ev)return tl.objectValues(e.enum);else if(e instanceof ex)return es(e._def.innerType);else if(e instanceof Z)return[void 0];else if(e instanceof Q)return[null];else if(e instanceof eb)return[void 0,...es(e.unwrap())];else if(e instanceof e_)return[null,...es(e.unwrap())];else if(e instanceof eA)return es(e.unwrap());else if(e instanceof ek)return es(e.unwrap());else if(e instanceof eN)return es(e._def.innerType);else return[]};class en extends E{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f;let a=this.discriminator,s=t.data[a],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let r of t){let t=es(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(a.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);a.set(i,r)}}return new en({typeName:th.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...T(r)})}}class eo extends E{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(y(e)||y(n))return f;let o=function e(t,i){let s=a(t),n=a(i);if(t===i)return{valid:!0,data:t};if(s===r.object&&n===r.object){let r=tl.objectKeys(i),a=tl.objectKeys(t).filter(e=>-1!==r.indexOf(e)),s={...t,...i};for(let r of a){let a=e(t[r],i[r]);if(!a.valid)return{valid:!1};s[r]=a.data}return{valid:!0,data:s}}if(s===r.array&&n===r.array){if(t.length!==i.length)return{valid:!1};let r=[];for(let a=0;a<t.length;a++){let s=e(t[a],i[a]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}if(s===r.date&&n===r.date&&+t==+i)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return o.valid?((w(e)||w(n))&&t.dirty(),{status:t.value,value:o.data}):(h(s,{code:i.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}eo.create=(e,t,r)=>new eo({left:e,right:t,typeName:th.ZodIntersection,...T(r)});class ep extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.array)return h(a,{code:i.invalid_type,expected:r.array,received:a.parsedType}),f;if(a.data.length<this._def.items.length)return h(a,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...a.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new x(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>m.mergeArray(t,e)):m.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ep({...this._def,rest:e})}}ep.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ep({items:e,typeName:th.ZodTuple,rest:null,...T(t)})};class ed extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.object)return h(a,{code:i.invalid_type,expected:r.object,received:a.parsedType}),f;let s=[],n=this._def.keyType,o=this._def.valueType;for(let e in a.data)s.push({key:n._parse(new x(a,e,a.path,e)),value:o._parse(new x(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?m.mergeObjectAsync(t,s):m.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return new ed(t instanceof E?{keyType:e,valueType:t,typeName:th.ZodRecord,...T(r)}:{keyType:W.create(),valueType:e,typeName:th.ZodRecord,...T(t)})}}class el extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.map)return h(a,{code:i.invalid_type,expected:r.map,received:a.parsedType}),f;let s=this._def.keyType,n=this._def.valueType,o=[...a.data.entries()].map(([e,t],r)=>({key:s._parse(new x(a,e,a.path,[r,"key"])),value:n._parse(new x(a,t,a.path,[r,"value"]))}));if(a.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of o){let a=await r.key,i=await r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of o){let a=r.key,i=r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}}}}el.create=(e,t,r)=>new el({valueType:t,keyType:e,typeName:th.ZodMap,...T(r)});class ec extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.set)return h(a,{code:i.invalid_type,expected:r.set,received:a.parsedType}),f;let s=this._def;null!==s.minSize&&a.data.size<s.minSize.value&&(h(a,{code:i.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&a.data.size>s.maxSize.value&&(h(a,{code:i.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let n=this._def.valueType;function o(e){let r=new Set;for(let a of e){if("aborted"===a.status)return f;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}let p=[...a.data.values()].map((e,t)=>n._parse(new x(a,e,a.path,t)));return a.common.async?Promise.all(p).then(e=>o(e)):o(p)}min(e,t){return new ec({...this._def,minSize:{value:e,message:tu.toString(t)}})}max(e,t){return new ec({...this._def,maxSize:{value:e,message:tu.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ec.create=(e,t)=>new ec({valueType:e,minSize:null,maxSize:null,typeName:th.ZodSet,...T(t)});class eu extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return h(t,{code:i.invalid_type,expected:r.function,received:t.parsedType}),f;function a(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:r}})}function s(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:r}})}let d={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof ey){let e=this;return v(async function(...t){let r=new n([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw r.addIssue(a(t,e)),r}),o=await Reflect.apply(l,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw r.addIssue(s(o,e)),r})})}{let e=this;return v(function(...t){let r=e._def.args.safeParse(t,d);if(!r.success)throw new n([a(t,r.error)]);let i=Reflect.apply(l,this,r.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new n([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new eu({...this._def,args:ep.create(e).rest(X.create())})}returns(e){return new eu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new eu({args:e||ep.create([]).rest(X.create()),returns:t||X.create(),typeName:th.ZodFunction,...T(r)})}}class eh extends E{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}eh.create=(e,t)=>new eh({getter:e,typeName:th.ZodLazy,...T(t)});class em extends E{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ef(e,t){return new eg({values:e,typeName:th.ZodEnum,...T(t)})}em.create=(e,t)=>new em({value:e,typeName:th.ZodLiteral,...T(t)});class eg extends E{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:tl.joinValues(r),received:t.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:i.invalid_enum_value,options:r}),f}return v(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return eg.create(e,{...this._def,...t})}exclude(e,t=this._def){return eg.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eg.create=ef;class ev extends E{_parse(e){let t=tl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==r.string&&a.parsedType!==r.number){let e=tl.objectValues(t);return h(a,{expected:tl.joinValues(e),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(tl.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tl.objectValues(t);return h(a,{received:a.data,code:i.invalid_enum_value,options:e}),f}return v(e.data)}get enum(){return this._def.values}}ev.create=(e,t)=>new ev({values:e,typeName:th.ZodNativeEnum,...T(t)});class ey extends E{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&!1===t.common.async?(h(t,{code:i.invalid_type,expected:r.promise,received:t.parsedType}),f):v((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ey.create=(e,t)=>new ey({type:e,typeName:th.ZodPromise,...T(t)});class ew extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===th.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:e=>{h(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===a.type){let e=a.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return f;let a=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a});{if("aborted"===t.value)return f;let a=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a}}if("refinement"===a.type){let e=e=>{let t=a.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?f:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===a.status?f:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}}if("transform"===a.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>b(e)?Promise.resolve(a.transform(e.value,i)).then(e=>({status:t.value,value:e})):f);else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!b(e))return f;let s=a.transform(e.value,i);if(s instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}tl.assertNever(a)}}ew.create=(e,t,r)=>new ew({schema:e,typeName:th.ZodEffects,effect:t,...T(r)}),ew.createWithPreprocess=(e,t,r)=>new ew({schema:t,effect:{type:"preprocess",transform:e},typeName:th.ZodEffects,...T(r)});class eb extends E{_parse(e){return this._getType(e)===r.undefined?v(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eb.create=(e,t)=>new eb({innerType:e,typeName:th.ZodOptional,...T(t)});class e_ extends E{_parse(e){return this._getType(e)===r.null?v(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}e_.create=(e,t)=>new e_({innerType:e,typeName:th.ZodNullable,...T(t)});class ex extends E{_parse(e){let{ctx:t}=this._processInputParams(e),a=t.data;return t.parsedType===r.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ex.create=(e,t)=>new ex({innerType:e,typeName:th.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...T(t)});class eN extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _(a)?a.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}eN.create=(e,t)=>new eN({innerType:e,typeName:th.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...T(t)});class eT extends E{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}eT.create=e=>new eT({typeName:th.ZodNaN,...T(e)});let eE=Symbol("zod_brand");class eA extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class eS extends E{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),g(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new eS({in:e,out:t,typeName:th.ZodPipeline})}}class ek extends E{_parse(e){let t=this._def.innerType._parse(e),r=e=>(b(e)&&(e.value=Object.freeze(e.value)),e);return _(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function eO(e,t){let r="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof r?{message:r}:r}function eC(e,t={},r){return e?Y.create().superRefine((a,i)=>{let s=e(a);if(s instanceof Promise)return s.then(e=>{if(!e){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}});if(!s){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}}):Y.create()}ek.create=(e,t)=>new ek({innerType:e,typeName:th.ZodReadonly,...T(t)});let eI={object:ea.lazycreate};(td=th||(th={})).ZodString="ZodString",td.ZodNumber="ZodNumber",td.ZodNaN="ZodNaN",td.ZodBigInt="ZodBigInt",td.ZodBoolean="ZodBoolean",td.ZodDate="ZodDate",td.ZodSymbol="ZodSymbol",td.ZodUndefined="ZodUndefined",td.ZodNull="ZodNull",td.ZodAny="ZodAny",td.ZodUnknown="ZodUnknown",td.ZodNever="ZodNever",td.ZodVoid="ZodVoid",td.ZodArray="ZodArray",td.ZodObject="ZodObject",td.ZodUnion="ZodUnion",td.ZodDiscriminatedUnion="ZodDiscriminatedUnion",td.ZodIntersection="ZodIntersection",td.ZodTuple="ZodTuple",td.ZodRecord="ZodRecord",td.ZodMap="ZodMap",td.ZodSet="ZodSet",td.ZodFunction="ZodFunction",td.ZodLazy="ZodLazy",td.ZodLiteral="ZodLiteral",td.ZodEnum="ZodEnum",td.ZodEffects="ZodEffects",td.ZodNativeEnum="ZodNativeEnum",td.ZodOptional="ZodOptional",td.ZodNullable="ZodNullable",td.ZodDefault="ZodDefault",td.ZodCatch="ZodCatch",td.ZodPromise="ZodPromise",td.ZodBranded="ZodBranded",td.ZodPipeline="ZodPipeline",td.ZodReadonly="ZodReadonly";let eR=(e,t={message:`Input not instance of ${e.name}`})=>eC(t=>t instanceof e,t),eD=W.create,eP=$.create,ej=eT.create,eq=G.create,eL=H.create,eM=K.create,eF=J.create,eU=Z.create,eB=Q.create,eV=Y.create,ez=X.create,eW=ee.create,e$=et.create,eG=er.create,eH=ea.create,eK=ea.strictCreate,eJ=ei.create,eZ=en.create,eQ=eo.create,eY=ep.create,eX=ed.create,e1=el.create,e0=ec.create,e2=eu.create,e6=eh.create,e4=em.create,e3=eg.create,e9=ev.create,e5=ey.create,e8=ew.create,e7=eb.create,te=e_.create,tt=ew.createWithPreprocess,tr=eS.create,ta=()=>eD().optional(),ti=()=>eP().optional(),ts=()=>eL().optional(),tn={string:e=>W.create({...e,coerce:!0}),number:e=>$.create({...e,coerce:!0}),boolean:e=>H.create({...e,coerce:!0}),bigint:e=>G.create({...e,coerce:!0}),date:e=>K.create({...e,coerce:!0})};e.s(["BRAND",0,eE,"NEVER",0,f,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"instanceof",()=>eR,"intersection",()=>eQ,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"record",()=>eX,"set",()=>e0,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"void",()=>e$],73023),e.i(73023),e.i(21466),e.s(["BRAND",0,eE,"DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"NEVER",0,f,"OK",0,v,"ParseStatus",()=>m,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodError",()=>n,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodIssueCode",0,i,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodParsedType",0,r,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"addIssueToContext",()=>h,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"defaultErrorMap",0,o,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"getErrorMap",()=>l,"getParsedType",0,a,"instanceof",()=>eR,"intersection",()=>eQ,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"makeIssue",0,c,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"objectUtil",()=>tc,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"quotelessJson",0,s,"record",()=>eX,"set",()=>e0,"setErrorMap",()=>d,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"util",()=>tl,"void",()=>e$],59063);var to,tp,td,tl,tc,tu,th,tm=e.i(59063);e.s(["z",0,tm],16172)},96401,e=>{"use strict";var t=e.i(16172);let r=t.z.enum(["local","postgres"]),a=t.z.enum(["local","gcs"]),i=t.z.object({serverPepper:t.z.string().min(1),standaloneMode:t.z.boolean().default(!1),storeTypes:t.z.object({global:r,log:r.optional(),app:r.optional(),blob:a}),paths:t.z.object({localStore:t.z.string().min(1),blobStore:t.z.string().min(1)}),gcs:t.z.object({bucketName:t.z.string().optional()})}),s={serverPepper:process.env.API_KEY_PEPPER||"default-pepper-change-in-production",standaloneMode:"false"!==process.env.AILOG_STANDALONE_MODE,storeTypes:{global:process.env.STORE_TYPE||"local",log:process.env.LOG_STORE_TYPE,app:process.env.APP_STORE_TYPE,blob:process.env.BLOB_STORE_TYPE||"local"},paths:{localStore:process.env.LOCAL_STORE_PATH||"./.ailog/data",blobStore:process.env.BLOB_STORE_LOCAL_PATH||"./data/blobs"},gcs:{bucketName:process.env.GCS_BUCKET_NAME}},n=i.parse(s),o={log:n.storeTypes.log??n.storeTypes.global,app:n.storeTypes.app??n.storeTypes.global,blob:n.storeTypes.blob};e.s(["config",0,n,"resolvedStoreTypes",0,o])},13558,e=>{"use strict";var t=e.i(30314),r=/^[\w!#$%&'*.^`|~+-]+$/,a=/^[ !#-:<-[\]-~]*$/,i=(e,i)=>{if(i&&-1===e.indexOf(i))return{};let s=e.trim().split(";"),n={};for(let e of s){let s=(e=e.trim()).indexOf("=");if(-1===s)continue;let o=e.substring(0,s).trim();if(i&&i!==o||!r.test(o))continue;let p=e.substring(s+1).trim();if(p.startsWith('"')&&p.endsWith('"')&&(p=p.slice(1,-1)),a.test(p)&&(n[o]=-1!==p.indexOf("%")?(0,t.tryDecode)(p,t.decodeURIComponent_):p,i))break}return n},s=e.i(80253),n=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,o=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,p=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;let d=function(e,t,r,a){let d;return d=async(i,s)=>{let n=i;if("header"===e&&"_def"in t||"header"===e&&"_zod"in t){let e=Object.fromEntries(Object.keys("in"in t?t.in.shape:t.shape).map(e=>[e.toLowerCase(),e]));n=Object.fromEntries(Object.entries(i).map(([t,r])=>[e[t]||t,r]))}let o=a&&a.validationFunction?await a.validationFunction(t,n):await t.safeParseAsync(n);if(r){let t=await r({data:n,...o,target:e},s);if(t){if(t instanceof Response)return t;if("response"in t)return t.response}}return o.success?o.data:s.json(o,400)},async(t,r)=>{let a={},l=t.req.header("Content-Type");switch(e){case"json":if(!l||!n.test(l))break;try{a=await t.req.json()}catch{throw new s.HTTPException(400,{message:"Malformed JSON in request body"})}break;case"form":{let e;if(!l||!(o.test(l)||p.test(l)))break;if(t.req.bodyCache.formData)e=await t.req.bodyCache.formData;else try{let r=await t.req.arrayBuffer();e=await new Response(r,{headers:{"Content-Type":l}}).formData(),t.req.bodyCache.formData=e}catch(t){let e="Malformed FormData request.";throw e+=t instanceof Error?` ${t.message}`:` ${String(t)}`,new s.HTTPException(400,{message:e})}let r={};e.forEach((e,t)=>{t.endsWith("[]")?(r[t]??=[]).push(e):Array.isArray(r[t])?r[t].push(e):t in r?r[t]=[r[t],e]:r[t]=e}),a=r;break}case"query":a=Object.fromEntries(Object.entries(t.req.queries()).map(([e,t])=>1===t.length?[e,t[0]]:[e,t]));break;case"param":a=t.req.param();break;case"header":a=t.req.header();break;case"cookie":a=((e,t,r)=>{let a=e.req.raw.headers.get("Cookie");if("string"==typeof t){if(!a)return;let e=t;return"secure"===r?e="__Secure-"+t:"host"===r&&(e="__Host-"+t),i(a,e)[e]}return a?i(a):{}})(t)}let c=await d(a,t);return c instanceof Response?c:(t.req.addValidatedData(e,c),await r())}};e.s(["zValidator",()=>d],13558)},84739,482,62212,79044,56967,6697,54199,6937,80864,90348,56900,22177,46220,40203,9581,83013,50430,72866,29986,27539,34939,2758,90640,46432,13424,82258,45393,86566,72515,21797,51014,67204,87799,e=>{"use strict";function t(e){return void 0===e||void 0===e}function r(e){return"string"==typeof e}function a(e){return"number"==typeof e}function i(e){return"boolean"==typeof e}function s(e){return null===e}function n(e){return e instanceof Date}function o(e){return"bigint"==typeof e}function p(e){return"function"==typeof e}function d(e){return"object"==typeof e&&null!==e}function l(e){return e[e.length-1]}function c(e){return Object.freeze(e)}function u(e){return h(e)?e:[e]}function h(e){return Array.isArray(e)}function m(e){return e}Object.prototype.toString,e.s(["asArray",()=>u,"freeze",()=>c,"getLast",()=>l,"isBigInt",()=>o,"isBoolean",()=>i,"isDate",()=>n,"isFunction",()=>p,"isNull",()=>s,"isNumber",()=>a,"isObject",()=>d,"isReadonlyArray",()=>h,"isString",()=>r,"isUndefined",()=>t,"noop",()=>m],84739);let f=c({is:e=>"IdentifierNode"===e.kind,create:e=>c({kind:"IdentifierNode",name:e})});e.s(["IdentifierNode",0,f],482);let g=c({is:e=>"SchemableIdentifierNode"===e.kind,create:e=>c({kind:"SchemableIdentifierNode",identifier:f.create(e)}),createWithSchema:(e,t)=>c({kind:"SchemableIdentifierNode",schema:f.create(e),identifier:f.create(t)})});e.s(["SchemableIdentifierNode",0,g],62212),e.s(["parseAliasedTable",()=>rt,"parseTable",()=>rr,"parseTableExpression",()=>re,"parseTableExpressionOrList",()=>t7],87799);let v=c({is:e=>"AliasNode"===e.kind,create:(e,t)=>c({kind:"AliasNode",node:e,alias:t})});e.s(["AliasNode",0,v],79044);let y=c({is:e=>"TableNode"===e.kind,create:e=>c({kind:"TableNode",table:g.create(e)}),createWithSchema:(e,t)=>c({kind:"TableNode",table:g.createWithSchema(e,t)})});function w(e){return d(e)&&p(e.toOperationNode)}e.s(["isExpressionOrFactory",()=>t8,"parseAliasedExpression",()=>t5,"parseExpression",()=>t9],67204),e.s(["isOperationNodeSource",()=>w],56967);let b=c({is:e=>"SelectModifierNode"===e.kind,create:(e,t)=>c({kind:"SelectModifierNode",modifier:e,of:t}),createWithExpression:e=>c({kind:"SelectModifierNode",rawModifier:e})}),_=c({is:e=>"AndNode"===e.kind,create:(e,t)=>c({kind:"AndNode",left:e,right:t})}),x=c({is:e=>"OrNode"===e.kind,create:(e,t)=>c({kind:"OrNode",left:e,right:t})}),N=c({is:e=>"OnNode"===e.kind,create:e=>c({kind:"OnNode",on:e}),cloneWithOperation:(e,t,r)=>c({...e,on:"And"===t?_.create(e.on,r):x.create(e.on,r)})}),T=c({is:e=>"JoinNode"===e.kind,create:(e,t)=>c({kind:"JoinNode",joinType:e,table:t,on:void 0}),createWithOn:(e,t,r)=>c({kind:"JoinNode",joinType:e,table:t,on:N.create(r)}),cloneWithOn:(e,t)=>c({...e,on:e.on?N.cloneWithOperation(e.on,"And",t):N.create(t)})});e.s(["parseFilterList",()=>ec,"parseFilterObject",()=>el,"parseReferentialBinaryOperation",()=>ed,"parseValueBinaryOperation",()=>ep,"parseValueBinaryOperationOrExpression",()=>eo],83013);let E=c({is:e=>"BinaryOperationNode"===e.kind,create:(e,t,r)=>c({kind:"BinaryOperationNode",leftOperand:e,operator:t,rightOperand:r})}),A=["->","->>"],S=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from","+","-","*","/","%","^","&","|","#","<<",">>","&&","||",...A,"not","-","exists","not exists","between","between symmetric"],k=c({is:e=>"OperatorNode"===e.kind,create:e=>c({kind:"OperatorNode",operator:e})});function O(e){return r(e)&&A.includes(e)}e.s(["OPERATORS",0,S,"OperatorNode",0,k,"isJSONOperator",()=>O],6697),e.s(["parseAliasedStringReference",()=>J,"parseColumnName",()=>Z,"parseJSONReference",()=>H,"parseOrderedColumnName",()=>Q,"parseReferenceExpression",()=>G,"parseReferenceExpressionOrList",()=>$,"parseSimpleReferenceExpression",()=>W,"parseStringReference",()=>K],56900);let C=c({is:e=>"ColumnNode"===e.kind,create:e=>c({kind:"ColumnNode",column:f.create(e)})});e.s(["ColumnNode",0,C],54199);let I=c({is:e=>"SelectAllNode"===e.kind,create:()=>c({kind:"SelectAllNode"})});e.s(["SelectAllNode",0,I],6937);let R=c({is:e=>"ReferenceNode"===e.kind,create:(e,t)=>c({kind:"ReferenceNode",table:t,column:e}),createSelectAll:e=>c({kind:"ReferenceNode",table:e,column:I.create()})});e.s(["DynamicReferenceBuilder",()=>D,"isDynamicReferenceBuilder",()=>P],80864);class D{#L;get dynamicReference(){return this.#L}get refType(){}constructor(e){this.#L=e}toOperationNode(){return W(this.#L)}}function P(e){return d(e)&&w(e)&&r(e.dynamicReference)}let j=c({is:e=>"OrderByItemNode"===e.kind,create:(e,t)=>c({kind:"OrderByItemNode",orderBy:e,direction:t})}),q=c({is:e=>"RawNode"===e.kind,create:(e,t)=>c({kind:"RawNode",sqlFragments:c(e),parameters:c(t)}),createWithSql:e=>q.create([e],[]),createWithChild:e=>q.create(["",""],[e]),createWithChildren:e=>q.create(Array(e.length+1).fill(""),e)});function L(e){return"asc"===e||"desc"===e}function M(e){if(2===e.length)return[F(e[0],e[1])];if(1===e.length){let[t]=e;return Array.isArray(t)?t.map(e=>F(e)):[F(t)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function F(e,t){let r=function(e){if(t8(e))return t9(e);if(P(e))return e.toOperationNode();let[t,r]=e.split(" ");if(r){if(!L(r))throw Error(`Invalid order by direction: ${r}`);return j.create(K(t),U(r))}return K(e)}(e);if(j.is(r)){if(t)throw Error("Cannot specify direction twice!");return r}return j.create(r,U(t))}function U(e){if(e)return"asc"===e||"desc"===e?q.createWithSql(e):e.toOperationNode()}e.s(["RawNode",0,q],90348);let B=c({is:e=>"JSONReferenceNode"===e.kind,create:(e,t)=>c({kind:"JSONReferenceNode",reference:e,traversal:t}),cloneWithTraversal:(e,t)=>c({...e,traversal:t})}),V=c({is:e=>"JSONOperatorChainNode"===e.kind,create:e=>c({kind:"JSONOperatorChainNode",operator:e,values:c([])}),cloneWithValue:(e,t)=>c({...e,values:c([...e.values,t])})}),z=c({is:e=>"JSONPathNode"===e.kind,create:e=>c({kind:"JSONPathNode",inOperator:e,pathLegs:c([])}),cloneWithLeg:(e,t)=>c({...e,pathLegs:c([...e.pathLegs,t])})});function W(e){return r(e)?K(e):e.toOperationNode()}function $(e){return h(e)?e.map(e=>G(e)):[G(e)]}function G(e){return t8(e)?t9(e):W(e)}function H(e,t){let r=K(e);if(O(t))return B.create(r,V.create(k.create(t)));let a=t.slice(0,-1);if(O(a))return B.create(r,z.create(k.create(a)));throw Error(`Invalid JSON operator: ${t}`)}function K(e){if(!e.includes("."))return R.create(C.create(e));let t=e.split(".").map(Y);if(3===t.length)return function(e){let[t,r,a]=e;return R.create(C.create(a),y.createWithSchema(t,r))}(t);if(2===t.length)return function(e){let[t,r]=e;return R.create(C.create(r),y.create(t))}(t);throw Error(`invalid column reference ${e}`)}function J(e){let t=" as ";if(!e.includes(t))return K(e);{let[r,a]=e.split(t).map(Y);return v.create(K(r),f.create(a))}}function Z(e){return C.create(e)}function Q(e){if(!e.includes(" "))return Z(e);{let[t,r]=e.split(" ").map(Y);if(!L(r))throw Error(`invalid order direction "${r}" next to "${t}"`);return M([t,r])[0]}}function Y(e){return e.trim()}e.s(["isSafeImmediateValue",()=>ei,"parseSafeImmediateValue",()=>es,"parseValueExpression",()=>ea,"parseValueExpressionOrList",()=>er],40203);let X=c({is:e=>"PrimitiveValueListNode"===e.kind,create:e=>c({kind:"PrimitiveValueListNode",values:c([...e])})}),ee=c({is:e=>"ValueListNode"===e.kind,create:e=>c({kind:"ValueListNode",values:c(e)})});e.s(["ValueListNode",0,ee],22177);let et=c({is:e=>"ValueNode"===e.kind,create:e=>c({kind:"ValueNode",value:e}),createImmediate:e=>c({kind:"ValueNode",value:e,immediate:!0})});function er(e){var t;return h(e)?(t=e).some(t8)?ee.create(t.map(e=>ea(e))):X.create(t):ea(e)}function ea(e){return t8(e)?t9(e):et.create(e)}function ei(e){return a(e)||i(e)||s(e)}function es(e){if(!ei(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return et.createImmediate(e)}e.s(["ValueNode",0,et],46220);let en=c({is:e=>"ParensNode"===e.kind,create:e=>c({kind:"ParensNode",node:e})});function eo(e){if(3===e.length)return ep(e[0],e[1],e[2]);if(1===e.length)return ea(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function ep(e,t,r){var a,n;return("is"===(a=t)||"is not"===a)&&(s(n=r)||i(n))?E.create(G(e),eu(t),et.createImmediate(r)):E.create(G(e),eu(t),er(r))}function ed(e,t,r){return E.create(G(e),eu(t),G(r))}function el(e,r){return ec(Object.entries(e).filter(([,e])=>!t(e)).map(([e,t])=>{var r;return ep(e,s(r=t)||i(r)?"is":"=",t)}),r)}function ec(e,t,r=!0){let a="and"===t?_.create:x.create;if(0===e.length)return E.create(et.createImmediate(1),k.create("="),et.createImmediate(+("and"===t)));let i=eh(e[0]);for(let t=1;t<e.length;++t)i=a(i,eh(e[t]));return e.length>1&&r?en.create(i):i}e.s(["ParensNode",0,en],9581);function eu(e){if(r(e)&&S.includes(e))return k.create(e);if(w(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function eh(e){return w(e)?e.toOperationNode():e}let em=c({is:e=>"OrderByNode"===e.kind,create:e=>c({kind:"OrderByNode",items:c([...e])}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ef=c({is:e=>"PartitionByNode"===e.kind,create:e=>c({kind:"PartitionByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),eg=c({is:e=>"OverNode"===e.kind,create:()=>c({kind:"OverNode"}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithPartitionByItems:(e,t)=>c({...e,partitionBy:e.partitionBy?ef.cloneWithItems(e.partitionBy,t):ef.create(t)})}),ev=c({is:e=>"FromNode"===e.kind,create:e=>c({kind:"FromNode",froms:c(e)}),cloneWithFroms:(e,t)=>c({...e,froms:c([...e.froms,...t])})}),ey=c({is:e=>"GroupByNode"===e.kind,create:e=>c({kind:"GroupByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ew=c({is:e=>"HavingNode"===e.kind,create:e=>c({kind:"HavingNode",having:e}),cloneWithOperation:(e,t,r)=>c({...e,having:"And"===t?_.create(e.having,r):x.create(e.having,r)})}),eb=c({is:e=>"SelectQueryNode"===e.kind,create:e=>c({kind:"SelectQueryNode",...e&&{with:e}}),createFrom:(e,t)=>c({kind:"SelectQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)}),cloneWithDistinctOn:(e,t)=>c({...e,distinctOn:e.distinctOn?c([...e.distinctOn,...t]):c(t)}),cloneWithFrontModifier:(e,t)=>c({...e,frontModifiers:e.frontModifiers?c([...e.frontModifiers,t]):c([t])}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithGroupByItems:(e,t)=>c({...e,groupBy:e.groupBy?ey.cloneWithItems(e.groupBy,t):ey.create(t)}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithOffset:(e,t)=>c({...e,offset:t}),cloneWithFetch:(e,t)=>c({...e,fetch:t}),cloneWithHaving:(e,t)=>c({...e,having:e.having?ew.cloneWithOperation(e.having,"And",t):ew.create(t)}),cloneWithSetOperations:(e,t)=>c({...e,setOperations:e.setOperations?c([...e.setOperations,...t]):c([...t])}),cloneWithoutSelections:e=>c({...e,selections:[]}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithoutOffset:e=>c({...e,offset:void 0}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithoutGroupBy:e=>c({...e,groupBy:void 0})});function e_(e,t){Object.defineProperties(e.prototype,{then:{enumerable:!1,value:()=>{throw Error(t)}}})}e.s(["preventAwait",()=>e_],50430);class ex{#M;constructor(e){this.#M=c(e)}on(...e){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,eo(e))})}onRef(e,t,r){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,ed(e,t,r))})}onTrue(){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,q.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#M.joinNode}}e_(ex,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");let eN=c({is:e=>"PartitionByItemNode"===e.kind,create:e=>c({kind:"PartitionByItemNode",partitionBy:e})});class eT{#M;constructor(e){this.#M=c(e)}orderBy(e,t){return new eT({overNode:eg.cloneWithOrderByItems(this.#M.overNode,M([e,t]))})}partitionBy(e){return new eT({overNode:eg.cloneWithPartitionByItems(this.#M.overNode,$(e).map(eN.create))})}$call(e){return e(this)}toOperationNode(){return this.#M.overNode}}e_(eT,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query."),e.s(["QueryCreator",()=>tA],82258);let eE=c({is:e=>"SelectionNode"===e.kind,create:e=>c({kind:"SelectionNode",selection:e}),createSelectAll:()=>c({kind:"SelectionNode",selection:I.create()}),createSelectAllFromTable:e=>c({kind:"SelectionNode",selection:R.createSelectAll(e)})});function eA(e){return p(e)?eA(e(t3())):h(e)?e.map(e=>eS(e)):[eS(e)]}function eS(e){return r(e)?eE.create(J(e)):P(e)?eE.create(e.toOperationNode()):eE.create(t5(e))}function ek(e){return e?Array.isArray(e)?e.map(eO):[eO(e)]:[eE.createSelectAll()]}function eO(e){if(r(e))return eE.createSelectAllFromTable(rr(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}let eC=c({is:e=>"ValuesNode"===e.kind,create:e=>c({kind:"ValuesNode",values:c(e)})}),eI=c({is:e=>"DefaultInsertValueNode"===e.kind,create:()=>c({kind:"DefaultInsertValueNode"})});function eR(e){var r;let a,i=p(e)?e(t3()):e;return a=function(e){let t=new Map;for(let r of e)for(let e of Object.keys(r))t.has(e)||void 0===r[e]||t.set(e,t.size);return t}(r=h(i)?i:c([i])),[c([...a.keys()].map(C.create)),eC.create(r.map(e=>(function(e,r){let a=Object.keys(e),i=Array.from({length:r.size}),s=!1,n=a.length;for(let o of a){let a=r.get(o);if(t(a)){n--;continue}let p=e[o];(t(p)||t8(p))&&(s=!0),i[a]=p}if(n<r.size||s){let e=eI.create();return ee.create(i.map(r=>t(r)?e:ea(r)))}return X.create(i)})(e,a)))]}let eD=c({is:e=>"InsertQueryNode"===e.kind,create:(e,t,r)=>c({kind:"InsertQueryNode",into:e,...t&&{with:t},replace:r}),createWithoutInto:()=>c({kind:"InsertQueryNode"}),cloneWith:(e,t)=>c({...e,...t})});e.s(["InsertQueryNode",0,eD],72866);let eP=c({is:e=>"UpdateQueryNode"===e.kind,create:(e,t)=>c({kind:"UpdateQueryNode",table:e,...t&&{with:t}}),createWithoutTable:()=>c({kind:"UpdateQueryNode"}),cloneWithFromItems:(e,t)=>c({...e,from:e.from?ev.cloneWithFroms(e.from,t):ev.create(t)}),cloneWithUpdates:(e,t)=>c({...e,updates:e.updates?c([...e.updates,...t]):t}),cloneWithLimit:(e,t)=>c({...e,limit:t})}),ej=c({is:e=>"UsingNode"===e.kind,create:e=>c({kind:"UsingNode",tables:c(e)}),cloneWithTables:(e,t)=>c({...e,tables:c([...e.tables,...t])})}),eq=c({is:e=>"DeleteQueryNode"===e.kind,create:(e,t)=>c({kind:"DeleteQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithUsing:(e,t)=>c({...e,using:void 0!==e.using?ej.cloneWithTables(e.using,t):ej.create(t)})}),eL=c({is:e=>"WhereNode"===e.kind,create:e=>c({kind:"WhereNode",where:e}),cloneWithOperation:(e,t,r)=>c({...e,where:"And"===t?_.create(e.where,r):x.create(e.where,r)})}),eM=c({is:e=>"ReturningNode"===e.kind,create:e=>c({kind:"ReturningNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),eF=c({is:e=>"ExplainNode"===e.kind,create:(e,t)=>c({kind:"ExplainNode",format:e,options:t})}),eU=c({is:e=>"WhenNode"===e.kind,create:e=>c({kind:"WhenNode",condition:e}),cloneWithResult:(e,t)=>c({...e,result:t})}),eB=c({is:e=>"MergeQueryNode"===e.kind,create:(e,t)=>c({kind:"MergeQueryNode",into:e,...t&&{with:t}}),cloneWithUsing:(e,t)=>c({...e,using:t}),cloneWithWhen:(e,t)=>c({...e,whens:e.whens?c([...e.whens,t]):c([t])}),cloneWithThen:(e,t)=>c({...e,whens:e.whens?c([...e.whens.slice(0,-1),eU.cloneWithResult(e.whens[e.whens.length-1],t)]):void 0})});e.s(["MergeQueryNode",0,eB],29986);let eV=c({is:e=>"OutputNode"===e.kind,create:e=>c({kind:"OutputNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),ez=c({is:e=>eb.is(e)||eD.is(e)||eP.is(e)||eq.is(e)||eB.is(e),cloneWithEndModifier:(e,t)=>c({...e,endModifiers:e.endModifiers?c([...e.endModifiers,t]):c([t])}),cloneWithWhere:(e,t)=>c({...e,where:e.where?eL.cloneWithOperation(e.where,"And",t):eL.create(t)}),cloneWithJoin:(e,t)=>c({...e,joins:e.joins?c([...e.joins,t]):c([t])}),cloneWithReturning:(e,t)=>c({...e,returning:e.returning?eM.cloneWithSelections(e.returning,t):eM.create(t)}),cloneWithoutReturning:e=>c({...e,returning:void 0}),cloneWithoutWhere:e=>c({...e,where:void 0}),cloneWithExplain:(e,t,r)=>c({...e,explain:eF.create(t,r?.toOperationNode())}),cloneWithTop:(e,t)=>c({...e,top:t}),cloneWithOutput:(e,t)=>c({...e,output:e.output?eV.cloneWithSelections(e.output,t):eV.create(t)})});e.s(["QueryNode",0,ez],27539);let eW=c({is:e=>"ColumnUpdateNode"===e.kind,create:(e,t)=>c({kind:"ColumnUpdateNode",column:e,value:t})});function e$(e){return Object.entries(p(e)?e(t3()):e).filter(([e,t])=>void 0!==t).map(([e,t])=>eW.create(C.create(e),ea(t)))}let eG=c({is:e=>"OnDuplicateKeyNode"===e.kind,create:e=>c({kind:"OnDuplicateKeyNode",updates:e})});class eH{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}}class eK extends Error{node;constructor(e){super("no result"),this.node=e}}function eJ(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}let eZ=c({is:e=>"OnConflictNode"===e.kind,create:()=>c({kind:"OnConflictNode"}),cloneWith:(e,t)=>c({...e,...t}),cloneWithIndexWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"And",t):eL.create(t)}),cloneWithIndexOrWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"Or",t):eL.create(t)}),cloneWithUpdateWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"And",t):eL.create(t)}),cloneWithUpdateOrWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"Or",t):eL.create(t)}),cloneWithoutIndexWhere:e=>c({...e,indexWhere:void 0}),cloneWithoutUpdateWhere:e=>c({...e,updateWhere:void 0})});class eQ{#M;constructor(e){this.#M=c(e)}column(e){let t=C.create(e);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,t]):c([t])})})}columns(e){let t=e.map(C.create);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,...t]):c(t)})})}constraint(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{constraint:f.create(e)})})}expression(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eQ({...this.#M,onConflictNode:eZ.cloneWithoutIndexWhere(this.#M.onConflictNode)})}doNothing(){return new eY({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new eX({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{updates:e$(e)})})}$call(e){return e(this)}}e_(eQ,"don't await OnConflictBuilder instances.");class eY{#M;constructor(e){this.#M=c(e)}toOperationNode(){return this.#M.onConflictNode}}e_(eY,"don't await OnConflictDoNothingBuilder instances.");class eX{#M;constructor(e){this.#M=c(e)}where(...e){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eX({...this.#M,onConflictNode:eZ.cloneWithoutUpdateWhere(this.#M.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#M.onConflictNode}}e_(eX,"don't await OnConflictUpdateBuilder instances.");let e1=c({is:e=>"TopNode"===e.kind,create:(e,t)=>c({kind:"TopNode",expression:e,modifiers:t})});function e0(e,r){var i;if(!a(e)&&!o(e))throw Error(`Invalid top expression: ${e}`);if(!t(r)&&"percent"!==(i=r)&&"with ties"!==i&&"percent with ties"!==i)throw Error(`Invalid top modifiers: ${r}`);return e1.create(e,r)}class e2{#M;constructor(e){this.#M=c(e)}values(e){let[t,r]=eR(e);return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:t,values:r})})}columns(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:c(e.map(C.create))})})}expression(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{values:t9(e)})})}defaultValues(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{defaultValues:!0})})}modifyEnd(e){return new e2({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}ignore(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{ignore:!0})})}top(e,t){return new e2({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}onConflict(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onConflict:e(new eQ({onConflictNode:eZ.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onDuplicateKey:eG.create(e$(e))})})}returning(e){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek())})}output(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e2({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e2({...this.#M})}$castTo(){return new e2(this.#M)}$narrowType(){return new e2(this.#M)}$assertType(){return new e2(this.#M)}withPlugin(e){return new e2({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new eH(t.insertId,t.numAffectedRows??t.numUpdatedOrDeletedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e2({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e2,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e6{numDeletedRows;constructor(e){this.numDeletedRows=e}}let e4=c({is:e=>"LimitNode"===e.kind,create:e=>c({kind:"LimitNode",limit:e})});class e3{#M;constructor(e){this.#M=c(e)}where(...e){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e3({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e3({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(e){return new e3({...this.#M,queryNode:eq.cloneWithUsing(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}returning(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e3({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}clearLimit(){return new e3({...this.#M,queryNode:eq.cloneWithoutLimit(this.#M.queryNode)})}clearOrderBy(){return new e3({...this.#M,queryNode:eq.cloneWithoutOrderBy(this.#M.queryNode)})}orderBy(e,t){return new e3({...this.#M,queryNode:eq.cloneWithOrderByItems(this.#M.queryNode,M([e,t]))})}limit(e){return new e3({...this.#M,queryNode:eq.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}modifyEnd(e){return new e3({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new e3({...this.#M})}$castTo(){return new e3(this.#M)}$narrowType(){return new e3(this.#M)}$assertType(){return new e3(this.#M)}withPlugin(e){return new e3({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e6(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e3({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e3,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e9{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}}class e5{#M;constructor(e){this.#M=c(e)}where(...e){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e5({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e5({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}from(e){return new e5({...this.#M,queryNode:eP.cloneWithFromItems(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}limit(e){return new e5({...this.#M,queryNode:eP.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}set(...e){return new e5({...this.#M,queryNode:eP.cloneWithUpdates(this.#M.queryNode,function(...e){return 2===e.length?[eW.create(G(e[0]),ea(e[1]))]:e$(e[0])}(...e))})}returning(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}modifyEnd(e){return new e5({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}clearReturning(){return new e5({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e5({...this.#M})}$castTo(){return new e5(this.#M)}$narrowType(){return new e5(this.#M)}$assertType(){return new e5(this.#M)}withPlugin(e){return new e5({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e9(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e5({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e5,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");let e8=c({is:e=>"CommonTableExpressionNameNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNameNode",table:y.create(e),columns:t?c(t.map(C.create)):void 0})}),e7=c({is:e=>"CommonTableExpressionNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNode",name:e,expression:t}),cloneWith:(e,t)=>c({...e,...t})});class te{#M;constructor(e){this.#M=c(e)}materialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!0})})}notMaterialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!1})})}toOperationNode(){return this.#M.node}}function tt(e,t){var r;let a=t(new tA({executor:tb})).toOperationNode();return p(e)?e((r=a,e=>new te({node:e7.create(tr(e),r)}))).toOperationNode():e7.create(tr(e),a)}function tr(e){if(!e.includes("("))return e8.create(e);{let t=e.split(/[\(\)]/),r=t[0],a=t[1].split(",").map(e=>e.trim());return e8.create(r,a)}}e_(te,"don't await CTEBuilder instances. They are never executed directly and are always just a part of a query.");let ta=c({is:e=>"WithNode"===e.kind,create:(e,t)=>c({kind:"WithNode",expressions:c([e]),...t}),cloneWithExpression:(e,t)=>c({...e,expressions:c([...e.expressions,t])})}),ti=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function ts(){return new tn}class tn{#F;get queryId(){return void 0===this.#F&&(this.#F=function(e){let t="";for(let e=0;e<8;++e)t+=ti[~~(Math.random()*ti.length)];return t}(0)),this.#F}}e.s(["createQueryId",()=>ts],34939);class to{nodeStack=[];#U=c({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)});transformNode(e){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e);return this.nodeStack.pop(),c(t)}transformNodeImpl(e){return this.#U[e.kind](e)}transformNodeList(e){return e?c(e.map(e=>this.transformNode(e))):e}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:c([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,orderBy:this.transformNode(e.orderBy),filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),endModifiers:this.transformNodeList(e.endModifiers),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}e.s(["OperationNodeTransformer",()=>to],2758);let tp=c({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),td={json_agg:!0,to_json:!0};class tl extends to{#B;#V=new Set;#z=new Set;constructor(e){super(),this.#B=e}transformNodeImpl(e){if(!this.#W(e))return super.transformNodeImpl(e);let t=this.#$(e);for(let e of t)this.#z.add(e);let r=this.#G(e);for(let e of r)this.#V.add(e);let a=super.transformNodeImpl(e);for(let e of r)this.#V.delete(e);for(let e of t)this.#z.delete(e);return a}transformSchemableIdentifier(e){let t=super.transformSchemableIdentifier(e);return t.schema||!this.#V.has(e.identifier.name)?t:{...t,schema:f.create(this.#B)}}transformReferences(e){let t=super.transformReferences(e);return t.table.table.schema?t:{...t,table:y.createWithSchema(this.#B,t.table.table.identifier.name)}}transformAggregateFunction(e){return{...super.transformAggregateFunction({...e,aggregated:[]}),aggregated:this.#H(e,"aggregated")}}transformFunction(e){return{...super.transformFunction({...e,arguments:[]}),arguments:this.#H(e,"arguments")}}#H(e,t){return td[e.func]?e[t].map(e=>!y.is(e)||e.table.schema?this.transformNode(e):{...e,table:this.transformIdentifier(e.table.identifier)}):this.transformNodeList(e[t])}#W(e){return e.kind in tp}#G(e){let t=new Set;if("name"in e&&e.name&&g.is(e.name)&&this.#K(e.name,t),"from"in e&&e.from)for(let r of e.from.froms)this.#J(r,t);if("into"in e&&e.into&&this.#J(e.into,t),"table"in e&&e.table&&this.#J(e.table,t),"joins"in e&&e.joins)for(let r of e.joins)this.#J(r.table,t);return"using"in e&&e.using&&this.#J(e.using,t),t}#$(e){let t=new Set;return"with"in e&&e.with&&this.#Z(e.with,t),t}#J(e,t){let r=y.is(e)?e:v.is(e)&&y.is(e.node)?e.node:null;r&&this.#K(r.table,t)}#K(e,t){let r=e.identifier.name;this.#V.has(r)||this.#z.has(r)||t.add(r)}#Z(e,t){for(let r of e.expressions){let e=r.name.table.table.identifier.name;this.#z.has(e)||t.add(e)}}}class tc{#Q;constructor(e){this.#Q=new tl(e)}transformQuery(e){return this.#Q.transformNode(e.node)}async transformResult(e){return e.result}}e.s(["WithSchemaPlugin",()=>tc],90640);let tu=c({is:e=>"MatchedNode"===e.kind,create:(e,t=!1)=>c({kind:"MatchedNode",not:e,bySource:t})});function th(e,t,r){return eU.create(ec([tu.create(!e.isMatched,e.bySource),...t&&t.length>0?[3===t.length&&r?ed(t[0],t[1],t[2]):eo(t)]:[]],"and",!1))}function tm(e){return r(e)?q.create([e],[]):w(e)?e.toOperationNode():e}class tf{#Y;#X;#ee;constructor(){this.#Y=new Promise((e,t)=>{this.#ee=t,this.#X=e})}get promise(){return this.#Y}resolve=e=>{this.#X&&this.#X(e)};reject=e=>{this.#ee&&this.#ee(e)}}let tg=new Set,tv=c([]);class ty{#et;constructor(e=tv){this.#et=e}get plugins(){return this.#et}transformQuery(e,t){for(let r of this.#et){let a=r.transformQuery({node:e,queryId:t});if(a.kind===e.kind)e=a;else throw Error(`KyselyPlugin.transformQuery must return a node of the same kind that was given to it. The plugin was given a ${e.kind} but it returned a ${a.kind}`)}return e}async executeQuery(e,t){return await this.provideConnection(async r=>{let a=await r.executeQuery(e),i=await this.#er(a,t);return function(e,t){let{numAffectedRows:r}=e;if((void 0!==r||void 0!==e.numUpdatedOrDeletedRows)&&(void 0===r||void 0===t.numAffectedRows)){var a;a="kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.",tg.has(a)||(tg.add(a),console.log(a))}}(a,i),i})}async *stream(e,t,r){let a=new tf,i=new tf;this.provideConnection(async e=>(a.resolve(e),await i.promise)).catch(e=>a.reject(e));let s=await a.promise;try{for await(let a of s.streamQuery(e,t))yield await this.#er(a,r)}finally{i.resolve()}}async #er(e,t){for(let r of this.#et)e=await r.transformResult({result:e,queryId:t});return e}}e.s(["QueryExecutorBase",()=>ty],46432);class tw extends ty{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new tw([...this.plugins,e])}withPlugins(e){return new tw([...this.plugins,...e])}withPluginAtFront(e){return new tw([e,...this.plugins])}withoutPlugins(){return new tw([])}}let tb=new tw;e.s(["NOOP_QUERY_EXECUTOR",0,tb],13424);class t_{numChangedRows;constructor(e){this.numChangedRows=e}}class tx{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tx({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tx({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(...e){return new tN({...this.#M,queryNode:eB.cloneWithUsing(this.#M.queryNode,tS("Using",e))})}output(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}}e_(tx,"don't await MergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tN{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tN({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tN({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}whenMatched(){return this.#ea([])}whenMatchedAnd(...e){return this.#ea(e)}whenMatchedAndRef(e,t,r){return this.#ea([e,t,r],!0)}#ea(e,t){return new tT({...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!0},e,t))})}whenNotMatched(){return this.#ei([])}whenNotMatchedAnd(...e){return this.#ei(e)}whenNotMatchedAndRef(e,t,r){return this.#ei([e,t,r],!0)}whenNotMatchedBySource(){return this.#ei([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#ei(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,r){return this.#ei([e,t,r],!0,!0)}output(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}#ei(e,t=!1,r=!1){let a={...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!1,bySource:r},e,t))};return new(r?tT:tE)(a)}$call(e){return e(this)}$if(e,t){return e?t(this):new tN({...this.#M})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId);return e.query.output&&this.#M.executor.adapter.supportsOutput?t.rows:[new t_(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}}e_(tN,"don't await WheneableMergeQueryBuilder instances directly. To execute the query you need to call `execute`.");class tT{#M;constructor(e){this.#M=c(e)}thenDelete(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("delete"))})}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenUpdate(e){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(e(new e5({queryId:this.#M.queryId,executor:tb,queryNode:eP.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}}e_(tT,"don't await MatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tE{#M;constructor(e){this.#M=c(e)}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenInsertValues(e){let[t,r]=eR(e);return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(eD.cloneWith(eD.createWithoutInto(),{columns:t,values:r})))})}}e_(tE,"don't await NotMatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tA{#M;constructor(e){this.#M=c(e)}selectFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.createFrom(t7(e),this.#M.withNode)})}selectNoFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.cloneWithSelections(eb.create(this.#M.withNode),eA(e))})}insertInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode)})}replaceInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode,!0)})}deleteFrom(e){return new e3({queryId:ts(),executor:this.#M.executor,queryNode:eq.create(t7(e),this.#M.withNode)})}updateTable(e){return new e5({queryId:ts(),executor:this.#M.executor,queryNode:eP.create(re(e),this.#M.withNode)})}mergeInto(e){return new tx({queryId:ts(),executor:this.#M.executor,queryNode:eB.create(rt(e),this.#M.withNode)})}with(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r)})}withRecursive(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r,{recursive:!0})})}withPlugin(e){return new tA({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new tA({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new tA({...this.#M,executor:this.#M.executor.withPluginAtFront(new tc(e))})}}function tS(e,t){if(3===t.length){var r,a,i,s;return r=e,a=t[0],i=t[1],s=t[2],T.createWithOn(r,re(a),ed(i,"=",s))}if(2===t.length)return function(e,t,r){return r(new ex({joinNode:T.create(e,re(t))})).toOperationNode()}(e,t[0],t[1]);throw Error("not implemented")}let tk=c({is:e=>"OffsetNode"===e.kind,create:e=>c({kind:"OffsetNode",offset:e})}),tO=c({is:e=>"GroupByItemNode"===e.kind,create:e=>c({kind:"GroupByItemNode",groupBy:e})}),tC=c({is:e=>"SetOperationNode"===e.kind,create:(e,t,r)=>c({kind:"SetOperationNode",operator:e,expression:t,all:r})});function tI(e,t,r){return p(t)&&(t=t(t3())),h(t)||(t=[t]),t.map(t=>tC.create(e,t9(t),r))}e.s(["SetOperationNode",0,tC],45393);class tR{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tR(this.#q)}$notNull(){return new tR(this.#q)}toOperationNode(){return this.#q}}class tD{#es;#en;constructor(e,t){this.#es=e,this.#en=t}get expression(){return this.#es}get alias(){return this.#en}toOperationNode(){return v.create(this.#es.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}class tP{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}$castTo(){return new tP(this.#q)}toOperationNode(){return en.create(this.#q)}}class tj{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tj(this.#q)}toOperationNode(){return en.create(this.#q)}}class tq{#M;constructor(e){this.#M=c(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}having(...e){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,eo(e))})}havingRef(e,t,r){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,ed(e,t,r))})}select(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,eA(e))})}distinctOn(e){return new tq({...this.#M,queryNode:eb.cloneWithDistinctOn(this.#M.queryNode,$(e))})}modifyFront(e){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}distinct(){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.create("Distinct"))})}forUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForUpdate",e?u(e).map(rr):void 0))})}forShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForShare",e?u(e).map(rr):void 0))})}forKeyShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForKeyShare",e?u(e).map(rr):void 0))})}forNoKeyUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForNoKeyUpdate",e?u(e).map(rr):void 0))})}skipLocked(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("SkipLocked"))})}noWait(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("NoWait"))})}selectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,ek(e))})}innerJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}innerJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralInnerJoin",e))})}leftJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralLeftJoin",e))})}orderBy(...e){return new tq({...this.#M,queryNode:eb.cloneWithOrderByItems(this.#M.queryNode,M(e))})}groupBy(e){var t;return new tq({...this.#M,queryNode:eb.cloneWithGroupByItems(this.#M.queryNode,$(t=p(t=e)?t(t3()):t).map(tO.create))})}limit(e){return new tq({...this.#M,queryNode:eb.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}offset(e){return new tq({...this.#M,queryNode:eb.cloneWithOffset(this.#M.queryNode,tk.create(ea(e)))})}fetch(e,t="only"){return new tq({...this.#M,queryNode:eb.cloneWithFetch(this.#M.queryNode,function(e,t){var r;let i,s;if(!a(e)&&!o(e))throw Error(`Invalid fetch row count: ${e}`);if("only"!==(r=t)&&"with ties"!==r)throw Error(`Invalid fetch modifier: ${t}`);return i=e,s=t,{kind:"FetchNode",rowCount:et.create(i),modifier:s}}(e,t))})}top(e,t){return new tq({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}union(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!1))})}unionAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!0))})}intersect(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!1))})}intersectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!0))})}except(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!1))})}exceptAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!0))})}as(e){return new tL(this,e)}clearSelect(){return new tq({...this.#M,queryNode:eb.cloneWithoutSelections(this.#M.queryNode)})}clearWhere(){return new tq({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}clearLimit(){return new tq({...this.#M,queryNode:eb.cloneWithoutLimit(this.#M.queryNode)})}clearOffset(){return new tq({...this.#M,queryNode:eb.cloneWithoutOffset(this.#M.queryNode)})}clearOrderBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutOrderBy(this.#M.queryNode)})}clearGroupBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutGroupBy(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new tq({...this.#M})}$castTo(){return new tq(this.#M)}$narrowType(){return new tq(this.#M)}$assertType(){return new tq(this.#M)}$asTuple(){return new tR(this.toOperationNode())}withPlugin(e){return new tq({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile();return(await this.#M.executor.executeQuery(e,this.#M.queryId)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new tq({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(tq,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class tL{#eo;#en;constructor(e,t){this.#eo=e,this.#en=t}get expression(){return this.#eo}get alias(){return this.#en}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return v.create(this.#eo.toOperationNode(),f.create(this.#en))}}e_(tL,"don't await AliasedSelectQueryBuilder instances directly. AliasedSelectQueryBuilder should never be executed directly since it's always a part of another query."),e.s(["createFunctionModule",()=>tV],86566);let tM=c({is:e=>"AggregateFunctionNode"===e.kind,create:(e,t=[])=>c({kind:"AggregateFunctionNode",func:e,aggregated:t}),cloneWithDistinct:e=>c({...e,distinct:!0}),cloneWithOrderBy:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"And",t):eL.create(t)}),cloneWithOrFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"Or",t):eL.create(t)}),cloneWithOver:(e,t)=>c({...e,over:t})}),tF=c({is:e=>"FunctionNode"===e.kind,create:(e,t)=>c({kind:"FunctionNode",func:e,arguments:t})});class tU{#M;constructor(e){this.#M=c(e)}get expressionType(){}as(e){return new tB(this,e)}distinct(){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithDistinct(this.#M.aggregateFunctionNode)})}orderBy(e,t){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOrderBy(this.#M.aggregateFunctionNode,M([e,t]))})}filterWhere(...e){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,eo(e))})}filterWhereRef(e,t,r){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,ed(e,t,r))})}over(e){let t=new eT({overNode:eg.create()});return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOver(this.#M.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new tU(this.#M)}$notNull(){return new tU(this.#M)}toOperationNode(){return this.#M.aggregateFunctionNode}}e_(tU,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class tB{#ep;#en;constructor(e,t){this.#ep=e,this.#en=t}get expression(){return this.#ep}get alias(){return this.#en}toOperationNode(){return v.create(this.#ep.toOperationNode(),f.create(this.#en))}}function tV(){let e=(e,t)=>new tR(tF.create(e,$(t??[]))),t=(e,t)=>new tU({aggregateFunctionNode:tM.create(e,t?$(t):void 0)});return Object.assign(e,{agg:t,avg:e=>t("avg",[e]),coalesce:(...t)=>e("coalesce",t),count:e=>t("count",[e]),countAll:e=>new tU({aggregateFunctionNode:tM.create("count",ek(e))}),max:e=>t("max",[e]),min:e=>t("min",[e]),sum:e=>t("sum",[e]),any:t=>e("any",[t]),jsonAgg:e=>new tU({aggregateFunctionNode:tM.create("json_agg",[r(e)?rr(e):e.toOperationNode()])}),toJson:e=>new tR(tF.create("to_json",[r(e)?rr(e):e.toOperationNode()]))})}let tz=c({is:e=>"UnaryOperationNode"===e.kind,create:(e,t)=>c({kind:"UnaryOperationNode",operator:e,operand:t})});e.s(["CaseBuilder",()=>t$],21797);let tW=c({is:e=>"CaseNode"===e.kind,create:e=>c({kind:"CaseNode",value:e}),cloneWithWhen:(e,t)=>c({...e,when:c(e.when?[...e.when,t]:[t])}),cloneWithThen:(e,t)=>c({...e,when:e.when?c([...e.when.slice(0,-1),eU.cloneWithResult(e.when[e.when.length-1],t)]):void 0}),cloneWith:(e,t)=>c({...e,...t})});e.s(["CaseNode",0,tW],72515);class t${#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}}class tG{#M;constructor(e){this.#M=c(e)}then(e){return new tH({...this.#M,node:tW.cloneWithThen(this.#M.node,ei(e)?es(e):ea(e))})}}class tH{#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}else(e){return new tK({...this.#M,node:tW.cloneWith(this.#M.node,{else:ei(e)?es(e):ea(e)})})}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}class tK{#M;constructor(e){this.#M=c(e)}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}let tJ=c({is:e=>"JSONPathLegNode"===e.kind,create:(e,t)=>c({kind:"JSONPathLegNode",type:e,value:t})});class tZ{#q;constructor(e){this.#q=e}at(e){return this.#ed("ArrayLocation",e)}key(e){return this.#ed("Member",e)}#ed(e,t){return new tQ(B.is(this.#q)?B.cloneWithTraversal(this.#q,z.is(this.#q.traversal)?z.cloneWithLeg(this.#q.traversal,tJ.create(e,t)):V.cloneWithValue(this.#q.traversal,et.createImmediate(t))):z.cloneWithLeg(this.#q,tJ.create(e,t)))}}class tQ extends tZ{#q;constructor(e){super(e),this.#q=e}get expressionType(){}as(e){return new tY(this,e)}$castTo(){return new tQ(this.#q)}$notNull(){return new tQ(this.#q)}toOperationNode(){return this.#q}}class tY{#el;#en;constructor(e,t){this.#el=e,this.#en=t}get expression(){return this.#el}get alias(){return this.#en}toOperationNode(){return v.create(this.#el.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}let tX=c({is:e=>"TupleNode"===e.kind,create:e=>c({kind:"TupleNode",values:c(e)})}),t1=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],t0=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],t2=c({is:e=>"DataTypeNode"===e.kind,create:e=>c({kind:"DataTypeNode",dataType:e})});function t6(e){if(w(e))return e.toOperationNode();if(t1.includes(e)||t0.some(t=>t.test(e)))return t2.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}e.s(["parseDataTypeExpression",()=>t6],51014);let t4=c({is:e=>"CastNode"===e.kind,create:(e,t)=>c({kind:"CastNode",expression:e,dataType:t})});function t3(e=tb){function r(e,t){return new tR(tz.create(k.create(e),G(t)))}let a=Object.assign(function(e,t,r){return new tR(ep(e,t,r))},{fn:void 0,eb:void 0,selectFrom:t=>new tq({queryId:ts(),executor:e,queryNode:eb.createFrom(t7(t))}),case:e=>new t$({node:tW.create(t(e)?void 0:G(e))}),ref:(e,r)=>t(r)?new tR(K(e)):new tZ(H(e,r)),jsonPath:()=>new tZ(z.create()),table:e=>new tR(rr(e)),val:e=>new tR(ea(e)),refTuple:(...e)=>new tR(tX.create(e.map(G))),tuple:(...e)=>new tR(tX.create(e.map(ea))),lit:e=>new tR(es(e)),unary:r,not:e=>r("not",e),exists:e=>r("exists",e),neg:e=>r("-",e),between:(e,t,r)=>new tR(E.create(G(e),k.create("between"),_.create(ea(t),ea(r)))),betweenSymmetric:(e,t,r)=>new tR(E.create(G(e),k.create("between symmetric"),_.create(ea(t),ea(r)))),and:e=>new tR(h(e)?ec(e,"and"):el(e,"and")),or:e=>new tR(h(e)?ec(e,"or"):el(e,"or")),parens(...e){let t=eo(e);return new tR(en.is(t)?t:en.create(t))},cast:(e,t)=>new tR(t4.create(G(e),t6(t))),withSchema:t=>t3(e.withPluginAtFront(new tc(t)))});return a.fn=tV(),a.eb=a,a}function t9(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function t5(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function t8(e){return d(e)&&"expressionType"in e&&w(e)||d(e)&&"expression"in e&&r(e.alias)&&w(e)||p(e)}function t7(e){return h(e)?e.map(e=>re(e)):[re(e)]}function re(e){return r(e)?rt(e):t5(e)}function rt(e){let t=" as ";if(!e.includes(t))return rr(e);{let[r,a]=e.split(t).map(ra);return v.create(rr(r),f.create(a))}}function rr(e){if(!e.includes("."))return y.create(e);{let[t,r]=e.split(".").map(ra);return y.createWithSchema(t,r)}}function ra(e){return e.trim()}},58666,3888,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"CreateTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTableNode",table:e,columns:(0,t.freeze)([])}),cloneWithColumn:(e,r)=>(0,t.freeze)({...e,columns:(0,t.freeze)([...e.columns,r])}),cloneWithConstraint:(e,r)=>(0,t.freeze)({...e,constraints:e.constraints?(0,t.freeze)([...e.constraints,r]):(0,t.freeze)([r])}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):(0,t.freeze)([r])}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):(0,t.freeze)([r])}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateTableNode",0,r,"ON_COMMIT_ACTIONS",0,["preserve rows","delete rows","drop"]],58666);var a=e.i(62212);let i=(0,t.freeze)({is:e=>"CreateViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateViewNode",name:a.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateViewNode",0,i],3888)},24659,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"AlterTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"AlterTableNode",table:e}),cloneWithTableProps:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumnAlteration:(e,r)=>(0,t.freeze)({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,r]:[r]})});var a=e.i(482);let i=(0,t.freeze)({is:e=>"CreateIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})}),s=(0,t.freeze)({is:e=>"CreateSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CreateSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var n=e.i(58666),o=e.i(62212);let p=(0,t.freeze)({is:e=>"DropIndexNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropIndexNode",name:o.SchemableIdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),d=(0,t.freeze)({is:e=>"DropSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),l=(0,t.freeze)({is:e=>"DropTableNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropTableNode",table:e,...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var c=e.i(87799);let u=(0,t.freeze)({is:e=>"AddColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddColumnNode",column:e})});var h=e.i(54199);let m=(0,t.freeze)({is:e=>"ColumnDefinitionNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ColumnDefinitionNode",column:h.ColumnNode.create(e),dataType:r}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):[r]}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):[r]}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),f=(0,t.freeze)({is:e=>"DropColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropColumnNode",column:h.ColumnNode.create(e)})}),g=(0,t.freeze)({is:e=>"RenameColumnNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"RenameColumnNode",column:h.ColumnNode.create(e),renameTo:h.ColumnNode.create(r)})});var v=e.i(50430);let y=(0,t.freeze)({is:e=>"CheckConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CheckConstraintNode",expression:e,name:r?a.IdentifierNode.create(r):void 0})}),w=["no action","restrict","cascade","set null","set default"],b=(0,t.freeze)({is:e=>"ReferencesNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ReferencesNode",table:e,columns:(0,t.freeze)([...r])}),cloneWithOnDelete:(e,r)=>(0,t.freeze)({...e,onDelete:r}),cloneWithOnUpdate:(e,r)=>(0,t.freeze)({...e,onUpdate:r})});var _=e.i(6937),x=e.i(56900),N=e.i(56967),T=e.i(46220);function E(e){return(0,N.isOperationNodeSource)(e)?e.toOperationNode():T.ValueNode.createImmediate(e)}let A=(0,t.freeze)({is:e=>"GeneratedNode"===e.kind,create:e=>(0,t.freeze)({kind:"GeneratedNode",...e}),createWithExpression:e=>(0,t.freeze)({kind:"GeneratedNode",always:!0,expression:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),S=(0,t.freeze)({is:e=>"DefaultValueNode"===e.kind,create:e=>(0,t.freeze)({kind:"DefaultValueNode",defaultValue:e})});function k(e){if(w.includes(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}class O{#q;constructor(e){this.#q=e}autoIncrement(){return new O(m.cloneWith(this.#q,{autoIncrement:!0}))}identity(){return new O(m.cloneWith(this.#q,{identity:!0}))}primaryKey(){return new O(m.cloneWith(this.#q,{primaryKey:!0}))}references(e){let t=(0,x.parseStringReference)(e);if(!t.table||_.SelectAllNode.is(t.column))throw Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new O(m.cloneWith(this.#q,{references:b.create(t.table,[t.column])}))}onDelete(e){if(!this.#q.references)throw Error("on delete constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnDelete(this.#q.references,k(e))}))}onUpdate(e){if(!this.#q.references)throw Error("on update constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnUpdate(this.#q.references,k(e))}))}unique(){return new O(m.cloneWith(this.#q,{unique:!0}))}notNull(){return new O(m.cloneWith(this.#q,{notNull:!0}))}unsigned(){return new O(m.cloneWith(this.#q,{unsigned:!0}))}defaultTo(e){return new O(m.cloneWith(this.#q,{defaultTo:S.create(E(e))}))}check(e){return new O(m.cloneWith(this.#q,{check:y.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new O(m.cloneWith(this.#q,{generated:A.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#q.generated)throw Error("stored() can only be called after generatedAlwaysAs");return new O(m.cloneWith(this.#q,{generated:A.cloneWith(this.#q.generated,{stored:!0})}))}modifyFront(e){return new O(m.cloneWithFrontModifier(this.#q,e.toOperationNode()))}nullsNotDistinct(){return new O(m.cloneWith(this.#q,{nullsNotDistinct:!0}))}ifNotExists(){return new O(m.cloneWith(this.#q,{ifNotExists:!0}))}modifyEnd(e){return new O(m.cloneWithEndModifier(this.#q,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(O,"don't await ColumnDefinitionBuilder instances directly.");let C=(0,t.freeze)({is:e=>"ModifyColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"ModifyColumnNode",column:e})});var I=e.i(51014);let R=(0,t.freeze)({is:e=>"ForeignKeyConstraintNode"===e.kind,create:(e,r,i,s)=>(0,t.freeze)({kind:"ForeignKeyConstraintNode",columns:e,references:b.create(r,i),name:s?a.IdentifierNode.create(s):void 0}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class D{#q;constructor(e){this.#q=e}onDelete(e){return new D(R.cloneWith(this.#q,{onDelete:k(e)}))}onUpdate(e){return new D(R.cloneWith(this.#q,{onUpdate:k(e)}))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(D,"don't await ForeignKeyConstraintBuilder instances directly.");let P=(0,t.freeze)({is:e=>"AddConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddConstraintNode",constraint:e})}),j=(0,t.freeze)({is:e=>"UniqueConstraintNode"===e.kind,create:(e,r,i)=>(0,t.freeze)({kind:"UniqueConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0,nullsNotDistinct:i}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),q=(0,t.freeze)({is:e=>"DropConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropConstraintNode",constraintName:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),L=(0,t.freeze)({is:e=>"AlterColumnNode"===e.kind,create:(e,r,a)=>(0,t.freeze)({kind:"AlterColumnNode",column:h.ColumnNode.create(e),[r]:a})});class M{#ec;constructor(e){this.#ec=e}setDataType(e){return new F(L.create(this.#ec,"dataType",(0,I.parseDataTypeExpression)(e)))}setDefault(e){return new F(L.create(this.#ec,"setDefault",E(e)))}dropDefault(){return new F(L.create(this.#ec,"dropDefault",!0))}setNotNull(){return new F(L.create(this.#ec,"setNotNull",!0))}dropNotNull(){return new F(L.create(this.#ec,"dropNotNull",!0))}$call(e){return e(this)}}(0,v.preventAwait)(M,"don't await AlterColumnBuilder instances");class F{#eu;constructor(e){this.#eu=e}toOperationNode(){return this.#eu}}(0,v.preventAwait)(F,"don't await AlteredColumnBuilder instances");class U{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(U,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");class B{#M;constructor(e){this.#M=(0,t.freeze)(e)}onDelete(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onDelete(e)})}onUpdate(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(this.#M.constraintBuilder.toOperationNode())}),this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(B,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");class V{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{ifExists:!0})})})}cascade(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(V,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");let z=(0,t.freeze)({is:e=>"PrimaryKeyConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"PrimaryKeyConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0})}),W=(0,t.freeze)({is:e=>"AddIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})});var $=e.i(90348);class G{#M;constructor(e){this.#M=(0,t.freeze)(e)}unique(){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{unique:!0})})})}column(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[(0,x.parseOrderedColumnName)(e)])})})}columns(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,e.map(x.parseOrderedColumnName))})})}expression(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[e.toOperationNode()])})})}using(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{using:$.RawNode.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(G,"don't await AlterTableAddIndexBuilder instances directly. To execute the query you need to call `execute`");class H{#q;constructor(e){this.#q=e}toOperationNode(){return this.#q}nullsNotDistinct(){return new H(j.cloneWith(this.#q,{nullsNotDistinct:!0}))}}(0,v.preventAwait)(H,"don't await UniqueConstraintNodeBuilder instances directly.");class K{#M;constructor(e){this.#M=(0,t.freeze)(e)}renameTo(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{renameTo:(0,c.parseTable)(e)})})}setSchema(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{setSchema:a.IdentifierNode.create(e)})})}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}addUniqueConstraint(e,a,i=t.noop){let s=i(new H(j.create(a,e)));return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(s.toOperationNode())})})}addCheckConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(y.create(t.toOperationNode(),e))})})}addForeignKeyConstraint(e,t,r,a){return new B({...this.#M,constraintBuilder:new D(R.create(t.map(h.ColumnNode.create),(0,c.parseTable)(r),a.map(h.ColumnNode.create),e))})}addPrimaryKeyConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(z.create(t,e))})})}dropConstraint(e){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.create(e)})})}addIndex(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.create(e)})})}dropIndex(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropIndex:p.create(e)})})}$call(e){return e(this)}}(0,v.preventAwait)(K,"don't await AlterTableBuilder instances");class J{#M;constructor(e){this.#M=(0,t.freeze)(e)}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(J,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");var Z=e.i(83013),Q=e.i(27539),Y=e.i(2758);class X extends Y.OperationNodeTransformer{transformValue(e){return{...super.transformValue(e),immediate:!0}}}class ee{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{ifNotExists:!0})})}unique(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{unique:!0})})}nullsNotDistinct(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{nullsNotDistinct:!0})})}on(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}column(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[(0,x.parseOrderedColumnName)(e)])})}columns(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,e.map(x.parseOrderedColumnName))})}expression(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[e.toOperationNode()])})}using(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{using:$.RawNode.createWithSql(e)})})}where(...e){let t=new X;return new ee({...this.#M,node:Q.QueryNode.cloneWithWhere(this.#M.node,t.transformNode((0,Z.parseValueBinaryOperationOrExpression)(e)))})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ee,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");class et{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new et({...this.#M,node:s.cloneWith(this.#M.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(et,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");var er=e.i(67204);class ea{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{temporary:!0})})}onCommit(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{onCommit:function(e){if(n.ON_COMMIT_ACTIONS.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}(e)})})}ifNotExists(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{ifNotExists:!0})})}addColumn(e,r,a=t.noop){let i=a(new O(m.create(e,(0,I.parseDataTypeExpression)(r))));return new ea({...this.#M,node:n.CreateTableNode.cloneWithColumn(this.#M.node,i.toOperationNode())})}addPrimaryKeyConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,z.create(t,e))})}addUniqueConstraint(e,r,a=t.noop){let i=a(new H(j.create(r,e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,i.toOperationNode())})}addCheckConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,y.create(t.toOperationNode(),e))})}addForeignKeyConstraint(e,r,a,i,s=t.noop){let o=s(new D(R.create(r.map(h.ColumnNode.create),(0,c.parseTable)(a),i.map(h.ColumnNode.create),e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,o.toOperationNode())})}modifyFront(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithFrontModifier(this.#M.node,e.toOperationNode())})}modifyEnd(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithEndModifier(this.#M.node,e.toOperationNode())})}as(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{selectQuery:(0,er.parseExpression)(e)})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ea,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");class ei{#M;constructor(e){this.#M=(0,t.freeze)(e)}on(e){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}ifExists(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ei,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");class es{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(es,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");class en{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(en,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");var eo=e.i(34939),ep=e.i(90640),ed=e.i(3888);class el{#Q=new X;transformQuery(e){return this.#Q.transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}class ec{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{temporary:!0})})}materialized(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{materialized:!0})})}ifNotExists(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{ifNotExists:!0})})}orReplace(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{orReplace:!0})})}columns(e){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{columns:e.map(x.parseColumnName)})})}as(e){let t=e.withPlugin(new el).toOperationNode();return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ec,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");let eu=(0,t.freeze)({is:e=>"DropViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropViewNode",name:o.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class eh{#M;constructor(e){this.#M=(0,t.freeze)(e)}materialized(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{materialized:!0})})}ifExists(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eh,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");var em=e.i(22177);let ef=(0,t.freeze)({is:e=>"CreateTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTypeNode",name:e}),cloneWithEnum:(e,r)=>(0,t.freeze)({...e,enum:em.ValueListNode.create(r.map(e=>T.ValueNode.createImmediate(e)))})});class eg{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}asEnum(e){return new eg({...this.#M,node:ef.cloneWithEnum(this.#M.node,e)})}$call(e){return e(this)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eg,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");let ev=(0,t.freeze)({is:e=>"DropTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropTypeNode",name:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class ey{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new ey({...this.#M,node:ev.cloneWith(this.#M.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}function ew(e){if(!e.includes("."))return o.SchemableIdentifierNode.create(e);{let t=e.split(".").map(eb);if(2===t.length)return o.SchemableIdentifierNode.createWithSchema(t[0],t[1]);throw Error(`invalid schemable identifier ${e}`)}}function eb(e){return e.trim()}(0,v.preventAwait)(ey,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");class e_{#eh;constructor(e){this.#eh=e}createTable(e){return new ea({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:n.CreateTableNode.create((0,c.parseTable)(e))})}dropTable(e){return new en({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:l.create((0,c.parseTable)(e))})}createIndex(e){return new ee({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:i.create(e)})}dropIndex(e){return new ei({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:p.create(e)})}createSchema(e){return new et({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:s.create(e)})}dropSchema(e){return new es({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:d.create(e)})}alterTable(e){return new K({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:r.create((0,c.parseTable)(e))})}createView(e){return new ec({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ed.CreateViewNode.create(e)})}dropView(e){return new eh({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:eu.create(e)})}createType(e){return new eg({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ef.create(ew(e))})}dropType(e){return new ey({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ev.create(ew(e))})}withPlugin(e){return new e_(this.#eh.withPlugin(e))}withoutPlugins(){return new e_(this.#eh.withoutPlugins())}withSchema(e){return new e_(this.#eh.withPluginAtFront(new ep.WithSchemaPlugin(e)))}}var ex=e.i(80864);class eN{ref(e){return new ex.DynamicReferenceBuilder(e)}}class eT{#em;constructor(e){this.#em=e}async provideConnection(e){let t=await this.#em.acquireConnection();try{return await e(t)}finally{await this.#em.releaseConnection(t)}}}var eE=e.i(82258),eA=e.i(46432);class eS extends eA.QueryExecutorBase{#ef;#eg;#ev;constructor(e,t,r,a=[]){super(a),this.#ef=e,this.#eg=t,this.#ev=r}get adapter(){return this.#eg}compileQuery(e){return this.#ef.compileQuery(e)}provideConnection(e){return this.#ev.provideConnection(e)}withPlugins(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,...e])}withPlugin(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,e])}withPluginAtFront(e){return new eS(this.#ef,this.#eg,this.#ev,[e,...this.plugins])}withConnectionProvider(e){return new eS(this.#ef,this.#eg,e,[...this.plugins])}withoutPlugins(){return new eS(this.#ef,this.#eg,this.#ev,[])}}function ek(){return"undefined"!=typeof performance&&(0,t.isFunction)(performance.now)?performance.now():Date.now()}class eO{#em;#ey;#ew;#eb;#e_;#ex=new WeakSet;constructor(e,t){this.#eb=!1,this.#em=e,this.#ey=t}async init(){if(this.#e_)throw Error("driver has already been destroyed");this.#ew||(this.#ew=this.#em.init().then(()=>{this.#eb=!0}).catch(e=>(this.#ew=void 0,Promise.reject(e)))),await this.#ew}async acquireConnection(){if(this.#e_)throw Error("driver has already been destroyed");this.#eb||await this.init();let e=await this.#em.acquireConnection();return this.#ex.has(e)||(this.#eN()&&this.#eT(e),this.#ex.add(e)),e}async releaseConnection(e){await this.#em.releaseConnection(e)}beginTransaction(e,t){return this.#em.beginTransaction(e,t)}commitTransaction(e){return this.#em.commitTransaction(e)}rollbackTransaction(e){return this.#em.rollbackTransaction(e)}async destroy(){this.#ew&&(await this.#ew,this.#e_||(this.#e_=this.#em.destroy().catch(e=>(this.#e_=void 0,Promise.reject(e)))),await this.#e_)}#eN(){return this.#ey.isLevelEnabled("query")||this.#ey.isLevelEnabled("error")}#eT(e){let t=e.executeQuery;e.executeQuery=async r=>{let a,i=ek();try{return await t.call(e,r)}catch(e){throw a=e,await this.#eE(e,r,i),e}finally{a||await this.#eA(r,i)}}}async #eE(e,t,r){await this.#ey.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#eS(r)}))}async #eA(e,t){await this.#ey.query(()=>({level:"query",query:e,queryDurationMillis:this.#eS(t)}))}#eS(e){return ek()-e}}let eC=()=>{};class eI{#ek;#eO;constructor(e){this.#ek=e}async provideConnection(e){for(;this.#eO;)await this.#eO.catch(eC);return this.#eO=this.#eC(e).finally(()=>{this.#eO=void 0}),this.#eO}async #eC(e){return await e(this.#ek)}}let eR=["read uncommitted","read committed","repeatable read","serializable","snapshot"];var eD=e.i(86566);(0,t.freeze)(["query","error"]);class eP{#eI;#eR;constructor(e){(0,t.isFunction)(e)?(this.#eR=e,this.#eI=(0,t.freeze)({query:!0,error:!0})):(this.#eR=ej,this.#eI=(0,t.freeze)({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#eI[e]}async query(e){this.#eI.query&&await this.#eR(e())}async error(e){this.#eI.error&&await this.#eR(e())}}function ej(e){"query"===e.level?(console.log(`kysely:query: ${e.query.sql}`),console.log(`kysely:query: duration: ${e.queryDurationMillis.toFixed(1)}ms`)):"error"===e.level&&(e.error instanceof Error?console.error(`kysely:error: ${e.error.stack??e.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`))}var eq=e.i(21797),eL=e.i(72515);class eM extends eE.QueryCreator{#M;constructor(e){let r,a;if(function(e){return(0,t.isObject)(e)&&(0,t.isObject)(e.config)&&(0,t.isObject)(e.driver)&&(0,t.isObject)(e.executor)&&(0,t.isObject)(e.dialect)}(e))r={executor:e.executor},a={...e};else{const t=e.dialect,i=t.createDriver(),s=t.createQueryCompiler(),n=t.createAdapter(),o=new eO(i,new eP(e.log??[])),p=new eS(s,n,new eT(o),e.plugins??[]);r={executor:p},a={config:e,executor:p,dialect:t,driver:o}}super(r),this.#M=(0,t.freeze)(a)}get schema(){return new e_(this.#M.executor)}get dynamic(){return new eN}get introspection(){return this.#M.dialect.createIntrospector(this.withoutPlugins())}case(e){return new eq.CaseBuilder({node:eL.CaseNode.create((0,t.isUndefined)(e)?void 0:(0,er.parseExpression)(e))})}get fn(){return(0,eD.createFunctionModule)()}transaction(){return new eB({...this.#M})}connection(){return new eU({...this.#M})}withPlugin(e){return new eM({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eM({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eM({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eM({...this.#M})}async destroy(){await this.#M.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#M.executor}executeQuery(e,r=(0,eo.createQueryId)()){let a=(0,t.isObject)(e)&&(0,t.isFunction)(e.compile)?e.compile():e;return this.getExecutor().executeQuery(a,r)}}class eF extends eM{#M;constructor(e){super(e),this.#M=e}get isTransaction(){return!0}transaction(){throw Error("calling the transaction method for a Transaction is not supported")}connection(){throw Error("calling the connection method for a Transaction is not supported")}async destroy(){throw Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new eF({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eF({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eF({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eF({...this.#M})}}class eU{#M;constructor(e){this.#M=(0,t.freeze)(e)}async execute(e){return this.#M.executor.provideConnection(async t=>{let r=this.#M.executor.withConnectionProvider(new eI(t)),a=new eM({...this.#M,executor:r});return await e(a)})}}(0,v.preventAwait)(eU,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");class eB{#M;constructor(e){this.#M=(0,t.freeze)(e)}setIsolationLevel(e){return new eB({...this.#M,isolationLevel:e})}async execute(e){let{isolationLevel:t,...r}=this.#M,a={isolationLevel:t};return function(e){if(e.isolationLevel&&!eR.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}(a),this.#M.executor.provideConnection(async t=>{let i=this.#M.executor.withConnectionProvider(new eI(t)),s=new eF({...r,executor:i});try{await this.#M.driver.beginTransaction(t,a);let r=await e(s);return await this.#M.driver.commitTransaction(t),r}catch(e){throw await this.#M.driver.rollbackTransaction(t),e}})}}(0,v.preventAwait)(eB,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method"),e.s(["Kysely",()=>eM],24659)},12995,e=>{"use strict";var t=e.i(482),r=e.i(56967),a=e.i(90348),i=e.i(46220),s=e.i(56900),n=e.i(87799),o=e.i(40203),p=e.i(34939),d=e.i(79044),l=e.i(50430),c=e.i(84739),u=e.i(13424);class h{#M;constructor(e){this.#M=(0,c.freeze)(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new f(this,e)}$castTo(){return new h({...this.#M})}$notNull(){return new h(this.#M)}withPlugin(e){return new h({...this.#M,plugins:void 0!==this.#M.plugins?(0,c.freeze)([...this.#M.plugins,e]):(0,c.freeze)([e])})}toOperationNode(){return this.#eD(this.#eP())}compile(e){return this.#ej(this.#eP(e))}async execute(e){let t=this.#eP(e);return t.executeQuery(this.#ej(t),this.#M.queryId)}#eP(e){let t=void 0!==e?e.getExecutor():u.NOOP_QUERY_EXECUTOR;return void 0!==this.#M.plugins?t.withPlugins(this.#M.plugins):t}#eD(e){return e.transformQuery(this.#M.rawNode,this.#M.queryId)}#ej(e){return e.compileQuery(this.#eD(e),this.#M.queryId)}}function m(e){return new h(e)}(0,l.preventAwait)(h,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class f{#eq;#en;constructor(e,t){this.#eq=e,this.#en=t}get expression(){return this.#eq}get alias(){return this.#en}get rawBuilder(){return this.#eq}toOperationNode(){return d.AliasNode.create(this.#eq.toOperationNode(),(0,r.isOperationNodeSource)(this.#en)?this.#en.toOperationNode():t.IdentifierNode.create(this.#en))}}(0,l.preventAwait)(f,"don't await AliasedRawBuilder instances directly. AliasedRawBuilder should never be executed directly since it's always a part of another query.");let g=Object.assign((e,...t)=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(e,t?.map(v)??[])}),{ref:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,s.parseStringReference)(e))}),val:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,o.parseValueExpression)(e))}),value(e){return this.val(e)},table:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,n.parseTable)(e))}),id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(r,e.map(t.IdentifierNode.create))})},lit:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild(i.ValueNode.createImmediate(e))}),literal(e){return this.lit(e)},raw:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithSql(e)}),join(e,t=g`, `){let r=Array(2*e.length-1),i=t.toOperationNode();for(let t=0;t<e.length;++t)r[2*t]=v(e[t]),t!==e.length-1&&(r[2*t+1]=i);return m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChildren(r)})}});function v(e){return(0,r.isOperationNodeSource)(e)?e.toOperationNode():(0,o.parseValueExpression)(e)}e.s(["sql",0,g],12995)},78134,e=>{"use strict";var t=e.i(90348),r=e.i(84739);let a=(0,r.freeze)({raw:(e,a=[])=>(0,r.freeze)({sql:e,query:t.RawNode.createWithSql(e),parameters:(0,r.freeze)(a)})}),i=Symbol();class s{#eL;#ex=new WeakMap;#eM;constructor(e){this.#eL=(0,r.freeze)({...e})}async init(){this.#eM=(0,r.isFunction)(this.#eL.pool)?await this.#eL.pool():this.#eL.pool}async acquireConnection(){let e=await this.#eM.connect(),t=this.#ex.get(e);return!t&&(t=new n(e,{cursor:this.#eL.cursor??null}),this.#ex.set(e,t),this.#eL.onCreateConnection&&await this.#eL.onCreateConnection(t)),this.#eL.onReserveConnection&&await this.#eL.onReserveConnection(t),t}async beginTransaction(e,t){t.isolationLevel?await e.executeQuery(a.raw(`start transaction isolation level ${t.isolationLevel}`)):await e.executeQuery(a.raw("begin"))}async commitTransaction(e){await e.executeQuery(a.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(a.raw("rollback"))}async releaseConnection(e){e[i]()}async destroy(){if(this.#eM){let e=this.#eM;this.#eM=void 0,await e.end()}}}class n{#eF;#eU;constructor(e,t){this.#eF=e,this.#eU=t}async executeQuery(e){try{let t=await this.#eF.query(e.sql,[...e.parameters]);if("INSERT"===t.command||"UPDATE"===t.command||"DELETE"===t.command||"MERGE"===t.command){let e=BigInt(t.rowCount);return{numUpdatedOrDeletedRows:e,numAffectedRows:e,rows:t.rows??[]}}return{rows:t.rows??[]}}catch(e){throw function(e,t){var a;if(a=e,(0,r.isObject)(a)&&(0,r.isString)(a.stack)&&t.stack){let r=t.stack.split("\n").slice(1).join("\n");e.stack+=`
|
|
1
|
+
module.exports=[80253,30314,e=>{"use strict";var t=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=t?.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};e.s(["HTTPException",()=>t],80253);var r=e=>{let t=e.split("/");return""===t[0]&&t.shift(),t},a=e=>{let{groups:t,path:a}=i(e);return s(r(a),t)},i=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,r)=>{let a=`@${r}`;return t.push([a,e]),a}),{groups:t,path:e}},s=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[a]=t[r];for(let i=e.length-1;i>=0;i--)if(e[i].includes(a)){e[i]=e[i].replace(a,t[r][1]);break}}return e},n={},o=(e,t)=>{if("*"===e)return"*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let a=`${e}#${t}`;return n[a]||(r[2]?n[a]=t&&":"!==t[0]&&"*"!==t[0]?[a,r[1],RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],RegExp(`^${r[2]}$`)]:n[a]=[e,r[1],!0]),n[a]}return null},p=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},d=e=>p(e,decodeURI),l=e=>{let t=e.url,r=t.indexOf("/",t.indexOf(":")+4),a=r;for(;a<t.length;a++){let e=t.charCodeAt(a);if(37===e){let e=t.indexOf("?",a),i=t.slice(r,-1===e?void 0:e);return d(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}if(63===e)break}return t.slice(r,a)},c=e=>{let t=l(e);return t.length>1&&"/"===t.at(-1)?t.slice(0,-1):t},u=(e,t,...r)=>(r.length&&(t=u(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${"/"===t?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),h=e=>{if(63!==e.charCodeAt(e.length-1)||!e.includes(":"))return null;let t=e.split("/"),r=[],a="";return t.forEach(e=>{if(""===e||/\:/.test(e)){if(/\:/.test(e))if(/\?/.test(e)){0===r.length&&""===a?r.push("/"):r.push(a);let t=e.replace("?","");a+="/"+t,r.push(a)}else a+="/"+e}else a+="/"+e}),r.filter((e,t,r)=>r.indexOf(e)===t)},m=e=>/[%+]/.test(e)?(-1!==e.indexOf("+")&&(e=e.replace(/\+/g," ")),-1!==e.indexOf("%")?p(e,v):e):e,f=(e,t,r)=>{let a;if(!r&&t&&!/[%+]/.test(t)){let r=e.indexOf("?",8);if(-1===r)return;for(e.startsWith(t,r+1)||(r=e.indexOf(`&${t}`,r+1));-1!==r;){let a=e.charCodeAt(r+t.length+1);if(61===a){let a=r+t.length+2,i=e.indexOf("&",a);return m(e.slice(a,-1===i?void 0:i))}if(38==a||isNaN(a))return"";r=e.indexOf(`&${t}`,r+1)}if(!(a=/[%+]/.test(e)))return}let i={};a??=/[%+]/.test(e);let s=e.indexOf("?",8);for(;-1!==s;){let t,n=e.indexOf("&",s+1),o=e.indexOf("=",s);o>n&&-1!==n&&(o=-1);let p=e.slice(s+1,-1===o?-1===n?void 0:n:o);a&&(p=m(p)),s=n,""!==p&&(-1===o?t="":(t=e.slice(o+1,-1===n?void 0:n),a&&(t=m(t))),r?(i[p]&&Array.isArray(i[p])||(i[p]=[]),i[p].push(t)):i[p]??=t)}return t?i[t]:i},g=(e,t)=>f(e,t,!0),v=decodeURIComponent;e.s(["checkOptionalParameter",()=>h,"decodeURIComponent_",()=>v,"getPath",()=>l,"getPathNoStrict",()=>c,"getPattern",()=>o,"getQueryParam",()=>f,"getQueryParams",()=>g,"mergePath",()=>u,"splitPath",()=>r,"splitRoutingPath",()=>a,"tryDecode",()=>p],30314)},26481,e=>{"use strict";var t=(e,t,r)=>(a,i)=>{let s=-1;return n(0);async function n(o){let p,d;if(o<=s)throw Error("next() called multiple times");s=o;let l=!1;if(e[o]?(d=e[o][0][0],a.req.routeIndex=o):d=o===e.length&&i||void 0,d)try{p=await d(a,()=>n(o+1))}catch(e){if(e instanceof Error&&t)a.error=e,p=await t(e,a),l=!0;else throw e}else!1===a.finalized&&r&&(p=await r(a));return p&&(!1===a.finalized||l)&&(a.res=p),a}};e.i(80253);var r=Symbol(),a=async(e,t=Object.create(null))=>{let{all:r=!1,dot:a=!1}=t,s=(e instanceof d?e.raw.headers:e.headers).get("Content-Type");return s?.startsWith("multipart/form-data")||s?.startsWith("application/x-www-form-urlencoded")?i(e,{all:r,dot:a}):{}};async function i(e,t){var r,a;let i,o=await e.formData();return o?(r=o,a=t,i=Object.create(null),r.forEach((e,t)=>{a.all||t.endsWith("[]")?s(i,t,e):i[t]=e}),a.dot&&Object.entries(i).forEach(([e,t])=>{e.includes(".")&&(n(i,e,t),delete i[e])}),i):{}}var s=(e,t,r)=>{void 0!==e[t]?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r},n=(e,t,r)=>{let a=e,i=t.split(".");i.forEach((e,t)=>{t===i.length-1?a[e]=r:((!a[e]||"object"!=typeof a[e]||Array.isArray(a[e])||a[e]instanceof File)&&(a[e]=Object.create(null)),a=a[e])})},o=e.i(30314),p=e=>(0,o.tryDecode)(e,o.decodeURIComponent_),d=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#t=r,this.#e={}}param(e){return e?this.#r(e):this.#a()}#r(e){let t=this.#t[0][this.routeIndex][1][e],r=this.#i(t);return r&&/\%/.test(r)?p(r):r}#a(){let e={};for(let t of Object.keys(this.#t[0][this.routeIndex][1])){let r=this.#i(this.#t[0][this.routeIndex][1][t]);void 0!==r&&(e[t]=/\%/.test(r)?p(r):r)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return(0,o.getQueryParam)(this.url,e)}queries(e){return(0,o.getQueryParams)(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,r)=>{t[r]=e}),t}async parseBody(e){return this.bodyCache.parsedBody??=await a(this,e)}#s=e=>{let{bodyCache:t,raw:r}=this,a=t[e];if(a)return a;let i=Object.keys(t)[0];return i?t[i].then(t=>("json"===i&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=r[e]()};json(){return this.#s("text").then(e=>JSON.parse(e))}text(){return this.#s("text")}arrayBuffer(){return this.#s("arrayBuffer")}blob(){return this.#s("blob")}formData(){return this.#s("formData")}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[r](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},l=async(e,t,r,a,i)=>{var s;let n;"object"==typeof e&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let o=e.callbacks;if(!o?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let p=Promise.all(o.map(e=>e({phase:t,buffer:i,context:a}))).then(e=>Promise.all(e.filter(Boolean).map(e=>l(e,t,!1,a,i))).then(()=>i[0]));if(!r)return p;return s=await p,(n=new String(s)).isEscaped=!0,n.callbacks=o,n},c=(e,t)=>({"Content-Type":e,...t}),u=class{#n;#o;env={};#p;finalized=!1;error;#d;#l;#c;#u;#h;#m;#f;#t;#g;constructor(e,t){this.#n=e,t&&(this.#l=t.executionCtx,this.env=t.env,this.#m=t.notFoundHandler,this.#g=t.path,this.#t=t.matchResult)}get req(){return this.#o??=new d(this.#n,this.#g,this.#t),this.#o}get event(){if(this.#l&&"respondWith"in this.#l)return this.#l;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#l)return this.#l;throw Error("This context has no ExecutionContext")}get res(){return this.#c||=new Response(null,{headers:this.#f??=new Headers})}set res(e){if(this.#c&&e){for(let[t,r]of(e=new Response(e.body,e),this.#c.headers.entries()))if("content-type"!==t)if("set-cookie"===t){let t=this.#c.headers.getSetCookie();for(let r of(e.headers.delete("set-cookie"),t))e.headers.append("set-cookie",r)}else e.headers.set(t,r)}this.#c=e,this.finalized=!0}render=(...e)=>(this.#h??=e=>this.html(e),this.#h(...e));setLayout=e=>this.#u=e;getLayout=()=>this.#u;setRenderer=e=>{this.#h=e};header=(e,t,r)=>{this.finalized&&(this.#c=new Response(this.#c.body,this.#c));let a=this.#c?this.#c.headers:this.#f??=new Headers;void 0===t?a.delete(e):r?.append?a.append(e,t):a.set(e,t)};status=e=>{this.#d=e};set=(e,t)=>{this.#p??=new Map,this.#p.set(e,t)};get=e=>this.#p?this.#p.get(e):void 0;get var(){return this.#p?Object.fromEntries(this.#p):{}}#v(e,t,r){let a=this.#c?new Headers(this.#c.headers):this.#f??new Headers;if("object"==typeof t&&"headers"in t)for(let[e,r]of t.headers instanceof Headers?t.headers:new Headers(t.headers))"set-cookie"===e.toLowerCase()?a.append(e,r):a.set(e,r);if(r)for(let[e,t]of Object.entries(r))if("string"==typeof t)a.set(e,t);else for(let r of(a.delete(e),t))a.append(e,r);return new Response(e,{status:"number"==typeof t?t:t?.status??this.#d,headers:a})}newResponse=(...e)=>this.#v(...e);body=(e,t,r)=>this.#v(e,t,r);text=(e,t,r)=>this.#f||this.#d||t||r||this.finalized?this.#v(e,t,c("text/plain; charset=UTF-8",r)):new Response(e);json=(e,t,r)=>this.#v(JSON.stringify(e),t,c("application/json",r));html=(e,t,r)=>{let a=e=>this.#v(e,t,c("text/html; charset=UTF-8",r));return"object"==typeof e?l(e,1,!1,{}).then(a):a(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#m??=()=>new Response,this.#m(this))},h=["get","post","put","delete","options","patch"],m="Can not add a route since the matcher is already built.",f=class extends Error{},g=e=>e.text("404 Not Found",404),v=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},y=class e{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#g="/";routes=[];constructor(e={}){[...h,"all"].forEach(e=>{this[e]=(t,...r)=>("string"==typeof t?this.#g=t:this.#y(e,this.#g,t),r.forEach(t=>{this.#y(e,this.#g,t)}),this)}),this.on=(e,t,...r)=>{for(let a of[t].flat())for(let t of(this.#g=a,[e].flat()))r.map(e=>{this.#y(t.toUpperCase(),this.#g,e)});return this},this.use=(e,...t)=>("string"==typeof e?this.#g=e:(this.#g="*",t.unshift(e)),t.forEach(e=>{this.#y("ALL",this.#g,e)}),this);const{strict:t,...r}=e;Object.assign(this,r),this.getPath=t??!0?e.getPath??o.getPath:o.getPathNoStrict}#w(){let t=new e({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#m=this.#m,t.routes=this.routes,t}#m=g;errorHandler=v;route(e,r){let a=this.basePath(e);return r.routes.map(e=>{let i;r.errorHandler===v?i=e.handler:(i=async(a,i)=>(await t([],r.errorHandler)(a,()=>e.handler(a,i))).res).__COMPOSED_HANDLER=e.handler,a.#y(e.method,e.path,i)}),this}basePath(e){let t=this.#w();return t._basePath=(0,o.mergePath)(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#m=e,this);mount(e,t,r){let a,i,s,n;r&&("function"==typeof r?i=r:(i=r.optionHandler,a=!1===r.replaceRequest?e=>e:r.replaceRequest));let p=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};a||=(n="/"===(s=(0,o.mergePath)(this._basePath,e))?0:s.length,e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||"/",new Request(t,e)});let d=async(e,r)=>{let i=await t(a(e.req.raw),...p(e));if(i)return i;await r()};return this.#y("ALL",(0,o.mergePath)(e,"*"),d),this}#y(e,t,r){e=e.toUpperCase(),t=(0,o.mergePath)(this._basePath,t);let a={basePath:this._basePath,path:t,method:e,handler:r};this.router.add(e,t,[r,a]),this.routes.push(a)}#b(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#_(e,r,a,i){if("HEAD"===i)return(async()=>new Response(null,await this.#_(e,r,a,"GET")))();let s=this.getPath(e,{env:a}),n=this.router.match(i,s),o=new u(e,{path:s,matchResult:n,env:a,executionCtx:r,notFoundHandler:this.#m});if(1===n[0].length){let e;try{e=n[0][0][0][0](o,async()=>{o.res=await this.#m(o)})}catch(e){return this.#b(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#m(o))).catch(e=>this.#b(e,o)):e??this.#m(o)}let p=t(n[0],this.errorHandler,this.#m);return(async()=>{try{let e=await p(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#b(e,o)}})()}fetch=(e,...t)=>this.#_(e,t[1],t[0],e.method);request=(e,t,r,a)=>e instanceof Request?this.fetch(t?new Request(e,t):e,r,a):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${(0,o.mergePath)("/",e)}`,t),r,a));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#_(e.request,e,void 0,e.request.method))})}},w=[];function b(e,t){let r=this.buildAllMatchers(),a=(e,t)=>{let a=r[e]||r.ALL,i=a[2][t];if(i)return i;let s=t.match(a[0]);if(!s)return[[],w];let n=s.indexOf("",1);return[a[1][n],s]};return this.match=a,a(e,t)}var _="[^/]+",x="(?:|/.*)",N=Symbol(),T=new Set(".\\+*[^]$()");function E(e,t){return 1===e.length?1===t.length?e<t?-1:1:-1:1===t.length||".*"===e||e===x?1:".*"===t||t===x?-1:e===_?1:t===_?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var A=class e{#x;#N;#T=Object.create(null);insert(t,r,a,i,s){let n;if(0===t.length){if(void 0!==this.#x)throw N;if(s)return;this.#x=r;return}let[o,...p]=t,d="*"===o?0===p.length?["","",".*"]:["","",_]:"/*"===o?["","",x]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(d){let t=d[1],r=d[2]||_;if(t&&d[2]&&(".*"===r||(r=r.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(r))))throw N;if(!(n=this.#T[r])){if(Object.keys(this.#T).some(e=>".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[r]=new e,""!==t&&(n.#N=i.varIndex++)}s||""===t||a.push([t,n.#N])}else if(!(n=this.#T[o])){if(Object.keys(this.#T).some(e=>e.length>1&&".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[o]=new e}n.insert(p,r,a,i,s)}buildRegExpStr(){let e=Object.keys(this.#T).sort(E).map(e=>{let t=this.#T[e];return("number"==typeof t.#N?`(${e})@${t.#N}`:T.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return("number"==typeof this.#x&&e.unshift(`#${this.#x}`),0===e.length)?"":1===e.length?e[0]:"(?:"+e.join("|")+")"}},S=class{#E={varIndex:0};#A=new A;insert(e,t,r){let a=[],i=[];for(let t=0;;){let r=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let a=`@\\${t}`;return i[t]=[a,e],t++,r=!0,a}),!r)break}let s=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let r=s.length-1;r>=0;r--)if(-1!==s[r].indexOf(t)){s[r]=s[r].replace(t,i[e][1]);break}}return this.#A.insert(s,t,a,this.#E,r),a}buildRegExp(){let e=this.#A.buildRegExpStr();if(""===e)return[/^$/,[],[]];let t=0,r=[],a=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,s)=>void 0!==i?(r[++t]=Number(i),"$()"):(void 0!==s&&(a[Number(s)]=++t),"")),[RegExp(`^${e}`),r,a]}},k=[/^$/,[],Object.create(null)],O=Object.create(null);function C(e){return O[e]??=new RegExp("*"===e?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`)}function I(e,t){if(e){for(let r of Object.keys(e).sort((e,t)=>t.length-e.length))if(C(r).test(t))return[...e[r]]}}var R=class{name="RegExpRouter";#S;#k;constructor(){this.#S={ALL:Object.create(null)},this.#k={ALL:Object.create(null)}}add(e,t,r){let a=this.#S,i=this.#k;if(!a||!i)throw Error(m);a[e]||[a,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t.ALL).forEach(r=>{t[e][r]=[...t.ALL[r]]})}),"/*"===t&&(t="*");let s=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let n=C(t);"ALL"===e?Object.keys(a).forEach(e=>{a[e][t]||=I(a[e],t)||I(a.ALL,t)||[]}):a[e][t]||=I(a[e],t)||I(a.ALL,t)||[],Object.keys(a).forEach(t=>{("ALL"===e||e===t)&&Object.keys(a[t]).forEach(e=>{n.test(e)&&a[t][e].push([r,s])})}),Object.keys(i).forEach(t=>{("ALL"===e||e===t)&&Object.keys(i[t]).forEach(e=>n.test(e)&&i[t][e].push([r,s]))});return}let n=(0,o.checkOptionalParameter)(t)||[t];for(let t=0,o=n.length;t<o;t++){let p=n[t];Object.keys(i).forEach(n=>{("ALL"===e||e===n)&&(i[n][p]||=[...I(a[n],p)||I(a.ALL,p)||[]],i[n][p].push([r,s-o+t+1]))})}}match=b;buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#k).concat(Object.keys(this.#S)).forEach(t=>{e[t]||=this.#O(t)}),this.#S=this.#k=void 0,O=Object.create(null),e}#O(e){let t=[],r="ALL"===e;return([this.#S,this.#k].forEach(a=>{let i=a[e]?Object.keys(a[e]).map(t=>[t,a[e][t]]):[];0!==i.length?(r||=!0,t.push(...i)):"ALL"!==e&&t.push(...Object.keys(a.ALL).map(e=>[e,a.ALL[e]]))}),r)?function(e){let t=new S,r=[];if(0===e.length)return k;let a=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[r,a])=>e?1:r?-1:t.length-a.length),i=Object.create(null);for(let e=0,s=-1,n=a.length;e<n;e++){let n,[o,p,d]=a[e];o?i[p]=[d.map(([e])=>[e,Object.create(null)]),w]:s++;try{n=t.insert(p,s,o)}catch(e){throw e===N?new f(p):e}o||(r[s]=d.map(([e,t])=>{let r=Object.create(null);for(t-=1;t>=0;t--){let[e,a]=n[t];r[e]=a}return[e,r]}))}let[s,n,o]=t.buildRegExp();for(let e=0,t=r.length;e<t;e++)for(let t=0,a=r[e].length;t<a;t++){let a=r[e][t]?.[1];if(!a)continue;let i=Object.keys(a);for(let e=0,t=i.length;e<t;e++)a[i[e]]=o[a[i[e]]]}let p=[];for(let e in n)p[e]=r[n[e]];return[s,p,i]}(t):null}},D=class{name="SmartRouter";#C=[];#k=[];constructor(e){this.#C=e.routers}add(e,t,r){if(!this.#k)throw Error(m);this.#k.push([e,t,r])}match(e,t){let r;if(!this.#k)throw Error("Fatal error");let a=this.#C,i=this.#k,s=a.length,n=0;for(;n<s;n++){let s=a[n];try{for(let e=0,t=i.length;e<t;e++)s.add(...i[e]);r=s.match(e,t)}catch(e){if(e instanceof f)continue;throw e}this.match=s.match.bind(s),this.#C=[s],this.#k=void 0;break}if(n===s)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,r}get activeRouter(){if(this.#k||1!==this.#C.length)throw Error("No active router has been determined yet.");return this.#C[0]}},P=Object.create(null),j=class e{#I;#T;#R;#D=0;#P=P;constructor(e,t,r){if(this.#T=r||Object.create(null),this.#I=[],e&&t){const r=Object.create(null);r[e]={handler:t,possibleKeys:[],score:0},this.#I=[r]}this.#R=[]}insert(t,r,a){this.#D=++this.#D;let i=this,s=(0,o.splitRoutingPath)(r),n=[];for(let t=0,r=s.length;t<r;t++){let r=s[t],a=s[t+1],p=(0,o.getPattern)(r,a),d=Array.isArray(p)?p[0]:r;if(d in i.#T){i=i.#T[d],p&&n.push(p[1]);continue}i.#T[d]=new e,p&&(i.#R.push(p),n.push(p[1])),i=i.#T[d]}return i.#I.push({[t]:{handler:a,possibleKeys:n.filter((e,t,r)=>r.indexOf(e)===t),score:this.#D}}),i}#j(e,t,r,a){let i=[];for(let s=0,n=e.#I.length;s<n;s++){let n=e.#I[s],o=n[t]||n.ALL,p={};if(void 0!==o&&(o.params=Object.create(null),i.push(o),r!==P||a&&a!==P))for(let e=0,t=o.possibleKeys.length;e<t;e++){let t=o.possibleKeys[e],i=p[o.score];o.params[t]=a?.[t]&&!i?a[t]:r[t]??a?.[t],p[o.score]=!0}}return i}search(e,t){let r=[];this.#P=P;let a=[this],i=(0,o.splitPath)(t),s=[];for(let t=0,n=i.length;t<n;t++){let o=i[t],p=t===n-1,d=[];for(let n=0,l=a.length;n<l;n++){let l=a[n],c=l.#T[o];c&&(c.#P=l.#P,p?(c.#T["*"]&&r.push(...this.#j(c.#T["*"],e,l.#P)),r.push(...this.#j(c,e,l.#P))):d.push(c));for(let a=0,n=l.#R.length;a<n;a++){let n=l.#R[a],c=l.#P===P?{}:{...l.#P};if("*"===n){let t=l.#T["*"];t&&(r.push(...this.#j(t,e,l.#P)),t.#P=c,d.push(t));continue}let[u,h,m]=n;if(!o&&!(m instanceof RegExp))continue;let f=l.#T[u],g=i.slice(t).join("/");if(m instanceof RegExp){let t=m.exec(g);if(t){if(c[h]=t[0],r.push(...this.#j(f,e,l.#P,c)),Object.keys(f.#T).length){f.#P=c;let e=t[0].match(/\//)?.length??0;(s[e]||=[]).push(f)}continue}}(!0===m||m.test(o))&&(c[h]=o,p?(r.push(...this.#j(f,e,c,l.#P)),f.#T["*"]&&r.push(...this.#j(f.#T["*"],e,c,l.#P))):(f.#P=c,d.push(f)))}}a=d.concat(s.shift()??[])}return r.length>1&&r.sort((e,t)=>e.score-t.score),[r.map(({handler:e,params:t})=>[e,t])]}},q=class{name="TrieRouter";#q;constructor(){this.#q=new j}add(e,t,r){let a=(0,o.checkOptionalParameter)(t);if(a){for(let t=0,i=a.length;t<i;t++)this.#q.insert(e,a[t],r);return}this.#q.insert(e,t,r)}match(e,t){return this.#q.search(e,t)}},L=class extends y{constructor(e={}){super(e),this.router=e.router??new D({routers:[new R,new q]})}};e.s(["Hono",()=>L],26481)},19991,e=>{"use strict";e.i(26481),e.s([])},66349,e=>{"use strict";var t=e=>t=>e.fetch(t);e.s(["handle",()=>t])},66587,e=>{"use strict";e.i(66349),e.s([],66587)},7805,e=>{"use strict";var t=e=>{var t;let r={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...e},a=(e=>{if("string"==typeof e)if("*"===e)return()=>e;else return t=>e===t?t:null;return"function"==typeof e?e:t=>e.includes(t)?t:null})(r.origin),i="function"==typeof(t=r.allowMethods)?t:Array.isArray(t)?()=>t:()=>[];return async function(e,t){function s(t,r){e.res.headers.set(t,r)}let n=await a(e.req.header("origin")||"",e);if(n&&s("Access-Control-Allow-Origin",n),r.credentials&&s("Access-Control-Allow-Credentials","true"),r.exposeHeaders?.length&&s("Access-Control-Expose-Headers",r.exposeHeaders.join(",")),"OPTIONS"===e.req.method){"*"!==r.origin&&s("Vary","Origin"),null!=r.maxAge&&s("Access-Control-Max-Age",r.maxAge.toString());let t=await i(e.req.header("origin")||"",e);t.length&&s("Access-Control-Allow-Methods",t.join(","));let a=r.allowHeaders;if(!a?.length){let t=e.req.header("Access-Control-Request-Headers");t&&(a=t.split(/\s*,\s*/))}return a?.length&&(s("Access-Control-Allow-Headers",a.join(",")),e.res.headers.append("Vary","Access-Control-Request-Headers")),e.res.headers.delete("Content-Length"),e.res.headers.delete("Content-Type"),new Response(null,{headers:e.res.headers,status:204,statusText:"No Content"})}await t(),"*"!==r.origin&&e.header("Vary","Origin",{append:!0})}};e.s(["cors",()=>t])},39768,e=>{"use strict";e.s([],39768)},79296,e=>{"use strict";function t(e,t,r){function a(r,a){var i;for(let s in Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(i=r._zod).traits??(i.traits=new Set),r._zod.traits.add(e),t(r,a),n.prototype)s in r||Object.defineProperty(r,s,{value:n.prototype[s].bind(r)});r._zod.constr=n,r._zod.def=a}let i=r?.Parent??Object;class s extends i{}function n(e){var t;let i=r?.Parent?new s:this;for(let r of(a(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}function r(e,t){return"bigint"==typeof t?t.toString():t}Object.freeze({status:"aborted"}),Symbol("zod_brand"),Error.captureStackTrace||((...e)=>{}),()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}};let a=t("$ZodError",(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,r,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})}),i=t("ZodError",(e,t)=>{a.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>{let r,a,i;return r=t||function(e){return e.message},a={_errors:[]},(i=e=>{for(let t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>i({issues:e}));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)a._errors.push(r(t));else{let e=a,i=0;for(;i<t.path.length;){let a=t.path[i];i===t.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(r(t))):e[a]=e[a]||{_errors:[]},e=e[a],i++}}})(e),a}},flatten:{value:t=>(function(e,t=e=>e.message){let r={},a=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}})(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})});e.s(["ZodError",0,i],79296)},16172,e=>{"use strict";let t;e.s([],44057),e.i(44057),(to=tl||(tl={})).assertEqual=e=>{},to.assertIs=function(e){},to.assertNever=function(e){throw Error()},to.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},to.getValidEnumValues=e=>{let t=to.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let a of t)r[a]=e[a];return to.objectValues(r)},to.objectValues=e=>to.objectKeys(e).map(function(t){return e[t]}),to.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},to.find=(e,t)=>{for(let r of e)if(t(r))return r},to.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,to.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},to.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(tc||(tc={})).mergeShapes=(e,t)=>({...e,...t});let r=tl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return r.undefined;case"string":return r.string;case"number":return Number.isNaN(e)?r.nan:r.number;case"boolean":return r.boolean;case"function":return r.function;case"bigint":return r.bigint;case"symbol":return r.symbol;case"object":if(Array.isArray(e))return r.array;if(null===e)return r.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return r.promise;if("undefined"!=typeof Map&&e instanceof Map)return r.map;if("undefined"!=typeof Set&&e instanceof Set)return r.set;if("undefined"!=typeof Date&&e instanceof Date)return r.date;return r.object;default:return r.unknown}};e.s(["ZodParsedType",0,r,"getParsedType",0,a,"objectUtil",()=>tc,"util",()=>tl],57500);let i=tl.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),s=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},a=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(a);else if("invalid_return_type"===i.code)a(i.returnTypeError);else if("invalid_arguments"===i.code)a(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,a=0;for(;a<i.path.length;){let r=i.path[a];a===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tl.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];t[r]=t[r]||[],t[r].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}n.create=e=>new n(e),e.s(["ZodError",()=>n,"ZodIssueCode",0,i,"quotelessJson",0,s],21466);let o=(e,t)=>{let a;switch(e.code){case i.invalid_type:a=e.received===r.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,tl.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${tl.joinValues(e.keys,", ")}`;break;case i.invalid_union:a="Invalid input";break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${tl.joinValues(e.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${tl.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:a="Invalid function arguments";break;case i.invalid_return_type:a="Invalid function return type";break;case i.invalid_date:a="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:tl.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case i.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case i.custom:a="Invalid input";break;case i.invalid_intersection_types:a="Intersection results could not be merged";break;case i.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:a="Number must be finite";break;default:a=t.defaultError,tl.assertNever(e)}return{message:a}},p=o;function d(e){p=e}function l(){return p}e.s(["getErrorMap",()=>l,"setErrorMap",()=>d],13981),e.i(13981),e.s(["defaultErrorMap",0,o,"getErrorMap",()=>l,"setErrorMap",()=>d],87672),e.i(87672);let c=e=>{let{data:t,path:r,errorMaps:a,issueData:i}=e,s=[...r,...i.path||[]],n={...i,path:s};if(void 0!==i.message)return{...i,path:s,message:i.message};let o="";for(let e of a.filter(e=>!!e).slice().reverse())o=e(n,{data:t,defaultError:o}).message;return{...i,path:s,message:o}},u=[];function h(e,t){let r=p,a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===o?void 0:o].filter(e=>!!e)});e.common.issues.push(a)}class m{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if("aborted"===a.status)return f;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,a=await e.value;r.push({key:t,value:a})}return m.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:t,value:i}=a;if("aborted"===t.status||"aborted"===i.status)return f;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||a.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let f=Object.freeze({status:"aborted"}),g=e=>({status:"dirty",value:e}),v=e=>({status:"valid",value:e}),y=e=>"aborted"===e.status,w=e=>"dirty"===e.status,b=e=>"valid"===e.status,_=e=>"undefined"!=typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"OK",0,v,"ParseStatus",()=>m,"addIssueToContext",()=>h,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"makeIssue",0,c],58216),e.i(58216),e.s([],28032),e.i(28032),e.i(57500),(tp=tu||(tu={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},tp.toString=e=>"string"==typeof e?e:e?.message;class x{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let N=(e,t)=>{if(b(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new n(e.common.issues);return this._error=t,this._error}}};function T(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=e;if(t&&(r||a))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:s}=e;return"invalid_enum_value"===t.code?{message:s??i.defaultError}:void 0===i.data?{message:s??a??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:s??r??i.defaultError}},description:i}}class E{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new m,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(_(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parseSync({data:e,path:r.path,parent:r});return N(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return b(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>b(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parse({data:e,path:r.path,parent:r});return N(r,await (_(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,a)=>{let s=e(r),n=()=>a.addIssue({code:i.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(n(),!1)):!!s||(n(),!1)})}refinement(e,t){return this._refinement((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1))}_refinement(e){return new ew({schema:this,typeName:th.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return eb.create(this,this._def)}nullable(){return e_.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this)}promise(){return ey.create(this,this._def)}or(e){return ei.create([this,e],this._def)}and(e){return eo.create(this,e,this._def)}transform(e){return new ew({...T(this._def),schema:this,typeName:th.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new ex({...T(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:th.ZodDefault})}brand(){return new eA({typeName:th.ZodBranded,type:this,...T(this._def)})}catch(e){return new eN({...T(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:th.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eS.create(this,e)}readonly(){return ek.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let A=/^c[^\s-]{8,}$/i,S=/^[0-9a-z]+$/,k=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,R=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,D=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,P=/^(?:(?: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])$/,j=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,q=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\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])))",B=RegExp(`^${U}$`);function V(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function z(e){let t=`${U}T${V(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class W extends E{_parse(e){var a,s,n,o;let p;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.string,received:t.parsedType}),f}let d=new m;for(let r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("max"===r.kind)e.data.length>r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("length"===r.kind){let t=e.data.length>r.value,a=e.data.length<r.value;(t||a)&&(p=this._getOrReturnCtx(e,p),t?h(p,{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&h(p,{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),d.dirty())}else if("email"===r.kind)D.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"email",code:i.invalid_string,message:r.message}),d.dirty());else if("emoji"===r.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"emoji",code:i.invalid_string,message:r.message}),d.dirty());else if("uuid"===r.kind)O.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"uuid",code:i.invalid_string,message:r.message}),d.dirty());else if("nanoid"===r.kind)C.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"nanoid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid"===r.kind)A.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid2"===r.kind)S.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid2",code:i.invalid_string,message:r.message}),d.dirty());else if("ulid"===r.kind)k.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"ulid",code:i.invalid_string,message:r.message}),d.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{h(p=this._getOrReturnCtx(e,p),{validation:"url",code:i.invalid_string,message:r.message}),d.dirty()}else"regex"===r.kind?(r.regex.lastIndex=0,r.regex.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"regex",code:i.invalid_string,message:r.message}),d.dirty())):"trim"===r.kind?e.data=e.data.trim():"includes"===r.kind?e.data.includes(r.value,r.position)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),d.dirty()):"toLowerCase"===r.kind?e.data=e.data.toLowerCase():"toUpperCase"===r.kind?e.data=e.data.toUpperCase():"startsWith"===r.kind?e.data.startsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{startsWith:r.value},message:r.message}),d.dirty()):"endsWith"===r.kind?e.data.endsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{endsWith:r.value},message:r.message}),d.dirty()):"datetime"===r.kind?z(r).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"datetime",message:r.message}),d.dirty()):"date"===r.kind?B.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"date",message:r.message}),d.dirty()):"time"===r.kind?RegExp(`^${V(r)}$`).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"time",message:r.message}),d.dirty()):"duration"===r.kind?R.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"duration",code:i.invalid_string,message:r.message}),d.dirty()):"ip"===r.kind?(a=e.data,!(("v4"===(s=r.version)||!s)&&P.test(a)||("v6"===s||!s)&&q.test(a))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"ip",code:i.invalid_string,message:r.message}),d.dirty())):"jwt"===r.kind?!function(e,t){if(!I.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,r.alg)&&(h(p=this._getOrReturnCtx(e,p),{validation:"jwt",code:i.invalid_string,message:r.message}),d.dirty()):"cidr"===r.kind?(n=e.data,!(("v4"===(o=r.version)||!o)&&j.test(n)||("v6"===o||!o)&&L.test(n))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"cidr",code:i.invalid_string,message:r.message}),d.dirty())):"base64"===r.kind?M.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64",code:i.invalid_string,message:r.message}),d.dirty()):"base64url"===r.kind?F.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64url",code:i.invalid_string,message:r.message}),d.dirty()):tl.assertNever(r);return{status:d.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...tu.errToObj(r)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tu.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tu.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tu.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tu.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tu.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tu.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tu.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tu.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tu.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tu.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tu.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tu.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tu.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...tu.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...tu.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tu.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tu.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tu.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tu.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tu.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tu.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tu.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tu.errToObj(t)})}nonempty(e){return this.min(1,tu.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}W.create=e=>new W({checks:[],typeName:th.ZodString,coerce:e?.coerce??!1,...T(e)});class $ extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==r.number){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.number,received:t.parsedType}),f}let a=new m;for(let r of this._def.checks)"int"===r.kind?tl.isInteger(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"multipleOf"===r.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.not_finite,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tu.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tu.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tu.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tu.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&tl.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}$.create=e=>new $({checks:[],typeName:th.ZodNumber,coerce:e?.coerce||!1,...T(e)});class G extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let a=new m;for(let r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}G.create=e=>new G({checks:[],typeName:th.ZodBigInt,coerce:e?.coerce??!1,...T(e)});class H extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.boolean,received:t.parsedType}),f}return v(e.data)}}H.create=e=>new H({typeName:th.ZodBoolean,coerce:e?.coerce||!1,...T(e)});class K extends E{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.date,received:t.parsedType}),f}if(Number.isNaN(e.data.getTime()))return h(this._getOrReturnCtx(e),{code:i.invalid_date}),f;let a=new m;for(let r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),a.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),a.dirty()):tl.assertNever(r);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tu.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tu.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}K.create=e=>new K({checks:[],coerce:e?.coerce||!1,typeName:th.ZodDate,...T(e)});class J extends E{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.symbol,received:t.parsedType}),f}return v(e.data)}}J.create=e=>new J({typeName:th.ZodSymbol,...T(e)});class Z extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.undefined,received:t.parsedType}),f}return v(e.data)}}Z.create=e=>new Z({typeName:th.ZodUndefined,...T(e)});class Q extends E{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.null,received:t.parsedType}),f}return v(e.data)}}Q.create=e=>new Q({typeName:th.ZodNull,...T(e)});class Y extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return v(e.data)}}Y.create=e=>new Y({typeName:th.ZodAny,...T(e)});class X extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return v(e.data)}}X.create=e=>new X({typeName:th.ZodUnknown,...T(e)});class ee extends E{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.never,received:t.parsedType}),f}}ee.create=e=>new ee({typeName:th.ZodNever,...T(e)});class et extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.void,received:t.parsedType}),f}return v(e.data)}}et.create=e=>new et({typeName:th.ZodVoid,...T(e)});class er extends E{_parse(e){let{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==r.array)return h(t,{code:i.invalid_type,expected:r.array,received:t.parsedType}),f;if(null!==s.exactLength){let e=t.data.length>s.exactLength.value,r=t.data.length<s.exactLength.value;(e||r)&&(h(t,{code:e?i.too_big:i.too_small,minimum:r?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(h(t,{code:i.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(h(t,{code:i.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>s.type._parseAsync(new x(t,e,t.path,r)))).then(e=>m.mergeArray(a,e));let n=[...t.data].map((e,r)=>s.type._parseSync(new x(t,e,t.path,r)));return m.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new er({...this._def,minLength:{value:e,message:tu.toString(t)}})}max(e,t){return new er({...this._def,maxLength:{value:e,message:tu.toString(t)}})}length(e,t){return new er({...this._def,exactLength:{value:e,message:tu.toString(t)}})}nonempty(e){return this.min(1,e)}}er.create=(e,t)=>new er({type:e,minLength:null,maxLength:null,exactLength:null,typeName:th.ZodArray,...T(t)});class ea extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=tl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f}let{status:t,ctx:a}=this._processInputParams(e),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof ee&&"strip"===this._def.unknownKeys))for(let e in a.data)n.includes(e)||o.push(e);let p=[];for(let e of n){let t=s[e],r=a.data[e];p.push({key:{status:"valid",value:e},value:t._parse(new x(a,r,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ee){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of o)p.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(h(a,{code:i.unrecognized_keys,keys:o}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of o){let r=a.data[t];p.push({key:{status:"valid",value:t},value:e._parse(new x(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of p){let r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>m.mergeObjectSync(t,e)):m.mergeObjectSync(t,p)}get shape(){return this._def.shape()}strict(e){return tu.errToObj,new ea({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let a=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:tu.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ea({...this._def,unknownKeys:"strip"})}passthrough(){return new ea({...this._def,unknownKeys:"passthrough"})}extend(e){return new ea({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ea({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:th.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ea({...this._def,catchall:e})}pick(e){let t={};for(let r of tl.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}omit(e){let t={};for(let r of tl.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ea){let r={};for(let a in t.shape){let i=t.shape[a];r[a]=eb.create(e(i))}return new ea({...t._def,shape:()=>r})}if(t instanceof er)return new er({...t._def,type:e(t.element)});if(t instanceof eb)return eb.create(e(t.unwrap()));if(t instanceof e_)return e_.create(e(t.unwrap()));if(t instanceof ep)return ep.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of tl.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new ea({...this._def,shape:()=>t})}required(e){let t={};for(let r of tl.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof eb;)e=e._def.innerType;t[r]=e}return new ea({...this._def,shape:()=>t})}keyof(){return ef(tl.objectKeys(this.shape))}}ea.create=(e,t)=>new ea({shape:()=>e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.strictCreate=(e,t)=>new ea({shape:()=>e,unknownKeys:"strict",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.lazycreate=(e,t)=>new ea({shape:e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)});class ei extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new n(e.ctx.common.issues));return h(t,{code:i.invalid_union,unionErrors:r}),f});{let e,a=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},s=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===s.status)return s;"dirty"!==s.status||e||(e={result:s,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let s=a.map(e=>new n(e));return h(t,{code:i.invalid_union,unionErrors:s}),f}}get options(){return this._def.options}}ei.create=(e,t)=>new ei({options:e,typeName:th.ZodUnion,...T(t)});let es=e=>{if(e instanceof eh)return es(e.schema);if(e instanceof ew)return es(e.innerType());if(e instanceof em)return[e.value];if(e instanceof eg)return e.options;if(e instanceof ev)return tl.objectValues(e.enum);else if(e instanceof ex)return es(e._def.innerType);else if(e instanceof Z)return[void 0];else if(e instanceof Q)return[null];else if(e instanceof eb)return[void 0,...es(e.unwrap())];else if(e instanceof e_)return[null,...es(e.unwrap())];else if(e instanceof eA)return es(e.unwrap());else if(e instanceof ek)return es(e.unwrap());else if(e instanceof eN)return es(e._def.innerType);else return[]};class en extends E{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f;let a=this.discriminator,s=t.data[a],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let r of t){let t=es(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(a.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);a.set(i,r)}}return new en({typeName:th.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...T(r)})}}class eo extends E{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(y(e)||y(n))return f;let o=function e(t,i){let s=a(t),n=a(i);if(t===i)return{valid:!0,data:t};if(s===r.object&&n===r.object){let r=tl.objectKeys(i),a=tl.objectKeys(t).filter(e=>-1!==r.indexOf(e)),s={...t,...i};for(let r of a){let a=e(t[r],i[r]);if(!a.valid)return{valid:!1};s[r]=a.data}return{valid:!0,data:s}}if(s===r.array&&n===r.array){if(t.length!==i.length)return{valid:!1};let r=[];for(let a=0;a<t.length;a++){let s=e(t[a],i[a]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}if(s===r.date&&n===r.date&&+t==+i)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return o.valid?((w(e)||w(n))&&t.dirty(),{status:t.value,value:o.data}):(h(s,{code:i.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}eo.create=(e,t,r)=>new eo({left:e,right:t,typeName:th.ZodIntersection,...T(r)});class ep extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.array)return h(a,{code:i.invalid_type,expected:r.array,received:a.parsedType}),f;if(a.data.length<this._def.items.length)return h(a,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...a.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new x(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>m.mergeArray(t,e)):m.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ep({...this._def,rest:e})}}ep.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ep({items:e,typeName:th.ZodTuple,rest:null,...T(t)})};class ed extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.object)return h(a,{code:i.invalid_type,expected:r.object,received:a.parsedType}),f;let s=[],n=this._def.keyType,o=this._def.valueType;for(let e in a.data)s.push({key:n._parse(new x(a,e,a.path,e)),value:o._parse(new x(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?m.mergeObjectAsync(t,s):m.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return new ed(t instanceof E?{keyType:e,valueType:t,typeName:th.ZodRecord,...T(r)}:{keyType:W.create(),valueType:e,typeName:th.ZodRecord,...T(t)})}}class el extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.map)return h(a,{code:i.invalid_type,expected:r.map,received:a.parsedType}),f;let s=this._def.keyType,n=this._def.valueType,o=[...a.data.entries()].map(([e,t],r)=>({key:s._parse(new x(a,e,a.path,[r,"key"])),value:n._parse(new x(a,t,a.path,[r,"value"]))}));if(a.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of o){let a=await r.key,i=await r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of o){let a=r.key,i=r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}}}}el.create=(e,t,r)=>new el({valueType:t,keyType:e,typeName:th.ZodMap,...T(r)});class ec extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.set)return h(a,{code:i.invalid_type,expected:r.set,received:a.parsedType}),f;let s=this._def;null!==s.minSize&&a.data.size<s.minSize.value&&(h(a,{code:i.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&a.data.size>s.maxSize.value&&(h(a,{code:i.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let n=this._def.valueType;function o(e){let r=new Set;for(let a of e){if("aborted"===a.status)return f;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}let p=[...a.data.values()].map((e,t)=>n._parse(new x(a,e,a.path,t)));return a.common.async?Promise.all(p).then(e=>o(e)):o(p)}min(e,t){return new ec({...this._def,minSize:{value:e,message:tu.toString(t)}})}max(e,t){return new ec({...this._def,maxSize:{value:e,message:tu.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ec.create=(e,t)=>new ec({valueType:e,minSize:null,maxSize:null,typeName:th.ZodSet,...T(t)});class eu extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return h(t,{code:i.invalid_type,expected:r.function,received:t.parsedType}),f;function a(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:r}})}function s(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:r}})}let d={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof ey){let e=this;return v(async function(...t){let r=new n([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw r.addIssue(a(t,e)),r}),o=await Reflect.apply(l,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw r.addIssue(s(o,e)),r})})}{let e=this;return v(function(...t){let r=e._def.args.safeParse(t,d);if(!r.success)throw new n([a(t,r.error)]);let i=Reflect.apply(l,this,r.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new n([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new eu({...this._def,args:ep.create(e).rest(X.create())})}returns(e){return new eu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new eu({args:e||ep.create([]).rest(X.create()),returns:t||X.create(),typeName:th.ZodFunction,...T(r)})}}class eh extends E{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}eh.create=(e,t)=>new eh({getter:e,typeName:th.ZodLazy,...T(t)});class em extends E{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ef(e,t){return new eg({values:e,typeName:th.ZodEnum,...T(t)})}em.create=(e,t)=>new em({value:e,typeName:th.ZodLiteral,...T(t)});class eg extends E{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:tl.joinValues(r),received:t.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:i.invalid_enum_value,options:r}),f}return v(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return eg.create(e,{...this._def,...t})}exclude(e,t=this._def){return eg.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eg.create=ef;class ev extends E{_parse(e){let t=tl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==r.string&&a.parsedType!==r.number){let e=tl.objectValues(t);return h(a,{expected:tl.joinValues(e),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(tl.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tl.objectValues(t);return h(a,{received:a.data,code:i.invalid_enum_value,options:e}),f}return v(e.data)}get enum(){return this._def.values}}ev.create=(e,t)=>new ev({values:e,typeName:th.ZodNativeEnum,...T(t)});class ey extends E{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&!1===t.common.async?(h(t,{code:i.invalid_type,expected:r.promise,received:t.parsedType}),f):v((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ey.create=(e,t)=>new ey({type:e,typeName:th.ZodPromise,...T(t)});class ew extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===th.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:e=>{h(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===a.type){let e=a.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return f;let a=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a});{if("aborted"===t.value)return f;let a=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a}}if("refinement"===a.type){let e=e=>{let t=a.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?f:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===a.status?f:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}}if("transform"===a.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>b(e)?Promise.resolve(a.transform(e.value,i)).then(e=>({status:t.value,value:e})):f);else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!b(e))return f;let s=a.transform(e.value,i);if(s instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}tl.assertNever(a)}}ew.create=(e,t,r)=>new ew({schema:e,typeName:th.ZodEffects,effect:t,...T(r)}),ew.createWithPreprocess=(e,t,r)=>new ew({schema:t,effect:{type:"preprocess",transform:e},typeName:th.ZodEffects,...T(r)});class eb extends E{_parse(e){return this._getType(e)===r.undefined?v(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eb.create=(e,t)=>new eb({innerType:e,typeName:th.ZodOptional,...T(t)});class e_ extends E{_parse(e){return this._getType(e)===r.null?v(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}e_.create=(e,t)=>new e_({innerType:e,typeName:th.ZodNullable,...T(t)});class ex extends E{_parse(e){let{ctx:t}=this._processInputParams(e),a=t.data;return t.parsedType===r.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ex.create=(e,t)=>new ex({innerType:e,typeName:th.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...T(t)});class eN extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _(a)?a.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}eN.create=(e,t)=>new eN({innerType:e,typeName:th.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...T(t)});class eT extends E{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}eT.create=e=>new eT({typeName:th.ZodNaN,...T(e)});let eE=Symbol("zod_brand");class eA extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class eS extends E{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),g(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new eS({in:e,out:t,typeName:th.ZodPipeline})}}class ek extends E{_parse(e){let t=this._def.innerType._parse(e),r=e=>(b(e)&&(e.value=Object.freeze(e.value)),e);return _(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function eO(e,t){let r="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof r?{message:r}:r}function eC(e,t={},r){return e?Y.create().superRefine((a,i)=>{let s=e(a);if(s instanceof Promise)return s.then(e=>{if(!e){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}});if(!s){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}}):Y.create()}ek.create=(e,t)=>new ek({innerType:e,typeName:th.ZodReadonly,...T(t)});let eI={object:ea.lazycreate};(td=th||(th={})).ZodString="ZodString",td.ZodNumber="ZodNumber",td.ZodNaN="ZodNaN",td.ZodBigInt="ZodBigInt",td.ZodBoolean="ZodBoolean",td.ZodDate="ZodDate",td.ZodSymbol="ZodSymbol",td.ZodUndefined="ZodUndefined",td.ZodNull="ZodNull",td.ZodAny="ZodAny",td.ZodUnknown="ZodUnknown",td.ZodNever="ZodNever",td.ZodVoid="ZodVoid",td.ZodArray="ZodArray",td.ZodObject="ZodObject",td.ZodUnion="ZodUnion",td.ZodDiscriminatedUnion="ZodDiscriminatedUnion",td.ZodIntersection="ZodIntersection",td.ZodTuple="ZodTuple",td.ZodRecord="ZodRecord",td.ZodMap="ZodMap",td.ZodSet="ZodSet",td.ZodFunction="ZodFunction",td.ZodLazy="ZodLazy",td.ZodLiteral="ZodLiteral",td.ZodEnum="ZodEnum",td.ZodEffects="ZodEffects",td.ZodNativeEnum="ZodNativeEnum",td.ZodOptional="ZodOptional",td.ZodNullable="ZodNullable",td.ZodDefault="ZodDefault",td.ZodCatch="ZodCatch",td.ZodPromise="ZodPromise",td.ZodBranded="ZodBranded",td.ZodPipeline="ZodPipeline",td.ZodReadonly="ZodReadonly";let eR=(e,t={message:`Input not instance of ${e.name}`})=>eC(t=>t instanceof e,t),eD=W.create,eP=$.create,ej=eT.create,eq=G.create,eL=H.create,eM=K.create,eF=J.create,eU=Z.create,eB=Q.create,eV=Y.create,ez=X.create,eW=ee.create,e$=et.create,eG=er.create,eH=ea.create,eK=ea.strictCreate,eJ=ei.create,eZ=en.create,eQ=eo.create,eY=ep.create,eX=ed.create,e1=el.create,e0=ec.create,e2=eu.create,e6=eh.create,e4=em.create,e3=eg.create,e9=ev.create,e5=ey.create,e8=ew.create,e7=eb.create,te=e_.create,tt=ew.createWithPreprocess,tr=eS.create,ta=()=>eD().optional(),ti=()=>eP().optional(),ts=()=>eL().optional(),tn={string:e=>W.create({...e,coerce:!0}),number:e=>$.create({...e,coerce:!0}),boolean:e=>H.create({...e,coerce:!0}),bigint:e=>G.create({...e,coerce:!0}),date:e=>K.create({...e,coerce:!0})};e.s(["BRAND",0,eE,"NEVER",0,f,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"instanceof",()=>eR,"intersection",()=>eQ,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"record",()=>eX,"set",()=>e0,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"void",()=>e$],73023),e.i(73023),e.i(21466),e.s(["BRAND",0,eE,"DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"NEVER",0,f,"OK",0,v,"ParseStatus",()=>m,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodError",()=>n,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodIssueCode",0,i,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodParsedType",0,r,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"addIssueToContext",()=>h,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"defaultErrorMap",0,o,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"getErrorMap",()=>l,"getParsedType",0,a,"instanceof",()=>eR,"intersection",()=>eQ,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"makeIssue",0,c,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"objectUtil",()=>tc,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"quotelessJson",0,s,"record",()=>eX,"set",()=>e0,"setErrorMap",()=>d,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"util",()=>tl,"void",()=>e$],59063);var to,tp,td,tl,tc,tu,th,tm=e.i(59063);e.s(["z",0,tm],16172)},96401,e=>{"use strict";var t=e.i(14747),r=e.i(16172);let a=r.z.enum(["local","postgres"]),i=r.z.enum(["local","gcs"]),s=r.z.object({serverPepper:r.z.string().min(1),standaloneMode:r.z.boolean().default(!1),storeTypes:r.z.object({global:a,log:a.optional(),app:a.optional(),blob:i}),paths:r.z.object({localStore:r.z.string().min(1),blobStore:r.z.string().min(1)}),gcs:r.z.object({bucketName:r.z.string().optional()})}),n={serverPepper:process.env.API_KEY_PEPPER||"default-pepper-change-in-production",standaloneMode:"false"!==process.env.AILOG_STANDALONE_MODE,storeTypes:{global:process.env.STORE_TYPE||"local",log:process.env.LOG_STORE_TYPE,app:process.env.APP_STORE_TYPE,blob:process.env.BLOB_STORE_TYPE||"local"},paths:{localStore:process.env.LOCAL_STORE_PATH||(0,t.resolve)(process.env.AILOG_WORK_DIR||process.cwd(),".ailog/data"),blobStore:process.env.BLOB_STORE_LOCAL_PATH||(0,t.resolve)(process.env.AILOG_WORK_DIR||process.cwd(),".ailog/blobs")},gcs:{bucketName:process.env.GCS_BUCKET_NAME}},o=s.parse(n),p={log:o.storeTypes.log??o.storeTypes.global,app:o.storeTypes.app??o.storeTypes.global,blob:o.storeTypes.blob};e.s(["config",0,o,"resolvedStoreTypes",0,p])},13558,e=>{"use strict";var t=e.i(30314),r=/^[\w!#$%&'*.^`|~+-]+$/,a=/^[ !#-:<-[\]-~]*$/,i=(e,i)=>{if(i&&-1===e.indexOf(i))return{};let s=e.trim().split(";"),n={};for(let e of s){let s=(e=e.trim()).indexOf("=");if(-1===s)continue;let o=e.substring(0,s).trim();if(i&&i!==o||!r.test(o))continue;let p=e.substring(s+1).trim();if(p.startsWith('"')&&p.endsWith('"')&&(p=p.slice(1,-1)),a.test(p)&&(n[o]=-1!==p.indexOf("%")?(0,t.tryDecode)(p,t.decodeURIComponent_):p,i))break}return n},s=e.i(80253),n=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,o=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,p=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;let d=function(e,t,r,a){let d;return d=async(i,s)=>{let n=i;if("header"===e&&"_def"in t||"header"===e&&"_zod"in t){let e=Object.fromEntries(Object.keys("in"in t?t.in.shape:t.shape).map(e=>[e.toLowerCase(),e]));n=Object.fromEntries(Object.entries(i).map(([t,r])=>[e[t]||t,r]))}let o=a&&a.validationFunction?await a.validationFunction(t,n):await t.safeParseAsync(n);if(r){let t=await r({data:n,...o,target:e},s);if(t){if(t instanceof Response)return t;if("response"in t)return t.response}}return o.success?o.data:s.json(o,400)},async(t,r)=>{let a={},l=t.req.header("Content-Type");switch(e){case"json":if(!l||!n.test(l))break;try{a=await t.req.json()}catch{throw new s.HTTPException(400,{message:"Malformed JSON in request body"})}break;case"form":{let e;if(!l||!(o.test(l)||p.test(l)))break;if(t.req.bodyCache.formData)e=await t.req.bodyCache.formData;else try{let r=await t.req.arrayBuffer();e=await new Response(r,{headers:{"Content-Type":l}}).formData(),t.req.bodyCache.formData=e}catch(t){let e="Malformed FormData request.";throw e+=t instanceof Error?` ${t.message}`:` ${String(t)}`,new s.HTTPException(400,{message:e})}let r={};e.forEach((e,t)=>{t.endsWith("[]")?(r[t]??=[]).push(e):Array.isArray(r[t])?r[t].push(e):t in r?r[t]=[r[t],e]:r[t]=e}),a=r;break}case"query":a=Object.fromEntries(Object.entries(t.req.queries()).map(([e,t])=>1===t.length?[e,t[0]]:[e,t]));break;case"param":a=t.req.param();break;case"header":a=t.req.header();break;case"cookie":a=((e,t,r)=>{let a=e.req.raw.headers.get("Cookie");if("string"==typeof t){if(!a)return;let e=t;return"secure"===r?e="__Secure-"+t:"host"===r&&(e="__Host-"+t),i(a,e)[e]}return a?i(a):{}})(t)}let c=await d(a,t);return c instanceof Response?c:(t.req.addValidatedData(e,c),await r())}};e.s(["zValidator",()=>d],13558)},84739,482,62212,79044,56967,6697,54199,6937,80864,90348,56900,22177,46220,40203,9581,83013,50430,72866,29986,27539,34939,2758,90640,46432,13424,82258,45393,86566,72515,21797,51014,67204,87799,e=>{"use strict";function t(e){return void 0===e||void 0===e}function r(e){return"string"==typeof e}function a(e){return"number"==typeof e}function i(e){return"boolean"==typeof e}function s(e){return null===e}function n(e){return e instanceof Date}function o(e){return"bigint"==typeof e}function p(e){return"function"==typeof e}function d(e){return"object"==typeof e&&null!==e}function l(e){return e[e.length-1]}function c(e){return Object.freeze(e)}function u(e){return h(e)?e:[e]}function h(e){return Array.isArray(e)}function m(e){return e}Object.prototype.toString,e.s(["asArray",()=>u,"freeze",()=>c,"getLast",()=>l,"isBigInt",()=>o,"isBoolean",()=>i,"isDate",()=>n,"isFunction",()=>p,"isNull",()=>s,"isNumber",()=>a,"isObject",()=>d,"isReadonlyArray",()=>h,"isString",()=>r,"isUndefined",()=>t,"noop",()=>m],84739);let f=c({is:e=>"IdentifierNode"===e.kind,create:e=>c({kind:"IdentifierNode",name:e})});e.s(["IdentifierNode",0,f],482);let g=c({is:e=>"SchemableIdentifierNode"===e.kind,create:e=>c({kind:"SchemableIdentifierNode",identifier:f.create(e)}),createWithSchema:(e,t)=>c({kind:"SchemableIdentifierNode",schema:f.create(e),identifier:f.create(t)})});e.s(["SchemableIdentifierNode",0,g],62212),e.s(["parseAliasedTable",()=>rt,"parseTable",()=>rr,"parseTableExpression",()=>re,"parseTableExpressionOrList",()=>t7],87799);let v=c({is:e=>"AliasNode"===e.kind,create:(e,t)=>c({kind:"AliasNode",node:e,alias:t})});e.s(["AliasNode",0,v],79044);let y=c({is:e=>"TableNode"===e.kind,create:e=>c({kind:"TableNode",table:g.create(e)}),createWithSchema:(e,t)=>c({kind:"TableNode",table:g.createWithSchema(e,t)})});function w(e){return d(e)&&p(e.toOperationNode)}e.s(["isExpressionOrFactory",()=>t8,"parseAliasedExpression",()=>t5,"parseExpression",()=>t9],67204),e.s(["isOperationNodeSource",()=>w],56967);let b=c({is:e=>"SelectModifierNode"===e.kind,create:(e,t)=>c({kind:"SelectModifierNode",modifier:e,of:t}),createWithExpression:e=>c({kind:"SelectModifierNode",rawModifier:e})}),_=c({is:e=>"AndNode"===e.kind,create:(e,t)=>c({kind:"AndNode",left:e,right:t})}),x=c({is:e=>"OrNode"===e.kind,create:(e,t)=>c({kind:"OrNode",left:e,right:t})}),N=c({is:e=>"OnNode"===e.kind,create:e=>c({kind:"OnNode",on:e}),cloneWithOperation:(e,t,r)=>c({...e,on:"And"===t?_.create(e.on,r):x.create(e.on,r)})}),T=c({is:e=>"JoinNode"===e.kind,create:(e,t)=>c({kind:"JoinNode",joinType:e,table:t,on:void 0}),createWithOn:(e,t,r)=>c({kind:"JoinNode",joinType:e,table:t,on:N.create(r)}),cloneWithOn:(e,t)=>c({...e,on:e.on?N.cloneWithOperation(e.on,"And",t):N.create(t)})});e.s(["parseFilterList",()=>ec,"parseFilterObject",()=>el,"parseReferentialBinaryOperation",()=>ed,"parseValueBinaryOperation",()=>ep,"parseValueBinaryOperationOrExpression",()=>eo],83013);let E=c({is:e=>"BinaryOperationNode"===e.kind,create:(e,t,r)=>c({kind:"BinaryOperationNode",leftOperand:e,operator:t,rightOperand:r})}),A=["->","->>"],S=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from","+","-","*","/","%","^","&","|","#","<<",">>","&&","||",...A,"not","-","exists","not exists","between","between symmetric"],k=c({is:e=>"OperatorNode"===e.kind,create:e=>c({kind:"OperatorNode",operator:e})});function O(e){return r(e)&&A.includes(e)}e.s(["OPERATORS",0,S,"OperatorNode",0,k,"isJSONOperator",()=>O],6697),e.s(["parseAliasedStringReference",()=>J,"parseColumnName",()=>Z,"parseJSONReference",()=>H,"parseOrderedColumnName",()=>Q,"parseReferenceExpression",()=>G,"parseReferenceExpressionOrList",()=>$,"parseSimpleReferenceExpression",()=>W,"parseStringReference",()=>K],56900);let C=c({is:e=>"ColumnNode"===e.kind,create:e=>c({kind:"ColumnNode",column:f.create(e)})});e.s(["ColumnNode",0,C],54199);let I=c({is:e=>"SelectAllNode"===e.kind,create:()=>c({kind:"SelectAllNode"})});e.s(["SelectAllNode",0,I],6937);let R=c({is:e=>"ReferenceNode"===e.kind,create:(e,t)=>c({kind:"ReferenceNode",table:t,column:e}),createSelectAll:e=>c({kind:"ReferenceNode",table:e,column:I.create()})});e.s(["DynamicReferenceBuilder",()=>D,"isDynamicReferenceBuilder",()=>P],80864);class D{#L;get dynamicReference(){return this.#L}get refType(){}constructor(e){this.#L=e}toOperationNode(){return W(this.#L)}}function P(e){return d(e)&&w(e)&&r(e.dynamicReference)}let j=c({is:e=>"OrderByItemNode"===e.kind,create:(e,t)=>c({kind:"OrderByItemNode",orderBy:e,direction:t})}),q=c({is:e=>"RawNode"===e.kind,create:(e,t)=>c({kind:"RawNode",sqlFragments:c(e),parameters:c(t)}),createWithSql:e=>q.create([e],[]),createWithChild:e=>q.create(["",""],[e]),createWithChildren:e=>q.create(Array(e.length+1).fill(""),e)});function L(e){return"asc"===e||"desc"===e}function M(e){if(2===e.length)return[F(e[0],e[1])];if(1===e.length){let[t]=e;return Array.isArray(t)?t.map(e=>F(e)):[F(t)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function F(e,t){let r=function(e){if(t8(e))return t9(e);if(P(e))return e.toOperationNode();let[t,r]=e.split(" ");if(r){if(!L(r))throw Error(`Invalid order by direction: ${r}`);return j.create(K(t),U(r))}return K(e)}(e);if(j.is(r)){if(t)throw Error("Cannot specify direction twice!");return r}return j.create(r,U(t))}function U(e){if(e)return"asc"===e||"desc"===e?q.createWithSql(e):e.toOperationNode()}e.s(["RawNode",0,q],90348);let B=c({is:e=>"JSONReferenceNode"===e.kind,create:(e,t)=>c({kind:"JSONReferenceNode",reference:e,traversal:t}),cloneWithTraversal:(e,t)=>c({...e,traversal:t})}),V=c({is:e=>"JSONOperatorChainNode"===e.kind,create:e=>c({kind:"JSONOperatorChainNode",operator:e,values:c([])}),cloneWithValue:(e,t)=>c({...e,values:c([...e.values,t])})}),z=c({is:e=>"JSONPathNode"===e.kind,create:e=>c({kind:"JSONPathNode",inOperator:e,pathLegs:c([])}),cloneWithLeg:(e,t)=>c({...e,pathLegs:c([...e.pathLegs,t])})});function W(e){return r(e)?K(e):e.toOperationNode()}function $(e){return h(e)?e.map(e=>G(e)):[G(e)]}function G(e){return t8(e)?t9(e):W(e)}function H(e,t){let r=K(e);if(O(t))return B.create(r,V.create(k.create(t)));let a=t.slice(0,-1);if(O(a))return B.create(r,z.create(k.create(a)));throw Error(`Invalid JSON operator: ${t}`)}function K(e){if(!e.includes("."))return R.create(C.create(e));let t=e.split(".").map(Y);if(3===t.length)return function(e){let[t,r,a]=e;return R.create(C.create(a),y.createWithSchema(t,r))}(t);if(2===t.length)return function(e){let[t,r]=e;return R.create(C.create(r),y.create(t))}(t);throw Error(`invalid column reference ${e}`)}function J(e){let t=" as ";if(!e.includes(t))return K(e);{let[r,a]=e.split(t).map(Y);return v.create(K(r),f.create(a))}}function Z(e){return C.create(e)}function Q(e){if(!e.includes(" "))return Z(e);{let[t,r]=e.split(" ").map(Y);if(!L(r))throw Error(`invalid order direction "${r}" next to "${t}"`);return M([t,r])[0]}}function Y(e){return e.trim()}e.s(["isSafeImmediateValue",()=>ei,"parseSafeImmediateValue",()=>es,"parseValueExpression",()=>ea,"parseValueExpressionOrList",()=>er],40203);let X=c({is:e=>"PrimitiveValueListNode"===e.kind,create:e=>c({kind:"PrimitiveValueListNode",values:c([...e])})}),ee=c({is:e=>"ValueListNode"===e.kind,create:e=>c({kind:"ValueListNode",values:c(e)})});e.s(["ValueListNode",0,ee],22177);let et=c({is:e=>"ValueNode"===e.kind,create:e=>c({kind:"ValueNode",value:e}),createImmediate:e=>c({kind:"ValueNode",value:e,immediate:!0})});function er(e){var t;return h(e)?(t=e).some(t8)?ee.create(t.map(e=>ea(e))):X.create(t):ea(e)}function ea(e){return t8(e)?t9(e):et.create(e)}function ei(e){return a(e)||i(e)||s(e)}function es(e){if(!ei(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return et.createImmediate(e)}e.s(["ValueNode",0,et],46220);let en=c({is:e=>"ParensNode"===e.kind,create:e=>c({kind:"ParensNode",node:e})});function eo(e){if(3===e.length)return ep(e[0],e[1],e[2]);if(1===e.length)return ea(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function ep(e,t,r){var a,n;return("is"===(a=t)||"is not"===a)&&(s(n=r)||i(n))?E.create(G(e),eu(t),et.createImmediate(r)):E.create(G(e),eu(t),er(r))}function ed(e,t,r){return E.create(G(e),eu(t),G(r))}function el(e,r){return ec(Object.entries(e).filter(([,e])=>!t(e)).map(([e,t])=>{var r;return ep(e,s(r=t)||i(r)?"is":"=",t)}),r)}function ec(e,t,r=!0){let a="and"===t?_.create:x.create;if(0===e.length)return E.create(et.createImmediate(1),k.create("="),et.createImmediate(+("and"===t)));let i=eh(e[0]);for(let t=1;t<e.length;++t)i=a(i,eh(e[t]));return e.length>1&&r?en.create(i):i}e.s(["ParensNode",0,en],9581);function eu(e){if(r(e)&&S.includes(e))return k.create(e);if(w(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function eh(e){return w(e)?e.toOperationNode():e}let em=c({is:e=>"OrderByNode"===e.kind,create:e=>c({kind:"OrderByNode",items:c([...e])}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ef=c({is:e=>"PartitionByNode"===e.kind,create:e=>c({kind:"PartitionByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),eg=c({is:e=>"OverNode"===e.kind,create:()=>c({kind:"OverNode"}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithPartitionByItems:(e,t)=>c({...e,partitionBy:e.partitionBy?ef.cloneWithItems(e.partitionBy,t):ef.create(t)})}),ev=c({is:e=>"FromNode"===e.kind,create:e=>c({kind:"FromNode",froms:c(e)}),cloneWithFroms:(e,t)=>c({...e,froms:c([...e.froms,...t])})}),ey=c({is:e=>"GroupByNode"===e.kind,create:e=>c({kind:"GroupByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ew=c({is:e=>"HavingNode"===e.kind,create:e=>c({kind:"HavingNode",having:e}),cloneWithOperation:(e,t,r)=>c({...e,having:"And"===t?_.create(e.having,r):x.create(e.having,r)})}),eb=c({is:e=>"SelectQueryNode"===e.kind,create:e=>c({kind:"SelectQueryNode",...e&&{with:e}}),createFrom:(e,t)=>c({kind:"SelectQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)}),cloneWithDistinctOn:(e,t)=>c({...e,distinctOn:e.distinctOn?c([...e.distinctOn,...t]):c(t)}),cloneWithFrontModifier:(e,t)=>c({...e,frontModifiers:e.frontModifiers?c([...e.frontModifiers,t]):c([t])}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithGroupByItems:(e,t)=>c({...e,groupBy:e.groupBy?ey.cloneWithItems(e.groupBy,t):ey.create(t)}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithOffset:(e,t)=>c({...e,offset:t}),cloneWithFetch:(e,t)=>c({...e,fetch:t}),cloneWithHaving:(e,t)=>c({...e,having:e.having?ew.cloneWithOperation(e.having,"And",t):ew.create(t)}),cloneWithSetOperations:(e,t)=>c({...e,setOperations:e.setOperations?c([...e.setOperations,...t]):c([...t])}),cloneWithoutSelections:e=>c({...e,selections:[]}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithoutOffset:e=>c({...e,offset:void 0}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithoutGroupBy:e=>c({...e,groupBy:void 0})});function e_(e,t){Object.defineProperties(e.prototype,{then:{enumerable:!1,value:()=>{throw Error(t)}}})}e.s(["preventAwait",()=>e_],50430);class ex{#M;constructor(e){this.#M=c(e)}on(...e){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,eo(e))})}onRef(e,t,r){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,ed(e,t,r))})}onTrue(){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,q.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#M.joinNode}}e_(ex,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");let eN=c({is:e=>"PartitionByItemNode"===e.kind,create:e=>c({kind:"PartitionByItemNode",partitionBy:e})});class eT{#M;constructor(e){this.#M=c(e)}orderBy(e,t){return new eT({overNode:eg.cloneWithOrderByItems(this.#M.overNode,M([e,t]))})}partitionBy(e){return new eT({overNode:eg.cloneWithPartitionByItems(this.#M.overNode,$(e).map(eN.create))})}$call(e){return e(this)}toOperationNode(){return this.#M.overNode}}e_(eT,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query."),e.s(["QueryCreator",()=>tA],82258);let eE=c({is:e=>"SelectionNode"===e.kind,create:e=>c({kind:"SelectionNode",selection:e}),createSelectAll:()=>c({kind:"SelectionNode",selection:I.create()}),createSelectAllFromTable:e=>c({kind:"SelectionNode",selection:R.createSelectAll(e)})});function eA(e){return p(e)?eA(e(t3())):h(e)?e.map(e=>eS(e)):[eS(e)]}function eS(e){return r(e)?eE.create(J(e)):P(e)?eE.create(e.toOperationNode()):eE.create(t5(e))}function ek(e){return e?Array.isArray(e)?e.map(eO):[eO(e)]:[eE.createSelectAll()]}function eO(e){if(r(e))return eE.createSelectAllFromTable(rr(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}let eC=c({is:e=>"ValuesNode"===e.kind,create:e=>c({kind:"ValuesNode",values:c(e)})}),eI=c({is:e=>"DefaultInsertValueNode"===e.kind,create:()=>c({kind:"DefaultInsertValueNode"})});function eR(e){var r;let a,i=p(e)?e(t3()):e;return a=function(e){let t=new Map;for(let r of e)for(let e of Object.keys(r))t.has(e)||void 0===r[e]||t.set(e,t.size);return t}(r=h(i)?i:c([i])),[c([...a.keys()].map(C.create)),eC.create(r.map(e=>(function(e,r){let a=Object.keys(e),i=Array.from({length:r.size}),s=!1,n=a.length;for(let o of a){let a=r.get(o);if(t(a)){n--;continue}let p=e[o];(t(p)||t8(p))&&(s=!0),i[a]=p}if(n<r.size||s){let e=eI.create();return ee.create(i.map(r=>t(r)?e:ea(r)))}return X.create(i)})(e,a)))]}let eD=c({is:e=>"InsertQueryNode"===e.kind,create:(e,t,r)=>c({kind:"InsertQueryNode",into:e,...t&&{with:t},replace:r}),createWithoutInto:()=>c({kind:"InsertQueryNode"}),cloneWith:(e,t)=>c({...e,...t})});e.s(["InsertQueryNode",0,eD],72866);let eP=c({is:e=>"UpdateQueryNode"===e.kind,create:(e,t)=>c({kind:"UpdateQueryNode",table:e,...t&&{with:t}}),createWithoutTable:()=>c({kind:"UpdateQueryNode"}),cloneWithFromItems:(e,t)=>c({...e,from:e.from?ev.cloneWithFroms(e.from,t):ev.create(t)}),cloneWithUpdates:(e,t)=>c({...e,updates:e.updates?c([...e.updates,...t]):t}),cloneWithLimit:(e,t)=>c({...e,limit:t})}),ej=c({is:e=>"UsingNode"===e.kind,create:e=>c({kind:"UsingNode",tables:c(e)}),cloneWithTables:(e,t)=>c({...e,tables:c([...e.tables,...t])})}),eq=c({is:e=>"DeleteQueryNode"===e.kind,create:(e,t)=>c({kind:"DeleteQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithUsing:(e,t)=>c({...e,using:void 0!==e.using?ej.cloneWithTables(e.using,t):ej.create(t)})}),eL=c({is:e=>"WhereNode"===e.kind,create:e=>c({kind:"WhereNode",where:e}),cloneWithOperation:(e,t,r)=>c({...e,where:"And"===t?_.create(e.where,r):x.create(e.where,r)})}),eM=c({is:e=>"ReturningNode"===e.kind,create:e=>c({kind:"ReturningNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),eF=c({is:e=>"ExplainNode"===e.kind,create:(e,t)=>c({kind:"ExplainNode",format:e,options:t})}),eU=c({is:e=>"WhenNode"===e.kind,create:e=>c({kind:"WhenNode",condition:e}),cloneWithResult:(e,t)=>c({...e,result:t})}),eB=c({is:e=>"MergeQueryNode"===e.kind,create:(e,t)=>c({kind:"MergeQueryNode",into:e,...t&&{with:t}}),cloneWithUsing:(e,t)=>c({...e,using:t}),cloneWithWhen:(e,t)=>c({...e,whens:e.whens?c([...e.whens,t]):c([t])}),cloneWithThen:(e,t)=>c({...e,whens:e.whens?c([...e.whens.slice(0,-1),eU.cloneWithResult(e.whens[e.whens.length-1],t)]):void 0})});e.s(["MergeQueryNode",0,eB],29986);let eV=c({is:e=>"OutputNode"===e.kind,create:e=>c({kind:"OutputNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),ez=c({is:e=>eb.is(e)||eD.is(e)||eP.is(e)||eq.is(e)||eB.is(e),cloneWithEndModifier:(e,t)=>c({...e,endModifiers:e.endModifiers?c([...e.endModifiers,t]):c([t])}),cloneWithWhere:(e,t)=>c({...e,where:e.where?eL.cloneWithOperation(e.where,"And",t):eL.create(t)}),cloneWithJoin:(e,t)=>c({...e,joins:e.joins?c([...e.joins,t]):c([t])}),cloneWithReturning:(e,t)=>c({...e,returning:e.returning?eM.cloneWithSelections(e.returning,t):eM.create(t)}),cloneWithoutReturning:e=>c({...e,returning:void 0}),cloneWithoutWhere:e=>c({...e,where:void 0}),cloneWithExplain:(e,t,r)=>c({...e,explain:eF.create(t,r?.toOperationNode())}),cloneWithTop:(e,t)=>c({...e,top:t}),cloneWithOutput:(e,t)=>c({...e,output:e.output?eV.cloneWithSelections(e.output,t):eV.create(t)})});e.s(["QueryNode",0,ez],27539);let eW=c({is:e=>"ColumnUpdateNode"===e.kind,create:(e,t)=>c({kind:"ColumnUpdateNode",column:e,value:t})});function e$(e){return Object.entries(p(e)?e(t3()):e).filter(([e,t])=>void 0!==t).map(([e,t])=>eW.create(C.create(e),ea(t)))}let eG=c({is:e=>"OnDuplicateKeyNode"===e.kind,create:e=>c({kind:"OnDuplicateKeyNode",updates:e})});class eH{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}}class eK extends Error{node;constructor(e){super("no result"),this.node=e}}function eJ(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}let eZ=c({is:e=>"OnConflictNode"===e.kind,create:()=>c({kind:"OnConflictNode"}),cloneWith:(e,t)=>c({...e,...t}),cloneWithIndexWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"And",t):eL.create(t)}),cloneWithIndexOrWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"Or",t):eL.create(t)}),cloneWithUpdateWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"And",t):eL.create(t)}),cloneWithUpdateOrWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"Or",t):eL.create(t)}),cloneWithoutIndexWhere:e=>c({...e,indexWhere:void 0}),cloneWithoutUpdateWhere:e=>c({...e,updateWhere:void 0})});class eQ{#M;constructor(e){this.#M=c(e)}column(e){let t=C.create(e);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,t]):c([t])})})}columns(e){let t=e.map(C.create);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,...t]):c(t)})})}constraint(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{constraint:f.create(e)})})}expression(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eQ({...this.#M,onConflictNode:eZ.cloneWithoutIndexWhere(this.#M.onConflictNode)})}doNothing(){return new eY({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new eX({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{updates:e$(e)})})}$call(e){return e(this)}}e_(eQ,"don't await OnConflictBuilder instances.");class eY{#M;constructor(e){this.#M=c(e)}toOperationNode(){return this.#M.onConflictNode}}e_(eY,"don't await OnConflictDoNothingBuilder instances.");class eX{#M;constructor(e){this.#M=c(e)}where(...e){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eX({...this.#M,onConflictNode:eZ.cloneWithoutUpdateWhere(this.#M.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#M.onConflictNode}}e_(eX,"don't await OnConflictUpdateBuilder instances.");let e1=c({is:e=>"TopNode"===e.kind,create:(e,t)=>c({kind:"TopNode",expression:e,modifiers:t})});function e0(e,r){var i;if(!a(e)&&!o(e))throw Error(`Invalid top expression: ${e}`);if(!t(r)&&"percent"!==(i=r)&&"with ties"!==i&&"percent with ties"!==i)throw Error(`Invalid top modifiers: ${r}`);return e1.create(e,r)}class e2{#M;constructor(e){this.#M=c(e)}values(e){let[t,r]=eR(e);return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:t,values:r})})}columns(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:c(e.map(C.create))})})}expression(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{values:t9(e)})})}defaultValues(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{defaultValues:!0})})}modifyEnd(e){return new e2({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}ignore(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{ignore:!0})})}top(e,t){return new e2({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}onConflict(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onConflict:e(new eQ({onConflictNode:eZ.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onDuplicateKey:eG.create(e$(e))})})}returning(e){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek())})}output(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e2({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e2({...this.#M})}$castTo(){return new e2(this.#M)}$narrowType(){return new e2(this.#M)}$assertType(){return new e2(this.#M)}withPlugin(e){return new e2({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new eH(t.insertId,t.numAffectedRows??t.numUpdatedOrDeletedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e2({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e2,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e6{numDeletedRows;constructor(e){this.numDeletedRows=e}}let e4=c({is:e=>"LimitNode"===e.kind,create:e=>c({kind:"LimitNode",limit:e})});class e3{#M;constructor(e){this.#M=c(e)}where(...e){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e3({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e3({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(e){return new e3({...this.#M,queryNode:eq.cloneWithUsing(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}returning(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e3({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}clearLimit(){return new e3({...this.#M,queryNode:eq.cloneWithoutLimit(this.#M.queryNode)})}clearOrderBy(){return new e3({...this.#M,queryNode:eq.cloneWithoutOrderBy(this.#M.queryNode)})}orderBy(e,t){return new e3({...this.#M,queryNode:eq.cloneWithOrderByItems(this.#M.queryNode,M([e,t]))})}limit(e){return new e3({...this.#M,queryNode:eq.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}modifyEnd(e){return new e3({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new e3({...this.#M})}$castTo(){return new e3(this.#M)}$narrowType(){return new e3(this.#M)}$assertType(){return new e3(this.#M)}withPlugin(e){return new e3({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e6(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e3({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e3,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e9{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}}class e5{#M;constructor(e){this.#M=c(e)}where(...e){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e5({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e5({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}from(e){return new e5({...this.#M,queryNode:eP.cloneWithFromItems(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}limit(e){return new e5({...this.#M,queryNode:eP.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}set(...e){return new e5({...this.#M,queryNode:eP.cloneWithUpdates(this.#M.queryNode,function(...e){return 2===e.length?[eW.create(G(e[0]),ea(e[1]))]:e$(e[0])}(...e))})}returning(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}modifyEnd(e){return new e5({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}clearReturning(){return new e5({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e5({...this.#M})}$castTo(){return new e5(this.#M)}$narrowType(){return new e5(this.#M)}$assertType(){return new e5(this.#M)}withPlugin(e){return new e5({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e9(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e5({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e5,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");let e8=c({is:e=>"CommonTableExpressionNameNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNameNode",table:y.create(e),columns:t?c(t.map(C.create)):void 0})}),e7=c({is:e=>"CommonTableExpressionNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNode",name:e,expression:t}),cloneWith:(e,t)=>c({...e,...t})});class te{#M;constructor(e){this.#M=c(e)}materialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!0})})}notMaterialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!1})})}toOperationNode(){return this.#M.node}}function tt(e,t){var r;let a=t(new tA({executor:tb})).toOperationNode();return p(e)?e((r=a,e=>new te({node:e7.create(tr(e),r)}))).toOperationNode():e7.create(tr(e),a)}function tr(e){if(!e.includes("("))return e8.create(e);{let t=e.split(/[\(\)]/),r=t[0],a=t[1].split(",").map(e=>e.trim());return e8.create(r,a)}}e_(te,"don't await CTEBuilder instances. They are never executed directly and are always just a part of a query.");let ta=c({is:e=>"WithNode"===e.kind,create:(e,t)=>c({kind:"WithNode",expressions:c([e]),...t}),cloneWithExpression:(e,t)=>c({...e,expressions:c([...e.expressions,t])})}),ti=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function ts(){return new tn}class tn{#F;get queryId(){return void 0===this.#F&&(this.#F=function(e){let t="";for(let e=0;e<8;++e)t+=ti[~~(Math.random()*ti.length)];return t}(0)),this.#F}}e.s(["createQueryId",()=>ts],34939);class to{nodeStack=[];#U=c({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)});transformNode(e){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e);return this.nodeStack.pop(),c(t)}transformNodeImpl(e){return this.#U[e.kind](e)}transformNodeList(e){return e?c(e.map(e=>this.transformNode(e))):e}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:c([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,orderBy:this.transformNode(e.orderBy),filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),endModifiers:this.transformNodeList(e.endModifiers),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}e.s(["OperationNodeTransformer",()=>to],2758);let tp=c({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),td={json_agg:!0,to_json:!0};class tl extends to{#B;#V=new Set;#z=new Set;constructor(e){super(),this.#B=e}transformNodeImpl(e){if(!this.#W(e))return super.transformNodeImpl(e);let t=this.#$(e);for(let e of t)this.#z.add(e);let r=this.#G(e);for(let e of r)this.#V.add(e);let a=super.transformNodeImpl(e);for(let e of r)this.#V.delete(e);for(let e of t)this.#z.delete(e);return a}transformSchemableIdentifier(e){let t=super.transformSchemableIdentifier(e);return t.schema||!this.#V.has(e.identifier.name)?t:{...t,schema:f.create(this.#B)}}transformReferences(e){let t=super.transformReferences(e);return t.table.table.schema?t:{...t,table:y.createWithSchema(this.#B,t.table.table.identifier.name)}}transformAggregateFunction(e){return{...super.transformAggregateFunction({...e,aggregated:[]}),aggregated:this.#H(e,"aggregated")}}transformFunction(e){return{...super.transformFunction({...e,arguments:[]}),arguments:this.#H(e,"arguments")}}#H(e,t){return td[e.func]?e[t].map(e=>!y.is(e)||e.table.schema?this.transformNode(e):{...e,table:this.transformIdentifier(e.table.identifier)}):this.transformNodeList(e[t])}#W(e){return e.kind in tp}#G(e){let t=new Set;if("name"in e&&e.name&&g.is(e.name)&&this.#K(e.name,t),"from"in e&&e.from)for(let r of e.from.froms)this.#J(r,t);if("into"in e&&e.into&&this.#J(e.into,t),"table"in e&&e.table&&this.#J(e.table,t),"joins"in e&&e.joins)for(let r of e.joins)this.#J(r.table,t);return"using"in e&&e.using&&this.#J(e.using,t),t}#$(e){let t=new Set;return"with"in e&&e.with&&this.#Z(e.with,t),t}#J(e,t){let r=y.is(e)?e:v.is(e)&&y.is(e.node)?e.node:null;r&&this.#K(r.table,t)}#K(e,t){let r=e.identifier.name;this.#V.has(r)||this.#z.has(r)||t.add(r)}#Z(e,t){for(let r of e.expressions){let e=r.name.table.table.identifier.name;this.#z.has(e)||t.add(e)}}}class tc{#Q;constructor(e){this.#Q=new tl(e)}transformQuery(e){return this.#Q.transformNode(e.node)}async transformResult(e){return e.result}}e.s(["WithSchemaPlugin",()=>tc],90640);let tu=c({is:e=>"MatchedNode"===e.kind,create:(e,t=!1)=>c({kind:"MatchedNode",not:e,bySource:t})});function th(e,t,r){return eU.create(ec([tu.create(!e.isMatched,e.bySource),...t&&t.length>0?[3===t.length&&r?ed(t[0],t[1],t[2]):eo(t)]:[]],"and",!1))}function tm(e){return r(e)?q.create([e],[]):w(e)?e.toOperationNode():e}class tf{#Y;#X;#ee;constructor(){this.#Y=new Promise((e,t)=>{this.#ee=t,this.#X=e})}get promise(){return this.#Y}resolve=e=>{this.#X&&this.#X(e)};reject=e=>{this.#ee&&this.#ee(e)}}let tg=new Set,tv=c([]);class ty{#et;constructor(e=tv){this.#et=e}get plugins(){return this.#et}transformQuery(e,t){for(let r of this.#et){let a=r.transformQuery({node:e,queryId:t});if(a.kind===e.kind)e=a;else throw Error(`KyselyPlugin.transformQuery must return a node of the same kind that was given to it. The plugin was given a ${e.kind} but it returned a ${a.kind}`)}return e}async executeQuery(e,t){return await this.provideConnection(async r=>{let a=await r.executeQuery(e),i=await this.#er(a,t);return function(e,t){let{numAffectedRows:r}=e;if((void 0!==r||void 0!==e.numUpdatedOrDeletedRows)&&(void 0===r||void 0===t.numAffectedRows)){var a;a="kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.",tg.has(a)||(tg.add(a),console.log(a))}}(a,i),i})}async *stream(e,t,r){let a=new tf,i=new tf;this.provideConnection(async e=>(a.resolve(e),await i.promise)).catch(e=>a.reject(e));let s=await a.promise;try{for await(let a of s.streamQuery(e,t))yield await this.#er(a,r)}finally{i.resolve()}}async #er(e,t){for(let r of this.#et)e=await r.transformResult({result:e,queryId:t});return e}}e.s(["QueryExecutorBase",()=>ty],46432);class tw extends ty{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new tw([...this.plugins,e])}withPlugins(e){return new tw([...this.plugins,...e])}withPluginAtFront(e){return new tw([e,...this.plugins])}withoutPlugins(){return new tw([])}}let tb=new tw;e.s(["NOOP_QUERY_EXECUTOR",0,tb],13424);class t_{numChangedRows;constructor(e){this.numChangedRows=e}}class tx{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tx({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tx({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(...e){return new tN({...this.#M,queryNode:eB.cloneWithUsing(this.#M.queryNode,tS("Using",e))})}output(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}}e_(tx,"don't await MergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tN{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tN({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tN({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}whenMatched(){return this.#ea([])}whenMatchedAnd(...e){return this.#ea(e)}whenMatchedAndRef(e,t,r){return this.#ea([e,t,r],!0)}#ea(e,t){return new tT({...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!0},e,t))})}whenNotMatched(){return this.#ei([])}whenNotMatchedAnd(...e){return this.#ei(e)}whenNotMatchedAndRef(e,t,r){return this.#ei([e,t,r],!0)}whenNotMatchedBySource(){return this.#ei([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#ei(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,r){return this.#ei([e,t,r],!0,!0)}output(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}#ei(e,t=!1,r=!1){let a={...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!1,bySource:r},e,t))};return new(r?tT:tE)(a)}$call(e){return e(this)}$if(e,t){return e?t(this):new tN({...this.#M})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId);return e.query.output&&this.#M.executor.adapter.supportsOutput?t.rows:[new t_(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}}e_(tN,"don't await WheneableMergeQueryBuilder instances directly. To execute the query you need to call `execute`.");class tT{#M;constructor(e){this.#M=c(e)}thenDelete(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("delete"))})}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenUpdate(e){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(e(new e5({queryId:this.#M.queryId,executor:tb,queryNode:eP.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}}e_(tT,"don't await MatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tE{#M;constructor(e){this.#M=c(e)}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenInsertValues(e){let[t,r]=eR(e);return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(eD.cloneWith(eD.createWithoutInto(),{columns:t,values:r})))})}}e_(tE,"don't await NotMatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tA{#M;constructor(e){this.#M=c(e)}selectFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.createFrom(t7(e),this.#M.withNode)})}selectNoFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.cloneWithSelections(eb.create(this.#M.withNode),eA(e))})}insertInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode)})}replaceInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode,!0)})}deleteFrom(e){return new e3({queryId:ts(),executor:this.#M.executor,queryNode:eq.create(t7(e),this.#M.withNode)})}updateTable(e){return new e5({queryId:ts(),executor:this.#M.executor,queryNode:eP.create(re(e),this.#M.withNode)})}mergeInto(e){return new tx({queryId:ts(),executor:this.#M.executor,queryNode:eB.create(rt(e),this.#M.withNode)})}with(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r)})}withRecursive(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r,{recursive:!0})})}withPlugin(e){return new tA({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new tA({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new tA({...this.#M,executor:this.#M.executor.withPluginAtFront(new tc(e))})}}function tS(e,t){if(3===t.length){var r,a,i,s;return r=e,a=t[0],i=t[1],s=t[2],T.createWithOn(r,re(a),ed(i,"=",s))}if(2===t.length)return function(e,t,r){return r(new ex({joinNode:T.create(e,re(t))})).toOperationNode()}(e,t[0],t[1]);throw Error("not implemented")}let tk=c({is:e=>"OffsetNode"===e.kind,create:e=>c({kind:"OffsetNode",offset:e})}),tO=c({is:e=>"GroupByItemNode"===e.kind,create:e=>c({kind:"GroupByItemNode",groupBy:e})}),tC=c({is:e=>"SetOperationNode"===e.kind,create:(e,t,r)=>c({kind:"SetOperationNode",operator:e,expression:t,all:r})});function tI(e,t,r){return p(t)&&(t=t(t3())),h(t)||(t=[t]),t.map(t=>tC.create(e,t9(t),r))}e.s(["SetOperationNode",0,tC],45393);class tR{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tR(this.#q)}$notNull(){return new tR(this.#q)}toOperationNode(){return this.#q}}class tD{#es;#en;constructor(e,t){this.#es=e,this.#en=t}get expression(){return this.#es}get alias(){return this.#en}toOperationNode(){return v.create(this.#es.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}class tP{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}$castTo(){return new tP(this.#q)}toOperationNode(){return en.create(this.#q)}}class tj{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tj(this.#q)}toOperationNode(){return en.create(this.#q)}}class tq{#M;constructor(e){this.#M=c(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}having(...e){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,eo(e))})}havingRef(e,t,r){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,ed(e,t,r))})}select(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,eA(e))})}distinctOn(e){return new tq({...this.#M,queryNode:eb.cloneWithDistinctOn(this.#M.queryNode,$(e))})}modifyFront(e){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}distinct(){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.create("Distinct"))})}forUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForUpdate",e?u(e).map(rr):void 0))})}forShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForShare",e?u(e).map(rr):void 0))})}forKeyShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForKeyShare",e?u(e).map(rr):void 0))})}forNoKeyUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForNoKeyUpdate",e?u(e).map(rr):void 0))})}skipLocked(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("SkipLocked"))})}noWait(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("NoWait"))})}selectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,ek(e))})}innerJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}innerJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralInnerJoin",e))})}leftJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralLeftJoin",e))})}orderBy(...e){return new tq({...this.#M,queryNode:eb.cloneWithOrderByItems(this.#M.queryNode,M(e))})}groupBy(e){var t;return new tq({...this.#M,queryNode:eb.cloneWithGroupByItems(this.#M.queryNode,$(t=p(t=e)?t(t3()):t).map(tO.create))})}limit(e){return new tq({...this.#M,queryNode:eb.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}offset(e){return new tq({...this.#M,queryNode:eb.cloneWithOffset(this.#M.queryNode,tk.create(ea(e)))})}fetch(e,t="only"){return new tq({...this.#M,queryNode:eb.cloneWithFetch(this.#M.queryNode,function(e,t){var r;let i,s;if(!a(e)&&!o(e))throw Error(`Invalid fetch row count: ${e}`);if("only"!==(r=t)&&"with ties"!==r)throw Error(`Invalid fetch modifier: ${t}`);return i=e,s=t,{kind:"FetchNode",rowCount:et.create(i),modifier:s}}(e,t))})}top(e,t){return new tq({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}union(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!1))})}unionAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!0))})}intersect(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!1))})}intersectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!0))})}except(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!1))})}exceptAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!0))})}as(e){return new tL(this,e)}clearSelect(){return new tq({...this.#M,queryNode:eb.cloneWithoutSelections(this.#M.queryNode)})}clearWhere(){return new tq({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}clearLimit(){return new tq({...this.#M,queryNode:eb.cloneWithoutLimit(this.#M.queryNode)})}clearOffset(){return new tq({...this.#M,queryNode:eb.cloneWithoutOffset(this.#M.queryNode)})}clearOrderBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutOrderBy(this.#M.queryNode)})}clearGroupBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutGroupBy(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new tq({...this.#M})}$castTo(){return new tq(this.#M)}$narrowType(){return new tq(this.#M)}$assertType(){return new tq(this.#M)}$asTuple(){return new tR(this.toOperationNode())}withPlugin(e){return new tq({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile();return(await this.#M.executor.executeQuery(e,this.#M.queryId)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new tq({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(tq,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class tL{#eo;#en;constructor(e,t){this.#eo=e,this.#en=t}get expression(){return this.#eo}get alias(){return this.#en}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return v.create(this.#eo.toOperationNode(),f.create(this.#en))}}e_(tL,"don't await AliasedSelectQueryBuilder instances directly. AliasedSelectQueryBuilder should never be executed directly since it's always a part of another query."),e.s(["createFunctionModule",()=>tV],86566);let tM=c({is:e=>"AggregateFunctionNode"===e.kind,create:(e,t=[])=>c({kind:"AggregateFunctionNode",func:e,aggregated:t}),cloneWithDistinct:e=>c({...e,distinct:!0}),cloneWithOrderBy:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"And",t):eL.create(t)}),cloneWithOrFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"Or",t):eL.create(t)}),cloneWithOver:(e,t)=>c({...e,over:t})}),tF=c({is:e=>"FunctionNode"===e.kind,create:(e,t)=>c({kind:"FunctionNode",func:e,arguments:t})});class tU{#M;constructor(e){this.#M=c(e)}get expressionType(){}as(e){return new tB(this,e)}distinct(){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithDistinct(this.#M.aggregateFunctionNode)})}orderBy(e,t){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOrderBy(this.#M.aggregateFunctionNode,M([e,t]))})}filterWhere(...e){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,eo(e))})}filterWhereRef(e,t,r){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,ed(e,t,r))})}over(e){let t=new eT({overNode:eg.create()});return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOver(this.#M.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new tU(this.#M)}$notNull(){return new tU(this.#M)}toOperationNode(){return this.#M.aggregateFunctionNode}}e_(tU,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class tB{#ep;#en;constructor(e,t){this.#ep=e,this.#en=t}get expression(){return this.#ep}get alias(){return this.#en}toOperationNode(){return v.create(this.#ep.toOperationNode(),f.create(this.#en))}}function tV(){let e=(e,t)=>new tR(tF.create(e,$(t??[]))),t=(e,t)=>new tU({aggregateFunctionNode:tM.create(e,t?$(t):void 0)});return Object.assign(e,{agg:t,avg:e=>t("avg",[e]),coalesce:(...t)=>e("coalesce",t),count:e=>t("count",[e]),countAll:e=>new tU({aggregateFunctionNode:tM.create("count",ek(e))}),max:e=>t("max",[e]),min:e=>t("min",[e]),sum:e=>t("sum",[e]),any:t=>e("any",[t]),jsonAgg:e=>new tU({aggregateFunctionNode:tM.create("json_agg",[r(e)?rr(e):e.toOperationNode()])}),toJson:e=>new tR(tF.create("to_json",[r(e)?rr(e):e.toOperationNode()]))})}let tz=c({is:e=>"UnaryOperationNode"===e.kind,create:(e,t)=>c({kind:"UnaryOperationNode",operator:e,operand:t})});e.s(["CaseBuilder",()=>t$],21797);let tW=c({is:e=>"CaseNode"===e.kind,create:e=>c({kind:"CaseNode",value:e}),cloneWithWhen:(e,t)=>c({...e,when:c(e.when?[...e.when,t]:[t])}),cloneWithThen:(e,t)=>c({...e,when:e.when?c([...e.when.slice(0,-1),eU.cloneWithResult(e.when[e.when.length-1],t)]):void 0}),cloneWith:(e,t)=>c({...e,...t})});e.s(["CaseNode",0,tW],72515);class t${#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}}class tG{#M;constructor(e){this.#M=c(e)}then(e){return new tH({...this.#M,node:tW.cloneWithThen(this.#M.node,ei(e)?es(e):ea(e))})}}class tH{#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}else(e){return new tK({...this.#M,node:tW.cloneWith(this.#M.node,{else:ei(e)?es(e):ea(e)})})}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}class tK{#M;constructor(e){this.#M=c(e)}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}let tJ=c({is:e=>"JSONPathLegNode"===e.kind,create:(e,t)=>c({kind:"JSONPathLegNode",type:e,value:t})});class tZ{#q;constructor(e){this.#q=e}at(e){return this.#ed("ArrayLocation",e)}key(e){return this.#ed("Member",e)}#ed(e,t){return new tQ(B.is(this.#q)?B.cloneWithTraversal(this.#q,z.is(this.#q.traversal)?z.cloneWithLeg(this.#q.traversal,tJ.create(e,t)):V.cloneWithValue(this.#q.traversal,et.createImmediate(t))):z.cloneWithLeg(this.#q,tJ.create(e,t)))}}class tQ extends tZ{#q;constructor(e){super(e),this.#q=e}get expressionType(){}as(e){return new tY(this,e)}$castTo(){return new tQ(this.#q)}$notNull(){return new tQ(this.#q)}toOperationNode(){return this.#q}}class tY{#el;#en;constructor(e,t){this.#el=e,this.#en=t}get expression(){return this.#el}get alias(){return this.#en}toOperationNode(){return v.create(this.#el.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}let tX=c({is:e=>"TupleNode"===e.kind,create:e=>c({kind:"TupleNode",values:c(e)})}),t1=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],t0=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],t2=c({is:e=>"DataTypeNode"===e.kind,create:e=>c({kind:"DataTypeNode",dataType:e})});function t6(e){if(w(e))return e.toOperationNode();if(t1.includes(e)||t0.some(t=>t.test(e)))return t2.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}e.s(["parseDataTypeExpression",()=>t6],51014);let t4=c({is:e=>"CastNode"===e.kind,create:(e,t)=>c({kind:"CastNode",expression:e,dataType:t})});function t3(e=tb){function r(e,t){return new tR(tz.create(k.create(e),G(t)))}let a=Object.assign(function(e,t,r){return new tR(ep(e,t,r))},{fn:void 0,eb:void 0,selectFrom:t=>new tq({queryId:ts(),executor:e,queryNode:eb.createFrom(t7(t))}),case:e=>new t$({node:tW.create(t(e)?void 0:G(e))}),ref:(e,r)=>t(r)?new tR(K(e)):new tZ(H(e,r)),jsonPath:()=>new tZ(z.create()),table:e=>new tR(rr(e)),val:e=>new tR(ea(e)),refTuple:(...e)=>new tR(tX.create(e.map(G))),tuple:(...e)=>new tR(tX.create(e.map(ea))),lit:e=>new tR(es(e)),unary:r,not:e=>r("not",e),exists:e=>r("exists",e),neg:e=>r("-",e),between:(e,t,r)=>new tR(E.create(G(e),k.create("between"),_.create(ea(t),ea(r)))),betweenSymmetric:(e,t,r)=>new tR(E.create(G(e),k.create("between symmetric"),_.create(ea(t),ea(r)))),and:e=>new tR(h(e)?ec(e,"and"):el(e,"and")),or:e=>new tR(h(e)?ec(e,"or"):el(e,"or")),parens(...e){let t=eo(e);return new tR(en.is(t)?t:en.create(t))},cast:(e,t)=>new tR(t4.create(G(e),t6(t))),withSchema:t=>t3(e.withPluginAtFront(new tc(t)))});return a.fn=tV(),a.eb=a,a}function t9(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function t5(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function t8(e){return d(e)&&"expressionType"in e&&w(e)||d(e)&&"expression"in e&&r(e.alias)&&w(e)||p(e)}function t7(e){return h(e)?e.map(e=>re(e)):[re(e)]}function re(e){return r(e)?rt(e):t5(e)}function rt(e){let t=" as ";if(!e.includes(t))return rr(e);{let[r,a]=e.split(t).map(ra);return v.create(rr(r),f.create(a))}}function rr(e){if(!e.includes("."))return y.create(e);{let[t,r]=e.split(".").map(ra);return y.createWithSchema(t,r)}}function ra(e){return e.trim()}},58666,3888,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"CreateTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTableNode",table:e,columns:(0,t.freeze)([])}),cloneWithColumn:(e,r)=>(0,t.freeze)({...e,columns:(0,t.freeze)([...e.columns,r])}),cloneWithConstraint:(e,r)=>(0,t.freeze)({...e,constraints:e.constraints?(0,t.freeze)([...e.constraints,r]):(0,t.freeze)([r])}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):(0,t.freeze)([r])}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):(0,t.freeze)([r])}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateTableNode",0,r,"ON_COMMIT_ACTIONS",0,["preserve rows","delete rows","drop"]],58666);var a=e.i(62212);let i=(0,t.freeze)({is:e=>"CreateViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateViewNode",name:a.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateViewNode",0,i],3888)},24659,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"AlterTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"AlterTableNode",table:e}),cloneWithTableProps:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumnAlteration:(e,r)=>(0,t.freeze)({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,r]:[r]})});var a=e.i(482);let i=(0,t.freeze)({is:e=>"CreateIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})}),s=(0,t.freeze)({is:e=>"CreateSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CreateSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var n=e.i(58666),o=e.i(62212);let p=(0,t.freeze)({is:e=>"DropIndexNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropIndexNode",name:o.SchemableIdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),d=(0,t.freeze)({is:e=>"DropSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),l=(0,t.freeze)({is:e=>"DropTableNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropTableNode",table:e,...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var c=e.i(87799);let u=(0,t.freeze)({is:e=>"AddColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddColumnNode",column:e})});var h=e.i(54199);let m=(0,t.freeze)({is:e=>"ColumnDefinitionNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ColumnDefinitionNode",column:h.ColumnNode.create(e),dataType:r}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):[r]}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):[r]}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),f=(0,t.freeze)({is:e=>"DropColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropColumnNode",column:h.ColumnNode.create(e)})}),g=(0,t.freeze)({is:e=>"RenameColumnNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"RenameColumnNode",column:h.ColumnNode.create(e),renameTo:h.ColumnNode.create(r)})});var v=e.i(50430);let y=(0,t.freeze)({is:e=>"CheckConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CheckConstraintNode",expression:e,name:r?a.IdentifierNode.create(r):void 0})}),w=["no action","restrict","cascade","set null","set default"],b=(0,t.freeze)({is:e=>"ReferencesNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ReferencesNode",table:e,columns:(0,t.freeze)([...r])}),cloneWithOnDelete:(e,r)=>(0,t.freeze)({...e,onDelete:r}),cloneWithOnUpdate:(e,r)=>(0,t.freeze)({...e,onUpdate:r})});var _=e.i(6937),x=e.i(56900),N=e.i(56967),T=e.i(46220);function E(e){return(0,N.isOperationNodeSource)(e)?e.toOperationNode():T.ValueNode.createImmediate(e)}let A=(0,t.freeze)({is:e=>"GeneratedNode"===e.kind,create:e=>(0,t.freeze)({kind:"GeneratedNode",...e}),createWithExpression:e=>(0,t.freeze)({kind:"GeneratedNode",always:!0,expression:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),S=(0,t.freeze)({is:e=>"DefaultValueNode"===e.kind,create:e=>(0,t.freeze)({kind:"DefaultValueNode",defaultValue:e})});function k(e){if(w.includes(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}class O{#q;constructor(e){this.#q=e}autoIncrement(){return new O(m.cloneWith(this.#q,{autoIncrement:!0}))}identity(){return new O(m.cloneWith(this.#q,{identity:!0}))}primaryKey(){return new O(m.cloneWith(this.#q,{primaryKey:!0}))}references(e){let t=(0,x.parseStringReference)(e);if(!t.table||_.SelectAllNode.is(t.column))throw Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new O(m.cloneWith(this.#q,{references:b.create(t.table,[t.column])}))}onDelete(e){if(!this.#q.references)throw Error("on delete constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnDelete(this.#q.references,k(e))}))}onUpdate(e){if(!this.#q.references)throw Error("on update constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnUpdate(this.#q.references,k(e))}))}unique(){return new O(m.cloneWith(this.#q,{unique:!0}))}notNull(){return new O(m.cloneWith(this.#q,{notNull:!0}))}unsigned(){return new O(m.cloneWith(this.#q,{unsigned:!0}))}defaultTo(e){return new O(m.cloneWith(this.#q,{defaultTo:S.create(E(e))}))}check(e){return new O(m.cloneWith(this.#q,{check:y.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new O(m.cloneWith(this.#q,{generated:A.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#q.generated)throw Error("stored() can only be called after generatedAlwaysAs");return new O(m.cloneWith(this.#q,{generated:A.cloneWith(this.#q.generated,{stored:!0})}))}modifyFront(e){return new O(m.cloneWithFrontModifier(this.#q,e.toOperationNode()))}nullsNotDistinct(){return new O(m.cloneWith(this.#q,{nullsNotDistinct:!0}))}ifNotExists(){return new O(m.cloneWith(this.#q,{ifNotExists:!0}))}modifyEnd(e){return new O(m.cloneWithEndModifier(this.#q,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(O,"don't await ColumnDefinitionBuilder instances directly.");let C=(0,t.freeze)({is:e=>"ModifyColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"ModifyColumnNode",column:e})});var I=e.i(51014);let R=(0,t.freeze)({is:e=>"ForeignKeyConstraintNode"===e.kind,create:(e,r,i,s)=>(0,t.freeze)({kind:"ForeignKeyConstraintNode",columns:e,references:b.create(r,i),name:s?a.IdentifierNode.create(s):void 0}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class D{#q;constructor(e){this.#q=e}onDelete(e){return new D(R.cloneWith(this.#q,{onDelete:k(e)}))}onUpdate(e){return new D(R.cloneWith(this.#q,{onUpdate:k(e)}))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(D,"don't await ForeignKeyConstraintBuilder instances directly.");let P=(0,t.freeze)({is:e=>"AddConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddConstraintNode",constraint:e})}),j=(0,t.freeze)({is:e=>"UniqueConstraintNode"===e.kind,create:(e,r,i)=>(0,t.freeze)({kind:"UniqueConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0,nullsNotDistinct:i}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),q=(0,t.freeze)({is:e=>"DropConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropConstraintNode",constraintName:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),L=(0,t.freeze)({is:e=>"AlterColumnNode"===e.kind,create:(e,r,a)=>(0,t.freeze)({kind:"AlterColumnNode",column:h.ColumnNode.create(e),[r]:a})});class M{#ec;constructor(e){this.#ec=e}setDataType(e){return new F(L.create(this.#ec,"dataType",(0,I.parseDataTypeExpression)(e)))}setDefault(e){return new F(L.create(this.#ec,"setDefault",E(e)))}dropDefault(){return new F(L.create(this.#ec,"dropDefault",!0))}setNotNull(){return new F(L.create(this.#ec,"setNotNull",!0))}dropNotNull(){return new F(L.create(this.#ec,"dropNotNull",!0))}$call(e){return e(this)}}(0,v.preventAwait)(M,"don't await AlterColumnBuilder instances");class F{#eu;constructor(e){this.#eu=e}toOperationNode(){return this.#eu}}(0,v.preventAwait)(F,"don't await AlteredColumnBuilder instances");class U{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(U,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");class B{#M;constructor(e){this.#M=(0,t.freeze)(e)}onDelete(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onDelete(e)})}onUpdate(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(this.#M.constraintBuilder.toOperationNode())}),this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(B,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");class V{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{ifExists:!0})})})}cascade(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(V,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");let z=(0,t.freeze)({is:e=>"PrimaryKeyConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"PrimaryKeyConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0})}),W=(0,t.freeze)({is:e=>"AddIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})});var $=e.i(90348);class G{#M;constructor(e){this.#M=(0,t.freeze)(e)}unique(){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{unique:!0})})})}column(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[(0,x.parseOrderedColumnName)(e)])})})}columns(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,e.map(x.parseOrderedColumnName))})})}expression(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[e.toOperationNode()])})})}using(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{using:$.RawNode.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(G,"don't await AlterTableAddIndexBuilder instances directly. To execute the query you need to call `execute`");class H{#q;constructor(e){this.#q=e}toOperationNode(){return this.#q}nullsNotDistinct(){return new H(j.cloneWith(this.#q,{nullsNotDistinct:!0}))}}(0,v.preventAwait)(H,"don't await UniqueConstraintNodeBuilder instances directly.");class K{#M;constructor(e){this.#M=(0,t.freeze)(e)}renameTo(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{renameTo:(0,c.parseTable)(e)})})}setSchema(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{setSchema:a.IdentifierNode.create(e)})})}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}addUniqueConstraint(e,a,i=t.noop){let s=i(new H(j.create(a,e)));return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(s.toOperationNode())})})}addCheckConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(y.create(t.toOperationNode(),e))})})}addForeignKeyConstraint(e,t,r,a){return new B({...this.#M,constraintBuilder:new D(R.create(t.map(h.ColumnNode.create),(0,c.parseTable)(r),a.map(h.ColumnNode.create),e))})}addPrimaryKeyConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(z.create(t,e))})})}dropConstraint(e){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.create(e)})})}addIndex(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.create(e)})})}dropIndex(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropIndex:p.create(e)})})}$call(e){return e(this)}}(0,v.preventAwait)(K,"don't await AlterTableBuilder instances");class J{#M;constructor(e){this.#M=(0,t.freeze)(e)}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(J,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");var Z=e.i(83013),Q=e.i(27539),Y=e.i(2758);class X extends Y.OperationNodeTransformer{transformValue(e){return{...super.transformValue(e),immediate:!0}}}class ee{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{ifNotExists:!0})})}unique(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{unique:!0})})}nullsNotDistinct(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{nullsNotDistinct:!0})})}on(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}column(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[(0,x.parseOrderedColumnName)(e)])})}columns(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,e.map(x.parseOrderedColumnName))})}expression(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[e.toOperationNode()])})}using(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{using:$.RawNode.createWithSql(e)})})}where(...e){let t=new X;return new ee({...this.#M,node:Q.QueryNode.cloneWithWhere(this.#M.node,t.transformNode((0,Z.parseValueBinaryOperationOrExpression)(e)))})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ee,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");class et{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new et({...this.#M,node:s.cloneWith(this.#M.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(et,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");var er=e.i(67204);class ea{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{temporary:!0})})}onCommit(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{onCommit:function(e){if(n.ON_COMMIT_ACTIONS.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}(e)})})}ifNotExists(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{ifNotExists:!0})})}addColumn(e,r,a=t.noop){let i=a(new O(m.create(e,(0,I.parseDataTypeExpression)(r))));return new ea({...this.#M,node:n.CreateTableNode.cloneWithColumn(this.#M.node,i.toOperationNode())})}addPrimaryKeyConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,z.create(t,e))})}addUniqueConstraint(e,r,a=t.noop){let i=a(new H(j.create(r,e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,i.toOperationNode())})}addCheckConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,y.create(t.toOperationNode(),e))})}addForeignKeyConstraint(e,r,a,i,s=t.noop){let o=s(new D(R.create(r.map(h.ColumnNode.create),(0,c.parseTable)(a),i.map(h.ColumnNode.create),e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,o.toOperationNode())})}modifyFront(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithFrontModifier(this.#M.node,e.toOperationNode())})}modifyEnd(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithEndModifier(this.#M.node,e.toOperationNode())})}as(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{selectQuery:(0,er.parseExpression)(e)})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ea,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");class ei{#M;constructor(e){this.#M=(0,t.freeze)(e)}on(e){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}ifExists(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ei,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");class es{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(es,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");class en{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(en,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");var eo=e.i(34939),ep=e.i(90640),ed=e.i(3888);class el{#Q=new X;transformQuery(e){return this.#Q.transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}class ec{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{temporary:!0})})}materialized(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{materialized:!0})})}ifNotExists(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{ifNotExists:!0})})}orReplace(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{orReplace:!0})})}columns(e){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{columns:e.map(x.parseColumnName)})})}as(e){let t=e.withPlugin(new el).toOperationNode();return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ec,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");let eu=(0,t.freeze)({is:e=>"DropViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropViewNode",name:o.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class eh{#M;constructor(e){this.#M=(0,t.freeze)(e)}materialized(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{materialized:!0})})}ifExists(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eh,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");var em=e.i(22177);let ef=(0,t.freeze)({is:e=>"CreateTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTypeNode",name:e}),cloneWithEnum:(e,r)=>(0,t.freeze)({...e,enum:em.ValueListNode.create(r.map(e=>T.ValueNode.createImmediate(e)))})});class eg{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}asEnum(e){return new eg({...this.#M,node:ef.cloneWithEnum(this.#M.node,e)})}$call(e){return e(this)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eg,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");let ev=(0,t.freeze)({is:e=>"DropTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropTypeNode",name:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class ey{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new ey({...this.#M,node:ev.cloneWith(this.#M.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}function ew(e){if(!e.includes("."))return o.SchemableIdentifierNode.create(e);{let t=e.split(".").map(eb);if(2===t.length)return o.SchemableIdentifierNode.createWithSchema(t[0],t[1]);throw Error(`invalid schemable identifier ${e}`)}}function eb(e){return e.trim()}(0,v.preventAwait)(ey,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");class e_{#eh;constructor(e){this.#eh=e}createTable(e){return new ea({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:n.CreateTableNode.create((0,c.parseTable)(e))})}dropTable(e){return new en({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:l.create((0,c.parseTable)(e))})}createIndex(e){return new ee({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:i.create(e)})}dropIndex(e){return new ei({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:p.create(e)})}createSchema(e){return new et({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:s.create(e)})}dropSchema(e){return new es({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:d.create(e)})}alterTable(e){return new K({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:r.create((0,c.parseTable)(e))})}createView(e){return new ec({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ed.CreateViewNode.create(e)})}dropView(e){return new eh({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:eu.create(e)})}createType(e){return new eg({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ef.create(ew(e))})}dropType(e){return new ey({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ev.create(ew(e))})}withPlugin(e){return new e_(this.#eh.withPlugin(e))}withoutPlugins(){return new e_(this.#eh.withoutPlugins())}withSchema(e){return new e_(this.#eh.withPluginAtFront(new ep.WithSchemaPlugin(e)))}}var ex=e.i(80864);class eN{ref(e){return new ex.DynamicReferenceBuilder(e)}}class eT{#em;constructor(e){this.#em=e}async provideConnection(e){let t=await this.#em.acquireConnection();try{return await e(t)}finally{await this.#em.releaseConnection(t)}}}var eE=e.i(82258),eA=e.i(46432);class eS extends eA.QueryExecutorBase{#ef;#eg;#ev;constructor(e,t,r,a=[]){super(a),this.#ef=e,this.#eg=t,this.#ev=r}get adapter(){return this.#eg}compileQuery(e){return this.#ef.compileQuery(e)}provideConnection(e){return this.#ev.provideConnection(e)}withPlugins(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,...e])}withPlugin(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,e])}withPluginAtFront(e){return new eS(this.#ef,this.#eg,this.#ev,[e,...this.plugins])}withConnectionProvider(e){return new eS(this.#ef,this.#eg,e,[...this.plugins])}withoutPlugins(){return new eS(this.#ef,this.#eg,this.#ev,[])}}function ek(){return"undefined"!=typeof performance&&(0,t.isFunction)(performance.now)?performance.now():Date.now()}class eO{#em;#ey;#ew;#eb;#e_;#ex=new WeakSet;constructor(e,t){this.#eb=!1,this.#em=e,this.#ey=t}async init(){if(this.#e_)throw Error("driver has already been destroyed");this.#ew||(this.#ew=this.#em.init().then(()=>{this.#eb=!0}).catch(e=>(this.#ew=void 0,Promise.reject(e)))),await this.#ew}async acquireConnection(){if(this.#e_)throw Error("driver has already been destroyed");this.#eb||await this.init();let e=await this.#em.acquireConnection();return this.#ex.has(e)||(this.#eN()&&this.#eT(e),this.#ex.add(e)),e}async releaseConnection(e){await this.#em.releaseConnection(e)}beginTransaction(e,t){return this.#em.beginTransaction(e,t)}commitTransaction(e){return this.#em.commitTransaction(e)}rollbackTransaction(e){return this.#em.rollbackTransaction(e)}async destroy(){this.#ew&&(await this.#ew,this.#e_||(this.#e_=this.#em.destroy().catch(e=>(this.#e_=void 0,Promise.reject(e)))),await this.#e_)}#eN(){return this.#ey.isLevelEnabled("query")||this.#ey.isLevelEnabled("error")}#eT(e){let t=e.executeQuery;e.executeQuery=async r=>{let a,i=ek();try{return await t.call(e,r)}catch(e){throw a=e,await this.#eE(e,r,i),e}finally{a||await this.#eA(r,i)}}}async #eE(e,t,r){await this.#ey.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#eS(r)}))}async #eA(e,t){await this.#ey.query(()=>({level:"query",query:e,queryDurationMillis:this.#eS(t)}))}#eS(e){return ek()-e}}let eC=()=>{};class eI{#ek;#eO;constructor(e){this.#ek=e}async provideConnection(e){for(;this.#eO;)await this.#eO.catch(eC);return this.#eO=this.#eC(e).finally(()=>{this.#eO=void 0}),this.#eO}async #eC(e){return await e(this.#ek)}}let eR=["read uncommitted","read committed","repeatable read","serializable","snapshot"];var eD=e.i(86566);(0,t.freeze)(["query","error"]);class eP{#eI;#eR;constructor(e){(0,t.isFunction)(e)?(this.#eR=e,this.#eI=(0,t.freeze)({query:!0,error:!0})):(this.#eR=ej,this.#eI=(0,t.freeze)({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#eI[e]}async query(e){this.#eI.query&&await this.#eR(e())}async error(e){this.#eI.error&&await this.#eR(e())}}function ej(e){"query"===e.level?(console.log(`kysely:query: ${e.query.sql}`),console.log(`kysely:query: duration: ${e.queryDurationMillis.toFixed(1)}ms`)):"error"===e.level&&(e.error instanceof Error?console.error(`kysely:error: ${e.error.stack??e.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`))}var eq=e.i(21797),eL=e.i(72515);class eM extends eE.QueryCreator{#M;constructor(e){let r,a;if(function(e){return(0,t.isObject)(e)&&(0,t.isObject)(e.config)&&(0,t.isObject)(e.driver)&&(0,t.isObject)(e.executor)&&(0,t.isObject)(e.dialect)}(e))r={executor:e.executor},a={...e};else{const t=e.dialect,i=t.createDriver(),s=t.createQueryCompiler(),n=t.createAdapter(),o=new eO(i,new eP(e.log??[])),p=new eS(s,n,new eT(o),e.plugins??[]);r={executor:p},a={config:e,executor:p,dialect:t,driver:o}}super(r),this.#M=(0,t.freeze)(a)}get schema(){return new e_(this.#M.executor)}get dynamic(){return new eN}get introspection(){return this.#M.dialect.createIntrospector(this.withoutPlugins())}case(e){return new eq.CaseBuilder({node:eL.CaseNode.create((0,t.isUndefined)(e)?void 0:(0,er.parseExpression)(e))})}get fn(){return(0,eD.createFunctionModule)()}transaction(){return new eB({...this.#M})}connection(){return new eU({...this.#M})}withPlugin(e){return new eM({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eM({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eM({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eM({...this.#M})}async destroy(){await this.#M.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#M.executor}executeQuery(e,r=(0,eo.createQueryId)()){let a=(0,t.isObject)(e)&&(0,t.isFunction)(e.compile)?e.compile():e;return this.getExecutor().executeQuery(a,r)}}class eF extends eM{#M;constructor(e){super(e),this.#M=e}get isTransaction(){return!0}transaction(){throw Error("calling the transaction method for a Transaction is not supported")}connection(){throw Error("calling the connection method for a Transaction is not supported")}async destroy(){throw Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new eF({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eF({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eF({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eF({...this.#M})}}class eU{#M;constructor(e){this.#M=(0,t.freeze)(e)}async execute(e){return this.#M.executor.provideConnection(async t=>{let r=this.#M.executor.withConnectionProvider(new eI(t)),a=new eM({...this.#M,executor:r});return await e(a)})}}(0,v.preventAwait)(eU,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");class eB{#M;constructor(e){this.#M=(0,t.freeze)(e)}setIsolationLevel(e){return new eB({...this.#M,isolationLevel:e})}async execute(e){let{isolationLevel:t,...r}=this.#M,a={isolationLevel:t};return function(e){if(e.isolationLevel&&!eR.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}(a),this.#M.executor.provideConnection(async t=>{let i=this.#M.executor.withConnectionProvider(new eI(t)),s=new eF({...r,executor:i});try{await this.#M.driver.beginTransaction(t,a);let r=await e(s);return await this.#M.driver.commitTransaction(t),r}catch(e){throw await this.#M.driver.rollbackTransaction(t),e}})}}(0,v.preventAwait)(eB,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method"),e.s(["Kysely",()=>eM],24659)},12995,e=>{"use strict";var t=e.i(482),r=e.i(56967),a=e.i(90348),i=e.i(46220),s=e.i(56900),n=e.i(87799),o=e.i(40203),p=e.i(34939),d=e.i(79044),l=e.i(50430),c=e.i(84739),u=e.i(13424);class h{#M;constructor(e){this.#M=(0,c.freeze)(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new f(this,e)}$castTo(){return new h({...this.#M})}$notNull(){return new h(this.#M)}withPlugin(e){return new h({...this.#M,plugins:void 0!==this.#M.plugins?(0,c.freeze)([...this.#M.plugins,e]):(0,c.freeze)([e])})}toOperationNode(){return this.#eD(this.#eP())}compile(e){return this.#ej(this.#eP(e))}async execute(e){let t=this.#eP(e);return t.executeQuery(this.#ej(t),this.#M.queryId)}#eP(e){let t=void 0!==e?e.getExecutor():u.NOOP_QUERY_EXECUTOR;return void 0!==this.#M.plugins?t.withPlugins(this.#M.plugins):t}#eD(e){return e.transformQuery(this.#M.rawNode,this.#M.queryId)}#ej(e){return e.compileQuery(this.#eD(e),this.#M.queryId)}}function m(e){return new h(e)}(0,l.preventAwait)(h,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class f{#eq;#en;constructor(e,t){this.#eq=e,this.#en=t}get expression(){return this.#eq}get alias(){return this.#en}get rawBuilder(){return this.#eq}toOperationNode(){return d.AliasNode.create(this.#eq.toOperationNode(),(0,r.isOperationNodeSource)(this.#en)?this.#en.toOperationNode():t.IdentifierNode.create(this.#en))}}(0,l.preventAwait)(f,"don't await AliasedRawBuilder instances directly. AliasedRawBuilder should never be executed directly since it's always a part of another query.");let g=Object.assign((e,...t)=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(e,t?.map(v)??[])}),{ref:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,s.parseStringReference)(e))}),val:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,o.parseValueExpression)(e))}),value(e){return this.val(e)},table:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,n.parseTable)(e))}),id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(r,e.map(t.IdentifierNode.create))})},lit:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild(i.ValueNode.createImmediate(e))}),literal(e){return this.lit(e)},raw:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithSql(e)}),join(e,t=g`, `){let r=Array(2*e.length-1),i=t.toOperationNode();for(let t=0;t<e.length;++t)r[2*t]=v(e[t]),t!==e.length-1&&(r[2*t+1]=i);return m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChildren(r)})}});function v(e){return(0,r.isOperationNodeSource)(e)?e.toOperationNode():(0,o.parseValueExpression)(e)}e.s(["sql",0,g],12995)},78134,e=>{"use strict";var t=e.i(90348),r=e.i(84739);let a=(0,r.freeze)({raw:(e,a=[])=>(0,r.freeze)({sql:e,query:t.RawNode.createWithSql(e),parameters:(0,r.freeze)(a)})}),i=Symbol();class s{#eL;#ex=new WeakMap;#eM;constructor(e){this.#eL=(0,r.freeze)({...e})}async init(){this.#eM=(0,r.isFunction)(this.#eL.pool)?await this.#eL.pool():this.#eL.pool}async acquireConnection(){let e=await this.#eM.connect(),t=this.#ex.get(e);return!t&&(t=new n(e,{cursor:this.#eL.cursor??null}),this.#ex.set(e,t),this.#eL.onCreateConnection&&await this.#eL.onCreateConnection(t)),this.#eL.onReserveConnection&&await this.#eL.onReserveConnection(t),t}async beginTransaction(e,t){t.isolationLevel?await e.executeQuery(a.raw(`start transaction isolation level ${t.isolationLevel}`)):await e.executeQuery(a.raw("begin"))}async commitTransaction(e){await e.executeQuery(a.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(a.raw("rollback"))}async releaseConnection(e){e[i]()}async destroy(){if(this.#eM){let e=this.#eM;this.#eM=void 0,await e.end()}}}class n{#eF;#eU;constructor(e,t){this.#eF=e,this.#eU=t}async executeQuery(e){try{let t=await this.#eF.query(e.sql,[...e.parameters]);if("INSERT"===t.command||"UPDATE"===t.command||"DELETE"===t.command||"MERGE"===t.command){let e=BigInt(t.rowCount);return{numUpdatedOrDeletedRows:e,numAffectedRows:e,rows:t.rows??[]}}return{rows:t.rows??[]}}catch(e){throw function(e,t){var a;if(a=e,(0,r.isObject)(a)&&(0,r.isString)(a.stack)&&t.stack){let r=t.stack.split("\n").slice(1).join("\n");e.stack+=`
|
|
2
2
|
${r}`}return e}(e,Error())}}async *streamQuery(e,t){if(!this.#eU.cursor)throw Error("'cursor' is not present in your postgres dialect config. It's required to make streaming work in postgres.");if(!Number.isInteger(t)||t<=0)throw Error("chunkSize must be a positive integer");let r=this.#eF.query(new this.#eU.cursor(e.sql,e.parameters.slice()));try{for(;;){let e=await r.read(t);if(0===e.length)break;yield{rows:e}}}finally{await r.close()}}[i](){this.#eF.release()}}e.i(90640),(0,r.freeze)({__noMigrations__:!0});var o=e.i(12995);class p{#eB;constructor(e){this.#eB=e}async getSchemas(){return(await this.#eB.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map(e=>({name:e.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#eB.selectFrom("pg_catalog.pg_attribute as a").innerJoin("pg_catalog.pg_class as c","a.attrelid","c.oid").innerJoin("pg_catalog.pg_namespace as ns","c.relnamespace","ns.oid").innerJoin("pg_catalog.pg_type as typ","a.atttypid","typ.oid").innerJoin("pg_catalog.pg_namespace as dtns","typ.typnamespace","dtns.oid").select(["a.attname as column","a.attnotnull as not_null","a.atthasdef as has_default","c.relname as table","c.relkind as table_type","ns.nspname as schema","typ.typname as type","dtns.nspname as type_schema",o.sql`col_description(a.attrelid, a.attnum)`.as("column_description"),this.#eB.selectFrom("pg_class").select(o.sql`true`.as("auto_incrementing")).whereRef("relnamespace","=","c.relnamespace").where("relkind","=","S").where("relname","=",o.sql`c.relname || '_' || a.attname || '_seq'`).as("auto_incrementing")]).where(e=>e.or([e("c.relkind","=","r"),e("c.relkind","=","v"),e("c.relkind","=","p")])).where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema").where("a.attnum",">=",0).where("a.attisdropped","!=",!0).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();e.withInternalKyselyTables||(t=t.where("c.relname","!=","kysely_migration").where("c.relname","!=","kysely_migration_lock"));let r=await t.execute();return this.#eV(r)}async getMetadata(e){return{tables:await this.getTables(e)}}#eV(e){return e.reduce((e,t)=>{let a=e.find(e=>e.name===t.table&&e.schema===t.schema);return a||(a=(0,r.freeze)({name:t.table,isView:"v"===t.table_type,schema:t.schema,columns:[]}),e.push(a)),a.columns.push((0,r.freeze)({name:t.column,dataType:t.type,dataTypeSchema:t.type_schema,isNullable:!t.not_null,isAutoIncrementing:!!t.auto_incrementing,hasDefaultValue:t.has_default,comment:t.column_description??void 0})),e},[])}}var d=e.i(58666),l=e.i(72866);class c{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#ez=(0,r.freeze)({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this)});visitNode=e=>{this.nodeStack.push(e),this.#ez[e.kind](e),this.nodeStack.pop()}}var u=e.i(6697),h=e.i(9581),m=e.i(27539),f=e.i(3888),g=e.i(45393),v=e.i(29986);class y extends c{#eW="";#e$=[];get numParameters(){return this.#e$.length}compileQuery(e){return this.#eW="",this.#e$=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),(0,r.freeze)({query:e,sql:this.getSql(),parameters:[...this.#e$]})}getSql(){return this.#eW}visitSelectQuery(e){let t=void 0!==this.parentNode&&!h.ParensNode.is(this.parentNode)&&!l.InsertQueryNode.is(this.parentNode)&&!d.CreateTableNode.is(this.parentNode)&&!f.CreateViewNode.is(this.parentNode)&&!g.SetOperationNode.is(this.parentNode);void 0===this.parentNode&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("select"),e.distinctOn&&(this.append(" "),this.compileDistinctOn(e.distinctOn)),e.frontModifiers?.length&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.top&&(this.append(" "),this.visitNode(e.top)),e.selections&&(this.append(" "),this.compileList(e.selections)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.groupBy&&(this.append(" "),this.visitNode(e.groupBy)),e.having&&(this.append(" "),this.visitNode(e.having)),e.setOperations&&(this.append(" "),this.compileList(e.setOperations," ")),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.offset&&(this.append(" "),this.visitNode(e.offset)),e.fetch&&(this.append(" "),this.visitNode(e.fetch)),e.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ")),t&&this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,t=", "){let r=e.length-1;for(let a=0;a<=r;a++)this.visitNode(e[a]),a<r&&this.append(t)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){let t=this.nodeStack.find(m.QueryNode.is),r=t!==e;!r&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&!v.MergeQueryNode.is(t)&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append(e.replace?"replace":"insert"),e.ignore&&this.append(" ignore"),e.top&&(this.append(" "),this.visitNode(e.top)),e.into&&(this.append(" into "),this.visitNode(e.into)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.output&&(this.append(" "),this.visitNode(e.output)),e.values&&(this.append(" "),this.visitNode(e.values)),e.defaultValues&&(this.append(" "),this.append("default values")),e.onConflict&&(this.append(" "),this.visitNode(e.onConflict)),e.onDuplicateKey&&(this.append(" "),this.visitNode(e.onDuplicateKey)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&!v.MergeQueryNode.is(t)&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){let t=this.nodeStack.find(m.QueryNode.is)!==e;!t&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("delete "),e.top&&(this.visitNode(e.top),this.append(" ")),this.visitNode(e.from),e.output&&(this.append(" "),this.visitNode(e.output)),e.using&&(this.append(" "),this.visitNode(e.using)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),t&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){e.table&&(this.visitNode(e.table),this.append(".")),this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!(0,r.isString)(e.name))throw Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){e.immediate?this.appendImmediateValue(e.value):this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");let{values:t}=e;for(let e=0;e<t.length;++e)this.appendValue(t[e]),e!==t.length-1&&this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){this.append(_[e.joinType]),this.append(" "),this.visitNode(e.table),e.on&&(this.append(" "),this.visitNode(e.on))}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){let{sqlFragments:t,parameters:r}=e;for(let e=0;e<t.length;++e)this.append(t[e]),r.length>e&&this.visitNode(r[e])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){e.schema&&(this.visitNode(e.schema),this.append(".")),this.visitNode(e.identifier)}visitCreateTable(e){this.append("create "),e.frontModifiers&&e.frontModifiers.length>0&&(this.compileList(e.frontModifiers," "),this.append(" ")),e.temporary&&this.append("temporary "),this.append("table "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.table),e.selectQuery?(this.append(" as "),this.visitNode(e.selectQuery)):(this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")"),e.onCommit&&(this.append(" on commit "),this.append(e.onCommit)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," ")))}visitColumnDefinition(e){e.ifNotExists&&this.append("if not exists "),this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned&&this.append(" unsigned"),e.frontModifiers&&e.frontModifiers.length>0&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.generated&&(this.append(" "),this.visitNode(e.generated)),e.identity&&this.append(" identity"),e.defaultTo&&(this.append(" "),this.visitNode(e.defaultTo)),e.notNull&&this.append(" not null"),e.unique&&this.append(" unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.primaryKey&&this.append(" primary key"),e.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),e.references&&(this.append(" "),this.visitNode(e.references)),e.check&&(this.append(" "),this.visitNode(e.check)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(e){this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitDropTable(e){this.append("drop table "),e.ifExists&&this.append("if exists "),this.visitNode(e.table),e.cascade&&this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){this.visitNode(e.orderBy),e.direction&&(this.append(" "),this.visitNode(e.direction))}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){let t=this.nodeStack.find(m.QueryNode.is),r=t!==e;!r&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&!v.MergeQueryNode.is(t)&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("update "),e.top&&(this.visitNode(e.top),this.append(" ")),e.table&&(this.visitNode(e.table),this.append(" ")),this.append("set "),e.updates&&this.compileList(e.updates),e.output&&(this.append(" "),this.visitNode(e.output)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&!v.MergeQueryNode.is(t)&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){this.append("on conflict"),e.columns?(this.append(" ("),this.compileList(e.columns),this.append(")")):e.constraint?(this.append(" on constraint "),this.visitNode(e.constraint)):e.indexExpression&&(this.append(" ("),this.visitNode(e.indexExpression),this.append(")")),e.indexWhere&&(this.append(" "),this.visitNode(e.indexWhere)),!0===e.doNothing?this.append(" do nothing"):e.updates&&(this.append(" do update set "),this.compileList(e.updates),e.updateWhere&&(this.append(" "),this.visitNode(e.updateWhere)))}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.using&&(this.append(" using "),this.visitNode(e.using)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.where&&(this.append(" "),this.visitNode(e.where))}visitDropIndex(e){this.append("drop index "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.cascade&&this.append(" cascade")}visitCreateSchema(e){this.append("create schema "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.schema)}visitDropSchema(e){this.append("drop schema "),e.ifExists&&this.append("if exists "),this.visitNode(e.schema),e.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("primary key ("),this.compileList(e.columns),this.append(")")}visitUniqueConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(e.columns),this.append(")")}visitCheckConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitList(e){this.compileList(e.items)}visitWith(e){this.append("with "),e.recursive&&this.append("recursive "),this.compileList(e.expressions)}visitCommonTableExpression(e){this.visitNode(e.name),this.append(" as "),(0,r.isBoolean)(e.materialized)&&(e.materialized||this.append("not "),this.append("materialized ")),this.visitNode(e.expression)}visitCommonTableExpressionName(e){this.visitNode(e.table),e.columns&&(this.append("("),this.compileList(e.columns),this.append(")"))}visitAlterTable(e){this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo&&(this.append("rename to "),this.visitNode(e.renameTo)),e.setSchema&&(this.append("set schema "),this.visitNode(e.setSchema)),e.addConstraint&&this.visitNode(e.addConstraint),e.dropConstraint&&this.visitNode(e.dropConstraint),e.columnAlterations&&this.compileColumnAlterations(e.columnAlterations),e.addIndex&&this.visitNode(e.addIndex),e.dropIndex&&this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(e.dataType),e.dataTypeExpression&&(this.append("using "),this.visitNode(e.dataTypeExpression))),e.setDefault&&(this.append("set default "),this.visitNode(e.setDefault)),e.dropDefault&&this.append("drop default"),e.setNotNull&&this.append("set not null"),e.dropNotNull&&this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){this.append("drop constraint "),e.ifExists&&this.append("if exists "),this.visitNode(e.constraintName),"cascade"===e.modifier?this.append(" cascade"):"restrict"===e.modifier&&this.append(" restrict")}visitSetOperation(e){this.append(e.operator),this.append(" "),e.all&&this.append("all "),this.visitNode(e.expression)}visitCreateView(e){this.append("create "),e.orReplace&&this.append("or replace "),e.materialized&&this.append("materialized "),e.temporary&&this.append("temporary "),this.append("view "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),this.append(" "),e.columns&&(this.append("("),this.compileList(e.columns),this.append(") ")),e.as&&(this.append("as "),this.visitNode(e.as))}visitDropView(e){this.append("drop "),e.materialized&&this.append("materialized "),this.append("view "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.cascade&&this.append(" cascade")}visitGenerated(e){this.append("generated "),e.always&&this.append("always "),e.byDefault&&this.append("by default "),this.append("as "),e.identity&&this.append("identity"),e.expression&&(this.append("("),this.visitNode(e.expression),this.append(")")),e.stored&&this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){e.rawModifier?this.visitNode(e.rawModifier):this.append(w[e.modifier]),e.of&&(this.append(" of "),this.compileList(e.of,", "))}visitCreateType(e){this.append("create type "),this.visitNode(e.name),e.enum&&(this.append(" as enum "),this.visitNode(e.enum))}visitDropType(e){this.append("drop type "),e.ifExists&&this.append("if exists "),this.visitNode(e.name)}visitExplain(e){this.append("explain"),(e.options||e.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options&&(this.visitNode(e.options),e.format&&this.append(this.getExplainOptionsDelimiter())),e.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){this.append(e.func),this.append("("),e.distinct&&this.append("distinct "),this.compileList(e.aggregated),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),this.append(")"),e.filter&&(this.append(" filter("),this.visitNode(e.filter),this.append(")")),e.over&&(this.append(" "),this.visitNode(e.over))}visitOver(e){this.append("over("),e.partitionBy&&(this.visitNode(e.partitionBy),e.orderBy&&this.append(" ")),e.orderBy&&this.visitNode(e.orderBy),this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){this.visitNode(e.operator),this.isMinusOperator(e.operator)||this.append(" "),this.visitNode(e.operand)}isMinusOperator(e){return u.OperatorNode.is(e)&&"-"===e.operator}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){this.append("case"),e.value&&(this.append(" "),this.visitNode(e.value)),e.when&&(this.append(" "),this.compileList(e.when," ")),e.else&&(this.append(" else "),this.visitNode(e.else)),this.append(" end"),e.isStatement&&this.append(" case")}visitWhen(e){this.append("when "),this.visitNode(e.condition),e.result&&(this.append(" then "),this.visitNode(e.result))}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){for(let t of(e.inOperator&&this.visitNode(e.inOperator),this.append("'$"),e.pathLegs))this.visitNode(t);this.append("'")}visitJSONPathLeg(e){let t="ArrayLocation"===e.type;this.append(t?"[":"."),this.append(String(e.value)),t&&this.append("]")}visitJSONOperatorChain(e){for(let t=0,r=e.values.length;t<r;t++)t===r-1?this.visitNode(e.operator):this.append("->"),this.visitNode(e.values[t])}visitMergeQuery(e){e.with&&(this.visitNode(e.with),this.append(" ")),this.append("merge "),e.top&&(this.visitNode(e.top),this.append(" ")),this.append("into "),this.visitNode(e.into),e.using&&(this.append(" "),this.visitNode(e.using)),e.whens&&(this.append(" "),this.compileList(e.whens," ")),e.output&&(this.append(" "),this.visitNode(e.output)),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitMatched(e){e.not&&this.append("not "),this.append("matched"),e.bySource&&this.append(" by source")}visitAddIndex(e){this.append("add "),e.unique&&this.append("unique "),this.append("index "),this.visitNode(e.name),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.using&&(this.append(" using "),this.visitNode(e.using))}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){this.append(`top(${e.expression})`),e.modifiers&&this.append(` ${e.modifiers}`)}append(e){this.#eW+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){let t=this.getLeftIdentifierWrapper(),r=this.getRightIdentifierWrapper(),a="";for(let i of e)a+=i,i===t?a+=t:i===r&&(a+=r);return a}addParameter(e){this.#e$.push(e)}appendImmediateValue(e){if((0,r.isString)(e))this.append(`'${e}'`);else if((0,r.isNumber)(e)||(0,r.isBoolean)(e))this.append(e.toString());else if((0,r.isNull)(e))this.append("null");else if((0,r.isDate)(e))this.appendImmediateValue(e.toISOString());else if((0,r.isBigInt)(e))this.appendImmediateValue(e.toString());else throw Error(`invalid immediate value ${e}`)}sortSelectModifiers(e){return e.sort((e,t)=>e.modifier&&t.modifier?b[e.modifier]-b[t.modifier]:1),(0,r.freeze)(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}}let w=(0,r.freeze)({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),b=(0,r.freeze)({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),_=(0,r.freeze)({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",Using:"using"}),x=/"/g;class N extends y{sanitizeIdentifier(e){return e.replace(x,'""')}}class T{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}let E=BigInt("3853314791062309107");class A extends T{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,t){await o.sql`select pg_advisory_xact_lock(${o.sql.lit(E)})`.execute(e)}async releaseMigrationLock(e,t){}}class S{#eL;constructor(e){this.#eL=e}createDriver(){return new s(this.#eL)}createQueryCompiler(){return new N}createAdapter(){return new A}createIntrospector(e){return new p(e)}}e.s(["PostgresDialect",()=>S],78134)},30056,e=>e.a(async(t,r)=>{try{let t=await e.y("pg");e.n(t),r()}catch(e){r(e)}},!0),14281,e=>e.a(async(t,r)=>{try{var a=e.i(24659),i=e.i(78134),s=e.i(30056),n=t([s]);[s]=n.then?(await n)():n;let o=new s.default.Pool({connectionString:process.env.DATABASE_URL}),p=new a.Kysely({dialect:new i.PostgresDialect({pool:o}),log:void 0}),d=async()=>{try{await p.destroy()}catch(e){throw console.error(e,"Failed to clean up resources"),e}};process.on("SIGTERM",d),process.on("SIGINT",d),e.s(["db",0,p]),r()}catch(e){r(e)}},!1),54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},7273,e=>{"use strict";let t,r;var a=e.i(66680);function i(e=21){var s;s=e|=0,!t||t.length<s?(t=Buffer.allocUnsafe(128*s),a.webcrypto.getRandomValues(t),r=0):r+s>t.length&&(a.webcrypto.getRandomValues(t),r=0),r+=s;let n="";for(let a=r-e;a<r;a++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return n}e.s(["nanoid",()=>i],7273)},69855,e=>{"use strict";var t=e.i(54799),r=e.i(12995),a=e.i(7273);class i{db;serverPepper;constructor(e,t){this.db=e,this.serverPepper=t}hashKey(e){return(0,t.createHash)("sha256").update(e+this.serverPepper).digest("hex")}generateApiKey(){let e=`sk_${(0,t.randomBytes)(32).toString("hex")}`,r=e.substring(0,12);return{apiKey:e,keyPrefix:r}}async createApp(e){let t=(0,a.nanoid)(),i=new Date,s=await this.db.insertInto("app").values({app_id:t,name:e.name,metadata:r.sql`cast(${JSON.stringify(e.metadata||{})} as jsonb)`,createdAt:i,updatedAt:i}).returningAll().executeTakeFirstOrThrow();return{appId:s.app_id,name:s.name,metadata:s.metadata,createdAt:s.createdAt,updatedAt:s.updatedAt}}async getApp(e){let t=await this.db.selectFrom("app").selectAll().where("app_id","=",e).executeTakeFirst();return t?{appId:t.app_id,name:t.name,metadata:t.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listApps(e){let t=e.limit||50,r=e.offset||0;return(await this.db.selectFrom("app").selectAll().orderBy("createdAt","desc").limit(t).offset(r).execute()).map(e=>({appId:e.app_id,name:e.name,metadata:e.metadata,createdAt:e.createdAt,updatedAt:e.updatedAt}))}async updateApp(e){let t={updatedAt:new Date};void 0!==e.name&&(t.name=e.name);let a=await this.db.updateTable("app").set(t).$if(void 0!==e.metadata,t=>t.set("metadata",r.sql`cast(${JSON.stringify(e.metadata||{})} as jsonb)`)).where("app_id","=",e.appId).returningAll().executeTakeFirst();return a?{appId:a.app_id,name:a.name,metadata:a.metadata,createdAt:a.createdAt,updatedAt:a.updatedAt}:null}async deleteApp(e){await this.db.deleteFrom("app").where("app_id","=",e).execute()}async createApiKey(e){let t=(0,a.nanoid)(),{apiKey:i,keyPrefix:s}=this.generateApiKey(),n=this.hashKey(i);return await this.db.insertInto("api_key").values({key_id:t,key_prefix:s,key_hash:n,app_id:e.appId,scopes:r.sql`cast(${JSON.stringify(e.scopes)} as jsonb)`,name:e.name,metadata:r.sql`cast(${JSON.stringify(e.metadata||{})} as jsonb)`,createdAt:new Date}).execute(),{apiKey:i,keyId:t,keyPrefix:s}}async verifyApiKey(e){let t=this.hashKey(e),r=await this.db.selectFrom("api_key").select(["key_id","app_id","scopes","revoked_at"]).where("key_hash","=",t).executeTakeFirst();return!r||r.revoked_at?null:(await this.db.updateTable("api_key").set({last_used_at:new Date}).where("key_id","=",r.key_id).execute(),{keyId:r.key_id,appId:r.app_id,scopes:r.scopes})}async revokeApiKey(e,t){await this.db.updateTable("api_key").set({revoked_at:new Date}).where("key_id","=",t).where("app_id","=",e).execute()}async listApiKeys(e){return(await this.db.selectFrom("api_key").select(["key_id","key_prefix","app_id","scopes","name","last_used_at","revoked_at","createdAt"]).where("app_id","=",e.appId).execute()).map(e=>({keyId:e.key_id,keyPrefix:e.key_prefix,appId:e.app_id,scopes:e.scopes,name:e.name,lastUsedAt:e.last_used_at,revokedAt:e.revoked_at,createdAt:e.createdAt}))}async getOrCreateAppByName(e){let t=await this.db.selectFrom("app").selectAll().where("name","=",e).executeTakeFirst();return t?{appId:t.app_id,name:t.name,metadata:t.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt}:this.createApp({name:e,metadata:{createdBy:"standalone-mode"}})}}e.s(["PostgresAppStore",()=>i])},24868,(e,t,r)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},13932,e=>{"use strict";var t=e.i(54799),r=e.i(24868),a=e.i(14747),i=e.i(7273);async function s(e){try{let t=await (0,r.readFile)(e,"utf-8");return JSON.parse(t)}catch(e){if("ENOENT"===e.code)return null;throw e}}async function n(e,t){await (0,r.mkdir)((0,a.dirname)(e),{recursive:!0}),await (0,r.writeFile)(e,JSON.stringify(t,null,2),"utf-8")}async function o(e){try{let t=await (0,r.readFile)(e,"utf-8"),a=await (0,r.stat)(e);return{data:JSON.parse(t),createdAt:a.birthtime,updatedAt:a.mtime}}catch(e){if("ENOENT"===e.code)return null;throw e}}async function p(e){try{return(await (0,r.readdir)(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if("ENOENT"===e.code)return[];throw e}}class d{basePath;serverPepper;constructor(e,t){this.basePath=e,this.serverPepper=t}getAppsDir(){return(0,a.join)(this.basePath,"apps")}getAppDir(e){return(0,a.join)(this.getAppsDir(),e)}getAppDataPath(e){return(0,a.join)(this.getAppDir(e),"data.json")}getApiKeysPath(e){return(0,a.join)(this.getAppDir(e),"api-keys","data.json")}hashKey(e){return(0,t.createHash)("sha256").update(e+this.serverPepper).digest("hex")}generateApiKey(){let e=`sk_${(0,t.randomBytes)(32).toString("hex")}`,r=e.substring(0,12);return{apiKey:e,keyPrefix:r}}async loadApiKeys(e){return await s(this.getApiKeysPath(e))??{keys:[],hashIndex:{}}}async saveApiKeys(e,t){await n(this.getApiKeysPath(e),t)}async createApp(e){let t=(0,i.nanoid)(),a={appId:t,name:e.name,metadata:e.metadata||{}};await n(this.getAppDataPath(t),a);let s=await (0,r.stat)(this.getAppDataPath(t));return{appId:a.appId,name:a.name,metadata:a.metadata,createdAt:s.birthtime,updatedAt:s.mtime}}async getApp(e){let t=await o(this.getAppDataPath(e));return t?{appId:t.data.appId,name:t.data.name,metadata:t.data.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listApps(e){let t=e.limit||50,a=e.offset||0,i=await p(this.getAppsDir()),s=[];for(let e of i)try{let t=await (0,r.stat)(this.getAppDataPath(e));s.push({appId:e,createdAt:t.birthtime})}catch{}s.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime());let n=s.slice(a,a+t),d=[];for(let{appId:e}of n){let t=await o(this.getAppDataPath(e));t&&d.push({appId:t.data.appId,name:t.data.name,metadata:t.data.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt})}return d}async updateApp(e){let t=await s(this.getAppDataPath(e.appId));if(!t)return null;let a={...t,name:void 0!==e.name?e.name:t.name,metadata:void 0!==e.metadata?e.metadata:t.metadata};await n(this.getAppDataPath(e.appId),a);let i=await (0,r.stat)(this.getAppDataPath(e.appId));return{appId:a.appId,name:a.name,metadata:a.metadata,createdAt:i.birthtime,updatedAt:i.mtime}}async deleteApp(e){try{await (0,r.rm)(this.getAppDir(e),{recursive:!0,force:!0})}catch(e){if("ENOENT"!==e.code)throw e}}async createApiKey(e){let t=(0,i.nanoid)(),{apiKey:r,keyPrefix:a}=this.generateApiKey(),s=this.hashKey(r),n=await this.loadApiKeys(e.appId),o={keyId:t,keyPrefix:a,keyHash:s,appId:e.appId,scopes:e.scopes,name:e.name,metadata:e.metadata||{},lastUsedAt:null,revokedAt:null,createdAt:new Date().toISOString()};return n.keys.push(o),n.hashIndex[s]=t,await this.saveApiKeys(e.appId,n),{apiKey:r,keyId:t,keyPrefix:a}}async verifyApiKey(e){let t=this.hashKey(e);for(let e of(await p(this.getAppsDir()))){let r=await this.loadApiKeys(e),a=r.hashIndex[t];if(!a)continue;let i=r.keys.find(e=>e.keyId===a);if(i){if(i.revokedAt)return null;return i.lastUsedAt=new Date().toISOString(),await this.saveApiKeys(e,r),{keyId:i.keyId,appId:i.appId,scopes:i.scopes}}}return null}async revokeApiKey(e,t){let r=await this.loadApiKeys(e),a=r.keys.find(e=>e.keyId===t);a&&(a.revokedAt=new Date().toISOString(),await this.saveApiKeys(e,r))}async listApiKeys(e){return(await this.loadApiKeys(e.appId)).keys.map(e=>({keyId:e.keyId,keyPrefix:e.keyPrefix,appId:e.appId,scopes:e.scopes,name:e.name,lastUsedAt:e.lastUsedAt?new Date(e.lastUsedAt):null,revokedAt:e.revokedAt?new Date(e.revokedAt):null,createdAt:new Date(e.createdAt)}))}async getOrCreateAppByName(e){for(let t of(await p(this.getAppsDir()))){let r=await o(this.getAppDataPath(t));if(r&&r.data.name===e)return{appId:r.data.appId,name:r.data.name,metadata:r.data.metadata,createdAt:r.createdAt,updatedAt:r.updatedAt}}return this.createApp({name:e,metadata:{createdBy:"standalone-mode"}})}}e.s(["LocalAppStore",()=>d])},54906,e=>{"use strict";e.i(69855),e.i(13932),e.s([])},36553,e=>{"use strict";var t=e.i(54799),r=e.i(24868),a=e.i(14747),i=e.i(7273);class s{blobPath;dataPath;constructor(e,t){this.blobPath=e,this.dataPath=t}getGenerationFilePath(e,t,r){return(0,a.join)(this.dataPath,"apps",e,"generations",t,"files",`${r}.json`)}getBlobPath(e,t,r,i){return(0,a.join)(this.blobPath,"apps",e,"generations",t,r,i)}async saveGenerationFile(e){let s=(0,i.nanoid)(),n=(0,t.createHash)("sha256").update(e.content).digest("hex"),o=`apps/${e.appId}/generations/${e.generationId}/${s}/${e.filename}`,p=(0,a.join)(this.blobPath,o);await (0,r.mkdir)((0,a.dirname)(p),{recursive:!0}),await (0,r.writeFile)(p,e.content);let d={fileId:s,generationId:e.generationId,filename:e.filename,contentType:e.contentType,sizeBytes:e.content.length.toString(),sha256Hex:n,gcsPath:o},l=this.getGenerationFilePath(e.appId,e.generationId,s);return await (0,r.mkdir)((0,a.dirname)(l),{recursive:!0}),await (0,r.writeFile)(l,JSON.stringify(d,null,2),"utf-8"),{fileId:s}}async downloadFile(e){let t=(0,a.join)(this.blobPath,e);return(0,r.readFile)(t)}}e.s(["LocalBlobStore",()=>s])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},46786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},91198,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GCE_LINUX_BIOS_PATHS=void 0,r.isGoogleCloudServerless=s,r.isGoogleComputeEngineLinux=n,r.isGoogleComputeEngineMACAddress=o,r.isGoogleComputeEngine=p,r.detectGCPResidency=function(){return s()||p()},e.r(22734);let a=e.r(46786);r.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};let i=/^42:01/;function s(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function n(){if("linux"!==(0,a.platform)())return!1}function o(){for(let e of Object.values((0,a.networkInterfaces)()))if(e){for(let{mac:t}of e)if(i.test(t))return!0}return!1}function p(){return n()||o()}},4446,(e,t,r)=>{t.exports=e.x("net",()=>require("net"))},55004,(e,t,r)=>{t.exports=e.x("tls",()=>require("tls"))},49719,(e,t,r)=>{t.exports=e.x("assert",()=>require("assert"))},57108,(e,t,r)=>{function a(e,t,r,a){return Math.round(e/r)+" "+a+(t>=1.5*r?"s":"")}t.exports=function(e,t){t=t||{};var r,i,s,n,o=typeof e;if("string"===o&&e.length>0){var p=e;if(!((p=String(p)).length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(d){var l=parseFloat(d[1]);switch((d[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*l;case"weeks":case"week":case"w":return 6048e5*l;case"days":case"day":case"d":return 864e5*l;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*l;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*l;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*l;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:break}}}return}if("number"===o&&isFinite(e)){return t.long?(i=Math.abs(r=e))>=864e5?a(r,i,864e5,"day"):i>=36e5?a(r,i,36e5,"hour"):i>=6e4?a(r,i,6e4,"minute"):i>=1e3?a(r,i,1e3,"second"):r+" ms":(n=Math.abs(s=e))>=864e5?Math.round(s/864e5)+"d":n>=36e5?Math.round(s/36e5)+"h":n>=6e4?Math.round(s/6e4)+"m":n>=1e3?Math.round(s/1e3)+"s":s+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},61086,(e,t,r)=>{t.exports=function(t){function r(e){let t,i,s,n=null;function o(...e){if(!o.enabled)return;let a=Number(new Date);o.diff=a-(t||a),o.prev=t,o.curr=a,t=a,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,a)=>{if("%%"===t)return"%";i++;let s=r.formatters[a];if("function"==typeof s){let r=e[i];t=s.call(o,r),e.splice(i,1),i--}return t}),r.formatArgs.call(o,e),(o.log||r.log).apply(o,e)}return o.namespace=e,o.useColors=r.useColors(),o.color=r.selectColor(e),o.extend=a,o.destroy=r.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==n?n:(i!==r.namespaces&&(i=r.namespaces,s=r.enabled(e)),s),set:e=>{n=e}}),"function"==typeof r.init&&r.init(o),o}function a(e,t){let a=r(this.namespace+(void 0===t?":":t)+e);return a.log=this.log,a}function i(e,t){let r=0,a=0,i=-1,s=0;for(;r<e.length;)if(a<t.length&&(t[a]===e[r]||"*"===t[a]))"*"===t[a]?(i=a,s=r):r++,a++;else{if(-1===i)return!1;a=i+1,r=++s}for(;a<t.length&&"*"===t[a];)a++;return a===t.length}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){let e=[...r.names,...r.skips.map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){for(let t of(r.save(e),r.namespaces=e,r.names=[],r.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===t[0]?r.skips.push(t.slice(1)):r.names.push(t)},r.enabled=function(e){for(let t of r.skips)if(i(e,t))return!1;for(let t of r.names)if(i(e,t))return!0;return!1},r.humanize=e.r(57108),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(e=>{r[e]=t[e]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},70722,(e,t,r)=>{t.exports=e.x("tty",()=>require("tty"))},75606,(e,t,r)=>{"use strict";t.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":1===e.length?"-":"--",a=t.indexOf(r+e),i=t.indexOf("--");return -1!==a&&(-1===i||a<i)}},2854,(e,t,r)=>{"use strict";let a;e.r(46786);let i=e.r(70722),s=e.r(75606),{env:n}=process;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function p(e,t){if(0===a)return 0;if(s("color=16m")||s("color=full")||s("color=truecolor"))return 3;if(s("color=256"))return 2;if(e&&!t&&void 0===a)return 0;let r=a||0;if("dumb"===n.TERM)return r;if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in n)||"codeship"===n.CI_NAME?1:r;if("TEAMCITY_VERSION"in n)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION);if("truecolor"===n.COLORTERM)return 3;if("TERM_PROGRAM"in n){let e=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:r}s("no-color")||s("no-colors")||s("color=false")||s("color=never")?a=0:(s("color")||s("colors")||s("color=true")||s("color=always"))&&(a=1),"FORCE_COLOR"in n&&(a="true"===n.FORCE_COLOR?1:"false"===n.FORCE_COLOR?0:0===n.FORCE_COLOR.length?1:Math.min(parseInt(n.FORCE_COLOR,10),3)),t.exports={supportsColor:function(e){return o(p(e,e&&e.isTTY))},stdout:o(p(!0,i.isatty(1))),stderr:o(p(!0,i.isatty(2)))}},89376,(e,t,r)=>{let a=e.r(70722),i=e.r(24361);r.init=function(e){e.inspectOpts={};let t=Object.keys(r.inspectOpts);for(let a=0;a<t.length;a++)e.inspectOpts[t[a]]=r.inspectOpts[t[a]]},r.log=function(...e){return process.stderr.write(i.formatWithOptions(r.inspectOpts,...e)+"\n")},r.formatArgs=function(e){let{namespace:a,useColors:i}=this;if(i){let r=this.color,i="\x1b[3"+(r<8?r:"8;5;"+r),s=` ${i};1m${a} \u001B[0m`;e[0]=s+e[0].split("\n").join("\n"+s),e.push(i+"m+"+t.exports.humanize(this.diff)+"\x1b[0m")}else e[0]=(r.inspectOpts.hideDate?"":new Date().toISOString()+" ")+a+" "+e[0]},r.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},r.load=function(){return process.env.DEBUG},r.useColors=function(){return"colors"in r.inspectOpts?!!r.inspectOpts.colors:a.isatty(process.stderr.fd)},r.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),r.colors=[6,2,3,4,5,1];try{let t=e.r(2854);t&&(t.stderr||t).level>=2&&(r.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}r.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),a=process.env[t];return a=!!/^(yes|on|true|enabled)$/i.test(a)||!/^(no|off|false|disabled)$/i.test(a)&&("null"===a?null:Number(a)),e[r]=a,e},{}),t.exports=e.r(61086)(r);let{formatters:s}=t.exports;s.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},s.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}},38771,(e,t,r)=>{let a;r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let r="color: "+this.color;e.splice(1,0,r,"color: inherit");let a=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(a++,"%c"===e&&(i=a))}),e.splice(i,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")||r.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},r.useColors=function(){let e;return!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},r.storage=function(){try{return localStorage}catch(e){}}(),a=!1,r.destroy=()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))},r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e.r(61086)(r);let{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},14682,(e,t,r)=>{"undefined"==typeof process||"renderer"===process.type||process.__nwjs?t.exports=e.r(38771):t.exports=e.r(89376)},21517,(e,t,r)=>{t.exports=e.x("http",()=>require("http"))},24836,(e,t,r)=>{t.exports=e.x("https",()=>require("https"))},62848,(e,t,r)=>{"use strict";var a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return i(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.req=r.json=r.toBuffer=void 0;let n=s(e.r(21517)),o=s(e.r(24836));async function p(e){let t=0,r=[];for await(let a of e)t+=a.length,r.push(a);return Buffer.concat(r,t)}r.toBuffer=p,r.json=async function(e){let t=(await p(e)).toString("utf8");try{return JSON.parse(t)}catch(e){throw e.message+=` (input: ${t})`,e}},r.req=function(e,t={}){let r=(("string"==typeof e?e:e.href).startsWith("https:")?o:n).request(e,t),a=new Promise((e,t)=>{r.once("response",e).once("error",t).end()});return r.then=a.then.bind(a),r}},15303,(e,t,r)=>{"use strict";var a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return i(t,e),t},n=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.Agent=void 0;let o=s(e.r(4446)),p=s(e.r(21517)),d=e.r(24836);n(e.r(62848),r);let l=Symbol("AgentBaseInternalState");class c extends p.Agent{constructor(e){super(e),this[l]={}}isSecureEndpoint(e){if(e){if("boolean"==typeof e.secureEndpoint)return e.secureEndpoint;if("string"==typeof e.protocol)return"https:"===e.protocol}let{stack:t}=Error();return"string"==typeof t&&t.split("\n").some(e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:"))}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[e]||(this.sockets[e]=[]);let t=new o.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||null===t)return;let r=this.sockets[e],a=r.indexOf(t);-1!==a&&(r.splice(a,1),this.totalSocketCount--,0===r.length&&delete this.sockets[e])}getName(e){return this.isSecureEndpoint(e)?d.Agent.prototype.getName.call(this,e):super.getName(e)}createSocket(e,t,r){let a={...t,secureEndpoint:this.isSecureEndpoint(t)},i=this.getName(a),s=this.incrementSockets(i);Promise.resolve().then(()=>this.connect(e,a)).then(n=>{if(this.decrementSockets(i,s),n instanceof p.Agent)try{return n.addRequest(e,a)}catch(e){return r(e)}this[l].currentSocket=n,super.createSocket(e,t,r)},e=>{this.decrementSockets(i,s),r(e)})}createConnection(){let e=this[l].currentSocket;if(this[l].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[l].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(e){this[l]&&(this[l].defaultPort=e)}get protocol(){return this[l].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){this[l]&&(this[l].protocol=e)}}r.Agent=c},92509,(e,t,r)=>{t.exports=e.x("url",()=>require("url"))},27842,(e,t,r)=>{"use strict";var a=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.parseProxyResponse=void 0;let i=(0,a(e.r(14682)).default)("https-proxy-agent:parse-proxy-response");r.parseProxyResponse=function(e){return new Promise((t,r)=>{let a=0,s=[];function n(){let p=e.read();p?function(p){s.push(p),a+=p.length;let d=Buffer.concat(s,a),l=d.indexOf("\r\n\r\n");if(-1===l){i("have not received end of HTTP headers yet..."),n();return}let c=d.slice(0,l).toString("ascii").split("\r\n"),u=c.shift();if(!u)return e.destroy(),r(Error("No header received from proxy CONNECT response"));let h=u.split(" "),m=+h[1],f=h.slice(2).join(" "),g={};for(let t of c){if(!t)continue;let a=t.indexOf(":");if(-1===a)return e.destroy(),r(Error(`Invalid header from proxy CONNECT response: "${t}"`));let i=t.slice(0,a).toLowerCase(),s=t.slice(a+1).trimStart(),n=g[i];"string"==typeof n?g[i]=[n,s]:Array.isArray(n)?n.push(s):g[i]=s}i("got proxy server response: %o %o",u,g),o(),t({connect:{statusCode:m,statusText:f,headers:g},buffered:d})}(p):e.once("readable",n)}function o(){e.removeListener("end",p),e.removeListener("error",d),e.removeListener("readable",n)}function p(){o(),i("onend"),r(Error("Proxy connection ended before receiving CONNECT response"))}function d(e){o(),i("onerror %o",e),r(e)}e.on("error",d),e.on("end",p),n()})}},63352,(e,t,r)=>{"use strict";var a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return i(t,e),t},n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.HttpsProxyAgent=void 0;let o=s(e.r(4446)),p=s(e.r(55004)),d=n(e.r(49719)),l=n(e.r(14682)),c=e.r(15303),u=e.r(92509),h=e.r(27842),m=(0,l.default)("https-proxy-agent"),f=e=>void 0===e.servername&&e.host&&!o.isIP(e.host)?{...e,servername:e.host}:e;class g extends c.Agent{constructor(e,t){super(t),this.options={path:void 0},this.proxy="string"==typeof e?new u.URL(e):e,this.proxyHeaders=t?.headers??{},m("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const r=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),a=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...t?y(t,"headers"):null,host:r,port:a}}async connect(e,t){let r,{proxy:a}=this;if(!t.host)throw TypeError('No "host" provided');"https:"===a.protocol?(m("Creating `tls.Socket`: %o",this.connectOpts),r=p.connect(f(this.connectOpts))):(m("Creating `net.Socket`: %o",this.connectOpts),r=o.connect(this.connectOpts));let i="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=o.isIPv6(t.host)?`[${t.host}]`:t.host,n=`CONNECT ${s}:${t.port} HTTP/1.1\r
|
|
3
3
|
`;if(a.username||a.password){let e=`${decodeURIComponent(a.username)}:${decodeURIComponent(a.password)}`;i["Proxy-Authorization"]=`Basic ${Buffer.from(e).toString("base64")}`}for(let e of(i.Host=`${s}:${t.port}`,i["Proxy-Connection"]||(i["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close"),Object.keys(i)))n+=`${e}: ${i[e]}\r
|
|
4
4
|
`;let l=(0,h.parseProxyResponse)(r);r.write(`${n}\r
|