@kyro-cms/core 0.12.44 → 0.12.45

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.
Files changed (311) hide show
  1. package/dist/{WebhookService-C19xR8qE.d.ts → WebhookService-CZf_na-J.d.ts} +1 -1
  2. package/dist/{WebhookService-BBcCHBo8.d.cts → WebhookService-DgIx21X-.d.cts} +1 -1
  3. package/dist/api-handler-graphql.cjs +1 -1
  4. package/dist/api-handler-graphql.js +2 -1
  5. package/dist/api-handler-trpc.cjs +1 -1
  6. package/dist/api-handler-trpc.js +2 -1
  7. package/dist/api-handler.cjs +1 -1
  8. package/dist/api-handler.js +1 -1
  9. package/dist/{base-yXdYZxFK.d.ts → base-7vJMzr4V.d.ts} +1 -1
  10. package/dist/{base-C2iwjdJQ.d.cts → base-DDEmdRqV.d.cts} +1 -1
  11. package/dist/bcryptjs-AZA6WEN2.js +2 -0
  12. package/dist/bcryptjs-WIQSWJGK.cjs +1 -0
  13. package/dist/better-sqlite3-42Q3FG3E.js +2 -0
  14. package/dist/better-sqlite3-5IISPX34.cjs +1 -0
  15. package/dist/bootstrap-7CI3NVSY.js +1 -0
  16. package/dist/bootstrap-DOOM2CNQ.cjs +1 -0
  17. package/dist/bowser-FI5JQGKZ.js +11 -0
  18. package/dist/bowser-VX6B6ZSE.cjs +10 -0
  19. package/dist/chokidar-24HVS6XD.cjs +5 -0
  20. package/dist/chokidar-43DT7CVN.js +6 -0
  21. package/dist/chunk-26Q7JXM4.cjs +3 -0
  22. package/dist/chunk-2BUODBE2.js +2 -0
  23. package/dist/chunk-2WFTETFB.js +2 -0
  24. package/dist/chunk-35PGCW3S.cjs +1 -0
  25. package/dist/chunk-3VXEK5ZW.cjs +1 -0
  26. package/dist/chunk-45TJAB5X.js +301 -0
  27. package/dist/chunk-5DWYVUQR.cjs +1 -0
  28. package/dist/chunk-5LPNEYK5.cjs +1 -0
  29. package/dist/chunk-66BJXVFJ.js +2 -0
  30. package/dist/chunk-6KRR7YHA.js +2 -0
  31. package/dist/chunk-6KUL2BSA.cjs +133 -0
  32. package/dist/chunk-6MSS5X77.js +2 -0
  33. package/dist/chunk-6QWLXJ7L.js +2 -0
  34. package/dist/chunk-6V3AP7HR.cjs +269 -0
  35. package/dist/chunk-73D2PNHD.cjs +7 -0
  36. package/dist/chunk-7ACHOBWY.cjs +13 -0
  37. package/dist/chunk-7AQSH3KR.js +2 -0
  38. package/dist/chunk-7GGZA5YU.cjs +2 -0
  39. package/dist/chunk-7I6URA6F.js +4 -0
  40. package/dist/chunk-7JWQ2PZP.cjs +1 -0
  41. package/dist/chunk-7SSFHJTR.js +57 -0
  42. package/dist/chunk-7T35572E.js +75 -0
  43. package/dist/chunk-7V67ONUD.js +4 -0
  44. package/dist/chunk-7WMMKGEO.cjs +1 -0
  45. package/dist/chunk-A73AVVFR.js +11 -0
  46. package/dist/chunk-AK754S3T.cjs +2 -0
  47. package/dist/chunk-AMGJ5AFH.cjs +1 -0
  48. package/dist/chunk-ATBH763U.js +2 -0
  49. package/dist/chunk-B3GDQ7UI.cjs +114 -0
  50. package/dist/chunk-BAVN7VDR.cjs +1 -0
  51. package/dist/chunk-BCEE4NBZ.cjs +2 -0
  52. package/dist/{chunk-J4252I5B.cjs → chunk-BHR7OAU4.cjs} +4 -4
  53. package/dist/chunk-BLH2MRK4.js +2 -0
  54. package/dist/chunk-BPMA2ECA.js +10 -0
  55. package/dist/chunk-BUNLC3II.cjs +1 -0
  56. package/dist/chunk-C2PXMVR5.js +2 -0
  57. package/dist/chunk-CGPAS4U5.js +4 -0
  58. package/dist/chunk-DS5DE5BU.js +2 -0
  59. package/dist/chunk-DUO523BH.cjs +1 -0
  60. package/dist/chunk-DVWYO3KK.cjs +1 -0
  61. package/dist/chunk-E27KEZPT.js +2 -0
  62. package/dist/chunk-EHWUALGH.cjs +1 -0
  63. package/dist/chunk-EN65ZEK2.cjs +2 -0
  64. package/dist/chunk-EOOZDOL7.js +3 -0
  65. package/dist/chunk-EZIDQBXI.cjs +1 -0
  66. package/dist/chunk-F4ITQ6XQ.cjs +3 -0
  67. package/dist/chunk-FLM37UVD.js +2 -0
  68. package/dist/chunk-GIS6X43A.cjs +3 -0
  69. package/dist/chunk-GNEVCEJU.cjs +3 -0
  70. package/dist/chunk-GNOSG3PK.cjs +1 -0
  71. package/dist/chunk-HLAEJB5R.js +384 -0
  72. package/dist/chunk-HPYH7GTS.cjs +1 -0
  73. package/dist/chunk-HT44I66C.js +24 -0
  74. package/dist/chunk-HTYVI2HK.cjs +9 -0
  75. package/dist/chunk-ICVQWR2A.js +2 -0
  76. package/dist/chunk-IP6JUEH3.js +3 -0
  77. package/dist/chunk-IPXOY4RI.js +2 -0
  78. package/dist/chunk-J6U5LWZ7.js +11 -0
  79. package/dist/{chunk-UHFDH3PG.js → chunk-JT36FTHY.cjs} +4 -4
  80. package/dist/chunk-JUJZOG6P.js +2 -0
  81. package/dist/{chunk-2BTRHVT3.cjs → chunk-K7YNEKVE.js} +5 -4
  82. package/dist/chunk-KCHPADCH.cjs +7 -0
  83. package/dist/chunk-KH7LM52S.js +3 -0
  84. package/dist/chunk-LEBM6ZSZ.cjs +10 -0
  85. package/dist/chunk-LQ3YZTPU.cjs +15 -0
  86. package/dist/chunk-LY7N3UHH.cjs +23 -0
  87. package/dist/chunk-M6ESQ5TE.cjs +56 -0
  88. package/dist/chunk-MCZ3YZ2L.js +2 -0
  89. package/dist/chunk-MP5VC5ER.cjs +1 -0
  90. package/dist/chunk-MVX2PYJJ.cjs +1 -0
  91. package/dist/chunk-MY42EWZP.js +2 -0
  92. package/dist/chunk-MZOWPV4D.js +20 -0
  93. package/dist/chunk-NGNJSUGL.cjs +1 -0
  94. package/dist/chunk-NWCREF47.js +3 -0
  95. package/dist/chunk-OMWQVPV7.js +14 -0
  96. package/dist/chunk-ORG67NXX.js +3 -0
  97. package/dist/chunk-OSAVAYJZ.js +16 -0
  98. package/dist/chunk-P7XYIKL6.cjs +300 -0
  99. package/dist/chunk-PBOZJOKN.js +2 -0
  100. package/dist/chunk-PITMDQYN.cjs +18 -0
  101. package/dist/chunk-PL5AIE6F.js +2 -0
  102. package/dist/chunk-QC4YXUBT.cjs +383 -0
  103. package/dist/chunk-QDHP5E4P.cjs +2 -0
  104. package/dist/chunk-QYI3GOHF.cjs +1 -0
  105. package/dist/chunk-R3NEPC4I.js +3 -0
  106. package/dist/chunk-R4LXRAMX.js +2 -0
  107. package/dist/chunk-S5HTTLN7.cjs +2 -0
  108. package/dist/chunk-STX5V7HG.cjs +20 -0
  109. package/dist/chunk-SVYUTQVE.js +115 -0
  110. package/dist/chunk-SYEP5QLG.js +19 -0
  111. package/dist/chunk-TR3ZS3T3.js +3 -0
  112. package/dist/chunk-UB5TJHQR.js +2 -0
  113. package/dist/chunk-UD6ZPO7T.js +2 -0
  114. package/dist/chunk-UK43ADRO.js +270 -0
  115. package/dist/chunk-UNYXWPLZ.cjs +2 -0
  116. package/dist/chunk-VBPAAQEF.js +2 -0
  117. package/dist/chunk-VIUU4D5I.js +2 -0
  118. package/dist/chunk-VJ2WMKPK.js +21 -0
  119. package/dist/chunk-VOQUO2EZ.cjs +74 -0
  120. package/dist/chunk-VQ53TFYA.cjs +1 -0
  121. package/dist/chunk-VRZC4TTF.cjs +1 -0
  122. package/dist/chunk-W46LZ4MY.js +2 -0
  123. package/dist/chunk-WCFHS7EZ.cjs +1 -0
  124. package/dist/chunk-WGESLAWV.js +8 -0
  125. package/dist/chunk-WSP7PSXC.js +8 -0
  126. package/dist/chunk-X54XZACS.cjs +10 -0
  127. package/dist/{chunk-Q2UYCYKV.js → chunk-XBH4YMC7.js} +5 -4
  128. package/dist/chunk-XDE7CFV6.cjs +19 -0
  129. package/dist/chunk-XOACKBG7.js +4 -0
  130. package/dist/chunk-XPPVX4GQ.cjs +1 -0
  131. package/dist/chunk-ZJE3VAAW.js +134 -0
  132. package/dist/chunk-ZO3YB5DK.cjs +1 -0
  133. package/dist/chunk-ZOVH6QT5.cjs +1 -0
  134. package/dist/chunk-ZYDOF65Q.cjs +1 -0
  135. package/dist/cli/index.cjs +197 -78
  136. package/dist/cli/index.js +198 -78
  137. package/dist/client.cjs +1 -1
  138. package/dist/client.d.cts +1 -1
  139. package/dist/client.d.ts +1 -1
  140. package/dist/client.js +2 -1
  141. package/dist/d1-5ZQJOFDX.cjs +1 -0
  142. package/dist/d1-VPH75GI2.js +2 -0
  143. package/dist/dist-es-3SSNUZST.cjs +1 -0
  144. package/dist/dist-es-6SVFVYN3.js +1 -0
  145. package/dist/dist-es-6TQTDPE7.js +2 -0
  146. package/dist/dist-es-A5OF2STN.cjs +2 -0
  147. package/dist/dist-es-BOW5V247.cjs +6 -0
  148. package/dist/dist-es-CRIMATLL.cjs +2 -0
  149. package/dist/dist-es-DL3VLVP6.cjs +1 -0
  150. package/dist/dist-es-EMUQ6ZNZ.js +3 -0
  151. package/dist/dist-es-MNIQZC4U.js +2 -0
  152. package/dist/dist-es-P25IKLBI.cjs +1 -0
  153. package/dist/dist-es-SJ76GYCI.js +2 -0
  154. package/dist/dist-es-SRPWSAF4.cjs +1 -0
  155. package/dist/dist-es-T2H2W5BX.cjs +3 -0
  156. package/dist/dist-es-TX4DBXEW.js +3 -0
  157. package/dist/dist-es-U4ZB3ZDA.js +7 -0
  158. package/dist/dist-es-XZBHIIKY.js +4 -0
  159. package/dist/drizzle/index.cjs +1 -1
  160. package/dist/drizzle/index.d.cts +2 -2
  161. package/dist/drizzle/index.d.ts +2 -2
  162. package/dist/drizzle/index.js +1 -1
  163. package/dist/drizzle-orm-47ELDEM6.cjs +1 -0
  164. package/dist/drizzle-orm-7YTX5NTT.js +1 -0
  165. package/dist/event-streams-25YJ2Z6R.js +1 -0
  166. package/dist/event-streams-JBMWCI2O.cjs +1 -0
  167. package/dist/fields/index.cjs +1 -1
  168. package/dist/fields/index.js +1 -1
  169. package/dist/fs-DGKZLRM6.cjs +1 -0
  170. package/dist/fs-YZJ5FM6J.js +2 -0
  171. package/dist/graphql/index.cjs +1 -1
  172. package/dist/graphql/index.d.cts +2 -2
  173. package/dist/graphql/index.d.ts +2 -2
  174. package/dist/graphql/index.js +1 -1
  175. package/dist/{index-DTz6u7w9.d.cts → index-BJ1rwHxk.d.cts} +1 -1
  176. package/dist/{index-BeQtbl3z.d.ts → index-BTjlptCL.d.ts} +1 -1
  177. package/dist/index.cjs +28 -46
  178. package/dist/index.d.cts +23 -9
  179. package/dist/index.d.ts +23 -9
  180. package/dist/index.js +29 -46
  181. package/dist/integration.cjs +1 -1
  182. package/dist/integration.js +1 -1
  183. package/dist/jsonwebtoken-DFB6ZBZA.cjs +8 -0
  184. package/dist/jsonwebtoken-S7BG2YWK.js +9 -0
  185. package/dist/lib-5QYYN6ML.cjs +12 -0
  186. package/dist/lib-IYW32OER.js +13 -0
  187. package/dist/loadSso-JY4WDQPS.cjs +2 -0
  188. package/dist/loadSso-YTG2GQGW.js +3 -0
  189. package/dist/local-VDCSEMC2.js +1 -0
  190. package/dist/local-YCWBUF3R.cjs +1 -0
  191. package/dist/media-3Z6YW5J4.cjs +1 -0
  192. package/dist/media-HK2IZMUZ.js +1 -0
  193. package/dist/mongo-auth-adapter-7K64Y2QM.cjs +1 -0
  194. package/dist/mongo-auth-adapter-BUKINEZL.js +1 -0
  195. package/dist/mongodb/index.cjs +1 -1
  196. package/dist/mongodb/index.d.cts +2 -2
  197. package/dist/mongodb/index.d.ts +2 -2
  198. package/dist/mongodb/index.js +1 -1
  199. package/dist/nodemailer-AXROO37D.js +54 -0
  200. package/dist/nodemailer-IDML4L6W.cjs +53 -0
  201. package/dist/postgres-auth-adapter-2M4RNEY3.cjs +1 -0
  202. package/dist/postgres-auth-adapter-MKSHIJDL.js +1 -0
  203. package/dist/postgres-js-3Y54EXVQ.cjs +1 -0
  204. package/dist/postgres-js-INQPBHJP.js +1 -0
  205. package/dist/redis-adapter-EGMUN65D.cjs +1 -0
  206. package/dist/redis-adapter-SXOXLHNH.js +1 -0
  207. package/dist/rest/index.cjs +1 -1
  208. package/dist/rest/index.d.cts +5 -5
  209. package/dist/rest/index.d.ts +5 -5
  210. package/dist/rest/index.js +1 -1
  211. package/dist/schema-RT6WSUYC.cjs +1 -0
  212. package/dist/schema-XC5ISGNR.js +2 -0
  213. package/dist/signin-KZBIAHGS.js +3 -0
  214. package/dist/signin-VFBLX7EL.cjs +2 -0
  215. package/dist/sqlite-adapter-DV7ZX2EJ.js +1 -0
  216. package/dist/sqlite-adapter-ZTABLT2X.cjs +1 -0
  217. package/dist/src-6LAUXXDM.cjs +1 -0
  218. package/dist/src-GZRZ4VAO.js +1 -0
  219. package/dist/sso-oidc-54BIRYR6.cjs +2 -0
  220. package/dist/sso-oidc-SX5OIQGG.js +3 -0
  221. package/dist/sts-HVGDJYIF.js +3 -0
  222. package/dist/sts-YLXXIB3X.cjs +2 -0
  223. package/dist/templates/index.cjs +1 -1
  224. package/dist/templates/index.d.cts +1 -1
  225. package/dist/templates/index.d.ts +1 -1
  226. package/dist/templates/index.js +1 -1
  227. package/dist/trpc/index.cjs +1 -1
  228. package/dist/trpc/index.d.cts +7 -7
  229. package/dist/trpc/index.d.ts +7 -7
  230. package/dist/trpc/index.js +1 -1
  231. package/dist/{types-CaXXmV9h.d.ts → types-CYGXsNcJ.d.ts} +5 -5
  232. package/dist/{types-BjivdGbU.d.cts → types-DOKMyC3y.d.cts} +5 -5
  233. package/dist/ws/index.cjs +1 -1
  234. package/dist/ws/index.js +1 -1
  235. package/package.json +2 -2
  236. package/dist/bootstrap-ROSTPMVL.js +0 -1
  237. package/dist/bootstrap-WW5NJ6EB.cjs +0 -1
  238. package/dist/chunk-3CVLI5C5.cjs +0 -3
  239. package/dist/chunk-3Q2WUG63.cjs +0 -2
  240. package/dist/chunk-3RSMK4DA.cjs +0 -2
  241. package/dist/chunk-4IGWJMBY.cjs +0 -2
  242. package/dist/chunk-4ORJMSJU.cjs +0 -1
  243. package/dist/chunk-4RMFCTWH.js +0 -1
  244. package/dist/chunk-5B6X2GBJ.js +0 -2
  245. package/dist/chunk-5J6HXUF6.js +0 -1
  246. package/dist/chunk-5KOQYQEE.js +0 -1
  247. package/dist/chunk-5SEHX7ON.js +0 -1
  248. package/dist/chunk-6ROHVUXF.js +0 -1
  249. package/dist/chunk-6SPPR5JZ.js +0 -3
  250. package/dist/chunk-7IVN6TTY.js +0 -133
  251. package/dist/chunk-AHSFSERC.cjs +0 -1
  252. package/dist/chunk-B5XWYVWK.js +0 -1
  253. package/dist/chunk-BGX27ZRG.cjs +0 -300
  254. package/dist/chunk-C2W5PSHC.js +0 -300
  255. package/dist/chunk-CCUQZ66T.cjs +0 -133
  256. package/dist/chunk-D5P2IPGX.cjs +0 -3
  257. package/dist/chunk-EPMGPNBE.js +0 -1
  258. package/dist/chunk-FHJJKFAU.cjs +0 -1
  259. package/dist/chunk-FVZ5RFLO.js +0 -2
  260. package/dist/chunk-FZ6Q2EBJ.cjs +0 -20
  261. package/dist/chunk-G3J2EU5D.cjs +0 -1
  262. package/dist/chunk-G7SSHELM.cjs +0 -1
  263. package/dist/chunk-GKYEJ2UF.js +0 -1
  264. package/dist/chunk-GO34AOBZ.cjs +0 -1
  265. package/dist/chunk-GYQMNXXW.cjs +0 -114
  266. package/dist/chunk-HLSB2MCK.js +0 -1
  267. package/dist/chunk-HQP2Y7QQ.js +0 -251
  268. package/dist/chunk-HS2KNFAB.cjs +0 -2
  269. package/dist/chunk-HVXO3OFB.cjs +0 -1
  270. package/dist/chunk-IETGL7WJ.js +0 -1
  271. package/dist/chunk-IFJ73O3A.cjs +0 -1
  272. package/dist/chunk-ILEZ3NYX.cjs +0 -2
  273. package/dist/chunk-INB4LNA6.js +0 -90
  274. package/dist/chunk-K6WUOU6P.js +0 -1
  275. package/dist/chunk-KD7LUCFY.cjs +0 -1
  276. package/dist/chunk-KDNYHLD2.js +0 -1
  277. package/dist/chunk-LHW4R367.js +0 -1
  278. package/dist/chunk-MIOMMB23.cjs +0 -1
  279. package/dist/chunk-N5VNHUJS.cjs +0 -4
  280. package/dist/chunk-NRLIGDYF.js +0 -1
  281. package/dist/chunk-NY47CFVP.cjs +0 -1
  282. package/dist/chunk-NZJAGASC.cjs +0 -251
  283. package/dist/chunk-OG7CNQGU.js +0 -1
  284. package/dist/chunk-PP5S2UBV.js +0 -0
  285. package/dist/chunk-PP7W5UKL.js +0 -2
  286. package/dist/chunk-Q3Q7BJVQ.cjs +0 -1
  287. package/dist/chunk-QCA3AP3M.cjs +0 -1
  288. package/dist/chunk-QOCHBPMK.js +0 -2
  289. package/dist/chunk-QYFU5Y7S.js +0 -3
  290. package/dist/chunk-RHCWCG3O.js +0 -114
  291. package/dist/chunk-SK2Q4PRV.cjs +0 -90
  292. package/dist/chunk-TFBHE5FF.cjs +0 -1
  293. package/dist/chunk-UBRYJP2G.js +0 -1
  294. package/dist/chunk-V65NPSR5.cjs +0 -1
  295. package/dist/chunk-VGQ4VUG6.js +0 -2
  296. package/dist/chunk-W7C6SJXZ.js +0 -20
  297. package/dist/chunk-WIZ6C5QZ.cjs +0 -1
  298. package/dist/chunk-ZIWJJRWQ.js +0 -4
  299. package/dist/chunk-ZUVP4UK7.cjs +0 -1
  300. package/dist/media-L5XDD47D.js +0 -1
  301. package/dist/media-OUBQTIQP.cjs +0 -1
  302. package/dist/mongo-auth-adapter-5TJO5J5U.js +0 -1
  303. package/dist/mongo-auth-adapter-JVE5M3S4.cjs +0 -1
  304. package/dist/postgres-auth-adapter-33QOIRXT.js +0 -1
  305. package/dist/postgres-auth-adapter-JKDYYULH.cjs +0 -1
  306. package/dist/redis-adapter-NN3H4GRX.js +0 -1
  307. package/dist/redis-adapter-OUKQGYCH.cjs +0 -1
  308. package/dist/schema-HIUSHSUI.cjs +0 -1
  309. package/dist/schema-KFYUM674.js +0 -1
  310. package/dist/sqlite-adapter-GTTVSXRV.cjs +0 -1
  311. package/dist/sqlite-adapter-UPANATIW.js +0 -1
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();var x=class{constructor(r){this.table=r;}static[chunkVRZC4TTF_cjs.a]="ColumnAliasProxyHandler";get(r,t){return t==="table"?this.table:r[t]}},A=class{constructor(r,t){this.alias=r,this.replaceOriginalName=t;}static[chunkVRZC4TTF_cjs.a]="TableAliasProxyHandler";get(r,t){if(t===chunkVRZC4TTF_cjs.t.Symbol.IsAlias)return true;if(t===chunkVRZC4TTF_cjs.t.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===chunkVRZC4TTF_cjs.t.Symbol.OriginalName)return this.alias;if(t===chunkVRZC4TTF_cjs.l)return {...r[chunkVRZC4TTF_cjs.l],name:this.alias,isAlias:true};if(t===chunkVRZC4TTF_cjs.t.Symbol.Columns){let o=r[chunkVRZC4TTF_cjs.t.Symbol.Columns];if(!o)return o;let a={};return Object.keys(o).map(l=>{a[l]=new Proxy(o[l],new x(new Proxy(r,this)));}),a}let i=r[t];return chunkVRZC4TTF_cjs.c(i,chunkVRZC4TTF_cjs.d)?new Proxy(i,new x(new Proxy(r,this))):i}},P=class{constructor(r){this.alias=r;}static[chunkVRZC4TTF_cjs.a]="RelationTableAliasProxyHandler";get(r,t){return t==="sourceTable"?pe(r.sourceTable,this.alias):r[t]}};function pe(e,r){return new Proxy(e,new A(r,false))}function Ke(e,r){return new Proxy(e,new P(r))}function Ne(e,r){return new Proxy(e,new x(new Proxy(e.table,new A(r,false))))}function ge(e,r){return new chunkVRZC4TTF_cjs.A.Aliased(z(e.sql,r),e.fieldAlias)}function z(e,r){return chunkVRZC4TTF_cjs.J.join(e.queryChunks.map(t=>chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.d)?Ne(t,r):chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.A)?z(t,r):chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.A.Aliased)?ge(t,r):t))}chunkBUNLC3II_cjs.h();var H=class{static[chunkVRZC4TTF_cjs.a]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(r){return this.then(void 0,r)}finally(r){return this.then(t=>(r?.(),t),t=>{throw r?.(),t})}then(r,t){return this.execute().then(r,t)}};chunkBUNLC3II_cjs.h();var j=class extends Error{static[chunkVRZC4TTF_cjs.a]="DrizzleError";constructor({message:r,cause:t}){super(r),this.name="DrizzleError",this.cause=t;}},M=class e extends Error{constructor(r,t,i){super(`Failed query: ${r}
2
+ params: ${t}`),this.query=r,this.params=t,this.cause=i,Error.captureStackTrace(this,e),i&&(this.cause=i);}},U=class extends j{static[chunkVRZC4TTF_cjs.a]="TransactionRollbackError";constructor(){super({message:"Rollback"});}};chunkBUNLC3II_cjs.h();function m(e,r){return chunkVRZC4TTF_cjs.D(r)&&!chunkVRZC4TTF_cjs.y(e)&&!chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.H)&&!chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.K)&&!chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.d)&&!chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.t)&&!chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.N)?new chunkVRZC4TTF_cjs.H(e,r):e}var W=(e,r)=>chunkVRZC4TTF_cjs.J`${e} = ${m(r,e)}`,G=(e,r)=>chunkVRZC4TTF_cjs.J`${e} <> ${m(r,e)}`;function X(...e){let r=e.filter(t=>t!==void 0);if(r.length!==0)return r.length===1?new chunkVRZC4TTF_cjs.A(r):new chunkVRZC4TTF_cjs.A([new chunkVRZC4TTF_cjs.z("("),chunkVRZC4TTF_cjs.J.join(r,new chunkVRZC4TTF_cjs.z(" and ")),new chunkVRZC4TTF_cjs.z(")")])}function Y(...e){let r=e.filter(t=>t!==void 0);if(r.length!==0)return r.length===1?new chunkVRZC4TTF_cjs.A(r):new chunkVRZC4TTF_cjs.A([new chunkVRZC4TTF_cjs.z("("),chunkVRZC4TTF_cjs.J.join(r,new chunkVRZC4TTF_cjs.z(" or ")),new chunkVRZC4TTF_cjs.z(")")])}function Z(e){return chunkVRZC4TTF_cjs.J`not ${e}`}var _=(e,r)=>chunkVRZC4TTF_cjs.J`${e} > ${m(r,e)}`,v=(e,r)=>chunkVRZC4TTF_cjs.J`${e} >= ${m(r,e)}`,ee=(e,r)=>chunkVRZC4TTF_cjs.J`${e} < ${m(r,e)}`,re=(e,r)=>chunkVRZC4TTF_cjs.J`${e} <= ${m(r,e)}`;function te(e,r){return Array.isArray(r)?r.length===0?chunkVRZC4TTF_cjs.J`false`:chunkVRZC4TTF_cjs.J`${e} in ${r.map(t=>m(t,e))}`:chunkVRZC4TTF_cjs.J`${e} in ${m(r,e)}`}function ne(e,r){return Array.isArray(r)?r.length===0?chunkVRZC4TTF_cjs.J`true`:chunkVRZC4TTF_cjs.J`${e} not in ${r.map(t=>m(t,e))}`:chunkVRZC4TTF_cjs.J`${e} not in ${m(r,e)}`}function ie(e){return chunkVRZC4TTF_cjs.J`${e} is null`}function oe(e){return chunkVRZC4TTF_cjs.J`${e} is not null`}function se(e){return chunkVRZC4TTF_cjs.J`exists ${e}`}function ae(e){return chunkVRZC4TTF_cjs.J`not exists ${e}`}function le(e,r,t){return chunkVRZC4TTF_cjs.J`${e} between ${m(r,e)} and ${m(t,e)}`}function ce(e,r,t){return chunkVRZC4TTF_cjs.J`${e} not between ${m(r,e)} and ${m(t,e)}`}function ue(e,r){return chunkVRZC4TTF_cjs.J`${e} like ${r}`}function fe(e,r){return chunkVRZC4TTF_cjs.J`${e} not like ${r}`}function me(e,r){return chunkVRZC4TTF_cjs.J`${e} ilike ${r}`}function he(e,r){return chunkVRZC4TTF_cjs.J`${e} not ilike ${r}`}function Ve(e,r){if(Array.isArray(r)){if(r.length===0)throw new Error("arrayContains requires at least one value");let t=chunkVRZC4TTF_cjs.J`${m(r,e)}`;return chunkVRZC4TTF_cjs.J`${e} @> ${t}`}return chunkVRZC4TTF_cjs.J`${e} @> ${m(r,e)}`}function ze(e,r){if(Array.isArray(r)){if(r.length===0)throw new Error("arrayContained requires at least one value");let t=chunkVRZC4TTF_cjs.J`${m(r,e)}`;return chunkVRZC4TTF_cjs.J`${e} <@ ${t}`}return chunkVRZC4TTF_cjs.J`${e} <@ ${m(r,e)}`}function He(e,r){if(Array.isArray(r)){if(r.length===0)throw new Error("arrayOverlaps requires at least one value");let t=chunkVRZC4TTF_cjs.J`${m(r,e)}`;return chunkVRZC4TTF_cjs.J`${e} && ${t}`}return chunkVRZC4TTF_cjs.J`${e} && ${m(r,e)}`}chunkBUNLC3II_cjs.h();function ye(e){return chunkVRZC4TTF_cjs.J`${e} asc`}function de(e){return chunkVRZC4TTF_cjs.J`${e} desc`}chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var C=class{static[chunkVRZC4TTF_cjs.a]="PgPrimaryKeyBuilder";columns;name;constructor(r,t){this.columns=r,this.name=t;}build(r){return new q(r,this.columns,this.name)}},q=class{constructor(r,t,i){this.table=r,this.columns=t,this.name=i;}static[chunkVRZC4TTF_cjs.a]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[chunkVRZC4TTF_cjs.qa.Symbol.Name]}_${this.columns.map(r=>r.name).join("_")}_pk`}};var O=class{constructor(r,t,i){this.sourceTable=r,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[chunkVRZC4TTF_cjs.t.Symbol.Name];}static[chunkVRZC4TTF_cjs.a]="Relation";referencedTableName;fieldName},E=class{constructor(r,t){this.table=r,this.config=t;}static[chunkVRZC4TTF_cjs.a]="Relations"},g=class e extends O{constructor(r,t,i,o){super(r,t,i?.relationName),this.config=i,this.isNullable=o;}static[chunkVRZC4TTF_cjs.a]="One";withFieldName(r){let t=new e(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=r,t}},R=class e extends O{constructor(r,t,i){super(r,t,i?.relationName),this.config=i;}static[chunkVRZC4TTF_cjs.a]="Many";withFieldName(r){let t=new e(this.sourceTable,this.referencedTable,this.config);return t.fieldName=r,t}};function sr(){return {and:X,between:le,eq:W,exists:se,gt:_,gte:v,ilike:me,inArray:te,isNull:ie,isNotNull:oe,like:ue,lt:ee,lte:re,ne:G,not:Z,notBetween:ce,notExists:ae,notLike:fe,notIlike:he,notInArray:ne,or:Y,sql:chunkVRZC4TTF_cjs.J}}function ar(){return {sql:chunkVRZC4TTF_cjs.J,asc:ye,desc:de}}function lr(e,r){Object.keys(e).length===1&&"default"in e&&!chunkVRZC4TTF_cjs.c(e.default,chunkVRZC4TTF_cjs.t)&&(e=e.default);let t={},i={},o={};for(let[a,l]of Object.entries(e))if(chunkVRZC4TTF_cjs.c(l,chunkVRZC4TTF_cjs.t)){let s=chunkVRZC4TTF_cjs.w(l),d=i[s];t[s]=a,o[a]={tsName:a,dbName:l[chunkVRZC4TTF_cjs.t.Symbol.Name],schema:l[chunkVRZC4TTF_cjs.t.Symbol.Schema],columns:l[chunkVRZC4TTF_cjs.t.Symbol.Columns],relations:d?.relations??{},primaryKey:d?.primaryKey??[]};for(let h of Object.values(l[chunkVRZC4TTF_cjs.t.Symbol.Columns]))h.primary&&o[a].primaryKey.push(h);let b=l[chunkVRZC4TTF_cjs.t.Symbol.ExtraConfigBuilder]?.(l[chunkVRZC4TTF_cjs.t.Symbol.ExtraConfigColumns]);if(b)for(let h of Object.values(b))chunkVRZC4TTF_cjs.c(h,C)&&o[a].primaryKey.push(...h.columns);}else if(chunkVRZC4TTF_cjs.c(l,E)){let s=chunkVRZC4TTF_cjs.w(l.table),d=t[s],b=l.config(r(l.table)),h;for(let[S,Q]of Object.entries(b))if(d){let L=o[d];L.relations[S]=Q;}else s in i||(i[s]={relations:{},primaryKey:h}),i[s].relations[S]=Q;}return {tables:o,tableNamesMap:t}}function cr(e,r){return new E(e,t=>Object.fromEntries(Object.entries(r(t)).map(([i,o])=>[i,o.withFieldName(i)])))}function Te(e){return function(t,i){return new g(e,t,i,i?.fields.reduce((o,a)=>o&&a.notNull,true)??false)}}function xe(e){return function(t,i){return new R(e,t,i)}}function ur(e,r,t){if(chunkVRZC4TTF_cjs.c(t,g)&&t.config)return {fields:t.config.fields,references:t.config.references};let i=r[chunkVRZC4TTF_cjs.w(t.referencedTable)];if(!i)throw new Error(`Table "${t.referencedTable[chunkVRZC4TTF_cjs.t.Symbol.Name]}" not found in schema`);let o=e[i];if(!o)throw new Error(`Table "${i}" not found in schema`);let a=t.sourceTable,l=r[chunkVRZC4TTF_cjs.w(a)];if(!l)throw new Error(`Table "${a[chunkVRZC4TTF_cjs.t.Symbol.Name]}" not found in schema`);let s=[];for(let d of Object.values(o.relations))(t.relationName&&t!==d&&d.relationName===t.relationName||!t.relationName&&d.referencedTable===t.sourceTable)&&s.push(d);if(s.length>1)throw t.relationName?new Error(`There are multiple relations with name "${t.relationName}" in table "${i}"`):new Error(`There are multiple relations between "${i}" and "${t.sourceTable[chunkVRZC4TTF_cjs.t.Symbol.Name]}". Please specify relation name`);if(s[0]&&chunkVRZC4TTF_cjs.c(s[0],g)&&s[0].config)return {fields:s[0].config.references,references:s[0].config.fields};throw new Error(`There is not enough information to infer relation "${l}.${t.fieldName}"`)}function fr(e){return {one:Te(e),many:xe(e)}}function be(e,r,t,i,o=a=>a){let a={};for(let[l,s]of i.entries())if(s.isJson){let d=r.relations[s.tsKey],b=t[l],h=typeof b=="string"?JSON.parse(b):b;a[s.tsKey]=chunkVRZC4TTF_cjs.c(d,g)?h&&be(e,e[s.relationTableTsKey],h,s.selection,o):h.map(S=>be(e,e[s.relationTableTsKey],S,s.selection,o));}else {let d=o(t[l]),b=s.field,h;chunkVRZC4TTF_cjs.c(b,chunkVRZC4TTF_cjs.d)?h=b:chunkVRZC4TTF_cjs.c(b,chunkVRZC4TTF_cjs.A)?h=b.decoder:h=b.sql.decoder,a[s.tsKey]=d===null?null:h.mapFromDriverValue(d);}return a}chunkBUNLC3II_cjs.h();var I=class{static[chunkVRZC4TTF_cjs.a]="ConsoleLogWriter";write(r){console.log(r);}},we=class{static[chunkVRZC4TTF_cjs.a]="DefaultLogger";writer;constructor(r){this.writer=r?.writer??new I;}logQuery(r,t){let i=t.map(a=>{try{return JSON.stringify(a)}catch{return String(a)}}),o=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${r}${o}`);}},$e=class{static[chunkVRZC4TTF_cjs.a]="NoopLogger";logQuery(){}};exports.$=we;exports.A=se;exports.B=ae;exports.C=le;exports.D=ce;exports.E=ue;exports.F=fe;exports.G=me;exports.H=he;exports.I=Ve;exports.J=ze;exports.K=He;exports.L=ye;exports.M=de;exports.N=O;exports.O=E;exports.P=g;exports.Q=R;exports.R=sr;exports.S=ar;exports.T=lr;exports.U=cr;exports.V=Te;exports.W=xe;exports.X=ur;exports.Y=fr;exports.Z=be;exports._=I;exports.a=x;exports.aa=$e;exports.b=A;exports.c=P;exports.d=pe;exports.e=Ke;exports.f=Ne;exports.g=ge;exports.h=z;exports.i=H;exports.j=j;exports.k=M;exports.l=U;exports.m=m;exports.n=W;exports.o=G;exports.p=X;exports.q=Y;exports.r=Z;exports.s=_;exports.t=v;exports.u=ee;exports.v=re;exports.w=te;exports.x=ne;exports.y=ie;exports.z=oe;
@@ -1,4 +1,4 @@
1
- 'use strict';var E=require('bcryptjs'),crypto=require('crypto'),fs=require('fs'),path=require('path'),module$1=require('module');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var E__default=/*#__PURE__*/_interopDefault(E);var c;function m(){return c||(c=module$1.createRequire("file:///")("node:sqlite").DatabaseSync,c)}var g=5e3,S=1e3,k=-64e3,A=268435456,l=class{db=null;path;saltRounds;externalDb;busyTimeout;walAutoCheckpoint;cacheSize;mmapSize;preparedStatements=new Map;constructor(e={}){this.path=e.path||"./data/auth.db",this.saltRounds=e.saltRounds||12,this.externalDb=!!e.db,this.busyTimeout=e.busyTimeout??g,this.walAutoCheckpoint=e.walAutoCheckpoint??S,this.cacheSize=e.cacheSize??k,this.mmapSize=e.mmapSize??A,e.db&&(this.db=e.db);}async connect(){if(this.db)return;let e=path.dirname(this.path);e&&e!=="."&&fs.mkdirSync(e,{recursive:true}),this.db=new(m())(this.path),this.db.exec(`PRAGMA busy_timeout = ${this.busyTimeout}`),this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA synchronous = NORMAL"),this.db.exec("PRAGMA cache_size = "+this.cacheSize),this.db.exec("PRAGMA mmap_size = "+this.mmapSize),this.db.exec("PRAGMA wal_autocheckpoint = "+this.walAutoCheckpoint),this.db.exec("PRAGMA foreign_keys = ON"),this.db.exec("PRAGMA temp_store = MEMORY"),this.ensureTables(),this.prepareStatements();}async disconnect(){this.db&&!this.externalDb&&(this.db.exec("PRAGMA wal_checkpoint(TRUNCATE)"),this.db.close(),this.db=null,this.preparedStatements.clear());}async ensureConnected(){if(this.db||await this.connect(),!this.db)throw new Error("Failed to connect to SQLite database");return this.db}ensureTables(){if(this.db){this.db.exec(`
1
+ 'use strict';var chunkHTYVI2HK_cjs=require('./chunk-HTYVI2HK.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),crypto=require('crypto'),fs=require('fs'),path=require('path'),module$1=require('module');chunkBUNLC3II_cjs.h();var E=chunkBUNLC3II_cjs.e(chunkHTYVI2HK_cjs.a(),1);var c;function k(){return c||(c=module$1.createRequire("file:///")("node:sqlite").DatabaseSync,c)}var A=5e3,y=1e3,R=-64e3,L=268435456,p=class{db=null;path;saltRounds;externalDb;busyTimeout;walAutoCheckpoint;cacheSize;mmapSize;preparedStatements=new Map;constructor(e={}){this.path=e.path||"./data/auth.db",this.saltRounds=e.saltRounds||12,this.externalDb=!!e.db,this.busyTimeout=e.busyTimeout??A,this.walAutoCheckpoint=e.walAutoCheckpoint??y,this.cacheSize=e.cacheSize??R,this.mmapSize=e.mmapSize??L,e.db&&(this.db=e.db);}async connect(){if(this.db)return;let e=path.dirname(this.path);e&&e!=="."&&fs.mkdirSync(e,{recursive:true}),this.db=new(k())(this.path),this.db.exec(`PRAGMA busy_timeout = ${this.busyTimeout}`),this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA synchronous = NORMAL"),this.db.exec("PRAGMA cache_size = "+this.cacheSize),this.db.exec("PRAGMA mmap_size = "+this.mmapSize),this.db.exec("PRAGMA wal_autocheckpoint = "+this.walAutoCheckpoint),this.db.exec("PRAGMA foreign_keys = ON"),this.db.exec("PRAGMA temp_store = MEMORY"),this.ensureTables(),this.prepareStatements();}async disconnect(){this.db&&!this.externalDb&&(this.db.exec("PRAGMA wal_checkpoint(TRUNCATE)"),this.db.close(),this.db=null,this.preparedStatements.clear());}async ensureConnected(){if(this.db||await this.connect(),!this.db)throw new Error("Failed to connect to SQLite database");return this.db}ensureTables(){if(this.db){this.db.exec(`
2
2
  CREATE TABLE IF NOT EXISTS kyro_users (
3
3
  id TEXT PRIMARY KEY,
4
4
  name TEXT,
@@ -115,8 +115,8 @@
115
115
  locked_at = excluded.locked_at,
116
116
  locked_until = excluded.locked_until
117
117
  `)),this.preparedStatements.set("resetLockout",this.db.prepare("UPDATE kyro_lockouts SET attempts = 0, locked_at = NULL, locked_until = NULL WHERE user_id = ?")));}stmt(e){let s=this.preparedStatements.get(e);if(!s)throw new Error(`Prepared statement not found: ${e}`);return s}async cleanupExpiredSessions(){return await this.ensureConnected(),this.stmt("deleteExpiredSessions").run(new Date().toISOString()).changes}async cleanupOldAuditLogs(e=30){await this.ensureConnected();let s=new Date(Date.now()-e*24*60*60*1e3).toISOString();return this.stmt("cleanupOldAuditLogs").run(s).changes}async getStats(){await this.ensureConnected();let e=this.stmt("countUsers").get().count,s=this.db.prepare("SELECT COUNT(*) as count FROM kyro_sessions WHERE expires_at > ?").get(new Date().toISOString()).count,t=this.db.prepare("SELECT COUNT(*) as count FROM kyro_audit_logs").get().count;return {userCount:e,activeSessionCount:s,auditLogCount:t}}async createUser(e){await this.ensureConnected();let s=crypto.randomBytes(16).toString("hex"),t=new Date().toISOString(),r=await this.hashPassword(e.password),n={id:s,name:e.name,email:e.email.toLowerCase(),passwordHash:r,role:e.role||"customer",avatar:e.avatar,tenantId:e.tenantId,createdAt:t,updatedAt:t};return this.db.prepare(`INSERT INTO kyro_users (id, name, email, password_hash, role, avatar, tenant_id, created_at, updated_at)
118
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(s,n.name||null,n.email,n.passwordHash,n.role,n.avatar||null,n.tenantId||null,t,t),n}async findUserByEmail(e){await this.ensureConnected();let s=this.stmt("findUserByEmail").get(e.toLowerCase());return s?this.rowToUser(s):null}async findUserById(e){await this.ensureConnected();let s=this.stmt("findUserById").get(e);return s?this.rowToUser(s):null}async updateUser(e,s){if(await this.ensureConnected(),!await this.findUserById(e))return null;let r=[],n=[];return s.email!==void 0&&(r.push("email = ?"),n.push(s.email.toLowerCase())),s.name!==void 0&&(r.push("name = ?"),n.push(s.name)),s.passwordHash!==void 0&&(r.push("password_hash = ?"),n.push(s.passwordHash)),s.role!==void 0&&(r.push("role = ?"),n.push(s.role)),s.avatar!==void 0&&(r.push("avatar = ?"),n.push(s.avatar)),s.tenantId!==void 0&&(r.push("tenant_id = ?"),n.push(s.tenantId)),s.emailVerified!==void 0&&(r.push("email_verified = ?"),n.push(s.emailVerified?1:0)),s.locked!==void 0&&(r.push("locked = ?"),n.push(s.locked?1:0)),s.lastLogin!==void 0&&(r.push("last_login = ?"),n.push(s.lastLogin)),s.failedLoginAttempts!==void 0&&(r.push("failed_login_attempts = ?"),n.push(s.failedLoginAttempts)),r.push("updated_at = ?"),n.push(new Date().toISOString()),n.push(e),this.db.prepare(`UPDATE kyro_users SET ${r.join(", ")} WHERE id = ?`).run(...n),this.findUserById(e)}async deleteUser(e){return await this.ensureConnected(),this.stmt("deleteUser").run(e).changes>0}async hashPassword(e){return E__default.default.hash(e,this.saltRounds)}async verifyPassword(e,s){await this.ensureConnected();let t=await this.findUserByEmail(e);if(!t)return null;let r=this.db.prepare("SELECT password_hash FROM kyro_users WHERE id = ?").get(t.id);return r?.password_hash&&await E__default.default.compare(s,r.password_hash)?t:null}async createSession(e,s={}){await this.ensureConnected();let t=crypto.randomBytes(32).toString("hex"),r=crypto.randomBytes(32).toString("base64url"),n=crypto.randomBytes(32).toString("base64url"),d=new Date,u=new Date(d.getTime()+864e5).toISOString(),i={id:t,userId:e,token:r,refreshToken:n,expiresAt:u,createdAt:d.toISOString(),ipAddress:s.ipAddress,userAgent:s.userAgent};return this.db.prepare(`INSERT INTO kyro_sessions (id, user_id, token, refresh_token, expires_at, created_at, ip_address, user_agent)
119
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(i.id,i.userId,i.token,i.refreshToken??null,i.expiresAt,i.createdAt,i.ipAddress??null,i.userAgent??null),i}async findSessionByToken(e){await this.ensureConnected();let s=this.stmt("findSessionByToken").get(e);return s?this.rowToSession(s):null}async findSessionByRefreshToken(e){await this.ensureConnected();let s=this.stmt("findSessionByRefreshToken").get(e);return s?this.rowToSession(s):null}async deleteSession(e){return await this.ensureConnected(),this.stmt("deleteSession").run(e,e).changes>0}async deleteUserSessions(e){return await this.ensureConnected(),this.stmt("deleteUserSessions").run(e).changes}async hasAnyUsers(){return await this.ensureConnected(),this.stmt("countUsers").get().count>0}async findUsers(e={}){await this.ensureConnected();let s=e.page??1,t=e.limit??10,r=(s-1)*t,n=e.search,d,u;if(n){let i=`%${n}%`;d=this.stmt("countUsersWithSearch").get(i).count,u=this.stmt("findUsersWithSearch").all(i,t,r);}else d=this.stmt("countUsers").get().count,u=this.stmt("findUsersPaginated").all(t,r);return {users:u.map(i=>this.rowToUser(i)),total:d}}async addPasswordToHistory(e,s){await this.ensureConnected(),this.stmt("addPasswordHistory").run(e,s,new Date().toISOString()),this.stmt("trimPasswordHistory").run(e);}async getPasswordHistory(e,s=5){return await this.ensureConnected(),this.stmt("getPasswordHistory").all(e,s).map(r=>r.password_hash)}async isPasswordInHistory(e,s,t=5){let r=await this.getPasswordHistory(s,t);for(let n of r)if(await E__default.default.compare(e,n))return true;return false}async recordFailedAttempt(e){await this.ensureConnected();let s=Date.now(),t=this.stmt("getLockout").get(e),r=(t?.attempts||0)+1,n=r>=5?s+900*1e3:t?.locked_until||null;this.stmt("upsertLockout").run(e,r,s,n!==null?s:null,n);}async resetAttempts(e){await this.ensureConnected(),this.stmt("resetLockout").run(e);}async checkLockout(e){await this.ensureConnected(),this.stmt("cleanupExpiredLockouts").run(Date.now());let s=this.stmt("getLockout").get(e);return s?s.locked_until!==null&&s.locked_until>Date.now()?{locked:true,attemptsRemaining:0,lockedUntil:new Date(s.locked_until),totalAttempts:s.attempts}:{locked:false,attemptsRemaining:Math.max(0,5-s.attempts),totalAttempts:s.attempts}:{locked:false,attemptsRemaining:5,totalAttempts:0}}async logAudit(e){await this.ensureConnected();let s=crypto.randomBytes(16).toString("hex"),t=new Date().toISOString();return this.db.prepare(`INSERT INTO kyro_audit_logs (
118
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(s,n.name||null,n.email,n.passwordHash,n.role,n.avatar||null,n.tenantId||null,t,t),n}async findUserByEmail(e){await this.ensureConnected();let s=this.stmt("findUserByEmail").get(e.toLowerCase());return s?this.rowToUser(s):null}async findUserById(e){await this.ensureConnected();let s=this.stmt("findUserById").get(e);return s?this.rowToUser(s):null}async updateUser(e,s){if(await this.ensureConnected(),!await this.findUserById(e))return null;let r=[],n=[];return s.email!==void 0&&(r.push("email = ?"),n.push(s.email.toLowerCase())),s.name!==void 0&&(r.push("name = ?"),n.push(s.name)),s.passwordHash!==void 0&&(r.push("password_hash = ?"),n.push(s.passwordHash)),s.role!==void 0&&(r.push("role = ?"),n.push(s.role)),s.avatar!==void 0&&(r.push("avatar = ?"),n.push(s.avatar)),s.tenantId!==void 0&&(r.push("tenant_id = ?"),n.push(s.tenantId)),s.emailVerified!==void 0&&(r.push("email_verified = ?"),n.push(s.emailVerified?1:0)),s.locked!==void 0&&(r.push("locked = ?"),n.push(s.locked?1:0)),s.lastLogin!==void 0&&(r.push("last_login = ?"),n.push(s.lastLogin)),s.failedLoginAttempts!==void 0&&(r.push("failed_login_attempts = ?"),n.push(s.failedLoginAttempts)),r.push("updated_at = ?"),n.push(new Date().toISOString()),n.push(e),this.db.prepare(`UPDATE kyro_users SET ${r.join(", ")} WHERE id = ?`).run(...n),this.findUserById(e)}async deleteUser(e){return await this.ensureConnected(),this.stmt("deleteUser").run(e).changes>0}async hashPassword(e){return E.default.hash(e,this.saltRounds)}async verifyPassword(e,s){await this.ensureConnected();let t=await this.findUserByEmail(e);if(!t)return null;let r=this.db.prepare("SELECT password_hash FROM kyro_users WHERE id = ?").get(t.id);return r?.password_hash&&await E.default.compare(s,r.password_hash)?t:null}async createSession(e,s={}){await this.ensureConnected();let t=crypto.randomBytes(32).toString("hex"),r=crypto.randomBytes(32).toString("base64url"),n=crypto.randomBytes(32).toString("base64url"),d=new Date,u=new Date(d.getTime()+864e5).toISOString(),i={id:t,userId:e,token:r,refreshToken:n,expiresAt:u,createdAt:d.toISOString(),ipAddress:s.ipAddress,userAgent:s.userAgent};return this.db.prepare(`INSERT INTO kyro_sessions (id, user_id, token, refresh_token, expires_at, created_at, ip_address, user_agent)
119
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(i.id,i.userId,i.token,i.refreshToken??null,i.expiresAt,i.createdAt,i.ipAddress??null,i.userAgent??null),i}async findSessionByToken(e){await this.ensureConnected();let s=this.stmt("findSessionByToken").get(e);return s?this.rowToSession(s):null}async findSessionByRefreshToken(e){await this.ensureConnected();let s=this.stmt("findSessionByRefreshToken").get(e);return s?this.rowToSession(s):null}async deleteSession(e){return await this.ensureConnected(),this.stmt("deleteSession").run(e,e).changes>0}async deleteUserSessions(e){return await this.ensureConnected(),this.stmt("deleteUserSessions").run(e).changes}async hasAnyUsers(){return await this.ensureConnected(),this.stmt("countUsers").get().count>0}async findUsers(e={}){await this.ensureConnected();let s=e.page??1,t=e.limit??10,r=(s-1)*t,n=e.search,d,u;if(n){let i=`%${n}%`;d=this.stmt("countUsersWithSearch").get(i).count,u=this.stmt("findUsersWithSearch").all(i,t,r);}else d=this.stmt("countUsers").get().count,u=this.stmt("findUsersPaginated").all(t,r);return {users:u.map(i=>this.rowToUser(i)),total:d}}async addPasswordToHistory(e,s){await this.ensureConnected(),this.stmt("addPasswordHistory").run(e,s,new Date().toISOString()),this.stmt("trimPasswordHistory").run(e);}async getPasswordHistory(e,s=5){return await this.ensureConnected(),this.stmt("getPasswordHistory").all(e,s).map(r=>r.password_hash)}async isPasswordInHistory(e,s,t=5){let r=await this.getPasswordHistory(s,t);for(let n of r)if(await E.default.compare(e,n))return true;return false}async recordFailedAttempt(e){await this.ensureConnected();let s=Date.now(),t=this.stmt("getLockout").get(e),r=(t?.attempts||0)+1,n=r>=5?s+900*1e3:t?.locked_until||null;this.stmt("upsertLockout").run(e,r,s,n!==null?s:null,n);}async resetAttempts(e){await this.ensureConnected(),this.stmt("resetLockout").run(e);}async checkLockout(e){await this.ensureConnected(),this.stmt("cleanupExpiredLockouts").run(Date.now());let s=this.stmt("getLockout").get(e);return s?s.locked_until!==null&&s.locked_until>Date.now()?{locked:true,attemptsRemaining:0,lockedUntil:new Date(s.locked_until),totalAttempts:s.attempts}:{locked:false,attemptsRemaining:Math.max(0,5-s.attempts),totalAttempts:s.attempts}:{locked:false,attemptsRemaining:5,totalAttempts:0}}async logAudit(e){await this.ensureConnected();let s=crypto.randomBytes(16).toString("hex"),t=new Date().toISOString();return this.db.prepare(`INSERT INTO kyro_audit_logs (
120
120
  id, timestamp, action, user_id, user_email, role, resource, resource_id,
121
121
  ip_address, user_agent, success, error, metadata, created_at
122
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(s,t,e.action,e.userId||null,e.userEmail||null,e.role||null,e.resource,e.resourceId||null,e.ipAddress||null,e.userAgent||null,e.success?1:0,e.error||null,e.metadata?JSON.stringify(e.metadata):null,new Date().toISOString()),s}async queryAuditLogs(e={}){await this.ensureConnected();let s=[],t=[];e.action&&(s.push("action = ?"),t.push(e.action)),e.userId&&(s.push("user_id = ?"),t.push(e.userId)),e.resource&&(s.push("resource = ?"),t.push(e.resource)),e.success!==void 0&&(s.push("success = ?"),t.push(e.success?1:0)),e.startDate&&(s.push("timestamp >= ?"),t.push(e.startDate.toISOString())),e.endDate&&(s.push("timestamp <= ?"),t.push(e.endDate.toISOString()));let r=s.length>0?"WHERE "+s.join(" AND "):"",n=e.limit||50,d=e.offset||0,u=this.db.prepare(`SELECT COUNT(*) as count FROM kyro_audit_logs ${r}`).get(...t),i=this.db.prepare(`SELECT * FROM kyro_audit_logs ${r} ORDER BY timestamp DESC LIMIT ? OFFSET ?`).all(...t,n,d);return {total:u.count,logs:i.map(a=>({id:a.id,timestamp:new Date(a.timestamp),action:a.action,userId:a.user_id||void 0,userEmail:a.user_email||void 0,resource:a.resource,resourceId:a.resource_id||void 0,ipAddress:a.ip_address||void 0,userAgent:a.user_agent||void 0,success:a.success===1,error:a.error||void 0,metadata:a.metadata?JSON.parse(a.metadata):void 0}))}}rowToUser(e){return {id:e.id,name:e.name||void 0,email:e.email,passwordHash:e.password_hash,role:e.role,tenantId:e.tenant_id,avatar:e.avatar,emailVerified:e.email_verified===1,locked:e.locked===1,lastLogin:e.last_login,failedLoginAttempts:e.failed_login_attempts||0,createdAt:e.created_at,updatedAt:e.updated_at}}rowToSession(e){return {id:e.id,userId:e.user_id,token:e.token,refreshToken:e.refresh_token,expiresAt:e.expires_at,createdAt:e.created_at,ipAddress:e.ip_address,userAgent:e.user_agent}}async findAuditLogs(e){let s=await this.queryAuditLogs({action:e.action,userId:e.userId,resource:e.resource,success:e.success,startDate:e.startDate,endDate:e.endDate,limit:e.limit,offset:e.offset});return {logs:s.logs.map(t=>({...t,action:t.action})),total:s.total}}async createAuditLog(e){let s=await this.logAudit({action:e.action,userId:e.userId,userEmail:e.userEmail,role:e.role,resource:e.resource,resourceId:e.resourceId,ipAddress:e.ipAddress,userAgent:e.userAgent,success:e.success,error:e.error,metadata:e.metadata}),t=this.db?.prepare("SELECT * FROM kyro_audit_logs WHERE id = ?").get(s);return {...e,id:s,timestamp:t?new Date(t.timestamp):new Date}}async createEmailVerificationToken(e){await this.ensureConnected();let s=crypto.randomBytes(16).toString("hex"),t=crypto.randomBytes(32).toString("hex"),r=new Date(Date.now()+1440*60*1e3);return this.db.prepare("INSERT INTO kyro_email_verifications (id, user_id, token, expires_at, created_at) VALUES (?, ?, ?, ?, ?)").run(s,e,t,r.toISOString(),new Date().toISOString()),{token:t,expiresAt:r}}async verifyEmailToken(e){await this.ensureConnected();let s=this.db.prepare("SELECT * FROM kyro_email_verifications WHERE token = ?").get(e);return s?new Date(s.expires_at)<new Date?{success:false,error:"Verification token has expired"}:(this.db.prepare("UPDATE kyro_users SET email_verified = 1 WHERE id = ?").run(s.user_id),this.db.prepare("DELETE FROM kyro_email_verifications WHERE id = ?").run(s.id),{success:true,userId:s.user_id}):{success:false,error:"Invalid verification token"}}async createPasswordResetToken(e){await this.ensureConnected();let s=await this.findUserByEmail(e);if(!s)return {token:"",expiresAt:new Date,error:"User not found"};let t=crypto.randomBytes(16).toString("hex"),r=crypto.randomBytes(32).toString("hex"),n=new Date(Date.now()+3600*1e3);return this.db.prepare("INSERT INTO kyro_password_resets (id, user_id, token, expires_at, created_at) VALUES (?, ?, ?, ?, ?)").run(t,s.id,r,n.toISOString(),new Date().toISOString()),{token:r,expiresAt:n}}async resetPasswordWithToken(e,s){await this.ensureConnected();let t=this.db.prepare("SELECT * FROM kyro_password_resets WHERE token = ?").get(e);if(!t)return {success:false,error:"Invalid reset token"};if(new Date(t.expires_at)<new Date)return {success:false,error:"Reset token has expired"};if(t.used_at)return {success:false,error:"Reset token has already been used"};let r=await this.hashPassword(s);return this.db.prepare("UPDATE kyro_users SET password_hash = ?, updated_at = ? WHERE id = ?").run(r,new Date().toISOString(),t.user_id),this.db.prepare("UPDATE kyro_password_resets SET used_at = ? WHERE id = ?").run(new Date().toISOString(),t.id),this.db.prepare("DELETE FROM kyro_sessions WHERE user_id = ?").run(t.user_id),{success:true}}};exports.a=l;
122
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(s,t,e.action,e.userId||null,e.userEmail||null,e.role||null,e.resource,e.resourceId||null,e.ipAddress||null,e.userAgent||null,e.success?1:0,e.error||null,e.metadata?JSON.stringify(e.metadata):null,new Date().toISOString()),s}async queryAuditLogs(e={}){await this.ensureConnected();let s=[],t=[];e.action&&(s.push("action = ?"),t.push(e.action)),e.userId&&(s.push("user_id = ?"),t.push(e.userId)),e.resource&&(s.push("resource = ?"),t.push(e.resource)),e.success!==void 0&&(s.push("success = ?"),t.push(e.success?1:0)),e.startDate&&(s.push("timestamp >= ?"),t.push(e.startDate.toISOString())),e.endDate&&(s.push("timestamp <= ?"),t.push(e.endDate.toISOString()));let r=s.length>0?"WHERE "+s.join(" AND "):"",n=e.limit||50,d=e.offset||0,u=this.db.prepare(`SELECT COUNT(*) as count FROM kyro_audit_logs ${r}`).get(...t),i=this.db.prepare(`SELECT * FROM kyro_audit_logs ${r} ORDER BY timestamp DESC LIMIT ? OFFSET ?`).all(...t,n,d);return {total:u.count,logs:i.map(a=>({id:a.id,timestamp:new Date(a.timestamp),action:a.action,userId:a.user_id||void 0,userEmail:a.user_email||void 0,resource:a.resource,resourceId:a.resource_id||void 0,ipAddress:a.ip_address||void 0,userAgent:a.user_agent||void 0,success:a.success===1,error:a.error||void 0,metadata:a.metadata?JSON.parse(a.metadata):void 0}))}}rowToUser(e){return {id:e.id,name:e.name||void 0,email:e.email,passwordHash:e.password_hash,role:e.role,tenantId:e.tenant_id,avatar:e.avatar,emailVerified:e.email_verified===1,locked:e.locked===1,lastLogin:e.last_login,failedLoginAttempts:e.failed_login_attempts||0,createdAt:e.created_at,updatedAt:e.updated_at}}rowToSession(e){return {id:e.id,userId:e.user_id,token:e.token,refreshToken:e.refresh_token,expiresAt:e.expires_at,createdAt:e.created_at,ipAddress:e.ip_address,userAgent:e.user_agent}}async findAuditLogs(e){let s=await this.queryAuditLogs({action:e.action,userId:e.userId,resource:e.resource,success:e.success,startDate:e.startDate,endDate:e.endDate,limit:e.limit,offset:e.offset});return {logs:s.logs.map(t=>({...t,action:t.action})),total:s.total}}async createAuditLog(e){let s=await this.logAudit({action:e.action,userId:e.userId,userEmail:e.userEmail,role:e.role,resource:e.resource,resourceId:e.resourceId,ipAddress:e.ipAddress,userAgent:e.userAgent,success:e.success,error:e.error,metadata:e.metadata}),t=this.db?.prepare("SELECT * FROM kyro_audit_logs WHERE id = ?").get(s);return {...e,id:s,timestamp:t?new Date(t.timestamp):new Date}}async createEmailVerificationToken(e){await this.ensureConnected();let s=crypto.randomBytes(16).toString("hex"),t=crypto.randomBytes(32).toString("hex"),r=new Date(Date.now()+1440*60*1e3);return this.db.prepare("INSERT INTO kyro_email_verifications (id, user_id, token, expires_at, created_at) VALUES (?, ?, ?, ?, ?)").run(s,e,t,r.toISOString(),new Date().toISOString()),{token:t,expiresAt:r}}async verifyEmailToken(e){await this.ensureConnected();let s=this.db.prepare("SELECT * FROM kyro_email_verifications WHERE token = ?").get(e);return s?new Date(s.expires_at)<new Date?{success:false,error:"Verification token has expired"}:(this.db.prepare("UPDATE kyro_users SET email_verified = 1 WHERE id = ?").run(s.user_id),this.db.prepare("DELETE FROM kyro_email_verifications WHERE id = ?").run(s.id),{success:true,userId:s.user_id}):{success:false,error:"Invalid verification token"}}async createPasswordResetToken(e){await this.ensureConnected();let s=await this.findUserByEmail(e);if(!s)return {token:"",expiresAt:new Date,error:"User not found"};let t=crypto.randomBytes(16).toString("hex"),r=crypto.randomBytes(32).toString("hex"),n=new Date(Date.now()+3600*1e3);return this.db.prepare("INSERT INTO kyro_password_resets (id, user_id, token, expires_at, created_at) VALUES (?, ?, ?, ?, ?)").run(t,s.id,r,n.toISOString(),new Date().toISOString()),{token:r,expiresAt:n}}async resetPasswordWithToken(e,s){await this.ensureConnected();let t=this.db.prepare("SELECT * FROM kyro_password_resets WHERE token = ?").get(e);if(!t)return {success:false,error:"Invalid reset token"};if(new Date(t.expires_at)<new Date)return {success:false,error:"Reset token has expired"};if(t.used_at)return {success:false,error:"Reset token has already been used"};let r=await this.hashPassword(s);return this.db.prepare("UPDATE kyro_users SET password_hash = ?, updated_at = ? WHERE id = ?").run(r,new Date().toISOString(),t.user_id),this.db.prepare("UPDATE kyro_password_resets SET used_at = ? WHERE id = ?").run(new Date().toISOString(),t.id),this.db.prepare("DELETE FROM kyro_sessions WHERE user_id = ?").run(t.user_id),{success:true}}};exports.a=p;
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';import {g}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
2
+ g();function o(e){if(e==null)return e;if(Array.isArray(e))return e.map(n=>o(n));if(typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)){let n={};for(let r of Object.keys(e))/^\d+$/.test(r)||(n[r]=o(e[r]));return n}return e}export{o as a};
@@ -0,0 +1,10 @@
1
+ import {createRequire}from'module';import {c,g,a}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
2
+ var q=c((X,g$1)=>{g();(function(i,y){typeof define=="function"&&define.amd?define([],y):typeof a=="function"&&typeof g$1=="object"&&g$1&&g$1.exports?g$1.exports=y():(i.dcodeIO=i.dcodeIO||{}).bcrypt=y();})(X,function(){var i={},y=null;function O(c){if(typeof g$1<"u"&&g$1&&g$1.exports)try{return a("crypto").randomBytes(c)}catch{}try{var a$1;return (self.crypto||self.msCrypto).getRandomValues(a$1=new Uint32Array(c)),Array.prototype.slice.call(a$1)}catch{}if(!y)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return y(c)}var H=false;try{O(1),H=!0;}catch{}y=null,i.setRandomFallback=function(c){y=c;},i.genSaltSync=function(c,a){if(c=c||C,typeof c!="number")throw Error("Illegal arguments: "+typeof c+", "+typeof a);c<4?c=4:c>31&&(c=31);var f=[];return f.push("$2a$"),c<10&&f.push("0"),f.push(c.toString()),f.push("$"),f.push(T(O(w),w)),f.join("")},i.genSalt=function(c,a,f){if(typeof a=="function"&&(f=a,a=void 0),typeof c=="function"&&(f=c,c=void 0),typeof c>"u")c=C;else if(typeof c!="number")throw Error("illegal arguments: "+typeof c);function e(x){p(function(){try{x(null,i.genSaltSync(c));}catch(d){x(d);}});}if(f){if(typeof f!="function")throw Error("Illegal callback: "+typeof f);e(f);}else return new Promise(function(x,d){e(function(b,r){if(b){d(b);return}x(r);});})},i.hashSync=function(c,a){if(typeof a>"u"&&(a=C),typeof a=="number"&&(a=i.genSaltSync(a)),typeof c!="string"||typeof a!="string")throw Error("Illegal arguments: "+typeof c+", "+typeof a);return _(c,a)},i.hash=function(c,a,f,e){function x(d){typeof c=="string"&&typeof a=="number"?i.genSalt(a,function(b,r){_(c,r,d,e);}):typeof c=="string"&&typeof a=="string"?_(c,a,d,e):p(d.bind(this,Error("Illegal arguments: "+typeof c+", "+typeof a)));}if(f){if(typeof f!="function")throw Error("Illegal callback: "+typeof f);x(f);}else return new Promise(function(d,b){x(function(r,n){if(r){b(r);return}d(n);});})};function R(c,a){for(var f=0,e=0,x=0,d=c.length;x<d;++x)c.charCodeAt(x)===a.charCodeAt(x)?++f:++e;return f<0?false:e===0}i.compareSync=function(c,a){if(typeof c!="string"||typeof a!="string")throw Error("Illegal arguments: "+typeof c+", "+typeof a);return a.length!==60?false:R(i.hashSync(c,a.substr(0,a.length-31)),a)},i.compare=function(c,a,f,e){function x(d){if(typeof c!="string"||typeof a!="string"){p(d.bind(this,Error("Illegal arguments: "+typeof c+", "+typeof a)));return}if(a.length!==60){p(d.bind(this,null,false));return}i.hash(c,a.substr(0,29),function(b,r){b?d(b):d(null,R(r,a));},e);}if(f){if(typeof f!="function")throw Error("Illegal callback: "+typeof f);x(f);}else return new Promise(function(d,b){x(function(r,n){if(r){b(r);return}d(n);});})},i.getRounds=function(c){if(typeof c!="string")throw Error("Illegal arguments: "+typeof c);return parseInt(c.split("$")[2],10)},i.getSalt=function(c){if(typeof c!="string")throw Error("Illegal arguments: "+typeof c);if(c.length!==60)throw Error("Illegal hash length: "+c.length+" != 60");return c.substring(0,29)};var p=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function V(c){var a=[],f=0;return Y.encodeUTF16toUTF8(function(){return f>=c.length?null:c.charCodeAt(f++)},function(e){a.push(e);}),a}var F="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],A=String.fromCharCode;function T(c,a){var f=0,e=[],x,d;if(a<=0||a>c.length)throw Error("Illegal len: "+a);for(;f<a;){if(x=c[f++]&255,e.push(F[x>>2&63]),x=(x&3)<<4,f>=a){e.push(F[x&63]);break}if(d=c[f++]&255,x|=d>>4&15,e.push(F[x&63]),x=(d&15)<<2,f>=a){e.push(F[x&63]);break}d=c[f++]&255,x|=d>>6&3,e.push(F[x&63]),e.push(F[d&63]);}return e.join("")}function N(c,a){var f=0,e=c.length,x=0,d=[],b,r,n,t,o,u;if(a<=0)throw Error("Illegal len: "+a);for(;f<e-1&&x<a&&(u=c.charCodeAt(f++),b=u<s.length?s[u]:-1,u=c.charCodeAt(f++),r=u<s.length?s[u]:-1,!(b==-1||r==-1||(o=b<<2>>>0,o|=(r&48)>>4,d.push(A(o)),++x>=a||f>=e)||(u=c.charCodeAt(f++),n=u<s.length?s[u]:-1,n==-1)||(o=(r&15)<<4>>>0,o|=(n&60)>>2,d.push(A(o)),++x>=a||f>=e)));)u=c.charCodeAt(f++),t=u<s.length?s[u]:-1,o=(n&3)<<6>>>0,o|=t,d.push(A(o)),++x;var h=[];for(f=0;f<x;f++)h.push(d[f].charCodeAt(0));return h}var Y=(function(){var c={};return c.MAX_CODEPOINT=1114111,c.encodeUTF8=function(a,f){var e=null;for(typeof a=="number"&&(e=a,a=function(){return null});e!==null||(e=a())!==null;)e<128?f(e&127):e<2048?(f(e>>6&31|192),f(e&63|128)):e<65536?(f(e>>12&15|224),f(e>>6&63|128),f(e&63|128)):(f(e>>18&7|240),f(e>>12&63|128),f(e>>6&63|128),f(e&63|128)),e=null;},c.decodeUTF8=function(a,f){for(var e,x,d,b,r=function(n){n=n.slice(0,n.indexOf(null));var t=Error(n.toString());throw t.name="TruncatedError",t.bytes=n,t};(e=a())!==null;)if((e&128)===0)f(e);else if((e&224)===192)(x=a())===null&&r([e,x]),f((e&31)<<6|x&63);else if((e&240)===224)((x=a())===null||(d=a())===null)&&r([e,x,d]),f((e&15)<<12|(x&63)<<6|d&63);else if((e&248)===240)((x=a())===null||(d=a())===null||(b=a())===null)&&r([e,x,d,b]),f((e&7)<<18|(x&63)<<12|(d&63)<<6|b&63);else throw RangeError("Illegal starting byte: "+e)},c.UTF16toUTF8=function(a,f){for(var e,x=null;(e=x!==null?x:a())!==null;){if(e>=55296&&e<=57343&&(x=a())!==null&&x>=56320&&x<=57343){f((e-55296)*1024+x-56320+65536),x=null;continue}f(e);}x!==null&&f(x);},c.UTF8toUTF16=function(a,f){var e=null;for(typeof a=="number"&&(e=a,a=function(){return null});e!==null||(e=a())!==null;)e<=65535?f(e):(e-=65536,f((e>>10)+55296),f(e%1024+56320)),e=null;},c.encodeUTF16toUTF8=function(a,f){c.UTF16toUTF8(a,function(e){c.encodeUTF8(e,f);});},c.decodeUTF8toUTF16=function(a,f){c.decodeUTF8(a,function(e){c.UTF8toUTF16(e,f);});},c.calculateCodePoint=function(a){return a<128?1:a<2048?2:a<65536?3:4},c.calculateUTF8=function(a){for(var f,e=0;(f=a())!==null;)e+=c.calculateCodePoint(f);return e},c.calculateUTF16asUTF8=function(a){var f=0,e=0;return c.UTF16toUTF8(a,function(x){++f,e+=c.calculateCodePoint(x);}),[f,e]},c})();Date.now=Date.now||function(){return +new Date};var w=16,C=10,z=16,J=100,$=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],B=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function E(c,a,f,e){var x,d=c[a],b=c[a+1];return d^=f[0],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[1],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[2],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[3],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[4],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[5],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[6],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[7],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[8],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[9],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[10],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[11],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[12],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[13],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[14],x=e[d>>>24],x+=e[256|d>>16&255],x^=e[512|d>>8&255],x+=e[768|d&255],b^=x^f[15],x=e[b>>>24],x+=e[256|b>>16&255],x^=e[512|b>>8&255],x+=e[768|b&255],d^=x^f[16],c[a]=b^f[z+1],c[a+1]=d,c}function v(c,a){for(var f=0,e=0;f<4;++f)e=e<<8|c[a]&255,a=(a+1)%c.length;return {key:e,offp:a}}function j(c,a,f){for(var e=0,x=[0,0],d=a.length,b=f.length,r,n=0;n<d;n++)r=v(c,e),e=r.offp,a[n]=a[n]^r.key;for(n=0;n<d;n+=2)x=E(x,0,a,f),a[n]=x[0],a[n+1]=x[1];for(n=0;n<b;n+=2)x=E(x,0,a,f),f[n]=x[0],f[n+1]=x[1];}function K(c,a,f,e){for(var x=0,d=[0,0],b=f.length,r=e.length,n,t=0;t<b;t++)n=v(a,x),x=n.offp,f[t]=f[t]^n.key;for(x=0,t=0;t<b;t+=2)n=v(c,x),x=n.offp,d[0]^=n.key,n=v(c,x),x=n.offp,d[1]^=n.key,d=E(d,0,f,e),f[t]=d[0],f[t+1]=d[1];for(t=0;t<r;t+=2)n=v(c,x),x=n.offp,d[0]^=n.key,n=v(c,x),x=n.offp,d[1]^=n.key,d=E(d,0,f,e),e[t]=d[0],e[t+1]=d[1];}function G(c,a,f,e,x){var d=L.slice(),b=d.length,r;if(f<4||f>31)if(r=Error("Illegal number of rounds (4-31): "+f),e){p(e.bind(this,r));return}else throw r;if(a.length!==w)if(r=Error("Illegal salt length: "+a.length+" != "+w),e){p(e.bind(this,r));return}else throw r;f=1<<f>>>0;var n,t,o=0,u;Int32Array?(n=new Int32Array($),t=new Int32Array(B)):(n=$.slice(),t=B.slice()),K(a,c,n,t);function h(){if(x&&x(o/f),o<f)for(var m=Date.now();o<f&&(o=o+1,j(c,n,t),j(a,n,t),!(Date.now()-m>J)););else {for(o=0;o<64;o++)for(u=0;u<b>>1;u++)E(d,u<<1,n,t);var l=[];for(o=0;o<b;o++)l.push((d[o]>>24&255)>>>0),l.push((d[o]>>16&255)>>>0),l.push((d[o]>>8&255)>>>0),l.push((d[o]&255)>>>0);if(e){e(null,l);return}else return l}e&&p(h);}if(typeof e<"u")h();else for(var I;;)if(typeof(I=h())<"u")return I||[]}function _(c,a,f,e){var x;if(typeof c!="string"||typeof a!="string")if(x=Error("Invalid string / salt: Not a string"),f){p(f.bind(this,x));return}else throw x;var d,b;if(a.charAt(0)!=="$"||a.charAt(1)!=="2")if(x=Error("Invalid salt version: "+a.substring(0,2)),f){p(f.bind(this,x));return}else throw x;if(a.charAt(2)==="$")d="\0",b=3;else {if(d=a.charAt(2),d!=="a"&&d!=="b"&&d!=="y"||a.charAt(3)!=="$")if(x=Error("Invalid salt revision: "+a.substring(2,4)),f){p(f.bind(this,x));return}else throw x;b=4;}if(a.charAt(b+2)>"$")if(x=Error("Missing salt rounds"),f){p(f.bind(this,x));return}else throw x;var r=parseInt(a.substring(b,b+1),10)*10,n=parseInt(a.substring(b+1,b+2),10),t=r+n,o=a.substring(b+3,b+25);c+=d>="a"?"\0":"";var u=V(c),h=N(o,w);function I(m){var l=[];return l.push("$2"),d>="a"&&l.push(d),l.push("$"),t<10&&l.push("0"),l.push(t.toString()),l.push("$"),l.push(T(h,h.length)),l.push(T(m,L.length*4-1)),l.join("")}if(typeof f>"u")return I(G(u,h,t));G(u,h,t,function(m,l){m?f(m,null):f(null,I(l));},e);}return i.encodeBase64=T,i.decodeBase64=N,i});});var k=c((x0,W)=>{g();W.exports=q();});/*! Bundled license information:
3
+
4
+ bcryptjs/dist/bcrypt.js:
5
+ (**
6
+ * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
7
+ * Released under the Apache License, Version 2.0
8
+ * see: https://github.com/dcodeIO/bcrypt.js for details
9
+ *)
10
+ */export{k as a};
@@ -0,0 +1 @@
1
+ 'use strict';var p=Object.create;var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var l=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),S=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:true});},m=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!d.call(e,n)&&n!==r&&c(e,n,{get:()=>t[n],enumerable:!(o=u(t,n))||o.enumerable});return e};var I=(e,t,r)=>(r=e!=null?p(i(e)):{},m(t||!e||!e.__esModule?c(r,"default",{value:e,enumerable:true}):r,e)),g=e=>m(c({},"__esModule",{value:true}),e);var s;exports.g=void 0;var U=f(()=>{s=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,exports.g=s();});exports.a=l;exports.b=f;exports.c=R;exports.d=S;exports.e=I;exports.f=g;exports.h=U;
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';import'path';import'url';var require$1 = createRequire(import.meta.url);
2
+ var a=Object.create;var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var d=(t=>typeof require$1<"u"?require$1:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require$1<"u"?require$1:e)[o]}):t)(function(t){if(typeof require$1<"u")return require$1.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var s=(t,e)=>()=>(t&&(e=t(t=0)),e);var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),h=(t,e)=>{for(var o in e)r(t,o,{get:e[o],enumerable:true});},n=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!l.call(t,m)&&m!==o&&r(t,m,{get:()=>e[m],enumerable:!(i=p(e,m))||i.enumerable});return t};var x=(t,e,o)=>(o=t!=null?a(f(t)):{},n(e||!t||!t.__esModule?r(o,"default",{value:t,enumerable:true}):o,t)),u=t=>n(r({},"__esModule",{value:true}),t);var _=s(()=>{});export{d as a,s as b,g as c,h as d,x as e,u as f,_ as g};
@@ -0,0 +1,4 @@
1
+ import {createRequire}from'module';import {g}from'./chunk-C2PXMVR5.js';import {execSync}from'child_process';import {existsSync}from'fs';import {join}from'path';createRequire(import.meta.url);
2
+ g();function s(){let n=process.cwd();return existsSync(join(n,"pnpm-lock.yaml"))?"pnpm":existsSync(join(n,"yarn.lock"))?"yarn":existsSync(join(n,"bun.lockb"))||existsSync(join(n,"bun.lock"))?"bun":"npm"}function d(n){let o=s();console.log(`
3
+ \u{1F4E6} [Kyro CMS] Auto-installing missing database drivers: ${n.join(", ")}...`);try{let i=o==="npm"?"npm install":`${o} add`;execSync(`${i} ${n.join(" ")}`,{stdio:"inherit"}),console.log(`\u2705 [Kyro CMS] Successfully installed drivers!
4
+ `);}catch(i){throw console.error(`\u274C [Kyro CMS] Failed to auto-install drivers. Please run manually: ${o==="npm"?"npm install":`${o} add`} ${n.join(" ")}`),i}}export{d as a};
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';import {l,k}from'./chunk-45TJAB5X.js';import {a}from'./chunk-XBH4YMC7.js';import {g as g$1}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
2
+ g$1();async function g(t){let{adminEmail:e,adminPassword:r,adminRole:a$1="super_admin",tenantId:n,emailConfig:o,sendWelcomeEmail:c=false}=t,s=t.authAdapter||new a({path:t.authDbPath||"./data/auth.db"});try{await s.connect?.();}catch{return {success:false,error:"Failed to connect to auth storage"}}let u=new l().validate(r);if(!u.valid)return await s.disconnect?.(),{success:false,error:`Invalid password: ${u.errors.join(", ")}`};if(await s.findUserByEmail(e))return await s.disconnect?.(),{success:false,error:"Admin user already exists"};try{let i=await s.createUser({name:"Super Admin",email:e,password:r,role:a$1||"admin",tenantId:n});if(await s.updateUser?.(i.id,{emailVerified:!0}),c&&o){let l=new k(o),A=l.getTemplates().welcome(e.split("@")[0]);await l.send({to:e,...A});}return await s.disconnect?.(),{success:!0,user:i}}catch(i){return await s.disconnect?.(),{success:false,error:i instanceof Error?i.message:"Failed to create admin user"}}}async function M(t,e){return !await t.findUserByEmail(e)}function w(t){let e=t.KYRO_ADMIN_EMAIL,r=t.KYRO_ADMIN_PASSWORD;return !e||!r?null:{authDbPath:t.KYRO_AUTH_DB_PATH||"./data/auth.db",adminEmail:e,adminPassword:r,adminRole:t.KYRO_ADMIN_ROLE||"super_admin",tenantId:t.KYRO_ADMIN_TENANT_ID,emailConfig:t.SMTP_HOST?{provider:"smtp",smtp:{host:t.SMTP_HOST,port:parseInt(t.SMTP_PORT||"587",10),secure:t.SMTP_SECURE==="true",auth:{user:t.SMTP_USER||"",pass:t.SMTP_PASS||""}},from:t.SMTP_FROM||"noreply@example.com",fromName:t.SMTP_FROM_NAME}:void 0,sendWelcomeEmail:t.KYRO_ADMIN_SEND_WELCOME==="true"}}function h(){return w(process.env)}async function E(){try{let{env:t}=await import('cloudflare:workers');if(t){let e=w(t);if(e)return e}}catch{}return null}async function x(t){let e=h()||await E();if(!e)return null;t&&(e.authAdapter=t);try{if(await e.authAdapter?.connect?.(),await e.authAdapter?.findUserByEmail(e.adminEmail))return await e.authAdapter?.disconnect?.(),{success:!1,error:"Admin user already exists"}}catch{}let r=await g(e);return r.success||console.error(`Bootstrap failed: ${r.error}`),r}async function C(t,e=3,r=2e3){let a="";for(let n=0;n<e;n++){let o=await g(t);if(o.success||(a=o.error||"Unknown error",a.includes("already exists")))return o;n<e-1&&await new Promise(c=>setTimeout(c,r));}return {success:false,error:`Failed after ${e} retries: ${a}`}}export{g as a,M as b,w as c,h as d,x as e,C as f};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),crypto=require('crypto');chunkBUNLC3II_cjs.h();async function f(e,r){return typeof e=="boolean"?e:typeof e=="function"?await e(r):true}function y(...e){let r={};for(let t of e)t&&typeof t=="object"&&Object.assign(r,t);return r}function h(e,r){return f(e,r).then(t=>{if(t!==true)return t===false?{_id:{$eq:null}}:t})}chunkBUNLC3II_cjs.h();var u="api_keys";function A(e){return e.substring(0,8)}function g(e,r){if(e.length!==r.length)return false;try{return crypto.timingSafeEqual(Buffer.from(e),Buffer.from(r))}catch{return false}}async function C(e,r,t){if(!e||typeof e!="string")return {valid:false,error:"No API key provided"};if(!e.startsWith("kyro_"))return {valid:false,error:"Invalid API key format"};let l=A(e);try{let s=await r.find({collection:u,where:{keyPrefix:{equals:l}},limit:100,page:1});if(!s.docs||s.docs.length===0)return {valid:!1,error:"Invalid API key"};let n=null;for(let i of s.docs){let c=i;if(g(c.key,e)){n=c;break}}if(!n)return {valid:!1,error:"Invalid API key"};if(n.expiresAt&&new Date(n.expiresAt)<new Date)return {valid:!1,error:"API key has expired"};try{await r.update({collection:u,id:n.id,data:{lastUsedAt:new Date().toISOString()}});}catch{}let o={id:n.userId,role:n.role||"author",tenantId:n.tenantId};if(t){let i=await t(n.userId);i&&Object.assign(o,i);}return {valid:!0,userId:n.userId,user:o,permissions:n.permissions||[],apiKeyId:n.id,tenantId:o.tenantId,role:o.role}}catch(s){return console.error("[ApiKey] Validation error:",s),{valid:false,error:"Failed to validate API key"}}}function P(e){let r=e.headers.get("Authorization");if(r){if(r.startsWith("ApiKey "))return r.slice(7).trim();if(r.startsWith("Bearer "))return null}let t=e.headers.get("X-API-Key");return t?t.trim():null}function K(e){return !e.valid||!e.userId?null:{userId:e.userId,user:e.user||{},permissions:e.permissions||[],apiKeyId:e.apiKeyId||"",tenantId:e.tenantId,role:e.role}}function k(e,r){if(e.length===0)return false;if(e.includes("*")||e.includes(r))return true;let[t,l]=r.split(":");return !!e.includes(`${t}:*`)}function v(){let e="abcdefghijklmnopqrstuvwxyz0123456789",r="";for(let t=0;t<32;t++)r+=e[Math.floor(Math.random()*e.length)];return `kyro_${r}`}function b(e){return e.substring(0,8)}exports.a=f;exports.b=y;exports.c=h;exports.d=u;exports.e=C;exports.f=P;exports.g=K;exports.h=k;exports.i=v;exports.j=b;
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7ACHOBWY_cjs=require('./chunk-7ACHOBWY.cjs'),chunkGNOSG3PK_cjs=require('./chunk-GNOSG3PK.cjs'),chunkBCEE4NBZ_cjs=require('./chunk-BCEE4NBZ.cjs'),chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function g(o){return chunkVRZC4TTF_cjs.c(o,chunk7ACHOBWY_cjs.d)?[`${o[chunkVRZC4TTF_cjs.t.Symbol.BaseName]}`]:chunkVRZC4TTF_cjs.c(o,chunkVRZC4TTF_cjs.i)?o._.usedTables??[]:chunkVRZC4TTF_cjs.c(o,chunkVRZC4TTF_cjs.A)?o.usedTables??[]:[]}var _=class extends chunkBCEE4NBZ_cjs.i{constructor(e,t,i,s){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s};}static[chunkVRZC4TTF_cjs.a]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.table[chunkVRZC4TTF_cjs.t.Symbol.Columns],new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i;}else {let t=e;this.config.orderBy=t;}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[chunk7ACHOBWY_cjs.d.Symbol.Columns]){return this.config.returning=chunkVRZC4TTF_cjs.R(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=true){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",true,void 0,{type:"delete",tables:g(this.config.table)})}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var y=class{static[chunkVRZC4TTF_cjs.a]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct;}from(e){let t=!!this.fields,i;return this.fields?i=this.fields:chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.i)?i=Object.fromEntries(Object.keys(e._.selectedFields).map(s=>[s,e[s]])):chunkVRZC4TTF_cjs.c(e,chunk7ACHOBWY_cjs.f)?i=e[chunkVRZC4TTF_cjs.l].selectedFields:chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.A)?i={}:i=chunkVRZC4TTF_cjs.V(e),new j({table:e,fields:i,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}},k=class extends chunkGNOSG3PK_cjs.c{static[chunkVRZC4TTF_cjs.a]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:r,withList:n,distinct:f}){super(),this.config={withList:n,table:e,fields:{...t},distinct:f,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=r,this._={selectedFields:t,config:this.config},this.tableName=chunkVRZC4TTF_cjs.X(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:true}:{};for(let d of g(e))this.usedTables.add(d);}getUsedTables(){return [...this.usedTables]}createJoin(e){return (t,i)=>{let s=this.tableName,r=chunkVRZC4TTF_cjs.X(t);for(let n of g(t))this.usedTables.add(n);if(typeof r=="string"&&this.config.joins?.some(n=>n.alias===r))throw new Error(`Alias "${r}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof s=="string"&&(this.config.fields={[s]:this.config.fields}),typeof r=="string"&&!chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.A))){let n=chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.i)?t._.selectedFields:chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.N)?t[chunkVRZC4TTF_cjs.l].selectedFields:t[chunkVRZC4TTF_cjs.t.Symbol.Columns];this.config.fields[r]=n;}if(typeof i=="function"&&(i=i(new Proxy(this.config.fields,new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,joinType:e,alias:r}),typeof r=="string")switch(e){case "left":{this.joinsNotNullableMap[r]=false;break}case "right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([n])=>[n,false])),this.joinsNotNullableMap[r]=true;break}case "cross":case "inner":{this.joinsNotNullableMap[r]=true;break}case "full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([n])=>[n,false])),this.joinsNotNullableMap[r]=false;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let s=typeof i=="function"?i(he()):i;if(!chunkVRZC4TTF_cjs.S(this.getSelectedFields(),s.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",false);unionAll=this.createSetOperator("union",true);intersect=this.createSetOperator("intersect",false);except=this.createSetOperator("except",false);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.fields,new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t];}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.fields,new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i;}else {let t=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t;}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...g(this.config.table)),this.config.joins)for(let i of this.config.joins)t.push(...g(i.table));return new Proxy(new chunkVRZC4TTF_cjs.i(this.getSQL(),this.config.fields,e,false,[...new Set(t)]),new chunkGNOSG3PK_cjs.a({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new chunkGNOSG3PK_cjs.a({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}},j=class extends k{static[chunkVRZC4TTF_cjs.a]="SQLiteSelect";_prepare(e=true){if(!this.session)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=chunkVRZC4TTF_cjs.R(this.config.fields),i=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",true,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:true,autoInvalidate:true}:e===false?{enable:false}:{enable:true,autoInvalidate:true,...e},this}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.all()}};chunkVRZC4TTF_cjs.U(j,[chunkBCEE4NBZ_cjs.i]);function P(o,e){return (t,i,...s)=>{let r=[i,...s].map(n=>({type:o,isAll:e,rightSelect:n}));for(let n of r)if(!chunkVRZC4TTF_cjs.S(t.getSelectedFields(),n.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return t.addSetOperators(r)}}var he=()=>({union:ce,unionAll:ue,intersect:fe,except:de}),ce=P("union",false),ue=P("union",true),fe=P("intersect",false),de=P("except",false);var C=class{static[chunkVRZC4TTF_cjs.a]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=chunkVRZC4TTF_cjs.c(e,chunk7ACHOBWY_cjs.g)?e:void 0,this.dialectConfig=chunkVRZC4TTF_cjs.c(e,chunk7ACHOBWY_cjs.g)?void 0:e;}$with=(e,t)=>{let i=this;return {as:r=>(typeof r=="function"&&(r=r(i)),new Proxy(new chunkVRZC4TTF_cjs.j(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,true),new chunkGNOSG3PK_cjs.a({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;function i(r){return new y({fields:r??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function s(r){return new y({fields:r??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:true})}return {select:i,selectDistinct:s}}select(e){return new y({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new y({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:true})}getDialect(){return this.dialect||(this.dialect=new chunk7ACHOBWY_cjs.h(this.dialectConfig)),this.dialect}};var T=class{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s;}static[chunkVRZC4TTF_cjs.a]="SQLiteInsertBuilder";values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw new Error("values() must be called with at least one value");let t=e.map(i=>{let s={},r=this.table[chunkVRZC4TTF_cjs.t.Symbol.Columns];for(let n of Object.keys(i)){let f=i[n];s[n]=chunkVRZC4TTF_cjs.c(f,chunkVRZC4TTF_cjs.A)?f:new chunkVRZC4TTF_cjs.H(f,r[n]);}return s});return new F(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e=="function"?e(new C):e;if(!chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.A)&&!chunkVRZC4TTF_cjs.S(this.table[chunkVRZC4TTF_cjs.n],t._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new F(this.table,t,this.session,this.dialect,this.withList,true)}},F=class extends chunkBCEE4NBZ_cjs.i{constructor(e,t,i,s,r,n){super(),this.session=i,this.dialect=s,this.config={table:e,values:t,withList:r,select:n};}static[chunkVRZC4TTF_cjs.a]="SQLiteInsert";config;returning(e=this.config.table[chunk7ACHOBWY_cjs.d.Symbol.Columns]){return this.config.returning=chunkVRZC4TTF_cjs.R(e),this}onConflictDoNothing(e={}){if(this.config.onConflict||(this.config.onConflict=[]),e.target===void 0)this.config.onConflict.push(chunkVRZC4TTF_cjs.J` on conflict do nothing`);else {let t=Array.isArray(e.target)?chunkVRZC4TTF_cjs.J`${e.target}`:chunkVRZC4TTF_cjs.J`${[e.target]}`,i=e.where?chunkVRZC4TTF_cjs.J` where ${e.where}`:chunkVRZC4TTF_cjs.J``;this.config.onConflict.push(chunkVRZC4TTF_cjs.J` on conflict ${t} do nothing${i}`);}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');this.config.onConflict||(this.config.onConflict=[]);let t=e.where?chunkVRZC4TTF_cjs.J` where ${e.where}`:void 0,i=e.targetWhere?chunkVRZC4TTF_cjs.J` where ${e.targetWhere}`:void 0,s=e.setWhere?chunkVRZC4TTF_cjs.J` where ${e.setWhere}`:void 0,r=Array.isArray(e.target)?chunkVRZC4TTF_cjs.J`${e.target}`:chunkVRZC4TTF_cjs.J`${[e.target]}`,n=this.dialect.buildUpdateSet(this.config.table,chunkVRZC4TTF_cjs.T(this.config.table,e.set));return this.config.onConflict.push(chunkVRZC4TTF_cjs.J` on conflict ${r}${i} do update set ${n}${t}${s}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=true){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",true,void 0,{type:"insert",tables:g(this.config.table)})}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}};chunkBUNLC3II_cjs.h();var A=class{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s;}static[chunkVRZC4TTF_cjs.a]="SQLiteUpdateBuilder";set(e){return new U(this.table,chunkVRZC4TTF_cjs.T(this.table,e),this.session,this.dialect,this.withList)}},U=class extends chunkBCEE4NBZ_cjs.i{constructor(e,t,i,s,r){super(),this.session=i,this.dialect=s,this.config={set:t,table:e,withList:r,joins:[]};}static[chunkVRZC4TTF_cjs.a]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return (t,i)=>{let s=chunkVRZC4TTF_cjs.X(t);if(typeof s=="string"&&this.config.joins.some(r=>r.alias===s))throw new Error(`Alias "${s}" is already used in this query`);if(typeof i=="function"){let r=this.config.from?chunkVRZC4TTF_cjs.c(t,chunk7ACHOBWY_cjs.d)?t[chunkVRZC4TTF_cjs.t.Symbol.Columns]:chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.i)?t._.selectedFields:chunkVRZC4TTF_cjs.c(t,chunk7ACHOBWY_cjs.f)?t[chunkVRZC4TTF_cjs.l].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[chunkVRZC4TTF_cjs.t.Symbol.Columns],new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),r&&new Proxy(r,new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));}return this.config.joins.push({on:i,table:t,joinType:e,alias:s}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.table[chunkVRZC4TTF_cjs.t.Symbol.Columns],new chunkGNOSG3PK_cjs.a({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i;}else {let t=e;this.config.orderBy=t;}return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[chunk7ACHOBWY_cjs.d.Symbol.Columns]){return this.config.returning=chunkVRZC4TTF_cjs.R(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=true){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",true,void 0,{type:"insert",tables:g(this.config.table)})}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}};chunkBUNLC3II_cjs.h();var E=class o extends chunkVRZC4TTF_cjs.A{constructor(e){super(o.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.session=e.session,this.sql=o.buildCount(e.source,e.filters);}sql;static[chunkVRZC4TTF_cjs.a]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return chunkVRZC4TTF_cjs.J`(select count(*) from ${e}${chunkVRZC4TTF_cjs.J.raw(" where ").if(t)}${t})`}static buildCount(e,t){return chunkVRZC4TTF_cjs.J`select count(*) from ${e}${chunkVRZC4TTF_cjs.J.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}};chunkBUNLC3II_cjs.h();var K=class{constructor(e,t,i,s,r,n,f,d){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=s,this.table=r,this.tableConfig=n,this.dialect=f,this.session=d;}static[chunkVRZC4TTF_cjs.a]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new D(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new M(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return this.mode==="sync"?new D(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new M(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}},M=class extends chunkBCEE4NBZ_cjs.i{constructor(e,t,i,s,r,n,f,d,le){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=s,this.tableConfig=r,this.dialect=n,this.session=f,this.config=d,this.mode=le;}static[chunkVRZC4TTF_cjs.a]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=false){let{query:t,builtQuery:i}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](i,void 0,this.mode==="first"?"get":"all",true,(s,r)=>{let n=s.map(f=>chunkBCEE4NBZ_cjs.Z(this.schema,this.tableConfig,f,t.selection,r));return this.mode==="first"?n[0]:n})}prepare(){return this._prepare(false)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return {query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){return this.mode==="first"?this._prepare(false).get():this._prepare(false).all()}async execute(){return this.executeRaw()}},D=class extends M{static[chunkVRZC4TTF_cjs.a]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}};chunkBUNLC3II_cjs.h();var B=class extends chunkBCEE4NBZ_cjs.i{constructor(e,t,i,s,r){super(),this.execute=e,this.getSQL=t,this.dialect=s,this.mapBatchResult=r,this.config={action:i};}static[chunkVRZC4TTF_cjs.a]="SQLiteRaw";config;getQuery(){return {...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return false}};var J=class{constructor(e,t,i,s){this.resultKind=e,this.dialect=t,this.session=i,this._=s?{schema:s.schema,fullSchema:s.fullSchema,tableNamesMap:s.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let r=this.query;if(this._.schema)for(let[n,f]of Object.entries(this._.schema))r[n]=new K(e,s.fullSchema,this._.schema,this._.tableNamesMap,s.fullSchema[n],f,t,i);this.$cache={invalidate:async n=>{}};}static[chunkVRZC4TTF_cjs.a]="BaseSQLiteDatabase";query;$with=(e,t)=>{let i=this;return {as:r=>(typeof r=="function"&&(r=r(new C(i.dialect))),new Proxy(new chunkVRZC4TTF_cjs.j(r.getSQL(),t??("getSelectedFields"in r?r.getSelectedFields()??{}:{}),e,true),new chunkGNOSG3PK_cjs.a({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new E({source:e,filters:t,session:this.session})}with(...e){let t=this;function i(d){return new y({fields:d??void 0,session:t.session,dialect:t.dialect,withList:e})}function s(d){return new y({fields:d??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:true})}function r(d){return new A(d,t.session,t.dialect,e)}function n(d){return new T(d,t.session,t.dialect,e)}function f(d){return new _(d,t.session,t.dialect,e)}return {select:i,selectDistinct:s,update:r,insert:n,delete:f}}select(e){return new y({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new y({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:true})}update(e){return new A(e,this.session,this.dialect)}$cache;insert(e){return new T(e,this.session,this.dialect)}delete(e){return new _(e,this.session,this.dialect)}run(e){let t=typeof e=="string"?chunkVRZC4TTF_cjs.J.raw(e):e.getSQL();return this.resultKind==="async"?new B(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session)):this.session.run(t)}all(e){let t=typeof e=="string"?chunkVRZC4TTF_cjs.J.raw(e):e.getSQL();return this.resultKind==="async"?new B(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session)):this.session.all(t)}get(e){let t=typeof e=="string"?chunkVRZC4TTF_cjs.J.raw(e):e.getSQL();return this.resultKind==="async"?new B(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session)):this.session.get(t)}values(e){let t=typeof e=="string"?chunkVRZC4TTF_cjs.J.raw(e):e.getSQL();return this.resultKind==="async"?new B(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session)):this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}};chunkBUNLC3II_cjs.h();var I=class extends chunkBCEE4NBZ_cjs.i{constructor(e){super(),this.resultCb=e;}static[chunkVRZC4TTF_cjs.a]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}},ne=class{constructor(e,t,i,s,r,n){this.mode=e,this.executeMethod=t,this.query=i,this.cache=s,this.queryMetadata=r,this.cacheConfig=n,s&&s.strategy()==="all"&&n===void 0&&(this.cacheConfig={enable:true,autoInvalidate:true}),this.cacheConfig?.enable||(this.cacheConfig=void 0);}static[chunkVRZC4TTF_cjs.a]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,i){if(this.cache===void 0||chunkVRZC4TTF_cjs.c(this.cache,chunkGNOSG3PK_cjs.d)||this.queryMetadata===void 0)try{return await i()}catch(s){throw new chunkBCEE4NBZ_cjs.k(e,t,s)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await i()}catch(s){throw new chunkBCEE4NBZ_cjs.k(e,t,s)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[s]=await Promise.all([i(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return s}catch(s){throw new chunkBCEE4NBZ_cjs.k(e,t,s)}if(!this.cacheConfig)try{return await i()}catch(s){throw new chunkBCEE4NBZ_cjs.k(e,t,s)}if(this.queryMetadata.type==="select"){let s=await this.cache.get(this.cacheConfig.tag??await chunkGNOSG3PK_cjs.e(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(s===void 0){let r;try{r=await i();}catch(n){throw new chunkBCEE4NBZ_cjs.k(e,t,n)}return await this.cache.put(this.cacheConfig.tag??await chunkGNOSG3PK_cjs.e(e,t),r,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),r}return s}try{return await i()}catch(s){throw new chunkBCEE4NBZ_cjs.k(e,t,s)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw new Error("Not implemented")}mapGetResult(e,t){throw new Error("Not implemented")}execute(e){return this.mode==="async"?this[this.executeMethod](e):new I(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case "run":return this.mapRunResult(e,t);case "all":return this.mapAllResult(e,t);case "get":return this.mapGetResult(e,t)}}},oe=class{constructor(e){this.dialect=e;}static[chunkVRZC4TTF_cjs.a]="SQLiteSession";prepareOneTimeQuery(e,t,i,s,r,n,f){return this.prepareQuery(e,t,i,s,r,n,f)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(i){throw new chunkBCEE4NBZ_cjs.j({cause:i,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",false).all()}extractRawAllValueFromBatchResult(e){throw new Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",false).get()}extractRawGetValueFromBatchResult(e){throw new Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",false).values()}async count(e){return (await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw new Error("Not implemented")}},ae=class extends J{constructor(e,t,i,s,r=0){super(e,t,i,s),this.schema=s,this.nestedIndex=r;}static[chunkVRZC4TTF_cjs.a]="SQLiteTransaction";rollback(){throw new chunkBCEE4NBZ_cjs.l}};exports.a=J;exports.b=ne;exports.c=oe;exports.d=ae;
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';import {g as g$1}from'./chunk-C2PXMVR5.js';import {timingSafeEqual}from'crypto';createRequire(import.meta.url);
2
+ g$1();async function p(e,r){return typeof e=="boolean"?e:typeof e=="function"?await e(r):true}function h(...e){let r={};for(let t of e)t&&typeof t=="object"&&Object.assign(r,t);return r}function x(e,r){return p(e,r).then(t=>{if(t!==true)return t===false?{_id:{$eq:null}}:t})}g$1();var u="api_keys";function g(e){return e.substring(0,8)}function y(e,r){if(e.length!==r.length)return false;try{return timingSafeEqual(Buffer.from(e),Buffer.from(r))}catch{return false}}async function P(e,r,t){if(!e||typeof e!="string")return {valid:false,error:"No API key provided"};if(!e.startsWith("kyro_"))return {valid:false,error:"Invalid API key format"};let l=g(e);try{let s=await r.find({collection:u,where:{keyPrefix:{equals:l}},limit:100,page:1});if(!s.docs||s.docs.length===0)return {valid:!1,error:"Invalid API key"};let n=null;for(let i of s.docs){let c=i;if(y(c.key,e)){n=c;break}}if(!n)return {valid:!1,error:"Invalid API key"};if(n.expiresAt&&new Date(n.expiresAt)<new Date)return {valid:!1,error:"API key has expired"};try{await r.update({collection:u,id:n.id,data:{lastUsedAt:new Date().toISOString()}});}catch{}let o={id:n.userId,role:n.role||"author",tenantId:n.tenantId};if(t){let i=await t(n.userId);i&&Object.assign(o,i);}return {valid:!0,userId:n.userId,user:o,permissions:n.permissions||[],apiKeyId:n.id,tenantId:o.tenantId,role:o.role}}catch(s){return console.error("[ApiKey] Validation error:",s),{valid:false,error:"Failed to validate API key"}}}function K(e){let r=e.headers.get("Authorization");if(r){if(r.startsWith("ApiKey "))return r.slice(7).trim();if(r.startsWith("Bearer "))return null}let t=e.headers.get("X-API-Key");return t?t.trim():null}function k(e){return !e.valid||!e.userId?null:{userId:e.userId,user:e.user||{},permissions:e.permissions||[],apiKeyId:e.apiKeyId||"",tenantId:e.tenantId,role:e.role}}function v(e,r){if(e.length===0)return false;if(e.includes("*")||e.includes(r))return true;let[t,l]=r.split(":");return !!e.includes(`${t}:*`)}function b(){let e="abcdefghijklmnopqrstuvwxyz0123456789",r="";for(let t=0;t<32;t++)r+=e[Math.floor(Math.random()*e.length)];return `kyro_${r}`}function R(e){return e.substring(0,8)}export{p as a,h as b,x as c,u as d,P as e,K as f,k as g,v as h,b as i,R as j};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkBAVN7VDR_cjs=require('./chunk-BAVN7VDR.cjs'),chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();var h=chunkVRZC4TTF_cjs.ra("media",{id:chunkVRZC4TTF_cjs.oa("id").primaryKey().defaultRandom(),filename:chunkVRZC4TTF_cjs.pa("filename",{length:255}).notNull().unique(),title:chunkVRZC4TTF_cjs.pa("title",{length:255}),originalName:chunkVRZC4TTF_cjs.pa("original_name",{length:255}).notNull(),mimeType:chunkVRZC4TTF_cjs.pa("mime_type",{length:100}).notNull(),fileSize:chunkVRZC4TTF_cjs.ca("file_size").notNull(),width:chunkVRZC4TTF_cjs.ca("width"),height:chunkVRZC4TTF_cjs.ca("height"),url:chunkVRZC4TTF_cjs.ia("url").notNull().unique(),thumbnailUrl:chunkVRZC4TTF_cjs.ia("thumbnail_url"),folder:chunkVRZC4TTF_cjs.pa("folder",{length:255}),provider:chunkVRZC4TTF_cjs.pa("provider",{length:50}).notNull(),alt:chunkVRZC4TTF_cjs.ia("alt"),caption:chunkVRZC4TTF_cjs.ia("caption"),type:chunkVRZC4TTF_cjs.pa("type",{length:50}).notNull().default("other"),status:chunkVRZC4TTF_cjs.pa("status",{length:20}).notNull().default("active"),metadata:chunkVRZC4TTF_cjs.fa("metadata").$type(),createdAt:chunkVRZC4TTF_cjs.ma("created_at").defaultNow().notNull(),updatedAt:chunkVRZC4TTF_cjs.ma("updated_at").defaultNow().notNull()},t=>[chunkBAVN7VDR_cjs.a("media_folder_idx").on(t.folder),chunkBAVN7VDR_cjs.a("media_provider_idx").on(t.provider),chunkBAVN7VDR_cjs.a("media_filename_idx").on(t.filename)]),f=chunkVRZC4TTF_cjs.ra("media_folders",{path:chunkVRZC4TTF_cjs.pa("path",{length:500}).primaryKey(),name:chunkVRZC4TTF_cjs.pa("name",{length:255}).notNull(),parentPath:chunkVRZC4TTF_cjs.pa("parent_path",{length:500}),createdAt:chunkVRZC4TTF_cjs.ma("created_at").defaultNow().notNull()},t=>[chunkBAVN7VDR_cjs.a("media_folders_parent_idx").on(t.parentPath)]);exports.a=h;exports.b=f;
@@ -0,0 +1,2 @@
1
+ 'use strict';var i={name:"@aws-sdk/nested-clients",version:"3.997.33",description:"Nested clients for AWS SDK packages.",homepage:"https://github.com/aws/aws-sdk-js-v3/tree/main/packages/nested-clients",license:"Apache-2.0",author:{name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/sdk-for-javascript/"},repository:{type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"packages/nested-clients"},files:["./cognito-identity.d.ts","./cognito-identity.js","./signin.d.ts","./signin.js","./sso-oidc.d.ts","./sso-oidc.js","./sso.d.ts","./sso.js","./sts.d.ts","./sts.js","dist-*/**"],sideEffects:false,main:"./dist-cjs/index.js",module:"./dist-es/index.js",browser:{"./dist-es/submodules/cognito-identity/runtimeConfig":"./dist-es/submodules/cognito-identity/runtimeConfig.browser","./dist-es/submodules/signin/runtimeConfig":"./dist-es/submodules/signin/runtimeConfig.browser","./dist-es/submodules/sso-oidc/runtimeConfig":"./dist-es/submodules/sso-oidc/runtimeConfig.browser","./dist-es/submodules/sso/runtimeConfig":"./dist-es/submodules/sso/runtimeConfig.browser","./dist-es/submodules/sts/runtimeConfig":"./dist-es/submodules/sts/runtimeConfig.browser"},types:"./dist-types/index.d.ts",typesVersions:{"<4.5":{"dist-types/*":["dist-types/ts3.4/*"],"*":["dist-types/ts3.4/submodules/*/index.d.ts"]}},"react-native":{},exports:{"./package.json":"./package.json","./sso-oidc":{types:"./dist-types/submodules/sso-oidc/index.d.ts",module:"./dist-es/submodules/sso-oidc/index.js",node:"./dist-cjs/submodules/sso-oidc/index.js",import:"./dist-es/submodules/sso-oidc/index.js",require:"./dist-cjs/submodules/sso-oidc/index.js"},"./sts":{types:"./dist-types/submodules/sts/index.d.ts",module:"./dist-es/submodules/sts/index.js",node:"./dist-cjs/submodules/sts/index.js",import:"./dist-es/submodules/sts/index.js",require:"./dist-cjs/submodules/sts/index.js"},"./signin":{types:"./dist-types/submodules/signin/index.d.ts",module:"./dist-es/submodules/signin/index.js",node:"./dist-cjs/submodules/signin/index.js",import:"./dist-es/submodules/signin/index.js",require:"./dist-cjs/submodules/signin/index.js"},"./cognito-identity":{types:"./dist-types/submodules/cognito-identity/index.d.ts",module:"./dist-es/submodules/cognito-identity/index.js",node:"./dist-cjs/submodules/cognito-identity/index.js",import:"./dist-es/submodules/cognito-identity/index.js",require:"./dist-cjs/submodules/cognito-identity/index.js"},"./sso":{types:"./dist-types/submodules/sso/index.d.ts",module:"./dist-es/submodules/sso/index.js",node:"./dist-cjs/submodules/sso/index.js",import:"./dist-es/submodules/sso/index.js",require:"./dist-cjs/submodules/sso/index.js"}},scripts:{build:"concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs","build:cjs":"node ../../scripts/compilation/inline","build:es":"premove dist-es && tsc -p tsconfig.es.json","build:include:deps":'yarn g:turbo run build -F="$npm_package_name"',"build:types":"premove dist-types && tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"premove dist-cjs dist-es dist-types",lint:"node ../../scripts/validation/submodules-linter.js",prebuild:"yarn lint",test:"yarn g:vitest run","test:watch":"yarn g:vitest watch"},dependencies:{"@aws-sdk/core":"^3.975.3","@aws-sdk/signature-v4-multi-region":"^3.996.41","@aws-sdk/types":"^3.974.2","@smithy/core":"^3.29.4","@smithy/fetch-http-handler":"^5.6.6","@smithy/node-http-handler":"^4.9.6","@smithy/types":"^4.16.1",tslib:"^2.6.2"},devDependencies:{concurrently:"7.0.0","downlevel-dts":"0.10.1",premove:"4.0.0",typescript:"~5.8.3"},engines:{node:">=20.0.0"}};
2
+ exports.a=i;
@@ -0,0 +1,3 @@
1
+ import {createRequire}from'module';import {a,c,b,d}from'./chunk-MCZ3YZ2L.js';import {a as a$1}from'./chunk-CGPAS4U5.js';import {a as a$2}from'./chunk-BLH2MRK4.js';import {g}from'./chunk-C2PXMVR5.js';import {randomBytes}from'crypto';createRequire(import.meta.url);
2
+ g();g();var w=class extends a{dialect="mongodb";client;db;database;connectionString;constructor(o){if(super(),o.connectionString){this.connectionString=o.connectionString;try{let e=new URL(o.connectionString);this.database=e.pathname.replace(/^\//,"")||"kyro_cms";}catch{this.database="kyro_cms";}}else this.client=o.client,this.database=o.database;}async connect(){if(this.connectionString&&!this.client){let o;try{o=(await import('./lib-IYW32OER.js')).MongoClient;}catch{a$1(["mongodb"]),o=(await import('./lib-IYW32OER.js')).MongoClient;}this.client=new o(this.connectionString),await this.client.connect();}this.db=this.client.db(this.database),this.connected=true;}async disconnect(){this.client&&(await this.client.close(),this.connected=false);}getMongoCollection(o){if(!this.db)throw new Error("MongoDB not connected");return this.db.collection(o)}async find(o){let{collection:e,where:n={},sort:s,limit:t=10,page:i=1,tenantId:r,select:a,draft:d$1}=o,l=this.getCollectionConfig(e),f=this.getMongoCollection(e),g={...n};this.tenantContext&&l.tenantScoped&&(g=c({where:g},e,this.tenantContext,b).where||{});let u=this.buildFilter(g,l.tenantScoped?r:void 0),c$1=l.fields.find(p=>p.name==="status"),h=c$1?.type==="select"&&Array.isArray(c$1.options)&&c$1.options.some(p=>p.value==="published");!d$1&&h&&(u.status="published");let y=this.parseSort(s),O={[y.field]:y.direction==="asc"?1:-1},$=(i-1)*t,[x,M]=await Promise.all([f.find(u).sort(O).skip($).limit(t).project(this.buildProjection(a)).toArray(),f.countDocuments(u)]),C=x.map(p=>this.processResult(p,l));return this.tenantContext&&!this.tenantContext.isSuperAdmin&&(C=C.filter(p=>d(p,e,this.tenantContext,b))),d$1&&(C=await Promise.all(C.map(async p=>{let m=await this.getMongoCollection(`${e}_versions`).findOne({document_id:p.id},{sort:{createdAt:-1}});if(m){let P=typeof m.data=="string"?JSON.parse(m.data):m.data&&typeof m.data=="object"?m.data:{};return {...p,...P,status:p.status}}return p}))),{docs:C,...this.calculatePagination(i,t,M)}}async findByID(o){let{collection:e,id:n,tenantId:s,draft:t}=o,i=this.getCollectionConfig(e),r=this.getMongoCollection(e);if(this.tenantContext&&i.tenantScoped){let u={_id:n,tenantId:this.tenantContext.tenantId};if(!d(u,e,this.tenantContext,b))return null}let a={_id:n};s&&i.tenantScoped&&(a.tenantId=s);let d$1=i.fields.find(u=>u.name==="status"),l=d$1?.type==="select"&&Array.isArray(d$1.options)&&d$1.options.some(u=>u.value==="published");!t&&l&&(a.status="published");let f=await r.findOne(a);if(!f)return null;let g=this.processResult(f,i);if(t){let c=await this.getMongoCollection(`${e}_versions`).findOne({document_id:g.id},{sort:{createdAt:-1}});if(c){let h=typeof c.data=="string"?JSON.parse(c.data):c.data&&typeof c.data=="object"?c.data:{};g={...g,...h,status:g.status};}}return g}async create(o){let{collection:e,data:n,tenantId:s}=o,t=this.getCollectionConfig(e),i=this.getMongoCollection(e),r=this.prepareData(n,t),a=r.id||this.generateId();delete r.id;let d={...r,_id:a};return s&&t.tenantScoped&&(d.tenantId=s),await i.insertOne(d),this.processResult(d,t)}async update(o){let{collection:e,id:n,data:s,tenantId:t}=o,i=this.getCollectionConfig(e),r=this.getMongoCollection(e),a={_id:n};t&&i.tenantScoped&&(a.tenantId=t);let d=this.prepareData(s,i),l=await r.findOneAndUpdate(a,{$set:d},{returnDocument:"after"});if(!l)throw new Error(`Document not found: ${e}/${n}`);return this.processResult(l,i)}async delete(o){let{collection:e,id:n,tenantId:s}=o,t=this.getCollectionConfig(e),i=this.getMongoCollection(e),r={_id:n};s&&t.tenantScoped&&(r.tenantId=s);let a=await i.findOneAndDelete(r);if(!a)throw new Error(`Document not found: ${e}/${n}`);return this.processResult(a,t)}async count(o){let{collection:e,where:n={},tenantId:s}=o,t=this.getCollectionConfig(e),i=this.getMongoCollection(e),r=this.buildFilter(n,t.tenantScoped?s:void 0);return i.countDocuments(r)}async findOne(o){let{collection:e,where:n={},tenantId:s,draft:t}=o,i=this.getCollectionConfig(e),r=this.getMongoCollection(e),a=this.buildFilter(n,i.tenantScoped?s:void 0),d=i.fields.find(u=>u.name==="status"),l=d?.type==="select"&&Array.isArray(d.options)&&d.options.some(u=>u.value==="published");!t&&l&&(a.status="published");let f=await r.findOne(a);if(!f)return null;let g=this.processResult(f,i);if(t){let c=await this.getMongoCollection(`${e}_versions`).findOne({document_id:g.id},{sort:{createdAt:-1}});if(c){let h=typeof c.data=="string"?JSON.parse(c.data):c.data&&typeof c.data=="object"?c.data:{};g={...g,...h,status:g.status};}}return g}async findVersions(o){let{collection:e,documentId:n,sort:s,limit:t=10,page:i=1,tenantId:r}=o,a=this.getCollectionConfig(e),d=this.getMongoCollection(`${e}_versions`),l={document_id:n,autosave:{$ne:true}};r&&a.tenantScoped&&(l.tenant_id=r);let f=(i-1)*t,g=this.parseSort(s),u={[g.field]:g.direction==="asc"?1:-1},[c,h]=await Promise.all([d.find(l).sort(u).skip(f).limit(t).toArray(),d.countDocuments(l)]);return {docs:c.map(y=>this.processResult(y,{})),...this.calculatePagination(i,t,h)}}async findVersionByID(o){let{collection:e,versionId:n,tenantId:s}=o,t=this.getCollectionConfig(e),i=this.getMongoCollection(`${e}_versions`),r={_id:n};s&&t.tenantScoped&&(r.tenant_id=s);let a=await i.findOne(r);return a?this.processResult(a,{}):null}async createVersion(o){let{collection:e,documentId:n,data:s,status:t,createdBy:i,changeDescription:r,tenantId:a,autosave:d}=o,l=this.getCollectionConfig(e),f=this.getMongoCollection(`${e}_versions`);if(d){let c={document_id:n,collection_slug:e,autosave:true};a&&l.tenantScoped&&(c.tenant_id=a);let h=await f.findOne(c);if(h){let y=new Date().toISOString();return await f.updateOne({_id:h._id},{$set:{data:s,status:t,updatedAt:y}}),this.processResult({...h,data:s,status:t,updatedAt:y},{})}}let g=new Date().toISOString(),u={_id:this.generateId(),document_id:n,collection_slug:e,data:s,status:t,autosave:d===true,created_by:i,change_description:r,createdAt:g,updatedAt:g};if(a&&l.tenantScoped&&(u.tenant_id=a),await f.insertOne(u),!d){let c=this.getCollectionConfig(e);c.versions?.maxPerDoc&&await this.deleteVersions({collection:e,documentId:n,keepLatest:c.versions.maxPerDoc,tenantId:a});}return this.processResult(u,{})}async updateLatestVersion(o){return this.createVersion({...o,autosave:true})}async deleteVersions(o){let{collection:e,documentId:n,keepLatest:s,tenantId:t}=o,i=this.getCollectionConfig(e),r=this.getMongoCollection(`${e}_versions`);if(s){let a={document_id:n,autosave:{$ne:true}};t&&i.tenantScoped&&(a.tenant_id=t);let l=(await r.find(a).sort({createdAt:-1}).limit(s).project({_id:1}).toArray()).map(f=>f._id);l.length>0&&await r.deleteMany({document_id:n,autosave:{$ne:true},_id:{$nin:l},...t&&i.tenantScoped?{tenant_id:t}:{}});}else {let a={document_id:n};t&&i.tenantScoped&&(a.tenant_id=t),await r.deleteMany(a);}}async migrate(){for(let o of this.collections.values()){let e=this.getMongoCollection(o.slug);await e.createIndex({_id:1}),o.tenantScoped&&await e.createIndex({tenantId:1}),o.timestamps&&await e.createIndex({createdAt:-1});for(let n of o.fields)n.unique&&n.name&&await e.createIndex({[n.name]:1},{unique:true}),n.indexed&&n.name&&await e.createIndex({[n.name]:1});}}getCollectionConfig(o){if(o.startsWith("_globals_")){let n=o.replace("_globals_",""),s=this.globals.get(n);if(!s)throw new Error(`Global "${n}" not found`);return s}let e=this.collections.get(o);if(!e)throw new Error(`Collection "${o}" not found`);return e}buildFilter(o={},e){let n={};e&&(n.tenantId=e);for(let[s,t]of Object.entries(o))if(s==="AND"&&Array.isArray(t)){let i=t.map(r=>this.buildFilter(r));Object.assign(n,...i);}else if(s==="OR"&&Array.isArray(t))n.$or=t.map(i=>this.buildFilter(i));else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let i={};if(t.equals!==void 0){n[s==="id"?"_id":s]=t.equals;continue}t.not_equals!==void 0&&(i.$ne=t.not_equals),t.in!==void 0&&(i.$in=t.in),t.not_in!==void 0&&(i.$nin=t.not_in),t.greater_than!==void 0&&(i.$gt=t.greater_than),t.greater_than_equal!==void 0&&(i.$gte=t.greater_than_equal),t.less_than!==void 0&&(i.$lt=t.less_than),t.less_than_equal!==void 0&&(i.$lte=t.less_than_equal),t.like!==void 0&&(i.$regex=new RegExp(t.like.replace(/%/g,".*"),"i")),t.not_like!==void 0&&(i.$not=new RegExp(t.not_like.replace(/%/g,".*"),"i")),t.contains!==void 0&&(i.$regex=new RegExp(`.*${t.contains}.*`,"i")),t.exists!==void 0&&(i.$exists=t.exists),Object.keys(i).length>0&&(n[s==="id"?"_id":s]=i);}else n[s==="id"?"_id":s]=t;return n}buildProjection(o){if(!o||o.length===0)return;let e={_id:1};for(let n of o)e[n]=1;return e}processResult(o,e){if(!o)return null;let n={...o};for(let s of Object.keys(n))/^\d+$/.test(s)&&delete n[s];return o._id&&(n.id=o._id,delete n._id),delete n.__v,n.createdAt&&(n.createdAt=new Date(n.createdAt).toISOString()),n.updatedAt&&(n.updatedAt=new Date(n.updatedAt).toISOString()),a$2(n)}generateId(){let o=Date.now().toString(16).padStart(12,"0"),e=randomBytes(6).toString("hex");return o+e}};function k(v){return new w(v)}
3
+ export{w as a,k as b};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkLQ3YZTPU_cjs=require('./chunk-LQ3YZTPU.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),H=require('zlib'),stream=require('stream'),crypto=require('crypto');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var H__namespace=/*#__PURE__*/_interopNamespace(H);chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var C=new Uint32Array(256);for(let n=0;n<256;++n){let e=n;for(let t=0;t<8;++t)e=e&1?3988292384^e>>>1:e>>>1;C[n]=e>>>0;}var L=4294967295,g=class{digestLength=4;checksum=L;update(e){for(let t=0;t<e.length;++t)this.checksum=this.checksum>>>8^C[(this.checksum^e[t])&255];}digestSync(){return (this.checksum^L)>>>0}async digest(){let e=this.digestSync(),t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,false),t}reset(){this.checksum=L;}};var M=typeof H__namespace.crc32=="function"?H__namespace.crc32:void 0,v=M?K(M):g;function K(n){return class{digestLength=4;value=0;update(t){this.value=n(t,this.value);}digestSync(){return this.value>>>0}async digest(){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,this.digestSync(),false),t}reset(){this.value=0;}}}chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var w=class extends stream.Writable{hash;constructor(e,t){super(t),this.hash=e;}_write(e,t,r){try{this.hash.update(chunkLQ3YZTPU_cjs.v(e));}catch(s){return r(s)}r();}};chunkBUNLC3II_cjs.h();var J=(n,e)=>{if(e.readableFlowing!==null)throw new Error("Unable to calculate hash for flowing readable stream");let t=new n,r=new w(t);return e.pipe(r),new Promise((s,f)=>{e.on("error",h=>{r.end(),f(h);}),r.on("error",f),r.on("finish",()=>{t.digest().then(s).catch(f);});})};chunkBUNLC3II_cjs.h();var A=class{digestLength=16;state=Uint32Array.from(E);writeBuffer=new DataView(new ArrayBuffer(64));bufferLength=0;bytesHashed=0;update(e){let t=chunkLQ3YZTPU_cjs.v(e),r=0,s=t.byteLength;for(this.bytesHashed+=s;s>0;)this.writeBuffer.setUint8(this.bufferLength++,t[r++]),--s,this.bufferLength===64&&(N(this.state,this.writeBuffer),this.bufferLength=0);}async digest(){let e=Uint32Array.from(this.state),t=new DataView(this.writeBuffer.buffer.slice(0)),r=this.bufferLength,s=this.bytesHashed*8;if(t.setUint8(r++,128),this.bufferLength%64>=56){for(let i=r;i<64;++i)t.setUint8(i,0);N(e,t),r=0;}for(let i=r;i<56;++i)t.setUint8(i,0);t.setUint32(56,s>>>0,true),t.setUint32(60,Math.floor(s/2**32),true),N(e,t);let f=new Uint8Array(16),h=new DataView(f.buffer);for(let i=0;i<4;++i)h.setUint32(i*4,e[i],true);return f}reset(){this.state.set(E),this.writeBuffer=new DataView(new ArrayBuffer(64)),this.bufferLength=0,this.bytesHashed=0;}},E=[1732584193,4023233417,2562383102,271733878],l=4294967295,_=Uint8Array.of(7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21),R=Array.from({length:64},(n,e)=>Math.abs(Math.sin(e+1))*2**32>>>0);function N(n,e){let t=n[0],r=n[1],s=n[2],f=n[3];for(let h=0;h<64;++h){let i,c;h<16?(i=r&s|~r&f,c=h):h<32?(i=f&r|s&~f,c=(5*h+1)%16):h<48?(i=r^s^f,c=(3*h+5)%16):(i=s^(r|~f),c=7*h%16);let y=e.getUint32(c*4,true),m=f;f=s,s=r;let p=_[(h>>4)*4+(h&3)],a=(t+i&l)+(y+R[h]&l)&l;r=r+((a<<p|a>>>32-p)>>>0)&l,t=m;}n[0]=n[0]+t&l,n[1]=n[1]+r&l,n[2]=n[2]+s&l,n[3]=n[3]+f&l;}chunkBUNLC3II_cjs.h();var F=(()=>{try{return crypto.createHash("md5"),!0}catch{return false}})(),I=F?P():A;function P(){return class{digestLength=16;hash=crypto.createHash("md5");update(e){this.hash.update(chunkLQ3YZTPU_cjs.v(e));}async digest(){let e=this.hash.copy().digest();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}reset(){this.hash=crypto.createHash("md5");}}}chunkBUNLC3II_cjs.h();var u=64,D=32,X=2**53-1,U=class n{digestLength=D;state=Int32Array.from(V);w;buffer=new Uint8Array(64);bufferLength=0;bytesHashed=0;finished=false;inner;outer;constructor(e){if(e){let t=n.normalizeKey(e);this.inner=new n,this.outer=new n;let{inner:r,outer:s}=this,f=new Uint8Array(u*2);for(let h=0;h<u;++h)f[h]=54^t[h],f[h+u]=92^t[h];r.update(f.subarray(0,u)),s.update(f.subarray(u));}}update(e){if(this.finished)throw new Error("Attempted to update an already finished HMAC.");if(this.inner){this.inner.update(e);return}let t=chunkLQ3YZTPU_cjs.v(e),r=0,{byteLength:s}=t;if(this.bytesHashed+=s,this.bytesHashed*8>X)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;s>0;)this.buffer[this.bufferLength++]=t[r++],s--,this.bufferLength===u&&(this.hashBuffer(),this.bufferLength=0);}async digest(){let{inner:e,outer:t}=this;if(e&&t){if(this.finished)throw new Error("Attempted to digest an already finished HMAC.");this.finished=true;let r=e.digestSync();return t.update(r),t.digestSync()}return this.digestSync()}reset(){this.state=Int32Array.from(V),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0;}digestSync(){let e=this.state.slice(),t=this.buffer.slice(),r=this.bufferLength,s=this.bytesHashed*8,f=new DataView(t.buffer,t.byteOffset,t.byteLength);if(f.setUint8(r++,128),(r-1)%u>=u-8){for(let i=r;i<u;++i)f.setUint8(i,0);this.hashBufferWith(e,t),r=0;}for(let i=r;i<u-8;++i)f.setUint8(i,0);f.setUint32(u-8,Math.floor(s/4294967296),false),f.setUint32(u-4,s,false),this.hashBufferWith(e,t);let h=new Uint8Array(D);for(let i=0;i<8;++i)h[i*4]=e[i]>>>24&255,h[i*4+1]=e[i]>>>16&255,h[i*4+2]=e[i]>>>8&255,h[i*4+3]=e[i]>>>0&255;return h}static normalizeKey(e){let t=chunkLQ3YZTPU_cjs.v(e);if(t.byteLength>u){let r=new n;r.update(t);let s=r.digestSync(),f=new Uint8Array(u);return f.set(s),f}if(t.byteLength<u){let r=new Uint8Array(u);return r.set(t),r}return t}hashBuffer(){this.hashBufferWith(this.state,this.buffer);}hashBufferWith(e,t){let r=this.w??=new Int32Array(64),s=e[0],f=e[1],h=e[2],i=e[3],c=e[4],y=e[5],m=e[6],p=e[7];for(let a=0;a<u;++a){if(a<16)r[a]=(t[a*4]&255)<<24|(t[a*4+1]&255)<<16|(t[a*4+2]&255)<<8|t[a*4+3]&255;else {let d=r[a-2],O=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10;d=r[a-15];let W=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;r[a]=(O+r[a-7]|0)+(W+r[a-16]|0);}let B=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&y^~c&m)|0)+(p+(q[a]+r[a]|0)|0)|0,z=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&f^s&h^f&h)|0;p=m,m=y,y=c,c=i+B|0,i=h,h=f,f=s,s=B+z|0;}e[0]+=s,e[1]+=f,e[2]+=h,e[3]+=i,e[4]+=c,e[5]+=y,e[6]+=m,e[7]+=p;}},V=new Int32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),q=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);chunkBUNLC3II_cjs.h();var Y=(()=>{try{return crypto.createHash("sha256"),!0}catch{return false}})(),T=Y?Z():U;function Z(){return class{digestLength=32;secret;hash;isHmac;finished=false;constructor(e){this.secret=e,this.isHmac=!!e,this.hash=this.createHash();}update(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");this.hash.update(e);}async digest(){let e;return this.isHmac?(this.finished=true,e=this.hash.digest()):e=this.hash.copy().digest(),new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}reset(){this.hash=this.createHash(),this.finished=false;}createHash(){return this.secret?crypto.createHmac("sha256",$(this.secret)):crypto.createHash("sha256")}}}function $(n){return typeof n=="string"?n:ArrayBuffer.isView(n)?Buffer.from(n.buffer,n.byteOffset,n.byteLength):Buffer.from(n)}exports.a=J;exports.b=I;exports.c=v;exports.d=T;
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),child_process=require('child_process'),fs=require('fs'),path=require('path');chunkBUNLC3II_cjs.h();function s(){let n=process.cwd();return fs.existsSync(path.join(n,"pnpm-lock.yaml"))?"pnpm":fs.existsSync(path.join(n,"yarn.lock"))?"yarn":fs.existsSync(path.join(n,"bun.lockb"))||fs.existsSync(path.join(n,"bun.lock"))?"bun":"npm"}function u(n){let o=s();console.log(`
2
+ \u{1F4E6} [Kyro CMS] Auto-installing missing database drivers: ${n.join(", ")}...`);try{let i=o==="npm"?"npm install":`${o} add`;child_process.execSync(`${i} ${n.join(" ")}`,{stdio:"inherit"}),console.log(`\u2705 [Kyro CMS] Successfully installed drivers!
3
+ `);}catch(i){throw console.error(`\u274C [Kyro CMS] Failed to auto-install drivers. Please run manually: ${o==="npm"?"npm install":`${o} add`} ${n.join(" ")}`),i}}exports.a=u;
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';import {C,A}from'./chunk-7SSFHJTR.js';import {e}from'./chunk-DS5DE5BU.js';import {nb}from'./chunk-UK43ADRO.js';import {a as a$1}from'./chunk-XBH4YMC7.js';import {c}from'./chunk-ZJE3VAAW.js';import {a}from'./chunk-SVYUTQVE.js';import {a as a$2}from'./chunk-6QWLXJ7L.js';import {g}from'./chunk-C2PXMVR5.js';import w from'kyro:config';createRequire(import.meta.url);
2
+ g();var r=null,l=null;async function b(){if(!r){if(globalThis.__KYRO_INSTANCE__)try{await globalThis.__KYRO_INSTANCE__.shutdown();}catch{}try{let e$1=w.default||w,t=e$1.adapter,o=t&&!t.dialect&&typeof t.connect=="function";if(globalThis.DB&&(!t||o)){let s=globalThis.DB;e$1.adapter=new c({type:"sqlite",client:s}),C.info("Hot-swapped to D1 DrizzleAdapter");}r=A(e$1);let a$3=e$1.adapter,p=a$3&&a$3.dialect&&(a$3.dialect==="postgres"||a$3.dialect==="sqlite"),c$1=a$3&&a$3.dialect==="mongodb",n;if(p)a$3.dialect==="postgres"?n=new a({db:a$3.client}):a$3.dialect==="sqlite"&&(n=new nb({db:a$3.rawClient||a$3.client}));else if(o&&!globalThis.DB){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";n=new a$1({path:s});}else c$1&&(n=new a$2({db:a$3.client}));if(n?.connect)try{await n.connect();}catch(s){C.warn("Auth connect warning:",s);}await r.init();try{await r.loadSettings();}catch(s){C.warn("loadSettings warning:",s);}try{await e(n);}catch(s){C.warn("autoBootstrap warning:",s);}globalThis.__KYRO_INSTANCE__=r;}catch(e){throw r=null,l=null,C.error("Init failed, will retry:",e),e}}}async function E(e){let t=globalThis.DB?globalThis:null;try{let{env:o}=await import('cloudflare:workers');o&&(t=o);}catch{}if(e)try{t=e.locals?.cfContext?.env||e?.env||t;}catch{}if(!t)try{t=process.env;}catch{}t?.DB&&(globalThis.DB=t.DB),t?.STORAGE_BUCKET&&(globalThis.STORAGE_BUCKET=t.STORAGE_BUCKET),l||(l=b()),await l;}var _={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function T(e){return r?r.settings?.access?.apiAccess?.[e]??_[e]??true:_[e]??true}var L=async e=>{if(!r)try{await Promise.race([E(e),new Promise((t,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch(t){return console.error("[Kyro API] Warm error:",t?.stack||t?.message||t),new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}try{let o=new URL(e.request.url).pathname,a=__KYRO_API_PATH__;if(o===`${a}/graphql`&&typeof r.getGraphQL=="function"){if(!T("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let n=await r.getGraphQL().fetch(e.request,e.locals);return new Response(n.body,n)}if(o.startsWith(`${a}/trpc/`)&&typeof r.getTRPC=="function"){if(!T("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let n=await r.getTRPC().fetch(e.request,e.locals);return new Response(n.body,n)}return await(await r.getREST()).fetch(e.request,e.locals)}catch(t){return console.error("[Kyro API Execution Error]:",t?.stack||t?.message||t),new Response(JSON.stringify({error:"Internal Server Error",message:t?.message||String(t),stack:t?.stack}),{status:500,headers:{"Content-Type":"application/json"}})}};export{r as a,E as b,L as c};
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunkGNEVCEJU_cjs=require('./chunk-GNEVCEJU.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),w=require('https'),stream=require('stream');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function S(o){let e=o&&typeof o=="object"&&"reason"in o?o.reason:void 0;if(e){if(e instanceof Error){let n=new Error("Request aborted");return n.name="AbortError",n.cause=e,n}let r=new Error(String(e));return r.name="AbortError",r}let t=new Error("Request aborted");return t.name="AbortError",t}chunkBUNLC3II_cjs.h();var U=["ECONNRESET","EPIPE","ETIMEDOUT"];chunkBUNLC3II_cjs.h();var B=o=>{let e={};for(let t in o){let r=o[t];e[t]=Array.isArray(r)?r.join(","):r;}return e};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var a={setTimeout:(o,e)=>setTimeout(o,e),clearTimeout:o=>clearTimeout(o)};var $=1e3,j=(o,e,t=0)=>{if(!t)return -1;let r=n=>{let c=a.setTimeout(()=>{o.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${t} ms.`),{name:"TimeoutError"}));},t-n),i=u=>{u?.connecting?u.on("connect",()=>{a.clearTimeout(c);}):a.clearTimeout(c);};o.socket?i(o.socket):o.on("socket",i);};return t<2e3?(r(0),0):a.setTimeout(r.bind(null,$),$)};chunkBUNLC3II_cjs.h();var W=(o,e,t=0,r,n)=>t?a.setTimeout(()=>{let c=`@smithy/node-http-handler - [${r?"ERROR":"WARN"}] a request has exceeded the configured ${t} ms requestTimeout.`;if(r){let i=Object.assign(new Error(c),{name:"TimeoutError",code:"ETIMEDOUT"});o.destroy(i),e(i);}else c+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",n?.warn?.(c);},t):-1;chunkBUNLC3II_cjs.h();var G=3e3,F=(o,{keepAlive:e,keepAliveMsecs:t},r=G)=>{if(e!==true)return -1;let n=()=>{o.socket?o.socket.setKeepAlive(e,t||0):o.on("socket",c=>{c.setKeepAlive(e,t||0);});};return r===0?(n(),0):a.setTimeout(n,r)};chunkBUNLC3II_cjs.h();var K=3e3,M=(o,e,t=0)=>{let r=n=>{let c=t-n,i=()=>{o.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${t} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}));};o.socket?(o.socket.setTimeout(c,i),o.on("close",()=>o.socket?.removeListener("timeout",i))):o.setTimeout(c,i);};return 0<t&&t<6e3?(r(0),0):a.setTimeout(r.bind(null,t===0?0:K),K)};chunkBUNLC3II_cjs.h();var V=6e3;async function Q(o,e,t=V,r=false){let n=e.headers,c=n?n.Expect||n.expect:void 0,i=-1,u=true;!r&&c==="100-continue"&&(u=await Promise.race([new Promise(m=>{i=Number(a.setTimeout(()=>m(true),Math.max(V,t)));}),new Promise(m=>{o.on("continue",()=>{a.clearTimeout(i),m(true);}),o.on("response",()=>{a.clearTimeout(i),m(false);}),o.on("error",()=>{a.clearTimeout(i),m(false);});})])),u&&Y(o,e.body);}function Y(o,e){if(e instanceof stream.Readable){e.pipe(o);return}if(e){let t=Buffer.isBuffer(e);if(t||typeof e=="string"){t&&e.byteLength===0?o.end():o.end(e);return}let n=e;if(typeof n=="object"&&n.buffer&&typeof n.byteOffset=="number"&&typeof n.byteLength=="number"){o.end(Buffer.from(n.buffer,n.byteOffset,n.byteLength));return}o.end(Buffer.from(e));return}o.end();}var b,J,I=class o{config;configProvider;socketWarningTimestamp=0;externalAgent=false;metadata={handlerProtocol:"http/1.1"};static create(e){return typeof e?.handle=="function"?e:new o(e)}static checkSocketUsage(e,t,r=console){let{sockets:n,requests:c,maxSockets:i}=e;if(typeof i!="number"||i===1/0||Date.now()-15e3<t)return t;if(n&&c)for(let m in n){let g=n[m]?.length??0,l=c[m]?.length??0;if(g>=i&&l>=2*i)return r?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${g} and ${l} additional requests are enqueued.
2
+ See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
3
+ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return t}constructor(e){this.configProvider=new Promise((t,r)=>{typeof e=="function"?e().then(n=>{t(this.resolveDefaultConfig(n));}).catch(r):t(this.resolveDefaultConfig(e));});}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy();}async handle(e,{abortSignal:t,requestTimeout:r}={}){this.config||(this.config=await this.configProvider);let n=this.config,c=e.protocol==="https:";return !c&&!this.config.httpAgent&&(this.config.httpAgent=await this.config.httpAgentProvider()),new Promise((i,u)=>{let m,g=-1,l=-1,E=-1,A=-1,x=-1,y=()=>{a.clearTimeout(g),a.clearTimeout(l),a.clearTimeout(E),a.clearTimeout(A),a.clearTimeout(x);},q=async f=>{await m,y(),i(f);},T=async f=>{await m,y(),u(f);};if(t?.aborted){let f=S(t);T(f);return}let R=e.headers,z=R?(R.Expect??R.expect)==="100-continue":false,_=c?n.httpsAgent:n.httpAgent;z&&!this.externalAgent&&(_=new(c?w__default.default.Agent:b)({keepAlive:false,maxSockets:1/0})),g=a.setTimeout(()=>{this.socketWarningTimestamp=o.checkSocketUsage(_,this.socketWarningTimestamp,n.logger);},n.socketAcquisitionWarningTimeout??(n.requestTimeout??2e3)+(n.connectionTimeout??1e3));let D=e.query?chunkGNEVCEJU_cjs.V(e.query):"",N;if(e.username!=null||e.password!=null){let f=e.username??"",p=e.password??"";N=`${f}:${p}`;}let O=e.path;D&&(O+=`?${D}`),e.fragment&&(O+=`#${e.fragment}`);let k=e.hostname??"";k[0]==="["&&k.endsWith("]")?k=e.hostname.slice(1,-1):k=e.hostname;let P={headers:e.headers,host:k,method:e.method,path:O,port:e.port,agent:_,auth:N},h=(c?w__default.default.request:J)(P,f=>{let p=new chunkGNEVCEJU_cjs.f({statusCode:f.statusCode||-1,reason:f.statusMessage,headers:B(f.headers),body:f});q({response:p});});if(h.on("error",f=>{U.includes(f.code)?T(Object.assign(f,{name:"TimeoutError"})):T(f);}),t){let f=()=>{h.destroy();let p=S(t);T(p);};if(typeof t.addEventListener=="function"){let p=t;p.addEventListener("abort",f,{once:true}),h.once("close",()=>p.removeEventListener("abort",f));}else t.onabort=f;}let C=r??n.requestTimeout;l=j(h,T,n.connectionTimeout),E=W(h,T,C,n.throwOnRequestTimeout,n.logger??console),A=M(h,T,n.socketTimeout);let v=P.agent;typeof v=="object"&&"keepAlive"in v&&(x=F(h,{keepAlive:v.keepAlive,keepAliveMsecs:v.keepAliveMsecs})),m=Q(h,e,C,this.externalAgent).catch(f=>(y(),u(f)));})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then(r=>({...r,[e]:t}));}httpHandlerConfigs(){return this.config??{}}resolveDefaultConfig(e){let{requestTimeout:t,connectionTimeout:r,socketTimeout:n,socketAcquisitionWarningTimeout:c,httpAgent:i,httpsAgent:u,throwOnRequestTimeout:m,logger:g}=e||{},l=true,E=50;return {connectionTimeout:r,requestTimeout:t,socketTimeout:n,socketAcquisitionWarningTimeout:c,throwOnRequestTimeout:m,httpAgentProvider:async()=>{let A=await import('http'),{Agent:x,request:y}=A.default??A;return J=y,b=x,i instanceof b||typeof i?.destroy=="function"?(this.externalAgent=true,i):new b({keepAlive:l,maxSockets:E,...i})},httpsAgent:u instanceof w__default.default.Agent||typeof u?.destroy=="function"?(this.externalAgent=true,u):new w__default.default.Agent({keepAlive:l,maxSockets:E,...u}),logger:g}}};chunkBUNLC3II_cjs.h();exports.a=I;
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunkLQ3YZTPU_cjs=require('./chunk-LQ3YZTPU.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),path=require('path'),os=require('os'),promises=require('fs/promises'),crypto=require('crypto');chunkBUNLC3II_cjs.h();exports.b=void 0;(function(r){r.MD5="md5",r.CRC32="crc32",r.CRC32C="crc32c",r.SHA1="sha1",r.SHA256="sha256";})(exports.b||(exports.b={}));chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var te="__smithy_context";chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();exports.a=void 0;(function(r){r.HTTP="http",r.HTTPS="https";})(exports.a||(exports.a={}));chunkBUNLC3II_cjs.h();var C;(function(r){r.PROFILE="profile",r.SSO_SESSION="sso-session",r.SERVICES="services";})(C||(C={}));chunkBUNLC3II_cjs.h();var z=r=>r[te]||(r[te]={});chunkBUNLC3II_cjs.h();var Mt=r=>{if(typeof r=="function")return r;let e=Promise.resolve(r);return ()=>e};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function Ke(r){let e={};if(r=r.replace(/^\?/,""),r)for(let t of r.split("&")){let[o,s=null]=t.split("=");o=decodeURIComponent(o),s&&(s=decodeURIComponent(s)),o in e?Array.isArray(e[o])?e[o].push(s):e[o]=[e[o],s]:e[o]=s;}return e}var R=r=>{if(typeof r=="string")return R(new URL(r));let{hostname:e,pathname:t,port:o,protocol:s,search:n}=r,a;return n&&(a=Ke(n)),{hostname:e,port:o?parseInt(o):void 0,protocol:s,path:t,query:a}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var b=class r{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)!==":"?`${e.protocol}:`:e.protocol:"https:",this.path=e.path?e.path.charAt(0)!=="/"?`/${e.path}`:e.path:"/",this.username=e.username,this.password=e.password,this.fragment=e.fragment;}static clone(e){let t=new r({...e,headers:{...e.headers}});return t.query&&(t.query=Lt(t.query)),t}static isInstance(e){if(!e)return false;let t=e;return "method"in t&&"protocol"in t&&"hostname"in t&&"path"in t&&typeof t.query=="object"&&typeof t.headers=="object"}clone(){return r.clone(this)}};function Lt(r){return Object.keys(r).reduce((e,t)=>{let o=r[t];return {...e,[t]:Array.isArray(o)?[...o]:o}},{})}chunkBUNLC3II_cjs.h();var D=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body;}static isInstance(e){if(!e)return false;let t=e;return typeof t.statusCode=="number"&&typeof t.headers=="object"}};chunkBUNLC3II_cjs.h();var zt=new RegExp("^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$"),re=(r,e=false)=>{if(!e)return zt.test(r);let t=r.split(".");for(let o of t)if(!re(o))return false;return true};chunkBUNLC3II_cjs.h();function ye(r){return /^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(r)}chunkBUNLC3II_cjs.h();var xe=r=>{if(typeof r=="object"){if("url"in r){let e=R(r.url);if(r.headers){e.headers={};for(let t in r.headers)e.headers[t.toLowerCase()]=r.headers[t].join(", ");}return e}return r}return R(r)};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var oe=(r,e,t,o,s)=>({name:e,namespace:r,traits:t,input:o,output:s});var qe=r=>(e,t)=>async o=>{let{response:s}=await e(o),{operationSchema:n}=z(t),[,a,f,m,h,u]=n??[];try{let p=await r.protocol.deserializeResponse(oe(a,f,m,h,u),{...r,...t},s);return {response:s,output:p}}catch(p){if(Object.defineProperty(p,"$response",{value:s,enumerable:false,writable:false,configurable:false}),!("$metadata"in p)){let S="Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.";try{p.message+=`
2
+ `+S;}catch{!t.logger||t.logger?.constructor?.name==="NoOpLogger"?console.warn(S):t.logger?.warn?.(S);}typeof p.$responseBodyText<"u"&&p.$response&&(p.$response.body=p.$responseBodyText);try{if(D.isInstance(s)){let{headers:E={},statusCode:d}=s,l=Object.entries(E);p.$metadata={httpStatusCode:d,requestId:Te(/^x-[\w-]+-request-?id$/,l),extendedRequestId:Te(/^x-[\w-]+-id-2$/,l),cfId:Te(/^x-[\w-]+-cf-id$/,l)};}}catch{}}throw p}},Te=(r,e)=>(e.find(([t])=>t.match(r))||[void 0,void 0])[1];chunkBUNLC3II_cjs.h();var Qe=r=>(e,t)=>async o=>{let{operationSchema:s}=z(t),[,n,a,f,m,h]=s??[],u=t.endpointV2?async()=>xe(t.endpointV2):r.endpoint,p=await r.protocol.serializeRequest(oe(n,a,f,m,h),o.input,{...r,...t,endpoint:u});return e({...o,request:p})};var Xe={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:true},Je={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:true};function Ht(r){return {applyToStack:e=>{e.add(Qe(r),Je),e.add(qe(r),Xe),r.protocol.setSerdeContext(r);}}}chunkBUNLC3II_cjs.h();var H=class r{namespace;schemas;exceptions;static registries=new Map;constructor(e,t=new Map,o=new Map){this.namespace=e,this.schemas=t,this.exceptions=o;}static for(e){return r.registries.has(e)||r.registries.set(e,new r(e)),r.registries.get(e)}copyFrom(e){let{schemas:t,exceptions:o}=this;for(let[s,n]of e.schemas)t.has(s)||t.set(s,n);for(let[s,n]of e.exceptions)o.has(s)||o.set(s,n);}register(e,t){let o=this.normalizeShapeId(e);for(let s of [this,r.for(o.split("#")[0])])s.schemas.set(o,t);}getSchema(e){let t=this.normalizeShapeId(e);if(!this.schemas.has(t)){if(!e.includes("#")){let o="#"+e,s=[];for(let[n,a]of this.schemas.entries())n.endsWith(o)&&s.push(a);if(s.length===1)return s[0]}throw new Error(`@smithy/core/schema - schema not found for ${t}`)}return this.schemas.get(t)}registerError(e,t){let o=e,s=o[1];for(let n of [this,r.for(s)])n.schemas.set(s+"#"+o[2],o),n.exceptions.set(o,t);}getErrorCtor(e){let t=e;return this.exceptions.has(t)?this.exceptions.get(t):r.for(t[1]).exceptions.get(t)}getBaseException(){for(let e of this.exceptions.keys())if(Array.isArray(e)){let[,t,o]=e,s=t+"#"+o;if(s.startsWith("smithy.ts.sdk.synthetic.")&&s.endsWith("ServiceException"))return e}}find(e){for(let t of this.schemas.values())if(e(t))return t}clear(){this.schemas.clear(),this.exceptions.clear();}normalizeShapeId(e){return e.includes("#")?e:this.namespace+"#"+e}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var U=r=>typeof r=="function"?r():r;chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var se=[];function _(r){if(typeof r=="object")return r;if(r=r|0,se[r])return se[r];let e={},t=0;for(let o of ["httpLabel","idempotent","idempotencyToken","sensitive","httpPayload","httpResponseCode","httpQueryParams"])(r>>t++&1)===1&&(e[o]=1);return se[r]=e}var k={it:Symbol.for("@smithy/nor-struct-it"),ns:Symbol.for("@smithy/ns")},ie=[],ne={},y=class r{ref;memberName;static symbol=Symbol.for("@smithy/nor");symbol=r.symbol;name;schema;_isMemberSchema;traits;memberTraits;normalizedTraits;constructor(e,t){this.ref=e,this.memberName=t;let o=[],s=e,n=e;for(this._isMemberSchema=false;be(s);)o.push(s[1]),s=s[0],n=U(s),this._isMemberSchema=true;if(o.length>0){this.memberTraits={};for(let a=o.length-1;a>=0;--a){let f=o[a];Object.assign(this.memberTraits,_(f));}}else this.memberTraits=0;if(n instanceof r){let a=this.memberTraits;Object.assign(this,n),this.memberTraits=Object.assign({},a,n.getMemberTraits(),this.getMemberTraits()),this.normalizedTraits=void 0,this.memberName=t??n.memberName;return}if(this.schema=U(n),Ye(this.schema)?(this.name=`${this.schema[1]}#${this.schema[2]}`,this.traits=this.schema[3]):(this.name=this.memberName??String(n),this.traits=0),this._isMemberSchema&&!t)throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`)}static[Symbol.hasInstance](e){let t=this.prototype.isPrototypeOf(e);return !t&&typeof e=="object"&&e!==null?e.symbol===this.symbol:t}static of(e){let t=typeof e=="function"||typeof e=="object"&&e!==null;if(typeof e=="number"){if(ie[e])return ie[e]}else if(typeof e=="string"){if(ne[e])return ne[e]}else if(t&&e[k.ns])return e[k.ns];let o=U(e);if(o instanceof r)return o;if(be(o)){let[n,a]=o;if(n instanceof r)return Object.assign(n.getMergedTraits(),_(a)),n;throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(e,null,2)}.`)}let s=new r(o);return t?e[k.ns]=s:typeof o=="string"?ne[o]=s:typeof o=="number"?ie[o]=s:s}getSchema(){let e=this.schema;return Array.isArray(e)&&e[0]===0?e[4]:e}getName(e=false){let{name:t}=this;return !e&&t&&t.includes("#")?t.split("#")[1]:t||void 0}getMemberName(){return this.memberName}isMemberSchema(){return this._isMemberSchema}isListSchema(){let e=this.getSchema();return typeof e=="number"?e>=64&&e<128:e[0]===1}isMapSchema(){let e=this.getSchema();return typeof e=="number"?e>=128&&e<=255:e[0]===2}isStructSchema(){let e=this.getSchema();if(typeof e!="object")return false;let t=e[0];return t===3||t===-3||t===4}isUnionSchema(){let e=this.getSchema();return typeof e!="object"?false:e[0]===4}isBlobSchema(){let e=this.getSchema();return e===21||e===42}isTimestampSchema(){let e=this.getSchema();return typeof e=="number"&&e>=4&&e<=7}isUnitSchema(){return this.getSchema()==="unit"}isDocumentSchema(){return this.getSchema()===15}isStringSchema(){return this.getSchema()===0}isBooleanSchema(){return this.getSchema()===2}isNumericSchema(){return this.getSchema()===1}isBigIntegerSchema(){return this.getSchema()===17}isBigDecimalSchema(){return this.getSchema()===19}isStreaming(){let{streaming:e}=this.getMergedTraits();return !!e||this.getSchema()===42}isIdempotencyToken(){return !!this.getMergedTraits().idempotencyToken}getMergedTraits(){return this.normalizedTraits??(this.normalizedTraits={...this.getOwnTraits(),...this.getMemberTraits()})}getMemberTraits(){return _(this.memberTraits)}getOwnTraits(){return _(this.traits)}getKeySchema(){let[e,t]=[this.isDocumentSchema(),this.isMapSchema()];if(!e&&!t)throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);let o=this.getSchema(),s=e?15:o[4]??0;return $([s,0],"key")}getValueSchema(){let e=this.getSchema(),[t,o,s]=[this.isDocumentSchema(),this.isMapSchema(),this.isListSchema()],n=typeof e=="number"?63&e:e&&typeof e=="object"&&(o||s)?e[3+e[0]]:t?15:void 0;if(n!=null)return $([n,0],o?"value":"member");throw new Error(`@smithy/core/schema - ${this.getName(true)} has no value member.`)}getMemberSchema(e){let t=this.getSchema();if(this.isStructSchema()&&t[4].includes(e)){let o=t[4].indexOf(e),s=t[5][o];return $(be(s)?s:[s,0],e)}if(this.isDocumentSchema())return $([15,0],e);throw new Error(`@smithy/core/schema - ${this.getName(true)} has no member=${e}.`)}getMemberSchemas(){let e={};try{for(let[t,o]of this.structIterator())e[t]=o;}catch{}return e}getEventStreamMember(){if(this.isStructSchema()){for(let[e,t]of this.structIterator())if(t.isStreaming()&&t.isStructSchema())return e}return ""}*structIterator(){if(this.isUnitSchema())return;if(!this.isStructSchema())throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");let e=this.getSchema(),t=e[4].length,o=e[k.it];if(o&&t===o.length){yield*o;return}o=Array(t);for(let s=0;s<t;++s){let n=e[4][s],a=$([e[5][s],0],n);yield o[s]=[n,a];}e[k.it]=o;}};function $(r,e){if(r instanceof y)return Object.assign(r,{memberName:e,_isMemberSchema:true});let t=y;return new t(r,e)}var be=r=>Array.isArray(r)&&r.length===2,Ye=r=>Array.isArray(r)&&r.length>=5;chunkBUNLC3II_cjs.h();var O=class r extends Error{name="ProviderError";tryNextLink;constructor(e,t=true){let o,s=true;typeof t=="boolean"?(o=void 0,s=t):t!=null&&typeof t=="object"&&(o=t.logger,s=t.tryNextLink??true),super(e),this.tryNextLink=s,Object.setPrototypeOf(this,r.prototype),o?.debug?.(`@smithy/property-provider ${s?"->":"(!)"} ${e}`);}static from(e,t=true){return Object.assign(new this(e.message,t),e)}};chunkBUNLC3II_cjs.h();var F=class r extends O{name="CredentialsProviderError";constructor(e,t=true){super(e,t),Object.setPrototypeOf(this,r.prototype);}};chunkBUNLC3II_cjs.h();var Ze="AWS_PROFILE",et="default",Ne=r=>r.profile||process.env[Ze]||et;chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var Ce={},$t=()=>process&&process.geteuid?`${process.geteuid()}`:"DEFAULT",v=()=>{let{HOME:r,USERPROFILE:e,HOMEPATH:t,HOMEDRIVE:o=`C:${path.sep}`}=process.env;if(r)return r;if(e)return e;if(t)return `${o}${t}`;let s=$t();return Ce[s]||(Ce[s]=os.homedir()),Ce[s]};var jt="AWS_CONFIG_FILE",ae=()=>process.env[jt]||path.join(v(),".aws","config");chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var tt=r=>Object.entries(r).filter(([e])=>{let t=e.indexOf(".");return t===-1?false:Object.values(C).includes(e.substring(0,t))}).reduce((e,[t,o])=>{let s=t.indexOf("."),n=t.substring(0,s)===C.PROFILE?t.substring(s+1):t;return e[n]=o,e},{...r.default&&{default:r.default}});chunkBUNLC3II_cjs.h();var Bt="AWS_SHARED_CREDENTIALS_FILE",rt=()=>process.env[Bt]||path.join(v(),".aws","credentials");chunkBUNLC3II_cjs.h();var Wt=/^([\w-]+)\s(["'])?([\w-@+.%:/]+)\2$/,Kt=["__proto__","profile __proto__"],j=r=>{let e={},t,o;for(let s of r.split(/\r?\n/)){let n=s.split(/(^|\s)[;#]/)[0].trim();if(n[0]==="["&&n[n.length-1]==="]"){t=void 0,o=void 0;let f=n.substring(1,n.length-1),m=Wt.exec(f);if(m){let[,h,,u]=m;Object.values(C).includes(h)&&(t=[h,u].join("."));}else t=f;if(Kt.includes(f))throw new Error(`Found invalid profile name "${f}"`)}else if(t){let f=n.indexOf("=");if(![0,-1].includes(f)){let[m,h]=[n.substring(0,f).trim(),n.substring(f+1).trim()];if(h==="")o=m;else {o&&s.trimStart()===s&&(o=void 0),e[t]=e[t]||{};let u=o?[o,m].join("."):m;e[t][u]=h;}}}}return e};chunkBUNLC3II_cjs.h();var _e={},G={},M=(r,e)=>G[r]!==void 0?G[r]:((!_e[r]||e?.ignoreCache)&&(_e[r]=promises.readFile(r,"utf8")),_e[r]);var st=()=>({}),ce=async(r={})=>{let{filepath:e=rt(),configFilepath:t=ae()}=r,o=v(),s="~/",n=e;e.startsWith(s)&&(n=path.join(o,e.slice(2)));let a=t;t.startsWith(s)&&(a=path.join(o,t.slice(2)));let f=await Promise.all([M(a,{ignoreCache:r.ignoreCache}).then(j).then(tt).catch(st),M(n,{ignoreCache:r.ignoreCache}).then(j).catch(st)]);return {configFile:f[0],credentialsFile:f[1]}};var it=r=>Object.entries(r).filter(([e])=>e.startsWith(C.SSO_SESSION+".")).reduce((e,[t,o])=>({...e,[t.substring(t.indexOf(".")+1)]:o}),{});var Qt=()=>({}),Xt=async(r={})=>M(r.configFilepath??ae()).then(j).then(it).catch(Qt);chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var nt=(...r)=>{let e={};for(let t of r)for(let[o,s]of Object.entries(t))e[o]!==void 0?Object.assign(e[o],s):e[o]=s;return e};var Jt=async r=>{let e=await ce(r);return nt(e.configFile,e.credentialsFile)};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var we=r=>{let t=crypto.createHash("sha1").update(r).digest("hex");return path.join(v(),".aws","sso","cache",`${t}.json`)};var B={},tr=async r=>{if(B[r])return B[r];let e=we(r),t=await promises.readFile(e,"utf8");return JSON.parse(t)};var rr={getFileRecord(){return G},interceptFile(r,e){G[r]=Promise.resolve(e);},getTokenRecord(){return B},interceptToken(r,e){B[r]=e;}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var Oe=(...r)=>async()=>{if(r.length===0)throw new O("No providers in chain");let e;for(let t of r)try{return await t()}catch(o){if(e=o,o?.tryNextLink)continue;throw o}throw e};chunkBUNLC3II_cjs.h();var me=(r,e,t)=>{let o,s,n,a=false,f=async()=>{s||(s=r());try{o=await s,n=!0,a=!1;}finally{s=void 0;}return o};return e===void 0?async m=>((!n||m?.forceRefresh)&&(o=await f()),o):async m=>((!n||m?.forceRefresh)&&(o=await f()),a?o:t&&!t(o)?(a=true,o):(e(o)&&await f(),o))};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function fe(r){try{let e=new Set(Array.from(r.match(/([A-Z_]){3,}/g)??[]));return e.delete("CONFIG"),e.delete("CONFIG_PREFIX_SEPARATOR"),e.delete("ENV"),[...e].join(", ")}catch{return r}}var at=(r,e)=>async()=>{try{let t=r(process.env,e);if(t===void 0)throw new Error;return t}catch(t){throw new F(t.message||`Not found in ENV: ${fe(r.toString())}`,{logger:e?.logger})}};chunkBUNLC3II_cjs.h();var ct=(r,{preferredFile:e="config",...t}={})=>async()=>{let o=Ne(t),{configFile:s,credentialsFile:n}=await ce(t),a=n[o]||{},f=s[o]||{},m=e==="config"?{...a,...f}:{...f,...a};try{let u=r(m,e==="config"?s:n);if(u===void 0)throw new Error;return u}catch(h){throw new F(h.message||`Not found in config files w/ profile [${o}]: ${fe(r.toString())}`,{logger:t.logger})}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var mt=r=>()=>Promise.resolve(r);var or=r=>typeof r=="function",ft=r=>or(r)?async()=>await r():mt(r);var he=({environmentVariableSelector:r,configFileSelector:e,default:t},o={})=>{let{signingName:s,logger:n}=o;return me(Oe(at(r,{signingName:s,logger:n}),ct(e,o),ft(t)))};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var ht=new Set,lt=(r,e=re)=>{if(!ht.has(r)&&!e(r))if(r==="*")console.warn('@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.');else throw new Error(`Region not accepted: region="${r}" is not a valid hostname component.`);else ht.add(r);};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var le=r=>typeof r=="string"&&(r.startsWith("fips-")||r.endsWith("-fips"));var pt=r=>le(r)?["fips-aws-global","aws-fips"].includes(r)?"us-east-1":r.replace(/fips-(dkr-|prod-)?|-fips/,""):r;var sr=r=>{let{region:e,useFipsEndpoint:t}=r;if(!e)throw new Error("Region is missing");return Object.assign(r,{region:async()=>{let o=typeof e=="function"?await e():e,s=pt(o);return lt(s),s},useFipsEndpoint:async()=>{let o=typeof e=="string"?e:await e();return le(o)?true:typeof t!="function"?Promise.resolve(!!t):t()}})};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var Ie=class r extends O{name="TokenProviderError";constructor(e,t=true){super(e,t),Object.setPrototypeOf(this,r.prototype);}};chunkBUNLC3II_cjs.h();var P=(r,e,t)=>{if(e in r){if(r[e]==="true")return true;if(r[e]==="false")return false;throw new Error(`Cannot load ${t} "${e}". Expected "true" or "false", got ${r[e]}.`)}};chunkBUNLC3II_cjs.h();exports.t=void 0;(function(r){r.ENV="env",r.CONFIG="shared config entry";})(exports.t||(exports.t={}));chunkBUNLC3II_cjs.h();var dt="AWS_USE_DUALSTACK_ENDPOINT",ut="use_dualstack_endpoint";var ir={environmentVariableSelector:r=>P(r,dt,exports.t.ENV),configFileSelector:r=>P(r,ut,exports.t.CONFIG),default:false};chunkBUNLC3II_cjs.h();var gt="AWS_USE_FIPS_ENDPOINT",St="use_fips_endpoint";var nr={environmentVariableSelector:r=>P(r,gt,exports.t.ENV),configFileSelector:r=>P(r,St,exports.t.CONFIG),default:false};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var Et="AWS_EXECUTION_ENV",Ae="AWS_REGION",De="AWS_DEFAULT_REGION",yt="AWS_EC2_METADATA_DISABLED",xt=["in-region","cross-region","mobile","standard","legacy"],Tt="/latest/meta-data/placement/region",bt="/latest/api/token",Nt="x-aws-ec2-metadata-token",Ct="x-aws-ec2-metadata-token-ttl-seconds";var _t=1e3,ar=6e4,It=0,pe=async()=>{if(!process.env[yt]&&!(Date.now()<It))try{let r=cr(),e=(await Ot({...r,path:bt,method:"PUT",headers:{[Ct]:"21600"}})).toString();return (await Ot({...r,path:Tt,method:"GET",headers:{[Nt]:e}})).toString().trim()||wt()}catch{return wt()}},wt=()=>{It=Date.now()+ar;},cr=()=>{let r=process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;if(r){let e=new URL(r);return {hostname:e.hostname.replace(/^\[(.+)]$/,"$1"),port:e.port?Number(e.port):void 0}}return process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE==="IPv6"?{hostname:"fd00:ec2::254"}:{hostname:"169.254.169.254"}},Ot=async r=>{let{request:e}=await import('http');return new Promise((t,o)=>{let s=e({hostname:r.hostname,port:r.port,path:r.path,method:r.method,headers:r.headers,timeout:_t,signal:AbortSignal.timeout(_t)});s.on("error",n=>{o(n),s.destroy();}),s.on("timeout",()=>{o(new Error("TimeoutError from instance metadata service")),s.destroy();}),s.on("response",n=>{let{statusCode:a=400}=n;if(a<200||a>=300){o(Object.assign(new Error("Error response received from instance metadata service"),{statusCode:a})),s.destroy();return}let f=[];n.on("data",m=>f.push(m)),n.on("end",()=>{t(Buffer.concat(f)),s.destroy();});}),s.end();})};var At="AWS_REGION",Dt="region",ve={environmentVariableSelector:r=>r[At],configFileSelector:r=>r[Dt],default:async()=>{let r=await pe();if(r)return r;throw new Error("Region is missing")}},mr={preferredFile:"credentials"};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var fr="AWS_DEFAULTS_MODE",hr="defaults_mode",vt={environmentVariableSelector:r=>r[fr],configFileSelector:r=>r[hr],default:"legacy"};var lr=({region:r=he(ve),defaultsMode:e=he(vt)}={})=>me(async()=>{let t=typeof e=="function"?await e():e;switch(t?.toLowerCase()){case "auto":return pr(r);case "in-region":case "cross-region":case "mobile":case "standard":case "legacy":return Promise.resolve(t?.toLocaleLowerCase());case void 0:return Promise.resolve("legacy");default:throw new Error(`Invalid parameter for "defaultsMode", expect ${xt.join(", ")}, got ${t}`)}}),pr=async r=>{if(r){let e=typeof r=="function"?await r():r,t=await dr();return t?e===t?"in-region":"cross-region":"standard"}return "standard"},dr=async()=>process.env[Et]&&(process.env[Ae]||process.env[De])?process.env[Ae]??process.env[De]:pe();chunkBUNLC3II_cjs.h();var Ft="content-length";function Pt(r){return e=>async t=>{let o=t.request;if(b.isInstance(o)){let{body:s,headers:n}=o;if(s&&Object.keys(n).map(a=>a.toLowerCase()).indexOf(Ft)===-1)try{let a=r(s);o.headers={...o.headers,[Ft]:String(a)};}catch{}}return e({...t,request:o})}}var Rt={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:true},ur=r=>({applyToStack:e=>{e.add(Pt(r.bodyLengthChecker),Rt);}});chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var A=async(r=new Uint8Array,e)=>{if(r instanceof Uint8Array)return chunkLQ3YZTPU_cjs.B.mutate(r);if(!r)return chunkLQ3YZTPU_cjs.B.mutate(new Uint8Array);let t=e.streamCollector(r);return chunkLQ3YZTPU_cjs.B.mutate(await t)};chunkBUNLC3II_cjs.h();function de(r){return encodeURIComponent(r).replace(/[!'()*]/g,function(e){return "%"+e.charCodeAt(0).toString(16).toUpperCase()})}chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var w=class{serdeContext;setSerdeContext(e){this.serdeContext=e;}};var L=class extends w{options;compositeErrorRegistry;constructor(e){super(),this.options=e,this.compositeErrorRegistry=H.for(e.defaultNamespace);for(let t of e.errorTypeRegistries??[])this.compositeErrorRegistry.copyFrom(t);}getRequestType(){return b}getResponseType(){return D}setSerdeContext(e){this.serdeContext=e,this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e),this.getPayloadCodec()&&this.getPayloadCodec().setSerdeContext(e);}updateServiceEndpoint(e,t){if("url"in t){e.protocol=t.url.protocol,e.hostname=t.url.hostname,e.port=t.url.port?Number(t.url.port):void 0,e.path=t.url.pathname,e.fragment=t.url.hash||void 0,e.username=t.url.username||void 0,e.password=t.url.password||void 0,e.query||(e.query={});for(let[o,s]of t.url.searchParams.entries())e.query[o]=s;if(t.headers)for(let o in t.headers)e.headers[o]=t.headers[o].join(", ");return e}else {if(e.protocol=t.protocol,e.hostname=t.hostname,e.port=t.port?Number(t.port):void 0,e.path=t.path,e.query={...t.query},t.headers)for(let o in t.headers)e.headers[o]=t.headers[o];return e}}setHostPrefix(e,t,o){if(this.serdeContext?.disableHostPrefix)return;let s=y.of(t.input),n=_(t.traits??{});if(n.endpoint){let a=n.endpoint?.[0];if(typeof a=="string"){for(let[f,m]of s.structIterator()){if(!m.getMergedTraits().hostLabel)continue;let h=o[f];if(typeof h!="string")throw new Error(`@smithy/core/schema - ${f} in input must be a string as hostLabel.`);a=a.replace(`{${f}}`,h);}if(e.hostname=a+e.hostname,!ye(e.hostname))throw new Error(`[${e.hostname}] is not a valid hostname.`)}}}deserializeMetadata(e){return {httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}}async serializeEventStream({eventStream:e,requestSchema:t,initialRequest:o}){return (await this.loadEventStreamCapability()).serializeEventStream({eventStream:e,requestSchema:t,initialRequest:o})}async deserializeEventStream({response:e,responseSchema:t,initialResponseContainer:o}){return (await this.loadEventStreamCapability()).deserializeEventStream({response:e,responseSchema:t,initialResponseContainer:o})}async loadEventStreamCapability(){let{EventStreamSerde:e,eventStreamSerdeProvider:t}=await import('./event-streams-JBMWCI2O.cjs'),o=this.resolveEventStreamMarshaller(t);return new e({marshaller:o,serializer:this.serializer,deserializer:this.deserializer,serdeContext:this.serdeContext,defaultContentType:this.getDefaultContentType()})}resolveEventStreamMarshaller(e){let t=this.serdeContext;return t.eventStreamMarshaller?t.eventStreamMarshaller:e(this.serdeContext)}getDefaultContentType(){throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`)}async deserializeHttpMessage(e,t,o,s,n){return []}getEventStreamMarshaller(){let e=this.serdeContext;if(!e.eventStreamMarshaller)throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");return e.eventStreamMarshaller}};var Fe=class extends L{async serializeRequest(e,t,o){let s=t&&typeof t=="object"?t:{},n=this.serializer,a={},f={},m=await o.endpoint(),h=y.of(e?.input),u=[],p=[],S=false,E,d=new b({protocol:"",hostname:"",port:void 0,path:"",fragment:void 0,query:a,headers:f,body:void 0});if(m){this.updateServiceEndpoint(d,m),this.setHostPrefix(d,e,s);let l=_(e.traits);if(l.http){d.method=l.http[0];let[g,x]=l.http[1].split("?");d.path=="/"?d.path=g:d.path+=g;let T=new URLSearchParams(x??"");for(let[N,Q]of T)a[N]=Q;}}for(let[l,g]of h.structIterator()){let x=g.getMergedTraits()??{},T=s[l];if(T==null&&!g.isIdempotencyToken()){if(x.httpLabel&&(d.path.includes(`{${l}+}`)||d.path.includes(`{${l}}`)))throw new Error(`No value provided for input HTTP label: ${l}.`);continue}if(x.httpPayload)g.isStreaming()?g.isStructSchema()?s[l]&&(E=await this.serializeEventStream({eventStream:s[l],requestSchema:h})):E=T:(n.write(g,T),E=n.flush());else if(x.httpLabel){n.write(g,T);let N=n.flush();d.path.includes(`{${l}+}`)?d.path=d.path.replace(`{${l}+}`,N.split("/").map(de).join("/")):d.path.includes(`{${l}}`)&&(d.path=d.path.replace(`{${l}}`,de(N)));}else if(x.httpHeader)n.write(g,T),f[x.httpHeader.toLowerCase()]=String(n.flush());else if(typeof x.httpPrefixHeaders=="string")for(let N in T){let Q=T[N],Le=x.httpPrefixHeaders+N;n.write([g.getValueSchema(),{httpHeader:Le}],Q),f[Le.toLowerCase()]=n.flush();}else x.httpQuery||x.httpQueryParams?this.serializeQuery(g,T,a):(S=true,u.push(l),p.push(g));}if(S&&s){let[l,g]=(h.getName(true)??"#Unknown").split("#"),x=h.getSchema()[6],T=[3,l,g,h.getMergedTraits(),u,p,void 0];x?T[6]=x:T.pop(),n.write(T,s),E=n.flush();}return d.headers=f,d.query=a,d.body=E,d}serializeQuery(e,t,o){let s=this.serializer,n=e.getMergedTraits();if(n.httpQueryParams){for(let a in t)if(!(a in o)){let f=t[a],m=e.getValueSchema();Object.assign(m.getMergedTraits(),{...n,httpQuery:a,httpQueryParams:void 0}),this.serializeQuery(m,f,o);}return}if(e.isListSchema()){let a=!!e.getMergedTraits().sparse,f=[];for(let m of t){s.write([e.getValueSchema(),n],m);let h=s.flush();(a||h!==void 0)&&f.push(h);}o[n.httpQuery]=f;}else s.write([e,n],t),o[n.httpQuery]=s.flush();}async deserializeResponse(e,t,o){let s=this.deserializer,n=y.of(e.output),a={};if(o.statusCode>=300){let m=await A(o.body,t);throw m.byteLength>0&&Object.assign(a,await s.read(15,m)),await this.handleError(e,t,o,a,this.deserializeMetadata(o)),new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.")}for(let m in o.headers){let h=o.headers[m];delete o.headers[m],o.headers[m.toLowerCase()]=h;}let f=await this.deserializeHttpMessage(n,t,o,a);if(f.length){let m=await A(o.body,t);if(m.byteLength>0){let h=await s.read(n,m);for(let u of f)h[u]!=null&&(a[u]=h[u]);}}else f.discardResponseBody&&await A(o.body,t);return a.$metadata=this.deserializeMetadata(o),a}async deserializeHttpMessage(e,t,o,s,n){let a;s instanceof Set?a=n:a=s;let f=true,m=this.deserializer,h=y.of(e),u=[];for(let[p,S]of h.structIterator()){let E=S.getMemberTraits();if(E.httpPayload){if(f=false,S.isStreaming())S.isStructSchema()?a[p]=await this.deserializeEventStream({response:o,responseSchema:h}):a[p]=chunkLQ3YZTPU_cjs.A(o.body);else if(o.body){let l=await A(o.body,t);l.byteLength>0&&(a[p]=await m.read(S,l));}}else if(E.httpHeader){let d=String(E.httpHeader).toLowerCase(),l=o.headers[d];if(l!=null)if(S.isListSchema()){let g=S.getValueSchema();g.getMergedTraits().httpHeader=d;let x;g.isTimestampSchema()&&g.getSchema()===4?x=chunkLQ3YZTPU_cjs.p(l,",",2):x=chunkLQ3YZTPU_cjs.q(l);let T=[];for(let N of x)T.push(await m.read(g,N.trim()));a[p]=T;}else a[p]=await m.read(S,l);}else if(E.httpPrefixHeaders!==void 0){a[p]={};for(let d in o.headers)if(d.startsWith(E.httpPrefixHeaders)){let l=o.headers[d],g=S.getValueSchema();g.getMergedTraits().httpHeader=d,a[p][d.slice(E.httpPrefixHeaders.length)]=await m.read(g,l);}}else E.httpResponseCode?a[p]=o.statusCode:u.push(p);}return u.discardResponseBody=f,u}};chunkBUNLC3II_cjs.h();var Pe=class extends L{async serializeRequest(e,t,o){let s=this.serializer,n={},a={},f=await o.endpoint(),m=y.of(e?.input),h=m.getSchema(),u,p=t&&typeof t=="object"?t:{},S=new b({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:n,headers:a,body:void 0});if(f&&(this.updateServiceEndpoint(S,f),this.setHostPrefix(S,e,p)),p){let E=m.getEventStreamMember();if(E){if(p[E]){let d={};for(let[l,g]of m.structIterator())l!==E&&p[l]&&(s.write(g,p[l]),d[l]=s.flush());u=await this.serializeEventStream({eventStream:p[E],requestSchema:m,initialRequest:d});}}else s.write(h,p),u=s.flush();}return S.headers=Object.assign(S.headers,a),S.query=n,S.body=u,S.method="POST",S}async deserializeResponse(e,t,o){let s=this.deserializer,n=y.of(e.output),a={};if(o.statusCode>=300){let m=await A(o.body,t);throw m.byteLength>0&&Object.assign(a,await s.read(15,m)),await this.handleError(e,t,o,a,this.deserializeMetadata(o)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(let m in o.headers){let h=o.headers[m];delete o.headers[m],o.headers[m.toLowerCase()]=h;}let f=n.getEventStreamMember();if(f)a[f]=await this.deserializeEventStream({response:o,responseSchema:n,initialResponseContainer:a});else {let m=await A(o.body,t);m.byteLength>0&&Object.assign(a,await s.read(n,m));}return a.$metadata=this.deserializeMetadata(o),a}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function W(r,e){if(e.timestampFormat.useTrait&&r.isTimestampSchema()&&(r.getSchema()===5||r.getSchema()===6||r.getSchema()===7))return r.getSchema();let{httpLabel:t,httpPrefixHeaders:o,httpHeader:s,httpQuery:n}=r.getMergedTraits();return (e.httpBindings?typeof o=="string"||s?6:n||t?5:void 0:void 0)??e.timestampFormat.default}var K=class extends w{settings;constructor(e){super(),this.settings=e;}read(e,t){let o=y.of(e);if(o.isListSchema())return chunkLQ3YZTPU_cjs.q(t).map(s=>this.read(o.getValueSchema(),s));if(o.isBlobSchema())return (this.serdeContext?.base64Decoder??chunkLQ3YZTPU_cjs.b)(t);if(o.isTimestampSchema())switch(W(o,this.settings)){case 5:return chunkLQ3YZTPU_cjs.n(t);case 6:return chunkLQ3YZTPU_cjs.o(t);case 7:return chunkLQ3YZTPU_cjs.m(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(o.isStringSchema()){let s=o.getMergedTraits().mediaType,n=t;if(s)return o.getMergedTraits().httpHeader&&(n=this.base64ToUtf8(n)),(s==="application/json"||s.endsWith("+json"))&&(n=chunkLQ3YZTPU_cjs.k.from(n)),n}return o.isNumericSchema()?Number(t):o.isBigIntegerSchema()?BigInt(t):o.isBigDecimalSchema()?new chunkLQ3YZTPU_cjs.r(t,"bigDecimal"):o.isBooleanSchema()?String(t).toLowerCase()==="true":t}base64ToUtf8(e){return (this.serdeContext?.utf8Encoder??chunkLQ3YZTPU_cjs.e)((this.serdeContext?.base64Decoder??chunkLQ3YZTPU_cjs.b)(e))}};chunkBUNLC3II_cjs.h();var Re=class extends w{codecDeserializer;stringDeserializer;constructor(e,t){super(),this.codecDeserializer=e,this.stringDeserializer=new K(t);}setSerdeContext(e){this.stringDeserializer.setSerdeContext(e),this.codecDeserializer.setSerdeContext(e),this.serdeContext=e;}read(e,t){let o=y.of(e),s=o.getMergedTraits(),n=this.serdeContext?.utf8Encoder??chunkLQ3YZTPU_cjs.e;if(s.httpHeader||s.httpResponseCode)return this.stringDeserializer.read(o,n(t));if(s.httpPayload){if(o.isBlobSchema()){let a=this.serdeContext?.utf8Decoder??chunkLQ3YZTPU_cjs.c;return typeof t=="string"?a(t):t}else if(o.isStringSchema())return "byteLength"in t?n(t):t}return this.codecDeserializer.read(o,t)}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var ue=class extends w{settings;stringBuffer="";constructor(e){super(),this.settings=e;}write(e,t){let o=y.of(e);switch(typeof t){case "object":if(t===null){this.stringBuffer="null";return}if(o.isTimestampSchema()){if(!(t instanceof Date))throw new Error(`@smithy/core/protocols - received non-Date value ${t} when schema expected Date in ${o.getName(true)}`);switch(W(o,this.settings)){case 5:this.stringBuffer=t.toISOString().replace(".000Z","Z");break;case 6:this.stringBuffer=chunkLQ3YZTPU_cjs.f(t);break;case 7:this.stringBuffer=String(t.getTime()/1e3);break;default:console.warn("Missing timestamp format, using epoch seconds",t),this.stringBuffer=String(t.getTime()/1e3);}return}if(o.isBlobSchema()&&"byteLength"in t){this.stringBuffer=(this.serdeContext?.base64Encoder??chunkLQ3YZTPU_cjs.d)(t);return}if(o.isListSchema()&&Array.isArray(t)){let a="";for(let f of t){this.write([o.getValueSchema(),o.getMergedTraits()],f);let m=this.flush(),h=o.getValueSchema().isTimestampSchema()?m:chunkLQ3YZTPU_cjs.l(m);a!==""&&(a+=", "),a+=h;}this.stringBuffer=a;return}this.stringBuffer=JSON.stringify(t,null,2);break;case "string":let s=o.getMergedTraits().mediaType,n=t;if(s&&((s==="application/json"||s.endsWith("+json"))&&(n=chunkLQ3YZTPU_cjs.k.from(n)),o.getMergedTraits().httpHeader)){this.stringBuffer=(this.serdeContext?.base64Encoder??chunkLQ3YZTPU_cjs.d)(n.toString());return}this.stringBuffer=t;break;default:o.isIdempotencyToken()?this.stringBuffer=chunkLQ3YZTPU_cjs.D():this.stringBuffer=String(t);}}flush(){let e=this.stringBuffer;return this.stringBuffer="",e}};var Me=class{codecSerializer;stringSerializer;buffer;constructor(e,t,o=new ue(t)){this.codecSerializer=e,this.stringSerializer=o;}setSerdeContext(e){this.codecSerializer.setSerdeContext(e),this.stringSerializer.setSerdeContext(e);}write(e,t){let o=y.of(e),s=o.getMergedTraits();if(s.httpHeader||s.httpLabel||s.httpQuery){this.stringSerializer.write(o,t),this.buffer=this.stringSerializer.flush();return}return this.codecSerializer.write(o,t)}flush(){if(this.buffer!==void 0){let e=this.buffer;return this.buffer=void 0,e}return this.codecSerializer.flush()}};chunkBUNLC3II_cjs.h();var gr=r=>({setHttpHandler(e){r.httpHandler=e;},httpHandler(){return r.httpHandler},updateHttpClientConfig(e,t){r.httpHandler?.updateHttpClientConfig(e,t);},httpHandlerConfigs(){return r.httpHandler.httpHandlerConfigs()}}),Sr=r=>({httpHandler:r.httpHandler()});chunkBUNLC3II_cjs.h();var q=r=>encodeURIComponent(r).replace(/[!'()*]/g,Er),Er=r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`;chunkBUNLC3II_cjs.h();function yr(r){let e=[];for(let t of Object.keys(r).sort()){let o=r[t];if(t=q(t),Array.isArray(o))for(let s=0,n=o.length;s<n;s++)e.push(`${t}=${q(o[s])}`);else {let s=t;(o||typeof o=="string")&&(s+=`=${q(o)}`),e.push(s);}}return e.join("&")}
3
+ exports.A=Jt;exports.B=rr;exports.C=he;exports.D=ir;exports.E=nr;exports.F=ve;exports.G=mr;exports.H=sr;exports.I=lr;exports.J=A;exports.K=de;exports.L=Fe;exports.M=Pe;exports.N=W;exports.O=K;exports.P=Re;exports.Q=Me;exports.R=gr;exports.S=Sr;exports.T=ur;exports.U=q;exports.V=yr;exports.c=te;exports.d=z;exports.e=b;exports.f=D;exports.g=re;exports.h=Mt;exports.i=R;exports.j=xe;exports.k=U;exports.l=Ht;exports.m=y;exports.n=H;exports.o=O;exports.p=F;exports.q=Ie;exports.r=Oe;exports.s=P;exports.u=Ze;exports.v=Ne;exports.w=we;exports.x=tr;exports.y=M;exports.z=Xt;
@@ -0,0 +1 @@
1
+ 'use strict';var chunkBCEE4NBZ_cjs=require('./chunk-BCEE4NBZ.cjs'),chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();var m=class{static[chunkVRZC4TTF_cjs.a]="Cache"},S=class extends m{strategy(){return "all"}static[chunkVRZC4TTF_cjs.a]="NoopCache";async get(e){}async put(e,a,i,t){}async onMutate(e){}};async function N(s,e){let a=`${s}-${JSON.stringify(e)}`,t=new TextEncoder().encode(a),n=await crypto.subtle.digest("SHA-256",t);return [...new Uint8Array(n)].map(_=>_.toString(16).padStart(2,"0")).join("")}chunkBUNLC3II_cjs.h();var x=class s{static[chunkVRZC4TTF_cjs.a]="SelectionProxyHandler";config;constructor(e){this.config={...e};}get(e,a){if(a==="_")return {...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(a===chunkVRZC4TTF_cjs.l)return {...e[chunkVRZC4TTF_cjs.l],selectedFields:new Proxy(e[chunkVRZC4TTF_cjs.l].selectedFields,this)};if(typeof a=="symbol")return e[a];let t=(chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.i)?e._.selectedFields:chunkVRZC4TTF_cjs.c(e,chunkVRZC4TTF_cjs.N)?e[chunkVRZC4TTF_cjs.l].selectedFields:e)[a];if(chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.A.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!t.isSelectionField)return t.sql;let n=t.clone();return n.isSelectionField=true,n}if(chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.A)){if(this.config.sqlBehavior==="sql")return t;throw new Error(`You tried to reference "${a}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return chunkVRZC4TTF_cjs.c(t,chunkVRZC4TTF_cjs.d)?this.config.alias?new Proxy(t,new chunkBCEE4NBZ_cjs.a(new Proxy(t.table,new chunkBCEE4NBZ_cjs.b(this.config.alias,this.config.replaceOriginalName??false)))):t:typeof t!="object"||t===null?t:new Proxy(t,new s(this.config))}};chunkBUNLC3II_cjs.h();function $(s){return (s.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(a=>a.toLowerCase()).join("_")}function F(s){return (s.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((a,i,t)=>{let n=t===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return a+n},"")}function T(s){return s}var C=class{static[chunkVRZC4TTF_cjs.a]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?$:e==="camelCase"?F:T;}getColumnCasing(e){if(!e.keyAsName)return e.name;let a=e.table[chunkVRZC4TTF_cjs.t.Symbol.Schema]??"public",i=e.table[chunkVRZC4TTF_cjs.t.Symbol.OriginalName],t=`${a}.${i}.${e.name}`;return this.cache[t]||this.cacheTable(e.table),this.cache[t]}cacheTable(e){let a=e[chunkVRZC4TTF_cjs.t.Symbol.Schema]??"public",i=e[chunkVRZC4TTF_cjs.t.Symbol.OriginalName],t=`${a}.${i}`;if(!this.cachedTables[t]){for(let n of Object.values(e[chunkVRZC4TTF_cjs.t.Symbol.Columns])){let u=`${t}.${n.name}`;this.cache[u]=this.convert(n.name);}this.cachedTables[t]=true;}}clearCache(){this.cache={},this.cachedTables={};}};chunkBUNLC3II_cjs.h();var A=class{static[chunkVRZC4TTF_cjs.a]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}};exports.a=x;exports.b=C;exports.c=A;exports.d=S;exports.e=N;