nebulosity 1.0.0 → 1.1.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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +11 -11
- package/.next/diagnostics/route-bundle-stats.json +10 -10
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +5 -5
- package/.next/server/app/_global-error/page/build-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page/build-manifest.json +3 -3
- package/.next/server/app/_not-found/page/next-font-manifest.json +2 -3
- package/.next/server/app/_not-found/page.js +3 -2
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +27 -20
- package/.next/server/app/_not-found.segments/_full.segment.rsc +27 -20
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +34 -26
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +29 -23
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +33 -24
- package/.next/server/app/index.segments/_full.segment.rsc +29 -23
- package/.next/server/app/index.segments/_tree.segment.rsc +4 -5
- package/.next/server/app/page/build-manifest.json +3 -3
- package/.next/server/app/page/next-font-manifest.json +2 -3
- package/.next/server/app/page.js +4 -4
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__06blyow8irfw3._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__0bmqko-d8fd5k._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__0cmmlmvta4i0g._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__0jgr1dt1j95ku._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__0m0n163465-zb._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__0p7epsgp2b5m3._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__1i5e5sqg45ens._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__1vjt0neva-819._.js +3 -3
- package/.next/server/chunks/_0uqus0ehnijt-._.js +1 -1
- package/.next/server/chunks/lib_background_start_ts_11u_1uu8b9yuy._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0_3l5tdzqy-td._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__10ockmlli-lun._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__0dyligeswbb47._.js → [root-of-the-server]__16-gclvix9mjd._.js} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1auodc3c0rppy._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1cf6qt9agg_9-._.js +3 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1i9r59yk4i69p._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1l3qp8u9yc_ig._.js +3 -0
- package/.next/server/chunks/ssr/_1p-0wsx9qfm68._.js +13 -0
- package/.next/server/chunks/ssr/app_map_18iu6j19jsqmu._.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_1r3iqtbm45lqp._.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0q-w892nagajq.js +3 -0
- package/.next/server/middleware-build-manifest.js +11 -11
- package/.next/server/next-font-manifest.js +1 -1
- package/.next/server/next-font-manifest.json +4 -6
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/preview-props.json +3 -3
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{1rljem7o1jtdo.js → 18kfexnrqek07.js} +1 -1
- package/.next/static/chunks/1hwbgd4nvvhg8.js +1 -0
- package/.next/static/chunks/25r4lkkf1shfo.css +3 -0
- package/.next/static/chunks/35ubvk2ivdjgs.js +1 -0
- package/.next/static/chunks/3ieqvmcg3hofj.js +31 -0
- package/.next/static/chunks/3w00e1w2125pp.js +11 -0
- package/.next/static/media/733da6bd8dac84c8-s.3hlisc-pwq13z.woff2 +0 -0
- package/.next/static/media/784318cea1dfcfa4-s.0-oo9_1x_xmvg.woff2 +0 -0
- package/.next/static/media/7e114457660b62ed-s.36fqqi66-3tjb.woff2 +0 -0
- package/.next/static/media/85e86a88f68a624a-s.357dd_6abeqge.woff2 +0 -0
- package/.next/static/media/9a321a2c78eff0b5-s.p.1bkzbscqrt8rl.woff2 +0 -0
- package/.next/static/media/9fecbd3e5ea9bccb-s.3_z45zcoc-xoz.woff2 +0 -0
- package/.next/static/media/c64053b510252f55-s.1kd-r_s9smv5m.woff2 +0 -0
- package/.next/static/media/c6a5c2fdc12da45c-s.p.17-aodiw50953.woff2 +0 -0
- package/.next/static/media/f263782c6a4bddee-s.1gyfqm5yhhzs7.woff2 +0 -0
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/README.md +13 -4
- package/app/globals.css +91 -54
- package/app/layout.tsx +20 -11
- package/app/map/BackButton.tsx +5 -5
- package/app/map/BoxActions.tsx +20 -12
- package/app/map/Breadcrumb.tsx +132 -46
- package/app/map/DetailPanel.tsx +408 -297
- package/app/map/Explorer.tsx +268 -0
- package/app/map/Header.tsx +105 -0
- package/app/map/HelpDialog.tsx +37 -34
- package/app/map/Legend.tsx +19 -75
- package/app/map/LineCard.tsx +187 -0
- package/app/map/MapBox.tsx +73 -38
- package/app/map/MapCanvas.tsx +344 -115
- package/app/map/MapToolbar.tsx +377 -0
- package/app/map/MapView.tsx +217 -213
- package/app/map/RepoMenu.tsx +13 -12
- package/app/map/RoutedEdge.tsx +48 -16
- package/app/map/SearchPalette.tsx +6 -6
- package/app/map/SourceViewer.tsx +19 -17
- package/app/map/StatusBar.tsx +166 -0
- package/app/map/embed.ts +22 -2
- package/app/map/emphasis.ts +94 -8
- package/app/map/explorerRows.ts +85 -0
- package/app/map/flowNodes.ts +12 -7
- package/app/map/format.ts +2 -2
- package/app/map/history.ts +4 -3
- package/app/map/inspector.ts +113 -0
- package/app/map/labels.ts +66 -7
- package/app/map/narrow.ts +165 -85
- package/app/map/opening.ts +16 -0
- package/app/map/portals.ts +2 -2
- package/app/map/routes.ts +1060 -55
- package/app/map/runs.ts +108 -0
- package/app/map/shell.ts +91 -0
- package/app/map/shortcuts.ts +2 -1
- package/app/map/summaries.ts +41 -5
- package/app/map/text.ts +9 -1
- package/app/map/theme.ts +197 -0
- package/app/map/useDismiss.ts +20 -6
- package/app/map/useEditorBridge.ts +12 -1
- package/app/map/useThemeKind.ts +28 -0
- package/app/map/useWindowSize.ts +37 -0
- package/app/map/viewport.ts +134 -16
- package/app/map/weights.ts +80 -0
- package/app/page.tsx +3 -5
- package/lib/background/child.ts +2 -0
- package/lib/background/service.ts +26 -10
- package/lib/contracts.ts +25 -2
- package/lib/db/migrations/0011_plain_summaries_prompt_version.sql +1 -0
- package/lib/db/migrations/meta/0011_snapshot.json +1498 -0
- package/lib/db/migrations/meta/_journal.json +7 -0
- package/lib/db/schema.ts +2 -1
- package/lib/db/store/map.ts +6 -0
- package/lib/db/store/summaries.ts +14 -8
- package/lib/engine/describe.ts +2 -0
- package/lib/index/summarize/budget.ts +5 -2
- package/lib/index/summarize/claude.ts +19 -4
- package/lib/index/summarize/compare.ts +2 -2
- package/lib/index/summarize/plan.ts +73 -13
- package/lib/index/summarize/preview.ts +12 -9
- package/lib/index/summarize/prompts.ts +122 -25
- package/lib/index/summarize/run.ts +48 -18
- package/lib/index/summarize/snapshot.ts +7 -2
- package/lib/index/summarize/status.ts +3 -2
- package/lib/tools/text.ts +3 -2
- package/mcp/server.ts +1 -1
- package/package.json +4 -2
- package/scripts/commands/summarize-command.ts +27 -9
- package/.next/server/chunks/ssr/[root-of-the-server]__0ekw8p2ramybv._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0fwbsqt9e2tr-._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__17_rqmx62cz59._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1zfp6sltse4hf._.js +0 -3
- package/.next/server/chunks/ssr/_1d2woi6toj_0_._.js +0 -3
- package/.next/server/chunks/ssr/_1wfc1zz26g5ji._.js +0 -9
- package/.next/server/chunks/ssr/app_0gw6epmxyea3q._.js +0 -3
- package/.next/server/chunks/ssr/node_modules_@swc_helpers_cjs__interop_require_default_cjs_1ztp13a5szri_._.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_1c5t_vsn6u8fr._.js +0 -3
- package/.next/static/chunks/02x9pxyl2d8om.css +0 -3
- package/.next/static/chunks/0p-0bv2dzer18.js +0 -7
- package/.next/static/chunks/10u7p2gj02qay.js +0 -1
- package/.next/static/chunks/31qp8jfkw0x2h.js +0 -31
- package/.next/static/media/123d516c9baeb953-s.1qc6dx89jd2qv.woff2 +0 -0
- package/.next/static/media/41ba59f553543ecf-s.3cb5lpr2l6xud.woff2 +0 -0
- package/.next/static/media/44ed10da57ebfb0e-s.2y65deuc30pmy.woff2 +0 -0
- package/.next/static/media/48eea41d8317494f-s.p.0wiir8udbzjvx.woff2 +0 -0
- package/.next/static/media/49b1d53681a91a99-s.1yd4_i3e35931.woff2 +0 -0
- package/.next/static/media/67bba87670b402d1-s.1u30mmyq6lnsd.woff2 +0 -0
- package/.next/static/media/6fca7e74603dd412-s.02z5rrbg5nt92.woff2 +0 -0
- package/.next/static/media/73263b2957b73100-s.2qt3tdwt-y9x_.woff2 +0 -0
- package/.next/static/media/7ac0b1cd3e695dd0-s.1i-sca43-qwng.woff2 +0 -0
- package/.next/static/media/916cd8a3bde3edf8-s.p.0oace-s_gkfks.woff2 +0 -0
- package/.next/static/media/a45aa1001bf9176f-s.2vemzm0itqzfy.woff2 +0 -0
- package/.next/static/media/a74d2542cc4c775f-s.29yke99gs9qpn.woff2 +0 -0
- package/.next/static/media/ab664c0e419cc841-s.3cvcemwuzoywn.woff2 +0 -0
- package/.next/static/media/c1b11b726b36a5e5-s.2rixgazldzomk.woff2 +0 -0
- package/.next/static/media/d6c1ff7e86974212-s.p.40sczeszzbjw1.woff2 +0 -0
- package/.next/static/media/faab88e4be272d29-s.0rgnxg2b64rzs.woff2 +0 -0
- package/app/map/ActivityBar.tsx +0 -81
- package/app/map/StatusPill.tsx +0 -93
- package/app/map/TopBar.tsx +0 -84
- /package/.next/static/{prDi039MhjlFqDOOwZ4aR → of6twfEZ3j95xtfQB_NSL}/_buildManifest.js +0 -0
- /package/.next/static/{prDi039MhjlFqDOOwZ4aR → of6twfEZ3j95xtfQB_NSL}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{prDi039MhjlFqDOOwZ4aR → of6twfEZ3j95xtfQB_NSL}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports=[[72507,e=>{var t=e.i(54799),i=e.i(22734),r=e.i(14747),s=e.i(52036);function n(){return(0,s.Q)("config.json")}function a(e){try{return{kind:"bytes",bytes:i.default.readFileSync(e)}}catch(e){var t;return"ENOENT"===(t=e,t?.code)?{kind:"missing"}:{kind:"error",error:e}}}function l(e,t){let i,r=(e=null)=>({config:{activeRepo:null,port:3e3},problem:e});if("missing"===t.kind)return r();if("error"===t.kind)return r(`${e} couldn't be read (${d(t.error)})`);let s=function(e){if(255===e[0]&&254===e[1])return new TextDecoder("utf-16le").decode(e);if(254===e[0]&&255===e[1]){let t=Buffer.from(e.subarray(0,e.length-e.length%2)).swap16();return new TextDecoder("utf-16le").decode(t)}return new TextDecoder("utf-8").decode(e)}(t.bytes);if(""===s.trim())return r();try{i=JSON.parse(s)}catch(t){return r(`${e} isn't valid JSON (${d(t)})`)}if("object"!=typeof i||null===i||Array.isArray(i))return r(`${e} holds ${null===i?"null":Array.isArray(i)?"an array":`a ${typeof i}`}, not one JSON object of settings`);let n=i,a="number"==typeof n.port&&Number.isInteger(n.port)&&n.port>0&&n.port<65536?n.port:3e3;return{config:{...n,activeRepo:"string"==typeof n.activeRepo?n.activeRepo:null,port:a},problem:null}}class o extends Error{constructor(e,t){super(`${e} couldn't be read to change it (${d(t)}), so nothing was written; try again`,{cause:t}),this.name="ConfigUnreadableError"}}let u=new Set(["EBUSY","EPERM","EACCES","EAGAIN"]);function c(e,t){for(let r=1;;r++)try{return e()}catch(e){var i;if(r>=5||!u.has((i=e,i?.code??"")))return t(e);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,40)}}function d(e){return e instanceof Error?e.message:String(e)}e.s(["V",0,n,"s",0,function(){let e;return l(e=n(),a(e)).config},"t",0,function(e,s=e=>console.error(e)){let u=n();for(let n=1;;n++){let f=c(()=>{let e=a(u);if("error"===e.kind)throw e.error;return e},e=>{throw new o(u,e)}),{config:m,problem:p}=l(u,f),g=e(m);if(null===g)return null;i.default.mkdirSync(r.default.dirname(u),{recursive:!0});let y=null;if(null!==p){var d,h;d=u,y=`${d}.invalid-${new Date().toISOString().replace(/[:.]/g,"-")}-${process.pid}-${(0,t.randomBytes)(4).toString("hex")}`;try{i.default.renameSync(u,y)}catch(e){if("ENOENT"===(h=e,h?.code)&&n<3)continue;throw e}s(`[nebulosity] ${p}, so it was moved aside to ${y} before the settings were written again; copy what you need from it into ${u}, then delete it`)}return function(e,r){let s=`${e}.${process.pid}-${(0,t.randomBytes)(4).toString("hex")}.tmp`;i.default.writeFileSync(s,JSON.stringify(r,null,2)+"\n"),c(()=>i.default.renameSync(s,e),e=>{throw i.default.rmSync(s,{force:!0}),e})}(u,g),y}}])},90793,44398,e=>{var t=e.i(22734),i=e.i(14747),r=e.i(85148),s=e.i(20842),n=e.i(94176),a=e.i(26889),l=e.i(14674),o=e.i(52036);function u(e,t){return`nebulosity ${e} ${t} (in a checkout: npm run ${e} -- ${t})`}e.s(["A",0,u,"D",0,function(){return`set it in the environment, or put it in ${(0,o.Q)(".env.local")}`}],44398);class c extends Error{constructor(e){super(`No repository indexed yet: there's no index at ${e}. Run ${u("index","<path-to-repo>")}.`),this.name="DatabaseMissingError"}}class d extends Error{constructor(){super(`Nebulosity's index is older than this version of Nebulosity. Run ${u("index","<path-to-repo>")} once, or start the Map (nebulosity map; in a checkout, npm run dev), to update it, then try again.`),this.name="DatabaseOutdatedError"}}let h=()=>(0,o.L)("lib","db","migrations"),f=e=>(0,s.f)(e,{schema:l});function m(e,s="readwrite"){if("readonly"===s)return function(e){if(!t.default.existsSync(e))throw new c(e);let i=new r.default(e,{readonly:!0,fileMustExist:!0});try{var s=i;let e=Math.max(...(0,a.f)({migrationsFolder:h()}).map(e=>e.folderMillis)),t=null;try{let e=s.prepare("select max(created_at) as at from __drizzle_migrations").get();t=null===e.at?null:Number(e.at)}catch(e){if(!/no such table/.test(e instanceof Error?e.message:String(e)))throw e}if(null===t||t<e)throw new d}catch(e){throw i.close(),e}return f(i)}(e);":memory:"!==e&&t.default.mkdirSync(i.default.dirname(e),{recursive:!0});let l=new r.default(e);l.pragma("journal_mode = WAL"),l.pragma("synchronous = NORMAL"),l.pragma("foreign_keys = ON");let o=f(l);return(0,n.f)(o,{migrationsFolder:h()}),o}let p=globalThis;e.s(["e",0,c,"K",0,d,"$",0,function(){return p.db||(p.db=process.env.VITEST?m(":memory:"):m((0,o.Q)("nebulosity.db"),p.readOnly?"readonly":"readwrite")),p.db}],90793)},15342,e=>{e.i(46786),e.i(14674),e.s(["f",0,class extends Error{constructor(e,t="Indexing"){super(`${t} already in progress (started ${e}).`),this.name="IndexLockedError"}}])},86812,e=>{var t=e.i(75225),i=e.i(18899),r=e.i(14674);function s(e,t){return""===t?i.B`1 = 1`:i.B`${e} >= ${`${t}/`} and ${e} < ${`${t}0`}`}function n(e,t){let r=""===t?0:t.length+1;return i.B`${s(e,t)} and instr(substr(${e}, ${r+1}), '/') = 0`}let a={kind:r.summaries.targetKind,path:r.summaries.targetPath,tagline:r.summaries.tagline,summary:r.summaries.summary,status:r.summaries.status,error:r.summaries.error};e.s(["H",0,function(e,n,a,l){let o="file"===l?(0,t.u)(r.summaries.targetPath,a):s(r.summaries.targetPath,"repo"===l?"":a);return e.select({n:i.B`count(*)`}).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,n),(0,t.u)(r.summaries.targetKind,"file"),(0,t.u)(r.summaries.status,"stale"),o)).get()?.n??0},"G",0,function(e,s,a){return e.select({path:r.files.path,lineCount:r.files.lineCount,importedBy:i.B`count(${r.imports.id})`}).from(r.files).leftJoin(r.imports,(0,t.u)(r.imports.targetFileId,r.files.id)).where((0,t.b)((0,t.u)(r.files.repoId,s),n(r.files.path,a))).groupBy(r.files.id).orderBy(r.files.path).all()},"R",0,function(e,i,s){return e.select({path:r.folders.path,name:r.folders.name,fileCount:r.folders.fileCount}).from(r.folders).where((0,t.b)((0,t.u)(r.folders.repoId,i),(0,t.u)(r.folders.parentPath,s))).orderBy(r.folders.path).all()},"W",0,function(e,s,l){return e.select(a).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,s),i.B`${r.summaries.targetKind} in ('file', 'folder')`,n(r.summaries.targetPath,l))).all()},"k",0,function(e,i,s){return e.select({path:r.files.path,lineCount:r.files.lineCount,isTest:r.files.isTest,sizeBytes:r.files.sizeBytes}).from(r.files).where((0,t.b)((0,t.u)(r.files.repoId,i),(0,t.u)(r.files.path,s))).get()??null},"o",0,function(e,i,s){return e.select({name:r.symbols.qualifiedName,kind:r.symbols.kind,startLine:r.symbols.startLine,endLine:r.symbols.endLine,exported:r.symbols.exported}).from(r.symbols).innerJoin(r.files,(0,t.u)(r.files.id,r.symbols.fileId)).where((0,t.b)((0,t.u)(r.files.repoId,i),(0,t.u)(r.files.path,s))).orderBy(r.symbols.startLine,r.symbols.qualifiedName).all()},"O",0,function(e,i,s){return e.select({path:r.folders.path,name:r.folders.name,fileCount:r.folders.fileCount}).from(r.folders).where((0,t.b)((0,t.u)(r.folders.repoId,i),(0,t.u)(r.folders.path,s))).get()??null},"B",0,function(e,i){return e.select({source:r.imports.sourceFileId,target:r.imports.targetFileId}).from(r.imports).innerJoin(r.files,(0,t.u)(r.files.id,r.imports.sourceFileId)).where((0,t.u)(r.files.repoId,i)).all()},"d",0,function(e,i){return e.select({id:r.files.id,path:r.files.path}).from(r.files).where((0,t.u)(r.files.repoId,i)).all()},"_",0,function(e,i,s){return e.select({source:r.levelEdges.sourceNode,target:r.levelEdges.targetNode,count:r.levelEdges.count}).from(r.levelEdges).where((0,t.b)((0,t.u)(r.levelEdges.repoId,i),(0,t.u)(r.levelEdges.levelPath,s))).orderBy(r.levelEdges.sourceNode,r.levelEdges.targetNode).all()},"n",0,function(e,i,s,n){return e.select(a).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,i),(0,t.u)(r.summaries.targetKind,s),(0,t.u)(r.summaries.targetPath,n))).get()??null},"F",0,function(e,n,a){return e.select({lines:i.B`coalesce(sum(${r.files.lineCount}), 0)`}).from(r.files).where((0,t.b)((0,t.u)(r.files.repoId,n),s(r.files.path,a))).get()?.lines??0}])},86304,e=>{var t=e.i(75225),i=e.i(18899),r=e.i(14674);let s=["structure","summaries","embeddings"],n=(e,t)=>`stage:${e}:${t}`;e.s(["J",0,function(e){return e.select({rootPath:r.repositories.rootPath,lastIndexAt:r.repositories.lastIndexAt}).from(r.repositories).where(i.B`exists (select 1 from ${r.meta} where ${r.meta.key} = 'stage:' || ${r.repositories.id} || ':structure')`).orderBy(r.repositories.rootPath).all()},"z",0,function(e,i){let a={};for(let l of s){let s=e.select({value:r.meta.value,updatedAt:r.meta.updatedAt}).from(r.meta).where((0,t.u)(r.meta.key,n(i,l))).get();s&&(a[l]={...JSON.parse(s.value),updatedAt:s.updatedAt})}return a}])},37756,e=>{var t=e.i(75225),i=e.i(14674);i.files.path,i.files.isTest,i.typedCalls.line,i.typedCalls.member,i.typedCalls.receiver,i.typedCalls.ref,i.typedCalls.inClass,i.typedCalls.how;var r=e.i(44398);function s(e,r){return e.select({id:i.repositories.id}).from(i.repositories).where((0,t.u)(i.repositories.rootPath,r)).get()?.id??null}class n extends Error{constructor(e){super(`${e} isn't indexed yet. Run ${(0,r.A)("index",`"${e}"`)} first.`),this.name="RepoNotIndexedError"}}e.s(["V",0,n,"_",0,s,"I",0,function(e,t){let i=s(e,t);if(null===i)throw new n(t);return i}],37756)},85861,e=>{var t=e.i(75225),i=e.i(18899),r=e.i(14674);e.i(89963),e.s(["b",0,function(e,s){return e.select({n:i.B`count(*)`}).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,s),(0,t.E)(r.summaries.batchId))).get()?.n??0},"j",0,function(e,s){return e.select({path:r.files.path,contentHash:r.files.contentHash,lineCount:r.files.lineCount,isTest:r.files.isTest,importedBy:i.B`count(${r.imports.id})`,sizeBytes:r.files.sizeBytes}).from(r.files).leftJoin(r.imports,(0,t.u)(r.imports.targetFileId,r.files.id)).where((0,t.u)(r.files.repoId,s)).groupBy(r.files.id).orderBy(r.files.path).all()},"Q",0,function(e,i){return e.select({path:r.folders.path,parentPath:r.folders.parentPath,depth:r.folders.depth,name:r.folders.name,fileCount:r.folders.fileCount,directFileCount:r.folders.directFileCount}).from(r.folders).where((0,t.u)(r.folders.repoId,i)).orderBy(r.folders.path).all()},"q",0,(e,t)=>`${e}:${t}`])},89963,e=>{var t=e.i(75225),i=e.i(14674);e.s(["f",0,function(e,r){let s=e.select({value:i.meta.value}).from(i.meta).where((0,t.u)(i.meta.key,`indexVersion:${r}`)).get();return s?Number(s.value):0}])},38874,e=>{var t=e.i(90793),i=e.i(15342),r=e.i(37756),s=e.i(44398),n=e.i(69251),a=e.i(5947),l=e.i(45225),o=e.i(95179),u=e.i(15013);class c extends Error{constructor(){super(`Summaries are off: ANTHROPIC_API_KEY is not set (${(0,s.D)()}, then restart the Map).`),this.name="SummariesOffError"}}class d extends Error{constructor(e){super(`Summaries for ${e} haven't been confirmed, so nothing is sent from here: run ${(0,s.A)("summarize",`"${e}"`)}, which shows the estimate and asks first.`),this.name="SummariesNotConfirmedError"}}class h extends Error{constructor(){super(`No repository indexed yet. Run ${(0,s.A)("index","<path-to-repo>")}.`),this.name="NoActiveRepoError"}}class f extends Error{constructor(e,t){super(`The background worker is on ${t??"no repository"}, not ${e}; it's switching now, so try again in a moment.`),this.name="RepoSwitchingError"}}class m extends Error{constructor(e){super(e),this.name="BadInputError"}}let p={BAD_REQUEST:400,FORBIDDEN:403,NOT_FOUND:404,INDEX_EMPTY:404,INDEX_LOCKED:409,NOT_READY:409,SUMMARIES_OFF:409,BUDGET_EXCEEDED:429,UPSTREAM:502,INTERNAL:500};e.s(["E",0,m,"Z",0,h,"Q",0,p,"v",0,function(e){var s;let g=(s=e)instanceof r.V||s instanceof h||s instanceof t.e?"INDEX_EMPTY":s instanceof o.f||s instanceof a.H||s instanceof a.g||s instanceof u.d?"NOT_FOUND":s instanceof o.i||s instanceof m?"BAD_REQUEST":s instanceof i.f||s instanceof a.V||s instanceof f?"INDEX_LOCKED":s instanceof a.a||s instanceof t.K?"NOT_READY":s instanceof c||s instanceof d||s instanceof n.f?"SUMMARIES_OFF":s instanceof l.G||s instanceof l.j?"UPSTREAM":"INTERNAL",y=e instanceof Error?e.message:String(e);return{status:p[g],error:{code:g,message:"INTERNAL"===g?`Internal error: ${y}`:y}}}])},95179,e=>{var t=e.i(14747),i=e.i(90793),r=e.i(86812),s=e.i(37756),n=e.i(89963),a=e.i(30596);let l=(e,t)=>`${e}//page-${t+1}`,o=e=>`${e}//pages`,u=(e,t)=>e<t?-1:+(e>t);class c extends Error{constructor(e){super(`Nothing is indexed at "${e}".`),this.name="PathNotFoundError"}}class d extends Error{constructor(e){let t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"";super(`"${e}" is a file. Open its folder ("${t}") and select it there.`),this.name="NotAFolderError"}}function h(e,t){return e?.tagline?e.status:t?"off":e?.status??"pending"}function f(e,t,i,s){let n=new Map((0,r.W)(e,t,i).map(e=>[`${e.kind}:${e.path}`,e])),a=new Map,l=(e,t,i,r)=>{let a=n.get(`${e}:${t}`);return{path:t,name:i,kind:e,fileCount:r,...a?.tagline?{tagline:a.tagline}:{},summaryStatus:h(a,s)}};return[...(0,r.R)(e,t,i).map(e=>l("folder",e.path,e.name,e.fileCount)),...(0,r.G)(e,t,i).map(e=>(a.set(e.path,e.importedBy),l("file",e.path,e.path.slice(e.path.lastIndexOf("/")+1),1)))].sort((e,t)=>{let i,r;return t.fileCount-e.fileCount||(a.get(t.path)??0)-(a.get(e.path)??0)||((i=e.path)<(r=t.path)?-1:+(i>r))})}e.s(["i",0,d,"f",0,c,"x",0,function(e,h,m={}){let p=(0,i.$)(),g=(0,a._)(t.default.resolve(e)),y=(0,s.I)(p,g);return p.transaction(()=>{var e,t,i;let s,a;if(!(0,r.O)(p,y,h)){if((0,r.k)(p,y,h))throw new d(h);throw new c(h)}let{nodes:b,edges:w,hiddenCount:S,page:$,pageCount:v}=(e=f(p,y,h,m.summariesOff??!1),t=(0,r._)(p,y,h),i={page:m.page,focus:m.focus},s=e.length<=50?[e.map(e=>e.path)]:function(e,t,i=44){let r=new Map(e.map((e,t)=>[e.path,t])),s=e.map(()=>new Map);for(let e of t){let t=r.get(e.source),i=r.get(e.target);void 0!==t&&void 0!==i&&t!==i&&(s[t].set(i,(s[t].get(i)??0)+e.count),s[i].set(t,(s[i].get(t)??0)+e.count))}let n=Array(e.length).fill(!1),a=0,l=[];for(let t=e.length;t>0;){let e=[],r=new Map,o=i=>{for(let[a,l]of(n[i]=!0,r.delete(i),e.push(i),t--,s[i]))n[a]||r.set(a,(r.get(a)??0)+l)};for(;e.length<i&&t>0;){let e=-1,t=0;for(let[i,s]of r)(s>t||s===t&&i<e)&&(e=i,t=s);if(-1===e){for(;n[a];)a++;e=a}o(e)}l.push(e.sort((e,t)=>e-t))}return l.map(t=>t.map(t=>e[t].path))}(e,t),a=(void 0===i.focus?null:function(e,t){for(let i=0;i<e.length;i++)if(e[i].some(e=>t===e||t.startsWith(`${e}/`)))return i;return null}(s,i.focus))??Math.min(Math.max(0,Math.floor(i.page??0)),s.length-1),{...function(e,t,i,r,s,n=6){let a=new Map(t.map(e=>[e.path,e])),c=new Map;r.forEach((e,t)=>e.forEach(e=>c.set(e,t)));let d=new Map;for(let e of i){let t=c.get(e.source),i=c.get(e.target);if(void 0===t||void 0===i||t===s==(i===s))continue;let r=t===s?i:t;d.set(r,(d.get(r)??0)+e.count)}let h=[...d.entries()].sort(([e,t],[i,r])=>r-t||e-i).map(([e])=>e),f=h.length>n?n-1:h.length,m=h.slice(0,f).sort((e,t)=>e-t),p=h.slice(f).sort((e,t)=>e-t),g=new Map;m.forEach(t=>g.set(t,l(e,t))),p.forEach(t=>g.set(t,o(e)));let y=(e,t,i,s)=>{let n=i.flatMap(e=>r[e]);return{path:e,name:t,kind:"portal",...s,fileCount:n.reduce((e,t)=>e+(a.get(t)?.fileCount??0),0),hiddenCount:n.length,summaryStatus:"skipped",members:n}},b=[...r[s].flatMap(e=>a.get(e)??[]),...m.map(t=>y(l(e,t),`Page ${t+1}`,[t],{page:t})),...p.length>0?[y(o(e),`+${p.length} pages`,p,{pages:p})]:[]],w=new Map;for(let e of i){let t=c.get(e.source),i=c.get(e.target);if(void 0===t||void 0===i||t!==s&&i!==s)continue;let r=t===s?e.source:g.get(t),n=i===s?e.target:g.get(i),a=`${r}\0${n}`,l=w.get(a);l?l.count+=e.count:w.set(a,{source:r,target:n,count:e.count})}return{nodes:b,edges:[...w.values()].sort((e,t)=>u(e.source,t.source)||u(e.target,t.target))}}(h,e,t,s,a),hiddenCount:e.length-s[a].length,page:a,pageCount:s.length});return{repo:g,path:h,breadcrumb:function(e){if(""===e)return[""];let t=e.split("/");return["",...t.map((e,i)=>t.slice(0,i+1).join("/"))]}(h),nodes:b,edges:w,hiddenCount:S,page:$,pageCount:v,indexVersion:(0,n.f)(p,y)}})},"P",0,f,"D",0,h],95179)},15013,e=>{var t=e.i(14747),i=e.i(72507),r=e.i(90793),s=e.i(86304),n=e.i(44398),a=e.i(22734);let l=/^(?:[\w.-]+@)?([\w.-]+):(?!\/)(.+)$/,o=new Set(["ssh.dev.azure.com","vs-ssh.visualstudio.com"]);class u extends Error{constructor(e){super(`${e} isn't an indexed repository. Run ${(0,n.A)("index",`"${e}"`)} first.`),this.name="UnknownRepoError"}}function c(){let e=(0,s.J)((0,r.$)()).map(e=>{let i=function(e){try{let i=function(e){let i=t.default.join(e,".git");if(a.default.statSync(i).isDirectory())return t.default.join(i,"config");let r=/^gitdir:\s*(.+)$/m.exec(a.default.readFileSync(i,"utf8"));if(!r)return null;let s=t.default.resolve(e,r[1].trim()),n=t.default.join(s,"commondir"),l=a.default.existsSync(n)?t.default.resolve(s,a.default.readFileSync(n,"utf8").trim()):s;return t.default.join(l,"config")}(e);if(null===i)return null;let r=function(e){let t=!1;for(let i of e.split(/\r?\n/)){let e=i.trim();if(e.startsWith("[")){t=/^\[remote\s+"origin"\]$/i.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/i.exec(e);if(r)return r[1].trim().replace(/^"(.*)"$/,"$1")}return null}(a.default.readFileSync(i,"utf8"));return null===r?null:function(e){let t,i,r=l.exec(e);if(r)t=r[1],i=r[2];else try{let r=new URL(e);if(!r.host)return null;t=r.hostname,i=r.pathname}catch{return null}let s=i.replace(/\/+$/,"").replace(/\.git$/,"").split("/").filter(e=>""!==e&&"_git"!==e);return(o.has(t)&&"v3"===s[0]&&(s=s.slice(1)),s.length<2)?null:{owner:s.slice(0,-1).join("/"),name:s[s.length-1]}}(r)}catch{return null}}(e.rootPath);return{root:e.rootPath,name:t.default.basename(e.rootPath),indexedAt:e.lastIndexAt?.toISOString()??null,...i?{remote:i}:{}}});return{active:(0,i.s)().activeRepo,repos:e}}e.s(["d",0,u,"o",0,c,"L",0,function(e){if(!c().repos.some(t=>t.root===e))throw new u(e);return(0,i.t)(t=>({...t,activeRepo:e})),c()}],15013)},52036,e=>{e.i(46786);var t=e.i(14747);function i(){return t.default.resolve(process.env.NEBULOSITY_HOME??process.cwd())}function r(...e){return t.default.join(i(),...e)}e.s(["Q",0,function(...e){return t.default.join(t.default.resolve(process.env.NEBULOSITY_DATA??r(".nebulosity")),...e)},"W",0,i,"L",0,r])},27074,e=>{e.i(33405),e.i(22734),e.i(14747),e.i(66870),e.i(40909),e.i(30596),e.s(["f",0,1e6])},66870,40909,e=>{var t=e.i(30596);let i=/`\d+/g,r=/\.(Tests?|UnitTests|IntegrationTests|FunctionalTests)$/,s=/Tests?\.cs$/;function n(e,t){let i=t.indexOf("=");return -1===i?null:`${e} ${t.slice(0,i)} = ${t.slice(i+1)}`}let a=new Map([["using",e=>`using ${e}`],["global",e=>`global using ${e}`],["static",e=>`using static ${e}`],["gstatic",e=>`global using static ${e}`],["alias",e=>n("using",e)],["galias",e=>n("global using",e)],["ns",e=>`namespace ${e}`],["type",e=>e],["qtype",e=>e]]),l=/(^|\/)go\.mod$/,o=/(Test|Tests|IT|TestCase)\.java$/,u=/(^|\/)pom\.xml$/,c=/(^|\/)build\.gradle(\.kts)?$/,d=/(^|\/)settings\.gradle(\.kts)?$/,h=/^(test_.*\.pyi?|.*_test\.pyi?|tests\.py|conftest\.py)$/,f=/(^|\/)Cargo\.toml$/,m=/(^|\/)(package\.json|tsconfig[^/]*\.json)$/,p={id:"typescript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],languageOf:function(e){return/\.(js|jsx|mjs|cjs)$/.test(e)?"javascript":"typescript"},isTest:e=>/\.(test|spec)\.[cm]?[jt]sx?$/.test(e),manifest:m,excluded:()=>()=>!1};e.s(["e",0,m,"a",0,p],40909);let g=[p,{id:"python",extensions:[".py",".pyi"],languageOf:()=>"python",isTest:e=>h.test(e.slice(e.lastIndexOf("/")+1)),manifest:/(^|\/)(pyproject\.toml|setup\.cfg|setup\.py|pyvenv\.cfg)$/,excluded(e){let i=e.filter(e=>/(^|\/)pyvenv\.cfg$/.test(e)).map(e=>""===(0,t.a)(e)?"":`${(0,t.a)(e)}/`);return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){if(""===e)return e;let t=e.indexOf(":");return -1===t?`import ${e}`:`from ${e.slice(0,t)} import ${e.slice(t+1)}`}},{id:"go",extensions:[".go"],languageOf:()=>"go",isTest:e=>e.endsWith("_test.go"),manifest:/(^|\/)go\.(mod|work)$/,excluded(e){let i=e.filter(e=>l.test(e)).map(e=>""===(0,t.a)(e)?"vendor/":`${(0,t.a)(e)}/vendor/`);return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){if(e.startsWith("import:")){let t=e.slice(7),i=t.lastIndexOf(" as ");return -1===i?`import "${t}"`:`import ${t.slice(i+4)} "${t.slice(0,i)}"`}return e.startsWith("use:")?e.slice(4):e.startsWith("name:")?e.slice(5):e}},{id:"java",extensions:[".java"],languageOf:()=>"java",isTest:e=>o.test(e.slice(e.lastIndexOf("/")+1)),manifest:/(^|\/)(pom\.xml|build\.gradle(\.kts)?|settings\.gradle(\.kts)?)$/,excluded(e){let i=[];for(let r of e){let e=function(e){let i=(0,t.a)(e);return""===i?"":`${i}/`}(r);u.test(r)&&i.push(`${e}target/`),c.test(r)&&i.push(`${e}build/`,`${e}.gradle/`),d.test(r)&&i.push(`${e}.gradle/`)}let r=[...new Set(i)];return e=>r.some(t=>e.startsWith(t))},displaySpecifier:function(e){return e.startsWith("import:")?`import ${e.slice(7)}`:e.startsWith("static:")?`import static ${e.slice(7)}`:e.startsWith("type:")?e.slice(5):e.startsWith("qualified:")?e.slice(10):e}},{id:"csharp",extensions:[".cs"],languageOf:()=>"csharp",isTest(e){let t=e.split("/"),i=t.pop()??"";return t.some(e=>r.test(e))||s.test(i)},manifest:/(\.csproj|(^|\/)Directory\.Build\.props)$/,excluded(e){let i=e.filter(e=>e.endsWith(".csproj")).flatMap(e=>{let i=(0,t.a)(e);return""===i?["bin/","obj/"]:[`${i}/bin/`,`${i}/obj/`]});return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){var t;let r=e.indexOf(":"),s=-1===r?void 0:a.get(e.slice(0,r));return s?.((t=e.slice(r+1)).includes("`")?t.replace(i,""):t)??e}},{id:"rust",extensions:[".rs"],languageOf:()=>"rust",isTest:e=>/(^|\/)(tests|[^/]*_tests?)\.rs$/.test(e),manifest:f,excluded(e){let i=e.filter(e=>f.test(e)).map(e=>""===(0,t.a)(e)?"target/":`${(0,t.a)(e)}/target/`);return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){let t=function(e){if(e.startsWith("extern:"))return{form:"extern",name:e.slice(7)};let t=e.indexOf(":"),i=e.indexOf("|");if(-1===t||i<t)return null;let r=e.slice(0,t),s=e.slice(t+1,i),n=""===s?[]:s.split("::"),a=e.slice(i+1);if("mod"===r){let e=a.indexOf("@");return -1===e?{form:r,inline:n,name:a,path:null}:{form:r,inline:n,name:a.slice(0,e),path:a.slice(e+1)}}if("use"===r||"path"===r){let e=a.lastIndexOf(" as ");return -1===e?{form:r,inline:n,path:a,alias:null}:{form:r,inline:n,path:a.slice(0,e),alias:a.slice(e+4)}}return null}(e);if(null===t)return e;switch(t.form){case"extern":return`extern crate ${t.name}`;case"mod":return null===t.path?`mod ${t.name}`:`#[path = "${t.path}"] mod ${t.name}`;case"use":return`use ${t.path}${null===t.alias?"":` as ${t.alias}`}`;case"path":return t.path}}}];e.s(["f",0,function(e,t=g){let i=null,r=0;for(let s of t)for(let t of s.extensions)t.length>r&&e.endsWith(t)&&(i=s,r=t.length);return i}],66870)},30596,e=>{var t=e.i(14747);function i(e){return e.replace(/\\/g,"/")}e.s(["a",0,function(e){let t=e.lastIndexOf("/");return -1===t?"":e.slice(0,t)},"L",0,function(e){if(null==e)return null;let t=i(e.trim());if(t.includes("\0")||t.startsWith("/")||/^[a-zA-Z]:/.test(t))return null;let r=t.split("/").filter(e=>""!==e&&"."!==e);return r.includes("..")?null:r.join("/")},"_",0,function(e){return i(t.default.resolve(e))}])},69251,e=>{e.i(72507);var t=e.i(96023),i=e.i(98815);i.V,function(e,i){let r={};for(let s of new Set(Object.values(e))){let e=(0,t.f)(s),n=i.get(s)?.input?.usd??e?.input,a=i.get(s)?.output?.usd??e?.output;void 0!==n&&void 0!==a&&(r[s]={input:n,output:a})}}(i.V,new Map),e.s(["f",0,class extends Error{constructor(e){super(e),this.name="SummaryModelsError"}}])},96023,e=>{let t={"claude-haiku-5-5":{input:.1,output:.5},"claude-sonnet-5-5":{input:2,output:10}};e.s(["f",0,function(e,i={}){let r=e=>Object.hasOwn(i,e)?i[e]:Object.hasOwn(t,e)?t[e]:null,s=/-\d{8}$/.test(e)?e.slice(0,-9):null;return r(e)??(null===s?null:r(s))}])},98815,25328,e=>{var t=e.i(30596);e.s(["c",0,function(e,i){let r=(0,t.a)(i);return r===e?i:r.split("/").slice(0,(""===e?0:e.split("/").length)+1).join("/")},"T",0,function(e,t){if(""===e||""===t)return"";let i=e.split("/"),r=t.split("/"),s=0;for(;s<i.length&&s<r.length&&i[s]===r[s];)s++;return i.slice(0,s).join("/")}],25328),e.i(8314),e.i(54799),new WeakMap,new WeakMap,e.s(["c",0,"You write the summary a developer sees for one source file while exploring an unfamiliar codebase.\nGive a tagline and a summary. The tagline is a noun phrase of 3 to 6 plain words, like \"Retry policy with exponential backoff\". The summary is 2 to 4 sentences.\nThe summary says what the file is responsible for, names its most important exports, and says how other code uses it. The \"Imported by\" line comes from the repository's import graph; use it to say how widely and where the file is used.\nIn the summary, write identifiers (functions, classes, types, variables and file names) in backticks, like `parseConfig`.\nUse real identifiers from the file. Don't narrate the code line by line, and don't guess beyond what you're shown. Don't mention truncation or code you weren't shown.","X",0,"You write the summary a developer sees for one folder while exploring an unfamiliar codebase. You're given the summaries of the files and subfolders inside it.\nGive a tagline and a summary. The tagline is a noun phrase of 3 to 6 plain words, like \"Payment provider integrations\". The summary is 2 to 4 sentences.\nThe summary says what the folder is responsible for as a whole, which parts matter most, and how they fit together.\nIn the summary, write file, folder, function and class names in backticks, like `retry.ts`.\nDon't list every item, and don't guess beyond the summaries you're given.","_",0,"You write the overview a developer sees first when opening an unfamiliar repository. You're given the summaries of its top-level folders and files.\nGive a tagline and a summary. The tagline is a noun phrase of 3 to 6 plain words, like \"Distributed task scheduling service\". The summary is 2 to 4 sentences.\nThe summary says what the project is, names its main areas, and says where a newcomer should start reading.\nIn the summary, write folder and file names in backticks, like `src/server`.\nDon't guess beyond the summaries you're given.","V",0,{file:"claude-haiku-5-5",folder:"claude-sonnet-5-5",repo:"claude-sonnet-5-5"},"G",0,function(e,t,i=`${t}s`){return`${e.toLocaleString("en-US")} ${1===e?t:i}`}],98815)},5947,45225,e=>{e.i(54799),e.i(22734),e.i(14747),e.i(90793),e.i(15342),e.i(86304),e.i(37756),e.i(85861);var t=e.i(44398);e.i(30596),e.i(69251),e.i(27074);var i=e.i(98815),r=e.i(72507);e.s(["j",0,class extends Error{model;reason;constructor(e,t,i=(0,r.V)()){super(`${e} isn't available: it was retired, or isn't open to this API key (the API said: ${t}). Choose another model under "summaryModels" in ${i}; see the README's "Summary models".`),this.model=e,this.reason=t,this.name="ModelUnavailableError"}},"G",0,class extends Error{reason;constructor(e){super(`Anthropic rejected the API key: ${e}`),this.reason=e,this.name="SummarizerAuthError"}}],45225),i.c,i.X,i._,e.s(["V",0,class extends Error{state;constructor(e){super(`the structure stage is ${e}; wait for the index run to finish, or run ${(0,t.A)("index","<path-to-repo>")} again, before summarizing`),this.state=e,this.name="StructureNotReadyError"}},"H",0,class extends Error{constructor(e){super(`Nothing indexed at "${e}". Pass a repo-relative file or folder path ("" for the repo itself).`),this.name="TargetNotFoundError"}},"a",0,class extends Error{constructor(e){super(`"${e}" can't be summarized yet: some of its files or subfolders have no summary, and a folder's summary is written from theirs. Run ${(0,t.A)("summarize","<path-to-repo>")}, or open them first.`),this.name="TargetNotReadyError"}},"g",0,class extends Error{batchId;constructor(e){super(`No request of this repo is waiting in batch ${e}. Copy the id from the summaries stage's note.`),this.batchId=e,this.name="UnknownBatchError"}}],5947)},20842,18899,75225,49129,26889,94176,14674,e=>{let t,i;var r,s=e.i(85148);let n=Symbol.for("drizzle:entityKind");function a(e,t){if(!e||"object"!=typeof e)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`Class "${t.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 i=Object.getPrototypeOf(e).constructor;if(i)for(;i;){if(n in i&&i[n]===t[n])return!0;i=Object.getPrototypeOf(i)}return!1}Symbol.for("drizzle:hasOwnEntityKind");class l{static [n]="ConsoleLogWriter";write(e){console.log(e)}}class o{static [n]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new l}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 u{static [n]="NoopLogger";logQuery(){}}let c=Symbol.for("drizzle:Name"),d=Symbol.for("drizzle:Schema"),h=Symbol.for("drizzle:Columns"),f=Symbol.for("drizzle:ExtraConfigColumns"),m=Symbol.for("drizzle:OriginalName"),p=Symbol.for("drizzle:BaseName"),g=Symbol.for("drizzle:IsAlias"),y=Symbol.for("drizzle:ExtraConfigBuilder"),b=Symbol.for("drizzle:IsDrizzleTable");class w{static [n]="Table";static Symbol={Name:c,Schema:d,OriginalName:m,Columns:h,ExtraConfigColumns:f,BaseName:p,IsAlias:g,ExtraConfigBuilder:y};[c];[m];[d];[h];[f];[p];[g]=!1;[b]=!0;[y]=void 0;constructor(e,t,i){this[c]=this[m]=e,this[d]=t,this[p]=i}}function S(e){return`${e[d]??"public"}.${e[c]}`}class ${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 [n]="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}}class v{static [n]="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)}}class N{static [n]="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 x(e,this)}}class x{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),r=t.map(e=>e.name),s=i.map(e=>e.name),n=[this.table[c],...r,i[0].table[c],...s];return e??`${n.join("_")}_fk`}}function _(e,...t){return e(...t)}function C(e,t){return`${e[c]}_${t.join("_")}_unique`}class T{constructor(e,t,i,r){this.table=e,this.columns=t,this.name=r??C(this.table,this.columns.map(e=>e.name)),this.nullsNotDistinct=i}static [n]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function Q(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]}class q extends v{foreignKeyConfigs=[];static [n]="PgColumnBuilder";array(e){return new B(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})=>_((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 I(e,this.config)}}class L extends ${constructor(e,t){t.uniqueName||(t.uniqueName=C(e,[t.name])),super(e,t),this.table=e}static [n]="PgColumn"}class I extends L{static [n]="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 B extends q{static [n]="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 O(e,this.config,t)}}class O extends L{constructor(e,t,i,r){super(e,t),this.baseColumn=i,this.range=r,this.size=t.size}size;static [n]="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]=Q(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[l,o]=Q(t,s,!1);r.push(l),s=o}return[r,s]}(e,1);return t}(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(e,t=!1){let i=e.map(e=>null===e?null:a(this.baseColumn,O)?this.baseColumn.mapToDriverValue(e,!0):this.baseColumn.mapToDriverValue(e));return t?i:function e(t){return`{${t.map(t=>Array.isArray(t)?e(t):"string"==typeof t?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}(i)}}let E=Symbol.for("drizzle:isPgEnum");class A{static [n]="Subquery";constructor(e,t,i,r=!1,s=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:i,isWith:r,usedTables:s}}}class j extends A{static [n]="WithSubquery"}let D=(e,r)=>t?(i||(i=t.trace.getTracer("drizzle-orm","0.45.2")),_((t,i)=>i.startActiveSpan(e,e=>{try{return r(e)}catch(i){throw e.setStatus({code:t.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{e.end()}}),t,i)):r(),F=Symbol.for("drizzle:ViewBaseConfig");function k(e){return null!=e&&"function"==typeof e.getSQL}class P{static [n]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new M([this])}}class M{constructor(e){for(let t of(this.queryChunks=e,e))if(a(t,w)){let e=t[w.Symbol.Schema];this.usedTables.push(void 0===e?t[w.Symbol.Name]:e+"."+t[w.Symbol.Name])}}static [n]="SQL";decoder=z;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return D("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 i=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:r,escapeName:s,escapeParam:n,prepareTyping:l,inlineParams:o,paramStartIndex:u}=i;var c=e.map(e=>{if(a(e,P))return{sql:e.value.join(""),params:[]};if(a(e,R))return{sql:s(e.value),params:[]};if(void 0===e)return{sql:"",params:[]};if(Array.isArray(e)){let t=[new P("(")];for(let[i,r]of e.entries())t.push(r),i<e.length-1&&t.push(new P(", "));return t.push(new P(")")),this.buildQueryFromSourceParams(t,i)}if(a(e,M))return this.buildQueryFromSourceParams(e.queryChunks,{...i,inlineParams:o||e.shouldInlineParams});if(a(e,w)){let t=e[w.Symbol.Schema],i=e[w.Symbol.Name];return{sql:void 0===t||e[g]?s(i):s(t)+"."+s(i),params:[]}}if(a(e,$)){let i=r.getColumnCasing(e);if("indexes"===t.invokeSource)return{sql:s(i),params:[]};let n=e.table[w.Symbol.Schema];return{sql:e.table[g]||void 0===n?s(e.table[w.Symbol.Name])+"."+s(i):s(n)+"."+s(e.table[w.Symbol.Name])+"."+s(i),params:[]}}if(a(e,H)){let t=e[F].schema,i=e[F].name;return{sql:void 0===t||e[F].isAlias?s(i):s(t)+"."+s(i),params:[]}}if(a(e,V)){if(a(e.value,W))return{sql:n(u.value++,e),params:[e],typings:["none"]};let t=null===e.value?null:e.encoder.mapToDriverValue(e.value);if(a(t,M))return this.buildQueryFromSourceParams([t],i);if(o)return{sql:this.mapInlineParam(t,i),params:[]};let r=["none"];return l&&(r=[l(e.encoder)]),{sql:n(u.value++,t),params:[t],typings:r}}return a(e,W)?{sql:n(u.value++,e),params:[e],typings:["none"]}:a(e,M.Aliased)&&void 0!==e.fieldAlias?{sql:s(e.fieldAlias),params:[]}:a(e,A)?e._.isWith?{sql:s(e._.alias),params:[]}:this.buildQueryFromSourceParams([new P("("),e._.sql,new P(") "),new R(e._.alias)],i):e&&"function"==typeof e&&E in e&&!0===e[E]?e.schema?{sql:s(e.schema)+"."+s(e.enumName),params:[]}:{sql:s(e.enumName),params:[]}:k(e)?e.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([e.getSQL()],i):this.buildQueryFromSourceParams([new P("("),e.getSQL(),new P(")")],i):o?{sql:this.mapInlineParam(e,i),params:[]}:{sql:n(u.value++,e),params:[e],typings:["none"]}});let d={sql:"",params:[]};for(let e of c)d.sql+=e.sql,d.params.push(...e.params),e.typings?.length&&(d.typings||(d.typings=[]),d.typings.push(...e.typings));return d}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 M.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 R{constructor(e){this.value=e}static [n]="Name";brand;getSQL(){return new M([this])}}function K(e){return"object"==typeof e&&null!==e&&"mapToDriverValue"in e&&"function"==typeof e.mapToDriverValue}let z={mapFromDriverValue:e=>e},U={mapToDriverValue:e=>e};({...z,...U});class V{constructor(e,t=U){this.value=e,this.encoder=t}static [n]="Param";brand;getSQL(){return new M([this])}}function J(e,...t){let i=[];for(let[r,s]of((t.length>0||e.length>0&&""!==e[0])&&i.push(new P(e[0])),t.entries()))i.push(s,new P(e[r+1]));return new M(i)}(r=J||(J={})).empty=function(){return new M([])},r.fromList=function(e){return new M(e)},r.raw=function(e){return new M([new P(e)])},r.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 M(i)},r.identifier=function(e){return new R(e)},r.placeholder=function(e){return new W(e)},r.param=function(e,t){return new V(e,t)},(M||(M={})).Aliased=class e{constructor(e,t){this.sql=e,this.fieldAlias=t}static [n]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}};class W{constructor(e){this.name=e}static [n]="Placeholder";getSQL(){return new M([this])}}function Y(e,t){return e.map(e=>{if(a(e,W)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(a(e,V)&&a(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})}let G=Symbol.for("drizzle:IsDrizzleView");class H{static [n]="View";[F];[G]=!0;constructor({name:e,schema:t,selectedFields:i,query:r}){this[F]={name:e,originalName:e,schema:t,selectedFields:i,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new M([this])}}function X(e,t,i){let r={},s=e.reduce((e,{path:s,field:n},l)=>{let o;o=a(n,$)?n:a(n,M)?n.decoder:a(n,A)?n._.sql.decoder:n.sql.decoder;let u=e;for(let[e,d]of s.entries())if(e<s.length-1)d in u||(u[d]={}),u=u[d];else{let e=t[l],h=u[d]=null===e?null:o.mapFromDriverValue(e);if(i&&a(n,$)&&2===s.length){let e=s[0];e in r?"string"==typeof r[e]&&r[e]!==n.table[c]&&(r[e]=!1):r[e]=null===h&&n.table[c]}}return e},{});if(i&&Object.keys(r).length>0)for(let[e,t]of Object.entries(r))"string"!=typeof t||i[t]||(s[e]=null);return s}function Z(e,t){return Object.entries(e).reduce((e,[i,r])=>{if("string"!=typeof i)return e;let s=t?[...t,i]:[i];return a(r,$)||a(r,M)||a(r,M.Aliased)||a(r,A)?e.push({path:s,field:r}):a(r,w)?e.push(...Z(r[w.Symbol.Columns],s)):e.push(...Z(r,s)),e},[])}function ee(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}function et(e,t){let i=Object.entries(t).filter(([,e])=>void 0!==e).map(([t,i])=>a(i,M)||a(i,$)?[t,i]:[t,new V(i,e[w.Symbol.Columns][t])]);if(0===i.length)throw Error("No values to set");return Object.fromEntries(i)}function ei(e){return a(e,A)?e._.alias:a(e,H)?e[F].name:a(e,M)?void 0:e[w.Symbol.IsAlias]?e[w.Symbol.Name]:e[w.Symbol.BaseName]}function er(e,t){return{name:"string"==typeof e&&e.length>0?e:"",config:"object"==typeof e?e:t}}$.prototype.getSQL=function(){return new M([this])},w.prototype.getSQL=function(){return new M([this])},A.prototype.getSQL=function(){return new M([this])},e.s(["r",0,V,"W",0,W,"o",0,M,"c",0,P,"_",0,H,"X",0,Y,"N",0,K,"f",0,k,"B",0,J],18899);let es="u"<typeof TextDecoder?null:new TextDecoder,en=Symbol.for("drizzle:PgInlineForeignKeys"),ea=Symbol.for("drizzle:EnableRLS");class el extends w{static [n]="PgTable";static Symbol=Object.assign({},w.Symbol,{InlineForeignKeys:en,EnableRLS:ea});[en]=[];[ea]=!1;[w.Symbol.ExtraConfigBuilder]=void 0;[w.Symbol.ExtraConfigColumns]={}}class eo{static [n]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new eu(e,this.columns,this.name)}}class eu{constructor(e,t,i){this.table=e,this.columns=t,this.name=i}static [n]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[el.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}function ec(e,t){return!K(t)||k(e)||a(e,V)||a(e,W)||a(e,$)||a(e,w)||a(e,H)?e:new V(e,t)}let ed=(e,t)=>J`${e} = ${ec(t,e)}`,eh=(e,t)=>J`${e} <> ${ec(t,e)}`;function ef(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new M(1===t.length?t:[new P("("),J.join(t,new P(" and ")),new P(")")])}function em(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new M(1===t.length?t:[new P("("),J.join(t,new P(" or ")),new P(")")])}function ep(e){return J`not ${e}`}let eg=(e,t)=>J`${e} > ${ec(t,e)}`,ey=(e,t)=>J`${e} >= ${ec(t,e)}`,eb=(e,t)=>J`${e} < ${ec(t,e)}`,ew=(e,t)=>J`${e} <= ${ec(t,e)}`;function eS(e,t){return Array.isArray(t)?0===t.length?J`false`:J`${e} in ${t.map(t=>ec(t,e))}`:J`${e} in ${ec(t,e)}`}function e$(e,t){return Array.isArray(t)?0===t.length?J`true`:J`${e} not in ${t.map(t=>ec(t,e))}`:J`${e} not in ${ec(t,e)}`}function ev(e){return J`${e} is null`}function eN(e){return J`${e} is not null`}function ex(e){return J`exists ${e}`}function e_(e){return J`not exists ${e}`}function eC(e,t,i){return J`${e} between ${ec(t,e)} and ${ec(i,e)}`}function eT(e,t,i){return J`${e} not between ${ec(t,e)} and ${ec(i,e)}`}function eQ(e,t){return J`${e} like ${t}`}function eq(e,t){return J`${e} not like ${t}`}function eL(e,t){return J`${e} ilike ${t}`}function eI(e,t){return J`${e} not ilike ${t}`}function eB(e){return J`${e} asc`}function eO(e){return J`${e} desc`}e.s(["b",0,ef,"C",0,eC,"u",0,ed,"v",0,ex,"H",0,eg,"B",0,ey,"O",0,eL,"y",0,eS,"E",0,eN,"M",0,ev,"D",0,eQ,"S",0,eb,"n",0,ew,"c",0,eh,"R",0,ep,"e",0,eT,"k",0,e_,"t",0,eI,"$",0,e$,"s",0,eq,"F",0,em],75225),e.s(["M",0,eB,"A",0,eO],49129);class eE{constructor(e,t,i){this.sourceTable=e,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[w.Symbol.Name]}static [n]="Relation";referencedTableName;fieldName}class eA{constructor(e,t){this.table=e,this.config=t}static [n]="Relations"}class ej extends eE{constructor(e,t,i,r){super(e,t,i?.relationName),this.config=i,this.isNullable=r}static [n]="One";withFieldName(e){let t=new ej(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class eD extends eE{constructor(e,t,i){super(e,t,i?.relationName),this.config=i}static [n]="Many";withFieldName(e){let t=new eD(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function eF(e){return{one:function(t,i){return new ej(e,t,i,i?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)},many:function(t,i){return new eD(e,t,i)}}}class ek{constructor(e){this.table=e}static [n]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class eP{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [n]="TableAliasProxyHandler";get(e,t){if(t===w.Symbol.IsAlias)return!0;if(t===w.Symbol.Name||this.replaceOriginalName&&t===w.Symbol.OriginalName)return this.alias;if(t===F)return{...e[F],name:this.alias,isAlias:!0};if(t===w.Symbol.Columns){let t=e[w.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(r=>{i[r]=new Proxy(t[r],new ek(new Proxy(e,this)))}),i}let i=e[t];return a(i,$)?new Proxy(i,new ek(new Proxy(e,this))):i}}function eM(e,t){return new Proxy(e,new eP(t,!1))}function eR(e,t){return new Proxy(e,new ek(new Proxy(e.table,new eP(t,!1))))}function eK(e,t){return new M.Aliased(ez(e.sql,t),e.fieldAlias)}function ez(e,t){return J.join(e.queryChunks.map(e=>a(e,$)?eR(e,t):a(e,M)?ez(e,t):a(e,M.Aliased)?eK(e,t):e))}class eU{static [n]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===F)return{...e[F],selectedFields:new Proxy(e[F].selectedFields,this)};if("symbol"==typeof t)return e[t];let i=(a(e,A)?e._.selectedFields:a(e,H)?e[F].selectedFields:e)[t];if(a(i,M.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(a(i,M)){if("sql"===this.config.sqlBehavior)return i;throw Error(`You tried to reference "${t}" 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 a(i,$)?this.config.alias?new Proxy(i,new ek(new Proxy(i.table,new eP(this.config.alias,this.config.replaceOriginalName??!1)))):i:"object"!=typeof i||null===i?i:new Proxy(i,new eU(this.config))}}function eV(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function eJ(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 eW(e){return e}class eY{static [n]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?eV:"camelCase"===e?eJ:eW}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[w.Symbol.Schema]??"public",i=e.table[w.Symbol.OriginalName],r=`${t}.${i}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[w.Symbol.Schema]??"public",i=e[w.Symbol.OriginalName],r=`${t}.${i}`;if(!this.cachedTables[r]){for(let t of Object.values(e[w.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class eG extends Error{static [n]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class eH extends Error{constructor(e,t,i){super(`Failed query: ${e}
|
|
2
|
-
params: ${t}`),this.query=e,this.params=t,this.cause=i,Error.captureStackTrace(this,eH),i&&(this.cause=i)}}class eX extends eG{static [n]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class eZ{static [n]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;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=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new e0(e,this)}}class e0{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),r=t.map(e=>e.name),s=i.map(e=>e.name),n=[this.table[c],...r,i[0].table[c],...s];return e??`${n.join("_")}_fk`}}function e1(e,t){return`${e[c]}_${t.join("_")}_unique`}class e4{constructor(e,t,i){this.table=e,this.columns=t,this.name=i??e1(this.table,this.columns.map(e=>e.name))}static [n]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}class e5 extends v{static [n]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:r})=>{let s;return s=new eZ(()=>({columns:[e],foreignColumns:[i()]})),r.onUpdate&&s.onUpdate(r.onUpdate),r.onDelete&&s.onDelete(r.onDelete),s.build(t)})}}class e2 extends ${constructor(e,t){t.uniqueName||(t.uniqueName=e1(e,[t.name])),super(e,t),this.table=e}static [n]="SQLiteColumn"}class e7 extends e5{static [n]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new e9(e,this.config)}}class e9 extends e2{static [n]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){return"u">typeof Buffer&&Buffer.from?BigInt((Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e)).toString("utf8")):BigInt(es.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}}class e8 extends e5{static [n]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new e6(e,this.config)}}class e6 extends e2{static [n]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){return"u">typeof Buffer&&Buffer.from?JSON.parse((Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e)).toString("utf8")):JSON.parse(es.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}}class e3 extends e5{static [n]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new te(e,this.config)}}class te extends e2{static [n]="SQLiteBlobBuffer";mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return"blob"}}function tt(e,t){let{name:i,config:r}=er(e,t);return r?.mode==="json"?new e8(i):r?.mode==="bigint"?new e7(i):new e3(i)}class ti extends e5{static [n]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new tr(e,this.config)}}class tr extends e2{static [n]="SQLiteCustomColumn";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 ts(e){return(t,i)=>{let{name:r,config:s}=er(t,i);return new ti(r,s,e)}}class tn extends e5{static [n]="SQLiteBaseIntegerBuilder";constructor(e,t,i){super(e,t,i),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}}class ta extends e2{static [n]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class tl extends tn{static [n]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new to(e,this.config)}}class to extends ta{static [n]="SQLiteInteger"}class tu extends tn{static [n]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t}defaultNow(){return this.default(J`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new tc(e,this.config)}}class tc extends ta{static [n]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return new Date("timestamp"===this.config.mode?1e3*e:e)}mapToDriverValue(e){let t=e.getTime();return"timestamp"===this.config.mode?Math.floor(t/1e3):t}}class td extends tn{static [n]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t}build(e){return new th(e,this.config)}}class th extends ta{static [n]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return 1===Number(e)}mapToDriverValue(e){return+!!e}}function tf(e,t){let{name:i,config:r}=er(e,t);return r?.mode==="timestamp"||r?.mode==="timestamp_ms"?new tu(i,r.mode):r?.mode==="boolean"?new td(i,r.mode):new tl(i)}class tm extends e5{static [n]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new tp(e,this.config)}}class tp extends e2{static [n]="SQLiteNumeric";mapFromDriverValue(e){return"string"==typeof e?e:String(e)}getSQLType(){return"numeric"}}class tg extends e5{static [n]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new ty(e,this.config)}}class ty extends e2{static [n]="SQLiteNumericNumber";mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}}class tb extends e5{static [n]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new tw(e,this.config)}}class tw extends e2{static [n]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function tS(e,t){let{name:i,config:r}=er(e,t),s=r?.mode;return"number"===s?new tg(i):"bigint"===s?new tb(i):new tm(i)}class t$ extends e5{static [n]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new tv(e,this.config)}}class tv extends e2{static [n]="SQLiteReal";getSQLType(){return"real"}}function tN(e){return new t$(e??"")}class tx extends e5{static [n]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new t_(e,this.config)}}class t_ extends e2{static [n]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class tC extends e5{static [n]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new tT(e,this.config)}}class tT extends e2{static [n]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}function tQ(e,t={}){let{name:i,config:r}=er(e,t);return"json"===r.mode?new tC(i):new tx(i,r)}let tq=Symbol.for("drizzle:SQLiteInlineForeignKeys");class tL extends w{static [n]="SQLiteTable";static Symbol=Object.assign({},w.Symbol,{InlineForeignKeys:tq});[w.Symbol.Columns];[tq]=[];[w.Symbol.ExtraConfigBuilder]=void 0}let tI=(e,t,i)=>(function(e,t,i,r=e){let s=new tL(e,void 0,r),n=Object.fromEntries(Object.entries("function"==typeof t?t({blob:tt,customType:ts,integer:tf,numeric:tS,real:tN,text:tQ}):t).map(([e,t])=>{t.setName(e);let i=t.build(s);return s[tq].push(...t.buildForeignKeys(i,s)),[e,i]})),a=Object.assign(s,n);return a[w.Symbol.Columns]=n,a[w.Symbol.ExtraConfigColumns]=n,i&&(a[tL.Symbol.ExtraConfigBuilder]=i),a})(e,t,i);class tB extends H{static [n]="SQLiteViewBase"}class tO{static [n]="SQLiteDialect";casing;constructor(e){this.casing=new eY(e?.casing)}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[J`with `];for(let[i,r]of e.entries())t.push(J`${J.identifier(r._.alias)} as (${r._.sql})`),i<e.length-1&&t.push(J`, `);return t.push(J` `),J.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:r,limit:s,orderBy:n}){let a=this.buildWithCTE(r),l=i?J` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,o=t?J` where ${t}`:void 0,u=this.buildOrderBy(n),c=this.buildLimit(s);return J`${a}delete from ${e}${o}${l}${u}${c}`}buildUpdateSet(e,t){let i=e[w.Symbol.Columns],r=Object.keys(i).filter(e=>void 0!==t[e]||i[e]?.onUpdateFn!==void 0),s=r.length;return J.join(r.flatMap((e,r)=>{let n=i[e],l=n.onUpdateFn?.(),o=t[e]??(a(l,M)?l:J.param(l,n)),u=J`${J.identifier(this.casing.getColumnCasing(n))} = ${o}`;return r<s-1?[u,J.raw(", ")]:[u]}))}buildUpdateQuery({table:e,set:t,where:i,returning:r,withList:s,joins:n,from:a,limit:l,orderBy:o}){let u=this.buildWithCTE(s),c=this.buildUpdateSet(e,t),d=a&&J.join([J.raw(" from "),this.buildFromTable(a)]),h=this.buildJoins(n),f=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,m=i?J` where ${i}`:void 0,p=this.buildOrderBy(o),g=this.buildLimit(l);return J`${u}update ${e} set ${c}${d}${h}${m}${f}${p}${g}`}buildSelection(e,{isSingleTable:t=!1}={}){let i=e.length,r=e.flatMap(({field:e},r)=>{let s=[];if(a(e,M.Aliased)&&e.isSelectionField)s.push(J.identifier(e.fieldAlias));else if(a(e,M.Aliased)||a(e,M)){let i=a(e,M.Aliased)?e.sql:e;t?s.push(new M(i.queryChunks.map(e=>a(e,$)?J.identifier(this.casing.getColumnCasing(e)):e))):s.push(i),a(e,M.Aliased)&&s.push(J` as ${J.identifier(e.fieldAlias)}`)}else if(a(e,$)){let i=e.table[w.Symbol.Name];"SQLiteNumericBigInt"===e.columnType?t?s.push(J`cast(${J.identifier(this.casing.getColumnCasing(e))} as text)`):s.push(J`cast(${J.identifier(i)}.${J.identifier(this.casing.getColumnCasing(e))} as text)`):t?s.push(J.identifier(this.casing.getColumnCasing(e))):s.push(J`${J.identifier(i)}.${J.identifier(this.casing.getColumnCasing(e))}`)}else if(a(e,A)){let t=Object.entries(e._.selectedFields);if(1===t.length){let i=t[0][1],r=a(i,M)?i.decoder:a(i,$)?{mapFromDriverValue:e=>i.mapFromDriverValue(e)}:i.sql.decoder;r&&(e._.sql.decoder=r)}s.push(e)}return r<i-1&&s.push(J`, `),s});return J.join(r)}buildJoins(e){if(!e||0===e.length)return;let t=[];if(e)for(let[i,r]of e.entries()){0===i&&t.push(J` `);let s=r.table,n=r.on?J` on ${r.on}`:void 0;if(a(s,tL)){let e=s[tL.Symbol.Name],i=s[tL.Symbol.Schema],a=s[tL.Symbol.OriginalName],l=e===a?void 0:r.alias;t.push(J`${J.raw(r.joinType)} join ${i?J`${J.identifier(i)}.`:void 0}${J.identifier(a)}${l&&J` ${J.identifier(l)}`}${n}`)}else t.push(J`${J.raw(r.joinType)} join ${s}${n}`);i<e.length-1&&t.push(J` `)}return J.join(t)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?J` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,r]of e.entries())t.push(r),i<e.length-1&&t.push(J`, `);return t.length>0?J` order by ${J.join(t)}`:void 0}buildFromTable(e){return a(e,w)&&e[w.Symbol.IsAlias]?J`${J`${J.identifier(e[w.Symbol.Schema]??"")}.`.if(e[w.Symbol.Schema])}${J.identifier(e[w.Symbol.OriginalName])} ${J.identifier(e[w.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:r,having:s,table:n,joins:l,orderBy:o,groupBy:u,limit:d,offset:h,distinct:f,setOperators:m}){let p=i??Z(t);for(let e of p){let t;if(a(e.field,$)&&e.field.table[c]!==(a(n,A)?n._.alias:a(n,tB)?n[F].name:a(n,M)?void 0:n[c])&&(t=e.field.table,!l?.some(({alias:e})=>e===(t[w.Symbol.IsAlias]?t[c]:t[w.Symbol.BaseName])))){let t=e.field.table[c];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 g=!l||0===l.length,y=this.buildWithCTE(e),b=f?J` distinct`:void 0,S=this.buildSelection(p,{isSingleTable:g}),v=this.buildFromTable(n),N=this.buildJoins(l),x=r?J` where ${r}`:void 0,_=s?J` having ${s}`:void 0,C=[];if(u)for(let[e,t]of u.entries())C.push(t),e<u.length-1&&C.push(J`, `);let T=C.length>0?J` group by ${J.join(C)}`:void 0,Q=this.buildOrderBy(o),q=this.buildLimit(d),L=h?J` offset ${h}`:void 0,I=J`${y}select${b} ${S} from ${v}${N}${x}${T}${_}${Q}${q}${L}`;return m.length>0?this.buildSetOperations(I,m):I}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:i,rightSelect:r,limit:s,orderBy:n,offset:l}}){let o,u=J`${e.getSQL()} `,c=J`${r.getSQL()}`;if(n&&n.length>0){let e=[];for(let t of n)if(a(t,e2))e.push(J.identifier(t.name));else if(a(t,M)){for(let e=0;e<t.queryChunks.length;e++){let i=t.queryChunks[e];a(i,e2)&&(t.queryChunks[e]=J.identifier(this.casing.getColumnCasing(i)))}e.push(J`${t}`)}else e.push(J`${t}`);o=J` order by ${J.join(e,J`, `)}`}let d="object"==typeof s||"number"==typeof s&&s>=0?J` limit ${s}`:void 0,h=J.raw(`${t} ${i?"all ":""}`),f=l?J` offset ${l}`:void 0;return J`${u}${h}${c}${o}${d}${f}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:r,withList:s,select:n}){let l=[],o=Object.entries(e[w.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),u=o.map(([,e])=>J.identifier(this.casing.getColumnCasing(e)));if(n)a(t,M)?l.push(t):l.push(t.getSQL());else for(let[e,i]of(l.push(J.raw("values ")),t.entries())){let r=[];for(let[e,t]of o){let s=i[e];if(void 0===s||a(s,V)&&void 0===s.value){let e;if(null!==t.default&&void 0!==t.default)e=a(t.default,M)?t.default:J.param(t.default,t);else if(void 0!==t.defaultFn){let i=t.defaultFn();e=a(i,M)?i:J.param(i,t)}else if(t.default||void 0===t.onUpdateFn)e=J`null`;else{let i=t.onUpdateFn();e=a(i,M)?i:J.param(i,t)}r.push(e)}else r.push(s)}l.push(r),e<t.length-1&&l.push(J`, `)}let c=this.buildWithCTE(s),d=J.join(l),h=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,f=i?.length?J.join(i):void 0;return J`${c}insert into ${e} ${u} ${d}${f}${h}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:r,tableConfig:s,queryConfig:n,tableAlias:l,nestedQueryRelation:o,joinOn:u}){let c,d=[],h,f,m=[],p,g=[];if(!0===n)d=Object.entries(s.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:eR(t,l),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let r=Object.fromEntries(Object.entries(s.columns).map(([e,t])=>[e,eR(t,l)]));if(n.where){let e="function"==typeof n.where?n.where(r,{and:ef,between:eC,eq:ed,exists:ex,gt:eg,gte:ey,ilike:eL,inArray:eS,isNull:ev,isNotNull:eN,like:eQ,lt:eb,lte:ew,ne:eh,not:ep,notBetween:eT,notExists:e_,notLike:eq,notIlike:eI,notInArray:e$,or:em,sql:J}):n.where;p=e&&ez(e,l)}let o=[],u=[];if(n.columns){let e=!1;for(let[t,i]of Object.entries(n.columns))void 0!==i&&t in s.columns&&(e||!0!==i||(e=!0),u.push(t));u.length>0&&(u=e?u.filter(e=>n.columns?.[e]===!0):Object.keys(s.columns).filter(e=>!u.includes(e)))}else u=Object.keys(s.columns);for(let e of u){let t=s.columns[e];o.push({tsKey:e,value:t})}let c=[];if(n.with&&(c=Object.entries(n.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:s.relations[e]}))),n.extras)for(let[e,t]of Object.entries("function"==typeof n.extras?n.extras(r,{sql:J}):n.extras))o.push({tsKey:e,value:eK(t,l)});for(let{tsKey:e,value:t}of o)d.push({dbKey:a(t,M.Aliased)?t.fieldAlias:s.columns[e].name,tsKey:e,field:a(t,$)?eR(t,l):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let g="function"==typeof n.orderBy?n.orderBy(r,{sql:J,asc:eB,desc:eO}):n.orderBy??[];for(let{tsKey:r,queryConfig:s,relation:o}of(Array.isArray(g)||(g=[g]),m=g.map(e=>a(e,$)?eR(e,l):ez(e,l)),h=n.limit,f=n.offset,c)){let n=function(e,t,i){if(a(i,ej)&&i.config)return{fields:i.config.fields,references:i.config.references};let r=t[S(i.referencedTable)];if(!r)throw Error(`Table "${i.referencedTable[w.Symbol.Name]}" not found in schema`);let s=e[r];if(!s)throw Error(`Table "${r}" not found in schema`);let n=i.sourceTable,l=t[S(n)];if(!l)throw Error(`Table "${n[w.Symbol.Name]}" not found in schema`);let o=[];for(let e of Object.values(s.relations))(i.relationName&&i!==e&&e.relationName===i.relationName||!i.relationName&&e.referencedTable===i.sourceTable)&&o.push(e);if(o.length>1)throw i.relationName?Error(`There are multiple relations with name "${i.relationName}" in table "${r}"`):Error(`There are multiple relations between "${r}" and "${i.sourceTable[w.Symbol.Name]}". Please specify relation name`);if(o[0]&&a(o[0],ej)&&o[0].config)return{fields:o[0].config.references,references:o[0].config.fields};throw Error(`There is not enough information to infer relation "${l}.${i.fieldName}"`)}(t,i,o),u=i[S(o.referencedTable)],c=`${l}_${r}`,h=ef(...n.fields.map((e,t)=>ed(eR(n.references[t],c),eR(e,l)))),f=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[u],tableConfig:t[u],queryConfig:a(o,ej)?!0===s?{limit:1}:{...s,limit:1}:s,tableAlias:c,joinOn:h,nestedQueryRelation:o}),m=J`(${f.sql})`.as(r);d.push({dbKey:r,tsKey:r,field:m,relationTableTsKey:u,isJson:!0,selection:f.selection})}}if(0===d.length)throw new eG({message:`No fields selected for table "${s.tsName}" ("${l}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});if(p=ef(u,p),o){let e=J`json_array(${J.join(d.map(({field:e})=>a(e,e2)?J.identifier(this.casing.getColumnCasing(e)):a(e,M.Aliased)?e.sql:e),J`, `)})`;a(o,eD)&&(e=J`coalesce(json_group_array(${e}), json_array())`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:s.tsName,selection:d}];void 0!==h||void 0!==f||m.length>0?(c=this.buildSelectQuery({table:eM(r,l),fields:{},fieldsFlat:[{path:[],field:J.raw("*")}],where:p,limit:h,offset:f,orderBy:m,setOperators:[]}),p=void 0,h=void 0,f=void 0,m=void 0):c=eM(r,l),c=this.buildSelectQuery({table:a(c,tL)?c:new A(c,{},l),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:a(e,$)?eR(e,l):e})),joins:g,where:p,limit:h,offset:f,orderBy:m,setOperators:[]})}else c=this.buildSelectQuery({table:eM(r,l),fields:{},fieldsFlat:d.map(({field:e})=>({path:[],field:a(e,$)?eR(e,l):e})),joins:g,where:p,limit:h,offset:f,orderBy:m,setOperators:[]});return{tableTsKey:s.tsName,sql:c,selection:d}}}class tE extends tO{static [n]="SQLiteSyncDialect";migrate(e,t,i){let r=void 0===i||"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",s=J`
|
|
1
|
+
module.exports=[[72507,e=>{var t=e.i(54799),i=e.i(22734),r=e.i(14747),s=e.i(52036);function n(){return(0,s.Q)("config.json")}function a(e){try{return{kind:"bytes",bytes:i.default.readFileSync(e)}}catch(e){var t;return"ENOENT"===(t=e,t?.code)?{kind:"missing"}:{kind:"error",error:e}}}function o(e,t){let i,r=(e=null)=>({config:{activeRepo:null,port:3e3},problem:e});if("missing"===t.kind)return r();if("error"===t.kind)return r(`${e} couldn't be read (${h(t.error)})`);let s=function(e){if(255===e[0]&&254===e[1])return new TextDecoder("utf-16le").decode(e);if(254===e[0]&&255===e[1]){let t=Buffer.from(e.subarray(0,e.length-e.length%2)).swap16();return new TextDecoder("utf-16le").decode(t)}return new TextDecoder("utf-8").decode(e)}(t.bytes);if(""===s.trim())return r();try{i=JSON.parse(s)}catch(t){return r(`${e} isn't valid JSON (${h(t)})`)}if("object"!=typeof i||null===i||Array.isArray(i))return r(`${e} holds ${null===i?"null":Array.isArray(i)?"an array":`a ${typeof i}`}, not one JSON object of settings`);let n=i,a="number"==typeof n.port&&Number.isInteger(n.port)&&n.port>0&&n.port<65536?n.port:3e3;return{config:{...n,activeRepo:"string"==typeof n.activeRepo?n.activeRepo:null,port:a},problem:null}}class l extends Error{constructor(e,t){super(`${e} couldn't be read to change it (${h(t)}), so nothing was written; try again`,{cause:t}),this.name="ConfigUnreadableError"}}let u=new Set(["EBUSY","EPERM","EACCES","EAGAIN"]);function c(e,t){for(let r=1;;r++)try{return e()}catch(e){var i;if(r>=5||!u.has((i=e,i?.code??"")))return t(e);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,40)}}function h(e){return e instanceof Error?e.message:String(e)}e.s(["V",0,n,"s",0,function(){let e;return o(e=n(),a(e)).config},"t",0,function(e,s=e=>console.error(e)){let u=n();for(let n=1;;n++){let f=c(()=>{let e=a(u);if("error"===e.kind)throw e.error;return e},e=>{throw new l(u,e)}),{config:m,problem:p}=o(u,f),g=e(m);if(null===g)return null;i.default.mkdirSync(r.default.dirname(u),{recursive:!0});let y=null;if(null!==p){var h,d;h=u,y=`${h}.invalid-${new Date().toISOString().replace(/[:.]/g,"-")}-${process.pid}-${(0,t.randomBytes)(4).toString("hex")}`;try{i.default.renameSync(u,y)}catch(e){if("ENOENT"===(d=e,d?.code)&&n<3)continue;throw e}s(`[nebulosity] ${p}, so it was moved aside to ${y} before the settings were written again; copy what you need from it into ${u}, then delete it`)}return function(e,r){let s=`${e}.${process.pid}-${(0,t.randomBytes)(4).toString("hex")}.tmp`;i.default.writeFileSync(s,JSON.stringify(r,null,2)+"\n"),c(()=>i.default.renameSync(s,e),e=>{throw i.default.rmSync(s,{force:!0}),e})}(u,g),y}}])},90793,44398,e=>{var t=e.i(22734),i=e.i(14747),r=e.i(85148),s=e.i(20842),n=e.i(94176),a=e.i(26889),o=e.i(14674),l=e.i(52036);function u(e,t){return`nebulosity ${e} ${t} (in a checkout: npm run ${e} -- ${t})`}e.s(["A",0,u,"D",0,function(){return`set it in the environment, or put it in ${(0,l.Q)(".env.local")}`}],44398);class c extends Error{constructor(e){super(`No repository indexed yet: there's no index at ${e}. Run ${u("index","<path-to-repo>")}.`),this.name="DatabaseMissingError"}}class h extends Error{constructor(){super(`Nebulosity's index is older than this version of Nebulosity. Run ${u("index","<path-to-repo>")} once, or start the Map (nebulosity map; in a checkout, npm run dev), to update it, then try again.`),this.name="DatabaseOutdatedError"}}let d=()=>(0,l.L)("lib","db","migrations"),f=e=>(0,s.f)(e,{schema:o});function m(e,s="readwrite"){if("readonly"===s)return function(e){if(!t.default.existsSync(e))throw new c(e);let i=new r.default(e,{readonly:!0,fileMustExist:!0});try{var s=i;let e=Math.max(...(0,a.f)({migrationsFolder:d()}).map(e=>e.folderMillis)),t=null;try{let e=s.prepare("select max(created_at) as at from __drizzle_migrations").get();t=null===e.at?null:Number(e.at)}catch(e){if(!/no such table/.test(e instanceof Error?e.message:String(e)))throw e}if(null===t||t<e)throw new h}catch(e){throw i.close(),e}return f(i)}(e);":memory:"!==e&&t.default.mkdirSync(i.default.dirname(e),{recursive:!0});let o=new r.default(e);o.pragma("journal_mode = WAL"),o.pragma("synchronous = NORMAL"),o.pragma("foreign_keys = ON");let l=f(o);return(0,n.f)(l,{migrationsFolder:d()}),l}let p=globalThis;e.s(["e",0,c,"K",0,h,"$",0,function(){return p.db||(p.db=process.env.VITEST?m(":memory:"):m((0,l.Q)("nebulosity.db"),p.readOnly?"readonly":"readwrite")),p.db}],90793)},15342,e=>{e.i(46786),e.i(14674),e.s(["f",0,class extends Error{constructor(e,t="Indexing"){super(`${t} already in progress (started ${e}).`),this.name="IndexLockedError"}}])},86812,e=>{var t=e.i(75225),i=e.i(18899),r=e.i(14674);function s(e,t){return""===t?i.B`1 = 1`:i.B`${e} >= ${`${t}/`} and ${e} < ${`${t}0`}`}function n(e,t){let r=""===t?0:t.length+1;return i.B`${s(e,t)} and instr(substr(${e}, ${r+1}), '/') = 0`}let a={kind:r.summaries.targetKind,path:r.summaries.targetPath,tagline:r.summaries.tagline,summary:r.summaries.summary,model:r.summaries.model,promptVersion:r.summaries.promptVersion,status:r.summaries.status,error:r.summaries.error};e.s(["H",0,function(e,n,a,o){let l="file"===o?(0,t.u)(r.summaries.targetPath,a):s(r.summaries.targetPath,"repo"===o?"":a);return e.select({n:i.B`count(*)`}).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,n),(0,t.u)(r.summaries.targetKind,"file"),(0,t.u)(r.summaries.status,"stale"),l)).get()?.n??0},"G",0,function(e,s,a){return e.select({path:r.files.path,lineCount:r.files.lineCount,importedBy:i.B`count(${r.imports.id})`}).from(r.files).leftJoin(r.imports,(0,t.u)(r.imports.targetFileId,r.files.id)).where((0,t.b)((0,t.u)(r.files.repoId,s),n(r.files.path,a))).groupBy(r.files.id).orderBy(r.files.path).all()},"R",0,function(e,i,s){return e.select({path:r.folders.path,name:r.folders.name,fileCount:r.folders.fileCount}).from(r.folders).where((0,t.b)((0,t.u)(r.folders.repoId,i),(0,t.u)(r.folders.parentPath,s))).orderBy(r.folders.path).all()},"W",0,function(e,s,o){return e.select(a).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,s),i.B`${r.summaries.targetKind} in ('file', 'folder')`,n(r.summaries.targetPath,o))).all()},"k",0,function(e,i,s){return e.select({path:r.files.path,lineCount:r.files.lineCount,isTest:r.files.isTest,sizeBytes:r.files.sizeBytes}).from(r.files).where((0,t.b)((0,t.u)(r.files.repoId,i),(0,t.u)(r.files.path,s))).get()??null},"o",0,function(e,i,s){return e.select({name:r.symbols.qualifiedName,kind:r.symbols.kind,startLine:r.symbols.startLine,endLine:r.symbols.endLine,exported:r.symbols.exported}).from(r.symbols).innerJoin(r.files,(0,t.u)(r.files.id,r.symbols.fileId)).where((0,t.b)((0,t.u)(r.files.repoId,i),(0,t.u)(r.files.path,s))).orderBy(r.symbols.startLine,r.symbols.qualifiedName).all()},"O",0,function(e,i,s){return e.select({path:r.folders.path,name:r.folders.name,fileCount:r.folders.fileCount}).from(r.folders).where((0,t.b)((0,t.u)(r.folders.repoId,i),(0,t.u)(r.folders.path,s))).get()??null},"B",0,function(e,i){return e.select({source:r.imports.sourceFileId,target:r.imports.targetFileId}).from(r.imports).innerJoin(r.files,(0,t.u)(r.files.id,r.imports.sourceFileId)).where((0,t.u)(r.files.repoId,i)).all()},"d",0,function(e,i){return e.select({id:r.files.id,path:r.files.path}).from(r.files).where((0,t.u)(r.files.repoId,i)).all()},"_",0,function(e,i,s){return e.select({source:r.levelEdges.sourceNode,target:r.levelEdges.targetNode,count:r.levelEdges.count}).from(r.levelEdges).where((0,t.b)((0,t.u)(r.levelEdges.repoId,i),(0,t.u)(r.levelEdges.levelPath,s))).orderBy(r.levelEdges.sourceNode,r.levelEdges.targetNode).all()},"n",0,function(e,i,s,n){return e.select(a).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,i),(0,t.u)(r.summaries.targetKind,s),(0,t.u)(r.summaries.targetPath,n))).get()??null},"F",0,function(e,n,a){return e.select({lines:i.B`coalesce(sum(${r.files.lineCount}), 0)`}).from(r.files).where((0,t.b)((0,t.u)(r.files.repoId,n),s(r.files.path,a))).get()?.lines??0}])},86304,e=>{var t=e.i(75225),i=e.i(18899),r=e.i(14674);let s=["structure","summaries","embeddings"],n=(e,t)=>`stage:${e}:${t}`;e.s(["J",0,function(e){return e.select({rootPath:r.repositories.rootPath,lastIndexAt:r.repositories.lastIndexAt}).from(r.repositories).where(i.B`exists (select 1 from ${r.meta} where ${r.meta.key} = 'stage:' || ${r.repositories.id} || ':structure')`).orderBy(r.repositories.rootPath).all()},"z",0,function(e,i){let a={};for(let o of s){let s=e.select({value:r.meta.value,updatedAt:r.meta.updatedAt}).from(r.meta).where((0,t.u)(r.meta.key,n(i,o))).get();s&&(a[o]={...JSON.parse(s.value),updatedAt:s.updatedAt})}return a}])},37756,e=>{var t=e.i(75225),i=e.i(14674);i.files.path,i.files.isTest,i.typedCalls.line,i.typedCalls.member,i.typedCalls.receiver,i.typedCalls.ref,i.typedCalls.inClass,i.typedCalls.how;var r=e.i(44398);function s(e,r){return e.select({id:i.repositories.id}).from(i.repositories).where((0,t.u)(i.repositories.rootPath,r)).get()?.id??null}class n extends Error{constructor(e){super(`${e} isn't indexed yet. Run ${(0,r.A)("index",`"${e}"`)} first.`),this.name="RepoNotIndexedError"}}e.s(["V",0,n,"_",0,s,"I",0,function(e,t){let i=s(e,t);if(null===i)throw new n(t);return i}],37756)},85861,e=>{var t=e.i(75225),i=e.i(18899),r=e.i(14674);e.i(89963),e.s(["b",0,function(e,s){return e.select({n:i.B`count(*)`}).from(r.summaries).where((0,t.b)((0,t.u)(r.summaries.repoId,s),(0,t.E)(r.summaries.batchId))).get()?.n??0},"j",0,function(e,s){return e.select({path:r.files.path,contentHash:r.files.contentHash,lineCount:r.files.lineCount,isTest:r.files.isTest,importedBy:i.B`count(${r.imports.id})`,sizeBytes:r.files.sizeBytes}).from(r.files).leftJoin(r.imports,(0,t.u)(r.imports.targetFileId,r.files.id)).where((0,t.u)(r.files.repoId,s)).groupBy(r.files.id).orderBy(r.files.path).all()},"Q",0,function(e,i){return e.select({path:r.folders.path,parentPath:r.folders.parentPath,depth:r.folders.depth,name:r.folders.name,fileCount:r.folders.fileCount,directFileCount:r.folders.directFileCount}).from(r.folders).where((0,t.u)(r.folders.repoId,i)).orderBy(r.folders.path).all()},"q",0,(e,t)=>`${e}:${t}`])},89963,e=>{var t=e.i(75225),i=e.i(14674);e.s(["f",0,function(e,r){let s=e.select({value:i.meta.value}).from(i.meta).where((0,t.u)(i.meta.key,`indexVersion:${r}`)).get();return s?Number(s.value):0}])},38874,e=>{var t=e.i(90793),i=e.i(15342),r=e.i(37756),s=e.i(44398),n=e.i(69251),a=e.i(5947),o=e.i(45225),l=e.i(95179),u=e.i(15013);class c extends Error{constructor(){super(`Summaries are off: ANTHROPIC_API_KEY is not set (${(0,s.D)()}, then restart the Map).`),this.name="SummariesOffError"}}class h extends Error{constructor(e){super(`Summaries for ${e} haven't been confirmed, so nothing is sent from here: run ${(0,s.A)("summarize",`"${e}"`)}, which shows the estimate and asks first.`),this.name="SummariesNotConfirmedError"}}class d extends Error{constructor(){super(`No repository indexed yet. Run ${(0,s.A)("index","<path-to-repo>")}.`),this.name="NoActiveRepoError"}}class f extends Error{constructor(e,t){super(`The background worker is on ${t??"no repository"}, not ${e}; it's switching now, so try again in a moment.`),this.name="RepoSwitchingError"}}class m extends Error{constructor(e){super(e),this.name="BadInputError"}}let p={BAD_REQUEST:400,FORBIDDEN:403,NOT_FOUND:404,INDEX_EMPTY:404,INDEX_LOCKED:409,NOT_READY:409,SUMMARIES_OFF:409,BUDGET_EXCEEDED:429,UPSTREAM:502,INTERNAL:500};e.s(["E",0,m,"Z",0,d,"Q",0,p,"v",0,function(e){var s;let g=(s=e)instanceof r.V||s instanceof d||s instanceof t.e?"INDEX_EMPTY":s instanceof l.f||s instanceof a.H||s instanceof a.g||s instanceof u.d?"NOT_FOUND":s instanceof l.i||s instanceof m?"BAD_REQUEST":s instanceof i.f||s instanceof a.V||s instanceof f?"INDEX_LOCKED":s instanceof a.a||s instanceof t.K?"NOT_READY":s instanceof c||s instanceof h||s instanceof n.f?"SUMMARIES_OFF":s instanceof o.G||s instanceof o.j?"UPSTREAM":"INTERNAL",y=e instanceof Error?e.message:String(e);return{status:p[g],error:{code:g,message:"INTERNAL"===g?`Internal error: ${y}`:y}}}])},95179,e=>{var t=e.i(14747),i=e.i(90793),r=e.i(86812),s=e.i(37756),n=e.i(89963),a=e.i(30596);let o=(e,t)=>`${e}//page-${t+1}`,l=e=>`${e}//pages`,u=(e,t)=>e<t?-1:+(e>t);class c extends Error{constructor(e){super(`Nothing is indexed at "${e}".`),this.name="PathNotFoundError"}}class h extends Error{constructor(e){let t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"";super(`"${e}" is a file. Open its folder ("${t}") and select it there.`),this.name="NotAFolderError"}}function d(e,t){return e?.tagline?e.status:t?"off":e?.status??"pending"}function f(e,t,i,s){let n=new Map((0,r.W)(e,t,i).map(e=>[`${e.kind}:${e.path}`,e])),a=new Map,o=(e,t,i,r)=>{let a=n.get(`${e}:${t}`);return{path:t,name:i,kind:e,fileCount:r,...a?.tagline?{tagline:a.tagline}:{},summaryStatus:d(a,s)}};return[...(0,r.R)(e,t,i).map(e=>o("folder",e.path,e.name,e.fileCount)),...(0,r.G)(e,t,i).map(e=>(a.set(e.path,e.importedBy),o("file",e.path,e.path.slice(e.path.lastIndexOf("/")+1),1)))].sort((e,t)=>{let i,r;return t.fileCount-e.fileCount||(a.get(t.path)??0)-(a.get(e.path)??0)||((i=e.path)<(r=t.path)?-1:+(i>r))})}e.s(["i",0,h,"f",0,c,"x",0,function(e,d,m={}){let p=(0,i.$)(),g=(0,a._)(t.default.resolve(e)),y=(0,s.I)(p,g);return p.transaction(()=>{var e,t,i;let s,a;if(!(0,r.O)(p,y,d)){if((0,r.k)(p,y,d))throw new h(d);throw new c(d)}let{nodes:b,edges:w,hiddenCount:S,page:$,pageCount:v}=(e=f(p,y,d,m.summariesOff??!1),t=(0,r._)(p,y,d),i={page:m.page,focus:m.focus},s=e.length<=50?[e.map(e=>e.path)]:function(e,t,i=44){let r=new Map(e.map((e,t)=>[e.path,t])),s=e.map(()=>new Map);for(let e of t){let t=r.get(e.source),i=r.get(e.target);void 0!==t&&void 0!==i&&t!==i&&(s[t].set(i,(s[t].get(i)??0)+e.count),s[i].set(t,(s[i].get(t)??0)+e.count))}let n=Array(e.length).fill(!1),a=0,o=[];for(let t=e.length;t>0;){let e=[],r=new Map,l=i=>{for(let[a,o]of(n[i]=!0,r.delete(i),e.push(i),t--,s[i]))n[a]||r.set(a,(r.get(a)??0)+o)};for(;e.length<i&&t>0;){let e=-1,t=0;for(let[i,s]of r)(s>t||s===t&&i<e)&&(e=i,t=s);if(-1===e){for(;n[a];)a++;e=a}l(e)}o.push(e.sort((e,t)=>e-t))}return o.map(t=>t.map(t=>e[t].path))}(e,t),a=(void 0===i.focus?null:function(e,t){for(let i=0;i<e.length;i++)if(e[i].some(e=>t===e||t.startsWith(`${e}/`)))return i;return null}(s,i.focus))??Math.min(Math.max(0,Math.floor(i.page??0)),s.length-1),{...function(e,t,i,r,s,n=6){let a=new Map(t.map(e=>[e.path,e])),c=new Map;r.forEach((e,t)=>e.forEach(e=>c.set(e,t)));let h=new Map;for(let e of i){let t=c.get(e.source),i=c.get(e.target);if(void 0===t||void 0===i||t===s==(i===s))continue;let r=t===s?i:t;h.set(r,(h.get(r)??0)+e.count)}let d=[...h.entries()].sort(([e,t],[i,r])=>r-t||e-i).map(([e])=>e),f=d.length>n?n-1:d.length,m=d.slice(0,f).sort((e,t)=>e-t),p=d.slice(f).sort((e,t)=>e-t),g=new Map;m.forEach(t=>g.set(t,o(e,t))),p.forEach(t=>g.set(t,l(e)));let y=(e,t,i,s)=>{let n=i.flatMap(e=>r[e]);return{path:e,name:t,kind:"portal",...s,fileCount:n.reduce((e,t)=>e+(a.get(t)?.fileCount??0),0),hiddenCount:n.length,summaryStatus:"skipped",members:n}},b=[...r[s].flatMap(e=>a.get(e)??[]),...m.map(t=>y(o(e,t),`Page ${t+1}`,[t],{page:t})),...p.length>0?[y(l(e),`+${p.length} pages`,p,{pages:p})]:[]],w=new Map;for(let e of i){let t=c.get(e.source),i=c.get(e.target);if(void 0===t||void 0===i||t!==s&&i!==s)continue;let r=t===s?e.source:g.get(t),n=i===s?e.target:g.get(i),a=`${r}\0${n}`,o=w.get(a);o?o.count+=e.count:w.set(a,{source:r,target:n,count:e.count})}return{nodes:b,edges:[...w.values()].sort((e,t)=>u(e.source,t.source)||u(e.target,t.target))}}(d,e,t,s,a),hiddenCount:e.length-s[a].length,page:a,pageCount:s.length});return{repo:g,path:d,breadcrumb:function(e){if(""===e)return[""];let t=e.split("/");return["",...t.map((e,i)=>t.slice(0,i+1).join("/"))]}(d),nodes:b,edges:w,hiddenCount:S,page:$,pageCount:v,indexVersion:(0,n.f)(p,y)}})},"P",0,f,"D",0,d],95179)},15013,e=>{var t=e.i(14747),i=e.i(72507),r=e.i(90793),s=e.i(86304),n=e.i(44398),a=e.i(22734);let o=/^(?:[\w.-]+@)?([\w.-]+):(?!\/)(.+)$/,l=new Set(["ssh.dev.azure.com","vs-ssh.visualstudio.com"]);class u extends Error{constructor(e){super(`${e} isn't an indexed repository. Run ${(0,n.A)("index",`"${e}"`)} first.`),this.name="UnknownRepoError"}}function c(){let e=(0,s.J)((0,r.$)()).map(e=>{let i=function(e){try{let i=function(e){let i=t.default.join(e,".git");if(a.default.statSync(i).isDirectory())return t.default.join(i,"config");let r=/^gitdir:\s*(.+)$/m.exec(a.default.readFileSync(i,"utf8"));if(!r)return null;let s=t.default.resolve(e,r[1].trim()),n=t.default.join(s,"commondir"),o=a.default.existsSync(n)?t.default.resolve(s,a.default.readFileSync(n,"utf8").trim()):s;return t.default.join(o,"config")}(e);if(null===i)return null;let r=function(e){let t=!1;for(let i of e.split(/\r?\n/)){let e=i.trim();if(e.startsWith("[")){t=/^\[remote\s+"origin"\]$/i.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/i.exec(e);if(r)return r[1].trim().replace(/^"(.*)"$/,"$1")}return null}(a.default.readFileSync(i,"utf8"));return null===r?null:function(e){let t,i,r=o.exec(e);if(r)t=r[1],i=r[2];else try{let r=new URL(e);if(!r.host)return null;t=r.hostname,i=r.pathname}catch{return null}let s=i.replace(/\/+$/,"").replace(/\.git$/,"").split("/").filter(e=>""!==e&&"_git"!==e);return(l.has(t)&&"v3"===s[0]&&(s=s.slice(1)),s.length<2)?null:{owner:s.slice(0,-1).join("/"),name:s[s.length-1]}}(r)}catch{return null}}(e.rootPath);return{root:e.rootPath,name:t.default.basename(e.rootPath),indexedAt:e.lastIndexAt?.toISOString()??null,...i?{remote:i}:{}}});return{active:(0,i.s)().activeRepo,repos:e}}e.s(["d",0,u,"o",0,c,"L",0,function(e){if(!c().repos.some(t=>t.root===e))throw new u(e);return(0,i.t)(t=>({...t,activeRepo:e})),c()}],15013)},52036,e=>{e.i(46786);var t=e.i(14747);function i(){return t.default.resolve(process.env.NEBULOSITY_HOME??process.cwd())}function r(...e){return t.default.join(i(),...e)}e.s(["Q",0,function(...e){return t.default.join(t.default.resolve(process.env.NEBULOSITY_DATA??r(".nebulosity")),...e)},"W",0,i,"L",0,r])},27074,e=>{e.i(33405),e.i(22734),e.i(14747),e.i(66870),e.i(40909),e.i(30596),e.s(["f",0,1e6])},66870,40909,e=>{var t=e.i(30596);let i=/`\d+/g,r=/\.(Tests?|UnitTests|IntegrationTests|FunctionalTests)$/,s=/Tests?\.cs$/;function n(e,t){let i=t.indexOf("=");return -1===i?null:`${e} ${t.slice(0,i)} = ${t.slice(i+1)}`}let a=new Map([["using",e=>`using ${e}`],["global",e=>`global using ${e}`],["static",e=>`using static ${e}`],["gstatic",e=>`global using static ${e}`],["alias",e=>n("using",e)],["galias",e=>n("global using",e)],["ns",e=>`namespace ${e}`],["type",e=>e],["qtype",e=>e]]),o=/(^|\/)go\.mod$/,l=/(Test|Tests|IT|TestCase)\.java$/,u=/(^|\/)pom\.xml$/,c=/(^|\/)build\.gradle(\.kts)?$/,h=/(^|\/)settings\.gradle(\.kts)?$/,d=/^(test_.*\.pyi?|.*_test\.pyi?|tests\.py|conftest\.py)$/,f=/(^|\/)Cargo\.toml$/,m=/(^|\/)(package\.json|tsconfig[^/]*\.json)$/,p={id:"typescript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],languageOf:function(e){return/\.(js|jsx|mjs|cjs)$/.test(e)?"javascript":"typescript"},isTest:e=>/\.(test|spec)\.[cm]?[jt]sx?$/.test(e),manifest:m,excluded:()=>()=>!1};e.s(["e",0,m,"a",0,p],40909);let g=[p,{id:"python",extensions:[".py",".pyi"],languageOf:()=>"python",isTest:e=>d.test(e.slice(e.lastIndexOf("/")+1)),manifest:/(^|\/)(pyproject\.toml|setup\.cfg|setup\.py|pyvenv\.cfg)$/,excluded(e){let i=e.filter(e=>/(^|\/)pyvenv\.cfg$/.test(e)).map(e=>""===(0,t.a)(e)?"":`${(0,t.a)(e)}/`);return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){if(""===e)return e;let t=e.indexOf(":");return -1===t?`import ${e}`:`from ${e.slice(0,t)} import ${e.slice(t+1)}`}},{id:"go",extensions:[".go"],languageOf:()=>"go",isTest:e=>e.endsWith("_test.go"),manifest:/(^|\/)go\.(mod|work)$/,excluded(e){let i=e.filter(e=>o.test(e)).map(e=>""===(0,t.a)(e)?"vendor/":`${(0,t.a)(e)}/vendor/`);return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){if(e.startsWith("import:")){let t=e.slice(7),i=t.lastIndexOf(" as ");return -1===i?`import "${t}"`:`import ${t.slice(i+4)} "${t.slice(0,i)}"`}return e.startsWith("use:")?e.slice(4):e.startsWith("name:")?e.slice(5):e}},{id:"java",extensions:[".java"],languageOf:()=>"java",isTest:e=>l.test(e.slice(e.lastIndexOf("/")+1)),manifest:/(^|\/)(pom\.xml|build\.gradle(\.kts)?|settings\.gradle(\.kts)?)$/,excluded(e){let i=[];for(let r of e){let e=function(e){let i=(0,t.a)(e);return""===i?"":`${i}/`}(r);u.test(r)&&i.push(`${e}target/`),c.test(r)&&i.push(`${e}build/`,`${e}.gradle/`),h.test(r)&&i.push(`${e}.gradle/`)}let r=[...new Set(i)];return e=>r.some(t=>e.startsWith(t))},displaySpecifier:function(e){return e.startsWith("import:")?`import ${e.slice(7)}`:e.startsWith("static:")?`import static ${e.slice(7)}`:e.startsWith("type:")?e.slice(5):e.startsWith("qualified:")?e.slice(10):e}},{id:"csharp",extensions:[".cs"],languageOf:()=>"csharp",isTest(e){let t=e.split("/"),i=t.pop()??"";return t.some(e=>r.test(e))||s.test(i)},manifest:/(\.csproj|(^|\/)Directory\.Build\.props)$/,excluded(e){let i=e.filter(e=>e.endsWith(".csproj")).flatMap(e=>{let i=(0,t.a)(e);return""===i?["bin/","obj/"]:[`${i}/bin/`,`${i}/obj/`]});return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){var t;let r=e.indexOf(":"),s=-1===r?void 0:a.get(e.slice(0,r));return s?.((t=e.slice(r+1)).includes("`")?t.replace(i,""):t)??e}},{id:"rust",extensions:[".rs"],languageOf:()=>"rust",isTest:e=>/(^|\/)(tests|[^/]*_tests?)\.rs$/.test(e),manifest:f,excluded(e){let i=e.filter(e=>f.test(e)).map(e=>""===(0,t.a)(e)?"target/":`${(0,t.a)(e)}/target/`);return e=>i.some(t=>e.startsWith(t))},displaySpecifier:function(e){let t=function(e){if(e.startsWith("extern:"))return{form:"extern",name:e.slice(7)};let t=e.indexOf(":"),i=e.indexOf("|");if(-1===t||i<t)return null;let r=e.slice(0,t),s=e.slice(t+1,i),n=""===s?[]:s.split("::"),a=e.slice(i+1);if("mod"===r){let e=a.indexOf("@");return -1===e?{form:r,inline:n,name:a,path:null}:{form:r,inline:n,name:a.slice(0,e),path:a.slice(e+1)}}if("use"===r||"path"===r){let e=a.lastIndexOf(" as ");return -1===e?{form:r,inline:n,path:a,alias:null}:{form:r,inline:n,path:a.slice(0,e),alias:a.slice(e+4)}}return null}(e);if(null===t)return e;switch(t.form){case"extern":return`extern crate ${t.name}`;case"mod":return null===t.path?`mod ${t.name}`:`#[path = "${t.path}"] mod ${t.name}`;case"use":return`use ${t.path}${null===t.alias?"":` as ${t.alias}`}`;case"path":return t.path}}}];e.s(["f",0,function(e,t=g){let i=null,r=0;for(let s of t)for(let t of s.extensions)t.length>r&&e.endsWith(t)&&(i=s,r=t.length);return i}],66870)},30596,e=>{var t=e.i(14747);function i(e){return e.replace(/\\/g,"/")}e.s(["a",0,function(e){let t=e.lastIndexOf("/");return -1===t?"":e.slice(0,t)},"L",0,function(e){if(null==e)return null;let t=i(e.trim());if(t.includes("\0")||t.startsWith("/")||/^[a-zA-Z]:/.test(t))return null;let r=t.split("/").filter(e=>""!==e&&"."!==e);return r.includes("..")?null:r.join("/")},"_",0,function(e){return i(t.default.resolve(e))}])},69251,e=>{e.i(72507);var t=e.i(96023),i=e.i(98815);i.V,function(e,i){let r={};for(let s of new Set(Object.values(e))){let e=(0,t.f)(s),n=i.get(s)?.input?.usd??e?.input,a=i.get(s)?.output?.usd??e?.output;void 0!==n&&void 0!==a&&(r[s]={input:n,output:a})}}(i.V,new Map),e.s(["f",0,class extends Error{constructor(e){super(e),this.name="SummaryModelsError"}}])},96023,e=>{let t={"claude-haiku-5-5":{input:.1,output:.5},"claude-sonnet-5-5":{input:2,output:10}};e.s(["f",0,function(e,i={}){let r=e=>Object.hasOwn(i,e)?i[e]:Object.hasOwn(t,e)?t[e]:null,s=/-\d{8}$/.test(e)?e.slice(0,-9):null;return r(e)??(null===s?null:r(s))}])},98815,25328,e=>{var t=e.i(30596);e.s(["c",0,function(e,i){let r=(0,t.a)(i);return r===e?i:r.split("/").slice(0,(""===e?0:e.split("/").length)+1).join("/")},"T",0,function(e,t){if(""===e||""===t)return"";let i=e.split("/"),r=t.split("/"),s=0;for(;s<i.length&&s<r.length&&i[s]===r[s];)s++;return i.slice(0,s).join("/")}],25328),e.i(8314),e.i(54799),new WeakMap,new WeakMap;let i="Use short sentences, with no semicolons, colons or dashes. When you need a technical term, say what it means the first time, or use a plainer word.",r=['You write the summary people see for one source file while they find their way around a codebase that\'s new to them. Write for a smart reader who doesn\'t know this project\'s vocabulary.\nGive a tagline and a summary. The tagline is a noun phrase of 3 to 6 plain words that says what the file is for, like "Automatic retry for failed requests". It doesn\'t count toward the summary\'s length.\nThe summary is short paragraphs with a blank line between them. The last line of the request says about how many words, paragraphs and code names to use. Stay close to it, and use fewer when the file is simple.\nThe first paragraph is 1 or 2 sentences on what the file is for and why the project needs it, in everyday words, with no code names.\nThen say what\'s inside. Name only the most important exports, in backticks like `parseConfig`, and say in plain words what each one does.\nEnd with one sentence on how widely the file is used and where, from the "Imported by" line, which comes from the repository\'s import graph. Say it in words that match how widely it really is used, like "Almost every part of the app relies on it." or "The settings screen uses it, and little else does." Name the parts that use it, never a number of files.',i,"Don't narrate the code line by line, don't guess beyond what you're shown, and don't mention truncation or code you weren't shown."].join("\n"),s=["You write the summary people see for one folder while they find their way around a codebase that's new to them. You're given the summaries of the files and subfolders inside it. Write for a smart reader who doesn't know this project's vocabulary.\nGive a tagline and a summary. The tagline is a noun phrase of 3 to 6 plain words that says what the folder is for, like \"Online payment handling\". It doesn't count toward the summary's length.\nThe summary is short paragraphs with a blank line between them. The last line of the request says about how many words, paragraphs and code names to use. Stay close to it, and use fewer when the folder is simple.\nThe first paragraph is 1 or 2 sentences on what this part of the project does, in everyday words, with no code names.\nThen say which parts matter most and how they fit together. Name only the most important files or subfolders, in backticks like `checkout/`, and say in plain words what each one does.",i,"Don't list every item, don't give numbers of files, and don't guess beyond the summaries you're given."].join("\n"),n=["You write the overview people see first when they open a repository that's new to them. You're given the summaries of its top-level folders and files. Write for a smart reader who doesn't know this project's vocabulary.\nGive a tagline and a summary. The tagline is a noun phrase of 3 to 6 plain words that says what the project is, like \"Online store server\". It doesn't count toward the summary's length.\nThe summary is short paragraphs with a blank line between them. The last line of the request says about how many words, paragraphs and code names to use. Stay close to it.\nThe first paragraph is 1 or 2 sentences on what the project is and who it's for, in everyday words, with no code names.\nThen name its main areas, in backticks like `src/server`, each with a few plain words on what it holds, and end by saying where a newcomer should start reading.",i,"Don't give numbers of files, and don't guess beyond the summaries you're given."].join("\n");e.s(["c",0,r,"X",0,s,"_",0,n,"V",0,{file:"claude-haiku-5-5",folder:"claude-sonnet-5-5",repo:"claude-sonnet-5-5"},"G",0,function(e,t,i=`${t}s`){return`${e.toLocaleString("en-US")} ${1===e?t:i}`},"C",0,function(e){return!!e.model&&"template"!==e.model&&(e.promptVersion??2)<3}],98815)},5947,45225,e=>{e.i(54799),e.i(22734),e.i(14747),e.i(90793),e.i(15342),e.i(86304),e.i(37756),e.i(85861);var t=e.i(44398);e.i(30596),e.i(69251),e.i(27074);var i=e.i(98815),r=e.i(72507);e.s(["j",0,class extends Error{model;reason;constructor(e,t,i=(0,r.V)()){super(`${e} isn't available: it was retired, or isn't open to this API key (the API said: ${t}). Choose another model under "summaryModels" in ${i}; see the README's "Summary models".`),this.model=e,this.reason=t,this.name="ModelUnavailableError"}},"G",0,class extends Error{reason;constructor(e){super(`Anthropic rejected the API key: ${e}`),this.reason=e,this.name="SummarizerAuthError"}}],45225),i.c,i.X,i._,e.s(["V",0,class extends Error{state;constructor(e){super(`the structure stage is ${e}; wait for the index run to finish, or run ${(0,t.A)("index","<path-to-repo>")} again, before summarizing`),this.state=e,this.name="StructureNotReadyError"}},"H",0,class extends Error{constructor(e){super(`Nothing indexed at "${e}". Pass a repo-relative file or folder path ("" for the repo itself).`),this.name="TargetNotFoundError"}},"a",0,class extends Error{constructor(e){super(`"${e}" can't be summarized yet: some of its files or subfolders have no summary, and a folder's summary is written from theirs. Run ${(0,t.A)("summarize","<path-to-repo>")}, or open them first.`),this.name="TargetNotReadyError"}},"g",0,class extends Error{batchId;constructor(e){super(`No request of this repo is waiting in batch ${e}. Copy the id from the summaries stage's note.`),this.batchId=e,this.name="UnknownBatchError"}}],5947)},20842,18899,75225,49129,26889,94176,14674,e=>{let t,i;var r,s=e.i(85148);let n=Symbol.for("drizzle:entityKind");function a(e,t){if(!e||"object"!=typeof e)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`Class "${t.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 i=Object.getPrototypeOf(e).constructor;if(i)for(;i;){if(n in i&&i[n]===t[n])return!0;i=Object.getPrototypeOf(i)}return!1}Symbol.for("drizzle:hasOwnEntityKind");class o{static [n]="ConsoleLogWriter";write(e){console.log(e)}}class l{static [n]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new o}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 u{static [n]="NoopLogger";logQuery(){}}let c=Symbol.for("drizzle:Name"),h=Symbol.for("drizzle:Schema"),d=Symbol.for("drizzle:Columns"),f=Symbol.for("drizzle:ExtraConfigColumns"),m=Symbol.for("drizzle:OriginalName"),p=Symbol.for("drizzle:BaseName"),g=Symbol.for("drizzle:IsAlias"),y=Symbol.for("drizzle:ExtraConfigBuilder"),b=Symbol.for("drizzle:IsDrizzleTable");class w{static [n]="Table";static Symbol={Name:c,Schema:h,OriginalName:m,Columns:d,ExtraConfigColumns:f,BaseName:p,IsAlias:g,ExtraConfigBuilder:y};[c];[m];[h];[d];[f];[p];[g]=!1;[b]=!0;[y]=void 0;constructor(e,t,i){this[c]=this[m]=e,this[h]=t,this[p]=i}}function S(e){return`${e[h]??"public"}.${e[c]}`}class ${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 [n]="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}}class v{static [n]="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)}}class N{static [n]="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 x(e,this)}}class x{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),r=t.map(e=>e.name),s=i.map(e=>e.name),n=[this.table[c],...r,i[0].table[c],...s];return e??`${n.join("_")}_fk`}}function _(e,...t){return e(...t)}function T(e,t){return`${e[c]}_${t.join("_")}_unique`}class C{constructor(e,t,i,r){this.table=e,this.columns=t,this.name=r??T(this.table,this.columns.map(e=>e.name)),this.nullsNotDistinct=i}static [n]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function Q(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]}class q extends v{foreignKeyConfigs=[];static [n]="PgColumnBuilder";array(e){return new B(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})=>_((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 I(e,this.config)}}class L extends ${constructor(e,t){t.uniqueName||(t.uniqueName=T(e,[t.name])),super(e,t),this.table=e}static [n]="PgColumn"}class I extends L{static [n]="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 B extends q{static [n]="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 O(e,this.config,t)}}class O extends L{constructor(e,t,i,r){super(e,t),this.baseColumn=i,this.range=r,this.size=t.size}size;static [n]="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]=Q(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]=Q(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,t=!1){let i=e.map(e=>null===e?null:a(this.baseColumn,O)?this.baseColumn.mapToDriverValue(e,!0):this.baseColumn.mapToDriverValue(e));return t?i:function e(t){return`{${t.map(t=>Array.isArray(t)?e(t):"string"==typeof t?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}(i)}}let E=Symbol.for("drizzle:isPgEnum");class j{static [n]="Subquery";constructor(e,t,i,r=!1,s=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:i,isWith:r,usedTables:s}}}class A extends j{static [n]="WithSubquery"}let D=(e,r)=>t?(i||(i=t.trace.getTracer("drizzle-orm","0.45.2")),_((t,i)=>i.startActiveSpan(e,e=>{try{return r(e)}catch(i){throw e.setStatus({code:t.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{e.end()}}),t,i)):r(),F=Symbol.for("drizzle:ViewBaseConfig");function k(e){return null!=e&&"function"==typeof e.getSQL}class P{static [n]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new M([this])}}class M{constructor(e){for(let t of(this.queryChunks=e,e))if(a(t,w)){let e=t[w.Symbol.Schema];this.usedTables.push(void 0===e?t[w.Symbol.Name]:e+"."+t[w.Symbol.Name])}}static [n]="SQL";decoder=z;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return D("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 i=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:r,escapeName:s,escapeParam:n,prepareTyping:o,inlineParams:l,paramStartIndex:u}=i;var c=e.map(e=>{if(a(e,P))return{sql:e.value.join(""),params:[]};if(a(e,R))return{sql:s(e.value),params:[]};if(void 0===e)return{sql:"",params:[]};if(Array.isArray(e)){let t=[new P("(")];for(let[i,r]of e.entries())t.push(r),i<e.length-1&&t.push(new P(", "));return t.push(new P(")")),this.buildQueryFromSourceParams(t,i)}if(a(e,M))return this.buildQueryFromSourceParams(e.queryChunks,{...i,inlineParams:l||e.shouldInlineParams});if(a(e,w)){let t=e[w.Symbol.Schema],i=e[w.Symbol.Name];return{sql:void 0===t||e[g]?s(i):s(t)+"."+s(i),params:[]}}if(a(e,$)){let i=r.getColumnCasing(e);if("indexes"===t.invokeSource)return{sql:s(i),params:[]};let n=e.table[w.Symbol.Schema];return{sql:e.table[g]||void 0===n?s(e.table[w.Symbol.Name])+"."+s(i):s(n)+"."+s(e.table[w.Symbol.Name])+"."+s(i),params:[]}}if(a(e,H)){let t=e[F].schema,i=e[F].name;return{sql:void 0===t||e[F].isAlias?s(i):s(t)+"."+s(i),params:[]}}if(a(e,V)){if(a(e.value,W))return{sql:n(u.value++,e),params:[e],typings:["none"]};let t=null===e.value?null:e.encoder.mapToDriverValue(e.value);if(a(t,M))return this.buildQueryFromSourceParams([t],i);if(l)return{sql:this.mapInlineParam(t,i),params:[]};let r=["none"];return o&&(r=[o(e.encoder)]),{sql:n(u.value++,t),params:[t],typings:r}}return a(e,W)?{sql:n(u.value++,e),params:[e],typings:["none"]}:a(e,M.Aliased)&&void 0!==e.fieldAlias?{sql:s(e.fieldAlias),params:[]}:a(e,j)?e._.isWith?{sql:s(e._.alias),params:[]}:this.buildQueryFromSourceParams([new P("("),e._.sql,new P(") "),new R(e._.alias)],i):e&&"function"==typeof e&&E in e&&!0===e[E]?e.schema?{sql:s(e.schema)+"."+s(e.enumName),params:[]}:{sql:s(e.enumName),params:[]}:k(e)?e.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([e.getSQL()],i):this.buildQueryFromSourceParams([new P("("),e.getSQL(),new P(")")],i):l?{sql:this.mapInlineParam(e,i),params:[]}:{sql:n(u.value++,e),params:[e],typings:["none"]}});let h={sql:"",params:[]};for(let e of c)h.sql+=e.sql,h.params.push(...e.params),e.typings?.length&&(h.typings||(h.typings=[]),h.typings.push(...e.typings));return h}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 M.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 R{constructor(e){this.value=e}static [n]="Name";brand;getSQL(){return new M([this])}}function K(e){return"object"==typeof e&&null!==e&&"mapToDriverValue"in e&&"function"==typeof e.mapToDriverValue}let z={mapFromDriverValue:e=>e},U={mapToDriverValue:e=>e};({...z,...U});class V{constructor(e,t=U){this.value=e,this.encoder=t}static [n]="Param";brand;getSQL(){return new M([this])}}function J(e,...t){let i=[];for(let[r,s]of((t.length>0||e.length>0&&""!==e[0])&&i.push(new P(e[0])),t.entries()))i.push(s,new P(e[r+1]));return new M(i)}(r=J||(J={})).empty=function(){return new M([])},r.fromList=function(e){return new M(e)},r.raw=function(e){return new M([new P(e)])},r.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 M(i)},r.identifier=function(e){return new R(e)},r.placeholder=function(e){return new W(e)},r.param=function(e,t){return new V(e,t)},(M||(M={})).Aliased=class e{constructor(e,t){this.sql=e,this.fieldAlias=t}static [n]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}};class W{constructor(e){this.name=e}static [n]="Placeholder";getSQL(){return new M([this])}}function Y(e,t){return e.map(e=>{if(a(e,W)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(a(e,V)&&a(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})}let G=Symbol.for("drizzle:IsDrizzleView");class H{static [n]="View";[F];[G]=!0;constructor({name:e,schema:t,selectedFields:i,query:r}){this[F]={name:e,originalName:e,schema:t,selectedFields:i,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new M([this])}}function X(e,t,i){let r={},s=e.reduce((e,{path:s,field:n},o)=>{let l;l=a(n,$)?n:a(n,M)?n.decoder:a(n,j)?n._.sql.decoder:n.sql.decoder;let u=e;for(let[e,h]of s.entries())if(e<s.length-1)h in u||(u[h]={}),u=u[h];else{let e=t[o],d=u[h]=null===e?null:l.mapFromDriverValue(e);if(i&&a(n,$)&&2===s.length){let e=s[0];e in r?"string"==typeof r[e]&&r[e]!==n.table[c]&&(r[e]=!1):r[e]=null===d&&n.table[c]}}return e},{});if(i&&Object.keys(r).length>0)for(let[e,t]of Object.entries(r))"string"!=typeof t||i[t]||(s[e]=null);return s}function Z(e,t){return Object.entries(e).reduce((e,[i,r])=>{if("string"!=typeof i)return e;let s=t?[...t,i]:[i];return a(r,$)||a(r,M)||a(r,M.Aliased)||a(r,j)?e.push({path:s,field:r}):a(r,w)?e.push(...Z(r[w.Symbol.Columns],s)):e.push(...Z(r,s)),e},[])}function ee(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}function et(e,t){let i=Object.entries(t).filter(([,e])=>void 0!==e).map(([t,i])=>a(i,M)||a(i,$)?[t,i]:[t,new V(i,e[w.Symbol.Columns][t])]);if(0===i.length)throw Error("No values to set");return Object.fromEntries(i)}function ei(e){return a(e,j)?e._.alias:a(e,H)?e[F].name:a(e,M)?void 0:e[w.Symbol.IsAlias]?e[w.Symbol.Name]:e[w.Symbol.BaseName]}function er(e,t){return{name:"string"==typeof e&&e.length>0?e:"",config:"object"==typeof e?e:t}}$.prototype.getSQL=function(){return new M([this])},w.prototype.getSQL=function(){return new M([this])},j.prototype.getSQL=function(){return new M([this])},e.s(["r",0,V,"W",0,W,"o",0,M,"c",0,P,"_",0,H,"X",0,Y,"N",0,K,"f",0,k,"B",0,J],18899);let es="u"<typeof TextDecoder?null:new TextDecoder,en=Symbol.for("drizzle:PgInlineForeignKeys"),ea=Symbol.for("drizzle:EnableRLS");class eo extends w{static [n]="PgTable";static Symbol=Object.assign({},w.Symbol,{InlineForeignKeys:en,EnableRLS:ea});[en]=[];[ea]=!1;[w.Symbol.ExtraConfigBuilder]=void 0;[w.Symbol.ExtraConfigColumns]={}}class el{static [n]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new eu(e,this.columns,this.name)}}class eu{constructor(e,t,i){this.table=e,this.columns=t,this.name=i}static [n]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[eo.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}function ec(e,t){return!K(t)||k(e)||a(e,V)||a(e,W)||a(e,$)||a(e,w)||a(e,H)?e:new V(e,t)}let eh=(e,t)=>J`${e} = ${ec(t,e)}`,ed=(e,t)=>J`${e} <> ${ec(t,e)}`;function ef(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new M(1===t.length?t:[new P("("),J.join(t,new P(" and ")),new P(")")])}function em(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new M(1===t.length?t:[new P("("),J.join(t,new P(" or ")),new P(")")])}function ep(e){return J`not ${e}`}let eg=(e,t)=>J`${e} > ${ec(t,e)}`,ey=(e,t)=>J`${e} >= ${ec(t,e)}`,eb=(e,t)=>J`${e} < ${ec(t,e)}`,ew=(e,t)=>J`${e} <= ${ec(t,e)}`;function eS(e,t){return Array.isArray(t)?0===t.length?J`false`:J`${e} in ${t.map(t=>ec(t,e))}`:J`${e} in ${ec(t,e)}`}function e$(e,t){return Array.isArray(t)?0===t.length?J`true`:J`${e} not in ${t.map(t=>ec(t,e))}`:J`${e} not in ${ec(t,e)}`}function ev(e){return J`${e} is null`}function eN(e){return J`${e} is not null`}function ex(e){return J`exists ${e}`}function e_(e){return J`not exists ${e}`}function eT(e,t,i){return J`${e} between ${ec(t,e)} and ${ec(i,e)}`}function eC(e,t,i){return J`${e} not between ${ec(t,e)} and ${ec(i,e)}`}function eQ(e,t){return J`${e} like ${t}`}function eq(e,t){return J`${e} not like ${t}`}function eL(e,t){return J`${e} ilike ${t}`}function eI(e,t){return J`${e} not ilike ${t}`}function eB(e){return J`${e} asc`}function eO(e){return J`${e} desc`}e.s(["b",0,ef,"C",0,eT,"u",0,eh,"v",0,ex,"H",0,eg,"B",0,ey,"O",0,eL,"y",0,eS,"E",0,eN,"M",0,ev,"D",0,eQ,"S",0,eb,"n",0,ew,"c",0,ed,"R",0,ep,"e",0,eC,"k",0,e_,"t",0,eI,"$",0,e$,"s",0,eq,"F",0,em],75225),e.s(["M",0,eB,"A",0,eO],49129);class eE{constructor(e,t,i){this.sourceTable=e,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[w.Symbol.Name]}static [n]="Relation";referencedTableName;fieldName}class ej{constructor(e,t){this.table=e,this.config=t}static [n]="Relations"}class eA extends eE{constructor(e,t,i,r){super(e,t,i?.relationName),this.config=i,this.isNullable=r}static [n]="One";withFieldName(e){let t=new eA(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class eD extends eE{constructor(e,t,i){super(e,t,i?.relationName),this.config=i}static [n]="Many";withFieldName(e){let t=new eD(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function eF(e){return{one:function(t,i){return new eA(e,t,i,i?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)},many:function(t,i){return new eD(e,t,i)}}}class ek{constructor(e){this.table=e}static [n]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class eP{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [n]="TableAliasProxyHandler";get(e,t){if(t===w.Symbol.IsAlias)return!0;if(t===w.Symbol.Name||this.replaceOriginalName&&t===w.Symbol.OriginalName)return this.alias;if(t===F)return{...e[F],name:this.alias,isAlias:!0};if(t===w.Symbol.Columns){let t=e[w.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(r=>{i[r]=new Proxy(t[r],new ek(new Proxy(e,this)))}),i}let i=e[t];return a(i,$)?new Proxy(i,new ek(new Proxy(e,this))):i}}function eM(e,t){return new Proxy(e,new eP(t,!1))}function eR(e,t){return new Proxy(e,new ek(new Proxy(e.table,new eP(t,!1))))}function eK(e,t){return new M.Aliased(ez(e.sql,t),e.fieldAlias)}function ez(e,t){return J.join(e.queryChunks.map(e=>a(e,$)?eR(e,t):a(e,M)?ez(e,t):a(e,M.Aliased)?eK(e,t):e))}class eU{static [n]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===F)return{...e[F],selectedFields:new Proxy(e[F].selectedFields,this)};if("symbol"==typeof t)return e[t];let i=(a(e,j)?e._.selectedFields:a(e,H)?e[F].selectedFields:e)[t];if(a(i,M.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(a(i,M)){if("sql"===this.config.sqlBehavior)return i;throw Error(`You tried to reference "${t}" 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 a(i,$)?this.config.alias?new Proxy(i,new ek(new Proxy(i.table,new eP(this.config.alias,this.config.replaceOriginalName??!1)))):i:"object"!=typeof i||null===i?i:new Proxy(i,new eU(this.config))}}function eV(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function eJ(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 eW(e){return e}class eY{static [n]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?eV:"camelCase"===e?eJ:eW}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[w.Symbol.Schema]??"public",i=e.table[w.Symbol.OriginalName],r=`${t}.${i}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[w.Symbol.Schema]??"public",i=e[w.Symbol.OriginalName],r=`${t}.${i}`;if(!this.cachedTables[r]){for(let t of Object.values(e[w.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class eG extends Error{static [n]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class eH extends Error{constructor(e,t,i){super(`Failed query: ${e}
|
|
2
|
+
params: ${t}`),this.query=e,this.params=t,this.cause=i,Error.captureStackTrace(this,eH),i&&(this.cause=i)}}class eX extends eG{static [n]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class eZ{static [n]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;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=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new e0(e,this)}}class e0{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),r=t.map(e=>e.name),s=i.map(e=>e.name),n=[this.table[c],...r,i[0].table[c],...s];return e??`${n.join("_")}_fk`}}function e1(e,t){return`${e[c]}_${t.join("_")}_unique`}class e4{constructor(e,t,i){this.table=e,this.columns=t,this.name=i??e1(this.table,this.columns.map(e=>e.name))}static [n]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}class e5 extends v{static [n]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:r})=>{let s;return s=new eZ(()=>({columns:[e],foreignColumns:[i()]})),r.onUpdate&&s.onUpdate(r.onUpdate),r.onDelete&&s.onDelete(r.onDelete),s.build(t)})}}class e2 extends ${constructor(e,t){t.uniqueName||(t.uniqueName=e1(e,[t.name])),super(e,t),this.table=e}static [n]="SQLiteColumn"}class e7 extends e5{static [n]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new e9(e,this.config)}}class e9 extends e2{static [n]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){return"u">typeof Buffer&&Buffer.from?BigInt((Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e)).toString("utf8")):BigInt(es.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}}class e8 extends e5{static [n]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new e6(e,this.config)}}class e6 extends e2{static [n]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){return"u">typeof Buffer&&Buffer.from?JSON.parse((Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e)).toString("utf8")):JSON.parse(es.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}}class e3 extends e5{static [n]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new te(e,this.config)}}class te extends e2{static [n]="SQLiteBlobBuffer";mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return"blob"}}function tt(e,t){let{name:i,config:r}=er(e,t);return r?.mode==="json"?new e8(i):r?.mode==="bigint"?new e7(i):new e3(i)}class ti extends e5{static [n]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new tr(e,this.config)}}class tr extends e2{static [n]="SQLiteCustomColumn";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 ts(e){return(t,i)=>{let{name:r,config:s}=er(t,i);return new ti(r,s,e)}}class tn extends e5{static [n]="SQLiteBaseIntegerBuilder";constructor(e,t,i){super(e,t,i),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}}class ta extends e2{static [n]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class to extends tn{static [n]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new tl(e,this.config)}}class tl extends ta{static [n]="SQLiteInteger"}class tu extends tn{static [n]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t}defaultNow(){return this.default(J`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new tc(e,this.config)}}class tc extends ta{static [n]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return new Date("timestamp"===this.config.mode?1e3*e:e)}mapToDriverValue(e){let t=e.getTime();return"timestamp"===this.config.mode?Math.floor(t/1e3):t}}class th extends tn{static [n]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t}build(e){return new td(e,this.config)}}class td extends ta{static [n]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return 1===Number(e)}mapToDriverValue(e){return+!!e}}function tf(e,t){let{name:i,config:r}=er(e,t);return r?.mode==="timestamp"||r?.mode==="timestamp_ms"?new tu(i,r.mode):r?.mode==="boolean"?new th(i,r.mode):new to(i)}class tm extends e5{static [n]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new tp(e,this.config)}}class tp extends e2{static [n]="SQLiteNumeric";mapFromDriverValue(e){return"string"==typeof e?e:String(e)}getSQLType(){return"numeric"}}class tg extends e5{static [n]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new ty(e,this.config)}}class ty extends e2{static [n]="SQLiteNumericNumber";mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}}class tb extends e5{static [n]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new tw(e,this.config)}}class tw extends e2{static [n]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function tS(e,t){let{name:i,config:r}=er(e,t),s=r?.mode;return"number"===s?new tg(i):"bigint"===s?new tb(i):new tm(i)}class t$ extends e5{static [n]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new tv(e,this.config)}}class tv extends e2{static [n]="SQLiteReal";getSQLType(){return"real"}}function tN(e){return new t$(e??"")}class tx extends e5{static [n]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new t_(e,this.config)}}class t_ extends e2{static [n]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class tT extends e5{static [n]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new tC(e,this.config)}}class tC extends e2{static [n]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}function tQ(e,t={}){let{name:i,config:r}=er(e,t);return"json"===r.mode?new tT(i):new tx(i,r)}let tq=Symbol.for("drizzle:SQLiteInlineForeignKeys");class tL extends w{static [n]="SQLiteTable";static Symbol=Object.assign({},w.Symbol,{InlineForeignKeys:tq});[w.Symbol.Columns];[tq]=[];[w.Symbol.ExtraConfigBuilder]=void 0}let tI=(e,t,i)=>(function(e,t,i,r=e){let s=new tL(e,void 0,r),n=Object.fromEntries(Object.entries("function"==typeof t?t({blob:tt,customType:ts,integer:tf,numeric:tS,real:tN,text:tQ}):t).map(([e,t])=>{t.setName(e);let i=t.build(s);return s[tq].push(...t.buildForeignKeys(i,s)),[e,i]})),a=Object.assign(s,n);return a[w.Symbol.Columns]=n,a[w.Symbol.ExtraConfigColumns]=n,i&&(a[tL.Symbol.ExtraConfigBuilder]=i),a})(e,t,i);class tB extends H{static [n]="SQLiteViewBase"}class tO{static [n]="SQLiteDialect";casing;constructor(e){this.casing=new eY(e?.casing)}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[J`with `];for(let[i,r]of e.entries())t.push(J`${J.identifier(r._.alias)} as (${r._.sql})`),i<e.length-1&&t.push(J`, `);return t.push(J` `),J.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:r,limit:s,orderBy:n}){let a=this.buildWithCTE(r),o=i?J` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,l=t?J` where ${t}`:void 0,u=this.buildOrderBy(n),c=this.buildLimit(s);return J`${a}delete from ${e}${l}${o}${u}${c}`}buildUpdateSet(e,t){let i=e[w.Symbol.Columns],r=Object.keys(i).filter(e=>void 0!==t[e]||i[e]?.onUpdateFn!==void 0),s=r.length;return J.join(r.flatMap((e,r)=>{let n=i[e],o=n.onUpdateFn?.(),l=t[e]??(a(o,M)?o:J.param(o,n)),u=J`${J.identifier(this.casing.getColumnCasing(n))} = ${l}`;return r<s-1?[u,J.raw(", ")]:[u]}))}buildUpdateQuery({table:e,set:t,where:i,returning:r,withList:s,joins:n,from:a,limit:o,orderBy:l}){let u=this.buildWithCTE(s),c=this.buildUpdateSet(e,t),h=a&&J.join([J.raw(" from "),this.buildFromTable(a)]),d=this.buildJoins(n),f=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,m=i?J` where ${i}`:void 0,p=this.buildOrderBy(l),g=this.buildLimit(o);return J`${u}update ${e} set ${c}${h}${d}${m}${f}${p}${g}`}buildSelection(e,{isSingleTable:t=!1}={}){let i=e.length,r=e.flatMap(({field:e},r)=>{let s=[];if(a(e,M.Aliased)&&e.isSelectionField)s.push(J.identifier(e.fieldAlias));else if(a(e,M.Aliased)||a(e,M)){let i=a(e,M.Aliased)?e.sql:e;t?s.push(new M(i.queryChunks.map(e=>a(e,$)?J.identifier(this.casing.getColumnCasing(e)):e))):s.push(i),a(e,M.Aliased)&&s.push(J` as ${J.identifier(e.fieldAlias)}`)}else if(a(e,$)){let i=e.table[w.Symbol.Name];"SQLiteNumericBigInt"===e.columnType?t?s.push(J`cast(${J.identifier(this.casing.getColumnCasing(e))} as text)`):s.push(J`cast(${J.identifier(i)}.${J.identifier(this.casing.getColumnCasing(e))} as text)`):t?s.push(J.identifier(this.casing.getColumnCasing(e))):s.push(J`${J.identifier(i)}.${J.identifier(this.casing.getColumnCasing(e))}`)}else if(a(e,j)){let t=Object.entries(e._.selectedFields);if(1===t.length){let i=t[0][1],r=a(i,M)?i.decoder:a(i,$)?{mapFromDriverValue:e=>i.mapFromDriverValue(e)}:i.sql.decoder;r&&(e._.sql.decoder=r)}s.push(e)}return r<i-1&&s.push(J`, `),s});return J.join(r)}buildJoins(e){if(!e||0===e.length)return;let t=[];if(e)for(let[i,r]of e.entries()){0===i&&t.push(J` `);let s=r.table,n=r.on?J` on ${r.on}`:void 0;if(a(s,tL)){let e=s[tL.Symbol.Name],i=s[tL.Symbol.Schema],a=s[tL.Symbol.OriginalName],o=e===a?void 0:r.alias;t.push(J`${J.raw(r.joinType)} join ${i?J`${J.identifier(i)}.`:void 0}${J.identifier(a)}${o&&J` ${J.identifier(o)}`}${n}`)}else t.push(J`${J.raw(r.joinType)} join ${s}${n}`);i<e.length-1&&t.push(J` `)}return J.join(t)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?J` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,r]of e.entries())t.push(r),i<e.length-1&&t.push(J`, `);return t.length>0?J` order by ${J.join(t)}`:void 0}buildFromTable(e){return a(e,w)&&e[w.Symbol.IsAlias]?J`${J`${J.identifier(e[w.Symbol.Schema]??"")}.`.if(e[w.Symbol.Schema])}${J.identifier(e[w.Symbol.OriginalName])} ${J.identifier(e[w.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:r,having:s,table:n,joins:o,orderBy:l,groupBy:u,limit:h,offset:d,distinct:f,setOperators:m}){let p=i??Z(t);for(let e of p){let t;if(a(e.field,$)&&e.field.table[c]!==(a(n,j)?n._.alias:a(n,tB)?n[F].name:a(n,M)?void 0:n[c])&&(t=e.field.table,!o?.some(({alias:e})=>e===(t[w.Symbol.IsAlias]?t[c]:t[w.Symbol.BaseName])))){let t=e.field.table[c];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 g=!o||0===o.length,y=this.buildWithCTE(e),b=f?J` distinct`:void 0,S=this.buildSelection(p,{isSingleTable:g}),v=this.buildFromTable(n),N=this.buildJoins(o),x=r?J` where ${r}`:void 0,_=s?J` having ${s}`:void 0,T=[];if(u)for(let[e,t]of u.entries())T.push(t),e<u.length-1&&T.push(J`, `);let C=T.length>0?J` group by ${J.join(T)}`:void 0,Q=this.buildOrderBy(l),q=this.buildLimit(h),L=d?J` offset ${d}`:void 0,I=J`${y}select${b} ${S} from ${v}${N}${x}${C}${_}${Q}${q}${L}`;return m.length>0?this.buildSetOperations(I,m):I}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:i,rightSelect:r,limit:s,orderBy:n,offset:o}}){let l,u=J`${e.getSQL()} `,c=J`${r.getSQL()}`;if(n&&n.length>0){let e=[];for(let t of n)if(a(t,e2))e.push(J.identifier(t.name));else if(a(t,M)){for(let e=0;e<t.queryChunks.length;e++){let i=t.queryChunks[e];a(i,e2)&&(t.queryChunks[e]=J.identifier(this.casing.getColumnCasing(i)))}e.push(J`${t}`)}else e.push(J`${t}`);l=J` order by ${J.join(e,J`, `)}`}let h="object"==typeof s||"number"==typeof s&&s>=0?J` limit ${s}`:void 0,d=J.raw(`${t} ${i?"all ":""}`),f=o?J` offset ${o}`:void 0;return J`${u}${d}${c}${l}${h}${f}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:r,withList:s,select:n}){let o=[],l=Object.entries(e[w.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>J.identifier(this.casing.getColumnCasing(e)));if(n)a(t,M)?o.push(t):o.push(t.getSQL());else for(let[e,i]of(o.push(J.raw("values ")),t.entries())){let r=[];for(let[e,t]of l){let s=i[e];if(void 0===s||a(s,V)&&void 0===s.value){let e;if(null!==t.default&&void 0!==t.default)e=a(t.default,M)?t.default:J.param(t.default,t);else if(void 0!==t.defaultFn){let i=t.defaultFn();e=a(i,M)?i:J.param(i,t)}else if(t.default||void 0===t.onUpdateFn)e=J`null`;else{let i=t.onUpdateFn();e=a(i,M)?i:J.param(i,t)}r.push(e)}else r.push(s)}o.push(r),e<t.length-1&&o.push(J`, `)}let c=this.buildWithCTE(s),h=J.join(o),d=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,f=i?.length?J.join(i):void 0;return J`${c}insert into ${e} ${u} ${h}${f}${d}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:r,tableConfig:s,queryConfig:n,tableAlias:o,nestedQueryRelation:l,joinOn:u}){let c,h=[],d,f,m=[],p,g=[];if(!0===n)h=Object.entries(s.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:eR(t,o),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let r=Object.fromEntries(Object.entries(s.columns).map(([e,t])=>[e,eR(t,o)]));if(n.where){let e="function"==typeof n.where?n.where(r,{and:ef,between:eT,eq:eh,exists:ex,gt:eg,gte:ey,ilike:eL,inArray:eS,isNull:ev,isNotNull:eN,like:eQ,lt:eb,lte:ew,ne:ed,not:ep,notBetween:eC,notExists:e_,notLike:eq,notIlike:eI,notInArray:e$,or:em,sql:J}):n.where;p=e&&ez(e,o)}let l=[],u=[];if(n.columns){let e=!1;for(let[t,i]of Object.entries(n.columns))void 0!==i&&t in s.columns&&(e||!0!==i||(e=!0),u.push(t));u.length>0&&(u=e?u.filter(e=>n.columns?.[e]===!0):Object.keys(s.columns).filter(e=>!u.includes(e)))}else u=Object.keys(s.columns);for(let e of u){let t=s.columns[e];l.push({tsKey:e,value:t})}let c=[];if(n.with&&(c=Object.entries(n.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:s.relations[e]}))),n.extras)for(let[e,t]of Object.entries("function"==typeof n.extras?n.extras(r,{sql:J}):n.extras))l.push({tsKey:e,value:eK(t,o)});for(let{tsKey:e,value:t}of l)h.push({dbKey:a(t,M.Aliased)?t.fieldAlias:s.columns[e].name,tsKey:e,field:a(t,$)?eR(t,o):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let g="function"==typeof n.orderBy?n.orderBy(r,{sql:J,asc:eB,desc:eO}):n.orderBy??[];for(let{tsKey:r,queryConfig:s,relation:l}of(Array.isArray(g)||(g=[g]),m=g.map(e=>a(e,$)?eR(e,o):ez(e,o)),d=n.limit,f=n.offset,c)){let n=function(e,t,i){if(a(i,eA)&&i.config)return{fields:i.config.fields,references:i.config.references};let r=t[S(i.referencedTable)];if(!r)throw Error(`Table "${i.referencedTable[w.Symbol.Name]}" not found in schema`);let s=e[r];if(!s)throw Error(`Table "${r}" not found in schema`);let n=i.sourceTable,o=t[S(n)];if(!o)throw Error(`Table "${n[w.Symbol.Name]}" not found in schema`);let l=[];for(let e of Object.values(s.relations))(i.relationName&&i!==e&&e.relationName===i.relationName||!i.relationName&&e.referencedTable===i.sourceTable)&&l.push(e);if(l.length>1)throw i.relationName?Error(`There are multiple relations with name "${i.relationName}" in table "${r}"`):Error(`There are multiple relations between "${r}" and "${i.sourceTable[w.Symbol.Name]}". Please specify relation name`);if(l[0]&&a(l[0],eA)&&l[0].config)return{fields:l[0].config.references,references:l[0].config.fields};throw Error(`There is not enough information to infer relation "${o}.${i.fieldName}"`)}(t,i,l),u=i[S(l.referencedTable)],c=`${o}_${r}`,d=ef(...n.fields.map((e,t)=>eh(eR(n.references[t],c),eR(e,o)))),f=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[u],tableConfig:t[u],queryConfig:a(l,eA)?!0===s?{limit:1}:{...s,limit:1}:s,tableAlias:c,joinOn:d,nestedQueryRelation:l}),m=J`(${f.sql})`.as(r);h.push({dbKey:r,tsKey:r,field:m,relationTableTsKey:u,isJson:!0,selection:f.selection})}}if(0===h.length)throw new eG({message:`No fields selected for table "${s.tsName}" ("${o}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});if(p=ef(u,p),l){let e=J`json_array(${J.join(h.map(({field:e})=>a(e,e2)?J.identifier(this.casing.getColumnCasing(e)):a(e,M.Aliased)?e.sql:e),J`, `)})`;a(l,eD)&&(e=J`coalesce(json_group_array(${e}), json_array())`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:s.tsName,selection:h}];void 0!==d||void 0!==f||m.length>0?(c=this.buildSelectQuery({table:eM(r,o),fields:{},fieldsFlat:[{path:[],field:J.raw("*")}],where:p,limit:d,offset:f,orderBy:m,setOperators:[]}),p=void 0,d=void 0,f=void 0,m=void 0):c=eM(r,o),c=this.buildSelectQuery({table:a(c,tL)?c:new j(c,{},o),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:a(e,$)?eR(e,o):e})),joins:g,where:p,limit:d,offset:f,orderBy:m,setOperators:[]})}else c=this.buildSelectQuery({table:eM(r,o),fields:{},fieldsFlat:h.map(({field:e})=>({path:[],field:a(e,$)?eR(e,o):e})),joins:g,where:p,limit:d,offset:f,orderBy:m,setOperators:[]});return{tableTsKey:s.tsName,sql:c,selection:h}}}class tE extends tO{static [n]="SQLiteSyncDialect";migrate(e,t,i){let r=void 0===i||"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",s=J`
|
|
3
3
|
CREATE TABLE IF NOT EXISTS ${J.identifier(r)} (
|
|
4
4
|
id SERIAL PRIMARY KEY,
|
|
5
5
|
hash text NOT NULL,
|
|
6
6
|
created_at numeric
|
|
7
7
|
)
|
|
8
|
-
`;t.run(s);let n=t.values(J`SELECT id, hash, created_at FROM ${J.identifier(r)} ORDER BY created_at DESC LIMIT 1`)[0]??void 0;t.run(J`BEGIN`);try{for(let i of e)if(!n||Number(n[2])<i.folderMillis){for(let e of i.sql)t.run(J.raw(e));t.run(J`INSERT INTO ${J.identifier(r)} ("hash", "created_at") VALUES(${i.hash}, ${i.folderMillis})`)}t.run(J`COMMIT`)}catch(e){throw t.run(J`ROLLBACK`),e}}}class tA{static [n]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class tj{static [n]="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)}}class tD{constructor(e,t){this.name=e,this.unique=t}static [n]="SQLiteIndexBuilderOn";on(...e){return new tF(this.name,e,this.unique)}}class tF{static [n]="SQLiteIndexBuilder";config;constructor(e,t,i){this.config={name:e,columns:t,unique:i,where:void 0}}where(e){return this.config.where=e,this}build(e){return new tk(this.config,e)}}class tk{static [n]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}function tP(e){return new tD(e,!1)}function tM(e){return new tD(e,!0)}function tR(e){return a(e,tL)?[`${e[w.Symbol.BaseName]}`]:a(e,A)?e._.usedTables??[]:a(e,M)?e.usedTables??[]:[]}class tK{static [n]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t,i=!!this.fields;return t=this.fields?this.fields:a(e,A)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):a(e,tB)?e[F].selectedFields:a(e,M)?{}:e[w.Symbol.Columns],new tU({table:e,fields:t,isPartialSelect:i,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}}class tz extends tA{static [n]="SQLiteSelectQueryBuilder";_;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 l 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=ei(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},tR(e)))this.usedTables.add(l)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,i)=>{let r=this.tableName,s=ei(t);for(let e of tR(t))this.usedTables.add(e);if("string"==typeof s&&this.config.joins?.some(e=>e.alias===s))throw Error(`Alias "${s}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof r&&(this.config.fields={[r]:this.config.fields}),"string"==typeof s&&!a(t,M))){let e=a(t,A)?t._.selectedFields:a(t,H)?t[F].selectedFields:t[w.Symbol.Columns];this.config.fields[s]=e}if("function"==typeof i&&(i=i(new Proxy(this.config.fields,new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,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"cross":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");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let r="function"==typeof i?i(tJ()):i;if(!ee(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);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new eU({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 eU({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 eU({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}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(...tR(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...tR(e.table));return new Proxy(new A(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new eU({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new eU({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class tU extends tz{static [n]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=Z(this.config.fields),i=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enable:!0,autoInvalidate:!0}:!1===e?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.all()}}for(let e of[tj])for(let t of Object.getOwnPropertyNames(e.prototype))"constructor"!==t&&Object.defineProperty(tU.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t)||Object.create(null));function tV(e,t){return(i,r,...s)=>{let n=[r,...s].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!ee(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)}}let tJ=()=>({union:tW,unionAll:tY,intersect:tG,except:tH}),tW=tV("union",!1),tY=tV("union",!0),tG=tV("intersect",!1),tH=tV("except",!1);class tX{static [n]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=a(e,tO)?e:void 0,this.dialectConfig=a(e,tO)?void 0:e}$with=(e,t)=>{let i=this;return{as:r=>("function"==typeof r&&(r=r(i)),new Proxy(new j(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,!0),new eU({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;return{select:function(i){return new tK({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(i){return new tK({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}}}select(e){return new tK({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new tK({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||(this.dialect=new tE(this.dialectConfig)),this.dialect}}class tZ extends tj{constructor(e,t,i,r){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:r}}static [n]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[w.Symbol.Columns],new eU({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[tL.Symbol.Columns]){return this.config.returning=Z(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:tR(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}class t0{constructor(e,t,i,r){this.table=e,this.session=t,this.dialect=i,this.withList=r}static [n]="SQLiteInsertBuilder";values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let t=e.map(e=>{let t={},i=this.table[w.Symbol.Columns];for(let r of Object.keys(e)){let s=e[r];t[r]=a(s,M)?s:new V(s,i[r])}return t});return new t1(this.table,t,this.session,this.dialect,this.withList)}select(e){let t="function"==typeof e?e(new tX):e;if(!a(t,M)&&!ee(this.table[h],t._.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 t1(this.table,t,this.session,this.dialect,this.withList,!0)}}class t1 extends tj{constructor(e,t,i,r,s,n){super(),this.session=i,this.dialect=r,this.config={table:e,values:t,withList:s,select:n}}static [n]="SQLiteInsert";config;returning(e=this.config.table[tL.Symbol.Columns]){return this.config.returning=Z(e),this}onConflictDoNothing(e={}){if(this.config.onConflict||(this.config.onConflict=[]),void 0===e.target)this.config.onConflict.push(J` on conflict do nothing`);else{let t=Array.isArray(e.target)?J`${e.target}`:J`${[e.target]}`,i=e.where?J` where ${e.where}`:J``;this.config.onConflict.push(J` on conflict ${t} do nothing${i}`)}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.');this.config.onConflict||(this.config.onConflict=[]);let t=e.where?J` where ${e.where}`:void 0,i=e.targetWhere?J` where ${e.targetWhere}`:void 0,r=e.setWhere?J` where ${e.setWhere}`:void 0,s=Array.isArray(e.target)?J`${e.target}`:J`${[e.target]}`,n=this.dialect.buildUpdateSet(this.config.table,et(this.config.table,e.set));return this.config.onConflict.push(J` on conflict ${s}${i} do update set ${n}${t}${r}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:tR(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class t4{constructor(e,t,i,r){this.table=e,this.session=t,this.dialect=i,this.withList=r}static [n]="SQLiteUpdateBuilder";set(e){return new t5(this.table,et(this.table,e),this.session,this.dialect,this.withList)}}class t5 extends tj{constructor(e,t,i,r,s){super(),this.session=i,this.dialect=r,this.config={set:t,table:e,withList:s,joins:[]}}static [n]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,i)=>{let r=ei(t);if("string"==typeof r&&this.config.joins.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if("function"==typeof i){let e=this.config.from?a(t,tL)?t[w.Symbol.Columns]:a(t,A)?t._.selectedFields:a(t,tB)?t[F].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[w.Symbol.Columns],new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:i,table:t,joinType:e,alias:r}),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}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[w.Symbol.Columns],new eU({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[tL.Symbol.Columns]){return this.config.returning=Z(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:tR(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class t2 extends M{constructor(e){super(t2.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.session=e.session,this.sql=t2.buildCount(e.source,e.filters)}sql;static [n]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return J`(select count(*) from ${e}${J.raw(" where ").if(t)}${t})`}static buildCount(e,t){return J`select count(*) from ${e}${J.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}}class t7{constructor(e,t,i,r,s,n,a,l){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=r,this.table=s,this.tableConfig=n,this.dialect=a,this.session=l}static [n]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return"sync"===this.mode?new t8(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new t9(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return"sync"===this.mode?new t8(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new t9(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}class t9 extends tj{constructor(e,t,i,r,s,n,a,l,o){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=r,this.tableConfig=s,this.dialect=n,this.session=a,this.config=l,this.mode=o}static [n]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](i,void 0,"first"===this.mode?"get":"all",!0,(e,i)=>{let r=e.map(e=>(function e(t,i,r,s,n=e=>e){let l={};for(let[o,u]of s.entries())if(u.isJson){let s=i.relations[u.tsKey],c=r[o],d="string"==typeof c?JSON.parse(c):c;l[u.tsKey]=a(s,ej)?d&&e(t,t[u.relationTableTsKey],d,u.selection,n):d.map(i=>e(t,t[u.relationTableTsKey],i,u.selection,n))}else{let e,t=n(r[o]),i=u.field;e=a(i,$)?i:a(i,M)?i.decoder:i.sql.decoder,l[u.tsKey]=null===t?null:e.mapFromDriverValue(t)}return l})(this.schema,this.tableConfig,e,t.selection,i));return"first"===this.mode?r[0]:r})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){return"first"===this.mode?this._prepare(!1).get():this._prepare(!1).all()}async execute(){return this.executeRaw()}}class t8 extends t9{static [n]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}class t6 extends tj{constructor(e,t,i,r,s){super(),this.execute=e,this.getSQL=t,this.dialect=r,this.mapBatchResult=s,this.config={action:i}}static [n]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}class t3{constructor(e,t,i,r){this.resultKind=e,this.dialect=t,this.session=i,this._=r?{schema:r.schema,fullSchema:r.fullSchema,tableNamesMap:r.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let s=this.query;if(this._.schema)for(let[n,a]of Object.entries(this._.schema))s[n]=new t7(e,r.fullSchema,this._.schema,this._.tableNamesMap,r.fullSchema[n],a,t,i);this.$cache={invalidate:async e=>{}}}static [n]="BaseSQLiteDatabase";query;$with=(e,t)=>{let i=this;return{as:r=>("function"==typeof r&&(r=r(new tX(i.dialect))),new Proxy(new j(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,!0),new eU({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new t2({source:e,filters:t,session:this.session})}with(...e){let t=this;return{select:function(i){return new tK({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e})},selectDistinct:function(i){return new tK({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})},update:function(i){return new t4(i,t.session,t.dialect,e)},insert:function(i){return new t0(i,t.session,t.dialect,e)},delete:function(i){return new tZ(i,t.session,t.dialect,e)}}}select(e){return new tK({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new tK({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new t4(e,this.session,this.dialect)}$cache;insert(e){return new t0(e,this.session,this.dialect)}delete(e){return new tZ(e,this.session,this.dialect)}run(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session)):this.session.run(t)}all(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session)):this.session.all(t)}get(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session)):this.session.get(t)}values(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session)):this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}class ie{static [n]="Cache"}class it extends ie{strategy(){return"all"}static [n]="NoopCache";async get(e){}async put(e,t,i,r){}async onMutate(e){}}async function ii(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("")}class ir extends tj{constructor(e){super(),this.resultCb=e}static [n]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}}class is{constructor(e,t,i,r,s,n){this.mode=e,this.executeMethod=t,this.query=i,this.cache=r,this.queryMetadata=s,this.cacheConfig=n,r&&"all"===r.strategy()&&void 0===n&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),this.cacheConfig?.enable||(this.cacheConfig=void 0)}static [n]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,i){if(void 0===this.cache||a(this.cache,it)||void 0===this.queryMetadata||this.cacheConfig&&!this.cacheConfig.enable)try{return await i()}catch(i){throw new eH(e,t,i)}if(("insert"===this.queryMetadata.type||"update"===this.queryMetadata.type||"delete"===this.queryMetadata.type)&&this.queryMetadata.tables.length>0)try{let[e]=await Promise.all([i(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return e}catch(i){throw new eH(e,t,i)}if(!this.cacheConfig)try{return await i()}catch(i){throw new eH(e,t,i)}if("select"===this.queryMetadata.type){let r=await this.cache.get(this.cacheConfig.tag??await ii(e,t),this.queryMetadata.tables,void 0!==this.cacheConfig.tag,this.cacheConfig.autoInvalidate);if(void 0===r){let r;try{r=await i()}catch(i){throw new eH(e,t,i)}return await this.cache.put(this.cacheConfig.tag??await ii(e,t),r,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],void 0!==this.cacheConfig.tag,this.cacheConfig.config),r}return r}try{return await i()}catch(i){throw new eH(e,t,i)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){return"async"===this.mode?this[this.executeMethod](e):new ir(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}}class ia{constructor(e){this.dialect=e}static [n]="SQLiteSession";prepareOneTimeQuery(e,t,i,r,s,n,a){return this.prepareQuery(e,t,i,r,s,n,a)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(e){throw new eG({cause:e,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}}class il extends t3{constructor(e,t,i,r,s=0){super(e,t,i,r),this.schema=r,this.nestedIndex=s}static [n]="SQLiteTransaction";rollback(){throw new eX}}class io extends ia{constructor(e,t,i,r={}){super(t),this.client=e,this.schema=i,this.logger=r.logger??new u,this.cache=r.cache??new it}static [n]="BetterSQLiteSession";logger;cache;prepareQuery(e,t,i,r,s,n,a){return new ic(this.client.prepare(e.sql),e,this.logger,this.cache,n,a,t,i,r,s)}transaction(e,t={}){let i=new iu("sync",this.dialect,this,this.schema);return this.client.transaction(e)[t.behavior??"deferred"](i)}}class iu extends il{static [n]="BetterSQLiteTransaction";transaction(e){let t=`sp${this.nestedIndex}`,i=new iu("sync",this.dialect,this.session,this.schema,this.nestedIndex+1);this.session.run(J.raw(`savepoint ${t}`));try{let r=e(i);return this.session.run(J.raw(`release savepoint ${t}`)),r}catch(e){throw this.session.run(J.raw(`rollback to savepoint ${t}`)),e}}}class ic extends is{constructor(e,t,i,r,s,n,a,l,o,u){super("sync",l,t,r,s,n),this.stmt=e,this.logger=i,this.fields=a,this._isResponseInArrayMode=o,this.customResultMapper=u}static [n]="BetterSQLitePreparedQuery";run(e){let t=Y(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.run(...t)}all(e){let{fields:t,joinsNotNullableMap:i,query:r,logger:s,stmt:n,customResultMapper:a}=this;if(!t&&!a){let t=Y(r.params,e??{});return s.logQuery(r.sql,t),n.all(...t)}let l=this.values(e);return a?a(l):l.map(e=>X(t,e,i))}get(e){let t=Y(this.query.params,e??{});this.logger.logQuery(this.query.sql,t);let{fields:i,stmt:r,joinsNotNullableMap:s,customResultMapper:n}=this;if(!i&&!n)return r.get(...t);let a=r.raw().get(...t);if(a)return n?n([a]):X(i,a,s)}values(e){let t=Y(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.raw().all(...t)}isResponseInArrayMode(){return this._isResponseInArrayMode}}class id extends t3{static [n]="BetterSQLite3Database"}function ih(e,t={}){let i,r,s=new tE({casing:t.casing});if(!0===t.logger?i=new o:!1!==t.logger&&(i=t.logger),t.schema){let e=function(e,t){1===Object.keys(e).length&&"default"in e&&!a(e.default,w)&&(e=e.default);let i={},r={},s={};for(let[n,l]of Object.entries(e))if(a(l,w)){let e=S(l),t=r[e];for(let r of(i[e]=n,s[n]={tsName:n,dbName:l[w.Symbol.Name],schema:l[w.Symbol.Schema],columns:l[w.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]},Object.values(l[w.Symbol.Columns])))r.primary&&s[n].primaryKey.push(r);let o=l[w.Symbol.ExtraConfigBuilder]?.(l[w.Symbol.ExtraConfigColumns]);if(o)for(let e of Object.values(o))a(e,eo)&&s[n].primaryKey.push(...e.columns)}else if(a(l,eA)){let e,n=S(l.table),a=i[n];for(let[i,o]of Object.entries(l.config(t(l.table))))if(a){let t=s[a];t.relations[i]=o,e&&t.primaryKey.push(...e)}else n in r||(r[n]={relations:{},primaryKey:e}),r[n].relations[i]=o}return{tables:s,tableNamesMap:i}}(t.schema,eF);r={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let n=new io(e,s,r,{logger:i}),l=new id("sync",s,n,r);return l.$client=e,l}function im(...e){if(void 0===e[0]||"string"==typeof e[0])return ih(void 0===e[0]?new s.default:new s.default(e[0]),e[1]);if(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}(e[0])){let{connection:t,client:i,...r}=e[0];if(i)return ih(i,r);if("object"==typeof t){let{source:e,...i}=t;return ih(new s.default(e,i),r)}return ih(new s.default(t),r)}return ih(e[0],e[1])}(im||(im={})).mock=function(e){return ih({},e)},e.s(["f",0,im],20842);var ip=e.i(66680),ig=e.i(2157);function iy(e){let t=e.migrationsFolder,i=[],r=`${t}/meta/_journal.json`;if(!ig.default.existsSync(r))throw Error("Can't find meta/_journal.json file");for(let e of JSON.parse(ig.default.readFileSync(`${t}/meta/_journal.json`).toString()).entries){let r=`${t}/${e.tag}.sql`;try{let r=ig.default.readFileSync(`${t}/${e.tag}.sql`).toString(),s=r.split("--> statement-breakpoint").map(e=>e);i.push({sql:s,bps:e.breakpoints,folderMillis:e.when,hash:ip.default.createHash("sha256").update(r).digest("hex")})}catch{throw Error(`No file ${r} found in ${t} folder`)}}return i}e.s(["f",0,iy],26889),e.s(["f",0,function(e,t){let i=iy(t);e.dialect.migrate(i,e.session,t)}],94176);let ib=tI("repositories",{id:tf().primaryKey({autoIncrement:!0}),rootPath:tQ("root_path").notNull().unique(),lastScanAt:tf("last_scan_at",{mode:"timestamp"}),lastIndexAt:tf("last_index_at",{mode:"timestamp"}),indexedHead:tQ("indexed_head")}),iw=tI("files",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),kind:tQ("kind",{enum:["component","module"]}).notNull(),contentHash:tQ("content_hash").notNull(),language:tQ("language").notNull().default("typescript"),sizeBytes:tf("size_bytes").notNull().default(0),lineCount:tf("line_count").notNull().default(0),isTest:tf("is_test",{mode:"boolean"}).notNull().default(!1),importSpecifiers:tQ("import_specifiers").notNull().default("[]"),declares:tQ("declares").notNull().default("[]")},e=>[tM("files_repo_path_unique").on(e.repoId,e.path)]),iS=tI("imports",{id:tf().primaryKey({autoIncrement:!0}),sourceFileId:tf("source_file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),targetFileId:tf("target_file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),specifier:tQ("specifier").notNull()},e=>[tM("imports_source_target_unique").on(e.sourceFileId,e.targetFileId),tP("imports_target_idx").on(e.targetFileId)]),i$=tI("chunks",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),chunkId:tQ("chunk_id").notNull(),kind:tQ("kind",{enum:["function","class","component","interface","type","const","enum","namespace","file-summary"]}).notNull(),name:tQ("name").notNull(),nameSplit:tQ("name_split").notNull().default(""),startLine:tf("start_line").notNull(),endLine:tf("end_line").notNull(),exported:tf("exported",{mode:"boolean"}).notNull().default(!1),partIndex:tf("part_index").notNull().default(0),text:tQ("text").notNull(),fileHash:tQ("file_hash").notNull(),createdAt:tf("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[tM("chunks_file_chunk_unique").on(e.fileId,e.chunkId)]),iv=tI("meta",{id:tf().primaryKey({autoIncrement:!0}),key:tQ("key").notNull().unique(),value:tQ("value").notNull(),updatedAt:tf("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date).$onUpdateFn(()=>new Date)}),iN=["function","class","method","property","accessor","constructor","interface","type","enum","const","namespace","struct","trait"],ix=tI("symbols",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),name:tQ("name").notNull(),qualifiedName:tQ("qualified_name").notNull(),kind:tQ("kind",{enum:iN}).notNull(),startLine:tf("start_line").notNull(),endLine:tf("end_line").notNull(),exported:tf("exported",{mode:"boolean"}).notNull().default(!1),parentQualifiedName:tQ("parent_qualified_name")},e=>[tP("symbols_file_idx").on(e.fileId),tP("symbols_name_idx").on(e.name)]),i_=tI("folders",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),parentPath:tQ("parent_path"),depth:tf("depth").notNull(),name:tQ("name").notNull(),fileCount:tf("file_count").notNull(),directFileCount:tf("direct_file_count").notNull()},e=>[tM("folders_repo_path_unique").on(e.repoId,e.path),tP("folders_repo_parent_idx").on(e.repoId,e.parentPath)]),iC=tI("level_edges",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),levelPath:tQ("level_path").notNull(),sourceNode:tQ("source_node").notNull(),targetNode:tQ("target_node").notNull(),count:tf("count").notNull()},e=>[tM("level_edges_unique").on(e.repoId,e.levelPath,e.sourceNode,e.targetNode)]),iT=["file","folder","repo"],iQ=["fresh","stale","pending","failed","skipped"],iq=tI("summaries",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),targetKind:tQ("target_kind",{enum:iT}).notNull(),targetPath:tQ("target_path").notNull(),tagline:tQ("tagline"),summary:tQ("summary"),model:tQ("model"),inputHash:tQ("input_hash"),status:tQ("status",{enum:iQ}).notNull(),error:tQ("error"),batchId:tQ("batch_id"),pendingHash:tQ("pending_hash"),updatedAt:tf("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[tM("summaries_target_unique").on(e.repoId,e.targetKind,e.targetPath),tP("summaries_batch_idx").on(e.batchId)]),iL=tI("summary_vectors",{id:tf().primaryKey({autoIncrement:!0}),summaryId:tf("summary_id").notNull().unique().references(()=>iq.id,{onDelete:"cascade"}),embedding:tt("embedding",{mode:"buffer"}).notNull()}),iI=tI("summary_usage",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),model:tQ("model").notNull(),transport:tQ("transport",{enum:["direct","batch"]}).notNull(),requests:tf("requests").notNull().default(0),inputTokens:tf("input_tokens").notNull().default(0),outputTokens:tf("output_tokens").notNull().default(0)},e=>[tM("summary_usage_unique").on(e.repoId,e.model,e.transport)]),iB=tI("entry_points",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),declaredBy:tQ("declared_by").notNull()},e=>[tM("entry_points_repo_path_unique").on(e.repoId,e.path)]),iO=tI("docs",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),title:tQ("title").notNull()},e=>[tM("docs_repo_path_unique").on(e.repoId,e.path)]),iE=["applies","readme","mentions"],iA=tI("doc_links",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),docPath:tQ("doc_path").notNull(),targetPath:tQ("target_path").notNull(),kind:tQ("kind",{enum:iE}).notNull(),count:tf("count").notNull(),detail:tQ("detail")},e=>[tP("doc_links_repo_target_idx").on(e.repoId,e.targetPath)]),ij=["param","local","destructure","constraint","cast","provider","new","alias","field","this","ctor-param","inject-field","super","return","member"],iD=tI("type_decls",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),name:tQ("name"),kind:tQ("kind",{enum:["class","interface"]}).notNull(),line:tf("line").notNull(),exported:tf("exported",{mode:"boolean"}).notNull().default(!1),nested:tf("nested",{mode:"boolean"}).notNull().default(!1),extendsRefs:tQ("extends_refs").notNull().default("[]"),implementsRefs:tQ("implements_refs").notNull().default("[]"),testDoubleOf:tQ("test_double_of"),members:tQ("members").notNull().default("[]"),fields:tQ("fields").notNull().default("{}")},e=>[tP("type_decls_file_idx").on(e.fileId),tP("type_decls_name_idx").on(e.name)]),iF=tI("call_bindings",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),kind:tQ("kind",{enum:["import","reexport","export"]}).notNull(),local:tQ("local").notNull(),imported:tQ("imported").notNull(),specifier:tQ("specifier")},e=>[tP("call_bindings_file_idx").on(e.fileId)]),ik=tI("typed_calls",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),line:tf("line").notNull(),member:tQ("member"),receiver:tQ("receiver",{enum:["type","field","this"]}).notNull(),ref:tQ("ref"),inClass:tQ("in_class"),how:tQ("how",{enum:ij}).notNull()},e=>[tP("typed_calls_file_idx").on(e.fileId),tP("typed_calls_member_idx").on(e.member)]);e.s(["CALL_RULES",0,ij,"DOC_LINK_KINDS",0,iE,"META_KEYS",0,{INDEXING_LOCK:"indexing",SUMMARIZING_LOCK:"summarizing"},"SUMMARY_STATUSES",0,iQ,"SUMMARY_TARGET_KINDS",0,iT,"SYMBOL_KINDS",0,iN,"callBindings",0,iF,"chunks",0,i$,"docLinks",0,iA,"docs",0,iO,"entryPoints",0,iB,"files",0,iw,"folders",0,i_,"imports",0,iS,"levelEdges",0,iC,"meta",0,iv,"repositories",0,ib,"summaries",0,iq,"summaryUsage",0,iI,"summaryVectors",0,iL,"symbols",0,ix,"typeDecls",0,iD,"typedCalls",0,ik],14674)}],8314,(e,t,i)=>{t.exports=e.x("typescript-279735412610ef8d",()=>require("typescript-279735412610ef8d"))}];
|
|
8
|
+
`;t.run(s);let n=t.values(J`SELECT id, hash, created_at FROM ${J.identifier(r)} ORDER BY created_at DESC LIMIT 1`)[0]??void 0;t.run(J`BEGIN`);try{for(let i of e)if(!n||Number(n[2])<i.folderMillis){for(let e of i.sql)t.run(J.raw(e));t.run(J`INSERT INTO ${J.identifier(r)} ("hash", "created_at") VALUES(${i.hash}, ${i.folderMillis})`)}t.run(J`COMMIT`)}catch(e){throw t.run(J`ROLLBACK`),e}}}class tj{static [n]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class tA{static [n]="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)}}class tD{constructor(e,t){this.name=e,this.unique=t}static [n]="SQLiteIndexBuilderOn";on(...e){return new tF(this.name,e,this.unique)}}class tF{static [n]="SQLiteIndexBuilder";config;constructor(e,t,i){this.config={name:e,columns:t,unique:i,where:void 0}}where(e){return this.config.where=e,this}build(e){return new tk(this.config,e)}}class tk{static [n]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}function tP(e){return new tD(e,!1)}function tM(e){return new tD(e,!0)}function tR(e){return a(e,tL)?[`${e[w.Symbol.BaseName]}`]:a(e,j)?e._.usedTables??[]:a(e,M)?e.usedTables??[]:[]}class tK{static [n]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t,i=!!this.fields;return t=this.fields?this.fields:a(e,j)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):a(e,tB)?e[F].selectedFields:a(e,M)?{}:e[w.Symbol.Columns],new tU({table:e,fields:t,isPartialSelect:i,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}}class tz extends tj{static [n]="SQLiteSelectQueryBuilder";_;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=ei(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},tR(e)))this.usedTables.add(o)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,i)=>{let r=this.tableName,s=ei(t);for(let e of tR(t))this.usedTables.add(e);if("string"==typeof s&&this.config.joins?.some(e=>e.alias===s))throw Error(`Alias "${s}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof r&&(this.config.fields={[r]:this.config.fields}),"string"==typeof s&&!a(t,M))){let e=a(t,j)?t._.selectedFields:a(t,H)?t[F].selectedFields:t[w.Symbol.Columns];this.config.fields[s]=e}if("function"==typeof i&&(i=i(new Proxy(this.config.fields,new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,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"cross":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");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let r="function"==typeof i?i(tJ()):i;if(!ee(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);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new eU({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 eU({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 eU({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}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(...tR(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...tR(e.table));return new Proxy(new j(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new eU({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new eU({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class tU extends tz{static [n]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=Z(this.config.fields),i=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enable:!0,autoInvalidate:!0}:!1===e?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.all()}}for(let e of[tA])for(let t of Object.getOwnPropertyNames(e.prototype))"constructor"!==t&&Object.defineProperty(tU.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t)||Object.create(null));function tV(e,t){return(i,r,...s)=>{let n=[r,...s].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!ee(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)}}let tJ=()=>({union:tW,unionAll:tY,intersect:tG,except:tH}),tW=tV("union",!1),tY=tV("union",!0),tG=tV("intersect",!1),tH=tV("except",!1);class tX{static [n]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=a(e,tO)?e:void 0,this.dialectConfig=a(e,tO)?void 0:e}$with=(e,t)=>{let i=this;return{as:r=>("function"==typeof r&&(r=r(i)),new Proxy(new A(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,!0),new eU({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;return{select:function(i){return new tK({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(i){return new tK({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}}}select(e){return new tK({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new tK({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||(this.dialect=new tE(this.dialectConfig)),this.dialect}}class tZ extends tA{constructor(e,t,i,r){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:r}}static [n]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[w.Symbol.Columns],new eU({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[tL.Symbol.Columns]){return this.config.returning=Z(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:tR(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}class t0{constructor(e,t,i,r){this.table=e,this.session=t,this.dialect=i,this.withList=r}static [n]="SQLiteInsertBuilder";values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let t=e.map(e=>{let t={},i=this.table[w.Symbol.Columns];for(let r of Object.keys(e)){let s=e[r];t[r]=a(s,M)?s:new V(s,i[r])}return t});return new t1(this.table,t,this.session,this.dialect,this.withList)}select(e){let t="function"==typeof e?e(new tX):e;if(!a(t,M)&&!ee(this.table[d],t._.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 t1(this.table,t,this.session,this.dialect,this.withList,!0)}}class t1 extends tA{constructor(e,t,i,r,s,n){super(),this.session=i,this.dialect=r,this.config={table:e,values:t,withList:s,select:n}}static [n]="SQLiteInsert";config;returning(e=this.config.table[tL.Symbol.Columns]){return this.config.returning=Z(e),this}onConflictDoNothing(e={}){if(this.config.onConflict||(this.config.onConflict=[]),void 0===e.target)this.config.onConflict.push(J` on conflict do nothing`);else{let t=Array.isArray(e.target)?J`${e.target}`:J`${[e.target]}`,i=e.where?J` where ${e.where}`:J``;this.config.onConflict.push(J` on conflict ${t} do nothing${i}`)}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.');this.config.onConflict||(this.config.onConflict=[]);let t=e.where?J` where ${e.where}`:void 0,i=e.targetWhere?J` where ${e.targetWhere}`:void 0,r=e.setWhere?J` where ${e.setWhere}`:void 0,s=Array.isArray(e.target)?J`${e.target}`:J`${[e.target]}`,n=this.dialect.buildUpdateSet(this.config.table,et(this.config.table,e.set));return this.config.onConflict.push(J` on conflict ${s}${i} do update set ${n}${t}${r}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:tR(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class t4{constructor(e,t,i,r){this.table=e,this.session=t,this.dialect=i,this.withList=r}static [n]="SQLiteUpdateBuilder";set(e){return new t5(this.table,et(this.table,e),this.session,this.dialect,this.withList)}}class t5 extends tA{constructor(e,t,i,r,s){super(),this.session=i,this.dialect=r,this.config={set:t,table:e,withList:s,joins:[]}}static [n]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,i)=>{let r=ei(t);if("string"==typeof r&&this.config.joins.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if("function"==typeof i){let e=this.config.from?a(t,tL)?t[w.Symbol.Columns]:a(t,j)?t._.selectedFields:a(t,tB)?t[F].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[w.Symbol.Columns],new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new eU({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:i,table:t,joinType:e,alias:r}),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}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[w.Symbol.Columns],new eU({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[tL.Symbol.Columns]){return this.config.returning=Z(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:tR(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class t2 extends M{constructor(e){super(t2.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.session=e.session,this.sql=t2.buildCount(e.source,e.filters)}sql;static [n]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return J`(select count(*) from ${e}${J.raw(" where ").if(t)}${t})`}static buildCount(e,t){return J`select count(*) from ${e}${J.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}}class t7{constructor(e,t,i,r,s,n,a,o){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=r,this.table=s,this.tableConfig=n,this.dialect=a,this.session=o}static [n]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return"sync"===this.mode?new t8(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new t9(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return"sync"===this.mode?new t8(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new t9(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}class t9 extends tA{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 [n]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](i,void 0,"first"===this.mode?"get":"all",!0,(e,i)=>{let r=e.map(e=>(function e(t,i,r,s,n=e=>e){let o={};for(let[l,u]of s.entries())if(u.isJson){let s=i.relations[u.tsKey],c=r[l],h="string"==typeof c?JSON.parse(c):c;o[u.tsKey]=a(s,eA)?h&&e(t,t[u.relationTableTsKey],h,u.selection,n):h.map(i=>e(t,t[u.relationTableTsKey],i,u.selection,n))}else{let e,t=n(r[l]),i=u.field;e=a(i,$)?i:a(i,M)?i.decoder:i.sql.decoder,o[u.tsKey]=null===t?null:e.mapFromDriverValue(t)}return o})(this.schema,this.tableConfig,e,t.selection,i));return"first"===this.mode?r[0]:r})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){return"first"===this.mode?this._prepare(!1).get():this._prepare(!1).all()}async execute(){return this.executeRaw()}}class t8 extends t9{static [n]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}class t6 extends tA{constructor(e,t,i,r,s){super(),this.execute=e,this.getSQL=t,this.dialect=r,this.mapBatchResult=s,this.config={action:i}}static [n]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}class t3{constructor(e,t,i,r){this.resultKind=e,this.dialect=t,this.session=i,this._=r?{schema:r.schema,fullSchema:r.fullSchema,tableNamesMap:r.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let s=this.query;if(this._.schema)for(let[n,a]of Object.entries(this._.schema))s[n]=new t7(e,r.fullSchema,this._.schema,this._.tableNamesMap,r.fullSchema[n],a,t,i);this.$cache={invalidate:async e=>{}}}static [n]="BaseSQLiteDatabase";query;$with=(e,t)=>{let i=this;return{as:r=>("function"==typeof r&&(r=r(new tX(i.dialect))),new Proxy(new A(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,!0),new eU({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new t2({source:e,filters:t,session:this.session})}with(...e){let t=this;return{select:function(i){return new tK({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e})},selectDistinct:function(i){return new tK({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})},update:function(i){return new t4(i,t.session,t.dialect,e)},insert:function(i){return new t0(i,t.session,t.dialect,e)},delete:function(i){return new tZ(i,t.session,t.dialect,e)}}}select(e){return new tK({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new tK({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new t4(e,this.session,this.dialect)}$cache;insert(e){return new t0(e,this.session,this.dialect)}delete(e){return new tZ(e,this.session,this.dialect)}run(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session)):this.session.run(t)}all(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session)):this.session.all(t)}get(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session)):this.session.get(t)}values(e){let t="string"==typeof e?J.raw(e):e.getSQL();return"async"===this.resultKind?new t6(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session)):this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}class ie{static [n]="Cache"}class it extends ie{strategy(){return"all"}static [n]="NoopCache";async get(e){}async put(e,t,i,r){}async onMutate(e){}}async function ii(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("")}class ir extends tA{constructor(e){super(),this.resultCb=e}static [n]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}}class is{constructor(e,t,i,r,s,n){this.mode=e,this.executeMethod=t,this.query=i,this.cache=r,this.queryMetadata=s,this.cacheConfig=n,r&&"all"===r.strategy()&&void 0===n&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),this.cacheConfig?.enable||(this.cacheConfig=void 0)}static [n]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,i){if(void 0===this.cache||a(this.cache,it)||void 0===this.queryMetadata||this.cacheConfig&&!this.cacheConfig.enable)try{return await i()}catch(i){throw new eH(e,t,i)}if(("insert"===this.queryMetadata.type||"update"===this.queryMetadata.type||"delete"===this.queryMetadata.type)&&this.queryMetadata.tables.length>0)try{let[e]=await Promise.all([i(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return e}catch(i){throw new eH(e,t,i)}if(!this.cacheConfig)try{return await i()}catch(i){throw new eH(e,t,i)}if("select"===this.queryMetadata.type){let r=await this.cache.get(this.cacheConfig.tag??await ii(e,t),this.queryMetadata.tables,void 0!==this.cacheConfig.tag,this.cacheConfig.autoInvalidate);if(void 0===r){let r;try{r=await i()}catch(i){throw new eH(e,t,i)}return await this.cache.put(this.cacheConfig.tag??await ii(e,t),r,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],void 0!==this.cacheConfig.tag,this.cacheConfig.config),r}return r}try{return await i()}catch(i){throw new eH(e,t,i)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){return"async"===this.mode?this[this.executeMethod](e):new ir(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}}class ia{constructor(e){this.dialect=e}static [n]="SQLiteSession";prepareOneTimeQuery(e,t,i,r,s,n,a){return this.prepareQuery(e,t,i,r,s,n,a)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(e){throw new eG({cause:e,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}}class io extends t3{constructor(e,t,i,r,s=0){super(e,t,i,r),this.schema=r,this.nestedIndex=s}static [n]="SQLiteTransaction";rollback(){throw new eX}}class il extends ia{constructor(e,t,i,r={}){super(t),this.client=e,this.schema=i,this.logger=r.logger??new u,this.cache=r.cache??new it}static [n]="BetterSQLiteSession";logger;cache;prepareQuery(e,t,i,r,s,n,a){return new ic(this.client.prepare(e.sql),e,this.logger,this.cache,n,a,t,i,r,s)}transaction(e,t={}){let i=new iu("sync",this.dialect,this,this.schema);return this.client.transaction(e)[t.behavior??"deferred"](i)}}class iu extends io{static [n]="BetterSQLiteTransaction";transaction(e){let t=`sp${this.nestedIndex}`,i=new iu("sync",this.dialect,this.session,this.schema,this.nestedIndex+1);this.session.run(J.raw(`savepoint ${t}`));try{let r=e(i);return this.session.run(J.raw(`release savepoint ${t}`)),r}catch(e){throw this.session.run(J.raw(`rollback to savepoint ${t}`)),e}}}class ic extends is{constructor(e,t,i,r,s,n,a,o,l,u){super("sync",o,t,r,s,n),this.stmt=e,this.logger=i,this.fields=a,this._isResponseInArrayMode=l,this.customResultMapper=u}static [n]="BetterSQLitePreparedQuery";run(e){let t=Y(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.run(...t)}all(e){let{fields:t,joinsNotNullableMap:i,query:r,logger:s,stmt:n,customResultMapper:a}=this;if(!t&&!a){let t=Y(r.params,e??{});return s.logQuery(r.sql,t),n.all(...t)}let o=this.values(e);return a?a(o):o.map(e=>X(t,e,i))}get(e){let t=Y(this.query.params,e??{});this.logger.logQuery(this.query.sql,t);let{fields:i,stmt:r,joinsNotNullableMap:s,customResultMapper:n}=this;if(!i&&!n)return r.get(...t);let a=r.raw().get(...t);if(a)return n?n([a]):X(i,a,s)}values(e){let t=Y(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.raw().all(...t)}isResponseInArrayMode(){return this._isResponseInArrayMode}}class ih extends t3{static [n]="BetterSQLite3Database"}function id(e,t={}){let i,r,s=new tE({casing:t.casing});if(!0===t.logger?i=new l:!1!==t.logger&&(i=t.logger),t.schema){let e=function(e,t){1===Object.keys(e).length&&"default"in e&&!a(e.default,w)&&(e=e.default);let i={},r={},s={};for(let[n,o]of Object.entries(e))if(a(o,w)){let e=S(o),t=r[e];for(let r of(i[e]=n,s[n]={tsName:n,dbName:o[w.Symbol.Name],schema:o[w.Symbol.Schema],columns:o[w.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]},Object.values(o[w.Symbol.Columns])))r.primary&&s[n].primaryKey.push(r);let l=o[w.Symbol.ExtraConfigBuilder]?.(o[w.Symbol.ExtraConfigColumns]);if(l)for(let e of Object.values(l))a(e,el)&&s[n].primaryKey.push(...e.columns)}else if(a(o,ej)){let e,n=S(o.table),a=i[n];for(let[i,l]of Object.entries(o.config(t(o.table))))if(a){let t=s[a];t.relations[i]=l,e&&t.primaryKey.push(...e)}else n in r||(r[n]={relations:{},primaryKey:e}),r[n].relations[i]=l}return{tables:s,tableNamesMap:i}}(t.schema,eF);r={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let n=new il(e,s,r,{logger:i}),o=new ih("sync",s,n,r);return o.$client=e,o}function im(...e){if(void 0===e[0]||"string"==typeof e[0])return id(void 0===e[0]?new s.default:new s.default(e[0]),e[1]);if(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}(e[0])){let{connection:t,client:i,...r}=e[0];if(i)return id(i,r);if("object"==typeof t){let{source:e,...i}=t;return id(new s.default(e,i),r)}return id(new s.default(t),r)}return id(e[0],e[1])}(im||(im={})).mock=function(e){return id({},e)},e.s(["f",0,im],20842);var ip=e.i(66680),ig=e.i(2157);function iy(e){let t=e.migrationsFolder,i=[],r=`${t}/meta/_journal.json`;if(!ig.default.existsSync(r))throw Error("Can't find meta/_journal.json file");for(let e of JSON.parse(ig.default.readFileSync(`${t}/meta/_journal.json`).toString()).entries){let r=`${t}/${e.tag}.sql`;try{let r=ig.default.readFileSync(`${t}/${e.tag}.sql`).toString(),s=r.split("--> statement-breakpoint").map(e=>e);i.push({sql:s,bps:e.breakpoints,folderMillis:e.when,hash:ip.default.createHash("sha256").update(r).digest("hex")})}catch{throw Error(`No file ${r} found in ${t} folder`)}}return i}e.s(["f",0,iy],26889),e.s(["f",0,function(e,t){let i=iy(t);e.dialect.migrate(i,e.session,t)}],94176);let ib=tI("repositories",{id:tf().primaryKey({autoIncrement:!0}),rootPath:tQ("root_path").notNull().unique(),lastScanAt:tf("last_scan_at",{mode:"timestamp"}),lastIndexAt:tf("last_index_at",{mode:"timestamp"}),indexedHead:tQ("indexed_head")}),iw=tI("files",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),kind:tQ("kind",{enum:["component","module"]}).notNull(),contentHash:tQ("content_hash").notNull(),language:tQ("language").notNull().default("typescript"),sizeBytes:tf("size_bytes").notNull().default(0),lineCount:tf("line_count").notNull().default(0),isTest:tf("is_test",{mode:"boolean"}).notNull().default(!1),importSpecifiers:tQ("import_specifiers").notNull().default("[]"),declares:tQ("declares").notNull().default("[]")},e=>[tM("files_repo_path_unique").on(e.repoId,e.path)]),iS=tI("imports",{id:tf().primaryKey({autoIncrement:!0}),sourceFileId:tf("source_file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),targetFileId:tf("target_file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),specifier:tQ("specifier").notNull()},e=>[tM("imports_source_target_unique").on(e.sourceFileId,e.targetFileId),tP("imports_target_idx").on(e.targetFileId)]),i$=tI("chunks",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),chunkId:tQ("chunk_id").notNull(),kind:tQ("kind",{enum:["function","class","component","interface","type","const","enum","namespace","file-summary"]}).notNull(),name:tQ("name").notNull(),nameSplit:tQ("name_split").notNull().default(""),startLine:tf("start_line").notNull(),endLine:tf("end_line").notNull(),exported:tf("exported",{mode:"boolean"}).notNull().default(!1),partIndex:tf("part_index").notNull().default(0),text:tQ("text").notNull(),fileHash:tQ("file_hash").notNull(),createdAt:tf("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[tM("chunks_file_chunk_unique").on(e.fileId,e.chunkId)]),iv=tI("meta",{id:tf().primaryKey({autoIncrement:!0}),key:tQ("key").notNull().unique(),value:tQ("value").notNull(),updatedAt:tf("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date).$onUpdateFn(()=>new Date)}),iN=["function","class","method","property","accessor","constructor","interface","type","enum","const","namespace","struct","trait"],ix=tI("symbols",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),name:tQ("name").notNull(),qualifiedName:tQ("qualified_name").notNull(),kind:tQ("kind",{enum:iN}).notNull(),startLine:tf("start_line").notNull(),endLine:tf("end_line").notNull(),exported:tf("exported",{mode:"boolean"}).notNull().default(!1),parentQualifiedName:tQ("parent_qualified_name")},e=>[tP("symbols_file_idx").on(e.fileId),tP("symbols_name_idx").on(e.name)]),i_=tI("folders",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),parentPath:tQ("parent_path"),depth:tf("depth").notNull(),name:tQ("name").notNull(),fileCount:tf("file_count").notNull(),directFileCount:tf("direct_file_count").notNull()},e=>[tM("folders_repo_path_unique").on(e.repoId,e.path),tP("folders_repo_parent_idx").on(e.repoId,e.parentPath)]),iT=tI("level_edges",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),levelPath:tQ("level_path").notNull(),sourceNode:tQ("source_node").notNull(),targetNode:tQ("target_node").notNull(),count:tf("count").notNull()},e=>[tM("level_edges_unique").on(e.repoId,e.levelPath,e.sourceNode,e.targetNode)]),iC=["file","folder","repo"],iQ=["fresh","stale","pending","failed","skipped"],iq=tI("summaries",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),targetKind:tQ("target_kind",{enum:iC}).notNull(),targetPath:tQ("target_path").notNull(),tagline:tQ("tagline"),summary:tQ("summary"),model:tQ("model"),inputHash:tQ("input_hash"),promptVersion:tf("prompt_version"),status:tQ("status",{enum:iQ}).notNull(),error:tQ("error"),batchId:tQ("batch_id"),pendingHash:tQ("pending_hash"),updatedAt:tf("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[tM("summaries_target_unique").on(e.repoId,e.targetKind,e.targetPath),tP("summaries_batch_idx").on(e.batchId)]),iL=tI("summary_vectors",{id:tf().primaryKey({autoIncrement:!0}),summaryId:tf("summary_id").notNull().unique().references(()=>iq.id,{onDelete:"cascade"}),embedding:tt("embedding",{mode:"buffer"}).notNull()}),iI=tI("summary_usage",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),model:tQ("model").notNull(),transport:tQ("transport",{enum:["direct","batch"]}).notNull(),requests:tf("requests").notNull().default(0),inputTokens:tf("input_tokens").notNull().default(0),outputTokens:tf("output_tokens").notNull().default(0)},e=>[tM("summary_usage_unique").on(e.repoId,e.model,e.transport)]),iB=tI("entry_points",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),declaredBy:tQ("declared_by").notNull()},e=>[tM("entry_points_repo_path_unique").on(e.repoId,e.path)]),iO=tI("docs",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),path:tQ("path").notNull(),title:tQ("title").notNull()},e=>[tM("docs_repo_path_unique").on(e.repoId,e.path)]),iE=["applies","readme","mentions"],ij=tI("doc_links",{id:tf().primaryKey({autoIncrement:!0}),repoId:tf("repo_id").notNull().references(()=>ib.id,{onDelete:"cascade"}),docPath:tQ("doc_path").notNull(),targetPath:tQ("target_path").notNull(),kind:tQ("kind",{enum:iE}).notNull(),count:tf("count").notNull(),detail:tQ("detail")},e=>[tP("doc_links_repo_target_idx").on(e.repoId,e.targetPath)]),iA=["param","local","destructure","constraint","cast","provider","new","alias","field","this","ctor-param","inject-field","super","return","member"],iD=tI("type_decls",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),name:tQ("name"),kind:tQ("kind",{enum:["class","interface"]}).notNull(),line:tf("line").notNull(),exported:tf("exported",{mode:"boolean"}).notNull().default(!1),nested:tf("nested",{mode:"boolean"}).notNull().default(!1),extendsRefs:tQ("extends_refs").notNull().default("[]"),implementsRefs:tQ("implements_refs").notNull().default("[]"),testDoubleOf:tQ("test_double_of"),members:tQ("members").notNull().default("[]"),fields:tQ("fields").notNull().default("{}")},e=>[tP("type_decls_file_idx").on(e.fileId),tP("type_decls_name_idx").on(e.name)]),iF=tI("call_bindings",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),kind:tQ("kind",{enum:["import","reexport","export"]}).notNull(),local:tQ("local").notNull(),imported:tQ("imported").notNull(),specifier:tQ("specifier")},e=>[tP("call_bindings_file_idx").on(e.fileId)]),ik=tI("typed_calls",{id:tf().primaryKey({autoIncrement:!0}),fileId:tf("file_id").notNull().references(()=>iw.id,{onDelete:"cascade"}),line:tf("line").notNull(),member:tQ("member"),receiver:tQ("receiver",{enum:["type","field","this"]}).notNull(),ref:tQ("ref"),inClass:tQ("in_class"),how:tQ("how",{enum:iA}).notNull()},e=>[tP("typed_calls_file_idx").on(e.fileId),tP("typed_calls_member_idx").on(e.member)]);e.s(["CALL_RULES",0,iA,"DOC_LINK_KINDS",0,iE,"META_KEYS",0,{INDEXING_LOCK:"indexing",SUMMARIZING_LOCK:"summarizing"},"SUMMARY_STATUSES",0,iQ,"SUMMARY_TARGET_KINDS",0,iC,"SYMBOL_KINDS",0,iN,"callBindings",0,iF,"chunks",0,i$,"docLinks",0,ij,"docs",0,iO,"entryPoints",0,iB,"files",0,iw,"folders",0,i_,"imports",0,iS,"levelEdges",0,iT,"meta",0,iv,"repositories",0,ib,"summaries",0,iq,"summaryUsage",0,iI,"summaryVectors",0,iL,"symbols",0,ix,"typeDecls",0,iD,"typedCalls",0,ik],14674)}],8314,(e,t,i)=>{t.exports=e.x("typescript-279735412610ef8d",()=>require("typescript-279735412610ef8d"))}];
|
|
9
9
|
|
|
10
10
|
//# sourceMappingURL=%5Broot-of-the-server%5D__1i5e5sqg45ens._.js.map
|