@shumai-one/shumai 0.5.0 → 0.5.2
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/bin/{chunk-h82r29wm.js → chunk-04avc4fn.js} +49 -49
- package/bin/chunk-0asthrjf.js +2 -0
- package/bin/chunk-0ge2mm8j.js +1 -0
- package/bin/{chunk-3z20b2hz.js → chunk-0j22699g.js} +2 -2
- package/bin/{chunk-j909v9p5.js → chunk-0v9srsdz.js} +1 -1
- package/bin/{chunk-exgtwask.js → chunk-0y4zq3y4.js} +1 -1
- package/bin/{chunk-5yd9cv7f.js → chunk-15vsw36h.js} +5 -5
- package/bin/{chunk-eez1yncf.js → chunk-15w79661.js} +2 -2
- package/bin/{chunk-xvdd04gy.js → chunk-19jpn3r6.js} +1 -1
- package/bin/{chunk-grsgkkrb.js → chunk-19q13a80.js} +6 -6
- package/bin/{chunk-r6gkv98n.js → chunk-1nvj833s.js} +6 -6
- package/bin/chunk-23780yj6.js +3 -0
- package/bin/chunk-2gf95tj0.js +1 -0
- package/bin/{chunk-6vvs18bw.js → chunk-2pw7xcrn.js} +1 -1
- package/bin/chunk-2tk5w3jc.js +1 -0
- package/bin/chunk-2w6gve12.js +4 -0
- package/bin/chunk-301e7g3z.js +2 -0
- package/bin/chunk-3kmjbc3m.js +2 -0
- package/bin/{chunk-zhe16jvg.js → chunk-3pm6q6kg.js} +1 -1
- package/bin/{chunk-zfqz72sd.js → chunk-3q5qkfkc.js} +1 -1
- package/bin/chunk-3td60k1m.js +2 -0
- package/bin/chunk-42hrvk6k.js +211 -0
- package/bin/chunk-4zksqvwj.js +2 -0
- package/bin/chunk-5bk16qdp.js +2 -0
- package/bin/{chunk-y03z5rrg.js → chunk-5nqvqvqp.js} +3 -3
- package/bin/{chunk-e3r1m6rb.js → chunk-5rzxekn4.js} +1 -1
- package/bin/{chunk-h9x81yp6.js → chunk-5vqbzsjv.js} +1 -1
- package/bin/{chunk-628k58ek.js → chunk-6hzktewz.js} +2 -2
- package/bin/{chunk-yfe6hkzk.js → chunk-6jkjx0n2.js} +3 -3
- package/bin/{chunk-gy8z8sd7.js → chunk-6rn094yj.js} +1 -1
- package/bin/{chunk-3cvbb6kh.js → chunk-7qvvf0yd.js} +2 -2
- package/bin/{chunk-35mpp84e.js → chunk-81dawvn4.js} +2 -2
- package/bin/chunk-8abhmarc.js +2 -0
- package/bin/{chunk-51h2bgpf.js → chunk-8ayz61rc.js} +3 -3
- package/bin/{chunk-03bfjh8k.js → chunk-8ny7wvzb.js} +2 -2
- package/bin/{chunk-3btc8a0p.js → chunk-8tzfcqtb.js} +2 -2
- package/bin/{chunk-5patxztz.js → chunk-8zgq5sav.js} +3 -3
- package/bin/{chunk-m1xc3t0p.js → chunk-93p27bbm.js} +6 -6
- package/bin/chunk-951r2rx1.js +1 -0
- package/bin/chunk-965102pf.js +3 -0
- package/bin/{chunk-hr2027z3.js → chunk-98mg3dpd.js} +8 -8
- package/bin/{chunk-v42jcex0.js → chunk-9bakwac0.js} +4 -4
- package/bin/{chunk-z8mmqfm4.js → chunk-9ggwc289.js} +1 -1
- package/bin/{chunk-6bgbx563.js → chunk-9zgqjdx1.js} +2 -2
- package/bin/{chunk-kzsdp31a.js → chunk-a8bymrv1.js} +2 -2
- package/bin/chunk-acn3r2m2.js +1 -0
- package/bin/{chunk-z1r86fna.js → chunk-ae6zgjhd.js} +2 -2
- package/bin/{chunk-trndqdaa.js → chunk-asy868kq.js} +1 -1
- package/bin/{chunk-r1m4q8vw.js → chunk-b5r0be06.js} +2 -2
- package/bin/{chunk-dz33q4v1.js → chunk-bbcmhcvc.js} +2 -2
- package/bin/{chunk-myd3wg9a.js → chunk-bpxw19ez.js} +1 -1
- package/bin/{chunk-sg7n2g3z.js → chunk-cdk8vqeg.js} +4 -4
- package/bin/chunk-ce0bhc72.js +2 -0
- package/bin/chunk-ce75dw3k.css +1 -0
- package/bin/{chunk-m7dp8rqv.js → chunk-cpj562n6.js} +1 -1
- package/bin/{chunk-h153xefb.js → chunk-cx32wsa1.js} +1 -1
- package/bin/{chunk-r5rpdhed.js → chunk-d2dgazjj.js} +1 -1
- package/bin/{chunk-3zvvct3r.js → chunk-d5hbzp7t.js} +1 -1
- package/bin/chunk-d9qpgkek.js +2 -0
- package/bin/{chunk-9h6nn1a3.js → chunk-dche0gy0.js} +1 -1
- package/bin/{chunk-zcrtr8qd.js → chunk-dppfek34.js} +2 -2
- package/bin/chunk-dv6p6n5e.js +1 -0
- package/bin/{chunk-hx76pje1.js → chunk-e439kt05.js} +1 -1
- package/bin/{chunk-gptzcgte.js → chunk-eqr0znmc.js} +1 -1
- package/bin/{chunk-q5mkbnr9.js → chunk-f5z3096k.js} +2 -2
- package/bin/{chunk-b9j5575n.js → chunk-ffj9cq9y.js} +2 -2
- package/bin/{chunk-80qz30dc.js → chunk-fxg81vtx.js} +2 -2
- package/bin/{chunk-5jbx9gqe.js → chunk-ggfx2b0f.js} +1 -1
- package/bin/chunk-gnt9gewm.js +2 -0
- package/bin/{chunk-czny5thj.js → chunk-grjek810.js} +2 -2
- package/bin/chunk-gvas3xkp.js +2 -0
- package/bin/{chunk-ghjhyajn.js → chunk-j53sjkxt.js} +2 -2
- package/bin/{chunk-0tf15vee.js → chunk-jgfye6nf.js} +2 -2
- package/bin/{chunk-tcat7q9p.js → chunk-jt6v15wx.js} +2 -2
- package/bin/{chunk-rn9rktp4.js → chunk-k3prp6c6.js} +4 -4
- package/bin/{chunk-mqr096rn.js → chunk-k97axrc4.js} +1 -1
- package/bin/{chunk-20anqpf1.js → chunk-kvwec0p3.js} +2 -2
- package/bin/{chunk-vbbn4hth.js → chunk-kzr6ecke.js} +1 -1
- package/bin/{chunk-rkq6jvhb.js → chunk-m6v8vt2b.js} +2 -2
- package/bin/{chunk-32japja5.js → chunk-mn108p93.js} +1 -1
- package/bin/{chunk-31vx01aw.js → chunk-mn208vrv.js} +2 -2
- package/bin/chunk-mneeg71d.js +2 -0
- package/bin/{chunk-d7mgjqf8.js → chunk-n76w2wcr.js} +1 -1
- package/bin/{chunk-fyssg02c.js → chunk-n9vp9nbg.js} +29 -29
- package/bin/{chunk-2g5qdx4s.js → chunk-p0j4wpa5.js} +2 -2
- package/bin/chunk-qb178ntp.js +2 -0
- package/bin/{chunk-7vd5yajk.js → chunk-qmrg2jhs.js} +7 -7
- package/bin/{chunk-d9btz95y.js → chunk-qxscgcn9.js} +2 -2
- package/bin/{chunk-0vtk7wrf.js → chunk-r249n1xe.js} +2 -2
- package/bin/{chunk-36r20sj7.js → chunk-r776bhsg.js} +1 -1
- package/bin/{chunk-1k16xsqq.js → chunk-rmvhyqyb.js} +6 -6
- package/bin/{chunk-zwb9kamp.js → chunk-rtaya5wc.js} +2 -2
- package/bin/chunk-rw5h0n0s.js +1 -0
- package/bin/{chunk-m9sp00a9.js → chunk-ryepy5er.js} +4 -4
- package/bin/{chunk-mcd7zas7.js → chunk-rza95y4z.js} +2 -2
- package/bin/chunk-s4r6e6ms.js +1 -0
- package/bin/{chunk-qgkbxw1k.js → chunk-sbyyn9yw.js} +2 -2
- package/bin/chunk-syjjke3f.js +1 -0
- package/bin/chunk-t1yamxgk.js +2 -0
- package/bin/chunk-tgfxe0sb.js +1 -0
- package/bin/chunk-tjretpx8.js +1 -0
- package/bin/chunk-tvkekn4z.js +1 -0
- package/bin/{chunk-5t05jpna.js → chunk-twpc640e.js} +1 -1
- package/bin/{chunk-p5v22g5n.js → chunk-v034sfw8.js} +2 -2
- package/bin/{chunk-wydd7sz7.js → chunk-v5hz09a1.js} +2 -2
- package/bin/{chunk-j3xaq9s3.js → chunk-vm2pz2hm.js} +2 -2
- package/bin/{chunk-mt532a33.js → chunk-vzdgsfkf.js} +1 -1
- package/bin/chunk-w4yjgez6.js +14 -0
- package/bin/{chunk-0yv0nnmh.js → chunk-w73v578p.js} +2 -2
- package/bin/{chunk-edjtb7pk.js → chunk-w9z27p0m.js} +2 -2
- package/bin/chunk-wjcebkpb.js +1 -0
- package/bin/{chunk-cw8z9w5c.js → chunk-wnqxyqrg.js} +2 -2
- package/bin/chunk-ws71fg50.js +2 -0
- package/bin/{chunk-g8h1e1kh.js → chunk-wwkhskce.js} +2 -2
- package/bin/{chunk-kgfa5y9w.js → chunk-xr2v0d6y.js} +5 -5
- package/bin/{chunk-wkxm6yny.js → chunk-y2dhf3p0.js} +2 -2
- package/bin/chunk-yfp3q4da.js +1 -0
- package/bin/{chunk-f22nrm6r.js → chunk-ypkkfwfb.js} +4 -4
- package/bin/chunk-z8e4wc59.js +1 -0
- package/bin/{chunk-fhq5m9ya.js → chunk-zckxc8m6.js} +2 -2
- package/bin/{chunk-3fjgf7eb.js → chunk-zdzkjp4q.js} +2 -2
- package/bin/chunk-zf5cyxnt.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +402 -397
- package/package.json +7 -7
- package/prisma/migrations/20261008134859_add_transcode_3d/migration.sql +2 -0
- package/prisma/schema.prisma +1 -0
- package/bin/chunk-12npypek.js +0 -2
- package/bin/chunk-13d525jm.js +0 -2
- package/bin/chunk-1yt1gsyy.js +0 -2
- package/bin/chunk-3ewmtf1c.js +0 -1
- package/bin/chunk-3xw70yr4.js +0 -2
- package/bin/chunk-5seey9ee.js +0 -2
- package/bin/chunk-66hdwm6f.js +0 -2
- package/bin/chunk-756mr32b.js +0 -2
- package/bin/chunk-7wb3dga5.js +0 -2
- package/bin/chunk-9k86d2a3.js +0 -4
- package/bin/chunk-9wk11jtz.js +0 -1
- package/bin/chunk-a1crhhzy.js +0 -1
- package/bin/chunk-axfwh5et.js +0 -2
- package/bin/chunk-cgsxyw07.js +0 -2
- package/bin/chunk-dckdnqc0.js +0 -2
- package/bin/chunk-dx0wz749.js +0 -211
- package/bin/chunk-dz4fdrmk.js +0 -1
- package/bin/chunk-hz9stgvn.js +0 -1
- package/bin/chunk-hzr8100w.js +0 -3
- package/bin/chunk-jb6d142z.js +0 -1
- package/bin/chunk-k9cgfzgk.js +0 -3
- package/bin/chunk-meyvvmgk.js +0 -1
- package/bin/chunk-n1b3pt17.js +0 -14
- package/bin/chunk-n5v48hz5.js +0 -2
- package/bin/chunk-phzemmmy.js +0 -2
- package/bin/chunk-qhzat67w.js +0 -2
- package/bin/chunk-smcn7ep7.js +0 -2
- package/bin/chunk-tf8q7h6b.js +0 -1
- package/bin/chunk-tvr5rm1g.js +0 -1
- package/bin/chunk-ty88m3yg.js +0 -2
- package/bin/chunk-v2x9915x.js +0 -1
- package/bin/chunk-vnk2p7mq.css +0 -1
- package/bin/chunk-x8hky9td.js +0 -1
- package/bin/chunk-y12ah7c6.js +0 -1
- package/bin/chunk-y7jz31ay.js +0 -1
- package/bin/chunk-ydk3edsw.js +0 -1
- package/bin/chunk-zbma2zeh.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{m,D,_,u,S,L,t,o,Z,mt,Re,A,O,sn,C,fE,z,dn,Bo,sf,Ke,vt,wt,at}from"./chunk-42hrvk6k.js";import{Ti}from"./chunk-w4yjgez6.js";import{Gl,ns}from"./chunk-04avc4fn.js";import{$l}from"./chunk-0asthrjf.js";import{Mi}from"./chunk-6jkjx0n2.js";import{jl,ql}from"./chunk-mneeg71d.js";import{Ir}from"./chunk-bpxw19ez.js";import{sr}from"./chunk-9zgqjdx1.js";S();function Ci({shareId:r,initialFolderId:ye,initialFileId:G,startTime:J,versionId:F,compare:Ie,compareLeftId:k,compareRightId:j,compareActiveSide:Y="left"}){let f=Re(),T=Bo(),w=!!Ie&&!!k&&!!j,[c,ee]=u(()=>localStorage.getItem(`share_pwd_${r}`)||""),[V,Fe]=u(""),{data:a,error:b,isLoading:be}=Z({queryKey:["share-info",r,c],queryFn:async()=>{let e=await A.api.shares[":shareId"].info.$get({param:{shareId:r}},{headers:{"x-share-password":c}});if(e.status===401)throw Error("Unauthorized");if(e.status===403){let s=await e.json();throw Error(s.error||"Forbidden")}if(!e.ok)throw Error("Failed to fetch share info");return await e.json()},retry:!1}),n=ye||a?.rootFolderId,d=G||null,U=F||d,[B,te]=u([]),{data:E}=Z({queryKey:["public-share-folder",r,n,c],queryFn:async()=>{let e=await A.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:n}},{headers:{"x-share-password":c}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!a&&!!n});m(()=>{if(E?.ancestorFolders&&a){let e=E.ancestorFolders.findIndex((s)=>s.id===a.rootFolderId);if(e!==-1)te(E.ancestorFolders.slice(0,e));else if(n===a.rootFolderId)te([])}},[E,a,n]);let[q,h]=u(null),[v,p]=u(new Set),[Se,Pe]=u(360),[W,Ne]=u(()=>!G),P=_(null),[se,R]=u([]),[ke,ae]=u(0),[Ce,H]=u(null),[oe,Ae]=u(null),[je,ze]=u(void 0),{data:M,fetchNextPage:re,hasNextPage:ne,isFetchingNextPage:ie,isLoading:le,error:de}=mt({queryKey:["public-share-children",r,n,"folder",c],queryFn:async({pageParam:e})=>{let s=await A.api.shares[":shareId"].folders[":folderId"].children.$get({param:{shareId:r,folderId:n},query:{assetType:"folder",after:e}},{headers:{"x-share-password":c}});if(s.status===401)throw Error("Unauthorized");if(s.status===403)throw Error("Expired");return await s.json()},enabled:!!a&&!!n,initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,retry:!1}),{data:K,fetchNextPage:ce,hasNextPage:fe,isFetchingNextPage:ue,isLoading:pe}=mt({queryKey:["public-share-children",r,n,"file",c],queryFn:async({pageParam:e})=>{let s=await A.api.shares[":shareId"].folders[":folderId"].children.$get({param:{shareId:r,folderId:n},query:{assetType:"file",after:e}},{headers:{"x-share-password":c}});if(s.status===401)throw Error("Unauthorized");if(s.status===403)throw Error("Expired");return await s.json()},enabled:!!a&&!!n,initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,retry:!1}),{data:me}=Z({queryKey:["public-share-fields",r,c],queryFn:async()=>{let e=await A.api.shares[":shareId"].fields.$get({param:{shareId:r}},{headers:{"x-share-password":c}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!a}),{data:g,isLoading:De}=Z({queryKey:["public-share-file",r,d,c],queryFn:async()=>{let e=await A.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:d}},{headers:{"x-share-password":c}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!d&&!!a}),{data:Te,isLoading:$e}=Z({queryKey:["public-share-file",r,F,c],queryFn:async()=>{let e=await A.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:F}},{headers:{"x-share-password":c}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!F&&!!a}),i=F?Te:g,Ee=De||!!F&&$e;m(()=>{if(de?.message==="Unauthorized")ee(""),localStorage.removeItem(`share_pwd_${r}`)},[de,r]);let x=D(()=>M?.pages.flatMap((e)=>e.data??[])??[],[M]),y=D(()=>K?.pages.flatMap((e)=>e.data??[])??[],[K]),Le=M?.pages[0]?.pageInfo?.total,qe=K?.pages[0]?.pageInfo?.total,Me=M?.pages[0]?.pageInfo?.totalSize,Ve=K?.pages[0]?.pageInfo?.totalSize,he=D(()=>{if(i)return i;if(v.size!==1)return null;let e=Array.from(v)[0];return[...x,...y].find((s)=>s.id===e)||null},[v,x,y,i]),Ue=(e)=>{e.preventDefault(),ee(V),localStorage.setItem(`share_pwd_${r}`,V)},ge=(e)=>{if(e.type==="folder"||e.targetType==="folder")f({to:"/share/$shareId/folders/$folderId",params:{shareId:r,folderId:e.id}});else f({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:e.versionStack?e.versionStack.id:e.id}});p(new Set)},_e=(e)=>{if(!a)return;let s=e==="root"?a.rootFolderId:e;if(s===a.rootFolderId)f({to:"/share/$shareId",params:{shareId:r}});else f({to:"/share/$shareId/folders/$folderId",params:{shareId:r,folderId:s}});p(new Set),h(null)},Be=(e)=>{H(e.id||null);let s=e.annotations;if(s&&s.length>0)R(s);else R([]);if(w){if(e.second!==null&&e.second!==void 0)ze({second:e.second,nonce:Date.now()});return}if(e.second!==null&&e.second!==void 0)P.current?.seekTo(e.second),P.current?.pause();else if(s&&s.length>0)P.current?.pause()},we=()=>{R([]),H(null)},We=()=>{R([]),H(null)},Q=(e)=>{if(!d)return;f({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:d},search:(s)=>({...s,...e})})},He=()=>{Q({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:Y==="left"?k:j})},{setProjectState:xe,clearProjectState:ve}=dn();m(()=>{if(a&&n){let e=n===a.rootFolderId?a.name:x.find((s)=>s.id===n)?.name||a.name;xe({teamId:"",projectId:a.projectId,projectName:a.name,ancestorFolders:B,currentAsset:{name:i?.name||e,type:d?"file":"folder",version:g?.versionStack?g.versionStack.versions.find((s)=>s.id===U)?.version??g.versionStack.versions.length:void 0,proxyType:i?.proxyType||null},isRootFolder:n===a.rootFolderId&&!d,isPublic:!0,shareId:r,fileId:d||void 0,allowDownload:a.allowDownload,downloadInfo:i?{originalKey:i.media?.original?.key,videoTranscodes:i.media?.videoTranscodes?.map((s)=>({key:s.key,width:s.width,height:s.height,resolution:s.resolution,hdr:s.hdr}))}:void 0,onFolderClick:_e,isRightSidebarCollapsed:W,onRightSidebarToggle:()=>Ne((s)=>!s),versions:g?.versionStack?.versions,compareMode:w,canCompareVersions:(g?.versionStack?.versions?.length??0)>=2,onCompareVersions:()=>{let s=Gl(g?.versionStack?.versions);if(!s||!d)return;f({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:d},search:(l)=>({...l,compare:!0,cmpLeft:s.left.id,cmpRight:s.right.id,cmpActive:"left"})})}})}return()=>ve()},[a,n,x,i,g,U,d,B,xe,ve,W,w,f,r]);let I;if(be&&!b)I=t("div",{className:"flex flex-1 items-center justify-center bg-background",children:t(O,{className:"h-8 w-8 animate-spin text-foreground"})});else if(b)if(b.message==="Unauthorized"){let e=c!=="";I=t("div",{className:"flex flex-1 items-center justify-center p-4",children:o(Ke,{className:"w-full max-w-md",children:[o(vt,{className:"text-center",children:[t("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:t(sn,{className:"h-6 w-6 text-primary"})}),t(wt,{children:fE()})]}),t(at,{children:o("form",{onSubmit:Ue,className:"space-y-4",children:[o("div",{className:"space-y-2",children:[t(z,{type:"password",placeholder:"Enter password",value:V,onChange:(s)=>Fe(s.target.value),autoFocus:!0}),e&&t("p",{className:"text-sm font-medium text-destructive",children:"Incorrect password. Please try again."})]}),t(C,{type:"submit",className:"w-full",children:"Access Share"})]})})]})})}else{let e=b.message.includes("expired"),s=b.message.includes("disabled");I=t("div",{className:"flex flex-1 items-center justify-center p-4",children:o(Ke,{className:"w-full max-w-md",children:[o(vt,{className:"text-center",children:[t("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:t(sr,{className:"h-6 w-6 text-destructive"})}),t(wt,{children:e?"Share Expired":s?"Share Disabled":"Error"})]}),t(at,{className:"text-center text-muted-foreground",children:b.message})]})})}else if(!a)I=t("div",{className:"flex flex-1 items-center justify-center bg-background",children:t(O,{className:"h-8 w-8 animate-spin text-foreground"})});else if(T&&d&&!w&&i){let e=i?.ancestorFolders?.[0]?.id||(n!==a.rootFolderId?n:void 0),s=i?.ancestorFolders&&i.ancestorFolders.length>0?i.ancestorFolders:B;I=t(jl,{projectId:a.projectId,fileId:d,file:i,projectInfo:{name:a.name,rootFolder:a.rootFolderId},ancestorFolders:s,versions:g?.versionStack?.versions??i?.versionStack?.versions,activeFileId:U||d,startTime:J,isPublic:!0,shareId:r,allowDownload:a.allowDownload,publicFields:me,siblingFiles:y,onNavigateToFile:(l)=>{f({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:l}})},onNavigateBack:()=>{if(e&&e!==a.rootFolderId)f({to:"/share/$shareId/folders/$folderId",params:{shareId:r,folderId:e}});else f({to:"/share/$shareId",params:{shareId:r}})},onSelectVersion:(l)=>{f({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:d},search:(N)=>({...N,version:l})})},onSaveField:()=>{}})}else I=o("div",{className:"flex flex-1 overflow-hidden relative",children:[d?o("div",{className:"flex-1 relative bg-muted/30",children:[Ee&&!w&&t("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:t(O,{className:"h-8 w-8 animate-spin text-foreground"})}),w&&k&&j?t(ql,{isPublic:!0,shareId:r,versions:i?.versionStack?.versions??[],leftId:k,rightId:j,activeSide:Y,annotations:se,seekRequest:je,allowDownload:a.allowDownload,onActiveSideChange:(e)=>Q({cmpActive:e}),onSwitchVersion:(e,s)=>Q(e==="left"?{cmpLeft:s}:{cmpRight:s}),onExit:He,onActiveAssetChange:Ae,onPlay:we,onTimeUpdate:ae}):i&&t(ns,{file:i,mediaControllerRef:P,onPlay:we,onTimeUpdate:ae,onSeek:We,annotations:se,startTime:J,shareId:r,allowDownload:a.allowDownload})]}):n&&(T?t($l,{teamId:"",projectId:a.projectId,assetId:n,folders:x,files:y,totalFolders:Le,totalFiles:qe,totalFoldersSize:Me,totalFilesSize:Ve,selectedItem:q,selectedIds:v,onItemSelect:(e,s)=>{if(s.metaKey||s.ctrlKey){let l=new Set(v);if(l.has(e.id)){if(l.delete(e.id),p(l),q?.id===e.id){let N=[...x,...y].find((X)=>l.has(X.id));h(N||null)}}else l.add(e.id),p(l),h(e)}else p(new Set([e.id])),h(e)},onItemDoubleClick:ge,onClearSelection:()=>{p(new Set),h(null)},fetchNextFoldersPage:re,hasNextFoldersPage:ne,isFetchingNextFoldersPage:ie,fetchNextFilesPage:ce,hasNextFilesPage:fe,isFetchingNextFilesPage:ue,isLoading:le||pe,isShareView:!0,isPublic:!0,shareId:r,allowDownload:a.allowDownload}):t(Ti,{teamId:"",projectId:a.projectId,assetId:n,folders:x,files:y,selectedItem:q,selectedIds:v,onItemSelect:(e,s)=>{if(s.metaKey||s.ctrlKey){let l=new Set(v);if(l.has(e.id)){if(l.delete(e.id),p(l),q?.id===e.id){let N=[...x,...y].find((X)=>l.has(X.id));h(N||null)}}else l.add(e.id),p(l),h(e)}else p(new Set([e.id])),h(e)},onItemDoubleClick:ge,onSaveField:()=>{},displayStyle:a.viewMode??"card",onClearSelection:()=>{p(new Set),h(null)},fetchNextFoldersPage:re,hasNextFoldersPage:ne,isFetchingNextFoldersPage:ie,fetchNextFilesPage:ce,hasNextFilesPage:fe,isFetchingNextFilesPage:ue,isLoading:le||pe,isShareView:!0,isPublic:!0,shareId:r,sharePassword:c,allowDownload:a.allowDownload})),!W&&!T&&o(L,{children:[t(Ir,{onResize:(e)=>Pe((s)=>Math.max(240,Math.min(600,s-e)))}),t("div",{style:{width:Se},className:"flex-shrink-0 border-l",children:t(Mi,{teamId:"",projectId:a.projectId,file:w?oe:he,onSaveField:()=>{},members:[],readOnly:!0,publicFields:me,onCommentSelect:Be,isPublic:!0,shareId:r,currentTime:ke,onTyping:()=>{P.current?.pause()},selectedCommentId:Ce,hideAnnotationControl:(w?oe:he)?.proxyType==="audio"})})]})]});return o("div",{className:"flex h-[100dvh] flex-col bg-background",children:[(!T||!d)&&t(sf,{}),I]})}
|
|
2
|
+
export{Ci};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u,S,L,t,o,O,ve,we,C,an,ln,cn,un,Ce,Ie,Te,ge,Ae,_e,Oc,bi,t0,r0,l0,c0,u0,Om,De,qs,Ih,tv,sv,lv,jv,kw,Rw,Rx,Px,Vc,RE,bp,DE,Rl,NC,DC,$s,UI,$d,Hp,Xe,et,tt,rt,nt,ot,st,it,ue,ae,pe,le,z,M}from"./chunk-42hrvk6k.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-d2dgazjj.js";S();function Kl({open:F,onOpenChange:V,title:H,members:_,isOwner:i,onInvite:g,onUpdateRole:D,onRemoveMember:y,currentUserId:U,availableMembersToAdd:b,onAddMember:c,type:n="team"}){let[x,A]=u("editor"),[m,T]=u(null),[j,R]=u(!1),[f,p]=u(null),[l,w]=u(null),[I,k]=u({}),[s,d]=u(null),v=(e)=>{if(!e)return"";switch(e.toLowerCase()){case"owner":return Vc();case"editor":return qs();case"reviewer":return $s();default:return e}},B=(e,a)=>{k((r)=>({...r,[e]:a}))},q=async(e,a)=>{if(!D)return;p(e);try{await D(e,a),M.success(Px())}catch(r){console.error(r),M.error(lv())}finally{p(null)}},E=async()=>{if(!y||!l?.id)return;p(l.id);try{await y(l.id),M.success(Rx()),w(null)}catch(e){console.error(e),M.error(sv())}finally{p(null)}},J=async()=>{if(!g)return;R(!0);try{let e=await g(x),a=`${window.location.origin}/signup?inviteCode=${e}`;T(a)}catch(e){console.error(e),M.error(tv())}finally{R(!1)}},K=async()=>{if(m){if(await fo(m))M.success(kw())}},h=(e)=>{if(!e)return"??";return e.split(" ").map((a)=>a[0]).slice(0,2).join("").toUpperCase()},Q=(e)=>{if(!e)T(null),A("editor"),k({}),d(null);V(e)},N=Array.isArray(_)?_:[],W=Array.isArray(b)?b:[],X=n==="project"&&i?N.filter((e)=>e.role==="owner"||e.scope==="project"||e.hasCustomRole):N,P=n==="project"&&i?N.filter((e)=>e.scope==="team"&&e.role!=="owner"&&!e.hasCustomRole):[],G=n==="project"&&i?W.filter((e)=>e.scope==="project"):[];return t(ue,{open:F,onOpenChange:Q,children:o(ae,{className:"sm:max-w-xl",onOpenAutoFocus:(e)=>e.preventDefault(),children:[t(pe,{children:t(le,{children:H})}),o("div",{className:"space-y-4",children:[t("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:X.map((e)=>{let a=n==="team"&&e.scope==="project";return o("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[o("div",{className:"flex items-center gap-3",children:[o(Ce,{children:[e.image&&t(Ie,{src:e.image,alt:e.name,className:"object-cover"}),t(Te,{children:h(e.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:e.name}),o("div",{className:"flex items-center gap-2",children:[!a&&t("span",{className:"text-xs text-muted-foreground capitalize",children:v(e.role)}),e.scope&&o(L,{children:[!a&&t("span",{className:"text-[10px] text-muted-foreground/70",children:"•"}),t("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?Hp():bp()})]})]})]})]}),i&&e.role!=="owner"&&e.id!==U&&o("div",{className:"flex items-center gap-2",children:[a?t(an,{children:o(ln,{children:[t(cn,{asChild:!0,children:t("span",{children:t(C,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26 justify-between",disabled:!0,children:t(ve,{className:"ml-auto h-3 w-3 opacity-50"})})})}),t(un,{side:"top",children:t("p",{className:"text-xs",children:DE()})})]})}):o(ge,{children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:f===e.id,children:[v(e.role),t(ve,{className:"ml-1 h-3 w-3 opacity-50"})]})}),t(_e,{children:o(Oc,{value:e.role,onValueChange:(r)=>q(e.id,r),children:[t(bi,{value:"editor",className:"text-xs",children:qs()}),t(bi,{value:"reviewer",className:"text-xs",children:$s()})]})})]}),t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>w(e),disabled:f===e.id,children:f===e.id?t(O,{className:"h-3 w-3 animate-spin"}):t(we,{className:"h-3 w-3"})})]})]},e.id)})}),t(Xe,{open:!!l,onOpenChange:(e)=>!e&&w(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:NC()}),t(ot,{children:DC({name:l?.name||"",type:n==="project"?RE():$d()})})]}),o(rt,{children:[t(it,{children:De()}),t(st,{onClick:E,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Rl()})]})]})})," ",i&&c&&P.length>0&&o("div",{className:"border-t pt-4",children:[t("h4",{className:"text-sm font-medium mb-1",children:l0()}),t("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:c0()}),t("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:P.map((e)=>{let a=I[e.id]||"editor";return o("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[o("div",{className:"flex items-center gap-3",children:[o(Ce,{children:[e.image&&t(Ie,{src:e.image,alt:e.name,className:"object-cover"}),t(Te,{children:h(e.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:e.name}),t("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?Hp():bp()})]})]}),o("div",{className:"flex items-center gap-2",children:[o(ge,{children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:s===e.id,children:[v(a),t(ve,{className:"ml-1 h-3 w-3 opacity-50"})]})}),t(_e,{children:o(Oc,{value:a,onValueChange:(r)=>B(e.id,r),children:[t(bi,{value:"editor",className:"text-xs",children:qs()}),t(bi,{value:"reviewer",className:"text-xs",children:$s()})]})})]}),t(C,{onClick:async()=>{d(e.id);try{await c(e.id,a),M.success(Om({name:e.name||""}))}catch(r){console.error(r),M.error(Ih({name:e.name||""}))}finally{d(null)}},disabled:s!==null,size:"sm",className:"h-8 text-xs px-3",children:s===e.id?t(O,{className:"h-3 w-3 animate-spin"}):UI()})]})]},e.id)})})]}),i&&c&&G.length>0&&o("div",{className:"border-t pt-4",children:[t("h4",{className:"text-sm font-medium mb-1",children:t0()}),t("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:r0()}),t("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:G.map((e)=>{let a=I[e.id]||"editor";return o("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[o("div",{className:"flex items-center gap-3",children:[o(Ce,{children:[e.image&&t(Ie,{src:e.image,alt:e.name,className:"object-cover"}),t(Te,{children:h(e.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:e.name}),t("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?Hp():bp()})]})]}),o("div",{className:"flex items-center gap-2",children:[o(ge,{children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:s===e.id,children:[v(a),t(ve,{className:"ml-1 h-3 w-3 opacity-50"})]})}),t(_e,{children:o(Oc,{value:a,onValueChange:(r)=>B(e.id,r),children:[t(bi,{value:"editor",className:"text-xs",children:qs()}),t(bi,{value:"reviewer",className:"text-xs",children:$s()})]})})]}),t(C,{onClick:async()=>{d(e.id);try{await c(e.id,a),M.success(Om({name:e.name||""}))}catch(r){console.error(r),M.error(Ih({name:e.name||""}))}finally{d(null)}},disabled:s!==null,size:"sm",className:"h-8 text-xs px-3",children:s===e.id?t(O,{className:"h-3 w-3 animate-spin"}):u0()})]})]},e.id)})})]}),i&&g&&o("div",{className:"border-t pt-4",children:[t("h4",{className:"text-sm font-medium mb-3",children:Rw()}),o("div",{className:"space-y-3",children:[o("div",{className:"flex gap-2",children:[o(ge,{children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",className:"w-[120px] justify-between",children:[x==="editor"?qs():$s(),t(ve,{className:"h-4 w-4 opacity-50"})]})}),t(_e,{children:o(Oc,{value:x,onValueChange:(e)=>A(e),children:[t(bi,{value:"editor",children:qs()}),t(bi,{value:"reviewer",children:$s()})]})})]}),o(C,{onClick:J,disabled:j,className:"flex-1",children:[j&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),jv()]})]}),m&&o("div",{className:"flex gap-2",children:[t(z,{value:m,readOnly:!0}),t(C,{variant:"outline",size:"icon",onClick:K,children:t(Nr,{className:"h-4 w-4"})})]})]})]})]})]})})}
|
|
2
|
+
export{Kl};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Rs}from"./chunk-grsgkkrb.js";import{dr,Zt,rl,gf,ko,Af,nl,$i,qr,sr,de,Gt,ku,Ye,_c,ls,Gi,Ru,yc,Ms,Pu,Ro,bc,cs,ho,_f,zt,Oe,pr}from"./chunk-31vx01aw.js";import{ii,ol,sl}from"./chunk-q5mkbnr9.js";import{On,Qt,qo,ks,ai,Nu,li,Am,Kt,Mr,p,Kn,je,_m,Ln,Sn,Bt,us,ds,Zn,Xr,En}from"./chunk-0yv0nnmh.js";var _=p({is(e){return e.kind==="AlterTableNode"},create(e){return p({kind:"AlterTableNode",table:e})},cloneWithTableProps(e,t){return p({...e,...t})},cloneWithColumnAlteration(e,t){return p({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,t]:[t]})}});var M=p({is(e){return e.kind==="CreateIndexNode"},create(e){return p({kind:"CreateIndexNode",name:je.create(e)})},cloneWith(e,t){return p({...e,...t})},cloneWithColumns(e,t){return p({...e,columns:[...e.columns||[],...t]})}});var De=p({is(e){return e.kind==="CreateSchemaNode"},create(e,t){return p({kind:"CreateSchemaNode",schema:je.create(e),...t})},cloneWith(e,t){return p({...e,...t})}});var H=p({is(e){return e.kind==="DropIndexNode"},create(e,t){return p({kind:"DropIndexNode",name:Sn.create(e),...t})},cloneWith(e,t){return p({...e,...t})}});var Ce=p({is(e){return e.kind==="DropSchemaNode"},create(e,t){return p({kind:"DropSchemaNode",schema:je.create(e),...t})},cloneWith(e,t){return p({...e,...t})}});var Te=p({is(e){return e.kind==="DropTableNode"},create(e,t){return p({kind:"DropTableNode",table:e,...t})},cloneWith(e,t){return p({...e,...t})}});var Ke=p({is(e){return e.kind==="AddColumnNode"},create(e){return p({kind:"AddColumnNode",column:e})}});var b=p({is(e){return e.kind==="ColumnDefinitionNode"},create(e,t){return p({kind:"ColumnDefinitionNode",column:Zt.create(e),dataType:t})},cloneWithFrontModifier(e,t){return p({...e,frontModifiers:e.frontModifiers?p([...e.frontModifiers,t]):[t]})},cloneWithEndModifier(e,t){return p({...e,endModifiers:e.endModifiers?p([...e.endModifiers,t]):[t]})},cloneWith(e,t){return p({...e,...t})}});var Ge=p({is(e){return e.kind==="DropColumnNode"},create(e){return p({kind:"DropColumnNode",column:Zt.create(e)})}});var Je=p({is(e){return e.kind==="RenameColumnNode"},create(e,t){return p({kind:"RenameColumnNode",column:Zt.create(e),renameTo:Zt.create(t)})}});var ie=p({is(e){return e.kind==="CheckConstraintNode"},create(e,t){return p({kind:"CheckConstraintNode",expression:e,name:t?je.create(t):void 0})}});var vt=["no action","restrict","cascade","set null","set default"],se=p({is(e){return e.kind==="ReferencesNode"},create(e,t){return p({kind:"ReferencesNode",table:e,columns:p([...t])})},cloneWithOnDelete(e,t){return p({...e,onDelete:t})},cloneWithOnUpdate(e,t){return p({...e,onUpdate:t})}});function Se(e){return dr(e)?e.toOperationNode():qr.createImmediate(e)}var ge=p({is(e){return e.kind==="GeneratedNode"},create(e){return p({kind:"GeneratedNode",...e})},createWithExpression(e){return p({kind:"GeneratedNode",always:!0,expression:e})},cloneWith(e,t){return p({...e,...t})}});var qt=p({is(e){return e.kind==="DefaultValueNode"},create(e){return p({kind:"DefaultValueNode",defaultValue:e})}});function ae(e){if(vt.includes(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}class I{#e;constructor(e){this.#e=e}autoIncrement(){return new I(b.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new I(b.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new I(b.cloneWith(this.#e,{primaryKey:!0}))}references(e){let t=ko(e);if(!t.table||rl.is(t.column))throw Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new I(b.cloneWith(this.#e,{references:se.create(t.table,[t.column])}))}onDelete(e){if(!this.#e.references)throw Error("on delete constraint can only be added for foreign keys");return new I(b.cloneWith(this.#e,{references:se.cloneWithOnDelete(this.#e.references,ae(e))}))}onUpdate(e){if(!this.#e.references)throw Error("on update constraint can only be added for foreign keys");return new I(b.cloneWith(this.#e,{references:se.cloneWithOnUpdate(this.#e.references,ae(e))}))}unique(){return new I(b.cloneWith(this.#e,{unique:!0}))}notNull(){return new I(b.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new I(b.cloneWith(this.#e,{unsigned:!0}))}defaultTo(e){return new I(b.cloneWith(this.#e,{defaultTo:qt.create(Se(e))}))}check(e){return new I(b.cloneWith(this.#e,{check:ie.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new I(b.cloneWith(this.#e,{generated:ge.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new I(b.cloneWith(this.#e,{generated:ge.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new I(b.cloneWith(this.#e,{generated:ge.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw Error("stored() can only be called after generatedAlwaysAs");return new I(b.cloneWith(this.#e,{generated:ge.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(e){return new I(b.cloneWithFrontModifier(this.#e,e.toOperationNode()))}nullsNotDistinct(){return new I(b.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new I(b.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(e){return new I(b.cloneWithEndModifier(this.#e,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}}var He=p({is(e){return e.kind==="ModifyColumnNode"},create(e){return p({kind:"ModifyColumnNode",column:e})}});var W=p({is(e){return e.kind==="ForeignKeyConstraintNode"},create(e,t,r,n){return p({kind:"ForeignKeyConstraintNode",columns:e,references:se.create(t,r),name:n?je.create(n):void 0})},cloneWith(e,t){return p({...e,...t})}});class P{#e;constructor(e){this.#e=e}onDelete(e){return new P(W.cloneWith(this.#e,{onDelete:ae(e)}))}onUpdate(e){return new P(W.cloneWith(this.#e,{onUpdate:ae(e)}))}deferrable(){return new P(W.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new P(W.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new P(W.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new P(W.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}var ce=p({is(e){return e.kind==="AddConstraintNode"},create(e){return p({kind:"AddConstraintNode",constraint:e})}});var R=p({is(e){return e.kind==="UniqueConstraintNode"},create(e,t,r){return p({kind:"UniqueConstraintNode",columns:p(e.map(Zt.create)),name:t?je.create(t):void 0,nullsNotDistinct:r})},cloneWith(e,t){return p({...e,...t})}});var ue=p({is(e){return e.kind==="DropConstraintNode"},create(e){return p({kind:"DropConstraintNode",constraintName:je.create(e)})},cloneWith(e,t){return p({...e,...t})}});var le=p({is(e){return e.kind==="AlterColumnNode"},create(e,t,r){return p({kind:"AlterColumnNode",column:Zt.create(e),[t]:r})}});class ke{#e;constructor(e){this.#e=e}setDataType(e){return new me(le.create(this.#e,"dataType",cs(e)))}setDefault(e){return new me(le.create(this.#e,"setDefault",Se(e)))}dropDefault(){return new me(le.create(this.#e,"dropDefault",!0))}setNotNull(){return new me(le.create(this.#e,"setNotNull",!0))}dropNotNull(){return new me(le.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}}class me{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}}class Y{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class j{#e;constructor(e){this.#e=p(e)}onDelete(e){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(e)})}onUpdate(e){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(e)})}deferrable(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class re{#e;constructor(e){this.#e=p(e)}ifExists(){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var V=p({is(e){return e.kind==="PrimaryKeyConstraintNode"},create(e,t){return p({kind:"PrimaryKeyConstraintNode",columns:p(e.map(Zt.create)),name:t?je.create(t):void 0})},cloneWith(e,t){return p({...e,...t})}});var X=p({is(e){return e.kind==="AddIndexNode"},create(e){return p({kind:"AddIndexNode",name:je.create(e)})},cloneWith(e,t){return p({...e,...t})},cloneWithColumns(e,t){return p({...e,columns:[...e.columns||[],...t]})}});class Z{#e;constructor(e){this.#e=p(e)}unique(){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWithColumns(this.#e.node.addIndex,[nl(e)])})})}columns(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWithColumns(this.#e.node.addIndex,e.map(nl))})})}expression(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWithColumns(this.#e.node.addIndex,[e.toOperationNode()])})})}using(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWith(this.#e.node.addIndex,{using:Bt.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Q{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new Q(R.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new Q(R.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new Q(R.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new Q(R.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new Q(R.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class U{#e;constructor(e){this.#e=e}deferrable(){return new U(V.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new U(V.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new U(V.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new U(V.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class Ee{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}}var Dt=p({is(e){return e.kind==="RenameConstraintNode"},create(e,t){return p({kind:"RenameConstraintNode",oldName:je.create(e),newName:je.create(t)})}});class Xe{#e;constructor(e){this.#e=p(e)}renameTo(e){return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{renameTo:zt(e)})})}setSchema(e){return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{setSchema:je.create(e)})})}alterColumn(e,t){let r=t(new ke(e));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}dropColumn(e){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ge.create(e))})}renameColumn(e,t){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Je.create(e,t))})}addColumn(e,t,r=Kn){let n=r(new I(b.create(e,cs(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ke.create(n.toOperationNode()))})}modifyColumn(e,t,r=Kn){let n=r(new I(b.create(e,cs(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,He.create(n.toOperationNode()))})}addUniqueConstraint(e,t,r=Kn){let n=r(new Q(R.create(t,e)));return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(n.toOperationNode())})})}addCheckConstraint(e,t,r=Kn){let n=r(new Ee(ie.create(t.toOperationNode(),e)));return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(n.toOperationNode())})})}addForeignKeyConstraint(e,t,r,n,o=Kn){let d=o(new P(W.create(t.map(Zt.create),zt(r),n.map(Zt.create),e)));return new j({...this.#e,constraintBuilder:d})}addPrimaryKeyConstraint(e,t,r=Kn){let n=r(new U(V.create(t,e)));return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(n.toOperationNode())})})}dropConstraint(e){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.create(e)})})}renameConstraint(e,t){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{renameConstraint:Dt.create(e,t)})})}addIndex(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.create(e)})})}dropIndex(e){return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropIndex:H.create(e)})})}$call(e){return e(this)}}class L{#e;constructor(e){this.#e=p(e)}alterColumn(e,t){let r=t(new ke(e));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}dropColumn(e){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ge.create(e))})}renameColumn(e,t){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Je.create(e,t))})}addColumn(e,t,r=Kn){let n=r(new I(b.create(e,cs(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ke.create(n.toOperationNode()))})}modifyColumn(e,t,r=Kn){let n=r(new I(b.create(e,cs(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,He.create(n.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class be extends _c{transformPrimitiveValueList(e){return $i.create(e.values.map(qr.createImmediate))}transformValue(e){return qr.createImmediate(e.value)}}class S{#e;constructor(e){this.#e=p(e)}ifNotExists(){return new S({...this.#e,node:M.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new S({...this.#e,node:M.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new S({...this.#e,node:M.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(e){return new S({...this.#e,node:M.cloneWith(this.#e.node,{table:zt(e)})})}column(e){return new S({...this.#e,node:M.cloneWithColumns(this.#e.node,[nl(e)])})}columns(e){return new S({...this.#e,node:M.cloneWithColumns(this.#e.node,e.map(nl))})}expression(e){return new S({...this.#e,node:M.cloneWithColumns(this.#e.node,[e.toOperationNode()])})}using(e){return new S({...this.#e,node:M.cloneWith(this.#e.node,{using:Bt.createWithSql(e)})})}where(...e){let t=new be;return new S({...this.#e,node:de.cloneWithWhere(this.#e.node,t.transformNode(sr(e),this.#e.queryId))})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Me{#e;constructor(e){this.#e=p(e)}ifNotExists(){return new Me({...this.#e,node:De.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function Ot(e){if(_m.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}class O{#e;constructor(e){this.#e=p(e)}temporary(){return new O({...this.#e,node:Ln.cloneWith(this.#e.node,{temporary:!0})})}onCommit(e){return new O({...this.#e,node:Ln.cloneWith(this.#e.node,{onCommit:Ot(e)})})}ifNotExists(){return new O({...this.#e,node:Ln.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(e,t,r=Kn){let n=r(new I(b.create(e,cs(t))));return new O({...this.#e,node:Ln.cloneWithColumn(this.#e.node,n.toOperationNode())})}addPrimaryKeyConstraint(e,t,r=Kn){let n=r(new U(V.create(t,e)));return new O({...this.#e,node:Ln.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addUniqueConstraint(e,t,r=Kn){let n=r(new Q(R.create(t,e)));return new O({...this.#e,node:Ln.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addCheckConstraint(e,t,r=Kn){let n=r(new Ee(ie.create(t.toOperationNode(),e)));return new O({...this.#e,node:Ln.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addForeignKeyConstraint(e,t,r,n,o=Kn){let d=o(new P(W.create(t.map(Zt.create),zt(r),n.map(Zt.create),e)));return new O({...this.#e,node:Ln.cloneWithConstraint(this.#e.node,d.toOperationNode())})}modifyFront(e){return new O({...this.#e,node:Ln.cloneWithFrontModifier(this.#e.node,e.toOperationNode())})}modifyEnd(e){return new O({...this.#e,node:Ln.cloneWithEndModifier(this.#e.node,e.toOperationNode())})}as(e){return new O({...this.#e,node:Ln.cloneWith(this.#e.node,{selectQuery:ho(e)})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class he{#e;constructor(e){this.#e=p(e)}on(e){return new he({...this.#e,node:H.cloneWith(this.#e.node,{table:zt(e)})})}ifExists(){return new he({...this.#e,node:H.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new he({...this.#e,node:H.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Ie{#e;constructor(e){this.#e=p(e)}ifExists(){return new Ie({...this.#e,node:Ce.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new Ie({...this.#e,node:Ce.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Ae{#e;constructor(e){this.#e=p(e)}ifExists(){return new Ae({...this.#e,node:Te.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new Ae({...this.#e,node:Te.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Ze{#e=new be;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}}class B{#e;constructor(e){this.#e=p(e)}temporary(){return new B({...this.#e,node:ds.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new B({...this.#e,node:ds.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new B({...this.#e,node:ds.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new B({...this.#e,node:ds.cloneWith(this.#e.node,{orReplace:!0})})}columns(e){return new B({...this.#e,node:ds.cloneWith(this.#e.node,{columns:e.map(Af)})})}as(e){let t=e.withPlugin(new Ze).toOperationNode();return new B({...this.#e,node:ds.cloneWith(this.#e.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var pe=p({is(e){return e.kind==="DropViewNode"},create(e){return p({kind:"DropViewNode",name:Sn.create(e)})},cloneWith(e,t){return p({...e,...t})}});class fe{#e;constructor(e){this.#e=p(e)}materialized(){return new fe({...this.#e,node:pe.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new fe({...this.#e,node:pe.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new fe({...this.#e,node:pe.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var We=p({is(e){return e.kind==="CreateTypeNode"},create(e){return p({kind:"CreateTypeNode",name:e})},cloneWithEnum(e,t){return p({...e,enum:$i.create(t.map(qr.createImmediate))})}});class Pe{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(e){return new Pe({...this.#e,node:We.cloneWithEnum(this.#e.node,e)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var Le=p({is(e){return e.kind==="DropTypeNode"},create(e){return p({kind:"DropTypeNode",name:e})},cloneWith(e,t){return p({...e,...t})}});class Re{#e;constructor(e){this.#e=p(e)}ifExists(){return new Re({...this.#e,node:Le.cloneWith(this.#e.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function et(e){if(e.includes(".")){let r=e.split(".").map(Xt);if(r.length===2)return Sn.createWithSchema(r[0],r[1]);else throw Error(`invalid schemable identifier ${e}`)}else return Sn.create(e)}function Xt(e){return e.trim()}var ye=p({is(e){return e.kind==="RefreshMaterializedViewNode"},create(e){return p({kind:"RefreshMaterializedViewNode",name:Sn.create(e)})},cloneWith(e,t){return p({...e,...t})}});class we{#e;constructor(e){this.#e=p(e)}concurrently(){return new we({...this.#e,node:ye.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new we({...this.#e,node:ye.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new we({...this.#e,node:ye.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class xe{#e;constructor(e){this.#e=e}createTable(e){return new O({queryId:Ye(),executor:this.#e,node:Ln.create(zt(e))})}dropTable(e){return new Ae({queryId:Ye(),executor:this.#e,node:Te.create(zt(e))})}createIndex(e){return new S({queryId:Ye(),executor:this.#e,node:M.create(e)})}dropIndex(e){return new he({queryId:Ye(),executor:this.#e,node:H.create(e)})}createSchema(e){return new Me({queryId:Ye(),executor:this.#e,node:De.create(e)})}dropSchema(e){return new Ie({queryId:Ye(),executor:this.#e,node:Ce.create(e)})}alterTable(e){return new Xe({queryId:Ye(),executor:this.#e,node:_.create(zt(e))})}createView(e){return new B({queryId:Ye(),executor:this.#e,node:ds.create(e)})}refreshMaterializedView(e){return new we({queryId:Ye(),executor:this.#e,node:ye.create(e)})}dropView(e){return new fe({queryId:Ye(),executor:this.#e,node:pe.create(e)})}createType(e){return new Pe({queryId:Ye(),executor:this.#e,node:We.create(et(e))})}dropType(e){return new Re({queryId:Ye(),executor:this.#e,node:Le.create(et(e))})}withPlugin(e){return new xe(this.#e.withPlugin(e))}withoutPlugins(){return new xe(this.#e.withoutPlugins())}withSchema(e){return new xe(this.#e.withPluginAtFront(new ls(e)))}}class tt{ref(e){return new gf(e)}table(e){return new _f(e)}}class rt{#e;constructor(e){this.#e=e}async provideConnection(e){let t=await this.#e.acquireConnection();try{return await e(t)}finally{await this.#e.releaseConnection(t)}}}class ee extends yc{#e;#t;#r;constructor(e,t,r,n=[]){super(n);this.#e=e,this.#t=t,this.#r=r}get adapter(){return this.#t}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e){return this.#r.provideConnection(e)}withPlugins(e){return new ee(this.#e,this.#t,this.#r,[...this.plugins,...e])}withPlugin(e){return new ee(this.#e,this.#t,this.#r,[...this.plugins,e])}withPluginAtFront(e){return new ee(this.#e,this.#t,this.#r,[e,...this.plugins])}withConnectionProvider(e){return new ee(this.#e,this.#t,e,[...this.plugins])}withoutPlugins(){return new ee(this.#e,this.#t,this.#r,[])}}function Qe(){if(typeof performance<"u"&&Kt(performance.now))return performance.now();else return Date.now()}class nt{#e;#t;#r;#n;#o;#i=new WeakSet;constructor(e,t){this.#n=!1,this.#e=e,this.#t=t}async init(){if(this.#o)throw Error("driver has already been destroyed");if(!this.#r)this.#r=this.#e.init().then(()=>{this.#n=!0}).catch((e)=>(this.#r=void 0,Promise.reject(e)));await this.#r}async acquireConnection(){if(this.#o)throw Error("driver has already been destroyed");if(!this.#n)await this.init();let e=await this.#e.acquireConnection();if(!this.#i.has(e)){if(this.#a())this.#c(e);this.#i.add(e)}return e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,t){return this.#e.beginTransaction(e,t)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,t,r){if(this.#e.savepoint)return this.#e.savepoint(e,t,r);throw Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,t,r){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,t,r);throw Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,t,r){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,t,r);throw Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){if(!this.#r)return;if(await this.#r,!this.#o)this.#o=this.#e.destroy().catch((e)=>(this.#o=void 0,Promise.reject(e)));await this.#o}#a(){return this.#t.isLevelEnabled("query")||this.#t.isLevelEnabled("error")}#c(e){let{executeQuery:t,streamQuery:r}=e,n=this;e.executeQuery=async(o)=>{let d,l=Qe();try{return await t.call(e,o)}catch(g){throw d=g,await n.#s(g,o,l),g}finally{if(!d)await n.#u(o,l)}},e.streamQuery=async function*(o,d){let l,g=Qe();try{for await(let A of r.call(e,o,d))yield A}catch(A){throw l=A,await n.#s(A,o,g),A}finally{if(!l)await n.#u(o,g,!0)}}}async#s(e,t,r){await this.#t.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#l(r)}))}async#u(e,t,r=!1){await this.#t.query(()=>({level:"query",isStream:r,query:e,queryDurationMillis:this.#l(t)}))}#l(e){return Qe()-e}}var er=()=>{};class ve{#e;#t;constructor(e){this.#e=e}async provideConnection(e){while(this.#t)await this.#t.catch(er);return this.#t=this.#r(e).finally(()=>{this.#t=void 0}),this.#t}async#r(e){return await e(this.#e)}}var tr=["read only","read write"],rr=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function ot(e){if(e.accessMode&&!tr.includes(e.accessMode))throw Error(`invalid transaction access mode ${e.accessMode}`);if(e.isolationLevel&&!rr.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}var nr=["query","error"],Ra=p(nr);class it{#e;#t;constructor(e){if(Kt(e))this.#t=e,this.#e=p({query:!0,error:!0});else this.#t=or,this.#e=p({query:e.includes("query"),error:e.includes("error")})}isLevelEnabled(e){return this.#e[e]}async query(e){if(this.#e.query)await this.#t(e())}async error(e){if(this.#e.error)await this.#t(e())}}function or(e){if(e.level==="query"){let t=`kysely:query:${e.isStream?"stream:":""}`;console.log(`${t} ${e.query.sql}`),console.log(`${t} duration: ${e.queryDurationMillis.toFixed(1)}ms`)}else if(e.level==="error")if(e.error instanceof Error)console.error(`kysely:error: ${e.error.stack??e.error.message}`);else console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`)}function St(e){return Mr(e)&&Kt(e.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");class F extends Ms{#e;constructor(e){let t,r;if(ir(e))t={executor:e.executor},r={...e};else{let n=e.dialect,o=n.createDriver(),d=n.createQueryCompiler(),l=n.createAdapter(),g=new it(e.log??[]),A=new nt(o,g),D=new rt(A),z=new ee(d,l,D,e.plugins??[]);t={executor:z},r={config:e,executor:z,dialect:n,driver:A}}super(t);this.#e=p(r)}get schema(){return new xe(this.#e.executor)}get dynamic(){return new tt}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new bc({node:Ro.create(On(e)?void 0:ho(e))})}get fn(){return Pu()}transaction(){return new $e({...this.#e})}startTransaction(){return new Fe({...this.#e})}connection(){return new kt({...this.#e})}withPlugin(e){return new F({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new F({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new F({...this.#e,executor:this.#e.executor.withPluginAtFront(new ls(e))})}withTables(){return new F({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(e,t){if(t!==void 0)us("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");let r=St(e)?e.compile():e;return this.getExecutor().executeQuery(r)}async[Symbol.asyncDispose](){await this.destroy()}}class oe extends F{#e;constructor(e){super(e);this.#e=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 oe({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new oe({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new oe({...this.#e,executor:this.#e.executor.withPluginAtFront(new ls(e))})}withTables(){return new oe({...this.#e})}}function ir(e){return Mr(e)&&Mr(e.config)&&Mr(e.driver)&&Mr(e.executor)&&Mr(e.dialect)}class kt{#e;constructor(e){this.#e=p(e)}async execute(e){return this.#e.executor.provideConnection(async(t)=>{let r=this.#e.executor.withConnectionProvider(new ve(t)),n=new F({...this.#e,executor:r});return await e(n)})}}class $e{#e;constructor(e){this.#e=p(e)}setAccessMode(e){return new $e({...this.#e,accessMode:e})}setIsolationLevel(e){return new $e({...this.#e,isolationLevel:e})}async execute(e){let{isolationLevel:t,accessMode:r,...n}=this.#e,o={isolationLevel:t,accessMode:r};return ot(o),this.#e.executor.provideConnection(async(d)=>{let l={isCommitted:!1,isRolledBack:!1},g=new G(this.#e.executor.withConnectionProvider(new ve(d)),l),A=new oe({...n,executor:g}),D=!1;try{await this.#e.driver.beginTransaction(d,o),D=!0;let z=await e(A);return await this.#e.driver.commitTransaction(d),l.isCommitted=!0,z}catch(z){if(D)await this.#e.driver.rollbackTransaction(d),l.isRolledBack=!0;throw z}})}}class Fe{#e;constructor(e){this.#e=p(e)}setAccessMode(e){return new Fe({...this.#e,accessMode:e})}setIsolationLevel(e){return new Fe({...this.#e,isolationLevel:e})}async execute(){let{isolationLevel:e,accessMode:t,...r}=this.#e,n={isolationLevel:e,accessMode:t};ot(n);let o=await Ru(this.#e.executor);return await this.#e.driver.beginTransaction(o.connection,n),new K({...r,connection:o,executor:this.#e.executor.withConnectionProvider(new ve(o.connection))})}}class K extends oe{#e;#t;#r;constructor(e){let t={isCommitted:!1,isRolledBack:!1};e={...e,executor:new G(e.executor,t)};let{connection:r,...n}=e;super(n);this.#e=p(e),this.#r=t;let o=Ye();this.#t=(d)=>e.executor.compileQuery(d,o)}get isCommitted(){return this.#r.isCommitted}get isRolledBack(){return this.#r.isRolledBack}commit(){return ne(this.#r),new Ne(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#r.isCommitted=!0,this.#e.connection.release()})}rollback(){return ne(this.#r),new Ne(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#r.isRolledBack=!0,this.#e.connection.release()})}savepoint(e){return ne(this.#r),new Ne(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,e,this.#t),new K({...this.#e})))}rollbackToSavepoint(e){return ne(this.#r),new Ne(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,e,this.#t),new K({...this.#e})))}releaseSavepoint(e){return ne(this.#r),new Ne(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,e,this.#t),new K({...this.#e})))}withPlugin(e){return new K({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new K({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new K({...this.#e,executor:this.#e.executor.withPluginAtFront(new ls(e))})}withTables(){return new K({...this.#e})}}class Ne{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}}function ne(e){if(e.isCommitted)throw Error("Transaction is already committed");if(e.isRolledBack)throw Error("Transaction is already rolled back")}class G{#e;#t;constructor(e,t){if(e instanceof G)this.#e=e.#e;else this.#e=e;this.#t=t}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,t){return this.#e.transformQuery(e,t)}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e){return this.#e.provideConnection(e)}executeQuery(e){return ne(this.#t),this.#e.executeQuery(e)}stream(e,t){return ne(this.#t),this.#e.stream(e,t)}withConnectionProvider(e){return new G(this.#e.withConnectionProvider(e),this.#t)}withPlugin(e){return new G(this.#e.withPlugin(e),this.#t)}withPlugins(e){return new G(this.#e.withPlugins(e),this.#t)}withPluginAtFront(e){return new G(this.#e.withPluginAtFront(e),this.#t)}withoutPlugins(){return new G(this.#e.withoutPlugins(),this.#t)}}function k(e,t){return Bt.createWithChildren([Bt.createWithSql(`${e} `),je.create(t)])}class st{#e;#t=new Wt;#r;#n;constructor(e){this.#e=p({...e})}async init(){if(this.#r=Kt(this.#e.database)?await this.#e.database():this.#e.database,this.#n=new Mt(this.#r),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#n)}async acquireConnection(){return await this.#t.lock(),this.#n}async beginTransaction(e){await e.executeQuery(pr.raw("begin"))}async commitTransaction(e){await e.executeQuery(pr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(pr.raw("rollback"))}async savepoint(e,t,r){await e.executeQuery(r(k("savepoint",t),Ye()))}async rollbackToSavepoint(e,t,r){await e.executeQuery(r(k("rollback to",t),Ye()))}async releaseSavepoint(e,t,r){await e.executeQuery(r(k("release",t),Ye()))}async releaseConnection(){this.#t.unlock()}async destroy(){this.#r?.close()}}class Mt{#e;constructor(e){this.#e=e}executeQuery(e){let{sql:t,parameters:r}=e,n=this.#e.prepare(t);if(n.reader)return Promise.resolve({rows:n.all(r)});let{changes:o,lastInsertRowid:d}=n.run(r);return Promise.resolve({numAffectedRows:o!==void 0&&o!==null?BigInt(o):void 0,insertId:d!==void 0&&d!==null?BigInt(d):void 0,rows:[]})}async*streamQuery(e,t){let{sql:r,parameters:n,query:o}=e,d=this.#e.prepare(r);if(Gt.is(o)){let l=d.iterate(n);for(let g of l)yield{rows:[g]}}else throw Error("Sqlite driver only supports streaming of select queries")}}class Wt{#e;#t;async lock(){while(this.#e)await this.#e;this.#e=new Promise((e)=>{this.#t=e})}unlock(){let e=this.#t;this.#e=void 0,this.#t=void 0,e?.()}}class at{#e;constructor(e){this.#e=e}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){return await this.#r(e)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e,t){let r=e.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select(["name","sql","type"]).orderBy("name");if(!t.withInternalKyselyTables)r=r.where("name","!=",Xr).where("name","!=",En);return r}async#r(e){let t=await this.#t(this.#e,e).execute(),r=await this.#e.with("table_list",(o)=>this.#t(o,e)).selectFrom(["table_list as tl",Oe`pragma_table_info(tl.name)`.as("p")]).select(["tl.name as table","p.cid","p.name","p.type","p.notnull","p.dflt_value","p.pk"]).orderBy("tl.name").orderBy("p.cid").execute(),n={};for(let o of r)n[o.table]??=[],n[o.table].push(o);return t.map(({name:o,sql:d,type:l})=>{let g=d?.split(/[\(\),]/)?.find((D)=>D.toLowerCase().includes("autoincrement"))?.trimStart()?.split(/\s+/)?.[0]?.replace(/["`]/g,""),A=n[o]??[];if(!g){let D=A.filter((z)=>z.pk>0);if(D.length===1&&D[0].type.toLowerCase()==="integer")g=D[0].name}return{name:o,isView:l==="view",columns:A.map((D)=>({name:D.name,dataType:D.type,isNullable:!D.notnull,isAutoIncrementing:D.name===g,hasDefaultValue:D.dflt_value!=null,comment:void 0}))}})}}class ze{#e;constructor(e){this.#e=p({...e})}createDriver(){return new st(this.#e)}createQueryCompiler(){return new ol}createAdapter(){return new sl}createIntrospector(e){return new at(e)}}var ar=/"/g;class ct extends Zn{sanitizeIdentifier(e){return e.replace(ar,'""')}}class ut{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map((t)=>({name:t.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.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",Oe`col_description(a.attrelid, a.attnum)`.as("column_description"),Oe`pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as("auto_incrementing")]).where("c.relkind","in",["r","v","p"]).where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema").where("ns.nspname","!=","crdb_internal").where(Oe`has_schema_privilege(ns.nspname, 'USAGE')`).where("a.attnum",">=",0).where("a.attisdropped","!=",!0).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();if(!e.withInternalKyselyTables)t=t.where("c.relname","!=",Xr).where("c.relname","!=",En);let r=await t.execute();return this.#t(r)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e){let t=new Map;for(let r=0,n=e.length;r<n;r++){let o=e[r],{schema:d,table:l}=o,g=`schema:${d};table:${l}`;if(!t.has(g))t.set(g,p({columns:[],isView:o.table_type==="v",name:l,schema:d}));t.get(g).columns.push(p({comment:o.column_description??void 0,dataType:o.type,dataTypeSchema:o.type_schema,hasDefaultValue:o.has_default,isAutoIncrementing:o.auto_incrementing!==null,isNullable:!o.not_null,name:o.column}))}return Array.from(t.values())}}var cr=BigInt("3853314791062309107");class lt extends ii{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,t){await Oe`select pg_advisory_xact_lock(${Oe.lit(cr)})`.execute(e)}async releaseMigrationLock(e,t){}}function _e(e,t){if(ur(e)&&t.stack){let r=t.stack.split(`
|
|
2
|
+
import{Ds}from"./chunk-19q13a80.js";import{pr,Zt,ol,yf,Po,bf,sl,$i,Hr,ir,fe,Gt,Ru,Je,bc,cs,Gi,Pu,vc,Ps,Nu,No,wc,us,Ao,vf,zt,Oe,mr}from"./chunk-mn208vrv.js";import{li,il,al}from"./chunk-f5z3096k.js";import{Fn,Qt,$o,Ns,ci,Du,ui,bm,Kt,Mr,p,Yn,je,vm,Zn,En,Bt,ds,fs,Bn,en,Cn}from"./chunk-w73v578p.js";var _=p({is(e){return e.kind==="AlterTableNode"},create(e){return p({kind:"AlterTableNode",table:e})},cloneWithTableProps(e,t){return p({...e,...t})},cloneWithColumnAlteration(e,t){return p({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,t]:[t]})}});var M=p({is(e){return e.kind==="CreateIndexNode"},create(e){return p({kind:"CreateIndexNode",name:je.create(e)})},cloneWith(e,t){return p({...e,...t})},cloneWithColumns(e,t){return p({...e,columns:[...e.columns||[],...t]})}});var De=p({is(e){return e.kind==="CreateSchemaNode"},create(e,t){return p({kind:"CreateSchemaNode",schema:je.create(e),...t})},cloneWith(e,t){return p({...e,...t})}});var H=p({is(e){return e.kind==="DropIndexNode"},create(e,t){return p({kind:"DropIndexNode",name:En.create(e),...t})},cloneWith(e,t){return p({...e,...t})}});var Ce=p({is(e){return e.kind==="DropSchemaNode"},create(e,t){return p({kind:"DropSchemaNode",schema:je.create(e),...t})},cloneWith(e,t){return p({...e,...t})}});var Te=p({is(e){return e.kind==="DropTableNode"},create(e,t){return p({kind:"DropTableNode",table:e,...t})},cloneWith(e,t){return p({...e,...t})}});var Ke=p({is(e){return e.kind==="AddColumnNode"},create(e){return p({kind:"AddColumnNode",column:e})}});var b=p({is(e){return e.kind==="ColumnDefinitionNode"},create(e,t){return p({kind:"ColumnDefinitionNode",column:Zt.create(e),dataType:t})},cloneWithFrontModifier(e,t){return p({...e,frontModifiers:e.frontModifiers?p([...e.frontModifiers,t]):[t]})},cloneWithEndModifier(e,t){return p({...e,endModifiers:e.endModifiers?p([...e.endModifiers,t]):[t]})},cloneWith(e,t){return p({...e,...t})}});var Ge=p({is(e){return e.kind==="DropColumnNode"},create(e){return p({kind:"DropColumnNode",column:Zt.create(e)})}});var He=p({is(e){return e.kind==="RenameColumnNode"},create(e,t){return p({kind:"RenameColumnNode",column:Zt.create(e),renameTo:Zt.create(t)})}});var ie=p({is(e){return e.kind==="CheckConstraintNode"},create(e,t){return p({kind:"CheckConstraintNode",expression:e,name:t?je.create(t):void 0})}});var vt=["no action","restrict","cascade","set null","set default"],se=p({is(e){return e.kind==="ReferencesNode"},create(e,t){return p({kind:"ReferencesNode",table:e,columns:p([...t])})},cloneWithOnDelete(e,t){return p({...e,onDelete:t})},cloneWithOnUpdate(e,t){return p({...e,onUpdate:t})}});function Se(e){return pr(e)?e.toOperationNode():Hr.createImmediate(e)}var ge=p({is(e){return e.kind==="GeneratedNode"},create(e){return p({kind:"GeneratedNode",...e})},createWithExpression(e){return p({kind:"GeneratedNode",always:!0,expression:e})},cloneWith(e,t){return p({...e,...t})}});var qt=p({is(e){return e.kind==="DefaultValueNode"},create(e){return p({kind:"DefaultValueNode",defaultValue:e})}});function ae(e){if(vt.includes(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}class I{#e;constructor(e){this.#e=e}autoIncrement(){return new I(b.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new I(b.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new I(b.cloneWith(this.#e,{primaryKey:!0}))}references(e){let t=Po(e);if(!t.table||ol.is(t.column))throw Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new I(b.cloneWith(this.#e,{references:se.create(t.table,[t.column])}))}onDelete(e){if(!this.#e.references)throw Error("on delete constraint can only be added for foreign keys");return new I(b.cloneWith(this.#e,{references:se.cloneWithOnDelete(this.#e.references,ae(e))}))}onUpdate(e){if(!this.#e.references)throw Error("on update constraint can only be added for foreign keys");return new I(b.cloneWith(this.#e,{references:se.cloneWithOnUpdate(this.#e.references,ae(e))}))}unique(){return new I(b.cloneWith(this.#e,{unique:!0}))}notNull(){return new I(b.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new I(b.cloneWith(this.#e,{unsigned:!0}))}defaultTo(e){return new I(b.cloneWith(this.#e,{defaultTo:qt.create(Se(e))}))}check(e){return new I(b.cloneWith(this.#e,{check:ie.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new I(b.cloneWith(this.#e,{generated:ge.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new I(b.cloneWith(this.#e,{generated:ge.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new I(b.cloneWith(this.#e,{generated:ge.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw Error("stored() can only be called after generatedAlwaysAs");return new I(b.cloneWith(this.#e,{generated:ge.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(e){return new I(b.cloneWithFrontModifier(this.#e,e.toOperationNode()))}nullsNotDistinct(){return new I(b.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new I(b.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(e){return new I(b.cloneWithEndModifier(this.#e,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}}var Ye=p({is(e){return e.kind==="ModifyColumnNode"},create(e){return p({kind:"ModifyColumnNode",column:e})}});var W=p({is(e){return e.kind==="ForeignKeyConstraintNode"},create(e,t,r,n){return p({kind:"ForeignKeyConstraintNode",columns:e,references:se.create(t,r),name:n?je.create(n):void 0})},cloneWith(e,t){return p({...e,...t})}});class P{#e;constructor(e){this.#e=e}onDelete(e){return new P(W.cloneWith(this.#e,{onDelete:ae(e)}))}onUpdate(e){return new P(W.cloneWith(this.#e,{onUpdate:ae(e)}))}deferrable(){return new P(W.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new P(W.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new P(W.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new P(W.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}var ce=p({is(e){return e.kind==="AddConstraintNode"},create(e){return p({kind:"AddConstraintNode",constraint:e})}});var R=p({is(e){return e.kind==="UniqueConstraintNode"},create(e,t,r){return p({kind:"UniqueConstraintNode",columns:p(e.map(Zt.create)),name:t?je.create(t):void 0,nullsNotDistinct:r})},cloneWith(e,t){return p({...e,...t})}});var ue=p({is(e){return e.kind==="DropConstraintNode"},create(e){return p({kind:"DropConstraintNode",constraintName:je.create(e)})},cloneWith(e,t){return p({...e,...t})}});var le=p({is(e){return e.kind==="AlterColumnNode"},create(e,t,r){return p({kind:"AlterColumnNode",column:Zt.create(e),[t]:r})}});class ke{#e;constructor(e){this.#e=e}setDataType(e){return new me(le.create(this.#e,"dataType",us(e)))}setDefault(e){return new me(le.create(this.#e,"setDefault",Se(e)))}dropDefault(){return new me(le.create(this.#e,"dropDefault",!0))}setNotNull(){return new me(le.create(this.#e,"setNotNull",!0))}dropNotNull(){return new me(le.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}}class me{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}}class Y{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class j{#e;constructor(e){this.#e=p(e)}onDelete(e){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(e)})}onUpdate(e){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(e)})}deferrable(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new j({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class re{#e;constructor(e){this.#e=p(e)}ifExists(){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var V=p({is(e){return e.kind==="PrimaryKeyConstraintNode"},create(e,t){return p({kind:"PrimaryKeyConstraintNode",columns:p(e.map(Zt.create)),name:t?je.create(t):void 0})},cloneWith(e,t){return p({...e,...t})}});var X=p({is(e){return e.kind==="AddIndexNode"},create(e){return p({kind:"AddIndexNode",name:je.create(e)})},cloneWith(e,t){return p({...e,...t})},cloneWithColumns(e,t){return p({...e,columns:[...e.columns||[],...t]})}});class Z{#e;constructor(e){this.#e=p(e)}unique(){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWithColumns(this.#e.node.addIndex,[sl(e)])})})}columns(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWithColumns(this.#e.node.addIndex,e.map(sl))})})}expression(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWithColumns(this.#e.node.addIndex,[e.toOperationNode()])})})}using(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.cloneWith(this.#e.node.addIndex,{using:Bt.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Q{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new Q(R.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new Q(R.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new Q(R.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new Q(R.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new Q(R.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class U{#e;constructor(e){this.#e=e}deferrable(){return new U(V.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new U(V.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new U(V.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new U(V.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class Ee{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}}var Dt=p({is(e){return e.kind==="RenameConstraintNode"},create(e,t){return p({kind:"RenameConstraintNode",oldName:je.create(e),newName:je.create(t)})}});class Xe{#e;constructor(e){this.#e=p(e)}renameTo(e){return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{renameTo:zt(e)})})}setSchema(e){return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{setSchema:je.create(e)})})}alterColumn(e,t){let r=t(new ke(e));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}dropColumn(e){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ge.create(e))})}renameColumn(e,t){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,He.create(e,t))})}addColumn(e,t,r=Yn){let n=r(new I(b.create(e,us(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ke.create(n.toOperationNode()))})}modifyColumn(e,t,r=Yn){let n=r(new I(b.create(e,us(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ye.create(n.toOperationNode()))})}addUniqueConstraint(e,t,r=Yn){let n=r(new Q(R.create(t,e)));return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(n.toOperationNode())})})}addCheckConstraint(e,t,r=Yn){let n=r(new Ee(ie.create(t.toOperationNode(),e)));return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(n.toOperationNode())})})}addForeignKeyConstraint(e,t,r,n,o=Yn){let d=o(new P(W.create(t.map(Zt.create),zt(r),n.map(Zt.create),e)));return new j({...this.#e,constraintBuilder:d})}addPrimaryKeyConstraint(e,t,r=Yn){let n=r(new U(V.create(t,e)));return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addConstraint:ce.create(n.toOperationNode())})})}dropConstraint(e){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropConstraint:ue.create(e)})})}renameConstraint(e,t){return new re({...this.#e,node:_.cloneWithTableProps(this.#e.node,{renameConstraint:Dt.create(e,t)})})}addIndex(e){return new Z({...this.#e,node:_.cloneWithTableProps(this.#e.node,{addIndex:X.create(e)})})}dropIndex(e){return new Y({...this.#e,node:_.cloneWithTableProps(this.#e.node,{dropIndex:H.create(e)})})}$call(e){return e(this)}}class L{#e;constructor(e){this.#e=p(e)}alterColumn(e,t){let r=t(new ke(e));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}dropColumn(e){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ge.create(e))})}renameColumn(e,t){return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,He.create(e,t))})}addColumn(e,t,r=Yn){let n=r(new I(b.create(e,us(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ke.create(n.toOperationNode()))})}modifyColumn(e,t,r=Yn){let n=r(new I(b.create(e,us(t))));return new L({...this.#e,node:_.cloneWithColumnAlteration(this.#e.node,Ye.create(n.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class be extends bc{transformPrimitiveValueList(e){return $i.create(e.values.map(Hr.createImmediate))}transformValue(e){return Hr.createImmediate(e.value)}}class S{#e;constructor(e){this.#e=p(e)}ifNotExists(){return new S({...this.#e,node:M.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new S({...this.#e,node:M.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new S({...this.#e,node:M.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(e){return new S({...this.#e,node:M.cloneWith(this.#e.node,{table:zt(e)})})}column(e){return new S({...this.#e,node:M.cloneWithColumns(this.#e.node,[sl(e)])})}columns(e){return new S({...this.#e,node:M.cloneWithColumns(this.#e.node,e.map(sl))})}expression(e){return new S({...this.#e,node:M.cloneWithColumns(this.#e.node,[e.toOperationNode()])})}using(e){return new S({...this.#e,node:M.cloneWith(this.#e.node,{using:Bt.createWithSql(e)})})}where(...e){let t=new be;return new S({...this.#e,node:fe.cloneWithWhere(this.#e.node,t.transformNode(ir(e),this.#e.queryId))})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Me{#e;constructor(e){this.#e=p(e)}ifNotExists(){return new Me({...this.#e,node:De.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function Ot(e){if(vm.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}class O{#e;constructor(e){this.#e=p(e)}temporary(){return new O({...this.#e,node:Zn.cloneWith(this.#e.node,{temporary:!0})})}onCommit(e){return new O({...this.#e,node:Zn.cloneWith(this.#e.node,{onCommit:Ot(e)})})}ifNotExists(){return new O({...this.#e,node:Zn.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(e,t,r=Yn){let n=r(new I(b.create(e,us(t))));return new O({...this.#e,node:Zn.cloneWithColumn(this.#e.node,n.toOperationNode())})}addPrimaryKeyConstraint(e,t,r=Yn){let n=r(new U(V.create(t,e)));return new O({...this.#e,node:Zn.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addUniqueConstraint(e,t,r=Yn){let n=r(new Q(R.create(t,e)));return new O({...this.#e,node:Zn.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addCheckConstraint(e,t,r=Yn){let n=r(new Ee(ie.create(t.toOperationNode(),e)));return new O({...this.#e,node:Zn.cloneWithConstraint(this.#e.node,n.toOperationNode())})}addForeignKeyConstraint(e,t,r,n,o=Yn){let d=o(new P(W.create(t.map(Zt.create),zt(r),n.map(Zt.create),e)));return new O({...this.#e,node:Zn.cloneWithConstraint(this.#e.node,d.toOperationNode())})}modifyFront(e){return new O({...this.#e,node:Zn.cloneWithFrontModifier(this.#e.node,e.toOperationNode())})}modifyEnd(e){return new O({...this.#e,node:Zn.cloneWithEndModifier(this.#e.node,e.toOperationNode())})}as(e){return new O({...this.#e,node:Zn.cloneWith(this.#e.node,{selectQuery:Ao(e)})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class de{#e;constructor(e){this.#e=p(e)}on(e){return new de({...this.#e,node:H.cloneWith(this.#e.node,{table:zt(e)})})}ifExists(){return new de({...this.#e,node:H.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new de({...this.#e,node:H.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Ie{#e;constructor(e){this.#e=p(e)}ifExists(){return new Ie({...this.#e,node:Ce.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new Ie({...this.#e,node:Ce.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Ae{#e;constructor(e){this.#e=p(e)}ifExists(){return new Ae({...this.#e,node:Te.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new Ae({...this.#e,node:Te.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class Ze{#e=new be;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}}class B{#e;constructor(e){this.#e=p(e)}temporary(){return new B({...this.#e,node:fs.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new B({...this.#e,node:fs.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new B({...this.#e,node:fs.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new B({...this.#e,node:fs.cloneWith(this.#e.node,{orReplace:!0})})}columns(e){return new B({...this.#e,node:fs.cloneWith(this.#e.node,{columns:e.map(bf)})})}as(e){let t=e.withPlugin(new Ze).toOperationNode();return new B({...this.#e,node:fs.cloneWith(this.#e.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var he=p({is(e){return e.kind==="DropViewNode"},create(e){return p({kind:"DropViewNode",name:En.create(e)})},cloneWith(e,t){return p({...e,...t})}});class pe{#e;constructor(e){this.#e=p(e)}materialized(){return new pe({...this.#e,node:he.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new pe({...this.#e,node:he.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new pe({...this.#e,node:he.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var We=p({is(e){return e.kind==="CreateTypeNode"},create(e){return p({kind:"CreateTypeNode",name:e})},cloneWithEnum(e,t){return p({...e,enum:$i.create(t.map(Hr.createImmediate))})}});class Pe{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(e){return new Pe({...this.#e,node:We.cloneWithEnum(this.#e.node,e)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}var Le=p({is(e){return e.kind==="DropTypeNode"},create(e){return p({kind:"DropTypeNode",name:e})},cloneWith(e,t){return p({...e,...t})}});class Re{#e;constructor(e){this.#e=p(e)}ifExists(){return new Re({...this.#e,node:Le.cloneWith(this.#e.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function et(e){if(e.includes(".")){let r=e.split(".").map(Xt);if(r.length===2)return En.createWithSchema(r[0],r[1]);else throw Error(`invalid schemable identifier ${e}`)}else return En.create(e)}function Xt(e){return e.trim()}var ye=p({is(e){return e.kind==="RefreshMaterializedViewNode"},create(e){return p({kind:"RefreshMaterializedViewNode",name:En.create(e)})},cloneWith(e,t){return p({...e,...t})}});class we{#e;constructor(e){this.#e=p(e)}concurrently(){return new we({...this.#e,node:ye.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new we({...this.#e,node:ye.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new we({...this.#e,node:ye.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class xe{#e;constructor(e){this.#e=e}createTable(e){return new O({queryId:Je(),executor:this.#e,node:Zn.create(zt(e))})}dropTable(e){return new Ae({queryId:Je(),executor:this.#e,node:Te.create(zt(e))})}createIndex(e){return new S({queryId:Je(),executor:this.#e,node:M.create(e)})}dropIndex(e){return new de({queryId:Je(),executor:this.#e,node:H.create(e)})}createSchema(e){return new Me({queryId:Je(),executor:this.#e,node:De.create(e)})}dropSchema(e){return new Ie({queryId:Je(),executor:this.#e,node:Ce.create(e)})}alterTable(e){return new Xe({queryId:Je(),executor:this.#e,node:_.create(zt(e))})}createView(e){return new B({queryId:Je(),executor:this.#e,node:fs.create(e)})}refreshMaterializedView(e){return new we({queryId:Je(),executor:this.#e,node:ye.create(e)})}dropView(e){return new pe({queryId:Je(),executor:this.#e,node:he.create(e)})}createType(e){return new Pe({queryId:Je(),executor:this.#e,node:We.create(et(e))})}dropType(e){return new Re({queryId:Je(),executor:this.#e,node:Le.create(et(e))})}withPlugin(e){return new xe(this.#e.withPlugin(e))}withoutPlugins(){return new xe(this.#e.withoutPlugins())}withSchema(e){return new xe(this.#e.withPluginAtFront(new cs(e)))}}class tt{ref(e){return new yf(e)}table(e){return new vf(e)}}class rt{#e;constructor(e){this.#e=e}async provideConnection(e){let t=await this.#e.acquireConnection();try{return await e(t)}finally{await this.#e.releaseConnection(t)}}}class ee extends vc{#e;#t;#r;constructor(e,t,r,n=[]){super(n);this.#e=e,this.#t=t,this.#r=r}get adapter(){return this.#t}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e){return this.#r.provideConnection(e)}withPlugins(e){return new ee(this.#e,this.#t,this.#r,[...this.plugins,...e])}withPlugin(e){return new ee(this.#e,this.#t,this.#r,[...this.plugins,e])}withPluginAtFront(e){return new ee(this.#e,this.#t,this.#r,[e,...this.plugins])}withConnectionProvider(e){return new ee(this.#e,this.#t,e,[...this.plugins])}withoutPlugins(){return new ee(this.#e,this.#t,this.#r,[])}}function Qe(){if(typeof performance<"u"&&Kt(performance.now))return performance.now();else return Date.now()}class nt{#e;#t;#r;#n;#o;#i=new WeakSet;constructor(e,t){this.#n=!1,this.#e=e,this.#t=t}async init(){if(this.#o)throw Error("driver has already been destroyed");if(!this.#r)this.#r=this.#e.init().then(()=>{this.#n=!0}).catch((e)=>(this.#r=void 0,Promise.reject(e)));await this.#r}async acquireConnection(){if(this.#o)throw Error("driver has already been destroyed");if(!this.#n)await this.init();let e=await this.#e.acquireConnection();if(!this.#i.has(e)){if(this.#a())this.#c(e);this.#i.add(e)}return e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,t){return this.#e.beginTransaction(e,t)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,t,r){if(this.#e.savepoint)return this.#e.savepoint(e,t,r);throw Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,t,r){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,t,r);throw Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,t,r){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,t,r);throw Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){if(!this.#r)return;if(await this.#r,!this.#o)this.#o=this.#e.destroy().catch((e)=>(this.#o=void 0,Promise.reject(e)));await this.#o}#a(){return this.#t.isLevelEnabled("query")||this.#t.isLevelEnabled("error")}#c(e){let{executeQuery:t,streamQuery:r}=e,n=this;e.executeQuery=async(o)=>{let d,l=Qe();try{return await t.call(e,o)}catch(g){throw d=g,await n.#s(g,o,l),g}finally{if(!d)await n.#u(o,l)}},e.streamQuery=async function*(o,d){let l,g=Qe();try{for await(let A of r.call(e,o,d))yield A}catch(A){throw l=A,await n.#s(A,o,g),A}finally{if(!l)await n.#u(o,g,!0)}}}async#s(e,t,r){await this.#t.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#l(r)}))}async#u(e,t,r=!1){await this.#t.query(()=>({level:"query",isStream:r,query:e,queryDurationMillis:this.#l(t)}))}#l(e){return Qe()-e}}var er=()=>{};class ve{#e;#t;constructor(e){this.#e=e}async provideConnection(e){while(this.#t)await this.#t.catch(er);return this.#t=this.#r(e).finally(()=>{this.#t=void 0}),this.#t}async#r(e){return await e(this.#e)}}var tr=["read only","read write"],rr=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function ot(e){if(e.accessMode&&!tr.includes(e.accessMode))throw Error(`invalid transaction access mode ${e.accessMode}`);if(e.isolationLevel&&!rr.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}var nr=["query","error"],Ra=p(nr);class it{#e;#t;constructor(e){if(Kt(e))this.#t=e,this.#e=p({query:!0,error:!0});else this.#t=or,this.#e=p({query:e.includes("query"),error:e.includes("error")})}isLevelEnabled(e){return this.#e[e]}async query(e){if(this.#e.query)await this.#t(e())}async error(e){if(this.#e.error)await this.#t(e())}}function or(e){if(e.level==="query"){let t=`kysely:query:${e.isStream?"stream:":""}`;console.log(`${t} ${e.query.sql}`),console.log(`${t} duration: ${e.queryDurationMillis.toFixed(1)}ms`)}else if(e.level==="error")if(e.error instanceof Error)console.error(`kysely:error: ${e.error.stack??e.error.message}`);else console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`)}function St(e){return Mr(e)&&Kt(e.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");class F extends Ps{#e;constructor(e){let t,r;if(sr(e))t={executor:e.executor},r={...e};else{let n=e.dialect,o=n.createDriver(),d=n.createQueryCompiler(),l=n.createAdapter(),g=new it(e.log??[]),A=new nt(o,g),D=new rt(A),z=new ee(d,l,D,e.plugins??[]);t={executor:z},r={config:e,executor:z,dialect:n,driver:A}}super(t);this.#e=p(r)}get schema(){return new xe(this.#e.executor)}get dynamic(){return new tt}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new wc({node:No.create(Fn(e)?void 0:Ao(e))})}get fn(){return Nu()}transaction(){return new $e({...this.#e})}startTransaction(){return new Fe({...this.#e})}connection(){return new kt({...this.#e})}withPlugin(e){return new F({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new F({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new F({...this.#e,executor:this.#e.executor.withPluginAtFront(new cs(e))})}withTables(){return new F({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(e,t){if(t!==void 0)ds("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");let r=St(e)?e.compile():e;return this.getExecutor().executeQuery(r)}async[Symbol.asyncDispose](){await this.destroy()}}class oe extends F{#e;constructor(e){super(e);this.#e=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 oe({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new oe({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new oe({...this.#e,executor:this.#e.executor.withPluginAtFront(new cs(e))})}withTables(){return new oe({...this.#e})}}function sr(e){return Mr(e)&&Mr(e.config)&&Mr(e.driver)&&Mr(e.executor)&&Mr(e.dialect)}class kt{#e;constructor(e){this.#e=p(e)}async execute(e){return this.#e.executor.provideConnection(async(t)=>{let r=this.#e.executor.withConnectionProvider(new ve(t)),n=new F({...this.#e,executor:r});return await e(n)})}}class $e{#e;constructor(e){this.#e=p(e)}setAccessMode(e){return new $e({...this.#e,accessMode:e})}setIsolationLevel(e){return new $e({...this.#e,isolationLevel:e})}async execute(e){let{isolationLevel:t,accessMode:r,...n}=this.#e,o={isolationLevel:t,accessMode:r};return ot(o),this.#e.executor.provideConnection(async(d)=>{let l={isCommitted:!1,isRolledBack:!1},g=new G(this.#e.executor.withConnectionProvider(new ve(d)),l),A=new oe({...n,executor:g}),D=!1;try{await this.#e.driver.beginTransaction(d,o),D=!0;let z=await e(A);return await this.#e.driver.commitTransaction(d),l.isCommitted=!0,z}catch(z){if(D)await this.#e.driver.rollbackTransaction(d),l.isRolledBack=!0;throw z}})}}class Fe{#e;constructor(e){this.#e=p(e)}setAccessMode(e){return new Fe({...this.#e,accessMode:e})}setIsolationLevel(e){return new Fe({...this.#e,isolationLevel:e})}async execute(){let{isolationLevel:e,accessMode:t,...r}=this.#e,n={isolationLevel:e,accessMode:t};ot(n);let o=await Pu(this.#e.executor);return await this.#e.driver.beginTransaction(o.connection,n),new K({...r,connection:o,executor:this.#e.executor.withConnectionProvider(new ve(o.connection))})}}class K extends oe{#e;#t;#r;constructor(e){let t={isCommitted:!1,isRolledBack:!1};e={...e,executor:new G(e.executor,t)};let{connection:r,...n}=e;super(n);this.#e=p(e),this.#r=t;let o=Je();this.#t=(d)=>e.executor.compileQuery(d,o)}get isCommitted(){return this.#r.isCommitted}get isRolledBack(){return this.#r.isRolledBack}commit(){return ne(this.#r),new Ne(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#r.isCommitted=!0,this.#e.connection.release()})}rollback(){return ne(this.#r),new Ne(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#r.isRolledBack=!0,this.#e.connection.release()})}savepoint(e){return ne(this.#r),new Ne(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,e,this.#t),new K({...this.#e})))}rollbackToSavepoint(e){return ne(this.#r),new Ne(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,e,this.#t),new K({...this.#e})))}releaseSavepoint(e){return ne(this.#r),new Ne(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,e,this.#t),new K({...this.#e})))}withPlugin(e){return new K({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new K({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new K({...this.#e,executor:this.#e.executor.withPluginAtFront(new cs(e))})}withTables(){return new K({...this.#e})}}class Ne{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}}function ne(e){if(e.isCommitted)throw Error("Transaction is already committed");if(e.isRolledBack)throw Error("Transaction is already rolled back")}class G{#e;#t;constructor(e,t){if(e instanceof G)this.#e=e.#e;else this.#e=e;this.#t=t}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,t){return this.#e.transformQuery(e,t)}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e){return this.#e.provideConnection(e)}executeQuery(e){return ne(this.#t),this.#e.executeQuery(e)}stream(e,t){return ne(this.#t),this.#e.stream(e,t)}withConnectionProvider(e){return new G(this.#e.withConnectionProvider(e),this.#t)}withPlugin(e){return new G(this.#e.withPlugin(e),this.#t)}withPlugins(e){return new G(this.#e.withPlugins(e),this.#t)}withPluginAtFront(e){return new G(this.#e.withPluginAtFront(e),this.#t)}withoutPlugins(){return new G(this.#e.withoutPlugins(),this.#t)}}function k(e,t){return Bt.createWithChildren([Bt.createWithSql(`${e} `),je.create(t)])}class st{#e;#t=new Wt;#r;#n;constructor(e){this.#e=p({...e})}async init(){if(this.#r=Kt(this.#e.database)?await this.#e.database():this.#e.database,this.#n=new Mt(this.#r),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#n)}async acquireConnection(){return await this.#t.lock(),this.#n}async beginTransaction(e){await e.executeQuery(mr.raw("begin"))}async commitTransaction(e){await e.executeQuery(mr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(mr.raw("rollback"))}async savepoint(e,t,r){await e.executeQuery(r(k("savepoint",t),Je()))}async rollbackToSavepoint(e,t,r){await e.executeQuery(r(k("rollback to",t),Je()))}async releaseSavepoint(e,t,r){await e.executeQuery(r(k("release",t),Je()))}async releaseConnection(){this.#t.unlock()}async destroy(){this.#r?.close()}}class Mt{#e;constructor(e){this.#e=e}executeQuery(e){let{sql:t,parameters:r}=e,n=this.#e.prepare(t);if(n.reader)return Promise.resolve({rows:n.all(r)});let{changes:o,lastInsertRowid:d}=n.run(r);return Promise.resolve({numAffectedRows:o!==void 0&&o!==null?BigInt(o):void 0,insertId:d!==void 0&&d!==null?BigInt(d):void 0,rows:[]})}async*streamQuery(e,t){let{sql:r,parameters:n,query:o}=e,d=this.#e.prepare(r);if(Gt.is(o)){let l=d.iterate(n);for(let g of l)yield{rows:[g]}}else throw Error("Sqlite driver only supports streaming of select queries")}}class Wt{#e;#t;async lock(){while(this.#e)await this.#e;this.#e=new Promise((e)=>{this.#t=e})}unlock(){let e=this.#t;this.#e=void 0,this.#t=void 0,e?.()}}class at{#e;constructor(e){this.#e=e}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){return await this.#r(e)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e,t){let r=e.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").select(["name","sql","type"]).orderBy("name");if(!t.withInternalKyselyTables)r=r.where("name","!=",en).where("name","!=",Cn);return r}async#r(e){let t=await this.#t(this.#e,e).execute(),r=await this.#e.with("table_list",(o)=>this.#t(o,e)).selectFrom(["table_list as tl",Oe`pragma_table_info(tl.name)`.as("p")]).select(["tl.name as table","p.cid","p.name","p.type","p.notnull","p.dflt_value","p.pk"]).orderBy("tl.name").orderBy("p.cid").execute(),n={};for(let o of r)n[o.table]??=[],n[o.table].push(o);return t.map(({name:o,sql:d,type:l})=>{let g=d?.split(/[\(\),]/)?.find((D)=>D.toLowerCase().includes("autoincrement"))?.trimStart()?.split(/\s+/)?.[0]?.replace(/["`]/g,""),A=n[o]??[];if(!g){let D=A.filter((z)=>z.pk>0);if(D.length===1&&D[0].type.toLowerCase()==="integer")g=D[0].name}return{name:o,isView:l==="view",columns:A.map((D)=>({name:D.name,dataType:D.type,isNullable:!D.notnull,isAutoIncrementing:D.name===g,hasDefaultValue:D.dflt_value!=null,comment:void 0}))}})}}class ze{#e;constructor(e){this.#e=p({...e})}createDriver(){return new st(this.#e)}createQueryCompiler(){return new il}createAdapter(){return new al}createIntrospector(e){return new at(e)}}var ar=/"/g;class ct extends Bn{sanitizeIdentifier(e){return e.replace(ar,'""')}}class ut{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map((t)=>({name:t.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.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",Oe`col_description(a.attrelid, a.attnum)`.as("column_description"),Oe`pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as("auto_incrementing")]).where("c.relkind","in",["r","v","p"]).where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema").where("ns.nspname","!=","crdb_internal").where(Oe`has_schema_privilege(ns.nspname, 'USAGE')`).where("a.attnum",">=",0).where("a.attisdropped","!=",!0).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();if(!e.withInternalKyselyTables)t=t.where("c.relname","!=",en).where("c.relname","!=",Cn);let r=await t.execute();return this.#t(r)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e){let t=new Map;for(let r=0,n=e.length;r<n;r++){let o=e[r],{schema:d,table:l}=o,g=`schema:${d};table:${l}`;if(!t.has(g))t.set(g,p({columns:[],isView:o.table_type==="v",name:l,schema:d}));t.get(g).columns.push(p({comment:o.column_description??void 0,dataType:o.type,dataTypeSchema:o.type_schema,hasDefaultValue:o.has_default,isAutoIncrementing:o.auto_incrementing!==null,isNullable:!o.not_null,name:o.column}))}return Array.from(t.values())}}var cr=BigInt("3853314791062309107");class lt extends li{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,t){await Oe`select pg_advisory_xact_lock(${Oe.lit(cr)})`.execute(e)}async releaseMigrationLock(e,t){}}function _e(e,t){if(ur(e)&&t.stack){let r=t.stack.split(`
|
|
3
3
|
`).slice(1).join(`
|
|
4
4
|
`);return e.stack+=`
|
|
5
|
-
${r}`,e}return e}function ur(e){return Mr(e)&&Qt(e.stack)}var Pt=Symbol();class mt{#e;#t=new WeakMap;#r;constructor(e){this.#e=p({...e})}async init(){this.#r=Kt(this.#e.pool)?await this.#e.pool():this.#e.pool}async acquireConnection(){let e=await this.#n(),t=this.#t.get(e);if(!t){if(t=new Lt(e),this.#t.set(e,t),this.#e?.onCreateConnection)await this.#e.onCreateConnection(t)}if(this.#e?.onReserveConnection)await this.#e.onReserveConnection(t);return t}async#n(){return new Promise((e,t)=>{this.#r.getConnection(async(r,n)=>{if(r)t(r);else e(n)})})}async beginTransaction(e,t){if(t.isolationLevel||t.accessMode){let r=[];if(t.isolationLevel)r.push(`isolation level ${t.isolationLevel}`);if(t.accessMode)r.push(t.accessMode);let n=`set transaction ${r.join(", ")}`;await e.executeQuery(pr.raw(n))}await e.executeQuery(pr.raw("begin"))}async commitTransaction(e){await e.executeQuery(pr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(pr.raw("rollback"))}async savepoint(e,t,r){await e.executeQuery(r(k("savepoint",t),Ye()))}async rollbackToSavepoint(e,t,r){await e.executeQuery(r(k("rollback to",t),Ye()))}async releaseSavepoint(e,t,r){await e.executeQuery(r(k("release savepoint",t),Ye()))}async releaseConnection(e){e[Pt]()}async destroy(){return new Promise((e,t)=>{this.#r.end((r)=>{if(r)t(r);else e()})})}}function lr(e){return Mr(e)&&"insertId"in e&&"affectedRows"in e}class Lt{#e;constructor(e){this.#e=e}async executeQuery(e){try{let t=await this.#t(e);if(lr(t)){let{insertId:r,affectedRows:n,changedRows:o}=t;return{insertId:r!==void 0&&r!==null&&r.toString()!=="0"?BigInt(r):void 0,numAffectedRows:n!==void 0&&n!==null?BigInt(n):void 0,numChangedRows:o!==void 0&&o!==null?BigInt(o):void 0,rows:[]}}else if(Array.isArray(t))return{rows:t};return{rows:[]}}catch(t){throw _e(t,Error())}}#t(e){return new Promise((t,r)=>{this.#e.query(e.sql,e.parameters,(n,o)=>{if(n)r(n);else t(o)})})}async*streamQuery(e,t){let r=this.#e.query(e.sql,e.parameters).stream({objectMode:!0});try{for await(let n of r)yield{rows:[n]}}catch(n){if(n&&typeof n==="object"&&"code"in n&&n.code==="ERR_STREAM_PREMATURE_CLOSE")return;throw n}}[Pt](){this.#e.release()}}var mr=/[\\']/g,dt=/`/g,hr=/[\\'"]/g;class ht extends Zn{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getExplainOptionAssignment(){return"="}getExplainOptionsDelimiter(){return" "}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return dt.source}getRightIdentifierWrapper(){return dt.source}sanitizeIdentifier(e){return e.replace(dt,"``")}sanitizeStringLiteral(e){return e.replace(mr,(t)=>t==="\\"?"\\\\":"''")}sanitizeJSONPathMemberValue(e){return e.replace(hr,(t)=>t==="\\"?"\\\\\\\\":t==="'"?"''":'\\\\"')}visitCreateIndex(e){if(this.append("create "),e.unique)this.append("unique ");if(this.append("index "),e.ifNotExists)this.append("if not exists ");if(this.visitNode(e.name),e.using)this.append(" using "),this.visitNode(e.using);if(e.table)this.append(" on "),this.visitNode(e.table);if(e.columns)this.append(" ("),this.compileList(e.columns),this.append(")");if(e.where)this.append(" "),this.visitNode(e.where)}}class pt{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom("information_schema.schemata").select("schema_name").$castTo().execute()).map((t)=>({name:t.SCHEMA_NAME}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom("information_schema.columns as columns").innerJoin("information_schema.tables as tables",(n)=>n.onRef("columns.TABLE_CATALOG","=","tables.TABLE_CATALOG").onRef("columns.TABLE_SCHEMA","=","tables.TABLE_SCHEMA").onRef("columns.TABLE_NAME","=","tables.TABLE_NAME")).select(["columns.COLUMN_NAME","columns.COLUMN_DEFAULT","columns.TABLE_NAME","columns.TABLE_SCHEMA","tables.TABLE_TYPE","columns.IS_NULLABLE","columns.DATA_TYPE","columns.EXTRA","columns.COLUMN_COMMENT"]).where("columns.TABLE_SCHEMA","=",Oe`database()`).orderBy("columns.TABLE_NAME").orderBy("columns.ORDINAL_POSITION").$castTo();if(!e.withInternalKyselyTables)t=t.where("columns.TABLE_NAME","!=",Xr).where("columns.TABLE_NAME","!=",En);let r=await t.execute();return this.#t(r)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e){return e.reduce((t,r)=>{let n=t.find((o)=>o.name===r.TABLE_NAME);if(!n)n=p({name:r.TABLE_NAME,isView:r.TABLE_TYPE==="VIEW",schema:r.TABLE_SCHEMA,columns:[]}),t.push(n);return n.columns.push(p({name:r.COLUMN_NAME,dataType:r.DATA_TYPE,isNullable:r.IS_NULLABLE==="YES",isAutoIncrementing:r.EXTRA.toLowerCase().includes("auto_increment"),hasDefaultValue:r.COLUMN_DEFAULT!==null,comment:r.COLUMN_COMMENT===""?void 0:r.COLUMN_COMMENT})),t},[])}}var Rt="ea586330-2c93-47c8-908d-981d9d270f9d",fr=3600;class ft extends ii{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}async acquireMigrationLock(e,t){await Oe`select get_lock(${Oe.lit(Rt)}, ${Oe.lit(fr)})`.execute(e)}async releaseMigrationLock(e,t){await Oe`select release_lock(${Oe.lit(Rt)})`.execute(e)}}class Ve{#e;constructor(e){this.#e=e}createDriver(){return new mt(this.#e)}createQueryCompiler(){return new ht}createAdapter(){return new ft}createIntrospector(e){return new pt(e)}}var $t=Symbol();class yt{#e;#t=new WeakMap;#r;constructor(e){this.#e=p({...e})}async init(){this.#r=Kt(this.#e.pool)?await this.#e.pool():this.#e.pool}async acquireConnection(){let e=await this.#r.connect(),t=this.#t.get(e);if(!t){if(t=new Ft(e,{cursor:this.#e.cursor??null}),this.#t.set(e,t),this.#e.onCreateConnection)await this.#e.onCreateConnection(t)}if(this.#e.onReserveConnection)await this.#e.onReserveConnection(t);return t}async beginTransaction(e,t){if(t.isolationLevel||t.accessMode){let r="start transaction";if(t.isolationLevel)r+=` isolation level ${t.isolationLevel}`;if(t.accessMode)r+=` ${t.accessMode}`;await e.executeQuery(pr.raw(r))}else await e.executeQuery(pr.raw("begin"))}async commitTransaction(e){await e.executeQuery(pr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(pr.raw("rollback"))}async savepoint(e,t,r){await e.executeQuery(r(k("savepoint",t),Ye()))}async rollbackToSavepoint(e,t,r){await e.executeQuery(r(k("rollback to",t),Ye()))}async releaseSavepoint(e,t,r){await e.executeQuery(r(k("release",t),Ye()))}async releaseConnection(e){e[$t]()}async destroy(){if(this.#r){let e=this.#r;this.#r=void 0,await e.end()}}}class Ft{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async executeQuery(e){try{let{command:t,rowCount:r,rows:n}=await this.#e.query(e.sql,[...e.parameters]);return{numAffectedRows:t==="INSERT"||t==="UPDATE"||t==="DELETE"||t==="MERGE"?BigInt(r):void 0,rows:n??[]}}catch(t){throw _e(t,Error())}}async*streamQuery(e,t){if(!this.#t.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.#e.query(new this.#t.cursor(e.sql,e.parameters.slice()));try{while(!0){let n=await r.read(t);if(n.length===0)break;yield{rows:n}}}finally{await r.close()}}[$t](){this.#e.release()}}class Ue{#e;constructor(e){this.#e=e}createDriver(){return new yt(this.#e)}createQueryCompiler(){return new ct}createAdapter(){return new lt}createIntrospector(e){return new ut(e)}}class wt extends ii{get supportsCreateIfNotExists(){return!1}get supportsTransactionalDdl(){return!0}get supportsOutput(){return!0}async acquireMigrationLock(e){await Oe`exec sp_getapplock @DbPrincipal = ${Oe.lit("dbo")}, @Resource = ${Oe.lit(Xr)}, @LockMode = ${Oe.lit("Exclusive")}`.execute(e)}async releaseMigrationLock(){}}var jt=Symbol(),Vt=Symbol(),Ut=Symbol();class xt{#e;#t;constructor(e){this.#e=p({...e});let{tarn:t,tedious:r,validateConnections:n}=this.#e,{validateConnections:o,...d}=t.options;this.#t=new t.Pool({...d,create:async()=>{let l=await r.connectionFactory();return await new Jt(l,r).connect()},destroy:async(l)=>{await l[Vt]()},validate:n===!1||o===!1?void 0:(l)=>l[Ut]()})}async init(){}async acquireConnection(){return await this.#t.acquire().promise}async beginTransaction(e,t){await e.beginTransaction(t)}async commitTransaction(e){await e.commitTransaction()}async rollbackTransaction(e){await e.rollbackTransaction()}async savepoint(e,t){await e.savepoint(t)}async rollbackToSavepoint(e,t){await e.rollbackTransaction(t)}async releaseConnection(e){if(this.#e.resetConnectionsOnRelease||this.#e.tedious.resetConnectionOnRelease)await e[jt]();this.#t.release(e)}async destroy(){await this.#t.destroy()}}class Jt{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=!1,this.#r=t}async beginTransaction(e){let{isolationLevel:t}=e;await new Promise((r,n)=>this.#e.beginTransaction((o)=>{if(o)n(o);else r(void 0)},t?ku(8):void 0,t?this.#n(t):void 0))}async commitTransaction(){await new Promise((e,t)=>this.#e.commitTransaction((r)=>{if(r)t(r);else e(void 0)}))}async connect(){let{promise:e,reject:t,resolve:r}=new Gi;this.#e.connect((o)=>{if(o)return t(o);r()}),this.#e.on("error",(o)=>{if(o instanceof Error&&"code"in o&&o.code==="ESOCKET")this.#t=!0;console.error(o),t(o)});function n(){t(Error("The connection ended without ever completing the connection"))}return this.#e.once("end",n),await e,this.#e.off("end",n),this}async executeQuery(e){try{let t=new Gi,r=new Be({compiledQuery:e,tedious:this.#r,onDone:t});this.#e.execSql(r.request);let{rowCount:n,rows:o}=await t.promise;return{numAffectedRows:n!==void 0?BigInt(n):void 0,rows:o}}catch(t){throw _e(t,Error())}}async rollbackTransaction(e){await new Promise((t,r)=>this.#e.rollbackTransaction((n)=>{if(n)r(n);else t(void 0)},e))}async savepoint(e){await new Promise((t,r)=>this.#e.saveTransaction((n)=>{if(n)r(n);else t(void 0)},e))}async*streamQuery(e,t){if(!Number.isInteger(t)||t<=0)throw Error("chunkSize must be a positive integer");let r=new Be({compiledQuery:e,streamChunkSize:t,tedious:this.#r});this.#e.execSql(r.request);try{while(!0){let n=await r.readChunk();if(n.length===0)break;if(yield{rows:n},n.length<t)break}}finally{await this.#o(r)}}#n(e){let{ISOLATION_LEVEL:t}=this.#r,n={"read committed":t.READ_COMMITTED,"read uncommitted":t.READ_UNCOMMITTED,"repeatable read":t.REPEATABLE_READ,serializable:t.SERIALIZABLE,snapshot:t.SNAPSHOT}[e];if(n===void 0)throw Error(`Unknown isolation level: ${e}`);return n}#o(e){return new Promise((t)=>{if(e.request.once("requestCompleted",t),!this.#e.cancel())e.request.off("requestCompleted",t),t()})}[Vt](){if("closed"in this.#e&&this.#e.closed)return Promise.resolve();return new Promise((e)=>{this.#e.once("end",e),this.#e.close()})}async[jt](){await new Promise((e,t)=>{this.#e.reset((r)=>{if(r)return t(r);e()})})}async[Ut](){if(this.#t||this.#i())return!1;try{let e=new Gi,t=new Be({compiledQuery:pr.raw("select 1"),onDone:e,tedious:this.#r});return this.#e.execSql(t.request),await e.promise,!0}catch{return!1}}#i(){return"closed"in this.#e&&Boolean(this.#e.closed)}}class Be{#e;#t;#r;#n;#o;#i;constructor(e){let{compiledQuery:t,onDone:r,streamChunkSize:n,tedious:o}=e;if(this.#t=[],this.#r=n,this.#n={},this.#o=o,r)this.#n.onDone=(l,g)=>{if(l==="chunkReady")return;if(delete this.#n.onDone,l==="error")return r.reject(g);r.resolve({rowCount:this.#i,rows:this.#t})};this.#e=new this.#o.Request(t.sql,(d,l)=>{if(d)return Object.values(this.#n).forEach((g)=>g("error",d instanceof AggregateError?d.errors:d));this.#i=l}),this.#a(t.parameters),this.#c()}get request(){return this.#e}readChunk(){let e=this.readChunk.name;return new Promise((t,r)=>{this.#n[e]=(n,o)=>{if(delete this.#n[e],n==="error")return r(o);t(this.#t.splice(0,this.#r))},this.#e.resume()})}#a(e){for(let t=0;t<e.length;t++){let r=e[t];this.#e.addParameter(String(t+1),this.#s(r),r)}}#c(){let e=this.#r?()=>{if(this.#r<=this.#t.length)this.#e.pause(),Object.values(this.#n).forEach((r)=>r("chunkReady"))}:()=>{},t=(r)=>{let n={};for(let o of r)n[o.metadata.colName]=o.value;this.#t.push(n),e()};this.#e.on("row",t),this.#e.once("requestCompleted",()=>{Object.values(this.#n).forEach((r)=>r("completed")),this.#e.off("row",t)})}#s(e){if(ai(e)||On(e)||Qt(e))return this.#o.TYPES.NVarChar;if(li(e)||qo(e)&&e%1===0)if(e<-2147483648||e>2147483647)return this.#o.TYPES.BigInt;else return this.#o.TYPES.Int;if(qo(e))return this.#o.TYPES.Float;if(ks(e))return this.#o.TYPES.Bit;if(Nu(e))return this.#o.TYPES.DateTime;if(Am(e))return this.#o.TYPES.VarBinary;return this.#o.TYPES.NVarChar}}class Nt{#e;constructor(e){this.#e=e}async getSchemas(){return await this.#e.selectFrom("sys.schemas").select("name").execute()}async getTables(e={withInternalKyselyTables:!1}){let t=await this.#e.selectFrom("sys.tables as tables").leftJoin("sys.schemas as table_schemas","table_schemas.schema_id","tables.schema_id").innerJoin("sys.columns as columns","columns.object_id","tables.object_id").innerJoin("sys.types as types","types.user_type_id","columns.user_type_id").leftJoin("sys.schemas as type_schemas","type_schemas.schema_id","types.schema_id").leftJoin("sys.extended_properties as comments",(n)=>n.onRef("comments.major_id","=","tables.object_id").onRef("comments.minor_id","=","columns.column_id").on("comments.name","=","MS_Description")).$if(!e.withInternalKyselyTables,(n)=>n.where("tables.name","!=",Xr).where("tables.name","!=",En)).select(["tables.name as table_name",(n)=>n.ref("tables.type").$castTo().as("table_type"),"table_schemas.name as table_schema_name","columns.default_object_id as column_default_object_id","columns.generated_always_type_desc as column_generated_always_type","columns.is_computed as column_is_computed","columns.is_identity as column_is_identity","columns.is_nullable as column_is_nullable","columns.is_rowguidcol as column_is_rowguidcol","columns.name as column_name","types.is_nullable as type_is_nullable","types.name as type_name","type_schemas.name as type_schema_name","comments.value as column_comment"]).unionAll(this.#e.selectFrom("sys.views as views").leftJoin("sys.schemas as view_schemas","view_schemas.schema_id","views.schema_id").innerJoin("sys.columns as columns","columns.object_id","views.object_id").innerJoin("sys.types as types","types.user_type_id","columns.user_type_id").leftJoin("sys.schemas as type_schemas","type_schemas.schema_id","types.schema_id").leftJoin("sys.extended_properties as comments",(n)=>n.onRef("comments.major_id","=","views.object_id").onRef("comments.minor_id","=","columns.column_id").on("comments.name","=","MS_Description")).select(["views.name as table_name","views.type as table_type","view_schemas.name as table_schema_name","columns.default_object_id as column_default_object_id","columns.generated_always_type_desc as column_generated_always_type","columns.is_computed as column_is_computed","columns.is_identity as column_is_identity","columns.is_nullable as column_is_nullable","columns.is_rowguidcol as column_is_rowguidcol","columns.name as column_name","types.is_nullable as type_is_nullable","types.name as type_name","type_schemas.name as type_schema_name","comments.value as column_comment"])).orderBy("table_schema_name").orderBy("table_name").orderBy("column_name").execute(),r={};for(let n of t){let o=`${n.table_schema_name}.${n.table_name}`;(r[o]=r[o]||p({columns:[],isView:n.table_type==="V ",name:n.table_name,schema:n.table_schema_name??void 0})).columns.push(p({dataType:n.type_name,dataTypeSchema:n.type_schema_name??void 0,hasDefaultValue:n.column_default_object_id>0||n.column_generated_always_type!=="NOT_APPLICABLE"||n.column_is_identity||n.column_is_computed||n.column_is_rowguidcol,isAutoIncrementing:n.column_is_identity,isNullable:n.column_is_nullable&&n.type_is_nullable,name:n.column_name,comment:n.column_comment??void 0}))}return Object.values(r)}async getMetadata(e){return{tables:await this.getTables(e)}}}var yr=/^[a-z0-9_]$/i;class _t extends Zn{getCurrentParameterPlaceholder(){return`@${this.numParameters}`}visitOffset(e){super.visitOffset(e),this.append(" rows")}compileColumnAlterations(e){let t={};for(let n of e){if(!t[n.kind])t[n.kind]=[];t[n.kind].push(n)}let r=!0;if(t.AddColumnNode)this.append("add "),this.compileList(t.AddColumnNode),r=!1;if(t.AlterColumnNode){if(!r)this.append(", ");this.compileList(t.AlterColumnNode)}if(t.DropColumnNode){if(!r)this.append(", ");this.append("drop column "),this.compileList(t.DropColumnNode)}if(t.ModifyColumnNode){if(!r)this.append(", ");this.compileList(t.ModifyColumnNode)}if(t.RenameColumnNode){if(!r)this.append(", ");this.compileList(t.RenameColumnNode)}}visitAddColumn(e){this.visitNode(e.column)}visitDropColumn(e){this.visitNode(e.column)}visitMergeQuery(e){super.visitMergeQuery(e),this.append(";")}visitCollate(e){this.append("collate ");let{name:t}=e.collation;for(let r of t)if(!yr.test(r))throw Error(`Invalid collation: ${t}`);this.append(t)}announcesNewColumnDataType(){return!1}}class Ct{#e;constructor(e){this.#e=e}createDriver(){return new xt(this.#e)}createQueryCompiler(){return new _t}createAdapter(){return new wt}createIntrospector(e){return new Nt(e)}}function Tt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Mu(e){if(!e)return null;if("dialect"in e)return Mu(e.dialect);if("createDriver"in e){if(e instanceof ze)return"sqlite";if(e instanceof Ve)return"mysql";if(e instanceof Ue)return"postgres";if(e instanceof Ct)return"mssql"}if("aggregate"in e)return"sqlite";if("getConnection"in e)return"mysql";if("connect"in e)return"postgres";if("fileControl"in e)return"sqlite";if("open"in e&&"close"in e&&"prepare"in e)return"sqlite";if("batch"in e&&"exec"in e&&"prepare"in e)return"sqlite";return null}var hf=async(e)=>{let t=e.database;if(!t)return{kysely:null,databaseType:null,transaction:void 0};if("db"in t)return{kysely:t.db,databaseType:t.type,transaction:t.transaction};if("dialect"in t)return{kysely:new F({dialect:t.dialect}),databaseType:t.type,transaction:t.transaction};let r=void 0,n=Mu(t);if("createDriver"in t)r=t;if("aggregate"in t&&!("createSession"in t))r=new ze({database:t});if("getConnection"in t)r=new Ve(t);if("connect"in t)r=new Ue({pool:t});if("fileControl"in t){let{BunSqliteDialect:o}=await import("./chunk-e3r1m6rb.js");r=new o({database:t})}if("createSession"in t){let o=void 0;try{({DatabaseSync:o}=await import("node:sqlite"))}catch(d){if(d!==null&&typeof d==="object"&&"code"in d&&d.code!=="ERR_UNKNOWN_BUILTIN_MODULE")throw d}if(o&&t instanceof o){let{NodeSqliteDialect:d}=await import("./chunk-trndqdaa.js");r=new d({database:t})}}if("batch"in t&&"exec"in t&&"prepare"in t){let{D1SqliteDialect:o}=await import("./chunk-hx76pje1.js");r=new o({database:t})}return{kysely:r?new F({dialect:r}):null,databaseType:n,transaction:void 0}};function gt(e,t,r){return r==="postgres"?Oe`${Oe.ref(e)} ILIKE ${t}`:Oe`LOWER(${Oe.ref(e)}) LIKE LOWER(${t})`}function wr(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,values:t.map((r)=>r.toLowerCase())}}function xr(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,values:t.map((r)=>r.toLowerCase())}}function Nr(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,value:t.toLowerCase()}}function _r(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,value:t.toLowerCase()}}var P1=(e,t)=>{let r=null,n=(l,g=!1)=>({getFieldName:A,schema:D,getDefaultFieldName:z,getDefaultModelName:Ht,getFieldAttributes:Cr,getModelName:te})=>{let Et=(u)=>{let x=[],y=[];if(u)for(let[h,m]of Object.entries(u)){let a=D[Ht(h)]?.fields,[c,w]=h.includes(".")?h.split("."):[void 0,h];if(!a)continue;a.id={type:"string"};for(let[v,i]of Object.entries(a))x.push(Oe`${Oe.ref(`join_${w}`)}.${Oe.ref(i.fieldName||v)} as ${Oe.ref(`_joined_${w}_${i.fieldName||v}`)}`),y.push({joinModel:h,joinModelRef:w,fieldName:i.fieldName||v})}return{allSelectsStr:y,allSelects:x}},bt=async(u,x,y,h)=>{let m;if(t?.type==="mysql"){await x.execute();let a=u.id?"id":h.length>0&&h[0]?.field?h[0].field:"id";if(!u.id&&h.length===0)return m=await l.selectFrom(y).selectAll().orderBy(A({model:y,field:a}),"desc").limit(1).executeTakeFirst(),m;let c=u[a]!==void 0?u[a]:h[0]?.value;return m=await l.selectFrom(y).selectAll().orderBy(A({model:y,field:a}),"desc").where(A({model:y,field:a}),c===null?"is":"=",c).limit(1).executeTakeFirst(),m}if(t?.type==="mssql")return m=await x.outputAll("inserted").executeTakeFirst(),m;return m=await x.returningAll().executeTakeFirst(),m};function J(u,x){if(!x)return{and:null,or:null};let y={and:[],or:[]};return x.forEach((h)=>{let{field:m,value:a,operator:c="eq",connector:w="AND",mode:v="sensitive"}=h,i=a,C=A({model:u,field:m}),N=v==="insensitive"&&(typeof i==="string"||Array.isArray(i)&&i.every((f)=>typeof f==="string")),T=(f)=>{let s=`${u}.${C}`;if(c.toLowerCase()==="in"){if(N){let{lhs:q,values:E}=wr(s,Array.isArray(i)?i:[i]);return f(q,"in",E)}return f(s,"in",Array.isArray(i)?i:[i])}if(c.toLowerCase()==="not_in"){if(N){let{lhs:q,values:E}=xr(s,Array.isArray(i)?i:[i]);return f(q,"not in",E)}return f(s,"not in",Array.isArray(i)?i:[i])}if(c==="contains"){if(N&&typeof i==="string")return gt(s,`%${i}%`,t?.type);return f(s,"like",`%${i}%`)}if(c==="starts_with"){if(N&&typeof i==="string")return gt(s,`${i}%`,t?.type);return f(s,"like",`${i}%`)}if(c==="ends_with"){if(N&&typeof i==="string")return gt(s,`%${i}`,t?.type);return f(s,"like",`%${i}`)}if(c==="eq"){if(i===null)return f(s,"is",null);if(N&&typeof i==="string"){let{lhs:q,value:E}=Nr(s,i);return f(q,"=",E)}return f(s,"=",i)}if(c==="ne"){if(i===null)return f(s,"is not",null);if(N&&typeof i==="string"){let{lhs:q,value:E}=_r(s,i);return f(q,"<>",E)}return f(s,"<>",i)}if(c==="gt")return f(s,">",i);if(c==="gte")return f(s,">=",i);if(c==="lt")return f(s,"<",i);if(c==="lte")return f(s,"<=",i);return f(s,c,i)};if(w==="OR")y.or.push(T);else y.and.push(T)}),{and:y.and.length?y.and:null,or:y.or.length?y.or:null}}function It(u,x,y){if(!x||!u.length)return u;let h=new Map;for(let a of u){let c={},w={};for(let[C]of Object.entries(x))w[te(C)]={};for(let[C,N]of Object.entries(a)){let T=String(C),f=!1;for(let{joinModel:s,fieldName:q,joinModelRef:E}of y)if(T===`_joined_${E}_${q}`||T===`_Joined${Tt(E)}${Tt(q)}`){w[te(s)][A({model:s,field:q})]=N,f=!0;break}if(!f)c[C]=N}let v=c.id;if(!v)continue;if(!h.has(v)){let C={...c};for(let[N,T]of Object.entries(x))C[te(N)]=T.relation==="one-to-one"?null:[];h.set(v,C)}let i=h.get(v);for(let[C,N]of Object.entries(x)){let T=N.relation==="one-to-one",f=N.limit??100,s=w[te(C)],q=s&&Object.keys(s).length>0&&Object.values(s).some((E)=>E!==null&&E!==void 0);if(T)i[te(C)]=q?s:null;else{let E=te(C);if(Array.isArray(i[E])&&q){if(i[E].length>=f)continue;let qe=A({model:C,field:"id"}),At=s[qe];if(At){if(!i[E].some((Yt)=>Yt[qe]===At)&&i[E].length<f)i[E].push(s)}else if(i[E].length<f)i[E].push(s)}}}}let m=Array.from(h.values());for(let a of m)for(let[c,w]of Object.entries(x))if(w.relation!=="one-to-one"){let v=te(c);if(Array.isArray(a[v])){let i=w.limit??100;if(a[v].length>i)a[v]=a[v].slice(0,i)}}return m}return{async create({data:u,model:x}){return await bt(u,l.insertInto(x).values(u),x,[])},async findOne({model:u,where:x,select:y,join:h}){let{and:m,or:a}=J(u,x),c=l.selectFrom((N)=>{let T=N.selectFrom(u);if(m)T=T.where((f)=>f.and(m.map((s)=>s(f))));if(a)T=T.where((f)=>f.or(a.map((s)=>s(f))));if(y?.length&&y.length>0)T=T.select(y.map((f)=>A({model:u,field:f})));else T=T.selectAll();return T.as("primary")}).selectAll("primary");if(h)for(let[N,T]of Object.entries(h)){let[f,s]=N.includes(".")?N.split("."):[void 0,N];c=c.leftJoin(`${N} as join_${s}`,(q)=>q.onRef(`join_${s}.${T.on.to}`,"=",`primary.${T.on.from}`))}let{allSelectsStr:w,allSelects:v}=Et(h);c=c.select(v);let i=await c.execute();if(!i||!Array.isArray(i)||i.length===0)return null;let C=i[0];if(h)return It(i,h,w)[0];return C},async findMany({model:u,where:x,limit:y,select:h,offset:m,sortBy:a,join:c}){let{and:w,or:v}=J(u,x),i=l.selectFrom((f)=>{let s=f.selectFrom(u);if(t?.type==="mssql"){if(m!==void 0){if(!a)s=s.orderBy(A({model:u,field:"id"}));s=s.offset(m).fetch(y||100)}else if(y!==void 0)s=s.top(y)}else{if(y!==void 0)s=s.limit(y);if(m!==void 0)s=s.offset(m)}if(a?.field)s=s.orderBy(`${A({model:u,field:a.field})}`,a.direction);if(w)s=s.where((q)=>q.and(w.map((E)=>E(q))));if(v)s=s.where((q)=>q.or(v.map((E)=>E(q))));if(h?.length&&h.length>0)s=s.select(h.map((q)=>A({model:u,field:q})));else s=s.selectAll();return s.as("primary")}).selectAll("primary");if(c)for(let[f,s]of Object.entries(c)){let[q,E]=f.includes(".")?f.split("."):[void 0,f];i=i.leftJoin(`${f} as join_${E}`,(qe)=>qe.onRef(`join_${E}.${s.on.to}`,"=",`primary.${s.on.from}`))}let{allSelectsStr:C,allSelects:N}=Et(c);if(i=i.select(N),a?.field)i=i.orderBy(`${A({model:u,field:a.field})}`,a.direction);let T=await i.execute();if(!T)return[];if(c)return It(T,c,C);return T},async update({model:u,where:x,update:y}){let{and:h,or:m}=J(u,x),a=l.updateTable(u).set(y);if(h)a=a.where((c)=>c.and(h.map((w)=>w(c))));if(m)a=a.where((c)=>c.or(m.map((w)=>w(c))));return await bt(y,a,u,x)},async updateMany({model:u,where:x,update:y}){let{and:h,or:m}=J(u,x),a=l.updateTable(u).set(y);if(h)a=a.where((w)=>w.and(h.map((v)=>v(w))));if(m)a=a.where((w)=>w.or(m.map((v)=>v(w))));let c=(await a.executeTakeFirst()).numUpdatedRows;return c>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:Number(c)},async count({model:u,where:x}){let{and:y,or:h}=J(u,x),m=l.selectFrom(u).select(l.fn.count("id").as("count"));if(y)m=m.where((c)=>c.and(y.map((w)=>w(c))));if(h)m=m.where((c)=>c.or(h.map((w)=>w(c))));let a=await m.execute();if(typeof a[0].count==="number")return a[0].count;if(typeof a[0].count==="bigint")return Number(a[0].count);return parseInt(a[0].count)},async delete({model:u,where:x}){let{and:y,or:h}=J(u,x),m=l.deleteFrom(u);if(y)m=m.where((a)=>a.and(y.map((c)=>c(a))));if(h)m=m.where((a)=>a.or(h.map((c)=>c(a))));await m.execute()},async deleteMany({model:u,where:x}){let{and:y,or:h}=J(u,x),m=l.deleteFrom(u);if(y)m=m.where((c)=>c.and(y.map((w)=>w(c))));if(h)m=m.where((c)=>c.or(h.map((w)=>w(c))));let a=(await m.executeTakeFirst()).numDeletedRows;return a>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:Number(a)},async consumeOne({model:u,where:x}){let{and:y,or:h}=J(u,x),m=(i)=>{if(y)i=i.where((C)=>C.and(y.map((N)=>N(C))));if(h)i=i.where((C)=>C.or(h.map((N)=>N(C))));return i},a=A({model:u,field:"id"}),c=async(i,C)=>{let N=C[a]??C.id;if(N===void 0||N===null)return null;let T=i.deleteFrom(u).where(`${u}.${a}`,"=",N);if(t?.type==="mysql"){let f=await T.executeTakeFirst();return Number(f.numDeletedRows)>0?C:null}if(t?.type==="mssql")return await T.outputAll("deleted").executeTakeFirst()??null;return await T.returningAll().executeTakeFirst()??null},w=async(i)=>{if(t?.type==="mssql")return await i.outputAll("deleted").executeTakeFirst()??null;return await i.returningAll().executeTakeFirst()??null};if(t?.type==="mysql"){let i=async(C)=>{let N=await m(C.selectFrom(u).selectAll().forUpdate()).limit(1).executeTakeFirst();if(!N)return null;return c(C,N)};return g?i(l):l.transaction().execute(i)}let v=m(l.selectFrom(u).select(`${u}.${a}`)).limit(1);return w(l.deleteFrom(u).where(`${u}.${a}`,"in",v))},options:t}},o=null;o={config:{adapterId:"kysely",adapterName:"Kysely Adapter",usePlural:t?.usePlural,debugLogs:t?.debugLogs,supportsBooleans:t?.type==="sqlite"||t?.type==="mssql"||t?.type==="mysql"||!t?.type?!1:!0,supportsDates:t?.type==="sqlite"||t?.type==="mssql"||!t?.type?!1:!0,supportsJSON:t?.type==="postgres"?!0:!1,supportsArrays:!1,supportsUUIDs:t?.type==="postgres"?!0:!1,transaction:t?.transaction?(l)=>e.transaction().execute((g)=>l(Rs({config:{...o.config,transaction:!1},adapter:n(g,!0)})(r))):!1},adapter:n(e)};let d=Rs(o);return(l)=>(r=l,d(l))};
|
|
6
|
-
export{
|
|
5
|
+
${r}`,e}return e}function ur(e){return Mr(e)&&Qt(e.stack)}var Pt=Symbol();class mt{#e;#t=new WeakMap;#r;constructor(e){this.#e=p({...e})}async init(){this.#r=Kt(this.#e.pool)?await this.#e.pool():this.#e.pool}async acquireConnection(){let e=await this.#n(),t=this.#t.get(e);if(!t){if(t=new Lt(e),this.#t.set(e,t),this.#e?.onCreateConnection)await this.#e.onCreateConnection(t)}if(this.#e?.onReserveConnection)await this.#e.onReserveConnection(t);return t}async#n(){return new Promise((e,t)=>{this.#r.getConnection(async(r,n)=>{if(r)t(r);else e(n)})})}async beginTransaction(e,t){if(t.isolationLevel||t.accessMode){let r=[];if(t.isolationLevel)r.push(`isolation level ${t.isolationLevel}`);if(t.accessMode)r.push(t.accessMode);let n=`set transaction ${r.join(", ")}`;await e.executeQuery(mr.raw(n))}await e.executeQuery(mr.raw("begin"))}async commitTransaction(e){await e.executeQuery(mr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(mr.raw("rollback"))}async savepoint(e,t,r){await e.executeQuery(r(k("savepoint",t),Je()))}async rollbackToSavepoint(e,t,r){await e.executeQuery(r(k("rollback to",t),Je()))}async releaseSavepoint(e,t,r){await e.executeQuery(r(k("release savepoint",t),Je()))}async releaseConnection(e){e[Pt]()}async destroy(){return new Promise((e,t)=>{this.#r.end((r)=>{if(r)t(r);else e()})})}}function lr(e){return Mr(e)&&"insertId"in e&&"affectedRows"in e}class Lt{#e;constructor(e){this.#e=e}async executeQuery(e){try{let t=await this.#t(e);if(lr(t)){let{insertId:r,affectedRows:n,changedRows:o}=t;return{insertId:r!==void 0&&r!==null&&r.toString()!=="0"?BigInt(r):void 0,numAffectedRows:n!==void 0&&n!==null?BigInt(n):void 0,numChangedRows:o!==void 0&&o!==null?BigInt(o):void 0,rows:[]}}else if(Array.isArray(t))return{rows:t};return{rows:[]}}catch(t){throw _e(t,Error())}}#t(e){return new Promise((t,r)=>{this.#e.query(e.sql,e.parameters,(n,o)=>{if(n)r(n);else t(o)})})}async*streamQuery(e,t){let r=this.#e.query(e.sql,e.parameters).stream({objectMode:!0});try{for await(let n of r)yield{rows:[n]}}catch(n){if(n&&typeof n==="object"&&"code"in n&&n.code==="ERR_STREAM_PREMATURE_CLOSE")return;throw n}}[Pt](){this.#e.release()}}var dr=/[\\']/g,dt=/`/g,hr=/[\\'"]/g;class ht extends Bn{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getExplainOptionAssignment(){return"="}getExplainOptionsDelimiter(){return" "}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return dt.source}getRightIdentifierWrapper(){return dt.source}sanitizeIdentifier(e){return e.replace(dt,"``")}sanitizeStringLiteral(e){return e.replace(dr,(t)=>t==="\\"?"\\\\":"''")}sanitizeJSONPathMemberValue(e){return e.replace(hr,(t)=>t==="\\"?"\\\\\\\\":t==="'"?"''":'\\\\"')}visitCreateIndex(e){if(this.append("create "),e.unique)this.append("unique ");if(this.append("index "),e.ifNotExists)this.append("if not exists ");if(this.visitNode(e.name),e.using)this.append(" using "),this.visitNode(e.using);if(e.table)this.append(" on "),this.visitNode(e.table);if(e.columns)this.append(" ("),this.compileList(e.columns),this.append(")");if(e.where)this.append(" "),this.visitNode(e.where)}}class pt{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom("information_schema.schemata").select("schema_name").$castTo().execute()).map((t)=>({name:t.SCHEMA_NAME}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom("information_schema.columns as columns").innerJoin("information_schema.tables as tables",(n)=>n.onRef("columns.TABLE_CATALOG","=","tables.TABLE_CATALOG").onRef("columns.TABLE_SCHEMA","=","tables.TABLE_SCHEMA").onRef("columns.TABLE_NAME","=","tables.TABLE_NAME")).select(["columns.COLUMN_NAME","columns.COLUMN_DEFAULT","columns.TABLE_NAME","columns.TABLE_SCHEMA","tables.TABLE_TYPE","columns.IS_NULLABLE","columns.DATA_TYPE","columns.EXTRA","columns.COLUMN_COMMENT"]).where("columns.TABLE_SCHEMA","=",Oe`database()`).orderBy("columns.TABLE_NAME").orderBy("columns.ORDINAL_POSITION").$castTo();if(!e.withInternalKyselyTables)t=t.where("columns.TABLE_NAME","!=",en).where("columns.TABLE_NAME","!=",Cn);let r=await t.execute();return this.#t(r)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e){return e.reduce((t,r)=>{let n=t.find((o)=>o.name===r.TABLE_NAME);if(!n)n=p({name:r.TABLE_NAME,isView:r.TABLE_TYPE==="VIEW",schema:r.TABLE_SCHEMA,columns:[]}),t.push(n);return n.columns.push(p({name:r.COLUMN_NAME,dataType:r.DATA_TYPE,isNullable:r.IS_NULLABLE==="YES",isAutoIncrementing:r.EXTRA.toLowerCase().includes("auto_increment"),hasDefaultValue:r.COLUMN_DEFAULT!==null,comment:r.COLUMN_COMMENT===""?void 0:r.COLUMN_COMMENT})),t},[])}}var Rt="ea586330-2c93-47c8-908d-981d9d270f9d",fr=3600;class ft extends li{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}async acquireMigrationLock(e,t){await Oe`select get_lock(${Oe.lit(Rt)}, ${Oe.lit(fr)})`.execute(e)}async releaseMigrationLock(e,t){await Oe`select release_lock(${Oe.lit(Rt)})`.execute(e)}}class Ve{#e;constructor(e){this.#e=e}createDriver(){return new mt(this.#e)}createQueryCompiler(){return new ht}createAdapter(){return new ft}createIntrospector(e){return new pt(e)}}var $t=Symbol();class yt{#e;#t=new WeakMap;#r;constructor(e){this.#e=p({...e})}async init(){this.#r=Kt(this.#e.pool)?await this.#e.pool():this.#e.pool}async acquireConnection(){let e=await this.#r.connect(),t=this.#t.get(e);if(!t){if(t=new Ft(e,{cursor:this.#e.cursor??null}),this.#t.set(e,t),this.#e.onCreateConnection)await this.#e.onCreateConnection(t)}if(this.#e.onReserveConnection)await this.#e.onReserveConnection(t);return t}async beginTransaction(e,t){if(t.isolationLevel||t.accessMode){let r="start transaction";if(t.isolationLevel)r+=` isolation level ${t.isolationLevel}`;if(t.accessMode)r+=` ${t.accessMode}`;await e.executeQuery(mr.raw(r))}else await e.executeQuery(mr.raw("begin"))}async commitTransaction(e){await e.executeQuery(mr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(mr.raw("rollback"))}async savepoint(e,t,r){await e.executeQuery(r(k("savepoint",t),Je()))}async rollbackToSavepoint(e,t,r){await e.executeQuery(r(k("rollback to",t),Je()))}async releaseSavepoint(e,t,r){await e.executeQuery(r(k("release",t),Je()))}async releaseConnection(e){e[$t]()}async destroy(){if(this.#r){let e=this.#r;this.#r=void 0,await e.end()}}}class Ft{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async executeQuery(e){try{let{command:t,rowCount:r,rows:n}=await this.#e.query(e.sql,[...e.parameters]);return{numAffectedRows:t==="INSERT"||t==="UPDATE"||t==="DELETE"||t==="MERGE"?BigInt(r):void 0,rows:n??[]}}catch(t){throw _e(t,Error())}}async*streamQuery(e,t){if(!this.#t.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.#e.query(new this.#t.cursor(e.sql,e.parameters.slice()));try{while(!0){let n=await r.read(t);if(n.length===0)break;yield{rows:n}}}finally{await r.close()}}[$t](){this.#e.release()}}class Ue{#e;constructor(e){this.#e=e}createDriver(){return new yt(this.#e)}createQueryCompiler(){return new ct}createAdapter(){return new lt}createIntrospector(e){return new ut(e)}}class wt extends li{get supportsCreateIfNotExists(){return!1}get supportsTransactionalDdl(){return!0}get supportsOutput(){return!0}async acquireMigrationLock(e){await Oe`exec sp_getapplock @DbPrincipal = ${Oe.lit("dbo")}, @Resource = ${Oe.lit(en)}, @LockMode = ${Oe.lit("Exclusive")}`.execute(e)}async releaseMigrationLock(){}}var jt=Symbol(),Vt=Symbol(),Ut=Symbol();class xt{#e;#t;constructor(e){this.#e=p({...e});let{tarn:t,tedious:r,validateConnections:n}=this.#e,{validateConnections:o,...d}=t.options;this.#t=new t.Pool({...d,create:async()=>{let l=await r.connectionFactory();return await new Jt(l,r).connect()},destroy:async(l)=>{await l[Vt]()},validate:n===!1||o===!1?void 0:(l)=>l[Ut]()})}async init(){}async acquireConnection(){return await this.#t.acquire().promise}async beginTransaction(e,t){await e.beginTransaction(t)}async commitTransaction(e){await e.commitTransaction()}async rollbackTransaction(e){await e.rollbackTransaction()}async savepoint(e,t){await e.savepoint(t)}async rollbackToSavepoint(e,t){await e.rollbackTransaction(t)}async releaseConnection(e){if(this.#e.resetConnectionsOnRelease||this.#e.tedious.resetConnectionOnRelease)await e[jt]();this.#t.release(e)}async destroy(){await this.#t.destroy()}}class Jt{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=!1,this.#r=t}async beginTransaction(e){let{isolationLevel:t}=e;await new Promise((r,n)=>this.#e.beginTransaction((o)=>{if(o)n(o);else r(void 0)},t?Ru(8):void 0,t?this.#n(t):void 0))}async commitTransaction(){await new Promise((e,t)=>this.#e.commitTransaction((r)=>{if(r)t(r);else e(void 0)}))}async connect(){let{promise:e,reject:t,resolve:r}=new Gi;this.#e.connect((o)=>{if(o)return t(o);r()}),this.#e.on("error",(o)=>{if(o instanceof Error&&"code"in o&&o.code==="ESOCKET")this.#t=!0;console.error(o),t(o)});function n(){t(Error("The connection ended without ever completing the connection"))}return this.#e.once("end",n),await e,this.#e.off("end",n),this}async executeQuery(e){try{let t=new Gi,r=new Be({compiledQuery:e,tedious:this.#r,onDone:t});this.#e.execSql(r.request);let{rowCount:n,rows:o}=await t.promise;return{numAffectedRows:n!==void 0?BigInt(n):void 0,rows:o}}catch(t){throw _e(t,Error())}}async rollbackTransaction(e){await new Promise((t,r)=>this.#e.rollbackTransaction((n)=>{if(n)r(n);else t(void 0)},e))}async savepoint(e){await new Promise((t,r)=>this.#e.saveTransaction((n)=>{if(n)r(n);else t(void 0)},e))}async*streamQuery(e,t){if(!Number.isInteger(t)||t<=0)throw Error("chunkSize must be a positive integer");let r=new Be({compiledQuery:e,streamChunkSize:t,tedious:this.#r});this.#e.execSql(r.request);try{while(!0){let n=await r.readChunk();if(n.length===0)break;if(yield{rows:n},n.length<t)break}}finally{await this.#o(r)}}#n(e){let{ISOLATION_LEVEL:t}=this.#r,n={"read committed":t.READ_COMMITTED,"read uncommitted":t.READ_UNCOMMITTED,"repeatable read":t.REPEATABLE_READ,serializable:t.SERIALIZABLE,snapshot:t.SNAPSHOT}[e];if(n===void 0)throw Error(`Unknown isolation level: ${e}`);return n}#o(e){return new Promise((t)=>{if(e.request.once("requestCompleted",t),!this.#e.cancel())e.request.off("requestCompleted",t),t()})}[Vt](){if("closed"in this.#e&&this.#e.closed)return Promise.resolve();return new Promise((e)=>{this.#e.once("end",e),this.#e.close()})}async[jt](){await new Promise((e,t)=>{this.#e.reset((r)=>{if(r)return t(r);e()})})}async[Ut](){if(this.#t||this.#i())return!1;try{let e=new Gi,t=new Be({compiledQuery:mr.raw("select 1"),onDone:e,tedious:this.#r});return this.#e.execSql(t.request),await e.promise,!0}catch{return!1}}#i(){return"closed"in this.#e&&Boolean(this.#e.closed)}}class Be{#e;#t;#r;#n;#o;#i;constructor(e){let{compiledQuery:t,onDone:r,streamChunkSize:n,tedious:o}=e;if(this.#t=[],this.#r=n,this.#n={},this.#o=o,r)this.#n.onDone=(l,g)=>{if(l==="chunkReady")return;if(delete this.#n.onDone,l==="error")return r.reject(g);r.resolve({rowCount:this.#i,rows:this.#t})};this.#e=new this.#o.Request(t.sql,(d,l)=>{if(d)return Object.values(this.#n).forEach((g)=>g("error",d instanceof AggregateError?d.errors:d));this.#i=l}),this.#a(t.parameters),this.#c()}get request(){return this.#e}readChunk(){let e=this.readChunk.name;return new Promise((t,r)=>{this.#n[e]=(n,o)=>{if(delete this.#n[e],n==="error")return r(o);t(this.#t.splice(0,this.#r))},this.#e.resume()})}#a(e){for(let t=0;t<e.length;t++){let r=e[t];this.#e.addParameter(String(t+1),this.#s(r),r)}}#c(){let e=this.#r?()=>{if(this.#r<=this.#t.length)this.#e.pause(),Object.values(this.#n).forEach((r)=>r("chunkReady"))}:()=>{},t=(r)=>{let n={};for(let o of r)n[o.metadata.colName]=o.value;this.#t.push(n),e()};this.#e.on("row",t),this.#e.once("requestCompleted",()=>{Object.values(this.#n).forEach((r)=>r("completed")),this.#e.off("row",t)})}#s(e){if(ci(e)||Fn(e)||Qt(e))return this.#o.TYPES.NVarChar;if(ui(e)||$o(e)&&e%1===0)if(e<-2147483648||e>2147483647)return this.#o.TYPES.BigInt;else return this.#o.TYPES.Int;if($o(e))return this.#o.TYPES.Float;if(Ns(e))return this.#o.TYPES.Bit;if(Du(e))return this.#o.TYPES.DateTime;if(bm(e))return this.#o.TYPES.VarBinary;return this.#o.TYPES.NVarChar}}class Nt{#e;constructor(e){this.#e=e}async getSchemas(){return await this.#e.selectFrom("sys.schemas").select("name").execute()}async getTables(e={withInternalKyselyTables:!1}){let t=await this.#e.selectFrom("sys.tables as tables").leftJoin("sys.schemas as table_schemas","table_schemas.schema_id","tables.schema_id").innerJoin("sys.columns as columns","columns.object_id","tables.object_id").innerJoin("sys.types as types","types.user_type_id","columns.user_type_id").leftJoin("sys.schemas as type_schemas","type_schemas.schema_id","types.schema_id").leftJoin("sys.extended_properties as comments",(n)=>n.onRef("comments.major_id","=","tables.object_id").onRef("comments.minor_id","=","columns.column_id").on("comments.name","=","MS_Description")).$if(!e.withInternalKyselyTables,(n)=>n.where("tables.name","!=",en).where("tables.name","!=",Cn)).select(["tables.name as table_name",(n)=>n.ref("tables.type").$castTo().as("table_type"),"table_schemas.name as table_schema_name","columns.default_object_id as column_default_object_id","columns.generated_always_type_desc as column_generated_always_type","columns.is_computed as column_is_computed","columns.is_identity as column_is_identity","columns.is_nullable as column_is_nullable","columns.is_rowguidcol as column_is_rowguidcol","columns.name as column_name","types.is_nullable as type_is_nullable","types.name as type_name","type_schemas.name as type_schema_name","comments.value as column_comment"]).unionAll(this.#e.selectFrom("sys.views as views").leftJoin("sys.schemas as view_schemas","view_schemas.schema_id","views.schema_id").innerJoin("sys.columns as columns","columns.object_id","views.object_id").innerJoin("sys.types as types","types.user_type_id","columns.user_type_id").leftJoin("sys.schemas as type_schemas","type_schemas.schema_id","types.schema_id").leftJoin("sys.extended_properties as comments",(n)=>n.onRef("comments.major_id","=","views.object_id").onRef("comments.minor_id","=","columns.column_id").on("comments.name","=","MS_Description")).select(["views.name as table_name","views.type as table_type","view_schemas.name as table_schema_name","columns.default_object_id as column_default_object_id","columns.generated_always_type_desc as column_generated_always_type","columns.is_computed as column_is_computed","columns.is_identity as column_is_identity","columns.is_nullable as column_is_nullable","columns.is_rowguidcol as column_is_rowguidcol","columns.name as column_name","types.is_nullable as type_is_nullable","types.name as type_name","type_schemas.name as type_schema_name","comments.value as column_comment"])).orderBy("table_schema_name").orderBy("table_name").orderBy("column_name").execute(),r={};for(let n of t){let o=`${n.table_schema_name}.${n.table_name}`;(r[o]=r[o]||p({columns:[],isView:n.table_type==="V ",name:n.table_name,schema:n.table_schema_name??void 0})).columns.push(p({dataType:n.type_name,dataTypeSchema:n.type_schema_name??void 0,hasDefaultValue:n.column_default_object_id>0||n.column_generated_always_type!=="NOT_APPLICABLE"||n.column_is_identity||n.column_is_computed||n.column_is_rowguidcol,isAutoIncrementing:n.column_is_identity,isNullable:n.column_is_nullable&&n.type_is_nullable,name:n.column_name,comment:n.column_comment??void 0}))}return Object.values(r)}async getMetadata(e){return{tables:await this.getTables(e)}}}var yr=/^[a-z0-9_]$/i;class _t extends Bn{getCurrentParameterPlaceholder(){return`@${this.numParameters}`}visitOffset(e){super.visitOffset(e),this.append(" rows")}compileColumnAlterations(e){let t={};for(let n of e){if(!t[n.kind])t[n.kind]=[];t[n.kind].push(n)}let r=!0;if(t.AddColumnNode)this.append("add "),this.compileList(t.AddColumnNode),r=!1;if(t.AlterColumnNode){if(!r)this.append(", ");this.compileList(t.AlterColumnNode)}if(t.DropColumnNode){if(!r)this.append(", ");this.append("drop column "),this.compileList(t.DropColumnNode)}if(t.ModifyColumnNode){if(!r)this.append(", ");this.compileList(t.ModifyColumnNode)}if(t.RenameColumnNode){if(!r)this.append(", ");this.compileList(t.RenameColumnNode)}}visitAddColumn(e){this.visitNode(e.column)}visitDropColumn(e){this.visitNode(e.column)}visitMergeQuery(e){super.visitMergeQuery(e),this.append(";")}visitCollate(e){this.append("collate ");let{name:t}=e.collation;for(let r of t)if(!yr.test(r))throw Error(`Invalid collation: ${t}`);this.append(t)}announcesNewColumnDataType(){return!1}}class Ct{#e;constructor(e){this.#e=e}createDriver(){return new xt(this.#e)}createQueryCompiler(){return new _t}createAdapter(){return new wt}createIntrospector(e){return new Nt(e)}}function Tt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ku(e){if(!e)return null;if("dialect"in e)return ku(e.dialect);if("createDriver"in e){if(e instanceof ze)return"sqlite";if(e instanceof Ve)return"mysql";if(e instanceof Ue)return"postgres";if(e instanceof Ct)return"mssql"}if("aggregate"in e)return"sqlite";if("getConnection"in e)return"mysql";if("connect"in e)return"postgres";if("fileControl"in e)return"sqlite";if("open"in e&&"close"in e&&"prepare"in e)return"sqlite";if("batch"in e&&"exec"in e&&"prepare"in e)return"sqlite";return null}var _f=async(e)=>{let t=e.database;if(!t)return{kysely:null,databaseType:null,transaction:void 0};if("db"in t)return{kysely:t.db,databaseType:t.type,transaction:t.transaction};if("dialect"in t)return{kysely:new F({dialect:t.dialect}),databaseType:t.type,transaction:t.transaction};let r=void 0,n=ku(t);if("createDriver"in t)r=t;if("aggregate"in t&&!("createSession"in t))r=new ze({database:t});if("getConnection"in t)r=new Ve(t);if("connect"in t)r=new Ue({pool:t});if("fileControl"in t){let{BunSqliteDialect:o}=await import("./chunk-5rzxekn4.js");r=new o({database:t})}if("createSession"in t){let o=void 0;try{({DatabaseSync:o}=await import("node:sqlite"))}catch(d){if(d!==null&&typeof d==="object"&&"code"in d&&d.code!=="ERR_UNKNOWN_BUILTIN_MODULE")throw d}if(o&&t instanceof o){let{NodeSqliteDialect:d}=await import("./chunk-asy868kq.js");r=new d({database:t})}}if("batch"in t&&"exec"in t&&"prepare"in t){let{D1SqliteDialect:o}=await import("./chunk-e439kt05.js");r=new o({database:t})}return{kysely:r?new F({dialect:r}):null,databaseType:n,transaction:void 0}};function gt(e,t,r){return r==="postgres"?Oe`${Oe.ref(e)} ILIKE ${t}`:Oe`LOWER(${Oe.ref(e)}) LIKE LOWER(${t})`}function wr(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,values:t.map((r)=>r.toLowerCase())}}function xr(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,values:t.map((r)=>r.toLowerCase())}}function Nr(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,value:t.toLowerCase()}}function _r(e,t){return{lhs:Oe`LOWER(${Oe.ref(e)})`,value:t.toLowerCase()}}var oM=(e,t)=>{let r=null,n=(l,g=!1)=>({getFieldName:A,schema:D,getDefaultFieldName:z,getDefaultModelName:Ht,getFieldAttributes:Cr,getModelName:te})=>{let Et=(u)=>{let x=[],y=[];if(u)for(let[h,m]of Object.entries(u)){let a=D[Ht(h)]?.fields,[c,w]=h.includes(".")?h.split("."):[void 0,h];if(!a)continue;a.id={type:"string"};for(let[v,i]of Object.entries(a))x.push(Oe`${Oe.ref(`join_${w}`)}.${Oe.ref(i.fieldName||v)} as ${Oe.ref(`_joined_${w}_${i.fieldName||v}`)}`),y.push({joinModel:h,joinModelRef:w,fieldName:i.fieldName||v})}return{allSelectsStr:y,allSelects:x}},bt=async(u,x,y,h)=>{let m;if(t?.type==="mysql"){await x.execute();let a=u.id?"id":h.length>0&&h[0]?.field?h[0].field:"id";if(!u.id&&h.length===0)return m=await l.selectFrom(y).selectAll().orderBy(A({model:y,field:a}),"desc").limit(1).executeTakeFirst(),m;let c=u[a]!==void 0?u[a]:h[0]?.value;return m=await l.selectFrom(y).selectAll().orderBy(A({model:y,field:a}),"desc").where(A({model:y,field:a}),c===null?"is":"=",c).limit(1).executeTakeFirst(),m}if(t?.type==="mssql")return m=await x.outputAll("inserted").executeTakeFirst(),m;return m=await x.returningAll().executeTakeFirst(),m};function J(u,x){if(!x)return{and:null,or:null};let y={and:[],or:[]};return x.forEach((h)=>{let{field:m,value:a,operator:c="eq",connector:w="AND",mode:v="sensitive"}=h,i=a,C=A({model:u,field:m}),N=v==="insensitive"&&(typeof i==="string"||Array.isArray(i)&&i.every((f)=>typeof f==="string")),T=(f)=>{let s=`${u}.${C}`;if(c.toLowerCase()==="in"){if(N){let{lhs:q,values:E}=wr(s,Array.isArray(i)?i:[i]);return f(q,"in",E)}return f(s,"in",Array.isArray(i)?i:[i])}if(c.toLowerCase()==="not_in"){if(N){let{lhs:q,values:E}=xr(s,Array.isArray(i)?i:[i]);return f(q,"not in",E)}return f(s,"not in",Array.isArray(i)?i:[i])}if(c==="contains"){if(N&&typeof i==="string")return gt(s,`%${i}%`,t?.type);return f(s,"like",`%${i}%`)}if(c==="starts_with"){if(N&&typeof i==="string")return gt(s,`${i}%`,t?.type);return f(s,"like",`${i}%`)}if(c==="ends_with"){if(N&&typeof i==="string")return gt(s,`%${i}`,t?.type);return f(s,"like",`%${i}`)}if(c==="eq"){if(i===null)return f(s,"is",null);if(N&&typeof i==="string"){let{lhs:q,value:E}=Nr(s,i);return f(q,"=",E)}return f(s,"=",i)}if(c==="ne"){if(i===null)return f(s,"is not",null);if(N&&typeof i==="string"){let{lhs:q,value:E}=_r(s,i);return f(q,"<>",E)}return f(s,"<>",i)}if(c==="gt")return f(s,">",i);if(c==="gte")return f(s,">=",i);if(c==="lt")return f(s,"<",i);if(c==="lte")return f(s,"<=",i);return f(s,c,i)};if(w==="OR")y.or.push(T);else y.and.push(T)}),{and:y.and.length?y.and:null,or:y.or.length?y.or:null}}function It(u,x,y){if(!x||!u.length)return u;let h=new Map;for(let a of u){let c={},w={};for(let[C]of Object.entries(x))w[te(C)]={};for(let[C,N]of Object.entries(a)){let T=String(C),f=!1;for(let{joinModel:s,fieldName:q,joinModelRef:E}of y)if(T===`_joined_${E}_${q}`||T===`_Joined${Tt(E)}${Tt(q)}`){w[te(s)][A({model:s,field:q})]=N,f=!0;break}if(!f)c[C]=N}let v=c.id;if(!v)continue;if(!h.has(v)){let C={...c};for(let[N,T]of Object.entries(x))C[te(N)]=T.relation==="one-to-one"?null:[];h.set(v,C)}let i=h.get(v);for(let[C,N]of Object.entries(x)){let T=N.relation==="one-to-one",f=N.limit??100,s=w[te(C)],q=s&&Object.keys(s).length>0&&Object.values(s).some((E)=>E!==null&&E!==void 0);if(T)i[te(C)]=q?s:null;else{let E=te(C);if(Array.isArray(i[E])&&q){if(i[E].length>=f)continue;let qe=A({model:C,field:"id"}),At=s[qe];if(At){if(!i[E].some((Yt)=>Yt[qe]===At)&&i[E].length<f)i[E].push(s)}else if(i[E].length<f)i[E].push(s)}}}}let m=Array.from(h.values());for(let a of m)for(let[c,w]of Object.entries(x))if(w.relation!=="one-to-one"){let v=te(c);if(Array.isArray(a[v])){let i=w.limit??100;if(a[v].length>i)a[v]=a[v].slice(0,i)}}return m}return{async create({data:u,model:x}){return await bt(u,l.insertInto(x).values(u),x,[])},async findOne({model:u,where:x,select:y,join:h}){let{and:m,or:a}=J(u,x),c=l.selectFrom((N)=>{let T=N.selectFrom(u);if(m)T=T.where((f)=>f.and(m.map((s)=>s(f))));if(a)T=T.where((f)=>f.or(a.map((s)=>s(f))));if(y?.length&&y.length>0)T=T.select(y.map((f)=>A({model:u,field:f})));else T=T.selectAll();return T.as("primary")}).selectAll("primary");if(h)for(let[N,T]of Object.entries(h)){let[f,s]=N.includes(".")?N.split("."):[void 0,N];c=c.leftJoin(`${N} as join_${s}`,(q)=>q.onRef(`join_${s}.${T.on.to}`,"=",`primary.${T.on.from}`))}let{allSelectsStr:w,allSelects:v}=Et(h);c=c.select(v);let i=await c.execute();if(!i||!Array.isArray(i)||i.length===0)return null;let C=i[0];if(h)return It(i,h,w)[0];return C},async findMany({model:u,where:x,limit:y,select:h,offset:m,sortBy:a,join:c}){let{and:w,or:v}=J(u,x),i=l.selectFrom((f)=>{let s=f.selectFrom(u);if(t?.type==="mssql"){if(m!==void 0){if(!a)s=s.orderBy(A({model:u,field:"id"}));s=s.offset(m).fetch(y||100)}else if(y!==void 0)s=s.top(y)}else{if(y!==void 0)s=s.limit(y);if(m!==void 0)s=s.offset(m)}if(a?.field)s=s.orderBy(`${A({model:u,field:a.field})}`,a.direction);if(w)s=s.where((q)=>q.and(w.map((E)=>E(q))));if(v)s=s.where((q)=>q.or(v.map((E)=>E(q))));if(h?.length&&h.length>0)s=s.select(h.map((q)=>A({model:u,field:q})));else s=s.selectAll();return s.as("primary")}).selectAll("primary");if(c)for(let[f,s]of Object.entries(c)){let[q,E]=f.includes(".")?f.split("."):[void 0,f];i=i.leftJoin(`${f} as join_${E}`,(qe)=>qe.onRef(`join_${E}.${s.on.to}`,"=",`primary.${s.on.from}`))}let{allSelectsStr:C,allSelects:N}=Et(c);if(i=i.select(N),a?.field)i=i.orderBy(`${A({model:u,field:a.field})}`,a.direction);let T=await i.execute();if(!T)return[];if(c)return It(T,c,C);return T},async update({model:u,where:x,update:y}){let{and:h,or:m}=J(u,x),a=l.updateTable(u).set(y);if(h)a=a.where((c)=>c.and(h.map((w)=>w(c))));if(m)a=a.where((c)=>c.or(m.map((w)=>w(c))));return await bt(y,a,u,x)},async updateMany({model:u,where:x,update:y}){let{and:h,or:m}=J(u,x),a=l.updateTable(u).set(y);if(h)a=a.where((w)=>w.and(h.map((v)=>v(w))));if(m)a=a.where((w)=>w.or(m.map((v)=>v(w))));let c=(await a.executeTakeFirst()).numUpdatedRows;return c>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:Number(c)},async count({model:u,where:x}){let{and:y,or:h}=J(u,x),m=l.selectFrom(u).select(l.fn.count("id").as("count"));if(y)m=m.where((c)=>c.and(y.map((w)=>w(c))));if(h)m=m.where((c)=>c.or(h.map((w)=>w(c))));let a=await m.execute();if(typeof a[0].count==="number")return a[0].count;if(typeof a[0].count==="bigint")return Number(a[0].count);return parseInt(a[0].count)},async delete({model:u,where:x}){let{and:y,or:h}=J(u,x),m=l.deleteFrom(u);if(y)m=m.where((a)=>a.and(y.map((c)=>c(a))));if(h)m=m.where((a)=>a.or(h.map((c)=>c(a))));await m.execute()},async deleteMany({model:u,where:x}){let{and:y,or:h}=J(u,x),m=l.deleteFrom(u);if(y)m=m.where((c)=>c.and(y.map((w)=>w(c))));if(h)m=m.where((c)=>c.or(h.map((w)=>w(c))));let a=(await m.executeTakeFirst()).numDeletedRows;return a>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:Number(a)},async consumeOne({model:u,where:x}){let{and:y,or:h}=J(u,x),m=(i)=>{if(y)i=i.where((C)=>C.and(y.map((N)=>N(C))));if(h)i=i.where((C)=>C.or(h.map((N)=>N(C))));return i},a=A({model:u,field:"id"}),c=async(i,C)=>{let N=C[a]??C.id;if(N===void 0||N===null)return null;let T=i.deleteFrom(u).where(`${u}.${a}`,"=",N);if(t?.type==="mysql"){let f=await T.executeTakeFirst();return Number(f.numDeletedRows)>0?C:null}if(t?.type==="mssql")return await T.outputAll("deleted").executeTakeFirst()??null;return await T.returningAll().executeTakeFirst()??null},w=async(i)=>{if(t?.type==="mssql")return await i.outputAll("deleted").executeTakeFirst()??null;return await i.returningAll().executeTakeFirst()??null};if(t?.type==="mysql"){let i=async(C)=>{let N=await m(C.selectFrom(u).selectAll().forUpdate()).limit(1).executeTakeFirst();if(!N)return null;return c(C,N)};return g?i(l):l.transaction().execute(i)}let v=m(l.selectFrom(u).select(`${u}.${a}`)).limit(1);return w(l.deleteFrom(u).where(`${u}.${a}`,"in",v))},options:t}},o=null;o={config:{adapterId:"kysely",adapterName:"Kysely Adapter",usePlural:t?.usePlural,debugLogs:t?.debugLogs,supportsBooleans:t?.type==="sqlite"||t?.type==="mssql"||t?.type==="mysql"||!t?.type?!1:!0,supportsDates:t?.type==="sqlite"||t?.type==="mssql"||!t?.type?!1:!0,supportsJSON:t?.type==="postgres"?!0:!1,supportsArrays:!1,supportsUUIDs:t?.type==="postgres"?!0:!1,transaction:t?.transaction?(l)=>e.transaction().execute((g)=>l(Ds({config:{...o.config,transaction:!1},adapter:n(g,!0)})(r))):!1},adapter:n(e)};let d=Ds(o);return(l)=>(r=l,d(l))};
|
|
6
|
+
export{ku,_f,oM};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Oe,
|
|
2
|
+
import{Oe,mr}from"./chunk-mn208vrv.js";import{Bn,en,Cn}from"./chunk-w73v578p.js";var n=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},s=class{#e;#t=new o;#r;#a;constructor(e){this.#e={...e}}async init(){if(this.#r=this.#e.database,this.#a=new i(this.#r),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#a)}async acquireConnection(){return await this.#t.lock(),this.#a}async beginTransaction(e){await e.executeQuery(mr.raw("begin"))}async commitTransaction(e){await e.executeQuery(mr.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(mr.raw("rollback"))}async releaseConnection(){this.#t.unlock()}async destroy(){this.#r?.close()}},i=class{#e;constructor(e){this.#e=e}executeQuery(e){let{sql:r,parameters:a}=e,t=this.#e.prepare(r);return Promise.resolve({rows:t.all(a)})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},o=class{#e;#t;async lock(){while(this.#e!==void 0)await this.#e;this.#e=new Promise((e)=>{this.#t=e})}unlock(){let e=this.#t;this.#e=void 0,this.#t=void 0,e?.()}},c=class{#e;constructor(e){this.#e=e}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=this.#e.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!e.withInternalKyselyTables)r=r.where("name","!=",en).where("name","!=",Cn);let a=await r.execute();return Promise.all(a.map(({name:t})=>this.#t(t)))}async getMetadata(e){return{tables:await this.getTables(e)}}async#t(e){let r=this.#e,a=(await r.selectFrom("sqlite_master").where("name","=",e).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((t)=>t.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:e,columns:(await r.selectFrom(Oe`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((t)=>({name:t.name,dataType:t.type,isNullable:!t.notnull,isAutoIncrementing:t.name===a,hasDefaultValue:t.dflt_value!=null})),isView:!0}}},l=class extends Bn{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},m=class{#e;constructor(e){this.#e={...e}}createDriver(){return new s(this.#e)}createQueryCompiler(){return new l}createAdapter(){return new n}createIntrospector(e){return new c(e)}};export{m as BunSqliteDialect};
|