@shumai-one/shumai 0.6.0 → 0.6.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-01052ssf.js +32 -0
- package/bin/{chunk-cdk8vqeg.js → chunk-02fvcrej.js} +4 -4
- package/bin/chunk-0bj887zm.js +2 -0
- package/bin/chunk-167z646e.js +2 -0
- package/bin/chunk-1ktk6764.js +10 -0
- package/bin/{chunk-4jj92zwa.js → chunk-1nvd90g2.js} +1 -1
- package/bin/{chunk-ww9qq8yq.js → chunk-1wfg56z3.js} +5 -5
- package/bin/{chunk-3tg10kwz.js → chunk-257dcd2f.js} +2 -2
- package/bin/chunk-26qn7fek.js +2 -0
- package/bin/chunk-2cdxm1cp.js +55 -0
- package/bin/chunk-2jj4j8cn.js +3 -0
- package/bin/chunk-2ne2b54t.js +2 -0
- package/bin/{chunk-h1fbev9c.js → chunk-2nhgdqdg.js} +2 -2
- package/bin/chunk-2vbeqczj.js +1 -0
- package/bin/chunk-37p6bcx2.js +1 -0
- package/bin/chunk-3ckkwdjx.js +13 -0
- package/bin/chunk-3knfx6dm.js +1 -0
- package/bin/chunk-3z85zxkn.js +1 -0
- package/bin/chunk-4mws03es.js +5 -0
- package/bin/chunk-54tbfvya.js +2 -0
- package/bin/chunk-55h9ze53.js +2 -0
- package/bin/chunk-56kh5fxc.js +1 -0
- package/bin/chunk-576nj64j.js +2 -0
- package/bin/{chunk-9gftd4f7.js → chunk-5wapd171.js} +13 -13
- package/bin/chunk-6cnqjngz.js +1 -0
- package/bin/chunk-73yncv54.js +2 -0
- package/bin/chunk-7g46e1wy.js +3 -0
- package/bin/{chunk-3020am4q.js → chunk-7naa7tpn.js} +2 -2
- package/bin/{chunk-6zerk0em.js → chunk-7sgrtxbt.js} +2 -2
- package/bin/{chunk-5bpvwv66.js → chunk-7v7mypc6.js} +2 -2
- package/bin/chunk-82tps5n1.js +2 -0
- package/bin/chunk-84x8p7v5.js +1 -0
- package/bin/{chunk-fxg81vtx.js → chunk-88jg9dq5.js} +2 -2
- package/bin/chunk-8cjet7pp.js +12 -0
- package/bin/chunk-8fyg9dy4.js +2 -0
- package/bin/chunk-8gtfgkrn.js +2 -0
- package/bin/chunk-8mqbztj8.js +2 -0
- package/bin/chunk-8qdtvfx3.css +1 -0
- package/bin/chunk-8xb6yz11.js +2 -0
- package/bin/chunk-8yjsmr7g.js +2 -0
- package/bin/chunk-91rb0jpb.js +2 -0
- package/bin/chunk-96qpjght.js +2 -0
- package/bin/chunk-9f1xk1nt.js +1 -0
- package/bin/chunk-9mk9cvbk.js +1 -0
- package/bin/{chunk-65t6rm5d.js → chunk-9n1w5dw1.js} +3 -3
- package/bin/chunk-9nw5w8vh.js +1 -0
- package/bin/{chunk-cv5xx81e.js → chunk-9t3p4xp6.js} +1 -1
- package/bin/chunk-9xhjy897.js +11 -0
- package/bin/chunk-9zsv6d2f.js +1 -0
- package/bin/chunk-a411xhmm.js +7 -0
- package/bin/{chunk-xbw7ffrz.js → chunk-a74g6h8a.js} +2 -2
- package/bin/chunk-ah8fjb6f.js +2 -0
- package/bin/chunk-atfz7g7e.js +2 -0
- package/bin/{chunk-j4p3eqtd.js → chunk-b5rhvzv9.js} +2 -2
- package/bin/{chunk-rq2h2bwt.js → chunk-b7bnp021.js} +2 -2
- package/bin/chunk-cf5axr8c.js +1 -0
- package/bin/chunk-cgmebxx6.js +2 -0
- package/bin/chunk-cwat1jwx.js +3 -0
- package/bin/chunk-cz13a82m.js +3 -0
- package/bin/chunk-dk42gf7v.js +2 -0
- package/bin/chunk-e4f56spj.js +4 -0
- package/bin/chunk-e4yscwen.js +18 -0
- package/bin/chunk-eb7mzbfm.js +1 -0
- package/bin/chunk-er14d498.js +3 -0
- package/bin/{chunk-sbyyn9yw.js → chunk-eyjfhdp9.js} +2 -2
- package/bin/chunk-f25fe9th.js +393 -0
- package/bin/chunk-f6avg5qe.js +129 -0
- package/bin/{chunk-vjyget8s.js → chunk-fatmqnp1.js} +1 -1
- package/bin/chunk-fvx9k1dc.js +2 -0
- package/bin/chunk-g22wmpk1.js +3 -0
- package/bin/chunk-g6sdezec.js +2 -0
- package/bin/chunk-gtf19jc1.js +2 -0
- package/bin/chunk-gxepkvt2.js +2 -0
- package/bin/chunk-h1n7jqnw.js +1 -0
- package/bin/chunk-hfm82066.js +2 -0
- package/bin/chunk-hnkcgvcj.js +3 -0
- package/bin/{chunk-fg9sr6r9.js → chunk-hpbn0k9n.js} +2 -2
- package/bin/{chunk-qk5hsn6e.js → chunk-hpwv4am3.js} +4 -4
- package/bin/{chunk-d6xezgrg.js → chunk-hw6czrya.js} +1 -1
- package/bin/{chunk-59t9s2jh.js → chunk-hzkjgcre.js} +1 -1
- package/bin/chunk-j2s311yc.js +3 -0
- package/bin/{chunk-6hzktewz.js → chunk-jt02kpfc.js} +2 -2
- package/bin/{chunk-qnyqtaf0.js → chunk-jt0ykktx.js} +1 -1
- package/bin/{chunk-047n9gfs.js → chunk-jzgbxqdg.js} +2 -2
- package/bin/chunk-kj6h5j5a.js +4 -0
- package/bin/chunk-km4gn6b6.js +1 -0
- package/bin/chunk-knj2s8mg.js +16 -0
- package/bin/{chunk-01ym2agz.js → chunk-kvhf12b4.js} +2 -2
- package/bin/chunk-m0q2cgfg.js +2 -0
- package/bin/chunk-m82tkhaa.js +11 -0
- package/bin/chunk-m9adtgzk.js +2 -0
- package/bin/{chunk-rh8dy99a.js → chunk-mcj1xpcc.js} +2 -2
- package/bin/chunk-mcw198kg.js +13 -0
- package/bin/{chunk-5e7r7a9d.js → chunk-mwktrwtx.js} +1 -1
- package/bin/chunk-mzsw9var.js +3 -0
- package/bin/chunk-ns33grgx.js +2 -0
- package/bin/{chunk-emgyjhmx.js → chunk-ny1kbmxt.js} +2 -2
- package/bin/{chunk-czybv3vy.js → chunk-p3f5aevs.js} +1 -1
- package/bin/chunk-p3j6ydk1.js +1 -0
- package/bin/chunk-p4s95471.js +2 -0
- package/bin/chunk-pk406dgy.js +2 -0
- package/bin/chunk-q2bew2vc.js +2 -0
- package/bin/chunk-q5vkxee3.js +5 -0
- package/bin/{chunk-n0wwtjwv.js → chunk-q83h0hkx.js} +2 -2
- package/bin/chunk-q8w4mbw4.js +2 -0
- package/bin/{chunk-hjwpd09v.js → chunk-qwpkcp8d.js} +2 -2
- package/bin/chunk-r1xer8gn.js +5 -0
- package/bin/chunk-s1e4qy3q.js +14 -0
- package/bin/{chunk-w89czwjj.js → chunk-s9ksftq2.js} +1 -1
- package/bin/chunk-srxp5jav.js +42 -0
- package/bin/chunk-swtwaaqe.js +1 -0
- package/bin/chunk-tagdrg7p.js +1 -0
- package/bin/{chunk-da86fpjt.js → chunk-tekwpkjf.js} +2 -2
- package/bin/chunk-twtxnzbv.js +2 -0
- package/bin/{chunk-q7t5zs7n.js → chunk-v05rrxp5.js} +2 -2
- package/bin/{chunk-8s9fehda.js → chunk-v5cn90cf.js} +2 -2
- package/bin/chunk-v5mcjwxy.js +2 -0
- package/bin/{chunk-fyb6t7ct.js → chunk-vcrmjtcz.js} +2 -2
- package/bin/chunk-vkzasgxw.js +2 -0
- package/bin/chunk-vp3czaeh.js +7 -0
- package/bin/chunk-x03jwaga.js +8 -0
- package/bin/chunk-x342vzdx.js +2 -0
- package/bin/chunk-x8mjh387.js +5 -0
- package/bin/chunk-xc54vhfz.js +2 -0
- package/bin/chunk-xvkwbczx.js +3 -0
- package/bin/chunk-y241cxff.js +1 -0
- package/bin/chunk-yk12hydf.js +7 -0
- package/bin/chunk-ympbfzz4.js +2 -0
- package/bin/chunk-yq32evnn.js +20 -0
- package/bin/chunk-z1p13dnc.js +2 -0
- package/bin/chunk-zarz3sqn.js +211 -0
- package/bin/chunk-zezje74z.js +4 -0
- package/bin/chunk-zrszykjf.js +3 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +947 -1012
- package/package.json +7 -7
- package/prisma/migrations/20261026024507_hash_api_tokens/migration.sql +28 -0
- package/prisma/migrations/20261026031904_add_audit_log_via/migration.sql +2 -0
- package/prisma/migrations/20261029024626_add_oauth_and_jwks/migration.sql +205 -0
- package/prisma/migrations/20261029030321_default_empty_arrays_oauth/migration.sql +25 -0
- package/prisma/schema.prisma +186 -1
- package/bin/chunk-0a4ahz7r.js +0 -2
- package/bin/chunk-0awcpx0a.js +0 -3
- package/bin/chunk-0fbgfgxv.js +0 -12
- package/bin/chunk-0nnqha4f.js +0 -3
- package/bin/chunk-0tvggyy4.js +0 -1
- package/bin/chunk-113baw0m.js +0 -2
- package/bin/chunk-1dbjyarc.js +0 -2
- package/bin/chunk-1qre79kf.js +0 -1
- package/bin/chunk-23780yj6.js +0 -3
- package/bin/chunk-27v3yepb.js +0 -1
- package/bin/chunk-2rq3w8sg.js +0 -2
- package/bin/chunk-3fjgf7eb.js +0 -3
- package/bin/chunk-3pwwg1xm.js +0 -1
- package/bin/chunk-3sfb63fp.js +0 -2
- package/bin/chunk-4g4pxmef.js +0 -3
- package/bin/chunk-4yhvexzk.js +0 -5
- package/bin/chunk-58cbk6e8.js +0 -1
- package/bin/chunk-5m51b7af.js +0 -2
- package/bin/chunk-6bed0rz4.js +0 -1
- package/bin/chunk-6smn0q1n.js +0 -20
- package/bin/chunk-7bbsv8g0.js +0 -2
- package/bin/chunk-83bdgs2c.js +0 -1
- package/bin/chunk-86qtjd30.js +0 -11
- package/bin/chunk-8rekh4h9.js +0 -3
- package/bin/chunk-8sf2hf31.js +0 -2
- package/bin/chunk-9d3w678j.js +0 -1
- package/bin/chunk-9rcg8zgs.js +0 -42
- package/bin/chunk-a23q1kc4.js +0 -5
- package/bin/chunk-a6cdt85k.js +0 -2
- package/bin/chunk-a76h3ehe.js +0 -1
- package/bin/chunk-b1bkd2p4.js +0 -32
- package/bin/chunk-bf5m8f6t.js +0 -2
- package/bin/chunk-cf57fk11.js +0 -2
- package/bin/chunk-d4sbcvpa.js +0 -2
- package/bin/chunk-dzjmwat0.js +0 -14
- package/bin/chunk-eex8sjfs.js +0 -2
- package/bin/chunk-exmwerag.js +0 -18
- package/bin/chunk-f38xyahm.js +0 -1
- package/bin/chunk-fb1bes2h.js +0 -2
- package/bin/chunk-fbvak7q2.js +0 -1
- package/bin/chunk-g2ptqqm3.js +0 -3
- package/bin/chunk-ggwqxn95.js +0 -2
- package/bin/chunk-ghk54h71.js +0 -13
- package/bin/chunk-h9akn41s.js +0 -3
- package/bin/chunk-hdansxny.js +0 -2
- package/bin/chunk-hjzbw975.js +0 -2
- package/bin/chunk-jtkxeat4.js +0 -2
- package/bin/chunk-jw4g9628.js +0 -5
- package/bin/chunk-jxebakyq.js +0 -1
- package/bin/chunk-kfewyax2.js +0 -2
- package/bin/chunk-kk3m4za5.js +0 -1
- package/bin/chunk-m7tnj47b.js +0 -3
- package/bin/chunk-maw5ah8t.js +0 -3
- package/bin/chunk-nahdd2t9.js +0 -2
- package/bin/chunk-nv7tztvh.js +0 -129
- package/bin/chunk-nyjwdxyj.js +0 -3
- package/bin/chunk-p0yfxt5e.js +0 -54
- package/bin/chunk-q27qn367.js +0 -5
- package/bin/chunk-q36sdt2w.js +0 -2
- package/bin/chunk-qbj5pe8t.js +0 -1
- package/bin/chunk-qj0bxb1m.js +0 -2
- package/bin/chunk-qqkr6h07.js +0 -11
- package/bin/chunk-qyqc5j3a.css +0 -1
- package/bin/chunk-qzaf6bre.js +0 -2
- package/bin/chunk-r1e59gf0.js +0 -2
- package/bin/chunk-ra5csbkr.js +0 -2
- package/bin/chunk-rx9g95wk.js +0 -10
- package/bin/chunk-rxyy37wa.js +0 -4
- package/bin/chunk-scez7ppq.js +0 -3
- package/bin/chunk-t2a1vq34.js +0 -7
- package/bin/chunk-t879v3b7.js +0 -1
- package/bin/chunk-tjavzarz.js +0 -3
- package/bin/chunk-treyx8em.js +0 -2
- package/bin/chunk-v3z4z04s.js +0 -2
- package/bin/chunk-v3z63tpw.js +0 -2
- package/bin/chunk-v9bes1fv.js +0 -2
- package/bin/chunk-vmm9m3nv.js +0 -2
- package/bin/chunk-vvr8tnse.js +0 -211
- package/bin/chunk-w3stry4v.js +0 -1
- package/bin/chunk-wk0hk00z.js +0 -1
- package/bin/chunk-x4q082e6.js +0 -2
- package/bin/chunk-x6rf77jm.js +0 -16
- package/bin/chunk-x7dyj53k.js +0 -2
- package/bin/chunk-xcrd0y8v.js +0 -6
- package/bin/chunk-z0z0jn5h.js +0 -4
- package/bin/chunk-zasjhrwc.js +0 -2
- package/bin/chunk-zefds5gg.js +0 -1
- package/bin/chunk-zzzgk1d5.js +0 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function So(e){return typeof e>"u"||e===void 0}function dr(e){return typeof e==="string"}function zs(e){return typeof e==="number"}function Vi(e){return typeof e==="boolean"}function Fa(e){return e===null}function rf(e){return e instanceof Date}function La(e){return typeof e==="bigint"}function zg(e){return typeof Buffer<"u"&&Buffer.isBuffer(e)}function fr(e){return typeof e==="function"}function sn(e){return typeof e==="object"&&e!==null}function C(e){return Object.freeze(e)}function xe(e){if(x(e))return e;else return[e]}function x(e){return Array.isArray(e)}function Io(e){return e}var st=C({is(e){return e.kind==="IdentifierNode"},create(e){return C({kind:"IdentifierNode",name:e})}});var jg=["preserve rows","delete rows","drop"],fo=C({is(e){return e.kind==="CreateTableNode"},create(e){return C({kind:"CreateTableNode",table:e,columns:C([])})},cloneWithColumn(e,t){return C({...e,columns:C([...e.columns,t])})},cloneWithConstraint(e,t){return C({...e,constraints:e.constraints?C([...e.constraints,t]):C([t])})},cloneWithFrontModifier(e,t){return C({...e,frontModifiers:e.frontModifiers?C([...e.frontModifiers,t]):C([t])})},cloneWithEndModifier(e,t){return C({...e,endModifiers:e.endModifiers?C([...e.endModifiers,t]):C([t])})},cloneWith(e,t){return C({...e,...t})}});var po=C({is(e){return e.kind==="SchemableIdentifierNode"},create(e){return C({kind:"SchemableIdentifierNode",identifier:st.create(e)})},createWithSchema(e,t){return C({kind:"SchemableIdentifierNode",schema:st.create(e),identifier:st.create(t)})}});var l=C({is(e){return e.kind==="AliasNode"},create(e,t){return C({kind:"AliasNode",node:e,alias:t})}});var mo=C({is(e){return e.kind==="TableNode"},create(e){return C({kind:"TableNode",table:po.create(e)})},createWithSchema(e,t){return C({kind:"TableNode",table:po.createWithSchema(e,t)})}});function Rr(e){return sn(e)&&fr(e.toOperationNode)}function Le(e){return sn(e)&&"expressionType"in e&&Rr(e)}function Ct(e){return sn(e)&&"expression"in e&&dr(e.alias)&&Rr(e)}var I=C({is(e){return e.kind==="SelectModifierNode"},create(e,t){return C({kind:"SelectModifierNode",modifier:e,of:t})},createWithExpression(e){return C({kind:"SelectModifierNode",rawModifier:e})}});var v=C({is(e){return e.kind==="AndNode"},create(e,t){return C({kind:"AndNode",left:e,right:t})}});var T=C({is(e){return e.kind==="OrNode"},create(e,t){return C({kind:"OrNode",left:e,right:t})}});var De=C({is(e){return e.kind==="OnNode"},create(e){return C({kind:"OnNode",on:e})},cloneWithOperation(e,t,r){return C({...e,on:t==="And"?v.create(e.on,r):T.create(e.on,r)})}});var L=C({is(e){return e.kind==="JoinNode"},create(e,t){return C({kind:"JoinNode",joinType:e,table:t,on:void 0})},createWithOn(e,t,r){return C({kind:"JoinNode",joinType:e,table:t,on:De.create(r)})},cloneWithOn(e,t){return C({...e,on:e.on?De.cloneWithOperation(e.on,"And",t):De.create(t)})}});var X=C({is(e){return e.kind==="BinaryOperationNode"},create(e,t,r){return C({kind:"BinaryOperationNode",leftOperand:e,operator:t,rightOperand:r})}});var Lr=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],Dr=["+","-","*","/","%","^","&","|","#","<<",">>"],kt=["->","->>"],Br=[...Lr,...Dr,"&&","||"],qr=["exists","not exists"],Mr=["not","-",...qr],Et=[...Br,...kt,...Mr,"between","between symmetric"],S=C({is(e){return e.kind==="OperatorNode"},create(e){return C({kind:"OperatorNode",operator:e})}});function Ke(e){return dr(e)&&kt.includes(e)}var Wt=C({is(e){return e.kind==="ColumnNode"},create(e){return C({kind:"ColumnNode",column:st.create(e)})}});var dc=C({is(e){return e.kind==="SelectAllNode"},create(){return C({kind:"SelectAllNode"})}});var Za=C({is(e){return e.kind==="ReferenceNode"},create(e,t){return C({kind:"ReferenceNode",table:t,column:e})},createSelectAll(e){return C({kind:"ReferenceNode",table:e,column:dc.create()})}});class pm{#e;get dynamicReference(){return this.#e}get refType(){return}constructor(e){this.#e=e}toOperationNode(){return He(this.#e)}}function Be(e){return sn(e)&&Rr(e)&&dr(e.dynamicReference)}var D=C({is(e){return e.kind==="OrderByItemNode"},create(e,t){return C({kind:"OrderByItemNode",orderBy:e,direction:t})},cloneWith(e,t){return C({...e,...t})}});var tr=C({is(e){return e.kind==="RawNode"},create(e,t){return C({kind:"RawNode",sqlFragments:C(e),parameters:C(t)})},createWithSql(e){return tr.create([e],[])},createWithChild(e){return tr.create(["",""],[e])},createWithChildren(e){return tr.create(Array(e.length+1).fill(""),e)}});var At=C({is(e){return e.kind==="CollateNode"},create(e){return C({kind:"CollateNode",collation:st.create(e)})}});class Z{#e;constructor(e){this.#e=C(e)}desc(){return new Z({node:D.cloneWith(this.#e.node,{direction:tr.createWithSql("desc")})})}asc(){return new Z({node:D.cloneWith(this.#e.node,{direction:tr.createWithSql("asc")})})}nullsLast(){return new Z({node:D.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new Z({node:D.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new Z({node:D.cloneWith(this.#e.node,{collation:At.create(e)})})}toOperationNode(){return this.#e.node}}var Rt=new Set;function hi(e){if(Rt.has(e))return;Rt.add(e),console.log(e)}function Xe(e){return e==="asc"||e==="desc"}function k(e){if(e.length===2)return[Ye(e[0],e[1])];if(e.length===1){let[t]=e;if(Array.isArray(t))return hi("orderBy(array) is deprecated, use multiple orderBy calls instead."),t.map((r)=>Ye(r));return[Ye(t)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function Ye(e,t){let r=Pr(e);if(D.is(r)){if(t)throw Error("Cannot specify direction twice!");return r}return Tt(r,t)}function Pr(e){if(J(e))return Ho(e);if(Be(e))return e.toOperationNode();let[t,r]=e.split(" ");if(r)return hi("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),Tt(is(t),r);return is(e)}function Tt(e,t){if(typeof t==="string"){if(!Xe(t))throw Error(`Invalid order by direction: ${t}`);return D.create(e,tr.createWithSql(t))}if(Le(t))return hi("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),D.create(e,t.toOperationNode());let r=D.create(e);if(!t)return r;return t(new Z({node:r})).toOperationNode()}var pe=C({is(e){return e.kind==="JSONReferenceNode"},create(e,t){return C({kind:"JSONReferenceNode",reference:e,traversal:t})},cloneWithTraversal(e,t){return C({...e,traversal:t})}});var qe=C({is(e){return e.kind==="JSONOperatorChainNode"},create(e){return C({kind:"JSONOperatorChainNode",operator:e,values:C([])})},cloneWithValue(e,t){return C({...e,values:C([...e.values,t])})}});var ee=C({is(e){return e.kind==="JSONPathNode"},create(e){return C({kind:"JSONPathNode",inOperator:e,pathLegs:C([])})},cloneWithLeg(e,t){return C({...e,pathLegs:C([...e.pathLegs,t])})}});function He(e){if(dr(e))return is(e);return e.toOperationNode()}function Q(e){if(x(e))return e.map((t)=>w(t));else return[w(e)]}function w(e){if(J(e))return Ho(e);return He(e)}function Lt(e,t){let r=is(e);if(Ke(t))return pe.create(r,qe.create(S.create(t)));let i=t.slice(0,-1);if(Ke(i))return pe.create(r,ee.create(S.create(i)));throw Error(`Invalid JSON operator: ${t}`)}function is(e){if(!e.includes("."))return Za.create(Wt.create(e));let r=e.split(".").map(Ze);if(r.length===3)return Ir(r);if(r.length===2)return Fr(r);throw Error(`invalid column reference ${e}`)}function Dt(e){if(e.includes(" as ")){let[r,i]=e.split(" as ").map(Ze);return l.create(is(r),st.create(i))}else return is(e)}function mm(e){return Wt.create(e)}function fc(e){if(e.includes(" ")){let[r,i]=e.split(" ").map(Ze);if(!Xe(i))throw Error(`invalid order direction "${i}" next to "${r}"`);return k([r,i])[0]}else return mm(e)}function Ir(e){let[t,r,i]=e;return Za.create(Wt.create(i),mo.createWithSchema(t,r))}function Fr(e){let[t,r]=e;return Za.create(Wt.create(r),mo.create(t))}function Ze(e){return e.trim()}var Me=C({is(e){return e.kind==="PrimitiveValueListNode"},create(e){return C({kind:"PrimitiveValueListNode",values:C([...e])})}});var Ba=C({is(e){return e.kind==="ValueListNode"},create(e){return C({kind:"ValueListNode",values:C(e)})}});var _n=C({is(e){return e.kind==="ValueNode"},create(e){return C({kind:"ValueNode",value:e})},createImmediate(e){return C({kind:"ValueNode",value:e,immediate:!0})}});function Bt(e){if(x(e))return Vr(e);return d(e)}function d(e){if(J(e))return Ho(e);return _n.create(e)}function Pe(e){return zs(e)||Vi(e)||Fa(e)}function ge(e){if(!Pe(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return _n.createImmediate(e)}function Vr(e){if(e.some(J))return Ba.create(e.map((t)=>d(t)));return Me.create(e)}var E=C({is(e){return e.kind==="ParensNode"},create(e){return C({kind:"ParensNode",node:e})}});function yr(e){if(e.length===3)return Ie(e[0],e[1],e[2]);else if(e.length===1)return d(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function Ie(e,t,r){if(Ur(t)&&Mt(r))return X.create(w(e),et(t),_n.createImmediate(r));return X.create(w(e),et(t),Bt(r))}function N(e,t,r){return X.create(w(e),et(t),w(r))}function tt(e,t){return de(Object.entries(e).filter(([,r])=>!So(r)).map(([r,i])=>Ie(r,Mt(i)?"is":"=",i)),t)}function de(e,t,r=!0){let i=t==="and"?v.create:T.create;if(e.length===0)return X.create(_n.createImmediate(1),S.create("="),_n.createImmediate(t==="and"?1:0));let n=qt(e[0]);for(let a=1;a<e.length;++a)n=i(n,qt(e[a]));if(e.length>1&&r)return E.create(n);return n}function Ur(e){return e==="is"||e==="is not"}function Mt(e){return Fa(e)||Vi(e)}function et(e){if(dr(e)&&Et.includes(e))return S.create(e);if(Rr(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function qt(e){return Rr(e)?e.toOperationNode():e}var _=C({is(e){return e.kind==="OrderByNode"},create(e){return C({kind:"OrderByNode",items:C([...e])})},cloneWithItems(e,t){return C({...e,items:C([...e.items,...t])})}});var rt=C({is(e){return e.kind==="PartitionByNode"},create(e){return C({kind:"PartitionByNode",items:C(e)})},cloneWithItems(e,t){return C({...e,items:C([...e.items,...t])})}});var ve=C({is(e){return e.kind==="OverNode"},create(){return C({kind:"OverNode"})},cloneWithOrderByItems(e,t){return C({...e,orderBy:e.orderBy?_.cloneWithItems(e.orderBy,t):_.create(t)})},cloneWithPartitionByItems(e,t){return C({...e,partitionBy:e.partitionBy?rt.cloneWithItems(e.partitionBy,t):rt.create(t)})}});var oe=C({is(e){return e.kind==="FromNode"},create(e){return C({kind:"FromNode",froms:C(e)})},cloneWithFroms(e,t){return C({...e,froms:C([...e.froms,...t])})}});var it=C({is(e){return e.kind==="GroupByNode"},create(e){return C({kind:"GroupByNode",items:C(e)})},cloneWithItems(e,t){return C({...e,items:C([...e.items,...t])})}});var ot=C({is(e){return e.kind==="HavingNode"},create(e){return C({kind:"HavingNode",having:e})},cloneWithOperation(e,t,r){return C({...e,having:t==="And"?v.create(e.having,r):T.create(e.having,r)})}});var u=C({is(e){return e.kind==="InsertQueryNode"},create(e,t,r){return C({kind:"InsertQueryNode",into:e,...t&&{with:t},replace:r})},createWithoutInto(){return C({kind:"InsertQueryNode"})},cloneWith(e,t){return C({...e,...t})}});var Fe=C({is(e){return e.kind==="ListNode"},create(e){return C({kind:"ListNode",items:C(e)})}});var F=C({is(e){return e.kind==="UpdateQueryNode"},create(e,t){return C({kind:"UpdateQueryNode",table:e.length===1?e[0]:Fe.create(e),...t&&{with:t}})},createWithoutTable(){return C({kind:"UpdateQueryNode"})},cloneWithFromItems(e,t){return C({...e,from:e.from?oe.cloneWithFroms(e.from,t):oe.create(t)})},cloneWithUpdates(e,t){return C({...e,updates:e.updates?C([...e.updates,...t]):t})},cloneWithLimit(e,t){return C({...e,limit:t})}});var be=C({is(e){return e.kind==="UsingNode"},create(e){return C({kind:"UsingNode",tables:C(e)})},cloneWithTables(e,t){return C({...e,tables:C([...e.tables,...t])})}});var te=C({is(e){return e.kind==="DeleteQueryNode"},create(e,t){return C({kind:"DeleteQueryNode",from:oe.create(e),...t&&{with:t}})},cloneWithOrderByItems:(e,t)=>Oe.cloneWithOrderByItems(e,t),cloneWithoutOrderBy:(e)=>Oe.cloneWithoutOrderBy(e),cloneWithLimit(e,t){return C({...e,limit:t})},cloneWithoutLimit(e){return C({...e,limit:void 0})},cloneWithUsing(e,t){return C({...e,using:e.using!==void 0?be.cloneWithTables(e.using,t):be.create(t)})}});var O=C({is(e){return e.kind==="WhereNode"},create(e){return C({kind:"WhereNode",where:e})},cloneWithOperation(e,t,r){return C({...e,where:t==="And"?v.create(e.where,r):T.create(e.where,r)})}});var nt=C({is(e){return e.kind==="ReturningNode"},create(e){return C({kind:"ReturningNode",selections:C(e)})},cloneWithSelections(e,t){return C({...e,selections:e.selections?C([...e.selections,...t]):C(t)})}});var Pt=C({is(e){return e.kind==="ExplainNode"},create(e,t){return C({kind:"ExplainNode",format:e,options:t})}});var R=C({is(e){return e.kind==="WhenNode"},create(e){return C({kind:"WhenNode",condition:e})},cloneWithResult(e,t){return C({...e,result:t})}});var A=C({is(e){return e.kind==="MergeQueryNode"},create(e,t){return C({kind:"MergeQueryNode",into:e,...t&&{with:t}})},cloneWithUsing(e,t){return C({...e,using:t})},cloneWithWhen(e,t){return C({...e,whens:e.whens?C([...e.whens,t]):C([t])})},cloneWithThen(e,t){return C({...e,whens:e.whens?C([...e.whens.slice(0,-1),R.cloneWithResult(e.whens[e.whens.length-1],t)]):void 0})}});var at=C({is(e){return e.kind==="OutputNode"},create(e){return C({kind:"OutputNode",selections:C(e)})},cloneWithSelections(e,t){return C({...e,selections:e.selections?C([...e.selections,...t]):C(t)})}});var Oe=C({is(e){return nr.is(e)||u.is(e)||F.is(e)||te.is(e)||A.is(e)},cloneWithEndModifier(e,t){return C({...e,endModifiers:e.endModifiers?C([...e.endModifiers,t]):C([t])})},cloneWithWhere(e,t){return C({...e,where:e.where?O.cloneWithOperation(e.where,"And",t):O.create(t)})},cloneWithJoin(e,t){return C({...e,joins:e.joins?C([...e.joins,t]):C([t])})},cloneWithReturning(e,t){return C({...e,returning:e.returning?nt.cloneWithSelections(e.returning,t):nt.create(t)})},cloneWithoutReturning(e){return C({...e,returning:void 0})},cloneWithoutWhere(e){return C({...e,where:void 0})},cloneWithExplain(e,t,r){return C({...e,explain:Pt.create(t,r?.toOperationNode())})},cloneWithTop(e,t){return C({...e,top:t})},cloneWithOutput(e,t){return C({...e,output:e.output?at.cloneWithSelections(e.output,t):at.create(t)})},cloneWithOrderByItems(e,t){return C({...e,orderBy:e.orderBy?_.cloneWithItems(e.orderBy,t):_.create(t)})},cloneWithoutOrderBy(e){return C({...e,orderBy:void 0})}});var nr=C({is(e){return e.kind==="SelectQueryNode"},create(e){return C({kind:"SelectQueryNode",...e&&{with:e}})},createFrom(e,t){return C({kind:"SelectQueryNode",from:oe.create(e),...t&&{with:t}})},cloneWithSelections(e,t){return C({...e,selections:e.selections?C([...e.selections,...t]):C(t)})},cloneWithDistinctOn(e,t){return C({...e,distinctOn:e.distinctOn?C([...e.distinctOn,...t]):C(t)})},cloneWithFrontModifier(e,t){return C({...e,frontModifiers:e.frontModifiers?C([...e.frontModifiers,t]):C([t])})},cloneWithOrderByItems:(e,t)=>Oe.cloneWithOrderByItems(e,t),cloneWithGroupByItems(e,t){return C({...e,groupBy:e.groupBy?it.cloneWithItems(e.groupBy,t):it.create(t)})},cloneWithLimit(e,t){return C({...e,limit:t})},cloneWithOffset(e,t){return C({...e,offset:t})},cloneWithFetch(e,t){return C({...e,fetch:t})},cloneWithHaving(e,t){return C({...e,having:e.having?ot.cloneWithOperation(e.having,"And",t):ot.create(t)})},cloneWithSetOperations(e,t){return C({...e,setOperations:e.setOperations?C([...e.setOperations,...t]):C([...t])})},cloneWithoutSelections(e){return C({...e,selections:[]})},cloneWithoutLimit(e){return C({...e,limit:void 0})},cloneWithoutOffset(e){return C({...e,offset:void 0})},cloneWithoutOrderBy:(e)=>Oe.cloneWithoutOrderBy(e),cloneWithoutGroupBy(e){return C({...e,groupBy:void 0})}});class he{#e;constructor(e){this.#e=C(e)}on(...e){return new he({...this.#e,joinNode:L.cloneWithOn(this.#e.joinNode,yr(e))})}onRef(e,t,r){return new he({...this.#e,joinNode:L.cloneWithOn(this.#e.joinNode,N(e,t,r))})}onTrue(){return new he({...this.#e,joinNode:L.cloneWithOn(this.#e.joinNode,tr.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}var Ft=C({is(e){return e.kind==="PartitionByItemNode"},create(e){return C({kind:"PartitionByItemNode",partitionBy:e})}});function Vt(e){return Q(e).map(Ft.create)}class ue{#e;constructor(e){this.#e=C(e)}orderBy(...e){return new ue({overNode:ve.cloneWithOrderByItems(this.#e.overNode,k(e))})}clearOrderBy(){return new ue({overNode:Oe.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new ue({overNode:ve.cloneWithPartitionByItems(this.#e.overNode,Vt(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}var me=C({is(e){return e.kind==="SelectionNode"},create(e){return C({kind:"SelectionNode",selection:e})},createSelectAll(){return C({kind:"SelectionNode",selection:dc.create()})},createSelectAllFromTable(e){return C({kind:"SelectionNode",selection:Za.createSelectAll(e)})}});function c(e){if(fr(e))return c(e(B()));else if(x(e))return e.map((t)=>Ut(t));else return[Ut(e)]}function Ut(e){if(dr(e))return me.create(Dt(e));else if(Be(e))return me.create(e.toOperationNode());else return me.create(Ve(e))}function y(e){if(!e)return[me.createSelectAll()];else if(Array.isArray(e))return e.map(zt);else return[zt(e)]}function zt(e){if(dr(e))return me.createSelectAllFromTable(or(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}var Jt=C({is(e){return e.kind==="ValuesNode"},create(e){return C({kind:"ValuesNode",values:C(e)})}});var Qt=C({is(e){return e.kind==="DefaultInsertValueNode"},create(){return C({kind:"DefaultInsertValueNode"})}});function Ue(e){let t=fr(e)?e(B()):e,r=x(t)?t:C([t]);return zr(r)}function zr(e){let t=Jr(e);return[C([...t.keys()].map(Wt.create)),Jt.create(e.map((r)=>Qr(r,t)))]}function Jr(e){let t=new Map;for(let r of e){let i=Object.keys(r);for(let n of i)if(!t.has(n)&&r[n]!==void 0)t.set(n,t.size)}return t}function Qr(e,t){let r=Object.keys(e),i=Array.from({length:t.size}),n=!1,a=r.length;for(let H of r){let Y=t.get(H);if(So(Y)){a--;continue}let we=e[H];if(So(we)||J(we))n=!0;i[Y]=we}if(a<t.size||n){let H=Qt.create();return Ba.create(i.map((Y)=>So(Y)?H:d(Y)))}return Me.create(i)}var pt=C({is(e){return e.kind==="ColumnUpdateNode"},create(e,t){return C({kind:"ColumnUpdateNode",column:e,value:t})}});function _t(...e){if(e.length===2)return[pt.create(w(e[0]),d(e[1]))];return We(e[0])}function We(e){let t=fr(e)?e(B()):e;return Object.entries(t).filter(([r,i])=>i!==void 0).map(([r,i])=>pt.create(Wt.create(r),d(i)))}var $t=C({is(e){return e.kind==="OnDuplicateKeyNode"},create(e){return C({kind:"OnDuplicateKeyNode",updates:e})}});class dt{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}}class q extends Error{node;constructor(e){super("no result");this.node=e}}function V(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}var g=C({is(e){return e.kind==="OnConflictNode"},create(){return C({kind:"OnConflictNode"})},cloneWith(e,t){return C({...e,...t})},cloneWithIndexWhere(e,t){return C({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"And",t):O.create(t)})},cloneWithIndexOrWhere(e,t){return C({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"Or",t):O.create(t)})},cloneWithUpdateWhere(e,t){return C({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"And",t):O.create(t)})},cloneWithUpdateOrWhere(e,t){return C({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"Or",t):O.create(t)})},cloneWithoutIndexWhere(e){return C({...e,indexWhere:void 0})},cloneWithoutUpdateWhere(e){return C({...e,updateWhere:void 0})}});class U{#e;constructor(e){this.#e=C(e)}column(e){let t=Wt.create(e);return new U({...this.#e,onConflictNode:g.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?C([...this.#e.onConflictNode.columns,t]):C([t])})})}columns(e){let t=e.map(Wt.create);return new U({...this.#e,onConflictNode:g.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?C([...this.#e.onConflictNode.columns,...t]):C(t)})})}constraint(e){return new U({...this.#e,onConflictNode:g.cloneWith(this.#e.onConflictNode,{constraint:st.create(e)})})}expression(e){return new U({...this.#e,onConflictNode:g.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new U({...this.#e,onConflictNode:g.cloneWithIndexWhere(this.#e.onConflictNode,yr(e))})}whereRef(e,t,r){return new U({...this.#e,onConflictNode:g.cloneWithIndexWhere(this.#e.onConflictNode,N(e,t,r))})}clearWhere(){return new U({...this.#e,onConflictNode:g.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Gt({...this.#e,onConflictNode:g.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Se({...this.#e,onConflictNode:g.cloneWith(this.#e.onConflictNode,{updates:We(e)})})}$call(e){return e(this)}}class Gt{#e;constructor(e){this.#e=C(e)}toOperationNode(){return this.#e.onConflictNode}}class Se{#e;constructor(e){this.#e=C(e)}where(...e){return new Se({...this.#e,onConflictNode:g.cloneWithUpdateWhere(this.#e.onConflictNode,yr(e))})}whereRef(e,t,r){return new Se({...this.#e,onConflictNode:g.cloneWithUpdateWhere(this.#e.onConflictNode,N(e,t,r))})}clearWhere(){return new Se({...this.#e,onConflictNode:g.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}var Kt=C({is(e){return e.kind==="TopNode"},create(e,t){return C({kind:"TopNode",expression:e,modifiers:t})}});function M(e,t){if(!zs(e)&&!La(e))throw Error(`Invalid top expression: ${e}`);if(!So(t)&&!_r(t))throw Error(`Invalid top modifiers: ${t}`);return Kt.create(e,t)}function _r(e){return e==="percent"||e==="with ties"||e==="percent with ties"}var ne=C({is(e){return e.kind==="OrActionNode"},create(e){return C({kind:"OrActionNode",action:e})}});class h{#e;constructor(e){this.#e=C(e)}values(e){let[t,r]=Ue(e);return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{columns:t,values:r})})}columns(e){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{columns:C(e.map(Wt.create))})})}expression(e){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{values:Ho(e)})})}defaultValues(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new h({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{orAction:ne.create("ignore")})})}orIgnore(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{orAction:ne.create("ignore")})})}orAbort(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{orAction:ne.create("abort")})})}orFail(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{orAction:ne.create("fail")})})}orReplace(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{orAction:ne.create("replace")})})}orRollback(){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{orAction:ne.create("rollback")})})}top(e,t){return new h({...this.#e,queryNode:Oe.cloneWithTop(this.#e.queryNode,M(e,t))})}onConflict(e){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{onConflict:e(new U({onConflictNode:g.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new h({...this.#e,queryNode:u.cloneWith(this.#e.queryNode,{onDuplicateKey:$t.create(We(e))})})}returning(e){return new h({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,c(e))})}returningAll(){return new h({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,y())})}output(e){return new h({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,c(e))})}outputAll(e){return new h({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new h({...this.#e,queryNode:Oe.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){if(e)return t(this);return new h({...this.#e})}$castTo(){return new h(this.#e)}$narrowType(){return new h(this.#e)}$assertType(){return new h(this.#e)}withPlugin(e){return new h({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:r}=this.#e.executor,i=e.query;if(i.returning&&r.supportsReturning||i.output&&r.supportsOutput)return t.rows;return[new dt(t.insertId,t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let t=await this.executeTakeFirst();if(t===void 0)throw V(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),r=this.#e.executor.stream(t,e);for await(let i of r)yield*i.rows}async explain(e,t){return await new h({...this.#e,queryNode:Oe.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}}class ht{numDeletedRows;constructor(e){this.numDeletedRows=e}}var fe=C({is(e){return e.kind==="LimitNode"},create(e){return C({kind:"LimitNode",limit:e})}});var m;class ze{#e;constructor(e){this.#e=C(e)}where(...e){return new m({...this.#e,queryNode:Oe.cloneWithWhere(this.#e.queryNode,yr(e))})}whereRef(e,t,r){return new m({...this.#e,queryNode:Oe.cloneWithWhere(this.#e.queryNode,N(e,t,r))})}clearWhere(){return new m({...this.#e,queryNode:Oe.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new m({...this.#e,queryNode:Oe.cloneWithTop(this.#e.queryNode,M(e,t))})}using(e){return new m({...this.#e,queryNode:te.cloneWithUsing(this.#e.queryNode,P(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,t){return new m({...this.#e,queryNode:Oe.cloneWithJoin(this.#e.queryNode,re(e,t))})}returning(e){return new m({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,c(e))})}returningAll(e){return new m({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new m({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,c(e))})}outputAll(e){return new m({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new m({...this.#e,queryNode:Oe.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new m({...this.#e,queryNode:te.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new m({...this.#e,queryNode:Oe.cloneWithOrderByItems(this.#e.queryNode,k(e))})}clearOrderBy(){return new m({...this.#e,queryNode:Oe.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new m({...this.#e,queryNode:te.cloneWithLimit(this.#e.queryNode,fe.create(d(e)))})}modifyEnd(e){return new m({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){if(e)return t(this);return new m({...this.#e})}$castTo(){return new m(this.#e)}$narrowType(){return new m(this.#e)}$assertType(){return new m(this.#e)}withPlugin(e){return new m({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:r}=this.#e.executor,i=e.query;if(i.returning&&r.supportsReturning||i.output&&r.supportsOutput)return t.rows;return[new ht(t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let t=await this.executeTakeFirst();if(t===void 0)throw V(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),r=this.#e.executor.stream(t,e);for await(let i of r)yield*i.rows}async explain(e,t){return await new m({...this.#e,queryNode:Oe.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}}m=ze;class ut{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}}var f;class ce{#e;constructor(e){this.#e=C(e)}where(...e){return new f({...this.#e,queryNode:Oe.cloneWithWhere(this.#e.queryNode,yr(e))})}whereRef(e,t,r){return new f({...this.#e,queryNode:Oe.cloneWithWhere(this.#e.queryNode,N(e,t,r))})}clearWhere(){return new f({...this.#e,queryNode:Oe.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new f({...this.#e,queryNode:Oe.cloneWithTop(this.#e.queryNode,M(e,t))})}from(e){return new f({...this.#e,queryNode:F.cloneWithFromItems(this.#e.queryNode,P(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,t){return new f({...this.#e,queryNode:Oe.cloneWithJoin(this.#e.queryNode,re(e,t))})}orderBy(...e){return new f({...this.#e,queryNode:Oe.cloneWithOrderByItems(this.#e.queryNode,k(e))})}clearOrderBy(){return new f({...this.#e,queryNode:Oe.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new f({...this.#e,queryNode:F.cloneWithLimit(this.#e.queryNode,fe.create(d(e)))})}set(...e){return new f({...this.#e,queryNode:F.cloneWithUpdates(this.#e.queryNode,_t(...e))})}returning(e){return new f({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,c(e))})}returningAll(e){return new f({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new f({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,c(e))})}outputAll(e){return new f({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,y(e))})}modifyEnd(e){return new f({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new f({...this.#e,queryNode:Oe.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){if(e)return t(this);return new f({...this.#e})}$castTo(){return new f(this.#e)}$narrowType(){return new f(this.#e)}$assertType(){return new f(this.#e)}withPlugin(e){return new f({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:r}=this.#e.executor,i=e.query;if(i.returning&&r.supportsReturning||i.output&&r.supportsOutput)return t.rows;return[new ut(t.numAffectedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let t=await this.executeTakeFirst();if(t===void 0)throw V(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),r=this.#e.executor.stream(t,e);for await(let i of r)yield*i.rows}async explain(e,t){return await new f({...this.#e,queryNode:Oe.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}}f=ce;var mt=C({is(e){return e.kind==="CommonTableExpressionNameNode"},create(e,t){return C({kind:"CommonTableExpressionNameNode",table:mo.create(e),columns:t?C(t.map(Wt.create)):void 0})}});var le=C({is(e){return e.kind==="CommonTableExpressionNode"},create(e,t){return C({kind:"CommonTableExpressionNode",name:e,expression:t})},cloneWith(e,t){return C({...e,...t})}});class Ce{#e;constructor(e){this.#e=C(e)}materialized(){return new Ce({...this.#e,node:le.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new Ce({...this.#e,node:le.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function ft(e,t){let r=t(Ht()).toOperationNode();if(fr(e))return e($r(r)).toOperationNode();return le.create(jt(e),r)}function $r(e){return(t)=>new Ce({node:le.create(jt(t),e)})}function jt(e){if(e.includes("(")){let t=e.split(/[\(\)]/),r=t[0],i=t[1].split(",").map((n)=>n.trim());return mt.create(r,i)}else return mt.create(e)}var ke=C({is(e){return e.kind==="WithNode"},create(e,t){return C({kind:"WithNode",expressions:C([e]),...t})},cloneWithExpression(e,t){return C({...e,expressions:C([...e.expressions,t])})}});var Yt=["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 nf(e){let t="";for(let r=0;r<e;++r)t+=Gr();return t}function Gr(){return Yt[~~(Math.random()*Yt.length)]}function It(){return new Xt}class Xt{#e;get queryId(){if(this.#e===void 0)this.#e=nf(8);return this.#e}}function o(e){return e}class Du{nodeStack=[];#e=C({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,t){if(!e)return e;this.nodeStack.push(e);let r=this.transformNodeImpl(e,t);return this.nodeStack.pop(),C(r)}transformNodeImpl(e,t){return this.#e[e.kind](e,t)}transformNodeList(e,t){if(!e)return e;return C(e.map((r)=>this.transformNode(r,t)))}transformSelectQuery(e,t){return o({kind:"SelectQueryNode",from:this.transformNode(e.from,t),selections:this.transformNodeList(e.selections,t),distinctOn:this.transformNodeList(e.distinctOn,t),joins:this.transformNodeList(e.joins,t),groupBy:this.transformNode(e.groupBy,t),orderBy:this.transformNode(e.orderBy,t),where:this.transformNode(e.where,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),limit:this.transformNode(e.limit,t),offset:this.transformNode(e.offset,t),with:this.transformNode(e.with,t),having:this.transformNode(e.having,t),explain:this.transformNode(e.explain,t),setOperations:this.transformNodeList(e.setOperations,t),fetch:this.transformNode(e.fetch,t),top:this.transformNode(e.top,t)})}transformSelection(e,t){return o({kind:"SelectionNode",selection:this.transformNode(e.selection,t)})}transformColumn(e,t){return o({kind:"ColumnNode",column:this.transformNode(e.column,t)})}transformAlias(e,t){return o({kind:"AliasNode",node:this.transformNode(e.node,t),alias:this.transformNode(e.alias,t)})}transformTable(e,t){return o({kind:"TableNode",table:this.transformNode(e.table,t)})}transformFrom(e,t){return o({kind:"FromNode",froms:this.transformNodeList(e.froms,t)})}transformReference(e,t){return o({kind:"ReferenceNode",column:this.transformNode(e.column,t),table:this.transformNode(e.table,t)})}transformAnd(e,t){return o({kind:"AndNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)})}transformOr(e,t){return o({kind:"OrNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)})}transformValueList(e,t){return o({kind:"ValueListNode",values:this.transformNodeList(e.values,t)})}transformParens(e,t){return o({kind:"ParensNode",node:this.transformNode(e.node,t)})}transformJoin(e,t){return o({kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,t),on:this.transformNode(e.on,t)})}transformRaw(e,t){return o({kind:"RawNode",sqlFragments:C([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,t)})}transformWhere(e,t){return o({kind:"WhereNode",where:this.transformNode(e.where,t)})}transformInsertQuery(e,t){return o({kind:"InsertQueryNode",into:this.transformNode(e.into,t),columns:this.transformNodeList(e.columns,t),values:this.transformNode(e.values,t),returning:this.transformNode(e.returning,t),onConflict:this.transformNode(e.onConflict,t),onDuplicateKey:this.transformNode(e.onDuplicateKey,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),ignore:e.ignore,orAction:this.transformNode(e.orAction,t),replace:e.replace,explain:this.transformNode(e.explain,t),defaultValues:e.defaultValues,top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)})}transformValues(e,t){return o({kind:"ValuesNode",values:this.transformNodeList(e.values,t)})}transformDeleteQuery(e,t){return o({kind:"DeleteQueryNode",from:this.transformNode(e.from,t),using:this.transformNode(e.using,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),orderBy:this.transformNode(e.orderBy,t),limit:this.transformNode(e.limit,t),explain:this.transformNode(e.explain,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)})}transformReturning(e,t){return o({kind:"ReturningNode",selections:this.transformNodeList(e.selections,t)})}transformCreateTable(e,t){return o({kind:"CreateTableNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),constraints:this.transformNodeList(e.constraints,t),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),selectQuery:this.transformNode(e.selectQuery,t)})}transformColumnDefinition(e,t){return o({kind:"ColumnDefinitionNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),references:this.transformNode(e.references,t),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,t),check:this.transformNode(e.check,t),generated:this.transformNode(e.generated,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists})}transformAddColumn(e,t){return o({kind:"AddColumnNode",column:this.transformNode(e.column,t)})}transformDropTable(e,t){return o({kind:"DropTableNode",table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade})}transformOrderBy(e,t){return o({kind:"OrderByNode",items:this.transformNodeList(e.items,t)})}transformOrderByItem(e,t){return o({kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,t),direction:this.transformNode(e.direction,t),collation:this.transformNode(e.collation,t),nulls:e.nulls})}transformGroupBy(e,t){return o({kind:"GroupByNode",items:this.transformNodeList(e.items,t)})}transformGroupByItem(e,t){return o({kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,t)})}transformUpdateQuery(e,t){return o({kind:"UpdateQueryNode",table:this.transformNode(e.table,t),from:this.transformNode(e.from,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),updates:this.transformNodeList(e.updates,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),explain:this.transformNode(e.explain,t),limit:this.transformNode(e.limit,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t),orderBy:this.transformNode(e.orderBy,t)})}transformColumnUpdate(e,t){return o({kind:"ColumnUpdateNode",column:this.transformNode(e.column,t),value:this.transformNode(e.value,t)})}transformLimit(e,t){return o({kind:"LimitNode",limit:this.transformNode(e.limit,t)})}transformOffset(e,t){return o({kind:"OffsetNode",offset:this.transformNode(e.offset,t)})}transformOnConflict(e,t){return o({kind:"OnConflictNode",columns:this.transformNodeList(e.columns,t),constraint:this.transformNode(e.constraint,t),indexExpression:this.transformNode(e.indexExpression,t),indexWhere:this.transformNode(e.indexWhere,t),updates:this.transformNodeList(e.updates,t),updateWhere:this.transformNode(e.updateWhere,t),doNothing:e.doNothing})}transformOnDuplicateKey(e,t){return o({kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,t)})}transformCreateIndex(e,t){return o({kind:"CreateIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,t),nullsNotDistinct:e.nullsNotDistinct})}transformList(e,t){return o({kind:"ListNode",items:this.transformNodeList(e.items,t)})}transformDropIndex(e,t){return o({kind:"DropIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade})}transformPrimaryKeyConstraint(e,t){return o({kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformUniqueConstraint(e,t){return o({kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformForeignKeyConstraint(e,t){return o({kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,t),references:this.transformNode(e.references,t),name:this.transformNode(e.name,t),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformSetOperation(e,t){return o({kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,t),all:e.all})}transformReferences(e,t){return o({kind:"ReferencesNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),onDelete:e.onDelete,onUpdate:e.onUpdate})}transformCheckConstraint(e,t){return o({kind:"CheckConstraintNode",expression:this.transformNode(e.expression,t),name:this.transformNode(e.name,t)})}transformWith(e,t){return o({kind:"WithNode",expressions:this.transformNodeList(e.expressions,t),recursive:e.recursive})}transformCommonTableExpression(e,t){return o({kind:"CommonTableExpressionNode",name:this.transformNode(e.name,t),materialized:e.materialized,expression:this.transformNode(e.expression,t)})}transformCommonTableExpressionName(e,t){return o({kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t)})}transformHaving(e,t){return o({kind:"HavingNode",having:this.transformNode(e.having,t)})}transformCreateSchema(e,t){return o({kind:"CreateSchemaNode",schema:this.transformNode(e.schema,t),ifNotExists:e.ifNotExists})}transformDropSchema(e,t){return o({kind:"DropSchemaNode",schema:this.transformNode(e.schema,t),ifExists:e.ifExists,cascade:e.cascade})}transformAlterTable(e,t){return o({kind:"AlterTableNode",table:this.transformNode(e.table,t),renameTo:this.transformNode(e.renameTo,t),setSchema:this.transformNode(e.setSchema,t),columnAlterations:this.transformNodeList(e.columnAlterations,t),addConstraint:this.transformNode(e.addConstraint,t),dropConstraint:this.transformNode(e.dropConstraint,t),renameConstraint:this.transformNode(e.renameConstraint,t),addIndex:this.transformNode(e.addIndex,t),dropIndex:this.transformNode(e.dropIndex,t)})}transformDropColumn(e,t){return o({kind:"DropColumnNode",column:this.transformNode(e.column,t)})}transformRenameColumn(e,t){return o({kind:"RenameColumnNode",column:this.transformNode(e.column,t),renameTo:this.transformNode(e.renameTo,t)})}transformAlterColumn(e,t){return o({kind:"AlterColumnNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),dataTypeExpression:this.transformNode(e.dataTypeExpression,t),setDefault:this.transformNode(e.setDefault,t),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull})}transformModifyColumn(e,t){return o({kind:"ModifyColumnNode",column:this.transformNode(e.column,t)})}transformAddConstraint(e,t){return o({kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,t)})}transformDropConstraint(e,t){return o({kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,t),ifExists:e.ifExists,modifier:e.modifier})}transformRenameConstraint(e,t){return o({kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,t),newName:this.transformNode(e.newName,t)})}transformCreateView(e,t){return o({kind:"CreateViewNode",name:this.transformNode(e.name,t),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,t),as:this.transformNode(e.as,t)})}transformRefreshMaterializedView(e,t){return o({kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,t),concurrently:e.concurrently,withNoData:e.withNoData})}transformDropView(e,t){return o({kind:"DropViewNode",name:this.transformNode(e.name,t),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade})}transformGenerated(e,t){return o({kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,t)})}transformDefaultValue(e,t){return o({kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,t)})}transformOn(e,t){return o({kind:"OnNode",on:this.transformNode(e.on,t)})}transformSelectModifier(e,t){return o({kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,t),of:this.transformNodeList(e.of,t)})}transformCreateType(e,t){return o({kind:"CreateTypeNode",name:this.transformNode(e.name,t),enum:this.transformNode(e.enum,t)})}transformDropType(e,t){return o({kind:"DropTypeNode",name:this.transformNode(e.name,t),ifExists:e.ifExists})}transformExplain(e,t){return o({kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,t)})}transformSchemableIdentifier(e,t){return o({kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,t),identifier:this.transformNode(e.identifier,t)})}transformAggregateFunction(e,t){return o({kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,t),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,t),withinGroup:this.transformNode(e.withinGroup,t),filter:this.transformNode(e.filter,t),over:this.transformNode(e.over,t)})}transformOver(e,t){return o({kind:"OverNode",orderBy:this.transformNode(e.orderBy,t),partitionBy:this.transformNode(e.partitionBy,t)})}transformPartitionBy(e,t){return o({kind:"PartitionByNode",items:this.transformNodeList(e.items,t)})}transformPartitionByItem(e,t){return o({kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,t)})}transformBinaryOperation(e,t){return o({kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,t),operator:this.transformNode(e.operator,t),rightOperand:this.transformNode(e.rightOperand,t)})}transformUnaryOperation(e,t){return o({kind:"UnaryOperationNode",operator:this.transformNode(e.operator,t),operand:this.transformNode(e.operand,t)})}transformUsing(e,t){return o({kind:"UsingNode",tables:this.transformNodeList(e.tables,t)})}transformFunction(e,t){return o({kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,t)})}transformCase(e,t){return o({kind:"CaseNode",value:this.transformNode(e.value,t),when:this.transformNodeList(e.when,t),else:this.transformNode(e.else,t),isStatement:e.isStatement})}transformWhen(e,t){return o({kind:"WhenNode",condition:this.transformNode(e.condition,t),result:this.transformNode(e.result,t)})}transformJSONReference(e,t){return o({kind:"JSONReferenceNode",reference:this.transformNode(e.reference,t),traversal:this.transformNode(e.traversal,t)})}transformJSONPath(e,t){return o({kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,t),pathLegs:this.transformNodeList(e.pathLegs,t)})}transformJSONPathLeg(e,t){return o({kind:"JSONPathLegNode",type:e.type,value:e.value})}transformJSONOperatorChain(e,t){return o({kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,t),values:this.transformNodeList(e.values,t)})}transformTuple(e,t){return o({kind:"TupleNode",values:this.transformNodeList(e.values,t)})}transformMergeQuery(e,t){return o({kind:"MergeQueryNode",into:this.transformNode(e.into,t),using:this.transformNode(e.using,t),whens:this.transformNodeList(e.whens,t),with:this.transformNode(e.with,t),top:this.transformNode(e.top,t),endModifiers:this.transformNodeList(e.endModifiers,t),output:this.transformNode(e.output,t),returning:this.transformNode(e.returning,t)})}transformMatched(e,t){return o({kind:"MatchedNode",not:e.not,bySource:e.bySource})}transformAddIndex(e,t){return o({kind:"AddIndexNode",name:this.transformNode(e.name,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists})}transformCast(e,t){return o({kind:"CastNode",expression:this.transformNode(e.expression,t),dataType:this.transformNode(e.dataType,t)})}transformFetch(e,t){return o({kind:"FetchNode",rowCount:this.transformNode(e.rowCount,t),modifier:e.modifier})}transformTop(e,t){return o({kind:"TopNode",expression:e.expression,modifiers:e.modifiers})}transformOutput(e,t){return o({kind:"OutputNode",selections:this.transformNodeList(e.selections,t)})}transformDataType(e,t){return e}transformSelectAll(e,t){return e}transformIdentifier(e,t){return e}transformValue(e,t){return e}transformPrimitiveValueList(e,t){return e}transformOperator(e,t){return e}transformDefaultInsertValue(e,t){return e}transformOrAction(e,t){return e}transformCollate(e,t){return e}}var Kr=C({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),jr={json_agg:!0,to_json:!0};class ct extends Du{#e;#t=new Set;#r=new Set;constructor(e){super();this.#e=e}transformNodeImpl(e,t){if(!this.#s(e))return super.transformNodeImpl(e,t);let r=this.#p(e);for(let a of r)this.#r.add(a);let i=this.#a(e);for(let a of i)this.#t.add(a);let n=super.transformNodeImpl(e,t);for(let a of i)this.#t.delete(a);for(let a of r)this.#r.delete(a);return n}transformSchemableIdentifier(e,t){let r=super.transformSchemableIdentifier(e,t);if(r.schema||!this.#t.has(e.identifier.name))return r;return{...r,schema:st.create(this.#e)}}transformReferences(e,t){let r=super.transformReferences(e,t);if(r.table.table.schema)return r;return{...r,table:mo.createWithSchema(this.#e,r.table.table.identifier.name)}}transformAggregateFunction(e,t){return{...super.transformAggregateFunction({...e,aggregated:[]},t),aggregated:this.#o(e,t,"aggregated")}}transformFunction(e,t){return{...super.transformFunction({...e,arguments:[]},t),arguments:this.#o(e,t,"arguments")}}transformSelectModifier(e,t){return{...super.transformSelectModifier({...e,of:void 0},t),of:e.of?.map((r)=>mo.is(r)&&!r.table.schema?{...r,table:this.transformIdentifier(r.table.identifier,t)}:this.transformNode(r,t))}}#o(e,t,r){return jr[e.func]?e[r].map((i)=>!mo.is(i)||i.table.schema?this.transformNode(i,t):{...i,table:this.transformIdentifier(i.table.identifier,t)}):this.transformNodeList(e[r],t)}#s(e){return e.kind in Kr}#a(e){let t=new Set;if("name"in e&&e.name&&po.is(e.name))this.#n(e.name,t);if("from"in e&&e.from)for(let r of e.from.froms)this.#i(r,t);if("into"in e&&e.into)this.#i(e.into,t);if("table"in e&&e.table)this.#i(e.table,t);if("joins"in e&&e.joins)for(let r of e.joins)this.#i(r.table,t);if("using"in e&&e.using)if(L.is(e.using))this.#i(e.using.table,t);else this.#i(e.using,t);return t}#p(e){let t=new Set;if("with"in e&&e.with)this.#d(e.with,t);return t}#i(e,t){if(mo.is(e))return this.#n(e.table,t);if(l.is(e)&&mo.is(e.node))return this.#n(e.node.table,t);if(Fe.is(e)){for(let r of e.items)this.#i(r,t);return}if(be.is(e)){for(let r of e.tables)this.#i(r,t);return}}#n(e,t){let r=e.identifier.name;if(!this.#t.has(r)&&!this.#r.has(r))t.add(r)}#d(e,t){for(let r of e.expressions){let i=r.name.table.table.identifier.name;if(!this.#r.has(i))t.add(i)}}}class js{#e;constructor(e){this.#e=new ct(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}var Zt=C({is(e){return e.kind==="MatchedNode"},create(e,t=!1){return C({kind:"MatchedNode",not:e,bySource:t})}});function lt(e,t,r){return R.create(de([Zt.create(!e.isMatched,e.bySource),...t&&t.length>0?[t.length===3&&r?N(t[0],t[1],t[2]):yr(t)]:[]],"and",!1))}function Ne(e){if(dr(e))return tr.create([e],[]);if(Rr(e))return e.toOperationNode();return e}class Ua{#e;#t;#r;constructor(){this.#e=new Promise((e,t)=>{this.#r=t,this.#t=e})}get promise(){return this.#e}resolve=(e)=>{if(this.#t)this.#t(e)};reject=(e)=>{if(this.#r)this.#r(e)}}async function of(e){let t=new Ua,r=new Ua;return e.provideConnection(async(i)=>(t.resolve(i),await r.promise)).catch((i)=>t.reject(i)),C({connection:await t.promise,release:r.resolve})}var Hr=C([]);class Nu{#e;constructor(e=Hr){this.#e=e}get plugins(){return this.#e}transformQuery(e,t){for(let r of this.#e){let i=r.transformQuery({node:e,queryId:t});if(i.kind===e.kind)e=i;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${i.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async(t)=>{let r=await t.executeQuery(e);if("numUpdatedOrDeletedRows"in r)hi("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#t(r,e.queryId)})}async*stream(e,t){let{connection:r,release:i}=await of(this);try{for await(let n of r.streamQuery(e,t))yield await this.#t(n,e.queryId)}finally{i()}}async#t(e,t){for(let r of this.#e)e=await r.transformResult({result:e,queryId:t});return e}}class ye extends Nu{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new ye([...this.plugins,e])}withPlugins(e){return new ye([...this.plugins,...e])}withPluginAtFront(e){return new ye([e,...this.plugins])}withoutPlugins(){return new ye([])}}var ie=new ye;class Nt{numChangedRows;constructor(e){this.numChangedRows=e}}class G{#e;constructor(e){this.#e=C(e)}modifyEnd(e){return new G({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new G({...this.#e,queryNode:Oe.cloneWithTop(this.#e.queryNode,M(e,t))})}using(...e){return new b({...this.#e,queryNode:A.cloneWithUsing(this.#e.queryNode,re("Using",e))})}returning(e){return new G({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,c(e))})}returningAll(e){return new G({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new G({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,c(e))})}outputAll(e){return new G({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,y(e))})}}class b{#e;constructor(e){this.#e=C(e)}modifyEnd(e){return new b({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new b({...this.#e,queryNode:Oe.cloneWithTop(this.#e.queryNode,M(e,t))})}whenMatched(){return this.#t([])}whenMatchedAnd(...e){return this.#t(e)}whenMatchedAndRef(e,t,r){return this.#t([e,t,r],!0)}#t(e,t){return new yt({...this.#e,queryNode:A.cloneWithWhen(this.#e.queryNode,lt({isMatched:!0},e,t))})}whenNotMatched(){return this.#r([])}whenNotMatchedAnd(...e){return this.#r(e)}whenNotMatchedAndRef(e,t,r){return this.#r([e,t,r],!0)}whenNotMatchedBySource(){return this.#r([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#r(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,r){return this.#r([e,t,r],!0,!0)}returning(e){return new b({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,c(e))})}returningAll(e){return new b({...this.#e,queryNode:Oe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new b({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,c(e))})}outputAll(e){return new b({...this.#e,queryNode:Oe.cloneWithOutput(this.#e.queryNode,y(e))})}#r(e,t=!1,r=!1){let i={...this.#e,queryNode:A.cloneWithWhen(this.#e.queryNode,lt({isMatched:!1,bySource:r},e,t))};return new(r?yt:er)(i)}$call(e){return e(this)}$if(e,t){if(e)return t(this);return new b({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:r}=this.#e.executor,i=e.query;if(i.returning&&r.supportsReturning||i.output&&r.supportsOutput)return t.rows;return[new Nt(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let t=await this.executeTakeFirst();if(t===void 0)throw V(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}}class yt{#e;constructor(e){this.#e=C(e)}thenDelete(){return new b({...this.#e,queryNode:A.cloneWithThen(this.#e.queryNode,Ne("delete"))})}thenDoNothing(){return new b({...this.#e,queryNode:A.cloneWithThen(this.#e.queryNode,Ne("do nothing"))})}thenUpdate(e){return new b({...this.#e,queryNode:A.cloneWithThen(this.#e.queryNode,Ne(e(new ce({queryId:this.#e.queryId,executor:ie,queryNode:F.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate((t)=>t.set(...e))}}class er{#e;constructor(e){this.#e=C(e)}thenDoNothing(){return new b({...this.#e,queryNode:A.cloneWithThen(this.#e.queryNode,Ne("do nothing"))})}thenInsertValues(e){let[t,r]=Ue(e);return new b({...this.#e,queryNode:A.cloneWithThen(this.#e.queryNode,Ne(u.cloneWith(u.createWithoutInto(),{columns:t,values:r})))})}}class gi{#e;constructor(e){this.#e=C(e)}selectFrom(e){return Ee({queryId:It(),executor:this.#e.executor,queryNode:nr.createFrom(P(e),this.#e.withNode)})}selectNoFrom(e){return Ee({queryId:It(),executor:this.#e.executor,queryNode:nr.cloneWithSelections(nr.create(this.#e.withNode),c(e))})}insertInto(e){return new h({queryId:It(),executor:this.#e.executor,queryNode:u.create(or(e),this.#e.withNode)})}replaceInto(e){return new h({queryId:It(),executor:this.#e.executor,queryNode:u.create(or(e),this.#e.withNode,!0)})}deleteFrom(e){return new ze({queryId:It(),executor:this.#e.executor,queryNode:te.create(P(e),this.#e.withNode)})}updateTable(e){return new ce({queryId:It(),executor:this.#e.executor,queryNode:F.create(P(e),this.#e.withNode)})}mergeInto(e){return new G({queryId:It(),executor:this.#e.executor,queryNode:A.create(wt(e),this.#e.withNode)})}with(e,t){let r=ft(e,t);return new gi({...this.#e,withNode:this.#e.withNode?ke.cloneWithExpression(this.#e.withNode,r):ke.create(r)})}withRecursive(e,t){let r=ft(e,t);return new gi({...this.#e,withNode:this.#e.withNode?ke.cloneWithExpression(this.#e.withNode,r):ke.create(r,{recursive:!0})})}withPlugin(e){return new gi({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new gi({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new gi({...this.#e,executor:this.#e.executor.withPluginAtFront(new js(e))})}}function Ht(){return new gi({executor:ie})}function rr(e,t){return new he({joinNode:L.create(e,se(t))})}function ir(){return new ue({overNode:ve.create()})}function re(e,t){if(t.length===3)return Xr(e,t[0],t[1],t[2]);else if(t.length===2)return Yr(e,t[0],t[1]);else if(t.length===1)return Zr(e,t[0]);else throw Error("not implemented")}function Yr(e,t,r){return r(rr(e,t)).toOperationNode()}function Xr(e,t,r,i){return L.createWithOn(e,se(t),N(r,"=",i))}function Zr(e,t){return L.create(e,se(t))}var sr=C({is(e){return e.kind==="OffsetNode"},create(e){return C({kind:"OffsetNode",offset:e})}});var ar=C({is(e){return e.kind==="GroupByItemNode"},create(e){return C({kind:"GroupByItemNode",groupBy:e})}});function pr(e){return e=fr(e)?e(B()):e,Q(e).map(ar.create)}var Je=C({is(e){return e.kind==="SetOperationNode"},create(e,t,r){return C({kind:"SetOperationNode",operator:e,expression:t,all:r})}});function ae(e,t,r){if(fr(t))t=t(Qe());if(!x(t))t=[t];return t.map((i)=>Je.create(e,Ho(i),r))}class p{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new Ge(this,e)}or(...e){return new _e(T.create(this.#e,yr(e)))}and(...e){return new $e(v.create(this.#e,yr(e)))}$castTo(){return new p(this.#e)}$notNull(){return new p(this.#e)}toOperationNode(){return this.#e}}class Ge{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return l.create(this.#e.toOperationNode(),Rr(this.#t)?this.#t.toOperationNode():st.create(this.#t))}}class _e{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new Ge(this,e)}or(...e){return new _e(T.create(this.#e,yr(e)))}$castTo(){return new _e(this.#e)}toOperationNode(){return E.create(this.#e)}}class $e{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new Ge(this,e)}and(...e){return new $e(v.create(this.#e,yr(e)))}$castTo(){return new $e(this.#e)}toOperationNode(){return E.create(this.#e)}}var hr=C({is(e){return e.kind==="FetchNode"},create(e,t){return{kind:"FetchNode",rowCount:_n.create(e),modifier:t}}});function ur(e,t){if(!zs(e)&&!La(e))throw Error(`Invalid fetch row count: ${e}`);if(!ei(t))throw Error(`Invalid fetch modifier: ${t}`);return hr.create(e,t)}function ei(e){return e==="only"||e==="with ties"}var s;class Ot{#e;constructor(e){this.#e=C(e)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...e){return new s({...this.#e,queryNode:Oe.cloneWithWhere(this.#e.queryNode,yr(e))})}whereRef(e,t,r){return new s({...this.#e,queryNode:Oe.cloneWithWhere(this.#e.queryNode,N(e,t,r))})}having(...e){return new s({...this.#e,queryNode:nr.cloneWithHaving(this.#e.queryNode,yr(e))})}havingRef(e,t,r){return new s({...this.#e,queryNode:nr.cloneWithHaving(this.#e.queryNode,N(e,t,r))})}select(e){return new s({...this.#e,queryNode:nr.cloneWithSelections(this.#e.queryNode,c(e))})}distinctOn(e){return new s({...this.#e,queryNode:nr.cloneWithDistinctOn(this.#e.queryNode,Q(e))})}modifyFront(e){return new s({...this.#e,queryNode:nr.cloneWithFrontModifier(this.#e.queryNode,I.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.createWithExpression(e.toOperationNode()))})}distinct(){return new s({...this.#e,queryNode:nr.cloneWithFrontModifier(this.#e.queryNode,I.create("Distinct"))})}forUpdate(e){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.create("ForUpdate",e?xe(e).map(or):void 0))})}forShare(e){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.create("ForShare",e?xe(e).map(or):void 0))})}forKeyShare(e){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.create("ForKeyShare",e?xe(e).map(or):void 0))})}forNoKeyUpdate(e){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.create("ForNoKeyUpdate",e?xe(e).map(or):void 0))})}skipLocked(){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.create("SkipLocked"))})}noWait(){return new s({...this.#e,queryNode:Oe.cloneWithEndModifier(this.#e.queryNode,I.create("NoWait"))})}selectAll(e){return new s({...this.#e,queryNode:nr.cloneWithSelections(this.#e.queryNode,y(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}crossJoin(...e){return this.#t("CrossJoin",e)}innerJoinLateral(...e){return this.#t("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#t("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#t("LateralCrossJoin",e)}crossApply(...e){return this.#t("CrossApply",e)}outerApply(...e){return this.#t("OuterApply",e)}#t(e,t){return new s({...this.#e,queryNode:Oe.cloneWithJoin(this.#e.queryNode,re(e,t))})}orderBy(...e){return new s({...this.#e,queryNode:Oe.cloneWithOrderByItems(this.#e.queryNode,k(e))})}groupBy(e){return new s({...this.#e,queryNode:nr.cloneWithGroupByItems(this.#e.queryNode,pr(e))})}limit(e){return new s({...this.#e,queryNode:nr.cloneWithLimit(this.#e.queryNode,fe.create(d(e)))})}offset(e){return new s({...this.#e,queryNode:nr.cloneWithOffset(this.#e.queryNode,sr.create(d(e)))})}fetch(e,t="only"){return new s({...this.#e,queryNode:nr.cloneWithFetch(this.#e.queryNode,ur(e,t))})}top(e,t){return new s({...this.#e,queryNode:Oe.cloneWithTop(this.#e.queryNode,M(e,t))})}union(e){return new s({...this.#e,queryNode:nr.cloneWithSetOperations(this.#e.queryNode,ae("union",e,!1))})}unionAll(e){return new s({...this.#e,queryNode:nr.cloneWithSetOperations(this.#e.queryNode,ae("union",e,!0))})}intersect(e){return new s({...this.#e,queryNode:nr.cloneWithSetOperations(this.#e.queryNode,ae("intersect",e,!1))})}intersectAll(e){return new s({...this.#e,queryNode:nr.cloneWithSetOperations(this.#e.queryNode,ae("intersect",e,!0))})}except(e){return new s({...this.#e,queryNode:nr.cloneWithSetOperations(this.#e.queryNode,ae("except",e,!1))})}exceptAll(e){return new s({...this.#e,queryNode:nr.cloneWithSetOperations(this.#e.queryNode,ae("except",e,!0))})}as(e){return new mr(this,e)}clearSelect(){return new s({...this.#e,queryNode:nr.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new s({...this.#e,queryNode:Oe.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new s({...this.#e,queryNode:nr.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new s({...this.#e,queryNode:nr.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new s({...this.#e,queryNode:Oe.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new s({...this.#e,queryNode:nr.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){if(e)return t(this);return new s({...this.#e})}$castTo(){return new s(this.#e)}$narrowType(){return new s(this.#e)}$assertType(){return new s(this.#e)}$asTuple(){return new p(this.toOperationNode())}$asScalar(){return new p(this.toOperationNode())}withPlugin(e){return new s({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let t=await this.executeTakeFirst();if(t===void 0)throw V(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),r=this.#e.executor.stream(t,e);for await(let i of r)yield*i.rows}async explain(e,t){return await new s({...this.#e,queryNode:Oe.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}}s=Ot;function Ee(e){return new Ot(e)}class mr{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return l.create(this.#e.toOperationNode(),st.create(this.#t))}}var z=C({is(e){return e.kind==="AggregateFunctionNode"},create(e,t=[]){return C({kind:"AggregateFunctionNode",func:e,aggregated:t})},cloneWithDistinct(e){return C({...e,distinct:!0})},cloneWithOrderBy(e,t,r=!1){let i=r?"withinGroup":"orderBy";return C({...e,[i]:e[i]?_.cloneWithItems(e[i],t):_.create(t)})},cloneWithFilter(e,t){return C({...e,filter:e.filter?O.cloneWithOperation(e.filter,"And",t):O.create(t)})},cloneWithOrFilter(e,t){return C({...e,filter:e.filter?O.cloneWithOperation(e.filter,"Or",t):O.create(t)})},cloneWithOver(e,t){return C({...e,over:t})}});var xt=C({is(e){return e.kind==="FunctionNode"},create(e,t){return C({kind:"FunctionNode",func:e,arguments:t})}});class W{#e;constructor(e){this.#e=C(e)}get expressionType(){return}as(e){return new cr(this,e)}distinct(){return new W({...this.#e,aggregateFunctionNode:z.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new W({...this.#e,aggregateFunctionNode:Oe.cloneWithOrderByItems(this.#e.aggregateFunctionNode,k(e))})}clearOrderBy(){return new W({...this.#e,aggregateFunctionNode:Oe.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new W({...this.#e,aggregateFunctionNode:z.cloneWithOrderBy(this.#e.aggregateFunctionNode,k(e),!0)})}filterWhere(...e){return new W({...this.#e,aggregateFunctionNode:z.cloneWithFilter(this.#e.aggregateFunctionNode,yr(e))})}filterWhereRef(e,t,r){return new W({...this.#e,aggregateFunctionNode:z.cloneWithFilter(this.#e.aggregateFunctionNode,N(e,t,r))})}over(e){let t=ir();return new W({...this.#e,aggregateFunctionNode:z.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new W(this.#e)}$notNull(){return new W(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class cr{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return l.create(this.#e.toOperationNode(),st.create(this.#t))}}function sf(){let e=(r,i)=>new p(xt.create(r,Q(i??[]))),t=(r,i)=>new W({aggregateFunctionNode:z.create(r,i?Q(i):void 0)});return Object.assign(e,{agg:t,avg(r){return t("avg",[r])},coalesce(...r){return e("coalesce",r)},count(r){return t("count",[r])},countAll(r){return new W({aggregateFunctionNode:z.create("count",y(r))})},max(r){return t("max",[r])},min(r){return t("min",[r])},sum(r){return t("sum",[r])},any(r){return e("any",[r])},jsonAgg(r){return new W({aggregateFunctionNode:z.create("json_agg",[dr(r)?or(r):r.toOperationNode()])})},toJson(r){return new p(xt.create("to_json",[dr(r)?or(r):r.toOperationNode()]))}})}var lr=C({is(e){return e.kind==="UnaryOperationNode"},create(e,t){return C({kind:"UnaryOperationNode",operator:e,operand:t})}});function Nr(e,t){return lr.create(S.create(e),w(t))}var as=C({is(e){return e.kind==="CaseNode"},create(e){return C({kind:"CaseNode",value:e})},cloneWithWhen(e,t){return C({...e,when:C(e.when?[...e.when,t]:[t])})},cloneWithThen(e,t){return C({...e,when:e.when?C([...e.when.slice(0,-1),R.cloneWithResult(e.when[e.when.length-1],t)]):void 0})},cloneWith(e,t){return C({...e,...t})}});class Fu{#e;constructor(e){this.#e=C(e)}when(...e){return new gt({...this.#e,node:as.cloneWithWhen(this.#e.node,R.create(yr(e)))})}}class gt{#e;constructor(e){this.#e=C(e)}then(e){return new wr({...this.#e,node:as.cloneWithThen(this.#e.node,Pe(e)?ge(e):d(e))})}}class wr{#e;constructor(e){this.#e=C(e)}when(...e){return new gt({...this.#e,node:as.cloneWithWhen(this.#e.node,R.create(yr(e)))})}else(e){return new Or({...this.#e,node:as.cloneWith(this.#e.node,{else:Pe(e)?ge(e):d(e)})})}end(){return new p(as.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new p(as.cloneWith(this.#e.node,{isStatement:!0}))}}class Or{#e;constructor(e){this.#e=C(e)}end(){return new p(as.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new p(as.cloneWith(this.#e.node,{isStatement:!0}))}}var vt=C({is(e){return e.kind==="JSONPathLegNode"},create(e,t){return C({kind:"JSONPathLegNode",type:e,value:t})}});var ti=/^#-\d+$/;class Re{#e;constructor(e){this.#e=e}at(e){if(typeof e!=="number"&&typeof e!=="string"||typeof e==="number"&&!Number.isInteger(e)||typeof e==="string"&&e!=="last"&&!ti.test(e))throw Error(`Unexpected index value in .at(...): ${e}`);return this.#t("ArrayLocation",e)}key(e){return this.#t("Member",e)}#t(e,t){if(pe.is(this.#e))return new Ae(pe.cloneWithTraversal(this.#e,ee.is(this.#e.traversal)?ee.cloneWithLeg(this.#e.traversal,vt.create(e,t)):qe.cloneWithValue(this.#e.traversal,_n.createImmediate(t))));return new Ae(ee.cloneWithLeg(this.#e,vt.create(e,t)))}}class Ae extends Re{#e;constructor(e){super(e);this.#e=e}get expressionType(){return}as(e){return new xr(this,e)}$castTo(){return new Ae(this.#e)}$notNull(){return new Ae(this.#e)}toOperationNode(){return this.#e}}class xr{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return l.create(this.#e.toOperationNode(),Rr(this.#t)?this.#t.toOperationNode():st.create(this.#t))}}var bt=C({is(e){return e.kind==="TupleNode"},create(e){return C({kind:"TupleNode",values:C(e)})}});var ri=["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"],ii=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],gr=C({is(e){return e.kind==="DataTypeNode"},create(e){return C({kind:"DataTypeNode",dataType:e})}});function vr(e){if(ri.includes(e))return!0;if(ii.some((t)=>t.test(e)))return!0;return!1}function qs(e){if(Rr(e))return e.toOperationNode();if(vr(e))return gr.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}var br=C({is(e){return e.kind==="CastNode"},create(e,t){return C({kind:"CastNode",expression:e,dataType:t})}});function Qe(e=ie){function t(n,a,j){return new p(Ie(n,a,j))}function r(n,a){return new p(Nr(n,a))}let i=Object.assign(t,{fn:void 0,eb:void 0,selectFrom(n){return Ee({queryId:It(),executor:e,queryNode:nr.createFrom(P(n))})},case(n){return new Fu({node:as.create(So(n)?void 0:w(n))})},ref(n,a){if(So(a))return new p(is(n));return new Re(Lt(n,a))},jsonPath(){return new Re(ee.create())},table(n){return new p(or(n))},val(n){return new p(d(n))},refTuple(...n){return new p(bt.create(n.map(w)))},tuple(...n){return new p(bt.create(n.map(d)))},lit(n){return new p(ge(n))},unary:r,not(n){return r("not",n)},exists(n){return r("exists",n)},neg(n){return r("-",n)},between(n,a,j){return new p(X.create(w(n),S.create("between"),v.create(d(a),d(j))))},betweenSymmetric(n,a,j){return new p(X.create(w(n),S.create("between symmetric"),v.create(d(a),d(j))))},and(n){if(x(n))return new p(de(n,"and"));return new p(tt(n,"and"))},or(n){if(x(n))return new p(de(n,"or"));return new p(tt(n,"or"))},parens(...n){let a=yr(n);if(E.is(a))return new p(a);else return new p(E.create(a))},cast(n,a){return new p(br.create(w(n),qs(a)))},withSchema(n){return Qe(e.withPluginAtFront(new js(n)))}});return i.fn=sf(),i.eb=i,i}function B(e){return Qe()}function Ho(e){if(Rr(e))return e.toOperationNode();else if(fr(e))return e(B()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function Ve(e){if(Rr(e))return e.toOperationNode();else if(fr(e))return e(B()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function J(e){return Le(e)||Ct(e)||fr(e)}class hm{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Wr(this.#e,e)}}class Wr{#e;#t;get table(){return this.#e}get alias(){return this.#t}constructor(e,t){this.#e=e,this.#t=t}toOperationNode(){return l.create(or(this.#e),st.create(this.#t))}}function Sr(e){return sn(e)&&Rr(e)&&dr(e.table)&&dr(e.alias)}function P(e){if(x(e))return e.map((t)=>se(t));else return[se(e)]}function se(e){if(dr(e))return wt(e);else if(Sr(e))return e.toOperationNode();else return Ve(e)}function wt(e){if(e.includes(" as ")){let[r,i]=e.split(" as ").map(Cr);return l.create(or(r),st.create(i))}else return or(e)}function or(e){if(e.includes(".")){let[r,i]=e.split(".").map(Cr);return mo.createWithSchema(r,i)}else return mo.create(e)}function Cr(e){return e.trim()}var $s=C({is(e){return e.kind==="CreateViewNode"},create(e){return C({kind:"CreateViewNode",name:po.create(e)})},cloneWith(e,t){return C({...e,...t})}});class Te{#e;constructor(e){this.#e=C(e)}get expressionType(){return}get isRawBuilder(){return!0}as(e){return new kr(this,e)}$castTo(){return new Te({...this.#e})}$notNull(){return new Te(this.#e)}withPlugin(e){return new Te({...this.#e,plugins:this.#e.plugins!==void 0?C([...this.#e.plugins,e]):C([e])})}toOperationNode(){return this.#r(this.#t())}compile(e){return this.#o(this.#t(e))}async execute(e){let t=this.#t(e);return t.executeQuery(this.#o(t))}#t(e){let t=e!==void 0?e.getExecutor():ie;return this.#e.plugins!==void 0?t.withPlugins(this.#e.plugins):t}#r(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#o(e){return e.compileQuery(this.#r(e),this.#e.queryId)}}function K(e){return new Te(e)}class kr{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}get rawBuilder(){return this.#e}toOperationNode(){return l.create(this.#e.toOperationNode(),Rr(this.#t)?this.#t.toOperationNode():st.create(this.#t))}}var je=Object.assign((e,...t)=>K({queryId:It(),rawNode:tr.create(e,t?.map(Er)??[])}),{ref(e){return K({queryId:It(),rawNode:tr.createWithChild(is(e))})},val(e){return K({queryId:It(),rawNode:tr.createWithChild(d(e))})},value(e){return this.val(e)},table(e){return K({queryId:It(),rawNode:tr.createWithChild(or(e))})},id(...e){let t=Array(e.length+1).fill(".");return t[0]="",t[t.length-1]="",K({queryId:It(),rawNode:tr.create(t,e.map(st.create))})},lit(e){return K({queryId:It(),rawNode:tr.createWithChild(_n.createImmediate(e))})},literal(e){return this.lit(e)},raw(e){return K({queryId:It(),rawNode:tr.createWithSql(e)})},join(e,t=je`, `){let r=Array(Math.max(2*e.length-1,0)),i=t.toOperationNode();for(let n=0;n<e.length;++n)if(r[2*n]=Er(e[n]),n!==e.length-1)r[2*n+1]=i;return K({queryId:It(),rawNode:tr.createWithChildren(r)})}});function Er(e){if(Rr(e))return e.toOperationNode();return d(e)}class St{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#e=C({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=(e)=>{this.nodeStack.push(e),this.#e[e.kind](e),this.nodeStack.pop()}}var oi=/'/g,ni=/['"]/g;class ho extends St{#e="";#t=[];get numParameters(){return this.#t.length}compileQuery(e,t){return this.#e="",this.#t=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),C({query:e,queryId:t,sql:this.getSql(),parameters:[...this.#t]})}getSql(){return this.#e}visitSelectQuery(e){let t=this.parentNode!==void 0&&!E.is(this.parentNode)&&!u.is(this.parentNode)&&!fo.is(this.parentNode)&&!$s.is(this.parentNode)&&!Je.is(this.parentNode);if(this.parentNode===void 0&&e.explain)this.visitNode(e.explain),this.append(" ");if(t)this.append("(");if(e.with)this.visitNode(e.with),this.append(" ");if(this.append("select"),e.distinctOn)this.append(" "),this.compileDistinctOn(e.distinctOn);if(e.frontModifiers?.length)this.append(" "),this.compileList(e.frontModifiers," ");if(e.top)this.append(" "),this.visitNode(e.top);if(e.selections)this.append(" "),this.compileList(e.selections);if(e.from)this.append(" "),this.visitNode(e.from);if(e.joins)this.append(" "),this.compileList(e.joins," ");if(e.where)this.append(" "),this.visitNode(e.where);if(e.groupBy)this.append(" "),this.visitNode(e.groupBy);if(e.having)this.append(" "),this.visitNode(e.having);if(e.setOperations)this.append(" "),this.compileList(e.setOperations," ");if(e.orderBy)this.append(" "),this.visitNode(e.orderBy);if(e.limit)this.append(" "),this.visitNode(e.limit);if(e.offset)this.append(" "),this.visitNode(e.offset);if(e.fetch)this.append(" "),this.visitNode(e.fetch);if(e.endModifiers?.length)this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ");if(t)this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,t=", "){let r=e.length-1;for(let i=0;i<=r;i++)if(this.visitNode(e[i]),i<r)this.append(t)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){let t=this.parentNode!==void 0&&!E.is(this.parentNode)&&!tr.is(this.parentNode)&&!R.is(this.parentNode);if(this.parentNode===void 0&&e.explain)this.visitNode(e.explain),this.append(" ");if(t)this.append("(");if(e.with)this.visitNode(e.with),this.append(" ");if(this.append(e.replace?"replace":"insert"),e.ignore)hi("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore");if(e.orAction)this.append(" "),this.visitNode(e.orAction);if(e.top)this.append(" "),this.visitNode(e.top);if(e.into)this.append(" into "),this.visitNode(e.into);if(e.columns)this.append(" ("),this.compileList(e.columns),this.append(")");if(e.output)this.append(" "),this.visitNode(e.output);if(e.values)this.append(" "),this.visitNode(e.values);if(e.defaultValues)this.append(" "),this.append("default values");if(e.onConflict)this.append(" "),this.visitNode(e.onConflict);if(e.onDuplicateKey)this.append(" "),this.visitNode(e.onDuplicateKey);if(e.returning)this.append(" "),this.visitNode(e.returning);if(t)this.append(")");if(e.endModifiers?.length)this.append(" "),this.compileList(e.endModifiers," ")}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){let t=this.parentNode!==void 0&&!E.is(this.parentNode)&&!tr.is(this.parentNode);if(this.parentNode===void 0&&e.explain)this.visitNode(e.explain),this.append(" ");if(t)this.append("(");if(e.with)this.visitNode(e.with),this.append(" ");if(this.append("delete "),e.top)this.visitNode(e.top),this.append(" ");if(this.visitNode(e.from),e.output)this.append(" "),this.visitNode(e.output);if(e.using)this.append(" "),this.visitNode(e.using);if(e.joins)this.append(" "),this.compileList(e.joins," ");if(e.where)this.append(" "),this.visitNode(e.where);if(e.orderBy)this.append(" "),this.visitNode(e.orderBy);if(e.limit)this.append(" "),this.visitNode(e.limit);if(e.returning)this.append(" "),this.visitNode(e.returning);if(t)this.append(")");if(e.endModifiers?.length)this.append(" "),this.compileList(e.endModifiers," ")}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){if(e.table)this.visitNode(e.table),this.append(".");this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!dr(e.name))throw Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){if(e.immediate)this.appendImmediateValue(e.value);else this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");let{values:t}=e;for(let r=0;r<t.length;++r)if(this.appendValue(t[r]),r!==t.length-1)this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){if(this.append(ai[e.joinType]),this.append(" "),this.visitNode(e.table),e.on)this.append(" "),this.visitNode(e.on)}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){let{sqlFragments:t,parameters:r}=e;for(let i=0;i<t.length;++i)if(this.append(t[i]),r.length>i)this.visitNode(r[i])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){if(e.schema)this.visitNode(e.schema),this.append(".");this.visitNode(e.identifier)}visitCreateTable(e){if(this.append("create "),e.frontModifiers?.length)this.compileList(e.frontModifiers," "),this.append(" ");if(e.temporary)this.append("temporary ");if(this.append("table "),e.ifNotExists)this.append("if not exists ");if(this.visitNode(e.table),!e.selectQuery)this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")");if(e.onCommit)this.append(" on commit "),this.append(e.onCommit);if(e.endModifiers?.length)this.append(" "),this.compileList(e.endModifiers," ");if(e.selectQuery)this.append(" as "),this.visitNode(e.selectQuery)}visitColumnDefinition(e){if(e.ifNotExists)this.append("if not exists ");if(this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned)this.append(" unsigned");if(e.frontModifiers&&e.frontModifiers.length>0)this.append(" "),this.compileList(e.frontModifiers," ");if(e.generated)this.append(" "),this.visitNode(e.generated);if(e.identity)this.append(" identity");if(e.defaultTo)this.append(" "),this.visitNode(e.defaultTo);if(e.notNull)this.append(" not null");if(e.unique)this.append(" unique");if(e.nullsNotDistinct)this.append(" nulls not distinct");if(e.primaryKey)this.append(" primary key");if(e.autoIncrement)this.append(" "),this.append(this.getAutoIncrement());if(e.references)this.append(" "),this.visitNode(e.references);if(e.check)this.append(" "),this.visitNode(e.check);if(e.endModifiers&&e.endModifiers.length>0)this.append(" "),this.compileList(e.endModifiers," ")}getAutoIncrement(){return"auto_increment"}visitReferences(e){if(this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete)this.append(" on delete "),this.append(e.onDelete);if(e.onUpdate)this.append(" on update "),this.append(e.onUpdate)}visitDropTable(e){if(this.append("drop table "),e.ifExists)this.append("if exists ");if(this.visitNode(e.table),e.cascade)this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){if(this.visitNode(e.orderBy),e.collation)this.append(" "),this.visitNode(e.collation);if(e.direction)this.append(" "),this.visitNode(e.direction);if(e.nulls)this.append(" nulls "),this.append(e.nulls)}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){let t=this.parentNode!==void 0&&!E.is(this.parentNode)&&!tr.is(this.parentNode)&&!R.is(this.parentNode);if(this.parentNode===void 0&&e.explain)this.visitNode(e.explain),this.append(" ");if(t)this.append("(");if(e.with)this.visitNode(e.with),this.append(" ");if(this.append("update "),e.top)this.visitNode(e.top),this.append(" ");if(e.table)this.visitNode(e.table),this.append(" ");if(this.append("set "),e.updates)this.compileList(e.updates);if(e.output)this.append(" "),this.visitNode(e.output);if(e.from)this.append(" "),this.visitNode(e.from);if(e.joins){if(!e.from)throw Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList(e.joins," ")}if(e.where)this.append(" "),this.visitNode(e.where);if(e.returning)this.append(" "),this.visitNode(e.returning);if(e.orderBy)this.append(" "),this.visitNode(e.orderBy);if(e.limit)this.append(" "),this.visitNode(e.limit);if(t)this.append(")");if(e.endModifiers?.length)this.append(" "),this.compileList(e.endModifiers," ")}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){if(this.append("on conflict"),e.columns)this.append(" ("),this.compileList(e.columns),this.append(")");else if(e.constraint)this.append(" on constraint "),this.visitNode(e.constraint);else if(e.indexExpression)this.append(" ("),this.visitNode(e.indexExpression),this.append(")");if(e.indexWhere)this.append(" "),this.visitNode(e.indexWhere);if(e.doNothing===!0)this.append(" do nothing");else if(e.updates){if(this.append(" do update set "),this.compileList(e.updates),e.updateWhere)this.append(" "),this.visitNode(e.updateWhere)}}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){if(this.append("create "),e.unique)this.append("unique ");if(this.append("index "),e.ifNotExists)this.append("if not exists ");if(this.visitNode(e.name),e.table)this.append(" on "),this.visitNode(e.table);if(e.using)this.append(" using "),this.visitNode(e.using);if(e.columns)this.append(" ("),this.compileList(e.columns),this.append(")");if(e.nullsNotDistinct)this.append(" nulls not distinct");if(e.where)this.append(" "),this.visitNode(e.where)}visitDropIndex(e){if(this.append("drop index "),e.ifExists)this.append("if exists ");if(this.visitNode(e.name),e.table)this.append(" on "),this.visitNode(e.table);if(e.cascade)this.append(" cascade")}visitCreateSchema(e){if(this.append("create schema "),e.ifNotExists)this.append("if not exists ");this.visitNode(e.schema)}visitDropSchema(e){if(this.append("drop schema "),e.ifExists)this.append("if exists ");if(this.visitNode(e.schema),e.cascade)this.append(" cascade")}visitPrimaryKeyConstraint(e){if(e.name)this.append("constraint "),this.visitNode(e.name),this.append(" ");this.append("primary key ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}buildDeferrable(e){if(e.deferrable!==void 0)if(e.deferrable)this.append(" deferrable");else this.append(" not deferrable");if(e.initiallyDeferred!==void 0)if(e.initiallyDeferred)this.append(" initially deferred");else this.append(" initially immediate")}visitUniqueConstraint(e){if(e.name)this.append("constraint "),this.visitNode(e.name),this.append(" ");if(this.append("unique"),e.nullsNotDistinct)this.append(" nulls not distinct");this.append(" ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}visitCheckConstraint(e){if(e.name)this.append("constraint "),this.visitNode(e.name),this.append(" ");this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){if(e.name)this.append("constraint "),this.visitNode(e.name),this.append(" ");if(this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete)this.append(" on delete "),this.append(e.onDelete);if(e.onUpdate)this.append(" on update "),this.append(e.onUpdate);this.buildDeferrable(e)}visitList(e){this.compileList(e.items)}visitWith(e){if(this.append("with "),e.recursive)this.append("recursive ");this.compileList(e.expressions)}visitCommonTableExpression(e){if(this.visitNode(e.name),this.append(" as "),Vi(e.materialized)){if(!e.materialized)this.append("not ");this.append("materialized ")}this.visitNode(e.expression)}visitCommonTableExpressionName(e){if(this.visitNode(e.table),e.columns)this.append("("),this.compileList(e.columns),this.append(")")}visitAlterTable(e){if(this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo)this.append("rename to "),this.visitNode(e.renameTo);if(e.setSchema)this.append("set schema "),this.visitNode(e.setSchema);if(e.addConstraint)this.visitNode(e.addConstraint);if(e.dropConstraint)this.visitNode(e.dropConstraint);if(e.renameConstraint)this.visitNode(e.renameConstraint);if(e.columnAlterations)this.compileColumnAlterations(e.columnAlterations);if(e.addIndex)this.visitNode(e.addIndex);if(e.dropIndex)this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){if(this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType){if(this.announcesNewColumnDataType())this.append("type ");if(this.visitNode(e.dataType),e.dataTypeExpression)this.append("using "),this.visitNode(e.dataTypeExpression)}if(e.setDefault)this.append("set default "),this.visitNode(e.setDefault);if(e.dropDefault)this.append("drop default");if(e.setNotNull)this.append("set not null");if(e.dropNotNull)this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){if(this.append("drop constraint "),e.ifExists)this.append("if exists ");if(this.visitNode(e.constraintName),e.modifier==="cascade")this.append(" cascade");else if(e.modifier==="restrict")this.append(" restrict")}visitRenameConstraint(e){this.append("rename constraint "),this.visitNode(e.oldName),this.append(" to "),this.visitNode(e.newName)}visitSetOperation(e){if(this.append(e.operator),this.append(" "),e.all)this.append("all ");this.visitNode(e.expression)}visitCreateView(e){if(this.append("create "),e.orReplace)this.append("or replace ");if(e.materialized)this.append("materialized ");if(e.temporary)this.append("temporary ");if(this.append("view "),e.ifNotExists)this.append("if not exists ");if(this.visitNode(e.name),this.append(" "),e.columns)this.append("("),this.compileList(e.columns),this.append(") ");if(e.as)this.append("as "),this.visitNode(e.as)}visitRefreshMaterializedView(e){if(this.append("refresh materialized view "),e.concurrently)this.append("concurrently ");if(this.visitNode(e.name),e.withNoData)this.append(" with no data");else this.append(" with data")}visitDropView(e){if(this.append("drop "),e.materialized)this.append("materialized ");if(this.append("view "),e.ifExists)this.append("if exists ");if(this.visitNode(e.name),e.cascade)this.append(" cascade")}visitGenerated(e){if(this.append("generated "),e.always)this.append("always ");if(e.byDefault)this.append("by default ");if(this.append("as "),e.identity)this.append("identity");if(e.expression)this.append("("),this.visitNode(e.expression),this.append(")");if(e.stored)this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){if(e.rawModifier)this.visitNode(e.rawModifier);else this.append(si[e.modifier]);if(e.of)this.append(" of "),this.compileList(e.of,", ")}visitCreateType(e){if(this.append("create type "),this.visitNode(e.name),e.enum)this.append(" as enum "),this.visitNode(e.enum)}visitDropType(e){if(this.append("drop type "),e.ifExists)this.append("if exists ");this.visitNode(e.name)}visitExplain(e){if(this.append("explain"),e.options||e.format){if(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options){if(this.visitNode(e.options),e.format)this.append(this.getExplainOptionsDelimiter())}if(e.format)this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format);this.append(this.getRightExplainOptionsWrapper())}}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){if(this.append(e.func),this.append("("),e.distinct)this.append("distinct ");if(this.compileList(e.aggregated),e.orderBy)this.append(" "),this.visitNode(e.orderBy);if(this.append(")"),e.withinGroup)this.append(" within group ("),this.visitNode(e.withinGroup),this.append(")");if(e.filter)this.append(" filter("),this.visitNode(e.filter),this.append(")");if(e.over)this.append(" "),this.visitNode(e.over)}visitOver(e){if(this.append("over("),e.partitionBy){if(this.visitNode(e.partitionBy),e.orderBy)this.append(" ")}if(e.orderBy)this.visitNode(e.orderBy);this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){if(this.visitNode(e.operator),!this.isMinusOperator(e.operator))this.append(" ");this.visitNode(e.operand)}isMinusOperator(e){return S.is(e)&&e.operator==="-"}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){if(this.append("case"),e.value)this.append(" "),this.visitNode(e.value);if(e.when)this.append(" "),this.compileList(e.when," ");if(e.else)this.append(" else "),this.visitNode(e.else);if(this.append(" end"),e.isStatement)this.append(" case")}visitWhen(e){if(this.append("when "),this.visitNode(e.condition),e.result)this.append(" then "),this.visitNode(e.result)}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){if(e.inOperator)this.visitNode(e.inOperator);this.append("'$");for(let t of e.pathLegs)this.visitNode(t);this.append("'")}visitJSONPathLeg(e){let t=e.type==="ArrayLocation",r=String(e.value);if(t)this.append("["),this.append(this.sanitizeStringLiteral(r)),this.append("]");else this.append('."'),this.append(this.sanitizeJSONPathMemberValue(r)),this.append('"')}visitJSONOperatorChain(e){for(let t=0,r=e.values.length;t<r;t++){if(t===r-1)this.visitNode(e.operator);else this.append("->");this.visitNode(e.values[t])}}visitMergeQuery(e){if(e.with)this.visitNode(e.with),this.append(" ");if(this.append("merge "),e.top)this.visitNode(e.top),this.append(" ");if(this.append("into "),this.visitNode(e.into),e.using)this.append(" "),this.visitNode(e.using);if(e.whens)this.append(" "),this.compileList(e.whens," ");if(e.returning)this.append(" "),this.visitNode(e.returning);if(e.output)this.append(" "),this.visitNode(e.output);if(e.endModifiers?.length)this.append(" "),this.compileList(e.endModifiers," ")}visitMatched(e){if(e.not)this.append("not ");if(this.append("matched"),e.bySource)this.append(" by source")}visitAddIndex(e){if(this.append("add "),e.unique)this.append("unique ");if(this.append("index "),this.visitNode(e.name),e.columns)this.append(" ("),this.compileList(e.columns),this.append(")");if(e.using)this.append(" using "),this.visitNode(e.using)}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){if(this.append(`top(${e.expression})`),e.modifiers)this.append(` ${e.modifiers}`)}visitOrAction(e){this.append(e.action)}visitCollate(e){this.append("collate "),this.visitNode(e.collation)}append(e){this.#e+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){let t=this.getLeftIdentifierWrapper(),r=this.getRightIdentifierWrapper(),i="";for(let n of e)if(i+=n,n===t)i+=t;else if(n===r)i+=r;return i}sanitizeStringLiteral(e){return e.replace(oi,"''")}sanitizeJSONPathMemberValue(e){return e.replace(ni,(t)=>t==="'"?"''":"\\\"")}addParameter(e){this.#t.push(e)}appendImmediateValue(e){if(dr(e))this.appendStringLiteral(e);else if(zs(e)||Vi(e)||La(e))this.append(e.toString());else if(Fa(e))this.append("null");else if(rf(e))this.appendImmediateValue(e.toISOString());else throw Error(`invalid immediate value ${e}`)}appendStringLiteral(e){this.append("'"),this.append(this.sanitizeStringLiteral(e)),this.append("'")}sortSelectModifiers(e){return e.sort((t,r)=>t.modifier&&r.modifier?Ar[t.modifier]-Ar[r.modifier]:1),C(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}}var si=C({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Ar=C({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),ai=C({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"});var gm="kysely_migration",Am="kysely_migration_lock";function _m(e){let t=e.filter((i)=>i.pk>0),r=t.length===1?t[0]:void 0;return r?.type.toLowerCase()==="integer"?r.name:void 0}async function Tr(e,t,r){let i=_m(r);if(!i)return;let{rows:n}=await je`
|
|
3
|
+
PRAGMA index_list(${je.id(t)})
|
|
4
|
+
`.execute(e.withoutPlugins());return n.some((a)=>a.origin==="pk")?void 0:i}function af(e,t,r){return{name:e.name,isView:e.type==="view",columns:t.map((i)=>({name:i.name,dataType:i.type,isNullable:i.notnull===0,isAutoIncrementing:i.name===r,hasDefaultValue:i.dflt_value!=null}))}}async function pi(e,t){let{rows:r}=await je`
|
|
5
|
+
PRAGMA table_info(${je.id(t)})
|
|
6
|
+
`.execute(e.withoutPlugins());if(r.length===0)return;let i=await Tr(e,t,r);return af({name:t},r,i)}async function qg(e,t){if(t.length===0)return[];try{return await e.introspection.getTables()}catch{return(await Promise.all(t.map((r)=>pi(e,r)))).filter((r)=>r!==void 0)}}function Lu(e){let t=e;async function r(){return[]}async function i(n={withInternalKyselyTables:!1}){let a=t.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name");if(!n.withInternalKyselyTables)a=a.where("name","!=",gm).where("name","!=",Am);let j=await a.execute();return Promise.all(j.map(async({name:H})=>{let Y=await e.selectFrom(je`pragma_table_info(${H})`.as("table_info")).select(["cid","name","type","notnull","dflt_value","pk"]).execute(),we=await Tr(e,H,Y);return af({name:H},Y,we)}))}return{getSchemas:r,getTables:i,getMetadata:async(n)=>({tables:await i(n)})}}
|
|
7
|
+
export{So,dr,zs,Vi,Fa,rf,La,zg,fr,sn,C,Io,st,jg,fo,po,mo,Rr,Wt,dc,Za,pm,tr,hi,is,mm,fc,Ba,_n,yr,Oe,nr,nf,It,Du,js,Ua,of,Nu,gi,sf,as,Fu,qs,Ho,hm,or,$s,je,ho,gm,Am,_m,af,qg,Lu};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
3
|
-
export{
|
|
2
|
+
function mi(i){let t=3735928559,h=1103547991;for(let e=0;e<i.length;e++){let l=i.charCodeAt(e);t=Math.imul(t^l,2654435761),h=Math.imul(h^l,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(h^h>>>13,3266489909),h=Math.imul(h^h>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(h>>>0).toString(36)+(t>>>0).toString(36)}
|
|
3
|
+
export{mi};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Q,S,M,w,Z,Y,a,g,ie,X,R,z,K,ao,$t,Be,Bt,Er,xr,Re,Ue,Ge,B,jb,qb,Vb,fw,Vm,e_,$w,dE,LE,ZE,Dr,B_,mh,yh,s0,tT,aT,RT,y0,Wh,Lp,PR,VM,dg,fg,bO,Jn,pg,Ie,Pt,ln,nn,ha,Xe,et,tt,rt,be,ts,Fi,ar,Ir}from"./chunk-zarz3sqn.js";import{ro}from"./chunk-55h9ze53.js";import{Gd,Bi}from"./chunk-1ktk6764.js";import{rs}from"./chunk-hpbn0k9n.js";var Ce=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],ae=z("brain",Ce);Z();function va({projectId:m,contextAssetId:k,file:f,currentTime:ne,frameRate:C,startTimecode:V,formatTimestamp:I,onTyping:le,onSelectMessage:W,selectedMessageId:de}){let{isHistoryMode:p,setIsHistoryMode:A,currentSessionId:me,chatAssets:ce,removeAsset:ue,messages:h,historySessions:J,isStreaming:_,fetchHistorySessions:U,loadSession:pe,deleteSession:fe,startNewSession:G,sendMessage:ge,abortActiveSession:xe,selectedAgentId:T,setSelectedAgentId:j,inputText:he,setInputText:ve}=Ir(),{teamId:c,ensureTeamIdForProject:ee}=Pt(),{videoTimeDisplayMode:ye}=ar(),[q,D]=w(null);S(()=>{if(m)ee(m)},[m,ee]);let{data:we=[],isSuccess:te}=X({queryKey:["chat-agents",m],queryFn:async()=>{if(!m)return[];let e=await R.api.projects[":projectId"]["chat-agents"].$get({param:{projectId:m}});if(!e.ok)throw Error("failed to fetch agents");return e.json()},enabled:!!m}),N=we.filter((e)=>e.type==="chat"&&e.enabled);S(()=>{if(!te)return;if(N.length>0){if(!N.some((t)=>t.id===T))j(N[0].id)}else if(T!==null)j(null)},[te,N,T,j]);let re=M(null),E=M(null),F=M(!0),H=M(!0);S(()=>{H.current=!0,F.current=!0},[m,k,p]),S(()=>{let e=E.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!e)return;let{scrollTop:t,isAtBottom:i}=Ir.getState(),r=setTimeout(()=>{if(i)e.scrollTop=e.scrollHeight;else e.scrollTop=t;let d=setTimeout(()=>{H.current=!1},50);return()=>clearTimeout(d)},0);return()=>clearTimeout(r)},[m,k,p]),S(()=>{let e=E.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!e)return;let t=()=>{if(H.current)return;let i=e.scrollTop,r=e.scrollHeight-i-e.clientHeight<10;Ir.getState().setScrollState(i,r)};return e.addEventListener("scroll",t),()=>{e.removeEventListener("scroll",t)}},[m,k,p]);let{ref:ke,isDropTarget:Ne}=ln({id:"chatbot-sidebar",data:{type:"chatbot-sidebar"}});S(()=>{if(!p){let{isAtBottom:e}=Ir.getState();if(e||_){let t=F.current?"auto":"smooth";re.current?.scrollIntoView({behavior:t})}F.current=!1}},[h,_,p]),S(()=>{if(p&&c)U(c)},[p,U,c]);let v=ie(),_e=Q(()=>{v.invalidateQueries({queryKey:["search"]}),v.invalidateQueries({queryKey:["folders"]}),v.invalidateQueries({queryKey:["files"]}),v.invalidateQueries({queryKey:["file"]}),v.invalidateQueries({queryKey:["version_stacks"]}),v.invalidateQueries({queryKey:["projects"]})},[v]),O=(e)=>{if(typeof e==="string")return e;if(Array.isArray(e))return e.map((t)=>{if(typeof t==="string")return t;if(t&&typeof t==="object"&&"type"in t&&t.type==="text"&&"text"in t)return String(t.text);return""}).join("");return""},oe=(e)=>e.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:"),Se=(e)=>{switch(e.role){case"user":case"custom":{let t=e;if(e.role==="custom"&&t.customType==="context_display_info"){let d=t.details?.assets||[];if(d.length===0)return null;return g("div",{className:"text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1",children:[a("div",{className:"font-semibold",children:qb()}),a("ul",{className:"list-disc list-inside space-y-0.5",children:d.map((s)=>g("li",{className:"truncate",children:[s.name," ",g("span",{className:"text-muted-foreground/70",children:["(",s.type,")"]})]},s.id))})]},e.id)}if(e.role==="user"||t.customType==="shumai_message"){let r=t.details,d=r?.referencedAssets||[],s=r?.attachedFiles||[],n=r?.position,u=r?.annotation||r?.annotations&&r.annotations.length>0,l=!r?.currentAsset?.id||k&&r.currentAsset.id===k||f?.id&&r.currentAsset.id===f.id,x=de===e.id,y="";if(n?.type==="time")if(I)y=I(n.seconds);else if(C){let o=Math.round(n.seconds*C);y=ro(o,C,ye,V)}else{let o=Math.floor(n.seconds/60),b=Math.floor(n.seconds%60);y=`${o.toString().padStart(2,"0")}:${b.toString().padStart(2,"0")}`}else if(n?.type==="page")y=y0({page:n.page});let se=O(t.content),Te=s.length>0||d.length>0;return a("div",{onClick:()=>{if(l&&W)W(e)},className:B("flex flex-col items-end w-full group transition-all duration-150",l&&(u||n)&&"cursor-pointer"),children:g("div",{className:B("bg-primary text-primary-foreground rounded-lg px-3 py-2 text-sm whitespace-pre-wrap shadow-xs break-words transition-all border",Te?"w-full":"max-w-[85%]",x?"border-blue-500 dark:border-blue-400":"border-transparent"),children:[g("div",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words",children:[u&&a("span",{className:"inline-flex items-center align-middle mr-1.5 p-0.5 rounded bg-primary-foreground/20 text-primary-foreground",title:$w(),children:a(ha,{className:"w-3.5 h-3.5"})}),n&&a("span",{className:"inline-flex items-center align-middle mr-1.5 px-1.5 py-0.5 rounded text-xs font-mono font-bold bg-primary-foreground/20 text-primary-foreground",children:y}),se&&a("span",{children:se})]}),s.length>0&&g("div",{className:"mt-2.5 w-full",children:[a("div",{className:"text-xs font-medium text-primary-foreground/70 mb-1",children:Vb()}),a("div",{className:"flex flex-col gap-1.5 w-full",children:s.map((o)=>{let b=o.name||"file",P=Fi(b)||o.mediaType==="image"||o.mimeType?.startsWith("image/");return g("div",{className:B("group/att relative flex items-center w-full max-w-full rounded-lg border border-primary-foreground/15 bg-primary-foreground/10 hover:bg-primary-foreground/15 transition-colors overflow-hidden",P?"h-18 p-1.5 gap-2.5 cursor-pointer":"h-9 px-2.5 gap-2.5"),onClick:(L)=>{if(L.stopPropagation(),o.url)if(P)D({url:o.url,name:b});else window.open(o.url,"_blank","noreferrer")},children:[P&&o.url?a("div",{className:"h-full aspect-square rounded-md overflow-hidden bg-black/20 shrink-0",children:a("img",{src:o.url,alt:b,className:"w-full h-full object-cover group-hover/att:scale-105 transition-transform duration-200"})}):a(Er,{className:"w-4 h-4 text-primary-foreground/70 shrink-0"}),a("div",{className:"min-w-0 flex-1 overflow-hidden",children:a("p",{className:"text-xs font-medium text-primary-foreground truncate block w-full",title:b,children:b})}),o.url&&a("a",{href:o.url,target:"_blank",rel:"noreferrer",download:b,className:"p-1 text-primary-foreground/70 hover:text-primary-foreground shrink-0 rounded-md hover:bg-primary-foreground/20 transition-colors opacity-0 group-hover/att:opacity-100",onClick:(L)=>L.stopPropagation(),title:Dr(),children:a(Bt,{className:"w-3.5 h-3.5"})})]},o.id)})})]}),d.length>0&&g("div",{className:"mt-2.5 w-full",children:[a("div",{className:"text-xs font-medium text-primary-foreground/70 mb-1",children:jb()}),a("div",{className:"flex flex-col gap-1.5 w-full",children:d.map((o)=>g("div",{className:"flex items-center justify-between w-full h-9 px-2.5 rounded-lg border border-primary-foreground/15 bg-primary-foreground/10 hover:bg-primary-foreground/15 transition-colors overflow-hidden",children:[g("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[o.type==="folder"?a(xr,{className:"w-4 h-4 text-primary-foreground/70 shrink-0"}):a(Er,{className:"w-4 h-4 text-primary-foreground/70 shrink-0"}),a("span",{className:"text-xs font-medium truncate text-primary-foreground",title:o.name,children:o.name})]}),a("span",{className:"text-[10px] text-primary-foreground/60 uppercase shrink-0 font-mono ml-2",children:o.type})]},o.id))})]})]})},e.id)}let i=t.content||"";return a("div",{className:"text-center text-xs text-muted-foreground italic bg-muted/20 py-1.5 rounded",children:O(i)},e.id)}case"assistant":{let i=e.content;if(!i)return null;let r=[];if(i.forEach((s,n)=>{if(!s||typeof s!=="object")return;let u=s;switch(u.type){case"text":{let l=u.text;if(typeof l!=="string"||!l.trim())return;r.push(a("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:a(ts,{components:{pre:({node:x,...y})=>a("pre",{className:"whitespace-pre-wrap break-all break-words bg-muted text-foreground p-4 rounded-md border border-border/50 font-mono text-sm",...y})},children:oe(l)})},`txt-${n}`));break}case"thinking":{let l=u.thinking;if(typeof l!=="string"||!l.trim())return;r.push(g("details",{className:"group border border-border/50 rounded-lg bg-muted/20 my-2 overflow-hidden",children:[g("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/40 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[a(ae,{className:"h-3.5 w-3.5 text-primary/70 animate-pulse"}),a("span",{children:Wh()||"Thinking"}),a(Be,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),a("div",{className:"p-3 pt-0 text-xs text-muted-foreground/90 border-t border-border/40 bg-muted/10 leading-relaxed prose prose-sm dark:prose-invert max-w-none whitespace-pre-wrap font-sans",children:a(ts,{children:oe(l)})})]},`think-${n}`));break}case"toolCall":{let l=String(u.name||u.toolName||Jn()),x=u.arguments||u.args;r.push(g("details",{className:"group border border-border/50 rounded-lg bg-violet-500/5 my-2 overflow-hidden",children:[g("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-semibold text-violet-600 dark:text-violet-400 select-none cursor-pointer hover:bg-violet-500/10 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[a(rs,{className:"h-3.5 w-3.5"}),a("span",{children:Vm()}),a("span",{className:"font-mono bg-violet-500/10 px-1.5 py-0.5 rounded text-[11px] text-violet-700 dark:text-violet-300",children:l}),a(Be,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),!!x&&g("div",{className:"p-3 pt-0 text-[10px] text-muted-foreground/90 border-t border-border/40 bg-violet-500/5 font-sans",children:[a("div",{className:"text-[9px] text-muted-foreground/60 uppercase font-bold tracking-wider mb-1.5",children:dg()||"Arguments"}),a("pre",{className:"font-mono bg-muted/30 p-2 rounded border border-border/30 overflow-x-auto max-h-32",children:JSON.stringify(x,null,2)})]})]},`tool-${n}`));break}case"image":{let l=String(u.mimeType||"image/png"),x=String(u.data||"");r.push(a("div",{className:"my-2 max-w-full",children:x?a("img",{src:x.startsWith("data:")?x:`data:${l};base64,${x}`,alt:"Attached asset",className:"max-h-60 rounded border border-border/50 object-contain shadow-xs"}):a("div",{className:"text-xs text-muted-foreground italic flex items-center gap-1.5 py-1",children:mh()})},`img-${n}`));break}default:{let l=JSON.stringify(s,null,2);if(l==="{}")return;r.push(a("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:l},`other-${n}`))}}}),r.length===0)return null;let d=!1;if(i.length>0){let s=i[i.length-1];if(typeof s==="string"&&s.trim().length>0)d=!0;else if(s&&typeof s==="object"){let n=s;if(n.type==="text"&&typeof n.text==="string"&&n.text.trim().length>0)d=!0}}return g("div",{className:"flex flex-col w-full space-y-1",children:[a("div",{className:"space-y-2 w-full",children:r}),d&&a("div",{className:"text-[10px] text-muted-foreground self-start italic pt-1",children:dE()})]},e.id)}case"toolResult":return a("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/40 p-2 rounded-md border border-border/50",children:a("span",{className:"font-semibold",children:fg({name:e.toolName||"tool"})})},e.id);case"thinking_level_change":{let i=e.content||"";return a("div",{className:"text-center text-xs text-muted-foreground italic bg-muted/20 py-1.5 rounded",children:O(i)},e.id)}default:return null}};return g("div",{ref:ke,className:B("relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0"),children:[Ne&&a("div",{className:"absolute inset-0 bg-accent/30 border-2 border-primary z-50 pointer-events-none flex items-center justify-center p-6 text-center animate-in fade-in duration-150",children:g("div",{className:"bg-background/95 text-foreground px-4 py-3 rounded-xl border border-border/80 flex flex-col items-center gap-2 shadow-lg max-w-[80%] animate-in zoom-in-95 duration-150",children:[a($t,{className:"h-6 w-6 text-primary animate-bounce"}),a("span",{className:"text-sm font-semibold text-foreground",children:e_()})]})}),g("div",{className:"h-12 border-b border-border flex items-center justify-between px-4 flex-shrink-0 bg-background/50 backdrop-blur-sm",children:[g("div",{className:"flex items-center gap-2",children:[p&&a("button",{onClick:()=>A(!1),className:"p-1 rounded-md hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:fw(),children:a(Gd,{className:"h-4 w-4"})}),a($t,{className:"h-5 w-5 text-primary"}),a("span",{className:"font-semibold text-sm",children:p?B_():PR()})]}),a("div",{className:"flex items-center gap-1",children:!p?g(Y,{children:[a("button",{onClick:G,className:"p-1.5 rounded-md hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:s0(),children:a(Re,{className:"h-4 w-4"})}),a("button",{onClick:()=>A(!0),className:"p-1.5 rounded-md hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:B_(),children:a(ao,{className:"h-4 w-4"})})]}):g("button",{onClick:()=>{G(),A(!1)},className:"flex items-center gap-1 text-xs bg-primary text-primary-foreground px-2.5 py-1 rounded-md hover:bg-primary/90 transition-colors shadow-xs cursor-pointer",children:[a(Re,{className:"h-3.5 w-3.5"}),a("span",{children:s0()})]})})]}),p?a(Ie,{className:"flex-1 p-3",children:J.length===0?a("div",{className:"text-center text-xs text-muted-foreground py-8",children:aT()}):a("div",{className:"space-y-1",children:J.map((e)=>{let t=e.id===me;return g("div",{onClick:()=>{if(c)pe(c,e.id),A(!1)},className:B("group flex items-center justify-between p-2.5 rounded-lg text-xs cursor-pointer transition-all border border-transparent",t?"bg-accent/80 text-accent-foreground font-medium border-border/40":"hover:bg-muted/60 text-muted-foreground hover:text-foreground"),children:[g("div",{className:"flex flex-col min-w-0 pr-2",children:[a("span",{className:"truncate text-foreground font-medium text-xs",children:e.name||pg()}),a("span",{className:"text-[10px] text-muted-foreground",children:nn(e.updatedAt)})]}),a("button",{onClick:(i)=>{if(i.stopPropagation(),c&&window.confirm(ZE()))fe(c,e.id)},className:"opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded hover:bg-muted cursor-pointer",title:LE(),children:a(Ue,{className:"h-4 w-4"})})]},e.id)})})}):g(Y,{children:[a(Ie,{ref:E,className:"flex-1 p-4 min-h-0 [&>div>div]:!block",children:h.length===0?g("div",{className:"flex flex-col items-center justify-center h-48 border-2 border-dashed border-border rounded-lg text-muted-foreground p-4 text-center",children:[a($t,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),a("p",{className:"text-sm",children:e_()})]}):g("div",{className:"space-y-4 pb-4",children:[h.map(Se),_&&h.length>0&&(h[h.length-1].role==="user"||h[h.length-1].customType==="shumai_message")&&g("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground italic",children:[a(K,{className:"h-3 w-3 animate-spin text-primary"}),a("span",{children:VM()})]}),a("div",{ref:re})]})}),a("div",{className:"p-2 flex-shrink-0 bg-background",children:a(Bi,{projectId:m,value:he,onChangeText:ve,placeholder:bO(),disabled:!T||!c,isStreaming:_,onAbort:()=>{if(c)xe(c)},allowMentions:!1,allowAttachments:!0,workspaceAssets:ce,onRemoveWorkspaceAsset:ue,allowMarkup:!0,canMarkup:!!f&&["image","video","pdf"].includes(f.proxyType||""),markupDisabledTooltip:!f?RT():yh(),allowTimestamp:f?.proxyType==="video"||f?.proxyType==="pdf",currentTime:ne,frameRate:C||f?.media?.metadata?.frameRate||30,startTimecode:V||f?.media?.metadata?.startTimecode,formatTimestamp:I||(f?.proxyType==="pdf"?(e)=>y0({page:Math.round(e)}):void 0),onTyping:le,onSendMessage:(e,t,i,r,d,s)=>{if(!c)return;ge(c,e,m,k,_e,t,i,d,s)},bottomLeftExtra:a("div",{className:"flex items-center gap-1.5 min-w-0 max-w-full",children:N.length>0?g(Xe,{value:T||"",onValueChange:(e)=>j(e),disabled:_,children:[a(tt,{className:"h-8 border-none bg-transparent hover:bg-muted text-muted-foreground hover:text-foreground focus:ring-0 focus:ring-offset-0 px-2 py-0 gap-1.5 text-xs shrink-0 select-none shadow-none max-w-full cursor-pointer",children:a(et,{placeholder:Lp()})}),a(rt,{children:N.map((e)=>a(be,{value:e.id,className:"cursor-pointer",children:g("div",{className:"flex items-center gap-2",children:[e.avatar?a("img",{src:e.avatar,alt:e.name,className:"w-4 h-4 rounded-full object-cover"}):a($t,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-xs",children:e.name})]})},e.id))})]}):a("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] text-muted-foreground/60 italic select-none",children:a("span",{children:tT()})})})})})]}),q&&g("div",{className:"fixed inset-0 z-[100] bg-black/95 flex flex-col items-center justify-center p-4 animate-in fade-in duration-200",onClick:()=>D(null),children:[a("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white hover:bg-white/20 rounded-full p-2 transition-colors z-50 cursor-pointer",children:a(Ge,{className:"w-8 h-8"})}),a("div",{className:"w-full h-full flex items-center justify-center p-2",children:a("img",{src:q.url,alt:q.name,className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:(e)=>{e.stopPropagation(),D(null)}})}),a("div",{className:"absolute bottom-6 text-white text-sm font-medium bg-black/50 px-4 py-2 rounded-full backdrop-blur-sm",children:q.name})]})]})}
|
|
2
|
+
export{va};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{z}from"./chunk-zarz3sqn.js";var e=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Uo=z("users",e);
|
|
2
|
+
export{Uo};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{
|
|
1
|
+
import{z}from"./chunk-zarz3sqn.js";var a=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],al=z("save",a);
|
|
2
|
+
export{al};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function r(e){let t=e[e.length-1];return t&&t.role!=="user"?"agent":"user"}function
|
|
3
|
-
export{
|
|
2
|
+
function r(e){let t=e[e.length-1];return t&&t.role!=="user"?"agent":"user"}function Pa(e){return e.some((t)=>{if(t.role==="user"&&Array.isArray(t.content))return t.content.some((n)=>n.type==="image");if(t.role==="toolResult"&&Array.isArray(t.content))return t.content.some((n)=>n.type==="image");return!1})}function Da(e){let t={"X-Initiator":r(e.messages),"Openai-Intent":"conversation-edits"};if(e.hasImages)t["Copilot-Vision-Request"]="true";return t}
|
|
3
|
+
export{Pa,Da};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S,M,w,Z,Y,a,g,ie,kl,X,ee,We,Je,R,z,Ar,K,qe,Re,Ge,B,F,$e,He,Qe,De,Ne,Fe,de,Vy,Ky,Ub,Ke,Zw,eE,oE,Jm,Mt,DE,NE,qE,Ix,Xx,eC,bd,FS,ET,_1,w1,Ip,C1,S1,I1,T1,I0,k1,vk,Di,Cd,Jc,JR,Yc,Sd,Id,XR,Td,tM,PM,wO,CO,TO,kO,gg,kd,_t,yt,vt,bt,wt,Et,xt,Ct,Se,xe,ke,ot,Ce,Ot,re,Xt,j,Zy,fe,Ve,Fr}from"./chunk-zarz3sqn.js";import{vu}from"./chunk-8mqbztj8.js";import{fu}from"./chunk-8fyg9dy4.js";import{ll}from"./chunk-vkzasgxw.js";import{zo}from"./chunk-kvhf12b4.js";import{qn}from"./chunk-qwpkcp8d.js";import"./chunk-v5cn90cf.js";var Ie=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],V=z("arrow-down-wide-narrow",Ie);var _e=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],te=z("sliders-vertical",_e);Z();function ae({open:o,onOpenChange:l,mode:c,teamId:f,project:i}){let p=ie(),m=We(),[s,h]=w(""),[I,b]=w(!0),[_,y]=w(void 0),[k,v]=w(void 0),[u,C]=w(!1),x=M(null);S(()=>{if(o)if(c==="edit"&&i)h(i.name||""),y(i.coverImageKey),v(i.coverImage),b(i.enableNotification!==!1);else h(""),y(void 0),v(void 0),b(!0)},[o,c,i]);let P=R.api.teams[":teamId"].projects.$post,{mutate:U}=ee({mutationFn:async(n)=>{let r=await P({param:{teamId:f},json:n});if(!r.ok)throw Error(Ix());return await r.json()},onSuccess:(n)=>{p.invalidateQueries({queryKey:["teams",f,"projects"]}),l(!1);let r=n;if(r&&typeof r.id==="string")m({to:"/projects/$projectId",params:{projectId:r.id}})}}),A=R.api.projects[":projectId"].$put,{mutate:O}=ee({mutationFn:async(n)=>{let r=await A({param:{projectId:i.id},json:n});if(!r.ok)throw Error(Xx());return await r.json()},onSuccess:()=>{p.invalidateQueries({queryKey:["teams",f,"projects"]}),l(!1)}}),Q=R.api.teams[":teamId"].files.$post,{mutate:E}=ee({mutationFn:async({file:n})=>{let r=await Q({param:{teamId:f},form:{file:n}});if(!r.ok)throw Error(bd());return await r.json()},onSuccess:(n)=>{let r=n;if(r&&typeof r.key==="string")y(r.key);C(!1)},onError:()=>{C(!1)}}),d=(n)=>{let r=n.target.files?.[0];if(r){C(!0);let H=URL.createObjectURL(r);v(H),E({file:r})}},N=()=>{x.current?.click()},T=(n)=>{n.stopPropagation(),y(void 0),v(void 0)},D=()=>{if(!s.trim())return;if(c==="create")U({name:s.trim(),coverImageKey:_,enableNotification:I});else if(c==="edit"&&i?.id)O({name:s.trim(),coverImageKey:_,enableNotification:I})};return a(Se,{open:o,onOpenChange:l,children:g(xe,{className:"sm:max-w-[550px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 backdrop-blur-md shadow-2xl p-0 gap-0",children:[g(ke,{className:"relative overflow-hidden bg-gradient-to-br from-primary/5 to-transparent p-6 border-b border-border/40",children:[a("div",{className:"absolute top-0 right-0 w-24 h-24 bg-primary/10 rounded-full blur-2xl pointer-events-none"}),a("div",{className:"absolute bottom-0 left-10 w-32 h-12 bg-primary/5 rounded-full blur-xl pointer-events-none"}),a("div",{className:"flex items-center gap-3",children:g("div",{children:[a(Ce,{className:"text-xl font-semibold tracking-tight text-foreground",children:c==="create"?oE():I0()}),a(Ot,{className:"text-xs text-muted-foreground/80 mt-1",children:c==="create"?Zw():FS()})]})})]}),g("div",{className:"space-y-6 p-6 max-h-[75vh] overflow-y-auto",children:[g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"name",className:"text-sm font-semibold tracking-tight text-foreground",children:Ip()}),g("div",{className:"relative",children:[a(re,{id:"name",value:s,onChange:(n)=>h(n.target.value),placeholder:S1(),className:"h-11 px-4 rounded-xl border-border/80 focus-visible:ring-ring/25 focus-visible:border-primary transition-all shadow-xs pr-10"}),s.trim()&&a("div",{className:"absolute inset-y-0 right-3 flex items-center",children:a(qe,{className:"w-4 h-4 text-primary"})})]}),a("p",{className:"text-[11px] text-muted-foreground",children:C1()})]}),g("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[g("div",{className:"flex items-center justify-between",children:[g(fe,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[a(qn,{className:"w-4 h-4 text-primary"}),w1()]}),k&&g("button",{type:"button",onClick:T,className:"text-xs text-muted-foreground hover:text-destructive hover:bg-destructive/5 px-2.5 py-1 rounded-lg transition-all flex items-center gap-1 font-medium",children:[a(Ge,{className:"w-3.5 h-3.5"}),vk()]})]}),g("div",{className:"relative aspect-square w-48 mx-auto rounded-2xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 transition-all duration-300 hover:border-primary/50 hover:bg-muted/40",onClick:N,children:[a("input",{type:"file",ref:x,className:"hidden",accept:"image/*",onChange:d}),u&&a("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:g("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[a(K,{className:"w-4 h-4 animate-spin text-primary"}),a("span",{className:"text-xs font-semibold text-foreground",children:kd()})]})}),k?g(Y,{children:[a("img",{src:k,alt:eE(),className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),g("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1.5 text-white z-10",children:[a(zo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),a("span",{className:"text-xs font-semibold",children:gg()})]})]}):g("div",{className:"flex flex-col items-center gap-2 text-center p-4",children:[a("div",{className:"p-2.5 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:a(zo,{className:"w-4 h-4 text-muted-foreground"})}),g("div",{children:[a("p",{className:"text-xs font-medium text-foreground",children:TO()}),a("p",{className:"text-[11px] text-muted-foreground mt-0.5 max-w-[140px] mx-auto leading-normal",children:kO()})]})]})]})]}),g("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[g(fe,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[a(te,{className:"w-4 h-4 text-primary"}),T1()]}),g("div",{className:"flex items-start justify-between rounded-xl border border-border/50 bg-muted/10 p-4 transition-all duration-300 hover:bg-muted/20",children:[g("div",{className:"space-y-1 pr-4",children:[g("div",{className:"text-sm font-semibold flex items-center gap-2 text-foreground",children:[a(ll,{className:"w-4 h-4 text-primary"}),Vy()]}),a("p",{className:"text-xs text-muted-foreground leading-normal",children:Ky()})]}),a(Ve,{checked:I,onCheckedChange:b,disabled:u,className:"mt-0.5"})]})]})]}),g(ot,{className:"flex items-center justify-end gap-3 px-6 py-4 bg-muted/20 border-t border-border/40",children:[a(F,{type:"button",variant:"ghost",onClick:()=>l(!1),disabled:u,className:"rounded-xl h-10 px-4 hover:bg-muted font-medium text-sm text-muted-foreground hover:text-foreground transition-colors",children:Ke()}),a(F,{type:"submit",onClick:D,disabled:!s.trim()||u,className:"rounded-xl h-10 px-5 bg-primary text-primary-foreground hover:bg-primary/90 font-semibold text-sm shadow-lg shadow-primary/10 hover:shadow-primary/20 active:scale-98 transition-all flex items-center gap-2",children:u?g(Y,{children:[a(K,{className:"w-4 h-4 animate-spin"}),_1()]}):c==="create"?Jm():Di()})]})]})})}function se({sortBy:o,sortDirection:l,onSortChange:c}){let f=(s)=>{c(s,l)},i=()=>{c(o,l==="asc"?"desc":"asc")},p=(s)=>{switch(s){case"name":return Yc();case"created_at":return JR();case"updated_at":return XR();default:return s}},m=l==="asc";return g(De,{children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",className:"gap-2 bg-muted/50",children:[a("span",{className:"text-muted-foreground",children:tM()}),a("span",{className:"font-medium text-foreground",children:p(o)})]})}),g(Fe,{align:"end",className:"w-56 p-2",children:[a("div",{className:"text-xs font-semibold text-muted-foreground mb-2 px-2",children:Jc()}),g(De,{children:[a(Ne,{asChild:!0,children:g(F,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted mb-2 border",children:[a("span",{children:p(o)}),a(V,{className:"h-4 w-4 opacity-50"})]})}),a(Fe,{className:"w-52",children:["name","created_at","updated_at"].map((s)=>g(de,{onClick:()=>f(s),className:"justify-between",children:[p(s),o===s&&a(qe,{className:"h-4 w-4"})]},s))})]}),g(F,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted border",onClick:i,children:[a("span",{className:"text-muted-foreground",children:o==="name"?m?a(Y,{children:Cd()}):a(Y,{children:Td()}):m?a(Y,{children:Id()}):a(Y,{children:Sd()})}),m?a(fu,{className:"h-4 w-4 opacity-50"}):a(V,{className:"h-4 w-4 opacity-50"})]})]})]})}Z();function Me(){let{teamId:o}=Pe.useParams(),{canEdit:l,canAdmin:c}=Xt(),f=We(),i=ie(),[p,m]=w(null),[s,h]=w(!1),[I,b]=w("create"),[_,y]=w(void 0),[k,v]=w(!1),[u,C]=w(void 0),[x,P]=w(""),[U,A]=w(!1),{metadata:O,setMetadata:Q}=Fr(),E=`team:${o}:projects:sort`,d=O[E],[N,T]=w(()=>d?.sortBy||"name"),[D,n]=w(()=>d?.sortDirection||"asc");S(()=>{if(d?.sortBy&&d.sortBy!==N)T(d.sortBy);if(d?.sortDirection&&d.sortDirection!==D)n(d.sortDirection)},[d]);let r=R.api.teams[":teamId"].projects.$get,{data:H}=X({queryKey:["teams",o,"projects",N,D],queryFn:async()=>{let e=await r({param:{teamId:o},query:{sortBy:N,sortDirection:D}});if(!e.ok)throw Error("Failed to fetch projects");return await e.json()},placeholderData:kl}),{data:W}=X({queryKey:["teams",o,"members"],queryFn:async()=>{let e=await R.api.teams[":teamId"].members.$get({param:{teamId:o},query:{}});if(!e.ok)throw Error("Failed to fetch members");return await e.json()}}),{data:G}=X({queryKey:["teams",o,"me"],queryFn:async()=>{let e=await R.api.teams[":teamId"].me.$get({param:{teamId:o}});if(!e.ok)throw Error("Failed to fetch me");return await e.json()}}),ne=R.api.teams[":teamId"].invite.$post,le=ee({mutationFn:async(e)=>{let t=await ne(e);if(!t.ok)throw Error("Failed to invite");return await t.json()}}),q=ee({mutationFn:async(e)=>{if(!(await R.api.projects[":projectId"].$delete({param:{projectId:e}})).ok)throw Error("Failed to delete project")},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",o,"projects"]})}}),ce=ee({mutationFn:async(e)=>{let t=await R.api.projects[":projectId"].$put({param:{projectId:e.id},json:{enableNotification:!e.enableNotification}});if(!t.ok)throw Error("Failed to update project notification settings");return await t.json()},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",o,"projects"]}),j.success(I1())},onError:(e)=>{j.error(e instanceof Error?e.message:eC())}}),J=()=>{b("create"),y(void 0),h(!0)},me=()=>{m("create"),setTimeout(()=>{m(null)},100),setTimeout(()=>{J()},200)},pe=(e)=>{b("edit"),y(e),h(!0)},ue=(e)=>{C(e),P(""),v(!0)},ge=async()=>{if(u&&x==="delete")try{await q.mutateAsync(u.id),v(!1)}catch(e){console.error(e)}},ve=(e,t)=>{if(t.detail>1)return;m(e),setTimeout(()=>{m(null)},100),setTimeout(()=>{f({to:"/projects/$projectId",params:{projectId:e}})},200)},he=async(e)=>(await le.mutateAsync({param:{teamId:o},json:{role:e}})).code,ye=ee({mutationFn:async({userId:e,role:t})=>{if(!(await R.api.teams[":teamId"].members[":userId"].$patch({param:{teamId:o,userId:e},json:{role:t}})).ok)throw Error("Failed to update member role")},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",o,"members"]})}}),be=ee({mutationFn:async(e)=>{if(!(await R.api.teams[":teamId"].members[":userId"].$delete({param:{teamId:o,userId:e}})).ok)throw Error("Failed to remove member")},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",o,"members"]})}}),we=(e)=>{if(!e)return"??";return e.split(" ").map((t)=>t[0]).slice(0,2).join("").toUpperCase()},je=(e,t)=>{T(e),n(t),Q(o,E,{sortBy:e,sortDirection:t})},L=Array.isArray(W)?W:[];return g("div",{className:"flex-1 overflow-y-auto p-4",children:[g("div",{className:"flex flex-wrap items-center justify-between mb-4 gap-4",children:[a("h1",{className:"text-2xl font-bold",children:k1()}),g("div",{className:"flex flex-wrap items-center gap-4",children:[g("div",{className:"flex items-center -space-x-2 cursor-pointer hover:opacity-90",onClick:()=>A(!0),"data-testid":"team-members-trigger",children:[L.slice(0,3).map((e)=>g($e,{className:"border-2 border-background w-8 h-8",children:[e.image&&a(He,{src:e.image,alt:e.name,className:"object-cover"}),a(Qe,{className:"text-[10px]",children:we(e.name)})]},e.id)),L.length>3&&g("div",{className:"flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium",children:["+",L.length-3]})]}),a(se,{sortBy:N,sortDirection:D,onSortChange:je}),l&&g(F,{className:"bg-orange-600 hover:bg-orange-700 text-white gap-2",onClick:J,children:[a(Re,{className:"w-4 h-4"}),Jm()]})]})]}),g("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4",children:[H?.data?.map((e)=>a("div",{className:B("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out",p===e.id?"scale-95":"scale-100"),onClick:(t)=>ve(e.id,t),children:g("div",{className:"flex flex-col",children:[g("div",{className:"relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20",children:[e.coverImage?a("img",{src:e.coverImage,alt:e.name,className:"w-full h-full object-cover rounded"}):g("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 180.95 164.7",preserveAspectRatio:"xMidYMid slice",className:"w-full h-full object-cover rounded",children:[a("polygon",{fill:"#FC9F8E",points:"0 18.5 0 76.0 151.69 164.7 180.95 164.7 180.95 113.6"}),a("polygon",{fill:"#FEBAB8",points:"0 0 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0"}),a("polyline",{fill:"#FAA5A5",points:"0 18.5 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0 0 0"}),a("polygon",{fill:"#EC5B6C",points:"0 76.0 0 164.7 151.69 164.7"}),a("polygon",{fill:"#E85C71",points:"180.95 18.9 110.33 63.9 117.37 68.0 117.26 73.4 180.95 113.6"}),a("polygon",{fill:"#C8405B",points:"117.26 73.4 117.37 99.0 90.53 114.9 174.35 164.7 180.95 164.7 180.95 113.6"}),a("polygon",{fill:"#FFCCBE",points:"90.53 51.6 63.69 68.1 90.53 83.4"}),a("path",{fill:"#FB9991",d:"M 90.53 51.6 L 90.53 61.3 L 100.87 67.4 L 90.53 73.5 L 90.53 83.4 L 117.37 68.0 C 117.15 67.6 90.53 51.6 90.53 51.6 Z"}),a("path",{fill:"#FFEACD",d:"M 63.69 68.1 C 63.47 68.5 64.02 99.3 64.02 99.3 C 64.02 99.3 64.46 99.6 64.9 99.9 L 90.53 83.4 L 63.69 68.1 Z"}),a("polygon",{fill:"#FFCFB5",points:"64.02 99.3 90.53 114.9 90.53 83.4"}),a("path",{fill:"#F67D73",d:"M 90.53 83.4 L 90.53 114.9 L 117.37 99.0 Z"}),a("path",{fill:"#F26560",d:"M 90.53 83.4 L 117.37 99.0 L 117.37 68.0 Z"}),a("polygon",{fill:"#EB5F5B",points:"80.08 67.5 90.53 73.5 90.53 61.3"}),a("polygon",{fill:"#DB4D50",points:"90.53 61.3 90.53 73.5 100.87 67.4"})]}),a("div",{className:"absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0"}),a("p",{className:"absolute left-1 bottom-2 text-white",children:e.name})]}),g("div",{className:"px-2 h-10 flex justify-between items-center",children:[g("p",{className:"truncate pr-1 text-xs text-muted-foreground",children:[CO()," ",Zy(e.updatedAt??"")]}),a("div",{onClick:(t)=>t.stopPropagation(),children:g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:a("button",{className:"hover:bg-muted outline-none flex px-1",children:a(Ar,{className:"w-5 h-5 text-muted-foreground"})})}),g(Fe,{align:"end",children:[l&&a(de,{onClick:(t)=>{t.stopPropagation(),pe(e)},children:I0()}),g(de,{className:"flex items-center justify-between gap-4 cursor-pointer",onSelect:(t)=>{t.preventDefault(),ce.mutate(e)},children:[a("span",{children:ET()}),a(Ve,{checked:e.enableNotification??!0,className:"pointer-events-none"})]}),c&&a(de,{className:"text-destructive focus:text-destructive",onClick:()=>ue(e),children:Mt()})]})]})})]})]})},e.id)),l&&a("div",{className:B("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group",p==="create"?"scale-95":"scale-100"),onClick:me,children:g("div",{className:"flex flex-col",children:[a("div",{className:"relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors",children:a(Re,{className:"w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors"})}),a("div",{className:"px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors",children:a("p",{className:"text-sm text-muted-foreground group-hover:text-orange-600 transition-colors",children:Jm()})})]})})]}),a(ae,{open:s,onOpenChange:h,mode:I,teamId:o,project:_}),a(_t,{open:k,onOpenChange:v,children:g(yt,{children:[g(vt,{children:[a(wt,{children:Ub()}),g(Et,{children:[NE({name:u?.name??""}),g("div",{className:"mt-4 flex flex-col gap-2 text-foreground",children:[a("span",{className:"text-sm font-medium",children:wO()}),a(re,{value:x,onChange:(e)=>P(e.target.value),placeholder:DE(),className:"h-9",autoFocus:!0})]})]})]}),g(bt,{children:[a(Ct,{disabled:q.isPending,children:Ke()}),a(xt,{onClick:(e)=>{e.preventDefault(),ge()},disabled:x!=="delete"||q.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:q.isPending?qE():Mt()})]})]})}),a(vu,{open:U,onOpenChange:A,title:PM(),type:"team",members:L,isOwner:G?.role==="owner",onInvite:he,onUpdateRole:async(e,t)=>{await ye.mutateAsync({userId:e,role:t})},onRemoveMember:async(e)=>{await be.mutateAsync(e)},currentUserId:G?.id})]})}var Pe=Je("/teams/$teamId/")({component:Me});export{Pe as Route};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Yt}from"./chunk-9xhjy897.js";import{at}from"./chunk-e4yscwen.js";import{se}from"./chunk-2jj4j8cn.js";var i=se(at());var t=se(at());import{exec as u}from"child_process";import{promisify as w}from"util";var a=se(Yt()),p=(r,e,o)=>{if(e.Version!==1)throw Error(`Profile ${r} credential_process did not return Version 1.`);if(e.AccessKeyId===void 0||e.SecretAccessKey===void 0)throw Error(`Profile ${r} credential_process returned invalid credentials.`);if(e.Expiration){let d=new Date;if(new Date(e.Expiration)<d)throw Error(`Profile ${r} credential_process returned expired credentials.`)}let s=e.AccountId;if(!s&&o?.[r]?.aws_account_id)s=o[r].aws_account_id;let n={accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,...e.SessionToken&&{sessionToken:e.SessionToken},...e.Expiration&&{expiration:new Date(e.Expiration)},...e.CredentialScope&&{credentialScope:e.CredentialScope},...s&&{accountId:s}};return a.setCredentialFeature(n,"CREDENTIALS_PROCESS","w"),n};var f=async(r,e,o)=>{let s=e[r];if(e[r]){let n=s.credential_process;if(n!==void 0){let d=w(t.externalDataInterceptor?.getTokenRecord?.().exec??u);try{let{stdout:c}=await d(n),l;try{l=JSON.parse(c.trim())}catch{throw Error(`Profile ${r} credential_process returned invalid JSON.`)}return p(r,l,e)}catch(c){throw new t.CredentialsProviderError(c.message,{logger:o})}}else throw new t.CredentialsProviderError(`Profile ${r} did not contain credential_process.`,{logger:o})}else throw new t.CredentialsProviderError(`Profile ${r} could not be found in shared credentials file.`,{logger:o})};var P=(r={})=>async({callerClientConfig:e}={})=>{r.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let o=await i.parseKnownFiles(r);return f(i.getProfileName({profile:r.profile??e?.profile}),o,r.logger)};export{P as fromProcess};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ae}from"./chunk-2jj4j8cn.js";var n=null;function c(e){if(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)return;if(n===null){n=new Map;try{let{readFileSync:t}=ae("fs"),s=t("/proc/self/environ","utf-8");for(let r of s.split("\x00")){let o=r.indexOf("=");if(o>0)n.set(r.slice(0,o),r.slice(o+1))}}catch{}}return n.get(e)}function kr(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||c(e)||void 0}
|
|
3
|
+
export{kr};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{L,ae}from"./chunk-2jj4j8cn.js";var ic=L(function(ar,m){var{defineProperty:k,getOwnPropertyDescriptor:ee,getOwnPropertyNames:re}=Object,te=Object.prototype.hasOwnProperty,oe=(e,r)=>{for(var t in r)k(e,t,{get:r[t],enumerable:!0})},ne=(e,r,t,n)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let o of re(r))if(!te.call(e,o)&&o!==t)k(e,o,{get:()=>r[o],enumerable:!(n=ee(r,o))||n.enumerable})}return e},se=(e)=>ne(k({},"__esModule",{value:!0}),e),T={};oe(T,{VercelOidcTokenError:()=>E});m.exports=se(T);class E extends Error{constructor(e,r){super(e);this.name="VercelOidcTokenError",this.cause=r}toString(){if(this.cause)return`${this.name}: ${this.message}: ${this.cause}`;return`${this.name}: ${this.message}`}}});var cm=L(function(cr,S){var{defineProperty:y,getOwnPropertyDescriptor:ie,getOwnPropertyNames:ce}=Object,ue=Object.prototype.hasOwnProperty,pe=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},le=(e,r,t,n)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let o of ce(r))if(!ue.call(e,o)&&o!==t)y(e,o,{get:()=>r[o],enumerable:!(n=ie(r,o))||n.enumerable})}return e},fe=(e)=>le(y({},"__esModule",{value:!0}),e),D={};pe(D,{AccessTokenMissingError:()=>x,RefreshAccessTokenFailedError:()=>A});S.exports=fe(D);class x extends Error{constructor(){super("No authentication found. Please log in with the Vercel CLI (vercel login).");this.name="AccessTokenMissingError"}}class A extends Error{constructor(e){super("Failed to refresh authentication token.",{cause:e});this.name="RefreshAccessTokenFailedError"}}});var M=L(function(ur,R){var{create:_e,defineProperty:_,getOwnPropertyDescriptor:de,getOwnPropertyNames:he,getPrototypeOf:ve}=Object,ke=Object.prototype.hasOwnProperty,ye=(e,r)=>{for(var t in r)_(e,t,{get:r[t],enumerable:!0})},V=(e,r,t,n)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let o of he(r))if(!ke.call(e,o)&&o!==t)_(e,o,{get:()=>r[o],enumerable:!(n=de(r,o))||n.enumerable})}return e},g=(e,r,t)=>(t=e!=null?_e(ve(e)):{},V(r||!e||!e.__esModule?_(t,"default",{value:e,enumerable:!0}):t,e)),we=(e)=>V(_({},"__esModule",{value:!0}),e),C={};ye(C,{findRootDir:()=>Pe,getUserDataDir:()=>be});R.exports=we(C);var p=g(ae("path")),ge=g(ae("fs")),w=g(ae("os")),Oe=ic();function Pe(){try{let e=process.cwd();while(e!==p.default.dirname(e)){let r=p.default.join(e,".vercel");if(ge.default.existsSync(r))return e;e=p.default.dirname(e)}}catch(e){throw new Oe.VercelOidcTokenError("Token refresh only supported in node server environments")}return null}function be(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(w.default.platform()){case"darwin":return p.default.join(w.default.homedir(),"Library/Application Support");case"linux":return p.default.join(w.default.homedir(),".local/share");case"win32":if(process.env.LOCALAPPDATA)return process.env.LOCALAPPDATA;return null;default:return null}}});var B=L(function(pr,J){var{create:je,defineProperty:d,getOwnPropertyDescriptor:Te,getOwnPropertyNames:Ee,getPrototypeOf:me}=Object,De=Object.prototype.hasOwnProperty,xe=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},I=(e,r,t,n)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let o of Ee(r))if(!De.call(e,o)&&o!==t)d(e,o,{get:()=>r[o],enumerable:!(n=Te(r,o))||n.enumerable})}return e},N=(e,r,t)=>(t=e!=null?je(me(e)):{},I(r||!e||!e.__esModule?d(t,"default",{value:e,enumerable:!0}):t,e)),Ae=(e)=>I(d({},"__esModule",{value:!0}),e),q={};xe(q,{isValidAccessToken:()=>Re,readAuthConfig:()=>Ve,writeAuthConfig:()=>Ce});J.exports=Ae(q);var l=N(ae("fs")),F=N(ae("path")),Se=ac();function U(){let e=(0,Se.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return F.join(e,"auth.json")}function Ve(){try{let e=U();if(!l.existsSync(e))return null;let r=l.readFileSync(e,"utf8");if(!r)return null;return JSON.parse(r)}catch(e){return null}}function Ce(e){let r=U(),t=F.dirname(r);if(!l.existsSync(t))l.mkdirSync(t,{mode:504,recursive:!0});l.writeFileSync(r,JSON.stringify(e,null,2),{mode:384})}function Re(e,r=0){if(!e.token)return!1;if(typeof e.expiresAt!=="number")return!0;let t=Math.floor(Date.now()/1000),n=r/1000;return e.expiresAt>=t+n}});var X=L(function(lr,G){var{defineProperty:b,getOwnPropertyDescriptor:Me,getOwnPropertyNames:Ie}=Object,Ne=Object.prototype.hasOwnProperty,qe=(e,r)=>{for(var t in r)b(e,t,{get:r[t],enumerable:!0})},Fe=(e,r,t,n)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let o of Ie(r))if(!Ne.call(e,o)&&o!==t)b(e,o,{get:()=>r[o],enumerable:!(n=Me(r,o))||n.enumerable})}return e},$e=(e)=>Fe(b({},"__esModule",{value:!0}),e),H={};qe(H,{processTokenResponse:()=>He,refreshTokenRequest:()=>Be});G.exports=$e(H);var O=ae("os"),Ue="https://vercel.com",Je="cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp",z=`@vercel/oidc node-${process.version} ${(0,O.platform)()} (${(0,O.arch)()}) ${(0,O.hostname)()}`,P=null;async function Le(){if(P)return P;let e=`${Ue}/.well-known/openid-configuration`,r=await fetch(e,{headers:{"user-agent":z}});if(!r.ok)throw Error("Failed to discover OAuth endpoints");let t=await r.json();if(!t||typeof t.token_endpoint!=="string")throw Error("Invalid OAuth discovery response");let n=t.token_endpoint;return P=n,n}async function Be(e){let r=await Le();return await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","user-agent":z},body:new URLSearchParams({client_id:Je,grant_type:"refresh_token",...e})})}async function He(e){let r=await e.json();if(!e.ok){let t=typeof r==="object"&&r&&"error"in r?String(r.error):"Token refresh failed";return[Error(t)]}if(typeof r!=="object"||r===null)return[Error("Invalid token response")];if(typeof r.access_token!=="string")return[Error("Missing access_token in response")];if(r.token_type!=="Bearer")return[Error("Invalid token_type in response")];if(typeof r.expires_in!=="number")return[Error("Missing expires_in in response")];return[null,r]}});var ac=L(function(fr,W){var{create:ze,defineProperty:h,getOwnPropertyDescriptor:Ge,getOwnPropertyNames:Xe,getPrototypeOf:Ye}=Object,Qe=Object.prototype.hasOwnProperty,Ze=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},Q=(e,r,t,n)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let o of Xe(r))if(!Qe.call(e,o)&&o!==t)h(e,o,{get:()=>r[o],enumerable:!(n=Ge(r,o))||n.enumerable})}return e},Z=(e,r,t)=>(t=e!=null?ze(Ye(e)):{},Q(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),Ke=(e)=>Q(h({},"__esModule",{value:!0}),e),K={};Ze(K,{assertVercelOidcTokenResponse:()=>j,findProjectInfo:()=>tr,getTokenPayload:()=>sr,getVercelDataDir:()=>We,getVercelOidcToken:()=>rr,getVercelToken:()=>er,isExpired:()=>ir,loadToken:()=>nr,saveToken:()=>or});W.exports=Ke(K);var f=Z(ae("path")),s=Z(ae("fs")),u=ic(),v=M(),a=B(),Y=X(),c=cm();function We(){let r=(0,v.getUserDataDir)();if(!r)return null;return f.join(r,"com.vercel.cli")}async function er(e){let r=(0,a.readAuthConfig)();if(!r?.token)throw new c.AccessTokenMissingError;if((0,a.isValidAccessToken)(r,e?.expirationBufferMs))return r.token;if(!r.refreshToken)throw(0,a.writeAuthConfig)({}),new c.RefreshAccessTokenFailedError("No refresh token available");try{let t=await(0,Y.refreshTokenRequest)({refresh_token:r.refreshToken}),[n,o]=await(0,Y.processTokenResponse)(t);if(n||!o)throw(0,a.writeAuthConfig)({}),new c.RefreshAccessTokenFailedError(n);let i={token:o.access_token,expiresAt:Math.floor(Date.now()/1000)+o.expires_in};if(o.refresh_token)i.refreshToken=o.refresh_token;return(0,a.writeAuthConfig)(i),i.token}catch(t){if((0,a.writeAuthConfig)({}),t instanceof c.AccessTokenMissingError||t instanceof c.RefreshAccessTokenFailedError)throw t;throw new c.RefreshAccessTokenFailedError(t)}}async function rr(e,r,t){let n=`https://api.vercel.com/v1/projects/${r}/token?source=vercel-oidc-refresh${t?`&teamId=${t}`:""}`,o=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!o.ok)throw new u.VercelOidcTokenError(`Failed to refresh OIDC token: ${o.statusText}`);let i=await o.json();return j(i),i}function j(e){if(!e||typeof e!=="object")throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!("token"in e)||typeof e.token!=="string")throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function tr(){let e=(0,v.findRootDir)();if(!e)throw new u.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let r=f.join(e,".vercel","project.json");if(!s.existsSync(r))throw new u.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let t=JSON.parse(s.readFileSync(r,"utf8"));if(typeof t.projectId!=="string"&&typeof t.orgId!=="string")throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:t.projectId,teamId:t.orgId}}function or(e,r){let t=(0,v.getUserDataDir)();if(!t)throw new u.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let n=f.join(t,"com.vercel.token",`${r}.json`),o=JSON.stringify(e);s.mkdirSync(f.dirname(n),{mode:504,recursive:!0}),s.writeFileSync(n,o),s.chmodSync(n,432);return}function nr(e){let r=(0,v.getUserDataDir)();if(!r)throw new u.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let t=f.join(r,"com.vercel.token",`${e}.json`);if(!s.existsSync(t))return null;let n=JSON.parse(s.readFileSync(t,"utf8"));return j(n),n}function sr(e){let r=e.split(".");if(r.length!==3)throw new u.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let t=r[1].replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(t.length+(4-t.length%4)%4,"=");return JSON.parse(Buffer.from(n,"base64").toString("utf8"))}function ir(e,r=0){return e.exp*1000<Date.now()+r}});
|
|
3
|
+
export{ic,cm,ac};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Pr,ra,sd,e,I,E,N,W,A,l,D,k,v,y}from"./chunk-2cdxm1cp.js";function ml(t){return{ok:!0,value:t}}function Fs(t){return{ok:!1,error:t}}async function V(t){let n=await t;if(!n.ok)throw n.error;return n.value}class C extends Error{rawValue;rawMessage;static[Symbol.hasInstance](t){if(!(t instanceof Error))return!1;if(!("rawValue"in t))return!1;if(!("rawMessage"in t))return!1;if(!("pretty"in t))return!1;if(typeof t.pretty!=="function")return!1;return!0}constructor(t,n,o){super(`${t}: ${n}`);this.name="SDKValidationError",this.cause=n,this.rawValue=o,this.rawMessage=t}pretty(){if(this.cause instanceof ra)return`${this.rawMessage}
|
|
3
|
+
${om(this.cause)}`;else return this.toString()}}function om(t){return sd(t)}function b(t,n){let o={};if(!Object.keys(n).length)return o=t,o;for(let[i,r]of Object.entries(t)){let a=n[i];if(a===null)continue;o[a??i]=r}return o}function O(t){let n={};for(let[o,i]of Object.entries(t))if(typeof i<"u")n[o]=i;return n}function P(t,n,o){try{return ml(n(t))}catch(i){return Fs(new C(o,i,t))}}function J(t){return d++,t}var d=0,U=0;function h(){U++;let t=d;return{end:(n)=>{let o=d-t;if(d=t+(n??o),--U===0)d=0;return o}}}function me(t){let n=Object.values(t);return D([...n.map((o)=>v(o)),e().transform((o)=>J(o))])}function nc(t){let n=Object.values(t).filter((o)=>typeof o==="number");return D([...n.map((o)=>v(o)),I().transform((o)=>J(o))])}function Lt(t){return e()}function Ng(t){return I()}var T=Symbol("UNKNOWN");function j(t){return typeof t==="object"&&t!==null&&T in t}function gt(t,n,o={}){let{unknownValue:i="UNKNOWN",outputPropertyName:r}=o;return W().transform((a)=>{let s=Object.defineProperties({raw:a,[r??t]:i,isUnknown:!0},{[T]:{value:!0,enumerable:!1,configurable:!1}});if(!(typeof a==="object"&&a!==null))return s;let m=a[t];if(typeof m!=="string")return s;if(!(m in n))return s;let g=n[m];if(!g)return s;let p=h(),f=g.safeParse(a);if(!f.success)return p.end(0),s;if(p.end(),r)f.data[r]=m;return f.data})}var w=/^\d{4}-\d{2}-\d{2}$/;class x{serialized;static today(){return new x(new Date)}constructor(t){if(typeof t==="string"&&!w.test(t))throw RangeError("RFCDate: date strings must be in the format YYYY-MM-DD: "+t);let n=new Date(t);if(isNaN(+n))throw RangeError("RFCDate: invalid date provided: "+t);if(this.serialized=n.toISOString().slice(0,10),!w.test(this.serialized))throw TypeError(`RFCDate: failed to build valid date with given value: ${t} serialized to ${this.serialized}`)}toJSON(){return this.toString()}toString(){return this.serialized}}function q(t){return W().transform((n,o)=>{let i=[],r=t.map(()=>[]),a=h();for(let[c,m]of t.entries()){let g=h(),p=m.safeParse(n),f=g.end(),re=0;if(p.success){i.push({data:p.data,inexactCount:f,zeroDefaultCount:0,fieldCount:-1});continue}r[c].push(...p.error.issues)}if(i.length===0)return a.end(0),o.addIssue({input:n,code:"invalid_union",errors:r}),Pr;let s=i[0];for(let c of i){if(i.length>1)c.fieldCount=te(c.data);s=ee(c,s)}return a.end(s.inexactCount),s.data})}function ee(t,n){let o=t.inexactCount===0,i=n.inexactCount===0;if(o!==i)return o?t:n;let r=t.fieldCount-t.zeroDefaultCount,a=n.fieldCount-n.zeroDefaultCount;if(r!==a)return r>a?t:n;return t.inexactCount<n.inexactCount?t:n}function te(t){let n=0,o=[t],i=0;while(i<o.length){let r=o[i++];if(r===void 0||j(r))continue;let a=typeof r;if(r===null||a==="number"||a==="string"||a==="boolean"||a==="bigint"||r instanceof Date||r instanceof x){n++;continue}if(Array.isArray(r)){o.push(...r);continue}if(a==="object")o.push(...Object.values(r))}return n}var L=l({type:v("input_audio"),input_audio:e()}).transform((t)=>b(t,{input_audio:"inputAudio"})),M=l({type:v("input_audio"),inputAudio:e()}).transform((t)=>b(t,{inputAudio:"input_audio"}));var Ta=l({type:v("document_url").default("document_url"),document_url:e(),document_name:y(e()).optional()}).transform((t)=>b(t,{document_url:"documentUrl",document_name:"documentName"})),Ui=l({type:v("document_url").default("document_url"),documentUrl:e(),documentName:y(e()).optional()}).transform((t)=>b(t,{documentUrl:"document_url",documentName:"document_name"}));var K=l({type:v("file").default("file"),file_id:e()}).transform((t)=>b(t,{file_id:"fileId"})),Tu=l({type:v("file").default("file"),fileId:e()}).transform((t)=>b(t,{fileId:"file_id"}));var Y={Low:"low",Auto:"auto",High:"high"},B=me(Y),Z=Lt(Y);var R=l({url:e(),detail:y(B).optional()}),F=l({url:e(),detail:y(Z).optional()});var Ie=q([R,e()]),we=q([F,e()]);var ka=l({type:v("image_url").default("image_url"),image_url:q([R,e()])}).transform((t)=>b(t,{image_url:"imageUrl"})),zi=l({type:v("image_url").default("image_url"),imageUrl:q([F,e()])}).transform((t)=>b(t,{imageUrl:"image_url"}));var Ae=q([I(),e()]),ve=q([I(),e()]);var z=l({type:v("reference").default("reference"),reference_ids:A(q([I(),e()]))}).transform((t)=>b(t,{reference_ids:"referenceIds"})),S=l({type:v("reference").default("reference"),referenceIds:A(q([I(),e()]))}).transform((t)=>b(t,{referenceIds:"reference_ids"}));var Ls=l({type:v("text").default("text"),text:e()}),Zs=l({type:v("text").default("text"),text:e()});var G={WebSearch:"web_search",WebSearchPremium:"web_search_premium",CodeInterpreter:"code_interpreter",ImageGeneration:"image_generation",DocumentLibrary:"document_library"},$n=me(G),ji=Lt(G);var Ve=q([$n,e()]),We=q([ji,e()]);var hl=l({type:v("tool_reference").default("tool_reference"),tool:q([$n,e()]),title:e(),url:y(e()).optional(),favicon:y(e()).optional(),description:y(e()).optional()}),ku=l({type:v("tool_reference").default("tool_reference"),tool:q([ji,e()]),title:e(),url:y(e()).optional(),favicon:y(e()).optional(),description:y(e()).optional()});var Xe=q([hl,Ls,z]),et=q([ku,Zs,S]);var Ra=l({type:v("thinking").default("thinking"),thinking:A(q([hl,Ls,z])),signature:y(e()).optional(),closed:E().optional()}),Ma=l({type:v("thinking").default("thinking"),thinking:A(q([ku,Zs,S])),signature:y(e()).optional(),closed:E().optional()});var oc=gt("type",{image_url:ka.and(l({type:v("image_url")})),document_url:Ta.and(l({type:v("document_url")})),text:Ls.and(l({type:v("text")})),reference:z.and(l({type:v("reference")})),file:K.and(l({type:v("file")})),thinking:Ra.and(l({type:v("thinking")})),input_audio:L}),qi=D([zi.and(l({type:v("image_url")})),Ui.and(l({type:v("document_url")})),Zs.and(l({type:v("text")})),S.and(l({type:v("reference")})),Tu.and(l({type:v("file")})),Ma.and(l({type:v("thinking")})),M]);var pt=q([k(e(),N()),e()]),ft=q([k(e(),N()),e()]);var H=l({name:e(),arguments:q([k(e(),N()),e()])}),Q=l({name:e(),arguments:q([k(e(),N()),e()])});var Wd=l({id:e().default("null"),type:e().optional(),function:H,index:I().default(0)}),Fg=l({id:e().default("null"),type:e().optional(),function:Q,index:I().default(0)});var kt=q([e(),A(oc)]);var Jd=l({role:y(e()).optional(),content:y(q([e(),A(oc)])).optional(),tool_calls:y(A(Wd)).optional(),tool_call_id:y(e()).optional(),index:y(I()).optional(),metadata:y(k(e(),N())).optional()}).transform((t)=>b(t,{tool_calls:"toolCalls",tool_call_id:"toolCallId"}));var ys=l({prompt_tokens:I().default(0),completion_tokens:I().default(0),total_tokens:I().default(0),prompt_audio_seconds:y(I()).optional()}).catchall(N()).transform((t)=>b(t,{prompt_tokens:"promptTokens",completion_tokens:"completionTokens",total_tokens:"totalTokens",prompt_audio_seconds:"promptAudioSeconds"})),Ru=l({promptTokens:I().default(0),completionTokens:I().default(0),totalTokens:I().default(0),promptAudioSeconds:y(I()).optional()}).catchall(N()).transform((t)=>({...b(t,{promptTokens:"prompt_tokens",completionTokens:"completion_tokens",totalTokens:"total_tokens",promptAudioSeconds:"prompt_audio_seconds"})}));var ne={Stop:"stop",Length:"length",Error:"error",ToolCalls:"tool_calls"},oe=me(ne),X=l({index:I(),delta:Jd,finish_reason:y(oe)}).transform((t)=>b(t,{finish_reason:"finishReason"}));var sm=l({id:e(),object:e().optional(),created:I().optional(),model:e(),usage:ys.optional(),choices:A(X)});function Lg(t){return P(t,(n)=>sm.parse(JSON.parse(n)),"Failed to parse 'CompletionChunk' from JSON")}
|
|
4
|
+
export{om,ml,Fs,V,P,b,O,me,nc,Lt,Ng,gt,q,Ta,Ui,Tu,ka,zi,Ls,Zs,$n,ji,hl,ku,Ra,Ma,oc,qi,Wd,Fg,Jd,ys,Ru,sm,Lg};
|