@shumai-one/shumai 0.2.0 → 0.2.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-0aj303as.js +3 -0
- package/bin/{chunk-kbzm1pwx.js → chunk-0qkj838r.js} +1 -1
- package/bin/{chunk-5a2maxwp.js → chunk-0rxhc7ka.js} +2 -2
- package/bin/chunk-0xbf8bcg.js +2 -0
- package/bin/{chunk-xh2ntgmk.js → chunk-14fh4s1a.js} +2 -2
- package/bin/{chunk-6mn3jqm9.js → chunk-15sefy5t.js} +2 -2
- package/bin/{chunk-mjan6b09.js → chunk-1wm57c6y.js} +3 -3
- package/bin/{chunk-pf8edn5x.js → chunk-1xpec5r8.js} +2 -2
- package/bin/chunk-23d3968z.js +2 -0
- package/bin/{chunk-r3n9zpfw.js → chunk-262hkppb.js} +2 -2
- package/bin/{chunk-3n1k9qt5.js → chunk-29tx9qe2.js} +1 -1
- package/bin/chunk-2aamsc5v.js +2 -0
- package/bin/chunk-2aascrtb.js +2 -0
- package/bin/chunk-2dsmsa6a.js +3 -0
- package/bin/chunk-2g12s6mc.js +2 -0
- package/bin/chunk-31baz5n0.js +2 -0
- package/bin/{chunk-a5kfa0k9.js → chunk-3rmc8nz6.js} +1 -1
- package/bin/{chunk-dyybbn07.js → chunk-46ar48f9.js} +1 -1
- package/bin/chunk-4e3jbp84.js +1 -0
- package/bin/chunk-4jk0y1w1.js +1 -0
- package/bin/{chunk-7ddaxdpf.js → chunk-4qpa7b5t.js} +1 -1
- package/bin/{chunk-8wv3kdz9.js → chunk-54tr7y2x.js} +2 -2
- package/bin/{chunk-ehfk24cf.js → chunk-5d2q46mx.js} +1 -1
- package/bin/{chunk-2cmg5sfn.js → chunk-5m9be8an.js} +2 -2
- package/bin/{chunk-yk3k5g5w.js → chunk-5r8858hx.js} +2 -2
- package/bin/{chunk-fwe9g818.js → chunk-5t6c3038.js} +1 -1
- package/bin/chunk-6z65xd0w.js +3 -0
- package/bin/{chunk-cp18trqb.js → chunk-77r8w95d.js} +2 -2
- package/bin/chunk-7b17fb36.js +6 -0
- package/bin/chunk-7e06b2zb.js +2 -0
- package/bin/{chunk-29ectt6g.js → chunk-7hsgmjpa.js} +2 -2
- package/bin/chunk-7we7ex0m.js +3 -0
- package/bin/{chunk-6r9w7z15.js → chunk-88fg1sw7.js} +2 -2
- package/bin/chunk-891h8br6.js +3 -0
- package/bin/{chunk-m7jfszqt.js → chunk-8mkfgcvb.js} +2 -2
- package/bin/chunk-8qg47kj6.js +3 -0
- package/bin/chunk-8tf6kgdj.js +2 -0
- package/bin/{chunk-s8d2045p.js → chunk-8wqfkm4c.js} +1 -1
- package/bin/{chunk-3rajscaz.js → chunk-922nnh39.js} +1 -1
- package/bin/{chunk-aakzq0w1.js → chunk-925q4paa.js} +1 -1
- package/bin/{chunk-frm7vz6v.js → chunk-92xxys10.js} +6 -6
- package/bin/chunk-97jzve52.js +4 -0
- package/bin/{chunk-w4y97tzy.js → chunk-9ab6k4rq.js} +1 -1
- package/bin/chunk-9avkn3x1.js +3 -0
- package/bin/{chunk-22dje1f5.js → chunk-9h027f50.js} +1 -1
- package/bin/{chunk-ec88pb09.js → chunk-9h3ds7rn.js} +2 -2
- package/bin/chunk-av71yjaa.js +1 -0
- package/bin/{chunk-xpqcvxej.js → chunk-b8js74jk.js} +1 -1
- package/bin/chunk-bd71dp4j.js +8 -0
- package/bin/{chunk-yhj8c5re.js → chunk-bs0fjz3w.js} +2 -2
- package/bin/chunk-byqc8tzq.js +1 -0
- package/bin/chunk-c45rh4hk.js +3 -0
- package/bin/chunk-ccw7mjgq.js +5 -0
- package/bin/{chunk-3x62t1m0.js → chunk-cxhmr356.js} +1 -1
- package/bin/chunk-d2vxmn9v.js +3 -0
- package/bin/chunk-d3wmdjze.js +8 -0
- package/bin/{chunk-z42cyc20.js → chunk-de99643r.js} +2 -2
- package/bin/{chunk-4kk5g619.js → chunk-dghtwyq1.js} +2 -2
- package/bin/chunk-dqgv5yy1.js +6 -0
- package/bin/chunk-e3s3rz2e.js +12 -0
- package/bin/chunk-e52nga6c.js +3 -0
- package/bin/chunk-e7ndw3hg.js +12 -0
- package/bin/chunk-f14sqw1d.js +1 -0
- package/bin/chunk-f7sbkfmk.js +2 -0
- package/bin/{chunk-mnv6pj0k.js → chunk-fa2g2wge.js} +2 -2
- package/bin/{chunk-fcb14agg.js → chunk-fbte2rmd.js} +1 -1
- package/bin/chunk-fcvtgx1y.js +7 -0
- package/bin/chunk-fd5a3pdd.js +1 -0
- package/bin/{chunk-49ej1y67.js → chunk-fepymbka.js} +2 -2
- package/bin/{chunk-j8q688sx.js → chunk-fz88kkk1.js} +2 -2
- package/bin/chunk-g6zzg6v2.js +1 -0
- package/bin/chunk-g8th86na.js +2 -0
- package/bin/chunk-gswbc6y9.js +2 -0
- package/bin/{chunk-d1ka11hc.js → chunk-gtrc5ka2.js} +1 -1
- package/bin/chunk-h0ytx8zc.js +2 -0
- package/bin/{chunk-gdm6y33a.js → chunk-hkbybhww.js} +1 -1
- package/bin/chunk-hr97a5j5.js +4 -0
- package/bin/{chunk-dypsm6m2.js → chunk-j8qtab70.js} +1 -1
- package/bin/{chunk-hdk93ghf.js → chunk-jf3vn5c3.js} +2 -2
- package/bin/{chunk-ajqsprm0.js → chunk-kfhtk3eh.js} +2 -2
- package/bin/chunk-kr06nrbx.js +2 -0
- package/bin/{chunk-9rw65s3e.js → chunk-m4zpf9gg.js} +2 -2
- package/bin/{chunk-y1xs4c5j.js → chunk-mqjzmn0e.js} +1 -1
- package/bin/{chunk-d2y3rbjm.js → chunk-mzg1h07d.js} +1 -1
- package/bin/{chunk-ysq64j13.js → chunk-n4meg9wb.js} +1 -1
- package/bin/{chunk-acxm86fh.js → chunk-nrwna4ha.js} +1 -1
- package/bin/chunk-nyhqy6q2.js +62 -0
- package/bin/{chunk-4zq8vxcy.css → chunk-pmswtfe3.css} +1 -1
- package/bin/chunk-pq18zenh.js +2 -0
- package/bin/chunk-pxw97qbq.js +3 -0
- package/bin/chunk-q09dfja5.js +3 -0
- package/bin/{chunk-m54p1cvp.js → chunk-q24epdh8.js} +2 -2
- package/bin/{chunk-k5w64spz.js → chunk-qksb0v3c.js} +2 -2
- package/bin/chunk-qqk51620.js +2 -0
- package/bin/chunk-r0w920zb.js +1 -0
- package/bin/{chunk-08m8mzfa.js → chunk-re0b7sj7.js} +1 -1
- package/bin/chunk-rtngbgpk.js +7 -0
- package/bin/{chunk-5tmf3c0g.js → chunk-ry33f2qk.js} +2 -2
- package/bin/{chunk-9n0etqsy.js → chunk-s1n39qte.js} +1 -1
- package/bin/{chunk-3qdn3pty.js → chunk-s46zwr4p.js} +1 -1
- package/bin/chunk-s8t74q9m.js +1 -0
- package/bin/chunk-sd86v1e6.js +1 -0
- package/bin/{chunk-kpy0kpna.js → chunk-srn8t0v7.js} +2 -2
- package/bin/chunk-szzff7gd.js +1 -0
- package/bin/{chunk-fwf8yne2.js → chunk-t3t6021k.js} +2 -2
- package/bin/{chunk-eadb78m8.js → chunk-ta7bfdrn.js} +1 -1
- package/bin/chunk-thsbcbay.js +8 -0
- package/bin/chunk-tspps87j.js +1 -0
- package/bin/chunk-w7dn1m95.js +2 -0
- package/bin/chunk-w88219ex.js +3 -0
- package/bin/{chunk-pqm0g14r.js → chunk-wc8sc9r9.js} +2 -2
- package/bin/chunk-wg98cacx.js +2 -0
- package/bin/chunk-wsyg4rwg.js +2 -0
- package/bin/{chunk-n5hfy93f.js → chunk-xcwbg4w9.js} +3 -3
- package/bin/{chunk-dgx2zxze.js → chunk-xyjw8w3r.js} +2 -2
- package/bin/chunk-y2qp11v9.js +1 -0
- package/bin/{chunk-1fpqq6ed.js → chunk-ybhgmvxa.js} +2 -2
- package/bin/{chunk-1wq9hjjr.js → chunk-ygz6pawn.js} +1 -1
- package/bin/{chunk-mv79zk8q.js → chunk-ymeycphq.js} +3 -3
- package/bin/{chunk-wv4fe1fj.js → chunk-zemrvz79.js} +2 -2
- package/bin/{chunk-3rt9mnj3.js → chunk-ztmj61z9.js} +1 -1
- package/bin/chunk-zzx99j8t.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +308 -283
- package/package.json +7 -7
- package/prisma/migrations/20260722022359_add_skill_permission/migration.sql +2 -0
- package/prisma/migrations/20260723025234_add_ai_usage_table/migration.sql +28 -0
- package/prisma/migrations/20260723032755_add_ai_usage_unique_constraint/migration.sql +8 -0
- package/prisma/schema.prisma +26 -0
- package/bin/chunk-09wp20mv.js +0 -1
- package/bin/chunk-0at8vxt5.js +0 -3
- package/bin/chunk-0zv7f9ca.js +0 -2
- package/bin/chunk-2k4vp654.js +0 -2
- package/bin/chunk-2s5a64nr.js +0 -2
- package/bin/chunk-2tbya52d.js +0 -2
- package/bin/chunk-2vs3evc7.js +0 -14
- package/bin/chunk-33169en9.js +0 -8
- package/bin/chunk-33ee1cvv.js +0 -2
- package/bin/chunk-3m39v371.js +0 -1
- package/bin/chunk-4hnrd4qh.js +0 -2
- package/bin/chunk-6c4c7t0n.js +0 -1
- package/bin/chunk-6frqqxkv.js +0 -1
- package/bin/chunk-7rhjej0x.js +0 -3
- package/bin/chunk-7wvgtw25.js +0 -3
- package/bin/chunk-8s0ae37g.js +0 -1
- package/bin/chunk-94h8644q.js +0 -2
- package/bin/chunk-ac2ky3q0.js +0 -12
- package/bin/chunk-axx5bh38.js +0 -2
- package/bin/chunk-cthpdt54.js +0 -11
- package/bin/chunk-d0earxhc.js +0 -4
- package/bin/chunk-d0n8nxp3.js +0 -3
- package/bin/chunk-d22pyc5n.js +0 -1
- package/bin/chunk-dmgjse02.js +0 -4
- package/bin/chunk-e5833tbd.js +0 -2
- package/bin/chunk-g7wrxnmd.js +0 -1
- package/bin/chunk-gk7158n4.js +0 -2
- package/bin/chunk-hb5v9ees.js +0 -2
- package/bin/chunk-jrvrg4fx.js +0 -1
- package/bin/chunk-k712q1zj.js +0 -2
- package/bin/chunk-kef0rnwn.js +0 -1
- package/bin/chunk-n296vcfw.js +0 -3
- package/bin/chunk-n6jgyv4y.js +0 -3
- package/bin/chunk-nar4s9v9.js +0 -3
- package/bin/chunk-nn8e9j7c.js +0 -1
- package/bin/chunk-nwtb6dt1.js +0 -62
- package/bin/chunk-ps4h3387.js +0 -5
- package/bin/chunk-q4f5vvtx.js +0 -2
- package/bin/chunk-qqesrgjk.js +0 -7
- package/bin/chunk-qz9xht6d.js +0 -2
- package/bin/chunk-symna5cj.js +0 -1
- package/bin/chunk-twzgpwst.js +0 -2
- package/bin/chunk-vgvmt2m1.js +0 -2
- package/bin/chunk-w4t9n9te.js +0 -6
- package/bin/chunk-z14hh99h.js +0 -2
- package/bin/chunk-zsdwska1.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Qg as n}from"./chunk-gswbc6y9.js";import{Tj as o,gk as l,oh as e,ph as d}from"./chunk-nyhqy6q2.js";function u({...t}){return e(o.Root,{"data-slot":"alert-dialog",...t})}function s({...t}){return e(o.Portal,{"data-slot":"alert-dialog-portal",...t})}function g({className:t,...a}){return e(o.Overlay,{"data-slot":"alert-dialog-overlay",className:l("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...a})}function f({className:t,size:a="default",...i}){return d(s,{children:[e(g,{}),e(o.Content,{"data-slot":"alert-dialog-content","data-size":a,className:l("group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg",t),...i})]})}function P({className:t,...a}){return e("div",{"data-slot":"alert-dialog-header",className:l("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...a})}function A({className:t,...a}){return e("div",{"data-slot":"alert-dialog-footer",className:l("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...a})}function D({className:t,...a}){return e(o.Title,{"data-slot":"alert-dialog-title",className:l("text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...a})}function v({className:t,...a}){return e(o.Description,{"data-slot":"alert-dialog-description",className:l("text-sm text-muted-foreground",t),...a})}function z({className:t,variant:a="default",size:i="default",...r}){return e(n,{variant:a,size:i,asChild:!0,children:e(o.Action,{"data-slot":"alert-dialog-action",className:l(t),...r})})}function C({className:t,variant:a="outline",size:i="default",...r}){return e(n,{variant:a,size:i,asChild:!0,children:e(o.Cancel,{"data-slot":"alert-dialog-cancel",className:l(t),...r})})}
|
|
2
|
+
export{u as _a,f as $a,P as ab,A as bb,D as cb,v as db,z as eb,C as fb};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$c as J,Nc as c,Oc as V,Pc as _k,Qc as ek,Rc as kW,Tc as GW,Vc as _,Wc as kk,Xc as h,Yc as dk,Zc as j,dd as I,ed as zk,fd as x,gd as hk,hd as Kk,id as pW,jd as y,kd as dW,ld as v,md as fk,nd as Xk,od as w,pd as sW,qd as TW,rd as Mk,td as YW,ud as Ch}from"./chunk-ysq64j13.js";function z(k){return kk(k)&&_(k.toOperationNode)}var Q=h({is(k){return k.kind==="ValueNode"},create(k){return h({kind:"ValueNode",value:k})},createImmediate(k){return h({kind:"ValueNode",value:k,immediate:!0})}});var S=h({is(k){return k.kind==="ColumnNode"},create(k){return h({kind:"ColumnNode",column:J.create(k)})}});var pk=h({is(k){return k.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}});var Ak=h({is(k){return k.kind==="ReferenceNode"},create(k,W){return h({kind:"ReferenceNode",table:W,column:k})},createSelectAll(k){return h({kind:"ReferenceNode",table:k,column:pk.create()})}});function ok(k){return kk(k)&&"expressionType"in k&&z(k)}function iW(k){return kk(k)&&"expression"in k&&V(k.alias)&&z(k)}var a=h({is(k){return k.kind==="SelectModifierNode"},create(k,W){return h({kind:"SelectModifierNode",modifier:k,of:W})},createWithExpression(k){return h({kind:"SelectModifierNode",rawModifier:k})}});var Yk=h({is(k){return k.kind==="BinaryOperationNode"},create(k,W,$){return h({kind:"BinaryOperationNode",leftOperand:k,operator:W,rightOperand:$})}});var sk=h({is(k){return k.kind==="PrimitiveValueListNode"},create(k){return h({kind:"PrimitiveValueListNode",values:h([...k])})}});var rk=h({is(k){return k.kind==="ValueListNode"},create(k){return h({kind:"ValueListNode",values:h(k)})}});function lW(k){if(j(k))return ih(k);return X(k)}function X(k){if(Wk(k))return p(k);return Q.create(k)}function WW(k){return _k(k)||ek(k)||kW(k)}function Bk(k){if(!WW(k))throw Error(`unsafe immediate value ${JSON.stringify(k)}`);return Q.createImmediate(k)}function ih(k){if(k.some(Wk))return rk.create(k.map((W)=>X(W)));return sk.create(k)}function L(k){if(k.length===3)return hW(k[0],k[1],k[2]);else if(k.length===1)return X(k[0]);throw Error(`invalid arguments: ${JSON.stringify(k)}`)}function hW(k,W,$){if(lh(W)&&oW($))return Yk.create(f(k),PW(W),Q.createImmediate($));return Yk.create(f(k),PW(W),lW($))}function m(k,W,$){return Yk.create(f(k),PW(W),f($))}function UW(k,W){return mk(Object.entries(k).filter(([,$])=>!c($)).map(([$,M])=>hW($,oW(M)?"is":"=",M)),W)}function mk(k,W,$=!0){let M=W==="and"?x.create:hk.create;if(k.length===0)return Yk.create(Q.createImmediate(1),y.create("="),Q.createImmediate(W==="and"?1:0));let G=aW(k[0]);for(let q=1;q<k.length;++q)G=M(G,aW(k[q]));if(k.length>1&&$)return Xk.create(G);return G}function lh(k){return k==="is"||k==="is not"}function oW(k){return kW(k)||ek(k)}function PW(k){if(V(k)&&pW.includes(k))return y.create(k);if(z(k))return k.toOperationNode();throw Error(`invalid operator ${JSON.stringify(k)}`)}function aW(k){return z(k)?k.toOperationNode():k}var $k=h({is(k){return k.kind==="OrderByNode"},create(k){return h({kind:"OrderByNode",items:h([...k])})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var VW=h({is(k){return k.kind==="PartitionByNode"},create(k){return h({kind:"PartitionByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var xk=h({is(k){return k.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithPartitionByItems(k,W){return h({...k,partitionBy:k.partitionBy?VW.cloneWithItems(k.partitionBy,W):VW.create(W)})}});var Vk=h({is(k){return k.kind==="FromNode"},create(k){return h({kind:"FromNode",froms:h(k)})},cloneWithFroms(k,W){return h({...k,froms:h([...k.froms,...W])})}});var wW=h({is(k){return k.kind==="GroupByNode"},create(k){return h({kind:"GroupByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var FW=h({is(k){return k.kind==="HavingNode"},create(k){return h({kind:"HavingNode",having:k})},cloneWithOperation(k,W,$){return h({...k,having:W==="And"?x.create(k.having,$):hk.create(k.having,$)})}});var o=h({is(k){return k.kind==="UpdateQueryNode"},create(k,W){return h({kind:"UpdateQueryNode",table:k.length===1?k[0]:sW.create(k),...W&&{with:W}})},createWithoutTable(){return h({kind:"UpdateQueryNode"})},cloneWithFromItems(k,W){return h({...k,from:k.from?Vk.cloneWithFroms(k.from,W):Vk.create(W)})},cloneWithUpdates(k,W){return h({...k,updates:k.updates?h([...k.updates,...W]):W})},cloneWithLimit(k,W){return h({...k,limit:W})}});var Dk=h({is(k){return k.kind==="DeleteQueryNode"},create(k,W){return h({kind:"DeleteQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithUsing(k,W){return h({...k,using:k.using!==void 0?TW.cloneWithTables(k.using,W):TW.create(W)})}});var C=h({is(k){return k.kind==="WhereNode"},create(k){return h({kind:"WhereNode",where:k})},cloneWithOperation(k,W,$){return h({...k,where:W==="And"?x.create(k.where,$):hk.create(k.where,$)})}});var vW=h({is(k){return k.kind==="ReturningNode"},create(k){return h({kind:"ReturningNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var rW=h({is(k){return k.kind==="ExplainNode"},create(k,W){return h({kind:"ExplainNode",format:k,options:W})}});var N=h({is(k){return k.kind==="MergeQueryNode"},create(k,W){return h({kind:"MergeQueryNode",into:k,...W&&{with:W}})},cloneWithUsing(k,W){return h({...k,using:W})},cloneWithWhen(k,W){return h({...k,whens:k.whens?h([...k.whens,W]):h([W])})},cloneWithThen(k,W){return h({...k,whens:k.whens?h([...k.whens.slice(0,-1),Mk.cloneWithResult(k.whens[k.whens.length-1],W)]):void 0})}});var AW=h({is(k){return k.kind==="OutputNode"},create(k){return h({kind:"OutputNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var K=h({is(k){return Y.is(k)||w.is(k)||o.is(k)||Dk.is(k)||N.is(k)},cloneWithEndModifier(k,W){return h({...k,endModifiers:k.endModifiers?h([...k.endModifiers,W]):h([W])})},cloneWithWhere(k,W){return h({...k,where:k.where?C.cloneWithOperation(k.where,"And",W):C.create(W)})},cloneWithJoin(k,W){return h({...k,joins:k.joins?h([...k.joins,W]):h([W])})},cloneWithReturning(k,W){return h({...k,returning:k.returning?vW.cloneWithSelections(k.returning,W):vW.create(W)})},cloneWithoutReturning(k){return h({...k,returning:void 0})},cloneWithoutWhere(k){return h({...k,where:void 0})},cloneWithExplain(k,W,$){return h({...k,explain:rW.create(W,$?.toOperationNode())})},cloneWithTop(k,W){return h({...k,top:W})},cloneWithOutput(k,W){return h({...k,output:k.output?AW.cloneWithSelections(k.output,W):AW.create(W)})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithoutOrderBy(k){return h({...k,orderBy:void 0})}});var Y=h({is(k){return k.kind==="SelectQueryNode"},create(k){return h({kind:"SelectQueryNode",...k&&{with:k}})},createFrom(k,W){return h({kind:"SelectQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})},cloneWithDistinctOn(k,W){return h({...k,distinctOn:k.distinctOn?h([...k.distinctOn,...W]):h(W)})},cloneWithFrontModifier(k,W){return h({...k,frontModifiers:k.frontModifiers?h([...k.frontModifiers,W]):h([W])})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithGroupByItems(k,W){return h({...k,groupBy:k.groupBy?wW.cloneWithItems(k.groupBy,W):wW.create(W)})},cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithOffset(k,W){return h({...k,offset:W})},cloneWithFetch(k,W){return h({...k,fetch:W})},cloneWithHaving(k,W){return h({...k,having:k.having?FW.cloneWithOperation(k.having,"And",W):FW.create(W)})},cloneWithSetOperations(k,W){return h({...k,setOperations:k.setOperations?h([...k.setOperations,...W]):h([...W])})},cloneWithoutSelections(k){return h({...k,selections:[]})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithoutOffset(k){return h({...k,offset:void 0})},cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithoutGroupBy(k){return h({...k,groupBy:void 0})}});class Rk{#k;constructor(k){this.#k=h(k)}on(...k){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,L(k))})}onRef(k,W,$){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,m(k,W,$))})}onTrue(){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,v.createWithSql("true"))})}$call(k){return k(this)}toOperationNode(){return this.#k.joinNode}}class ah{#k;get dynamicReference(){return this.#k}get refType(){return}constructor(k){this.#k=k}toOperationNode(){return _W(this.#k)}}function $W(k){return kk(k)&&z(k)&&V(k.dynamicReference)}var g=h({is(k){return k.kind==="OrderByItemNode"},create(k,W){return h({kind:"OrderByItemNode",orderBy:k,direction:W})},cloneWith(k,W){return h({...k,...W})}});var eW=h({is(k){return k.kind==="CollateNode"},create(k){return h({kind:"CollateNode",collation:J.create(k)})}});class Lk{#k;constructor(k){this.#k=h(k)}desc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("desc")})})}asc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"last"})})}nullsFirst(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"first"})})}collate(k){return new Lk({node:g.cloneWith(this.#k.node,{collation:eW.create(k)})})}toOperationNode(){return this.#k.node}}function RW(k){return k==="asc"||k==="desc"}function B(k){if(k.length===2)return[mW(k[0],k[1])];if(k.length===1){let[W]=k;if(Array.isArray(W))return fk("orderBy(array) is deprecated, use multiple orderBy calls instead."),W.map(($)=>mW($));return[mW(W)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${k.length}`)}function mW(k,W){let $=ph(k);if(g.is($)){if(W)throw Error("Cannot specify direction twice!");return $}return kh($,W)}function ph(k){if(Wk(k))return p(k);if($W(k))return k.toOperationNode();let[W,$]=k.split(" ");if($)return fk("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),kh(t(W),$);return t(k)}function kh(k,W){if(typeof W==="string"){if(!RW(W))throw Error(`Invalid order by direction: ${W}`);return g.create(k,v.createWithSql(W))}if(ok(W))return fk("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),g.create(k,W.toOperationNode());let $=g.create(k);if(!W)return $;return W(new Lk({node:$})).toOperationNode()}var Wh=h({is(k){return k.kind==="PartitionByItemNode"},create(k){return h({kind:"PartitionByItemNode",partitionBy:k})}});function hh(k){return Gk(k).map(Wh.create)}class Ck{#k;constructor(k){this.#k=h(k)}orderBy(...k){return new Ck({overNode:xk.cloneWithOrderByItems(this.#k.overNode,B(k))})}clearOrderBy(){return new Ck({overNode:K.cloneWithoutOrderBy(this.#k.overNode)})}partitionBy(k){return new Ck({overNode:xk.cloneWithPartitionByItems(this.#k.overNode,hh(k))})}$call(k){return k(this)}toOperationNode(){return this.#k.overNode}}var Sk=h({is(k){return k.kind==="SelectionNode"},create(k){return h({kind:"SelectionNode",selection:k})},createSelectAll(){return h({kind:"SelectionNode",selection:pk.create()})},createSelectAllFromTable(k){return h({kind:"SelectionNode",selection:Ak.createSelectAll(k)})}});class oh{#k;get table(){return this.#k}constructor(k){this.#k=k}as(k){return new $h(this.#k,k)}}class $h{#k;#W;get table(){return this.#k}get alias(){return this.#W}constructor(k,W){this.#k=k,this.#W=W}toOperationNode(){return I.create(F(this.#k),J.create(this.#W))}}function Mh(k){return kk(k)&&z(k)&&V(k.table)&&V(k.alias)}function n(k){if(j(k))return k.map((W)=>wk(W));else return[wk(k)]}function wk(k){if(V(k))return fW(k);else if(Mh(k))return k.toOperationNode();else return MW(k)}function fW(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(Kh);return I.create(F($),J.create(M))}else return F(k)}function F(k){if(k.includes(".")){let[$,M]=k.split(".").map(Kh);return zk.createWithSchema($,M)}else return zk.create(k)}function Kh(k){return k.trim()}function A(k){if(_(k))return A(k(d()));else if(j(k))return k.map((W)=>Gh(W));else return[Gh(k)]}function Gh(k){if(V(k))return Sk.create(Zh(k));else if($W(k))return Sk.create(k.toOperationNode());else return Sk.create(MW(k))}function R(k){if(!k)return[Sk.createSelectAll()];else if(Array.isArray(k))return k.map(Hh);else return[Hh(k)]}function Hh(k){if(V(k))return Sk.createSelectAllFromTable(F(k));throw Error(`invalid value selectAll expression: ${JSON.stringify(k)}`)}var Yh=h({is(k){return k.kind==="ValuesNode"},create(k){return h({kind:"ValuesNode",values:h(k)})}});var Xh=h({is(k){return k.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function KW(k){let W=_(k)?k(d()):k,$=j(W)?W:h([W]);return sh($)}function sh(k){let W=rh(k);return[h([...W.keys()].map(S.create)),Yh.create(k.map(($)=>eh($,W)))]}function rh(k){let W=new Map;for(let $ of k){let M=Object.keys($);for(let G of M)if(!W.has(G)&&$[G]!==void 0)W.set(G,W.size)}return W}function eh(k,W){let $=Object.keys(k),M=Array.from({length:W.size}),G=!1,q=$.length;for(let ak of $){let Nk=W.get(ak);if(c(Nk)){q--;continue}let qW=k[ak];if(c(qW)||Wk(qW))G=!0;M[Nk]=qW}if(q<W.size||G){let ak=Xh.create();return rk.create(M.map((Nk)=>c(Nk)?ak:X(Nk)))}return sk.create(M)}var CW=h({is(k){return k.kind==="ColumnUpdateNode"},create(k,W){return h({kind:"ColumnUpdateNode",column:k,value:W})}});function Dh(...k){if(k.length===2)return[CW.create(f(k[0]),X(k[1]))];return ck(k[0])}function ck(k){let W=_(k)?k(d()):k;return Object.entries(W).filter(([$,M])=>M!==void 0).map(([$,M])=>{return CW.create(S.create($),X(M))})}var Lh=h({is(k){return k.kind==="OnDuplicateKeyNode"},create(k){return h({kind:"OnDuplicateKeyNode",updates:k})}});class SW{insertId;numInsertedOrUpdatedRows;constructor(k,W){this.insertId=k,this.numInsertedOrUpdatedRows=W}}class u extends Error{node;constructor(k){super("no result");this.node=k}}function s(k){return Object.prototype.hasOwnProperty.call(k,"prototype")}var E=h({is(k){return k.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(k,W){return h({...k,...W})},cloneWithIndexWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"And",W):C.create(W)})},cloneWithIndexOrWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"Or",W):C.create(W)})},cloneWithUpdateWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"And",W):C.create(W)})},cloneWithUpdateOrWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"Or",W):C.create(W)})},cloneWithoutIndexWhere(k){return h({...k,indexWhere:void 0})},cloneWithoutUpdateWhere(k){return h({...k,updateWhere:void 0})}});class r{#k;constructor(k){this.#k=h(k)}column(k){let W=S.create(k);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,W]):h([W])})})}columns(k){let W=k.map(S.create);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,...W]):h(W)})})}constraint(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{constraint:J.create(k)})})}expression(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{indexExpression:k.toOperationNode()})})}where(...k){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new r({...this.#k,onConflictNode:E.cloneWithoutIndexWhere(this.#k.onConflictNode)})}doNothing(){return new zh({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{doNothing:!0})})}doUpdateSet(k){return new yk({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{updates:ck(k)})})}$call(k){return k(this)}}class zh{#k;constructor(k){this.#k=h(k)}toOperationNode(){return this.#k.onConflictNode}}class yk{#k;constructor(k){this.#k=h(k)}where(...k){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new yk({...this.#k,onConflictNode:E.cloneWithoutUpdateWhere(this.#k.onConflictNode)})}$call(k){return k(this)}toOperationNode(){return this.#k.onConflictNode}}var Jh=h({is(k){return k.kind==="TopNode"},create(k,W){return h({kind:"TopNode",expression:k,modifiers:W})}});function i(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid top expression: ${k}`);if(!c(W)&&!k$(W))throw Error(`Invalid top modifiers: ${W}`);return Jh.create(k,W)}function k$(k){return k==="percent"||k==="with ties"||k==="percent with ties"}var Fk=h({is(k){return k.kind==="OrActionNode"},create(k){return h({kind:"OrActionNode",action:k})}});class D{#k;constructor(k){this.#k=h(k)}values(k){let[W,$]=KW(k);return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:W,values:$})})}columns(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:h(k.map(S.create))})})}expression(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{values:p(k)})})}defaultValues(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{defaultValues:!0})})}modifyEnd(k){return new D({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}ignore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orIgnore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orAbort(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("abort")})})}orFail(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("fail")})})}orReplace(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("replace")})})}orRollback(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("rollback")})})}top(k,W){return new D({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}onConflict(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onConflict:k(new r({onConflictNode:E.create()})).toOperationNode()})})}onDuplicateKeyUpdate(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onDuplicateKey:Lh.create(ck(k))})})}returning(k){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R())})}output(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new D({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new D({...this.#k})}$castTo(){return new D(this.#k)}$narrowType(){return new D(this.#k)}$assertType(){return new D(this.#k)}withPlugin(k){return new D({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new SW(W.insertId,W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new D({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}class IW{numDeletedRows;constructor(k){this.numDeletedRows=k}}var Ik=h({is(k){return k.kind==="LimitNode"},create(k){return h({kind:"LimitNode",limit:k})}});var P;class HW{#k;constructor(k){this.#k=h(k)}where(...k){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new P({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new P({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(k){return new P({...this.#k,queryNode:Dk.cloneWithUsing(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new P({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}returning(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new P({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}clearLimit(){return new P({...this.#k,queryNode:Dk.cloneWithoutLimit(this.#k.queryNode)})}orderBy(...k){return new P({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new P({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new P({...this.#k,queryNode:Dk.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}modifyEnd(k){return new P({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new P({...this.#k})}$castTo(){return new P(this.#k)}$narrowType(){return new P(this.#k)}$assertType(){return new P(this.#k)}withPlugin(k){return new P({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new IW(W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new P({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}P=HW;class jW{numUpdatedRows;numChangedRows;constructor(k,W){this.numUpdatedRows=k,this.numChangedRows=W}}var U;class jk{#k;constructor(k){this.#k=h(k)}where(...k){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new U({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new U({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}from(k){return new U({...this.#k,queryNode:o.cloneWithFromItems(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new U({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new U({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new U({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new U({...this.#k,queryNode:o.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}set(...k){return new U({...this.#k,queryNode:o.cloneWithUpdates(this.#k.queryNode,Dh(...k))})}returning(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}modifyEnd(k){return new U({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}clearReturning(){return new U({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new U({...this.#k})}$castTo(){return new U(this.#k)}$narrowType(){return new U(this.#k)}$assertType(){return new U(this.#k)}withPlugin(k){return new U({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new jW(W.numAffectedRows??BigInt(0),W.numChangedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new U({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}U=jk;var EW=h({is(k){return k.kind==="CommonTableExpressionNameNode"},create(k,W){return h({kind:"CommonTableExpressionNameNode",table:zk.create(k),columns:W?h(W.map(S.create)):void 0})}});var Ek=h({is(k){return k.kind==="CommonTableExpressionNode"},create(k,W){return h({kind:"CommonTableExpressionNode",name:k,expression:W})},cloneWith(k,W){return h({...k,...W})}});class gk{#k;constructor(k){this.#k=h(k)}materialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!0})})}notMaterialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!1})})}toOperationNode(){return this.#k.node}}function OW(k,W){let $=W(Ph()).toOperationNode();if(_(k))return k(W$($)).toOperationNode();return Ek.create(qh(k),$)}function W$(k){return(W)=>{return new gk({node:Ek.create(qh(W),k)})}}function qh(k){if(k.includes("(")){let W=k.split(/[\(\)]/),$=W[0],M=W[1].split(",").map((G)=>G.trim());return EW.create($,M)}else return EW.create(k)}var tk=h({is(k){return k.kind==="WithNode"},create(k,W){return h({kind:"WithNode",expressions:h([k]),...W})},cloneWithExpression(k,W){return h({...k,expressions:h([...k.expressions,W])})}});var Uh=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Vh(k){let W="";for(let $=0;$<k;++$)W+=h$();return W}function h$(){return Uh[~~(Math.random()*Uh.length)]}function T(){return new wh}class wh{#k;get queryId(){if(this.#k===void 0)this.#k=Vh(8);return this.#k}}var Fh=h({is(k){return k.kind==="MatchedNode"},create(k,W=!1){return h({kind:"MatchedNode",not:k,bySource:W})}});function bW(k,W,$){return Mk.create(mk([Fh.create(!k.isMatched,k.bySource),...W&&W.length>0?[W.length===3&&$?m(W[0],W[1],W[2]):L(W)]:[]],"and",!1))}function Ok(k){if(V(k))return v.create([k],[]);if(z(k))return k.toOperationNode();return k}class ZW{#k;#W;#h;constructor(){this.#k=new Promise((k,W)=>{this.#h=W,this.#W=k})}get promise(){return this.#k}resolve=(k)=>{if(this.#W)this.#W(k)};reject=(k)=>{if(this.#h)this.#h(k)}}async function Th(k){let W=new ZW,$=new ZW;return k.provideConnection(async(M)=>{return W.resolve(M),await $.promise}).catch((M)=>W.reject(M)),h({connection:await W.promise,release:$.resolve})}var $$=h([]);class QW{#k;constructor(k=$$){this.#k=k}get plugins(){return this.#k}transformQuery(k,W){for(let $ of this.#k){let M=$.transformQuery({node:k,queryId:W});if(M.kind===k.kind)k=M;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${k.kind}`,`but it returned a ${M.kind}`].join(" "))}return k}async executeQuery(k){return await this.provideConnection(async(W)=>{let $=await W.executeQuery(k);if("numUpdatedOrDeletedRows"in $)fk("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#W($,k.queryId)})}async*stream(k,W){let{connection:$,release:M}=await Th(this);try{for await(let G of $.streamQuery(k,W))yield await this.#W(G,k.queryId)}finally{M()}}async#W(k,W){for(let $ of this.#k)k=await $.transformResult({result:k,queryId:W});return k}}class bk extends QW{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(k){return new bk([...this.plugins,k])}withPlugins(k){return new bk([...this.plugins,...k])}withPluginAtFront(k){return new bk([k,...this.plugins])}withoutPlugins(){return new bk([])}}var qk=new bk;class NW{numChangedRows;constructor(k){this.numChangedRows=k}}class Hk{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new Hk({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new Hk({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(...k){return new O({...this.#k,queryNode:N.cloneWithUsing(this.#k.queryNode,Jk("Using",k))})}returning(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}}class O{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new O({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new O({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}whenMatched(){return this.#W([])}whenMatchedAnd(...k){return this.#W(k)}whenMatchedAndRef(k,W,$){return this.#W([k,W,$],!0)}#W(k,W){return new BW({...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!0},k,W))})}whenNotMatched(){return this.#h([])}whenNotMatchedAnd(...k){return this.#h(k)}whenNotMatchedAndRef(k,W,$){return this.#h([k,W,$],!0)}whenNotMatchedBySource(){return this.#h([],!1,!0)}whenNotMatchedBySourceAnd(...k){return this.#h(k,!1,!0)}whenNotMatchedBySourceAndRef(k,W,$){return this.#h([k,W,$],!0,!0)}returning(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}#h(k,W=!1,$=!1){let M={...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!1,bySource:$},k,W))};return new($?BW:vh)(M)}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new O({...this.#k})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new NW(W.numAffectedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}}class BW{#k;constructor(k){this.#k=h(k)}thenDelete(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("delete"))})}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenUpdate(k){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(k(new jk({queryId:this.#k.queryId,executor:qk,queryNode:o.createWithoutTable()}))))})}thenUpdateSet(...k){return this.thenUpdate((W)=>W.set(...k))}}class vh{#k;constructor(k){this.#k=h(k)}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenInsertValues(k){let[W,$]=KW(k);return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(w.cloneWith(w.createWithoutInto(),{columns:W,values:$})))})}}class Pk{#k;constructor(k){this.#k=h(k)}selectFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.createFrom(n(k),this.#k.withNode)})}selectNoFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.cloneWithSelections(Y.create(this.#k.withNode),A(k))})}insertInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode)})}replaceInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode,!0)})}deleteFrom(k){return new HW({queryId:T(),executor:this.#k.executor,queryNode:Dk.create(n(k),this.#k.withNode)})}updateTable(k){return new jk({queryId:T(),executor:this.#k.executor,queryNode:o.create(n(k),this.#k.withNode)})}mergeInto(k){return new Hk({queryId:T(),executor:this.#k.executor,queryNode:N.create(fW(k),this.#k.withNode)})}with(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($)})}withRecursive(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($,{recursive:!0})})}withPlugin(k){return new Pk({...this.#k,executor:this.#k.executor.withPlugin(k)})}withoutPlugins(){return new Pk({...this.#k,executor:this.#k.executor.withoutPlugins()})}withSchema(k){return new Pk({...this.#k,executor:this.#k.executor.withPluginAtFront(new YW(k))})}}function Ph(){return new Pk({executor:qk})}function Ah(k,W){return new Rk({joinNode:Kk.create(k,wk(W))})}function _h(){return new Ck({overNode:xk.create()})}function Jk(k,W){if(W.length===3)return K$(k,W[0],W[1],W[2]);else if(W.length===2)return M$(k,W[0],W[1]);else if(W.length===1)return G$(k,W[0]);else throw Error("not implemented")}function M$(k,W,$){return $(Ah(k,W)).toOperationNode()}function K$(k,W,$,M){return Kk.createWithOn(k,wk(W),m($,"=",M))}function G$(k,W){return Kk.create(k,wk(W))}var mh=h({is(k){return k.kind==="OffsetNode"},create(k){return h({kind:"OffsetNode",offset:k})}});var Rh=h({is(k){return k.kind==="GroupByItemNode"},create(k){return h({kind:"GroupByItemNode",groupBy:k})}});function fh(k){return k=_(k)?k(d()):k,Gk(k).map(Rh.create)}function Tk(k,W,$){if(_(W))W=W(XW());if(!j(W))W=[W];return W.map((M)=>Ch.create(k,p(M),$))}class Z{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new Z(this.#k)}$notNull(){return new Z(this.#k)}toOperationNode(){return this.#k}}class zW{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}class DW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}$castTo(){return new DW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}class LW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new LW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}var Sh=h({is(k){return k.kind==="FetchNode"},create(k,W){return{kind:"FetchNode",rowCount:Q.create(k),modifier:W}}});function Ih(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid fetch row count: ${k}`);if(!H$(W))throw Error(`Invalid fetch modifier: ${W}`);return Sh.create(k,W)}function H$(k){return k==="only"||k==="with ties"}var H;class xW{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...k){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}having(...k){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,L(k))})}havingRef(k,W,$){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,m(k,W,$))})}select(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,A(k))})}distinctOn(k){return new H({...this.#k,queryNode:Y.cloneWithDistinctOn(this.#k.queryNode,Gk(k))})}modifyFront(k){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}modifyEnd(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}distinct(){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.create("Distinct"))})}forUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForUpdate",k?dk(k).map(F):void 0))})}forShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForShare",k?dk(k).map(F):void 0))})}forKeyShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForKeyShare",k?dk(k).map(F):void 0))})}forNoKeyUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForNoKeyUpdate",k?dk(k).map(F):void 0))})}skipLocked(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("SkipLocked"))})}noWait(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("NoWait"))})}selectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,R(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}crossJoin(...k){return this.#W("CrossJoin",k)}innerJoinLateral(...k){return this.#W("LateralInnerJoin",k)}leftJoinLateral(...k){return this.#W("LateralLeftJoin",k)}crossJoinLateral(...k){return this.#W("LateralCrossJoin",k)}crossApply(...k){return this.#W("CrossApply",k)}outerApply(...k){return this.#W("OuterApply",k)}#W(k,W){return new H({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new H({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}groupBy(k){return new H({...this.#k,queryNode:Y.cloneWithGroupByItems(this.#k.queryNode,fh(k))})}limit(k){return new H({...this.#k,queryNode:Y.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}offset(k){return new H({...this.#k,queryNode:Y.cloneWithOffset(this.#k.queryNode,mh.create(X(k)))})}fetch(k,W="only"){return new H({...this.#k,queryNode:Y.cloneWithFetch(this.#k.queryNode,Ih(k,W))})}top(k,W){return new H({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}union(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!1))})}unionAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!0))})}intersect(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!1))})}intersectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!0))})}except(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!1))})}exceptAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!0))})}as(k){return new jh(this,k)}clearSelect(){return new H({...this.#k,queryNode:Y.cloneWithoutSelections(this.#k.queryNode)})}clearWhere(){return new H({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}clearLimit(){return new H({...this.#k,queryNode:Y.cloneWithoutLimit(this.#k.queryNode)})}clearOffset(){return new H({...this.#k,queryNode:Y.cloneWithoutOffset(this.#k.queryNode)})}clearOrderBy(){return new H({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}clearGroupBy(){return new H({...this.#k,queryNode:Y.cloneWithoutGroupBy(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new H({...this.#k})}$castTo(){return new H(this.#k)}$narrowType(){return new H(this.#k)}$assertType(){return new H(this.#k)}$asTuple(){return new Z(this.toOperationNode())}$asScalar(){return new Z(this.toOperationNode())}withPlugin(k){return new H({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile();return(await this.#k.executor.executeQuery(k)).rows}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new H({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}H=xW;function nk(k){return new xW(k)}class jh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}var e=h({is(k){return k.kind==="AggregateFunctionNode"},create(k,W=[]){return h({kind:"AggregateFunctionNode",func:k,aggregated:W})},cloneWithDistinct(k){return h({...k,distinct:!0})},cloneWithOrderBy(k,W,$=!1){let M=$?"withinGroup":"orderBy";return h({...k,[M]:k[M]?$k.cloneWithItems(k[M],W):$k.create(W)})},cloneWithFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"And",W):C.create(W)})},cloneWithOrFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"Or",W):C.create(W)})},cloneWithOver(k,W){return h({...k,over:W})}});var cW=h({is(k){return k.kind==="FunctionNode"},create(k,W){return h({kind:"FunctionNode",func:k,arguments:W})}});class b{#k;constructor(k){this.#k=h(k)}get expressionType(){return}as(k){return new Eh(this,k)}distinct(){return new b({...this.#k,aggregateFunctionNode:e.cloneWithDistinct(this.#k.aggregateFunctionNode)})}orderBy(...k){return new b({...this.#k,aggregateFunctionNode:K.cloneWithOrderByItems(this.#k.aggregateFunctionNode,B(k))})}clearOrderBy(){return new b({...this.#k,aggregateFunctionNode:K.cloneWithoutOrderBy(this.#k.aggregateFunctionNode)})}withinGroupOrderBy(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithOrderBy(this.#k.aggregateFunctionNode,B(k),!0)})}filterWhere(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,L(k))})}filterWhereRef(k,W,$){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,m(k,W,$))})}over(k){let W=_h();return new b({...this.#k,aggregateFunctionNode:e.cloneWithOver(this.#k.aggregateFunctionNode,(k?k(W):W).toOperationNode())})}$call(k){return k(this)}$castTo(){return new b(this.#k)}$notNull(){return new b(this.#k)}toOperationNode(){return this.#k.aggregateFunctionNode}}class Eh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}function Oh(){let k=($,M)=>{return new Z(cW.create($,Gk(M??[])))},W=($,M)=>{return new b({aggregateFunctionNode:e.create($,M?Gk(M):void 0)})};return Object.assign(k,{agg:W,avg($){return W("avg",[$])},coalesce(...$){return k("coalesce",$)},count($){return W("count",[$])},countAll($){return new b({aggregateFunctionNode:e.create("count",R($))})},max($){return W("max",[$])},min($){return W("min",[$])},sum($){return W("sum",[$])},any($){return k("any",[$])},jsonAgg($){return new b({aggregateFunctionNode:e.create("json_agg",[V($)?F($):$.toOperationNode()])})},toJson($){return new Z(cW.create("to_json",[V($)?F($):$.toOperationNode()]))}})}var bh=h({is(k){return k.kind==="UnaryOperationNode"},create(k,W){return h({kind:"UnaryOperationNode",operator:k,operand:W})}});function Qh(k,W){return bh.create(y.create(k),f(W))}var l=h({is(k){return k.kind==="CaseNode"},create(k){return h({kind:"CaseNode",value:k})},cloneWithWhen(k,W){return h({...k,when:h(k.when?[...k.when,W]:[W])})},cloneWithThen(k,W){return h({...k,when:k.when?h([...k.when.slice(0,-1),Mk.cloneWithResult(k.when[k.when.length-1],W)]):void 0})},cloneWith(k,W){return h({...k,...W})}});class yW{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}}class gW{#k;constructor(k){this.#k=h(k)}then(k){return new Nh({...this.#k,node:l.cloneWithThen(this.#k.node,WW(k)?Bk(k):X(k))})}}class Nh{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}else(k){return new Bh({...this.#k,node:l.cloneWith(this.#k.node,{else:WW(k)?Bk(k):X(k)})})}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}class Bh{#k;constructor(k){this.#k=h(k)}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}var JW=h({is(k){return k.kind==="JSONOperatorChainNode"},create(k){return h({kind:"JSONOperatorChainNode",operator:k,values:h([])})},cloneWithValue(k,W){return h({...k,values:h([...k.values,W])})}});var tW=h({is(k){return k.kind==="JSONPathLegNode"},create(k,W){return h({kind:"JSONPathLegNode",type:k,value:W})}});var Uk=h({is(k){return k.kind==="JSONPathNode"},create(k){return h({kind:"JSONPathNode",inOperator:k,pathLegs:h([])})},cloneWithLeg(k,W){return h({...k,pathLegs:h([...k.pathLegs,W])})}});var Qk=h({is(k){return k.kind==="JSONReferenceNode"},create(k,W){return h({kind:"JSONReferenceNode",reference:k,traversal:W})},cloneWithTraversal(k,W){return h({...k,traversal:W})}});var Z$=/^#-\d+$/;class ik{#k;constructor(k){this.#k=k}at(k){if(typeof k!=="number"&&typeof k!=="string"||typeof k==="number"&&!Number.isInteger(k)||typeof k==="string"&&k!=="last"&&!Z$.test(k))throw Error(`Unexpected index value in .at(...): ${k}`);return this.#W("ArrayLocation",k)}key(k){return this.#W("Member",k)}#W(k,W){if(Qk.is(this.#k))return new uk(Qk.cloneWithTraversal(this.#k,Uk.is(this.#k.traversal)?Uk.cloneWithLeg(this.#k.traversal,tW.create(k,W)):JW.cloneWithValue(this.#k.traversal,Q.createImmediate(W))));return new uk(Uk.cloneWithLeg(this.#k,tW.create(k,W)))}}class uk extends ik{#k;constructor(k){super(k);this.#k=k}get expressionType(){return}as(k){return new xh(this,k)}$castTo(){return new uk(this.#k)}$notNull(){return new uk(this.#k)}toOperationNode(){return this.#k}}class xh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var nW=h({is(k){return k.kind==="TupleNode"},create(k){return h({kind:"TupleNode",values:h(k)})}});var Y$=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],X$=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ch=h({is(k){return k.kind==="DataTypeNode"},create(k){return h({kind:"DataTypeNode",dataType:k})}});function yh(k){if(Y$.includes(k))return!0;if(X$.some((W)=>W.test(k)))return!0;return!1}function gh(k){if(z(k))return k.toOperationNode();if(yh(k))return ch.create(k);throw Error(`invalid column data type ${JSON.stringify(k)}`)}var th=h({is(k){return k.kind==="CastNode"},create(k,W){return h({kind:"CastNode",expression:k,dataType:W})}});function XW(k=qk){function W(G,q,vk){return new Z(hW(G,q,vk))}function $(G,q){return new Z(Qh(G,q))}let M=Object.assign(W,{fn:void 0,eb:void 0,selectFrom(G){return nk({queryId:T(),executor:k,queryNode:Y.createFrom(n(G))})},case(G){return new yW({node:l.create(c(G)?void 0:f(G))})},ref(G,q){if(c(q))return new Z(t(G));return new ik(nh(G,q))},jsonPath(){return new ik(Uk.create())},table(G){return new Z(F(G))},val(G){return new Z(X(G))},refTuple(...G){return new Z(nW.create(G.map(f)))},tuple(...G){return new Z(nW.create(G.map(X)))},lit(G){return new Z(Bk(G))},unary:$,not(G){return $("not",G)},exists(G){return $("exists",G)},neg(G){return $("-",G)},between(G,q,vk){return new Z(Yk.create(f(G),y.create("between"),x.create(X(q),X(vk))))},betweenSymmetric(G,q,vk){return new Z(Yk.create(f(G),y.create("between symmetric"),x.create(X(q),X(vk))))},and(G){if(j(G))return new Z(mk(G,"and"));return new Z(UW(G,"and"))},or(G){if(j(G))return new Z(mk(G,"or"));return new Z(UW(G,"or"))},parens(...G){let q=L(G);if(Xk.is(q))return new Z(q);else return new Z(Xk.create(q))},cast(G,q){return new Z(th.create(f(G),gh(q)))},withSchema(G){return XW(k.withPluginAtFront(new YW(G)))}});return M.fn=Oh(),M.eb=M,M}function d(k){return XW()}function p(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(k)}`)}function MW(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(k)}`)}function Wk(k){return ok(k)||iW(k)||_(k)}function _W(k){if(V(k))return t(k);return k.toOperationNode()}function Gk(k){if(j(k))return k.map((W)=>f(W));else return[f(k)]}function f(k){if(Wk(k))return p(k);return _W(k)}function nh(k,W){let $=t(k);if(dW(W))return Qk.create($,JW.create(y.create(W)));let M=W.slice(0,-1);if(dW(M))return Qk.create($,Uk.create(y.create(M)));throw Error(`Invalid JSON operator: ${W}`)}function t(k){if(!k.includes("."))return Ak.create(S.create(k));let $=k.split(".").map(uW);if($.length===3)return L$($);if($.length===2)return z$($);throw Error(`invalid column reference ${k}`)}function Zh(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(uW);return I.create(t($),J.create(M))}else return t(k)}function D$(k){return S.create(k)}function R3(k){if(k.includes(" ")){let[$,M]=k.split(" ").map(uW);if(!RW(M))throw Error(`invalid order direction "${M}" next to "${$}"`);return B([$,M])[0]}else return D$(k)}function L$(k){let[W,$,M]=k;return Ak.create(S.create(M),zk.createWithSchema(W,$))}function z$(k){let[W,$]=k;return Ak.create(S.create($),zk.create(W))}function uW(k){return k.trim()}class lk{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isRawBuilder(){return!0}as(k){return new dh(this,k)}$castTo(){return new lk({...this.#k})}$notNull(){return new lk(this.#k)}withPlugin(k){return new lk({...this.#k,plugins:this.#k.plugins!==void 0?h([...this.#k.plugins,k]):h([k])})}toOperationNode(){return this.#h(this.#W())}compile(k){return this.#$(this.#W(k))}async execute(k){let W=this.#W(k);return W.executeQuery(this.#$(W))}#W(k){let W=k!==void 0?k.getExecutor():qk;return this.#k.plugins!==void 0?W.withPlugins(this.#k.plugins):W}#h(k){return k.transformQuery(this.#k.rawNode,this.#k.queryId)}#$(k){return k.compileQuery(this.#h(k),this.#k.queryId)}}function Zk(k){return new lk(k)}class dh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get rawBuilder(){return this.#k}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var J$=Object.assign((k,...W)=>{return Zk({queryId:T(),rawNode:v.create(k,W?.map(uh)??[])})},{ref(k){return Zk({queryId:T(),rawNode:v.createWithChild(t(k))})},val(k){return Zk({queryId:T(),rawNode:v.createWithChild(X(k))})},value(k){return this.val(k)},table(k){return Zk({queryId:T(),rawNode:v.createWithChild(F(k))})},id(...k){let W=Array(k.length+1).fill(".");return W[0]="",W[W.length-1]="",Zk({queryId:T(),rawNode:v.create(W,k.map(J.create))})},lit(k){return Zk({queryId:T(),rawNode:v.createWithChild(Q.createImmediate(k))})},literal(k){return this.lit(k)},raw(k){return Zk({queryId:T(),rawNode:v.createWithSql(k)})},join(k,W=J$`, `){let $=Array(Math.max(2*k.length-1,0)),M=W.toOperationNode();for(let G=0;G<k.length;++G)if($[2*G]=uh(k[G]),G!==k.length-1)$[2*G+1]=M;return Zk({queryId:T(),rawNode:v.createWithChildren($)})}});function uh(k){if(z(k))return k.toOperationNode();return X(k)}var l3=h({raw(k,W=[]){return h({sql:k,query:v.createWithSql(k),parameters:h(W),queryId:T()})}});
|
|
3
|
-
export{z as
|
|
2
|
+
import{$d as Mk,Bd as GW,Dd as _,Ed as kk,Fd as h,Gd as dk,Hd as j,Jd as J,Nd as I,Od as zk,Pd as x,Qd as hk,Rd as Kk,Sd as pW,Td as y,Ud as dW,Vd as v,Wd as fk,Xd as Xk,Yd as w,Zd as sW,_d as TW,be as YW,ce as Ch,vd as c,wd as V,xd as _k,yd as ek,zd as kW}from"./chunk-n4meg9wb.js";function z(k){return kk(k)&&_(k.toOperationNode)}var Q=h({is(k){return k.kind==="ValueNode"},create(k){return h({kind:"ValueNode",value:k})},createImmediate(k){return h({kind:"ValueNode",value:k,immediate:!0})}});var S=h({is(k){return k.kind==="ColumnNode"},create(k){return h({kind:"ColumnNode",column:J.create(k)})}});var pk=h({is(k){return k.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}});var Ak=h({is(k){return k.kind==="ReferenceNode"},create(k,W){return h({kind:"ReferenceNode",table:W,column:k})},createSelectAll(k){return h({kind:"ReferenceNode",table:k,column:pk.create()})}});function ok(k){return kk(k)&&"expressionType"in k&&z(k)}function iW(k){return kk(k)&&"expression"in k&&V(k.alias)&&z(k)}var a=h({is(k){return k.kind==="SelectModifierNode"},create(k,W){return h({kind:"SelectModifierNode",modifier:k,of:W})},createWithExpression(k){return h({kind:"SelectModifierNode",rawModifier:k})}});var Yk=h({is(k){return k.kind==="BinaryOperationNode"},create(k,W,$){return h({kind:"BinaryOperationNode",leftOperand:k,operator:W,rightOperand:$})}});var sk=h({is(k){return k.kind==="PrimitiveValueListNode"},create(k){return h({kind:"PrimitiveValueListNode",values:h([...k])})}});var rk=h({is(k){return k.kind==="ValueListNode"},create(k){return h({kind:"ValueListNode",values:h(k)})}});function lW(k){if(j(k))return ih(k);return X(k)}function X(k){if(Wk(k))return p(k);return Q.create(k)}function WW(k){return _k(k)||ek(k)||kW(k)}function Bk(k){if(!WW(k))throw Error(`unsafe immediate value ${JSON.stringify(k)}`);return Q.createImmediate(k)}function ih(k){if(k.some(Wk))return rk.create(k.map((W)=>X(W)));return sk.create(k)}function L(k){if(k.length===3)return hW(k[0],k[1],k[2]);else if(k.length===1)return X(k[0]);throw Error(`invalid arguments: ${JSON.stringify(k)}`)}function hW(k,W,$){if(lh(W)&&oW($))return Yk.create(f(k),PW(W),Q.createImmediate($));return Yk.create(f(k),PW(W),lW($))}function m(k,W,$){return Yk.create(f(k),PW(W),f($))}function UW(k,W){return mk(Object.entries(k).filter(([,$])=>!c($)).map(([$,M])=>hW($,oW(M)?"is":"=",M)),W)}function mk(k,W,$=!0){let M=W==="and"?x.create:hk.create;if(k.length===0)return Yk.create(Q.createImmediate(1),y.create("="),Q.createImmediate(W==="and"?1:0));let G=aW(k[0]);for(let q=1;q<k.length;++q)G=M(G,aW(k[q]));if(k.length>1&&$)return Xk.create(G);return G}function lh(k){return k==="is"||k==="is not"}function oW(k){return kW(k)||ek(k)}function PW(k){if(V(k)&&pW.includes(k))return y.create(k);if(z(k))return k.toOperationNode();throw Error(`invalid operator ${JSON.stringify(k)}`)}function aW(k){return z(k)?k.toOperationNode():k}var $k=h({is(k){return k.kind==="OrderByNode"},create(k){return h({kind:"OrderByNode",items:h([...k])})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var VW=h({is(k){return k.kind==="PartitionByNode"},create(k){return h({kind:"PartitionByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var xk=h({is(k){return k.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithPartitionByItems(k,W){return h({...k,partitionBy:k.partitionBy?VW.cloneWithItems(k.partitionBy,W):VW.create(W)})}});var Vk=h({is(k){return k.kind==="FromNode"},create(k){return h({kind:"FromNode",froms:h(k)})},cloneWithFroms(k,W){return h({...k,froms:h([...k.froms,...W])})}});var wW=h({is(k){return k.kind==="GroupByNode"},create(k){return h({kind:"GroupByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var FW=h({is(k){return k.kind==="HavingNode"},create(k){return h({kind:"HavingNode",having:k})},cloneWithOperation(k,W,$){return h({...k,having:W==="And"?x.create(k.having,$):hk.create(k.having,$)})}});var o=h({is(k){return k.kind==="UpdateQueryNode"},create(k,W){return h({kind:"UpdateQueryNode",table:k.length===1?k[0]:sW.create(k),...W&&{with:W}})},createWithoutTable(){return h({kind:"UpdateQueryNode"})},cloneWithFromItems(k,W){return h({...k,from:k.from?Vk.cloneWithFroms(k.from,W):Vk.create(W)})},cloneWithUpdates(k,W){return h({...k,updates:k.updates?h([...k.updates,...W]):W})},cloneWithLimit(k,W){return h({...k,limit:W})}});var Dk=h({is(k){return k.kind==="DeleteQueryNode"},create(k,W){return h({kind:"DeleteQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithUsing(k,W){return h({...k,using:k.using!==void 0?TW.cloneWithTables(k.using,W):TW.create(W)})}});var C=h({is(k){return k.kind==="WhereNode"},create(k){return h({kind:"WhereNode",where:k})},cloneWithOperation(k,W,$){return h({...k,where:W==="And"?x.create(k.where,$):hk.create(k.where,$)})}});var vW=h({is(k){return k.kind==="ReturningNode"},create(k){return h({kind:"ReturningNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var rW=h({is(k){return k.kind==="ExplainNode"},create(k,W){return h({kind:"ExplainNode",format:k,options:W})}});var N=h({is(k){return k.kind==="MergeQueryNode"},create(k,W){return h({kind:"MergeQueryNode",into:k,...W&&{with:W}})},cloneWithUsing(k,W){return h({...k,using:W})},cloneWithWhen(k,W){return h({...k,whens:k.whens?h([...k.whens,W]):h([W])})},cloneWithThen(k,W){return h({...k,whens:k.whens?h([...k.whens.slice(0,-1),Mk.cloneWithResult(k.whens[k.whens.length-1],W)]):void 0})}});var AW=h({is(k){return k.kind==="OutputNode"},create(k){return h({kind:"OutputNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var K=h({is(k){return Y.is(k)||w.is(k)||o.is(k)||Dk.is(k)||N.is(k)},cloneWithEndModifier(k,W){return h({...k,endModifiers:k.endModifiers?h([...k.endModifiers,W]):h([W])})},cloneWithWhere(k,W){return h({...k,where:k.where?C.cloneWithOperation(k.where,"And",W):C.create(W)})},cloneWithJoin(k,W){return h({...k,joins:k.joins?h([...k.joins,W]):h([W])})},cloneWithReturning(k,W){return h({...k,returning:k.returning?vW.cloneWithSelections(k.returning,W):vW.create(W)})},cloneWithoutReturning(k){return h({...k,returning:void 0})},cloneWithoutWhere(k){return h({...k,where:void 0})},cloneWithExplain(k,W,$){return h({...k,explain:rW.create(W,$?.toOperationNode())})},cloneWithTop(k,W){return h({...k,top:W})},cloneWithOutput(k,W){return h({...k,output:k.output?AW.cloneWithSelections(k.output,W):AW.create(W)})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithoutOrderBy(k){return h({...k,orderBy:void 0})}});var Y=h({is(k){return k.kind==="SelectQueryNode"},create(k){return h({kind:"SelectQueryNode",...k&&{with:k}})},createFrom(k,W){return h({kind:"SelectQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})},cloneWithDistinctOn(k,W){return h({...k,distinctOn:k.distinctOn?h([...k.distinctOn,...W]):h(W)})},cloneWithFrontModifier(k,W){return h({...k,frontModifiers:k.frontModifiers?h([...k.frontModifiers,W]):h([W])})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithGroupByItems(k,W){return h({...k,groupBy:k.groupBy?wW.cloneWithItems(k.groupBy,W):wW.create(W)})},cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithOffset(k,W){return h({...k,offset:W})},cloneWithFetch(k,W){return h({...k,fetch:W})},cloneWithHaving(k,W){return h({...k,having:k.having?FW.cloneWithOperation(k.having,"And",W):FW.create(W)})},cloneWithSetOperations(k,W){return h({...k,setOperations:k.setOperations?h([...k.setOperations,...W]):h([...W])})},cloneWithoutSelections(k){return h({...k,selections:[]})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithoutOffset(k){return h({...k,offset:void 0})},cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithoutGroupBy(k){return h({...k,groupBy:void 0})}});class Rk{#k;constructor(k){this.#k=h(k)}on(...k){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,L(k))})}onRef(k,W,$){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,m(k,W,$))})}onTrue(){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,v.createWithSql("true"))})}$call(k){return k(this)}toOperationNode(){return this.#k.joinNode}}class ah{#k;get dynamicReference(){return this.#k}get refType(){return}constructor(k){this.#k=k}toOperationNode(){return _W(this.#k)}}function $W(k){return kk(k)&&z(k)&&V(k.dynamicReference)}var g=h({is(k){return k.kind==="OrderByItemNode"},create(k,W){return h({kind:"OrderByItemNode",orderBy:k,direction:W})},cloneWith(k,W){return h({...k,...W})}});var eW=h({is(k){return k.kind==="CollateNode"},create(k){return h({kind:"CollateNode",collation:J.create(k)})}});class Lk{#k;constructor(k){this.#k=h(k)}desc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("desc")})})}asc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"last"})})}nullsFirst(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"first"})})}collate(k){return new Lk({node:g.cloneWith(this.#k.node,{collation:eW.create(k)})})}toOperationNode(){return this.#k.node}}function RW(k){return k==="asc"||k==="desc"}function B(k){if(k.length===2)return[mW(k[0],k[1])];if(k.length===1){let[W]=k;if(Array.isArray(W))return fk("orderBy(array) is deprecated, use multiple orderBy calls instead."),W.map(($)=>mW($));return[mW(W)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${k.length}`)}function mW(k,W){let $=ph(k);if(g.is($)){if(W)throw Error("Cannot specify direction twice!");return $}return kh($,W)}function ph(k){if(Wk(k))return p(k);if($W(k))return k.toOperationNode();let[W,$]=k.split(" ");if($)return fk("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),kh(t(W),$);return t(k)}function kh(k,W){if(typeof W==="string"){if(!RW(W))throw Error(`Invalid order by direction: ${W}`);return g.create(k,v.createWithSql(W))}if(ok(W))return fk("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),g.create(k,W.toOperationNode());let $=g.create(k);if(!W)return $;return W(new Lk({node:$})).toOperationNode()}var Wh=h({is(k){return k.kind==="PartitionByItemNode"},create(k){return h({kind:"PartitionByItemNode",partitionBy:k})}});function hh(k){return Gk(k).map(Wh.create)}class Ck{#k;constructor(k){this.#k=h(k)}orderBy(...k){return new Ck({overNode:xk.cloneWithOrderByItems(this.#k.overNode,B(k))})}clearOrderBy(){return new Ck({overNode:K.cloneWithoutOrderBy(this.#k.overNode)})}partitionBy(k){return new Ck({overNode:xk.cloneWithPartitionByItems(this.#k.overNode,hh(k))})}$call(k){return k(this)}toOperationNode(){return this.#k.overNode}}var Sk=h({is(k){return k.kind==="SelectionNode"},create(k){return h({kind:"SelectionNode",selection:k})},createSelectAll(){return h({kind:"SelectionNode",selection:pk.create()})},createSelectAllFromTable(k){return h({kind:"SelectionNode",selection:Ak.createSelectAll(k)})}});class oh{#k;get table(){return this.#k}constructor(k){this.#k=k}as(k){return new $h(this.#k,k)}}class $h{#k;#W;get table(){return this.#k}get alias(){return this.#W}constructor(k,W){this.#k=k,this.#W=W}toOperationNode(){return I.create(F(this.#k),J.create(this.#W))}}function Mh(k){return kk(k)&&z(k)&&V(k.table)&&V(k.alias)}function n(k){if(j(k))return k.map((W)=>wk(W));else return[wk(k)]}function wk(k){if(V(k))return fW(k);else if(Mh(k))return k.toOperationNode();else return MW(k)}function fW(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(Kh);return I.create(F($),J.create(M))}else return F(k)}function F(k){if(k.includes(".")){let[$,M]=k.split(".").map(Kh);return zk.createWithSchema($,M)}else return zk.create(k)}function Kh(k){return k.trim()}function A(k){if(_(k))return A(k(d()));else if(j(k))return k.map((W)=>Gh(W));else return[Gh(k)]}function Gh(k){if(V(k))return Sk.create(Zh(k));else if($W(k))return Sk.create(k.toOperationNode());else return Sk.create(MW(k))}function R(k){if(!k)return[Sk.createSelectAll()];else if(Array.isArray(k))return k.map(Hh);else return[Hh(k)]}function Hh(k){if(V(k))return Sk.createSelectAllFromTable(F(k));throw Error(`invalid value selectAll expression: ${JSON.stringify(k)}`)}var Yh=h({is(k){return k.kind==="ValuesNode"},create(k){return h({kind:"ValuesNode",values:h(k)})}});var Xh=h({is(k){return k.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function KW(k){let W=_(k)?k(d()):k,$=j(W)?W:h([W]);return sh($)}function sh(k){let W=rh(k);return[h([...W.keys()].map(S.create)),Yh.create(k.map(($)=>eh($,W)))]}function rh(k){let W=new Map;for(let $ of k){let M=Object.keys($);for(let G of M)if(!W.has(G)&&$[G]!==void 0)W.set(G,W.size)}return W}function eh(k,W){let $=Object.keys(k),M=Array.from({length:W.size}),G=!1,q=$.length;for(let ak of $){let Nk=W.get(ak);if(c(Nk)){q--;continue}let qW=k[ak];if(c(qW)||Wk(qW))G=!0;M[Nk]=qW}if(q<W.size||G){let ak=Xh.create();return rk.create(M.map((Nk)=>c(Nk)?ak:X(Nk)))}return sk.create(M)}var CW=h({is(k){return k.kind==="ColumnUpdateNode"},create(k,W){return h({kind:"ColumnUpdateNode",column:k,value:W})}});function Dh(...k){if(k.length===2)return[CW.create(f(k[0]),X(k[1]))];return ck(k[0])}function ck(k){let W=_(k)?k(d()):k;return Object.entries(W).filter(([$,M])=>M!==void 0).map(([$,M])=>{return CW.create(S.create($),X(M))})}var Lh=h({is(k){return k.kind==="OnDuplicateKeyNode"},create(k){return h({kind:"OnDuplicateKeyNode",updates:k})}});class SW{insertId;numInsertedOrUpdatedRows;constructor(k,W){this.insertId=k,this.numInsertedOrUpdatedRows=W}}class u extends Error{node;constructor(k){super("no result");this.node=k}}function s(k){return Object.prototype.hasOwnProperty.call(k,"prototype")}var E=h({is(k){return k.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(k,W){return h({...k,...W})},cloneWithIndexWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"And",W):C.create(W)})},cloneWithIndexOrWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"Or",W):C.create(W)})},cloneWithUpdateWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"And",W):C.create(W)})},cloneWithUpdateOrWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"Or",W):C.create(W)})},cloneWithoutIndexWhere(k){return h({...k,indexWhere:void 0})},cloneWithoutUpdateWhere(k){return h({...k,updateWhere:void 0})}});class r{#k;constructor(k){this.#k=h(k)}column(k){let W=S.create(k);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,W]):h([W])})})}columns(k){let W=k.map(S.create);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,...W]):h(W)})})}constraint(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{constraint:J.create(k)})})}expression(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{indexExpression:k.toOperationNode()})})}where(...k){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new r({...this.#k,onConflictNode:E.cloneWithoutIndexWhere(this.#k.onConflictNode)})}doNothing(){return new zh({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{doNothing:!0})})}doUpdateSet(k){return new yk({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{updates:ck(k)})})}$call(k){return k(this)}}class zh{#k;constructor(k){this.#k=h(k)}toOperationNode(){return this.#k.onConflictNode}}class yk{#k;constructor(k){this.#k=h(k)}where(...k){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new yk({...this.#k,onConflictNode:E.cloneWithoutUpdateWhere(this.#k.onConflictNode)})}$call(k){return k(this)}toOperationNode(){return this.#k.onConflictNode}}var Jh=h({is(k){return k.kind==="TopNode"},create(k,W){return h({kind:"TopNode",expression:k,modifiers:W})}});function i(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid top expression: ${k}`);if(!c(W)&&!k$(W))throw Error(`Invalid top modifiers: ${W}`);return Jh.create(k,W)}function k$(k){return k==="percent"||k==="with ties"||k==="percent with ties"}var Fk=h({is(k){return k.kind==="OrActionNode"},create(k){return h({kind:"OrActionNode",action:k})}});class D{#k;constructor(k){this.#k=h(k)}values(k){let[W,$]=KW(k);return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:W,values:$})})}columns(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:h(k.map(S.create))})})}expression(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{values:p(k)})})}defaultValues(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{defaultValues:!0})})}modifyEnd(k){return new D({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}ignore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orIgnore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orAbort(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("abort")})})}orFail(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("fail")})})}orReplace(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("replace")})})}orRollback(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("rollback")})})}top(k,W){return new D({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}onConflict(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onConflict:k(new r({onConflictNode:E.create()})).toOperationNode()})})}onDuplicateKeyUpdate(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onDuplicateKey:Lh.create(ck(k))})})}returning(k){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R())})}output(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new D({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new D({...this.#k})}$castTo(){return new D(this.#k)}$narrowType(){return new D(this.#k)}$assertType(){return new D(this.#k)}withPlugin(k){return new D({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new SW(W.insertId,W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new D({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}class IW{numDeletedRows;constructor(k){this.numDeletedRows=k}}var Ik=h({is(k){return k.kind==="LimitNode"},create(k){return h({kind:"LimitNode",limit:k})}});var P;class HW{#k;constructor(k){this.#k=h(k)}where(...k){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new P({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new P({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(k){return new P({...this.#k,queryNode:Dk.cloneWithUsing(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new P({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}returning(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new P({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}clearLimit(){return new P({...this.#k,queryNode:Dk.cloneWithoutLimit(this.#k.queryNode)})}orderBy(...k){return new P({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new P({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new P({...this.#k,queryNode:Dk.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}modifyEnd(k){return new P({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new P({...this.#k})}$castTo(){return new P(this.#k)}$narrowType(){return new P(this.#k)}$assertType(){return new P(this.#k)}withPlugin(k){return new P({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new IW(W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new P({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}P=HW;class jW{numUpdatedRows;numChangedRows;constructor(k,W){this.numUpdatedRows=k,this.numChangedRows=W}}var U;class jk{#k;constructor(k){this.#k=h(k)}where(...k){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new U({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new U({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}from(k){return new U({...this.#k,queryNode:o.cloneWithFromItems(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new U({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new U({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new U({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new U({...this.#k,queryNode:o.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}set(...k){return new U({...this.#k,queryNode:o.cloneWithUpdates(this.#k.queryNode,Dh(...k))})}returning(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}modifyEnd(k){return new U({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}clearReturning(){return new U({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new U({...this.#k})}$castTo(){return new U(this.#k)}$narrowType(){return new U(this.#k)}$assertType(){return new U(this.#k)}withPlugin(k){return new U({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new jW(W.numAffectedRows??BigInt(0),W.numChangedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new U({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}U=jk;var EW=h({is(k){return k.kind==="CommonTableExpressionNameNode"},create(k,W){return h({kind:"CommonTableExpressionNameNode",table:zk.create(k),columns:W?h(W.map(S.create)):void 0})}});var Ek=h({is(k){return k.kind==="CommonTableExpressionNode"},create(k,W){return h({kind:"CommonTableExpressionNode",name:k,expression:W})},cloneWith(k,W){return h({...k,...W})}});class gk{#k;constructor(k){this.#k=h(k)}materialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!0})})}notMaterialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!1})})}toOperationNode(){return this.#k.node}}function OW(k,W){let $=W(Ph()).toOperationNode();if(_(k))return k(W$($)).toOperationNode();return Ek.create(qh(k),$)}function W$(k){return(W)=>{return new gk({node:Ek.create(qh(W),k)})}}function qh(k){if(k.includes("(")){let W=k.split(/[\(\)]/),$=W[0],M=W[1].split(",").map((G)=>G.trim());return EW.create($,M)}else return EW.create(k)}var tk=h({is(k){return k.kind==="WithNode"},create(k,W){return h({kind:"WithNode",expressions:h([k]),...W})},cloneWithExpression(k,W){return h({...k,expressions:h([...k.expressions,W])})}});var Uh=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Vh(k){let W="";for(let $=0;$<k;++$)W+=h$();return W}function h$(){return Uh[~~(Math.random()*Uh.length)]}function T(){return new wh}class wh{#k;get queryId(){if(this.#k===void 0)this.#k=Vh(8);return this.#k}}var Fh=h({is(k){return k.kind==="MatchedNode"},create(k,W=!1){return h({kind:"MatchedNode",not:k,bySource:W})}});function bW(k,W,$){return Mk.create(mk([Fh.create(!k.isMatched,k.bySource),...W&&W.length>0?[W.length===3&&$?m(W[0],W[1],W[2]):L(W)]:[]],"and",!1))}function Ok(k){if(V(k))return v.create([k],[]);if(z(k))return k.toOperationNode();return k}class ZW{#k;#W;#h;constructor(){this.#k=new Promise((k,W)=>{this.#h=W,this.#W=k})}get promise(){return this.#k}resolve=(k)=>{if(this.#W)this.#W(k)};reject=(k)=>{if(this.#h)this.#h(k)}}async function Th(k){let W=new ZW,$=new ZW;return k.provideConnection(async(M)=>{return W.resolve(M),await $.promise}).catch((M)=>W.reject(M)),h({connection:await W.promise,release:$.resolve})}var $$=h([]);class QW{#k;constructor(k=$$){this.#k=k}get plugins(){return this.#k}transformQuery(k,W){for(let $ of this.#k){let M=$.transformQuery({node:k,queryId:W});if(M.kind===k.kind)k=M;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${k.kind}`,`but it returned a ${M.kind}`].join(" "))}return k}async executeQuery(k){return await this.provideConnection(async(W)=>{let $=await W.executeQuery(k);if("numUpdatedOrDeletedRows"in $)fk("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#W($,k.queryId)})}async*stream(k,W){let{connection:$,release:M}=await Th(this);try{for await(let G of $.streamQuery(k,W))yield await this.#W(G,k.queryId)}finally{M()}}async#W(k,W){for(let $ of this.#k)k=await $.transformResult({result:k,queryId:W});return k}}class bk extends QW{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(k){return new bk([...this.plugins,k])}withPlugins(k){return new bk([...this.plugins,...k])}withPluginAtFront(k){return new bk([k,...this.plugins])}withoutPlugins(){return new bk([])}}var qk=new bk;class NW{numChangedRows;constructor(k){this.numChangedRows=k}}class Hk{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new Hk({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new Hk({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(...k){return new O({...this.#k,queryNode:N.cloneWithUsing(this.#k.queryNode,Jk("Using",k))})}returning(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}}class O{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new O({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new O({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}whenMatched(){return this.#W([])}whenMatchedAnd(...k){return this.#W(k)}whenMatchedAndRef(k,W,$){return this.#W([k,W,$],!0)}#W(k,W){return new BW({...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!0},k,W))})}whenNotMatched(){return this.#h([])}whenNotMatchedAnd(...k){return this.#h(k)}whenNotMatchedAndRef(k,W,$){return this.#h([k,W,$],!0)}whenNotMatchedBySource(){return this.#h([],!1,!0)}whenNotMatchedBySourceAnd(...k){return this.#h(k,!1,!0)}whenNotMatchedBySourceAndRef(k,W,$){return this.#h([k,W,$],!0,!0)}returning(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}#h(k,W=!1,$=!1){let M={...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!1,bySource:$},k,W))};return new($?BW:vh)(M)}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new O({...this.#k})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new NW(W.numAffectedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}}class BW{#k;constructor(k){this.#k=h(k)}thenDelete(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("delete"))})}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenUpdate(k){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(k(new jk({queryId:this.#k.queryId,executor:qk,queryNode:o.createWithoutTable()}))))})}thenUpdateSet(...k){return this.thenUpdate((W)=>W.set(...k))}}class vh{#k;constructor(k){this.#k=h(k)}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenInsertValues(k){let[W,$]=KW(k);return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(w.cloneWith(w.createWithoutInto(),{columns:W,values:$})))})}}class Pk{#k;constructor(k){this.#k=h(k)}selectFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.createFrom(n(k),this.#k.withNode)})}selectNoFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.cloneWithSelections(Y.create(this.#k.withNode),A(k))})}insertInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode)})}replaceInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode,!0)})}deleteFrom(k){return new HW({queryId:T(),executor:this.#k.executor,queryNode:Dk.create(n(k),this.#k.withNode)})}updateTable(k){return new jk({queryId:T(),executor:this.#k.executor,queryNode:o.create(n(k),this.#k.withNode)})}mergeInto(k){return new Hk({queryId:T(),executor:this.#k.executor,queryNode:N.create(fW(k),this.#k.withNode)})}with(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($)})}withRecursive(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($,{recursive:!0})})}withPlugin(k){return new Pk({...this.#k,executor:this.#k.executor.withPlugin(k)})}withoutPlugins(){return new Pk({...this.#k,executor:this.#k.executor.withoutPlugins()})}withSchema(k){return new Pk({...this.#k,executor:this.#k.executor.withPluginAtFront(new YW(k))})}}function Ph(){return new Pk({executor:qk})}function Ah(k,W){return new Rk({joinNode:Kk.create(k,wk(W))})}function _h(){return new Ck({overNode:xk.create()})}function Jk(k,W){if(W.length===3)return K$(k,W[0],W[1],W[2]);else if(W.length===2)return M$(k,W[0],W[1]);else if(W.length===1)return G$(k,W[0]);else throw Error("not implemented")}function M$(k,W,$){return $(Ah(k,W)).toOperationNode()}function K$(k,W,$,M){return Kk.createWithOn(k,wk(W),m($,"=",M))}function G$(k,W){return Kk.create(k,wk(W))}var mh=h({is(k){return k.kind==="OffsetNode"},create(k){return h({kind:"OffsetNode",offset:k})}});var Rh=h({is(k){return k.kind==="GroupByItemNode"},create(k){return h({kind:"GroupByItemNode",groupBy:k})}});function fh(k){return k=_(k)?k(d()):k,Gk(k).map(Rh.create)}function Tk(k,W,$){if(_(W))W=W(XW());if(!j(W))W=[W];return W.map((M)=>Ch.create(k,p(M),$))}class Z{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new Z(this.#k)}$notNull(){return new Z(this.#k)}toOperationNode(){return this.#k}}class zW{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}class DW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}$castTo(){return new DW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}class LW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new LW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}var Sh=h({is(k){return k.kind==="FetchNode"},create(k,W){return{kind:"FetchNode",rowCount:Q.create(k),modifier:W}}});function Ih(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid fetch row count: ${k}`);if(!H$(W))throw Error(`Invalid fetch modifier: ${W}`);return Sh.create(k,W)}function H$(k){return k==="only"||k==="with ties"}var H;class xW{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...k){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}having(...k){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,L(k))})}havingRef(k,W,$){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,m(k,W,$))})}select(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,A(k))})}distinctOn(k){return new H({...this.#k,queryNode:Y.cloneWithDistinctOn(this.#k.queryNode,Gk(k))})}modifyFront(k){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}modifyEnd(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}distinct(){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.create("Distinct"))})}forUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForUpdate",k?dk(k).map(F):void 0))})}forShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForShare",k?dk(k).map(F):void 0))})}forKeyShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForKeyShare",k?dk(k).map(F):void 0))})}forNoKeyUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForNoKeyUpdate",k?dk(k).map(F):void 0))})}skipLocked(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("SkipLocked"))})}noWait(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("NoWait"))})}selectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,R(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}crossJoin(...k){return this.#W("CrossJoin",k)}innerJoinLateral(...k){return this.#W("LateralInnerJoin",k)}leftJoinLateral(...k){return this.#W("LateralLeftJoin",k)}crossJoinLateral(...k){return this.#W("LateralCrossJoin",k)}crossApply(...k){return this.#W("CrossApply",k)}outerApply(...k){return this.#W("OuterApply",k)}#W(k,W){return new H({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new H({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}groupBy(k){return new H({...this.#k,queryNode:Y.cloneWithGroupByItems(this.#k.queryNode,fh(k))})}limit(k){return new H({...this.#k,queryNode:Y.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}offset(k){return new H({...this.#k,queryNode:Y.cloneWithOffset(this.#k.queryNode,mh.create(X(k)))})}fetch(k,W="only"){return new H({...this.#k,queryNode:Y.cloneWithFetch(this.#k.queryNode,Ih(k,W))})}top(k,W){return new H({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}union(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!1))})}unionAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!0))})}intersect(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!1))})}intersectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!0))})}except(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!1))})}exceptAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!0))})}as(k){return new jh(this,k)}clearSelect(){return new H({...this.#k,queryNode:Y.cloneWithoutSelections(this.#k.queryNode)})}clearWhere(){return new H({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}clearLimit(){return new H({...this.#k,queryNode:Y.cloneWithoutLimit(this.#k.queryNode)})}clearOffset(){return new H({...this.#k,queryNode:Y.cloneWithoutOffset(this.#k.queryNode)})}clearOrderBy(){return new H({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}clearGroupBy(){return new H({...this.#k,queryNode:Y.cloneWithoutGroupBy(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new H({...this.#k})}$castTo(){return new H(this.#k)}$narrowType(){return new H(this.#k)}$assertType(){return new H(this.#k)}$asTuple(){return new Z(this.toOperationNode())}$asScalar(){return new Z(this.toOperationNode())}withPlugin(k){return new H({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile();return(await this.#k.executor.executeQuery(k)).rows}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new H({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}H=xW;function nk(k){return new xW(k)}class jh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}var e=h({is(k){return k.kind==="AggregateFunctionNode"},create(k,W=[]){return h({kind:"AggregateFunctionNode",func:k,aggregated:W})},cloneWithDistinct(k){return h({...k,distinct:!0})},cloneWithOrderBy(k,W,$=!1){let M=$?"withinGroup":"orderBy";return h({...k,[M]:k[M]?$k.cloneWithItems(k[M],W):$k.create(W)})},cloneWithFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"And",W):C.create(W)})},cloneWithOrFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"Or",W):C.create(W)})},cloneWithOver(k,W){return h({...k,over:W})}});var cW=h({is(k){return k.kind==="FunctionNode"},create(k,W){return h({kind:"FunctionNode",func:k,arguments:W})}});class b{#k;constructor(k){this.#k=h(k)}get expressionType(){return}as(k){return new Eh(this,k)}distinct(){return new b({...this.#k,aggregateFunctionNode:e.cloneWithDistinct(this.#k.aggregateFunctionNode)})}orderBy(...k){return new b({...this.#k,aggregateFunctionNode:K.cloneWithOrderByItems(this.#k.aggregateFunctionNode,B(k))})}clearOrderBy(){return new b({...this.#k,aggregateFunctionNode:K.cloneWithoutOrderBy(this.#k.aggregateFunctionNode)})}withinGroupOrderBy(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithOrderBy(this.#k.aggregateFunctionNode,B(k),!0)})}filterWhere(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,L(k))})}filterWhereRef(k,W,$){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,m(k,W,$))})}over(k){let W=_h();return new b({...this.#k,aggregateFunctionNode:e.cloneWithOver(this.#k.aggregateFunctionNode,(k?k(W):W).toOperationNode())})}$call(k){return k(this)}$castTo(){return new b(this.#k)}$notNull(){return new b(this.#k)}toOperationNode(){return this.#k.aggregateFunctionNode}}class Eh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}function Oh(){let k=($,M)=>{return new Z(cW.create($,Gk(M??[])))},W=($,M)=>{return new b({aggregateFunctionNode:e.create($,M?Gk(M):void 0)})};return Object.assign(k,{agg:W,avg($){return W("avg",[$])},coalesce(...$){return k("coalesce",$)},count($){return W("count",[$])},countAll($){return new b({aggregateFunctionNode:e.create("count",R($))})},max($){return W("max",[$])},min($){return W("min",[$])},sum($){return W("sum",[$])},any($){return k("any",[$])},jsonAgg($){return new b({aggregateFunctionNode:e.create("json_agg",[V($)?F($):$.toOperationNode()])})},toJson($){return new Z(cW.create("to_json",[V($)?F($):$.toOperationNode()]))}})}var bh=h({is(k){return k.kind==="UnaryOperationNode"},create(k,W){return h({kind:"UnaryOperationNode",operator:k,operand:W})}});function Qh(k,W){return bh.create(y.create(k),f(W))}var l=h({is(k){return k.kind==="CaseNode"},create(k){return h({kind:"CaseNode",value:k})},cloneWithWhen(k,W){return h({...k,when:h(k.when?[...k.when,W]:[W])})},cloneWithThen(k,W){return h({...k,when:k.when?h([...k.when.slice(0,-1),Mk.cloneWithResult(k.when[k.when.length-1],W)]):void 0})},cloneWith(k,W){return h({...k,...W})}});class yW{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}}class gW{#k;constructor(k){this.#k=h(k)}then(k){return new Nh({...this.#k,node:l.cloneWithThen(this.#k.node,WW(k)?Bk(k):X(k))})}}class Nh{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}else(k){return new Bh({...this.#k,node:l.cloneWith(this.#k.node,{else:WW(k)?Bk(k):X(k)})})}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}class Bh{#k;constructor(k){this.#k=h(k)}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}var JW=h({is(k){return k.kind==="JSONOperatorChainNode"},create(k){return h({kind:"JSONOperatorChainNode",operator:k,values:h([])})},cloneWithValue(k,W){return h({...k,values:h([...k.values,W])})}});var tW=h({is(k){return k.kind==="JSONPathLegNode"},create(k,W){return h({kind:"JSONPathLegNode",type:k,value:W})}});var Uk=h({is(k){return k.kind==="JSONPathNode"},create(k){return h({kind:"JSONPathNode",inOperator:k,pathLegs:h([])})},cloneWithLeg(k,W){return h({...k,pathLegs:h([...k.pathLegs,W])})}});var Qk=h({is(k){return k.kind==="JSONReferenceNode"},create(k,W){return h({kind:"JSONReferenceNode",reference:k,traversal:W})},cloneWithTraversal(k,W){return h({...k,traversal:W})}});var Z$=/^#-\d+$/;class ik{#k;constructor(k){this.#k=k}at(k){if(typeof k!=="number"&&typeof k!=="string"||typeof k==="number"&&!Number.isInteger(k)||typeof k==="string"&&k!=="last"&&!Z$.test(k))throw Error(`Unexpected index value in .at(...): ${k}`);return this.#W("ArrayLocation",k)}key(k){return this.#W("Member",k)}#W(k,W){if(Qk.is(this.#k))return new uk(Qk.cloneWithTraversal(this.#k,Uk.is(this.#k.traversal)?Uk.cloneWithLeg(this.#k.traversal,tW.create(k,W)):JW.cloneWithValue(this.#k.traversal,Q.createImmediate(W))));return new uk(Uk.cloneWithLeg(this.#k,tW.create(k,W)))}}class uk extends ik{#k;constructor(k){super(k);this.#k=k}get expressionType(){return}as(k){return new xh(this,k)}$castTo(){return new uk(this.#k)}$notNull(){return new uk(this.#k)}toOperationNode(){return this.#k}}class xh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var nW=h({is(k){return k.kind==="TupleNode"},create(k){return h({kind:"TupleNode",values:h(k)})}});var Y$=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],X$=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ch=h({is(k){return k.kind==="DataTypeNode"},create(k){return h({kind:"DataTypeNode",dataType:k})}});function yh(k){if(Y$.includes(k))return!0;if(X$.some((W)=>W.test(k)))return!0;return!1}function gh(k){if(z(k))return k.toOperationNode();if(yh(k))return ch.create(k);throw Error(`invalid column data type ${JSON.stringify(k)}`)}var th=h({is(k){return k.kind==="CastNode"},create(k,W){return h({kind:"CastNode",expression:k,dataType:W})}});function XW(k=qk){function W(G,q,vk){return new Z(hW(G,q,vk))}function $(G,q){return new Z(Qh(G,q))}let M=Object.assign(W,{fn:void 0,eb:void 0,selectFrom(G){return nk({queryId:T(),executor:k,queryNode:Y.createFrom(n(G))})},case(G){return new yW({node:l.create(c(G)?void 0:f(G))})},ref(G,q){if(c(q))return new Z(t(G));return new ik(nh(G,q))},jsonPath(){return new ik(Uk.create())},table(G){return new Z(F(G))},val(G){return new Z(X(G))},refTuple(...G){return new Z(nW.create(G.map(f)))},tuple(...G){return new Z(nW.create(G.map(X)))},lit(G){return new Z(Bk(G))},unary:$,not(G){return $("not",G)},exists(G){return $("exists",G)},neg(G){return $("-",G)},between(G,q,vk){return new Z(Yk.create(f(G),y.create("between"),x.create(X(q),X(vk))))},betweenSymmetric(G,q,vk){return new Z(Yk.create(f(G),y.create("between symmetric"),x.create(X(q),X(vk))))},and(G){if(j(G))return new Z(mk(G,"and"));return new Z(UW(G,"and"))},or(G){if(j(G))return new Z(mk(G,"or"));return new Z(UW(G,"or"))},parens(...G){let q=L(G);if(Xk.is(q))return new Z(q);else return new Z(Xk.create(q))},cast(G,q){return new Z(th.create(f(G),gh(q)))},withSchema(G){return XW(k.withPluginAtFront(new YW(G)))}});return M.fn=Oh(),M.eb=M,M}function d(k){return XW()}function p(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(k)}`)}function MW(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(k)}`)}function Wk(k){return ok(k)||iW(k)||_(k)}function _W(k){if(V(k))return t(k);return k.toOperationNode()}function Gk(k){if(j(k))return k.map((W)=>f(W));else return[f(k)]}function f(k){if(Wk(k))return p(k);return _W(k)}function nh(k,W){let $=t(k);if(dW(W))return Qk.create($,JW.create(y.create(W)));let M=W.slice(0,-1);if(dW(M))return Qk.create($,Uk.create(y.create(M)));throw Error(`Invalid JSON operator: ${W}`)}function t(k){if(!k.includes("."))return Ak.create(S.create(k));let $=k.split(".").map(uW);if($.length===3)return L$($);if($.length===2)return z$($);throw Error(`invalid column reference ${k}`)}function Zh(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(uW);return I.create(t($),J.create(M))}else return t(k)}function D$(k){return S.create(k)}function R3(k){if(k.includes(" ")){let[$,M]=k.split(" ").map(uW);if(!RW(M))throw Error(`invalid order direction "${M}" next to "${$}"`);return B([$,M])[0]}else return D$(k)}function L$(k){let[W,$,M]=k;return Ak.create(S.create(M),zk.createWithSchema(W,$))}function z$(k){let[W,$]=k;return Ak.create(S.create($),zk.create(W))}function uW(k){return k.trim()}class lk{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isRawBuilder(){return!0}as(k){return new dh(this,k)}$castTo(){return new lk({...this.#k})}$notNull(){return new lk(this.#k)}withPlugin(k){return new lk({...this.#k,plugins:this.#k.plugins!==void 0?h([...this.#k.plugins,k]):h([k])})}toOperationNode(){return this.#h(this.#W())}compile(k){return this.#$(this.#W(k))}async execute(k){let W=this.#W(k);return W.executeQuery(this.#$(W))}#W(k){let W=k!==void 0?k.getExecutor():qk;return this.#k.plugins!==void 0?W.withPlugins(this.#k.plugins):W}#h(k){return k.transformQuery(this.#k.rawNode,this.#k.queryId)}#$(k){return k.compileQuery(this.#h(k),this.#k.queryId)}}function Zk(k){return new lk(k)}class dh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get rawBuilder(){return this.#k}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var J$=Object.assign((k,...W)=>{return Zk({queryId:T(),rawNode:v.create(k,W?.map(uh)??[])})},{ref(k){return Zk({queryId:T(),rawNode:v.createWithChild(t(k))})},val(k){return Zk({queryId:T(),rawNode:v.createWithChild(X(k))})},value(k){return this.val(k)},table(k){return Zk({queryId:T(),rawNode:v.createWithChild(F(k))})},id(...k){let W=Array(k.length+1).fill(".");return W[0]="",W[W.length-1]="",Zk({queryId:T(),rawNode:v.create(W,k.map(J.create))})},lit(k){return Zk({queryId:T(),rawNode:v.createWithChild(Q.createImmediate(k))})},literal(k){return this.lit(k)},raw(k){return Zk({queryId:T(),rawNode:v.createWithSql(k)})},join(k,W=J$`, `){let $=Array(Math.max(2*k.length-1,0)),M=W.toOperationNode();for(let G=0;G<k.length;++G)if($[2*G]=uh(k[G]),G!==k.length-1)$[2*G+1]=M;return Zk({queryId:T(),rawNode:v.createWithChildren($)})}});function uh(k){if(z(k))return k.toOperationNode();return X(k)}var l3=h({raw(k,W=[]){return h({sql:k,query:v.createWithSql(k),parameters:h(W),queryId:T()})}});
|
|
3
|
+
export{z as Tc,S as Uc,pk as Vc,ah as Wc,t as Xc,D$ as Yc,R3 as Zc,rk as _c,Q as $c,L as ad,K as bd,Y as cd,Vh as dd,T as ed,ZW as fd,Th as gd,QW as hd,Pk as id,Oh as jd,l as kd,yW as ld,gh as md,p as nd,oh as od,F as pd,J$ as qd,l3 as rd};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{d as
|
|
1
|
+
import{gk as r,oh as o}from"./chunk-nyhqy6q2.js";function d({className:t,...a}){return o("div",{"data-slot":"card",className:r("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",t),...a})}function n({className:t,...a}){return o("div",{"data-slot":"card-header",className:r("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function c({className:t,...a}){return o("div",{"data-slot":"card-title",className:r("leading-none font-semibold",t),...a})}function s({className:t,...a}){return o("div",{"data-slot":"card-description",className:r("text-sm text-muted-foreground",t),...a})}function i({className:t,...a}){return o("div",{"data-slot":"card-content",className:r("px-6",t),...a})}function l({className:t,...a}){return o("div",{"data-slot":"card-footer",className:r("flex items-center px-6 [.border-t]:pt-6",t),...a})}
|
|
2
|
+
export{d as qf,n as rf,c as sf,s as tf,i as uf,l as vf};
|