plaincrew 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/app-build/BUILD_ID +1 -1
- package/app-build/app-path-routes-manifest.json +7 -0
- package/app-build/build-manifest.json +32 -21
- package/app-build/diagnostics/route-bundle-stats.json +55 -32
- package/app-build/fallback-build-manifest.json +3 -3
- package/app-build/routes-manifest.json +46 -0
- package/app-build/server/app/_global-error/page/build-manifest.json +3 -3
- package/app-build/server/app/_global-error/page.js +1 -1
- package/app-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/_global-error.html +1 -1
- package/app-build/server/app/_global-error.rsc +1 -1
- package/app-build/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app-build/server/app/_not-found/page/build-manifest.json +3 -3
- package/app-build/server/app/_not-found/page.js +1 -1
- package/app-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/_not-found.html +1 -1
- package/app-build/server/app/_not-found.rsc +2 -2
- package/app-build/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/app-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/app-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app-build/server/app/api/account/ai/route.js +14 -8
- package/app-build/server/app/api/account/leaving/route.js +13 -7
- package/app-build/server/app/api/ais/models/route.js +14 -8
- package/app-build/server/app/api/attachments/route.js +13 -7
- package/app-build/server/app/api/auth/[...all]/route.js +14 -8
- package/app-build/server/app/api/cloud/enter/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/cloud/enter/route/build-manifest.json +12 -0
- package/app-build/server/app/api/cloud/enter/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/cloud/enter/route.js +20 -0
- package/app-build/server/app/api/cloud/enter/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/connect/[code]/approve/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/connect/[code]/approve/route/build-manifest.json +12 -0
- package/app-build/server/app/api/connect/[code]/approve/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/connect/[code]/approve/route.js +23 -0
- package/app-build/server/app/api/connect/[code]/approve/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/connect/[code]/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/connect/[code]/route/build-manifest.json +12 -0
- package/app-build/server/app/api/connect/[code]/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/connect/[code]/route.js +11 -0
- package/app-build/server/app/api/connect/[code]/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/connect/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/connect/route/build-manifest.json +12 -0
- package/app-build/server/app/api/connect/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/connect/route.js +11 -0
- package/app-build/server/app/api/connect/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/health/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/health/route/build-manifest.json +12 -0
- package/app-build/server/app/api/health/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/health/route.js +8 -0
- package/app-build/server/app/api/health/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/inngest/route.js +14 -12
- package/app-build/server/app/api/organization/route.js +13 -7
- package/app-build/server/app/api/projects/[id]/base/route.js +13 -7
- package/app-build/server/app/api/projects/[id]/github/route.js +14 -8
- package/app-build/server/app/api/projects/[id]/notes/[noteId]/route.js +14 -8
- package/app-build/server/app/api/projects/[id]/notes/route.js +14 -8
- package/app-build/server/app/api/projects/[id]/route.js +14 -8
- package/app-build/server/app/api/projects/[id]/site/route.js +14 -8
- package/app-build/server/app/api/projects/analyze/route.js +13 -7
- package/app-build/server/app/api/projects/route.js +20 -13
- package/app-build/server/app/api/projects/scratch/route.js +22 -15
- package/app-build/server/app/api/runs/[runId]/blocks/[blockId]/route.js +12 -6
- package/app-build/server/app/api/runs/[runId]/branch-name/route.js +12 -6
- package/app-build/server/app/api/runs/[runId]/cancel/route.js +18 -12
- package/app-build/server/app/api/runs/[runId]/connect-github/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/decision/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/delivery/route.js +13 -7
- package/app-build/server/app/api/runs/[runId]/events/route.js +13 -7
- package/app-build/server/app/api/runs/[runId]/failure/explain/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/failure/route.js +15 -9
- package/app-build/server/app/api/runs/[runId]/findings/route.js +20 -14
- package/app-build/server/app/api/runs/[runId]/follow-up/route.js +20 -14
- package/app-build/server/app/api/runs/[runId]/plan/route.js +16 -10
- package/app-build/server/app/api/runs/[runId]/preview/route.js +16 -10
- package/app-build/server/app/api/runs/[runId]/prompts/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/questions/[questionId]/route.js +21 -15
- package/app-build/server/app/api/runs/[runId]/review/route.js +13 -7
- package/app-build/server/app/api/runs/[runId]/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/ship/route.js +18 -12
- package/app-build/server/app/api/runs/[runId]/snapshots/[shot]/route.js +12 -6
- package/app-build/server/app/api/runs/[runId]/snapshots/route.js +12 -6
- package/app-build/server/app/api/runs/[runId]/versions/[n]/route.js +12 -6
- package/app-build/server/app/api/runs/[runId]/versions/[n]/site/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/versions/live/route.js +14 -8
- package/app-build/server/app/api/runs/[runId]/versions/route.js +12 -6
- package/app-build/server/app/api/storage/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/storage/route/build-manifest.json +12 -0
- package/app-build/server/app/api/storage/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/storage/route.js +11 -0
- package/app-build/server/app/api/storage/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/system/choose-folder/route.js +15 -9
- package/app-build/server/app/api/workflows/[id]/draft/route.js +17 -11
- package/app-build/server/app/api/workflows/[id]/publish/route.js +19 -13
- package/app-build/server/app/api/workflows/[id]/runs/route.js +21 -15
- package/app-build/server/app/canvas/[workflowId]/page/build-manifest.json +3 -3
- package/app-build/server/app/canvas/[workflowId]/page.js +6 -6
- package/app-build/server/app/canvas/[workflowId]/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/connect/page/app-paths-manifest.json +3 -0
- package/app-build/server/app/connect/page/build-manifest.json +22 -0
- package/app-build/server/app/connect/page/next-font-manifest.json +15 -0
- package/app-build/server/app/connect/page/react-loadable-manifest.json +1 -0
- package/app-build/server/app/connect/page/server-reference-manifest.json +4 -0
- package/app-build/server/app/connect/page.js +22 -0
- package/app-build/server/app/connect/page_client-reference-manifest.js +3 -0
- package/app-build/server/app/icon.svg/route.js +4 -3
- package/app-build/server/app/invite/[id]/page/build-manifest.json +3 -3
- package/app-build/server/app/invite/[id]/page.js +6 -6
- package/app-build/server/app/invite/[id]/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/organization/new/page/build-manifest.json +3 -3
- package/app-build/server/app/organization/new/page.js +7 -7
- package/app-build/server/app/organization/new/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/page/build-manifest.json +3 -3
- package/app-build/server/app/page.js +6 -6
- package/app-build/server/app/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/sign-in/page/build-manifest.json +3 -3
- package/app-build/server/app/sign-in/page.js +5 -5
- package/app-build/server/app/sign-in/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/sign-up/page/build-manifest.json +3 -3
- package/app-build/server/app/sign-up/page.js +5 -5
- package/app-build/server/app/sign-up/page_client-reference-manifest.js +1 -1
- package/app-build/server/app-paths-manifest.json +7 -0
- package/app-build/server/chunks/[externals]__0kpij9k8-fioh._.js +3 -0
- package/app-build/server/chunks/{[externals]__04-ztb9lgz_qk._.js → [externals]__12cr78va7l10m._.js} +1 -1
- package/app-build/server/chunks/{[externals]__0qr-zdkva44f-._.js → [externals]__1c4isywy94j7c._.js} +1 -1
- package/app-build/server/chunks/{[externals]__0i1ilt3jn8bz-._.js → [externals]__1h-hxq7f0qqrs._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__08fupt7uivknp._.js → [root-of-the-server]__0-hf81cjc9miq._.js} +2 -2
- package/app-build/server/chunks/{[root-of-the-server]__0-67bq4krqdly._.js → [root-of-the-server]__01_h69z_7y8hj._.js} +2 -2
- package/app-build/server/chunks/[root-of-the-server]__04bfm6aam99jr._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__04fo6q9-bmsqf._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__05mrgzj69be88._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__0y2ca5kb5-mhs._.js → [root-of-the-server]__06wj_ntp--r7-._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__083kealcx1eos._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__08j3jvnnyh0k3._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__093bos_8cbc5e._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__09mx4_ihytiv9._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0_use5ykfraw7._.js +12 -12
- package/app-build/server/chunks/[root-of-the-server]__0_wicg5sueifn._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0c7krm9gpwvm1._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__084tpb8hzqbsc._.js → [root-of-the-server]__0d4dt0ywt1ow0._.js} +2 -2
- package/app-build/server/chunks/{[root-of-the-server]__076a8rs-5ove6._.js → [root-of-the-server]__0drcpac0a5hru._.js} +2 -2
- package/app-build/server/chunks/[root-of-the-server]__0fer144qqb0_6._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__0cmedn5yph-qf._.js → [root-of-the-server]__0hryxb3l1_c-b._.js} +2 -2
- package/app-build/server/chunks/[root-of-the-server]__0j-5-xlcodeao._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0j9vey56ni96j._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0k_l2trzzo8vs._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__0o-3c4wjexyir._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0oslh36tklohe._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__0qwqrlb3b7i0y._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0qzb976d_qj48._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0qzwj14rh2ym2._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0rwo4zg_leice._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0tt48asd4bq_v._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0wi9o-l23wx21._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0x8sjs-qr0fi-._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0z7e3um13c2p0._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0zb8p36snewnm._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__11-p_3onzgf2e._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__111rn2m71ahq1._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__11vhj0obteagu._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__153b932lf_ik5._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__15p8ahu4ip30q._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__16023he7o7zot._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__16_r5tdw4ji2s._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__17bg71e4epczi._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__17z8-upkyjz-v._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1_2bvyen56qja._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1_67_outgzgho._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1a17c0kjajkbe._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1bbm3yv2mh0ob._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1dx64weifqusv._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1ehsotx9v9v0-._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1f1iirzm5u5a-._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__0rs3mde7ikr10._.js → [root-of-the-server]__1fg-66qrs9vmd._.js} +2 -2
- package/app-build/server/chunks/[root-of-the-server]__1ghp4gx3vslm5._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1gt4-5e1kdit3._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__1irx63ehwr_32._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1j82aseh7oyg8._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1jwagne56rhyq._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1m9ci-2fhznpr._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1mh5ulkjr-g0t._.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__1n1otzmcc-pl-._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1no1kg2v5558v._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1p__xrrmhqted._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1rq-k_585r2e9._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1su62l6u2edkj._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1xodvnju6iwx3._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1yrm6-0jop6pq._.js +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__198ndqspcvvv8._.js → [root-of-the-server]__20oqzfu0t4513._.js} +2 -2
- package/app-build/server/chunks/_00v0id0w247kv._.js +3 -0
- package/app-build/server/chunks/_04ipxobgytrai._.js +19 -0
- package/app-build/server/chunks/_06_bsixuw5t32._.js +19 -0
- package/app-build/server/chunks/_07m78jtsyjmn1._.js +10 -0
- package/app-build/server/chunks/_080g7ve3me2dc._.js +3 -0
- package/app-build/server/chunks/_09ejh1dyvkto7._.js +10 -0
- package/app-build/server/chunks/_0_6-kjk5l5ckf._.js +19 -0
- package/app-build/server/chunks/_0_q5vorhn2m7p._.js +19 -0
- package/app-build/server/chunks/_0b15uwzi-_wuu._.js +19 -0
- package/app-build/server/chunks/_0b2ridyy82jxe._.js +10 -0
- package/app-build/server/chunks/_0dn7480wo_c3b._.js +3 -0
- package/app-build/server/chunks/_0e2pq-eirvzjq._.js +10 -0
- package/app-build/server/chunks/_0et5mjk8ma941._.js +10 -0
- package/app-build/server/chunks/_0fx9tvayvawom._.js +19 -0
- package/app-build/server/chunks/_0hfgolst82fo-._.js +19 -0
- package/app-build/server/chunks/_0mvcmkm58awy6._.js +19 -0
- package/app-build/server/chunks/_0n48mbivlprvf._.js +3 -0
- package/app-build/server/chunks/_0o8jagzqj8-1r._.js +2 -2
- package/app-build/server/chunks/_0p2av7ih_dhj4._.js +19 -0
- package/app-build/server/chunks/_0p5fqb7_si6x6._.js +10 -0
- package/app-build/server/chunks/_0prtq3d1e3y27._.js +10 -0
- package/app-build/server/chunks/_0qjwzjuyaym3p._.js +3 -0
- package/app-build/server/chunks/_0rnf-n0hrw3r0._.js +19 -0
- package/app-build/server/chunks/_0sqpau27sb7i_._.js +19 -0
- package/app-build/server/chunks/_0w3v4t4p9vsb-._.js +5 -5
- package/app-build/server/chunks/_0wuc81q3tth-g._.js +19 -0
- package/app-build/server/chunks/_0wwb7zpr0_tmw._.js +1 -1
- package/app-build/server/chunks/_0x2g7uj3hbyqa._.js +19 -0
- package/app-build/server/chunks/_0yi75njq4zxzw._.js +12 -0
- package/app-build/server/chunks/_1-bgcffz4bjus._.js +19 -0
- package/app-build/server/chunks/_1-y_cqqaf9ob6._.js +3 -0
- package/app-build/server/chunks/_1-yeinb4sdagg._.js +19 -0
- package/app-build/server/chunks/_108rver1pgqw-._.js +19 -0
- package/app-build/server/chunks/_12v43tznpol4u._.js +10 -0
- package/app-build/server/chunks/_139ug1e85f3h4._.js +10 -0
- package/app-build/server/chunks/_13lb7kts14z5a._.js +3 -0
- package/app-build/server/chunks/_143_tdoh-o8r2._.js +19 -0
- package/app-build/server/chunks/_146_--s-6f_o-._.js +19 -0
- package/app-build/server/chunks/_190n79a8itd96._.js +19 -0
- package/app-build/server/chunks/_19_0wmfnwvz9o._.js +10 -0
- package/app-build/server/chunks/_19q1zxel7pllh._.js +10 -0
- package/app-build/server/chunks/_1bf1pcq2wtg91._.js +10 -0
- package/app-build/server/chunks/_1cq7469bqdm3u._.js +10 -0
- package/app-build/server/chunks/_1fq2ezphtpgk3._.js +19 -0
- package/app-build/server/chunks/_1fv67kzffpbb_._.js +19 -0
- package/app-build/server/chunks/_1k79cnpkap3g1._.js +19 -0
- package/app-build/server/chunks/_1kwxo3qf7dky_._.js +19 -0
- package/app-build/server/chunks/_1l3fh2phky48z._.js +3 -0
- package/app-build/server/chunks/_1nvu29lfamrdk._.js +3 -0
- package/app-build/server/chunks/_1ob-6ym8mt48u._.js +10 -0
- package/app-build/server/chunks/_1p4epxp2kfwl3._.js +19 -0
- package/app-build/server/chunks/_1pg4_7uout-4a._.js +3 -0
- package/app-build/server/chunks/_1tqh-hw_2xsox._.js +19 -0
- package/app-build/server/chunks/_1u_phco4tax56._.js +19 -0
- package/app-build/server/chunks/_1unrzazajazmw._.js +19 -0
- package/app-build/server/chunks/_1uwtj6yrwszfe._.js +10 -0
- package/app-build/server/chunks/_1vb0vvvhh6nh7._.js +10 -0
- package/app-build/server/chunks/_1vmf9gx675--i._.js +19 -0
- package/app-build/server/chunks/_1wau1ee-6k-7o._.js +5 -5
- package/app-build/server/chunks/_1x2pk99sw0irp._.js +1 -1
- package/app-build/server/chunks/_1y5_49ip8l9oe._.js +3 -0
- package/app-build/server/chunks/_1yho6hc7s0457._.js +5 -5
- package/app-build/server/chunks/_20y-6xht4mb44._.js +19 -0
- package/app-build/server/chunks/_next-internal_server_app_api_cloud_enter_route_actions_1ykz98qhixfjs.js +3 -0
- package/app-build/server/chunks/_next-internal_server_app_api_connect_[code]_approve_route_actions_0ji2m-dij9hl5.js +3 -0
- package/app-build/server/chunks/_next-internal_server_app_api_connect_[code]_route_actions_0g60q3c0wvykf.js +3 -0
- package/app-build/server/chunks/_next-internal_server_app_api_connect_route_actions_1r5w03mk355_9.js +3 -0
- package/app-build/server/chunks/_next-internal_server_app_api_health_route_actions_1ryftkbeskq31.js +3 -0
- package/app-build/server/chunks/_next-internal_server_app_api_storage_route_actions_0oc2s3uo_vbg9.js +3 -0
- package/app-build/server/chunks/node_modules_@better-auth_core_dist_0u4ij-92kqpy1._.js +5 -0
- package/app-build/server/chunks/node_modules_@better-auth_core_dist_1slw0ax7qf28q._.js +5 -0
- package/app-build/server/chunks/node_modules_next_1zdbrneapig6o._.js +10 -0
- package/app-build/server/chunks/node_modules_ulid_dist_node_index_1p7p0eihcl4xu.js +3 -0
- package/app-build/server/chunks/node_modules_zod_v4_classic_schemas_0x4mq4j_us6_1.js +57 -0
- package/app-build/server/chunks/src_0akj18zj93gwk._.js +1 -1
- package/app-build/server/chunks/src_0gfs644l13a-r._.js +3 -0
- package/app-build/server/chunks/src_1d8a0zxtjfsuf._.js +1 -1
- package/app-build/server/chunks/src_1fy1guu0m36-q._.js +3 -0
- package/app-build/server/chunks/src_1mb1qcardcu_6._.js +1 -1
- package/app-build/server/chunks/src_auth_201pnaihqfe_5._.js +1 -1
- package/app-build/server/chunks/src_cloud_connect_ts_0-md3vzxn7lpp._.js +3 -0
- package/app-build/server/chunks/src_cloud_provision_ts_0ie1awdx54-v7._.js +3 -0
- package/app-build/server/chunks/src_db_where_ts_0pjok_m6bv-44._.js +1 -1
- package/app-build/server/chunks/src_engine_machine_ts_1l-5d6ibw02uq._.js +3 -0
- package/app-build/server/chunks/src_engine_storage_ts_09h_zn3p2eb2o._.js +3 -0
- package/app-build/server/chunks/ssr/{[root-of-the-server]__0hvog5ndgreaj._.js → [root-of-the-server]__02fcbpwktzl0e._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1wy84x6274wi0._.js → [root-of-the-server]__06kehcks298uq._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__13jf90nikuz-v._.js → [root-of-the-server]__07qbaxjilfrhb._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1t2mfcfc8i815._.js → [root-of-the-server]__0ayx2k8e4n7yj._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1vii79aq3jl2m._.js → [root-of-the-server]__0mpgsl517i3-0._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__0m3ns_a_2cw5q._.js → [root-of-the-server]__105vglixsp00a._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__0tfe4nl35ph55._.js → [root-of-the-server]__12pgkxyn_b38p._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1v3sow19yjtmw._.js → [root-of-the-server]__1cu7ckiad_t58._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1wua7k6dot3x4._.js → [root-of-the-server]__1gxrsvq_gh93m._.js} +1 -1
- package/app-build/server/chunks/ssr/[root-of-the-server]__1ik_gvdjzwan6._.js +3 -0
- package/app-build/server/chunks/ssr/{[root-of-the-server]__03w_9e_k6kgud._.js → [root-of-the-server]__1n-87555yleii._.js} +1 -1
- package/app-build/server/chunks/ssr/_0fb4klqsym0_6._.js +3 -0
- package/app-build/server/chunks/ssr/_0plc10a4e_g26._.js +498 -0
- package/app-build/server/chunks/ssr/_0vqiqfwum1eeq._.js +498 -0
- package/app-build/server/chunks/ssr/_14z-y2hqpv20w._.js +4 -4
- package/app-build/server/chunks/ssr/_15rry-mn1ylod._.js +498 -0
- package/app-build/server/chunks/ssr/_18d6v6hzvx1mu._.js +1 -1
- package/app-build/server/chunks/ssr/{_0buybf2wnrn_4._.js → _1dyej_7akyn4m._.js} +2 -2
- package/app-build/server/chunks/ssr/_1er7c_w1fawws._.js +3 -0
- package/app-build/server/chunks/ssr/_1mebmslk3b4xf._.js +1 -1
- package/app-build/server/chunks/ssr/{_0u7gwi85h6cf-._.js → _1ph9xm-z7tn_h._.js} +2 -2
- package/app-build/server/chunks/ssr/_1stfnmis3lpoq._.js +498 -0
- package/app-build/server/chunks/ssr/_1uj-3d4t3_f-w._.js +498 -0
- package/app-build/server/chunks/ssr/_next-internal_server_app_connect_page_actions_1g-s_3iey9c04.js +3 -0
- package/app-build/server/chunks/ssr/node_modules_10id6sduifkvy._.js +59 -0
- package/app-build/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0w96iu1ncvvo0.js +3 -0
- package/app-build/server/chunks/ssr/src_13l727gejp_6n._.js +3 -0
- package/app-build/server/chunks/ssr/{src_0r--q7x0ztpgu._.js → src_1cn16bn7pzjnd._.js} +2 -2
- package/app-build/server/chunks/ssr/src_1j5tc25jwfv_8._.js +3 -0
- package/app-build/server/chunks/ssr/src_1oitb44kjbwhi._.js +21 -0
- package/app-build/server/chunks/ssr/src_1qpok7f_-18_w._.js +3 -0
- package/app-build/server/chunks/ssr/src_auth_client_ts_0q_2k3z_l1ip-._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_0a7papum2y8_i._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_0dybjq718frlj._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_1lk_5nzn_qoqs._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_1pd2_lbqeputa._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_AiMark_tsx_0-kcacyns0w8e._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_auth_ConnectScreen_tsx_0fe1yscm_2_27._.js +3 -0
- package/app-build/server/chunks/ssr/src_ui_canvas_AddProjectDialog_tsx_10a7chj-0e01u._.js +57 -0
- package/app-build/server/chunks/ssr/src_ui_strings_ts_1es3352ykktl1._.js +1 -1
- package/app-build/server/instrumentation.js +1 -1
- package/app-build/server/middleware-build-manifest.js +32 -21
- package/app-build/server/middleware.js +1 -1
- package/app-build/server/next-font-manifest.js +1 -1
- package/app-build/server/next-font-manifest.json +8 -0
- package/app-build/server/pages/404.html +1 -1
- package/app-build/server/pages/500.html +1 -1
- package/app-build/static/chunks/04hu91jpixs3u.js +1 -0
- package/app-build/static/chunks/0u800lsoqi8_z.js +55 -0
- package/app-build/static/chunks/{1bnawoiy5_570.js → 1kp-bz-o-8ck-.js} +3 -3
- package/app-build/static/chunks/1wg6_v6094_ev.js +1 -0
- package/app-build/static/chunks/217-kbs71m5l2.js +1 -0
- package/app-build/static/chunks/2k_3gu76w6kra.js +1 -0
- package/app-build/static/chunks/2ku8241h3kja_.js +5 -0
- package/app-build/static/chunks/2r_8wjfab8ek7.js +1 -0
- package/app-build/static/chunks/2urr6-fm2smyv.js +1 -0
- package/app-build/static/chunks/2w14sgj4v2wr8.js +1 -0
- package/app-build/static/chunks/{324p9a1j89bkh.css → 3qsw-xu34m6k4.css} +1 -1
- package/app-build/static/chunks/3x09-es7lx-9r.js +1 -0
- package/app-build/trace-build +1 -1
- package/bin/plaincrew.mjs +88 -4
- package/drizzle-pg/0017_mysterious_major_mapleleaf.sql +20 -0
- package/drizzle-pg/0018_puzzling_magdalene.sql +12 -0
- package/drizzle-pg/meta/0017_snapshot.json +2978 -0
- package/drizzle-pg/meta/0018_snapshot.json +3070 -0
- package/drizzle-pg/meta/_journal.json +14 -0
- package/package.json +2 -1
- package/app-build/server/chunks/[externals]_next_dist_server_app-render_1yoqe3gkwr3dg._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0-dtybr1h5y66._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__05_5uof-vh0ur._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__05d-vefbcavd3._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__06i52ssvds_4l._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0eduzqmkmc65q._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0fu80h1ryrjqj._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0hf3vbo5kjyuy._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0ilio9-5rd-d8._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0jqz-s5880rsj._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0kbuhf_sq5zgo._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0khjs7gbsfbjd._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0lvn5y8zcusur._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0m87p_jnin9di._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0n57671zyqi-b._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0n6ovv8grc91o._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0nhkl1m3cu6ri._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0omzj4w4vqjjj._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0prnmbd2nc0a1._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0qhoro7nfi0o0._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0quxao-smsayh._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0ruz2yyah___m._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0s378vzw-73-n._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0u06g320ljnbt._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0yyzjyq-oy-e1._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0z7dh952zeb9f._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1-x13b8ye1wfs._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__10-yy5gpbp308._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__10dplucy-sz7s._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__10n1c02pch_ot._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__12o-04az_z-mg._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__13-hl-756hoon._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__14qr9wmmvw7xf._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__156stbqt7ugb9._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1aetujxeqqt_d._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1e62d7e5vw5k3._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1fgplw81nl-ss._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1fzc6c4-172b2._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1hv-y842n87d8._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1iz569gw7tcd-._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1j-8olcwngr7q._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1sqed3wmvgodn._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1t_dswewodt5w._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1u9hq4soe2xwp._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1vp_i0kfcgv8v._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1x0k45ov7_05w._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1yf5s1twz5moo._.js +0 -3
- package/app-build/server/chunks/_0-jxl7nrok4vo._.js +0 -26
- package/app-build/server/chunks/_00j6_u1runs4w._.js +0 -26
- package/app-build/server/chunks/_02rqsv-5r1xyh._.js +0 -26
- package/app-build/server/chunks/_037kdv10i5y_3._.js +0 -26
- package/app-build/server/chunks/_04qeqxkodasvw._.js +0 -26
- package/app-build/server/chunks/_060517ixkutga._.js +0 -26
- package/app-build/server/chunks/_0_ohdufir0pc0._.js +0 -26
- package/app-build/server/chunks/_0a399s004z09i._.js +0 -26
- package/app-build/server/chunks/_0c8uqvkdnv8om._.js +0 -26
- package/app-build/server/chunks/_0cpx6gxrun97c._.js +0 -26
- package/app-build/server/chunks/_0e0zdgh5__9o9._.js +0 -26
- package/app-build/server/chunks/_0i95e9zu6fj4n._.js +0 -26
- package/app-build/server/chunks/_0jd49raqadz76._.js +0 -26
- package/app-build/server/chunks/_0lhu42i9ysm02._.js +0 -26
- package/app-build/server/chunks/_0nk-c9zmnj37l._.js +0 -26
- package/app-build/server/chunks/_0rnjb46ttnp_1._.js +0 -10
- package/app-build/server/chunks/_0t315blstrlgt._.js +0 -26
- package/app-build/server/chunks/_0v3u7bir_x-f1._.js +0 -26
- package/app-build/server/chunks/_0vkp8d-4v66df._.js +0 -10
- package/app-build/server/chunks/_0vnwz2wsr7rta._.js +0 -26
- package/app-build/server/chunks/_0zmtu_rs0-xx3._.js +0 -26
- package/app-build/server/chunks/_0zx-1d3-vgrjf._.js +0 -26
- package/app-build/server/chunks/_13_q0s3m37izl._.js +0 -26
- package/app-build/server/chunks/_15_pg1-nh_uey._.js +0 -26
- package/app-build/server/chunks/_16kc8tvml_4jr._.js +0 -10
- package/app-build/server/chunks/_197p633h-h37y._.js +0 -26
- package/app-build/server/chunks/_1hyd5-0pvbz7j._.js +0 -10
- package/app-build/server/chunks/_1k0nwfy3n5zq6._.js +0 -26
- package/app-build/server/chunks/_1qp5atyvlmjms._.js +0 -26
- package/app-build/server/chunks/_1r8yign_b4xit._.js +0 -26
- package/app-build/server/chunks/_1s7c6rvg9jq1b._.js +0 -26
- package/app-build/server/chunks/_1srrbf3r_cgyh._.js +0 -3
- package/app-build/server/chunks/_1tcp49lkcyk9b._.js +0 -26
- package/app-build/server/chunks/_1tmt_2duzfhf-._.js +0 -26
- package/app-build/server/chunks/_1tx_iizje6rr5._.js +0 -26
- package/app-build/server/chunks/_1vmuo5nz7e9j7._.js +0 -26
- package/app-build/server/chunks/_1zqmp75fro5bj._.js +0 -26
- package/app-build/server/chunks/_207efa75ej326._.js +0 -26
- package/app-build/server/chunks/node_modules_038x-mogk4n7d._.js +0 -59
- package/app-build/server/chunks/node_modules_06i8knol64dp4._.js +0 -59
- package/app-build/server/chunks/node_modules_1bu1e_tx1yhos._.js +0 -59
- package/app-build/server/chunks/src_0ya5sso2-uxy9._.js +0 -3
- package/app-build/server/chunks/src_1idm2q9mpd_ac._.js +0 -3
- package/app-build/server/chunks/ssr/_0c07_u5ve9h96._.js +0 -3
- package/app-build/server/chunks/ssr/_0c9c3otndjyb3._.js +0 -491
- package/app-build/server/chunks/ssr/_0r-_quaoj7vtd._.js +0 -491
- package/app-build/server/chunks/ssr/_1nnyuupo9_rf8._.js +0 -491
- package/app-build/server/chunks/ssr/_1v3g8djeka9qb._.js +0 -32
- package/app-build/server/chunks/ssr/_1wcw1-cjuk4-r._.js +0 -491
- package/app-build/server/chunks/ssr/node_modules_@better-auth_core_dist_14kycjq88o05j._.js +0 -59
- package/app-build/server/chunks/ssr/src_0dka4d-sj76yr._.js +0 -3
- package/app-build/server/chunks/ssr/src_0kr0vdt5cmmqe._.js +0 -3
- package/app-build/server/chunks/ssr/src_0xa_ew7bgnab8._.js +0 -3
- package/app-build/server/chunks/ssr/src_14kyflsj7vzua._.js +0 -3
- package/app-build/server/chunks/ssr/src_1kc7a2tc4zk79._.js +0 -3
- package/app-build/server/chunks/ssr/src_1xj6pksvrcr7j._.js +0 -21
- package/app-build/static/chunks/0ioqfqts8esiv.js +0 -1
- package/app-build/static/chunks/0p_562p4eiia0.js +0 -5
- package/app-build/static/chunks/0sisrf23dzct3.js +0 -1
- package/app-build/static/chunks/16_8pb-q1k23d.js +0 -1
- package/app-build/static/chunks/1lj8cya75hc47.js +0 -1
- package/app-build/static/chunks/1smn3_hn-_7bt.js +0 -1
- package/app-build/static/chunks/1wnov70f88xjy.js +0 -1
- /package/app-build/static/{m8GgIjZTfSoO8KWsqC9Cm → r8bYBXboElhyfwYccuAh5}/_buildManifest.js +0 -0
- /package/app-build/static/{m8GgIjZTfSoO8KWsqC9Cm → r8bYBXboElhyfwYccuAh5}/_clientMiddlewareManifest.js +0 -0
- /package/app-build/static/{m8GgIjZTfSoO8KWsqC9Cm → r8bYBXboElhyfwYccuAh5}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module.exports=[261,39833,88443,53081,e=>{"use strict";var t=e.i(63369),i=e.i(39774),r=e.i(33102),s=e.i(25490),n=e.i(31902);class a{constructor(e){this.table=e}static [i.h]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class o{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [i.h]="TableAliasProxyHandler";get(e,r){if(r===s.s.Symbol.IsAlias)return!0;if(r===s.s.Symbol.Name||this.replaceOriginalName&&r===s.s.Symbol.OriginalName)return this.alias;if(r===n.f)return{...e[n.f],name:this.alias,isAlias:!0};if(r===s.s.Symbol.Columns){let t=e[s.s.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(r=>{i[r]=new Proxy(t[r],new a(new Proxy(e,this)))}),i}let o=e[r];return(0,i.f)(o,t.f)?new Proxy(o,new a(new Proxy(e,this))):o}}function l(e,t){return new Proxy(e,new o(t,!1))}function c(e,t){return new Proxy(e,new a(new Proxy(e.table,new o(t,!1))))}function u(e,t){return new r.o.Aliased(d(e.sql,t),e.fieldAlias)}function d(e,s){return r.B.join(e.queryChunks.map(e=>(0,i.f)(e,t.f)?c(e,s):(0,i.f)(e,r.o)?d(e,s):(0,i.f)(e,r.o.Aliased)?u(e,s):e))}function h(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function f(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,i)=>e+(0===i?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}function g(e){return e}i.h,e.s(["Z",0,a,"e",0,o,"L",0,l,"P",0,c,"C",0,u,"t",0,d],261);class p{static [i.h]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?h:"camelCase"===e?f:g}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[s.s.Symbol.Schema]??"public",i=e.table[s.s.Symbol.OriginalName],r=`${t}.${i}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[s.s.Symbol.Schema]??"public",i=e[s.s.Symbol.OriginalName],r=`${t}.${i}`;if(!this.cachedTables[r]){for(let t of Object.values(e[s.s.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class m extends Error{static [i.h]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class y extends m{static [i.h]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}e.s(["S",0,m,"l",0,class e extends Error{constructor(t,i,r){super(`Failed query: ${t}
|
|
2
|
+
params: ${i}`),this.query=t,this.params=i,this.cause=r,Error.captureStackTrace(this,e),r&&(this.cause=r)}},"b",0,y],39833);var b=e.i(34950),w=e.i(23235),v=e.i(12639),N=e.i(41630),S=e.i(1477),_=e.i(75528),B=e.i(10566),T=e.i(45115),$=e.i(75375),x=e.i(5644),P=e.i(36763),q=e.i(55464),C=e.i(84346),j=r;class A extends j._{static [i.h]="PgViewBase"}e.s(["f",0,A],88443);class D{static [i.h]="PgDialect";casing;constructor(e){this.casing=new p(e?.casing)}async migrate(e,t,i){let s="string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",n="string"==typeof i?"drizzle":i.migrationsSchema??"drizzle",a=r.B`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS ${r.B.identifier(n)}.${r.B.identifier(s)} (
|
|
4
|
+
id SERIAL PRIMARY KEY,
|
|
5
|
+
hash text NOT NULL,
|
|
6
|
+
created_at bigint
|
|
7
|
+
)
|
|
8
|
+
`;await t.execute(r.B`CREATE SCHEMA IF NOT EXISTS ${r.B.identifier(n)}`),await t.execute(a);let o=(await t.all(r.B`select id, hash, created_at from ${r.B.identifier(n)}.${r.B.identifier(s)} order by created_at desc limit 1`))[0];await t.transaction(async t=>{for await(let i of e)if(!o||Number(o.created_at)<i.folderMillis){for(let e of i.sql)await t.execute(r.B.raw(e));await t.execute(r.B`insert into ${r.B.identifier(n)}.${r.B.identifier(s)} ("hash", "created_at") values(${i.hash}, ${i.folderMillis})`)}})}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return`$${e+1}`}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[r.B`with `];for(let[i,s]of e.entries())t.push(r.B`${r.B.identifier(s._.alias)} as (${s._.sql})`),i<e.length-1&&t.push(r.B`, `);return t.push(r.B` `),r.B.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:s}){let n=this.buildWithCTE(s),a=i?r.B` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,o=t?r.B` where ${t}`:void 0;return r.B`${n}delete from ${e}${o}${a}`}buildUpdateSet(e,t){let n=e[s.s.Symbol.Columns],a=Object.keys(n).filter(e=>void 0!==t[e]||n[e]?.onUpdateFn!==void 0),o=a.length;return r.B.join(a.flatMap((e,s)=>{let a=n[e],l=a.onUpdateFn?.(),c=t[e]??((0,i.f)(l,r.o)?l:r.B.param(l,a)),u=r.B`${r.B.identifier(this.casing.getColumnCasing(a))} = ${c}`;return s<o-1?[u,r.B.raw(", ")]:[u]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:n,from:a,joins:o}){let l=this.buildWithCTE(n),c=e[$.M.Symbol.Name],u=e[$.M.Symbol.Schema],d=e[$.M.Symbol.OriginalName],h=c===d?void 0:c,f=r.B`${u?r.B`${r.B.identifier(u)}.`:void 0}${r.B.identifier(d)}${h&&r.B` ${r.B.identifier(h)}`}`,g=this.buildUpdateSet(e,t),p=a&&r.B.join([r.B.raw(" from "),this.buildFromTable(a)]),m=this.buildJoins(o),y=s?r.B` returning ${this.buildSelection(s,{isSingleTable:!a})}`:void 0,b=i?r.B` where ${i}`:void 0;return r.B`${l}update ${f} set ${g}${p}${m}${b}${y}`}buildSelection(e,{isSingleTable:s=!1}={}){let n=e.length,a=e.flatMap(({field:e},a)=>{let o=[];if((0,i.f)(e,r.o.Aliased)&&e.isSelectionField)o.push(r.B.identifier(e.fieldAlias));else if((0,i.f)(e,r.o.Aliased)||(0,i.f)(e,r.o)){let t=(0,i.f)(e,r.o.Aliased)?e.sql:e;s?o.push(new r.o(t.queryChunks.map(e=>(0,i.f)(e,b.t)?r.B.identifier(this.casing.getColumnCasing(e)):e))):o.push(t),(0,i.f)(e,r.o.Aliased)&&o.push(r.B` as ${r.B.identifier(e.fieldAlias)}`)}else if((0,i.f)(e,t.f))s?o.push(r.B.identifier(this.casing.getColumnCasing(e))):o.push(e);else if((0,i.f)(e,q.Q)){let s=Object.entries(e._.selectedFields);if(1===s.length){let n=s[0][1],a=(0,i.f)(n,r.o)?n.decoder:(0,i.f)(n,t.f)?{mapFromDriverValue:e=>n.mapFromDriverValue(e)}:n.sql.decoder;a&&(e._.sql.decoder=a)}o.push(e)}return a<n-1&&o.push(r.B`, `),o});return r.B.join(a)}buildJoins(e){if(!e||0===e.length)return;let t=[];for(let[s,a]of e.entries()){0===s&&t.push(r.B` `);let o=a.table,l=a.lateral?r.B` lateral`:void 0,c=a.on?r.B` on ${a.on}`:void 0;if((0,i.f)(o,$.M)){let e=o[$.M.Symbol.Name],i=o[$.M.Symbol.Schema],s=o[$.M.Symbol.OriginalName],n=e===s?void 0:a.alias;t.push(r.B`${r.B.raw(a.joinType)} join${l} ${i?r.B`${r.B.identifier(i)}.`:void 0}${r.B.identifier(s)}${n&&r.B` ${r.B.identifier(n)}`}${c}`)}else if((0,i.f)(o,r._)){let e=o[n.f].name,i=o[n.f].schema,s=o[n.f].originalName,u=e===s?void 0:a.alias;t.push(r.B`${r.B.raw(a.joinType)} join${l} ${i?r.B`${r.B.identifier(i)}.`:void 0}${r.B.identifier(s)}${u&&r.B` ${r.B.identifier(u)}`}${c}`)}else t.push(r.B`${r.B.raw(a.joinType)} join${l} ${o}${c}`);s<e.length-1&&t.push(r.B` `)}return r.B.join(t)}buildFromTable(e){if((0,i.f)(e,s.s)&&e[s.s.Symbol.IsAlias]){let t=r.B`${r.B.identifier(e[s.s.Symbol.OriginalName])}`;return e[s.s.Symbol.Schema]&&(t=r.B`${r.B.identifier(e[s.s.Symbol.Schema])}.${t}`),r.B`${t} ${r.B.identifier(e[s.s.Symbol.Name])}`}return e}buildSelectQuery({withList:e,fields:a,fieldsFlat:o,where:l,having:c,table:u,joins:d,orderBy:h,groupBy:f,limit:g,offset:p,lockingClause:m,distinct:y,setOperators:b}){let w,v,N,S=o??(0,C.$)(a);for(let e of S){let a;if((0,i.f)(e.field,t.f)&&(0,s.P)(e.field.table)!==((0,i.f)(u,q.Q)?u._.alias:(0,i.f)(u,A)?u[n.f].name:(0,i.f)(u,r.o)?void 0:(0,s.P)(u))&&(a=e.field.table,!d?.some(({alias:e})=>e===(a[s.s.Symbol.IsAlias]?(0,s.P)(a):a[s.s.Symbol.BaseName])))){let t=(0,s.P)(e.field.table);throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let _=!d||0===d.length,B=this.buildWithCTE(e);y&&(w=!0===y?r.B` distinct`:r.B` distinct on (${r.B.join(y.on,r.B`, `)})`);let T=this.buildSelection(S,{isSingleTable:_}),$=this.buildFromTable(u),x=this.buildJoins(d),P=l?r.B` where ${l}`:void 0,j=c?r.B` having ${c}`:void 0;h&&h.length>0&&(v=r.B` order by ${r.B.join(h,r.B`, `)}`),f&&f.length>0&&(N=r.B` group by ${r.B.join(f,r.B`, `)}`);let D="object"==typeof g||"number"==typeof g&&g>=0?r.B` limit ${g}`:void 0,Q=p?r.B` offset ${p}`:void 0,I=r.B.empty();if(m){let e=r.B` for ${r.B.raw(m.strength)}`;m.config.of&&e.append(r.B` of ${r.B.join(Array.isArray(m.config.of)?m.config.of:[m.config.of],r.B`, `)}`),m.config.noWait?e.append(r.B` nowait`):m.config.skipLocked&&e.append(r.B` skip locked`),I.append(e)}let z=r.B`${B}select${w} ${T} from ${$}${x}${P}${N}${j}${v}${D}${Q}${I}`;return b.length>0?this.buildSetOperations(z,b):z}buildSetOperations(e,t){let[i,...r]=t;if(!i)throw Error("Cannot pass undefined values to any set operator");return 0===r.length?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),r)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:s,rightSelect:n,limit:a,orderBy:o,offset:l}}){let c,u=r.B`(${e.getSQL()}) `,d=r.B`(${n.getSQL()})`;if(o&&o.length>0){let e=[];for(let t of o)if((0,i.f)(t,b.t))e.push(r.B.identifier(t.name));else if((0,i.f)(t,r.o)){for(let e=0;e<t.queryChunks.length;e++){let s=t.queryChunks[e];(0,i.f)(s,b.t)&&(t.queryChunks[e]=r.B.identifier(s.name))}e.push(r.B`${t}`)}else e.push(r.B`${t}`);c=r.B` order by ${r.B.join(e,r.B`, `)} `}let h="object"==typeof a||"number"==typeof a&&a>=0?r.B` limit ${a}`:void 0,f=r.B.raw(`${t} ${s?"all ":""}`),g=l?r.B` offset ${l}`:void 0;return r.B`${u}${f}${d}${c}${h}${g}`}buildInsertQuery({table:e,values:t,onConflict:n,returning:a,withList:o,select:l,overridingSystemValue_:c}){let u=[],d=Object.entries(e[s.s.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),h=d.map(([,e])=>r.B.identifier(this.casing.getColumnCasing(e)));if(l)(0,i.f)(t,r.o)?u.push(t):u.push(t.getSQL());else for(let[e,s]of(u.push(r.B.raw("values ")),t.entries())){let n=[];for(let[e,t]of d){let a=s[e];if(void 0===a||(0,i.f)(a,r.r)&&void 0===a.value)if(void 0!==t.defaultFn){let e=t.defaultFn(),s=(0,i.f)(e,r.o)?e:r.B.param(e,t);n.push(s)}else if(t.default||void 0===t.onUpdateFn)n.push(r.B`default`);else{let e=t.onUpdateFn(),s=(0,i.f)(e,r.o)?e:r.B.param(e,t);n.push(s)}else n.push(a)}u.push(n),e<t.length-1&&u.push(r.B`, `)}let f=this.buildWithCTE(o),g=r.B.join(u),p=a?r.B` returning ${this.buildSelection(a,{isSingleTable:!0})}`:void 0,m=n?r.B` on conflict ${n}`:void 0,y=!0===c?r.B`overriding system value `:void 0;return r.B`${f}insert into ${e} ${h} ${y}${g}${m}${p}`}buildRefreshMaterializedViewQuery({view:e,concurrently:t,withNoData:i}){let s=t?r.B` concurrently`:void 0,n=i?r.B` with no data`:void 0;return r.B`refresh materialized view${s} ${e}${n}`}prepareTyping(e){if((0,i.f)(e,N.Z)||(0,i.f)(e,v.E))return"json";if((0,i.f)(e,S.e))return"decimal";if((0,i.f)(e,_.F))return"time";if((0,i.f)(e,B.R)||(0,i.f)(e,B.y))return"timestamp";if((0,i.f)(e,w.r)||(0,i.f)(e,w.$))return"date";else if((0,i.f)(e,T.I))return"uuid";else return"none"}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:t})}buildRelationalQueryWithoutPK({fullSchema:e,schema:n,tableNamesMap:a,table:o,tableConfig:h,queryConfig:f,tableAlias:g,nestedQueryRelation:p,joinOn:y}){let b,w=[],v,N,S=[],_,B=[];if(!0===f)w=Object.entries(h.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:c(t,g),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let o=Object.fromEntries(Object.entries(h.columns).map(([e,t])=>[e,c(t,g)]));if(f.where){let e="function"==typeof f.where?f.where(o,(0,x.l)()):f.where;_=e&&d(e,g)}let l=[],p=[];if(f.columns){let e=!1;for(let[t,i]of Object.entries(f.columns))void 0!==i&&t in h.columns&&(e||!0!==i||(e=!0),p.push(t));p.length>0&&(p=e?p.filter(e=>f.columns?.[e]===!0):Object.keys(h.columns).filter(e=>!p.includes(e)))}else p=Object.keys(h.columns);for(let e of p){let t=h.columns[e];l.push({tsKey:e,value:t})}let m=[];if(f.with&&(m=Object.entries(f.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:h.relations[e]}))),f.extras)for(let[e,t]of Object.entries("function"==typeof f.extras?f.extras(o,{sql:r.B}):f.extras))l.push({tsKey:e,value:u(t,g)});for(let{tsKey:e,value:s}of l)w.push({dbKey:(0,i.f)(s,r.o.Aliased)?s.fieldAlias:h.columns[e].name,tsKey:e,field:(0,i.f)(s,t.f)?c(s,g):s,relationTableTsKey:void 0,isJson:!1,selection:[]});let y="function"==typeof f.orderBy?f.orderBy(o,(0,x.u)()):f.orderBy??[];for(let{tsKey:o,queryConfig:l,relation:u}of(Array.isArray(y)||(y=[y]),S=y.map(e=>(0,i.f)(e,t.f)?c(e,g):d(e,g)),v=f.limit,N=f.offset,m)){let t=(0,x.J)(n,a,u),d=a[(0,s.I)(u.referencedTable)],h=`${g}_${o}`,f=(0,P.b)(...t.fields.map((e,i)=>(0,P.u)(c(t.references[i],h),c(e,g)))),p=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:n,tableNamesMap:a,table:e[d],tableConfig:n[d],queryConfig:(0,i.f)(u,x.V)?!0===l?{limit:1}:{...l,limit:1}:l,tableAlias:h,joinOn:f,nestedQueryRelation:u}),m=r.B`${r.B.identifier(h)}.${r.B.identifier("data")}`.as(o);B.push({on:r.B`true`,table:new q.Q(p.sql,{},h),alias:h,joinType:"left",lateral:!0}),w.push({dbKey:o,tsKey:o,field:m,relationTableTsKey:d,isJson:!0,selection:p.selection})}}if(0===w.length)throw new m({message:`No fields selected for table "${h.tsName}" ("${g}")`});if(_=(0,P.b)(y,_),p){let e=r.B`json_build_array(${r.B.join(w.map(({field:e,tsKey:t,isJson:s})=>s?r.B`${r.B.identifier(`${g}_${t}`)}.${r.B.identifier("data")}`:(0,i.f)(e,r.o.Aliased)?e.sql:e),r.B`, `)})`;(0,i.f)(p,x.P)&&(e=r.B`coalesce(json_agg(${e}${S.length>0?r.B` order by ${r.B.join(S,r.B`, `)}`:void 0}), '[]'::json)`);let s=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:h.tsName,selection:w}];void 0!==v||void 0!==N||S.length>0?(b=this.buildSelectQuery({table:l(o,g),fields:{},fieldsFlat:[{path:[],field:r.B.raw("*")}],where:_,limit:v,offset:N,orderBy:S,setOperators:[]}),_=void 0,v=void 0,N=void 0,S=[]):b=l(o,g),b=this.buildSelectQuery({table:(0,i.f)(b,$.M)?b:new q.Q(b,{},g),fields:{},fieldsFlat:s.map(({field:e})=>({path:[],field:(0,i.f)(e,t.f)?c(e,g):e})),joins:B,where:_,limit:v,offset:N,orderBy:S,setOperators:[]})}else b=this.buildSelectQuery({table:l(o,g),fields:{},fieldsFlat:w.map(({field:e})=>({path:[],field:(0,i.f)(e,t.f)?c(e,g):e})),joins:B,where:_,limit:v,offset:N,orderBy:S,setOperators:[]});return{tableTsKey:h.tsName,sql:b,selection:w}}}e.s(["f",0,D],53081)},75228,e=>{"use strict";var t=e.i(39774);class i{static [t.h]="Cache"}class r extends i{strategy(){return"all"}static [t.h]="NoopCache";async get(e){}async put(e,t,i,r){}async onMutate(e){}}async function s(e,t){let i=`${e}-${JSON.stringify(t)}`,r=new TextEncoder().encode(i);return[...new Uint8Array(await crypto.subtle.digest("SHA-256",r))].map(e=>e.toString(16).padStart(2,"0")).join("")}e.s(["p",0,r,"t",0,s])},16213,e=>{"use strict";var t=e.i(39774);class i{static [t.h]="ColumnBuilder";config;constructor(e,t,i){this.config={name:e,keyAsName:""===e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:i,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){""===this.config.name&&(this.config.name=e)}}e.s(["f",0,i])},63369,e=>{"use strict";var t=e.i(39774);class i{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static [t.h]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return void 0!==this.config.generated&&"byDefault"!==this.config.generated.type}}e.s(["f",0,i])},39774,e=>{"use strict";let t=Symbol.for("drizzle:entityKind");Symbol.for("drizzle:hasOwnEntityKind"),e.s(["h",0,t,"f",0,function(e,i){if(!e||"object"!=typeof e)return!1;if(e instanceof i)return!0;if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Class "${i.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let r=Object.getPrototypeOf(e).constructor;if(r)for(;r;){if(t in r&&r[t]===i[t])return!0;r=Object.getPrototypeOf(r)}return!1}])},15988,e=>{"use strict";var t=e.i(39774);class i{static [t.h]="ConsoleLogWriter";write(e){console.log(e)}}class r{static [t.h]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new i}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),r=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${r}`)}}class s{static [t.h]="NoopLogger";logQuery(){}}e.s(["P",0,r,"N",0,s])},51521,e=>{"use strict";var t=e.i(66680),i=e.i(2157);e.s(["f",0,function(e){let r=e.migrationsFolder,s=[],n=`${r}/meta/_journal.json`;if(!i.default.existsSync(n))throw Error("Can't find meta/_journal.json file");for(let e of JSON.parse(i.default.readFileSync(`${r}/meta/_journal.json`).toString()).entries){let n=`${r}/${e.tag}.sql`;try{let n=i.default.readFileSync(`${r}/${e.tag}.sql`).toString(),a=n.split("--> statement-breakpoint").map(e=>e);s.push({sql:a,bps:e.breakpoints,folderMillis:e.when,hash:t.default.createHash("sha256").update(n).digest("hex")})}catch{throw Error(`No file ${n} found in ${r} folder`)}}return s}])},96100,e=>e.a(async(t,i)=>{try{var r=e.i(23862),s=e.i(39774),n=e.i(15988),a=e.i(43135),o=e.i(53081),l=e.i(5644),c=e.i(84346),u=e.i(33275),d=t([r,u]);[r,u]=d.then?(await d)():d;class g{constructor(e,t,i={}){this.client=e,this.dialect=t,this.options=i}static [s.h]="NodePgDriver";createSession(e){return new u.f(this.client,this.dialect,e,{logger:this.options.logger,cache:this.options.cache})}}class p extends a.f{static [s.h]="NodePgDatabase"}function h(e,t={}){let i,r,s=new o.f({casing:t.casing});if(!0===t.logger?i=new n.P:!1!==t.logger&&(i=t.logger),t.schema){let e=(0,l.m)(t.schema,l.s);r={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new g(e,s,{logger:i,cache:t.cache}).createSession(r),c=new p(s,a,r);return c.$client=e,c.$cache=t.cache,c.$cache&&(c.$cache.invalidate=t.cache?.onMutate),c}function f(...e){if("string"==typeof e[0])return h(new r.default.Pool({connectionString:e[0]}),e[1]);if((0,c.n)(e[0])){let{connection:t,client:i,...s}=e[0];return i?h(i,s):h(new r.default.Pool("string"==typeof t?{connectionString:t}:t),s)}return h(e[0],e[1])}(f||(f={})).mock=function(e){return h({},e)},e.s(["f",0,f]),i()}catch(e){i(e)}},!1),34382,e=>{"use strict";var t=e.i(51521);async function i(e,i){let r=(0,t.f)(i);await e.dialect.migrate(r,e.session,i)}e.s(["f",0,i])},33275,e=>e.a(async(t,i)=>{try{var r=e.i(23862),s=e.i(75228),n=e.i(39774),a=e.i(15988),o=e.i(33860),l=e.i(33102),c=e.i(3243),u=e.i(84346),d=t([r]);[r]=d.then?(await d)():d;let{Pool:h,types:f}=r.default;class g extends o.F{constructor(e,t,i,r,s,n,a,o,l,c,u){super({sql:t,params:i},s,n,a),this.client=e,this.queryString=t,this.params=i,this.logger=r,this.fields=o,this._isResponseInArrayMode=c,this.customResultMapper=u,this.rawQueryConfig={name:l,text:t,types:{getTypeParser:(e,t)=>e===f.builtins.TIMESTAMPTZ||e===f.builtins.TIMESTAMP||e===f.builtins.DATE||e===f.builtins.INTERVAL||1231===e||1115===e||1185===e||1187===e||1182===e?e=>e:f.getTypeParser(e,t)}},this.queryConfig={name:l,text:t,rowMode:"array",types:{getTypeParser:(e,t)=>e===f.builtins.TIMESTAMPTZ||e===f.builtins.TIMESTAMP||e===f.builtins.DATE||e===f.builtins.INTERVAL||1231===e||1115===e||1185===e||1187===e||1182===e?e=>e:f.getTypeParser(e,t)}}}static [n.h]="NodePgPreparedQuery";rawQueryConfig;queryConfig;async execute(e={}){return c.f.startActiveSpan("drizzle.execute",async()=>{let t=(0,l.X)(this.params,e);this.logger.logQuery(this.rawQueryConfig.text,t);let{fields:i,rawQueryConfig:r,client:s,queryConfig:n,joinsNotNullableMap:a,customResultMapper:o}=this;if(!i&&!o)return c.f.startActiveSpan("drizzle.driver.execute",async e=>(e?.setAttributes({"drizzle.query.name":r.name,"drizzle.query.text":r.text,"drizzle.query.params":JSON.stringify(t)}),this.queryWithCache(r.text,t,async()=>await s.query(r,t))));let d=await c.f.startActiveSpan("drizzle.driver.execute",e=>(e?.setAttributes({"drizzle.query.name":n.name,"drizzle.query.text":n.text,"drizzle.query.params":JSON.stringify(t)}),this.queryWithCache(n.text,t,async()=>await s.query(n,t))));return c.f.startActiveSpan("drizzle.mapResponse",()=>o?o(d.rows):d.rows.map(e=>(0,u.L)(i,e,a)))})}all(e={}){return c.f.startActiveSpan("drizzle.execute",()=>{let t=(0,l.X)(this.params,e);return this.logger.logQuery(this.rawQueryConfig.text,t),c.f.startActiveSpan("drizzle.driver.execute",e=>(e?.setAttributes({"drizzle.query.name":this.rawQueryConfig.name,"drizzle.query.text":this.rawQueryConfig.text,"drizzle.query.params":JSON.stringify(t)}),this.queryWithCache(this.rawQueryConfig.text,t,async()=>this.client.query(this.rawQueryConfig,t)).then(e=>e.rows)))})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class p extends o.W{constructor(e,t,i,r={}){super(t),this.client=e,this.schema=i,this.options=r,this.logger=r.logger??new a.N,this.cache=r.cache??new s.p}static [n.h]="NodePgSession";logger;cache;prepareQuery(e,t,i,r,s,n,a){return new g(this.client,e.sql,e.params,this.logger,this.cache,n,a,t,i,r,s)}async transaction(e,t){let i=this.client instanceof h||Object.getPrototypeOf(this.client).constructor.name.includes("Pool"),r=i?new p(await this.client.connect(),this.dialect,this.schema,this.options):this,s=new m(this.dialect,r,this.schema);await s.execute(l.B`begin${t?l.B` ${s.getTransactionConfigSQL(t)}`:void 0}`);try{let t=await e(s);return await s.execute(l.B`commit`),t}catch(e){throw await s.execute(l.B`rollback`),e}finally{i&&r.client.release()}}async count(e){return Number((await this.execute(e)).rows[0].count)}}class m extends o.Y{static [n.h]="NodePgTransaction";async transaction(e){let t=`sp${this.nestedIndex+1}`,i=new m(this.dialect,this.session,this.schema,this.nestedIndex+1);await i.execute(l.B.raw(`savepoint ${t}`));try{let r=await e(i);return await i.execute(l.B.raw(`release savepoint ${t}`)),r}catch(e){throw await i.execute(l.B.raw(`rollback to savepoint ${t}`)),e}}}e.s(["f",0,p]),i()}catch(e){i(e)}},!1),56892,74372,6097,34950,55464,31902,e=>{"use strict";var t=e.i(39774),i=e.i(16213),r=e.i(63369),s=e.i(76519);class n{static [t.h]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){this.reference=()=>{let{name:t,columns:i,foreignColumns:r}=e();return{name:t,columns:i,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=void 0===e?"no action":e,this}onDelete(e){return this._onDelete=void 0===e?"no action":e,this}build(e){return new a(e,this)}}class a{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [t.h]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),r=t.map(e=>e.name),n=i.map(e=>e.name),a=[this.table[s.f],...r,i[0].table[s.f],...n];return e??`${a.join("_")}_fk`}}e.s(["f",0,n],74372);var o=e.i(39704);function l(e,t){return`${e[s.f]}_${t.join("_")}_unique`}class c{constructor(e,t){this.name=t,this.columns=e}static [t.h]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new u(e,this.columns,this.nullsNotDistinctConfig,this.name)}}t.h;class u{constructor(e,t,i,r){this.table=e,this.columns=t,this.name=r??l(this.table,this.columns.map(e=>e.name)),this.nullsNotDistinct=i}static [t.h]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function d(e,t,i){for(let r=t;r<e.length;r++){let s=e[r];if("\\"===s){r++;continue}if('"'===s)return[e.slice(t,r).replace(/\\/g,""),r+1];if(!i&&(","===s||"}"===s))return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}e.s(["v",0,c,"e",0,l],6097);class h extends i.f{foreignKeyConfigs=[];static [t.h]="PgColumnBuilder";array(e){return new m(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:r})=>(0,o.f)((i,r)=>{let s=new n(()=>({columns:[e],foreignColumns:[i()]}));return r.onUpdate&&s.onUpdate(r.onUpdate),r.onDelete&&s.onDelete(r.onDelete),s.build(t)},i,r))}buildExtraConfigColumn(e){return new g(e,this.config)}}class f extends r.f{constructor(e,t){t.uniqueName||(t.uniqueName=l(e,[t.name])),super(e,t),this.table=e}static [t.h]="PgColumn"}class g extends f{static [t.h]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}}class p{static [t.h]="IndexedColumn";constructor(e,t,i,r){this.name=e,this.keyAsName=t,this.type=i,this.indexConfig=r}name;keyAsName;type;indexConfig}class m extends h{static [t.h]="PgArrayBuilder";constructor(e,t,i){super(e,"array","PgArray"),this.config.baseBuilder=t,this.config.size=i}build(e){let t=this.config.baseBuilder.build(e);return new y(e,this.config,t)}}class y extends f{constructor(e,t,i,r){super(e,t),this.baseColumn=i,this.range=r,this.size=t.size}size;static [t.h]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${"number"==typeof this.size?this.size:""}]`}mapFromDriverValue(e){return"string"==typeof e&&(e=function(e){let[t]=function e(t,i=0){let r=[],s=i,n=!1;for(;s<t.length;){let a=t[s];if(","===a){(n||s===i)&&r.push(""),n=!0,s++;continue}if(n=!1,"\\"===a){s+=2;continue}if('"'===a){let[e,i]=d(t,s+1,!0);r.push(e),s=i;continue}if("}"===a)return[r,s+1];if("{"===a){let[i,n]=e(t,s+1);r.push(i),s=n;continue}let[o,l]=d(t,s,!1);r.push(o),s=l}return[r,s]}(e,1);return t}(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(e,i=!1){let r=e.map(e=>null===e?null:(0,t.f)(this.baseColumn,y)?this.baseColumn.mapToDriverValue(e,!0):this.baseColumn.mapToDriverValue(e));return i?r:function e(t){return`{${t.map(t=>Array.isArray(t)?e(t):"string"==typeof t?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}(r)}}e.s(["E",0,p,"t",0,f,"f",0,h],34950),t.h,t.h;let b=Symbol.for("drizzle:isPgEnum");t.h,t.h,e.s(["f",0,function(e){return!!e&&"function"==typeof e&&b in e&&!0===e[b]}],56892);class w{static [t.h]="Subquery";constructor(e,t,i,r=!1,s=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:i,isWith:r,usedTables:s}}}class v extends w{static [t.h]="WithSubquery"}e.s(["Q",0,w,"Y",0,v],55464);let N=Symbol.for("drizzle:ViewBaseConfig");e.s(["f",0,N],31902)},43135,e=>{"use strict";var t=e.i(39774);class i{static [t.h]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}var r=e.i(261),s=e.i(63369),n=e.i(33102),a=e.i(55464),o=e.i(31902);class l{static [t.h]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,i){if("_"===i)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(i===o.f)return{...e[o.f],selectedFields:new Proxy(e[o.f].selectedFields,this)};if("symbol"==typeof i)return e[i];let c=((0,t.f)(e,a.Q)?e._.selectedFields:(0,t.f)(e,n._)?e[o.f].selectedFields:e)[i];if((0,t.f)(c,n.o.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!c.isSelectionField)return c.sql;let e=c.clone();return e.isSelectionField=!0,e}if((0,t.f)(c,n.o)){if("sql"===this.config.sqlBehavior)return c;throw Error(`You tried to reference "${i}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return(0,t.f)(c,s.f)?this.config.alias?new Proxy(c,new r.Z(new Proxy(c.table,new r.e(this.config.alias,this.config.replaceOriginalName??!1)))):c:"object"!=typeof c||null===c?c:new Proxy(c,new l(this.config))}}var c=e.i(25490),u=e.i(3243),d=e.i(84346),h=e.i(75375);t.h,t.h,e.i(74372),e.i(11302),t.h,e.i(70705),e.i(6097);Symbol.for("drizzle:PgViewConfig");var f=e.i(53081),g=e.i(88443);class p{static [t.h]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class m{static [t.h]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,e.withList&&(this.withList=e.withList),this.distinct=e.distinct}authToken;setToken(e){return this.authToken=e,this}from(e){let i,r=!!this.fields;return i=this.fields?this.fields:(0,t.f)(e,a.Q)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):(0,t.f)(e,g.f)?e[o.f].selectedFields:(0,t.f)(e,n.o)?{}:(0,d.q)(e),new b({table:e,fields:i,isPartialSelect:r,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class y extends p{static [t.h]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:r,dialect:s,withList:n,distinct:a}){for(let o of(super(),this.config={withList:n,table:e,fields:{...t},distinct:a,setOperators:[]},this.isPartialSelect=i,this.session=r,this.dialect=s,this._={selectedFields:t,config:this.config},this.tableName=(0,d.x)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},q(e)))this.usedTables.add(o)}getUsedTables(){return[...this.usedTables]}createJoin(e,i){return(r,s)=>{let u=this.tableName,h=(0,d.x)(r);for(let e of q(r))this.usedTables.add(e);if("string"==typeof h&&this.config.joins?.some(e=>e.alias===h))throw Error(`Alias "${h}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof u&&(this.config.fields={[u]:this.config.fields}),"string"==typeof h&&!(0,t.f)(r,n.o))){let e=(0,t.f)(r,a.Q)?r._.selectedFields:(0,t.f)(r,n._)?r[o.f].selectedFields:r[c.s.Symbol.Columns];this.config.fields[h]=e}if("function"==typeof s&&(s=s(new Proxy(this.config.fields,new l({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:s,table:r,joinType:e,alias:h,lateral:i}),"string"==typeof h)switch(e){case"left":this.joinsNotNullableMap[h]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[h]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[h]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[h]=!1}return this}}leftJoin=this.createJoin("left",!1);leftJoinLateral=this.createJoin("left",!0);rightJoin=this.createJoin("right",!1);innerJoin=this.createJoin("inner",!1);innerJoinLateral=this.createJoin("inner",!0);fullJoin=this.createJoin("full",!1);crossJoin=this.createJoin("cross",!1);crossJoinLateral=this.createJoin("cross",!0);createSetOperator(e,t){return i=>{let r="function"==typeof i?i(v()):i;if(!(0,d.B)(this.getSelectedFields(),r.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:r}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new l({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new l({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new l({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new l({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}for(e,t={}){return this.config.lockingClause={strength:e,config:t},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...q(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...q(e.table));return new Proxy(new a.Q(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new l({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new l({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enable:!0,autoInvalidate:!0}:!1===e?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}}class b extends y{static [t.h]="PgSelect";_prepare(e){let{session:t,config:i,dialect:r,joinsNotNullableMap:s,authToken:n,cacheConfig:a,usedTables:o}=this;if(!t)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let{fields:l}=i;return u.f.startActiveSpan("drizzle.prepareQuery",()=>{let i=(0,d.$)(l),c=t.prepareQuery(r.sqlToQuery(this.getSQL()),i,e,!0,void 0,{type:"select",tables:[...o]},a);return c.joinsNotNullableMap=s,c.setToken(n)})}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>u.f.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken))}function w(e,t){return(i,r,...s)=>{let n=[r,...s].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!(0,d.B)(i.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return i.addSetOperators(n)}}(0,d.X)(b,[i]);let v=()=>({union:N,unionAll:S,intersect:_,intersectAll:B,except:T,exceptAll:$}),N=w("union",!1),S=w("union",!0),_=w("intersect",!1),B=w("intersect",!0),T=w("except",!1),$=w("except",!0);class x{static [t.h]="PgQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=(0,t.f)(e,f.f)?e:void 0,this.dialectConfig=(0,t.f)(e,f.f)?void 0:e}$with=(e,t)=>{let i=this;return{as:r=>("function"==typeof r&&(r=r(i)),new Proxy(new a.Y(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,!0),new l({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;return{select:function(i){return new m({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(e){return new m({fields:e??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})},selectDistinctOn:function(e,i){return new m({fields:i??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:e}})}}}select(e){return new m({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new m({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new m({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||(this.dialect=new f.f(this.dialectConfig)),this.dialect}}var P=g;t.h,t.h,t.h,t.h,t.h,t.h,P.f,t.h;Symbol.for("drizzle:PgMaterializedViewConfig");function q(e){return(0,t.f)(e,h.M)?[e[c.B]?`${e[c.B]}.${e[c.s.Symbol.BaseName]}`:e[c.s.Symbol.BaseName]]:(0,t.f)(e,a.Q)?e._.usedTables??[]:(0,t.f)(e,n.o)?e.usedTables??[]:[]}P.f,t.h;class C extends i{constructor(e,t,i,r){super(),this.session=t,this.dialect=i,this.config={table:e,withList:r}}static [t.h]="PgDelete";config;cacheConfig;where(e){return this.config.where=e,this}returning(e=this.config.table[c.s.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=(0,d.$)(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return u.f.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:"delete",tables:q(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>u.f.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new l({alias:(0,c.P)(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class j{constructor(e,t,i,r,s){this.table=e,this.session=t,this.dialect=i,this.withList=r,this.overridingSystemValue_=s}static [t.h]="PgInsertBuilder";authToken;setToken(e){return this.authToken=e,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let i=e.map(e=>{let i={},r=this.table[c.s.Symbol.Columns];for(let s of Object.keys(e)){let a=e[s];i[s]=(0,t.f)(a,n.o)?a:new n.r(a,r[s])}return i});return new A(this.table,i,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){let i="function"==typeof e?e(new x):e;if(!(0,t.f)(i,n.o)&&!(0,d.B)(this.table[c.b],i._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new A(this.table,i,this.session,this.dialect,this.withList,!0)}}class A extends i{constructor(e,t,i,r,s,n,a){super(),this.session=i,this.dialect=r,this.config={table:e,values:t,withList:s,select:n,overridingSystemValue_:a}}static [t.h]="PgInsert";config;cacheConfig;returning(e=this.config.table[c.s.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=(0,d.$)(e),this}onConflictDoNothing(e={}){if(void 0===e.target)this.config.onConflict=n.B`do nothing`;else{let t="";t=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));let i=e.where?n.B` where ${e.where}`:void 0;this.config.onConflict=n.B`(${n.B.raw(t)})${i} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let t=e.where?n.B` where ${e.where}`:void 0,i=e.targetWhere?n.B` where ${e.targetWhere}`:void 0,r=e.setWhere?n.B` where ${e.setWhere}`:void 0,s=this.dialect.buildUpdateSet(this.config.table,(0,d.o)(this.config.table,e.set)),a="";return a=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=n.B`(${n.B.raw(a)})${i} do update set ${s}${t}${r}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return u.f.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:"insert",tables:q(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>u.f.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new l({alias:(0,c.P)(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class D{constructor(e,t,i,r){this.table=e,this.session=t,this.dialect=i,this.withList=r}static [t.h]="PgUpdateBuilder";authToken;setToken(e){return this.authToken=e,this}set(e){return new Q(this.table,(0,d.o)(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}}class Q extends i{constructor(e,t,i,r,s){super(),this.session=i,this.dialect=r,this.config={set:t,table:e,withList:s,joins:[]},this.tableName=(0,d.x)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{}}static [t.h]="PgUpdate";config;tableName;joinsNotNullableMap;cacheConfig;from(e){let t=(0,d.x)(e);return"string"==typeof t&&(this.joinsNotNullableMap[t]=!0),this.config.from=e,this}getTableLikeFields(e){return(0,t.f)(e,h.M)?e[c.s.Symbol.Columns]:(0,t.f)(e,a.Q)?e._.selectedFields:e[o.f].selectedFields}createJoin(e){return(i,r)=>{let s=(0,d.x)(i);if("string"==typeof s&&this.config.joins.some(e=>e.alias===s))throw Error(`Alias "${s}" is already used in this query`);if("function"==typeof r){let e=this.config.from&&!(0,t.f)(this.config.from,n.o)?this.getTableLikeFields(this.config.from):void 0;r=r(new Proxy(this.config.table[c.s.Symbol.Columns],new l({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new l({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:r,table:i,joinType:e,alias:s}),"string"==typeof s)switch(e){case"left":this.joinsNotNullableMap[s]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[s]=!0;break;case"inner":this.joinsNotNullableMap[s]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[s]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[c.s.Symbol.Columns]),this.config.from)){let i=(0,d.x)(this.config.from);if("string"==typeof i&&this.config.from&&!(0,t.f)(this.config.from,n.o)){let t=this.getTableLikeFields(this.config.from);e[i]=t}for(let i of this.config.joins){let r=(0,d.x)(i.table);if("string"==typeof r&&!(0,t.f)(i.table,n.o)){let t=this.getTableLikeFields(i.table);e[r]=t}}}return this.config.returningFields=e,this.config.returning=(0,d.$)(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){let t=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:"insert",tables:q(this.config.table)},this.cacheConfig);return t.joinsNotNullableMap=this.joinsNotNullableMap,t}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>this._prepare().execute(e,this.authToken);getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new l({alias:(0,c.P)(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}var I=n;class z extends I.o{constructor(e){super(z.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.mapWith(Number),this.session=e.session,this.sql=z.buildCount(e.source,e.filters)}sql;token;static [t.h]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount(e,t){return I.B`(select count(*) from ${e}${I.B.raw(" where ").if(t)}${t})`}static buildCount(e,t){return I.B`select count(*) as count from ${e}${I.B.raw(" where ").if(t)}${t};`}setToken(e){return this.token=e,this}then(e,t){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}}var k=e.i(5644);class F{constructor(e,t,i,r,s,n,a){this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=r,this.tableConfig=s,this.dialect=n,this.session=a}static [t.h]="PgRelationalQueryBuilder";findMany(e){return new L(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return new L(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}class L extends i{constructor(e,t,i,r,s,n,a,o,l){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=r,this.tableConfig=s,this.dialect=n,this.session=a,this.config=o,this.mode=l}static [t.h]="PgRelationalQuery";_prepare(e){return u.f.startActiveSpan("drizzle.prepareQuery",()=>{let{query:t,builtQuery:i}=this._toSQL();return this.session.prepareQuery(i,void 0,e,!0,(e,i)=>{let r=e.map(e=>(0,k.h)(this.schema,this.tableConfig,e,t.selection,i));return"first"===this.mode?r[0]:r})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let e=this._getQuery(),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(e){return this.authToken=e,this}execute(){return u.f.startActiveSpan("drizzle.operation",()=>this._prepare().execute(void 0,this.authToken))}}class O extends i{constructor(e,t,i,r){super(),this.execute=e,this.sql=t,this.query=i,this.mapBatchResult=r}static [t.h]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}class M extends i{constructor(e,t,i){super(),this.session=t,this.dialect=i,this.config={view:e}}static [t.h]="PgRefreshMaterializedView";config;concurrently(){if(void 0!==this.config.withNoData)throw Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(void 0!==this.config.concurrently)throw Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return u.f.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>u.f.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken))}class E{constructor(e,t,i){if(this.dialect=e,this.session=t,this._=i?{schema:i.schema,fullSchema:i.fullSchema,tableNamesMap:i.tableNamesMap,session:t}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:t},this.query={},this._.schema)for(let[r,s]of Object.entries(this._.schema))this.query[r]=new F(i.fullSchema,this._.schema,this._.tableNamesMap,i.fullSchema[r],s,e,t);this.$cache={invalidate:async e=>{}}}static [t.h]="PgDatabase";query;$with=(e,t)=>{let i=this;return{as:r=>("function"==typeof r&&(r=r(new x(i.dialect))),new Proxy(new a.Y(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,!0),new l({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new z({source:e,filters:t,session:this.session})}$cache;with(...e){let t=this;return{select:function(i){return new m({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e})},selectDistinct:function(i){return new m({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})},selectDistinctOn:function(i,r){return new m({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:i}})},update:function(i){return new D(i,t.session,t.dialect,e)},insert:function(i){return new j(i,t.session,t.dialect,e)},delete:function(i){return new C(i,t.session,t.dialect,e)}}}select(e){return new m({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new m({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new m({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new D(e,this.session,this.dialect)}insert(e){return new j(e,this.session,this.dialect)}delete(e){return new C(e,this.session,this.dialect)}refreshMaterializedView(e){return new M(e,this.session,this.dialect)}authToken;execute(e){let t="string"==typeof e?n.B.raw(e):e.getSQL(),i=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(i,void 0,void 0,!1);return new O(()=>r.execute(void 0,this.authToken),t,i,e=>r.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}}e.s(["f",0,E],43135)},11302,e=>{"use strict";var t=e.i(33102),i=e.i(39774),r=e.i(34950);class s{constructor(e,t){this.unique=e,this.name=t}static [i.h]="PgIndexBuilderOn";on(...e){return new n(e.map(e=>{if((0,i.f)(e,t.o))return e;let s=new r.E(e.name,!!e.keyAsName,e.columnType,e.indexConfig);return e.indexConfig=JSON.parse(JSON.stringify(e.defaultConfig)),s}),this.unique,!1,this.name)}onOnly(...e){return new n(e.map(e=>{if((0,i.f)(e,t.o))return e;let s=new r.E(e.name,!!e.keyAsName,e.columnType,e.indexConfig);return e.indexConfig=e.defaultConfig,s}),this.unique,!0,this.name)}using(e,...s){return new n(s.map(e=>{if((0,i.f)(e,t.o))return e;let s=new r.E(e.name,!!e.keyAsName,e.columnType,e.indexConfig);return e.indexConfig=JSON.parse(JSON.stringify(e.defaultConfig)),s}),this.unique,!0,this.name,e)}}class n{static [i.h]="PgIndexBuilder";config;constructor(e,t,i,r,s="btree"){this.config={name:r,columns:e,unique:t,only:i,method:s}}concurrently(){return this.config.concurrently=!0,this}with(e){return this.config.with=e,this}where(e){return this.config.where=e,this}build(e){return new a(this.config,e)}}class a{static [i.h]="PgIndex";config;constructor(e,t){this.config={...e,table:t}}}e.s(["e",0,n,"y",0,function(e){return new s(!1,e)},"v",0,function(e){return new s(!0,e)}])},70705,e=>{"use strict";var t=e.i(39774),i=e.i(75375);class r{static [t.h]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new s(e,this.columns,this.name)}}class s{constructor(e,t,i){this.table=e,this.columns=t,this.name=i}static [t.h]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[i.M.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}e.s(["E",0,r,"_",0,function(...e){return e[0].columns?new r(e[0].columns,e[0].name):new r(e)}])},33860,e=>{"use strict";var t=e.i(75228),i=e.i(39774),r=e.i(39833),s=e.i(33102),n=e.i(3243),a=e.i(43135);class o{constructor(e,t,i,r){this.query=e,this.cache=t,this.queryMetadata=i,this.cacheConfig=r,t&&"all"===t.strategy()&&void 0===r&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),this.cacheConfig?.enable||(this.cacheConfig=void 0)}authToken;getQuery(){return this.query}mapResult(e,t){return e}setToken(e){return this.authToken=e,this}static [i.h]="PgPreparedQuery";joinsNotNullableMap;async queryWithCache(e,s,n){if(void 0===this.cache||(0,i.f)(this.cache,t.p)||void 0===this.queryMetadata||this.cacheConfig&&!this.cacheConfig.enable)try{return await n()}catch(t){throw new r.l(e,s,t)}if(("insert"===this.queryMetadata.type||"update"===this.queryMetadata.type||"delete"===this.queryMetadata.type)&&this.queryMetadata.tables.length>0)try{let[e]=await Promise.all([n(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return e}catch(t){throw new r.l(e,s,t)}if(!this.cacheConfig)try{return await n()}catch(t){throw new r.l(e,s,t)}if("select"===this.queryMetadata.type){let i=await this.cache.get(this.cacheConfig.tag??await (0,t.t)(e,s),this.queryMetadata.tables,void 0!==this.cacheConfig.tag,this.cacheConfig.autoInvalidate);if(void 0===i){let i;try{i=await n()}catch(t){throw new r.l(e,s,t)}return await this.cache.put(this.cacheConfig.tag??await (0,t.t)(e,s),i,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],void 0!==this.cacheConfig.tag,this.cacheConfig.config),i}return i}try{return await n()}catch(t){throw new r.l(e,s,t)}}}class l{constructor(e){this.dialect=e}static [i.h]="PgSession";execute(e,t){return n.f.startActiveSpan("drizzle.operation",()=>n.f.startActiveSpan("drizzle.prepareQuery",()=>this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1)).setToken(t).execute(void 0,t))}all(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1).all()}async count(e,t){return Number((await this.execute(e,t))[0].count)}}class c extends a.f{constructor(e,t,i,r=0){super(e,t,i),this.schema=i,this.nestedIndex=r}static [i.h]="PgTransaction";rollback(){throw new r.b}getTransactionConfigSQL(e){let t=[];return e.isolationLevel&&t.push(`isolation level ${e.isolationLevel}`),e.accessMode&&t.push(e.accessMode),"boolean"==typeof e.deferrable&&t.push(e.deferrable?"deferrable":"not deferrable"),s.B.raw(t.join(" "))}setTransaction(e){return this.session.execute(s.B`set transaction ${this.getTransactionConfigSQL(e)}`)}}e.s(["F",0,o,"W",0,l,"Y",0,c])},75375,45644,23235,53184,12639,41630,1477,41757,75528,10566,45115,e=>{"use strict";var t=e.i(39774),i=e.i(25490),r=e.i(84346),s=e.i(34950),n=s;class a extends n.f{static [t.h]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(e){if(e){let{name:t,...i}=e;this.config.generatedIdentity={type:"always",sequenceName:t,sequenceOptions:i}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(e){if(e){let{name:t,...i}=e;this.config.generatedIdentity={type:"byDefault",sequenceName:t,sequenceOptions:i}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class o extends a{static [t.h]="PgBigInt53Builder";constructor(e){super(e,"number","PgBigInt53")}build(e){return new l(e,this.config)}}class l extends s.t{static [t.h]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class c extends a{static [t.h]="PgBigInt64Builder";constructor(e){super(e,"bigint","PgBigInt64")}build(e){return new u(e,this.config)}}class u extends s.t{static [t.h]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}function d(e,t){let{name:i,config:s}=(0,r.c)(e,t);return"number"===s.mode?new o(i):new c(i)}var h=s;class f extends h.f{static [t.h]="PgBigSerial53Builder";constructor(e){super(e,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new g(e,this.config)}}class g extends h.t{static [t.h]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class p extends h.f{static [t.h]="PgBigSerial64Builder";constructor(e){super(e,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(e){return new m(e,this.config)}}class m extends h.t{static [t.h]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}function y(e,t){let{name:i,config:s}=(0,r.c)(e,t);return"number"===s.mode?new f(i):new p(i)}var b=s;class w extends b.f{static [t.h]="PgBooleanBuilder";constructor(e){super(e,"boolean","PgBoolean")}build(e){return new v(e,this.config)}}class v extends b.t{static [t.h]="PgBoolean";getSQLType(){return"boolean"}}function N(e){return new w(e??"")}e.s(["f",0,N],45644);var S=s;class _ extends S.f{static [t.h]="PgCharBuilder";constructor(e,t){super(e,"string","PgChar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new B(e,this.config)}}class B extends S.t{static [t.h]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}function T(e,t={}){let{name:i,config:s}=(0,r.c)(e,t);return new _(i,s)}var $=s;class x extends $.f{static [t.h]="PgCidrBuilder";constructor(e){super(e,"string","PgCidr")}build(e){return new P(e,this.config)}}class P extends $.t{static [t.h]="PgCidr";getSQLType(){return"cidr"}}function q(e){return new x(e??"")}var C=s;class j extends C.f{static [t.h]="PgCustomColumnBuilder";constructor(e,t,i){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new A(e,this.config)}}class A extends C.t{static [t.h]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function D(e){return(t,i)=>{let{name:s,config:n}=(0,r.c)(t,i);return new j(s,n,e)}}var Q=s,I=e.i(33102),z=s;class k extends z.f{static [t.h]="PgDateColumnBaseBuilder";defaultNow(){return this.default(I.B`now()`)}}class F extends k{static [t.h]="PgDateBuilder";constructor(e){super(e,"date","PgDate")}build(e){return new L(e,this.config)}}class L extends Q.t{static [t.h]="PgDate";getSQLType(){return"date"}mapFromDriverValue(e){return"string"==typeof e?new Date(e):e}mapToDriverValue(e){return e.toISOString()}}class O extends k{static [t.h]="PgDateStringBuilder";constructor(e){super(e,"string","PgDateString")}build(e){return new M(e,this.config)}}class M extends Q.t{static [t.h]="PgDateString";getSQLType(){return"date"}mapFromDriverValue(e){return"string"==typeof e?e:e.toISOString().slice(0,-14)}}function E(e,t){let{name:i,config:s}=(0,r.c)(e,t);return s?.mode==="date"?new F(i):new O(i)}e.s(["r",0,L,"$",0,M,"c",0,E],23235);var V=s;class J extends V.f{static [t.h]="PgDoublePrecisionBuilder";constructor(e){super(e,"number","PgDoublePrecision")}build(e){return new K(e,this.config)}}class K extends V.t{static [t.h]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}function R(e){return new J(e??"")}var U=s;class X extends U.f{static [t.h]="PgInetBuilder";constructor(e){super(e,"string","PgInet")}build(e){return new W(e,this.config)}}class W extends U.t{static [t.h]="PgInet";getSQLType(){return"inet"}}function Y(e){return new X(e??"")}var H=s;class Z extends a{static [t.h]="PgIntegerBuilder";constructor(e){super(e,"number","PgInteger")}build(e){return new G(e,this.config)}}class G extends H.t{static [t.h]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}function ee(e){return new Z(e??"")}e.s(["f",0,ee],53184);var et=s;class ei extends et.f{static [t.h]="PgIntervalBuilder";constructor(e,t){super(e,"string","PgInterval"),this.config.intervalConfig=t}build(e){return new er(e,this.config)}}class er extends et.t{static [t.h]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let e=this.fields?` ${this.fields}`:"",t=this.precision?`(${this.precision})`:"";return`interval${e}${t}`}}function es(e,t={}){let{name:i,config:s}=(0,r.c)(e,t);return new ei(i,s)}var en=s;class ea extends en.f{static [t.h]="PgJsonBuilder";constructor(e){super(e,"json","PgJson")}build(e){return new eo(e,this.config)}}class eo extends en.t{static [t.h]="PgJson";constructor(e,t){super(e,t)}getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if("string"==typeof e)try{return JSON.parse(e)}catch{}return e}}function el(e){return new ea(e??"")}e.s(["E",0,eo,"y",0,el],12639);var ec=s;class eu extends ec.f{static [t.h]="PgJsonbBuilder";constructor(e){super(e,"json","PgJsonb")}build(e){return new ed(e,this.config)}}class ed extends ec.t{static [t.h]="PgJsonb";constructor(e,t){super(e,t)}getSQLType(){return"jsonb"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if("string"==typeof e)try{return JSON.parse(e)}catch{}return e}}function eh(e){return new eu(e??"")}e.s(["Z",0,ed,"y",0,eh],41630);var ef=s;class eg extends ef.f{static [t.h]="PgLineBuilder";constructor(e){super(e,"array","PgLine")}build(e){return new ep(e,this.config)}}class ep extends ef.t{static [t.h]="PgLine";getSQLType(){return"line"}mapFromDriverValue(e){let[t,i,r]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(i),Number.parseFloat(r)]}mapToDriverValue(e){return`{${e[0]},${e[1]},${e[2]}}`}}class em extends ef.f{static [t.h]="PgLineABCBuilder";constructor(e){super(e,"json","PgLineABC")}build(e){return new ey(e,this.config)}}class ey extends ef.t{static [t.h]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(e){let[t,i,r]=e.slice(1,-1).split(",");return{a:Number.parseFloat(t),b:Number.parseFloat(i),c:Number.parseFloat(r)}}mapToDriverValue(e){return`{${e.a},${e.b},${e.c}}`}}function eb(e,t){let{name:i,config:s}=(0,r.c)(e,t);return s?.mode&&"tuple"!==s.mode?new em(i):new eg(i)}var ew=s;class ev extends ew.f{static [t.h]="PgMacaddrBuilder";constructor(e){super(e,"string","PgMacaddr")}build(e){return new eN(e,this.config)}}class eN extends ew.t{static [t.h]="PgMacaddr";getSQLType(){return"macaddr"}}function eS(e){return new ev(e??"")}var e_=s;class eB extends e_.f{static [t.h]="PgMacaddr8Builder";constructor(e){super(e,"string","PgMacaddr8")}build(e){return new eT(e,this.config)}}class eT extends e_.t{static [t.h]="PgMacaddr8";getSQLType(){return"macaddr8"}}function e$(e){return new eB(e??"")}var ex=s;class eP extends ex.f{static [t.h]="PgNumericBuilder";constructor(e,t,i){super(e,"string","PgNumeric"),this.config.precision=t,this.config.scale=i}build(e){return new eq(e,this.config)}}class eq extends ex.t{static [t.h]="PgNumeric";precision;scale;constructor(e,t){super(e,t),this.precision=t.precision,this.scale=t.scale}mapFromDriverValue(e){return"string"==typeof e?e:String(e)}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`numeric(${this.precision}, ${this.scale})`:void 0===this.precision?"numeric":`numeric(${this.precision})`}}class eC extends ex.f{static [t.h]="PgNumericNumberBuilder";constructor(e,t,i){super(e,"number","PgNumericNumber"),this.config.precision=t,this.config.scale=i}build(e){return new ej(e,this.config)}}class ej extends ex.t{static [t.h]="PgNumericNumber";precision;scale;constructor(e,t){super(e,t),this.precision=t.precision,this.scale=t.scale}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}mapToDriverValue=String;getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`numeric(${this.precision}, ${this.scale})`:void 0===this.precision?"numeric":`numeric(${this.precision})`}}class eA extends ex.f{static [t.h]="PgNumericBigIntBuilder";constructor(e,t,i){super(e,"bigint","PgNumericBigInt"),this.config.precision=t,this.config.scale=i}build(e){return new eD(e,this.config)}}class eD extends ex.t{static [t.h]="PgNumericBigInt";precision;scale;constructor(e,t){super(e,t),this.precision=t.precision,this.scale=t.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`numeric(${this.precision}, ${this.scale})`:void 0===this.precision?"numeric":`numeric(${this.precision})`}}function eQ(e,t){let{name:i,config:s}=(0,r.c)(e,t),n=s?.mode;return"number"===n?new eC(i,s?.precision,s?.scale):"bigint"===n?new eA(i,s?.precision,s?.scale):new eP(i,s?.precision,s?.scale)}e.s(["e",0,eq,"D",0,eQ],1477);var eI=s;class ez extends eI.f{static [t.h]="PgPointTupleBuilder";constructor(e){super(e,"array","PgPointTuple")}build(e){return new ek(e,this.config)}}class ek extends eI.t{static [t.h]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(e){if("string"==typeof e){let[t,i]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(i)]}return[e.x,e.y]}mapToDriverValue(e){return`(${e[0]},${e[1]})`}}class eF extends eI.f{static [t.h]="PgPointObjectBuilder";constructor(e){super(e,"json","PgPointObject")}build(e){return new eL(e,this.config)}}class eL extends eI.t{static [t.h]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(e){if("string"==typeof e){let[t,i]=e.slice(1,-1).split(",");return{x:Number.parseFloat(t),y:Number.parseFloat(i)}}return e}mapToDriverValue(e){return`(${e.x},${e.y})`}}function eO(e,t){let{name:i,config:s}=(0,r.c)(e,t);return s?.mode&&"tuple"!==s.mode?new eF(i):new ez(i)}var eM=s;function eE(e,t){let i=new DataView(new ArrayBuffer(8));for(let r=0;r<8;r++)i.setUint8(r,e[t+r]);return i.getFloat64(0,!0)}function eV(e){let t=function(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(Number.parseInt(e.slice(i,i+2),16));return new Uint8Array(t)}(e),i=0,r=t[0];i+=1;let s=new DataView(t.buffer),n=s.getUint32(i,1===r);if(i+=4,0x20000000&n&&(s.getUint32(i,1===r),i+=4),(65535&n)==1){let e=eE(t,i),r=eE(t,i+=8);return i+=8,[e,r]}throw Error("Unsupported geometry type")}class eJ extends eM.f{static [t.h]="PgGeometryBuilder";constructor(e){super(e,"array","PgGeometry")}build(e){return new eK(e,this.config)}}class eK extends eM.t{static [t.h]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(e){return eV(e)}mapToDriverValue(e){return`point(${e[0]} ${e[1]})`}}class eR extends eM.f{static [t.h]="PgGeometryObjectBuilder";constructor(e){super(e,"json","PgGeometryObject")}build(e){return new eU(e,this.config)}}class eU extends eM.t{static [t.h]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(e){let t=eV(e);return{x:t[0],y:t[1]}}mapToDriverValue(e){return`point(${e.x} ${e.y})`}}function eX(e,t){let{name:i,config:s}=(0,r.c)(e,t);return s?.mode&&"tuple"!==s.mode?new eR(i):new eJ(i)}var eW=s;class eY extends eW.f{static [t.h]="PgRealBuilder";constructor(e,t){super(e,"number","PgReal"),this.config.length=t}build(e){return new eH(e,this.config)}}class eH extends eW.t{static [t.h]="PgReal";constructor(e,t){super(e,t)}getSQLType(){return"real"}mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}function eZ(e){return new eY(e??"")}var eG=s;class e0 extends eG.f{static [t.h]="PgSerialBuilder";constructor(e){super(e,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new e1(e,this.config)}}class e1 extends eG.t{static [t.h]="PgSerial";getSQLType(){return"serial"}}function e3(e){return new e0(e??"")}var e5=s;class e4 extends a{static [t.h]="PgSmallIntBuilder";constructor(e){super(e,"number","PgSmallInt")}build(e){return new e7(e,this.config)}}class e7 extends e5.t{static [t.h]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=e=>"string"==typeof e?Number(e):e}function e2(e){return new e4(e??"")}var e6=s;class e8 extends e6.f{static [t.h]="PgSmallSerialBuilder";constructor(e){super(e,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new e9(e,this.config)}}class e9 extends e6.t{static [t.h]="PgSmallSerial";getSQLType(){return"smallserial"}}function te(e){return new e8(e??"")}var tt=s;class ti extends tt.f{static [t.h]="PgTextBuilder";constructor(e,t){super(e,"string","PgText"),this.config.enumValues=t.enum}build(e){return new tr(e,this.config)}}class tr extends tt.t{static [t.h]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function ts(e,t={}){let{name:i,config:s}=(0,r.c)(e,t);return new ti(i,s)}e.s(["f",0,ts],41757);var tn=s;class ta extends k{constructor(e,t,i){super(e,"string","PgTime"),this.withTimezone=t,this.precision=i,this.config.withTimezone=t,this.config.precision=i}static [t.h]="PgTimeBuilder";build(e){return new to(e,this.config)}}class to extends tn.t{static [t.h]="PgTime";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":`(${this.precision})`;return`time${e}${this.withTimezone?" with time zone":""}`}}function tl(e,t={}){let{name:i,config:s}=(0,r.c)(e,t);return new ta(i,s.withTimezone??!1,s.precision)}e.s(["F",0,to,"U",0,tl],75528);var tc=s;class tu extends k{static [t.h]="PgTimestampBuilder";constructor(e,t,i){super(e,"date","PgTimestamp"),this.config.withTimezone=t,this.config.precision=i}build(e){return new td(e,this.config)}}class td extends tc.t{static [t.h]="PgTimestamp";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":` (${this.precision})`;return`timestamp${e}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(e){return"string"==typeof e?new Date(this.withTimezone?e:e+"+0000"):e}mapToDriverValue=e=>e.toISOString()}class th extends k{static [t.h]="PgTimestampStringBuilder";constructor(e,t,i){super(e,"string","PgTimestampString"),this.config.withTimezone=t,this.config.precision=i}build(e){return new tf(e,this.config)}}class tf extends tc.t{static [t.h]="PgTimestampString";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":`(${this.precision})`;return`timestamp${e}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(e){if("string"==typeof e)return e;let t=e.toISOString().slice(0,-1).replace("T"," ");if(this.withTimezone){let i=e.getTimezoneOffset();return`${t}${i<=0?"+":"-"}${Math.floor(Math.abs(i)/60).toString().padStart(2,"0")}`}return t}}function tg(e,t={}){let{name:i,config:s}=(0,r.c)(e,t);return s?.mode==="string"?new th(i,s.withTimezone??!1,s.precision):new tu(i,s?.withTimezone??!1,s?.precision)}e.s(["R",0,td,"y",0,tf,"_",0,tg],10566);var tp=s;class tm extends tp.f{static [t.h]="PgUUIDBuilder";constructor(e){super(e,"string","PgUUID")}defaultRandom(){return this.default(I.B`gen_random_uuid()`)}build(e){return new ty(e,this.config)}}class ty extends tp.t{static [t.h]="PgUUID";getSQLType(){return"uuid"}}function tb(e){return new tm(e??"")}e.s(["I",0,ty,"q",0,tb],45115);var tw=s;class tv extends tw.f{static [t.h]="PgVarcharBuilder";constructor(e,t){super(e,"string","PgVarchar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new tN(e,this.config)}}class tN extends tw.t{static [t.h]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}function tS(e,t={}){let{name:i,config:s}=(0,r.c)(e,t);return new tv(i,s)}var t_=s;class tB extends t_.f{static [t.h]="PgBinaryVectorBuilder";constructor(e,t){super(e,"string","PgBinaryVector"),this.config.dimensions=t.dimensions}build(e){return new tT(e,this.config)}}class tT extends t_.t{static [t.h]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function t$(e,t){let{name:i,config:s}=(0,r.c)(e,t);return new tB(i,s)}var tx=s;class tP extends tx.f{static [t.h]="PgHalfVectorBuilder";constructor(e,t){super(e,"array","PgHalfVector"),this.config.dimensions=t.dimensions}build(e){return new tq(e,this.config)}}class tq extends tx.t{static [t.h]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){return e.slice(1,-1).split(",").map(e=>Number.parseFloat(e))}}function tC(e,t){let{name:i,config:s}=(0,r.c)(e,t);return new tP(i,s)}var tj=s;class tA extends tj.f{static [t.h]="PgSparseVectorBuilder";constructor(e,t){super(e,"string","PgSparseVector"),this.config.dimensions=t.dimensions}build(e){return new tD(e,this.config)}}class tD extends tj.t{static [t.h]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function tQ(e,t){let{name:i,config:s}=(0,r.c)(e,t);return new tA(i,s)}var tI=s;class tz extends tI.f{static [t.h]="PgVectorBuilder";constructor(e,t){super(e,"array","PgVector"),this.config.dimensions=t.dimensions}build(e){return new tk(e,this.config)}}class tk extends tI.t{static [t.h]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){return e.slice(1,-1).split(",").map(e=>Number.parseFloat(e))}}function tF(e,t){let{name:i,config:s}=(0,r.c)(e,t);return new tz(i,s)}let tL=Symbol.for("drizzle:PgInlineForeignKeys"),tO=Symbol.for("drizzle:EnableRLS");class tM extends i.s{static [t.h]="PgTable";static Symbol=Object.assign({},i.s.Symbol,{InlineForeignKeys:tL,EnableRLS:tO});[tL]=[];[tO]=!1;[i.s.Symbol.ExtraConfigBuilder]=void 0;[i.s.Symbol.ExtraConfigColumns]={}}e.s(["M",0,tM,"X",0,(e,t,r)=>(function(e,t,r,s,n=e){let a=new tM(e,s,n),o="function"==typeof t?t({bigint:d,bigserial:y,boolean:N,char:T,cidr:q,customType:D,date:E,doublePrecision:R,inet:Y,integer:ee,interval:es,json:el,jsonb:eh,line:eb,macaddr:eS,macaddr8:e$,numeric:eQ,point:eO,geometry:eX,real:eZ,serial:e3,smallint:e2,smallserial:te,text:ts,time:tl,timestamp:tg,uuid:tb,varchar:tS,bit:t$,halfvec:tC,sparsevec:tQ,vector:tF}):t,l=Object.fromEntries(Object.entries(o).map(([e,t])=>{t.setName(e);let i=t.build(a);return a[tL].push(...t.buildForeignKeys(i,a)),[e,i]})),c=Object.fromEntries(Object.entries(o).map(([e,t])=>(t.setName(e),[e,t.buildExtraConfigColumn(a)]))),u=Object.assign(a,l);return u[i.s.Symbol.Columns]=l,u[i.s.Symbol.ExtraConfigColumns]=c,r&&(u[tM.Symbol.ExtraConfigBuilder]=r),Object.assign(u,{enableRLS:()=>(u[tM.Symbol.EnableRLS]=!0,u)})})(e,t,r,void 0)],75375)},19137,e=>e.a(async(t,i)=>{try{var r=e.i(85801),s=e.i(39774),n=e.i(15988),a=e.i(43135),o=e.i(53081),l=e.i(5644),c=e.i(84346),u=e.i(31279),d=t([r,u]);[r,u]=d.then?(await d)():d;class g{constructor(e,t,i={}){this.client=e,this.dialect=t,this.options=i}static [s.h]="PgliteDriver";createSession(e){return new u.f(this.client,this.dialect,e,{logger:this.options.logger,cache:this.options.cache})}}class p extends a.f{static [s.h]="PgliteDatabase"}function h(e,t={}){let i,r,s=new o.f({casing:t.casing});if(!0===t.logger?i=new n.P:!1!==t.logger&&(i=t.logger),t.schema){let e=(0,l.m)(t.schema,l.s);r={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new g(e,s,{logger:i,cache:t.cache}).createSession(r),c=new p(s,a,r);return c.$client=e,c.$cache=t.cache,c.$cache&&(c.$cache.invalidate=t.cache?.onMutate),c}function f(...e){if(void 0===e[0]||"string"==typeof e[0])return h(new r.PGlite(e[0]),e[1]);if((0,c.n)(e[0])){let{connection:t,client:i,...s}=e[0];if(i)return h(i,s);if("object"==typeof t){let{dataDir:e,...i}=t;return h(new r.PGlite(e,i),s)}return h(new r.PGlite(t),s)}return h(e[0],e[1])}(f||(f={})).mock=function(e){return h({},e)},e.s(["f",0,f]),i()}catch(e){i(e)}},!1),43178,e=>{"use strict";var t=e.i(51521);async function i(e,i){let r=(0,t.f)(i);await e.dialect.migrate(r,e.session,i)}e.s(["f",0,i])},31279,e=>e.a(async(t,i)=>{try{var r=e.i(39774),s=e.i(15988),n=e.i(33860),a=e.i(33102),o=e.i(84346),l=e.i(85801),c=e.i(75228),u=t([l]);[l]=u.then?(await u)():u;class d extends n.F{constructor(e,t,i,r,s,n,a,o,c,u,d){super({sql:t,params:i},s,n,a),this.client=e,this.queryString=t,this.params=i,this.logger=r,this.fields=o,this._isResponseInArrayMode=u,this.customResultMapper=d,this.rawQueryConfig={rowMode:"object",parsers:{[l.types.TIMESTAMP]:e=>e,[l.types.TIMESTAMPTZ]:e=>e,[l.types.INTERVAL]:e=>e,[l.types.DATE]:e=>e,1231:e=>e,1115:e=>e,1185:e=>e,1187:e=>e,1182:e=>e}},this.queryConfig={rowMode:"array",parsers:{[l.types.TIMESTAMP]:e=>e,[l.types.TIMESTAMPTZ]:e=>e,[l.types.INTERVAL]:e=>e,[l.types.DATE]:e=>e,1231:e=>e,1115:e=>e,1185:e=>e,1187:e=>e,1182:e=>e}}}static [r.h]="PglitePreparedQuery";rawQueryConfig;queryConfig;async execute(e={}){let t=(0,a.X)(this.params,e);this.logger.logQuery(this.queryString,t);let{fields:i,client:r,queryConfig:s,joinsNotNullableMap:n,customResultMapper:l,queryString:c,rawQueryConfig:u}=this;if(!i&&!l)return this.queryWithCache(c,t,async()=>await r.query(c,t,u));let d=await this.queryWithCache(c,t,async()=>await r.query(c,t,s));return l?l(d.rows):d.rows.map(e=>(0,o.L)(i,e,n))}all(e={}){let t=(0,a.X)(this.params,e);return this.logger.logQuery(this.queryString,t),this.queryWithCache(this.queryString,t,async()=>await this.client.query(this.queryString,t,this.rawQueryConfig)).then(e=>e.rows)}isResponseInArrayMode(){return this._isResponseInArrayMode}}class h extends n.W{constructor(e,t,i,r={}){super(t),this.client=e,this.schema=i,this.options=r,this.logger=r.logger??new s.N,this.cache=r.cache??new c.p}static [r.h]="PgliteSession";logger;cache;prepareQuery(e,t,i,r,s,n,a){return new d(this.client,e.sql,e.params,this.logger,this.cache,n,a,t,i,r,s)}async transaction(e,t){return this.client.transaction(async i=>{let r=new h(i,this.dialect,this.schema,this.options),s=new f(this.dialect,r,this.schema);return t&&await s.setTransaction(t),e(s)})}async count(e){return Number((await this.execute(e)).rows[0].count)}}class f extends n.Y{static [r.h]="PgliteTransaction";async transaction(e){let t=`sp${this.nestedIndex+1}`,i=new f(this.dialect,this.session,this.schema,this.nestedIndex+1);await i.execute(a.B.raw(`savepoint ${t}`));try{let r=await e(i);return await i.execute(a.B.raw(`release savepoint ${t}`)),r}catch(e){throw await i.execute(a.B.raw(`rollback to savepoint ${t}`)),e}}}e.s(["f",0,h]),i()}catch(e){i(e)}},!1),5644,e=>{"use strict";var t=e.i(25490),i=e.i(63369),r=e.i(39774),s=e.i(70705),n=e.i(36763),a=e.i(96918),o=e.i(33102);class l{constructor(e,i,r){this.sourceTable=e,this.referencedTable=i,this.relationName=r,this.referencedTableName=i[t.s.Symbol.Name]}static [r.h]="Relation";referencedTableName;fieldName}class c{constructor(e,t){this.table=e,this.config=t}static [r.h]="Relations"}class u extends l{constructor(e,t,i,r){super(e,t,i?.relationName),this.config=i,this.isNullable=r}static [r.h]="One";withFieldName(e){let t=new u(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class d extends l{constructor(e,t,i){super(e,t,i?.relationName),this.config=i}static [r.h]="Many";withFieldName(e){let t=new d(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}e.s(["P",0,d,"V",0,u,"s",0,function(e){return{one:function(t,i){return new u(e,t,i,i?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)},many:function(t,i){return new d(e,t,i)}}},"m",0,function(e,i){1===Object.keys(e).length&&"default"in e&&!(0,r.f)(e.default,t.s)&&(e=e.default);let n={},a={},o={};for(let[l,u]of Object.entries(e))if((0,r.f)(u,t.s)){let e=(0,t.I)(u),i=a[e];for(let r of(n[e]=l,o[l]={tsName:l,dbName:u[t.s.Symbol.Name],schema:u[t.s.Symbol.Schema],columns:u[t.s.Symbol.Columns],relations:i?.relations??{},primaryKey:i?.primaryKey??[]},Object.values(u[t.s.Symbol.Columns])))r.primary&&o[l].primaryKey.push(r);let c=u[t.s.Symbol.ExtraConfigBuilder]?.(u[t.s.Symbol.ExtraConfigColumns]);if(c)for(let e of Object.values(c))(0,r.f)(e,s.E)&&o[l].primaryKey.push(...e.columns)}else if((0,r.f)(u,c)){let e,r=(0,t.I)(u.table),s=n[r];for(let[t,n]of Object.entries(u.config(i(u.table))))if(s){let i=o[s];i.relations[t]=n,e&&i.primaryKey.push(...e)}else r in a||(a[r]={relations:{},primaryKey:e}),a[r].relations[t]=n}return{tables:o,tableNamesMap:n}},"l",0,function(){return{and:n.b,between:n.C,eq:n.u,exists:n.v,gt:n.H,gte:n.B,ilike:n.O,inArray:n.y,isNull:n.M,isNotNull:n.E,like:n.D,lt:n.S,lte:n.n,ne:n.c,not:n.R,notBetween:n.e,notExists:n.k,notLike:n.s,notIlike:n.t,notInArray:n.$,or:n.F,sql:o.B}},"u",0,function(){return{sql:o.B,asc:a.M,desc:a.A}},"h",0,function e(t,s,n,a,l=e=>e){let c={};for(let[d,h]of a.entries())if(h.isJson){let i=s.relations[h.tsKey],a=n[d],o="string"==typeof a?JSON.parse(a):a;c[h.tsKey]=(0,r.f)(i,u)?o&&e(t,t[h.relationTableTsKey],o,h.selection,l):o.map(i=>e(t,t[h.relationTableTsKey],i,h.selection,l))}else{let e,t=l(n[d]),s=h.field;e=(0,r.f)(s,i.f)?s:(0,r.f)(s,o.o)?s.decoder:s.sql.decoder,c[h.tsKey]=null===t?null:e.mapFromDriverValue(t)}return c},"J",0,function(e,i,s){if((0,r.f)(s,u)&&s.config)return{fields:s.config.fields,references:s.config.references};let n=i[(0,t.I)(s.referencedTable)];if(!n)throw Error(`Table "${s.referencedTable[t.s.Symbol.Name]}" not found in schema`);let a=e[n];if(!a)throw Error(`Table "${n}" not found in schema`);let o=s.sourceTable,l=i[(0,t.I)(o)];if(!l)throw Error(`Table "${o[t.s.Symbol.Name]}" not found in schema`);let c=[];for(let e of Object.values(a.relations))(s.relationName&&s!==e&&e.relationName===s.relationName||!s.relationName&&e.referencedTable===s.sourceTable)&&c.push(e);if(c.length>1)throw s.relationName?Error(`There are multiple relations with name "${s.relationName}" in table "${n}"`):Error(`There are multiple relations between "${n}" and "${s.sourceTable[t.s.Symbol.Name]}". Please specify relation name`);if(c[0]&&(0,r.f)(c[0],u)&&c[0].config)return{fields:c[0].config.references,references:c[0].config.fields};throw Error(`There is not enough information to infer relation "${l}.${s.fieldName}"`)}])},36763,e=>{"use strict";var t=e.i(63369),i=e.i(39774),r=e.i(25490),s=e.i(33102);function n(e,n){return!(0,s.N)(n)||(0,s.f)(e)||(0,i.f)(e,s.r)||(0,i.f)(e,s.W)||(0,i.f)(e,t.f)||(0,i.f)(e,r.s)||(0,i.f)(e,s._)?e:new s.r(e,n)}e.s(["b",0,function(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new s.o(1===t.length?t:[new s.c("("),s.B.join(t,new s.c(" and ")),new s.c(")")])},"C",0,function(e,t,i){return s.B`${e} between ${n(t,e)} and ${n(i,e)}`},"u",0,(e,t)=>s.B`${e} = ${n(t,e)}`,"v",0,function(e){return s.B`exists ${e}`},"H",0,(e,t)=>s.B`${e} > ${n(t,e)}`,"B",0,(e,t)=>s.B`${e} >= ${n(t,e)}`,"O",0,function(e,t){return s.B`${e} ilike ${t}`},"y",0,function(e,t){return Array.isArray(t)?0===t.length?s.B`false`:s.B`${e} in ${t.map(t=>n(t,e))}`:s.B`${e} in ${n(t,e)}`},"E",0,function(e){return s.B`${e} is not null`},"M",0,function(e){return s.B`${e} is null`},"D",0,function(e,t){return s.B`${e} like ${t}`},"S",0,(e,t)=>s.B`${e} < ${n(t,e)}`,"n",0,(e,t)=>s.B`${e} <= ${n(t,e)}`,"c",0,(e,t)=>s.B`${e} <> ${n(t,e)}`,"R",0,function(e){return s.B`not ${e}`},"e",0,function(e,t,i){return s.B`${e} not between ${n(t,e)} and ${n(i,e)}`},"k",0,function(e){return s.B`not exists ${e}`},"t",0,function(e,t){return s.B`${e} not ilike ${t}`},"$",0,function(e,t){return Array.isArray(t)?0===t.length?s.B`true`:s.B`${e} not in ${t.map(t=>n(t,e))}`:s.B`${e} not in ${n(t,e)}`},"s",0,function(e,t){return s.B`${e} not like ${t}`},"F",0,function(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new s.o(1===t.length?t:[new s.c("("),s.B.join(t,new s.c(" or ")),new s.c(")")])}])},96918,e=>{"use strict";var t=e.i(33102);e.s(["M",0,function(e){return t.B`${e} asc`},"A",0,function(e){return t.B`${e} desc`}])},33102,e=>{"use strict";var t,i=e.i(39774),r=e.i(56892),s=e.i(55464),n=e.i(3243),a=e.i(31902),o=e.i(63369),l=e.i(25490);function c(e){return null!=e&&"function"==typeof e.getSQL}i.h;class u{static [i.h]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new d([this])}}class d{constructor(e){for(let t of(this.queryChunks=e,e))if((0,i.f)(t,l.s)){let e=t[l.s.Symbol.Schema];this.usedTables.push(void 0===e?t[l.s.Symbol.Name]:e+"."+t[l.s.Symbol.Name])}}static [i.h]="SQL";decoder=f;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return n.f.startActiveSpan("drizzle.buildSQL",t=>{let i=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":i.sql,"drizzle.query.params":JSON.stringify(i.params)}),i})}buildQueryFromSourceParams(e,t){let n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:f,escapeName:g,escapeParam:m,prepareTyping:y,inlineParams:b,paramStartIndex:v}=n;var S=e.map(e=>{if((0,i.f)(e,u))return{sql:e.value.join(""),params:[]};if((0,i.f)(e,h))return{sql:g(e.value),params:[]};if(void 0===e)return{sql:"",params:[]};if(Array.isArray(e)){let t=[new u("(")];for(let[i,r]of e.entries())t.push(r),i<e.length-1&&t.push(new u(", "));return t.push(new u(")")),this.buildQueryFromSourceParams(t,n)}if((0,i.f)(e,d))return this.buildQueryFromSourceParams(e.queryChunks,{...n,inlineParams:b||e.shouldInlineParams});if((0,i.f)(e,l.s)){let t=e[l.s.Symbol.Schema],i=e[l.s.Symbol.Name];return{sql:void 0===t||e[l.Y]?g(i):g(t)+"."+g(i),params:[]}}if((0,i.f)(e,o.f)){let i=f.getColumnCasing(e);if("indexes"===t.invokeSource)return{sql:g(i),params:[]};let r=e.table[l.s.Symbol.Schema];return{sql:e.table[l.Y]||void 0===r?g(e.table[l.s.Symbol.Name])+"."+g(i):g(r)+"."+g(e.table[l.s.Symbol.Name])+"."+g(i),params:[]}}if((0,i.f)(e,N)){let t=e[a.f].schema,i=e[a.f].name;return{sql:void 0===t||e[a.f].isAlias?g(i):g(t)+"."+g(i),params:[]}}if((0,i.f)(e,p)){if((0,i.f)(e.value,w))return{sql:m(v.value++,e),params:[e],typings:["none"]};let t=null===e.value?null:e.encoder.mapToDriverValue(e.value);if((0,i.f)(t,d))return this.buildQueryFromSourceParams([t],n);if(b)return{sql:this.mapInlineParam(t,n),params:[]};let r=["none"];return y&&(r=[y(e.encoder)]),{sql:m(v.value++,t),params:[t],typings:r}}return(0,i.f)(e,w)?{sql:m(v.value++,e),params:[e],typings:["none"]}:(0,i.f)(e,d.Aliased)&&void 0!==e.fieldAlias?{sql:g(e.fieldAlias),params:[]}:(0,i.f)(e,s.Q)?e._.isWith?{sql:g(e._.alias),params:[]}:this.buildQueryFromSourceParams([new u("("),e._.sql,new u(") "),new h(e._.alias)],n):(0,r.f)(e)?e.schema?{sql:g(e.schema)+"."+g(e.enumName),params:[]}:{sql:g(e.enumName),params:[]}:c(e)?e.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([e.getSQL()],n):this.buildQueryFromSourceParams([new u("("),e.getSQL(),new u(")")],n):b?{sql:this.mapInlineParam(e,n),params:[]}:{sql:m(v.value++,e),params:[e],typings:["none"]}});let _={sql:"",params:[]};for(let e of S)_.sql+=e.sql,_.params.push(...e.params),e.typings?.length&&(_.typings||(_.typings=[]),_.typings.push(...e.typings));return _}mapInlineParam(e,{escapeString:t}){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return e.toString();if("string"==typeof e)return t(e);if("object"==typeof e){let i=e.toString();return"[object Object]"===i?t(JSON.stringify(e)):t(i)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return void 0===e?this:new d.Aliased(this,e)}mapWith(e){return this.decoder="function"==typeof e?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}}class h{constructor(e){this.value=e}static [i.h]="Name";brand;getSQL(){return new d([this])}}let f={mapFromDriverValue:e=>e},g={mapToDriverValue:e=>e};({...f,...g});class p{constructor(e,t=g){this.value=e,this.encoder=t}static [i.h]="Param";brand;getSQL(){return new d([this])}}function m(e,...t){let i=[];for(let[r,s]of((t.length>0||e.length>0&&""!==e[0])&&i.push(new u(e[0])),t.entries()))i.push(s,new u(e[r+1]));return new d(i)}(t=m||(m={})).empty=function(){return new d([])},t.fromList=function(e){return new d(e)},t.raw=function(e){return new d([new u(e)])},t.join=function(e,t){let i=[];for(let[r,s]of e.entries())r>0&&void 0!==t&&i.push(t),i.push(s);return new d(i)},t.identifier=function(e){return new h(e)},t.placeholder=function(e){return new w(e)},t.param=function(e,t){return new p(e,t)};var y=d||(d={});class b{constructor(e,t){this.sql=e,this.fieldAlias=t}static [i.h]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new b(this.sql,this.fieldAlias)}}y.Aliased=b;class w{constructor(e){this.name=e}static [i.h]="Placeholder";getSQL(){return new d([this])}}let v=Symbol.for("drizzle:IsDrizzleView");class N{static [i.h]="View";[a.f];[v]=!0;constructor({name:e,schema:t,selectedFields:i,query:r}){this[a.f]={name:e,originalName:e,schema:t,selectedFields:i,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new d([this])}}o.f.prototype.getSQL=function(){return new d([this])},l.s.prototype.getSQL=function(){return new d([this])},s.Q.prototype.getSQL=function(){return new d([this])},e.s(["r",0,p,"W",0,w,"o",0,d,"c",0,u,"_",0,N,"X",0,function(e,t){return e.map(e=>{if((0,i.f)(e,w)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if((0,i.f)(e,p)&&(0,i.f)(e.value,w)){if(!(e.value.name in t))throw Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})},"N",0,function(e){return"object"==typeof e&&null!==e&&"mapToDriverValue"in e&&"function"==typeof e.mapToDriverValue},"f",0,c,"B",0,m])},25490,e=>{"use strict";var t=e.i(39774),i=e.i(76519);let r=Symbol.for("drizzle:Schema"),s=Symbol.for("drizzle:Columns"),n=Symbol.for("drizzle:ExtraConfigColumns"),a=Symbol.for("drizzle:OriginalName"),o=Symbol.for("drizzle:BaseName"),l=Symbol.for("drizzle:IsAlias"),c=Symbol.for("drizzle:ExtraConfigBuilder"),u=Symbol.for("drizzle:IsDrizzleTable");class d{static [t.h]="Table";static Symbol={Name:i.f,Schema:r,OriginalName:a,Columns:s,ExtraConfigColumns:n,BaseName:o,IsAlias:l,ExtraConfigBuilder:c};[i.f];[a];[r];[s];[n];[o];[l]=!1;[u]=!0;[c]=void 0;constructor(e,t,s){this[i.f]=this[a]=e,this[r]=t,this[o]=s}}e.s(["b",0,s,"Y",0,l,"B",0,r,"s",0,d,"P",0,function(e){return e[i.f]},"I",0,function(e){return`${e[r]??"public"}.${e[i.f]}`}])},76519,e=>{"use strict";let t=Symbol.for("drizzle:Name");e.s(["f",0,t])},39704,3243,e=>{"use strict";let t,i;function r(e,...t){return e(...t)}e.s(["f",0,r],39704),e.s(["f",0,{startActiveSpan:(e,s)=>t?(i||(i=t.trace.getTracer("drizzle-orm","0.45.4")),r((t,i)=>i.startActiveSpan(e,e=>{try{return s(e)}catch(i){throw e.setStatus({code:t.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{e.end()}}),t,i)):s()}],3243)},84346,e=>{"use strict";var t=e.i(63369),i=e.i(39774),r=e.i(33102),s=e.i(55464),n=e.i(25490),a=e.i(31902);"u"<typeof TextDecoder||new TextDecoder,e.s(["X",0,function(e,t){for(let i of t)for(let t of Object.getOwnPropertyNames(i.prototype))"constructor"!==t&&Object.defineProperty(e.prototype,t,Object.getOwnPropertyDescriptor(i.prototype,t)||Object.create(null))},"c",0,function(e,t){return{name:"string"==typeof e&&e.length>0?e:"",config:"object"==typeof e?e:t}},"q",0,function(e){return e[n.s.Symbol.Columns]},"x",0,function(e){return(0,i.f)(e,s.Q)?e._.alias:(0,i.f)(e,r._)?e[a.f].name:(0,i.f)(e,r.o)?void 0:e[n.s.Symbol.IsAlias]?e[n.s.Symbol.Name]:e[n.s.Symbol.BaseName]},"B",0,function(e,t){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let[e,t]of i.entries())if(t!==r[e])return!1;return!0},"n",0,function(e){if("object"!=typeof e||null===e||"Object"!==e.constructor.name)return!1;if("logger"in e){let t=typeof e.logger;return"boolean"===t||"object"===t&&"function"==typeof e.logger.logQuery||"undefined"===t}if("schema"in e){let t=typeof e.schema;return"object"===t||"undefined"===t}if("casing"in e){let t=typeof e.casing;return"string"===t||"undefined"===t}if("mode"in e)return"default"===e.mode&&"planetscale"===e.mode&&void 0===e.mode;if("connection"in e){let t=typeof e.connection;return"string"===t||"object"===t||"undefined"===t}if("client"in e){let t=typeof e.client;return"object"===t||"function"===t||"undefined"===t}return 0===Object.keys(e).length},"L",0,function(e,a,o){let l={},c=e.reduce((e,{path:c,field:u},d)=>{let h;h=(0,i.f)(u,t.f)?u:(0,i.f)(u,r.o)?u.decoder:(0,i.f)(u,s.Q)?u._.sql.decoder:u.sql.decoder;let f=e;for(let[e,r]of c.entries())if(e<c.length-1)r in f||(f[r]={}),f=f[r];else{let e=a[d],s=f[r]=null===e?null:h.mapFromDriverValue(e);if(o&&(0,i.f)(u,t.f)&&2===c.length){let e=c[0];e in l?"string"==typeof l[e]&&l[e]!==(0,n.P)(u.table)&&(l[e]=!1):l[e]=null===s&&(0,n.P)(u.table)}}return e},{});if(o&&Object.keys(l).length>0)for(let[e,t]of Object.entries(l))"string"!=typeof t||o[t]||(c[e]=null);return c},"o",0,function(e,s){let a=Object.entries(s).filter(([,e])=>void 0!==e).map(([s,a])=>(0,i.f)(a,r.o)||(0,i.f)(a,t.f)?[s,a]:[s,new r.r(a,e[n.s.Symbol.Columns][s])]);if(0===a.length)throw Error("No values to set");return Object.fromEntries(a)},"$",0,function e(a,o){return Object.entries(a).reduce((a,[l,c])=>{if("string"!=typeof l)return a;let u=o?[...o,l]:[l];return(0,i.f)(c,t.f)||(0,i.f)(c,r.o)||(0,i.f)(c,r.o.Aliased)||(0,i.f)(c,s.Q)?a.push({path:u,field:c}):(0,i.f)(c,n.s)?a.push(...e(c[n.s.Symbol.Columns],u)):a.push(...e(c,u)),a},[])}])},80201,e=>{"use strict";var t=e.i(45644),i=e.i(11302),r=e.i(75375),s=e.i(41757),n=e.i(10566);let a=e=>(0,n._)(e,{withTimezone:!0,mode:"date"}),o=(0,r.X)("users",{id:(0,s.f)("id").primaryKey(),name:(0,s.f)("name").notNull(),email:(0,s.f)("email").notNull().unique(),emailVerified:(0,t.f)("email_verified").notNull().default(!1),image:(0,s.f)("image"),createdAt:a("created_at").notNull(),updatedAt:a("updated_at").notNull()}),l=(0,r.X)("sessions",{id:(0,s.f)("id").primaryKey(),expiresAt:a("expires_at").notNull(),token:(0,s.f)("token").notNull().unique(),createdAt:a("created_at").notNull(),updatedAt:a("updated_at").notNull(),ipAddress:(0,s.f)("ip_address"),userAgent:(0,s.f)("user_agent"),userId:(0,s.f)("user_id").notNull().references(()=>o.id,{onDelete:"cascade"}),activeOrganizationId:(0,s.f)("active_organization_id")},e=>[(0,i.y)("sessions_user_idx").on(e.userId)]),c=(0,r.X)("accounts",{id:(0,s.f)("id").primaryKey(),accountId:(0,s.f)("account_id").notNull(),providerId:(0,s.f)("provider_id").notNull(),userId:(0,s.f)("user_id").notNull().references(()=>o.id,{onDelete:"cascade"}),accessToken:(0,s.f)("access_token"),refreshToken:(0,s.f)("refresh_token"),idToken:(0,s.f)("id_token"),accessTokenExpiresAt:a("access_token_expires_at"),refreshTokenExpiresAt:a("refresh_token_expires_at"),scope:(0,s.f)("scope"),password:(0,s.f)("password"),createdAt:a("created_at").notNull(),updatedAt:a("updated_at").notNull()},e=>[(0,i.y)("accounts_user_idx").on(e.userId)]),u=(0,r.X)("verifications",{id:(0,s.f)("id").primaryKey(),identifier:(0,s.f)("identifier").notNull(),value:(0,s.f)("value").notNull(),expiresAt:a("expires_at").notNull(),createdAt:a("created_at").notNull(),updatedAt:a("updated_at").notNull()},e=>[(0,i.y)("verifications_identifier_idx").on(e.identifier)]),d=(0,r.X)("organizations",{id:(0,s.f)("id").primaryKey(),name:(0,s.f)("name").notNull(),slug:(0,s.f)("slug").notNull().unique(),logo:(0,s.f)("logo"),createdAt:a("created_at").notNull(),metadata:(0,s.f)("metadata")}),h=(0,r.X)("members",{id:(0,s.f)("id").primaryKey(),organizationId:(0,s.f)("organization_id").notNull().references(()=>d.id,{onDelete:"cascade"}),userId:(0,s.f)("user_id").notNull().references(()=>o.id,{onDelete:"cascade"}),role:(0,s.f)("role").notNull().default("member"),createdAt:a("created_at").notNull()},e=>[(0,i.v)("members_once").on(e.organizationId,e.userId),(0,i.y)("members_user_idx").on(e.userId)]),f=(0,r.X)("invitations",{id:(0,s.f)("id").primaryKey(),organizationId:(0,s.f)("organization_id").notNull().references(()=>d.id,{onDelete:"cascade"}),email:(0,s.f)("email").notNull(),role:(0,s.f)("role"),status:(0,s.f)("status").notNull().default("pending"),expiresAt:a("expires_at").notNull(),createdAt:a("created_at").notNull(),inviterId:(0,s.f)("inviter_id").notNull().references(()=>o.id,{onDelete:"cascade"})},e=>[(0,i.y)("invitations_organization_idx").on(e.organizationId)]);e.s(["account",0,c,"invitation",0,f,"member",0,h,"organization",0,d,"session",0,l,"user",0,o,"verification",0,u])},6212,e=>e.a(async(t,i)=>{try{var r=e.i(85801),s=e.i(96100),n=e.i(34382),a=e.i(19137),o=e.i(43178),l=e.i(2157),c=e.i(50227),u=e.i(23862),d=e.i(95850);e.i(70903);var h=e.i(30298),f=e.i(18430),g=t([r,s,a,u]);[r,s,a,u]=g.then?(await g)():g;let p=globalThis,m=p.__factoryDb??=function(){if(process.env.VITEST||(0,f.embeddedDb)()){let e=process.env.VITEST?void 0:(0,c.join)(d.f,"db");e&&(0,l.mkdirSync)(d.f,{recursive:!0});let t=new r.PGlite(e);return{db:(0,a.f)(t,{schema:h}),migrate:()=>(0,o.f)((0,a.f)(t,{schema:h}),{migrationsFolder:"./drizzle-pg"})}}let e=(0,f.databaseUrl)();if(!e)throw Error("DATABASE_URL_UNPOOLED is not set. Run `neon env pull` to write it into .env.local.");let t=new u.Pool({connectionString:e,max:5});return t.on("error",e=>console.warn("Database connection dropped:",String(e.message).replace(/postgres(ql)?:\/\/\S+/g,"<url>"))),{db:(0,s.f)(t,{schema:h}),migrate:()=>(0,n.f)((0,s.f)(t,{schema:h}),{migrationsFolder:"./drizzle-pg"})}}(),y=m.db;e.s(["db",0,y,"migrateDb",0,function(){return m.migrate()}]),i()}catch(e){i(e)}},!1),30298,e=>{"use strict";e.S([70903,"approvals,a,attachments,K,claims,N,connectRequests,g,devices,p,events,f,evidence,A,findings,h,jobs,Y,machines,u,nodeRuns,r,orgDatabases,M,personSettings,k,projectMachines,l,projectNotes,F,projects,c,questions,m,runSteps,j,runs,B,usageRecords,Z,workflowVersions,G,workflows,q",0,80201,"account,account,invitation,invitation,member,member,organization,organization,session,session,user,user,verification,verification"])},70903,e=>{"use strict";var t=e.i(33102),i=e.i(45644),r=e.i(11302),s=e.i(53184),n=e.i(75375),a=e.i(70705),o=e.i(41757),l=e.i(80201);let c=(0,n.X)("projects",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull(),name:(0,o.f)("name").notNull(),organizationId:(0,o.f)("organization_id").references(()=>l.organization.id,{onDelete:"cascade"}),repoPath:(0,o.f)("repo_path"),testCommand:(0,o.f)("test_command"),autoApproveLowRisk:(0,i.f)("auto_approve_low_risk").notNull().default(!1),askMode:(0,o.f)("ask_mode"),baseStatus:(0,o.f)("base_status").notNull().default("none"),baseCommit:(0,o.f)("base_commit"),baseLockHash:(0,o.f)("base_lock_hash"),baseMessage:(0,o.f)("base_message"),baseUpdatedAt:(0,o.f)("base_updated_at"),registerSeq:(0,s.f)("register_seq").notNull().default(0),createdAt:(0,o.f)("created_at").notNull()}),u=(0,n.X)("workflows",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),name:(0,o.f)("name").notNull(),draftJson:(0,o.f)("draft_json").notNull(),createdAt:(0,o.f)("created_at").notNull(),updatedAt:(0,o.f)("updated_at").notNull()}),d=(0,n.X)("workflow_versions",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),workflowId:(0,o.f)("workflow_id").notNull().references(()=>u.id,{onDelete:"cascade"}),graphJson:(0,o.f)("graph_json").notNull(),hash:(0,o.f)("hash").notNull(),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,r.y)("workflow_versions_workflow_idx").on(e.workflowId)]),h=(0,n.X)("runs",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),workflowId:(0,o.f)("workflow_id").notNull().references(()=>u.id,{onDelete:"restrict"}),versionId:(0,o.f)("version_id").notNull().references(()=>d.id,{onDelete:"restrict"}),status:(0,o.f)("status").notNull(),request:(0,o.f)("request").notNull(),title:(0,o.f)("title"),titleByPerson:(0,i.f)("title_by_person").notNull().default(!1),stopForMe:(0,i.f)("stop_for_me").notNull().default(!1),memoryJson:(0,o.f)("memory_json"),providerId:(0,o.f)("provider_id").notNull(),machineId:(0,o.f)("machine_id"),reviewJson:(0,o.f)("review_json"),worktreePath:(0,o.f)("worktree_path"),branch:(0,o.f)("branch"),baseCommit:(0,o.f)("base_commit"),parentRunId:(0,o.f)("parent_run_id"),deliveryBase:(0,o.f)("delivery_base"),createdAt:(0,o.f)("created_at").notNull(),startedAt:(0,o.f)("started_at"),finishedAt:(0,o.f)("finished_at")},e=>[(0,r.y)("runs_workflow_idx").on(e.workflowId)]),f=(0,n.X)("node_runs",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),blockId:(0,o.f)("block_id").notNull(),state:(0,o.f)("state").notNull(),attempt:(0,s.f)("attempt").notNull().default(1),summary:(0,o.f)("summary"),failureCause:(0,o.f)("failure_cause"),startedAt:(0,o.f)("started_at"),finishedAt:(0,o.f)("finished_at")},e=>[(0,r.y)("node_runs_run_idx").on(e.runId),(0,r.v)("node_runs_run_block_uq").on(e.runId,e.blockId)]),g=(0,n.X)("run_steps",{runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),stepId:(0,o.f)("step_id").notNull(),resultJson:(0,o.f)("result_json").notNull(),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,a._)({columns:[e.runId,e.stepId]})]),p=(0,n.X)("jobs",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").references(()=>f.id,{onDelete:"cascade"}),kind:(0,o.f)("kind").notNull(),status:(0,o.f)("status").notNull(),payloadJson:(0,o.f)("payload_json").notNull().default("{}"),createdAt:(0,o.f)("created_at").notNull(),updatedAt:(0,o.f)("updated_at").notNull()},e=>[(0,r.y)("jobs_run_idx").on(e.runId)]),m=(0,n.X)("events",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").references(()=>f.id,{onDelete:"cascade"}),sequence:(0,s.f)("sequence").notNull(),type:(0,o.f)("type").notNull(),payloadJson:(0,o.f)("payload_json").notNull(),createdAt:(0,o.f)("created_at").notNull(),deliveredAt:(0,o.f)("delivered_at")},e=>[(0,r.v)("events_run_sequence_uq").on(e.runId,e.sequence)]),y=(0,n.X)("claims",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").notNull().references(()=>f.id,{onDelete:"cascade"}),text:(0,o.f)("text").notNull(),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,r.y)("claims_node_run_idx").on(e.nodeRunId)]),b=(0,n.X)("evidence",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").notNull().references(()=>f.id,{onDelete:"cascade"}),kind:(0,o.f)("kind").notNull(),source:(0,o.f)("source").notNull(),dataJson:(0,o.f)("data_json").notNull(),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,r.y)("evidence_node_run_idx").on(e.nodeRunId)]),w=(0,n.X)("usage_records",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").notNull().references(()=>f.id,{onDelete:"cascade"}),tokens:(0,s.f)("tokens"),costCents:(0,s.f)("cost_cents"),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,r.y)("usage_records_node_run_idx").on(e.nodeRunId)]),v=(0,n.X)("approvals",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").notNull().references(()=>f.id,{onDelete:"cascade"}),decision:(0,o.f)("decision").notNull(),actor:(0,o.f)("actor").notNull(),reason:(0,o.f)("reason"),diffHash:(0,o.f)("diff_hash"),createdAt:(0,o.f)("created_at").notNull(),consumedAt:(0,o.f)("consumed_at"),deliveredAt:(0,o.f)("delivered_at")},e=>[(0,r.y)("approvals_run_idx").on(e.runId)]),N=(0,n.X)("attachments",{id:(0,o.f)("id").primaryKey(),runId:(0,o.f)("run_id").references(()=>h.id,{onDelete:"cascade"}),approvalId:(0,o.f)("approval_id").references(()=>v.id,{onDelete:"cascade"}),questionId:(0,o.f)("question_id"),path:(0,o.f)("path").notNull(),name:(0,o.f)("name").notNull(),mime:(0,o.f)("mime").notNull(),size:(0,s.f)("size").notNull(),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,r.y)("attachments_run_idx").on(e.runId)]),S=(0,n.X)("project_notes",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),text:(0,o.f)("text").notNull(),source:(0,o.f)("source").notNull(),runId:(0,o.f)("run_id"),enabled:(0,i.f)("enabled").notNull().default(!0),createdAt:(0,o.f)("created_at").notNull(),number:(0,s.f)("number"),kind:(0,o.f)("kind").notNull().default("rule"),paths:(0,o.f)("paths"),outcome:(0,o.f)("outcome"),reason:(0,o.f)("reason")},e=>[(0,r.y)("project_notes_project_idx").on(e.projectId),(0,r.v)("project_notes_number_idx").on(e.projectId,e.number)]),_=(0,n.X)("findings",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),round:(0,s.f)("round").notNull(),type:(0,o.f)("type").notNull(),file:(0,o.f)("file"),line:(0,s.f)("line"),problem:(0,o.f)("problem").notNull(),severity:(0,o.f)("severity").notNull(),affectsJson:(0,o.f)("affects_json").notNull(),decisionsJson:(0,o.f)("decisions_json").notNull(),reportersJson:(0,o.f)("reporters_json").notNull(),count:(0,s.f)("count").notNull().default(1),state:(0,o.f)("state").notNull(),reason:(0,o.f)("reason"),reproJson:(0,o.f)("repro_json"),evidenceJson:(0,o.f)("evidence_json"),entryNumber:(0,s.f)("entry_number"),createdAt:(0,o.f)("created_at").notNull(),updatedAt:(0,o.f)("updated_at").notNull()},e=>[(0,r.y)("findings_run_idx").on(e.runId)]),B=(0,n.X)("questions",{id:(0,o.f)("id").primaryKey(),projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),runId:(0,o.f)("run_id").notNull().references(()=>h.id,{onDelete:"cascade"}),nodeRunId:(0,o.f)("node_run_id").notNull().references(()=>f.id,{onDelete:"cascade"}),findingId:(0,o.f)("finding_id"),kind:(0,o.f)("kind").notNull(),text:(0,o.f)("text").notNull(),why:(0,o.f)("why").notNull(),detail:(0,o.f)("detail"),optionsJson:(0,o.f)("options_json").notNull(),recommended:(0,o.f)("recommended"),touchesJson:(0,o.f)("touches_json").notNull(),paths:(0,o.f)("paths"),state:(0,o.f)("state").notNull(),answerOption:(0,o.f)("answer_option"),answerText:(0,o.f)("answer_text"),actor:(0,o.f)("actor"),answeredAt:(0,o.f)("answered_at"),deliveredAt:(0,o.f)("delivered_at"),consumedAt:(0,o.f)("consumed_at"),createdAt:(0,o.f)("created_at").notNull()},e=>[(0,r.y)("questions_run_idx").on(e.runId),(0,r.v)("questions_asked_once").on(e.runId,e.nodeRunId,e.kind,t.B`coalesce(${e.findingId}, '')`).where(t.B`${e.kind} <> 'plan'`),(0,r.v)("questions_plan_open_once").on(e.runId,e.nodeRunId).where(t.B`${e.kind} = 'plan' and ${e.consumedAt} is null`)]),T=(0,n.X)("machines",{id:(0,o.f)("id").primaryKey(),name:(0,o.f)("name").notNull(),createdAt:(0,o.f)("created_at").notNull()}),$=(0,n.X)("project_machines",{projectId:(0,o.f)("project_id").notNull().references(()=>c.id,{onDelete:"cascade"}),machineId:(0,o.f)("machine_id").notNull(),repoPath:(0,o.f)("repo_path"),baseStatus:(0,o.f)("base_status").notNull().default("none"),baseCommit:(0,o.f)("base_commit"),baseLockHash:(0,o.f)("base_lock_hash"),baseMessage:(0,o.f)("base_message"),baseUpdatedAt:(0,o.f)("base_updated_at")},e=>[(0,a._)({columns:[e.projectId,e.machineId]})]),x=(0,n.X)("person_settings",{userId:(0,o.f)("user_id").primaryKey().references(()=>l.user.id,{onDelete:"cascade"}),ai:(0,o.f)("ai")}),P=(0,n.X)("org_databases",{organizationId:(0,o.f)("organization_id").primaryKey().references(()=>l.organization.id,{onDelete:"cascade"}),databaseName:(0,o.f)("database_name").notNull(),roleName:(0,o.f)("role_name").notNull(),url:(0,o.f)("url").notNull(),createdAt:(0,o.f)("created_at").notNull()}),q=(0,n.X)("connect_requests",{code:(0,o.f)("code").primaryKey(),createdAt:(0,o.f)("created_at").notNull(),userId:(0,o.f)("user_id").references(()=>l.user.id,{onDelete:"cascade"}),organizationId:(0,o.f)("organization_id").references(()=>l.organization.id,{onDelete:"cascade"}),approvedAt:(0,o.f)("approved_at"),takenAt:(0,o.f)("taken_at")}),C=(0,n.X)("devices",{id:(0,o.f)("id").primaryKey(),organizationId:(0,o.f)("organization_id").notNull().references(()=>l.organization.id,{onDelete:"cascade"}),userId:(0,o.f)("user_id").notNull().references(()=>l.user.id,{onDelete:"cascade"}),tokenHash:(0,o.f)("token_hash").notNull(),createdAt:(0,o.f)("created_at").notNull(),revokedAt:(0,o.f)("revoked_at")},e=>[(0,r.v)("devices_token_uq").on(e.tokenHash)]);e.s(["a",0,v,"K",0,N,"N",0,y,"g",0,q,"p",0,C,"f",0,m,"A",0,b,"h",0,_,"Y",0,p,"u",0,T,"r",0,f,"M",0,P,"k",0,x,"l",0,$,"F",0,S,"c",0,c,"m",0,B,"j",0,g,"B",0,h,"Z",0,w,"G",0,d,"q",0,u])},95850,e=>{"use strict";var t=e.i(50227);let i=process.env.FACTORY_DATA_DIR??(0,t.join)(process.cwd(),".factory");e.s(["f",0,i])}];
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=_139ug1e85f3h4._.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
module.exports=[62810,e=>{"use strict";var t=e.i(7855);e.s([],85648),e.i(85648),e.i(15874),e.s([],48804),e.i(48804),e.s([],63203),e.i(63203),e.S([t,"array,array,boolean,boolean,discriminatedUnion,discriminatedUnion,enum,enum,literal,literal,number,number,object,object,record,record,string,string,union,union,unknown,unknown"],62810)},55744,e=>{"use strict";var t=e.i(62810);e.s(["z",0,t])},80473,e=>{"use strict";var t=e.i(62810);e.s(["z",0,t])},4147,e=>{"use strict";var t=e.i(62810);e.s(["z",0,t])},71724,e=>{"use strict";var t=e.i(62810);e.s(["z",0,t])},5954,e=>{"use strict";var t=e.i(62810);e.s(["z",0,t])},27308,e=>{"use strict";var t=e.i(82283);function n(e){if(!process.env.FACTORY_HOSTED&&!o(s(e)))return i();let t=e.headers.get("sec-fetch-site");if(null!==t&&"same-origin"!==t&&"none"!==t)return i();let n=e.headers.get("origin");if(null!==n){let t=s(e),r=null;try{r=new URL(n).host}catch{}if(r!==t)return i()}return null}function i(){return Response.json({error:t.f.errors.crossSite},{status:403})}function s(e){return e.headers.get("host")??new URL(e.url).host}let r=new Set(["localhost","127.0.0.1","[::1]"]);function o(e){let t=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0];return r.has(t.toLowerCase())}e.s(["g",0,o,"p",0,n,"f",0,function(e){let i=n(e);return i||("same-origin"!==e.headers.get("sec-fetch-site")?Response.json({error:t.f.gate.browserOnly},{status:403}):null)}])},22009,e=>{"use strict";var t=e.i(72950);let n=[{id:t.y,name:"Claude",bin:"claude",ready:!0,setup:{steps:[{kind:"install",paste:"npm install -g @anthropic-ai/claude-code"},{kind:"signIn",paste:"claude"}],needs:"A Claude subscription (Pro or Max) or an Anthropic API key.",page:"https://claude.com/claude-code"}},{id:t.r,name:"Codex (OpenAI)",short:"Codex",bin:"codex",ready:!0,setup:{steps:[{kind:"install",paste:"npm install -g @openai/codex"},{kind:"signIn",paste:"codex login"}],needs:"A ChatGPT plan that includes Codex, or an OpenAI API key.",page:"https://github.com/openai/codex"}},{id:t.T,name:"GitHub Copilot",short:"Copilot",bin:"copilot",ready:!0,setup:{steps:[{kind:"install",paste:"npm install -g @github/copilot"},{kind:"signIn",paste:"copilot login"}],needs:'A GitHub account with Copilot (the free plan works for a few tasks a month; Pro, Business or Enterprise for regular work). If your Copilot comes from a company, its administrator must allow "Copilot CLI": without that it answers "not authorized to use this Copilot feature".',page:"https://github.com/features/copilot/cli"}}],i=t.y,s=e=>n.find(t=>t.id===e)?.ready===!0,r=/^(opus|sonnet|haiku|fable|claude)\b/i,o=e=>r.test(e),a=/^claude-[a-z]+-\d+(\.\d+)?(-fast)?$/i,l=new Set(["plan","build","review"]);e.s(["R",0,n,"b",0,i,"t",0,function(e,t,n){return s(e)&&(void 0===n||l.has(n))&&"string"==typeof t&&s(t)?t:e},"c",0,function(e,n){return e===t.r?o(n):e===t.T&&o(n)&&!a.test(n)},"q",0,e=>e===t.r||e===t.T,"d",0,o,"y",0,s,"e",0,function(e,t,n=""){return{...Object.fromEntries(Object.entries(e).filter(([e])=>!["ai","model","modelFrontend","modelBackend"].includes(e))),...""===t?{}:{ai:t},...""===n?{}:{model:n}}}])}];
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=_13lb7kts14z5a._.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports=[60338,e=>{"use strict";var t=e.i(56325),r=e.i(44988),n=e.i(18899);e.s(["H",0,function(e){return n.B`count(${e||n.B.raw("*")})`.mapWith(Number)},"y",0,function(e){return n.B`max(${e})`.mapWith((0,r.f)(e,t.f)?e:String)}])},96662,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(49129),a=e.i(24924),s=e.i(92335),o=e.i(82283),l=t([a]);async function c(e){let t=await f(e);return e=>{let r=[];for(let n of t)n.runId===e&&("undo"===n.answerOption?r.pop():"other"===n.answerOption&&n.answerText?.trim()&&r.push(n.answerText.trim()));return r}}[a]=l.then?(await l)():l;let f=async e=>e.length>0?a.r.select().from(s.m).where((0,n.b)((0,n.y)(s.m.runId,e),(0,n.u)(s.m.kind,"direct"))).orderBy((0,i.M)(s.m.createdAt)):[];async function u(e,t){let r=[];for(let t of(await f([e])))"undo"===t.answerOption?r.push({at:t.createdAt,text:null}):"other"===t.answerOption&&t.answerText?.trim()&&r.push({at:t.createdAt,text:t.answerText.trim()});for(let t of(await a.r.select().from(s.a).where((0,n.b)((0,n.u)(s.a.runId,e),(0,n.u)(s.a.decision,"changes")))))t.reason?.trim()&&r.push({at:t.createdAt,text:t.reason.trim()});r.sort((e,t)=>e.at.localeCompare(t.at));let i=[];for(let e of r)null===e.text?i.pop():i.push(e.text);return i.length>0?o.f.review.withLaterAsks(t,i):t}e.s(["P",0,c,"u",0,u]),r()}catch(e){r(e)}},!1),82461,e=>e.a(async(t,r)=>{try{var n=e.i(2157),i=e.i(50227),a=e.i(75225),s=e.i(6561),o=e.i(24924),l=e.i(92335),c=e.i(65272),u=e.i(82283),f=e.i(91138),d=t([o]);[o]=d.then?(await d)():d;let m=(0,i.join)(f.f,"attachments");class y extends Error{}let g=[{mime:"image/png",ext:"png",test:e=>e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))},{mime:"image/jpeg",ext:"jpg",test:e=>255===e[0]&&216===e[1]&&255===e[2]},{mime:"image/gif",ext:"gif",test:e=>"GIF87a"===e.subarray(0,6).toString("ascii")||"GIF89a"===e.subarray(0,6).toString("ascii")},{mime:"image/webp",ext:"webp",test:e=>"RIFF"===e.subarray(0,4).toString("ascii")&&"WEBP"===e.subarray(8,12).toString("ascii")}];async function h(e,t,r=m){let a;if(0===t.length)throw new y(u.f.attachments.notImage);if(t.length>0xa00000)throw new y(u.f.attachments.tooBig(10));let f=(a=g.find(e=>t.length>=12&&e.test(t)))?{mime:a.mime,ext:a.ext}:null;if(!f)throw new y(u.f.attachments.notImage);let d=(0,s.v)();(0,n.mkdirSync)(r,{recursive:!0});let p=(0,i.join)(r,`${d}.${f.ext}`);(0,n.writeFileSync)(p,t),await (0,c.h)()?.put((0,c._)(d,f.ext),t,f.mime);let w=e.replace(/[^\w.\- ]+/g,"_").slice(0,120)||`image.${f.ext}`;return await o.r.insert(l.K).values({id:d,path:p,name:w,mime:f.mime,size:t.length,createdAt:new Date().toISOString()}),{id:d,name:w,mime:f.mime,size:t.length}}async function p(e,t,r=null,n=null){let i=[...new Set(e)].slice(0,6);if(0===i.length)return 0;let s=await o.r.select().from(l.K).where((0,a.b)((0,a.y)(l.K.id,i),(0,a.M)(l.K.runId)));for(let e of s)await o.r.update(l.K).set({runId:t,approvalId:r,questionId:n}).where((0,a.u)(l.K.id,e.id));return s.length}async function w(e,t=null,r=m){let s="string"==typeof t?t:null,u=null!==t&&"object"==typeof t?(0,a.u)(l.K.questionId,t.question):(0,a.b)(s?(0,a.u)(l.K.approvalId,s):(0,a.M)(l.K.approvalId),(0,a.M)(l.K.questionId)),f=await o.r.select().from(l.K).where((0,a.b)((0,a.u)(l.K.runId,e),u)),d=[];for(let e of f){let t=(0,i.extname)(e.path).slice(1)||"png",a=(0,n.existsSync)(e.path)?e.path:(0,i.join)(r,`${e.id}.${t}`);if(!(0,n.existsSync)(a)){let i=await (0,c.h)()?.get((0,c._)(e.id,t));if(!i)continue;(0,n.mkdirSync)(r,{recursive:!0}),(0,n.writeFileSync)(a,i.body)}d.push(a)}return d}e.s(["o",0,m,"F",0,y,"H",0,6,"R",0,0xa00000,"V",0,p,"W",0,w,"r",0,h]),r()}catch(e){r(e)}},!1),120,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(66680),a=e.i(2157),s=e.i(50227),o=e.i(29420),l=e.i(62534),c=e.i(40855),u=e.i(64950),f=e.i(91138),d=t([u]);[u]=d.then?(await d)():d;let v=(0,s.join)(f.f,"bases"),S=["pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","package-lock.json"],k=(e,t)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();function h(e){for(let t of[...S,"package.json"]){let r=(0,s.join)(e,t);if((0,a.existsSync)(r))return`${t}:${(0,i.createHash)("sha256").update((0,a.readFileSync)(r)).digest("hex")}`}return null}let x=(e,t=v)=>(0,s.join)(t,e);function p(e,t,r=v){let n=x(e,r);if((0,a.existsSync)(n))try{if(!t)throw Error("no repository to ask");k(t,["worktree","remove","--force",n])}catch{(0,a.rmSync)(n,{recursive:!0,force:!0})}}async function w(e,t){await (0,u.J)(e,{...t,baseUpdatedAt:new Date().toISOString()})}let I=new Set;async function m(e,t={}){if(I.has(e))return;let r=await (0,u.I)(e);if(!r?.repoPath)return;I.add(e);let n=r.repoPath,i=x(e,t.root);try{await w(e,{baseStatus:"installing",baseMessage:null});let r=(0,o.I)(n),u=r?await (0,o.Y)(n,r):null,f=u?.commit??k(n,["rev-parse","HEAD"]);p(e,n,t.root),(0,a.mkdirSync)((0,s.dirname)(i),{recursive:!0}),k(n,["worktree","prune"]),k(n,["worktree","add","--detach","-q",i,f]);let d=await (t.install??l.F)(i);if(d&&!d.ok)return void await w(e,{baseStatus:"failed",baseCommit:f,baseLockHash:null,baseMessage:(0,c.l)((0,c.h)(d.outputTail).trim().split("\n").slice(-2).join(" "),300)});await w(e,{baseStatus:"ready",baseCommit:f,baseLockHash:h(i),baseMessage:null})}catch(t){await w(e,{baseStatus:"failed",baseMessage:(0,c.l)((0,c.h)(t instanceof Error?t.message:String(t)),300)})}finally{I.delete(e)}}function y(e,t){try{(0,n.execFileSync)("python3",["-I","-c","import ctypes,sys; sys.exit(ctypes.CDLL(None).clonefile(sys.argv[1].encode(), sys.argv[2].encode(), 0))",e,t],{stdio:"ignore",timeout:12e4});return}catch{(0,a.rmSync)(t,{recursive:!0,force:!0})}try{(0,n.execFileSync)("cp",["-cR",e,t],{stdio:"ignore"});return}catch{(0,a.rmSync)(t,{recursive:!0,force:!0})}(0,n.execFileSync)("cp",["-R",e,t],{stdio:"ignore"})}async function g(e,t,r=v){let n=await (0,u.I)(e),i=x(e,r);if(n?.baseStatus!=="ready"||!n.baseLockHash||!(0,a.existsSync)(i))return{copied:!1,reason:"no-base"};if(h(t)!==n.baseLockHash)return{copied:!1,reason:"different-lockfile"};let o=Date.now();try{let e,r;for(let n of(e=[],(r=t=>{for(let n of(0,a.readdirSync)(t,{withFileTypes:!0})){if(!n.isDirectory()||".git"===n.name)continue;let a=(0,s.join)(t,n.name);"node_modules"===n.name?e.push((0,s.relative)(i,a)):r(a)}})(i),e.sort())){let e=(0,s.join)(t,n);(0,a.existsSync)(e)||((0,a.mkdirSync)((0,s.dirname)(e),{recursive:!0}),y((0,s.join)(i,n),e))}return{copied:!0,ms:Date.now()-o}}catch{return{copied:!1,reason:"copy-failed"}}}async function b(e,t){let r=await (0,u.I)(e);if(!r?.repoPath||"ready"!==r.baseStatus)return!1;let a=function(e,t){for(let r of[...S,"package.json"])try{let a=(0,n.execFileSync)("git",["show",`${t}:${r}`],{cwd:e,stdio:["ignore","pipe","ignore"],maxBuffer:0x10000000});return`${r}:${(0,i.createHash)("sha256").update(a).digest("hex")}`}catch{}return null}(r.repoPath,t);return null!==a&&a!==r.baseLockHash}e.s(["y",0,b,"q",0,y,"S",0,g,"F",0,p,"m",0,m]),r()}catch(e){r(e)}},!1),28033,e=>{"use strict";var t=e.i(74533),r=e.i(60526),n=e.i(40855);let i=/^[a-z0-9]+(?:-[a-z0-9]+){1,5}$/,a=new Set("a al an and are as at be by con de del el en es esta este first for from haz in is it la las lo los make me mi my no now of on or para please por primero que se sin so solo the then to un una uno y ya you your ejecuta ejecutar run install pnpm npm yarn bun cambia cambiar change quiero want can could would nada mas more".split(" "));function s(e){let t=(0,n.h)(e).normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/\s+/).filter(e=>!/[/\\]|\.[a-z]{1,4}\b/.test(e)).map(e=>e.replace(/[^a-z0-9]+/g,"")).filter(e=>e.length>1&&!a.has(e)&&!/^\d+(px|rem|em|%)?$/.test(e)),r=[];for(let e of t)if(!r.includes(e)&&([...r,e].join("-").length>48||(r.push(e),5===r.length)))break;return r.length>0?r.join("-"):null}let o=e=>new Promise((n,i)=>{(0,t.execFile)("claude",["-p","--model","haiku","--setting-sources","","--strict-mcp-config",e],{cwd:(0,r.tmpdir)(),timeout:2e4,maxBuffer:65536},(e,t)=>e?i(e):n(t))});async function l(e,t,r=o){let n=`Name a git branch for this change. Reply with ONLY 2 to 5 lowercase English words joined by hyphens that say what changed, nothing else.
|
|
2
|
+
Request: ${e.slice(0,2e3)}
|
|
3
|
+
Files changed: ${t.slice(0,20).join(", ")||"unknown"}`;try{var a;let e,t=(a=await r(n),e=a.trim().split("\n")[0]?.trim().toLowerCase().replace(/^[`'"]+|[`'".]+$/g,"").replace(/^ai\//,"")??"",i.test(e)&&e.length<=48?e:null);if(t)return t}catch{}return s(e)??"change"}async function c(e,t,r=o){let n;if(""===t.trim())return null;let i=`Write a git commit message for this diff. Line 1: an imperative summary of what the code change does, at most 72 characters. Then a blank line, then 1 to 4 short lines starting with "- " saying what changed. English. Reply with the message only.
|
|
4
|
+
What the person asked for (context only): ${e.slice(0,1e3)}
|
|
5
|
+
Diff:
|
|
6
|
+
${t.slice(0,12e3)}`;try{n=await r(i)}catch{return null}let a=n.replace(/```[a-z]*\n?/g,"").trim().split("\n"),s=(a[0]??"").trim().replace(/^["'`]+|["'`]+$/g,"");return s.length<3||s.length>72||/[:!]$/.test(s)||/^(sure|here|okay|ok)\b/i.test(s)?null:{subject:s,body:a.slice(1).filter(e=>!/^\s*(co-authored-by|signed-off-by|generated with)\b/i.test(e)&&!e.includes("🤖")).join("\n").trim().slice(0,800)}}e.s(["q",0,o,"k",0,function(e,t){return`ai/${t}-${e.slice(-6).toLowerCase()}`},"R",0,s,"A",0,l,"s",0,c])},29420,e=>{"use strict";var t=e.i(74533);let r=(e,r)=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim(),n=(e,t)=>{try{return r(e,t)||null}catch{return null}},i=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/;function a(e,t){return!i.test(t)||t.includes("..")?null:n(e,["rev-parse","--verify","--quiet",`refs/heads/${t}^{commit}`])}async function s(e,i){let s=a(e,i);if(!s)return null;if(!n(e,["remote","get-url","origin"]))return{commit:s,fromOrigin:!1};await new Promise(r=>(0,t.execFile)("git",["fetch","--quiet","origin",`refs/heads/${i}:refs/remotes/origin/${i}`],{cwd:e,timeout:2e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},()=>r()));let o=n(e,["rev-parse","--verify","--quiet",`refs/remotes/origin/${i}^{commit}`]);if(!o||o===s)return{commit:s,fromOrigin:!1};try{return r(e,["merge-base","--is-ancestor",s,o]),{commit:o,fromOrigin:!0}}catch{return{commit:s,fromOrigin:!1}}}e.s(["m",0,a,"I",0,function(e){for(let t of[n(e,["symbolic-ref","--quiet","--short","refs/remotes/origin/HEAD"])?.replace(/^origin\//,""),"main","master"])if(t&&a(e,t))return t;return n(e,["symbolic-ref","--quiet","--short","HEAD"])},"Y",0,s])},37857,e=>{"use strict";async function t(){let t,{chromium:r}=await e.A(64351);for(let e of[void 0,"chrome","msedge"])try{return await r.launch(e?{channel:e}:{})}catch(e){t??=e}throw t}e.s(["f",0,t])},16806,e=>{"use strict";let t=/^(__NEXT|NEXT_|INNGEST|TURBOPACK|NODE_ENV$|PORT$|HOSTNAME$|FACTORY_|DATABASE_URL|LOCAL_DATABASE_URL$|NEON_|R2_)/;e.s(["f",0,function(e={},r=process.env){let n={};for(let[e,i]of Object.entries(r))t.test(e)||(n[e]=i);return{...n,...e}}])},65080,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(2157),a=e.i(60526),s=e.i(50227),o=e.i(75225),l=e.i(49129),c=e.i(24924),u=e.i(92335),f=e.i(55372),d=e.i(40855),h=e.i(28033),p=e.i(29420),w=e.i(18536),m=e.i(82283),y=e.i(64950),g=e.i(30188),b=e.i(77954),v=t([c,f,y,b]);[c,f,y,b]=v.then?(await v)():v;class L extends Error{status;kind;constructor(e,t,r){super(e),this.status=t,this.kind=r,this.name="DeliveryError"}}let z=(e,t,r)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",input:r,stdio:["pipe","pipe","pipe"],maxBuffer:0x4000000}).trim();async function S(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!t)return null;let r=await (0,b.v)(e);return{run:t,passedBy:r,eligible:"completed"===t.status&&null!==r&&!!t.worktreePath&&!!t.baseCommit}}async function k(e,t){let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,t))).orderBy((0,l.A)(u.f.sequence)))[0];return r?JSON.parse(r.payloadJson):null}async function x(e){return(await (0,y.I)(e))?.repoPath??null}function I(e){if(!e)return null;try{return z(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}function $(e){try{return z(e,["remote","get-url","origin"]).trim()||null}catch{return null}}async function j(e){var t;let r=await S(e);if(!r)throw new L(m.f.errors.runNotFound,404);let n=await k(e,"run.kept"),i=await k(e,"run.delivered"),a=await k(e,"run.pushed"),s=await (0,y.D)(e),o=await x(r.run.projectId);return{hasRemote:s.here&&(t=o)?null!==$(t):null,here:s.here,machine:s.machine,eligible:r.eligible,passedBy:r.passedBy,kept:!!n,delivered:!!i,branch:n?.branch??r.run.branch,commit:i?.commit??n?.commit??null,files:i?.files??n?.files??[],appliedTo:i?.appliedTo??null,current:I(o),returnTo:(await k(e,"run.switched"))?.from??null,pushed:null!==a&&a.branch===(n?.branch??r.run.branch),pullRequestUrl:a?.pullRequestUrl??null,autoShip:await _(e)}}async function _(e){let t=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.auto_ship"))).orderBy((0,l.A)(u.f.sequence)))[0];if(!t)return null;let r=JSON.parse(t.payloadJson);return{state:r.state??"started",step:r.step??null,reason:r.reason??null,message:r.message??null,at:t.createdAt}}function P(e,t,r="person"){let n=e.worktreePath;if(z(n,["add","-A"]),""!==z(n,["diff","--cached","--name-only"])){let i=e.request.replace(/\s+/g," ").trim(),a="app"===r?`Made by an agent in Plaincrew, run ${e.id}. ${m.f.delivery.passedOnItsOwn}`:`Made by an agent in Plaincrew, run ${e.id}, and approved by a person.`,s=(0,d.h)(i);z(n,["-c","user.name=Plaincrew","-c","user.email=plaincrew@localhost","commit","-q","--no-verify","-m",t?`${(0,d.h)(t.subject)}
|
|
7
|
+
|
|
8
|
+
${t.body?`${(0,d.h)(t.body)}
|
|
9
|
+
|
|
10
|
+
`:""}Asked for: ${(0,d.l)(s,500)}
|
|
11
|
+
|
|
12
|
+
${a}`:`${(0,d.l)(s,72)}
|
|
13
|
+
|
|
14
|
+
${a}`])}return z(n,["rev-parse","HEAD"])}async function E(e){return await k(e,"run.delivered")!==null}let H=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,99}$/;async function A(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],r=t?.worktreePath;if(!t||!r)return[];try{let e=t.deliveryBase??t.baseCommit,n=z(r,["diff","--name-only",e]).split("\n"),i=z(r,["ls-files","--others","--exclude-standard"]).split("\n");return[...new Set([...n,...i].filter(Boolean))].sort()}catch{return[]}}async function B(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],r=t?.worktreePath;if(!t||!r)return"";try{let e=t.deliveryBase??t.baseCommit,n=z(r,["diff",e]),i=z(r,["ls-files","--others","--exclude-standard"]).split("\n").filter(Boolean).map(e=>`new file: ${e}`);return(0,d.h)([n,...i].join("\n"))}catch{return""}}async function T(e){return(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0]?.request??null}async function F(e,t={}){return(0,g.f)(e,async()=>{let r=await (0,y.b)(e);if(r)throw new L(r,409);let i=await S(e);if(!i)throw new L(m.f.errors.runNotFound,404);if(!i.eligible)throw new L(m.f.delivery.notEligible,409);if(await k(e,"run.kept"))return j(e);let{run:a}=i,s=a.worktreePath,l=t.name?.trim()||null;if(null!==l&&!function(e){if(!H.test(e)||e.includes("..")||e.includes("//")||e.endsWith("/")||e.endsWith(".lock")||e.endsWith("."))return!1;try{return(0,n.execFileSync)("git",["check-ref-format","--branch",e],{stdio:"ignore"}),!0}catch{return!1}}(l))throw new L(m.f.delivery.badBranchName,400);let d=a.branch??z(s,["rev-parse","--abbrev-ref","HEAD"]),p=e=>""!==z(s,["branch","--list",e]);if(null!==l&&l!==d&&p(l))throw new L(m.f.delivery.branchExists(l),409);let g=P(a,t.message,i.passedBy??"person"),b=z(s,["diff","--name-only",a.deliveryBase??a.baseCommit,g]).split("\n").filter(Boolean);if(0===b.length)throw new L(m.f.delivery.nothing,409);let v=null===l?await N(a,s,g):null;v&&(await c.r.update(u.B).set({branch:v}).where((0,o.u)(u.B.id,a.id)),d=v);let x=null===v&&(d.startsWith("factory/")||d===(0,w.E)(a.id,a.request)),I=l??(x?t.fallbackName??(0,h.k)(a.id,(0,h.R)(a.request)??"change"):d);return I===d||null===l&&p(I)||(z(s,["branch","-m",I]),await c.r.update(u.B).set({branch:I}).where((0,o.u)(u.B.id,a.id)),d=I),await c.r.transaction(async t=>{await (0,f.f)({runId:e,type:"run.kept",payload:{branch:d,commit:g,files:b}},t)}),j(e)})}async function R(e,t){let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.pr_opened"))).orderBy((0,l.A)(u.f.sequence)).limit(1))[0],i=r?JSON.parse(r.payloadJson).number:void 0;if("number"!=typeof i)return!1;try{let e=(0,n.execFileSync)("gh",["pr","view",String(i),"--json","state"],{cwd:t,encoding:"utf8",timeout:15e3,stdio:["ignore","pipe","ignore"]});if("MERGED"!==JSON.parse(e).state)return!1}catch{return!1}return await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.merged",payload:{number:i}},t)),!0}async function N(e,t,r){if(!e.parentRunId)return null;let n=await k(e.parentRunId,"run.kept");if(!n?.branch||await k(e.parentRunId,"run.merged")||await R(e.parentRunId,t))return null;let i=n.branch;try{let n=z(t,["rev-parse","--verify","--quiet",`refs/heads/${i}^{commit}`]);z(t,["merge-base","--is-ancestor",n,r]);let a=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e.parentRunId)))[0];if(a?.worktreePath)try{z(a.worktreePath,["symbolic-ref","--quiet","--short","HEAD"])===i&&z(a.worktreePath,["checkout","-q","--detach"])}catch{}return z(t,["checkout","-q","-B",i,r]),i}catch{return null}}async function O(e,t={}){return(0,g.f)(e,async()=>{let r=await (0,y.b)(e);if(r)throw new L(r,409);let n=await S(e);if(!n)throw new L(m.f.errors.runNotFound,404);if(!n.eligible)throw new L(m.f.delivery.notEligible,409);if(await k(e,"run.delivered"))return j(e);let l=await (0,y.I)(n.run.projectId),d=l?.repoPath;if(!d)throw new L(m.f.run.noRepository,409);if(""!==z(d,["status","--porcelain"]))throw new L(m.f.delivery.dirty,409);let h=await F(e,t),p=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],w=p.worktreePath,g=p.deliveryBase??p.baseCommit,b=h.commit,v=h.files,x=z(w,["diff","--binary",g,b]),I=(0,i.mkdtempSync)((0,s.join)((0,a.tmpdir)(),"factory-delivery-")),$=(0,s.join)(I,"change.patch");try{(0,i.writeFileSync)($,x.endsWith("\n")?x:`${x}
|
|
15
|
+
`);try{z(d,["apply","--check","--whitespace=nowarn",$])}catch{throw new L(m.f.delivery.conflict(p.branch??""),409)}z(d,["apply","--whitespace=nowarn",$])}finally{(0,i.rmSync)(I,{recursive:!0,force:!0})}return await c.r.transaction(async t=>{await (0,f.f)({runId:e,type:"run.delivered",payload:{branch:h.branch,commit:b,files:v,appliedTo:d}},t)}),j(e)})}function M(e,t){if(""!==z(e,["status","--porcelain","--untracked-files=no"]))throw new L(m.f.delivery.dirty,409);try{z(e,["checkout","-q",t])}catch{throw new L(m.f.delivery.switchFailed(t),409)}}async function C(e){return(0,g.f)(e,async()=>{let t=await (0,y.b)(e);if(t)throw new L(t,409);let r=await S(e);if(!r)throw new L(m.f.errors.runNotFound,404);let n=await k(e,"run.kept");if(!n?.branch)throw new L(m.f.delivery.keepFirst,409);let i=await x(r.run.projectId);if(!i)throw new L(m.f.run.noRepository,409);let a=I(i);if(a===n.branch)return j(e);if(!a)throw new L(m.f.delivery.notOnBranch,409);if(""!==z(i,["status","--porcelain","--untracked-files=no"]))throw new L(m.f.delivery.dirty,409);let s=r.run.worktreePath;if(s)try{z(s,["checkout","-q","--detach"])}catch{}return M(i,n.branch),await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.switched",payload:{branch:n.branch,from:a}},t)),j(e)})}async function D(e){return(0,g.f)(e,async()=>{let t=await (0,y.b)(e);if(t)throw new L(t,409);let r=await S(e);if(!r)throw new L(m.f.errors.runNotFound,404);let n=await k(e,"run.switched");if(!n?.from)throw new L(m.f.delivery.neverSwitched,409);let i=await x(r.run.projectId);if(!i)throw new L(m.f.run.noRepository,409);return I(i)!==n.from&&(M(i,n.from),await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.switched_back",payload:{branch:n.from}},t))),j(e)})}let J=(e,t)=>new Promise((r,i)=>{(0,n.execFile)("git",t,{cwd:e,timeout:6e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},(e,t,n)=>e?i(Error(String(n||e.message))):r(String(t).trim()))});async function q(e){return(0,g.f)(e,async()=>{let t,r=await (0,y.b)(e);if(r)throw new L(r,409);let n=await S(e);if(!n)throw new L(m.f.errors.runNotFound,404);let i=await k(e,"run.kept");if(!i?.branch)throw new L(m.f.delivery.keepFirst,409);let a=i.branch,s=await x(n.run.projectId);if(!s)throw new L(m.f.run.noRepository,409);let o=$(s);if(null===o)throw new L(m.f.delivery.noRemote,409,"no_connection");try{let e=(0,p.I)(s);e&&e!==a&&await J(s,["ls-remote","--heads","origin",`refs/heads/${e}`])===""&&await J(s,["push","--porcelain","origin",`refs/heads/${e}:refs/heads/${e}`]),await J(s,["push","--porcelain","origin",`refs/heads/${a}:refs/heads/${a}`])}catch(t){let e=(0,d.h)(String(t.message)).replace(/[a-z]+:\/\/[^\s]*@/gi,"").trim().split("\n").filter(Boolean).slice(-2).join(" ");throw new L(m.f.delivery.pushFailed((0,d.l)(e,240)),409)}try{z(s,["branch","--set-upstream-to",`origin/${a}`,a])}catch{}let l=(t=/^(?:https?:\/\/(?:[^@/]+@)?github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/.exec(o.trim()))?`https://github.com/${t[1]}/${t[2]}/pull/new/${a}`:null,u=await k(e,"run.pushed");return(u?.branch!==a||(u.pullRequestUrl??null)!==l)&&await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.pushed",payload:{branch:a,pullRequestUrl:l}},t)),j(e)})}e.s(["E",0,L,"D",0,_,"Q",0,A,"s",0,O,"Z",0,j,"w",0,P,"$",0,F,"J",0,function(e){try{return z(e,["remote","get-url","--push","origin"]).trim()||null}catch{return null}},"K",0,$,"c",0,B,"y",0,q,"t",0,T,"P",0,D,"V",0,C,"_",0,function(e){let t=e.worktreePath;if(z(t,["add","-A"]),""!==z(t,["diff","--cached","--name-only"])){let r=e.request.replace(/\s+/g," ").trim();z(t,["-c","user.name=Plaincrew","-c","user.email=plaincrew@localhost","commit","-q","--no-verify","-m",`Unfinished: ${(0,d.l)((0,d.h)(r),60)}
|
|
16
|
+
|
|
17
|
+
Left by an agent in Plaincrew, run ${e.id}, which stopped before a person approved it.`])}return z(t,["rev-parse","HEAD"])},"A",0,E]),r()}catch(e){r(e)}},!1),55372,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(49129),a=e.i(60338),s=e.i(18899),o=e.i(6561),l=e.i(24924),c=e.i(92335),u=t([l]);[l]=u.then?(await u)():u;class m extends Error{runId;constructor(e){super(`Cannot append event: run ${e} does not exist`),this.runId=e,this.name="RunNotFoundError"}}class y extends Error{constructor(e){super(`${e} event requires a payload with a non-empty string blockId`),this.name="InvalidEventPayloadError"}}function f(e){return{id:e.id,runId:e.runId,nodeRunId:e.nodeRunId,sequence:e.sequence,type:e.type,payload:JSON.parse(e.payloadJson),createdAt:e.createdAt}}async function d(e,t){if(t.type.startsWith("node.")){let e=t.payload?.blockId;if("string"!=typeof e||""===e)throw new y(t.type)}let r=(await e.select({projectId:c.B.projectId}).from(c.B).where((0,n.u)(c.B.id,t.runId)))[0];if(!r)throw new m(t.runId);await h(e,t.runId);let i=(await e.select({m:(0,a.y)(c.f.sequence)}).from(c.f).where((0,n.u)(c.f.runId,t.runId)))[0];return f((await e.insert(c.f).values({id:(0,o.v)(),projectId:r.projectId,runId:t.runId,nodeRunId:t.nodeRunId??null,sequence:(i?.m??0)+1,type:t.type,payloadJson:JSON.stringify(t.payload??{}),createdAt:new Date().toISOString()}).returning())[0])}async function h(e,t){await e.execute(s.B`select pg_advisory_xact_lock(hashtext(${t}))`)}async function p(e,t){return t?d(t,e):l.r.transaction(t=>d(t,e))}async function w(e,t){return(await l.r.select().from(c.f).where((0,n.b)((0,n.u)(c.f.runId,e),(0,n.H)(c.f.sequence,t))).orderBy((0,i.M)(c.f.sequence))).map(f)}e.s(["q",0,p,"f",0,function(e,t){return d(t,e)},"J",0,w,"g",0,h]),r()}catch(e){r(e)}},!1),62534,e=>{"use strict";var t=e.i(2157),r=e.i(50227),n=e.i(32374);function i(e){let n=n=>(0,t.existsSync)((0,r.join)(e,n));return n("package.json")?n("pnpm-lock.yaml")?"pnpm install --frozen-lockfile --prefer-offline":n("yarn.lock")?"yarn install --frozen-lockfile":n("bun.lockb")||n("bun.lock")?"bun install --frozen-lockfile":n("package-lock.json")?"npm ci --prefer-offline --no-audit --no-fund":"npm install --no-package-lock --no-audit --no-fund":null}async function a(e,t){let r=i(e);if(!r)return null;let a=new AbortController,s=setTimeout(()=>a.abort(),6e5),o=()=>a.abort();t?.addEventListener("abort",o,{once:!0});try{let t=await (0,n.P)(r,e,a.signal);return{command:r,ok:t.started&&0===t.exitCode,durationMs:t.durationMs,outputTail:t.outputTail}}finally{clearTimeout(s),t?.removeEventListener("abort",o)}}e.s(["d",0,i,"F",0,a])},64950,e=>e.a(async(t,r)=>{try{var n=e.i(2157),i=e.i(60526),a=e.i(50227),s=e.i(75225),o=e.i(6561),l=e.i(24924),c=e.i(92335),u=e.i(82283),f=e.i(91138),d=t([l]);[l]=d.then?(await d)():d;let b=globalThis;function h(){if(process.env.FACTORY_MACHINE_ID)return{id:process.env.FACTORY_MACHINE_ID,name:process.env.FACTORY_MACHINE_NAME??"this computer"};if(b.__factoryMachine)return b.__factoryMachine;let e=process.env.FACTORY_MACHINE_FILE??(0,a.join)(f.f,"machine.json"),t=null;if((0,n.existsSync)(e))try{let r=JSON.parse((0,n.readFileSync)(e,"utf8"));"string"==typeof r.id&&"string"==typeof r.name&&(t={id:r.id,name:r.name})}catch{t=null}return t||(t={id:(0,o.v)(),name:(0,i.hostname)().replace(/\.local$/,"")||"this computer"},(0,n.mkdirSync)((0,a.dirname)(e),{recursive:!0}),(0,n.writeFileSync)(e,JSON.stringify(t,null,2))),b.__factoryMachine=t}async function p(e){return e?(await l.r.select({name:c.u.name}).from(c.u).where((0,s.u)(c.u.id,e)))[0]?.name??null:null}async function w(e,t=l.r){let r=(await t.select().from(c.c).where((0,s.u)(c.c.id,e)))[0];if(!r)return;let n=(await t.select().from(c.l).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,h().id))))[0];return n?{...r,repoPath:n.repoPath,baseStatus:n.baseStatus,baseCommit:n.baseCommit,baseLockHash:n.baseLockHash,baseMessage:n.baseMessage,baseUpdatedAt:n.baseUpdatedAt}:r}async function m(e,t,r=l.r){let n=h().id;if((await r.select().from(c.l).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,n))))[0])return void await r.update(c.l).set(t).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,n)));let i=(await r.select().from(c.c).where((0,s.u)(c.c.id,e)))[0];await r.insert(c.l).values({projectId:e,machineId:n,repoPath:i?.repoPath??null,baseStatus:i?.baseStatus??"none",baseCommit:i?.baseCommit??null,baseLockHash:i?.baseLockHash??null,baseMessage:i?.baseMessage??null,baseUpdatedAt:i?.baseUpdatedAt??null,...t})}async function y(e){let t=(await l.r.select({machineId:c.B.machineId}).from(c.B).where((0,s.u)(c.B.id,e)))[0],r=t?.machineId??null;return{here:null!==r&&r===h().id,machineId:r,machine:await p(r)}}async function g(e){let t=await y(e);return t.here?null:u.f.machine.elsewhere(t.machine)}e.s(["b",0,g,"I",0,w,"D",0,y,"J",0,m,"j",0,h]),r()}catch(e){r(e)}},!1),77954,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(24924),a=e.i(92335),s=t([i]);async function o(e,t=i.r){if((await t.select().from(a.a).where((0,n.b)((0,n.u)(a.a.runId,e),(0,n.u)(a.a.decision,"approved"))))[0])return"person";let r=(await t.select().from(a.B).where((0,n.u)(a.B.id,e)))[0];if(!r)return null;let s=(await t.select().from(a.G).where((0,n.u)(a.G.id,r.versionId)))[0];if(!s)return null;let l=JSON.parse(s.graphJson).blocks.filter(e=>"human"===e.kind).map(e=>e.id);if(0===l.length)return null;let c=new Set((await t.select().from(a.r).where((0,n.b)((0,n.u)(a.r.runId,e),(0,n.u)(a.r.state,"passed")))).filter(e=>l.includes(e.blockId)).map(e=>e.id));return(await t.select().from(a.f).where((0,n.b)((0,n.u)(a.f.runId,e),(0,n.u)(a.f.type,"node.completed")))).some(e=>{if(!e.nodeRunId||!c.has(e.nodeRunId))return!1;try{return!0===JSON.parse(e.payloadJson).autoApproved}catch{return!1}})?"app":null}async function l(e,t=i.r){let r=new Set;if(0===e.length)return r;let s=await t.select({id:a.B.id,versionId:a.B.versionId}).from(a.B).where((0,n.b)((0,n.y)(a.B.id,e),(0,n.u)(a.B.status,"completed")));if(0===s.length)return r;let o=s.map(e=>e.id),c=new Set((await t.select({runId:a.a.runId}).from(a.a).where((0,n.b)((0,n.y)(a.a.runId,o),(0,n.u)(a.a.decision,"approved")))).map(e=>e.runId)),u=new Map;for(let e of(await t.select().from(a.G).where((0,n.y)(a.G.id,[...new Set(s.map(e=>e.versionId))]))))try{u.set(e.id,JSON.parse(e.graphJson).blocks.filter(e=>"human"===e.kind).map(e=>e.id))}catch{u.set(e.id,[])}let f=new Map(s.map(e=>[e.id,e.versionId])),d=new Map;for(let e of(await t.select().from(a.r).where((0,n.b)((0,n.y)(a.r.runId,o),(0,n.u)(a.r.state,"passed")))))u.get(f.get(e.runId)??"")?.includes(e.blockId)&&d.set(e.id,e.runId);if(0===d.size)return r;for(let e of(await t.select().from(a.f).where((0,n.b)((0,n.y)(a.f.nodeRunId,[...d.keys()]),(0,n.u)(a.f.type,"node.completed")))))if(!(!e.nodeRunId||!d.has(e.nodeRunId)||c.has(e.runId)))try{!0===JSON.parse(e.payloadJson).autoApproved&&r.add(e.runId)}catch{}return r}[i]=s.then?(await s)():s,e.s(["v",0,o,"o",0,l]),r()}catch(e){r(e)}},!1),20195,e=>e.a(async(t,r)=>{try{var n=e.i(16806),i=e.i(74533),a=e.i(2157),s=e.i(61095),o=e.i(50227),l=e.i(75225),c=e.i(24924),u=e.i(92335),f=e.i(62534),d=e.i(40855),h=e.i(32374),p=e.i(82283),w=e.i(64950),m=t([c,w]);[c,w]=m.then?(await m)():m;let E=globalThis.__factoryPreviews??=new Map;function y(e,t){let r;try{r=JSON.parse((0,a.readFileSync)((0,o.join)(e,"package.json"),"utf8"))}catch{return null}if(!r.scripts?.dev)return null;let n={...r.dependencies,...r.devDependencies},i=t=>(0,a.existsSync)((0,o.join)(e,t)),s=i("pnpm-lock.yaml")?"pnpm":i("yarn.lock")?"yarn":i("bun.lockb")||i("bun.lock")?"bun":"npm",l=String(t);return{argv:[..."npm"===s?["npm","run","dev","--"]:"yarn"===s?["yarn","dev"]:[s,"run","dev"],...n.next?["-p",l,"-H","127.0.0.1"]:n.vite?["--port",l,"--host","127.0.0.1","--strictPort"]:[]],installArgv:i("node_modules")?null:[s,"install"]}}let A=Promise.resolve();function g(e,t){e.log=(0,d.l)((0,d.h)((0,h.X)(e.log+t.toString())).slice(-4e3),4e3)}async function b(e,t){let r=Date.now()+18e4;for(;Date.now()<r&&"starting"===t.status&&(!t.child||null===t.child.exitCode);)try{return await fetch(e,{signal:AbortSignal.timeout(3e3)}),!0}catch{await new Promise(e=>setTimeout(e,1e3))}return!1}function v(e,t){if(e?.pid)try{process.kill(-e.pid,t)}catch{}}function S(e){let t=E.get(e);return t?{status:t.status,url:t.url,message:t.message,log:t.log}:{status:"stopped",url:null,message:null,log:""}}let B=globalThis.__factoryPreviewSeen??=new Map,T=globalThis;T.__factoryPreviewWatch||(T.__factoryPreviewWatch=setInterval(()=>void function(e=36e4,t=Date.now()){let r=[];for(let[n,i]of[...B]){let a=E.get(n)?.status;"installing"!==a&&"starting"!==a&&"ready"!==a?B.delete(n):t-i>e&&(P(n),r.push(n))}}(),6e4).unref());let F=globalThis.__factoryPreviewStops??=new Map;async function k(e,t){let r=F.get(e)??0,n=await t();return(F.get(e)??0)===r?n:(P(e),S(e))}async function x(e){let t=await (0,w.b)(e);if(t)throw new N(t);let r=E.get(e);if(r&&"failed"!==r.status&&"stopped"!==r.status)return S(e);if(!(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0])throw new N(p.f.preview.noWorktree);if(await I(e)){let t={status:"installing",url:null,message:null,log:"",child:null,port:null};return E.set(e,t),(async()=>{let r=Date.now()+R;for(;Date.now()<r&&"installing"===t.status&&await I(e).catch(()=>!1);)await new Promise(e=>setTimeout(e,1e3));if(E.get(e)===t&&"installing"===t.status){E.delete(e);try{await $(e)}catch(r){E.set(e,{...t,status:"failed",message:r instanceof N?r.message:p.f.preview.failed})}}})(),S(e)}return $(e)}let R=24e4;async function I(e){let t=(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0];return!!t&&("queued"===t.status||"running"===t.status)&&(!(t.worktreePath&&(0,a.existsSync)(t.worktreePath))||"running"===t.status&&!!(0,f.d)(t.worktreePath)&&void 0===(await c.r.select().from(u.f).where((0,l.b)((0,l.u)(u.f.runId,e),(0,l.u)(u.f.type,"run.installed"))))[0])}async function $(e){let t=(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0];if(!t?.worktreePath||!(0,a.existsSync)(t.worktreePath))throw new N(p.f.preview.noWorktree);let r=await (0,w.I)(t.projectId);return P(`site:${t.projectId}`),j(e,t.worktreePath,r?.repoPath??null)}async function j(e,t,r){let l,c=E.get(e);if(c&&"failed"!==c.status&&"stopped"!==c.status)return S(e);let u=await (A=(l=A.then(()=>new Promise((e,t)=>{let r=n=>{if(n>4400)return t(Error("no free port"));let i=(0,s.createServer)();i.once("error",()=>r(n+1)),i.listen(n,"127.0.0.1",()=>i.close(()=>[...E.values()].some(e=>e.port===n&&"failed"!==e.status&&"stopped"!==e.status)?r(n+1):e(n)))};r(4200)}))).then(()=>new Promise(e=>setTimeout(e,0)),()=>void 0),l),f=y(t,u);if(!f)throw new N(p.f.preview.noDevScript);let d={status:f.installArgv?"installing":"starting",url:null,message:null,log:"",child:null,port:u};E.set(e,d),r&&function(e,t){let r=[];for(let n of(0,a.readdirSync)(e))!(!/^\.env(\..+)?$/.test(n)||/\.example$|\.sample$|\.template$/.test(n))&&((0,a.existsSync)((0,o.join)(t,n))||((0,a.copyFileSync)((0,o.join)(e,n),(0,o.join)(t,n)),r.push(n)))}(r,t);let h=(0,n.f)({NODE_ENV:"development",PORT:String(u),HOST:"127.0.0.1",HOSTNAME:"127.0.0.1",BROWSER:"none"});return(async()=>{if(f.installArgv){var e;let r=await (e=f.installArgv,new Promise(r=>{let n=(0,i.spawn)(e[0],e.slice(1),{cwd:t,env:h,detached:!0,stdio:["ignore","pipe","pipe"]});d.child=n,n.stdout?.on("data",e=>g(d,e)),n.stderr?.on("data",e=>g(d,e)),n.once("error",()=>r(null)),n.once("close",e=>r(e))}));if("stopped"===d.status)return;if(0!==r){d.status="failed",d.message=p.f.preview.installFailed;return}d.status="starting"}let r=(0,i.spawn)(f.argv[0],f.argv.slice(1),{cwd:t,env:h,detached:!0,stdio:["ignore","pipe","pipe"]});d.child=r,r.stdout?.on("data",e=>g(d,e)),r.stderr?.on("data",e=>g(d,e)),r.once("close",()=>{("starting"===d.status||"ready"===d.status)&&(d.status="failed",d.message=p.f.preview.exited)});let n=`http://127.0.0.1:${u}/`;await b(n,d)?(d.status="ready",d.url=n):"starting"===d.status&&(d.status="failed",d.message=p.f.preview.neverServed,v(r,"SIGTERM"))})(),S(e)}async function _(e,t=3e5){let r=Date.now()+t;for(;Date.now()<r;){let t=S(e);if("ready"===t.status)return t.url;if("failed"===t.status||"stopped"===t.status)break;await new Promise(e=>setTimeout(e,1e3))}return null}function P(e){F.set(e,(F.get(e)??0)+1),B.delete(e);let t=E.get(e);if(!t)return;t.status="stopped",t.url=null;let r=t.child;v(r,"SIGTERM"),setTimeout(()=>v(r,"SIGKILL"),3e3).unref()}class N extends Error{}let O=globalThis;O.__factoryPreviewExitHook||(O.__factoryPreviewExitHook=!0,process.once("exit",()=>{for(let e of E.values())v(e.child,"SIGKILL")})),e.s(["L",0,N,"n",0,y,"h",0,S,"s",0,e=>k(e,()=>x(e)),"O",0,j,"D",0,P,"m",0,k,"q",0,_,"i",0,function(e){B.set(e,Date.now())}]),r()}catch(e){r(e)}},!1),40855,e=>{"use strict";let t="[redacted]",r=[[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,t],[/\bsk-(?:ant-)?[A-Za-z0-9_-]{16,}/g,t],[/\bgh[pousr]_[A-Za-z0-9]{20,}/g,t],[/\bgithub_pat_[A-Za-z0-9_]{20,}/g,t],[/\bAKIA[0-9A-Z]{16}\b/g,t],[/\bxox[abposr]-[A-Za-z0-9-]{10,}/g,t],[/\b(Bearer)\s+[A-Za-z0-9._~+/=-]{8,}/gi,`$1 ${t}`],[/(["']?[A-Za-z0-9_]*(?:key|token|secret|password|passwd|credential)[A-Za-z0-9_]*["']?\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s"',}]+)/gi,`$1${t}`]],n=/KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL/i,i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e.s(["l",0,function(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`},"h",0,function(e,a=process.env){let s=e;for(let[e,r]of Object.entries(a))r&&!(r.length<8)&&n.test(e)&&(s=s.replace(RegExp(i(r),"g"),t));for(let[e,t]of r)s=s.replace(e,t);return s}])},87345,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(82283);let a=/(^|\/)\.env(\.|$)|secret|credential/i,s=[[a,i.f.risk.areas.secrets],[/auth|login|logout|sign-?in|sign-?up|session|password|oauth|jwt|token/i,i.f.risk.areas.auth],[/payment|billing|stripe|checkout|invoice|subscription|paypal|price|pricing/i,i.f.risk.areas.payments],[/migration|(^|\/)(prisma|supabase|drizzle|db|database)\/|schema\.(prisma|sql|ts)$|\.sql$/i,i.f.risk.areas.database],[/(^|\/)(api|server|actions)\/|(^|\/)(middleware|proxy)\.[jt]s$|route\.[jt]sx?$/i,i.f.risk.areas.server],[/(^|\/)(package\.json|pnpm-lock\.yaml|package-lock\.json|yarn\.lock|bun\.lockb?|tsconfig[^/]*\.json)$|\.config\.[cm]?[jt]s$|(^|\/)\.[a-z]+rc(\.[a-z]+)?$/i,i.f.risk.areas.config],[/(^|\/)(\.github|\.gitlab|\.circleci)\/|(^|\/)(dockerfile|docker-compose[^/]*|vercel\.json|vercel\.ts|fly\.toml|netlify\.toml|render\.yaml|procfile)$/i,i.f.risk.areas.deploy]];function o(e,t){let r=e.toLowerCase(),n=t.toLowerCase();return n.endsWith("/")?r.startsWith(n):r===n}function l(e,t,r=[],n=[]){let a,c,u=[],f=e.reduce((e,t)=>e+t.lines,0);for(let t of(0===e.length&&u.push(i.f.risk.nothingChanged),u.push(...(a=[...new Set(r)].flatMap(t=>{let r=e.filter(e=>o(e.path,t));return r.length>0?[i.f.risk.insideCore(r[0].path,t,r.length-1)]:[]})).length>5?[...a.slice(0,5),i.f.risk.moreCore(a.length-5)]:a),u.push(...(c=n.flatMap(t=>{let r=e.find(e=>t.paths.some(t=>o(e.path,t)));return r?[i.f.risk.onDecision(r.path,t.text)]:[]})).length>5?[...c.slice(0,5),i.f.risk.moreDecisions(c.length-5)]:c),e)){let e=s.find(([e])=>e.test(t.path));e&&u.push(i.f.risk.touches(t.path,e[1]))}e.length>8&&u.push(i.f.risk.tooManyFiles(e.length,8)),f>300&&u.push(i.f.risk.tooManyLines(f,300)),t.testsRan?t.testsPassed||u.push(i.f.risk.testsFailed):u.push(i.f.risk.noTests),t.testsChanged&&u.push(i.f.risk.testsChanged),t.reviewOpen&&u.push(i.f.risk.reviewStillOpen),t.reviewUnchecked&&u.push(i.f.risk.fixUnchecked),t.reviewUnreadable&&u.push(i.f.risk.reviewUnreadable);let d=0===u.length?"low":"high",h=t.testsChanged||!t.testsRan,p="high"===d&&h&&u.every(e=>e===i.f.risk.noTests||e===i.f.risk.testsChanged);return{level:d,reasons:"low"===d?[i.f.risk.lowBecause(e.length,f)]:u,files:e.map(e=>e.path),linesChanged:f,...p?{onlyTests:p}:{}}}e.s(["Q",0,a,"y",0,s,"r",0,function(e,a,s,o=[],c=[]){try{return l(function(e,i){let a=r=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),s=[];for(let e of a(["diff","--numstat","-z","--no-renames",i]).split("\0")){let[t,r,...n]=e.split(" "),i=n.join(" ");if(!i)continue;let a=e=>void 0===e||"-"===e?1:Number(e);s.push({path:i,lines:a(t)+a(r)})}let o=new Set(s.map(e=>e.path));return[...s,...a(["ls-files","--others","--exclude-standard","-z"]).split("\0").filter(e=>e&&!o.has(e)).map(t=>{let i=1;try{i=Math.max(1,(0,r.readFileSync)((0,n.join)(e,t),"utf8").split("\n").length)}catch{}return{path:t,lines:i}})]}(e,a),s,o,c)}catch{return{level:"high",reasons:[i.f.risk.unreadable],files:[],linesChanged:0}}},"F",0,l,"B",0,o])},30188,e=>{"use strict";var t=e.i(78500);let r=globalThis,n=r.__factorySerial??=new Map,i=new t.AsyncLocalStorage;async function a(e,t){let r,a=i.getStore();if(a?.has(e))return t();let s=n.get(e)??Promise.resolve(),o=new Promise(e=>r=e),l=s.then(()=>o);n.set(e,l),await s.catch(()=>void 0);try{return await i.run(new Set([...a??[],e]),t)}finally{r(),n.get(e)===l&&n.delete(e)}}e.s(["f",0,a])},69608,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(66680),a=e.i(2157),s=e.i(50227),o=e.i(75225),l=e.i(49129),c=e.i(24924),u=e.i(92335),f=e.i(120),d=e.i(65080),h=e.i(55372),p=e.i(20195),w=e.i(40855),m=e.i(82283),y=e.i(64950),g=e.i(65272),b=e.i(26955),v=e.i(91138),S=e.i(37857),k=t([c,f,d,h,p,y]);[c,f,d,h,p,y]=k.then?(await k)():k;let T=(0,s.join)(v.f,"snapshots"),F=["before-desktop","after-desktop","before-mobile","after-mobile"],R={desktop:{viewport:{width:1440,height:900},deviceScaleFactor:1},mobile:{viewport:{width:390,height:844},deviceScaleFactor:2,isMobile:!0,hasTouch:!0}},N=async(e,t)=>{let r=await (0,S.f)();try{for(let n of["desktop","mobile"]){let i=await r.newContext(R[n]),a=await i.newPage();await a.goto(e,{waitUntil:"load",timeout:12e4}),await a.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await a.waitForTimeout(1500),await a.screenshot({path:t[n]}),await i.close()}}finally{await r.close()}},O='[role="tab"]:not([aria-selected="true"]), summary, button[aria-expanded="false"]',M=async(e,t,r)=>{let n=await (0,S.f)();try{let i=await n.newContext(R.desktop),[a,s,o]=[await i.newPage(),await i.newPage(),await i.newPage()],l=async(e,t)=>{await e.goto(t,{waitUntil:"load",timeout:12e4}),await e.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await e.waitForTimeout(1200)},c=e=>e.screenshot({animations:"disabled"}),u=(e,t)=>o.evaluate(async([e,t])=>{let r=e=>new Promise((t,r)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>r(Error("picture")),n.src=`data:image/png;base64,${e}`}),[n,i]=await Promise.all([r(e),r(t)]);if(n.width!==i.width||n.height!==i.height)return 1;let a=e=>{let t=document.createElement("canvas");t.width=e.width,t.height=e.height;let r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height).data},[s,o]=[a(n),a(i)],l=0;for(let e=0;e<s.length;e+=4)Math.abs(s[e]-o[e])+Math.abs(s[e+1]-o[e+1])+Math.abs(s[e+2]-o[e+2])>48&&l++;return l/(s.length/4)},[e.toString("base64"),t.toString("base64")]),f=async(e,t,r)=>{let n=e.locator(O),i=r?n.filter({hasText:r}).first():null,a=i&&await i.count()>0?i:n.nth(t);await a.count()!==0&&(await a.click({timeout:4e3}).catch(()=>void 0),await e.waitForLoadState("networkidle",{timeout:8e3}).catch(()=>void 0),await e.waitForTimeout(1200))};if(await Promise.all([l(a,e),l(s,t)]),await u(await c(a),await c(s))>3e-4)return null;let d=(e,t,r)=>o.evaluate(async([e,t,r])=>{let n=e=>new Promise((t,r)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>r(Error("picture")),n.src=`data:image/png;base64,${e}`}),[i,a]=await Promise.all([n(e),n(t)]),s=Math.min(i.width,a.width),o=Math.min(i.height,a.height);if(0===s||0===o||Math.max(i.height,a.height)>16e3)return null;let l=e=>{let t=document.createElement("canvas");t.width=s,t.height=o;let r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,s,o).data},[c,u]=[l(i),l(a)],f=Math.max(4,Math.floor(.004*s));for(let e=0;e<o;e++){let t=0;for(let n=e*s*4,i=n+4*s;n<i;n+=4)if(Math.abs(c[n]-u[n])+Math.abs(c[n+1]-u[n+1])+Math.abs(c[n+2]-u[n+2])>48&&++t>=f)return Math.floor(e/r)}return i.height!==a.height?Math.floor(o/r):null},[e.toString("base64"),t.toString("base64"),r]),h=!1;for(let o of["desktop","mobile"]){let c="desktop"===o?i:await n.newContext(R[o]),[u,f]="desktop"===o?[a,s]:[await c.newPage(),await c.newPage()];"desktop"!==o&&await Promise.all([l(u,e),l(f,t)]);let p=e=>e.screenshot({fullPage:!0,animations:"disabled"}),w=await d(await p(u),await p(f),R[o].deviceScaleFactor).catch(()=>null);if(null===w)continue;let m=Math.max(0,w-180);await Promise.all([u,f].map(e=>e.evaluate(e=>window.scrollTo(0,e),m))),await u.waitForTimeout(900),await u.screenshot({path:r.before[o],animations:"disabled"}),await f.screenshot({path:r.after[o],animations:"disabled"}),h=!0}if(h)return"@below";let p=(await s.locator(O).allInnerTexts()).slice(0,6).map(e=>(e.split("\n")[0]??"").trim()),w=null;for(let[r,n]of p.entries()){r>0&&await Promise.all([l(a,e),l(s,t)]),await Promise.all([f(a,r,n),f(s,r,n)]);let i=await u(await c(a),await c(s));i>3e-4&&(!w||i>w.by)&&(w={index:r,name:n,by:i})}if(!w)return null;let m=w;for(let o of["desktop","mobile"]){let c="desktop"===o?i:await n.newContext(R[o]),[u,d]="desktop"===o?[a,s]:[await c.newPage(),await c.newPage()];await Promise.all([l(u,e),l(d,t)]),await Promise.all([f(u,m.index,m.name),f(d,m.index,m.name)]),await u.screenshot({path:r.before[o]}),await d.screenshot({path:r.after[o]})}return m.name||null}finally{await n.close()}},C=/^(?:src\/)?app\/(?:(.*)\/)?page\.(?:tsx|jsx|ts|js|mdx)$/,D=/^(?:src\/)?pages\/(.*)\.(?:tsx|jsx|ts|js|mdx)$/;function x(e){let t=C.exec(e);if(t)return`/${(t[1]??"").split("/").filter(e=>e&&!/^\(.*\)$/.test(e)&&!e.startsWith("@")).join("/")}`;let r=D.exec(e);return r&&!/^(_|api\/)/.test(r[1])?`/${r[1].replace(/(^|\/)index$/,"")}`.replace(/\/$/,"")||"/":null}let q=/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\(\s*)['"]([^'"]+)['"]/g,L=["",".tsx",".ts",".jsx",".js",".mjs",".mdx","/index.tsx","/index.ts","/index.jsx","/index.js"];async function I(e,t,r,n,i=6){let a=e=>e.split(/[?#]/)[0].replace(/(.)\/$/,"$1"),s=new Set(["/"]),o=["/"],l=0;for(let c=0;c<3&&o.length>0;c++){let c=[];for(let u of o){if(l++>=i)return null;let o=await r(new URL(u,t).toString()).catch(()=>[]),f=function(e,t,r){let n=RegExp(`^${e.split("/").map(e=>/^\[\[?\.\.\./.test(e)?".+":e.startsWith("[")?"[^/]+":e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/")}$`),i=new Set(r);for(let e of t){let t=e.split(/[?#]/)[0].replace(/(.)\/$/,"$1");if(n.test(t)&&!i.has(t))return t}return null}(e,o,n);if(f)return f;for(let e of o.map(a))s.has(e)||n.includes(e)||(s.add(e),c.push(e))}o=c}return null}let z=[/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|docs?|\.github|\.husky|\.vscode)\//,/\.(test|spec|stories)\.[cm]?[jt]sx?$/,/\.(md|mdx|txt|snap|lock)$/i,/(^|\/)(package\.json|package-lock\.json|pnpm-lock\.yaml|bun\.lockb?|tsconfig[^/]*\.json|\.[^/]+)$/,/(^|\/)(vitest|jest|playwright|cypress|eslint|prettier|commitlint|lint-staged)\.config\.[cm]?[jt]s$/,/(^|\/)(vitest|jest)\.setup\.[cm]?[jt]sx?$/],H=/(^|\/)__tests__\/|\.(test|spec)\.[cm]?[jt]sx?$/;function $(e){return 0===e.length||e.some(e=>/(^|\/)(app|pages)\//.test(e)&&!H.test(e)||!z.some(t=>t.test(e)))}let J={status:"unneeded",route:null,shots:[],message:null},W=(e,t,r=T)=>(0,s.join)(r,e,`${t}.png`),G=/^[0-9a-f]{16}$/,U=(e,t,r,n=T)=>(0,s.join)(n,e,"kept",t,`${r}.png`);async function j(e,t,r=T,n){if(!F.includes(t))return null;if(void 0!==n){if(!G.test(n))return null;let i=U(e,n,t,r);return(0,a.existsSync)(i)?new Uint8Array((0,a.readFileSync)(i)):(await (0,g.h)()?.get((0,g.q)(e,n,t)))?.body??null}let i=K(e,t,r);return i?new Uint8Array((0,a.readFileSync)(i)):(await (0,g.h)()?.get((0,g.g)(e,t)))?.body??null}let K=(e,t,r=T)=>F.includes(t)&&(0,a.existsSync)(W(e,t,r))?W(e,t,r):null,Z=async e=>{let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];try{if(t?.worktreePath&&(0,a.existsSync)(t.worktreePath))return(0,i.createHash)("sha256").update(`${Y(t)??""}:${(0,b.$)(t.worktreePath)}`).digest("hex").slice(0,16)}catch{}return(0,i.createHash)("sha256").update(await (0,d.c)(e)).digest("hex").slice(0,16)},Y=e=>e.baseCommit??e.deliveryBase,V=globalThis.__factorySnapshots??=new Map;async function _(e){let t=V.get(e);if(void 0!==t)return{status:"working",route:null,shots:[],message:t};if(!$(await (0,d.Q)(e)))return J;let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.snapshots"))).orderBy((0,l.A)(u.f.sequence)))[0];if(!r)return{status:"none",route:null,shots:[],message:null};let n=JSON.parse(r.payloadJson);if(n.change!==await Z(e))return{status:"none",route:null,shots:[],message:null};let i=n.shots.filter(t=>null!==(0,g.h)()||null!==K(e,t));return i.length>0?{status:"ready",route:n.route,opened:n.opened??null,shots:i,taken:String(r.sequence),message:null}:{status:"failed",route:n.route,shots:[],message:n.message}}let X=async e=>{let t=await (0,S.f)();try{let r=await t.newPage();await r.goto(e,{waitUntil:"load",timeout:12e4}),await r.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0);let n=await r.$$eval("a[href]",e=>e.map(e=>e.href)),i=new URL(e).origin;return n.filter(e=>e.startsWith(`${i}/`)).map(e=>e.slice(i.length))}finally{await t.close()}},Q=(e,t)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();async function P(e,t,r=T){let n={status:"none",route:null,shots:[],message:null};if(!G.test(t))return n;for(let i of(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.snapshots"))).orderBy((0,l.A)(u.f.sequence)))){let s=JSON.parse(i.payloadJson);if(s.change!==t)continue;let o=s.shots.filter(n=>null!==(0,g.h)()||(0,a.existsSync)(U(e,t,n,r)));return o.length>0?{status:"ready",route:s.route,opened:s.opened??null,shots:o,taken:`${i.sequence}-${t}`,message:null}:n}return n}async function E(e,t=T){let r=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!r)return[];let n=r.request,i=0,s=new Set,f=new Set,d=new Map;for(let r of(await c.r.select().from(u.f).where((0,o.u)(u.f.runId,e)).orderBy((0,l.M)(u.f.sequence)))){let o=JSON.parse(r.payloadJson);"node.plan_decided"===r.type&&r.nodeRunId&&f.add(r.nodeRunId);let l="string"==typeof o.note?o.note.trim():"",c=`${String(o.by)}-${String(o.round)}`;if("node.reopened"===r.type&&"fixes"!==o.by&&"reviewer"!==o.by&&l&&!s.has(c)&&!(r.nodeRunId&&f.has(r.nodeRunId))&&(s.add(c),n=l,i++),"run.snapshots"!==r.type||"string"!=typeof o.change||!G.test(o.change)||!Array.isArray(o.shots))continue;let u=o.change,h=o.shots.filter(r=>null!==(0,g.h)()||(0,a.existsSync)(U(e,u,r,t)));h.length>0&&d.set(i,{change:u,asked:n,shots:h,taken:`${r.sequence}-${u}`})}return[...d.entries()].sort((e,t)=>e[0]-t[0]).map(([,e])=>e)}async function A(e,t=N,r=T,n=X,i=M){let l,b=await (0,y.b)(e);if(b)throw new ee(b);if(V.has(e))return _(e);let v=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!v?.worktreePath||!(0,a.existsSync)(v.worktreePath))throw new ee(m.f.snapshots.noWorkingCopy);let S=await (0,y.I)(v.projectId),k=S?.repoPath,j=Y(v);if(!k||!j)throw new ee(m.f.snapshots.noWorkingCopy);let P=await (0,d.Q)(e);if(!$(P))return J;let E=await Z(e),F=v.worktreePath,R=P.some(e=>null!==x(e))?P:function(e,t){let r=e=>L.map(t=>e+t).find(e=>t.has(e))??null,n=new Map;for(let[e,i]of t){let t=e.split("/").slice(0,-1);for(let a of i.matchAll(q)){let i=a[1],s=(i.startsWith(".")?[i.split("/").reduce((e,t)=>"."===t||""===t?e:".."===t?e.slice(0,-1):[...e,t],t).join("/")]:/^[@~]\//.test(i)?[`src/${i.slice(2)}`,i.slice(2)]:[]).map(r).find(Boolean);s&&s!==e&&n.set(s,[...n.get(s)??[],e])}}let i=new Set(e),a=[...e];for(;a.length>0;){let e=a.filter(e=>null!==x(e));if(e.length>0)return e;for(let e of a=[...new Set(a.flatMap(e=>n.get(e)??[]))].filter(e=>!i.has(e)))i.add(e)}return[]}(P,function(e){let t=new Map;try{for(let r of Q(e,["ls-files","--cached","--others","--exclude-standard"]).split("\n").filter(e=>/\.(?:[cm]?[jt]sx?|mdx)$/.test(e)).slice(0,4e3))try{let n=(0,a.readFileSync)((0,s.join)(e,r),"utf8");n.length<4e5&&t.set(r,n)}catch{}}catch{}return t}(F)),O=function(e){for(let t of e){let e=x(t);if(null!==e&&!e.includes("["))return e}return"/"}(R),C=(l=R.map(x).filter(e=>null!==e)).some(e=>!e.includes("["))?null:l[0]??null,D=(0,s.join)(r,e),z=(0,s.join)(D,"before-tree"),H=`${e}:before`,G=["starting","installing","ready"].includes((0,p.h)(e).status);return V.set(e,m.f.snapshots.starting),(async()=>{let o=[],l=null,u=null;try{(0,a.mkdirSync)(D,{recursive:!0}),(0,a.existsSync)(z)&&B(k,z),Q(k,["worktree","add","-q","--detach",z,j]),await (0,f.S)(v.projectId,z);let c=null!==(0,p.n)(z,0);await Promise.all([(0,p.s)(e),c?(0,p.O)(H,z,k):null]),V.set(e,m.f.snapshots.waiting);let[d,h]=await Promise.all([(0,p.q)(e),c?(0,p.q)(H):null]);if(C&&d)try{let e=Q(F,["ls-files"]).split("\n").map(x).filter(e=>null!==e&&!e.includes("["));O=await I(C,d,n,e)??O}catch{}V.set(e,m.f.snapshots.shooting);let w=e=>new URL(O,e).toString();if(h&&(await t(w(h),{desktop:W(e,"before-desktop",r),mobile:W(e,"before-mobile",r)}),o.push("before-desktop","before-mobile")),d&&(await t(w(d),{desktop:W(e,"after-desktop",r),mobile:W(e,"after-mobile",r)}),o.push("after-desktop","after-mobile")),h&&d){V.set(e,m.f.snapshots.looking);let t=t=>({desktop:W(e,`${t}-desktop`,r),mobile:W(e,`${t}-mobile`,r)});u=await i(w(h),w(d),{before:t("before"),after:t("after")}).catch(()=>null)}let y=(0,g.h)();for(let t of((0,a.mkdirSync)((0,s.join)(D,"kept",E),{recursive:!0}),o)){if((0,a.copyFileSync)(W(e,t,r),U(e,E,t,r)),!y)continue;let n=(0,a.readFileSync)(W(e,t,r));await y.put((0,g.g)(e,t),n,"image/png"),await y.put((0,g.q)(e,E,t),n,"image/png")}(!c||h)&&d||(l=m.f.snapshots.didNotStart(d?m.f.snapshots.beforeVersion:m.f.snapshots.afterVersion))}catch(e){l=m.f.snapshots.failed((0,w.l)((0,w.h)(String(e?.message??e)).split("\n")[0]??"",200))}finally{(0,p.D)(H),G||(0,p.D)(e),setTimeout(()=>B(k,z),4e3).unref();try{await c.r.transaction(async t=>void await (0,h.f)({runId:e,type:"run.snapshots",payload:{route:O,opened:u,shots:o,message:l,change:E}},t))}finally{V.delete(e)}}})(),_(e)}function B(e,t){try{Q(e,["worktree","remove","--force",t])}catch{(0,a.rmSync)(t,{recursive:!0,force:!0});try{Q(e,["worktree","prune"])}catch{}}}class ee extends Error{}e.s(["P",0,T,"J",0,ee,"e",0,A,"c",0,$,"_",0,P,"g",0,j,"S",0,B,"V",0,_,"j",0,E]),r()}catch(e){r(e)}},!1),32374,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(16806),a=e.i(40855);let s=/Tests\s+((?:\d+\s+(?:passed|failed|skipped|todo)\s*\|?\s*)+)\((\d+)\)/g,o=/Tests:\s+([^\n]*?)(\d+)\s+total/g,l=(e,t)=>Number(e.match(RegExp(`(\\d+)\\s+${t}`))?.[1]??0),c=/\x1b\[[0-9;?]*[ -\/]*[@-~]/g;function u(e){return e.replace(c,"")}let f=[/(^|\/)package\.json$/,/(^|\/)(__tests__|tests?|spec|e2e)\//,/\.(test|spec)\.[cm]?[jt]sx?$/,/(^|\/)(vitest|jest|playwright|mocha|karma|cypress)\.config\.[cm]?[jt]s$/,/(^|\/)\.mocharc(\.[a-z]+)?$/,/(^|\/)(test_[^/]*|[^/]*_test)\.py$/,/(^|\/)(pytest\.ini|conftest\.py|tox\.ini)$/,/_test\.go$/,/(^|\/)Makefile$/];function d(e){return f.some(t=>t.test(e))}let h=/no test specified/;e.s(["L",0,function(e,r){if(!r)return null;try{let n=r=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),i=n(["diff","--name-only",r]).split("\n"),a=n(["ls-files","--others","--exclude-standard"]).split("\n");return[...new Set([...i,...a].map(e=>e.trim()).filter(Boolean))].filter(d).sort()}catch{return null}},"n",0,function(e){let t=(0,n.join)(e,"package.json");if(!(0,r.existsSync)(t))return null;try{let i=JSON.parse((0,r.readFileSync)(t,"utf8")),a=i.scripts?.test;if("string"!=typeof a||""===a.trim()||h.test(a))return null;let s=t=>(0,r.existsSync)((0,n.join)(e,t));if(s("pnpm-lock.yaml"))return"pnpm test";if(s("yarn.lock"))return"yarn test";if(s("bun.lockb")||s("bun.lock"))return"bun run test";return"npm test"}catch{return null}},"P",0,function(e,r,n,c={},f){let d=Date.now();return new Promise(h=>{let p="",w=(0,t.spawn)("sh",["-c",e],{cwd:r,detached:!0,env:(0,i.f)({CI:"1",FORCE_COLOR:"0",NO_COLOR:"1",...c})}),m=e=>{p=(p+e.toString()).slice(-16e3)};w.stdout.on("data",m),w.stderr.on("data",m);let y=!1,g=()=>{y=!0;try{w.pid&&process.kill(-w.pid,"SIGKILL")}catch{}};n.aborted?g():n.addEventListener("abort",g,{once:!0});let b=(t,r,i)=>{n.removeEventListener("abort",g);let c=y?null:function(e){let t=u(e),r={passed:0,failed:0,total:0},n=!1;for(let e of t.matchAll(s))r.passed+=l(e[1],"passed"),r.failed+=l(e[1],"failed"),r.total+=Number(e[2]),n=!0;for(let e of t.matchAll(o))r.passed+=l(e[1],"passed"),r.failed+=l(e[1],"failed"),r.total+=Number(e[2]),n=!0;let i=e=>[...t.matchAll(RegExp(`(?:^|\\s)(?:#|ℹ)\\s+${e}\\s+(\\d+)\\s*$`,"gm"))].map(e=>Number(e[1])),[a,c,f]=[i("tests"),i("pass"),i("fail")];if(a.length>0&&a.length===c.length&&a.length===f.length){let e=e=>e.reduce((e,t)=>e+t,0);r.passed+=e(c),r.failed+=e(f),r.total+=e(a),n=!0}return n?r:null}(p);f?.(u(p)),h({command:e,exitCode:y?null:t,signal:y?null:r,started:i,durationMs:Date.now()-d,counts:c,outputTail:(0,a.h)(u(p)).slice(-4e3),changedTestFiles:null})};w.on("error",()=>b(null,null,!1)),w.on("close",(e,t)=>b(e,t,!0))})},"X",0,u])},26955,e=>{"use strict";var t=e.i(74533),r=e.i(66680),n=e.i(2157),i=e.i(60526),a=e.i(50227),s=e.i(87345),o=e.i(91138);let l=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;function c(e,t){if("string"!=typeof e||!l.test(e))throw Error(`Not a git object id: ${t}`)}function u(e,t){if(t.store)return(0,a.resolve)(t.store);let i=(0,r.createHash)("sha256").update((0,n.realpathSync)(e)).digest("hex").slice(0,16);return(0,a.join)(o.f,"snapshots",i)}function f(e,r,i){let s={...process.env};for(let e of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_COMMON_DIR","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_PREFIX"])delete s[e];let o=(0,t.execFileSync)("git",["rev-parse","--git-path","objects"],{cwd:e,env:s,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim(),l=(0,a.join)(u(e,r),"objects");return(0,n.mkdirSync)(l,{recursive:!0}),{...s,GIT_OBJECT_DIRECTORY:l,GIT_ALTERNATE_OBJECT_DIRECTORIES:(0,a.isAbsolute)(o)?o:(0,a.resolve)(e,o),...i?{GIT_INDEX_FILE:i}:{}}}function d(e,r,n,i={}){return(0,t.execFileSync)("git",["--no-optional-locks","-c","core.hooksPath=/dev/null","-c","core.fsmonitor=false",...n],{cwd:e,env:f(e,r,i.index),encoding:"utf8",input:i.input,stdio:["pipe","pipe","pipe"],maxBuffer:0x10000000,timeout:12e4})}function h(e,r,n){return(0,t.execFileSync)("git",["--no-optional-locks","-c","core.hooksPath=/dev/null",...n],{cwd:e,env:f(e,r),stdio:["ignore","pipe","pipe"],maxBuffer:0x10000000,timeout:12e4})}function p(e,t={}){let r=d(e,t,["rev-parse","--show-toplevel"]).trim();if((0,n.realpathSync)(r)!==(0,n.realpathSync)(e))throw Error("The folder is not a working copy of its own");let s=(0,n.mkdtempSync)((0,a.join)((0,i.tmpdir)(),"factory-index-"));try{var o=(0,a.join)(s,"index");let r=!0;try{d(e,t,["rev-parse","--verify","-q","HEAD^{commit}"])}catch{r=!1}return r&&d(e,t,["read-tree","HEAD"],{index:o}),d(e,t,["add","-A","--","."],{index:o}),d(e,t,["write-tree"],{index:o}).trim()}finally{(0,n.rmSync)(s,{recursive:!0,force:!0})}}let w=e=>e?"100755":"100644",m=new Set(["node_modules",".next","dist","build","out","coverage",".turbo",".cache",".vercel",".git"]);function y(e,t={}){let r=p(e,t),{files:i,skipped:o}=function(e,t){let r=d(e,t,["ls-files","-o","-i","--exclude-standard","-z"]).split("\0").filter(Boolean).filter(e=>!e.split("/").some(e=>m.has(e))&&s.Q.test(e)),i=[],o=0;for(let s of r)try{let r=(0,n.lstatSync)((0,a.join)(e,s));if(i.length>=50||!r.isFile()||r.size>1048576){o++;continue}i.push({path:s,mode:w((73&r.mode)!=0),blob:d(e,t,["hash-object","-w","--",s]).trim()})}catch{o++}return{files:i.sort((e,t)=>e.path<t.path?-1:1),skipped:o}}(e,t);return{tree:r,ignored:i,skipped:o}}let g=e=>e?`${e.mode} ${e.sha}`:"-";function b(e,t,r,n){let i=d(e,t,["diff-tree","-r","-z","--name-status","--no-renames",r,n]).split("\0"),a=[];for(let e=0;e+1<i.length;e+=2)a.push({status:i[e],path:i[e+1]});return a}function v(e,t,r,n={}){return c(t,"from"),c(r,"tree"),b(e,n,t,r).map(e=>e.path).sort()}let S=e=>"string"==typeof e?{tree:e,ignored:[],skipped:0}:e;function k(e,t,r,n={}){let i=S(t),a=S(r);c(i.tree,"before"),c(a.tree,"after");let s=new Set(b(e,n,i.tree,a.tree).map(e=>e.path)),o=e=>new Map(e.ignored.map(e=>[e.path,g({mode:e.mode,sha:e.blob})])),l=o(i),u=o(a);for(let e of new Set([...l.keys(),...u.keys()]))l.get(e)!==u.get(e)&&s.add(e);return[...s].sort()}function x(e,t,r,n){let i=new Map;for(let a=0;a<n.length;a+=100){let s=n.slice(a,a+100);for(let n of d(e,t,["ls-tree","-r","-z",r,"--",...s]).split("\0").filter(Boolean)){let e=n.indexOf(" "),[t,r,a]=n.slice(0,e).split(" ");"blob"===r&&s.includes(n.slice(e+1))&&i.set(n.slice(e+1),{mode:t,sha:a})}}return i}function I(e,t,r){let i,s=(0,a.join)(e,r);try{i=(0,n.lstatSync)(s)}catch{return null}return i.isSymbolicLink()?{mode:"120000",sha:d(e,t,["hash-object","--stdin"],{input:(0,n.readlinkSync)(s)}).trim()}:i.isDirectory()?0===(0,n.readdirSync)(s).length?null:{mode:"040000",sha:"folder"}:{mode:w((73&i.mode)!=0),sha:d(e,t,["hash-object","--",r]).trim()}}let $=e=>""!==e&&!e.startsWith("/")&&e.split("/").every(e=>""!==e&&".."!==e&&".git"!==e),j=e=>/(^|\/)\.(gitignore|gitattributes)$/.test(e);function _(e,t,r,i={}){let s=S(t),o=S(r);c(s.tree,"before"),c(o.tree,"after");let l=k(e,s,o,i),u=new Set([...s.ignored,...o.ignored].map(e=>e.path)),f=x(e,i,s.tree,l),p=x(e,i,o.tree,l),w=(e,t,r)=>{let n=t.get(r);if(n)return n;let i=e.ignored.find(e=>e.path===r);return i?{mode:i.mode,sha:i.blob}:null},m=[],y=[],b=[],v=!1,P=t=>{try{if(!$(t)||function(e,t){let r=t.split("/"),i=e;for(let e of r.slice(0,-1)){i=(0,a.join)(i,e);try{if((0,n.lstatSync)(i).isSymbolicLink())return!0}catch{break}}return!1}(e,t))throw Error("Not a path to touch");let r=w(s,f,t),l=w(o,p,t);if(g(r)===g(l))return;let c=I(e,i,t);if(g(c)===g(r))return void m.push(t);if(g(c)!==g(l))return void y.push(t);if(null===r){if(!u.has(t)){if(v)return void y.push(t);if(function(e,t,r){try{return d(e,t,["check-ignore","-q","--",r]),!0}catch{return!1}}(e,i,t))return}(0,n.rmSync)((0,a.join)(e,t),{force:!0})}else{let s=(0,a.join)(e,t),o="120000"===r.mode?h(e,i,["cat-file","blob",r.sha]):h(e,i,["cat-file","--filters",`--path=${t}`,r.sha]),l=t.split("/"),c=e;for(let e of l.slice(0,-1))if(c=(0,a.join)(c,e),(0,n.existsSync)(c)){if(!(0,n.lstatSync)(c).isDirectory())throw Error("A file is in the way")}else(0,n.mkdirSync)(c);((0,n.existsSync)(s)||function(e){try{return(0,n.lstatSync)(e).isSymbolicLink()}catch{return!1}}(s))&&((0,n.lstatSync)(s).isDirectory()?(0,n.rmdirSync)(s):(0,n.rmSync)(s,{force:!0})),"120000"===r.mode?(0,n.symlinkSync)(o.toString(),s):((0,n.writeFileSync)(s,o),(0,n.chmodSync)(s,"100755"===r.mode?493:420))}m.push(t)}catch{b.push(t)}},E=e=>null===w(s,f,e),A=[...l.filter(j),...l.filter(e=>!j(e)&&E(e)),...l.filter(e=>!j(e)&&!E(e))];for(let e of A.filter(j))P(e);for(let e of(v=[...y,...b].some(j),A.filter(e=>!j(e))))P(e);return{reverted:m.sort(),kept:y.sort(),failed:b.sort()}}let P=(e,t)=>(0,a.join)(u(e,t),"attempts");e.s(["n",0,2,"H",0,v,"d",0,k,"e",0,function(e,t,r={}){let n=d(e,r,["status","--porcelain=v1","-z","-uall"]).split("\0").filter(Boolean),i=new Set(t.ignored.map(e=>e.path));for(let e=0;e<n.length;e++){let t=n[e].slice(0,2);i.add(n[e].slice(3).replace(/\/$/,"")),("R"===t[0]||"C"===t[0])&&e++}let a=[...i].filter($),s=x(e,r,t.tree,a);return a.filter(n=>g(s.get(n)??(t.ignored.find(e=>e.path===n)?{mode:t.ignored.find(e=>e.path===n).mode,sha:t.ignored.find(e=>e.path===n).blob}:null))!==g(I(e,r,n))).sort()},"G",0,function(e,t,r={}){c(t,"tree");let n=p(e,r),i=["--no-renames","--no-color","--no-ext-diff","--no-textconv"],a=v(e,t,n,r),s=d(e,r,["-c","core.quotepath=off","diff-tree","-r","-p",...i,t,n]),o=new Map;for(let a of d(e,r,["diff-tree","-r","-z","--numstat",...i,t,n]).split("\0").filter(Boolean)){let[e,t,...r]=a.split(" "),n=e=>void 0===e||"-"===e?1:Number(e);o.set(r.join(" "),n(e)+n(t))}return{paths:a,diff:s,files:a.map(e=>({path:e,lines:Math.max(1,o.get(e)??1)}))}},"W",0,function(e,t,r={}){let i=P(e,r);if((0,n.existsSync)(i))for(let e of(0,n.readdirSync)(i))e.startsWith(`${t}-`)&&(0,n.rmSync)((0,a.join)(i,e),{force:!0})},"z",0,function(e,t,r={}){c(t,"tree");let n=_(e,t,p(e,r),r);if(n.failed.length>0)throw Error(`Could not put back: ${n.failed.join(", ")}`)},"$",0,p,"u",0,function(e,t,r={}){if(!/^[A-Za-z0-9_-]+$/.test(t))throw Error("Not a name to claim");let i=P(e,r);(0,n.mkdirSync)(i,{recursive:!0});let s=(0,a.join)(i,t),o=()=>{try{let e=JSON.parse((0,n.readFileSync)(s,"utf8")),t="string"==typeof e.tree&&l.test(e.tree)&&Array.isArray(e.ignored)&&e.ignored.every(e=>e&&"string"==typeof e.path&&"string"==typeof e.mode&&"string"==typeof e.blob&&l.test(e.blob));return{again:!0,start:t?{tree:e.tree,ignored:e.ignored,skipped:"number"==typeof e.skipped?e.skipped:0}:null}}catch{return{again:!0,start:null}}};if((0,n.existsSync)(s))return o();let c=y(e,r);try{(0,n.writeFileSync)(s,JSON.stringify(c),{flag:"wx"})}catch{return o()}return{again:!1,start:c}},"o",0,y,"p",0,_])},92835,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(2157),a=e.i(60526),s=e.i(50227),o=e.i(75225),l=e.i(24924),c=e.i(92335),u=e.i(96662),f=e.i(120),d=e.i(20195),h=e.i(64950),p=e.i(30188),w=e.i(69608),m=e.i(82283),y=e.i(37857),g=t([l,u,f,d,h,w]);[l,u,f,d,h,w]=g.then?(await g)():g;let j=async(e,t)=>{let r=await (0,y.f)();try{let n=await (await r.newContext({viewport:{width:1440,height:900},deviceScaleFactor:1})).newPage();await n.goto(e,{waitUntil:"load",timeout:12e4}),await n.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await n.waitForTimeout(1500),await n.screenshot({path:t,fullPage:!0})}finally{await r.close()}},_=/^version-(\d{1,2})\.(png|patch)$/,P=(e,t,r)=>(0,s.join)(r,e,`version-${t}.png`),E=(e,t,r)=>(0,s.join)(r,e,`version-${t}.patch`),A=(e,t,r)=>(0,n.execFileSync)("git",["-c","core.hooksPath=/dev/null",...t],{cwd:e,env:r??process.env,stdio:["ignore","pipe","pipe"],maxBuffer:0x20000000});async function b(e,t,r=j,n=w.P){try{let a=(0,d.h)(e);if("ready"!==a.status||!a.url)return!1;return(0,i.mkdirSync)((0,s.join)(n,e),{recursive:!0}),await r(a.url,P(e,t,n)),!0}catch{return!1}}function v(e,t=w.P){let r=(0,s.join)(t,e);return(0,i.existsSync)(r)?[...new Set((0,i.readdirSync)(r).flatMap(e=>{let t=_.exec(e);return t?[Number(t[1])]:[]}))].sort((e,t)=>e-t):[]}async function S(e,t=w.P){let r=v(e,t);if(0===r.length)return[];let n=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0];if(!n)return[];let a=[n.request,...(await (0,u.P)([e]))(e)];return r.map(r=>({n:r,text:a[r-1]??null,site:(0,i.existsSync)(E(e,r,t)),picture:(0,i.existsSync)(P(e,r,t))}))}let B=globalThis.__factoryVersions??=new Map,T=e=>`${e}:version`,F=(e,t)=>(0,s.join)(t,e,"version-tree");class R extends Error{}function k(e){return(0,d.i)(T(e)),{...(0,d.h)(T(e)),n:B.get(e)??null}}async function x(e,t,r){let n=(0,d.h)(T(e)).status;if(B.get(e)===t&&("starting"===n||"installing"===n||"ready"===n))return k(e);let a=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0],s=a?(await (0,h.I)(a.projectId))?.repoPath??null:null,u=E(e,t,r),p=(0,i.existsSync)(`${u}.base`)?(0,i.readFileSync)(`${u}.base`,"utf8").trim():"";if(!a||!s||!(0,i.existsSync)(u)||!/^[0-9a-f]{7,64}$/.test(p))throw new R(m.f.direct.versionNotKept);await $(e,r,!0);let w=F(e,r);try{A(s,["worktree","add","-q","--detach",w,p]),(0,i.statSync)(u).size>0&&A(w,["apply","--binary","--whitespace=nowarn",u]),await (0,f.S)(a.projectId,w),B.set(e,t),await (0,d.O)(T(e),w,s)}catch{throw(0,d.D)(T(e)),B.delete(e),I(s,w),new R(m.f.direct.versionNotBuilt)}return k(e)}function I(e,t){try{e?(0,w.S)(e,t):(0,i.rmSync)(t,{recursive:!0,force:!0})}catch{}}async function $(e,t,r){let n="stopped"!==(0,d.h)(T(e)).status;(0,d.D)(T(e)),B.delete(e);let a=F(e,t);if(!(0,i.existsSync)(a))return;let s=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0],u=s?(await (0,h.I)(s.projectId))?.repoPath??null:null;n&&await new Promise(e=>setTimeout(e,r?1500:4e3)),I(u,a)}e.s(["R",0,R,"q",0,b,"x",0,function(e,t,r=w.P){for(let n of v(e,r))n<=t||((0,i.rmSync)(P(e,n,r),{force:!0}),(0,i.rmSync)(E(e,n,r),{force:!0}),(0,i.rmSync)(`${E(e,n,r)}.base`,{force:!0}))},"H",0,S,"A",0,function(e,t,r=w.P){let n=P(e,t,r);return Number.isInteger(t)&&t>=1&&t<=99&&(0,i.existsSync)(n)?new Uint8Array((0,i.readFileSync)(n)):null},"Y",0,function(e,t,r,n,o=w.P){let l=(0,i.mkdtempSync)((0,s.join)((0,a.tmpdir)(),"factory-version-"));try{let a={...process.env,GIT_INDEX_FILE:(0,s.join)(l,"index")};A(e,["read-tree",t],a),A(e,["add","-A","--","."],a);let c=A(e,["diff","--cached","--binary","--full-index",t],a);return(0,i.mkdirSync)((0,s.join)(o,r),{recursive:!0}),(0,i.writeFileSync)(E(r,n,o),c),(0,i.writeFileSync)(`${E(r,n,o)}.base`,t),!0}catch{return!1}finally{(0,i.rmSync)(l,{recursive:!0,force:!0})}},"C",0,(e,t,r=w.P)=>(0,p.f)(T(e),()=>x(e,t,r)),"i",0,(e,t=w.P)=>(0,p.f)(T(e),()=>$(e,t,!1)),"S",0,k]),r()}catch(e){r(e)}},!1),18536,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(91138);let a=(0,n.join)(i.f,"worktrees"),s=(e,r)=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();function o(e,t){let r=(t??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/g,"");return`ai/${r||"change"}-${e.slice(-6).toLowerCase()}`}e.s(["U",0,a,"E",0,o,"r",0,function(e,t,i=a,l,c){let u=o(t,c),f=(0,n.join)(i,t);if((0,r.existsSync)(f))return{path:f,branch:s(f,["rev-parse","--abbrev-ref","HEAD"]),baseCommit:s(f,["merge-base","HEAD",u])};let d=s(e,["rev-parse","--verify",l?`${l}^{commit}`:"HEAD"]);return(0,r.mkdirSync)(i,{recursive:!0}),s(e,["worktree","add","-q","-b",u,f,d]),{path:f,branch:u,baseCommit:d}}])}];
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=_143_tdoh-o8r2._.js.map
|