gemi 0.100.0 → 0.101.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.
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{va as j}from"./chunk-8z37k28d.js";import{createElement as x}from"react";function h(i,n){let s=Object.keys(n).sort((u,r)=>r.length-u.length).map((u)=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(s.join("|"),"g");return i.replace(b,(u)=>n[u])}async function J(i,n,s=[]){let b=[...s.map((t)=>`${i}/views/${t}.tsx`),`${i}/views/RootLayout.tsx`],u=new Set;for(let t of b){let e=n.moduleGraph.getModulesByFile(t);if(e)for(let g of e)u.add(g)}let r=[],p=[],l={};for(let t of u)if(t)for(let e of t.importedModules){if(e.file.includes("module.css"))l[e.file]=e.ssrTransformResult.map.sourcesContent.join("");if(e.file.includes(".css"))p.push(e.file)}for(let t of p){let e=await n.transformRequest(t+"?direct"),g=t.includes("module.css"),a="";if(g)a=h(l[t],e.default);r.push({isDev:!0,id:t,content:g?a:e.code})}return r.map((t,e)=>{return x("style",{key:e,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function L(i=[]){return i.map((n,s)=>{return x("style",{key:s,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as v}from"fs";import{basename as f}from"path";import{networkInterfaces as k}from"os";var y={name:"gemi",version:"0.100.0",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*","ide/typescript-plugin/package.json","skills/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./ai":"./ai/index.ts","./ai/client":"./ai/client/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./console/run":"./console/run.ts","./queue/work":"./services/queue/work.ts","./ide/typescript-plugin":"./ide/typescript-plugin/index.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json && tsc --noEmit -p ide/typescript-plugin/tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:ts-plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --external=typescript --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/ai/client dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:ts-plugin":"bun ./scripts/build-ts-plugin.ts","build:types":"tsc -p tsconfig.build.json","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun vitest","test:types":"vitest run --typecheck.only","test:live":"bun --bun vitest run ai/live","test:packaging":"bun --bun vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0",jsdom:"^30.0.1",oxlint:"^1.39.0",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",typescript:">=5",vite:"^8.0.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0},typescript:{optional:!0}}};var q=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],z=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,c=(i,n)=>z?`\x1B[${i}m${n}\x1B[0m`:n,E=(i)=>c("1",i),d=(i)=>c("2",i),o=(i)=>c("36",i),O=(i)=>c("32",i),T=(i)=>c("35",i);function R(){return y.version??"?"}function _(i){for(let n of Object.values(k()))for(let s of n??[])if((s.family==="IPv4"||s.family===4)&&!s.internal)return`http://${s.address}:${i}`;return null}function G(i){return j(i).filter((n)=>v(n)).map((n)=>f(n))}function A(i){let{port:n,rootDir:s}=i,b=`http://localhost:${n}`,u=_(n),r=G(s),p=(t,e)=>` ${O("\u279C")} ${E(t.padEnd(9))}${e}`,l=["",...q.map((t)=>T(t)),"",` ${d("gemi")} ${o(`v${R()}`)}`,"",p("Local:",o(b)),p("Network:",u?o(u):d("unavailable")),p("Env:",r.length?r.join(", "):d("none")),""];console.log(l.join(`
2
+ import{va as j}from"./chunk-8z37k28d.js";import{createElement as x}from"react";function h(i,n){let s=Object.keys(n).sort((u,r)=>r.length-u.length).map((u)=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(s.join("|"),"g");return i.replace(b,(u)=>n[u])}async function J(i,n,s=[]){let b=[...s.map((t)=>`${i}/views/${t}.tsx`),`${i}/views/RootLayout.tsx`],u=new Set;for(let t of b){let e=n.moduleGraph.getModulesByFile(t);if(e)for(let g of e)u.add(g)}let r=[],p=[],l={};for(let t of u)if(t)for(let e of t.importedModules){if(e.file.includes("module.css"))l[e.file]=e.ssrTransformResult.map.sourcesContent.join("");if(e.file.includes(".css"))p.push(e.file)}for(let t of p){let e=await n.transformRequest(t+"?direct"),g=t.includes("module.css"),a="";if(g)a=h(l[t],e.default);r.push({isDev:!0,id:t,content:g?a:e.code})}return r.map((t,e)=>{return x("style",{key:e,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function L(i=[]){return i.map((n,s)=>{return x("style",{key:s,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as v}from"fs";import{basename as f}from"path";import{networkInterfaces as k}from"os";var y={name:"gemi",version:"0.101.0",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*","ide/typescript-plugin/package.json","skills/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./ai":"./ai/index.ts","./ai/client":"./ai/client/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./console/run":"./console/run.ts","./queue/work":"./services/queue/work.ts","./ide/typescript-plugin":"./ide/typescript-plugin/index.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json && tsc --noEmit -p ide/typescript-plugin/tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:ts-plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --external=typescript --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/ai/client dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:ts-plugin":"bun ./scripts/build-ts-plugin.ts","build:types":"tsc -p tsconfig.build.json","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun vitest","test:types":"vitest run --typecheck.only","test:live":"bun --bun vitest run ai/live","test:packaging":"bun --bun vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0",jsdom:"^30.0.1",oxlint:"^1.39.0",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",typescript:">=5",vite:"^8.0.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0},typescript:{optional:!0}}};var q=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],z=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,c=(i,n)=>z?`\x1B[${i}m${n}\x1B[0m`:n,E=(i)=>c("1",i),d=(i)=>c("2",i),o=(i)=>c("36",i),O=(i)=>c("32",i),T=(i)=>c("35",i);function R(){return y.version??"?"}function _(i){for(let n of Object.values(k()))for(let s of n??[])if((s.family==="IPv4"||s.family===4)&&!s.internal)return`http://${s.address}:${i}`;return null}function G(i){return j(i).filter((n)=>v(n)).map((n)=>f(n))}function A(i){let{port:n,rootDir:s}=i,b=`http://localhost:${n}`,u=_(n),r=G(s),p=(t,e)=>` ${O("\u279C")} ${E(t.padEnd(9))}${e}`,l=["",...q.map((t)=>T(t)),"",` ${d("gemi")} ${o(`v${R()}`)}`,"",p("Local:",o(b)),p("Network:",u?o(u):d("unavailable")),p("Env:",r.length?r.join(", "):d("none")),""];console.log(l.join(`
3
3
  `))}
4
4
  export{J as h,L as i,A as j};
5
5
 
6
- //# debugId=72A001EE135212D964756E2164756E21
6
+ //# debugId=2BBAD893EA665AFA64756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "import { existsSync } from \"node:fs\";\nimport { basename } from \"node:path\";\nimport { networkInterfaces } from \"node:os\";\nimport { envFiles } from \"./watchEnv\";\nimport pkg from \"../package.json\";\n\n// \"GEMI\" — ANSI Shadow figlet font.\nconst ART = [\n \" ██████╗ ███████╗███╗ ███╗██╗\",\n \"██╔════╝ ██╔════╝████╗ ████║██║\",\n \"██║ ███╗█████╗ ██╔████╔██║██║\",\n \"██║ ██║██╔══╝ ██║╚██╔╝██║██║\",\n \"╚██████╔╝███████╗██║ ╚═╝ ██║██║\",\n \" ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝\",\n];\n\nconst useColor = Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;\nconst paint = (code: string, text: string) =>\n useColor ? `\\x1b[${code}m${text}\\x1b[0m` : text;\nconst bold = (t: string) => paint(\"1\", t);\nconst dim = (t: string) => paint(\"2\", t);\nconst cyan = (t: string) => paint(\"36\", t);\nconst green = (t: string) => paint(\"32\", t);\nconst magenta = (t: string) => paint(\"35\", t);\n\nfunction gemiVersion(): string {\n return (pkg as { version?: string }).version ?? \"?\";\n}\n\nfunction networkUrl(port: number | string): string | null {\n for (const ifaces of Object.values(networkInterfaces())) {\n for (const iface of ifaces ?? []) {\n // Node <18 reported `family` as the number 4; newer Bun/Node use \"IPv4\".\n const isV4 = iface.family === \"IPv4\" || (iface.family as unknown) === 4;\n if (isV4 && !iface.internal) return `http://${iface.address}:${port}`;\n }\n }\n return null;\n}\n\nfunction loadedEnvFiles(rootDir: string): string[] {\n return envFiles(rootDir)\n .filter((file) => existsSync(file))\n .map((file) => basename(file));\n}\n\nexport function printStartupBanner(params: {\n port: number | string;\n rootDir: string;\n}) {\n const { port, rootDir } = params;\n const local = `http://localhost:${port}`;\n const network = networkUrl(port);\n const env = loadedEnvFiles(rootDir);\n\n const row = (label: string, value: string) =>\n ` ${green(\"➜\")} ${bold(label.padEnd(9))}${value}`;\n\n const out = [\n \"\",\n ...ART.map((line) => magenta(line)),\n \"\",\n ` ${dim(\"gemi\")} ${cyan(`v${gemiVersion()}`)}`,\n \"\",\n row(\"Local:\", cyan(local)),\n row(\"Network:\", network ? cyan(network) : dim(\"unavailable\")),\n row(\"Env:\", env.length ? env.join(\", \") : dim(\"none\")),\n \"\",\n ];\n\n console.log(out.join(\"\\n\"));\n}\n"
7
7
  ],
8
8
  "mappings": ";yCAAA,wBAAS,cAGT,SAAS,CAAc,CAAC,EAAc,EAAwC,CAC5E,IAAM,EAAc,OAAO,KAAK,CAAM,EACnC,KAAK,CAAC,EAAG,IAAM,EAAE,OAAS,EAAE,MAAM,EAClC,IAAI,CAAC,IAAQ,EAAI,QAAQ,sBAAuB,MAAM,CAAC,EAGpD,EAAQ,IAAI,OAAO,EAAY,KAAK,GAAG,EAAG,GAAG,EAEnD,OAAO,EAAK,QAAQ,EAAO,CAAC,IAAU,EAAO,EAAM,EAGrD,eAAsB,CAAe,CACnC,EACA,EACA,EAAyB,CAAC,EAC1B,CACA,IAAM,EAAQ,CACZ,GAAG,EAAa,IAAI,CAAC,IAAS,GAAG,WAAgB,OAAU,EAC3D,GAAG,wBACL,EAEM,EAAU,IAAI,IACpB,QAAW,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAK,YAAY,iBAAiB,CAAI,EAClD,GAAI,EACF,QAAW,KAAK,EAAK,EAAQ,IAAI,CAAC,EAItC,IAAM,EAAS,CAAC,EACV,EAAa,CAAC,EACd,EAA2C,CAAC,EAClD,QAAW,KAAO,EAChB,GAAI,EACF,QAAW,KAAY,EAAI,gBAAiB,CAC1C,GAAI,EAAS,KAAK,SAAS,YAAY,EACrC,EAAiB,EAAS,MAAQ,EAAS,mBAAmB,IAAI,eAAe,KAAK,EAAE,EAE1F,GAAI,EAAS,KAAK,SAAS,MAAM,EAC/B,EAAW,KAAK,EAAS,IAAI,EAMrC,QAAW,KAAiB,EAAY,CACtC,IAAM,EAAY,MAAM,EAAK,iBAAiB,EAAgB,SAAS,EAEjE,EAAc,EAAc,SAAS,YAAY,EAEnD,EAAuB,GAE3B,GAAI,EACF,EAAuB,EACrB,EAAiB,GAGhB,EAA6D,OAChE,EAGF,EAAO,KAAK,CACV,MAAO,GACP,GAAI,EACJ,QAAS,EAAc,EAAuB,EAAU,IAC1D,CAAC,EAGH,OAAO,EAAO,IAAI,CAAC,EAAO,IAAM,CAC9B,OAAO,EAAc,QAAS,CAC5B,IAAK,EACL,KAAM,WACN,mBAAoB,EAAM,GAC1B,wBAAyB,CAAE,OAAQ,EAAM,OAAQ,CACnD,CAAC,EACF,EAGH,eAAsB,CAAY,CAAC,EAAS,CAAC,EAAG,CAC9C,OAAO,EAAO,IAAI,CAAC,EAAO,IAAM,CAC9B,OAAO,EAAc,QAAS,CAC5B,IAAK,EACL,GAAI,GAAO,GACX,KAAM,WACN,wBAAyB,CAAE,OAAQ,EAAM,OAAQ,CACnD,CAAC,EACF,ECzFH,qBAAS,WACT,mBAAS,aACT,4BAAS,ipHAKT,IAAM,EAAM,CACV,oKACA,mLACA,yKACA,oKACA,mLACA,yJACF,EAEM,EAAW,QAAQ,QAAQ,OAAO,KAAK,GAAK,CAAC,QAAQ,IAAI,SACzD,EAAQ,CAAC,EAAc,IAC3B,EAAW,QAAQ,KAAQ,WAAgB,EACvC,EAAO,CAAC,IAAc,EAAM,IAAK,CAAC,EAClC,EAAM,CAAC,IAAc,EAAM,IAAK,CAAC,EACjC,EAAO,CAAC,IAAc,EAAM,KAAM,CAAC,EACnC,EAAQ,CAAC,IAAc,EAAM,KAAM,CAAC,EACpC,EAAU,CAAC,IAAc,EAAM,KAAM,CAAC,EAE5C,SAAS,CAAW,EAAW,CAC7B,OAAQ,EAA6B,SAAW,IAGlD,SAAS,CAAU,CAAC,EAAsC,CACxD,QAAW,KAAU,OAAO,OAAO,EAAkB,CAAC,EACpD,QAAW,KAAS,GAAU,CAAC,EAG7B,IADa,EAAM,SAAW,QAAW,EAAM,SAAuB,IAC1D,CAAC,EAAM,SAAU,MAAO,UAAU,EAAM,WAAW,IAGnE,OAAO,KAGT,SAAS,CAAc,CAAC,EAA2B,CACjD,OAAO,EAAS,CAAO,EACpB,OAAO,CAAC,IAAS,EAAW,CAAI,CAAC,EACjC,IAAI,CAAC,IAAS,EAAS,CAAI,CAAC,EAG1B,SAAS,CAAkB,CAAC,EAGhC,CACD,IAAQ,OAAM,WAAY,EACpB,EAAQ,oBAAoB,IAC5B,EAAU,EAAW,CAAI,EACzB,EAAM,EAAe,CAAO,EAE5B,EAAM,CAAC,EAAe,IAC1B,KAAK,EAAM,QAAE,MAAM,EAAK,EAAM,OAAO,CAAC,CAAC,IAAI,IAEvC,EAAM,CACV,GACA,GAAG,EAAI,IAAI,CAAC,IAAS,EAAQ,CAAI,CAAC,EAClC,GACA,KAAK,EAAI,MAAM,KAAK,EAAK,IAAI,EAAY,GAAG,IAC5C,GACA,EAAI,SAAU,EAAK,CAAK,CAAC,EACzB,EAAI,WAAY,EAAU,EAAK,CAAO,EAAI,EAAI,aAAa,CAAC,EAC5D,EAAI,OAAQ,EAAI,OAAS,EAAI,KAAK,IAAI,EAAI,EAAI,MAAM,CAAC,EACrD,EACF,EAEA,QAAQ,IAAI,EAAI,KAAK;AAAA,CAAI,CAAC",
9
- "debugId": "72A001EE135212D964756E2164756E21",
9
+ "debugId": "2BBAD893EA665AFA64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{i as B,j as e}from"./chunk-kgckt396.js";import{ka as D,oa as I,pa as r}from"./chunk-zq5m4scz.js";import"./chunk-8z37k28d.js";import{hc as c,ud as o,vd as P}from"./chunk-rc4z7ykq.js";import"./chunk-bf1q3m7a.js";import"./chunk-adm5g1v8.js";import{Se as f,Te as u,We as m}from"./chunk-h15bd9vn.js";import{Bf as n}from"./chunk-9xf2fx98.js";import"./chunk-eqtsfvvd.js";import"./chunk-br9p390p.js";import"./chunk-n4807648.js";import"./chunk-ghz3e8b7.js";import"./chunk-7vjbebst.js";import"./chunk-3fr22rtg.js";import"./chunk-qttatc7h.js";import"./chunk-48dek9s7.js";import"./chunk-f6s7ddjz.js";import{Wg as a}from"./chunk-n63xjrck.js";import{Xg as _}from"./chunk-2tm56xq1.js";import"./chunk-68zf43ah.js";import{join as M,resolve as yJ,sep as vJ}from"path";import{Duplex as KJ}from"stream";import{constants as L,createBrotliCompress as OJ,createGzip as YJ}from"zlib";var UJ=["br","gzip"],xJ=1024,VJ=5,IJ=19,CJ=6;function LJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function AJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let X of J.split(",")){let[Z,...Q]=X.split(";"),W=Z.trim().toLowerCase();if(W==="")continue;let j=1;for(let G of Q){let Y=G.indexOf("=");if(Y===-1)continue;if(G.slice(0,Y).trim().toLowerCase()==="q"){j=LJ(G.slice(Y+1));break}}$.set(W,j)}return $}function PJ(J,$=UJ){let X=AJ(J);if(!X)return null;let Z=X.get("*"),Q=null,W=0;for(let j of $){let G=X.get(j)??Z??0;if(G>W)Q=j,W=G}return Q}function _J(J,$){if(!J)return!1;return J.split(",").some((X)=>X.trim().toLowerCase().split("=")[0].trim()===$)}function SJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let X=$.headers.get("Content-Type");if(!X||!/^\s*text\/html\s*(;|$)/i.test(X))return!1;if(!$.body)return!1;let Z=$.headers.get("Content-Encoding");if(Z&&Z.trim().toLowerCase()!=="identity")return!1;if(_J($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<xJ)return!1;return!0}function TJ(J){let $=J==="br"?OJ({params:{[L.BROTLI_PARAM_QUALITY]:VJ,[L.BROTLI_PARAM_LGWIN]:IJ},flush:L.BROTLI_OPERATION_FLUSH}):YJ({level:CJ,flush:L.Z_SYNC_FLUSH});return KJ.toWeb($)}function DJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let X=$.split(",").map((Z)=>Z.trim().toLowerCase());if(X.includes("*")||X.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function g(J,$){if(!SJ(J.method,$))return $;let X=new Headers($.headers);DJ(X);let Z=PJ(J.headers.get("Accept-Encoding"));if(!Z)return new Response($.body,{status:$.status,statusText:$.statusText,headers:X});let Q;try{Q=TJ(Z)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:X})}return X.set("Content-Encoding",Z),X.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:X})}import{readdir as FJ,stat as NJ}from"fs/promises";import{join as BJ}from"path";function w(J){let $=J.toString(),X=new Bun.CryptoHasher("sha1");return X.update($),X.digest("hex")}async function h(J){let $=new Set;async function X(Z,Q){let W;try{W=await FJ(Z,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let G=BJ(Z,j.name),Y=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let C=await NJ(G);Y=C.isDirectory(),V=C.isFile()}catch{continue}if(V)$.add(G);else if(Y&&!j.isSymbolicLink())await X(G,!1)}}return await X(J,!0),$}var bJ="public, max-age=31536000, must-revalidate";function p(J,$){let X=Bun.file($),Z=X.size,Q=w(X.lastModified),W={"Content-Type":X.type||"application/octet-stream","Cache-Control":bJ,"Accept-Ranges":"bytes",ETag:Q},j=f(J.headers.get("Range"));if(j){let G=u(j,Z);if(!G)return c(Z);return new Response(X.slice(G.start,G.end+1).stream(),{status:206,headers:{...W,"Content-Range":m(G.start,G.end,Z),"Content-Length":String(G.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Z)}})}import{stat as EJ}from"fs/promises";var A="app/client.tsx";function d(J,$=D){let X=J[A]?.file;if(!X)return;return{module:I(X,$),preload:F(J,A,$)}}function F(J,$,X=D){let Z=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let G=J[j];if(!G?.file)return;Z.push(I(G.file,X));for(let Y of G.imports??[])W(Y)};return W($),Z}function l(J,$=30000){let X=JSON.stringify("gemi:chunk-reload"),Z=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${X})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${X},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${Z});export {}`}var MJ=new RegExp(`^${o}/.+\\.m?js$`);function qJ(J){return MJ.test(J)}function i(J){if(qJ(J))return new Response(l(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(P(J))return new Response("Not found",{status:404});return}var RJ=`<!DOCTYPE html>
2
+ import{i as B,j as e}from"./chunk-jyswmx60.js";import{ka as D,oa as I,pa as r}from"./chunk-zq5m4scz.js";import"./chunk-8z37k28d.js";import{hc as c,ud as o,vd as P}from"./chunk-d6prwkff.js";import"./chunk-bf1q3m7a.js";import"./chunk-adm5g1v8.js";import{Se as f,Te as u,We as m}from"./chunk-4x41cmg3.js";import{Bf as n}from"./chunk-9xf2fx98.js";import"./chunk-eqtsfvvd.js";import"./chunk-br9p390p.js";import"./chunk-n4807648.js";import"./chunk-ghz3e8b7.js";import"./chunk-7vjbebst.js";import"./chunk-3fr22rtg.js";import"./chunk-qttatc7h.js";import"./chunk-48dek9s7.js";import"./chunk-f6s7ddjz.js";import{Wg as a}from"./chunk-n63xjrck.js";import{Xg as _}from"./chunk-2tm56xq1.js";import"./chunk-68zf43ah.js";import{join as M,resolve as yJ,sep as vJ}from"path";import{Duplex as KJ}from"stream";import{constants as L,createBrotliCompress as OJ,createGzip as YJ}from"zlib";var UJ=["br","gzip"],xJ=1024,VJ=5,IJ=19,CJ=6;function LJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function AJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let X of J.split(",")){let[Z,...Q]=X.split(";"),W=Z.trim().toLowerCase();if(W==="")continue;let j=1;for(let G of Q){let Y=G.indexOf("=");if(Y===-1)continue;if(G.slice(0,Y).trim().toLowerCase()==="q"){j=LJ(G.slice(Y+1));break}}$.set(W,j)}return $}function PJ(J,$=UJ){let X=AJ(J);if(!X)return null;let Z=X.get("*"),Q=null,W=0;for(let j of $){let G=X.get(j)??Z??0;if(G>W)Q=j,W=G}return Q}function _J(J,$){if(!J)return!1;return J.split(",").some((X)=>X.trim().toLowerCase().split("=")[0].trim()===$)}function SJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let X=$.headers.get("Content-Type");if(!X||!/^\s*text\/html\s*(;|$)/i.test(X))return!1;if(!$.body)return!1;let Z=$.headers.get("Content-Encoding");if(Z&&Z.trim().toLowerCase()!=="identity")return!1;if(_J($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<xJ)return!1;return!0}function TJ(J){let $=J==="br"?OJ({params:{[L.BROTLI_PARAM_QUALITY]:VJ,[L.BROTLI_PARAM_LGWIN]:IJ},flush:L.BROTLI_OPERATION_FLUSH}):YJ({level:CJ,flush:L.Z_SYNC_FLUSH});return KJ.toWeb($)}function DJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let X=$.split(",").map((Z)=>Z.trim().toLowerCase());if(X.includes("*")||X.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function g(J,$){if(!SJ(J.method,$))return $;let X=new Headers($.headers);DJ(X);let Z=PJ(J.headers.get("Accept-Encoding"));if(!Z)return new Response($.body,{status:$.status,statusText:$.statusText,headers:X});let Q;try{Q=TJ(Z)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:X})}return X.set("Content-Encoding",Z),X.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:X})}import{readdir as FJ,stat as NJ}from"fs/promises";import{join as BJ}from"path";function w(J){let $=J.toString(),X=new Bun.CryptoHasher("sha1");return X.update($),X.digest("hex")}async function h(J){let $=new Set;async function X(Z,Q){let W;try{W=await FJ(Z,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let G=BJ(Z,j.name),Y=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let C=await NJ(G);Y=C.isDirectory(),V=C.isFile()}catch{continue}if(V)$.add(G);else if(Y&&!j.isSymbolicLink())await X(G,!1)}}return await X(J,!0),$}var bJ="public, max-age=31536000, must-revalidate";function p(J,$){let X=Bun.file($),Z=X.size,Q=w(X.lastModified),W={"Content-Type":X.type||"application/octet-stream","Cache-Control":bJ,"Accept-Ranges":"bytes",ETag:Q},j=f(J.headers.get("Range"));if(j){let G=u(j,Z);if(!G)return c(Z);return new Response(X.slice(G.start,G.end+1).stream(),{status:206,headers:{...W,"Content-Range":m(G.start,G.end,Z),"Content-Length":String(G.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Z)}})}import{stat as EJ}from"fs/promises";var A="app/client.tsx";function d(J,$=D){let X=J[A]?.file;if(!X)return;return{module:I(X,$),preload:F(J,A,$)}}function F(J,$,X=D){let Z=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let G=J[j];if(!G?.file)return;Z.push(I(G.file,X));for(let Y of G.imports??[])W(Y)};return W($),Z}function l(J,$=30000){let X=JSON.stringify("gemi:chunk-reload"),Z=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${X})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${X},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${Z});export {}`}var MJ=new RegExp(`^${o}/.+\\.m?js$`);function qJ(J){return MJ.test(J)}function i(J){if(qJ(J))return new Response(l(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(P(J))return new Response("Not found",{status:404});return}var RJ=`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8" />
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{h as N,j as q}from"./chunk-kgckt396.js";import{ia as E,ja as w}from"./chunk-53we503k.js";import"./chunk-zq5m4scz.js";import"./chunk-9a8qz3s7.js";import"./chunk-gvkydx8r.js";import"./chunk-8z37k28d.js";import"./chunk-xp6nr441.js";import{Bf as _}from"./chunk-9xf2fx98.js";import{Xg as y}from"./chunk-2tm56xq1.js";import"./chunk-68zf43ah.js";import{join as KJ}from"path";import{createServer as QJ}from"vite";import{join as u}from"path";import{IncomingMessage as v,ServerResponse as l}from"http";import{Socket as d}from"net";function c(J){return J.replace(/\x1b\[[0-9;]*m/g,"").replace(/\[[0-9;]*m/g,"").replace(/\n\s*\n/g,`
2
+ import{h as N,j as q}from"./chunk-jyswmx60.js";import{ia as E,ja as w}from"./chunk-53we503k.js";import"./chunk-zq5m4scz.js";import"./chunk-9a8qz3s7.js";import"./chunk-gvkydx8r.js";import"./chunk-8z37k28d.js";import"./chunk-xp6nr441.js";import{Bf as _}from"./chunk-9xf2fx98.js";import{Xg as y}from"./chunk-2tm56xq1.js";import"./chunk-68zf43ah.js";import{join as KJ}from"path";import{createServer as QJ}from"vite";import{join as u}from"path";import{IncomingMessage as v,ServerResponse as l}from"http";import{Socket as d}from"net";function c(J){return J.replace(/\x1b\[[0-9;]*m/g,"").replace(/\[[0-9;]*m/g,"").replace(/\n\s*\n/g,`
3
3
  `).split(`
4
4
  `).map((K)=>K.trim()).filter((K)=>K.length>0).join(`
5
5
  `).trim()}function F(J){return`
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Lc as c,Mc as d,Nc as f,Oc as g,Pc as i,Qc as j,Rc as k,Sc as l,Tc as m,fd as n,gd as o,hd as p,mc as a}from"../chunk-rc4z7ykq.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import{lf as b,tf as e,vf as h}from"../chunk-h15bd9vn.js";import"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import"../chunk-qttatc7h.js";import"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";export{g as Url,e as Storage,k as Redis,a as Redirect,l as RateLimiter,f as Query,i as Meta,h as Log,m as Lock,d as Lang,n as Features,b as Facade,p as DB,j as Cookie,o as ConnectionQueries,c as Auth};
2
+ import{Lc as c,Mc as d,Nc as f,Oc as g,Pc as i,Qc as j,Rc as k,Sc as l,Tc as m,fd as n,gd as o,hd as p,mc as a}from"../chunk-d6prwkff.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import{lf as b,tf as e,vf as h}from"../chunk-4x41cmg3.js";import"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import"../chunk-qttatc7h.js";import"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";export{g as Url,e as Storage,k as Redis,a as Redirect,l as RateLimiter,f as Query,i as Meta,h as Log,m as Lock,d as Lang,n as Features,b as Facade,p as DB,j as Cookie,o as ConnectionQueries,c as Auth};
3
3
 
4
4
  //# debugId=0905CD6AC3F7D4D564756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ac as H,Fd as I,Gd as J,Hd as K,Id as L,Jd as M,Kd as N,gc as n,hc as o,ic as p,jc as v,kc as w,lc as x,nc as y,oc as z,pc as A,qc as B,rc as C,sc as D,tc as E,yc as F,zc as G}from"../chunk-rc4z7ykq.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import{Me as a,Ne as b,Oe as d,Se as e,Te as f,Ue as g,Ve as h,We as i,Xe as j,af as k,bf as l,ff as m,gf as q,hf as r,if as s,jf as t,kf as u}from"../chunk-h15bd9vn.js";import{zf as c}from"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import"../chunk-qttatc7h.js";import"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";export{g as toRangeHeaderValue,n as toMiddlewareList,f as resolveRange,e as parseRangeHeader,h as parseContentRange,E as middlewareConfigDefaults,z as httpError,d as getCookies,j as formatUnsatisfiedContentRange,i as formatContentRange,D as defineMiddlewareConfig,o as createUnsatisfiableResponse,p as createStreamResponse,A as createFileResponse,H as clientIp,B as ViewRouter,k as ValidationError,b as ResourceController,c as RequestBreakerError,G as RateLimitMiddleware,F as RateLimitExceededError,s as RangeNotSatisfiableError,M as PoliciesServiceProvider,N as Policies,C as Middleware,x as McpRouter,w as McpRouteDeclaration,l as InvalidValidationRuleError,r as InsufficientPermissionsError,y as HttpResponse,m as HttpRequest,t as FileNotFoundError,K as CorsMiddleware,a as Controller,J as CacheMiddleware,L as CSRFMiddleware,q as AuthorizationError,I as AuthenticationMiddleware,u as AuthenticationError,v as ApiRouter};
2
+ import{Ac as H,Fd as I,Gd as J,Hd as K,Id as L,Jd as M,Kd as N,gc as n,hc as o,ic as p,jc as v,kc as w,lc as x,nc as y,oc as z,pc as A,qc as B,rc as C,sc as D,tc as E,yc as F,zc as G}from"../chunk-d6prwkff.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import{Me as a,Ne as b,Oe as d,Se as e,Te as f,Ue as g,Ve as h,We as i,Xe as j,af as k,bf as l,ff as m,gf as q,hf as r,if as s,jf as t,kf as u}from"../chunk-4x41cmg3.js";import{zf as c}from"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import"../chunk-qttatc7h.js";import"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";export{g as toRangeHeaderValue,n as toMiddlewareList,f as resolveRange,e as parseRangeHeader,h as parseContentRange,E as middlewareConfigDefaults,z as httpError,d as getCookies,j as formatUnsatisfiedContentRange,i as formatContentRange,D as defineMiddlewareConfig,o as createUnsatisfiableResponse,p as createStreamResponse,A as createFileResponse,H as clientIp,B as ViewRouter,k as ValidationError,b as ResourceController,c as RequestBreakerError,G as RateLimitMiddleware,F as RateLimitExceededError,s as RangeNotSatisfiableError,M as PoliciesServiceProvider,N as Policies,C as Middleware,x as McpRouter,w as McpRouteDeclaration,l as InvalidValidationRuleError,r as InsufficientPermissionsError,y as HttpResponse,m as HttpRequest,t as FileNotFoundError,K as CorsMiddleware,a as Controller,J as CacheMiddleware,L as CSRFMiddleware,q as AuthorizationError,I as AuthenticationMiddleware,u as AuthenticationError,v as ApiRouter};
3
3
 
4
4
  //# debugId=40862F9DA4E1987764756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{aa as w}from"../chunk-mekw2ap4.js";import"../chunk-9a8qz3s7.js";import{Wa as b}from"../chunk-yhkffean.js";import{dc as R,ec as S}from"../chunk-f9t39vwk.js";import"../chunk-7kedxtbp.js";import{Mc as j}from"../chunk-rc4z7ykq.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import"../chunk-h15bd9vn.js";import"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import{Dg as X,Eg as E,Fg as V,Gg as L}from"../chunk-qttatc7h.js";import"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";import{createElement as J,Fragment as M,isValidElement as U}from"react";function $(q,B){let G=Object.values(B).some((z)=>typeof z==="function"&&U(z(""))),Q=/{{([^{}]+?)(?::([^{}\[\]]+?))?(?:\[(.*?)\])?}}/g;if(!G)return q.replace(Q,(W,O,_,Z)=>{let C=O.includes(":")?O.split(":")[0]:O,H=B[C];if(H===void 0)return W;if(typeof H==="function"){let K=H(Z!==void 0?Z:"");if(U(K))throw Error("JSX returned in string context");return String(K)}if(_)switch(_.toLowerCase()){case"number":return Number(H).toString();case"string":return String(H);case"boolean":return Boolean(H).toString();default:return String(H)}return String(H)});else{let z=[],W=0,O=null;while((O=Q.exec(q))!==null){let[_,Z,C,H]=O,F=O.index,K=Z.includes(":")?Z.split(":")[0]:Z;if(F>W)z.push(q.substring(W,F));let Y=B[K];if(Y===void 0)z.push(_);else if(typeof Y==="function"){let A=Y(H!==void 0?H:"");z.push(A)}else if(C)switch(C.toLowerCase()){case"number":z.push(Number(Y).toString());break;case"string":z.push(String(Y));break;case"boolean":z.push(Boolean(Y).toString());break;default:z.push(String(Y))}else z.push(String(Y));W=F+_.length}if(W<q.length)z.push(q.substring(W));return J(M,{},...z)}}class P{name;dictionary;constructor(q,B){this.name=q;this.dictionary=B}reference(q){if(typeof window<"u")throw Error("Cannot use reference in the browser");if(!this.dictionary?.[q])throw Error(`Translation not found for ${String(q)}`);return this.dictionary[q]}render(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B[0]};if(typeof window<"u")throw Error("Cannot use render in the browser");if(!this.dictionary?.[q]?.[G])throw Error(`Translation not found for ${String(q)} in ${String(G)}`);return $(this.dictionary[q][G],Q??{})}static create(q,B){return new P(q,B)}static text(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B?.[0]};if(!q?.[G])throw Error(`Translation not found for ${String(G)}`);return $(q[G],Q??{})}}async function N(q,B,...G){let{locale:Q=j.locale(),params:z}={params:{},...G[0]},O=(await q.load(String(Q)))[B];if(typeof O!=="string")throw Error(`Translation not found for "${B}" in "${String(Q)}" (dictionary ${q.id})`);return $(O,z??{})}export{S as translationConfigDefaults,N as translate,E as isValidTimeZone,R as defineTranslationConfig,w as defineDictionary,V as createFormatter,L as Translator,b as TranslationServiceProvider,P as Dictionary,X as DEFAULT_TIME_ZONE};
2
+ import{aa as w}from"../chunk-mekw2ap4.js";import"../chunk-9a8qz3s7.js";import{Wa as b}from"../chunk-yhkffean.js";import{dc as R,ec as S}from"../chunk-f9t39vwk.js";import"../chunk-7kedxtbp.js";import{Mc as j}from"../chunk-d6prwkff.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import"../chunk-4x41cmg3.js";import"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import{Dg as X,Eg as E,Fg as V,Gg as L}from"../chunk-qttatc7h.js";import"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";import{createElement as J,Fragment as M,isValidElement as U}from"react";function $(q,B){let G=Object.values(B).some((z)=>typeof z==="function"&&U(z(""))),Q=/{{([^{}]+?)(?::([^{}\[\]]+?))?(?:\[(.*?)\])?}}/g;if(!G)return q.replace(Q,(W,O,_,Z)=>{let C=O.includes(":")?O.split(":")[0]:O,H=B[C];if(H===void 0)return W;if(typeof H==="function"){let K=H(Z!==void 0?Z:"");if(U(K))throw Error("JSX returned in string context");return String(K)}if(_)switch(_.toLowerCase()){case"number":return Number(H).toString();case"string":return String(H);case"boolean":return Boolean(H).toString();default:return String(H)}return String(H)});else{let z=[],W=0,O=null;while((O=Q.exec(q))!==null){let[_,Z,C,H]=O,F=O.index,K=Z.includes(":")?Z.split(":")[0]:Z;if(F>W)z.push(q.substring(W,F));let Y=B[K];if(Y===void 0)z.push(_);else if(typeof Y==="function"){let A=Y(H!==void 0?H:"");z.push(A)}else if(C)switch(C.toLowerCase()){case"number":z.push(Number(Y).toString());break;case"string":z.push(String(Y));break;case"boolean":z.push(Boolean(Y).toString());break;default:z.push(String(Y))}else z.push(String(Y));W=F+_.length}if(W<q.length)z.push(q.substring(W));return J(M,{},...z)}}class P{name;dictionary;constructor(q,B){this.name=q;this.dictionary=B}reference(q){if(typeof window<"u")throw Error("Cannot use reference in the browser");if(!this.dictionary?.[q])throw Error(`Translation not found for ${String(q)}`);return this.dictionary[q]}render(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B[0]};if(typeof window<"u")throw Error("Cannot use render in the browser");if(!this.dictionary?.[q]?.[G])throw Error(`Translation not found for ${String(q)} in ${String(G)}`);return $(this.dictionary[q][G],Q??{})}static create(q,B){return new P(q,B)}static text(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B?.[0]};if(!q?.[G])throw Error(`Translation not found for ${String(G)}`);return $(q[G],Q??{})}}async function N(q,B,...G){let{locale:Q=j.locale(),params:z}={params:{},...G[0]},O=(await q.load(String(Q)))[B];if(typeof O!=="string")throw Error(`Translation not found for "${B}" in "${String(Q)}" (dictionary ${q.id})`);return $(O,z??{})}export{S as translationConfigDefaults,N as translate,E as isValidTimeZone,R as defineTranslationConfig,w as defineDictionary,V as createFormatter,L as Translator,b as TranslationServiceProvider,P as Dictionary,X as DEFAULT_TIME_ZONE};
3
3
 
4
4
  //# debugId=57FB2330D198750F64756E2164756E21
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ya as y}from"../chunk-epwaxctc.js";import{Va as i}from"../chunk-pjg7gqnh.js";import{Wa as g}from"../chunk-yhkffean.js";import{$a as e,Za as T,_a as D,ab as A,bb as w,fb as P,gb as S,ib as h,jb as R,kb as u,lb as l,ob as v,pb as d,sb as c,vb as p,yb as n}from"../chunk-jv38q9n7.js";import"../chunk-wc46df4w.js";import"../chunk-3tn480wt.js";import{_b as r}from"../chunk-z8jf7jwg.js";import"../chunk-f9t39vwk.js";import"../chunk-7kedxtbp.js";import{Ad as m,Bd as Q,Cd as t,Dd as o,Fc as Zj,Gc as $j,Jc as Gj,Kc as Hj,nd as x,sd as I,td as E,wd as K,xd as M,yd as s,zd as C}from"../chunk-rc4z7ykq.js";import{Od as a}from"../chunk-bf1q3m7a.js";import{$d as V,ee as f}from"../chunk-adm5g1v8.js";import{ff as F}from"../chunk-h15bd9vn.js";import{yf as B}from"../chunk-9xf2fx98.js";import{Ef as L}from"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import"../chunk-77kw61f4.js";import"../chunk-qttatc7h.js";import{Hg as _,Jg as N,Kg as b}from"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-xmjhensy.js";import"../chunk-n63xjrck.js";import{Xg as q}from"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";function Jj(j){let X=j.headers.get("Cache-Control")?.toLowerCase()??"";return/(^|[\s,])(public|s-maxage)\b/.test(X)}var Wj=new Set,Xj={refusal:null,apply:(j)=>j,carried:null};async function k(j){let X=b(x);if(X.config.global.length===0)return Xj;let{pathname:Z}=new URL(j.url),W=q(Z),z=new F(j,{},W?"api":"view","");return await L.run(z,async()=>{let $=L.getStore(),{headers:H,cookies:zj}=$,Y=(J)=>{if(!Jj(J))return Q(J,H,zj);let G=new Headers(H);return G.delete("Set-Cookie"),Q(J,G,Wj)};try{return await X.runGlobalMiddleware(),{refusal:null,apply:Y,carried:{user:$.user}}}catch(J){let G=!W&&Z.endsWith(".json");if(J?.kind===B){let O=W?m(J.payload.api):G?M(J.payload.viewData??J.payload.api):K(J.payload.view);return{refusal:Y(O),apply:Y,carried:null}}if(V(J)&&(W||G))return{refusal:Y(C()),apply:Y,carried:null};if(f(J)){console.error(J);let O=W||G?I():K(E());return{refusal:Y(O),apply:Y,carried:null}}throw J}finally{$.destroy()}})}var U=[l,d,y,P,n,A,S,v,R,D,h,p,u,g,c,w];class jj{config={};providers=[];services=[];serviceInstances=[];serviceTokens=new Set;servicesBooted=!1;models=[];app=new N;boot(){if(this.models.length>0)i(...this.models);else Yj();this.app.config.merge(this.config),N.setInstance(this.app),this.app.registerMany([...U,...this.providers]),this.registerServices()}registerServices(){let j=this.serviceTokens;this.serviceInstances=[],this.serviceTokens=new Set,this.servicesBooted=!1;let X=new Map;for(let Z of this.services){let W=typeof Z==="function"?new Z:Z,z=W.constructor;if(!z.token)throw Error(`Service [${z.name}] is listed in \`services\` but does not declare a \`static token\`.`);let $=X.get(z.token);if($)throw Error(`Services [${$}] and [${z.name}] both declare the token "${z.token}". Tokens are the container's keys, so they must be unique.`);X.set(z.token,z.name);let H=z;if(!j.has(z.token)&&this.app.bound(H))throw Error(`Service [${z.name}] declares the token "${z.token}", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`);this.app.instance(H,W),this.serviceInstances.push(W),this.serviceTokens.add(z.token)}}async waitForBoot(){await this.app.boot(),await this.bootServices(),e(this.app)}async bootServices(){if(this.servicesBooted)return;for(let j of this.serviceInstances)await j.boot();this.servicesBooted=!0}shutdown(j){return this.run(()=>this.app.shutdown(j))}run(j){return _.run(this.app,j)}resolve(j){return this.app.make(j)}apiRoutes(){return this.app.make(t)}viewRoutes(){return this.app.make(s)}domains(){return this.app.make(o)}queue(){return this.app.make(r)}globalMiddleware(j){return k(j)}destroy(){if(this.app.resolved(T))this.app.make(T).stop();if(this.app.flush(),N.getInstance()===this.app)N.setInstance(void 0);_.disable()}}function Yj(){if(Bun.env.NODE_ENV==="production")return;let j=a();if(j.length===0)return;console.warn(`[gemi] ${j.length} model${j.length===1?" is":"s are"} registered, but Kernel.models is empty.
2
+ import{ya as y}from"../chunk-epwaxctc.js";import{Va as i}from"../chunk-pjg7gqnh.js";import{Wa as g}from"../chunk-yhkffean.js";import{$a as e,Za as T,_a as D,ab as A,bb as w,fb as P,gb as S,ib as h,jb as R,kb as u,lb as l,ob as v,pb as d,sb as c,vb as p,yb as n}from"../chunk-8v5z6646.js";import"../chunk-wc46df4w.js";import"../chunk-3tn480wt.js";import{_b as r}from"../chunk-z8jf7jwg.js";import"../chunk-f9t39vwk.js";import"../chunk-7kedxtbp.js";import{Ad as m,Bd as Q,Cd as t,Dd as o,Fc as Zj,Gc as $j,Jc as Gj,Kc as Hj,nd as x,sd as I,td as E,wd as K,xd as M,yd as s,zd as C}from"../chunk-d6prwkff.js";import{Od as a}from"../chunk-bf1q3m7a.js";import{$d as V,ee as f}from"../chunk-adm5g1v8.js";import{ff as F}from"../chunk-4x41cmg3.js";import{yf as B}from"../chunk-9xf2fx98.js";import{Ef as L}from"../chunk-eqtsfvvd.js";import"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import"../chunk-77kw61f4.js";import"../chunk-qttatc7h.js";import{Hg as _,Jg as N,Kg as b}from"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-xmjhensy.js";import"../chunk-n63xjrck.js";import{Xg as q}from"../chunk-2tm56xq1.js";import"../chunk-68zf43ah.js";function Jj(j){let X=j.headers.get("Cache-Control")?.toLowerCase()??"";return/(^|[\s,])(public|s-maxage)\b/.test(X)}var Wj=new Set,Xj={refusal:null,apply:(j)=>j,carried:null};async function k(j){let X=b(x);if(X.config.global.length===0)return Xj;let{pathname:Z}=new URL(j.url),W=q(Z),z=new F(j,{},W?"api":"view","");return await L.run(z,async()=>{let $=L.getStore(),{headers:H,cookies:zj}=$,Y=(J)=>{if(!Jj(J))return Q(J,H,zj);let G=new Headers(H);return G.delete("Set-Cookie"),Q(J,G,Wj)};try{return await X.runGlobalMiddleware(),{refusal:null,apply:Y,carried:{user:$.user}}}catch(J){let G=!W&&Z.endsWith(".json");if(J?.kind===B){let O=W?m(J.payload.api):G?M(J.payload.viewData??J.payload.api):K(J.payload.view);return{refusal:Y(O),apply:Y,carried:null}}if(V(J)&&(W||G))return{refusal:Y(C()),apply:Y,carried:null};if(f(J)){console.error(J);let O=W||G?I():K(E());return{refusal:Y(O),apply:Y,carried:null}}throw J}finally{$.destroy()}})}var U=[l,d,y,P,n,A,S,v,R,D,h,p,u,g,c,w];class jj{config={};providers=[];services=[];serviceInstances=[];serviceTokens=new Set;servicesBooted=!1;models=[];app=new N;boot(){if(this.models.length>0)i(...this.models);else Yj();this.app.config.merge(this.config),N.setInstance(this.app),this.app.registerMany([...U,...this.providers]),this.registerServices()}registerServices(){let j=this.serviceTokens;this.serviceInstances=[],this.serviceTokens=new Set,this.servicesBooted=!1;let X=new Map;for(let Z of this.services){let W=typeof Z==="function"?new Z:Z,z=W.constructor;if(!z.token)throw Error(`Service [${z.name}] is listed in \`services\` but does not declare a \`static token\`.`);let $=X.get(z.token);if($)throw Error(`Services [${$}] and [${z.name}] both declare the token "${z.token}". Tokens are the container's keys, so they must be unique.`);X.set(z.token,z.name);let H=z;if(!j.has(z.token)&&this.app.bound(H))throw Error(`Service [${z.name}] declares the token "${z.token}", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`);this.app.instance(H,W),this.serviceInstances.push(W),this.serviceTokens.add(z.token)}}async waitForBoot(){await this.app.boot(),await this.bootServices(),e(this.app)}async bootServices(){if(this.servicesBooted)return;for(let j of this.serviceInstances)await j.boot();this.servicesBooted=!0}shutdown(j){return this.run(()=>this.app.shutdown(j))}run(j){return _.run(this.app,j)}resolve(j){return this.app.make(j)}apiRoutes(){return this.app.make(t)}viewRoutes(){return this.app.make(s)}domains(){return this.app.make(o)}queue(){return this.app.make(r)}globalMiddleware(j){return k(j)}destroy(){if(this.app.resolved(T))this.app.make(T).stop();if(this.app.flush(),N.getInstance()===this.app)N.setInstance(void 0);_.disable()}}function Yj(){if(Bun.env.NODE_ENV==="production")return;let j=a();if(j.length===0)return;console.warn(`[gemi] ${j.length} model${j.length===1?" is":"s are"} registered, but Kernel.models is empty.
3
3
  Nested relation reads resolve a model by name, so a policy on a subclass that does not own its
4
4
  `+" name is skipped inside every include \u2014 scoped at the root, "+`unscoped in an include, with nothing
5
5
  to notice it. Declaring the modules registers each class under its own name and audits the set:
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{wa as I}from"../chunk-8z37k28d.js";import{xa as A}from"../chunk-xp6nr441.js";import{Ng as b,Pg as V,Qg as H,Rg as O,Sg as W}from"../chunk-xmjhensy.js";import{Wg as k}from"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import{bh as $}from"../chunk-68zf43ah.js";var X=Symbol.for("gemi.server.devGeneration"),L={graceMs:1e4,providerTimeoutMs:5000};class Q{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,J)=>{this.inFlight++;try{return await z(B,J)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(J){Z(J)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let J=()=>{clearTimeout(K),this.waiters.delete(J),B()},K=setTimeout(J,z);this.waiters.add(J)})}wake(){for(let z of this.waiters)z()}}function Y(z,B=L){let J=globalThis,K=J[X];if(J[X]=z,!K||K===z||typeof K.retire!=="function")return Promise.resolve();let _=K.retire.bind(K);return Promise.resolve().then(()=>_(B)).catch(Z)}function Z(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class P{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=O(z.instrumentation??((B,J)=>J(B)))}async start(){process.env.ROOT_DIR=k();let z=Bun.env.NODE_ENV==="production";if(z){if(this.handleSignals)W(()=>this.stop());this.settings=V()}try{await this.app.waitForBoot()}catch(B){if(!z)this.app.shutdown({timeoutMs:L.providerTimeoutMs});throw B}if(z){let{httpProd:B}=await import("../chunk-q2r6b35k.js");this.server=await B(this.app,this.instrumentation.bind(this))}else{I();let{httpDev:B}=await import("../chunk-vdynb16s.js"),J=new Q(this.app);this.server=await B(this.app,J.track(this.instrumentation.bind(this))),Y(J)}return this.server}stop(z={}){return this.stopping??=H({server:this.server,shutdownProviders:(B)=>this.app.shutdown(B),settings:{...this.settings??V(),...z}}),this.stopping}}export{b as isShuttingDown,P as Server};
2
+ import{wa as I}from"../chunk-8z37k28d.js";import{xa as A}from"../chunk-xp6nr441.js";import{Ng as b,Pg as V,Qg as H,Rg as O,Sg as W}from"../chunk-xmjhensy.js";import{Wg as k}from"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import{bh as $}from"../chunk-68zf43ah.js";var X=Symbol.for("gemi.server.devGeneration"),L={graceMs:1e4,providerTimeoutMs:5000};class Q{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,J)=>{this.inFlight++;try{return await z(B,J)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(J){Z(J)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let J=()=>{clearTimeout(K),this.waiters.delete(J),B()},K=setTimeout(J,z);this.waiters.add(J)})}wake(){for(let z of this.waiters)z()}}function Y(z,B=L){let J=globalThis,K=J[X];if(J[X]=z,!K||K===z||typeof K.retire!=="function")return Promise.resolve();let _=K.retire.bind(K);return Promise.resolve().then(()=>_(B)).catch(Z)}function Z(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class P{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=O(z.instrumentation??((B,J)=>J(B)))}async start(){process.env.ROOT_DIR=k();let z=Bun.env.NODE_ENV==="production";if(z){if(this.handleSignals)W(()=>this.stop());this.settings=V()}try{await this.app.waitForBoot()}catch(B){if(!z)this.app.shutdown({timeoutMs:L.providerTimeoutMs});throw B}if(z){let{httpProd:B}=await import("../chunk-pdvsc6jd.js");this.server=await B(this.app,this.instrumentation.bind(this))}else{I();let{httpDev:B}=await import("../chunk-ztcsyeg7.js"),J=new Q(this.app);this.server=await B(this.app,J.track(this.instrumentation.bind(this))),Y(J)}return this.server}stop(z={}){return this.stopping??=H({server:this.server,shutdownProviders:(B)=>this.app.shutdown(B),settings:{...this.settings??V(),...z}}),this.stopping}}export{b as isShuttingDown,P as Server};
3
3
 
4
4
  //# debugId=3D36CFA294CE7ED664756E2164756E21
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ya as dW}from"../chunk-zytmxty5.js";import{Za as i6,_a as DW,ab as FW,bb as UW,cb as SW,db as fW,eb as RW,fb as kW,gb as _W,hb as U,ib as CW,jb as vW,kb as bW,lb as IW,mb as TW,nb as qW,ob as hW,pb as PW,qb as wW,rb as AW,sb as yW,tb as VW,ub as gW,vb as cW,wb as EW,xb as mW,yb as uW}from"../chunk-jv38q9n7.js";import"../chunk-wc46df4w.js";import{Eb as YW,Fb as JW,Gb as ZW,Hb as GW,Ib as $W,Jb as QW,Kb as KW,Lb as XW,Mb as zW,Nb as BW,Ob as xW,Pb as MW,Qb as jW,Rb as NW,Sb as LW}from"../chunk-3tn480wt.js";import{Tb as n6,Ub as o6,Vb as s6,Wb as a6,Xb as t6,Yb as r6,Zb as e6,_b as WW}from"../chunk-z8jf7jwg.js";import{dc as OW,ec as HW}from"../chunk-f9t39vwk.js";import"../chunk-7kedxtbp.js";import{$c as d4,Bc as s4,Cc as a4,Cd as c6,Dc as g1,Ec as $6,Ed as E6,Hc as Q6,Ic as K6,Uc as D6,Vc as F6,Wc as O6,Xc as H6,Yc as U6,Zc as S6,_c as f6,ad as R6,bd as k6,cd as _6,dd as C6,ed as v6,id as b6,jd as I6,kd as T6,ld as q6,mc as b0,md as h6,nd as P6,od as w6,pd as A6,qd as y6,rd as V6,sc as e0,tc as W6,uc as Y6,vc as J6,wc as Z6,xc as G6,yd as g6}from"../chunk-rc4z7ykq.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import{Te as V1,Ue as A1,Ve as Y1,if as g,jf as w,nf as J1,of as L1,pf as X6,qf as z6,rf as B6,sf as x6,uf as M6,wf as D1}from"../chunk-h15bd9vn.js";import"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import{Ff as j6,Gf as N6,Hf as L6}from"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import{Bg as l6,wg as m6,xg as u6,yg as d6,zg as p6}from"../chunk-77kw61f4.js";import"../chunk-qttatc7h.js";import{Kg as c}from"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-xmjhensy.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import{bh as l4}from"../chunk-68zf43ah.js";import{Buffer as p4}from"buffer";class n4 extends J1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-99wzvsz5.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$=process.env.BUCKET_NAME;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket??$,Z=W.contentType||(J instanceof Blob||J instanceof File?J.type:void 0);Z=Z||void 0;let Q=J instanceof p4?J:J instanceof Blob||J instanceof File?p4.from(await J.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return Y?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:$,Key:G,Body:Q,ContentType:Z}),{abortSignal:Y}),G}async delete(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Y)throw Error("Object name has to be specified");let{sdk:Z,client:G}=await this.connect();try{await G.send(new Z.DeleteObjectCommand({Bucket:J,Key:Y}))}catch($){if($?.name==="NoSuchKey"||$?.$metadata?.httpStatusCode===404)return;throw $}}async list(W){let{sdk:Y,client:J}=await this.connect();return await J.send(new Y.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=process.env.BUCKET_NAME,Z;if(typeof W==="string")Z=W;else J=W.bucket??J,Z=W.name;if(!Z)throw Error("Object name has to be specified");let{sdk:G,client:$}=await this.connect();Y?.throwIfAborted();let Q=await $.send(new G.GetObjectCommand({Bucket:J,Key:Z}),{abortSignal:Y}),K=L1(Q.Body.transformToWebStream(),Y);return Y?.throwIfAborted(),new Response(K,{headers:{"Content-Type":Q.ContentType,"Content-Length":Q.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Q.LastModified?.toUTCString()||"",ETag:Q.ETag||""}})}async read(W){let Y=typeof W==="string"?{name:W}:W,J=Y.bucket??process.env.BUCKET_NAME,{name:Z,range:G=null}=Y;if(!Z)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect(),K;try{K=await Q.send(new $.GetObjectCommand({Bucket:J,Key:Z,Range:G?A1(G):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new g(await this.size({name:Z,bucket:J}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new w(Z);throw M}let z=Y1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,x=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??x-1,total:x,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:Z}}async size(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Z,client:G}=await this.connect();try{return(await G.send(new Z.HeadObjectCommand({Bucket:J,Key:Y}))).ContentLength??0}catch($){if($?.name==="NotFound"||$?.$metadata?.httpStatusCode===404)throw new w(Y);throw $}}}import{Buffer as i4}from"buffer";import{Readable as q0}from"stream";function y1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function h0(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class o4 extends J1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Y=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Y)return W.BlobServiceClient.fromConnectionString(Y);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Y){if(!W)throw Error("Object name has to be specified");let J=Y??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(J).getBlockBlobClient(W)}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket,Z=W.contentType??(J instanceof Blob||J instanceof File?J.type:void 0);let Q=J instanceof i4?J:i4.from(await J.arrayBuffer()),K=await this.blob(G,$);return Y?.throwIfAborted(),await K.uploadData(Q,{blobHTTPHeaders:Z?{blobContentType:Z}:void 0,abortSignal:Y}),G}async list(W){let Y=this.config.container??process.env.BUCKET_NAME,Z=(await this.serviceClient()).getContainerClient(Y),G=[];for await(let $ of Z.listBlobsFlat({prefix:W}))G.push($.name);return G}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Y);return new Response(J.body,{headers:{"Content-Type":J.type,"Content-Length":String(J.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.lastModified?.toUTCString()??"",ETag:J.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Y){let{name:J,bucket:Z,range:G=null}=W,$=await this.blob(J,Z);Y?.throwIfAborted();let Q,K,z=G?.kind==="suffix"||G?.kind==="offset"&&G.end===null&&G.start===0;if(G&&z){let b=await this.size({name:J,bucket:Z}),W1=V1(G,b);if(!W1)throw new g(b);Q=W1.start,K=W1.length}else if(G?.kind==="offset")Q=G.start,K=G.end===null?void 0:G.end-G.start+1;let X;try{X=await $.download(Q,K,Y?{abortSignal:Y}:void 0)}catch(b){if(h0(b))throw new g(await this.size({name:J,bucket:Z}));if(y1(b))throw new w(J);throw b}let x=Y1(X.contentRange),M=Boolean(x),R=x?.total??X.contentLength??0,v=await P0(X);if(v instanceof ReadableStream)v=L1(v,Y);return Y?.throwIfAborted(),{body:v,start:x?.start??0,end:x?.end??R-1,total:R,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:J}}async size(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{return(await Z.getProperties()).contentLength??0}catch(G){if(y1(G))throw new w(Y);throw G}}async delete(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{await Z.delete()}catch(G){if(y1(G))return;throw G}}}async function P0(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return q0.toWeb(W.readableStreamBody);return null}var w0=`
2
+ import{Ya as dW}from"../chunk-zytmxty5.js";import{Za as i6,_a as DW,ab as FW,bb as UW,cb as SW,db as fW,eb as RW,fb as kW,gb as _W,hb as U,ib as CW,jb as vW,kb as bW,lb as IW,mb as TW,nb as qW,ob as hW,pb as PW,qb as wW,rb as AW,sb as yW,tb as VW,ub as gW,vb as cW,wb as EW,xb as mW,yb as uW}from"../chunk-8v5z6646.js";import"../chunk-wc46df4w.js";import{Eb as YW,Fb as JW,Gb as ZW,Hb as GW,Ib as $W,Jb as QW,Kb as KW,Lb as XW,Mb as zW,Nb as BW,Ob as xW,Pb as MW,Qb as jW,Rb as NW,Sb as LW}from"../chunk-3tn480wt.js";import{Tb as n6,Ub as o6,Vb as s6,Wb as a6,Xb as t6,Yb as r6,Zb as e6,_b as WW}from"../chunk-z8jf7jwg.js";import{dc as OW,ec as HW}from"../chunk-f9t39vwk.js";import"../chunk-7kedxtbp.js";import{$c as d4,Bc as s4,Cc as a4,Cd as c6,Dc as g1,Ec as $6,Ed as E6,Hc as Q6,Ic as K6,Uc as D6,Vc as F6,Wc as O6,Xc as H6,Yc as U6,Zc as S6,_c as f6,ad as R6,bd as k6,cd as _6,dd as C6,ed as v6,id as b6,jd as I6,kd as T6,ld as q6,mc as b0,md as h6,nd as P6,od as w6,pd as A6,qd as y6,rd as V6,sc as e0,tc as W6,uc as Y6,vc as J6,wc as Z6,xc as G6,yd as g6}from"../chunk-d6prwkff.js";import"../chunk-bf1q3m7a.js";import"../chunk-adm5g1v8.js";import{Te as V1,Ue as A1,Ve as Y1,if as g,jf as w,nf as J1,of as L1,pf as X6,qf as z6,rf as B6,sf as x6,uf as M6,wf as D1}from"../chunk-4x41cmg3.js";import"../chunk-9xf2fx98.js";import"../chunk-eqtsfvvd.js";import{Ff as j6,Gf as N6,Hf as L6}from"../chunk-br9p390p.js";import"../chunk-n4807648.js";import"../chunk-ghz3e8b7.js";import"../chunk-7vjbebst.js";import"../chunk-3fr22rtg.js";import{Bg as l6,wg as m6,xg as u6,yg as d6,zg as p6}from"../chunk-77kw61f4.js";import"../chunk-qttatc7h.js";import{Kg as c}from"../chunk-48dek9s7.js";import"../chunk-f6s7ddjz.js";import"../chunk-xmjhensy.js";import"../chunk-n63xjrck.js";import"../chunk-2tm56xq1.js";import{bh as l4}from"../chunk-68zf43ah.js";import{Buffer as p4}from"buffer";class n4 extends J1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-99wzvsz5.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$=process.env.BUCKET_NAME;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket??$,Z=W.contentType||(J instanceof Blob||J instanceof File?J.type:void 0);Z=Z||void 0;let Q=J instanceof p4?J:J instanceof Blob||J instanceof File?p4.from(await J.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return Y?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:$,Key:G,Body:Q,ContentType:Z}),{abortSignal:Y}),G}async delete(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Y)throw Error("Object name has to be specified");let{sdk:Z,client:G}=await this.connect();try{await G.send(new Z.DeleteObjectCommand({Bucket:J,Key:Y}))}catch($){if($?.name==="NoSuchKey"||$?.$metadata?.httpStatusCode===404)return;throw $}}async list(W){let{sdk:Y,client:J}=await this.connect();return await J.send(new Y.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=process.env.BUCKET_NAME,Z;if(typeof W==="string")Z=W;else J=W.bucket??J,Z=W.name;if(!Z)throw Error("Object name has to be specified");let{sdk:G,client:$}=await this.connect();Y?.throwIfAborted();let Q=await $.send(new G.GetObjectCommand({Bucket:J,Key:Z}),{abortSignal:Y}),K=L1(Q.Body.transformToWebStream(),Y);return Y?.throwIfAborted(),new Response(K,{headers:{"Content-Type":Q.ContentType,"Content-Length":Q.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Q.LastModified?.toUTCString()||"",ETag:Q.ETag||""}})}async read(W){let Y=typeof W==="string"?{name:W}:W,J=Y.bucket??process.env.BUCKET_NAME,{name:Z,range:G=null}=Y;if(!Z)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect(),K;try{K=await Q.send(new $.GetObjectCommand({Bucket:J,Key:Z,Range:G?A1(G):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new g(await this.size({name:Z,bucket:J}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new w(Z);throw M}let z=Y1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,x=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??x-1,total:x,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:Z}}async size(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Z,client:G}=await this.connect();try{return(await G.send(new Z.HeadObjectCommand({Bucket:J,Key:Y}))).ContentLength??0}catch($){if($?.name==="NotFound"||$?.$metadata?.httpStatusCode===404)throw new w(Y);throw $}}}import{Buffer as i4}from"buffer";import{Readable as q0}from"stream";function y1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function h0(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class o4 extends J1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Y=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Y)return W.BlobServiceClient.fromConnectionString(Y);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Y){if(!W)throw Error("Object name has to be specified");let J=Y??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(J).getBlockBlobClient(W)}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket,Z=W.contentType??(J instanceof Blob||J instanceof File?J.type:void 0);let Q=J instanceof i4?J:i4.from(await J.arrayBuffer()),K=await this.blob(G,$);return Y?.throwIfAborted(),await K.uploadData(Q,{blobHTTPHeaders:Z?{blobContentType:Z}:void 0,abortSignal:Y}),G}async list(W){let Y=this.config.container??process.env.BUCKET_NAME,Z=(await this.serviceClient()).getContainerClient(Y),G=[];for await(let $ of Z.listBlobsFlat({prefix:W}))G.push($.name);return G}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Y);return new Response(J.body,{headers:{"Content-Type":J.type,"Content-Length":String(J.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.lastModified?.toUTCString()??"",ETag:J.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Y){let{name:J,bucket:Z,range:G=null}=W,$=await this.blob(J,Z);Y?.throwIfAborted();let Q,K,z=G?.kind==="suffix"||G?.kind==="offset"&&G.end===null&&G.start===0;if(G&&z){let b=await this.size({name:J,bucket:Z}),W1=V1(G,b);if(!W1)throw new g(b);Q=W1.start,K=W1.length}else if(G?.kind==="offset")Q=G.start,K=G.end===null?void 0:G.end-G.start+1;let X;try{X=await $.download(Q,K,Y?{abortSignal:Y}:void 0)}catch(b){if(h0(b))throw new g(await this.size({name:J,bucket:Z}));if(y1(b))throw new w(J);throw b}let x=Y1(X.contentRange),M=Boolean(x),R=x?.total??X.contentLength??0,v=await P0(X);if(v instanceof ReadableStream)v=L1(v,Y);return Y?.throwIfAborted(),{body:v,start:x?.start??0,end:x?.end??R-1,total:R,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:J}}async size(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{return(await Z.getProperties()).contentLength??0}catch(G){if(y1(G))throw new w(Y);throw G}}async delete(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{await Z.delete()}catch(G){if(y1(G))return;throw G}}}async function P0(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return q0.toWeb(W.readableStreamBody);return null}var w0=`
3
3
  local currentKey = KEYS[1]
4
4
  local previousKey = KEYS[2]
5
5
  local limit = tonumber(ARGV[1])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.100.0",
3
+ "version": "0.101.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",
@@ -1,9 +0,0 @@
1
- // @bun
2
- import{Af as e,Bf as m,zf as B}from"./chunk-9xf2fx98.js";import{Ef as C}from"./chunk-eqtsfvvd.js";import{Kg as _H}from"./chunk-48dek9s7.js";import{Wg as S}from"./chunk-n63xjrck.js";import{bh as Q0}from"./chunk-68zf43ah.js";class WH{static kind="controller";constructor(){}}class wH extends WH{}function o(H){let G=new Map;if(!H)return G;for(let Q of H.split(";")){let Z=Q.indexOf("=");if(Z===-1)continue;let X=Q.slice(0,Z).trim();if(!X)continue;G.set(X,Q.slice(Z+1).trim())}return G}function Y0(H){return o(H.headers.get("cookie"))}function j(H){if(!/^\d+$/.test(H))return null;let G=Number(H);return Number.isSafeInteger(G)?G:null}function KH(H){if(!H)return null;let G=H.trim();if(!/^bytes=/i.test(G))return null;let Z=G.slice(6).split(",").map((D)=>D.trim()).filter((D)=>D!=="");if(Z.length!==1)return null;let X=Z[0],$=X.indexOf("-");if($===-1)return null;let U=X.slice(0,$),W=X.slice($+1);if(U===""){let D=j(W);if(D===null)return null;return{kind:"suffix",suffixLength:D}}let K=j(U);if(K===null)return null;if(W==="")return{kind:"offset",start:K,end:null};let M=j(W);if(M===null||M<K)return null;return{kind:"offset",start:K,end:M}}function MH(H,G){if(!Number.isFinite(G)||G<=0)return null;let Q,Z;if(H.kind==="suffix"){if(H.suffixLength<=0)return null;Q=Math.max(0,G-H.suffixLength),Z=G-1}else{if(H.start>=G)return null;if(Q=H.start,Z=H.end===null?G-1:Math.min(H.end,G-1),Z<Q)return null}return{start:Q,end:Z,length:Z-Q+1}}function R0(H){if(H.kind==="suffix")return`bytes=-${H.suffixLength}`;return H.end===null?`bytes=${H.start}-`:`bytes=${H.start}-${H.end}`}function P0(H){if(!H)return null;let G=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(H.trim());if(!G)return null;let Q=j(G[1]),Z=j(G[2]),X=j(G[3]);if(Q===null||Z===null||X===null||Z<Q)return null;return{start:Q,end:Z,total:X}}function B0(H,G,Q){return`bytes ${H}-${G}/${Q}`}function TH(H){return`bytes */${H}`}class w extends B{errors={};constructor(H){super("Validation error");this.name="ValidationError",this.errors=H,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:H,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function EH(H){let[G,Q]=H.match(/\d+|\D+/g)??[];if(!G||!Q)return 0;let Z=Number.parseInt(G);switch(Q){case"B":return Z;case"KB":return Z*1024;case"MB":return Z*1024*1024;case"GB":return Z*1024*1024*1024;case"TB":return Z*1024*1024*1024*1024;default:return 0}}function NH(H){switch(H){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return H}}function YH(H){if(typeof H==="string"||Array.isArray(H))return H.length;return}function n(H){return typeof H==="number"&&!Number.isNaN(H)}var SH=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class J extends Error{name="InvalidValidationRuleError"}function y(H,G){let Q=G===void 0||G.trim()===""?Number.NaN:Number(G);if(Number.isNaN(Q))throw new J(`Validation rule "${H}:${G??""}" needs a number, e.g. "${H}:3"`);return Q}function DH(H){let G=H.indexOf(":"),Q=G===-1?H:H.slice(0,G),Z=G===-1?void 0:H.slice(G+1);switch(Q){case"required":return(X)=>{if(X instanceof Blob)return X.size>0;if(X===null||X===void 0)return!1;if(typeof X==="string"||Array.isArray(X))return X.length>0;return!0};case"string":return(X)=>typeof X==="string";case"boolean":return(X)=>typeof X==="boolean";case"number":return(X)=>n(X);case"password":return(X)=>{return typeof X==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(X)};case"min":{let X=y(Q,Z);return($)=>{let U=YH($);return U!==void 0&&U>=X}}case"max":{let X=y(Q,Z);return($)=>{let U=YH($);return U!==void 0&&U<=X}}case"gte":{let X=y(Q,Z);return($)=>n($)&&$>=X}case"lte":{let X=y(Q,Z);return($)=>n($)&&$<=X}case"email":return(X)=>{return typeof X==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(X)};case"file":return(X)=>{return X instanceof Blob};case"fileType":{if(!Z)throw new J('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let X=NH(Z);return($)=>$ instanceof Blob&&$.type.startsWith(X)}case"fileSize":{let X=EH(Z??"");if(X===0&&!/^0+(B|KB|MB|GB|TB)$/.test(Z??""))throw new J(`Validation rule "fileSize:${Z??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return($)=>$ instanceof Blob&&$.size<=X}case"array":return(X)=>Array.isArray(X);case"object":return(X)=>typeof X==="object"&&X!==null&&!Array.isArray(X)&&!(X instanceof Blob);case"in":{let X=(Z??"").split(",").filter(($)=>$!=="");if(X.length===0)throw new J('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return($)=>typeof $==="string"&&X.includes($)}default:throw new J(`Unknown validation rule "${H}". Known rules: ${SH.join(", ")}`)}}var d=new WeakMap;function PH(H){return typeof H==="object"&&H!==null&&d.has(H)}function i(H){let G=d.get(H);if(!G)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return G}function b(H){let G=(H.optional||H.nullable)&&H.node.kind!=="json",Q=kH(yH(H.node),G),Z=[H.description,gH(H.node)].filter(Boolean).join(" ");return Z?{description:Z,...Q}:Q}function gH(H){let G=[];if(H.kind==="string"||H.kind==="enum"){let Q=H.checks;if(Q?.format)G.push(`Format: ${Q.format.name}.`);if(Q?.minLength!==void 0)G.push(`At least ${Q.minLength} characters.`);if(Q?.maxLength!==void 0)G.push(`At most ${Q.maxLength} characters.`)}else if(H.kind==="number"){let Q=H.checks;if(Q?.minimum!==void 0)G.push(`Minimum ${Q.minimum}.`);if(Q?.exclusiveMinimum!==void 0)G.push(`Greater than ${Q.exclusiveMinimum}.`);if(Q?.maximum!==void 0)G.push(`Maximum ${Q.maximum}.`);if(Q?.exclusiveMaximum!==void 0)G.push(`Less than ${Q.exclusiveMaximum}.`)}else if(H.kind==="array"){let Q=H.checks;if(Q?.minItems!==void 0)G.push(`At least ${Q.minItems} items.`);if(Q?.maxItems!==void 0)G.push(`At most ${Q.maxItems} items.`)}return G.join(" ")}function yH(H){switch(H.kind){case"string":return{type:"string"};case"number":return{type:H.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof H.value,const:H.value};case"enum":return{type:"string",enum:H.values};case"array":return{type:"array",items:b(H.item)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(H.shape).map(([G,Q])=>[G,b(Q)])),required:Object.keys(H.shape),additionalProperties:!1};case"union":return{anyOf:H.members.map(b)};case"json":return{}}}function kH(H,G){if(!G)return H;if(H.anyOf)return{...H,anyOf:[...H.anyOf,{type:"null"}]};if(H.enum||H.const!==void 0)return{anyOf:[H,{type:"null"}]};if(typeof H.type==="string")return{...H,type:[H.type,"null"]};return{anyOf:[H,{type:"null"}]}}function bH(H){if(H===null)return"null";if(Array.isArray(H))return"array";return typeof H}function fH(H,G){if(typeof G==="number"&&!Number.isFinite(G))return String(G);if(H.kind==="literal"||H.kind==="enum"){if(typeof G==="string"||typeof G==="number"||typeof G==="boolean")return JSON.stringify(G)}return bH(G)}function cH(H){let G=H.node,Q=(()=>{switch(G.kind){case"number":return G.checks?.integer?"integer":"number";case"string":case"boolean":return G.kind;case"literal":return JSON.stringify(G.value);case"enum":return`one of ${G.values.map((Z)=>JSON.stringify(Z)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value"}})();return H.optional||H.nullable?`${Q} or null`:Q}function vH(H){let G="";for(let Q of H)G+=typeof Q==="number"?`[${Q}]`:G?`.${Q}`:Q;return G}function pH(H){let G=vH(H);return G?`${G}: `:""}function t(H){return`${pH(H.path)}${H.message}`}function r(H,G){if(G===null||G===void 0)return H.optional||H.nullable?1:0;let Q=H.node;switch(Q.kind){case"string":return typeof G==="string"?1:0;case"number":return typeof G==="number"?1:0;case"boolean":return typeof G==="boolean"?1:0;case"literal":return G===Q.value?10:0;case"enum":return typeof G==="string"&&Q.values.includes(G)?10:0;case"array":return Array.isArray(G)?1:0;case"object":{if(typeof G!=="object"||Array.isArray(G))return 0;let Z=G,X=1;for(let[$,U]of Object.entries(Q.shape))X+=r(U,Z[$]);return X}case"union":return Q.members.reduce((Z,X)=>Math.max(Z,r(X,G)),0);case"json":return 1}}function x(H,G,Q,Z){if(H.optional&&(G===null||G===void 0))return{drop:!0,value:void 0};if(H.nullable&&G===null)return{drop:!1,value:null};return{drop:!1,value:hH(H,G,Q,Z)}}function hH(H,G,Q,Z){let X=H.node,$=()=>{let U=G===void 0?"required":X.kind==="literal"?"const":X.kind==="enum"&&typeof G==="string"?"enum":"type",W=U==="const"?{allowedValue:X.value}:U==="enum"?{allowedValues:X.values}:{};Z.push({path:Q,code:U,message:`expected ${cH(H)}, got ${fH(X,G)}`,params:W});return};switch(X.kind){case"string":if(typeof G!=="string")return $();return RH(X.checks,G,Q,Z),G;case"number":if(typeof G!=="number"||!Number.isFinite(G))return $();if(X.checks?.integer&&!Number.isInteger(G))return $();return mH(X.checks,G,Q,Z),G;case"boolean":return typeof G==="boolean"?G:$();case"literal":return G===X.value?G:$();case"enum":if(typeof G!=="string"||!X.values.includes(G))return $();return RH(X.checks,G,Q,Z),G;case"array":{if(!Array.isArray(G))return $();let U=G.map((M,D)=>{let q=x(X.item,M,[...Q,D],Z);return q.drop?void 0:q.value}),{minItems:W,maxItems:K}=X.checks??{};if(W!==void 0&&G.length<W)Z.push({path:Q,code:"minItems",message:`expected at least ${W} items, got ${G.length}`,params:{limit:W}});if(K!==void 0&&G.length>K)Z.push({path:Q,code:"maxItems",message:`expected at most ${K} items, got ${G.length}`,params:{limit:K}});return U}case"object":{if(typeof G!=="object"||G===null||Array.isArray(G))return $();let U=G,W={};for(let[K,M]of Object.entries(X.shape)){let D=x(M,U[K],[...Q,K],Z);if(!D.drop)W[K]=D.value}return W}case"union":{let U;for(let W of X.members){let K=[],M=x(W,G,Q,K);if(K.length===0)return M.drop?void 0:M.value;let D=r(W,G);if(!U||D>U.score)U={issues:K,score:D}}Z.push({path:Q,code:"anyOf",message:`no matching variant; closest: ${U.issues.map(t).join("; ")}`,params:{closest:U.issues}});return}case"json":if(G===void 0)return $();return f(G,Q,Z,new Set),G}}function dH(H){let G=0;for(let Q of H)G++;return G}function RH(H,G,Q,Z){if(!H)return;let{minLength:X,maxLength:$,format:U}=H;if(X!==void 0||$!==void 0){let W=dH(G);if(X!==void 0&&W<X)Z.push({path:Q,code:"minLength",message:`expected at least ${X} characters, got ${W}`,params:{limit:X}});if($!==void 0&&W>$)Z.push({path:Q,code:"maxLength",message:`expected at most ${$} characters, got ${W}`,params:{limit:$}})}if(U){let W=!1;try{W=U.test(G)===!0}catch{}if(!W)Z.push({path:Q,code:"format",message:`expected a string in format "${U.name}"`,params:{format:U.name}})}}function mH(H,G,Q,Z){if(!H)return;let X=($,U,W,K)=>{if(U===void 0||W(U))return;Z.push({path:Q,code:$,message:`expected ${K} ${U}, got ${G}`,params:{limit:U}})};X("minimum",H.minimum,($)=>G>=$,"at least"),X("exclusiveMinimum",H.exclusiveMinimum,($)=>G>$,"more than"),X("maximum",H.maximum,($)=>G<=$,"at most"),X("exclusiveMaximum",H.exclusiveMaximum,($)=>G<$,"less than")}function f(H,G,Q,Z,X=!0){let $=(W)=>{Q.push({path:G,code:"type",message:`expected a JSON value, got ${W}`,params:{}})};switch(typeof H){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(H))$(String(H));return;case"bigint":return $("a bigint");case"function":return $("a function");case"symbol":return $("a symbol")}if(H===null)return;let U=H;if(Z.has(U))return $("a circular reference");Z.add(U);try{let W=X?U.toJSON:void 0;if(typeof W==="function"){let K;try{K=W.call(U)}catch{return $("a toJSON that threw")}if(K===void 0)return $("a toJSON that returns undefined");return f(K,G,Q,Z,!1)}if(Array.isArray(H))H.forEach((K,M)=>f(K,[...G,M],Q,Z));else for(let[K,M]of Object.entries(U))f(M,[...G,K],Q,Z)}finally{Z.delete(U)}}function z(H){return c(H)}function c(H){let G={toJSONSchema:()=>b(H),parse(Q){let Z=[],X=x(H,Q,[],Z);if(Z.length>0)throw Error(Z.map(t).join("; "));return X.drop?void 0:X.value},safeParse(Q){let Z=[],X=x(H,Q,[],Z);if(Z.length>0)return{ok:!1,errors:Z.map(t)};return{ok:!0,value:X.drop?void 0:X.value}},validate(Q){let Z=[],X=x(H,Q,[],Z);if(Z.length>0)return{ok:!1,issues:Z};return{ok:!0,value:X.drop?void 0:X.value}},describe:(Q)=>c({...H,description:Q}),optional:()=>c({...H,optional:!0}),nullable:()=>c({...H,nullable:!0,optional:!1})};return d.set(G,H),G}function L(H){return{node:H,optional:!1,nullable:!1}}class BH extends Error{problems;constructor(H){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
3
- ${H.map((G)=>`- ${G}`).join(`
4
- `)}`);this.name="JSONSchemaError",this.problems=H}}var uH=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),E={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function k(H){return typeof H==="object"&&H!==null&&!Array.isArray(H)}function v(H,G,Q,Z){let X=(T,Y=Q)=>{Z.push(Y?`${Y}: ${T}`:T);return},$=(T)=>Q?`${Q}.${T}`:T;if(!k(H))return X("expected a schema object");let U=new Set(G.ignoreKeywords??[]),W=(T)=>uH.has(T)||T.startsWith("x-")||U.has(T),K=!1,M=H.type;if(Array.isArray(M)){let T=M.filter((Y)=>Y!=="null");if(T.length!==1)return X(`type ${JSON.stringify(M)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,$("type"));K=T.length<M.length,M=T[0]}if(M!==void 0&&(typeof M!=="string"||!(M in E)))return X(`type ${JSON.stringify(M)} is not supported; expected one of ${Object.keys(E).join(", ")}`,$("type"));let D=new Set(["type","description","enum","const","anyOf",...M?E[M]:[]]),q=!1;for(let T of Object.keys(H)){if(D.has(T)||W(T))continue;q=!0;let Y=Object.entries(E).find(([,P])=>P.includes(T));X(Y&&Y[0]!==M?`"${T}" applies to type ${Y[0]}, and this schema is ${M?`type ${M}`:"untyped"}`:`"${T}" is not supported by s.fromJSONSchema`,$(T))}if(q)return;if(H.description!==void 0&&typeof H.description!=="string")return X("expected a string",$("description"));let g=H.description,F=(T)=>({node:T,optional:!1,nullable:K,...g?{description:g}:{}});if(H.anyOf!==void 0){if(M!==void 0||H.enum!==void 0||H.const!==void 0)return X("anyOf cannot be combined with type, enum or const here",$("anyOf"));if(!Array.isArray(H.anyOf)||H.anyOf.length===0)return X("expected a non-empty array",$("anyOf"));let T=[],Y=!1;if(H.anyOf.forEach((P,R)=>{if(k(P)&&P.type==="null"&&Object.keys(P).length===1){K=!0;return}let A=v(P,G,$(`anyOf[${R}]`),Z);if(A)T.push(A);else Y=!0}),Y)return;if(T.length===0)return X("anyOf has only null in it",$("anyOf"));if(T.length===1){let P=T[0];return{...P,nullable:P.nullable||K,...g?{description:g}:{}}}return F({kind:"union",members:T})}if(H.const!==void 0){let T=H.const;if(typeof T!=="string"&&typeof T!=="number"&&typeof T!=="boolean")return X("only a string, number or boolean const is supported",$("const"));if(M!==void 0&&typeof T!==(M==="integer"?"number":M))return X(`const ${JSON.stringify(T)} is not of type ${M}`,$("const"));return F({kind:"literal",value:T})}let O;if(M==="string"){if(O=oH(H,G,$,Z),O===null)return}if(H.enum!==void 0){if(!Array.isArray(H.enum)||H.enum.length===0)return X("expected a non-empty array",$("enum"));let T=H.enum.filter((R)=>R!==null);if(T.length<H.enum.length)K=!0;let Y=T.find((R)=>!(typeof R==="string"||typeof R==="number"||typeof R==="boolean")||M!==void 0&&typeof R!==(M==="integer"?"number":M));if(Y!==void 0||T.length===0)return X(M?`every value must be of type ${M}${T.length===0?", and there must be one":`; ${JSON.stringify(Y)} is not`}`:"only strings, numbers and booleans are supported",$("enum"));if(T.every((R)=>typeof R==="string"))return F({kind:"enum",values:[...new Set(T)],...O?{checks:O}:{}});let P=[...new Set(T)];if(P.length===1)return F({kind:"literal",value:P[0]});return F({kind:"union",members:P.map((R)=>L({kind:"literal",value:R}))})}switch(M){case void 0:return X("a schema needs a type, an enum, a const or an anyOf");case"string":return F({kind:"string",...O?{checks:O}:{}});case"number":case"integer":{let T=M==="integer"?{integer:!0}:{},Y=!1;for(let P of E.number){let R=H[P];if(R===void 0)continue;if(typeof R!=="number"||!Number.isFinite(R)){X("expected a number",$(P)),Y=!0;continue}T[P]=R}if(Y)return;return F({kind:"number",...Object.keys(T).length>0?{checks:T}:{}})}case"boolean":return F({kind:"boolean"});case"array":{if(!k(H.items))return X('an array needs "items" to be one schema (tuples are not supported)',$("items"));let T={},Y=!1;for(let R of["minItems","maxItems"]){let A=H[R];if(A===void 0)continue;if(typeof A!=="number"||!Number.isInteger(A)||A<0){X("expected a non-negative integer",$(R)),Y=!0;continue}T[R]=A}let P=v(H.items,G,$("items"),Z);if(!P||Y)return;return F({kind:"array",item:P,...Object.keys(T).length>0?{checks:T}:{}})}case"object":{let T=H.properties??{};if(!k(T))return X("expected an object",$("properties"));if(H.additionalProperties!==void 0&&H.additionalProperties!==!1)return X("only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())",$("additionalProperties"));let Y=H.required??[];if(!Array.isArray(Y)||!Y.every((V)=>typeof V==="string"))return X("expected an array of property names",$("required"));let P=Y.filter((V)=>!Object.hasOwn(T,V));if(P.length>0)return X(`lists properties the schema doesn't have: ${P.join(", ")}`,$("required"));let R={},A=!1;for(let[V,qH]of Object.entries(T)){let u=v(qH,G,$(`properties.${V}`),Z);if(!u){A=!0;continue}R[V]=Y.includes(V)?u:{...u,optional:!0}}if(A)return;return F({kind:"object",shape:R})}}return}function oH(H,G,Q,Z){let X={},$=!1;for(let U of["minLength","maxLength"]){let W=H[U];if(W===void 0)continue;if(typeof W!=="number"||!Number.isInteger(W)||W<0){Z.push(`${Q(U)}: expected a non-negative integer`),$=!0;continue}X[U]=W}if(H.format!==void 0){let U=H.format,W=typeof U==="string"?G.formats?.[U]:void 0;if(typeof U!=="string")Z.push(`${Q("format")}: expected a string`),$=!0;else if(!W||!Object.hasOwn(G.formats,U))Z.push(`${Q("format")}: unknown format ${JSON.stringify(U)}; pass a check for it in the formats option`),$=!0;else X.format={name:U,test:nH(W)}}if($)return null;return Object.keys(X).length>0?X:void 0}function nH(H){if(H===!0)return()=>!0;if(H instanceof RegExp)return(G)=>{return H.lastIndex=0,H.test(G)};return H}var J0={string:()=>z(L({kind:"string"})),number:()=>z(L({kind:"number"})),boolean:()=>z(L({kind:"boolean"})),literal:(H)=>z(L({kind:"literal",value:H})),enum:(H)=>z(L({kind:"enum",values:H})),object:(H)=>z(L({kind:"object",shape:Object.fromEntries(Object.entries(H).map(([G,Q])=>[G,i(Q)]))})),array:(H)=>z(L({kind:"array",item:i(H)})),union:(H)=>z(L({kind:"union",members:H.map(i)})),json:()=>z(L({kind:"json"})),fromJSONSchema:(H,G={})=>{let Q=[],Z=v(H,G,"",Q);if(!Z||Q.length>0)throw new BH(Q.length>0?Q:["unreadable schema"]);return z(Z)}};function C0(H){let G=d.get(H);if(G)return h(G.node);return p(H.toJSONSchema())}function p(H){if(!(H.type!==void 0||H.enum!==void 0||H.const!==void 0||H.anyOf!==void 0||H.properties!==void 0||H.items!==void 0))return!1;for(let Q of Object.values(H.properties??{}))if(!p(Q))return!1;if(H.items&&!p(H.items))return!1;for(let Q of H.anyOf??[])if(!p(Q))return!1;return!0}function h(H){switch(H.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(H.shape).every((G)=>h(G.node));case"array":return h(H.item.node);case"union":return H.members.every((G)=>h(G.node));case"json":return!1}}function AH(H){if(typeof H!=="string")return null;let[G]=H.split(";",1),Q=G.trim().toLowerCase();return Q===""?null:Q}function FH(H){if(H===null)return!1;if(H==="application/json")return!0;let G=H.indexOf("/");return G>0&&H.endsWith("+json")&&H.length>G+1+5}var l=new WeakMap;function O0(H,G){l.set(H,{clientAddress:G})}function zH(H){return l.has(H)}function j0(H){return l.get(H)?.clientAddress}var LH=new WeakMap;function I0(H,G){LH.set(H,G)}function JH(H){return LH.get(H)??null}var s=new WeakMap;function q0(H,G){let Q=s.get(H)??[];if(!Q.includes(G))s.set(H,[...Q,G])}function w0(H){return s.get(H)??[]}class I{data;constructor(H){this.data=H}get(H){return this.data[H]}has(H){return this.data[H]!==void 0}toJSON(){return this.data}}function CH(H){return typeof H==="object"&&H!==null&&!(H instanceof Blob)}function iH(H,G){if(!G.includes(".")||Object.hasOwn(H,G))return[{path:[G],value:H[G]}];let Q=[{path:[],value:H}];for(let Z of G.split(".")){let X=[];for(let{path:$,value:U}of Q){if(Z==="*"){if(Array.isArray(U))U.forEach((W,K)=>X.push({path:[...$,K],value:W}));else if(CH(U))for(let[W,K]of Object.entries(U))X.push({path:[...$,W],value:K});continue}if(Array.isArray(U)&&/^\d+$/.test(Z)){X.push({path:[...$,Number(Z)],value:U[Number(Z)]});continue}X.push({path:[...$,Z],value:CH(U)&&Object.hasOwn(U,Z)?U[Z]:void 0})}Q=X}return Q}function VH(H){return H.join(".")}class tH{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;constructor(H,G,Q,Z){if(!H){let K=C.getStore().req;this.params=K.params,this.rawRequest=K.rawRequest,this.kind=K.kind,this.routePath=K.routePath,this.domain=K.domain??null}else this.params=G,this.rawRequest=H,this.routePath=Z,this.kind=Q??"api",this.domain=JH(H);this.headers=this.rawRequest.headers;let X=o(this.rawRequest.headers.get("Cookie")),$=new URL(this.rawRequest.url),U=new Map;for(let[K,M]of $.searchParams)if(U.has(K)){let D=U.get(K);if(Array.isArray(D))D.push(M),U.set(K,D);else U.set(K,[D,M])}else U.set(K,M);let W=Object.fromEntries(U.entries());this.search=new I(W),this.cookies=X}locale(){return C.getStore().locale}ctx(){return C.getStore()}isModelOriginated(){return zH(this.rawRequest)}get signal(){return this.rawRequest.signal}range(){return KH(this.rawRequest.headers.get("Range"))}refine(H){return{}}async parseBody(){let H=AH(this.rawRequest.headers.get("Content-Type"));if(FH(H))return new I(await this.parseJsonBody());if(H==="application/x-www-form-urlencoded"||H==="multipart/form-data"){let G;try{G=await this.rawRequest.formData()}catch{throw new B("The request body could not be read as a form.")}let Q=new Map;for(let[Z,X]of G.entries())if(Q.has(Z)){let $=Q.get(Z);if(Array.isArray($))$.push(X);else Q.set(Z,[$,X])}else Q.set(Z,X);return new I(Object.fromEntries(Q.entries()))}return new I({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let H;try{H=await this.rawRequest.text()}catch{throw new B("The request body could not be read.")}if(H.trim()==="")return{};let G;try{G=JSON.parse(H)}catch{throw new B("The request body is not valid JSON.")}if(G===null||typeof G!=="object")throw new B("The request body must be a JSON object.");return G}validateInput(H){if(PH(this.schema))return this.validateWithSchema(H);let G=H.toJSON()??{},Q={},Z=Object.entries(this.schema).map(([X,$])=>({key:X,rules:Object.entries($).map(([U,W])=>({rule:U,message:W,check:typeof W==="function"?null:this.ruleFor(X,U)}))}));for(let{key:X,rules:$}of Z)for(let{path:U,value:W}of iH(G,X)){let K=this.checkField(W,$);if(K.length>0){let M=Q[VH(U)]??=[];for(let D of K)if(!M.includes(D))M.push(D)}}if(this.addRefinements(Q,G),Object.keys(Q).length>0)throw new w(Q);return H}checkField(H,G){let Q=G.some(({rule:$})=>$==="required"),Z=H===void 0||H===null||H==="",X=[];for(let{rule:$,message:U,check:W}of G){let K=U,M=!1;if(typeof U==="function")K=U(H),M=typeof K>"u";else M=W(H);if(M)continue;if(Z&&!Q)continue;if($==="required")return[String(K)];if(!X.includes(String(K)))X.push(String(K))}return X}validateWithSchema(H){let G=this.schema.validate(H.toJSON()),Q={};if("issues"in G)for(let X of G.issues){let $=VH(X.path),U=Q[$]??=[];if(!U.includes(X.message))U.push(X.message)}let Z="value"in G?new I(G.value):H;if(this.addRefinements(Q,Z.toJSON()),Object.keys(Q).length>0)throw new w(Q);return Z}addRefinements(H,G){for(let[Q,Z]of Object.entries(this.refine(G)??{})){let X=H[Q]??[];H[Q]=X.includes(Z)?X:[...X,Z]}}ruleFor(H,G){try{return DH(G)}catch(Q){if(Q instanceof J)throw new J(`${this.constructor.name}.schema.${H}: ${Q.message}`);throw Q}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let H=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(H)}}catch(G){if(!(G instanceof w))throw G;return{isValid:!1,errors:G.errors,input:H}}}}class rH extends B{error;constructor(H="Not authorized"){super(H);this.name="AuthorizationError",this.error=H,this.payload={api:{status:401,data:{error:m("authorization",this.error,401)}},view:{}}}}class a extends B{static apiStatus=403;error;constructor(H="Insufficient permissions"){super(H);this.name="InsufficientPermissionsError",this.error=H,this.payload={api:{status:a.apiStatus,data:{error:m("permission",this.error,a.apiStatus)}},view:{status:403}}}}class HH extends B{total;constructor(H){super("Range not satisfiable");this.total=H;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:e("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":TH(H),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class _ extends B{fileName;constructor(H){super("File not found");this.fileName=H;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:e("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{}}}}class lH extends B{constructor(H={}){super("Authentication error");this.name="AuthenticationError";let G=H.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:m("authentication","Authentication error",401)}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:G}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:G}}}}}class N{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return _H(this.getFacadeAccessor())}}class GH{async delete(H){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(H){let G=typeof H==="string"?{name:H}:H,Q=await this.fetch({name:G.name,bucket:G.bucket});if(!Q.ok)throw new _(G.name);let Z=Q.headers.get("Content-Type")??"application/octet-stream",X=Q.headers.get("ETag")??void 0,$=Q.headers.get("Last-Modified"),U=$?new Date($):void 0;if(G.range){let M=await Q.blob();return{body:M,start:0,end:M.size-1,total:M.size,partial:!1,type:Z,etag:X,lastModified:U,name:G.name}}let W=Number(Q.headers.get("Content-Length")),K=Number.isFinite(W)?W:0;return{body:Q.body,start:0,end:K-1,total:K,partial:!1,type:Z,etag:X,lastModified:U,name:G.name}}async size(H){let G=typeof H==="string"?H:H.name,Q=typeof H==="string"?void 0:H.bucket,Z=await this.fetch({name:G,bucket:Q});if(!Z.ok)throw new _(G);let X=Number(Z.headers.get("Content-Length"));if(Number.isFinite(X))return await Z.body?.cancel(),X;return(await Z.blob()).size}}function OH(H,G){if(!G)return H;let Q=H.getReader(),Z=!1,X,$=()=>{if(Z=!0,X)G.removeEventListener("abort",X)};return new ReadableStream({start(U){if(X=()=>{if(Z)return;$(),U.error(G.reason),Q.cancel(G.reason).catch(()=>{})},G.aborted)X();else G.addEventListener("abort",X,{once:!0})},async pull(U){let W;try{W=await Q.read()}catch(K){if(Z)return;$(),U.error(K);return}if(Z)return;if(W.done){$(),U.close();return}U.enqueue(W.value)},cancel(U){return $(),Q.cancel(U)}},{highWaterMark:0})}import{readdir as sH,unlink as aH}from"fs/promises";import{isAbsolute as eH,relative as H0,resolve as jH,sep as G0}from"path";class QH extends GH{configured;constructor(H){super();this.configured=H}get folderPath(){return this.configured??`${S()}/storage`}async put(H,{signal:G}={}){G?.throwIfAborted();let Q,Z;if(H instanceof Blob)Q=H,Z=`${Bun.randomUUIDv7()}.${H.type.split("/")[1].split(";")[0]}`;else Q=H.body,Z=H.name;let X=Q instanceof Buffer?Q:Q instanceof Blob||Q instanceof File?Buffer.from(await Q.arrayBuffer()):"",$=`${this.folderPath}/${Z}`;return G?.throwIfAborted(),await Bun.write($,X),Z}async fetch(H,{signal:G}={}){G?.throwIfAborted();let Q=process.env.BUCKET_NAME,Z;if(typeof H==="string")Z=H;else Q=H.bucket??Q,Z=H.name;if(!Z)throw Error("Object name has to be specified");let X=`${this.folderPath}/${Z}`,$=Bun.file(X),U=OH(Bun.file(X).stream(),G),W=new Date($.lastModified).toUTCString();return new Response(U,{headers:{"Content-Type":$.type,"Content-Length":String($.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":W}})}async read(H){let G=typeof H==="string"?{name:H}:H,{name:Q,range:Z=null}=G;if(!Q)throw Error("Object name has to be specified");let X=Bun.file(`${this.folderPath}/${Q}`);if(!await X.exists())throw new _(Q);let $=X.size,U=Z?MH(Z,$):null;if(Z&&!U)throw new HH($);let W=U?.start??0,K=U?U.end:$-1;return{body:U?X.slice(W,K+1):X,start:W,end:K,total:$,partial:Boolean(U),type:X.type||"application/octet-stream",lastModified:new Date(X.lastModified),name:Q}}async size(H){let G=typeof H==="string"?H:H.name,Q=Bun.file(`${this.folderPath}/${G}`);if(!await Q.exists())throw new _(G);return Q.size}async delete(H){let G=typeof H==="string"?H:H.name;if(!G)throw Error("Object name has to be specified");let Q=jH(this.folderPath),Z=jH(Q,G),X=H0(Q,Z);if(!X||X===".."||X.startsWith(`..${G0}`)||eH(X))throw Error(`Refusing to delete "${G}": it is outside the storage folder`);try{await aH(Z)}catch($){if($?.code==="ENOENT")return;throw $}}async list(){return await sH(this.folderPath)}}function $4(H){return H}function xH(){return{driver:new QH}}class XH{static token="filesystem";driver;constructor(H={}){this.driver=H.driver??xH().driver}}import{Buffer as X0}from"buffer";async function IH(H){try{return(await import("sharp")).default}catch(G){throw Error(`${H} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:G})}}class Z0 extends N{static getFacadeAccessor(){return XH}static async put(H,G={}){return this.getFacadeRoot().driver.put(H,G)}static async metadata(H){let G=X0.from(await H.arrayBuffer()),Q=await IH("Storage.metadata()");try{return await Q(G).metadata()}catch{return{}}}static async fetch(H,G={}){return G.signal?.throwIfAborted(),this.getFacadeRoot().driver.fetch(H,G)}static async read(H,G={}){let Q=typeof H==="string"?{name:H}:{...H},Z="range"in G?G.range??null:Q.range!==void 0?Q.range:C.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...Q,range:Z})}static list(H){return this.getFacadeRoot().driver.list(H)}static async delete(H){return this.getFacadeRoot().driver.delete(H)}}import{mkdir as ZH,readdir as $0,access as U0}from"fs/promises";async function $H(H){try{return await U0(H),!0}catch{return!1}}class UH{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${S()}/storage/logs`}constructor(H){this.config=H}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch((H)=>{console.error("Log storage unavailable, file logging disabled",H)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let H=`${S()}/storage`;if(!await $H(H))await ZH(H);if(!await $H(this.logsDirPath))await ZH(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await $H(this.logsDirPath))await ZH(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let Q=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(Q),this.fileSize=0,this.writerSize=0}let G=(await $0(this.logsDirPath)).sort().reverse()[0];if(G){let Q=Bun.file(`${this.logsDirPath}/${G}`);if(Q.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${G}`,this.writer=Q.writer(),this.writer.write(await Q.text()),this.writer.write(`
5
- `),this.writer.flush(),this.fileSize=Q.size}if(!this.writer){let Q=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${Q}`;let Z=Bun.file(`${this.logsDirPath}/${Q}`);this.writer=Z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log(H,G,Q={}){if(!this.isReady)await this.boot();let Z=C.getStore(),X={};if(Z)X={url:Z.req.rawRequest.url,method:Z.req.rawRequest.method,headers:Z.req.rawRequest.headers,body:Z.req.rawRequest.body};let $={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:H,message:G,metadata:{...X,...Q}},U="";try{U=JSON.stringify($)}catch(W){console.log("Error parsing log object",W)}try{let W=this.config.onLogCreated($);if(W instanceof Promise)W.catch((K)=>console.error("Error in onLogCreated",K))}catch(W){console.error("Error in onLogCreated",W)}if(!this.writer)return;this.writerSize+=U.length,this.fileSize+=U.length;try{this.writer.write(U),this.writer.write(`
6
- `),this.tryFlush()}catch(W){console.error("Error writing log",W)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class W0 extends N{static getFacadeAccessor(){return UH}static debug(H,G){this.getFacadeRoot().log("debug",H,G)}static info(H,G){this.getFacadeRoot().log("info",H,G)}static notice(H,G){this.getFacadeRoot().log("notice",H,G)}static warning(H,G){this.getFacadeRoot().log("warning",H,G)}static error(H,G){this.getFacadeRoot().log("error",H,G)}static critical(H,G){this.getFacadeRoot().log("critical",H,G)}static alert(H,G){this.getFacadeRoot().log("alert",H,G)}static emergency(H,G){this.getFacadeRoot().log("emergency",H,G)}}class K0{config;static token="redis";instance=null;constructor(H={}){this.config=H}get client(){return this.instance??=new(M0())(this.config.url,this.config.options)}set client(H){this.instance=H}close(){let H=this.instance;this.instance=null,H?.close()}}function M0(){let H=globalThis.Bun?.RedisClient;if(typeof H!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return H}
7
- export{WH as Me,wH as Ne,Y0 as Oe,AH as Pe,O0 as Qe,j0 as Re,KH as Se,MH as Te,R0 as Ue,P0 as Ve,B0 as We,TH as Xe,I0 as Ye,JH as Ze,q0 as _e,w0 as $e,w as af,J as bf,BH as cf,J0 as df,C0 as ef,tH as ff,rH as gf,a as hf,HH as if,_ as jf,lH as kf,N as lf,IH as mf,GH as nf,OH as of,QH as pf,$4 as qf,xH as rf,XH as sf,Z0 as tf,UH as uf,W0 as vf,K0 as wf};
8
-
9
- //# debugId=7E9BF6B66E88523664756E2164756E21