watchbell 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (682) hide show
  1. package/package.json +1 -1
  2. package/server/.next/BUILD_ID +1 -1
  3. package/server/.next/build-manifest.json +3 -3
  4. package/server/.next/prerender-manifest.json +3 -3
  5. package/server/.next/server/app/(console)/(private)/ai/agents/page/server-reference-manifest.json +22 -12
  6. package/server/.next/server/app/(console)/(private)/ai/agents/page.js +63 -67
  7. package/server/.next/server/app/(console)/(private)/ai/agents/page.js.nft.json +1 -1
  8. package/server/.next/server/app/(console)/(private)/ai/agents/page_client-reference-manifest.js +1 -1
  9. package/server/.next/server/app/(console)/(private)/ai/ask/page/server-reference-manifest.json +21 -11
  10. package/server/.next/server/app/(console)/(private)/ai/ask/page.js +63 -67
  11. package/server/.next/server/app/(console)/(private)/ai/ask/page.js.nft.json +1 -1
  12. package/server/.next/server/app/(console)/(private)/ai/ask/page_client-reference-manifest.js +1 -1
  13. package/server/.next/server/app/(console)/(private)/ai/connect/page/server-reference-manifest.json +20 -10
  14. package/server/.next/server/app/(console)/(private)/ai/connect/page.js +63 -67
  15. package/server/.next/server/app/(console)/(private)/ai/connect/page.js.nft.json +1 -1
  16. package/server/.next/server/app/(console)/(private)/ai/connect/page_client-reference-manifest.js +1 -1
  17. package/server/.next/server/app/(console)/(private)/ai/keys/page/server-reference-manifest.json +23 -13
  18. package/server/.next/server/app/(console)/(private)/ai/keys/page.js +63 -67
  19. package/server/.next/server/app/(console)/(private)/ai/keys/page.js.nft.json +1 -1
  20. package/server/.next/server/app/(console)/(private)/ai/keys/page_client-reference-manifest.js +1 -1
  21. package/server/.next/server/app/(console)/(private)/ai/logs/page/server-reference-manifest.json +21 -11
  22. package/server/.next/server/app/(console)/(private)/ai/logs/page.js +63 -67
  23. package/server/.next/server/app/(console)/(private)/ai/logs/page.js.nft.json +1 -1
  24. package/server/.next/server/app/(console)/(private)/ai/logs/page_client-reference-manifest.js +1 -1
  25. package/server/.next/server/app/(console)/(private)/ai/models/page/server-reference-manifest.json +30 -20
  26. package/server/.next/server/app/(console)/(private)/ai/models/page.js +63 -67
  27. package/server/.next/server/app/(console)/(private)/ai/models/page.js.nft.json +1 -1
  28. package/server/.next/server/app/(console)/(private)/ai/models/page_client-reference-manifest.js +1 -1
  29. package/server/.next/server/app/(console)/(private)/ai/page/server-reference-manifest.json +20 -10
  30. package/server/.next/server/app/(console)/(private)/ai/page.js +63 -67
  31. package/server/.next/server/app/(console)/(private)/ai/page.js.nft.json +1 -1
  32. package/server/.next/server/app/(console)/(private)/ai/page_client-reference-manifest.js +1 -1
  33. package/server/.next/server/app/(console)/(private)/ai/playground/page/server-reference-manifest.json +23 -13
  34. package/server/.next/server/app/(console)/(private)/ai/playground/page.js +63 -67
  35. package/server/.next/server/app/(console)/(private)/ai/playground/page.js.nft.json +1 -1
  36. package/server/.next/server/app/(console)/(private)/ai/playground/page_client-reference-manifest.js +1 -1
  37. package/server/.next/server/app/(console)/(private)/ai/providers/page/server-reference-manifest.json +26 -16
  38. package/server/.next/server/app/(console)/(private)/ai/providers/page.js +63 -67
  39. package/server/.next/server/app/(console)/(private)/ai/providers/page.js.nft.json +1 -1
  40. package/server/.next/server/app/(console)/(private)/ai/providers/page_client-reference-manifest.js +1 -1
  41. package/server/.next/server/app/(console)/(private)/ai/quota/page/server-reference-manifest.json +21 -11
  42. package/server/.next/server/app/(console)/(private)/ai/quota/page.js +63 -67
  43. package/server/.next/server/app/(console)/(private)/ai/quota/page.js.nft.json +1 -1
  44. package/server/.next/server/app/(console)/(private)/ai/quota/page_client-reference-manifest.js +1 -1
  45. package/server/.next/server/app/(console)/(private)/ai/usage/page/server-reference-manifest.json +21 -11
  46. package/server/.next/server/app/(console)/(private)/ai/usage/page.js +63 -67
  47. package/server/.next/server/app/(console)/(private)/ai/usage/page.js.nft.json +1 -1
  48. package/server/.next/server/app/(console)/(private)/ai/usage/page_client-reference-manifest.js +1 -1
  49. package/server/.next/server/app/(console)/(private)/api-docs/[[...op]]/page/server-reference-manifest.json +20 -10
  50. package/server/.next/server/app/(console)/(private)/api-docs/[[...op]]/page.js +63 -67
  51. package/server/.next/server/app/(console)/(private)/api-docs/[[...op]]/page.js.nft.json +1 -1
  52. package/server/.next/server/app/(console)/(private)/api-docs/[[...op]]/page_client-reference-manifest.js +1 -1
  53. package/server/.next/server/app/(console)/(private)/auto-actions/page/server-reference-manifest.json +21 -11
  54. package/server/.next/server/app/(console)/(private)/auto-actions/page.js +63 -67
  55. package/server/.next/server/app/(console)/(private)/auto-actions/page.js.nft.json +1 -1
  56. package/server/.next/server/app/(console)/(private)/auto-actions/page_client-reference-manifest.js +1 -1
  57. package/server/.next/server/app/(console)/alerts/page/server-reference-manifest.json +36 -26
  58. package/server/.next/server/app/(console)/alerts/page.js +63 -67
  59. package/server/.next/server/app/(console)/alerts/page.js.nft.json +1 -1
  60. package/server/.next/server/app/(console)/alerts/page_client-reference-manifest.js +1 -1
  61. package/server/.next/server/app/(console)/apps/[id]/page/server-reference-manifest.json +94 -54
  62. package/server/.next/server/app/(console)/apps/[id]/page.js +69 -71
  63. package/server/.next/server/app/(console)/apps/[id]/page.js.nft.json +1 -1
  64. package/server/.next/server/app/(console)/apps/[id]/page_client-reference-manifest.js +1 -1
  65. package/server/.next/server/app/(console)/apps/page/server-reference-manifest.json +23 -13
  66. package/server/.next/server/app/(console)/apps/page.js +66 -69
  67. package/server/.next/server/app/(console)/apps/page.js.nft.json +1 -1
  68. package/server/.next/server/app/(console)/apps/page_client-reference-manifest.js +1 -1
  69. package/server/.next/server/app/(console)/backups/page/server-reference-manifest.json +23 -13
  70. package/server/.next/server/app/(console)/backups/page.js +63 -67
  71. package/server/.next/server/app/(console)/backups/page.js.nft.json +1 -1
  72. package/server/.next/server/app/(console)/backups/page_client-reference-manifest.js +1 -1
  73. package/server/.next/server/app/(console)/catalog/page/server-reference-manifest.json +20 -10
  74. package/server/.next/server/app/(console)/catalog/page.js +63 -67
  75. package/server/.next/server/app/(console)/catalog/page.js.nft.json +1 -1
  76. package/server/.next/server/app/(console)/catalog/page_client-reference-manifest.js +1 -1
  77. package/server/.next/server/app/(console)/connections/page/server-reference-manifest.json +31 -21
  78. package/server/.next/server/app/(console)/connections/page.js +63 -67
  79. package/server/.next/server/app/(console)/connections/page.js.nft.json +1 -1
  80. package/server/.next/server/app/(console)/connections/page_client-reference-manifest.js +1 -1
  81. package/server/.next/server/app/(console)/d1/page/server-reference-manifest.json +20 -10
  82. package/server/.next/server/app/(console)/d1/page.js +63 -67
  83. package/server/.next/server/app/(console)/d1/page.js.nft.json +1 -1
  84. package/server/.next/server/app/(console)/d1/page_client-reference-manifest.js +1 -1
  85. package/server/.next/server/app/(console)/deployments/page/server-reference-manifest.json +46 -16
  86. package/server/.next/server/app/(console)/deployments/page.js +66 -69
  87. package/server/.next/server/app/(console)/deployments/page.js.nft.json +1 -1
  88. package/server/.next/server/app/(console)/deployments/page_client-reference-manifest.js +1 -1
  89. package/server/.next/server/app/(console)/dns/page/server-reference-manifest.json +27 -17
  90. package/server/.next/server/app/(console)/dns/page.js +63 -67
  91. package/server/.next/server/app/(console)/dns/page.js.nft.json +1 -1
  92. package/server/.next/server/app/(console)/dns/page_client-reference-manifest.js +1 -1
  93. package/server/.next/server/app/(console)/domains/page/server-reference-manifest.json +22 -12
  94. package/server/.next/server/app/(console)/domains/page.js +63 -67
  95. package/server/.next/server/app/(console)/domains/page.js.nft.json +1 -1
  96. package/server/.next/server/app/(console)/domains/page_client-reference-manifest.js +1 -1
  97. package/server/.next/server/app/(console)/events/page/server-reference-manifest.json +20 -10
  98. package/server/.next/server/app/(console)/events/page.js +63 -67
  99. package/server/.next/server/app/(console)/events/page.js.nft.json +1 -1
  100. package/server/.next/server/app/(console)/events/page_client-reference-manifest.js +1 -1
  101. package/server/.next/server/app/(console)/firebase/page/server-reference-manifest.json +27 -17
  102. package/server/.next/server/app/(console)/firebase/page.js +63 -67
  103. package/server/.next/server/app/(console)/firebase/page.js.nft.json +1 -1
  104. package/server/.next/server/app/(console)/firebase/page_client-reference-manifest.js +1 -1
  105. package/server/.next/server/app/(console)/logs/page/server-reference-manifest.json +21 -11
  106. package/server/.next/server/app/(console)/logs/page.js +63 -67
  107. package/server/.next/server/app/(console)/logs/page.js.nft.json +1 -1
  108. package/server/.next/server/app/(console)/logs/page_client-reference-manifest.js +1 -1
  109. package/server/.next/server/app/(console)/manage/sections/page/server-reference-manifest.json +21 -11
  110. package/server/.next/server/app/(console)/manage/sections/page.js +63 -67
  111. package/server/.next/server/app/(console)/manage/sections/page.js.nft.json +1 -1
  112. package/server/.next/server/app/(console)/manage/sections/page_client-reference-manifest.js +1 -1
  113. package/server/.next/server/app/(console)/neon/page/server-reference-manifest.json +31 -21
  114. package/server/.next/server/app/(console)/neon/page.js +63 -67
  115. package/server/.next/server/app/(console)/neon/page.js.nft.json +1 -1
  116. package/server/.next/server/app/(console)/neon/page_client-reference-manifest.js +1 -1
  117. package/server/.next/server/app/(console)/overview/page/server-reference-manifest.json +28 -18
  118. package/server/.next/server/app/(console)/overview/page.js +69 -72
  119. package/server/.next/server/app/(console)/overview/page.js.nft.json +1 -1
  120. package/server/.next/server/app/(console)/overview/page_client-reference-manifest.js +1 -1
  121. package/server/.next/server/app/(console)/repos/[id]/page/server-reference-manifest.json +21 -11
  122. package/server/.next/server/app/(console)/repos/[id]/page.js +67 -70
  123. package/server/.next/server/app/(console)/repos/[id]/page.js.nft.json +1 -1
  124. package/server/.next/server/app/(console)/repos/[id]/page_client-reference-manifest.js +1 -1
  125. package/server/.next/server/app/(console)/repos/page/server-reference-manifest.json +20 -10
  126. package/server/.next/server/app/(console)/repos/page.js +65 -68
  127. package/server/.next/server/app/(console)/repos/page.js.nft.json +1 -1
  128. package/server/.next/server/app/(console)/repos/page_client-reference-manifest.js +1 -1
  129. package/server/.next/server/app/(console)/settings/page/server-reference-manifest.json +30 -20
  130. package/server/.next/server/app/(console)/settings/page.js +63 -67
  131. package/server/.next/server/app/(console)/settings/page.js.nft.json +1 -1
  132. package/server/.next/server/app/(console)/settings/page_client-reference-manifest.js +1 -1
  133. package/server/.next/server/app/(console)/sql/page/server-reference-manifest.json +27 -17
  134. package/server/.next/server/app/(console)/sql/page.js +63 -67
  135. package/server/.next/server/app/(console)/sql/page.js.nft.json +1 -1
  136. package/server/.next/server/app/(console)/sql/page_client-reference-manifest.js +1 -1
  137. package/server/.next/server/app/(console)/status/page/server-reference-manifest.json +20 -10
  138. package/server/.next/server/app/(console)/status/page.js +63 -67
  139. package/server/.next/server/app/(console)/status/page.js.nft.json +1 -1
  140. package/server/.next/server/app/(console)/status/page_client-reference-manifest.js +1 -1
  141. package/server/.next/server/app/(console)/supabase/page/server-reference-manifest.json +39 -29
  142. package/server/.next/server/app/(console)/supabase/page.js +63 -67
  143. package/server/.next/server/app/(console)/supabase/page.js.nft.json +1 -1
  144. package/server/.next/server/app/(console)/supabase/page_client-reference-manifest.js +1 -1
  145. package/server/.next/server/app/(console)/topology/page/server-reference-manifest.json +20 -10
  146. package/server/.next/server/app/(console)/topology/page.js +63 -67
  147. package/server/.next/server/app/(console)/topology/page.js.nft.json +1 -1
  148. package/server/.next/server/app/(console)/topology/page_client-reference-manifest.js +1 -1
  149. package/server/.next/server/app/(console)/turso/page/server-reference-manifest.json +20 -10
  150. package/server/.next/server/app/(console)/turso/page.js +63 -67
  151. package/server/.next/server/app/(console)/turso/page.js.nft.json +1 -1
  152. package/server/.next/server/app/(console)/turso/page_client-reference-manifest.js +1 -1
  153. package/server/.next/server/app/(console)/upstash/page/server-reference-manifest.json +20 -10
  154. package/server/.next/server/app/(console)/upstash/page.js +63 -67
  155. package/server/.next/server/app/(console)/upstash/page.js.nft.json +1 -1
  156. package/server/.next/server/app/(console)/upstash/page_client-reference-manifest.js +1 -1
  157. package/server/.next/server/app/(console)/uptime/page/server-reference-manifest.json +34 -24
  158. package/server/.next/server/app/(console)/uptime/page.js +63 -67
  159. package/server/.next/server/app/(console)/uptime/page.js.nft.json +1 -1
  160. package/server/.next/server/app/(console)/uptime/page_client-reference-manifest.js +1 -1
  161. package/server/.next/server/app/(console)/welcome/page/server-reference-manifest.json +25 -15
  162. package/server/.next/server/app/(console)/welcome/page.js +63 -67
  163. package/server/.next/server/app/(console)/welcome/page.js.nft.json +1 -1
  164. package/server/.next/server/app/(console)/welcome/page_client-reference-manifest.js +1 -1
  165. package/server/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  166. package/server/.next/server/app/_global-error/page.js.nft.json +1 -1
  167. package/server/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  168. package/server/.next/server/app/_global-error.html +1 -1
  169. package/server/.next/server/app/_global-error.rsc +2 -2
  170. package/server/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  171. package/server/.next/server/app/_global-error.segments/_full.segment.rsc +2 -2
  172. package/server/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  173. package/server/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  174. package/server/.next/server/app/_not-found/page.js.nft.json +1 -1
  175. package/server/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  176. package/server/.next/server/app/_not-found.html +1 -1
  177. package/server/.next/server/app/_not-found.rsc +3 -3
  178. package/server/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  179. package/server/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  180. package/server/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  181. package/server/.next/server/app/account/password/page/server-reference-manifest.json +2 -2
  182. package/server/.next/server/app/account/password/page.js.nft.json +1 -1
  183. package/server/.next/server/app/account/password/page_client-reference-manifest.js +1 -1
  184. package/server/.next/server/app/api/collect/route/server-reference-manifest.json +17 -7
  185. package/server/.next/server/app/api/collect/route.js +69 -71
  186. package/server/.next/server/app/api/collect/route.js.nft.json +1 -1
  187. package/server/.next/server/app/api/daily/route/server-reference-manifest.json +17 -7
  188. package/server/.next/server/app/api/daily/route.js +51 -53
  189. package/server/.next/server/app/api/daily/route.js.nft.json +1 -1
  190. package/server/.next/server/app/api/status/route.js +2 -2
  191. package/server/.next/server/app/api/status/route.js.nft.json +1 -1
  192. package/server/.next/server/app/api/telegram/webhook/route/server-reference-manifest.json +17 -7
  193. package/server/.next/server/app/api/telegram/webhook/route.js +48 -50
  194. package/server/.next/server/app/api/telegram/webhook/route.js.nft.json +1 -1
  195. package/server/.next/server/app/api/v1/advice/route.js +4 -3
  196. package/server/.next/server/app/api/v1/advice/route.js.nft.json +1 -1
  197. package/server/.next/server/app/api/v1/ai/questions/route.js +2 -2
  198. package/server/.next/server/app/api/v1/ai/questions/route.js.nft.json +1 -1
  199. package/server/.next/server/app/api/v1/mcp/route.js +1 -1
  200. package/server/.next/server/app/api/v1/mcp/route.js.nft.json +1 -1
  201. package/server/.next/server/app/api/v1/status/apps/[app]/route.js +4 -3
  202. package/server/.next/server/app/api/v1/status/apps/[app]/route.js.nft.json +1 -1
  203. package/server/.next/server/app/api/v1/status/route.js +4 -3
  204. package/server/.next/server/app/api/v1/status/route.js.nft.json +1 -1
  205. package/server/.next/server/app/api/watchdog/route.js +15 -15
  206. package/server/.next/server/app/api/watchdog/route.js.nft.json +1 -1
  207. package/server/.next/server/app/invite/page/server-reference-manifest.json +2 -2
  208. package/server/.next/server/app/invite/page.js.nft.json +1 -1
  209. package/server/.next/server/app/invite/page_client-reference-manifest.js +1 -1
  210. package/server/.next/server/app/mfa/page/server-reference-manifest.json +2 -2
  211. package/server/.next/server/app/mfa/page.js +25 -25
  212. package/server/.next/server/app/mfa/page.js.nft.json +1 -1
  213. package/server/.next/server/app/mfa/page_client-reference-manifest.js +1 -1
  214. package/server/.next/server/app/mfa/setup/page/server-reference-manifest.json +3 -3
  215. package/server/.next/server/app/mfa/setup/page.js +25 -25
  216. package/server/.next/server/app/mfa/setup/page.js.nft.json +1 -1
  217. package/server/.next/server/app/mfa/setup/page_client-reference-manifest.js +1 -1
  218. package/server/.next/server/app/page/server-reference-manifest.json +1 -1
  219. package/server/.next/server/app/page.js.nft.json +1 -1
  220. package/server/.next/server/app/page_client-reference-manifest.js +1 -1
  221. package/server/.next/server/app/s/[slug]/page/server-reference-manifest.json +1 -1
  222. package/server/.next/server/app/s/[slug]/page.js +7 -7
  223. package/server/.next/server/app/s/[slug]/page.js.nft.json +1 -1
  224. package/server/.next/server/app/s/[slug]/page_client-reference-manifest.js +1 -1
  225. package/server/.next/server/app/setup/page/server-reference-manifest.json +2 -2
  226. package/server/.next/server/app/setup/page.js.nft.json +1 -1
  227. package/server/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  228. package/server/.next/server/app/signin/page/server-reference-manifest.json +3 -3
  229. package/server/.next/server/app/signin/page.js +28 -29
  230. package/server/.next/server/app/signin/page.js.nft.json +1 -1
  231. package/server/.next/server/app/signin/page_client-reference-manifest.js +1 -1
  232. package/server/.next/server/chunks/{[externals]__0ia-wyj5qrosx._.js → [externals]__1-y7b_mfadqi-._.js} +1 -1
  233. package/server/.next/server/chunks/{[externals]__0igl_rsv6z3fr._.js → [externals]__1b3dgyi9diwhy._.js} +1 -1
  234. package/server/.next/server/chunks/{[externals]__0mh8e6gkgfswq._.js → [externals]__1dd9hhrnxhegy._.js} +1 -1
  235. package/server/.next/server/chunks/{[root-of-the-server]__01vos42kjq9nn._.js → [root-of-the-server]__0-94urkhm871c._.js} +1 -1
  236. package/server/.next/server/chunks/{[root-of-the-server]__0_e2eoq7w3ff_._.js → [root-of-the-server]__0-zrmrb4499ay._.js} +2 -2
  237. package/server/.next/server/chunks/{[root-of-the-server]__0ezd1s2862iob._.js → [root-of-the-server]__01hgqxx2a0okv._.js} +2 -2
  238. package/server/.next/server/chunks/{[root-of-the-server]__0exicuoq6gmph._.js → [root-of-the-server]__02h-ec_gusm_2._.js} +2 -2
  239. package/server/.next/server/chunks/{[root-of-the-server]__0-ftc1hhcjcl2._.js → [root-of-the-server]__038br8sr9eepd._.js} +2 -2
  240. package/server/.next/server/chunks/{[root-of-the-server]__20ng0hgzxagf_._.js → [root-of-the-server]__040a3il587nja._.js} +2 -2
  241. package/server/.next/server/chunks/{[root-of-the-server]__0cc32xnniktg9._.js → [root-of-the-server]__04iumkvxok49x._.js} +2 -2
  242. package/server/.next/server/chunks/[root-of-the-server]__0a5op--7u5_xh._.js +3 -0
  243. package/server/.next/server/chunks/{[root-of-the-server]__040ix5fqb_zb-._.js → [root-of-the-server]__0a5t6bkr3-uqw._.js} +2 -2
  244. package/server/.next/server/chunks/{[root-of-the-server]__0r88w3qhrtzz_._.js → [root-of-the-server]__0c2heh-0pjyob._.js} +1 -1
  245. package/server/.next/server/chunks/{[root-of-the-server]__1gt_-h9n48pwi._.js → [root-of-the-server]__0c9y_zg74k4oe._.js} +2 -2
  246. package/server/.next/server/chunks/{[root-of-the-server]__0185dne3slx7e._.js → [root-of-the-server]__0cmp5mwchd8sn._.js} +2 -2
  247. package/server/.next/server/chunks/{[root-of-the-server]__0oqltt9cni6m0._.js → [root-of-the-server]__0ct18spdi1leu._.js} +2 -2
  248. package/server/.next/server/chunks/{[root-of-the-server]__0rb1-3538-pq9._.js → [root-of-the-server]__0db2p-om-b_4s._.js} +1 -1
  249. package/server/.next/server/chunks/{[root-of-the-server]__09uh8gefrxmkg._.js → [root-of-the-server]__0fc4c9-xzmkol._.js} +2 -2
  250. package/server/.next/server/chunks/{[root-of-the-server]__0ikiyg3u02ofv._.js → [root-of-the-server]__0fmt9z8-xukob._.js} +1 -1
  251. package/server/.next/server/chunks/{[root-of-the-server]__0sabwm3w1rm0q._.js → [root-of-the-server]__0i3h5covkd6_t._.js} +1 -1
  252. package/server/.next/server/chunks/[root-of-the-server]__0inf2zuuqjrq6._.js +3 -0
  253. package/server/.next/server/chunks/{[root-of-the-server]__0070gc9ml0mf7._.js → [root-of-the-server]__0jswmvddgl3sb._.js} +1 -1
  254. package/server/.next/server/chunks/{[root-of-the-server]__0ms1uw85c5wg2._.js → [root-of-the-server]__0lco43i5w25zg._.js} +2 -2
  255. package/server/.next/server/chunks/{[root-of-the-server]__0x6qqr79pq_j9._.js → [root-of-the-server]__0m_nqt44ioex_._.js} +1 -1
  256. package/server/.next/server/chunks/{[root-of-the-server]__0w_og0zl6hqzj._.js → [root-of-the-server]__0qme276hvajvy._.js} +1 -1
  257. package/server/.next/server/chunks/[root-of-the-server]__0r3cq1lecww4e._.js +3 -0
  258. package/server/.next/server/chunks/[root-of-the-server]__0r_6xpjwcdrda._.js +3 -0
  259. package/server/.next/server/chunks/[root-of-the-server]__0rctmpp7p7cp9._.js +3 -0
  260. package/server/.next/server/chunks/[root-of-the-server]__0rpys5i04hzww._.js +3 -0
  261. package/server/.next/server/chunks/{[root-of-the-server]__1ol4c4uzqqqfw._.js → [root-of-the-server]__0sp5xoed3-994._.js} +2 -2
  262. package/server/.next/server/chunks/{[root-of-the-server]__01yzy5zxsekxi._.js → [root-of-the-server]__0ubalx5w0ds9m._.js} +1 -1
  263. package/server/.next/server/chunks/[root-of-the-server]__0vv63vp8y0fs-._.js +3 -0
  264. package/server/.next/server/chunks/{[root-of-the-server]__0-st5xltl53h9._.js → [root-of-the-server]__0w07p3ypro834._.js} +2 -2
  265. package/server/.next/server/chunks/{[root-of-the-server]__0znmcklxfccvk._.js → [root-of-the-server]__0x929r1phz1oi._.js} +2 -2
  266. package/server/.next/server/chunks/{[root-of-the-server]__1vqs8o9bv1wbk._.js → [root-of-the-server]__0xfgfo-ks4_e8._.js} +2 -2
  267. package/server/.next/server/chunks/[root-of-the-server]__0ycpg444s91lb._.js +3 -0
  268. package/server/.next/server/chunks/[root-of-the-server]__0zjhlf_yodox3._.js +3 -0
  269. package/server/.next/server/chunks/{[root-of-the-server]__1cc__h9taeylv._.js → [root-of-the-server]__0zkeao78mms1_._.js} +2 -2
  270. package/server/.next/server/chunks/{[root-of-the-server]__0y_xyc1cyvtej._.js → [root-of-the-server]__0zwr7fll4dm9q._.js} +2 -2
  271. package/server/.next/server/chunks/{[root-of-the-server]__0cz3da2wx3_wd._.js → [root-of-the-server]__1-2ckgdamg0-j._.js} +2 -2
  272. package/server/.next/server/chunks/[root-of-the-server]__1-ne3clcouvm2._.js +3 -0
  273. package/server/.next/server/chunks/{[root-of-the-server]__1bce11artflky._.js → [root-of-the-server]__130_vkgsongq_._.js} +2 -2
  274. package/server/.next/server/chunks/{[root-of-the-server]__0x47i6wm-cd1z._.js → [root-of-the-server]__14jw0y_hj7jmw._.js} +2 -2
  275. package/server/.next/server/chunks/[root-of-the-server]__14vj8ywy5spa2._.js +3 -0
  276. package/server/.next/server/chunks/{[root-of-the-server]__05jzua9637vlo._.js → [root-of-the-server]__15vqo7amys573._.js} +2 -2
  277. package/server/.next/server/chunks/{[root-of-the-server]__08-puk3_gawjd._.js → [root-of-the-server]__161v5qfd5qk2p._.js} +2 -2
  278. package/server/.next/server/chunks/[root-of-the-server]__16jyhasrd2ojp._.js +3 -0
  279. package/server/.next/server/chunks/[root-of-the-server]__16u9d_hm9lefl._.js +3 -0
  280. package/server/.next/server/chunks/{[root-of-the-server]__0kzpzdkpz_nt0._.js → [root-of-the-server]__177l2p7kcj-16._.js} +2 -2
  281. package/server/.next/server/chunks/{[root-of-the-server]__186-sa38csgot._.js → [root-of-the-server]__17dr2z1o1hsvk._.js} +1 -1
  282. package/server/.next/server/chunks/{[root-of-the-server]__1hl9k6e1o7xh2._.js → [root-of-the-server]__1_df6aphi-pfk._.js} +2 -2
  283. package/server/.next/server/chunks/[root-of-the-server]__1_zr2xlmtkn4l._.js +3 -0
  284. package/server/.next/server/chunks/[root-of-the-server]__1aagly59gw-xf._.js +3 -0
  285. package/server/.next/server/chunks/{[root-of-the-server]__0tykhzqhwdx_k._.js → [root-of-the-server]__1bjvjngj7lvqi._.js} +2 -2
  286. package/server/.next/server/chunks/[root-of-the-server]__1c0cb3ur16yhh._.js +3 -0
  287. package/server/.next/server/chunks/{[root-of-the-server]__1g4iy2tasmn0f._.js → [root-of-the-server]__1d1u-wejsfl84._.js} +1 -1
  288. package/server/.next/server/chunks/{[root-of-the-server]__05pabbazg42oy._.js → [root-of-the-server]__1g6xpr_typmce._.js} +2 -2
  289. package/server/.next/server/chunks/{[root-of-the-server]__195ax9c1nsi5b._.js → [root-of-the-server]__1j527a18gh10b._.js} +2 -2
  290. package/server/.next/server/chunks/{[root-of-the-server]__1a7_3nq1jjab-._.js → [root-of-the-server]__1jjusd74y8gd5._.js} +2 -2
  291. package/server/.next/server/chunks/[root-of-the-server]__1jvy8r4n-62x7._.js +3 -0
  292. package/server/.next/server/chunks/[root-of-the-server]__1k-7jan2fsbys._.js +3 -0
  293. package/server/.next/server/chunks/[root-of-the-server]__1kr6f03r82mk6._.js +3 -0
  294. package/server/.next/server/chunks/[root-of-the-server]__1m8gyvj7rkapj._.js +1 -1
  295. package/server/.next/server/chunks/[root-of-the-server]__1pa_syiho939h._.js +3 -0
  296. package/server/.next/server/chunks/[root-of-the-server]__1qmdi981syrsn._.js +3 -0
  297. package/server/.next/server/chunks/[root-of-the-server]__1r9v6qgjwlv32._.js +3 -0
  298. package/server/.next/server/chunks/{[root-of-the-server]__0xqgsjnebebv8._.js → [root-of-the-server]__1smidspfoqz48._.js} +2 -2
  299. package/server/.next/server/chunks/{[root-of-the-server]__20r_62r36t28o._.js → [root-of-the-server]__1t87mhqedigsz._.js} +2 -2
  300. package/server/.next/server/chunks/[root-of-the-server]__1u5my3-gpw499._.js +3 -0
  301. package/server/.next/server/chunks/[root-of-the-server]__1uad-kugxmkx8._.js +3 -0
  302. package/server/.next/server/chunks/{[root-of-the-server]__1ny8nr52qvr4i._.js → [root-of-the-server]__20sp5m_w5iklm._.js} +2 -2
  303. package/server/.next/server/chunks/{_1_9n8x5ncta29._.js → _0-jfehdfklu-i._.js} +2 -2
  304. package/server/.next/server/chunks/{_1n-fm2bdo9t2m._.js → _0-ub844lc_z_a._.js} +3 -3
  305. package/server/.next/server/chunks/_004c7-39glldb._.js +4 -4
  306. package/server/.next/server/chunks/_05hhw0eql5-dv._.js +12 -0
  307. package/server/.next/server/chunks/{_0zj10_al6r59j._.js → _08fv52mqg619m._.js} +12 -10
  308. package/server/.next/server/chunks/{_1cq1vvbp6pglr._.js → _08z7lmk32r__5._.js} +3 -3
  309. package/server/.next/server/chunks/_0b7rdk-4lrvfy._.js +10 -0
  310. package/server/.next/server/chunks/_0n-wbmmvp4omq._.js +1 -1
  311. package/server/.next/server/chunks/_0tz4o-qufnu3l._.js +4 -4
  312. package/server/.next/server/chunks/{_1myv9csc_in08._.js → _1-pv4d4qhe7to._.js} +3 -3
  313. package/server/.next/server/chunks/_10vh_l3hht4_3._.js +4 -4
  314. package/server/.next/server/chunks/{_1e_rbkrukj0x9._.js → _13dlt388gceez._.js} +12 -10
  315. package/server/.next/server/chunks/_19wqm5leaaesp._.js +1 -1
  316. package/server/.next/server/chunks/_1d_77nvqcnkcg._.js +3 -0
  317. package/server/.next/server/chunks/_1e_6lrlg9ml3-._.js +1 -1
  318. package/server/.next/server/chunks/_1fj4vzjpusyn8._.js +5 -0
  319. package/server/.next/server/chunks/_1l-68brbq289m._.js +12 -0
  320. package/server/.next/server/chunks/{_1476vtrt9101m._.js → _1rskctyr7yt-b._.js} +2 -2
  321. package/server/.next/server/chunks/src_0--qn984h6czu._.js +1 -1
  322. package/server/.next/server/chunks/src_05vq-abuilwk4._.js +3 -0
  323. package/server/.next/server/chunks/src_063xvouojxyoa._.js +1 -1
  324. package/server/.next/server/chunks/src_06lwphwuzgl6e._.js +3 -0
  325. package/server/.next/server/chunks/src_0_9n02bmhtk4z._.js +3 -0
  326. package/server/.next/server/chunks/{src_0_l3dzp06o4x5._.js → src_0j8daco-75zka._.js} +2 -2
  327. package/server/.next/server/chunks/src_0tw-h0otr2tgt._.js +1 -1
  328. package/server/.next/server/chunks/src_1a5yibsjcy1ga._.js +1 -1
  329. package/server/.next/server/chunks/{src_0m6xxpw2u-xv_._.js → src_1lvv9wiag2d8-._.js} +2 -2
  330. package/server/.next/server/chunks/src_1u-olt84z63rx._.js +1 -1
  331. package/server/.next/server/chunks/{src_15fupbs9-n8q9._.js → src_20sym_ohuqw76._.js} +2 -2
  332. package/server/.next/server/chunks/src_2108_me3q06ih._.js +3 -0
  333. package/server/.next/server/chunks/src_lib_0eqv8l-v8d5ze._.js +1 -1
  334. package/server/.next/server/chunks/src_lib_0glcfed-uogyd._.js +1 -1
  335. package/server/.next/server/chunks/src_lib_0n-8zjgq6mcc7._.js +3 -0
  336. package/server/.next/server/chunks/src_lib_0pyyxm3m1rttg._.js +9 -0
  337. package/server/.next/server/chunks/src_lib_13irheo9qqhgx._.js +9 -0
  338. package/server/.next/server/chunks/src_lib_1nkahiclbn55q._.js +3 -0
  339. package/server/.next/server/chunks/src_lib_1y5l54dwaet39._.js +3 -0
  340. package/server/.next/server/chunks/src_lib_collector_runners_ts_12z4gtgikss74._.js +5 -5
  341. package/server/.next/server/chunks/src_lib_view_labels_ts_1uxs84z7vclz5._.js +1 -1
  342. package/server/.next/server/chunks/src_private_0uwb-eyaxy9b3._.js +5 -0
  343. package/server/.next/server/chunks/src_private_notes_notes-actions_ts_1g63g8u965fhc._.js +1 -1
  344. package/server/.next/server/chunks/ssr/1oeh_server_app_(console)_(private)_ai_agents_page_actions_21atz5tidps07.js +1 -1
  345. package/server/.next/server/chunks/ssr/1oeh_server_app_(console)_(private)_ai_models_page_actions_0rvlzfa8rjyz_.js +1 -1
  346. package/server/.next/server/chunks/ssr/1oeh_server_app_(console)_(private)_ai_playground_page_actions_01ejc1xilpuh4.js +1 -1
  347. package/server/.next/server/chunks/ssr/1oeh_server_app_(console)_(private)_ai_quota_page_actions_0iki29gyi8cwa.js +1 -1
  348. package/server/.next/server/chunks/ssr/1oeh_server_app_(console)_(private)_ai_usage_page_actions_1c99h-kwdnep7.js +1 -1
  349. package/server/.next/server/chunks/ssr/1oeh_server_app_(console)_(private)_auto-actions_page_actions_1kw4ce6-efkr1.js +1 -1
  350. package/server/.next/server/chunks/ssr/{[externals]__0vlxry7jq5j1j._.js → [externals]__02s9k1gg9qqkm._.js} +1 -1
  351. package/server/.next/server/chunks/ssr/{[externals]__1mol6ksxmtkv6._.js → [externals]__1rj83sktdlxvt._.js} +1 -1
  352. package/server/.next/server/chunks/ssr/{[externals]__0yyslm1ka5px3._.js → [externals]__1s7xw086rvse0._.js} +1 -1
  353. package/server/.next/server/chunks/ssr/{[externals]__0irbihjwcc9is._.js → [externals]__20leqouf6m6f3._.js} +1 -1
  354. package/server/.next/server/chunks/ssr/{[root-of-the-server]__193nmh09rrpbx._.js → [root-of-the-server]__0-zqh1gf4dsj3._.js} +1 -1
  355. package/server/.next/server/chunks/ssr/[root-of-the-server]__001mglelq4wpc._.js +1 -1
  356. package/server/.next/server/chunks/ssr/[root-of-the-server]__03mal5uo1rzg4._.js +3 -0
  357. package/server/.next/server/chunks/ssr/[root-of-the-server]__05_98ql5tgeii._.js +3 -0
  358. package/server/.next/server/chunks/ssr/[root-of-the-server]__077-acap7g4ck._.js +1 -1
  359. package/server/.next/server/chunks/ssr/{[root-of-the-server]__1_h_ya1h8efdj._.js → [root-of-the-server]__07k_84t5-d55n._.js} +2 -2
  360. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0wi2grctadbk8._.js → [root-of-the-server]__080do5vfu69n5._.js} +1 -1
  361. package/server/.next/server/chunks/ssr/[root-of-the-server]__09blzlbsxqvy9._.js +1 -1
  362. package/server/.next/server/chunks/ssr/{[root-of-the-server]__1_z273zso5at1._.js → [root-of-the-server]__09j1po2u91fp3._.js} +2 -2
  363. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0sj92w6mg92ds._.js → [root-of-the-server]__0b3g72j9cu141._.js} +2 -2
  364. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0xjg51t1__v-s._.js → [root-of-the-server]__0e1s_5gg-u3iu._.js} +1 -1
  365. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0-i_tj8wp9oto._.js → [root-of-the-server]__0ed6qo3lg9_f9._.js} +2 -2
  366. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0z_1k5876-_wx._.js → [root-of-the-server]__0ee5ew5q3jh8i._.js} +2 -2
  367. package/server/.next/server/chunks/ssr/{[root-of-the-server]__110158s15r7mi._.js → [root-of-the-server]__0fd39clnjw9fb._.js} +2 -2
  368. package/server/.next/server/chunks/ssr/[root-of-the-server]__0h2hxe0vl-2x0._.js +1 -1
  369. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0i07g85h2g72h._.js → [root-of-the-server]__0h9rpg5-lhp5q._.js} +2 -2
  370. package/server/.next/server/chunks/ssr/[root-of-the-server]__0jgapr1cnvhi6._.js +1 -1
  371. package/server/.next/server/chunks/ssr/[root-of-the-server]__0keo0-hwsnkw9._.js +1 -1
  372. package/server/.next/server/chunks/ssr/[root-of-the-server]__0l50vsk8enxzj._.js +1 -1
  373. package/server/.next/server/chunks/ssr/{[root-of-the-server]__1a0b_dbx4uans._.js → [root-of-the-server]__0p86d9imejczs._.js} +2 -2
  374. package/server/.next/server/chunks/ssr/[root-of-the-server]__0rdf04ziqasfz._.js +1 -1
  375. package/server/.next/server/chunks/ssr/[root-of-the-server]__0rrdzb9wowemv._.js +1 -1
  376. package/server/.next/server/chunks/ssr/[root-of-the-server]__0s2of3mcou177._.js +3 -0
  377. package/server/.next/server/chunks/ssr/{[root-of-the-server]__1-d88ogkwql_b._.js → [root-of-the-server]__0skfdezx5rxie._.js} +2 -2
  378. package/server/.next/server/chunks/ssr/{[root-of-the-server]__1ijizmc3ga_6o._.js → [root-of-the-server]__0tqqte5jb6jz7._.js} +2 -2
  379. package/server/.next/server/chunks/ssr/{[root-of-the-server]__1ogwz1buruc_x._.js → [root-of-the-server]__11paa809_igt_._.js} +2 -2
  380. package/server/.next/server/chunks/ssr/[root-of-the-server]__1_f7nip9age3d._.js +1 -1
  381. package/server/.next/server/chunks/ssr/[root-of-the-server]__1e9tlsk1gl8lw._.js +4 -0
  382. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0hzlz_t5eect2._.js → [root-of-the-server]__1qrk2rfmx21b_._.js} +2 -2
  383. package/server/.next/server/chunks/ssr/[root-of-the-server]__1sw2q1p1t59y8._.js +1 -1
  384. package/server/.next/server/chunks/ssr/[root-of-the-server]__1u_13nhw3kuz3._.js +1 -1
  385. package/server/.next/server/chunks/ssr/[root-of-the-server]__1v3b498_j-68t._.js +4 -0
  386. package/server/.next/server/chunks/ssr/{[root-of-the-server]__0n-sc7pzu7fpz._.js → [root-of-the-server]__1y7nfsglxx7cn._.js} +1 -1
  387. package/server/.next/server/chunks/ssr/_02eudwc8ieb2r._.js +2 -2
  388. package/server/.next/server/chunks/ssr/_08xqk3eibu5aw._.js +1 -1
  389. package/server/.next/server/chunks/ssr/{_10q5jocsvw-i8._.js → _09arvqnznfrzl._.js} +2 -2
  390. package/server/.next/server/chunks/ssr/_09s2unlb4r6yf._.js +3 -0
  391. package/server/.next/server/chunks/ssr/_0_oc9q0vqkynd._.js +1 -1
  392. package/server/.next/server/chunks/ssr/_0a22b7zsckifp._.js +1 -1
  393. package/server/.next/server/chunks/ssr/_0ao-urx9ftj1s._.js +3 -0
  394. package/server/.next/server/chunks/ssr/_0azq3ml4gbn1d._.js +1 -1
  395. package/server/.next/server/chunks/ssr/_0bd4cxnpnnq2u._.js +1 -1
  396. package/server/.next/server/chunks/ssr/_0c7stbntpuyt_._.js +1 -1
  397. package/server/.next/server/chunks/ssr/_0c8kew3jsb-yb._.js +3 -0
  398. package/server/.next/server/chunks/ssr/_0cbbks0ms7i_u._.js +2 -2
  399. package/server/.next/server/chunks/ssr/_0cw4kz3d6kmb1._.js +1 -1
  400. package/server/.next/server/chunks/ssr/_0d2d527wcx-lf._.js +2 -2
  401. package/server/.next/server/chunks/ssr/_0d702k82llasi._.js +1 -1
  402. package/server/.next/server/chunks/ssr/_0dvz4dndt6lkf._.js +3 -0
  403. package/server/.next/server/chunks/ssr/{_0s8qoh8v5kqcm._.js → _0f11sdi6yislb._.js} +2 -2
  404. package/server/.next/server/chunks/ssr/_0gl-ewvbhb677._.js +2 -2
  405. package/server/.next/server/chunks/ssr/_0gmw45sb1llld._.js +3 -0
  406. package/server/.next/server/chunks/ssr/_0i04zoixa2iup._.js +2 -2
  407. package/server/.next/server/chunks/ssr/_0idbg-ok0so2h._.js +2 -2
  408. package/server/.next/server/chunks/ssr/_0iy27gi4y9-fe._.js +4 -0
  409. package/server/.next/server/chunks/ssr/_0kdn56_ow-x_s._.js +1 -1
  410. package/server/.next/server/chunks/ssr/_0oovfx_t_-u0k._.js +1 -1
  411. package/server/.next/server/chunks/ssr/_0oub-njkja8gu._.js +2 -2
  412. package/server/.next/server/chunks/ssr/_0pqkexxo7rts_._.js +2 -2
  413. package/server/.next/server/chunks/ssr/_0qhvl_fw4qetx._.js +1 -1
  414. package/server/.next/server/chunks/ssr/_0rsh9v4b3yj0b._.js +3 -0
  415. package/server/.next/server/chunks/ssr/{_1476vtrt9101m._.js → _0rw2pberdmaa5._.js} +2 -2
  416. package/server/.next/server/chunks/ssr/_0tnd528j0i1i4._.js +2 -2
  417. package/server/.next/server/chunks/ssr/_0uwkwcgucqgcf._.js +2 -2
  418. package/server/.next/server/chunks/ssr/_0v6v5w16qxwke._.js +1 -1
  419. package/server/.next/server/chunks/ssr/{_1edj756n1im8t._.js → _0w3mz8059j-pk._.js} +2 -2
  420. package/server/.next/server/chunks/ssr/_0wo-lpqf7hr1y._.js +2 -2
  421. package/server/.next/server/chunks/ssr/_0xmud7u5hdnqu._.js +4 -0
  422. package/server/.next/server/chunks/ssr/_1-4401bfn50mf._.js +4 -0
  423. package/server/.next/server/chunks/ssr/_1-6d1tm3r_qwg._.js +1 -1
  424. package/server/.next/server/chunks/ssr/_10bven6gb1vj0._.js +1 -1
  425. package/server/.next/server/chunks/ssr/_118h21qua_4o3._.js +1 -1
  426. package/server/.next/server/chunks/ssr/_12makqwatfke-._.js +2 -2
  427. package/server/.next/server/chunks/ssr/_12wjuabpo0ofk._.js +3 -0
  428. package/server/.next/server/chunks/ssr/_19-3vzkc6rk97._.js +1 -1
  429. package/server/.next/server/chunks/ssr/_1_-o2s48aj4i7._.js +1 -1
  430. package/server/.next/server/chunks/ssr/_1c7jkkvkvzj_u._.js +2 -2
  431. package/server/.next/server/chunks/ssr/_1cl55h_h3q-b_._.js +1 -1
  432. package/server/.next/server/chunks/ssr/_1dlo17ba9g-f9._.js +2 -2
  433. package/server/.next/server/chunks/ssr/_1dp5bgqob29-f._.js +3 -0
  434. package/server/.next/server/chunks/ssr/{_1qiv079hbwt43._.js → _1er-95g7emfdz._.js} +2 -2
  435. package/server/.next/server/chunks/ssr/_1fc8k_0p8l00c._.js +2 -2
  436. package/server/.next/server/chunks/ssr/_1fj4vzjpusyn8._.js +5 -0
  437. package/server/.next/server/chunks/ssr/_1fuywfexex2s8._.js +2 -2
  438. package/server/.next/server/chunks/ssr/_1g2zbl_-4z_hg._.js +1 -1
  439. package/server/.next/server/chunks/ssr/{_18z44n8yl5tzj._.js → _1h7x73oxtp7h5._.js} +2 -2
  440. package/server/.next/server/chunks/ssr/_1he21-bt45k8z._.js +2 -2
  441. package/server/.next/server/chunks/ssr/_1j9cka-44jd65._.js +1 -1
  442. package/server/.next/server/chunks/ssr/_1jh_o2i8hj2g5._.js +1 -1
  443. package/server/.next/server/chunks/ssr/{_166ljgwi6shw7._.js → _1jl374mbl90fb._.js} +2 -2
  444. package/server/.next/server/chunks/ssr/{_1r7o1vx4875hu._.js → _1ktvwngz0lzjr._.js} +2 -2
  445. package/server/.next/server/chunks/ssr/_1ln6o3a9quwxo._.js +2 -2
  446. package/server/.next/server/chunks/ssr/_1m4km_w39x5e9._.js +1 -1
  447. package/server/.next/server/chunks/ssr/_1pp1o361lgpwu._.js +2 -2
  448. package/server/.next/server/chunks/ssr/_1rskctyr7yt-b._.js +3 -0
  449. package/server/.next/server/chunks/ssr/_1yh3k88t_kh4h._.js +2 -2
  450. package/server/.next/server/chunks/ssr/_1z6dy1k48mskn._.js +1 -1
  451. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_(private)_ai_keys_page_actions_181-3r4e_0yb5.js +1 -1
  452. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_(private)_ai_logs_page_actions_1ryb93n6khky3.js +1 -1
  453. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_alerts_page_actions_06_3gmyq3jtvi.js +1 -1
  454. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_apps_[id]_page_actions_1--1mjfnoprr2.js +3 -0
  455. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_apps_page_actions_0ksau5eicvycc.js +1 -1
  456. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_connections_page_actions_1fgolmmpxrouc.js +1 -1
  457. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_dns_page_actions_17d_lvhl-u_4w.js +1 -1
  458. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_domains_page_actions_1yv3fj_fh-n-5.js +1 -1
  459. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_firebase_page_actions_00wuues_v_j3r.js +1 -1
  460. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_logs_page_actions_0oqh51t2rx6q0.js +1 -1
  461. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_manage_sections_page_actions_1sb2ldu57uj32.js +1 -1
  462. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_settings_page_actions_12wgjpd0lbh12.js +1 -1
  463. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_supabase_page_actions_1f3a_tpkwjo8z.js +1 -1
  464. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_uptime_page_actions_1ylbdz0-ykfh6.js +1 -1
  465. package/server/.next/server/chunks/ssr/_next-internal_server_app_account_password_page_actions_1v4e71_oifbx9.js +1 -1
  466. package/server/.next/server/chunks/ssr/_next-internal_server_app_signin_page_actions_11wzk446p6_zi.js +1 -1
  467. package/server/.next/server/chunks/ssr/src_0330uf9pdfco9._.js +1 -1
  468. package/server/.next/server/chunks/ssr/src_04o0-kzfmcnim._.js +3 -0
  469. package/server/.next/server/chunks/ssr/src_06tjy8wljego8._.js +1 -1
  470. package/server/.next/server/chunks/ssr/src_084tdkx3c_yqi._.js +1 -1
  471. package/server/.next/server/chunks/ssr/src_0abts6wp5ucc0._.js +1 -1
  472. package/server/.next/server/chunks/ssr/src_0dceh6hsdybq8._.js +3 -0
  473. package/server/.next/server/chunks/ssr/src_0etvjdinp5urq._.js +1 -1
  474. package/server/.next/server/chunks/ssr/src_0ovx2ogvlz2eh._.js +3 -0
  475. package/server/.next/server/chunks/ssr/src_0ph020gy78gi9._.js +1 -1
  476. package/server/.next/server/chunks/ssr/src_0uitfl3c1mdqb._.js +3 -1
  477. package/server/.next/server/chunks/ssr/src_0yxy3bklfxtzz._.js +3 -0
  478. package/server/.next/server/chunks/ssr/src_1-k3gvxaqli74._.js +3 -0
  479. package/server/.next/server/chunks/ssr/src_10zavgy86u3us._.js +1 -1
  480. package/server/.next/server/chunks/ssr/{src_186l56gdeizg8._.js → src_14ulgwoxoyfkq._.js} +2 -2
  481. package/server/.next/server/chunks/ssr/src_1ckoccd8qvnje._.js +1 -1
  482. package/server/.next/server/chunks/ssr/src_1maoe8g5gnv0u._.js +8 -0
  483. package/server/.next/server/chunks/ssr/src_1q-jgpnd3lbcu._.js +1 -1
  484. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_agents_1fyhh1ldgm23z._.js +1 -1
  485. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_ask_ask-form_tsx_18ttm9nna_9y6._.js +1 -1
  486. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_logs_export-button_tsx_1k-crb88n1za_._.js +1 -1
  487. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_models_0ayzqn062pnv5._.js +1 -1
  488. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_playground_playground-view_tsx_18ua5zn_a0mar._.js +1 -1
  489. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_providers_1ru-30x6-uwu4._.js +1 -1
  490. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_quota_limits-form_tsx_1vouaaf560z_x._.js +1 -1
  491. package/server/.next/server/chunks/ssr/src_app_(console)_(private)_ai_usage_limits-form_tsx_0sfk3ver58rqw._.js +1 -1
  492. package/server/.next/server/chunks/ssr/src_app_(console)_0u4_y9-b7g971._.js +3 -0
  493. package/server/.next/server/chunks/ssr/{src_app_(console)_1vpkg9rd7v3pk._.js → src_app_(console)_11o_ga_rurg55._.js} +2 -2
  494. package/server/.next/server/chunks/ssr/src_app_(console)_alerts_0j5xlt68kwg8x._.js +2 -2
  495. package/server/.next/server/chunks/ssr/src_app_(console)_apps_[id]_10xvt--29v-ed._.js +3 -0
  496. package/server/.next/server/chunks/ssr/src_app_(console)_backups_actions_ts_1vpytsdh0wc1f._.js +1 -1
  497. package/server/.next/server/chunks/ssr/src_app_(console)_backups_drive-buttons_tsx_00cku5r_z3jkg._.js +1 -1
  498. package/server/.next/server/chunks/ssr/src_app_(console)_connections_1fahc65-97qla._.js +1 -1
  499. package/server/.next/server/chunks/ssr/src_app_(console)_connections_1fmp_anbkapur._.js +1 -1
  500. package/server/.next/server/chunks/ssr/src_app_(console)_connections_actions_ts_103blv4gzq76z._.js +1 -1
  501. package/server/.next/server/chunks/ssr/src_app_(console)_create_actions_ts_05-86qr6kfjey._.js +1 -1
  502. package/server/.next/server/chunks/ssr/src_app_(console)_deployments_06a83hsex1kba._.js +1 -1
  503. package/server/.next/server/chunks/ssr/src_app_(console)_dns_actions_ts_1jzn58xzwbukz._.js +1 -1
  504. package/server/.next/server/chunks/ssr/src_app_(console)_dns_record-actions_tsx_0cqmz51zcuebv._.js +1 -1
  505. package/server/.next/server/chunks/ssr/src_app_(console)_firebase_row-menu_tsx_0hssoq3pqjl-n._.js +1 -1
  506. package/server/.next/server/chunks/ssr/src_app_(console)_logs_log-viewer_tsx_0v3e4cflfk14w._.js +1 -1
  507. package/server/.next/server/chunks/ssr/src_app_(console)_manage_sections_section-switch_tsx_1mfs-o_357i22._.js +1 -1
  508. package/server/.next/server/chunks/ssr/src_app_(console)_monitor-actions_ts_10w3h7myk2ppi._.js +1 -1
  509. package/server/.next/server/chunks/ssr/src_app_(console)_overview_page_tsx_0se3f3ln9q-42._.js +1 -1
  510. package/server/.next/server/chunks/ssr/src_app_(console)_palette-action_ts_0zyw9a9imev6p._.js +1 -1
  511. package/server/.next/server/chunks/ssr/src_app_(console)_repos_[id]_page_tsx_1nkxthc4ethrj._.js +2 -2
  512. package/server/.next/server/chunks/ssr/src_app_(console)_repos_repo-list_tsx_1n1gcm4qfrfdt._.js +1 -1
  513. package/server/.next/server/chunks/ssr/src_app_(console)_sql_1icfsti04djqe._.js +2 -2
  514. package/server/.next/server/chunks/ssr/src_app_(console)_sql_actions_ts_1oqco02hw-3vp._.js +1 -1
  515. package/server/.next/server/chunks/ssr/src_app_(console)_supabase_0ib3m2ch9gu-4._.js +1 -1
  516. package/server/.next/server/chunks/ssr/src_app_(console)_supabase_pool-actions_ts_0nzd4vwy_9zzx._.js +1 -1
  517. package/server/.next/server/chunks/ssr/src_app_(console)_uptime_1mnnkfi-2zv-k._.js +1 -1
  518. package/server/.next/server/chunks/ssr/src_app_(console)_vercel-actions_ts_0wpk1yo9v632d._.js +1 -1
  519. package/server/.next/server/chunks/ssr/src_app_mfa_setup_setup-flow_tsx_1fpwygr2vdgnh._.js +1 -1
  520. package/server/.next/server/chunks/ssr/src_app_setup_setup-form_tsx_0izoagdur96e1._.js +1 -1
  521. package/server/.next/server/chunks/ssr/{src_app_signin_0ndz9-tbuaohn._.js → src_app_signin_0u6eoxbd8ttqy._.js} +2 -2
  522. package/server/.next/server/chunks/ssr/src_components_create_create-dialog_tsx_1s_9clly_m1ru._.js +1 -1
  523. package/server/.next/server/chunks/ssr/src_components_list-filter_tsx_1zp29997g97yd._.js +1 -1
  524. package/server/.next/server/chunks/ssr/{_0ls7sornjrg95._.js → src_lib_0-nc33gvdtkg5._.js} +2 -2
  525. package/server/.next/server/chunks/ssr/src_lib_0eqv8l-v8d5ze._.js +1 -1
  526. package/server/.next/server/chunks/ssr/src_lib_0n-8zjgq6mcc7._.js +3 -0
  527. package/server/.next/server/chunks/ssr/src_lib_10d18lqjfj8je._.js +3 -0
  528. package/server/.next/server/chunks/ssr/src_lib_1eioo4oodq-8h._.js +1 -1
  529. package/server/.next/server/chunks/ssr/src_lib_1y5l54dwaet39._.js +3 -0
  530. package/server/.next/server/chunks/ssr/src_lib_collector_run_ts_0-q8is8s0y9cq._.js +3 -3
  531. package/server/.next/server/chunks/ssr/{src_lib_demo_0ftmf3wmtezvl._.js → src_lib_demo_0sbw5n9n4mpzx._.js} +2 -2
  532. package/server/.next/server/chunks/ssr/src_lib_providers_github-browse_ts_1apskpn4fe9qr._.js +3 -0
  533. package/server/.next/server/chunks/ssr/src_lib_view_labels_ts_1uxs84z7vclz5._.js +1 -1
  534. package/server/.next/server/chunks/ssr/src_private_0iy_wyg2p1jkn._.js +1 -1
  535. package/server/.next/server/chunks/ssr/src_private_1b8918m4jsjpi._.js +5 -0
  536. package/server/.next/server/chunks/ssr/src_private_1yzfhupl3rlpx._.js +6 -0
  537. package/server/.next/server/chunks/ssr/src_private_actions_decide-form_tsx_1hngtxpyle3v8._.js +1 -1
  538. package/server/.next/server/chunks/ssr/src_private_ai_providers_actions_ts_0wxa36ai6s5nn._.js +1 -1
  539. package/server/.next/server/chunks/ssr/src_private_notes_notes-actions_ts_1g63g8u965fhc._.js +1 -1
  540. package/server/.next/server/functions-config-manifest.json +3 -0
  541. package/server/.next/server/middleware-build-manifest.js +3 -3
  542. package/server/.next/server/pages/404.html +1 -1
  543. package/server/.next/server/pages/500.html +1 -1
  544. package/server/.next/server/preview-props.json +3 -3
  545. package/server/.next/server/server-reference-manifest.js +1 -1
  546. package/server/.next/server/server-reference-manifest.json +384 -168
  547. package/server/.next/static/chunks/{3o45i7xbzm0w-.js → 05uco41_mcq9o.js} +1 -1
  548. package/server/.next/static/chunks/{2_vwhuzct036v.js → 06o7zhf9tv649.js} +1 -1
  549. package/server/.next/static/chunks/{25je6-38ula0p.js → 0bkm_mj9zqjdn.js} +1 -1
  550. package/server/.next/static/chunks/0bqipdtnu2hws.js +1 -0
  551. package/server/.next/static/chunks/0d609c7qn6uke.js +1 -0
  552. package/server/.next/static/chunks/0ghhg0xs85ipn.js +1 -0
  553. package/server/.next/static/chunks/{026a6w6rbx-fh.js → 0inb7hk8o9yz-.js} +1 -1
  554. package/server/.next/static/chunks/{1khar1yl-th2r.js → 0lgt6mz4u8rzx.js} +1 -1
  555. package/server/.next/static/chunks/0r-etc_jv_08f.js +1 -0
  556. package/server/.next/static/chunks/{0p14kwfj_2w_l.js → 0un8ttgrt0gtq.js} +1 -1
  557. package/server/.next/static/chunks/{1bsk5ub4zhehk.js → 0v5xmga7srjvl.js} +1 -1
  558. package/server/.next/static/chunks/{24p8ti6ronsdf.js → 0zzbinjpe41vj.js} +1 -1
  559. package/server/.next/static/chunks/{1ruv-a_ft592k.js → 12vmyliqgjlbi.js} +1 -1
  560. package/server/.next/static/chunks/{234h8_ywb6t9s.js → 131_xlsbuxnhr.js} +1 -1
  561. package/server/.next/static/chunks/{19bfo1_ejzqmp.js → 146uoz7wc8q2y.js} +1 -1
  562. package/server/.next/static/chunks/{2w3otuq4cx1pd.js → 1crspgs6bd_rg.js} +1 -1
  563. package/server/.next/static/chunks/{1b4nkf_ka3hwr.js → 1h0025pjnwxmg.js} +2 -2
  564. package/server/.next/static/chunks/{35ua22np4u9jr.js → 1ot9e084ramy3.js} +1 -1
  565. package/server/.next/static/chunks/{3ngtjj5afybe9.js → 1ouf289jk00f3.js} +1 -1
  566. package/server/.next/static/chunks/{3m825h0uvc8b6.js → 1sds57ddvk_30.js} +1 -1
  567. package/server/.next/static/chunks/{3oe302ug_esoe.js → 1sexa68j4kb7d.js} +1 -1
  568. package/server/.next/static/chunks/1t9iq0wi3ykuc.js +1 -0
  569. package/server/.next/static/chunks/{2baqn9ru2pmf4.js → 1u4r7ru8i619_.js} +2 -2
  570. package/server/.next/static/chunks/{0m3kg-eiti9zu.js → 1vuqw31-hmrxb.js} +1 -1
  571. package/server/.next/static/chunks/{20ujg0hz_need.js → 1xhyfwwelhzu1.js} +1 -1
  572. package/server/.next/static/chunks/{2ehpfaelmkee6.js → 1z85thzinc0kx.js} +1 -1
  573. package/server/.next/static/chunks/{1j7e6cd8t5jar.js → 25erhrojc-1fi.js} +1 -1
  574. package/server/.next/static/chunks/{2uk9mjknuxmxx.js → 29sduk6krs_b1.js} +1 -1
  575. package/server/.next/static/chunks/{0o-c28x8k05p4.js → 29v9jg7vw7brb.js} +1 -1
  576. package/server/.next/static/chunks/2dbx53nx6f-9f.js +7 -0
  577. package/server/.next/static/chunks/{25ba60sl_edr3.js → 2e195xkcjq72y.js} +1 -1
  578. package/server/.next/static/chunks/{1urtw14pwufsv.js → 2f07frmj7udob.js} +1 -1
  579. package/server/.next/static/chunks/{16en34z8w8ezr.js → 2fp4pmte8dtbb.js} +1 -1
  580. package/server/.next/static/chunks/2gv1tg_m49u9m.js +1 -0
  581. package/server/.next/static/chunks/{0jbau1a66ts45.js → 2ockms4mqiec_.js} +11 -11
  582. package/server/.next/static/chunks/{1rgejqx65romt.js → 2p-ty5g5uq133.js} +1 -1
  583. package/server/.next/static/chunks/{231dmdy7r03nd.js → 2tnbp3f6x0jv_.js} +1 -1
  584. package/server/.next/static/chunks/{1y8hxiy48l5hq.js → 2uu38i0lq_wlc.js} +1 -1
  585. package/server/.next/static/chunks/2uufhbm18_cri.js +1 -0
  586. package/server/.next/static/chunks/{4126vjheqklsp.js → 2vxmvnntekclp.js} +1 -1
  587. package/server/.next/static/chunks/{0lhj_nuhfszt5.js → 2xhqwi0hiv_70.js} +1 -1
  588. package/server/.next/static/chunks/{05rysjdxtzhu1.js → 3-8by5unw1j-r.js} +1 -1
  589. package/server/.next/static/chunks/{15x1am33zx_7r.js → 310xe703zu_qp.js} +1 -1
  590. package/server/.next/static/chunks/{3odrzjmblvoxt.js → 33z05hmv7hw1s.js} +1 -1
  591. package/server/.next/static/chunks/{1aiapinh40brx.js → 36wyyf_gobe7n.js} +1 -1
  592. package/server/.next/static/chunks/{1kwbsrtnz8o1l.js → 3_5xff9sl-2e3.js} +1 -1
  593. package/server/.next/static/chunks/{3zx1pe40m_ddz.js → 3b0xtqo5kfyuj.js} +1 -1
  594. package/server/.next/static/chunks/{34jajbsx3uisy.js → 3cvrxnnojhvxz.js} +1 -1
  595. package/server/.next/static/chunks/{20pwnun2aiajo.js → 3fais-5rzury8.js} +2 -2
  596. package/server/.next/static/chunks/{317o5vyehd1xx.js → 3gj8dc0o09zl6.js} +1 -1
  597. package/server/.next/static/chunks/{0wz_jmdt88plr.js → 3s3unktz7g7f0.js} +1 -1
  598. package/server/.next/static/chunks/{35j75g5h_qytc.js → 3w26qimof6fnj.js} +1 -1
  599. package/server/.next/static/chunks/{0o08yqz8_53p6.js → 3z70obsntezy0.js} +1 -1
  600. package/server/.next/server/chunks/[root-of-the-server]__028cxv1v6v0yb._.js +0 -3
  601. package/server/.next/server/chunks/[root-of-the-server]__07g16s_wi2sai._.js +0 -3
  602. package/server/.next/server/chunks/[root-of-the-server]__0dvuy3ibsyiik._.js +0 -3
  603. package/server/.next/server/chunks/[root-of-the-server]__0e2utnqdim70d._.js +0 -3
  604. package/server/.next/server/chunks/[root-of-the-server]__0gmn5s40au84-._.js +0 -3
  605. package/server/.next/server/chunks/[root-of-the-server]__0i75m0es1m3hf._.js +0 -3
  606. package/server/.next/server/chunks/[root-of-the-server]__0k7o0hgdraix2._.js +0 -3
  607. package/server/.next/server/chunks/[root-of-the-server]__0o0z59_jylzvy._.js +0 -3
  608. package/server/.next/server/chunks/[root-of-the-server]__0quiawzx_nww0._.js +0 -3
  609. package/server/.next/server/chunks/[root-of-the-server]__0wdxw44t9l9o_._.js +0 -3
  610. package/server/.next/server/chunks/[root-of-the-server]__0y99cuuxm0xs3._.js +0 -3
  611. package/server/.next/server/chunks/[root-of-the-server]__0zflnh-2nol66._.js +0 -3
  612. package/server/.next/server/chunks/[root-of-the-server]__10dp33pb5e0ml._.js +0 -3
  613. package/server/.next/server/chunks/[root-of-the-server]__12xl6ax-q8s93._.js +0 -3
  614. package/server/.next/server/chunks/[root-of-the-server]__14sac3h4sfhh7._.js +0 -3
  615. package/server/.next/server/chunks/[root-of-the-server]__17xbg7cngebwp._.js +0 -3
  616. package/server/.next/server/chunks/[root-of-the-server]__18lfi0w0e_h0k._.js +0 -3
  617. package/server/.next/server/chunks/[root-of-the-server]__1c1wqmzm65xo8._.js +0 -3
  618. package/server/.next/server/chunks/[root-of-the-server]__1gry2nrq5xhxl._.js +0 -3
  619. package/server/.next/server/chunks/[root-of-the-server]__1kk_s-q90445m._.js +0 -3
  620. package/server/.next/server/chunks/[root-of-the-server]__1lfsf7un8kdbr._.js +0 -3
  621. package/server/.next/server/chunks/[root-of-the-server]__1nusfevn1z4nm._.js +0 -3
  622. package/server/.next/server/chunks/[root-of-the-server]__1oc55uo0ax787._.js +0 -3
  623. package/server/.next/server/chunks/[root-of-the-server]__1uqxnb7qfqcms._.js +0 -3
  624. package/server/.next/server/chunks/[root-of-the-server]__1vxtt1favjdfr._.js +0 -3
  625. package/server/.next/server/chunks/[root-of-the-server]__1xwgj26z5f7ih._.js +0 -3
  626. package/server/.next/server/chunks/[root-of-the-server]__20sv90-2ei08l._.js +0 -3
  627. package/server/.next/server/chunks/_0hsj1tx2ynla-._.js +0 -3
  628. package/server/.next/server/chunks/_0ls7sornjrg95._.js +0 -5
  629. package/server/.next/server/chunks/_0qmi54vmnlwdv._.js +0 -10
  630. package/server/.next/server/chunks/_1daeuesc2d2tg._.js +0 -3
  631. package/server/.next/server/chunks/_1g_prqb_u33e3._.js +0 -10
  632. package/server/.next/server/chunks/src_12wdz9bdn7a-7._.js +0 -3
  633. package/server/.next/server/chunks/src_lib_103kimc1xvc_0._.js +0 -9
  634. package/server/.next/server/chunks/src_lib_1sdusf16f07x-._.js +0 -9
  635. package/server/.next/server/chunks/src_lib_collector_http-check_ts_0bh0rtjky3u1-._.js +0 -3
  636. package/server/.next/server/chunks/src_lib_data_apps-db_ts_02ovqtci8e7o6._.js +0 -3
  637. package/server/.next/server/chunks/src_lib_data_deployments-db_ts_1shbv_55rwa2-._.js +0 -3
  638. package/server/.next/server/chunks/src_lib_domain-move_ts_04stiet1-xpe2._.js +0 -3
  639. package/server/.next/server/chunks/src_private_1_nggk_wre7qf._.js +0 -5
  640. package/server/.next/server/chunks/ssr/[root-of-the-server]__0nxyo70ahj7tk._.js +0 -3
  641. package/server/.next/server/chunks/ssr/[root-of-the-server]__1ctkj-25wt37o._.js +0 -4
  642. package/server/.next/server/chunks/ssr/[root-of-the-server]__1e0l6kek0ufui._.js +0 -3
  643. package/server/.next/server/chunks/ssr/[root-of-the-server]__1kfivch_kfesn._.js +0 -4
  644. package/server/.next/server/chunks/ssr/[root-of-the-server]__1o63-3k1wez40._.js +0 -3
  645. package/server/.next/server/chunks/ssr/_0-wc6f6p0c8lv._.js +0 -3
  646. package/server/.next/server/chunks/ssr/_034fv8o7kws2k._.js +0 -3
  647. package/server/.next/server/chunks/ssr/_042ow6smd_1gj._.js +0 -3
  648. package/server/.next/server/chunks/ssr/_0hsj1tx2ynla-._.js +0 -3
  649. package/server/.next/server/chunks/ssr/_0uvkx5n0kf7r2._.js +0 -3
  650. package/server/.next/server/chunks/ssr/_0zixhhc1lheoi._.js +0 -4
  651. package/server/.next/server/chunks/ssr/_0zkmkbrbc96-h._.js +0 -3
  652. package/server/.next/server/chunks/ssr/_1b1t9p1xljuql._.js +0 -5
  653. package/server/.next/server/chunks/ssr/_1o94cw0ml7xu7._.js +0 -3
  654. package/server/.next/server/chunks/ssr/_218164gkxgum_._.js +0 -4
  655. package/server/.next/server/chunks/ssr/_next-internal_server_app_(console)_apps_[id]_page_actions_0y5m8cul6d7kk.js +0 -3
  656. package/server/.next/server/chunks/ssr/src_0_5_wl0sww-x7._.js +0 -8
  657. package/server/.next/server/chunks/ssr/src_1koc8y1nfdlw3._.js +0 -3
  658. package/server/.next/server/chunks/ssr/src_1xoua7wkmyfkn._.js +0 -3
  659. package/server/.next/server/chunks/ssr/src_1y827m5-ojdib._.js +0 -6
  660. package/server/.next/server/chunks/ssr/src_app_(console)_0f-d8u7sm169e._.js +0 -3
  661. package/server/.next/server/chunks/ssr/src_app_(console)_apps_[id]_1sfvku9ui1le-._.js +0 -3
  662. package/server/.next/server/chunks/ssr/src_components_08d78uqnnmrrh._.js +0 -3
  663. package/server/.next/server/chunks/ssr/src_lib_04orn7u7ufxp1._.js +0 -3
  664. package/server/.next/server/chunks/ssr/src_lib_1l8ej-zoyyegd._.js +0 -3
  665. package/server/.next/server/chunks/ssr/src_lib_collector_http-check_ts_0bh0rtjky3u1-._.js +0 -3
  666. package/server/.next/server/chunks/ssr/src_lib_data_apps-db_ts_02ovqtci8e7o6._.js +0 -3
  667. package/server/.next/server/chunks/ssr/src_lib_data_deployments-db_ts_1shbv_55rwa2-._.js +0 -3
  668. package/server/.next/server/chunks/ssr/src_lib_data_vercel-action_ts_1hvera3nwo5fp._.js +0 -3
  669. package/server/.next/server/chunks/ssr/src_lib_domain-move_ts_04stiet1-xpe2._.js +0 -3
  670. package/server/.next/server/chunks/ssr/src_lib_view_14iq8onyfo7nd._.js +0 -3
  671. package/server/.next/server/chunks/ssr/src_lib_view_deploy-actions_ts_1l3rr2k-04gi4._.js +0 -3
  672. package/server/.next/server/chunks/ssr/src_private_04omlb_sgy-_r._.js +0 -5
  673. package/server/.next/static/chunks/0-0tkevn8vwix.js +0 -1
  674. package/server/.next/static/chunks/0qd8lafp_2ta5.js +0 -1
  675. package/server/.next/static/chunks/14teejsfv-awi.js +0 -1
  676. package/server/.next/static/chunks/1c0s-ejiwfy2u.js +0 -1
  677. package/server/.next/static/chunks/38rdy3k5li9gb.js +0 -1
  678. package/server/.next/static/chunks/3u-qfdthw123i.js +0 -7
  679. package/server/.next/static/chunks/3xhrztkjpas1b.js +0 -1
  680. /package/server/.next/static/{00kxZsHPpI3WSDxVn1e4b → WqHYD3Noq8qkEPXvfVDGQ}/_buildManifest.js +0 -0
  681. /package/server/.next/static/{00kxZsHPpI3WSDxVn1e4b → WqHYD3Noq8qkEPXvfVDGQ}/_clientMiddlewareManifest.js +0 -0
  682. /package/server/.next/static/{00kxZsHPpI3WSDxVn1e4b → WqHYD3Noq8qkEPXvfVDGQ}/_ssgManifest.js +0 -0
@@ -1,5 +1,5 @@
1
- module.exports=[[132245,(e,t,r)=>{function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}r._=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var o=a?Object.getOwnPropertyDescriptor(e,i):null;o&&(o.get||o.set)?Object.defineProperty(n,i,o):n[i]=e[i]}return n.default=e,r&&r.set(e,n),n}},738458,(e,t,r)=>{let s;Object.defineProperty(r,"__esModule",{value:!0}),r.parseCookie=d,r.parse=d,r.stringifyCookie=function(e,t){let r=t?.encode||encodeURIComponent,s=[];for(let t of Object.keys(e)){let i=e[t];if(void 0===i)continue;if(!n.test(t))throw TypeError(`cookie name is invalid: ${t}`);let o=r(i);if(!a.test(o))throw TypeError(`cookie val is invalid: ${i}`);s.push(`${t}=${o}`)}return s.join("; ")},r.stringifySetCookie=h,r.serialize=h,r.parseSetCookie=function(e,t){let r=t?.decode||g,s=e.length,n=p(e,0,s),a=f(e,0,n),i=-1===a?{name:"",value:r(m(e,0,n))}:{name:m(e,0,a),value:r(m(e,a+1,n))},o=n+1;for(;o<s;){let t=p(e,o,s),r=f(e,o,t),n=-1===r?m(e,o,t):m(e,o,r),a=-1===r?void 0:m(e,r+1,t);switch(n.toLowerCase()){case"httponly":i.httpOnly=!0;break;case"secure":i.secure=!0;break;case"partitioned":i.partitioned=!0;break;case"domain":i.domain=a;break;case"path":i.path=a;break;case"max-age":a&&l.test(a)&&(i.maxAge=Number(a));break;case"expires":if(!a)break;let c=new Date(a);Number.isFinite(c.valueOf())&&(i.expires=c);break;case"priority":if(!a)break;let u=a.toLowerCase();("low"===u||"medium"===u||"high"===u)&&(i.priority=u);break;case"samesite":if(!a)break;let d=a.toLowerCase();("lax"===d||"strict"===d||"none"===d)&&(i.sameSite=d)}o=t+1}return i},r.stringifySetCookie=h,r.serialize=h;let n=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,a=/^[\u0021-\u003A\u003C-\u007E]*$/,i=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,o=/^[\u0020-\u003A\u003D-\u007E]*$/,l=/^-?\d+$/,c=Object.prototype.toString,u=((s=function(){}).prototype=Object.create(null),s);function d(e,t){let r=new u,s=e.length;if(s<2)return r;let n=t?.decode||g,a=0;do{let t=f(e,a,s);if(-1===t)break;let i=p(e,a,s);if(t>i){a=e.lastIndexOf(";",t-1)+1;continue}let o=m(e,a,t);void 0===r[o]&&(r[o]=n(m(e,t+1,i))),a=i+1}while(a<s)return r}function h(e,t,r){let s="object"==typeof e?e:{...r,name:e,value:String(t)},l=("object"==typeof t?t:r)?.encode||encodeURIComponent;if(!n.test(s.name))throw TypeError(`argument name is invalid: ${s.name}`);let u=s.value?l(s.value):"";if(!a.test(u))throw TypeError(`argument val is invalid: ${s.value}`);let d=s.name+"="+u;if(void 0!==s.maxAge){if(!Number.isInteger(s.maxAge))throw TypeError(`option maxAge is invalid: ${s.maxAge}`);d+="; Max-Age="+s.maxAge}if(s.domain){if(!i.test(s.domain))throw TypeError(`option domain is invalid: ${s.domain}`);d+="; Domain="+s.domain}if(s.path){if(!o.test(s.path))throw TypeError(`option path is invalid: ${s.path}`);d+="; Path="+s.path}if(s.expires){var h;if(h=s.expires,"[object Date]"!==c.call(h)||!Number.isFinite(s.expires.valueOf()))throw TypeError(`option expires is invalid: ${s.expires}`);d+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(d+="; HttpOnly"),s.secure&&(d+="; Secure"),s.partitioned&&(d+="; Partitioned"),s.priority)switch("string"==typeof s.priority?s.priority.toLowerCase():void 0){case"low":d+="; Priority=Low";break;case"medium":d+="; Priority=Medium";break;case"high":d+="; Priority=High";break;default:throw TypeError(`option priority is invalid: ${s.priority}`)}if(s.sameSite)switch("string"==typeof s.sameSite?s.sameSite.toLowerCase():s.sameSite){case!0:case"strict":d+="; SameSite=Strict";break;case"lax":d+="; SameSite=Lax";break;case"none":d+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${s.sameSite}`)}return d}function p(e,t,r){let s=e.indexOf(";",t);return -1===s?r:s}function f(e,t,r){let s=e.indexOf("=",t);return s<r?s:-1}function m(e,t,r){let s=t,n=r;do{let t=e.charCodeAt(s);if(32!==t&&9!==t)break}while(++s<n)for(;n>s;){let t=e.charCodeAt(n-1);if(32!==t&&9!==t)break;n--}return e.slice(s,n)}function g(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}},63493,e=>{var t=e.i(31194);e.n(t)},133791,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0});var s={default:function(){return l},useLinkStatus:function(){return o.useLinkStatus}};for(var n in s)Object.defineProperty(r,n,{enumerable:!0,get:s[n]});let a=e.r(132245),i=e.r(133210),o=a._(e.r(63493));function l(e){let t=e.legacyBehavior,r="string"==typeof e.children||"number"==typeof e.children||"string"==typeof e.children?.type,s=e.children?.type?.$$typeof===Symbol.for("react.client.reference");return!t||r||s||(e.children?.type?.$$typeof===Symbol.for("react.lazy")?console.error("Using a Lazy Component as a direct child of `<Link legacyBehavior>` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's `<a>` tag."):console.error("Using a Server Component as a direct child of `<Link legacyBehavior>` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's `<a>` tag.")),(0,i.jsx)(o.default,{...e})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},385585,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"after",{enumerable:!0,get:function(){return a}});let s=e.r(556704),n=e.r(832319);function a(e){let t=s.workAsyncStorage.getStore(),r=n.workUnitAsyncStorage.getStore();if(!t||!r)throw Error("`after` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context");let{afterContext:a}=t;return a.after(e,r)}},910473,(e,t,r)=>{var s,n;Object.defineProperty(r,"__esModule",{value:!0}),s=e.r(385585),n=r,Object.keys(s).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})})},476550,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"connection",{enumerable:!0,get:function(){return d}});let s=e.r(556704),n=e.r(832319),a=e.r(258200),i=e.r(183589),o=e.r(225176),l=e.r(679847);e.r(865832);let c=e.r(585346),u=e.r(748448);function d(){let e=s.workAsyncStorage.getStore(),t=n.workUnitAsyncStorage.getStore();if(e){if(t&&!(0,l.isRequestApiAllowedInCurrentPhase)(t))throw Error(`Route ${e.route} used \`connection()\` inside \`after()\` while rendering. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but \`after()\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`);if(e.forceStatic)return Promise.resolve(void 0);if(e.dynamicShouldError)throw new i.StaticGenBailoutError(`Route ${e.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`connection()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`);if(t)switch(t.type){case"cache":{let t=(0,u.createConnectionInPublicUseCacheError)(e.route);throw Error.captureStackTrace(t,d),(0,o.applyOwnerStack)(t),e.invalidDynamicUsageError??=t,t}case"private-cache":{let t=(0,u.createConnectionInPrivateUseCacheError)(e.route);throw Error.captureStackTrace(t,d),(0,o.applyOwnerStack)(t),e.invalidDynamicUsageError??=t,t}case"unstable-cache":throw(0,u.createConnectionInUnstableCacheError)(e.route);case"build-time-generator":throw Error(`Route ${e.route} used \`connection()\` inside \`${t.functionName}\`. This is not supported because \`${t.functionName}\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context`);case"prerender":case"prerender-client":case"prerender-runtime":return(0,o.makeDynamicHangingPromise)(t.renderSignal,e.route,"`connection()`");case"validation-client":{let e="`connection`";throw new c.InvariantError(`${e} must not be used within a Client Component. Next.js should be preventing ${e} from being included in Client Components statically, but did not in this case.`)}case"prerender-legacy":return(0,a.throwToInterruptStaticGeneration)("connection",e,t);case"request":if((0,a.trackDynamicDataInDynamicRender)(t),t.asyncApiPromises)return t.asyncApiPromises.connection;return Promise.resolve(void 0)}}(0,n.throwForMissingRequestStore)("connection")}},133210,(e,t,r)=>{t.exports=e.r(307450).vendored["react-rsc"].ReactJsxRuntime},310086,(e,t,r)=>{t.exports=e.r(307450).vendored["react-rsc"].ReactServerDOMTurbopackServer},853702,(e,t,r)=>{function s(){throw Error('ImageResponse moved from "next/server" to "next/og" since Next.js 14, please import from "next/og" instead')}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"ImageResponse",{enumerable:!0,get:function(){return s}})},628661,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"NextResponse",{enumerable:!0,get:function(){return d}});let s=e.r(86547),n=e.r(723866),a=e.r(287790),i=e.r(770956),o=e.r(86547),l=Symbol("internal response"),c=new Set([301,302,303,307,308]);function u(e,t){var r;if(null==e||null==(r=e.request)?void 0:r.headers){if(!(e.request.headers instanceof Headers))throw Error("request.headers must be an instance of Headers");let r=[];for(let[s,n]of e.request.headers)t.set("x-middleware-request-"+s,n),r.push(s);t.set("x-middleware-override-headers",r.join(","))}}class d extends Response{constructor(e,t={}){super(e,t);let r=this.headers,c=new Proxy(new o.ResponseCookies(r),{get(e,n,a){switch(n){case"delete":case"set":return(...a)=>{let i=Reflect.apply(e[n],e,a),l=new Headers(r);return i instanceof o.ResponseCookies&&r.set("x-middleware-set-cookie",i.getAll().map(e=>(0,s.stringifyCookie)(e)).join(",")),u(t,l),i};default:return i.ReflectAdapter.get(e,n,a)}}});this[l]={cookies:c,url:t.url?new n.NextURL(t.url,{headers:(0,a.toNodeOutgoingHttpHeaders)(r),nextConfig:t.nextConfig}):void 0}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,url:this.url,body:this.body,bodyUsed:this.bodyUsed,headers:Object.fromEntries(this.headers),ok:this.ok,redirected:this.redirected,status:this.status,statusText:this.statusText,type:this.type}}get cookies(){return this[l].cookies}static json(e,t){let r=Response.json(e,t);return new d(r.body,r)}static redirect(e,t){let r="number"==typeof t?t:(null==t?void 0:t.status)??307;if(!c.has(r))throw RangeError('Failed to execute "redirect" on "response": Invalid status code');let s="object"==typeof t?t:{},n=new Headers(null==s?void 0:s.headers);return n.set("Location",(0,a.validateURL)(e)),new d(null,{...s,headers:n,status:r})}static rewrite(e,t){let r=new Headers(null==t?void 0:t.headers);return r.set("x-middleware-rewrite",(0,a.validateURL)(e)),u(t,r),new d(null,{...t,headers:r})}static next(e){let t=new Headers(null==e?void 0:e.headers);return t.set("x-middleware-next","1"),u(e,t),new d(null,{...e,headers:t})}}},374644,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"URLPattern",{enumerable:!0,get:function(){return s}});let s="u"<typeof URLPattern?void 0:URLPattern},276870,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0});var s,n={isBot:function(){return o},userAgent:function(){return c},userAgentFromString:function(){return l}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=(s=e.r(547850))&&s.__esModule?s:{default:s};function o(e){return/Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Google-InspectionTool|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver|GPTBot/i.test(e)}function l(e){return{...(0,i.default)(e),isBot:void 0!==e&&o(e)}}function c({headers:e}){return l(e.get("user-agent")||void 0)}},352565,e=>{var t=e.i(310086);(0,t.registerClientReference)(function(){throw Error("Attempted to call AliasProvider() from the server but AliasProvider is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","AliasProvider"),(0,t.registerClientReference)(function(){throw Error("Attempted to call DbName() from the server but DbName is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","DbName"),(0,t.registerClientReference)(function(){throw Error("Attempted to call Masked() from the server but Masked is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","Masked");let r=(0,t.registerClientReference)(function(){throw Error("Attempted to call MaskedText() from the server but MaskedText is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","MaskedText");(0,t.registerClientReference)(function(){throw Error("Attempted to call Reveal() from the server but Reveal is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","Reveal"),(0,t.registerClientReference)(function(){throw Error("Attempted to call maskedValue() from the server but maskedValue is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","maskedValue"),(0,t.registerClientReference)(function(){throw Error("Attempted to call useAliasBook() from the server but useAliasBook is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","useAliasBook"),(0,t.registerClientReference)(function(){throw Error("Attempted to call useMask() from the server but useMask is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","useMask"),(0,t.registerClientReference)(function(){throw Error("Attempted to call usePrivacy() from the server but usePrivacy is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","usePrivacy"),e.s(["MaskedText",0,r])},639307,e=>{var t=e.i(352565);e.n(t)},455891,e=>{var t=e.i(336763),r=e.i(75064),s=e.i(492973),n=e.i(79322),a=e.i(909592),i=e.i(406212),o=e.i(530298),l=e.i(27479),c=e.i(728335);let u=e=>{let t=(0,c.calendarDate)(e);return`${t.day} ${t.month} ${t.year}`},d=c.dayKey;var h=e.i(857799),p=e.i(123076),f=e.i(70377),m=e.i(586307),g=e.i(827439);let b="advisor.latest",y=r.z.object({key:s.z.string(),severity:n.z.enum(["warning","info"]),appId:s.z.string().nullable(),subject:s.z.string(),title:s.z.string(),why:s.z.string(),fix:s.z.string(),href:s.z.string()}),w=r.z.object({at:s.z.string(),items:a.z.array(y)});async function v(e){let r=(0,t.and)((0,t.eq)(o.resources.kind,"app"),(0,t.eq)(o.resources.monitored,!0),(0,t.isNull)(o.resources.goneAt)),s=await (0,g.P)(),n=await (0,m.V)(),[a,c,u,d,b]=await Promise.all([(0,i.db)().select({id:o.monitors.id,appId:o.monitors.resourceId,appName:o.resources.name,url:o.monitors.url,kind:o.monitors.kind,name:o.monitors.name,paused:o.monitors.paused,ownerPaused:o.monitors.ownerPaused,lastStatus:o.monitors.lastStatus,expectedStatus:o.monitors.expectedStatus,lastPingAt:o.monitors.lastPingAt,createdAt:o.monitors.createdAt}).from(o.monitors).innerJoin(o.resources,(0,t.eq)(o.resources.id,o.monitors.resourceId)).where(r).orderBy(o.resources.name,o.monitors.url).limit(f.O.monitors),(0,i.db)().select({id:o.resources.id,name:o.resources.name,version:o.appSecurity.version}).from(o.resources).innerJoin(o.appSecurity,(0,t.eq)(o.appSecurity.resourceId,o.resources.id)).where(r).orderBy(o.resources.name).limit(f.O.apps),(0,i.db)().select({id:o.resources.id,name:o.resources.name,kind:o.resources.kind,accountId:o.resources.accountId,accountLabel:o.accounts.label,state:o.snapshots.state}).from(o.resources).innerJoin(o.accounts,(0,t.eq)(o.accounts.id,o.resources.accountId)).leftJoin(o.snapshots,(0,t.eq)(o.snapshots.resourceId,o.resources.id)).where((0,t.and)((0,t.inArray)(o.resources.kind,[...h.H]),(0,t.eq)(o.resources.monitored,!0),(0,t.isNull)(o.resources.goneAt))).orderBy(o.resources.name).limit(f.O.databases),(0,i.db)().select({appId:o.links.fromResourceId,dbId:o.links.toResourceId}).from(o.links).where((0,t.eq)(o.links.kind,"uses_db")).limit(f.O.apps),(0,i.db)().select({id:o.accounts.id,provider:o.accounts.provider,label:o.accounts.label,expiresAt:o.accounts.expiresAt,scopeNote:o.accounts.scopeNote}).from(o.accounts).orderBy(o.accounts.label).limit(200)]);return{now:e,monitors:a.map(e=>({id:e.id,appId:e.appId,appName:e.appName,path:"heartbeat"===e.kind?e.url:(0,l.K)(e.url),kind:e.kind,name:e.name,paused:e.paused||e.ownerPaused,lastStatus:e.lastStatus,expectedStatus:e.expectedStatus,lastPingAt:e.lastPingAt,createdAt:e.createdAt})),eol:function(e,t){if(!t)return null;let r=t.cycles.find(e=>!e.isEol)?.latest??null,s=[];for(let n of e){let e=n.version?.split(".")[0],a=e?t.cycles.find(t=>t.name===e):void 0;a&&s.push({appId:n.id,appName:n.name,cycle:a.name,eolFrom:a.eolFrom?new Date(`${a.eolFrom}T00:00:00Z`):null,latest:r})}return s}(c,s),headers:null,dbs:u.map(e=>({id:e.id,name:e.name,provider:(0,h.Z)(e.kind),accountId:e.accountId,accountLabel:e.accountLabel,state:e.state??"unknown"})),slots:(0,p.f)(n).map(e=>({account:e.account,used:e.used,total:e.total,planUnknown:e.planUnknown})),links:d,accounts:b}}async function k(e){let t=function(e){let t=[];for(let r of e.eol??[]){if(!r.eolFrom||r.eolFrom.getTime()-e.now.getTime()>2592e6)continue;let s=r.eolFrom.getTime()<=e.now.getTime(),n=r.latest?.split(".")[0];t.push({key:`next-eol:${r.appId}:${r.cycle}`,severity:"warning",appId:r.appId,subject:r.appName,title:`Next.js ${r.cycle} ${s?"reached":"reaches"} end of life on ${u(r.eolFrom)}`,why:`No security fixes after that date.${r.latest?` Latest is ${r.latest}.`:""}`,fix:n?`Upgrade to Next.js ${n}.`:"Upgrade Next.js.",href:"https://endoflife.date/nextjs"})}for(let r of e.monitors)!r.paused&&("heartbeat"===r.kind&&!r.lastPingAt&&e.now.getTime()-r.createdAt.getTime()>864e5&&t.push({key:`hb-silent:${r.id}`,severity:"warning",appId:r.appId,subject:r.appName,title:`${r.name??"A heartbeat"} has never pinged`,why:"It was added more than a day ago and no job has called its URL.",fix:"Add the ping to the job, or delete the monitor.",href:"/uptime"}),"http"===r.kind&&"/"===r.path&&200===r.expectedStatus&&null!==r.lastStatus&&[401,403,404].includes(r.lastStatus)&&t.push({key:`monitor-root:${r.id}:${r.lastStatus}`,severity:"info",appId:r.appId,subject:r.appName,title:`The monitor on / answers ${r.lastStatus}`,why:`A login or missing page answering ${r.lastStatus} makes the monitor look down.`,fix:`Point the monitor at a public health route, or expect ${r.lastStatus}.`,href:"/uptime"}));for(let r of e.headers??[]){if(!r.missing.length)continue;let e=[...r.missing].sort();t.push({key:`headers:${r.appId}:${e.join(",")}`,severity:"info",appId:r.appId,subject:r.appName,title:`Missing security headers: ${e.join(", ")}`,why:"Browsers use them to block clickjacking, sniffing and downgrade attacks.",fix:"Add them in next.config headers().",href:"https://developer.mozilla.org/en-US/observatory"})}for(let r of e.slots??[])r.used<r.total||t.push({key:`no-slot:${r.account}`,severity:"warning",appId:null,subject:`supabase \xb7 ${r.account}`,title:`Account ${r.account} has no free slot`,why:r.planUnknown?"Two projects are active. If this account is on the free plan (it couldn't be read), a paused one can't be restored here.":"Both free projects are active, so a paused one can't be restored here.",fix:"Pause one project, or move one to another account.",href:"/supabase"});if(e.dbs&&e.links){let r=new Set(e.links.map(e=>e.dbId));for(let s of e.dbs.filter(e=>!r.has(e.id)))t.push({key:`db-unlinked:${s.id}`,severity:"info",appId:null,subject:s.name,title:"Database isn't linked to any app",why:"Topology and the app status can't use it.",fix:"Link it from the app page.",href:"/apps"})}for(let r of e.accounts)"supabase"===r.provider&&r.scopeNote&&/all[- ]access/i.test(r.scopeNote)&&t.push({key:`broad-cred:${r.id}`,severity:"info",appId:null,subject:`supabase \xb7 ${r.label}`,title:`${r.label} uses an all-access token`,why:"The console only reads; a broader token is a bigger risk if it ever leaks.",fix:"Replace it with a read-only token in Connections, then revoke the old one in Supabase.",href:"/connections"});for(let r of e.accounts){if(!r.expiresAt)continue;let s=r.expiresAt.getTime()-e.now.getTime();s>=12096e5&&s<=5184e6&&t.push({key:`cred-60:${r.id}:${d(r.expiresAt)}`,severity:"info",appId:null,subject:`${r.provider} \xb7 ${r.label}`,title:`The ${r.provider} credential ${r.label} expires on ${(0,c.dayMonth)(r.expiresAt)}`,why:"An expired credential stops every reading from that account.",fix:"Create a new one and use Replace credential in Connections.",href:"/connections"})}return t.map((e,t)=>({r:e,i:t})).sort((e,t)=>("warning"!==e.r.severity)-("warning"!==t.r.severity)||e.i-t.i).map(({r:e})=>e).slice(0,50)}(await v(e)),r={at:e.toISOString(),items:t};return await (0,i.db)().insert(o.settings).values({key:b,value:r}).onConflictDoUpdate({target:o.settings.key,set:{value:r,updatedAt:e}}),t}async function _(e){let[r]=await (0,i.db)().select({value:o.settings.value}).from(o.settings).where((0,t.eq)(o.settings.key,b)).limit(1),s=w.safeParse(r?.value);return s.success?s.data.items:k(e)}async function S(e,r){var s;let n=await _(e);if(!n.length)return[];let a=await (0,i.db)().select({key:o.recommendationDismissals.key,dismissedAt:o.recommendationDismissals.dismissedAt}).from(o.recommendationDismissals).where((0,t.inArray)(o.recommendationDismissals.key,n.map(e=>e.key))).limit(50),l=(s=new Map(a.map(e=>[e.key,e.dismissedAt])),n.filter(t=>{let r=s.get(t.key);return!r||e.getTime()-r.getTime()>=2592e6}));return r?l.filter(e=>e.appId===r):l}e.s(["T",0,S,"O",0,k],455891)},42784,464161,e=>{var t=e.i(336763),r=e.i(396918),s=e.i(533102),n=e.i(406212),a=e.i(530298),i=e.i(978196),o=e.i(736337),l=e.i(667378),c=e.i(412948),u=e.i(178233),d=e.i(785194),h=e.i(70377),p=e.i(586307),f=e.i(764266);e.i(333407);var m=e.i(706959),g=e.i(706539),b=e.i(380719),y=e.i(584820);let w=e=>"string"==typeof e&&e?e:null;async function v(e,v){let k=await (0,n.db)().select({r:a.resources,s:a.snapshots,sec:a.appSecurity,accStatus:a.accounts.status}).from(a.resources).leftJoin(a.accounts,(0,t.eq)(a.accounts.id,a.resources.accountId)).leftJoin(a.snapshots,(0,t.eq)(a.snapshots.resourceId,a.resources.id)).leftJoin(a.appSecurity,(0,t.eq)(a.appSecurity.resourceId,a.resources.id)).where((0,t.and)((0,t.eq)(a.resources.kind,"app"),(0,t.eq)(a.resources.monitored,!0),v?(0,t.eq)(a.resources.id,v):void 0)).orderBy(a.resources.name).limit(h.O.apps);if(!k.length)return[];let _=k.map(e=>e.r.id),S=(await (0,n.db)().select().from(a.monitors).where((0,t.inArray)(a.monitors.resourceId,_)).orderBy(a.monitors.createdAt).limit(h.O.monitors)).map(b.M),x=await (0,n.db)().selectDistinctOn([a.deployments.resourceId]).from(a.deployments).where((0,t.and)((0,t.inArray)(a.deployments.resourceId,_),(0,t.eq)(a.deployments.target,"production"),(0,t.or)((0,t.eq)(a.deployments.isCurrent,!0),(0,t.ne)(a.deployments.state,"ready"),s.sql`${a.deployments.resourceId} not in (select serving.resource_id from ${a.deployments} as serving where serving.target = 'production' and serving.is_current)`))).orderBy(a.deployments.resourceId,(0,r.desc)(a.deployments.createdAtProvider)),A=await (0,g._)(S.map(e=>e.id),e),T=new Map(k.map(e=>[e.r.id,e.r])),R=await (0,b.J)(S.map(e=>({id:e.id,kind:e.kind,url:e.url,appId:e.appId,appName:T.get(e.appId)?.name??"",appMeta:T.get(e.appId)?.meta,lastError:e.lastError}))),E=new Map;for(let e of(await (0,n.db)().select({parentId:a.resources.parentId,name:a.resources.name,meta:a.resources.meta}).from(a.resources).where((0,t.and)((0,t.eq)(a.resources.kind,"domain"),(0,t.inArray)(a.resources.parentId,_),(0,t.isNull)(a.resources.goneAt))))){if(!e.parentId)continue;let t=E.get(e.parentId)??{};t[e.name.toLowerCase()]={redirect:w(e.meta.redirect),verified:!1!==e.meta.verified},E.set(e.parentId,t)}let I=await (0,g.P)(_,e),j=await (0,p.F)(_),O=S.length?await (0,m.f)():[];return k.map(({r:t,s:r,sec:s,accStatus:n})=>{let a=S.filter(e=>e.appId===t.id).map(t=>({...t,maintUntil:(0,f.x)(O,{monitorId:t.id,appId:t.appId},e)?.end??null,move:R.get(t.id)??null})),p=w(t.meta.createdAt),m=x.find(e=>e.resourceId===t.id);return{id:t.id,name:t.name,gone:null!==t.goneAt,state:r?.state??"unknown",stateSince:r?.stateSince??null,domain:(0,i.Y)(t.meta)?.primaryDomain??(0,c.m)(t.name,a.map(e=>e.url)),domainLines:(0,l.f)(t.meta,E.get(t.id)??{},(0,i.Y)(t.meta)?.primaryDomain??(0,c.m)(t.name,a.map(e=>e.url))),framework:w(t.meta.framework),productionBranch:w(t.meta.productionBranch),productionSource:(0,o.O)(t.meta.productionSource),createdAt:p?new Date(p):null,teamName:w(t.meta.teamName),teamSlug:w(t.meta.teamSlug),repo:w(t.meta.repo),repoType:w(t.meta.repoType),functionRegions:Array.isArray(t.meta.functionRegions)?t.meta.functionRegions.filter(e=>"string"==typeof e):[],monitors:a,lastDeploy:m?{id:m.id,externalId:m.externalId,state:m.state,target:m.target,branch:m.branch,commitSha:m.commitSha,commitMessage:m.commitMessage,url:m.url,createdAt:m.createdAtProvider,buildingAt:m.buildingAt,readyAt:m.readyAt,isCurrent:m.isCurrent,isPreviousProduction:m.isPreviousProduction}:null,uptime30:(0,d.Y)(a.flatMap(t=>(0,d.w)(A.get(t.id),e,d.I))),response:I.get(t.id)??{hourly:Array.from({length:h.A.responseHours},()=>null),p95:null,p50:null},days:new Map(a.flatMap(e=>{let t=A.get(e.id);return t?[[e.id,t]]:[]})),security:s?(0,y.Z)(s):null,database:j.get(t.id)??null,dbPaused:r?.data.dbPaused===!0,pageViews:(0,u.G)(r?.data),pageViewsNote:(0,u.R)({gone:null!==t.goneAt,teamId:w(t.meta.teamId),accountOk:"ok"===n,hasProductionDeploy:void 0!==m})}})}e.s(["f",0,v],42784),s.sql`coalesce(${a.events.lastAt}, ${a.events.at})`,e.s([],464161)},328586,e=>{var t=e.i(336763),r=e.i(396918),s=e.i(406212),n=e.i(530298),a=e.i(112515),i=e.i(803237),o=e.i(93387);let l=e=>e.trim().toLowerCase();var c=e.i(802641),u=e.i(958948);async function d(e){let l=e?(0,t.and)((0,t.eq)(n.accounts.id,e),(0,t.eq)(n.accounts.provider,"github")):(0,t.eq)(n.accounts.provider,"github"),[c]=await (0,s.db)().select().from(n.accounts).where(l).orderBy((0,r.asc)(n.accounts.createdAt)).limit(1);if(!c)return null;let u=(0,i.V)({ciphertext:c.credentialCiphertext,iv:c.credentialIv},(0,o.serverEnv)().OPS_ENCRYPTION_KEY);return{account:c,token:u,problem:(0,a.A)(u)}}async function h(e,t,r){let s=0;for(let n=0;n<e.length&&!(Date.now()>t);n+=5){let t=e.slice(n,n+5);s+=t.length,await Promise.allSettled(t.map(r))}return s}async function p(e,r,i={}){var o,c;let m,g,b,y=await d(e);if(!y)return{ok:!1,error:"GitHub isn't connected."};let{account:w,token:v,problem:k}=y;if(k||!v)return{ok:!1,error:k??"The credential can't be read."};let _=await (0,u.o)(v,i);if(!_.ok){let e=(0,a.E)({ok:!1,kind:"scope"===_.kind?"auth":"missing"===_.kind?"transient":_.kind,error:_.error});return e&&await (0,s.db)().update(n.accounts).set({...e,updatedAt:new Date}).where((0,t.eq)(n.accounts.id,w.id)),{ok:!1,error:_.error}}let S=new Date,x=(o=await (0,s.db)().select({id:n.githubRepos.id,externalId:n.githubRepos.externalId,goneAt:n.githubRepos.goneAt}).from(n.githubRepos).where((0,t.eq)(n.githubRepos.accountId,w.id)).limit(1e3),c=_.data.repos,m=new Map(o.map(e=>[e.externalId,e])),g=new Set(c.map(e=>e.id)),{insert:c.filter(e=>!m.has(e.id)),update:c.filter(e=>m.has(e.id)).map(e=>({id:m.get(e.id).id,repo:e})),gone:o.filter(e=>!g.has(e.externalId)&&!e.goneAt).map(e=>e.id)}),A=e=>({owner:e.owner,name:e.name,fullName:e.fullName,defaultBranch:e.defaultBranch,private:e.private,archived:e.archived,htmlUrl:e.htmlUrl,pushedAt:e.pushedAt});await (0,s.db)().transaction(async e=>{for(let r of x.update)await e.update(n.githubRepos).set({...A(r.repo),lastSeenAt:S,goneAt:null,updatedAt:S}).where((0,t.eq)(n.githubRepos.id,r.id));x.insert.length&&await e.insert(n.githubRepos).values(x.insert.map(e=>({accountId:w.id,externalId:e.id,...A(e)}))).onConflictDoNothing({target:[n.githubRepos.accountId,n.githubRepos.externalId]}),x.gone.length&&await e.update(n.githubRepos).set({goneAt:S,updatedAt:S}).where((0,t.and)((0,t.inArray)(n.githubRepos.id,x.gone),(0,t.isNull)(n.githubRepos.goneAt)))});let T=await (0,s.db)().select().from(n.githubRepos).where((0,t.eq)(n.githubRepos.accountId,w.id)).limit(1e3),R=[];_.data.truncated&&R.push("Only the 300 most recently pushed repositories are listed.");let E=0;await h(T.filter(e=>!e.archived&&!e.goneAt&&(!e.packageCheckedAt||null!==e.pushedAt&&e.pushedAt>e.packageCheckedAt)).sort((e,t)=>(t.pushedAt?.getTime()??0)-(e.pushedAt?.getTime()??0)).slice(0,10),r,async e=>{let r=await (0,u.q)(v,e.fullName,i);r.ok?await (0,s.db)().update(n.githubRepos).set({packageName:r.data,packageCheckedAt:new Date,updatedAt:new Date}).where((0,t.eq)(n.githubRepos.id,e.id)):"scope"===r.kind&&E++}),E&&R.push("Some package.json files can't be read: give the token Contents read on those repositories.");let I=await (0,s.db)().select({id:n.resources.id,name:n.resources.name,meta:n.resources.meta}).from(n.resources).where((0,t.and)((0,t.eq)(n.resources.kind,"app"),(0,t.isNull)(n.resources.goneAt))).limit(500),j=await (0,s.db)().select({appId:n.appRepos.appId,repoId:n.appRepos.repoId,source:n.appRepos.source}).from(n.appRepos).limit(500),O=e=>"string"==typeof e&&e?e:null,C=function(e,t,r){let s=new Map(t.filter(e=>!e.goneAt).map(e=>[l(e.fullName),e.id])),n=new Map(r.map(e=>[e.appId,e])),a=[];for(let t of e){if("github"!==t.repoType||!t.repo)continue;let e=s.get(l(t.repo));if(!e)continue;let r=n.get(t.id);r?.source!=="manual"&&r?.repoId!==e&&a.push({appId:t.id,repoId:e})}return a}(I.map(e=>({id:e.id,name:e.name,repo:O(e.meta.repo),repoType:O(e.meta.repoType)})),T,j);for(let e of C)await (0,s.db)().insert(n.appRepos).values({appId:e.appId,repoId:e.repoId,source:"vercel"}).onConflictDoUpdate({target:n.appRepos.appId,set:{repoId:e.repoId,source:"vercel",updatedAt:new Date},setWhere:(0,t.ne)(n.appRepos.source,"manual")});let $=await (0,s.db)().selectDistinct({id:n.githubRepos.id,fullName:n.githubRepos.fullName,defaultBranch:n.githubRepos.defaultBranch}).from(n.appRepos).innerJoin(n.githubRepos,(0,t.eq)(n.githubRepos.id,n.appRepos.repoId)).where((0,t.and)((0,t.eq)(n.githubRepos.accountId,w.id),(0,t.isNull)(n.githubRepos.goneAt))).limit(500),P=0,N=await h($,r,async e=>{let t=await (0,u.W)(v,e.fullName,e.defaultBranch,i);t.ok?await f(e.id,t.data):"scope"===t.kind&&P++});P&&R.push("Some Actions runs can't be read: give the token Actions read on those repositories."),N<$.length&&R.push(`${$.length-N} Actions status${$.length-N==1?"":"es"} left for the next run, time budget used.`);let D=await (0,u.k)(v,i);await (0,s.db)().update(n.accounts).set({lastSyncAt:S,status:"ok",lastError:null,updatedAt:S,...D.ok?{expiresAt:D.data.expiresAt}:{}}).where((0,t.eq)(n.accounts.id,w.id));let L={at:S.toISOString(),actionsDenied:P,contentsDenied:E};return await (0,s.db)().insert(n.settings).values({key:(b=w.id,`github.readGaps.${b}`),value:L}).onConflictDoUpdate({target:n.settings.key,set:{value:L,updatedAt:S}}),{ok:!0,repos:T.filter(e=>!e.goneAt).length,linked:$.length,newLinks:C.length,notes:R}}async function f(e,r){await (0,s.db)().update(n.githubRepos).set({actions:r,actionsCheckedAt:new Date,updatedAt:new Date}).where((0,t.eq)(n.githubRepos.id,e))}async function m(e){let[r]=await (0,s.db)().select({id:n.accounts.id}).from(n.accounts).where((0,t.eq)(n.accounts.provider,"github")).limit(1);if(!r)return null;if(Date.now()>e)return"left for the next run, time budget used";let a=await p(r.id,e);return a.ok?null:a.error}async function g(e){if(!(0,c.f)(e))return{ok:!1,reason:"no-repo",error:"That app no longer exists."};let[r]=await (0,s.db)().select({r:n.githubRepos}).from(n.appRepos).innerJoin(n.githubRepos,(0,t.eq)(n.githubRepos.id,n.appRepos.repoId)).where((0,t.and)((0,t.eq)(n.appRepos.appId,e),(0,t.isNull)(n.githubRepos.goneAt))).limit(1);if(!r)return{ok:!1,reason:"no-repo",error:"This app isn't linked to a GitHub repository yet."};let a=await d(r.r.accountId);return a?.token?{ok:!0,fullName:r.r.fullName,defaultBranch:r.r.defaultBranch,token:a.token}:{ok:!1,reason:"no-token",error:"The GitHub token can't be read; check the GitHub connection."}}e.s(["D",0,m,"l",0,g],328586)},451682,313903,205746,e=>{var t=e.i(336763),r=e.i(157406),s=e.i(533102),n=e.i(406212),a=e.i(530298),i=e.i(122603),o=e.i(803237),l=e.i(333407),c=e.i(93387),u=e.i(765503),d=e.i(666680),h=e.i(75064),p=e.i(909592),f=e.i(932378),m=e.i(246517),g=e.i(492973),b=e.i(794588);e.s(["z",0,b],313903);var b=b,y=e.i(260417);let w=["debug","info","warning","error","fatal","trace"],v=h.z.object({rows:p.z.array(f.z.unknown()).catch([]),hasMoreRows:m.z.boolean().catch(!1)}),k=h.z.object({requestId:g.z.string().min(1),timestamp:g.z.string().transform((e,t)=>{let r=Date.parse(e);return Number.isNaN(r)?(t.addIssue({code:"custom",message:"bad timestamp"}),b.NEVER):new Date(r)}),deploymentId:g.z.string().nullish().catch(null),requestMethod:g.z.string().nullish().catch(null),requestPath:g.z.string().nullish().catch(null),statusCode:y.z.number().nullish().catch(null),logs:p.z.array(f.z.unknown()).nullish().catch(null),events:p.z.array(f.z.unknown()).nullish().catch(null)}),_=h.z.object({level:g.z.string().nullish().catch(null),message:g.z.string().nullish().catch(null)}),S=h.z.object({source:g.z.string().nullish().catch(null)}),x=(e,t)=>(0,d.createHash)("sha1").update(`${e}
2
- ${t}`).digest("hex").slice(0,8),A=(e,t,r={})=>({ok:!1,kind:e,error:t,...r});async function T(e,t,r,s){let n=(s.now??new Date).getTime(),a=Math.max(s.since.getTime(),n-864e5),o=s.until.getTime();if(a>=o)return{ok:!0,lines:[],more:!1};let l=s.maxRows??300,c=s.levels?new Set(s.levels):null,u=e=>!c||c.has(e),d=s.levels?[...new Set(s.levels.map(e=>"fatal"===e?"error":e))]:[],h=s.fetch??fetch,p=new AbortController,f=setTimeout(()=>p.abort(new DOMException("window","TimeoutError")),s.timeoutMs??8e3),m=s.signal?AbortSignal.any([p.signal,s.signal]):p.signal,g=(0,i.X)(m),b=()=>p.signal.aborted&&!s.signal?.aborted?A("transient","Vercel's log history didn't answer in time."):A("transient","Reading Vercel's log history was cancelled."),y=[],T=!1;try{for(let n=0;n<3;n++){let i,c=new URLSearchParams({projectId:r,ownerId:t,page:String(n),startDate:String(a),endDate:String(o)});s.deploymentId&&c.set("deploymentId",s.deploymentId),s.environment&&c.set("environment",s.environment),d.length&&c.set("level",d.join(","));let p=null;try{let t=await Promise.race([h(`https://vercel.com/api/logs/request-logs?${c}`,{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"},signal:m,cache:"no-store"}),g]);if(401===t.status||403===t.status)p=A("auth",`Vercel rejected this credential (${t.status}).`,{status:t.status});else if(429===t.status){let e=Number(t.headers.get("Retry-After"));p=A("transient","Vercel says there were too many requests.",{status:429,retryAfterS:Number.isFinite(e)&&e>0?e:60})}else if(400===t.status)p=A("transient","Vercel's log history didn't answer (400); the range may be past retention.",{status:400});else if(t.ok)try{i=await Promise.race([t.json(),g])}catch(e){if(m.aborted)throw e;p=A("format","Vercel's log history answered in a format the console doesn't recognise.")}else p=A("transient",`Vercel's log history returned an error (${t.status}).`,{status:t.status});p&&await t.body?.cancel().catch(()=>void 0)}catch{p=m.aborted?b():A("transient","Couldn't reach Vercel's log history.")}if(!p){let e=v.safeParse(i),t=e.success&&i&&"object"==typeof i?Object.keys(i):[];if(!e.success||t.includes("rows")||t.includes("hasMoreRows"))if(e.success){for(let t of e.data.rows)y.push(...function(e,t,r=!1){let s=k.safeParse(e);if(!s.success)return[];let n=s.data,a={at:n.timestamp,requestMethod:n.requestMethod??null,requestPath:n.requestPath??null,statusCode:n.statusCode??null,deploymentId:n.deploymentId??null,source:(n.events??[]).map(e=>S.safeParse(e)).find(e=>e.success&&e.data.source)?.data?.source??null},i=[],o=new Map;for(let e of n.logs??[]){let r=_.safeParse(e);if(!r.success||!r.data.message)continue;let s=function(e){let t=(e??"").toLowerCase();return"warn"===t?"warning":w.includes(t)?t:"info"}(r.data.level),l=x(s,r.data.message),c=o.get(l)??0;o.set(l,c+1),t(s)&&i.push({rowId:`${n.requestId}:${l}${c?`#${c}`:""}`,level:s,message:r.data.message,...a})}if(null!=n.statusCode&&n.statusCode>=500&&t("error")&&!i.some(e=>"error"===e.level||"fatal"===e.level)&&i.push({rowId:`${n.requestId}:status`,level:"error",message:`${n.requestMethod??"GET"} ${n.requestPath??"/"} → ${n.statusCode}`,...a}),r&&0===i.length){let e=n.statusCode??0,r=e>=500?"error":e>=400?"warning":"info";t(r)&&i.push({rowId:`${n.requestId}:request`,level:r,message:`${n.requestMethod??"GET"} ${n.requestPath??"/"}${e>0?` → ${e}`:""}`,...a})}return i}(t,u,s.requests));if(!(T=e.data.hasMoreRows)||y.length>=l)break}else p=A("format","Vercel's log history answered in a format the console doesn't recognise.");else p=A("transient","Vercel's log format changed: the answer has neither rows nor hasMoreRows.")}if(p){if(0===n)return p;T=!0;break}}}finally{clearTimeout(f),p.abort()}return y.sort((e,t)=>e.at.getTime()-t.at.getTime()),y.length>l&&(y.splice(0,y.length-l),T=!0),{ok:!0,lines:y,more:T}}e.s(["f",0,T],205746);var R=e.i(728335);let E=["warning","error","fatal"],I="logs_read_cursor";async function j(e){let[r]=await (0,n.db)().select().from(a.accounts).where((0,t.and)((0,t.eq)(a.accounts.provider,"vercel"),(0,t.eq)(a.accounts.status,"ok"))).limit(1),s=r?(0,o.V)({ciphertext:r.credentialCiphertext,iv:r.credentialIv},(0,c.serverEnv)().OPS_ENCRYPTION_KEY):null;return r&&s?(await (0,n.db)().select({appId:a.resources.id,appName:a.resources.name,projectId:a.resources.externalId,meta:a.resources.meta,deploymentId:a.deployments.externalId}).from(a.deployments).innerJoin(a.resources,(0,t.eq)(a.resources.id,a.deployments.resourceId)).where((0,t.and)((0,t.eq)(a.deployments.isCurrent,!0),(0,t.eq)(a.resources.accountId,r.id),(0,t.eq)(a.resources.monitored,!0),(0,t.isNull)(a.resources.goneAt),...e?[(0,t.eq)(a.resources.id,e)]:[]))).map(e=>({appId:e.appId,appName:e.appName,projectId:e.projectId,deploymentId:e.deploymentId,teamId:String(e.meta.teamId??""),token:s})):[]}let O=(e,t)=>({resourceId:e.appId,deploymentId:t.deploymentId??e.deploymentId,rowId:t.rowId,at:t.at,level:t.level,message:(0,u.l)((0,u.h)(t.message),2e3),requestMethod:t.requestMethod,requestPath:(0,u.n)(t.requestPath?(0,u.h)(t.requestPath):null),statusCode:t.statusCode,source:t.source});async function C(e,o,c){let u,[d]=await (0,n.db)().select().from(a.settings).where((0,t.eq)(a.settings.key,"logs.disabled")).limit(1);if(d?.value===!0)return;let h=await j(null);if(!h.length)return;let p=(0,R.dayStart)((0,R.dayKey)(e)),f=new Map((await (0,n.db)().select({id:a.storedLogs.resourceId,n:s.sql`count(*)::int`}).from(a.storedLogs).where((0,t.and)((0,t.inArray)(a.storedLogs.resourceId,h.map(e=>e.appId)),(0,t.gte)(a.storedLogs.at,p))).groupBy(a.storedLogs.resourceId)).map(e=>[e.id,e.n])),m=new Map((await (0,n.db)().select({id:a.storedLogs.resourceId,at:(0,r.max)(a.storedLogs.at)}).from(a.storedLogs).where((0,t.inArray)(a.storedLogs.resourceId,h.map(e=>e.appId))).groupBy(a.storedLogs.resourceId)).map(e=>[e.id,e.at])),[g]=await (0,n.db)().select().from(a.settings).where((0,t.eq)(a.settings.key,I)).limit(1),b=(u=g?.value)&&"object"==typeof u&&!Array.isArray(u)?Object.fromEntries(Object.entries(u).filter(e=>"string"==typeof e[1]&&!Number.isNaN(Date.parse(e[1])))):{},y=e.getTime()-864e5,w=await (0,i.P)(h,3,t=>{if(Date.now()+8500>o)return Promise.resolve(null);let r=[m.get(t.appId)?.getTime(),b[t.appId]?Date.parse(b[t.appId]):void 0].filter(e=>void 0!==e),s=new Date(Math.max(r.length?Math.max(...r)-3e5:y,y));return T(t.token,t.teamId,t.projectId,{since:s,until:e,now:e,levels:E,environment:"production",maxRows:300})}),v=h.map((e,t)=>{let r=w[t];return r?r.ok?(r.more&&c.push(`logs/${e.appName}: more than 300 log lines since the last read; the oldest were skipped`),r.lines.filter(e=>E.includes(e.level))):(c.push(`logs/${e.appName}: ${r.error}`),[]):[]}),k=v.flat().map(e=>e.rowId),_=new Set(k.length?(await (0,n.db)().select({rowId:a.storedLogs.rowId}).from(a.storedLogs).where((0,t.inArray)(a.storedLogs.rowId,k))).map(e=>e.rowId):[]),S=[];for(let[e,t]of h.entries()){let r=v[e].filter(e=>!_.has(e.rowId));if(!r.length)continue;let s=f.get(t.appId)??0,i=Math.max(0,1e3-s),o=(i>=r.length?r:r.slice(r.length-i)).map(e=>O(t,e));o.length&&await (0,n.db)().insert(a.storedLogs).values(o).onConflictDoNothing({target:a.storedLogs.rowId}),s+r.length>=1e3&&S.push(t.appId)}let x=h.filter((e,t)=>w[t]?.ok);if(x.length){let t={};for(let e of h)b[e.appId]&&(t[e.appId]=b[e.appId]);for(let r of x)t[r.appId]=e.toISOString();await (0,n.db)().insert(a.settings).values({key:I,value:t}).onConflictDoUpdate({target:a.settings.key,set:{value:t,updatedAt:new Date}})}await (0,l.f)(S.map(e=>({resourceId:e,type:"system",kind:"warn",message:"Stored-log limit reached",detail:"More than 1000 warnings and errors today; the rest stay in Vercel only for its short log history (about a day on Hobby).",reason:"LogCapReached"})))}e.s(["g",0,j,"_",0,C],451682)},486118,e=>{let t;var r,s,n=e.i(547963),a=e.i(804308),i=e.i(515683),o=e.i(25734),l=e.i(27626),c=e.i(64858),u=e.i(248744),d=e.i(379593),h=e.i(423660),p=e.i(717799),f=e.i(336763),m=e.i(396918),g=e.i(406212),b=e.i(530298),y=e.i(503313),w=e.i(595262),v=e.i(638809),k=e.i(732077),_=e.i(908223),S=e.i(328586),x=e.i(406197),A=e.i(964964),T=e.i(736337),R=e.i(974034),E=e.i(958948),I=e.i(348657),j=e.i(198552),O=e.i(205746),C=e.i(760859),$=e.i(518581),P=e.i(633075),N=e.i(108621),D=e.i(809303);let L="waiting: Vercel didn't say which deployment is live";async function U(e){let t=Date.now();try{let r=await fetch(e,{redirect:"manual",signal:AbortSignal.timeout(A.w),cache:"no-store",headers:{"User-Agent":"Watchbell smoke test"}}),s=401===r.status||403===r.status?(await r.text().catch(()=>"")).slice(0,8192):"";return{status:r.status,ms:Date.now()-t,authWall:(0,A.S)(r.status,s,r.headers)}}catch{return{status:null,ms:Date.now()-t,authWall:!1}}}async function q(t,r){let{extensions:s}=await e.A(27505);return await s.runner?.lockfileJobActive(t,r).catch(()=>!1)??!1}let M=null;async function B(e,t){let r=(0,R.Q)(t.meta?.rootDirectory),s=(0,R.H)(r,"package.json"),n=t.lockfilePath??(0,R.H)(r,"package-lock.json");if(M?.token!==e){let t=await (0,I.z)(e);if(!t.ok)return null;M={token:e,login:t.data}}let a=M.login,[i,o]=await Promise.all([(0,I.O)(e,t.fullName,t.number),(0,I.P)(e,t.fullName,t.number)]);if(!i.ok||!o.ok)return null;let l=[];for(let r of o.data.slice(0,A.y+1)){let s=null!==r.login&&r.login.toLowerCase()===a.toLowerCase()?null:await (0,I.h)(e,t.fullName,r.sha);if(s&&!s.ok)return null;l.push({...r,files:s?s.data:null})}let[c,u]=await Promise.all([(0,I.E)(e,t.fullName,t.baseBranch,{},s),(0,I.E)(e,t.fullName,t.headSha,{},s)]);if(!c.ok||!u.ok)return null;let d=c.data&&u.data?(0,A.C)(c.data.text,u.data.text,t.packages):"unexpected change: package.json is missing",h=null;if(n!==s&&i.data.some(e=>e.filename===n||e.previous===n))if((0,I.$)(n)){let[r,s]=await Promise.all([(0,I.l)(e,t.fullName,t.baseBranch,n),(0,I.l)(e,t.fullName,t.headSha,n)]);if(!r.ok||!s.ok)return null;h=(0,A.T)(r.data,s.data,n)}else h=`unexpected lockfile change ${n} (only package-lock.json can be checked)`;return{manifest:s,lockfile:n,lockfileRequired:!!t.lockfilePath,manifestProblem:d,lockfileProblem:h,headSha:t.headSha,tokenLogin:a,files:i.data,commits:l}}async function z(e,t={}){let r=await (t.vercel??F.vercel)(e);if(!r)return null;let s=await (t.serving??j.k)(r.token,r.teamId,r.projectId);if(!s.ok)return null;let n=s.data.currentId,a=null;if(!n){let e=s.data.latest?.readyState??null;if("ERROR"!==e&&"CANCELED"!==e)return null;let i=await (t.running??j.N)(r.token,r.teamId,r.projectId);if(!i.ok||i.data)return null;let o=await (t.ready??j.r)(r.token,r.teamId,r.projectId);if(!o.ok)return null;let l=[...o.data].sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),c=s.data.promote;c?(a=l.find(e=>e.createdAt.getTime()>c.requestedAt)??null)||(n=c.toDeploymentId):a=l[0]??null}if(!a&&n){let e=await (t.deployment??j.S)(r.token,{id:r.teamId,slug:r.teamId,name:r.teamId},n);if(!e.ok)return null;a=e.data}return a?{source:(0,T.s)({source:a.source,branch:a.branch,sha:a.sha,branchFrom:a.branchFrom??null,gitDirty:!0===a.gitDirty})}:null}let F={rows:async()=>await (0,g.db)().select({id:b.dependencyPrs.id,repoId:b.dependencyPrs.repoId,appId:b.dependencyPrs.appId,proposalId:b.dependencyPrs.proposalId,number:b.dependencyPrs.number,branch:b.dependencyPrs.branch,baseBranch:b.dependencyPrs.baseBranch,headSha:b.dependencyPrs.headSha,title:b.dependencyPrs.title,packages:b.dependencyPrs.packages,auto:b.dependencyPrs.auto,stage:b.dependencyPrs.stage,smokeMode:b.dependencyPrs.smokeMode,previewReadyAt:b.dependencyPrs.previewReadyAt,openedAt:b.dependencyPrs.openedAt,fullName:b.githubRepos.fullName,appName:b.resources.name,meta:b.resources.meta,lockfilePath:b.dependencyScans.lockfilePath,appMonitored:b.resources.monitored,appGone:b.resources.goneAt,stageText:b.dependencyPrs.stageText}).from(b.dependencyPrs).innerJoin(b.githubRepos,(0,f.eq)(b.githubRepos.id,b.dependencyPrs.repoId)).leftJoin(b.resources,(0,f.eq)(b.resources.id,b.dependencyPrs.appId)).leftJoin(b.dependencyScans,(0,f.eq)(b.dependencyScans.repoId,b.dependencyPrs.repoId)).where((0,f.inArray)(b.dependencyPrs.stage,[...A.X])).orderBy((0,m.asc)(b.dependencyPrs.openedAt)).limit(10),security:D.X,rollback:D.K,writeToken:async()=>{let e=await (0,_.G)();return e&&"unreadable"!==e?e.token:null},readToken:async e=>{let t=await (0,S.l)(e);return t.ok?t.token:null},vercel:async e=>{let t=await (0,x.p)(e,"app"),r=t?.resource.meta.teamId;return t&&"string"==typeof r&&t.resource.externalId?{token:t.token,teamId:r,projectId:t.resource.externalId}:null},monitorUrls:async e=>(await (0,g.db)().select({url:b.monitors.url}).from(b.monitors).where((0,f.and)((0,f.eq)(b.monitors.resourceId,e),(0,f.eq)(b.monitors.kind,"http"))).limit(10)).map(e=>e.url),pull:I.b,checks:I.s,runs:E.L,previews:j.C,probe:U,errorLogs:async(e,t,r,s)=>{let n=await (0,O.f)(e.token,e.teamId,e.projectId,{since:r,until:s,now:s,deploymentId:t,levels:["error","fatal"],maxRows:20,timeoutMs:8e3});return n.ok?n.lines.length:null},merge:I.C,review:B,save:async(e,t,r,s)=>{await (0,g.db)().update(b.dependencyPrs).set({...t,stageText:s,checkedAt:new Date}).where((0,f.eq)(b.dependencyPrs.id,e)),r&&await (0,g.db)().update($.O).set({result:s}).where((0,f.eq)($.O.id,r)).catch(()=>void 0)},notify:e=>(0,N.y)(e),liveSource:e=>z(e),lockfileBusy:async(e,t,r)=>await q(e,t)||await (0,k.W)(r,t),audit:(e,t)=>(0,w.f)({kind:"ok",message:e,resourceId:t,actorUserId:null}),book:()=>(0,y.f)()};async function W(e,t,r=F){let s={watched:0,merged:0,stopped:0},n=()=>t-Date.now(),a=await r.rows();if(!a.length)return s;let[i,o,l]=await Promise.all([r.security().catch(()=>null),r.rollback().catch(()=>null),r.writeToken().catch(()=>null)]);if(!l)return s;let c=await r.book().catch(()=>C.a);for(let t of a){if(15e3>n())break;if(t.auto||i?.enabled)try{let n=await H(t,e,l,o?.enabled===!0,r);if(!n)continue;s.watched++;let a=t.appName?(0,C.r)(c,t.appName):"app";await K(t,n,a,o?.windowMin??30,e,l,r,s)}catch(e){console.warn("deps/watch failed:",e instanceof Error?e.name:"error")}}return s}async function H(e,t,r,s,n){let a=await n.pull(r,e.fullName,e.number);if(!a.ok)return null;let i=await n.checks(r,e.fullName,a.data.headSha),o=null;if(i.ok&&null===i.data.checkRuns&&e.appId){let t=await n.readToken(e.appId),r=t?await n.runs(t,e.fullName,a.data.headSha):null;o=r?.ok?r.data:null}i.ok||(i={ok:!0,data:{checkRuns:[{status:"queued",conclusion:null}],combined:null}});let l=(0,A.j)({...i.data,actionRuns:o}),c={state:null,readyAt:null},u=null,d=e.appId?await n.vercel(e.appId):null;if(d&&"success"===l&&a.data.headSha===e.headSha){let r=await n.previews(d.token,d.teamId,d.projectId,a.data.headSha),s=r.ok?r.data.find(e=>"preview"===e.target)??r.data[0]??null:null;if(s&&(c={state:s.state,readyAt:s.readyAt??("ready"===s.state?t:null)},"ready"===s.state&&s.url)){let r=e.previewReadyAt??c.readyAt??t;if("logs"!==e.smokeMode){let t=(0,A.E)(e.appId?await n.monitorUrls(e.appId):[]),r=await Promise.all(t.map(async e=>({path:e,...await n.probe(`https://${s.url}${e}`)})));u=(0,A.L)(r)}u||(u=(0,A.n)(r,t,await n.errorLogs(d,s.id,r,t).catch(()=>null))),c.readyAt=r}}return{step:(0,A.M)({now:t,openedAt:e.openedAt,pr:{state:a.data.state,merged:a.data.merged,mergeable:a.data.mergeable,headSha:a.data.headSha,base:a.data.base},recordedSha:e.headSha,recordedBase:e.baseBranch,checks:l,preview:c,smoke:u,autoRollbackOn:s}),smoke:u,previewReadyAt:c.readyAt,headSha:a.data.headSha}}function G(e,t){if(!e.appId||!1===e.appMonitored||e.appGone)return"the app is gone or no longer watched, so Watchbell can't confirm what production is built from. Merging this PR could replace what is live";let r=(0,T.B)(e.meta?.productionSource,e.baseBranch,t);if(r)return r;let s=(0,T.O)(e.meta?.productionSource),n=e.meta?.productionBranch;return s?.kind==="git"&&s.ref===e.baseBranch&&"string"==typeof n&&n!==e.baseBranch?`Merging into ${e.baseBranch} won't deploy to production by itself: production was promoted from a ${e.baseBranch} preview. Merge, then promote the new preview.`:null}async function K(e,t,r,s,n,a,i,o){let{step:l}=t,c=t.smoke?{smokeMode:t.smoke.mode}:{},u=t.previewReadyAt?{previewReadyAt:t.previewReadyAt}:{},d={app:r,number:e.number,packages:e.packages};if("wait"===l.kind)return void await i.save(e.id,{stage:l.stage,...c,...u,...l.resetSha?{headSha:l.resetSha,previewReadyAt:null,smokeMode:null}:{}},e.proposalId,(0,A.m)(e.number,l.stage,l.reason));if("done"===l.kind)return void await i.save(e.id,{stage:l.stage,finishedAt:n},e.proposalId,(0,A.m)(e.number,l.stage));if("stop"===l.kind&&("CI gagal"===l.reason||"CI failed"===l.reason)&&await i.lockfileBusy?.(e.repoId,e.branch,e.fullName).catch(()=>!1))return void await i.save(e.id,{stage:"checks"},e.proposalId,(0,A.m)(e.number,"checks","waiting for the lockfile from the runner"));let h=async t=>{await i.save(e.id,{stage:"failed",finishedAt:n,...c},e.proposalId,(0,A.m)(e.number,"failed",t)),o.stopped++,await i.notify({...d,kind:"stopped",reason:t.replace(/\.$/,"")}).catch(()=>void 0)},p="merge"===l.kind||"stop"===l.kind&&"ready-manual"===l.stage?G(e,n):null;if(p)return h(p);let f=async()=>{let r=e.appId?await i.liveSource(e.appId).catch(()=>null):null;if(!r){let r=t.previewReadyAt??e.previewReadyAt??e.openedAt;if((e.stageText??"").includes(L)&&n.getTime()-r.getTime()>A.R)return await h("Vercel didn't say which deployment is live for 45 minutes, so Watchbell can't confirm what production is built from. Check it, then merge yourself"),!0;let s="checks"===e.stage||"preview"===e.stage||"smoke"===e.stage?e.stage:"smoke";return await i.save(e.id,{stage:s,...c,...u},e.proposalId,(0,A.m)(e.number,s,L)),!0}let s=r.source?G({...e,meta:{...e.meta??{},productionSource:{...r.source,at:n.toISOString()}}},n):`Watchbell can't confirm what production is built from (Vercel names no branch for it). Merging this PR could deploy ${e.baseBranch} to production and replace what is live.`;return!!s&&(await h(s),!0)};if("stop"===l.kind&&"ready-manual"===l.stage&&await f())return;if("stop"===l.kind){await i.save(e.id,{stage:l.stage,finishedAt:n,...c},e.proposalId,(0,A.m)(e.number,l.stage,"ready-manual"===l.stage?null:l.reason)),o.stopped++,await i.notify({...d,kind:"ready-manual"===l.stage?"ready-manual":"stopped",reason:l.reason}).catch(()=>void 0);return}let m=await i.review(a,e).catch(()=>null);if(!m)return;let g=(0,A.k)(m);if(!g&&(0,A.H)(m)&&n.getTime()-e.openedAt.getTime()>A.R){let t="the lockfile wasn't added within 45 minutes";await i.save(e.id,{stage:"timeout",finishedAt:n,...c},e.proposalId,(0,A.m)(e.number,"timeout",t)),o.stopped++,await i.notify({...d,kind:"stopped",reason:t}).catch(()=>void 0);return}if(!g&&(0,A.H)(m))return void await i.save(e.id,{stage:"checks"},e.proposalId,(0,A.m)(e.number,"checks","waiting for the lockfile"));if(g){await i.save(e.id,{stage:"failed",finishedAt:n,...c},e.proposalId,(0,A.m)(e.number,"failed",g)),o.stopped++,await i.notify({...d,kind:"stopped",reason:g}).catch(()=>void 0);return}if(await f())return;await i.save(e.id,{stage:"merging",...c,...u},e.proposalId,(0,A.m)(e.number,"merging"));let b=await i.merge(a,e.fullName,e.number,e.branch,e.baseBranch,e.headSha,e.title);if(b.ok){await i.save(e.id,{stage:"merged",mergedSha:b.data.sha,finishedAt:n},e.proposalId,(0,A.m)(e.number,"merged")),o.merged++,await i.audit(`${P.v}PR #${e.number} merged \xb7 ${e.packages.join(", ")}`.slice(0,200),e.appId).catch(()=>void 0),await i.notify({...d,kind:"merged",windowMin:s}).catch(()=>void 0);return}if(409===b.status)return void await i.save(e.id,{stage:"checks"},e.proposalId,(0,A.m)(e.number,"checks","new commit on the PR branch, checking again"));let y=405===b.status?"GitHub refused the merge (cannot be merged)":`merge failed: ${b.error}`.slice(0,150);await i.save(e.id,{stage:"failed",finishedAt:n},e.proposalId,(0,A.m)(e.number,"failed",y)),o.stopped++,await i.notify({...d,kind:"stopped",reason:y}).catch(()=>void 0)}let J=null;async function V(e,t,r=v.I){if((0,A.f)(e,J)&&!(await r()).has("devops")){J=e.getTime();try{let r=await W(e,t?.deadline??e.getTime()+5e4);r.watched&&console.log(`deps/watch: ${r.watched} PR, ${r.merged} merged, ${r.stopped} stopped`)}catch(e){console.warn("deps/watch failed:",e instanceof Error?e.name:"error")}}}var Y=e.i(653587),X=e.i(452475);let Z={nav:[{section:"manage",after:"backups",items:[{key:"ai",label:"AI Gateway",href:"/ai",icon:"route",stage:5,ownerOnly:!0,sub:"AI & API"},{key:"api-docs",label:"API explorer",href:"/api-docs",icon:"api",stage:5,ownerOnly:!0,sub:"AI & API"}]}],palette:[{label:"AI Gateway",href:"/ai",keywords:["ai","gateway","overview"]},{label:"API keys",href:"/ai/keys",keywords:["key","token","wb_","wp_"]},{label:"Agents",href:"/ai/agents",keywords:["agent","client","mcp"]},{label:"Connect an agent",href:"/ai/connect",keywords:["mcp",...n.I.palette.connectKeywords,"gemini cli","quick start"]},{label:"Bring your own key",href:"/ai/providers",keywords:["provider","byok","cloudflare","groq","openrouter","gemini"]},{label:"Quota",href:"/ai/quota",keywords:["limit","usage","rate"]},{label:"AI logs",href:"/ai/logs",keywords:["logs","requests","usage"]},{label:"Models",href:"/ai/models",keywords:["model","llm"]},{label:"Playground",href:"/ai/playground",keywords:["chat","try","prompt"]},{label:"API explorer",href:"/api-docs",keywords:["openapi","swagger","api","v1"]}]},Q={dailySteps:[{name:"ai-usage-retention",run:i.$}]},ee={WhyAiSlot:d.f,RecSummarySlot:u.f,AiNotesSlot:c.f,dailySteps:[{name:"advisor-summary",run:l.f}],minuteSteps:[{name:"advisor-notes",run:o.f}]},et={dailySteps:[{name:"ai-notes-retention",run:h.v}]},er={nav:[{section:"manage",after:"alerts",items:[{key:"auto-actions",label:"Auto-actions",href:"/auto-actions",icon:"bolt",stage:9,ownerOnly:!0,sub:"Alerting"}]}],palette:[{label:"Auto-actions",href:"/auto-actions",keywords:["proposal","approve","reject","auto-run","rollback"]}],dailySteps:[{name:"auto-actions-retention",run:Y.t}],minuteSteps:[{name:"auto-actions",run:Y.Z},{name:"deps-pr-watch",run:V}],settingsTabs:[{key:"office-auto-run",label:"Auto-actions",Tab:p.f}]},es={telegramCallback:X.proposalCallback},en=function(...e){let t={nav:[],palette:[]};for(let r of e){for(let e of r.nav??[]){let r=t.nav.find(t=>t.section===e.section&&t.after===e.after);r?r.items=[...r.items,...e.items]:t.nav.push({...e,items:[...e.items]})}t.palette.push(...r.palette??[]),r.dailySteps?.length&&(t.dailySteps=[...t.dailySteps??[],...r.dailySteps]),r.minuteSteps?.length&&(t.minuteSteps=[...t.minuteSteps??[],...r.minuteSteps]),r.WhyAiSlot&&(t.WhyAiSlot=r.WhyAiSlot),r.RecSummarySlot&&(t.RecSummarySlot=r.RecSummarySlot),r.AiNotesSlot&&(t.AiNotesSlot=r.AiNotesSlot),r.DevNotesSlot&&(t.DevNotesSlot=r.DevNotesSlot),r.office&&(t.office=r.office),r.settingsTabs?.length&&(t.settingsTabs=[...t.settingsTabs??[],...r.settingsTabs]),r.telegramCallback&&(t.telegramCallback=r.telegramCallback),r.runner&&(t.runner=r.runner),r.RepoPreviewSlot&&(t.RepoPreviewSlot=r.RepoPreviewSlot)}return t}({...Z,palette:(r=Z.palette??[],s={label:"Ask AI",href:"/ai/ask",keywords:["ask","question","answer"]},(t=r.findIndex(e=>"/ai"===e.href))<0?[...r,s]:[...r.slice(0,t+1),s,...r.slice(t+1)])},{dailySteps:[{name:"ai-agents-prune",run:()=>(0,a.f)()}]},Q,{},{},et,er,ee,es);e.s(["extensions",0,en],486118)},667378,e=>{var t=e.i(978196);e.s(["f",0,function(e,r,s){let n=(0,t.Y)(e);if(!n)return{lines:[{name:s,tag:null,target:null}],more:0};let a=[n.primaryDomain,...n.domains.filter(e=>e!==n.primaryDomain)].filter((e,t,r)=>r.indexOf(e)===t),i=[...new Set(n.pastDomains)].filter(e=>!a.includes(e)).reverse(),o=a.map((e,t)=>{let s=r[e],n={name:e,target:s?.redirect?s.redirect.replace(/^https?:\/\//i,"").replace(/\/.*$/,"").toLowerCase():null};return 0===t?{...n,tag:a.length>1||i.length?"primary":null}:{...n,tag:s?.redirect?"redirect":s&&!s.verified?"pending":null}});return o.push(...i.slice(0,3).map(e=>({name:e,tag:"former",target:null}))),{lines:o,more:Math.max(0,i.length-3)}}])},178233,e=>{let t=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0?e:null;e.s(["G",0,function(e){let r=e&&"object"==typeof e?e.pageviews:null;if(!r||"object"!=typeof r)return null;let s="string"==typeof r.readAt?Date.parse(r.readAt):0/0;if(Number.isNaN(s)||"boolean"!=typeof r.enabled)return null;if(!r.enabled)return{enabled:!1,readAt:new Date(s)};let n=t(r.total24h),a=null===r.visitors24h?null:t(r.visitors24h);if(null===n||null===a&&null!==r.visitors24h)return null;let i=36e5*Math.floor(s/36e5),o=new Map;for(let e of Array.isArray(r.hourly)?r.hourly:[]){if(!Array.isArray(e))continue;let r="string"==typeof e[0]?Date.parse(e[0]):0/0,s=t(e[1]);if(Number.isNaN(r)||null===s)continue;let n=36e5*Math.floor(r/36e5);o.set(n,(o.get(n)??0)+s)}return{enabled:!0,total:n,visitors:a,hours:Array.from({length:24},(e,t)=>{let r=i-(23-t)*36e5;return{at:new Date(r),views:o.get(r)??0}}),readAt:new Date(s)}},"R",0,function(e){return!e.gone&&e.teamId&&e.accountOk?e.hasProductionDeploy?null:"Not read: this app has no production deployment yet.":"Not read: this app isn't in a connected Vercel account."},"Z",0,function(e,t){return e.enabled?{enabled:!0,total24h:e.total,visitors24h:e.visitors,readAt:t.toISOString(),hourly:e.hourly.slice(-24).map(e=>[e.at.toISOString(),e.views])}:{enabled:!1,readAt:t.toISOString()}}])},530831,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call AutoRollbackForm() from the server but AutoRollbackForm is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/actions/auto-rollback-form.tsx","AutoRollbackForm");e.s(["AutoRollbackForm",0,t])},657753,e=>{var t=e.i(530831);e.n(t)},842941,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call AutoRunForm() from the server but AutoRunForm is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/actions/auto-run-form.tsx","AutoRunForm");e.s(["AutoRunForm",0,t])},27295,e=>{var t=e.i(842941);e.n(t)},699286,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call AutoSecurityForm() from the server but AutoSecurityForm is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/actions/auto-security-form.tsx","AutoSecurityForm");e.s(["AutoSecurityForm",0,t])},783671,e=>{var t=e.i(699286);e.n(t)},804308,515683,585585,e=>{let t,r,s,n,a;var i=e.i(533102),o=e.i(406212);e.i(333407);var l=e.i(518581);async function c(){await (0,o.db)().execute(i.sql`
1
+ module.exports=[[132245,(e,t,r)=>{function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}r._=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var o=a?Object.getOwnPropertyDescriptor(e,i):null;o&&(o.get||o.set)?Object.defineProperty(n,i,o):n[i]=e[i]}return n.default=e,r&&r.set(e,n),n}},738458,(e,t,r)=>{let s;Object.defineProperty(r,"__esModule",{value:!0}),r.parseCookie=d,r.parse=d,r.stringifyCookie=function(e,t){let r=t?.encode||encodeURIComponent,s=[];for(let t of Object.keys(e)){let i=e[t];if(void 0===i)continue;if(!n.test(t))throw TypeError(`cookie name is invalid: ${t}`);let o=r(i);if(!a.test(o))throw TypeError(`cookie val is invalid: ${i}`);s.push(`${t}=${o}`)}return s.join("; ")},r.stringifySetCookie=h,r.serialize=h,r.parseSetCookie=function(e,t){let r=t?.decode||g,s=e.length,n=p(e,0,s),a=f(e,0,n),i=-1===a?{name:"",value:r(m(e,0,n))}:{name:m(e,0,a),value:r(m(e,a+1,n))},o=n+1;for(;o<s;){let t=p(e,o,s),r=f(e,o,t),n=-1===r?m(e,o,t):m(e,o,r),a=-1===r?void 0:m(e,r+1,t);switch(n.toLowerCase()){case"httponly":i.httpOnly=!0;break;case"secure":i.secure=!0;break;case"partitioned":i.partitioned=!0;break;case"domain":i.domain=a;break;case"path":i.path=a;break;case"max-age":a&&l.test(a)&&(i.maxAge=Number(a));break;case"expires":if(!a)break;let c=new Date(a);Number.isFinite(c.valueOf())&&(i.expires=c);break;case"priority":if(!a)break;let u=a.toLowerCase();("low"===u||"medium"===u||"high"===u)&&(i.priority=u);break;case"samesite":if(!a)break;let d=a.toLowerCase();("lax"===d||"strict"===d||"none"===d)&&(i.sameSite=d)}o=t+1}return i},r.stringifySetCookie=h,r.serialize=h;let n=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,a=/^[\u0021-\u003A\u003C-\u007E]*$/,i=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,o=/^[\u0020-\u003A\u003D-\u007E]*$/,l=/^-?\d+$/,c=Object.prototype.toString,u=((s=function(){}).prototype=Object.create(null),s);function d(e,t){let r=new u,s=e.length;if(s<2)return r;let n=t?.decode||g,a=0;do{let t=f(e,a,s);if(-1===t)break;let i=p(e,a,s);if(t>i){a=e.lastIndexOf(";",t-1)+1;continue}let o=m(e,a,t);void 0===r[o]&&(r[o]=n(m(e,t+1,i))),a=i+1}while(a<s)return r}function h(e,t,r){let s="object"==typeof e?e:{...r,name:e,value:String(t)},l=("object"==typeof t?t:r)?.encode||encodeURIComponent;if(!n.test(s.name))throw TypeError(`argument name is invalid: ${s.name}`);let u=s.value?l(s.value):"";if(!a.test(u))throw TypeError(`argument val is invalid: ${s.value}`);let d=s.name+"="+u;if(void 0!==s.maxAge){if(!Number.isInteger(s.maxAge))throw TypeError(`option maxAge is invalid: ${s.maxAge}`);d+="; Max-Age="+s.maxAge}if(s.domain){if(!i.test(s.domain))throw TypeError(`option domain is invalid: ${s.domain}`);d+="; Domain="+s.domain}if(s.path){if(!o.test(s.path))throw TypeError(`option path is invalid: ${s.path}`);d+="; Path="+s.path}if(s.expires){var h;if(h=s.expires,"[object Date]"!==c.call(h)||!Number.isFinite(s.expires.valueOf()))throw TypeError(`option expires is invalid: ${s.expires}`);d+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(d+="; HttpOnly"),s.secure&&(d+="; Secure"),s.partitioned&&(d+="; Partitioned"),s.priority)switch("string"==typeof s.priority?s.priority.toLowerCase():void 0){case"low":d+="; Priority=Low";break;case"medium":d+="; Priority=Medium";break;case"high":d+="; Priority=High";break;default:throw TypeError(`option priority is invalid: ${s.priority}`)}if(s.sameSite)switch("string"==typeof s.sameSite?s.sameSite.toLowerCase():s.sameSite){case!0:case"strict":d+="; SameSite=Strict";break;case"lax":d+="; SameSite=Lax";break;case"none":d+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${s.sameSite}`)}return d}function p(e,t,r){let s=e.indexOf(";",t);return -1===s?r:s}function f(e,t,r){let s=e.indexOf("=",t);return s<r?s:-1}function m(e,t,r){let s=t,n=r;do{let t=e.charCodeAt(s);if(32!==t&&9!==t)break}while(++s<n)for(;n>s;){let t=e.charCodeAt(n-1);if(32!==t&&9!==t)break;n--}return e.slice(s,n)}function g(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}},63493,e=>{var t=e.i(31194);e.n(t)},133791,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0});var s={default:function(){return l},useLinkStatus:function(){return o.useLinkStatus}};for(var n in s)Object.defineProperty(r,n,{enumerable:!0,get:s[n]});let a=e.r(132245),i=e.r(133210),o=a._(e.r(63493));function l(e){let t=e.legacyBehavior,r="string"==typeof e.children||"number"==typeof e.children||"string"==typeof e.children?.type,s=e.children?.type?.$$typeof===Symbol.for("react.client.reference");return!t||r||s||(e.children?.type?.$$typeof===Symbol.for("react.lazy")?console.error("Using a Lazy Component as a direct child of `<Link legacyBehavior>` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's `<a>` tag."):console.error("Using a Server Component as a direct child of `<Link legacyBehavior>` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's `<a>` tag.")),(0,i.jsx)(o.default,{...e})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},385585,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"after",{enumerable:!0,get:function(){return a}});let s=e.r(556704),n=e.r(832319);function a(e){let t=s.workAsyncStorage.getStore(),r=n.workUnitAsyncStorage.getStore();if(!t||!r)throw Error("`after` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context");let{afterContext:a}=t;return a.after(e,r)}},910473,(e,t,r)=>{var s,n;Object.defineProperty(r,"__esModule",{value:!0}),s=e.r(385585),n=r,Object.keys(s).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})})},476550,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"connection",{enumerable:!0,get:function(){return d}});let s=e.r(556704),n=e.r(832319),a=e.r(258200),i=e.r(183589),o=e.r(225176),l=e.r(679847);e.r(865832);let c=e.r(585346),u=e.r(748448);function d(){let e=s.workAsyncStorage.getStore(),t=n.workUnitAsyncStorage.getStore();if(e){if(t&&!(0,l.isRequestApiAllowedInCurrentPhase)(t))throw Error(`Route ${e.route} used \`connection()\` inside \`after()\` while rendering. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but \`after()\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`);if(e.forceStatic)return Promise.resolve(void 0);if(e.dynamicShouldError)throw new i.StaticGenBailoutError(`Route ${e.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`connection()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`);if(t)switch(t.type){case"cache":{let t=(0,u.createConnectionInPublicUseCacheError)(e.route);throw Error.captureStackTrace(t,d),(0,o.applyOwnerStack)(t),e.invalidDynamicUsageError??=t,t}case"private-cache":{let t=(0,u.createConnectionInPrivateUseCacheError)(e.route);throw Error.captureStackTrace(t,d),(0,o.applyOwnerStack)(t),e.invalidDynamicUsageError??=t,t}case"unstable-cache":throw(0,u.createConnectionInUnstableCacheError)(e.route);case"build-time-generator":throw Error(`Route ${e.route} used \`connection()\` inside \`${t.functionName}\`. This is not supported because \`${t.functionName}\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context`);case"prerender":case"prerender-client":case"prerender-runtime":return(0,o.makeDynamicHangingPromise)(t.renderSignal,e.route,"`connection()`");case"validation-client":{let e="`connection`";throw new c.InvariantError(`${e} must not be used within a Client Component. Next.js should be preventing ${e} from being included in Client Components statically, but did not in this case.`)}case"prerender-legacy":return(0,a.throwToInterruptStaticGeneration)("connection",e,t);case"request":if((0,a.trackDynamicDataInDynamicRender)(t),t.asyncApiPromises)return t.asyncApiPromises.connection;return Promise.resolve(void 0)}}(0,n.throwForMissingRequestStore)("connection")}},133210,(e,t,r)=>{t.exports=e.r(307450).vendored["react-rsc"].ReactJsxRuntime},310086,(e,t,r)=>{t.exports=e.r(307450).vendored["react-rsc"].ReactServerDOMTurbopackServer},853702,(e,t,r)=>{function s(){throw Error('ImageResponse moved from "next/server" to "next/og" since Next.js 14, please import from "next/og" instead')}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"ImageResponse",{enumerable:!0,get:function(){return s}})},628661,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"NextResponse",{enumerable:!0,get:function(){return d}});let s=e.r(86547),n=e.r(723866),a=e.r(287790),i=e.r(770956),o=e.r(86547),l=Symbol("internal response"),c=new Set([301,302,303,307,308]);function u(e,t){var r;if(null==e||null==(r=e.request)?void 0:r.headers){if(!(e.request.headers instanceof Headers))throw Error("request.headers must be an instance of Headers");let r=[];for(let[s,n]of e.request.headers)t.set("x-middleware-request-"+s,n),r.push(s);t.set("x-middleware-override-headers",r.join(","))}}class d extends Response{constructor(e,t={}){super(e,t);let r=this.headers,c=new Proxy(new o.ResponseCookies(r),{get(e,n,a){switch(n){case"delete":case"set":return(...a)=>{let i=Reflect.apply(e[n],e,a),l=new Headers(r);return i instanceof o.ResponseCookies&&r.set("x-middleware-set-cookie",i.getAll().map(e=>(0,s.stringifyCookie)(e)).join(",")),u(t,l),i};default:return i.ReflectAdapter.get(e,n,a)}}});this[l]={cookies:c,url:t.url?new n.NextURL(t.url,{headers:(0,a.toNodeOutgoingHttpHeaders)(r),nextConfig:t.nextConfig}):void 0}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,url:this.url,body:this.body,bodyUsed:this.bodyUsed,headers:Object.fromEntries(this.headers),ok:this.ok,redirected:this.redirected,status:this.status,statusText:this.statusText,type:this.type}}get cookies(){return this[l].cookies}static json(e,t){let r=Response.json(e,t);return new d(r.body,r)}static redirect(e,t){let r="number"==typeof t?t:(null==t?void 0:t.status)??307;if(!c.has(r))throw RangeError('Failed to execute "redirect" on "response": Invalid status code');let s="object"==typeof t?t:{},n=new Headers(null==s?void 0:s.headers);return n.set("Location",(0,a.validateURL)(e)),new d(null,{...s,headers:n,status:r})}static rewrite(e,t){let r=new Headers(null==t?void 0:t.headers);return r.set("x-middleware-rewrite",(0,a.validateURL)(e)),u(t,r),new d(null,{...t,headers:r})}static next(e){let t=new Headers(null==e?void 0:e.headers);return t.set("x-middleware-next","1"),u(e,t),new d(null,{...e,headers:t})}}},374644,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"URLPattern",{enumerable:!0,get:function(){return s}});let s="u"<typeof URLPattern?void 0:URLPattern},276870,(e,t,r)=>{Object.defineProperty(r,"__esModule",{value:!0});var s,n={isBot:function(){return o},userAgent:function(){return c},userAgentFromString:function(){return l}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=(s=e.r(547850))&&s.__esModule?s:{default:s};function o(e){return/Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Google-InspectionTool|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver|GPTBot/i.test(e)}function l(e){return{...(0,i.default)(e),isBot:void 0!==e&&o(e)}}function c({headers:e}){return l(e.get("user-agent")||void 0)}},352565,e=>{var t=e.i(310086);(0,t.registerClientReference)(function(){throw Error("Attempted to call AliasProvider() from the server but AliasProvider is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","AliasProvider"),(0,t.registerClientReference)(function(){throw Error("Attempted to call DbName() from the server but DbName is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","DbName"),(0,t.registerClientReference)(function(){throw Error("Attempted to call Masked() from the server but Masked is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","Masked");let r=(0,t.registerClientReference)(function(){throw Error("Attempted to call MaskedText() from the server but MaskedText is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","MaskedText");(0,t.registerClientReference)(function(){throw Error("Attempted to call Reveal() from the server but Reveal is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","Reveal"),(0,t.registerClientReference)(function(){throw Error("Attempted to call maskedValue() from the server but maskedValue is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","maskedValue"),(0,t.registerClientReference)(function(){throw Error("Attempted to call useAliasBook() from the server but useAliasBook is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","useAliasBook"),(0,t.registerClientReference)(function(){throw Error("Attempted to call useMask() from the server but useMask is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","useMask"),(0,t.registerClientReference)(function(){throw Error("Attempted to call usePrivacy() from the server but usePrivacy is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/alias.tsx","usePrivacy"),e.s(["MaskedText",0,r])},639307,e=>{var t=e.i(352565);e.n(t)},455891,e=>{var t=e.i(336763),r=e.i(75064),s=e.i(492973),n=e.i(79322),a=e.i(909592),i=e.i(406212),o=e.i(530298),l=e.i(27479),c=e.i(728335);let u=e=>{let t=(0,c.calendarDate)(e);return`${t.day} ${t.month} ${t.year}`},d=c.dayKey;var h=e.i(857799),p=e.i(123076),f=e.i(70377),m=e.i(586307),g=e.i(827439);let b="advisor.latest",y=r.z.object({key:s.z.string(),severity:n.z.enum(["warning","info"]),appId:s.z.string().nullable(),subject:s.z.string(),title:s.z.string(),why:s.z.string(),fix:s.z.string(),href:s.z.string()}),w=r.z.object({at:s.z.string(),items:a.z.array(y)});async function v(e){let r=(0,t.and)((0,t.eq)(o.resources.kind,"app"),(0,t.eq)(o.resources.monitored,!0),(0,t.isNull)(o.resources.goneAt)),s=await (0,g.P)(),n=await (0,m.V)(),[a,c,u,d,b]=await Promise.all([(0,i.db)().select({id:o.monitors.id,appId:o.monitors.resourceId,appName:o.resources.name,url:o.monitors.url,kind:o.monitors.kind,name:o.monitors.name,paused:o.monitors.paused,ownerPaused:o.monitors.ownerPaused,lastStatus:o.monitors.lastStatus,expectedStatus:o.monitors.expectedStatus,lastPingAt:o.monitors.lastPingAt,createdAt:o.monitors.createdAt}).from(o.monitors).innerJoin(o.resources,(0,t.eq)(o.resources.id,o.monitors.resourceId)).where(r).orderBy(o.resources.name,o.monitors.url).limit(f.O.monitors),(0,i.db)().select({id:o.resources.id,name:o.resources.name,version:o.appSecurity.version}).from(o.resources).innerJoin(o.appSecurity,(0,t.eq)(o.appSecurity.resourceId,o.resources.id)).where(r).orderBy(o.resources.name).limit(f.O.apps),(0,i.db)().select({id:o.resources.id,name:o.resources.name,kind:o.resources.kind,accountId:o.resources.accountId,accountLabel:o.accounts.label,state:o.snapshots.state}).from(o.resources).innerJoin(o.accounts,(0,t.eq)(o.accounts.id,o.resources.accountId)).leftJoin(o.snapshots,(0,t.eq)(o.snapshots.resourceId,o.resources.id)).where((0,t.and)((0,t.inArray)(o.resources.kind,[...h.H]),(0,t.eq)(o.resources.monitored,!0),(0,t.isNull)(o.resources.goneAt))).orderBy(o.resources.name).limit(f.O.databases),(0,i.db)().select({appId:o.links.fromResourceId,dbId:o.links.toResourceId}).from(o.links).where((0,t.eq)(o.links.kind,"uses_db")).limit(f.O.apps),(0,i.db)().select({id:o.accounts.id,provider:o.accounts.provider,label:o.accounts.label,expiresAt:o.accounts.expiresAt,scopeNote:o.accounts.scopeNote}).from(o.accounts).orderBy(o.accounts.label).limit(200)]);return{now:e,monitors:a.map(e=>({id:e.id,appId:e.appId,appName:e.appName,path:"heartbeat"===e.kind?e.url:(0,l.K)(e.url),kind:e.kind,name:e.name,paused:e.paused||e.ownerPaused,lastStatus:e.lastStatus,expectedStatus:e.expectedStatus,lastPingAt:e.lastPingAt,createdAt:e.createdAt})),eol:function(e,t){if(!t)return null;let r=t.cycles.find(e=>!e.isEol)?.latest??null,s=[];for(let n of e){let e=n.version?.split(".")[0],a=e?t.cycles.find(t=>t.name===e):void 0;a&&s.push({appId:n.id,appName:n.name,cycle:a.name,eolFrom:a.eolFrom?new Date(`${a.eolFrom}T00:00:00Z`):null,latest:r})}return s}(c,s),headers:null,dbs:u.map(e=>({id:e.id,name:e.name,provider:(0,h.Z)(e.kind),accountId:e.accountId,accountLabel:e.accountLabel,state:e.state??"unknown"})),slots:(0,p.f)(n).map(e=>({account:e.account,used:e.used,total:e.total,planUnknown:e.planUnknown})),links:d,accounts:b}}async function k(e){let t=function(e){let t=[];for(let r of e.eol??[]){if(!r.eolFrom||r.eolFrom.getTime()-e.now.getTime()>2592e6)continue;let s=r.eolFrom.getTime()<=e.now.getTime(),n=r.latest?.split(".")[0];t.push({key:`next-eol:${r.appId}:${r.cycle}`,severity:"warning",appId:r.appId,subject:r.appName,title:`Next.js ${r.cycle} ${s?"reached":"reaches"} end of life on ${u(r.eolFrom)}`,why:`No security fixes after that date.${r.latest?` Latest is ${r.latest}.`:""}`,fix:n?`Upgrade to Next.js ${n}.`:"Upgrade Next.js.",href:"https://endoflife.date/nextjs"})}for(let r of e.monitors)!r.paused&&("heartbeat"===r.kind&&!r.lastPingAt&&e.now.getTime()-r.createdAt.getTime()>864e5&&t.push({key:`hb-silent:${r.id}`,severity:"warning",appId:r.appId,subject:r.appName,title:`${r.name??"A heartbeat"} has never pinged`,why:"It was added more than a day ago and no job has called its URL.",fix:"Add the ping to the job, or delete the monitor.",href:"/uptime"}),"http"===r.kind&&"/"===r.path&&200===r.expectedStatus&&null!==r.lastStatus&&[401,403,404].includes(r.lastStatus)&&t.push({key:`monitor-root:${r.id}:${r.lastStatus}`,severity:"info",appId:r.appId,subject:r.appName,title:`The monitor on / answers ${r.lastStatus}`,why:`A login or missing page answering ${r.lastStatus} makes the monitor look down.`,fix:`Point the monitor at a public health route, or expect ${r.lastStatus}.`,href:"/uptime"}));for(let r of e.headers??[]){if(!r.missing.length)continue;let e=[...r.missing].sort();t.push({key:`headers:${r.appId}:${e.join(",")}`,severity:"info",appId:r.appId,subject:r.appName,title:`Missing security headers: ${e.join(", ")}`,why:"Browsers use them to block clickjacking, sniffing and downgrade attacks.",fix:"Add them in next.config headers().",href:"https://developer.mozilla.org/en-US/observatory"})}for(let r of e.slots??[])r.used<r.total||t.push({key:`no-slot:${r.account}`,severity:"warning",appId:null,subject:`supabase \xb7 ${r.account}`,title:`Account ${r.account} has no free slot`,why:r.planUnknown?"Two projects are active. If this account is on the free plan (it couldn't be read), a paused one can't be restored here.":"Both free projects are active, so a paused one can't be restored here.",fix:"Pause one project, or move one to another account.",href:"/supabase"});if(e.dbs&&e.links){let r=new Set(e.links.map(e=>e.dbId));for(let s of e.dbs.filter(e=>!r.has(e.id)))t.push({key:`db-unlinked:${s.id}`,severity:"info",appId:null,subject:s.name,title:"Database isn't linked to any app",why:"Topology and the app status can't use it.",fix:"Link it from the app page.",href:"/apps"})}for(let r of e.accounts)"supabase"===r.provider&&r.scopeNote&&/all[- ]access/i.test(r.scopeNote)&&t.push({key:`broad-cred:${r.id}`,severity:"info",appId:null,subject:`supabase \xb7 ${r.label}`,title:`${r.label} uses an all-access token`,why:"The console only reads; a broader token is a bigger risk if it ever leaks.",fix:"Replace it with a read-only token in Connections, then revoke the old one in Supabase.",href:"/connections"});for(let r of e.accounts){if(!r.expiresAt)continue;let s=r.expiresAt.getTime()-e.now.getTime();s>=12096e5&&s<=5184e6&&t.push({key:`cred-60:${r.id}:${d(r.expiresAt)}`,severity:"info",appId:null,subject:`${r.provider} \xb7 ${r.label}`,title:`The ${r.provider} credential ${r.label} expires on ${(0,c.dayMonth)(r.expiresAt)}`,why:"An expired credential stops every reading from that account.",fix:"Create a new one and use Replace credential in Connections.",href:"/connections"})}return t.map((e,t)=>({r:e,i:t})).sort((e,t)=>("warning"!==e.r.severity)-("warning"!==t.r.severity)||e.i-t.i).map(({r:e})=>e).slice(0,50)}(await v(e)),r={at:e.toISOString(),items:t};return await (0,i.db)().insert(o.settings).values({key:b,value:r}).onConflictDoUpdate({target:o.settings.key,set:{value:r,updatedAt:e}}),t}async function _(e){let[r]=await (0,i.db)().select({value:o.settings.value}).from(o.settings).where((0,t.eq)(o.settings.key,b)).limit(1),s=w.safeParse(r?.value);return s.success?s.data.items:k(e)}async function S(e,r){var s;let n=await _(e);if(!n.length)return[];let a=await (0,i.db)().select({key:o.recommendationDismissals.key,dismissedAt:o.recommendationDismissals.dismissedAt}).from(o.recommendationDismissals).where((0,t.inArray)(o.recommendationDismissals.key,n.map(e=>e.key))).limit(50),l=(s=new Map(a.map(e=>[e.key,e.dismissedAt])),n.filter(t=>{let r=s.get(t.key);return!r||e.getTime()-r.getTime()>=2592e6}));return r?l.filter(e=>e.appId===r):l}e.s(["T",0,S,"O",0,k],455891)},42784,464161,e=>{var t=e.i(336763),r=e.i(396918),s=e.i(533102),n=e.i(406212),a=e.i(530298),i=e.i(978196),o=e.i(736337),l=e.i(667378),c=e.i(412948),u=e.i(178233),d=e.i(785194),h=e.i(70377),p=e.i(586307),f=e.i(764266);e.i(333407);var m=e.i(706959),g=e.i(706539),b=e.i(380719),y=e.i(584820);let w=e=>"string"==typeof e&&e?e:null;async function v(e,v){let k=await (0,n.db)().select({r:a.resources,s:a.snapshots,sec:a.appSecurity,accStatus:a.accounts.status}).from(a.resources).leftJoin(a.accounts,(0,t.eq)(a.accounts.id,a.resources.accountId)).leftJoin(a.snapshots,(0,t.eq)(a.snapshots.resourceId,a.resources.id)).leftJoin(a.appSecurity,(0,t.eq)(a.appSecurity.resourceId,a.resources.id)).where((0,t.and)((0,t.eq)(a.resources.kind,"app"),(0,t.eq)(a.resources.monitored,!0),v?(0,t.eq)(a.resources.id,v):void 0)).orderBy(a.resources.name).limit(h.O.apps);if(!k.length)return[];let _=k.map(e=>e.r.id),S=(await (0,n.db)().select().from(a.monitors).where((0,t.inArray)(a.monitors.resourceId,_)).orderBy(a.monitors.createdAt).limit(h.O.monitors)).map(b.M),x=await (0,n.db)().selectDistinctOn([a.deployments.resourceId]).from(a.deployments).where((0,t.and)((0,t.inArray)(a.deployments.resourceId,_),(0,t.eq)(a.deployments.target,"production"),(0,t.or)((0,t.eq)(a.deployments.isCurrent,!0),(0,t.ne)(a.deployments.state,"ready"),s.sql`${a.deployments.resourceId} not in (select serving.resource_id from ${a.deployments} as serving where serving.target = 'production' and serving.is_current)`))).orderBy(a.deployments.resourceId,(0,r.desc)(a.deployments.createdAtProvider)),A=await (0,g._)(S.map(e=>e.id),e),T=new Map(k.map(e=>[e.r.id,e.r])),R=await (0,b.J)(S.map(e=>({id:e.id,kind:e.kind,url:e.url,appId:e.appId,appName:T.get(e.appId)?.name??"",appMeta:T.get(e.appId)?.meta,lastError:e.lastError}))),E=new Map;for(let e of(await (0,n.db)().select({parentId:a.resources.parentId,name:a.resources.name,meta:a.resources.meta}).from(a.resources).where((0,t.and)((0,t.eq)(a.resources.kind,"domain"),(0,t.inArray)(a.resources.parentId,_),(0,t.isNull)(a.resources.goneAt))))){if(!e.parentId)continue;let t=E.get(e.parentId)??{};t[e.name.toLowerCase()]={redirect:w(e.meta.redirect),verified:!1!==e.meta.verified},E.set(e.parentId,t)}let I=await (0,g.P)(_,e),j=await (0,p.F)(_),O=S.length?await (0,m.f)():[];return k.map(({r:t,s:r,sec:s,accStatus:n})=>{let a=S.filter(e=>e.appId===t.id).map(t=>({...t,maintUntil:(0,f.x)(O,{monitorId:t.id,appId:t.appId},e)?.end??null,move:R.get(t.id)??null})),p=w(t.meta.createdAt),m=x.find(e=>e.resourceId===t.id);return{id:t.id,name:t.name,gone:null!==t.goneAt,state:r?.state??"unknown",stateSince:r?.stateSince??null,domain:(0,i.Y)(t.meta)?.primaryDomain??(0,c.m)(t.name,a.map(e=>e.url)),domainLines:(0,l.f)(t.meta,E.get(t.id)??{},(0,i.Y)(t.meta)?.primaryDomain??(0,c.m)(t.name,a.map(e=>e.url))),framework:w(t.meta.framework),productionBranch:w(t.meta.productionBranch),productionSource:(0,o.O)(t.meta.productionSource),createdAt:p?new Date(p):null,teamName:w(t.meta.teamName),teamSlug:w(t.meta.teamSlug),repo:w(t.meta.repo),repoType:w(t.meta.repoType),functionRegions:Array.isArray(t.meta.functionRegions)?t.meta.functionRegions.filter(e=>"string"==typeof e):[],monitors:a,lastDeploy:m?{id:m.id,externalId:m.externalId,state:m.state,target:m.target,branch:m.branch,commitSha:m.commitSha,commitMessage:m.commitMessage,url:m.url,createdAt:m.createdAtProvider,buildingAt:m.buildingAt,readyAt:m.readyAt,isCurrent:m.isCurrent,isPreviousProduction:m.isPreviousProduction}:null,uptime30:(0,d.Y)(a.flatMap(t=>(0,d.w)(A.get(t.id),e,d.I))),response:I.get(t.id)??{hourly:Array.from({length:h.A.responseHours},()=>null),p95:null,p50:null},days:new Map(a.flatMap(e=>{let t=A.get(e.id);return t?[[e.id,t]]:[]})),security:s?(0,y.Z)(s):null,database:j.get(t.id)??null,dbPaused:r?.data.dbPaused===!0,pageViews:(0,u.G)(r?.data),pageViewsNote:(0,u.R)({gone:null!==t.goneAt,teamId:w(t.meta.teamId),accountOk:"ok"===n,hasProductionDeploy:void 0!==m})}})}e.s(["f",0,v],42784),s.sql`coalesce(${a.events.lastAt}, ${a.events.at})`,e.s([],464161)},328586,e=>{var t=e.i(336763),r=e.i(396918),s=e.i(406212),n=e.i(530298),a=e.i(112515),i=e.i(803237),o=e.i(93387);let l=e=>e.trim().toLowerCase();var c=e.i(802641),u=e.i(958948);async function d(e){let l=e?(0,t.and)((0,t.eq)(n.accounts.id,e),(0,t.eq)(n.accounts.provider,"github")):(0,t.eq)(n.accounts.provider,"github"),[c]=await (0,s.db)().select().from(n.accounts).where(l).orderBy((0,r.asc)(n.accounts.createdAt)).limit(1);if(!c)return null;let u=(0,i.V)({ciphertext:c.credentialCiphertext,iv:c.credentialIv},(0,o.serverEnv)().OPS_ENCRYPTION_KEY);return{account:c,token:u,problem:(0,a.A)(u)}}async function h(e,t,r){let s=0;for(let n=0;n<e.length&&!(Date.now()>t);n+=5){let t=e.slice(n,n+5);s+=t.length,await Promise.allSettled(t.map(r))}return s}async function p(e,r,i={}){var o,c;let m,g,b,y=await d(e);if(!y)return{ok:!1,error:"GitHub isn't connected."};let{account:w,token:v,problem:k}=y;if(k||!v)return{ok:!1,error:k??"The credential can't be read."};let _=await (0,u.o)(v,i);if(!_.ok){let e=(0,a.E)({ok:!1,kind:"scope"===_.kind?"auth":"missing"===_.kind?"transient":_.kind,error:_.error});return e&&await (0,s.db)().update(n.accounts).set({...e,updatedAt:new Date}).where((0,t.eq)(n.accounts.id,w.id)),{ok:!1,error:_.error}}let S=new Date,x=(o=await (0,s.db)().select({id:n.githubRepos.id,externalId:n.githubRepos.externalId,goneAt:n.githubRepos.goneAt}).from(n.githubRepos).where((0,t.eq)(n.githubRepos.accountId,w.id)).limit(1e3),c=_.data.repos,m=new Map(o.map(e=>[e.externalId,e])),g=new Set(c.map(e=>e.id)),{insert:c.filter(e=>!m.has(e.id)),update:c.filter(e=>m.has(e.id)).map(e=>({id:m.get(e.id).id,repo:e})),gone:o.filter(e=>!g.has(e.externalId)&&!e.goneAt).map(e=>e.id)}),A=e=>({owner:e.owner,name:e.name,fullName:e.fullName,defaultBranch:e.defaultBranch,private:e.private,archived:e.archived,htmlUrl:e.htmlUrl,pushedAt:e.pushedAt});await (0,s.db)().transaction(async e=>{for(let r of x.update)await e.update(n.githubRepos).set({...A(r.repo),lastSeenAt:S,goneAt:null,updatedAt:S}).where((0,t.eq)(n.githubRepos.id,r.id));x.insert.length&&await e.insert(n.githubRepos).values(x.insert.map(e=>({accountId:w.id,externalId:e.id,...A(e)}))).onConflictDoNothing({target:[n.githubRepos.accountId,n.githubRepos.externalId]}),x.gone.length&&await e.update(n.githubRepos).set({goneAt:S,updatedAt:S}).where((0,t.and)((0,t.inArray)(n.githubRepos.id,x.gone),(0,t.isNull)(n.githubRepos.goneAt)))});let T=await (0,s.db)().select().from(n.githubRepos).where((0,t.eq)(n.githubRepos.accountId,w.id)).limit(1e3),R=[];_.data.truncated&&R.push("Only the 300 most recently pushed repositories are listed.");let E=0;await h(T.filter(e=>!e.archived&&!e.goneAt&&(!e.packageCheckedAt||null!==e.pushedAt&&e.pushedAt>e.packageCheckedAt)).sort((e,t)=>(t.pushedAt?.getTime()??0)-(e.pushedAt?.getTime()??0)).slice(0,10),r,async e=>{let r=await (0,u.q)(v,e.fullName,i);r.ok?await (0,s.db)().update(n.githubRepos).set({packageName:r.data,packageCheckedAt:new Date,updatedAt:new Date}).where((0,t.eq)(n.githubRepos.id,e.id)):"scope"===r.kind&&E++}),E&&R.push("Some package.json files can't be read: give the token Contents read on those repositories.");let I=await (0,s.db)().select({id:n.resources.id,name:n.resources.name,meta:n.resources.meta}).from(n.resources).where((0,t.and)((0,t.eq)(n.resources.kind,"app"),(0,t.isNull)(n.resources.goneAt))).limit(500),j=await (0,s.db)().select({appId:n.appRepos.appId,repoId:n.appRepos.repoId,source:n.appRepos.source}).from(n.appRepos).limit(500),O=e=>"string"==typeof e&&e?e:null,$=function(e,t,r){let s=new Map(t.filter(e=>!e.goneAt).map(e=>[l(e.fullName),e.id])),n=new Map(r.map(e=>[e.appId,e])),a=[];for(let t of e){if("github"!==t.repoType||!t.repo)continue;let e=s.get(l(t.repo));if(!e)continue;let r=n.get(t.id);r?.source!=="manual"&&r?.repoId!==e&&a.push({appId:t.id,repoId:e})}return a}(I.map(e=>({id:e.id,name:e.name,repo:O(e.meta.repo),repoType:O(e.meta.repoType)})),T,j);for(let e of $)await (0,s.db)().insert(n.appRepos).values({appId:e.appId,repoId:e.repoId,source:"vercel"}).onConflictDoUpdate({target:n.appRepos.appId,set:{repoId:e.repoId,source:"vercel",updatedAt:new Date},setWhere:(0,t.ne)(n.appRepos.source,"manual")});let C=await (0,s.db)().selectDistinct({id:n.githubRepos.id,fullName:n.githubRepos.fullName,defaultBranch:n.githubRepos.defaultBranch}).from(n.appRepos).innerJoin(n.githubRepos,(0,t.eq)(n.githubRepos.id,n.appRepos.repoId)).where((0,t.and)((0,t.eq)(n.githubRepos.accountId,w.id),(0,t.isNull)(n.githubRepos.goneAt))).limit(500),P=0,N=await h(C,r,async e=>{let t=await (0,u.W)(v,e.fullName,e.defaultBranch,i);t.ok?await f(e.id,t.data):"scope"===t.kind&&P++});P&&R.push("Some Actions runs can't be read: give the token Actions read on those repositories."),N<C.length&&R.push(`${C.length-N} Actions status${C.length-N==1?"":"es"} left for the next run, time budget used.`);let D=await (0,u.k)(v,i);await (0,s.db)().update(n.accounts).set({lastSyncAt:S,status:"ok",lastError:null,updatedAt:S,...D.ok?{expiresAt:D.data.expiresAt}:{}}).where((0,t.eq)(n.accounts.id,w.id));let L={at:S.toISOString(),actionsDenied:P,contentsDenied:E};return await (0,s.db)().insert(n.settings).values({key:(b=w.id,`github.readGaps.${b}`),value:L}).onConflictDoUpdate({target:n.settings.key,set:{value:L,updatedAt:S}}),{ok:!0,repos:T.filter(e=>!e.goneAt).length,linked:C.length,newLinks:$.length,notes:R}}async function f(e,r){await (0,s.db)().update(n.githubRepos).set({actions:r,actionsCheckedAt:new Date,updatedAt:new Date}).where((0,t.eq)(n.githubRepos.id,e))}async function m(e){let[r]=await (0,s.db)().select({id:n.accounts.id}).from(n.accounts).where((0,t.eq)(n.accounts.provider,"github")).limit(1);if(!r)return null;if(Date.now()>e)return"left for the next run, time budget used";let a=await p(r.id,e);return a.ok?null:a.error}async function g(e){if(!(0,c.f)(e))return{ok:!1,reason:"no-repo",error:"That app no longer exists."};let[r]=await (0,s.db)().select({r:n.githubRepos}).from(n.appRepos).innerJoin(n.githubRepos,(0,t.eq)(n.githubRepos.id,n.appRepos.repoId)).where((0,t.and)((0,t.eq)(n.appRepos.appId,e),(0,t.isNull)(n.githubRepos.goneAt))).limit(1);if(!r)return{ok:!1,reason:"no-repo",error:"This app isn't linked to a GitHub repository yet."};let a=await d(r.r.accountId);return a?.token?{ok:!0,fullName:r.r.fullName,defaultBranch:r.r.defaultBranch,token:a.token}:{ok:!1,reason:"no-token",error:"The GitHub token can't be read; check the GitHub connection."}}e.s(["D",0,m,"l",0,g],328586)},451682,313903,205746,e=>{var t=e.i(336763),r=e.i(157406),s=e.i(533102),n=e.i(406212),a=e.i(530298),i=e.i(122603),o=e.i(803237),l=e.i(333407),c=e.i(93387),u=e.i(765503),d=e.i(666680),h=e.i(75064),p=e.i(909592),f=e.i(932378),m=e.i(246517),g=e.i(492973),b=e.i(794588);e.s(["z",0,b],313903);var b=b,y=e.i(260417);let w=["debug","info","warning","error","fatal","trace"],v=h.z.object({rows:p.z.array(f.z.unknown()).catch([]),hasMoreRows:m.z.boolean().catch(!1)}),k=h.z.object({requestId:g.z.string().min(1),timestamp:g.z.string().transform((e,t)=>{let r=Date.parse(e);return Number.isNaN(r)?(t.addIssue({code:"custom",message:"bad timestamp"}),b.NEVER):new Date(r)}),deploymentId:g.z.string().nullish().catch(null),requestMethod:g.z.string().nullish().catch(null),requestPath:g.z.string().nullish().catch(null),statusCode:y.z.number().nullish().catch(null),logs:p.z.array(f.z.unknown()).nullish().catch(null),events:p.z.array(f.z.unknown()).nullish().catch(null)}),_=h.z.object({level:g.z.string().nullish().catch(null),message:g.z.string().nullish().catch(null)}),S=h.z.object({source:g.z.string().nullish().catch(null)}),x=(e,t)=>(0,d.createHash)("sha1").update(`${e}
2
+ ${t}`).digest("hex").slice(0,8),A=(e,t,r={})=>({ok:!1,kind:e,error:t,...r});async function T(e,t,r,s){let n=(s.now??new Date).getTime(),a=Math.max(s.since.getTime(),n-864e5),o=s.until.getTime();if(a>=o)return{ok:!0,lines:[],more:!1};let l=s.maxRows??300,c=s.levels?new Set(s.levels):null,u=e=>!c||c.has(e),d=s.levels?[...new Set(s.levels.map(e=>"fatal"===e?"error":e))]:[],h=s.fetch??fetch,p=new AbortController,f=setTimeout(()=>p.abort(new DOMException("window","TimeoutError")),s.timeoutMs??8e3),m=s.signal?AbortSignal.any([p.signal,s.signal]):p.signal,g=(0,i.X)(m),b=()=>p.signal.aborted&&!s.signal?.aborted?A("transient","Vercel's log history didn't answer in time."):A("transient","Reading Vercel's log history was cancelled."),y=[],T=!1;try{for(let n=0;n<3;n++){let i,c=new URLSearchParams({projectId:r,ownerId:t,page:String(n),startDate:String(a),endDate:String(o)});s.deploymentId&&c.set("deploymentId",s.deploymentId),s.environment&&c.set("environment",s.environment),d.length&&c.set("level",d.join(","));let p=null;try{let t=await Promise.race([h(`https://vercel.com/api/logs/request-logs?${c}`,{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"},signal:m,cache:"no-store"}),g]);if(401===t.status||403===t.status)p=A("auth",`Vercel rejected this credential (${t.status}).`,{status:t.status});else if(429===t.status){let e=Number(t.headers.get("Retry-After"));p=A("transient","Vercel says there were too many requests.",{status:429,retryAfterS:Number.isFinite(e)&&e>0?e:60})}else if(400===t.status)p=A("transient","Vercel's log history didn't answer (400); the range may be past retention.",{status:400});else if(t.ok)try{i=await Promise.race([t.json(),g])}catch(e){if(m.aborted)throw e;p=A("format","Vercel's log history answered in a format the console doesn't recognise.")}else p=A("transient",`Vercel's log history returned an error (${t.status}).`,{status:t.status});p&&await t.body?.cancel().catch(()=>void 0)}catch{p=m.aborted?b():A("transient","Couldn't reach Vercel's log history.")}if(!p){let e=v.safeParse(i),t=e.success&&i&&"object"==typeof i?Object.keys(i):[];if(!e.success||t.includes("rows")||t.includes("hasMoreRows"))if(e.success){for(let t of e.data.rows)y.push(...function(e,t,r=!1){let s=k.safeParse(e);if(!s.success)return[];let n=s.data,a={at:n.timestamp,requestMethod:n.requestMethod??null,requestPath:n.requestPath??null,statusCode:n.statusCode??null,deploymentId:n.deploymentId??null,source:(n.events??[]).map(e=>S.safeParse(e)).find(e=>e.success&&e.data.source)?.data?.source??null},i=[],o=new Map;for(let e of n.logs??[]){let r=_.safeParse(e);if(!r.success||!r.data.message)continue;let s=function(e){let t=(e??"").toLowerCase();return"warn"===t?"warning":w.includes(t)?t:"info"}(r.data.level),l=x(s,r.data.message),c=o.get(l)??0;o.set(l,c+1),t(s)&&i.push({rowId:`${n.requestId}:${l}${c?`#${c}`:""}`,level:s,message:r.data.message,...a})}if(null!=n.statusCode&&n.statusCode>=500&&t("error")&&!i.some(e=>"error"===e.level||"fatal"===e.level)&&i.push({rowId:`${n.requestId}:status`,level:"error",message:`${n.requestMethod??"GET"} ${n.requestPath??"/"} → ${n.statusCode}`,...a}),r&&0===i.length){let e=n.statusCode??0,r=e>=500?"error":e>=400?"warning":"info";t(r)&&i.push({rowId:`${n.requestId}:request`,level:r,message:`${n.requestMethod??"GET"} ${n.requestPath??"/"}${e>0?` → ${e}`:""}`,...a})}return i}(t,u,s.requests));if(!(T=e.data.hasMoreRows)||y.length>=l)break}else p=A("format","Vercel's log history answered in a format the console doesn't recognise.");else p=A("transient","Vercel's log format changed: the answer has neither rows nor hasMoreRows.")}if(p){if(0===n)return p;T=!0;break}}}finally{clearTimeout(f),p.abort()}return y.sort((e,t)=>e.at.getTime()-t.at.getTime()),y.length>l&&(y.splice(0,y.length-l),T=!0),{ok:!0,lines:y,more:T}}e.s(["f",0,T],205746);var R=e.i(728335);let E=["warning","error","fatal"],I="logs_read_cursor";async function j(e){let[r]=await (0,n.db)().select().from(a.accounts).where((0,t.and)((0,t.eq)(a.accounts.provider,"vercel"),(0,t.eq)(a.accounts.status,"ok"))).limit(1),s=r?(0,o.V)({ciphertext:r.credentialCiphertext,iv:r.credentialIv},(0,c.serverEnv)().OPS_ENCRYPTION_KEY):null;return r&&s?(await (0,n.db)().select({appId:a.resources.id,appName:a.resources.name,projectId:a.resources.externalId,meta:a.resources.meta,deploymentId:a.deployments.externalId}).from(a.deployments).innerJoin(a.resources,(0,t.eq)(a.resources.id,a.deployments.resourceId)).where((0,t.and)((0,t.eq)(a.deployments.isCurrent,!0),(0,t.eq)(a.resources.accountId,r.id),(0,t.eq)(a.resources.monitored,!0),(0,t.isNull)(a.resources.goneAt),...e?[(0,t.eq)(a.resources.id,e)]:[]))).map(e=>({appId:e.appId,appName:e.appName,projectId:e.projectId,deploymentId:e.deploymentId,teamId:String(e.meta.teamId??""),token:s})):[]}let O=(e,t)=>({resourceId:e.appId,deploymentId:t.deploymentId??e.deploymentId,rowId:t.rowId,at:t.at,level:t.level,message:(0,u.l)((0,u.h)(t.message),2e3),requestMethod:t.requestMethod,requestPath:(0,u.n)(t.requestPath?(0,u.h)(t.requestPath):null),statusCode:t.statusCode,source:t.source});async function $(e,o,c){let u,[d]=await (0,n.db)().select().from(a.settings).where((0,t.eq)(a.settings.key,"logs.disabled")).limit(1);if(d?.value===!0)return;let h=await j(null);if(!h.length)return;let p=(0,R.dayStart)((0,R.dayKey)(e)),f=new Map((await (0,n.db)().select({id:a.storedLogs.resourceId,n:s.sql`count(*)::int`}).from(a.storedLogs).where((0,t.and)((0,t.inArray)(a.storedLogs.resourceId,h.map(e=>e.appId)),(0,t.gte)(a.storedLogs.at,p))).groupBy(a.storedLogs.resourceId)).map(e=>[e.id,e.n])),m=new Map((await (0,n.db)().select({id:a.storedLogs.resourceId,at:(0,r.max)(a.storedLogs.at)}).from(a.storedLogs).where((0,t.inArray)(a.storedLogs.resourceId,h.map(e=>e.appId))).groupBy(a.storedLogs.resourceId)).map(e=>[e.id,e.at])),[g]=await (0,n.db)().select().from(a.settings).where((0,t.eq)(a.settings.key,I)).limit(1),b=(u=g?.value)&&"object"==typeof u&&!Array.isArray(u)?Object.fromEntries(Object.entries(u).filter(e=>"string"==typeof e[1]&&!Number.isNaN(Date.parse(e[1])))):{},y=e.getTime()-864e5,w=await (0,i.P)(h,3,t=>{if(Date.now()+8500>o)return Promise.resolve(null);let r=[m.get(t.appId)?.getTime(),b[t.appId]?Date.parse(b[t.appId]):void 0].filter(e=>void 0!==e),s=new Date(Math.max(r.length?Math.max(...r)-3e5:y,y));return T(t.token,t.teamId,t.projectId,{since:s,until:e,now:e,levels:E,environment:"production",maxRows:300})}),v=h.map((e,t)=>{let r=w[t];return r?r.ok?(r.more&&c.push(`logs/${e.appName}: more than 300 log lines since the last read; the oldest were skipped`),r.lines.filter(e=>E.includes(e.level))):(c.push(`logs/${e.appName}: ${r.error}`),[]):[]}),k=v.flat().map(e=>e.rowId),_=new Set(k.length?(await (0,n.db)().select({rowId:a.storedLogs.rowId}).from(a.storedLogs).where((0,t.inArray)(a.storedLogs.rowId,k))).map(e=>e.rowId):[]),S=[];for(let[e,t]of h.entries()){let r=v[e].filter(e=>!_.has(e.rowId));if(!r.length)continue;let s=f.get(t.appId)??0,i=Math.max(0,1e3-s),o=(i>=r.length?r:r.slice(r.length-i)).map(e=>O(t,e));o.length&&await (0,n.db)().insert(a.storedLogs).values(o).onConflictDoNothing({target:a.storedLogs.rowId}),s+r.length>=1e3&&S.push(t.appId)}let x=h.filter((e,t)=>w[t]?.ok);if(x.length){let t={};for(let e of h)b[e.appId]&&(t[e.appId]=b[e.appId]);for(let r of x)t[r.appId]=e.toISOString();await (0,n.db)().insert(a.settings).values({key:I,value:t}).onConflictDoUpdate({target:a.settings.key,set:{value:t,updatedAt:new Date}})}await (0,l.f)(S.map(e=>({resourceId:e,type:"system",kind:"warn",message:"Stored-log limit reached",detail:"More than 1000 warnings and errors today; the rest stay in Vercel only for its short log history (about a day on Hobby).",reason:"LogCapReached"})))}e.s(["g",0,j,"_",0,$],451682)},486118,e=>{let t;var r,s,n=e.i(547963),a=e.i(804308),i=e.i(515683),o=e.i(25734),l=e.i(216640),c=e.i(27626),u=e.i(64858),d=e.i(248744),h=e.i(379593),p=e.i(423660),f=e.i(717799),m=e.i(336763),g=e.i(396918),b=e.i(406212),y=e.i(530298),w=e.i(503313),v=e.i(595262),k=e.i(638809),_=e.i(732077),S=e.i(908223),x=e.i(328586),A=e.i(406197),T=e.i(964964),R=e.i(736337),E=e.i(974034),I=e.i(958948),j=e.i(348657),O=e.i(198552),$=e.i(205746),C=e.i(760859),P=e.i(518581),N=e.i(633075),D=e.i(108621),L=e.i(809303);let U="waiting: Vercel didn't say which deployment is live";async function q(e){let t=Date.now();try{let r=await fetch(e,{redirect:"manual",signal:AbortSignal.timeout(T.w),cache:"no-store",headers:{"User-Agent":"Watchbell smoke test"}}),s=401===r.status||403===r.status?(await r.text().catch(()=>"")).slice(0,8192):"";return{status:r.status,ms:Date.now()-t,authWall:(0,T.S)(r.status,s,r.headers)}}catch{return{status:null,ms:Date.now()-t,authWall:!1}}}async function M(t,r){let{extensions:s}=await e.A(27505);return await s.runner?.lockfileJobActive(t,r).catch(()=>!1)??!1}let B=null;async function z(e,t){let r=(0,E.Q)(t.meta?.rootDirectory),s=(0,E.H)(r,"package.json"),n=t.lockfilePath??(0,E.H)(r,"package-lock.json");if(B?.token!==e){let t=await (0,j.z)(e);if(!t.ok)return null;B={token:e,login:t.data}}let a=B.login,[i,o]=await Promise.all([(0,j.O)(e,t.fullName,t.number),(0,j.P)(e,t.fullName,t.number)]);if(!i.ok||!o.ok)return null;let l=[];for(let r of o.data.slice(0,T.y+1)){let s=null!==r.login&&r.login.toLowerCase()===a.toLowerCase()?null:await (0,j.h)(e,t.fullName,r.sha);if(s&&!s.ok)return null;l.push({...r,files:s?s.data:null})}let[c,u]=await Promise.all([(0,j.E)(e,t.fullName,t.baseBranch,{},s),(0,j.E)(e,t.fullName,t.headSha,{},s)]);if(!c.ok||!u.ok)return null;let d=c.data&&u.data?(0,T.C)(c.data.text,u.data.text,t.packages):"unexpected change: package.json is missing",h=null;if(n!==s&&i.data.some(e=>e.filename===n||e.previous===n))if((0,j.$)(n)){let[r,s]=await Promise.all([(0,j.l)(e,t.fullName,t.baseBranch,n),(0,j.l)(e,t.fullName,t.headSha,n)]);if(!r.ok||!s.ok)return null;h=(0,T.T)(r.data,s.data,n)}else h=`unexpected lockfile change ${n} (only package-lock.json can be checked)`;return{manifest:s,lockfile:n,lockfileRequired:!!t.lockfilePath,manifestProblem:d,lockfileProblem:h,headSha:t.headSha,tokenLogin:a,files:i.data,commits:l}}async function F(e,t={}){let r=await (t.vercel??W.vercel)(e);if(!r)return null;let s=await (t.serving??O.k)(r.token,r.teamId,r.projectId);if(!s.ok)return null;let n=s.data.currentId,a=null;if(!n){let e=s.data.latest?.readyState??null;if("ERROR"!==e&&"CANCELED"!==e)return null;let i=await (t.running??O.N)(r.token,r.teamId,r.projectId);if(!i.ok||i.data)return null;let o=await (t.ready??O.r)(r.token,r.teamId,r.projectId);if(!o.ok)return null;let l=[...o.data].sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),c=s.data.promote;c?(a=l.find(e=>e.createdAt.getTime()>c.requestedAt)??null)||(n=c.toDeploymentId):a=l[0]??null}if(!a&&n){let e=await (t.deployment??O.S)(r.token,{id:r.teamId,slug:r.teamId,name:r.teamId},n);if(!e.ok)return null;a=e.data}return a?{source:(0,R.s)({source:a.source,branch:a.branch,sha:a.sha,branchFrom:a.branchFrom??null,gitDirty:!0===a.gitDirty})}:null}let W={rows:async()=>await (0,b.db)().select({id:y.dependencyPrs.id,repoId:y.dependencyPrs.repoId,appId:y.dependencyPrs.appId,proposalId:y.dependencyPrs.proposalId,number:y.dependencyPrs.number,branch:y.dependencyPrs.branch,baseBranch:y.dependencyPrs.baseBranch,headSha:y.dependencyPrs.headSha,title:y.dependencyPrs.title,packages:y.dependencyPrs.packages,auto:y.dependencyPrs.auto,stage:y.dependencyPrs.stage,smokeMode:y.dependencyPrs.smokeMode,previewReadyAt:y.dependencyPrs.previewReadyAt,openedAt:y.dependencyPrs.openedAt,fullName:y.githubRepos.fullName,appName:y.resources.name,meta:y.resources.meta,lockfilePath:y.dependencyScans.lockfilePath,appMonitored:y.resources.monitored,appGone:y.resources.goneAt,stageText:y.dependencyPrs.stageText}).from(y.dependencyPrs).innerJoin(y.githubRepos,(0,m.eq)(y.githubRepos.id,y.dependencyPrs.repoId)).leftJoin(y.resources,(0,m.eq)(y.resources.id,y.dependencyPrs.appId)).leftJoin(y.dependencyScans,(0,m.eq)(y.dependencyScans.repoId,y.dependencyPrs.repoId)).where((0,m.inArray)(y.dependencyPrs.stage,[...T.X])).orderBy((0,g.asc)(y.dependencyPrs.openedAt)).limit(10),security:L.X,rollback:L.K,writeToken:async()=>{let e=await (0,S.G)();return e&&"unreadable"!==e?e.token:null},readToken:async e=>{let t=await (0,x.l)(e);return t.ok?t.token:null},vercel:async e=>{let t=await (0,A.p)(e,"app"),r=t?.resource.meta.teamId;return t&&"string"==typeof r&&t.resource.externalId?{token:t.token,teamId:r,projectId:t.resource.externalId}:null},monitorUrls:async e=>(await (0,b.db)().select({url:y.monitors.url}).from(y.monitors).where((0,m.and)((0,m.eq)(y.monitors.resourceId,e),(0,m.eq)(y.monitors.kind,"http"))).limit(10)).map(e=>e.url),pull:j.b,checks:j.s,runs:I.L,previews:O.C,probe:q,errorLogs:async(e,t,r,s)=>{let n=await (0,$.f)(e.token,e.teamId,e.projectId,{since:r,until:s,now:s,deploymentId:t,levels:["error","fatal"],maxRows:20,timeoutMs:8e3});return n.ok?n.lines.length:null},merge:j.C,review:z,save:async(e,t,r,s)=>{await (0,b.db)().update(y.dependencyPrs).set({...t,stageText:s,checkedAt:new Date}).where((0,m.eq)(y.dependencyPrs.id,e)),r&&await (0,b.db)().update(P.O).set({result:s}).where((0,m.eq)(P.O.id,r)).catch(()=>void 0)},notify:e=>(0,D.y)(e),liveSource:e=>F(e),lockfileBusy:async(e,t,r)=>await M(e,t)||await (0,_.W)(r,t),audit:(e,t)=>(0,v.f)({kind:"ok",message:e,resourceId:t,actorUserId:null}),book:()=>(0,w.f)()};async function H(e,t,r=W){let s={watched:0,merged:0,stopped:0},n=()=>t-Date.now(),a=await r.rows();if(!a.length)return s;let[i,o,l]=await Promise.all([r.security().catch(()=>null),r.rollback().catch(()=>null),r.writeToken().catch(()=>null)]);if(!l)return s;let c=await r.book().catch(()=>C.a);for(let t of a){if(15e3>n())break;if(t.auto||i?.enabled)try{let n=await G(t,e,l,o?.enabled===!0,r);if(!n)continue;s.watched++;let a=t.appName?(0,C.r)(c,t.appName):"app";await J(t,n,a,o?.windowMin??30,e,l,r,s)}catch(e){console.warn("deps/watch failed:",e instanceof Error?e.name:"error")}}return s}async function G(e,t,r,s,n){let a=await n.pull(r,e.fullName,e.number);if(!a.ok)return null;let i=await n.checks(r,e.fullName,a.data.headSha),o=null;if(i.ok&&null===i.data.checkRuns&&e.appId){let t=await n.readToken(e.appId),r=t?await n.runs(t,e.fullName,a.data.headSha):null;o=r?.ok?r.data:null}i.ok||(i={ok:!0,data:{checkRuns:[{status:"queued",conclusion:null}],combined:null}});let l=(0,T.j)({...i.data,actionRuns:o}),c={state:null,readyAt:null},u=null,d=e.appId?await n.vercel(e.appId):null;if(d&&"success"===l&&a.data.headSha===e.headSha){let r=await n.previews(d.token,d.teamId,d.projectId,a.data.headSha),s=r.ok?r.data.find(e=>"preview"===e.target)??r.data[0]??null:null;if(s&&(c={state:s.state,readyAt:s.readyAt??("ready"===s.state?t:null)},"ready"===s.state&&s.url)){let r=e.previewReadyAt??c.readyAt??t;if("logs"!==e.smokeMode){let t=(0,T.E)(e.appId?await n.monitorUrls(e.appId):[]),r=await Promise.all(t.map(async e=>({path:e,...await n.probe(`https://${s.url}${e}`)})));u=(0,T.L)(r)}u||(u=(0,T.n)(r,t,await n.errorLogs(d,s.id,r,t).catch(()=>null))),c.readyAt=r}}return{step:(0,T.M)({now:t,openedAt:e.openedAt,pr:{state:a.data.state,merged:a.data.merged,mergeable:a.data.mergeable,headSha:a.data.headSha,base:a.data.base},recordedSha:e.headSha,recordedBase:e.baseBranch,checks:l,preview:c,smoke:u,autoRollbackOn:s}),smoke:u,previewReadyAt:c.readyAt,headSha:a.data.headSha}}function K(e,t){if(!e.appId||!1===e.appMonitored||e.appGone)return"the app is gone or no longer watched, so Watchbell can't confirm what production is built from. Merging this PR could replace what is live";let r=(0,R.B)(e.meta?.productionSource,e.baseBranch,t);if(r)return r;let s=(0,R.O)(e.meta?.productionSource),n=e.meta?.productionBranch;return s?.kind==="git"&&s.ref===e.baseBranch&&"string"==typeof n&&n!==e.baseBranch?`Merging into ${e.baseBranch} won't deploy to production by itself: production was promoted from a ${e.baseBranch} preview. Merge, then promote the new preview.`:null}async function J(e,t,r,s,n,a,i,o){let{step:l}=t,c=t.smoke?{smokeMode:t.smoke.mode}:{},u=t.previewReadyAt?{previewReadyAt:t.previewReadyAt}:{},d={app:r,number:e.number,packages:e.packages};if("wait"===l.kind)return void await i.save(e.id,{stage:l.stage,...c,...u,...l.resetSha?{headSha:l.resetSha,previewReadyAt:null,smokeMode:null}:{}},e.proposalId,(0,T.m)(e.number,l.stage,l.reason));if("done"===l.kind)return void await i.save(e.id,{stage:l.stage,finishedAt:n},e.proposalId,(0,T.m)(e.number,l.stage));if("stop"===l.kind&&("CI gagal"===l.reason||"CI failed"===l.reason)&&await i.lockfileBusy?.(e.repoId,e.branch,e.fullName).catch(()=>!1))return void await i.save(e.id,{stage:"checks"},e.proposalId,(0,T.m)(e.number,"checks","waiting for the lockfile from the runner"));let h=async t=>{await i.save(e.id,{stage:"failed",finishedAt:n,...c},e.proposalId,(0,T.m)(e.number,"failed",t)),o.stopped++,await i.notify({...d,kind:"stopped",reason:t.replace(/\.$/,"")}).catch(()=>void 0)},p="merge"===l.kind||"stop"===l.kind&&"ready-manual"===l.stage?K(e,n):null;if(p)return h(p);let f=async()=>{let r=e.appId?await i.liveSource(e.appId).catch(()=>null):null;if(!r){let r=t.previewReadyAt??e.previewReadyAt??e.openedAt;if((e.stageText??"").includes(U)&&n.getTime()-r.getTime()>T.R)return await h("Vercel didn't say which deployment is live for 45 minutes, so Watchbell can't confirm what production is built from. Check it, then merge yourself"),!0;let s="checks"===e.stage||"preview"===e.stage||"smoke"===e.stage?e.stage:"smoke";return await i.save(e.id,{stage:s,...c,...u},e.proposalId,(0,T.m)(e.number,s,U)),!0}let s=r.source?K({...e,meta:{...e.meta??{},productionSource:{...r.source,at:n.toISOString()}}},n):`Watchbell can't confirm what production is built from (Vercel names no branch for it). Merging this PR could deploy ${e.baseBranch} to production and replace what is live.`;return!!s&&(await h(s),!0)};if("stop"===l.kind&&"ready-manual"===l.stage&&await f())return;if("stop"===l.kind){await i.save(e.id,{stage:l.stage,finishedAt:n,...c},e.proposalId,(0,T.m)(e.number,l.stage,"ready-manual"===l.stage?null:l.reason)),o.stopped++,await i.notify({...d,kind:"ready-manual"===l.stage?"ready-manual":"stopped",reason:l.reason}).catch(()=>void 0);return}let m=await i.review(a,e).catch(()=>null);if(!m)return;let g=(0,T.k)(m);if(!g&&(0,T.H)(m)&&n.getTime()-e.openedAt.getTime()>T.R){let t="the lockfile wasn't added within 45 minutes";await i.save(e.id,{stage:"timeout",finishedAt:n,...c},e.proposalId,(0,T.m)(e.number,"timeout",t)),o.stopped++,await i.notify({...d,kind:"stopped",reason:t}).catch(()=>void 0);return}if(!g&&(0,T.H)(m))return void await i.save(e.id,{stage:"checks"},e.proposalId,(0,T.m)(e.number,"checks","waiting for the lockfile"));if(g){await i.save(e.id,{stage:"failed",finishedAt:n,...c},e.proposalId,(0,T.m)(e.number,"failed",g)),o.stopped++,await i.notify({...d,kind:"stopped",reason:g}).catch(()=>void 0);return}if(await f())return;await i.save(e.id,{stage:"merging",...c,...u},e.proposalId,(0,T.m)(e.number,"merging"));let b=await i.merge(a,e.fullName,e.number,e.branch,e.baseBranch,e.headSha,e.title);if(b.ok){await i.save(e.id,{stage:"merged",mergedSha:b.data.sha,finishedAt:n},e.proposalId,(0,T.m)(e.number,"merged")),o.merged++,await i.audit(`${N.v}PR #${e.number} merged \xb7 ${e.packages.join(", ")}`.slice(0,200),e.appId).catch(()=>void 0),await i.notify({...d,kind:"merged",windowMin:s}).catch(()=>void 0);return}if(409===b.status)return void await i.save(e.id,{stage:"checks"},e.proposalId,(0,T.m)(e.number,"checks","new commit on the PR branch, checking again"));let y=405===b.status?"GitHub refused the merge (cannot be merged)":`merge failed: ${b.error}`.slice(0,150);await i.save(e.id,{stage:"failed",finishedAt:n},e.proposalId,(0,T.m)(e.number,"failed",y)),o.stopped++,await i.notify({...d,kind:"stopped",reason:y}).catch(()=>void 0)}let V=null;async function Y(e,t,r=k.I){if((0,T.f)(e,V)&&!(await r()).has("devops")){V=e.getTime();try{let r=await H(e,t?.deadline??e.getTime()+5e4);r.watched&&console.log(`deps/watch: ${r.watched} PR, ${r.merged} merged, ${r.stopped} stopped`)}catch(e){console.warn("deps/watch failed:",e instanceof Error?e.name:"error")}}}var Z=e.i(653587),X=e.i(452475);let Q={nav:[{section:"manage",after:"backups",items:[{key:"ai",label:"AI Gateway",href:"/ai",icon:"route",stage:5,ownerOnly:!0,sub:"AI & API"},{key:"api-docs",label:"API explorer",href:"/api-docs",icon:"api",stage:5,ownerOnly:!0,sub:"AI & API"}]}],palette:[{label:"AI Gateway",href:"/ai",keywords:["ai","gateway","overview"]},{label:"API keys",href:"/ai/keys",keywords:["key","token","wb_","wp_"]},{label:"Agents",href:"/ai/agents",keywords:["agent","client","mcp"]},{label:"Connect an agent",href:"/ai/connect",keywords:["mcp",...n.I.palette.connectKeywords,"gemini cli","quick start"]},{label:"Bring your own key",href:"/ai/providers",keywords:["provider","byok","cloudflare","groq","openrouter","gemini"]},{label:"Quota",href:"/ai/quota",keywords:["limit","usage","rate"]},{label:"AI logs",href:"/ai/logs",keywords:["logs","requests","usage"]},{label:"Models",href:"/ai/models",keywords:["model","llm"]},{label:"Playground",href:"/ai/playground",keywords:["chat","try","prompt"]},{label:"API explorer",href:"/api-docs",keywords:["openapi","swagger","api","v1"]}]},ee={dailySteps:[{name:"ai-usage-retention",run:i.$}]},et={WhyAiSlot:h.f,RecSummarySlot:d.f,AiNotesSlot:u.f,explainBuild:l.f,dailySteps:[{name:"advisor-summary",run:c.f}],minuteSteps:[{name:"advisor-notes",run:o.f}]},er={dailySteps:[{name:"ai-notes-retention",run:p.v}]},es={nav:[{section:"manage",after:"alerts",items:[{key:"auto-actions",label:"Auto-actions",href:"/auto-actions",icon:"bolt",stage:9,ownerOnly:!0,sub:"Alerting"}]}],palette:[{label:"Auto-actions",href:"/auto-actions",keywords:["proposal","approve","reject","auto-run","rollback"]}],dailySteps:[{name:"auto-actions-retention",run:Z.t}],minuteSteps:[{name:"auto-actions",run:Z.Z},{name:"deps-pr-watch",run:Y}],settingsTabs:[{key:"office-auto-run",label:"Auto-actions",Tab:f.f}]},en={telegramCallback:X.proposalCallback},ea=function(...e){let t={nav:[],palette:[]};for(let r of e){for(let e of r.nav??[]){let r=t.nav.find(t=>t.section===e.section&&t.after===e.after);r?r.items=[...r.items,...e.items]:t.nav.push({...e,items:[...e.items]})}t.palette.push(...r.palette??[]),r.dailySteps?.length&&(t.dailySteps=[...t.dailySteps??[],...r.dailySteps]),r.minuteSteps?.length&&(t.minuteSteps=[...t.minuteSteps??[],...r.minuteSteps]),r.WhyAiSlot&&(t.WhyAiSlot=r.WhyAiSlot),r.RecSummarySlot&&(t.RecSummarySlot=r.RecSummarySlot),r.AiNotesSlot&&(t.AiNotesSlot=r.AiNotesSlot),r.DevNotesSlot&&(t.DevNotesSlot=r.DevNotesSlot),r.office&&(t.office=r.office),r.settingsTabs?.length&&(t.settingsTabs=[...t.settingsTabs??[],...r.settingsTabs]),r.telegramCallback&&(t.telegramCallback=r.telegramCallback),r.runner&&(t.runner=r.runner),r.RepoPreviewSlot&&(t.RepoPreviewSlot=r.RepoPreviewSlot),r.explainBuild&&(t.explainBuild=r.explainBuild)}return t}({...Q,palette:(r=Q.palette??[],s={label:"Ask AI",href:"/ai/ask",keywords:["ask","question","answer"]},(t=r.findIndex(e=>"/ai"===e.href))<0?[...r,s]:[...r.slice(0,t+1),s,...r.slice(t+1)])},{dailySteps:[{name:"ai-agents-prune",run:()=>(0,a.f)()}]},ee,{},{},er,es,et,en);e.s(["extensions",0,ea],486118)},667378,e=>{var t=e.i(978196);e.s(["f",0,function(e,r,s){let n=(0,t.Y)(e);if(!n)return{lines:[{name:s,tag:null,target:null}],more:0};let a=[n.primaryDomain,...n.domains.filter(e=>e!==n.primaryDomain)].filter((e,t,r)=>r.indexOf(e)===t),i=[...new Set(n.pastDomains)].filter(e=>!a.includes(e)).reverse(),o=a.map((e,t)=>{let s=r[e],n={name:e,target:s?.redirect?s.redirect.replace(/^https?:\/\//i,"").replace(/\/.*$/,"").toLowerCase():null};return 0===t?{...n,tag:a.length>1||i.length?"primary":null}:{...n,tag:s?.redirect?"redirect":s&&!s.verified?"pending":null}});return o.push(...i.slice(0,3).map(e=>({name:e,tag:"former",target:null}))),{lines:o,more:Math.max(0,i.length-3)}}])},178233,e=>{let t=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0?e:null;e.s(["G",0,function(e){let r=e&&"object"==typeof e?e.pageviews:null;if(!r||"object"!=typeof r)return null;let s="string"==typeof r.readAt?Date.parse(r.readAt):0/0;if(Number.isNaN(s)||"boolean"!=typeof r.enabled)return null;if(!r.enabled)return{enabled:!1,readAt:new Date(s)};let n=t(r.total24h),a=null===r.visitors24h?null:t(r.visitors24h);if(null===n||null===a&&null!==r.visitors24h)return null;let i=36e5*Math.floor(s/36e5),o=new Map;for(let e of Array.isArray(r.hourly)?r.hourly:[]){if(!Array.isArray(e))continue;let r="string"==typeof e[0]?Date.parse(e[0]):0/0,s=t(e[1]);if(Number.isNaN(r)||null===s)continue;let n=36e5*Math.floor(r/36e5);o.set(n,(o.get(n)??0)+s)}return{enabled:!0,total:n,visitors:a,hours:Array.from({length:24},(e,t)=>{let r=i-(23-t)*36e5;return{at:new Date(r),views:o.get(r)??0}}),readAt:new Date(s)}},"R",0,function(e){return!e.gone&&e.teamId&&e.accountOk?e.hasProductionDeploy?null:"Not read: this app has no production deployment yet.":"Not read: this app isn't in a connected Vercel account."},"Z",0,function(e,t){return e.enabled?{enabled:!0,total24h:e.total,visitors24h:e.visitors,readAt:t.toISOString(),hourly:e.hourly.slice(-24).map(e=>[e.at.toISOString(),e.views])}:{enabled:!1,readAt:t.toISOString()}}])},530831,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call AutoRollbackForm() from the server but AutoRollbackForm is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/actions/auto-rollback-form.tsx","AutoRollbackForm");e.s(["AutoRollbackForm",0,t])},657753,e=>{var t=e.i(530831);e.n(t)},842941,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call AutoRunForm() from the server but AutoRunForm is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/actions/auto-run-form.tsx","AutoRunForm");e.s(["AutoRunForm",0,t])},27295,e=>{var t=e.i(842941);e.n(t)},699286,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call AutoSecurityForm() from the server but AutoSecurityForm is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/actions/auto-security-form.tsx","AutoSecurityForm");e.s(["AutoSecurityForm",0,t])},783671,e=>{var t=e.i(699286);e.n(t)},804308,515683,585585,e=>{let t,r,s,n,a;var i=e.i(533102),o=e.i(406212);e.i(333407);var l=e.i(518581);async function c(){await (0,o.db)().execute(i.sql`
3
3
  delete from ops.ai_agents where id in (select id from ops.ai_agents order by last_seen_at desc offset ${2e3})
4
4
  `)}e.s(["f",0,c],804308);var u=e.i(885298);let d={name:"watchpost-console",version:"5c",via:"console",userAgent:"Watchbell console"},h=i.sql.raw("'00000000-0000-0000-0000-000000000000'::uuid");async function p(e,t){let r=e.client,s=e.tool??e.model,n=e.tokensIn??0,a=e.tokensOut??0,l=JSON.stringify(t.map(e=>({provider_id:e.providerId,scope:e.scope.slice(0,100),metric:e.metric.slice(0,40),used:e.used,limit:e.limit,remaining:e.remaining,reset_at:e.resetAt?.toISOString()??null,source:e.source}))),c=e.at.toISOString();await (0,o.db)().execute(i.sql`
5
5
  with agent as (
@@ -43,7 +43,7 @@ ${t}`).digest("hex").slice(0,8),A=(e,t,r={})=>({ok:!1,kind:e,error:t,...r});asyn
43
43
  select id from ops.ai_agents order by last_seen_at desc offset ${2e3}
44
44
  ) returning 1
45
45
  )
46
- select (select count(*) from old) as usage, (select count(*) from extra) as agents`)}e.s(["q",0,d,"$",0,f,"h",0,p],515683);var m=e.i(260417),g=e.i(684330),b=e.i(79322),y=e.i(978071),w=e.i(492973),v=e.i(909592),k=e.i(932378),_=e.i(794588),_=_,S=e.i(75064),x=e.i(246517),A=e.i(542746),T=e.i(105464),R=e.i(90879);function E(e){let t=e.maxKeys??1e4,r=new Map;return{has(t,s=Date.now()){let n=r.get(t);return void 0!==n&&(!(s-n>=e.ttlMs)||(r.delete(t),!1))},add(e,s=Date.now()){for(r.delete(e),r.set(e,s);r.size>t;)r.delete(r.keys().next().value)},delete:e=>void r.delete(e),reset:()=>r.clear()}}e.i(666680),e.i(484817),e.i(659916);var I=_,j=_,O=e.i(547963);O.B.writeNotesLong;let C=I.strictObject({name:w.z.string().regex(/^[a-z0-9-]{2,40}$/,"Use 2–40 lowercase letters, digits or dashes."),scopes:v.z.array(b.z.enum(["ai:invoke","read:status","write:notes"])).min(1,"Pick at least one scope.").transform(e=>[...new Set(e)]),expiry:b.z.enum(["7d","30d","90d","1y","never"]).default("90d"),ratePerMin:j.coerce.number("Enter a whole number from 1 to 600.").int("Enter a whole number from 1 to 600.").min(1,"Enter a whole number from 1 to 600.").max(600,"Enter a whole number from 1 to 600.")});C.shape.name,C.shape.ratePerMin;let $={max:30,windowMs:6e5};globalThis.__watchbellKeyFailures??={...a={limit:(t=$.maxKeys??1e4,r=new Map,s=(e,s)=>{let n=r.get(e);for(n&&r.delete(e),(!n||s-n.start>=$.windowMs)&&(n={start:s,n:0}),r.set(e,n);r.size>t;)r.delete(r.keys().next().value);return n},n=(e,t,r)=>({allowed:r,retryAfter:Math.max(1,Math.ceil((e.start+$.windowMs-t)/1e3))}),{hit(e,t=Date.now()){let r=s(e,t);return r.n++,n(r,t,r.n<=$.max)},peek(e,t=Date.now()){let r=s(e,t);return n(r,t,r.n<$.max)},count(e,t=Date.now()){s(e,t).n++},size:()=>r.size,reset:()=>r.clear()}),seen:E({ttlMs:$.windowMs,maxKeys:5e4}),failed:E({ttlMs:6e4})},reset:()=>{a.limit.reset(),a.seen.reset(),a.failed.reset()}};let P=["gemini","cloudflare","custom"],N=["gemini","antigravity"],D=["@cf/google/gemma"],L={gemini:{name:"Google Gemini",baseUrl:()=>"https://generativelanguage.googleapis.com/v1beta/openai",secretFields:["apiKey"],modelsPath:"/models",listModels:"gemini-native",quotaFrom:"own",auth:"x-goog-api-key",streamUsage:!0,advanced:!1,keyLabel:"AI Studio API key",where:{url:"https://aistudio.google.com/apikey",text:"Create a key (it starts with AQ. or AIza). If Google says the project is restricted or denied, use a key from another Google project or account."}},cloudflare:{name:"Cloudflare Workers AI",baseUrl:e=>`https://api.cloudflare.com/client/v4/accounts/${e.accountId??""}/ai/v1`,secretFields:["accountId","apiKey"],modelsPath:"/models/search",listModels:"cloudflare-search",quotaFrom:"own",auth:"bearer",streamUsage:!0,advanced:!1,keyLabel:"API token",where:{url:"https://dash.cloudflare.com/profile/api-tokens",text:"Create a token with Workers AI: Read. The account ID is on the Workers AI page. Only Google's Gemma models are offered."}},custom:{name:"Custom OpenAI-compatible",baseUrl:e=>(e.baseUrl??"").replace(/\/+$/,""),secretFields:["baseUrl","apiKey"],modelsPath:"/models",listModels:"openai",quotaFrom:"headers",auth:"bearer",streamUsage:!0,advanced:!0,keyLabel:"API key",where:{url:null,text:"Any HTTPS server that speaks the OpenAI chat completions API and answers GET /models. Every model the server lists is offered; switch any off on Models."}}};O.Y.localUrl;class U extends Error{info;constructor(e,t){super(t),this.info=e,this.name="UpstreamError"}}function q(e,t,r){switch(e){case"project_denied":return"Google denied this project's Gemini API access. Use a key from another Google project or account.";case"project_restricted":return"This Google project's Gemini API access is restricted. Create a key in another project or enable billing.";case"auth_rejected":return`${r} rejected the API key (${t}). Replace it under Bring your own key.`;case"rate_limited":return`${r} says the rate limit or quota is used up (429). Try again later.`;case"model_not_found":return`${r} doesn't know this model (404).`;case"bad_request":return`${r} refused the request (${t}). Check the request body.`;case"server_error":return`${r} failed (${t}). Try again later.`;case"timeout":return`${r} didn't answer within 60 s.`;case"network":return`Can't reach ${r}.`;case"bad_response":return`${r} sent an answer Watchbell can't read.`;default:return`${r} answered ${t}.`}}async function M(e,t,r,s=6e4){var n,a,i,o;try{return await fetch(`${e.baseUrl}/chat/completions`,{method:"POST",headers:(n=t.stream?"text/event-stream":"application/json",{"content-type":"application/json",accept:n,...(a=e.kind,!(i=e.secret.apiKey)?{}:"x-goog-api-key"===L[a].auth?{"x-goog-api-key":i}:{Authorization:`Bearer ${i}`})}),body:JSON.stringify(t),signal:AbortSignal.any([r,AbortSignal.timeout(s)]),redirect:"error",cache:"no-store"})}catch(n){let t,s;if(r.aborted)throw n;throw o=e.name,new U({type:"upstream_error",errorClass:s=(t=n instanceof Error&&("TimeoutError"===n.name||"AbortError"===n.name))?"timeout":"network",retryAfter:null,status:t?504:502},q(s,0,o))}}function B(e,t,r,s){let n=[];for(let a of["requests","tokens"]){let i=r.get(`x-ratelimit-limit-${a}`),o=r.get(`x-ratelimit-remaining-${a}`);if(null===i&&null===o)continue;let l=null!==i&&/^\d+$/.test(i.trim())?Number(i):null,c=null!==o&&/^\d+$/.test(o.trim())?Number(o):null;if(null===l&&null===c)continue;let u=function(e){if(!e)return null;let t=e.trim();if(/^\d+(\.\d+)?$/.test(t))return 1e3*Number(t);let r=/(\d+(?:\.\d+)?)(ms|h|m|s)/g,s=0,n="";for(let e=r.exec(t);e;e=r.exec(t)){n+=e[0];let t=Number(e[1]);s+="h"===e[2]?36e5*t:"m"===e[2]?6e4*t:"s"===e[2]?1e3*t:t}return n===t&&n?Math.round(s):null}(r.get(`x-ratelimit-reset-${a}`));n.push({providerId:e.id,scope:t??"all",metric:a,limit:l,remaining:c,used:null!==l&&null!==c?Math.max(0,l-c):null,resetAt:null!==u?new Date(s.getTime()+u):null,source:"header"})}return n}let z="Bring your own key (/ai/providers)";function F(e,t){if(e.length<=t)return e;let r="";for(let s of e){if(r.length+s.length>t-1)break;r+=s}return`${r.trimEnd()}…`}let W=e=>e.replace(/\s+/g," ").trim(),H=(e,t)=>F(W(e.provider)||"unnamed",t);function G(e){var t;return"network"===e.errorClass||"timeout"===e.errorClass||502===(t=e.status)||503===t||504===t||t>=520&&t<=530?"unreachable":"auth_rejected"===e.errorClass||"project_denied"===e.errorClass||"project_restricted"===e.errorClass||401===e.status||403===e.status?"auth":"rate_limited"===e.errorClass||429===e.status?"rate_limited":"bad_response"===e.errorClass?"unreadable":e.status>=500?"server":"other"}function K(e){let t=G(e);return"unreachable"===t||"rate_limited"===t||"server"===t||"unreadable"===t}let J={en:{unreachable:e=>`AI provider "${e}" is unreachable (its endpoint or tunnel is down).`,auth:(e,t)=>`AI provider "${e}" refused the key${t?` (${t})`:""}.`,replaceKey:`Replace it on ${z}.`,rate_limited:e=>`AI provider "${e}" is rate limited (429): its quota is used up.`,server:(e,t)=>`AI provider "${e}" failed with a server error (${t}).`,unreadable:e=>`AI provider "${e}" sent an answer Watchbell can't read.`,other:(e,t)=>`AI provider "${e}" answered ${t}.`,tried:(e,t)=>`Tried "${e}" instead, and that failed too (${t}).`,none:e=>`No other provider is enabled: add one on ${z}, or ${e?"try again later":"check the endpoint"}.`,pinned:()=>"This model was picked by name, so no other provider was tried.",outOfTime:"There was no time left to try another provider.",why:{unreachable:()=>"unreachable",auth:e=>`key refused${e?`, ${e}`:""}`,rate_limited:()=>"rate limited, 429",server:e=>`server error ${e}`,unreadable:()=>"unreadable answer",other:e=>`answered ${e}`}},id:{unreachable:e=>`Penyedia AI "${e}" tak bisa dihubungi (endpoint atau tunnel-nya mati).`,auth:(e,t)=>`Penyedia AI "${e}" menolak kuncinya${t?` (${t})`:""}.`,replaceKey:`Ganti kuncinya di ${z}.`,rate_limited:e=>`Penyedia AI "${e}" kena batas pemakaian (429): kuotanya habis.`,server:(e,t)=>`Penyedia AI "${e}" gagal karena error di servernya (${t}).`,unreadable:e=>`Penyedia AI "${e}" mengirim jawaban yang tidak bisa dibaca Watchbell.`,other:(e,t)=>`Penyedia AI "${e}" menjawab ${t}.`,tried:(e,t)=>`Sudah dicoba "${e}" sebagai gantinya, tapi juga gagal (${t}).`,none:e=>`Tak ada penyedia lain yang aktif: tambah di ${z}, atau ${e?"coba lagi nanti":"cek endpoint-nya"}.`,pinned:()=>"Model ini dipilih langsung, jadi penyedia lain tidak dicoba.",outOfTime:"Tidak ada waktu tersisa untuk mencoba penyedia lain.",why:{unreachable:()=>"tidak bisa dihubungi",auth:e=>`kunci ditolak${e?`, ${e}`:""}`,rate_limited:()=>"kena batas pemakaian, 429",server:e=>`error server ${e}`,unreadable:()=>"jawabannya tidak terbaca",other:e=>`menjawab ${e}`}}},V=e=>e.detail?F(W(e.detail),160):"";function Y(e,t,r="en"){let s=s=>{let n=function(e,t,r){let s=J[t],n=H(e,r);switch(G(e)){case"unreachable":return s.unreachable(n);case"auth":{let t="project_denied"===e.errorClass||"project_restricted"===e.errorClass?V(e):"";return`${s.auth(n,e.status)} ${t||s.replaceKey}`}case"rate_limited":return s.rate_limited(n);case"server":return s.server(n,e.status);case"unreadable":return s.unreadable(n);default:return V(e)||s.other(n,e.status)}}(e,r,s);return K(e)?`${n} ${function(e,t,r,s){let n=J[r],a="rate_limited"===G(t);switch(e.kind){case"tried":{let t=e.fallback;return n.tried(H(t,s),n.why[G(t)](t.status))}case"none":return n.none(a);case"pinned":return n.pinned();default:return n.outOfTime}}(t,e,r,s)}`:n};for(let e=60;e>8;e--){let t=s(e);if(t.length<=200)return t}return F(s(8),200)}var X=e.i(336763),I=_,Z=e.i(530298),Q=e.i(803237),ee=e.i(93387),et=e.i(898757);function er(e){let t=e.trim();if(t.startsWith("@cf/"))return{provider:null,model:t};let r=t.indexOf("/");if(r<=0)return{provider:null,model:t};let s=t.slice(0,r).toLowerCase(),n=t.slice(r+1);return"models"===s?{provider:null,model:n}:{provider:s,model:n}}function es(e,t){let r;return!0===e.manual||"custom"===t||((r=e.upstream.trim()).startsWith("@cf/")?(0,et.S)(r,D):(0,et.S)(er(r).model,N))}function en(e){let t=e.find(e=>"gemini-3.8-flash"===e.id);if(t)return t;let r=e=>(/gemma-(\d+(?:\.\d+)?)/.exec(e)?.[1]??"0").split(".").map(Number),s=e=>Number(/-(\d+(?:\.\d+)?)b-/.exec(`${e}-`)?.[1]??0),n=e.filter(e=>e.upstream.startsWith("@cf/google/gemma")&&/(-it|instruct)(-|$)/.test(e.id));return n.sort((e,t)=>{let[n,a]=[r(e.id),r(t.id)];for(let e=0;e<Math.max(n.length,a.length);e++)if((a[e]??0)!==(n[e]??0))return(a[e]??0)-(n[e]??0);return s(t.id)-s(e.id)||e.id.localeCompare(t.id)}),n[0]??e[0]??null}function ea(e,t){return`${e.slug}/${t.id}`}function ei(e,t=null){let r=e.filter(e=>e.enabled);return t?r.find(e=>e.id===t)??null:r.find(e=>e.isDefault)??(1===r.length?r[0]:null)}function eo(e,t,r){let s,n,a=(r?.model?r.model:t).trim(),{provider:i,model:o}=er(a),l=e.filter(e=>e.enabled);if(0===l.length)return"provider_not_connected";if(i&&e.some(e=>e.slug===i)){if(!(s=l.find(e=>e.slug===i)??null))return"provider_not_connected";if(r?.providerId&&s.id!==r.providerId)return"model_not_enabled";n=[o]}else{if(!(s=ei(e,r?.providerId??null)))return"provider_not_connected";n=i?[a]:[...new Set([o,a])]}let c=s.models.find(e=>e.enabled&&(n.includes(e.id)||n.includes(e.upstream)));return c&&es(c,s.kind)?{conn:s,model:c,publicId:ea(s,c)}:"model_not_enabled"}l.f.id,l.f.kind,l.f.name,l.f.baseUrl,l.f.keyHint,l.f.enabled,l.f.isDefault,l.f.models,l.f.limits,l.f.lastTestAt,l.f.lastTestStatus,l.f.lastError,l.f.createdAt;let el=null;async function ec(e=Date.now(),t=!1){if(!t&&el&&e-el.at<6e4)return el.conns;let r=await (0,o.db)().select().from(l.f),s=(0,ee.serverEnv)().OPS_ENCRYPTION_KEY,n=[];for(let e of r){var a,i,c;let t;if(a=e.kind,!P.includes(a))continue;let r=(0,Q.V)({ciphertext:e.ciphertext,iv:e.iv},s);if(r){try{t=JSON.parse(r)}catch{continue}n.push({id:e.id,kind:e.kind,name:e.name,slug:(i=e.kind,c=e.name,"custom"!==i?i:c.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"custom"),baseUrl:e.baseUrl,secret:t,enabled:e.enabled,isDefault:e.isDefault,models:e.models,limits:e.limits,updatedAt:e.updatedAt})}}return el={at:e,conns:n},n}async function eu(){try{let[e]=await (0,o.db)().select({value:Z.settings.value}).from(Z.settings).where((0,X.eq)(Z.settings.key,et.L)).limit(1);return"string"==typeof e?.value&&e.value.trim()?e.value.trim():null}catch{return console.warn("reading ai.defaultModel failed; using the provider's default model"),null}}async function ed(e,t){let r=eo(await ec(),e,t);return"string"==typeof r?r:{conn:r.conn,upstream:r.model.upstream,publicId:r.publicId}}v.z.array(I.strictObject({metric:b.z.enum(["requests","tokens"]),scope:w.z.string().trim().min(1).max(100).regex(/^[A-Za-z0-9._:-]+$/),limit:m.z.number().int().min(1).max(1e12),window:b.z.enum(["minute","day","week"])})).max(10);let eh=()=>m.z.number().finite(),ep=g.z.looseObject({role:b.z.enum(["system","developer","user","assistant","tool","function"]),content:y.z.union([w.z.string(),v.z.array(k.z.unknown()),_.null()]).optional()});S.z.object({model:w.z.string().trim().min(1).max(200),messages:v.z.array(ep).min(1).max(100),stream:x.z.boolean().nullish(),stream_options:g.z.looseObject({}).nullish(),temperature:eh().min(0).max(2).nullish(),top_p:eh().min(0).max(1).nullish(),max_tokens:m.z.number().int().min(1).max(1e6).nullish(),max_completion_tokens:m.z.number().int().min(1).max(1e6).nullish(),stop:y.z.union([w.z.string().max(200),v.z.array(w.z.string().max(200)).max(4)]).nullish(),n:A.z.literal(1).nullish(),presence_penalty:eh().min(-2).max(2).nullish(),frequency_penalty:eh().min(-2).max(2).nullish(),seed:m.z.number().int().nullish(),response_format:g.z.looseObject({type:w.z.string().max(40)}).nullish(),tools:v.z.array(g.z.looseObject({})).max(128).nullish(),tool_choice:y.z.union([w.z.string().max(40),g.z.looseObject({})]).nullish(),user:w.z.string().max(256).nullish()});let ef=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null;function em(e,t=[]){return p(e,t).catch(e=>{console.error("ai usage not recorded:",e instanceof Error?e.name:"unknown")})}function eg(e){try{(0,u.after)(e)}catch{e()}}class eb extends Error{type;status;failure;constructor(e,t,r,s){super(t),this.type=e,this.status=r,this.failure=s,this.name="GatewayError"}}async function ey(e){if(e){let t=await ed(e,null);if("provider_not_connected"===t)throw new eb(t,"No AI provider is connected. Connect one under AI Gateway › Bring your own key.",503);if("model_not_enabled"===t)throw new eb(t,`Model "${e.slice(0,120)}" isn't enabled.`,400);return t}let[t,r]=await Promise.all([ec(),eu()]);if(r){let e=eo(t,r,null);if("string"!=typeof e)return{conn:e.conn,upstream:e.model.upstream,publicId:e.publicId}}let s=ei(t);if(!s)throw new eb("provider_not_connected","No AI provider is connected. Connect one under AI Gateway › Bring your own key.",503);let n=en(s.models.filter(e=>e.enabled&&es(e,s.kind)));if(!n)throw new eb("model_not_enabled",`No model is turned on for ${s.name}. Turn one on under Models.`,400);return{conn:s,upstream:n.upstream,publicId:ea(s,n)}}async function ew(e,t,r,s=r.timeoutMs){var n;let a,i=Date.now(),{conn:o,upstream:l,publicId:c}=e,u={...d,userAgent:`Watchbell console (${r.purpose})`},h={at:new Date(i),keyId:null,client:u,providerId:o.id,model:c,kind:"console",tool:null,stream:!1},p={model:l,messages:t,max_tokens:Math.min(Math.max(r.maxTokens??1024,1),8192),...void 0!==r.temperature?{temperature:r.temperature}:{}},f=(e,t,r)=>{let s={provider:o.name,...r};return new eb(e,Y(s,{kind:"none"}),t,{first:s,next:{kind:"none"}})};try{a=s?await M(o,p,new AbortController().signal,s):await M(o,p,new AbortController().signal)}catch(t){let e=t instanceof U?t.info:{type:"upstream_error",errorClass:"network",status:502};throw eg(()=>em({...h,latencyMs:Date.now()-i,status:e.status,errorClass:`${e.type} \xb7 ${e.errorClass}`,tokensIn:null,tokensOut:null})),f(e.type,e.status,{status:0,errorClass:e.errorClass,detail:t instanceof U?t.message:q("network",0,o.name)})}if(!a.ok){let e=await a.text().catch(()=>""),t=function(e,t){let r=t.slice(0,2e4);if(429===e){let e;return{type:"quota_exceeded",errorClass:"rate_limited",retryAfter:(e=/"retryDelay"\s*:\s*"(\d+(?:\.\d+)?)s"/.exec(r))?Math.max(1,Math.ceil(Number(e[1]))):null,status:429}}return 403===e&&/denied access/i.test(r)?{type:"upstream_error",errorClass:"project_denied",retryAfter:null,status:502}:403===e&&/restricted|billing/i.test(r)?{type:"upstream_error",errorClass:"project_restricted",retryAfter:null,status:502}:401===e||403===e||/API_KEY_INVALID|API key not valid|API_KEY_SERVICE_BLOCKED|ACCESS_TOKEN_TYPE_UNSUPPORTED/.test(r)?{type:"upstream_error",errorClass:"auth_rejected",retryAfter:null,status:502}:404===e?{type:"invalid_request",errorClass:"model_not_found",retryAfter:null,status:404}:400===e||413===e||422===e?{type:"invalid_request",errorClass:"bad_request",retryAfter:null,status:e}:e>=500?{type:"upstream_error",errorClass:"server_error",retryAfter:null,status:502}:{type:"upstream_error",errorClass:`http_${e}`,retryAfter:null,status:502}}(a.status,e);throw eg(()=>em({...h,latencyMs:Date.now()-i,status:t.status,errorClass:`${t.type} \xb7 ${t.errorClass}`,tokensIn:null,tokensOut:null},B(o,l,a.headers,new Date))),f(t.type,t.status,{status:a.status,errorClass:t.errorClass,detail:q(t.errorClass,a.status,o.name)})}let m=await a.json().catch(()=>null),g=m?.choices?.[0]?.message?.content,b="string"==typeof g?g:Array.isArray(g)?g.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"",y=((n=m?.usage)&&"object"==typeof n?{in:ef(n.prompt_tokens),out:ef(n.completion_tokens)}:null)??{in:null,out:null},w=Date.now()-i,v=null!==m;if(eg(()=>{var e,t;let r;return em({...h,latencyMs:w,status:v?200:502,errorClass:v?null:"upstream_error · bad_response",tokensIn:y.in,tokensOut:y.out},(e=a.headers,t=new Date,r=y&&(null!==y.in||null!==y.out)?(y.in??0)+(y.out??0):null,[...e?B(o,l,e,t):[],...function(e,t,r,s,n){let a=[];for(let i of t.map(e=>{let t=function(e,t){let r=t.getTime();if("minute"===e){let e=6e4*Math.floor(r/6e4);return{start:new Date(e),end:new Date(e+6e4)}}let s=864e5*Math.floor(r/864e5);if("day"===e)return{start:new Date(s),end:new Date(s+864e5)};let n=(new Date(s).getUTCDay()+6)%7,a=s-864e5*n;return{start:new Date(a),end:new Date(a+6048e5)}}(e.window,n);return{...e,start:t.start,resetAt:t.end}})){if("all"!==i.scope&&i.scope!==r)continue;let t="tokens"===i.metric?s??0:1;a.push({providerId:e,scope:i.scope,metric:`${i.metric}:${i.window}`,limit:i.limit,remaining:null,used:t,resetAt:i.resetAt,source:"own"})}return a}(o.id,o.limits,l,r,t)]))}),!v)throw f("upstream_error",502,{status:a.status,errorClass:"bad_response",detail:q("bad_response",a.status,o.name)});return{text:b,model:c,usage:y,ms:w}}let ev=new Set([429,500,502,503,504]),ek=2/3;async function e_(e){for(let t of(await ec()).filter(t=>t.enabled&&t.id!==e)){let e=en(t.models.filter(e=>e.enabled&&es(e,t.kind)));if(e)return{conn:t,upstream:e.upstream,publicId:ea(t,e)}}return null}function eS(e,t){return e instanceof eb&&e.failure?new eb(e.type,Y(e.failure.first,t),e.status,{first:e.failure.first,next:t}):e}async function ex(e,t){let r;if((0,R.isDemo)())return{text:T.v,model:"demo",usage:{in:null,out:null},ms:0};let s=Date.now(),n=await ey(t.model),a=!t.model||!0===t.fallback,i=async()=>void 0===r?r=await e_(n.conn.id).catch(()=>null):r,o=t.timeoutMs;if(t.timeoutMs&&a){let e=Math.floor(t.timeoutMs*(1-ek));e>=3e3&&await i()&&(o=t.timeoutMs-e)}try{return await ew(n,e,t,o)}catch(l){if(!(l instanceof eb&&(l.failure?K(l.failure.first):ev.has(l.status))))throw l;if(!a)throw eS(l,{kind:"pinned"});let r=await i();if(!r)throw eS(l,{kind:"none"});let o=t.timeoutMs?t.timeoutMs-(Date.now()-s):void 0;if(void 0!==o&&o<3e3)throw eS(l,{kind:"out-of-time"});console.info(`ai: ${n.conn.name} failed, trying ${r.conn.name}`);try{return await ew(r,e,t,o)}catch(t){let e=t instanceof eb?t.failure?.first:void 0;throw e?eS(l,{kind:"tried",fallback:e}):t}}}e.s(["X",0,ex,"M",0,ey],585585)},25734,423660,27626,64858,248744,379593,717799,e=>{let t,r,s,n,a,i,o,l;var c,u,d,h,p,f,m,g,b,y,w,v,k,_,S,x=e.i(336763),A=e.i(533102),T=e.i(406212),R=e.i(200123),E=e.i(530298),I=e.i(585585),j=e.i(910931),O=e.i(455891),C=e.i(234195),$=e.i(42784),P=e.i(589878);e.i(464161),e.i(451682);var N=e.i(380719),D=e.i(760859),L=e.i(412948),U=e.i(216899),q=e.i(785194),M=e.i(164617),B=e.i(857799);let z=e=>"heartbeat"===e.kind?e.lastError?e.lastError.replace(/^(Down|Late) · /,""):"warn"===e.state?"Late":"No ping":(0,M.H)(e)??(e.lastStatus?`HTTP ${e.lastStatus}`:e.lastError||"No answer");var F=e.i(756371);let W=["apps","monitors","alerts","advisor"],H=e=>null===e?null:Math.round(100*e)/100,G=(0,j.cache)(()=>(0,P.f)()),K=(0,j.cache)(e=>(0,$.f)(new Date(e))),J=(0,j.cache)(e=>(0,N.d)(new Date(e))),V=(0,j.cache)(()=>(0,C.i)()),Y=(0,j.cache)(e=>(0,O.T)(new Date(e))),X={ok:"running",warn:"degraded",err:"down",build:"building",paused:"paused",maint:"paused"},Z={ok:"up",warn:"degraded",err:"down"},Q=(e,t,r)=>{let s=(0,U.k)(e),n=function(e){if(e.gone)return[];let t=[],r=e.monitors.filter(e=>(0,M.i)(e)&&!e.maintUntil&&("err"===e.state||"warn"===e.state)),s=e=>2*("heartbeat"===e.kind)+ +("err"!==e.state);for(let e of[...r].sort((e,t)=>s(e)-s(t))){let r="heartbeat"===e.kind,s=r?e.name??e.path:e.path;t.push({kind:"monitor",where:r?`Monitor ${s} (heartbeat)`:`Monitor ${s}`,subject:s,state:e.state,reason:z(e),since:e.stateSince??(r?e.lastPingAt??null:null),href:"/uptime",remedies:r?function(e){let t=(e.lastError??"").toLowerCase();return t.includes("failure")?["The job reported a failure: open its logs","Fix and re-run the job; the next OK ping clears it"]:t.includes("didn't finish")||t.includes("started")?["The job started but never finished: it may have hung or hit its timeout","Check the job's own logs for where it stopped","Raise the job's timeout, or fix what it waits on; the next OK ping clears it"]:["Check that the job's scheduler ran (cron, Vercel Cron, GitHub Actions)","Check the job's own logs for errors before the ping line","Make sure the job calls the ping URL at the end (curl -fsS -m 10 <url>)","If the job is retired, pause or delete the heartbeat"]}(e):function(e){let t=e.lastError??"";if(/blocked address/i.test(t))return["The monitor's URL resolves to a private address; fix the URL in Edit monitor"];let r=(0,M.H)(e);if(r&&/keyword|json|body|content/i.test(r))return["The page answered but its content changed: check the keyword or JSON path in Edit monitor, or the page itself"];let s=e.lastStatus;return null!==s&&s>=500?["Open Logs (last hour) for errors","Check the latest deployment; roll back if it started after the deploy"]:null!==s&&s>=300?["Check the expected status and path in Edit monitor","The route may need sign-in or moved"]:null===s||r?["Check the domain, DNS and the provider status page","Cold start or overload: retry with Check now"]:["Open Logs (last hour) for errors","Check the latest deployment; roll back if it started after the deploy"]}(e)})}e.dbPaused&&e.database&&t.push({kind:"database",where:`Database ${e.database.name}`,subject:e.database.name,state:"warn",reason:"Paused",since:e.stateSince??null,href:(0,B.N)(e.database.kind),remedies:["Restore the database from its provider (Supabase restore)"]});let n=e.lastDeploy;if(n&&"error"===n.state){let e=(0,L._)(n.commitSha);t.push({kind:"deployment",where:`Production deployment ${e}`,subject:e,state:"fail",reason:"Build failed",since:n.readyAt??n.createdAt,href:"/deployments",remedies:["Open the deployment's build logs; redeploy after fixing"]})}return t}({...e,database:e.database?{id:e.database.id,kind:e.database.kind,name:(0,D.X)(t,e.database.id)}:null});return{id:e.name,state:X[s.state]??"unknown",uptime30d:H(e.uptime30),database:e.database?(0,D.X)(t,e.database.id):null,lastDeploy:e.lastDeploy?`${(0,L._)(e.lastDeploy.commitSha)} \xb7 ${(0,L.$)(e.lastDeploy,r)}`:null,problems:n.map(e=>({kind:e.kind,where:(0,F.f)(e.where,t),what:(0,F.f)(e.reason,t),fix:e.remedies.length?(0,F.f)(e.remedies.join("; "),t):null}))}},ee=e=>e.paused||e.ownerPaused?"paused":Z[e.state]??"unknown",et=(0,j.cache)(async e=>{let t=new Date(e),[r,s]=await Promise.all([K(e),G()]);return r.filter(e=>!e.gone).map(e=>Q(e,s,t))}),er=(0,j.cache)(async e=>{let[t,r]=await Promise.all([J(e),G()]),s=t.filter(e=>!e.appGone).map(e=>({app:e.appName,path:(0,F.f)(e.path,r),kind:e.kind,state:ee(e),lastStatus:e.lastStatus,latencyMs:e.lastLatencyMs,uptime30d:H(e.uptime30),lastCheckedAt:e.lastCheckedAt?.toISOString()??null})),n=e=>s.filter(t=>t.state===e).length;return{up:n("up"),degraded:n("degraded"),down:n("down"),paused:n("paused"),items:s.filter(e=>"up"!==e.state)}}),es=(0,j.cache)(async()=>{let[e,t]=await Promise.all([V(),G()]),r=e.slice(0,50).map(e=>{let r=(0,D.o)(e,t);return{title:(0,F.f)(r.title,t),severity:e.severity,app:"app"===e.resourceKind?e.resourceName:null,since:e.startedAt.toISOString(),message:(0,F.f)(r.message,t)}});return{open:e.length,critical:e.filter(e=>"critical"===e.severity).length,items:r}}),en=(0,j.cache)(async e=>{let[t,r,s]=await Promise.all([Y(e),K(e),G()]),n=new Map(r.map(e=>[e.id,e.name]));return t.map(e=>{let t=(0,D.d)(e,s);return{title:(0,F.f)(t.title,s),app:e.appId&&n.get(e.appId)||"console",severity:e.severity}})}),ea=e=>en(e.getTime());async function ei(e,t=W){let r=new Set(t),[s,n,a,i]=await Promise.all([r.has("apps")?et(e.getTime()):Promise.resolve([]),r.has("monitors")?er(e.getTime()):Promise.resolve({up:0,degraded:0,down:0,paused:0}),r.has("alerts")?es():Promise.resolve({open:0,critical:0}),r.has("advisor")?ea(e):Promise.resolve(void 0)]);return{generatedAt:e.toISOString(),apps:s,monitors:n,alerts:a,...i?{advisor:i}:{}}}async function eo(e,t){let r=e.trim().toLowerCase();return r?(await K(t.getTime())).find(e=>!e.gone&&(e.id.toLowerCase()===r||e.name.toLowerCase()===r))??null:null}async function el(e,t){let[r,s]=await Promise.all([eo(e,t),G()]);return r?{...Q(r,s,t),monitors:r.monitors.map(e=>({path:(0,F.f)(e.path,s),kind:e.kind,state:ee(e),lastStatus:e.lastStatus,latencyMs:e.lastLatencyMs,uptime30d:H((0,q.Y)((0,q.w)(r.days.get(e.id),t,q.I)))}))}:null}e.i(586307);let ec=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function eu(){return(0,T.db)().select({id:E.resources.id,name:E.resources.name}).from(E.resources).where((0,x.and)((0,x.eq)(E.resources.kind,"app"),(0,x.eq)(E.resources.monitored,!0))).orderBy(E.resources.name).limit(200)}async function ed(e,t,r,s=new Date){let n=s.toISOString(),a=t?`ai-note:${t}`:`ai-note:${r}`,i=await (0,T.db)().execute(A.sql`
46
+ select (select count(*) from old) as usage, (select count(*) from extra) as agents`)}e.s(["q",0,d,"$",0,f,"h",0,p],515683);var m=e.i(260417),g=e.i(684330),b=e.i(79322),y=e.i(978071),w=e.i(492973),v=e.i(909592),k=e.i(932378),_=e.i(794588),_=_,S=e.i(75064),x=e.i(246517),A=e.i(542746),T=e.i(105464),R=e.i(90879);function E(e){let t=e.maxKeys??1e4,r=new Map;return{has(t,s=Date.now()){let n=r.get(t);return void 0!==n&&(!(s-n>=e.ttlMs)||(r.delete(t),!1))},add(e,s=Date.now()){for(r.delete(e),r.set(e,s);r.size>t;)r.delete(r.keys().next().value)},delete:e=>void r.delete(e),reset:()=>r.clear()}}e.i(666680),e.i(484817),e.i(659916);var I=_,j=_,O=e.i(547963);O.C.writeNotesLong;let $=I.strictObject({name:w.z.string().regex(/^[a-z0-9-]{2,40}$/,"Use 2–40 lowercase letters, digits or dashes."),scopes:v.z.array(b.z.enum(["ai:invoke","read:status","write:notes"])).min(1,"Pick at least one scope.").transform(e=>[...new Set(e)]),expiry:b.z.enum(["7d","30d","90d","1y","never"]).default("90d"),ratePerMin:j.coerce.number("Enter a whole number from 1 to 600.").int("Enter a whole number from 1 to 600.").min(1,"Enter a whole number from 1 to 600.").max(600,"Enter a whole number from 1 to 600.")});$.shape.name,$.shape.ratePerMin;let C={max:30,windowMs:6e5};globalThis.__watchbellKeyFailures??={...a={limit:(t=C.maxKeys??1e4,r=new Map,s=(e,s)=>{let n=r.get(e);for(n&&r.delete(e),(!n||s-n.start>=C.windowMs)&&(n={start:s,n:0}),r.set(e,n);r.size>t;)r.delete(r.keys().next().value);return n},n=(e,t,r)=>({allowed:r,retryAfter:Math.max(1,Math.ceil((e.start+C.windowMs-t)/1e3))}),{hit(e,t=Date.now()){let r=s(e,t);return r.n++,n(r,t,r.n<=C.max)},peek(e,t=Date.now()){let r=s(e,t);return n(r,t,r.n<C.max)},count(e,t=Date.now()){s(e,t).n++},size:()=>r.size,reset:()=>r.clear()}),seen:E({ttlMs:C.windowMs,maxKeys:5e4}),failed:E({ttlMs:6e4})},reset:()=>{a.limit.reset(),a.seen.reset(),a.failed.reset()}};let P=["gemini","cloudflare","custom"],N=["gemini","antigravity"],D=["@cf/google/gemma"],L={gemini:{name:"Google Gemini",baseUrl:()=>"https://generativelanguage.googleapis.com/v1beta/openai",secretFields:["apiKey"],modelsPath:"/models",listModels:"gemini-native",quotaFrom:"own",auth:"x-goog-api-key",streamUsage:!0,advanced:!1,keyLabel:"AI Studio API key",where:{url:"https://aistudio.google.com/apikey",text:"Create a key (it starts with AQ. or AIza). If Google says the project is restricted or denied, use a key from another Google project or account."}},cloudflare:{name:"Cloudflare Workers AI",baseUrl:e=>`https://api.cloudflare.com/client/v4/accounts/${e.accountId??""}/ai/v1`,secretFields:["accountId","apiKey"],modelsPath:"/models/search",listModels:"cloudflare-search",quotaFrom:"own",auth:"bearer",streamUsage:!0,advanced:!1,keyLabel:"API token",where:{url:"https://dash.cloudflare.com/profile/api-tokens",text:"Create a token with Workers AI: Read. The account ID is on the Workers AI page. Only Google's Gemma models are offered."}},custom:{name:"Custom OpenAI-compatible",baseUrl:e=>(e.baseUrl??"").replace(/\/+$/,""),secretFields:["baseUrl","apiKey"],modelsPath:"/models",listModels:"openai",quotaFrom:"headers",auth:"bearer",streamUsage:!0,advanced:!0,keyLabel:"API key",where:{url:null,text:"Any HTTPS server that speaks the OpenAI chat completions API and answers GET /models. Every model the server lists is offered; switch any off on Models."}}};O.Y.localUrl;class U extends Error{info;constructor(e,t){super(t),this.info=e,this.name="UpstreamError"}}function q(e,t,r){switch(e){case"project_denied":return"Google denied this project's Gemini API access. Use a key from another Google project or account.";case"project_restricted":return"This Google project's Gemini API access is restricted. Create a key in another project or enable billing.";case"auth_rejected":return`${r} rejected the API key (${t}). Replace it under Bring your own key.`;case"rate_limited":return`${r} says the rate limit or quota is used up (429). Try again later.`;case"model_not_found":return`${r} doesn't know this model (404).`;case"bad_request":return`${r} refused the request (${t}). Check the request body.`;case"server_error":return`${r} failed (${t}). Try again later.`;case"timeout":return`${r} didn't answer within 60 s.`;case"network":return`Can't reach ${r}.`;case"bad_response":return`${r} sent an answer Watchbell can't read.`;default:return`${r} answered ${t}.`}}async function M(e,t,r,s=6e4){var n,a,i,o;try{return await fetch(`${e.baseUrl}/chat/completions`,{method:"POST",headers:(n=t.stream?"text/event-stream":"application/json",{"content-type":"application/json",accept:n,...(a=e.kind,!(i=e.secret.apiKey)?{}:"x-goog-api-key"===L[a].auth?{"x-goog-api-key":i}:{Authorization:`Bearer ${i}`})}),body:JSON.stringify(t),signal:AbortSignal.any([r,AbortSignal.timeout(s)]),redirect:"error",cache:"no-store"})}catch(n){let t,s;if(r.aborted)throw n;throw o=e.name,new U({type:"upstream_error",errorClass:s=(t=n instanceof Error&&("TimeoutError"===n.name||"AbortError"===n.name))?"timeout":"network",retryAfter:null,status:t?504:502},q(s,0,o))}}function B(e,t,r,s){let n=[];for(let a of["requests","tokens"]){let i=r.get(`x-ratelimit-limit-${a}`),o=r.get(`x-ratelimit-remaining-${a}`);if(null===i&&null===o)continue;let l=null!==i&&/^\d+$/.test(i.trim())?Number(i):null,c=null!==o&&/^\d+$/.test(o.trim())?Number(o):null;if(null===l&&null===c)continue;let u=function(e){if(!e)return null;let t=e.trim();if(/^\d+(\.\d+)?$/.test(t))return 1e3*Number(t);let r=/(\d+(?:\.\d+)?)(ms|h|m|s)/g,s=0,n="";for(let e=r.exec(t);e;e=r.exec(t)){n+=e[0];let t=Number(e[1]);s+="h"===e[2]?36e5*t:"m"===e[2]?6e4*t:"s"===e[2]?1e3*t:t}return n===t&&n?Math.round(s):null}(r.get(`x-ratelimit-reset-${a}`));n.push({providerId:e.id,scope:t??"all",metric:a,limit:l,remaining:c,used:null!==l&&null!==c?Math.max(0,l-c):null,resetAt:null!==u?new Date(s.getTime()+u):null,source:"header"})}return n}let z="Bring your own key (/ai/providers)";function F(e,t){if(e.length<=t)return e;let r="";for(let s of e){if(r.length+s.length>t-1)break;r+=s}return`${r.trimEnd()}…`}let W=e=>e.replace(/\s+/g," ").trim(),H=(e,t)=>F(W(e.provider)||"unnamed",t);function G(e){var t;return"network"===e.errorClass||"timeout"===e.errorClass||502===(t=e.status)||503===t||504===t||t>=520&&t<=530?"unreachable":"auth_rejected"===e.errorClass||"project_denied"===e.errorClass||"project_restricted"===e.errorClass||401===e.status||403===e.status?"auth":"rate_limited"===e.errorClass||429===e.status?"rate_limited":"bad_response"===e.errorClass?"unreadable":e.status>=500?"server":"other"}function K(e){let t=G(e);return"unreachable"===t||"rate_limited"===t||"server"===t||"unreadable"===t}let J={en:{unreachable:e=>`AI provider "${e}" is unreachable (its endpoint or tunnel is down).`,auth:(e,t)=>`AI provider "${e}" refused the key${t?` (${t})`:""}.`,replaceKey:`Replace it on ${z}.`,rate_limited:e=>`AI provider "${e}" is rate limited (429): its quota is used up.`,server:(e,t)=>`AI provider "${e}" failed with a server error (${t}).`,unreadable:e=>`AI provider "${e}" sent an answer Watchbell can't read.`,other:(e,t)=>`AI provider "${e}" answered ${t}.`,tried:(e,t)=>`Tried "${e}" instead, and that failed too (${t}).`,none:e=>`No other provider is enabled: add one on ${z}, or ${e?"try again later":"check the endpoint"}.`,pinned:()=>"This model was picked by name, so no other provider was tried.",outOfTime:"There was no time left to try another provider.",why:{unreachable:()=>"unreachable",auth:e=>`key refused${e?`, ${e}`:""}`,rate_limited:()=>"rate limited, 429",server:e=>`server error ${e}`,unreadable:()=>"unreadable answer",other:e=>`answered ${e}`}},id:{unreachable:e=>`Penyedia AI "${e}" tak bisa dihubungi (endpoint atau tunnel-nya mati).`,auth:(e,t)=>`Penyedia AI "${e}" menolak kuncinya${t?` (${t})`:""}.`,replaceKey:`Ganti kuncinya di ${z}.`,rate_limited:e=>`Penyedia AI "${e}" kena batas pemakaian (429): kuotanya habis.`,server:(e,t)=>`Penyedia AI "${e}" gagal karena error di servernya (${t}).`,unreadable:e=>`Penyedia AI "${e}" mengirim jawaban yang tidak bisa dibaca Watchbell.`,other:(e,t)=>`Penyedia AI "${e}" menjawab ${t}.`,tried:(e,t)=>`Sudah dicoba "${e}" sebagai gantinya, tapi juga gagal (${t}).`,none:e=>`Tak ada penyedia lain yang aktif: tambah di ${z}, atau ${e?"coba lagi nanti":"cek endpoint-nya"}.`,pinned:()=>"Model ini dipilih langsung, jadi penyedia lain tidak dicoba.",outOfTime:"Tidak ada waktu tersisa untuk mencoba penyedia lain.",why:{unreachable:()=>"tidak bisa dihubungi",auth:e=>`kunci ditolak${e?`, ${e}`:""}`,rate_limited:()=>"kena batas pemakaian, 429",server:e=>`error server ${e}`,unreadable:()=>"jawabannya tidak terbaca",other:e=>`menjawab ${e}`}}},V=e=>e.detail?F(W(e.detail),160):"";function Y(e,t,r="en"){let s=s=>{let n=function(e,t,r){let s=J[t],n=H(e,r);switch(G(e)){case"unreachable":return s.unreachable(n);case"auth":{let t="project_denied"===e.errorClass||"project_restricted"===e.errorClass?V(e):"";return`${s.auth(n,e.status)} ${t||s.replaceKey}`}case"rate_limited":return s.rate_limited(n);case"server":return s.server(n,e.status);case"unreadable":return s.unreadable(n);default:return V(e)||s.other(n,e.status)}}(e,r,s);return K(e)?`${n} ${function(e,t,r,s){let n=J[r],a="rate_limited"===G(t);switch(e.kind){case"tried":{let t=e.fallback;return n.tried(H(t,s),n.why[G(t)](t.status))}case"none":return n.none(a);case"pinned":return n.pinned();default:return n.outOfTime}}(t,e,r,s)}`:n};for(let e=60;e>8;e--){let t=s(e);if(t.length<=200)return t}return F(s(8),200)}var Z=e.i(336763),I=_,X=e.i(530298),Q=e.i(803237),ee=e.i(93387),et=e.i(898757);function er(e){let t=e.trim();if(t.startsWith("@cf/"))return{provider:null,model:t};let r=t.indexOf("/");if(r<=0)return{provider:null,model:t};let s=t.slice(0,r).toLowerCase(),n=t.slice(r+1);return"models"===s?{provider:null,model:n}:{provider:s,model:n}}function es(e,t){let r;return!0===e.manual||"custom"===t||((r=e.upstream.trim()).startsWith("@cf/")?(0,et.S)(r,D):(0,et.S)(er(r).model,N))}function en(e){let t=e.find(e=>"gemini-3.8-flash"===e.id);if(t)return t;let r=e=>(/gemma-(\d+(?:\.\d+)?)/.exec(e)?.[1]??"0").split(".").map(Number),s=e=>Number(/-(\d+(?:\.\d+)?)b-/.exec(`${e}-`)?.[1]??0),n=e.filter(e=>e.upstream.startsWith("@cf/google/gemma")&&/(-it|instruct)(-|$)/.test(e.id));return n.sort((e,t)=>{let[n,a]=[r(e.id),r(t.id)];for(let e=0;e<Math.max(n.length,a.length);e++)if((a[e]??0)!==(n[e]??0))return(a[e]??0)-(n[e]??0);return s(t.id)-s(e.id)||e.id.localeCompare(t.id)}),n[0]??e[0]??null}function ea(e,t){return`${e.slug}/${t.id}`}function ei(e,t=null){let r=e.filter(e=>e.enabled);return t?r.find(e=>e.id===t)??null:r.find(e=>e.isDefault)??(1===r.length?r[0]:null)}function eo(e,t,r){let s,n,a=(r?.model?r.model:t).trim(),{provider:i,model:o}=er(a),l=e.filter(e=>e.enabled);if(0===l.length)return"provider_not_connected";if(i&&e.some(e=>e.slug===i)){if(!(s=l.find(e=>e.slug===i)??null))return"provider_not_connected";if(r?.providerId&&s.id!==r.providerId)return"model_not_enabled";n=[o]}else{if(!(s=ei(e,r?.providerId??null)))return"provider_not_connected";n=i?[a]:[...new Set([o,a])]}let c=s.models.find(e=>e.enabled&&(n.includes(e.id)||n.includes(e.upstream)));return c&&es(c,s.kind)?{conn:s,model:c,publicId:ea(s,c)}:"model_not_enabled"}l.f.id,l.f.kind,l.f.name,l.f.baseUrl,l.f.keyHint,l.f.enabled,l.f.isDefault,l.f.models,l.f.limits,l.f.lastTestAt,l.f.lastTestStatus,l.f.lastError,l.f.createdAt;let el=null;async function ec(e=Date.now(),t=!1){if(!t&&el&&e-el.at<6e4)return el.conns;let r=await (0,o.db)().select().from(l.f),s=(0,ee.serverEnv)().OPS_ENCRYPTION_KEY,n=[];for(let e of r){var a,i,c;let t;if(a=e.kind,!P.includes(a))continue;let r=(0,Q.V)({ciphertext:e.ciphertext,iv:e.iv},s);if(r){try{t=JSON.parse(r)}catch{continue}n.push({id:e.id,kind:e.kind,name:e.name,slug:(i=e.kind,c=e.name,"custom"!==i?i:c.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"custom"),baseUrl:e.baseUrl,secret:t,enabled:e.enabled,isDefault:e.isDefault,models:e.models,limits:e.limits,updatedAt:e.updatedAt})}}return el={at:e,conns:n},n}async function eu(){try{let[e]=await (0,o.db)().select({value:X.settings.value}).from(X.settings).where((0,Z.eq)(X.settings.key,et.L)).limit(1);return"string"==typeof e?.value&&e.value.trim()?e.value.trim():null}catch{return console.warn("reading ai.defaultModel failed; using the provider's default model"),null}}async function ed(e,t){let r=eo(await ec(),e,t);return"string"==typeof r?r:{conn:r.conn,upstream:r.model.upstream,publicId:r.publicId}}v.z.array(I.strictObject({metric:b.z.enum(["requests","tokens"]),scope:w.z.string().trim().min(1).max(100).regex(/^[A-Za-z0-9._:-]+$/),limit:m.z.number().int().min(1).max(1e12),window:b.z.enum(["minute","day","week"])})).max(10);let eh=()=>m.z.number().finite(),ep=g.z.looseObject({role:b.z.enum(["system","developer","user","assistant","tool","function"]),content:y.z.union([w.z.string(),v.z.array(k.z.unknown()),_.null()]).optional()});S.z.object({model:w.z.string().trim().min(1).max(200),messages:v.z.array(ep).min(1).max(100),stream:x.z.boolean().nullish(),stream_options:g.z.looseObject({}).nullish(),temperature:eh().min(0).max(2).nullish(),top_p:eh().min(0).max(1).nullish(),max_tokens:m.z.number().int().min(1).max(1e6).nullish(),max_completion_tokens:m.z.number().int().min(1).max(1e6).nullish(),stop:y.z.union([w.z.string().max(200),v.z.array(w.z.string().max(200)).max(4)]).nullish(),n:A.z.literal(1).nullish(),presence_penalty:eh().min(-2).max(2).nullish(),frequency_penalty:eh().min(-2).max(2).nullish(),seed:m.z.number().int().nullish(),response_format:g.z.looseObject({type:w.z.string().max(40)}).nullish(),tools:v.z.array(g.z.looseObject({})).max(128).nullish(),tool_choice:y.z.union([w.z.string().max(40),g.z.looseObject({})]).nullish(),user:w.z.string().max(256).nullish()});let ef=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null;function em(e,t=[]){return p(e,t).catch(e=>{console.error("ai usage not recorded:",e instanceof Error?e.name:"unknown")})}function eg(e){try{(0,u.after)(e)}catch{e()}}class eb extends Error{type;status;failure;constructor(e,t,r,s){super(t),this.type=e,this.status=r,this.failure=s,this.name="GatewayError"}}async function ey(e){if(e){let t=await ed(e,null);if("provider_not_connected"===t)throw new eb(t,"No AI provider is connected. Connect one under AI Gateway › Bring your own key.",503);if("model_not_enabled"===t)throw new eb(t,`Model "${e.slice(0,120)}" isn't enabled.`,400);return t}let[t,r]=await Promise.all([ec(),eu()]);if(r){let e=eo(t,r,null);if("string"!=typeof e)return{conn:e.conn,upstream:e.model.upstream,publicId:e.publicId}}let s=ei(t);if(!s)throw new eb("provider_not_connected","No AI provider is connected. Connect one under AI Gateway › Bring your own key.",503);let n=en(s.models.filter(e=>e.enabled&&es(e,s.kind)));if(!n)throw new eb("model_not_enabled",`No model is turned on for ${s.name}. Turn one on under Models.`,400);return{conn:s,upstream:n.upstream,publicId:ea(s,n)}}async function ew(e,t,r,s=r.timeoutMs){var n;let a,i=Date.now(),{conn:o,upstream:l,publicId:c}=e,u={...d,userAgent:`Watchbell console (${r.purpose})`},h={at:new Date(i),keyId:null,client:u,providerId:o.id,model:c,kind:"console",tool:null,stream:!1},p={model:l,messages:t,max_tokens:Math.min(Math.max(r.maxTokens??1024,1),8192),...void 0!==r.temperature?{temperature:r.temperature}:{}},f=(e,t,r)=>{let s={provider:o.name,...r};return new eb(e,Y(s,{kind:"none"}),t,{first:s,next:{kind:"none"}})};try{a=s?await M(o,p,new AbortController().signal,s):await M(o,p,new AbortController().signal)}catch(t){let e=t instanceof U?t.info:{type:"upstream_error",errorClass:"network",status:502};throw eg(()=>em({...h,latencyMs:Date.now()-i,status:e.status,errorClass:`${e.type} \xb7 ${e.errorClass}`,tokensIn:null,tokensOut:null})),f(e.type,e.status,{status:0,errorClass:e.errorClass,detail:t instanceof U?t.message:q("network",0,o.name)})}if(!a.ok){let e=await a.text().catch(()=>""),t=function(e,t){let r=t.slice(0,2e4);if(429===e){let e;return{type:"quota_exceeded",errorClass:"rate_limited",retryAfter:(e=/"retryDelay"\s*:\s*"(\d+(?:\.\d+)?)s"/.exec(r))?Math.max(1,Math.ceil(Number(e[1]))):null,status:429}}return 403===e&&/denied access/i.test(r)?{type:"upstream_error",errorClass:"project_denied",retryAfter:null,status:502}:403===e&&/restricted|billing/i.test(r)?{type:"upstream_error",errorClass:"project_restricted",retryAfter:null,status:502}:401===e||403===e||/API_KEY_INVALID|API key not valid|API_KEY_SERVICE_BLOCKED|ACCESS_TOKEN_TYPE_UNSUPPORTED/.test(r)?{type:"upstream_error",errorClass:"auth_rejected",retryAfter:null,status:502}:404===e?{type:"invalid_request",errorClass:"model_not_found",retryAfter:null,status:404}:400===e||413===e||422===e?{type:"invalid_request",errorClass:"bad_request",retryAfter:null,status:e}:e>=500?{type:"upstream_error",errorClass:"server_error",retryAfter:null,status:502}:{type:"upstream_error",errorClass:`http_${e}`,retryAfter:null,status:502}}(a.status,e);throw eg(()=>em({...h,latencyMs:Date.now()-i,status:t.status,errorClass:`${t.type} \xb7 ${t.errorClass}`,tokensIn:null,tokensOut:null},B(o,l,a.headers,new Date))),f(t.type,t.status,{status:a.status,errorClass:t.errorClass,detail:q(t.errorClass,a.status,o.name)})}let m=await a.json().catch(()=>null),g=m?.choices?.[0]?.message?.content,b="string"==typeof g?g:Array.isArray(g)?g.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"",y=((n=m?.usage)&&"object"==typeof n?{in:ef(n.prompt_tokens),out:ef(n.completion_tokens)}:null)??{in:null,out:null},w=Date.now()-i,v=null!==m;if(eg(()=>{var e,t;let r;return em({...h,latencyMs:w,status:v?200:502,errorClass:v?null:"upstream_error · bad_response",tokensIn:y.in,tokensOut:y.out},(e=a.headers,t=new Date,r=y&&(null!==y.in||null!==y.out)?(y.in??0)+(y.out??0):null,[...e?B(o,l,e,t):[],...function(e,t,r,s,n){let a=[];for(let i of t.map(e=>{let t=function(e,t){let r=t.getTime();if("minute"===e){let e=6e4*Math.floor(r/6e4);return{start:new Date(e),end:new Date(e+6e4)}}let s=864e5*Math.floor(r/864e5);if("day"===e)return{start:new Date(s),end:new Date(s+864e5)};let n=(new Date(s).getUTCDay()+6)%7,a=s-864e5*n;return{start:new Date(a),end:new Date(a+6048e5)}}(e.window,n);return{...e,start:t.start,resetAt:t.end}})){if("all"!==i.scope&&i.scope!==r)continue;let t="tokens"===i.metric?s??0:1;a.push({providerId:e,scope:i.scope,metric:`${i.metric}:${i.window}`,limit:i.limit,remaining:null,used:t,resetAt:i.resetAt,source:"own"})}return a}(o.id,o.limits,l,r,t)]))}),!v)throw f("upstream_error",502,{status:a.status,errorClass:"bad_response",detail:q("bad_response",a.status,o.name)});return{text:b,model:c,usage:y,ms:w}}let ev=new Set([429,500,502,503,504]),ek=2/3;async function e_(e){for(let t of(await ec()).filter(t=>t.enabled&&t.id!==e)){let e=en(t.models.filter(e=>e.enabled&&es(e,t.kind)));if(e)return{conn:t,upstream:e.upstream,publicId:ea(t,e)}}return null}function eS(e,t){return e instanceof eb&&e.failure?new eb(e.type,Y(e.failure.first,t),e.status,{first:e.failure.first,next:t}):e}async function ex(e,t){let r;if((0,R.isDemo)())return{text:T.v,model:"demo",usage:{in:null,out:null},ms:0};let s=Date.now(),n=await ey(t.model),a=!t.model||!0===t.fallback,i=async()=>void 0===r?r=await e_(n.conn.id).catch(()=>null):r,o=t.timeoutMs;if(t.timeoutMs&&a){let e=Math.floor(t.timeoutMs*(1-ek));e>=3e3&&await i()&&(o=t.timeoutMs-e)}try{return await ew(n,e,t,o)}catch(l){if(!(l instanceof eb&&(l.failure?K(l.failure.first):ev.has(l.status))))throw l;if(!a)throw eS(l,{kind:"pinned"});let r=await i();if(!r)throw eS(l,{kind:"none"});let o=t.timeoutMs?t.timeoutMs-(Date.now()-s):void 0;if(void 0!==o&&o<3e3)throw eS(l,{kind:"out-of-time"});console.info(`ai: ${n.conn.name} failed, trying ${r.conn.name}`);try{return await ew(r,e,t,o)}catch(t){let e=t instanceof eb?t.failure?.first:void 0;throw e?eS(l,{kind:"tried",fallback:e}):t}}}e.s(["X",0,ex,"M",0,ey],585585)},25734,423660,216640,27626,64858,248744,379593,717799,e=>{let t,r,s,n,a,i,o,l;var c,u,d,h,p,f,m,g,b,y,w,v,k,_,S,x=e.i(336763),A=e.i(533102),T=e.i(406212),R=e.i(200123),E=e.i(530298),I=e.i(585585),j=e.i(910931),O=e.i(455891),$=e.i(234195),C=e.i(42784),P=e.i(589878);e.i(464161),e.i(451682);var N=e.i(380719),D=e.i(760859),L=e.i(412948),U=e.i(216899),q=e.i(785194),M=e.i(164617),B=e.i(857799);let z=e=>"heartbeat"===e.kind?e.lastError?e.lastError.replace(/^(Down|Late) · /,""):"warn"===e.state?"Late":"No ping":(0,M.H)(e)??(e.lastStatus?`HTTP ${e.lastStatus}`:e.lastError||"No answer");var F=e.i(756371);let W=["apps","monitors","alerts","advisor"],H=e=>null===e?null:Math.round(100*e)/100,G=(0,j.cache)(()=>(0,P.f)()),K=(0,j.cache)(e=>(0,C.f)(new Date(e))),J=(0,j.cache)(e=>(0,N.d)(new Date(e))),V=(0,j.cache)(()=>(0,$.i)()),Y=(0,j.cache)(e=>(0,O.T)(new Date(e))),Z={ok:"running",warn:"degraded",err:"down",build:"building",paused:"paused",maint:"paused"},X={ok:"up",warn:"degraded",err:"down"},Q=(e,t,r)=>{let s=(0,U.k)(e),n=function(e){if(e.gone)return[];let t=[],r=e.monitors.filter(e=>(0,M.i)(e)&&!e.maintUntil&&("err"===e.state||"warn"===e.state)),s=e=>2*("heartbeat"===e.kind)+ +("err"!==e.state);for(let e of[...r].sort((e,t)=>s(e)-s(t))){let r="heartbeat"===e.kind,s=r?e.name??e.path:e.path;t.push({kind:"monitor",where:r?`Monitor ${s} (heartbeat)`:`Monitor ${s}`,subject:s,state:e.state,reason:z(e),since:e.stateSince??(r?e.lastPingAt??null:null),href:"/uptime",remedies:r?function(e){let t=(e.lastError??"").toLowerCase();return t.includes("failure")?["The job reported a failure: open its logs","Fix and re-run the job; the next OK ping clears it"]:t.includes("didn't finish")||t.includes("started")?["The job started but never finished: it may have hung or hit its timeout","Check the job's own logs for where it stopped","Raise the job's timeout, or fix what it waits on; the next OK ping clears it"]:["Check that the job's scheduler ran (cron, Vercel Cron, GitHub Actions)","Check the job's own logs for errors before the ping line","Make sure the job calls the ping URL at the end (curl -fsS -m 10 <url>)","If the job is retired, pause or delete the heartbeat"]}(e):function(e){let t=e.lastError??"";if(/blocked address/i.test(t))return["The monitor's URL resolves to a private address; fix the URL in Edit monitor"];let r=(0,M.H)(e);if(r&&/keyword|json|body|content/i.test(r))return["The page answered but its content changed: check the keyword or JSON path in Edit monitor, or the page itself"];let s=e.lastStatus;return null!==s&&s>=500?["Open Logs (last hour) for errors","Check the latest deployment; roll back if it started after the deploy"]:null!==s&&s>=300?["Check the expected status and path in Edit monitor","The route may need sign-in or moved"]:null===s||r?["Check the domain, DNS and the provider status page","Cold start or overload: retry with Check now"]:["Open Logs (last hour) for errors","Check the latest deployment; roll back if it started after the deploy"]}(e)})}e.dbPaused&&e.database&&t.push({kind:"database",where:`Database ${e.database.name}`,subject:e.database.name,state:"warn",reason:"Paused",since:e.stateSince??null,href:(0,B.N)(e.database.kind),remedies:["Restore the database from its provider (Supabase restore)"]});let n=e.lastDeploy;if(n&&"error"===n.state){let e=(0,L._)(n.commitSha);t.push({kind:"deployment",where:`Production deployment ${e}`,subject:e,state:"fail",reason:"Build failed",since:n.readyAt??n.createdAt,href:"/deployments",remedies:["Open the deployment's build logs; redeploy after fixing"]})}return t}({...e,database:e.database?{id:e.database.id,kind:e.database.kind,name:(0,D.X)(t,e.database.id)}:null});return{id:e.name,state:Z[s.state]??"unknown",uptime30d:H(e.uptime30),database:e.database?(0,D.X)(t,e.database.id):null,lastDeploy:e.lastDeploy?`${(0,L._)(e.lastDeploy.commitSha)} \xb7 ${(0,L.$)(e.lastDeploy,r)}`:null,problems:n.map(e=>({kind:e.kind,where:(0,F.f)(e.where,t),what:(0,F.f)(e.reason,t),fix:e.remedies.length?(0,F.f)(e.remedies.join("; "),t):null}))}},ee=e=>e.paused||e.ownerPaused?"paused":X[e.state]??"unknown",et=(0,j.cache)(async e=>{let t=new Date(e),[r,s]=await Promise.all([K(e),G()]);return r.filter(e=>!e.gone).map(e=>Q(e,s,t))}),er=(0,j.cache)(async e=>{let[t,r]=await Promise.all([J(e),G()]),s=t.filter(e=>!e.appGone).map(e=>({app:e.appName,path:(0,F.f)(e.path,r),kind:e.kind,state:ee(e),lastStatus:e.lastStatus,latencyMs:e.lastLatencyMs,uptime30d:H(e.uptime30),lastCheckedAt:e.lastCheckedAt?.toISOString()??null})),n=e=>s.filter(t=>t.state===e).length;return{up:n("up"),degraded:n("degraded"),down:n("down"),paused:n("paused"),items:s.filter(e=>"up"!==e.state)}}),es=(0,j.cache)(async()=>{let[e,t]=await Promise.all([V(),G()]),r=e.slice(0,50).map(e=>{let r=(0,D.o)(e,t);return{title:(0,F.f)(r.title,t),severity:e.severity,app:"app"===e.resourceKind?e.resourceName:null,since:e.startedAt.toISOString(),message:(0,F.f)(r.message,t)}});return{open:e.length,critical:e.filter(e=>"critical"===e.severity).length,items:r}}),en=(0,j.cache)(async e=>{let[t,r,s]=await Promise.all([Y(e),K(e),G()]),n=new Map(r.map(e=>[e.id,e.name]));return t.map(e=>{let t=(0,D.d)(e,s);return{title:(0,F.f)(t.title,s),app:e.appId&&n.get(e.appId)||"console",severity:e.severity}})}),ea=e=>en(e.getTime());async function ei(e,t=W){let r=new Set(t),[s,n,a,i]=await Promise.all([r.has("apps")?et(e.getTime()):Promise.resolve([]),r.has("monitors")?er(e.getTime()):Promise.resolve({up:0,degraded:0,down:0,paused:0}),r.has("alerts")?es():Promise.resolve({open:0,critical:0}),r.has("advisor")?ea(e):Promise.resolve(void 0)]);return{generatedAt:e.toISOString(),apps:s,monitors:n,alerts:a,...i?{advisor:i}:{}}}async function eo(e,t){let r=e.trim().toLowerCase();return r?(await K(t.getTime())).find(e=>!e.gone&&(e.id.toLowerCase()===r||e.name.toLowerCase()===r))??null:null}async function el(e,t){let[r,s]=await Promise.all([eo(e,t),G()]);return r?{...Q(r,s,t),monitors:r.monitors.map(e=>({path:(0,F.f)(e.path,s),kind:e.kind,state:ee(e),lastStatus:e.lastStatus,latencyMs:e.lastLatencyMs,uptime30d:H((0,q.Y)((0,q.w)(r.days.get(e.id),t,q.I)))}))}:null}e.i(586307);let ec=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function eu(){return(0,T.db)().select({id:E.resources.id,name:E.resources.name}).from(E.resources).where((0,x.and)((0,x.eq)(E.resources.kind,"app"),(0,x.eq)(E.resources.monitored,!0))).orderBy(E.resources.name).limit(200)}async function ed(e,t,r,s=new Date){let n=s.toISOString(),a=t?`ai-note:${t}`:`ai-note:${r}`,i=await (0,T.db)().execute(A.sql`
47
47
  with hit as (
48
48
  insert into ops.rate_limits (key, window_start, count) values (${a}, ${new Date(36e5*Math.floor(s.getTime()/36e5)).toISOString()}::timestamptz, 1)
49
49
  on conflict (key, window_start) do update set count = ops.rate_limits.count + 1
@@ -70,17 +70,19 @@ ${t}`).digest("hex").slice(0,8),A=(e,t,r={})=>({ok:!1,kind:e,error:t,...r});asyn
70
70
  values (${"ai.advisorRuns"}, ${JSON.stringify({window:e,at:r})}::jsonb, ${r}::timestamptz, ${r}::timestamptz)
71
71
  on conflict (key) do update set value = excluded.value, updated_at = excluded.updated_at
72
72
  where ops.settings.value->>'window' is distinct from ${e}
73
- returning 1 as claimed`);return 1===(0,R.f)(s).length}async function eE(e,t={}){var r,s;let n,a,i,o=ev(e);if(!t.force&&!o)return{status:"skipped",reason:"outside-window"};let l=await eT();if(!t.force&&!l.enabled)return{status:"skipped",reason:"off"};try{await (0,I.M)(l.model??void 0)}catch{return{status:"skipped",reason:"no-provider"}}if(!t.force&&!await eR(o,e))return{status:"skipped",reason:"already-ran"};let c=await ei(e),u=function(e){let t=e.apps.map(e=>e.id),r=new Map,s=(e,s)=>{let n=t.find(t=>t.toLowerCase()===ek(e));n&&r.set(n,Math.max(r.get(n)??0,s))};for(let t of e.apps)"down"===t.state?s(t.id,4):"degraded"===t.state&&s(t.id,2);for(let t of e.alerts.items??[])s(t.app,3);for(let t of e.monitors.items??[])("down"===t.state||"degraded"===t.state)&&s(t.app,2);for(let t of e.advisor??[])("warn"===t.severity||"crit"===t.severity||"critical"===t.severity||"warning"===t.severity)&&s(t.app,1);let n,a=[...r.entries()].filter(([e])=>e!==n).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,3).map(([e])=>e);return[...n?[n]:[],...a]}(c);if(0===u.length)return{status:"skipped",reason:"no-apps"};let d=await (r=(0,I.X)((n=e=>u.some(t=>t.toLowerCase()===ek(e)),a={generatedAt:c.generatedAt,apps:c.apps.filter(e=>n(e.id)).map(e=>({app:ey(e.id,80),state:e.state,uptime30d:e.uptime30d,database:e.database?ey(e.database,40):null,lastDeploy:e.lastDeploy?ey(e.lastDeploy,40):null,problems:e.problems.slice(0,8).map(e=>({kind:ey(e.kind,30),where:ey(e.where,120),what:ey(e.what),fix:e.fix?ey(e.fix):null}))})),alerts:(c.alerts.items??[]).filter(e=>n(e.app)).slice(0,12).map(e=>({app:ey(e.app,80),severity:ey(e.severity,20),title:ey(e.title),message:ey(e.message)})),monitors:(c.monitors.items??[]).filter(e=>n(e.app)).slice(0,12).map(e=>({app:ey(e.app,80),state:ey(e.state,20),path:ey(e.path,120)})),recommendations:(c.advisor??[]).filter(e=>n(e.app)).slice(0,12).map(e=>({app:ey(e.app,80),severity:ey(e.severity,20),title:ey(e.title)}))},[{role:"system",content:eb},{role:"user",content:[`Write one short advisor note for each of these apps: ${u.map(e=>ey(e,80)).join(", ")}.`,'Answer with JSON only, no prose and no code fence: {"notes":[{"app":"<app name as given>","severity":"info|warn|crit","title":"<under 80 characters>","body":"<at most 4 short sentences in English with one concrete suggestion>"}]}.\nUse only the data below. Never include secrets, keys, email addresses, hostnames or URLs. Severity: crit when the app is down or has a critical alert, warn for anything else wrong, info when all is well.\n',JSON.stringify(a)].join("\n")}]),{...l.model?{model:l.model,fallback:!0}:{},purpose:"summary",maxTokens:1500,temperature:.2}),s=t.deadlineMs??4e4,Promise.race([r,new Promise((e,t)=>{i=setTimeout(()=>t(Error("advisor deadline")),s)})]).finally(()=>clearTimeout(i))),h=function(e,t){let r,s=e.indexOf("{"),n=e.lastIndexOf("}");if(s<0||n<=s)return[];try{r=JSON.parse(e.slice(s,n+1))}catch{return[]}let a=r?.notes;if(!Array.isArray(a))return[];let i=[];for(let e of a.slice(0,20)){let r=e_.safeParse(e);if(!r.success)continue;let s=t.find(e=>e.toLowerCase()===r.data.app.toLowerCase());if(!s||i.some(e=>e.app===s))continue;let{title:n,body:a}=r.data;if(ex(a)>4)continue;let o=`${n} ${a}`;if(!(ey(o,1e4)!==o.replace(/\s+/g," ").trim()||eS.test(o))&&(i.push({app:s,severity:r.data.severity,title:n,body:a}),i.length>=4))break}return i}(d.text,u);if(0===h.length)return{status:"skipped",reason:"no-valid-notes"};let p=await eu(),f=0;for(let t of h)(await ed({title:t.title,body:t.body,severity:t.severity,appId:function(e,t){let r=t.trim();return ec.test(r)?e.find(e=>e.id.toLowerCase()===r.toLowerCase())??null:e.find(e=>e.name.toLowerCase()===r.toLowerCase())??null}(p,t.app)?.id??null,model:d.model.slice(0,120),client:eA},null,eA,e)).ok&&f++;return{status:"written",count:f,model:d.model}}async function eI(e){if(ev(e))try{let t=await eE(e,{deadlineMs:4e4});"written"===t.status?console.log(`advisor notes: ${t.count} written (${t.model})`):"already-ran"!==t.reason&&"outside-window"!==t.reason&&console.log(`advisor notes: skipped (${t.reason})`)}catch(e){console.warn("advisor notes failed:",e instanceof Error?"advisor deadline"===e.message?"deadline":e.name:"unknown")}}e.s(["f",0,eI],25734);var ej=e.i(90879);let eO={provider:async()=>{if((0,ej.isDemo)())return{name:"Demo",model:"demo"};try{let e=await (0,I.M)();return{name:e.conn.name,model:e.publicId}}catch{return null}},appSnapshot:el,advice:ea,complete:I.X};var eC=e.i(666680),e$=e.i(260417);let eP="advisor.ai_summary",eN=ep.z.object({text:ef.z.string().min(1).max(1200),model:ef.z.string().max(200),at:ef.z.string(),count:e$.z.number().int().min(0),hash:ef.z.string().length(64)});function eD(e){let t=e.map(e=>`${e.severity}\0${e.app}\0${e.title}`).sort();return(0,eC.createHash)("sha256").update(t.join("\x01")).digest("hex")}async function eL(){let[e]=await (0,T.db)().select({value:E.settings.value}).from(E.settings).where((0,x.eq)(E.settings.key,eP)).limit(1),t=eN.safeParse(e?.value);return t.success?t.data:null}async function eU(e,t){var r,s;let n;if(!await eO.provider())return{status:"no-provider"};let a=await eO.advice(e),i=(r=await eL(),s=t.force,a.length?!s&&r&&r.hash===eD(a)?"skip-unchanged":"run":"skip-empty");if("skip-empty"===i)return{status:"empty"};if("skip-unchanged"===i)return{status:"unchanged"};let o=await eO.complete((n=a.slice(0,40).map(e=>`- [${ey(e.severity,20)}] ${ey(e.title)} (app: ${ey(e.app,80)})`),[{role:"system",content:eb},{role:"user",content:[`Summarise these ${a.length} recommendations in two or three sentences, most urgent first. Name each app once.`,"",...n].join("\n")}]),{purpose:"summary",maxTokens:400}),l=o.text.trim().slice(0,1200);if(!l)throw Error("The model returned no text.");let c={text:l,model:o.model.slice(0,200),at:e.toISOString(),count:a.length,hash:eD(a)};return await (0,T.db)().insert(E.settings).values({key:eP,value:c}).onConflictDoUpdate({target:E.settings.key,set:{value:c,updatedAt:e}}),{status:"stored",summary:c}}async function eq(e){await eU(e,{force:!1})}e.s(["f",0,eq],27626);var eM=e.i(133210);e.i(989112);var eB=e.i(66389);class ez extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function eF(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class eW extends ez{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function eH(e){return eF(e)&&"AuthApiError"===e.name}class eG extends ez{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class eK extends ez{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}}class eJ extends eK{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function eV(e){return eF(e)&&"AuthSessionMissingError"===e.name}class eY extends eK{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class eX extends eK{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class eZ extends eK{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class eQ extends eK{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class e0 extends eK{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function e1(e){return eF(e)&&"AuthRetryableFetchError"===e.name}class e2 extends eK{constructor(e="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(e,"AuthRefreshDiscardedError",409,void 0)}}function e3(e){return eF(e)&&"AuthRefreshDiscardedError"===e.name}class e4 extends eK{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class e5 extends eK{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}var e6=e.i(37294),e8=e.i(187481),e9=e.i(447514);let e7=Symbol.for("@supabase/supabase-js.traceContextExtractor");class te extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class tt extends te{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class tr extends te{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class ts extends te{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}(c=g||(g={})).Any="any",c.ApNortheast1="ap-northeast-1",c.ApNortheast2="ap-northeast-2",c.ApSouth1="ap-south-1",c.ApSoutheast1="ap-southeast-1",c.ApSoutheast2="ap-southeast-2",c.CaCentral1="ca-central-1",c.EuCentral1="eu-central-1",c.EuWest1="eu-west-1",c.EuWest2="eu-west-2",c.EuWest3="eu-west-3",c.SaEast1="sa-east-1",c.UsEast1="us-east-1",c.UsWest1="us-west-1",c.UsWest2="us-west-2";function tn(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)0>t.indexOf(s[n])&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}"function"==typeof SuppressedError&&SuppressedError;class ta{constructor(e,{headers:t={},customFetch:r,region:s=g.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=r?(...e)=>r(...e):(...e)=>fetch(...e)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){var t,r,s,n;return t=this,r=arguments,s=void 0,n=function*(e,t={}){var r,s;let n,a,i;try{let s,{headers:o,method:l,body:c,signal:u,timeout:d}=t,h={},{region:p}=t;p||(p=this.region);let f=new URL(`${this.url}/${e}`);p&&"any"!==p&&(h["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let m=!!o&&Object.keys(o).some(e=>"content-type"===e.toLowerCase());c&&!m?"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]=c.type||"application/octet-stream",s=c):"string"==typeof c?(h["Content-Type"]="text/plain",s=c):"u">typeof FormData&&c instanceof FormData?s=c:(h["Content-Type"]="application/json",s=JSON.stringify(c)):s=!c||"string"==typeof c||"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer||"u">typeof FormData&&c instanceof FormData?c:JSON.stringify(c);let g=u;d&&(a=new AbortController,n=setTimeout(()=>a.abort(),d),u?(g=a.signal,i=()=>a.abort(),u.addEventListener("abort",i)):g=a.signal);let b=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),o),body:s,signal:g}).catch(e=>{throw new tt(e)}),y=b.headers.get("x-relay-error");if(y&&"true"===y)throw new tr(b);if(!b.ok)throw new ts(b);let w=(null!=(r=b.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim().toLowerCase();return{data:"application/json"===w?yield b.json():"application/octet-stream"===w||"application/pdf"===w?yield b.blob():"text/event-stream"===w?b:"multipart/form-data"===w?yield b.formData():yield b.text(),error:null,response:b}}catch(e){return{data:null,error:e,response:e instanceof ts||e instanceof tr?e.context:void 0}}finally{n&&clearTimeout(n),i&&(null==(s=t.signal)||s.removeEventListener("abort",i))}},new(s||(s=Promise))(function(e,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function o(e){try{l(n.throw(e))}catch(e){a(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof s?r:new s(function(e){e(r)})).then(i,o)}l((n=n.apply(t,r||[])).next())})}}var ti=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};let to=e=>Math.min(1e3*2**e,3e4),tl=[520,503],tc=["GET","HEAD","OPTIONS"];function tu(e){return(tu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function td(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function th(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?td(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=tu(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=tu(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==tu(s)?s:s+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):td(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function tp(e,t){return new Promise(r=>{if(null==t?void 0:t.aborted)return void r();let s=setTimeout(()=>{null==t||t.removeEventListener("abort",n),r()},e);function n(){clearTimeout(s),r()}null==t||t.addEventListener("abort",n)})}async function tf(e,t,r,s){let n=0;for(;;){var a,i,o,l,c,u;let d,h=th({},r.headers);n>0&&(h["X-Retry-Count"]=String(n));try{d=await e(t,{method:r.method,headers:h,body:r.body,signal:r.signal})}catch(e){if((null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"||(null==e?void 0:e.name)==="TimeoutError"&&(null==(a=r.signal)?void 0:a.aborted)||!tc.includes(r.method))throw e;if(s&&n<3){let e=to(n);n++,await tp(e,r.signal);continue}throw e}if(l=r.method,c=d.status,u=n,s&&!(u>=3)&&tc.includes(l)&&tl.includes(c)&&1){let e=null!=(i=null==(o=d.headers)?void 0:o.get("Retry-After"))?i:null,t=null!==e?1e3*Math.max(0,parseInt(e,10)||0):to(n);await d.text(),n++,await tp(t,r.signal);continue}return d}}var tm=class{constructor(e){var t,r,s,n,a;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!=(t=e.shouldThrowOnError)&&t,this.signal=e.signal,this.isMaybeSingle=null!=(r=e.isMaybeSingle)&&r,this.shouldStripNulls=null!=(s=e.shouldStripNulls)&&s,this.urlLengthLimit=null!=(n=e.urlLengthLimit)?n:8e3,this.retryEnabled=null==(a=e.retry)||a,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if("text/csv"===this.headers.get("Accept"))throw Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var r=this;if(void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){let e=this.headers.get("Accept");"application/vnd.pgrst.object+json"===e?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):e&&"application/json"!==e||this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}let s=this.fetch,n=(async()=>{let e={};r.headers.forEach((t,r)=>{e[r]=t});let t=await tf(s,r.url.toString(),{method:r.method,headers:e,body:JSON.stringify(r.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:r.signal},r.retryEnabled);return await r.processResponse(t)})();return this.shouldThrowOnError||(n=n.catch(e=>{var t,r,s,n,a,i;let o="",l="",c="",u=null==e?void 0:e.cause;if(u){let t=null!=(r=null==u?void 0:u.message)?r:"",i=null!=(s=null==u?void 0:u.code)?s:"";o=`${null!=(n=null==e?void 0:e.name)?n:"FetchError"}: ${null==e?void 0:e.message}
73
+ returning 1 as claimed`);return 1===(0,R.f)(s).length}async function eE(e,t={}){var r,s;let n,a,i,o=ev(e);if(!t.force&&!o)return{status:"skipped",reason:"outside-window"};let l=await eT();if(!t.force&&!l.enabled)return{status:"skipped",reason:"off"};try{await (0,I.M)(l.model??void 0)}catch{return{status:"skipped",reason:"no-provider"}}if(!t.force&&!await eR(o,e))return{status:"skipped",reason:"already-ran"};let c=await ei(e),u=function(e){let t=e.apps.map(e=>e.id),r=new Map,s=(e,s)=>{let n=t.find(t=>t.toLowerCase()===ek(e));n&&r.set(n,Math.max(r.get(n)??0,s))};for(let t of e.apps)"down"===t.state?s(t.id,4):"degraded"===t.state&&s(t.id,2);for(let t of e.alerts.items??[])s(t.app,3);for(let t of e.monitors.items??[])("down"===t.state||"degraded"===t.state)&&s(t.app,2);for(let t of e.advisor??[])("warn"===t.severity||"crit"===t.severity||"critical"===t.severity||"warning"===t.severity)&&s(t.app,1);let n,a=[...r.entries()].filter(([e])=>e!==n).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,3).map(([e])=>e);return[...n?[n]:[],...a]}(c);if(0===u.length)return{status:"skipped",reason:"no-apps"};let d=await (r=(0,I.X)((n=e=>u.some(t=>t.toLowerCase()===ek(e)),a={generatedAt:c.generatedAt,apps:c.apps.filter(e=>n(e.id)).map(e=>({app:ey(e.id,80),state:e.state,uptime30d:e.uptime30d,database:e.database?ey(e.database,40):null,lastDeploy:e.lastDeploy?ey(e.lastDeploy,40):null,problems:e.problems.slice(0,8).map(e=>({kind:ey(e.kind,30),where:ey(e.where,120),what:ey(e.what),fix:e.fix?ey(e.fix):null}))})),alerts:(c.alerts.items??[]).filter(e=>n(e.app)).slice(0,12).map(e=>({app:ey(e.app,80),severity:ey(e.severity,20),title:ey(e.title),message:ey(e.message)})),monitors:(c.monitors.items??[]).filter(e=>n(e.app)).slice(0,12).map(e=>({app:ey(e.app,80),state:ey(e.state,20),path:ey(e.path,120)})),recommendations:(c.advisor??[]).filter(e=>n(e.app)).slice(0,12).map(e=>({app:ey(e.app,80),severity:ey(e.severity,20),title:ey(e.title)}))},[{role:"system",content:eb},{role:"user",content:[`Write one short advisor note for each of these apps: ${u.map(e=>ey(e,80)).join(", ")}.`,'Answer with JSON only, no prose and no code fence: {"notes":[{"app":"<app name as given>","severity":"info|warn|crit","title":"<under 80 characters>","body":"<at most 4 short sentences in English with one concrete suggestion>"}]}.\nUse only the data below. Never include secrets, keys, email addresses, hostnames or URLs. Severity: crit when the app is down or has a critical alert, warn for anything else wrong, info when all is well.\n',JSON.stringify(a)].join("\n")}]),{...l.model?{model:l.model,fallback:!0}:{},purpose:"summary",maxTokens:1500,temperature:.2}),s=t.deadlineMs??4e4,Promise.race([r,new Promise((e,t)=>{i=setTimeout(()=>t(Error("advisor deadline")),s)})]).finally(()=>clearTimeout(i))),h=function(e,t){let r,s=e.indexOf("{"),n=e.lastIndexOf("}");if(s<0||n<=s)return[];try{r=JSON.parse(e.slice(s,n+1))}catch{return[]}let a=r?.notes;if(!Array.isArray(a))return[];let i=[];for(let e of a.slice(0,20)){let r=e_.safeParse(e);if(!r.success)continue;let s=t.find(e=>e.toLowerCase()===r.data.app.toLowerCase());if(!s||i.some(e=>e.app===s))continue;let{title:n,body:a}=r.data;if(ex(a)>4)continue;let o=`${n} ${a}`;if(!(ey(o,1e4)!==o.replace(/\s+/g," ").trim()||eS.test(o))&&(i.push({app:s,severity:r.data.severity,title:n,body:a}),i.length>=4))break}return i}(d.text,u);if(0===h.length)return{status:"skipped",reason:"no-valid-notes"};let p=await eu(),f=0;for(let t of h)(await ed({title:t.title,body:t.body,severity:t.severity,appId:function(e,t){let r=t.trim();return ec.test(r)?e.find(e=>e.id.toLowerCase()===r.toLowerCase())??null:e.find(e=>e.name.toLowerCase()===r.toLowerCase())??null}(p,t.app)?.id??null,model:d.model.slice(0,120),client:eA},null,eA,e)).ok&&f++;return{status:"written",count:f,model:d.model}}async function eI(e){if(ev(e))try{let t=await eE(e,{deadlineMs:4e4});"written"===t.status?console.log(`advisor notes: ${t.count} written (${t.model})`):"already-ran"!==t.reason&&"outside-window"!==t.reason&&console.log(`advisor notes: skipped (${t.reason})`)}catch(e){console.warn("advisor notes failed:",e instanceof Error?"advisor deadline"===e.message?"deadline":e.name:"unknown")}}e.s(["f",0,eI],25734);var ej=e.i(547963);let eO="«redacted»",e$=[[/-----BEGIN [A-Z0-9 ]*(?:PRIVATE KEY|KEY)-----[\s\S]*?(?:-----END [A-Z0-9 ]*(?:PRIVATE KEY|KEY)-----|$)/g,eO],[/\b(?:postgres(?:ql)?|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?|mssql|sqlserver|clickhouse|libsql):\/\/[^\s'"`<>]+/gi,eO],[/\b[a-z][a-z0-9+.-]*:\/\/[^\s'"`<>/:@]+:[^\s'"`<>@]+@[^\s'"`<>]+/gi,eO],[/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}/g,eO],[/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g,eO],[/\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{10,}/g,eO],[/\bsk-(?:proj-|ant-)?[A-Za-z0-9_-]{16,}/g,eO],[/\bxox[abposr]-[A-Za-z0-9-]{10,}/g,eO],[/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,eO],[/\bAIza[0-9A-Za-z_-]{30,}/g,eO],[/\b(?:glpat|npm|hf|gsk|whsec|shpat|shpss|dop_v1|sbp|sb_secret|sb_publishable|re|wb|wp|hb|wr|xai|pplx)[-_][A-Za-z0-9_-]{16,}/g,eO],[/\bSG\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}/g,eO],[/\b(Bearer|Basic|Token)\s+[A-Za-z0-9._~+/=-]{12,}/g,(e,t)=>`${t} ${eO}`],[/\b([A-Za-z0-9_$.-]*(?:key|token|secret|passw(?:or)?d|passwd|pwd|credential|auth|dsn|signature|salt)[A-Za-z0-9_$-]*["']?\]?\s*(?:=|:|=>)\s*)(["'`])([^"'`\n]{4,})\2/gi,(e,t,r)=>`${t}${r}${eO}${r}`],[/^(\s*(?:export\s+)?[A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|PWD|DSN|URL|AUTH|CREDENTIALS?)[A-Z0-9_]*\s*=\s*)(?!["'`])(\S{4,})/gm,(e,t)=>`${t}${eO}`],[/(["'`])((?=[A-Za-z0-9+/_=-]*[0-9])(?=[A-Za-z0-9+/_=-]*[A-Za-z])[A-Za-z0-9+/_=-]{32,})\1/g,(e,t)=>`${t}${eO}${t}`],[/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,eO]];var eC=e.i(659916),eP=e.i(355620);let eN={name:"ai-assist",max:20,windowSeconds:600};async function eD(e){let t=await (0,eP.f)(eN,e);return t.allowed?null:`Too many AI requests. Try again in ${(0,eC.H)(t.retryAfter)}.`}var eL=e.i(90879);let eU={provider:async()=>{if((0,eL.isDemo)())return{name:"Demo",model:"demo"};try{let e=await (0,I.M)();return{name:e.conn.name,model:e.publicId}}catch{return null}},appSnapshot:el,advice:ea,complete:I.X},eq=/error|failed|cannot|not found|exit code/i;async function eM(e,t){var r;let s,n,a,i,o=(s=t.lines.map((e,t)=>({l:e,i:t})).filter(({l:e})=>"delimiter"!==e.kind&&""!==e.text.trim()),n=e=>"stderr"===e.kind||eq.test(e.text),i=120-(a=s.filter(({l:e})=>n(e)).slice(-120)).length,[...a,...i>0?s.filter(({l:e})=>!n(e)).slice(-i):[]].sort((e,t)=>e.i-t.i).map(({l:e})=>(function(e){let t=String(e??"");for(let[e,r]of e$)t=t.replace(e,r);return t})("command"===e.kind?`$ ${e.text}`:e.text).slice(0,400)));if(o.length<3||!o.some(e=>eq.test(e)))return{ok:!1,error:"There is too little in the build log to explain."};let l=await e.overQuota(t.memberId);if(l)return{ok:!1,error:l};if(!await e.provider())return{ok:!1,error:ej.B.noProvider};try{let s=await e.complete((r=t.app,[{role:"system",content:"You read a web app's failed build log and explain it to its developer. Answer in at most 6 short lines of plain text, no headings and no preamble: what broke, the likely fix, and the file (with the line, when the log names one). If the log doesn't say enough, say what to look at next."},{role:"user",content:`The build of ${r} failed. The end of its build log (secrets removed):
74
+
75
+ ${o.join("\n")}`}]),{purpose:"ask-ai",maxTokens:400}),n=s.text.trim();return n?{ok:!0,text:n,model:s.model}:{ok:!1,error:"The model returned no text. Try again."}}catch(e){return{ok:!1,error:e instanceof Error&&"GatewayError"===e.name?e.message.slice(0,300):"The AI provider couldn't answer. Try again."}}}e.s(["f",0,e=>eM({overQuota:eD,provider:eU.provider,complete:eU.complete},e)],216640);var eB=e.i(666680),ez=e.i(260417);let eF="advisor.ai_summary",eW=ep.z.object({text:ef.z.string().min(1).max(1200),model:ef.z.string().max(200),at:ef.z.string(),count:ez.z.number().int().min(0),hash:ef.z.string().length(64)});function eH(e){let t=e.map(e=>`${e.severity}\0${e.app}\0${e.title}`).sort();return(0,eB.createHash)("sha256").update(t.join("\x01")).digest("hex")}async function eG(){let[e]=await (0,T.db)().select({value:E.settings.value}).from(E.settings).where((0,x.eq)(E.settings.key,eF)).limit(1),t=eW.safeParse(e?.value);return t.success?t.data:null}async function eK(e,t){var r,s;let n;if(!await eU.provider())return{status:"no-provider"};let a=await eU.advice(e),i=(r=await eG(),s=t.force,a.length?!s&&r&&r.hash===eH(a)?"skip-unchanged":"run":"skip-empty");if("skip-empty"===i)return{status:"empty"};if("skip-unchanged"===i)return{status:"unchanged"};let o=await eU.complete((n=a.slice(0,40).map(e=>`- [${ey(e.severity,20)}] ${ey(e.title)} (app: ${ey(e.app,80)})`),[{role:"system",content:eb},{role:"user",content:[`Summarise these ${a.length} recommendations in two or three sentences, most urgent first. Name each app once.`,"",...n].join("\n")}]),{purpose:"summary",maxTokens:400}),l=o.text.trim().slice(0,1200);if(!l)throw Error("The model returned no text.");let c={text:l,model:o.model.slice(0,200),at:e.toISOString(),count:a.length,hash:eH(a)};return await (0,T.db)().insert(E.settings).values({key:eF,value:c}).onConflictDoUpdate({target:E.settings.key,set:{value:c,updatedAt:e}}),{status:"stored",summary:c}}async function eJ(e){await eK(e,{force:!1})}e.s(["f",0,eJ],27626);var eV=e.i(133210);e.i(989112);var eY=e.i(66389);class eZ extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function eX(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class eQ extends eZ{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function e0(e){return eX(e)&&"AuthApiError"===e.name}class e1 extends eZ{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class e2 extends eZ{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}}class e3 extends e2{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function e4(e){return eX(e)&&"AuthSessionMissingError"===e.name}class e5 extends e2{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class e6 extends e2{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class e8 extends e2{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class e9 extends e2{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class e7 extends e2{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function te(e){return eX(e)&&"AuthRetryableFetchError"===e.name}class tt extends e2{constructor(e="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(e,"AuthRefreshDiscardedError",409,void 0)}}function tr(e){return eX(e)&&"AuthRefreshDiscardedError"===e.name}class ts extends e2{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class tn extends e2{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}var ta=e.i(37294),ti=e.i(187481),to=e.i(447514);let tl=Symbol.for("@supabase/supabase-js.traceContextExtractor");class tc extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class tu extends tc{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class td extends tc{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class th extends tc{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}(c=g||(g={})).Any="any",c.ApNortheast1="ap-northeast-1",c.ApNortheast2="ap-northeast-2",c.ApSouth1="ap-south-1",c.ApSoutheast1="ap-southeast-1",c.ApSoutheast2="ap-southeast-2",c.CaCentral1="ca-central-1",c.EuCentral1="eu-central-1",c.EuWest1="eu-west-1",c.EuWest2="eu-west-2",c.EuWest3="eu-west-3",c.SaEast1="sa-east-1",c.UsEast1="us-east-1",c.UsWest1="us-west-1",c.UsWest2="us-west-2";function tp(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)0>t.indexOf(s[n])&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}"function"==typeof SuppressedError&&SuppressedError;class tf{constructor(e,{headers:t={},customFetch:r,region:s=g.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=r?(...e)=>r(...e):(...e)=>fetch(...e)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){var t,r,s,n;return t=this,r=arguments,s=void 0,n=function*(e,t={}){var r,s;let n,a,i;try{let s,{headers:o,method:l,body:c,signal:u,timeout:d}=t,h={},{region:p}=t;p||(p=this.region);let f=new URL(`${this.url}/${e}`);p&&"any"!==p&&(h["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let m=!!o&&Object.keys(o).some(e=>"content-type"===e.toLowerCase());c&&!m?"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]=c.type||"application/octet-stream",s=c):"string"==typeof c?(h["Content-Type"]="text/plain",s=c):"u">typeof FormData&&c instanceof FormData?s=c:(h["Content-Type"]="application/json",s=JSON.stringify(c)):s=!c||"string"==typeof c||"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer||"u">typeof FormData&&c instanceof FormData?c:JSON.stringify(c);let g=u;d&&(a=new AbortController,n=setTimeout(()=>a.abort(),d),u?(g=a.signal,i=()=>a.abort(),u.addEventListener("abort",i)):g=a.signal);let b=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),o),body:s,signal:g}).catch(e=>{throw new tu(e)}),y=b.headers.get("x-relay-error");if(y&&"true"===y)throw new td(b);if(!b.ok)throw new th(b);let w=(null!=(r=b.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim().toLowerCase();return{data:"application/json"===w?yield b.json():"application/octet-stream"===w||"application/pdf"===w?yield b.blob():"text/event-stream"===w?b:"multipart/form-data"===w?yield b.formData():yield b.text(),error:null,response:b}}catch(e){return{data:null,error:e,response:e instanceof th||e instanceof td?e.context:void 0}}finally{n&&clearTimeout(n),i&&(null==(s=t.signal)||s.removeEventListener("abort",i))}},new(s||(s=Promise))(function(e,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function o(e){try{l(n.throw(e))}catch(e){a(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof s?r:new s(function(e){e(r)})).then(i,o)}l((n=n.apply(t,r||[])).next())})}}var tm=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};let tg=e=>Math.min(1e3*2**e,3e4),tb=[520,503],ty=["GET","HEAD","OPTIONS"];function tw(e){return(tw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function tv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function tk(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tv(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=tw(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=tw(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==tw(s)?s:s+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tv(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function t_(e,t){return new Promise(r=>{if(null==t?void 0:t.aborted)return void r();let s=setTimeout(()=>{null==t||t.removeEventListener("abort",n),r()},e);function n(){clearTimeout(s),r()}null==t||t.addEventListener("abort",n)})}async function tS(e,t,r,s){let n=0;for(;;){var a,i,o,l,c,u;let d,h=tk({},r.headers);n>0&&(h["X-Retry-Count"]=String(n));try{d=await e(t,{method:r.method,headers:h,body:r.body,signal:r.signal})}catch(e){if((null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"||(null==e?void 0:e.name)==="TimeoutError"&&(null==(a=r.signal)?void 0:a.aborted)||!ty.includes(r.method))throw e;if(s&&n<3){let e=tg(n);n++,await t_(e,r.signal);continue}throw e}if(l=r.method,c=d.status,u=n,s&&!(u>=3)&&ty.includes(l)&&tb.includes(c)&&1){let e=null!=(i=null==(o=d.headers)?void 0:o.get("Retry-After"))?i:null,t=null!==e?1e3*Math.max(0,parseInt(e,10)||0):tg(n);await d.text(),n++,await t_(t,r.signal);continue}return d}}var tx=class{constructor(e){var t,r,s,n,a;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!=(t=e.shouldThrowOnError)&&t,this.signal=e.signal,this.isMaybeSingle=null!=(r=e.isMaybeSingle)&&r,this.shouldStripNulls=null!=(s=e.shouldStripNulls)&&s,this.urlLengthLimit=null!=(n=e.urlLengthLimit)?n:8e3,this.retryEnabled=null==(a=e.retry)||a,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if("text/csv"===this.headers.get("Accept"))throw Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var r=this;if(void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){let e=this.headers.get("Accept");"application/vnd.pgrst.object+json"===e?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):e&&"application/json"!==e||this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}let s=this.fetch,n=(async()=>{let e={};r.headers.forEach((t,r)=>{e[r]=t});let t=await tS(s,r.url.toString(),{method:r.method,headers:e,body:JSON.stringify(r.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:r.signal},r.retryEnabled);return await r.processResponse(t)})();return this.shouldThrowOnError||(n=n.catch(e=>{var t,r,s,n,a,i;let o="",l="",c="",u=null==e?void 0:e.cause;if(u){let t=null!=(r=null==u?void 0:u.message)?r:"",i=null!=(s=null==u?void 0:u.code)?s:"";o=`${null!=(n=null==e?void 0:e.name)?n:"FetchError"}: ${null==e?void 0:e.message}
74
76
 
75
77
  Caused by: ${null!=(a=null==u?void 0:u.name)?a:"Error"}: ${t}`,i&&(o+=` (${i})`),(null==u?void 0:u.stack)&&(o+=`
76
- ${u.stack}`)}else o=null!=(i=null==e?void 0:e.stack)?i:"";let d=this.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(c="",l="Request was aborted (timeout or manual cancellation)",d>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${d} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((null==u?void 0:u.name)==="HeadersOverflowError"||(null==u?void 0:u.code)==="UND_ERR_HEADERS_OVERFLOW")&&(c="",l="HTTP headers exceeded server limits (typically 16KB)",d>this.urlLengthLimit&&(l+=`. Your request URL is ${d} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${null!=(t=null==e?void 0:e.name)?t:"FetchError"}: ${null==e?void 0:e.message}`,details:o,hint:l,code:c},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}async processResponse(e){var t,r,s,n;let a=null,i=null,o=null,l=e.status,c=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();if(""===t);else if("text/csv"===this.headers.get("Accept"))i=t;else if(this.headers.get("Accept")&&(null==(s=this.headers.get("Accept"))?void 0:s.includes("application/vnd.pgrst.plan+text")))i=t;else try{i=JSON.parse(t)}catch(e){if(a={message:t},i=null,this.shouldThrowOnError)throw new ti({message:t,details:"",hint:"",code:""})}}let u=null==(t=this.headers.get("Prefer"))?void 0:t.match(/count=(exact|planned|estimated)/),d=null==(r=e.headers.get("content-range"))?void 0:r.split("/");if(u&&d&&d.length>1&&(o=parseInt(d[1])),this.isMaybeSingle&&Array.isArray(i))if(i.length>1){if(a={code:"PGRST116",details:`Results contain ${i.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},i=null,o=null,l=406,c="Not Acceptable",this.shouldThrowOnError)throw new ti(th(th({},a),{},{hint:null!=(n=a.hint)?n:""}))}else i=1===i.length?i[0]:null}else{let t=await e.text();try{a=JSON.parse(t),Array.isArray(a)&&404===e.status&&(i=[],a=null,l=200,c="OK")}catch(r){404===e.status&&""===t?(l=204,c="No Content"):a={message:t}}if(a&&this.shouldThrowOnError)throw new ti(a)}return{success:null===a,error:a,data:i,count:o,status:l,statusText:c}}returns(){return this}overrideTypes(){return this}},tg=class extends tm{throwOnError(){return super.throwOnError()}select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){let a=n?`${n}.order`:"order",i=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${i?`${i},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let n=void 0===s?"offset":`${s}.offset`,a=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this.url.searchParams.set(a,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:a="text"}={}){var i;let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=null!=(i=this.headers.get("Accept"))?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${o};`),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};let tb=RegExp("[,()]");var ty=class extends tg{throwOnError(){return super.throwOnError()}eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&tb.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}notIn(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&tb.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`not.in.(${r})`),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let n="";"plain"===s?n="pl":"phrase"===s?n="ph":"websearch"===s&&(n="w");let a=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${n}fts${a}.${t}`),this}match(e){return Object.entries(e).filter(([e,t])=>void 0!==t).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}},tw=class{constructor(e,{headers:t={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:a}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){let{head:r=!1,count:s}=null!=t?t:{},n=!1,a=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e)).join(""),{url:i,headers:o}=this.cloneRequestState();return i.searchParams.set("select",a),s&&o.append("Prefer",`count=${s}`),new ty({method:r?"HEAD":"GET",url:i,headers:o,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;let{url:n,headers:a}=this.cloneRequestState();if(t&&a.append("Prefer",`count=${t}`),r||a.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);n.searchParams.set("columns",e.join(","))}}return new ty({method:"POST",url:n,headers:a,schema:this.schema,body:e,fetch:null!=(s=this.fetch)?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var a;let{url:i,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&i.searchParams.set("on_conflict",t),s&&o.append("Prefer",`count=${s}`),n||o.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);i.searchParams.set("columns",e.join(","))}}return new ty({method:"POST",url:i,headers:o,schema:this.schema,body:e,fetch:null!=(a=this.fetch)?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var r;let{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new ty({method:"PATCH",url:s,headers:n,schema:this.schema,body:e,fetch:null!=(r=this.fetch)?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:e}={}){var t;let{url:r,headers:s}=this.cloneRequestState();return e&&s.append("Prefer",`count=${e}`),new ty({method:"DELETE",url:r,headers:s,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function tv(e,t,r){var s;return{success:!1,error:new ti({message:`${null!=(s=null==e?void 0:e.name)?s:"FetchError"}: ${null==e?void 0:e.message}`,details:"",hint:"",code:""}),data:null,count:null,status:t,statusText:r}}var tk=class e{constructor(e,{headers:t={},schema:r,fetch:s,timeout:n,urlLengthLimit:a=8e3,retry:i}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.urlLengthLimit=a;let o=null!=s?s:globalThis.fetch;void 0!==n&&n>0?this.fetch=(e,t)=>{let r=new AbortController,s=setTimeout(()=>r.abort(),n),a=null==t?void 0:t.signal;if(a){if(a.aborted)return clearTimeout(s),o(e,t);let n=()=>{clearTimeout(s),r.abort()};return a.addEventListener("abort",n,{once:!0}),o(e,th(th({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(s),a.removeEventListener("abort",n)})}return o(e,th(th({},t),{},{signal:r.signal})).finally(()=>clearTimeout(s))}:this.fetch=o,this.retry=i}from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new tw(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}async getOpenApiSpec(){var e,t;let r,s,n=new Headers(this.headers);n.set("Accept","application/openapi+json"),this.schemaName&&n.set("Accept-Profile",this.schemaName);let a={};n.forEach((e,t)=>{a[t]=e});let i=null!=(e=this.fetch)?e:globalThis.fetch;try{r=await tf(i,`${this.url}/`,{method:"GET",headers:a},null==(t=this.retry)||t)}catch(e){return tv(e,0,"")}try{s=await r.text()}catch(e){return tv(e,r.status,r.statusText)}if(r.ok)try{return{success:!0,error:null,data:JSON.parse(s),count:null,status:r.status,statusText:r.statusText}}catch(e){}return{success:!1,error:function(e,t){try{let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t)){var r,s,n,a;return new ti({message:String(null!=(r=t.message)?r:e),details:null!=(s=t.details)?s:"",hint:null!=(n=t.hint)?n:"",code:null!=(a=t.code)?a:""})}}catch(e){}return new ti({message:e||t,details:"",hint:"",code:""})}(s,r.statusText),data:null,count:null,status:r.status,statusText:r.statusText}}rpc(e,t={},{head:r=!1,get:s=!1,count:n}={}){var a;let i,o,l=new URL(`${this.url}/rpc/${e}`),c=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(c)),u=r&&Object.values(t).some(c);u?(i="POST",o=t):r||s?(i=r?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`]).forEach(([e,t])=>{l.searchParams.append(e,t)})):(i="POST",o=t);let d=new Headers(this.headers);return u?d.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&d.set("Prefer",`count=${n}`),new ty({method:i,url:l,headers:d,schema:this.schemaName,body:o,fetch:null!=(a=this.fetch)?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};let t_=class{static detectEnvironment(){var t;if("u">typeof WebSocket)return{type:"native",wsConstructor:WebSocket};let r=globalThis;if("u">typeof globalThis&&void 0!==r.WebSocket)return{type:"native",wsConstructor:r.WebSocket};let s=e.g;if(s&&void 0!==s.WebSocket)return{type:"native",wsConstructor:s.WebSocket};if("u">typeof globalThis&&void 0!==r.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("u">typeof globalThis&&r.EdgeRuntime||"u">typeof navigator&&(null==(t=navigator.userAgent)?void 0:t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};let n=globalThis.process;if(n){let e=n.versions;if(e&&e.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+=`
78
+ ${u.stack}`)}else o=null!=(i=null==e?void 0:e.stack)?i:"";let d=this.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(c="",l="Request was aborted (timeout or manual cancellation)",d>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${d} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((null==u?void 0:u.name)==="HeadersOverflowError"||(null==u?void 0:u.code)==="UND_ERR_HEADERS_OVERFLOW")&&(c="",l="HTTP headers exceeded server limits (typically 16KB)",d>this.urlLengthLimit&&(l+=`. Your request URL is ${d} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${null!=(t=null==e?void 0:e.name)?t:"FetchError"}: ${null==e?void 0:e.message}`,details:o,hint:l,code:c},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}async processResponse(e){var t,r,s,n;let a=null,i=null,o=null,l=e.status,c=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();if(""===t);else if("text/csv"===this.headers.get("Accept"))i=t;else if(this.headers.get("Accept")&&(null==(s=this.headers.get("Accept"))?void 0:s.includes("application/vnd.pgrst.plan+text")))i=t;else try{i=JSON.parse(t)}catch(e){if(a={message:t},i=null,this.shouldThrowOnError)throw new tm({message:t,details:"",hint:"",code:""})}}let u=null==(t=this.headers.get("Prefer"))?void 0:t.match(/count=(exact|planned|estimated)/),d=null==(r=e.headers.get("content-range"))?void 0:r.split("/");if(u&&d&&d.length>1&&(o=parseInt(d[1])),this.isMaybeSingle&&Array.isArray(i))if(i.length>1){if(a={code:"PGRST116",details:`Results contain ${i.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},i=null,o=null,l=406,c="Not Acceptable",this.shouldThrowOnError)throw new tm(tk(tk({},a),{},{hint:null!=(n=a.hint)?n:""}))}else i=1===i.length?i[0]:null}else{let t=await e.text();try{a=JSON.parse(t),Array.isArray(a)&&404===e.status&&(i=[],a=null,l=200,c="OK")}catch(r){404===e.status&&""===t?(l=204,c="No Content"):a={message:t}}if(a&&this.shouldThrowOnError)throw new tm(a)}return{success:null===a,error:a,data:i,count:o,status:l,statusText:c}}returns(){return this}overrideTypes(){return this}},tA=class extends tx{throwOnError(){return super.throwOnError()}select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){let a=n?`${n}.order`:"order",i=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${i?`${i},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let n=void 0===s?"offset":`${s}.offset`,a=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this.url.searchParams.set(a,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:a="text"}={}){var i;let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=null!=(i=this.headers.get("Accept"))?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${o};`),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};let tT=RegExp("[,()]");var tR=class extends tA{throwOnError(){return super.throwOnError()}eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&tT.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}notIn(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&tT.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`not.in.(${r})`),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let n="";"plain"===s?n="pl":"phrase"===s?n="ph":"websearch"===s&&(n="w");let a=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${n}fts${a}.${t}`),this}match(e){return Object.entries(e).filter(([e,t])=>void 0!==t).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}},tE=class{constructor(e,{headers:t={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:a}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){let{head:r=!1,count:s}=null!=t?t:{},n=!1,a=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e)).join(""),{url:i,headers:o}=this.cloneRequestState();return i.searchParams.set("select",a),s&&o.append("Prefer",`count=${s}`),new tR({method:r?"HEAD":"GET",url:i,headers:o,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;let{url:n,headers:a}=this.cloneRequestState();if(t&&a.append("Prefer",`count=${t}`),r||a.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);n.searchParams.set("columns",e.join(","))}}return new tR({method:"POST",url:n,headers:a,schema:this.schema,body:e,fetch:null!=(s=this.fetch)?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var a;let{url:i,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&i.searchParams.set("on_conflict",t),s&&o.append("Prefer",`count=${s}`),n||o.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);i.searchParams.set("columns",e.join(","))}}return new tR({method:"POST",url:i,headers:o,schema:this.schema,body:e,fetch:null!=(a=this.fetch)?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var r;let{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new tR({method:"PATCH",url:s,headers:n,schema:this.schema,body:e,fetch:null!=(r=this.fetch)?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:e}={}){var t;let{url:r,headers:s}=this.cloneRequestState();return e&&s.append("Prefer",`count=${e}`),new tR({method:"DELETE",url:r,headers:s,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function tI(e,t,r){var s;return{success:!1,error:new tm({message:`${null!=(s=null==e?void 0:e.name)?s:"FetchError"}: ${null==e?void 0:e.message}`,details:"",hint:"",code:""}),data:null,count:null,status:t,statusText:r}}var tj=class e{constructor(e,{headers:t={},schema:r,fetch:s,timeout:n,urlLengthLimit:a=8e3,retry:i}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.urlLengthLimit=a;let o=null!=s?s:globalThis.fetch;void 0!==n&&n>0?this.fetch=(e,t)=>{let r=new AbortController,s=setTimeout(()=>r.abort(),n),a=null==t?void 0:t.signal;if(a){if(a.aborted)return clearTimeout(s),o(e,t);let n=()=>{clearTimeout(s),r.abort()};return a.addEventListener("abort",n,{once:!0}),o(e,tk(tk({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(s),a.removeEventListener("abort",n)})}return o(e,tk(tk({},t),{},{signal:r.signal})).finally(()=>clearTimeout(s))}:this.fetch=o,this.retry=i}from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new tE(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}async getOpenApiSpec(){var e,t;let r,s,n=new Headers(this.headers);n.set("Accept","application/openapi+json"),this.schemaName&&n.set("Accept-Profile",this.schemaName);let a={};n.forEach((e,t)=>{a[t]=e});let i=null!=(e=this.fetch)?e:globalThis.fetch;try{r=await tS(i,`${this.url}/`,{method:"GET",headers:a},null==(t=this.retry)||t)}catch(e){return tI(e,0,"")}try{s=await r.text()}catch(e){return tI(e,r.status,r.statusText)}if(r.ok)try{return{success:!0,error:null,data:JSON.parse(s),count:null,status:r.status,statusText:r.statusText}}catch(e){}return{success:!1,error:function(e,t){try{let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t)){var r,s,n,a;return new tm({message:String(null!=(r=t.message)?r:e),details:null!=(s=t.details)?s:"",hint:null!=(n=t.hint)?n:"",code:null!=(a=t.code)?a:""})}}catch(e){}return new tm({message:e||t,details:"",hint:"",code:""})}(s,r.statusText),data:null,count:null,status:r.status,statusText:r.statusText}}rpc(e,t={},{head:r=!1,get:s=!1,count:n}={}){var a;let i,o,l=new URL(`${this.url}/rpc/${e}`),c=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(c)),u=r&&Object.values(t).some(c);u?(i="POST",o=t):r||s?(i=r?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`]).forEach(([e,t])=>{l.searchParams.append(e,t)})):(i="POST",o=t);let d=new Headers(this.headers);return u?d.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&d.set("Prefer",`count=${n}`),new tR({method:i,url:l,headers:d,schema:this.schemaName,body:o,fetch:null!=(a=this.fetch)?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};let tO=class{static detectEnvironment(){var t;if("u">typeof WebSocket)return{type:"native",wsConstructor:WebSocket};let r=globalThis;if("u">typeof globalThis&&void 0!==r.WebSocket)return{type:"native",wsConstructor:r.WebSocket};let s=e.g;if(s&&void 0!==s.WebSocket)return{type:"native",wsConstructor:s.WebSocket};if("u">typeof globalThis&&void 0!==r.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("u">typeof globalThis&&r.EdgeRuntime||"u">typeof navigator&&(null==(t=navigator.userAgent)?void 0:t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};let n=globalThis.process;if(n){let e=n.versions;if(e&&e.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+=`
77
79
 
78
- Suggested solution: ${e.workaround}`),Error(t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type}catch(e){return!1}}},tS="2.0.0",tx="errored",tA="joined",tT={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"};class tR{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}encode(e,t){return e.event!==this.BROADCAST_EVENT||e.payload instanceof ArrayBuffer||"string"!=typeof e.payload.event?t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload])):t(this._binaryEncodeUserBroadcastPush(e))}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null==(t=e.payload)?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var t,r;let s=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(e){var t,r;let s=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:{},n=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,n)}_encodeUserBroadcastPush(e,t,r){let s=new TextEncoder,n=s.encode(e.topic),a=s.encode(null!=(m=e.ref)?m:""),i=s.encode(null!=(g=e.join_ref)?g:""),o=s.encode(e.payload.event),l=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},c=s.encode(0===Object.keys(l).length?"":JSON.stringify(l));if(i.length>255)throw Error(`joinRef length ${i.length} exceeds maximum of 255`);if(a.length>255)throw Error(`ref length ${a.length} exceeds maximum of 255`);if(n.length>255)throw Error(`topic length ${n.length} exceeds maximum of 255`);if(o.length>255)throw Error(`userEvent length ${o.length} exceeds maximum of 255`);if(c.length>255)throw Error(`metadata length ${c.length} exceeds maximum of 255`);let u=this.USER_BROADCAST_PUSH_META_LENGTH+i.length+a.length+n.length+o.length+c.length,d=new ArrayBuffer(this.HEADER_LENGTH+u),h=new DataView(d),p=new Uint8Array(d),f=0;h.setUint8(f++,this.KINDS.userBroadcastPush),h.setUint8(f++,i.length),h.setUint8(f++,a.length),h.setUint8(f++,n.length),h.setUint8(f++,o.length),h.setUint8(f++,c.length),h.setUint8(f++,t),p.set(i,f),f+=i.length,p.set(a,f),f+=a.length,p.set(n,f),f+=n.length,p.set(o,f),f+=o.length,p.set(c,f),f+=c.length;var m,g,b=new Uint8Array(d.byteLength+r.byteLength);return b.set(new Uint8Array(d),0),b.set(new Uint8Array(r),d.byteLength),b.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,s,n,a,i]=JSON.parse(e);return t({join_ref:r,ref:s,topic:n,event:a,payload:i})}return t({})}_binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),s=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,s)}_decodeUserBroadcast(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=t.getUint8(3),i=t.getUint8(4),o=this.HEADER_LENGTH+4,l=r.decode(e.slice(o,o+s));o+=s;let c=r.decode(e.slice(o,o+n));o+=n;let u=r.decode(e.slice(o,o+a));o+=a;let d=e.slice(o,e.byteLength),h=i===this.JSON_ENCODING?JSON.parse(r.decode(d)):d,p={type:this.BROADCAST_EVENT,event:c,payload:h};return a>0&&(p.meta=JSON.parse(u)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:p}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||(null==(t=null==e?void 0:e.constructor)?void 0:t.name)==="ArrayBuffer"}_pick(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e))):{}}}(u=b||(b={})).abstime="abstime",u.bool="bool",u.date="date",u.daterange="daterange",u.float4="float4",u.float8="float8",u.int2="int2",u.int4="int4",u.int4range="int4range",u.int8="int8",u.int8range="int8range",u.json="json",u.jsonb="jsonb",u.money="money",u.numeric="numeric",u.oid="oid",u.reltime="reltime",u.text="text",u.time="time",u.timestamp="timestamp",u.timestamptz="timestamptz",u.timetz="timetz",u.tsrange="tsrange",u.tstzrange="tstzrange";let tE=(e,t,r={})=>{var s;let n=null!=(s=r.skipTypes)?s:[];return t?Object.keys(t).reduce((r,s)=>(r[s]=tI(s,e,t,n),r),{}):{}},tI=(e,t,r,s)=>{let n=t.find(t=>t.name===e),a=null==n?void 0:n.type,i=r[e];return a&&!s.includes(a)?tj(a,i):tO(i)},tj=(e,t)=>{if("_"===e.charAt(0))return tN(t,e.slice(1,e.length));switch(e){case b.bool:return tC(t);case b.float4:case b.float8:case b.int2:case b.int4:case b.int8:case b.numeric:case b.oid:return t$(t);case b.json:case b.jsonb:return tP(t);case b.timestamp:return tD(t);case b.abstime:case b.date:case b.daterange:case b.int4range:case b.int8range:case b.money:case b.reltime:case b.text:case b.time:case b.timestamptz:case b.timetz:case b.tsrange:case b.tstzrange:default:return tO(t)}},tO=e=>e,tC=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},t$=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},tP=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},tN=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s,n=e.slice(1,r);try{s=JSON.parse("["+n+"]")}catch(e){s=n?n.split(","):[]}return s.map(e=>tj(t,e))}return e},tD=e=>"string"==typeof e?e.replace(" ","T"):e,tL=e=>{let t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var tU=e=>"function"==typeof e?e:function(){return e},tq=("u">typeof self?self:null)||globalThis,tM="closed",tB="errored",tz="joined",tF="joining",tW="leaving",tH="phx_close",tG="phx_error",tK="phx_reply",tJ="phx_leave",tV="websocket",tY="base64url.bearer.phx.",tX=class{constructor(e,t,r,s){this.channel=e,this.event=t,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:r}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},tZ=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},tQ=class{constructor(e,t,r){this.state=tM,this.topic=e,this.params=tU(t||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new tX(this,"phx_join",this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new tZ(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=tz,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=tB,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=tM,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=tB,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new tX(this,tJ,tU({}),this.timeout).send(),this.state=tB,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(tK,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(!this.joinedOnce)return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush;throw Error("tried to join multiple times. 'join' can only be called a single time per channel instance")}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=tM,this.bindings=[]}onClose(e){this.on(tH,e)}onError(e){return this.on(tG,t=>e(t))}on(e,t){let r=this.bindingRef++;return this.bindings.push({event:e,ref:r,callback:t}),r}off(e,t){this.bindings=this.bindings.filter(r=>r.event!==e||void 0!==t&&t!==r.ref)}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,r=this.timeout){if(t=t||{},!this.joinedOnce)throw Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new tX(this,e,function(){return t},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=tW;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(tH,"leave")},r=new tX(this,tJ,tU({}),e);return r.receive("ok",()=>t()).receive("timeout",()=>t()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(e,t,r){return t}filterBindings(e,t,r){return!0}isMember(e,t,r,s){return this.topic===e&&(!s||s===this.joinRef()||(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:r,joinRef:s}),!1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=tF,this.joinPush.resend(e))}trigger(e,t,r,s){let n=this.onMessage(e,t,r,s);if(t&&!n)throw Error("channel onMessage callbacks must return the payload, modified or unmodified");let a=this.bindings.filter(s=>s.event===e&&this.filterBindings(s,t,r));for(let e=0;e<a.length;e++)a[e].callback(n,r,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===tM}isErrored(){return this.state===tB}isJoined(){return this.state===tz}isJoining(){return this.state===tF}isLeaving(){return this.state===tW}},t0=class{static request(e,t,r,s,n,a,i){if(tq.XDomainRequest){let r=new tq.XDomainRequest;return this.xdomainRequest(r,e,t,s,n,a,i)}if(tq.XMLHttpRequest){let o=new tq.XMLHttpRequest;return this.xhrRequest(o,e,t,r,s,n,a,i)}if(tq.fetch&&tq.AbortController)return this.fetchRequest(e,t,r,s,n,a,i);throw Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,r,s,n,a,i){let o={method:e,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),o.signal=l.signal),tq.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>i&&i(e)).catch(e=>{"AbortError"===e.name&&a?a():i&&i(null)}),l}static xdomainRequest(e,t,r,s,n,a,i){return e.timeout=n,e.open(t,r),e.onload=()=>{let t=this.parseJSON(e.responseText);i&&i(t)},a&&(e.ontimeout=a),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,r,s,n,a,i,o){for(let[n,i]of(e.open(t,r,!0),e.timeout=a,Object.entries(s)))e.setRequestHeader(n,i);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{4===e.readyState&&o&&o(this.parseJSON(e.responseText))},i&&(e.ontimeout=i),e.send(n),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let r=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let n=t?`${t}[${s}]`:s,a=e[s];"object"==typeof a?r.push(this.serialize(a,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(a))}return r.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?";return`${e}${r}${this.serialize(t)}`}},t1=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(tY)&&(this.authToken=atob(t[1].slice(tY.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=0,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(RegExp("(.*)/"+tV),"$1/longpoll")}endpointURL(){return t0.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,r){this.close(e,t,r),this.readyState=0}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return 1===this.readyState||0===this.readyState}poll(){let e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:r,messages:s}=e;if(410===t&&null!==this.token){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=r}else t=0;switch(t){case 200:s.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=1,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw Error(`unhandled poll status ${t}`)}})}send(e){"string"!=typeof e&&(e=(e=>{let t="",r=new Uint8Array(e),s=r.byteLength;for(let e=0;e<s;e++)t+=String.fromCharCode(r[e]);return btoa(t)})(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e,t=0){this.awaitingBatchAck=!0;let r=t+100,s=e.slice(t,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},s.join("\n"),()=>this.onerror("timeout"),t=>{t&&200===t.status?r<e.length?this.batchSend(e,r):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1:(this.awaitingBatchAck=!1,this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,r){for(let e of this.reqs)e.abort();this.readyState=3;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"u">typeof CloseEvent?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,r,s,n){let a,i=()=>{this.reqs.delete(a),s()};a=t0.request(e,this.endpointURL(),t,r,this.timeout,i,e=>{this.reqs.delete(a),this.isActive()&&n(e)}),this.reqs.add(a)}},t2=class e{constructor(t,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,t=>{let{onJoin:r,onLeave:s,onSync:n}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,r,s),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,r,s)}),this.pendingDiffs=[],n()}),this.channel.on(s.diff,t=>{let{onJoin:r,onLeave:s,onSync:n}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,r,s),n())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,r,s){let n=this.toNullProtoObj(this.clone(e));t=this.toNullProtoObj(t);let a=Object.create(null),i=Object.create(null);return this.map(n,(e,r)=>{t[e]||(i[e]=r)}),this.map(t,(e,t)=>{let r=n[e];if(r){let s=t.metas.map(e=>e.phx_ref),n=r.metas.map(e=>e.phx_ref),o=t.metas.filter(e=>0>n.indexOf(e.phx_ref)),l=r.metas.filter(e=>0>s.indexOf(e.phx_ref));o.length>0&&(a[e]=t,a[e].metas=o),l.length>0&&(i[e]=this.clone(r),i[e].metas=l)}else a[e]=t}),this.syncDiff(n,{joins:a,leaves:i},r,s)}static syncDiff(e,t,r,s){e=this.toNullProtoObj(e);let{joins:n,leaves:a}=this.clone(t);return r||(r=function(){}),s||(s=function(){}),this.map(n,(t,s)=>{let n=e[t];if(e[t]=this.clone(s),n){let r=e[t].metas.map(e=>e.phx_ref),s=n.metas.filter(e=>0>r.indexOf(e.phx_ref));e[t].metas.unshift(...s)}r(t,n,s)}),this.map(a,(t,r)=>{let n=e[t];if(!n)return;let a=r.metas.map(e=>e.phx_ref);n.metas=n.metas.filter(e=>0>a.indexOf(e.phx_ref)),s(t,n,r),0===n.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,r)=>t(e,r))}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static toNullProtoObj(e){if(null===Object.getPrototypeOf(e))return e;let t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=e[r]}),t}static clone(e){return JSON.parse(JSON.stringify(e))}},t3={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){return e.payload.constructor===ArrayBuffer?t(this.binaryEncode(e)):t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload]))},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[r,s,n,a,i]=JSON.parse(e);return t({join_ref:r,ref:s,topic:n,event:a,payload:i})}},binaryEncode(e){let{join_ref:t,ref:r,event:s,topic:n,payload:a}=e,i=new TextEncoder,o=i.encode(t),l=i.encode(r),c=i.encode(n),u=i.encode(s);this.assertFieldSize(o.byteLength,"join_ref"),this.assertFieldSize(l.byteLength,"ref"),this.assertFieldSize(c.byteLength,"topic"),this.assertFieldSize(u.byteLength,"event");let d=this.META_LENGTH+o.byteLength+l.byteLength+c.byteLength+u.byteLength,h=new ArrayBuffer(this.HEADER_LENGTH+d),p=new Uint8Array(h),f=new DataView(h),m=0;f.setUint8(m++,this.KINDS.push),f.setUint8(m++,o.byteLength),f.setUint8(m++,l.byteLength),f.setUint8(m++,c.byteLength),f.setUint8(m++,u.byteLength),p.set(o,m),m+=o.byteLength,p.set(l,m),m+=l.byteLength,p.set(c,m),m+=c.byteLength,p.set(u,m),m+=u.byteLength;var g=new Uint8Array(h.byteLength+a.byteLength);return g.set(p,0),g.set(new Uint8Array(a),h.byteLength),g.buffer},assertFieldSize(e,t){if(e>255)throw Error(`unable to convert ${t} to binary: must be less than or equal to 255 bytes, but is ${e} bytes`)},binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=t.getUint8(3),i=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(e.slice(i,i+s));i+=s;let l=r.decode(e.slice(i,i+n));i+=n;let c=r.decode(e.slice(i,i+a));return i+=a,{join_ref:o,ref:null,topic:l,event:c,payload:e.slice(i,e.byteLength)}},decodeReply(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=t.getUint8(3),i=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(e.slice(o,o+s));o+=s;let c=r.decode(e.slice(o,o+n));o+=n;let u=r.decode(e.slice(o,o+a));o+=a;let d=r.decode(e.slice(o,o+i));return o+=i,{join_ref:l,ref:c,topic:u,event:tK,payload:{status:d,response:e.slice(o,e.byteLength)}}},decodeBroadcast(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=this.HEADER_LENGTH+2,i=r.decode(e.slice(a,a+s));a+=s;let o=r.decode(e.slice(a,a+n));return a+=n,{join_ref:null,ref:null,topic:i,event:o,payload:e.slice(a,e.byteLength)}}},t4=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||1e4,this.transport=t.transport||tq.WebSocket||t1,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=tq&&tq.sessionStorage}catch{}this.sessionStore=t.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=t3.encode.bind(t3),this.defaultDecoder=t3.decode.bind(t3),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==t1?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,r)=>{console.log(`${e}: ${t}`,r)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=tU(t.params||{}),this.endPoint=`${e}/${tV}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new tZ(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken&&tU(t.authToken)}getLongPollTransport(){return t1}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=t0.appendParams(t0.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,r)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=tU(e)),(!this.conn||this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==t1?this.connectWithFallback(t1,this.longPollFallbackMs):this.transportConnect())}log(e,t,r){this.logger&&this.logger(e,t,r)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-r))});return!0}transportName(e){return e===t1?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${tY}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){let r,s;clearTimeout(this.fallbackTimer);let n=!1,a=!0,i=this.transportName(e),o=t=>{this.log("transport",`falling back to ${i}...`,t),this.off([r,s]),a=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${i}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),s=this.onError(e=>{this.log("transport","error",e),a&&!n&&(clearTimeout(this.fallbackTimer),o(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(n=!0,!a){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,"true"),this.log("transport",`established ${t} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,r){if(!this.conn)return e&&e();let s=this.conn;this.waitForBufferDone(s,()=>{t?s.close(t,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,r=1){5!==r&&e.bufferedAmount?setTimeout(()=>{this.waitForBufferDone(e,t,r+1)},150*r):t()}waitForSocketClosed(e,t,r=1){5===r||3===e.readyState?t():setTimeout(()=>{this.waitForSocketClosed(e,t,r+1)},150*r)}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",e,t,r),(t===this.transport||r>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(tG,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case 0:return"connecting";case 1:return"open";case 2:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>-1===e.indexOf(t))}channel(e,t={}){let r=new tQ(e,t,this);return this.channels.push(r),r}push(e){if(this.hasLogger()){let{topic:t,event:r,payload:s,ref:n,join_ref:a}=e;this.log("push",`${t} ${r} (${a}, ${n})`,s)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef)return void this.heartbeatTimeout();this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:r,payload:s,ref:n,join_ref:a}=e;if(n&&n===this.pendingHeartbeatRef){let e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===s.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${s.status||""} ${t} ${r} ${n&&"("+n+")"||""}`.trim(),s);for(let e=0;e<this.channels.length;e++){let i=this.channels[e];i.isMember(t,r,s,a)&&i.trigger(r,s,n,a)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([r,s])=>{try{s(...t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};class t5{constructor(e,t){var r;let s=(null==(r=t)?void 0:r.events)&&{events:r.events};this.presence=new t2(e.getChannel(),s),this.presence.onJoin((t,r,s)=>{let n=t5.onJoinPayload(t,r,s);e.getChannel().trigger("presence",n)}),this.presence.onLeave((t,r,s)=>{let n=t5.onLeavePayload(t,r,s);e.getChannel().trigger("presence",n)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return t5.transformState(this.presence.state)}static transformState(e){return Object.getOwnPropertyNames(e=JSON.parse(JSON.stringify(e))).reduce((t,r)=>{let s=e[r];return t[r]=t6(s),t},{})}static onJoinPayload(e,t,r){return{event:"join",key:e,currentPresences:t8(t),newPresences:t6(r)}}static onLeavePayload(e,t,r){return{event:"leave",key:e,currentPresences:t8(t),leftPresences:t6(r)}}}function t6(e){return e.metas.map(e=>{let t=Object.defineProperties({},Object.getOwnPropertyDescriptors(e));return t.presence_ref=t.phx_ref,delete t.phx_ref,delete t.phx_ref_prev,t})}function t8(e){return(null==e?void 0:e.metas)?t6(e):[]}(d=y||(y={})).SYNC="sync",d.JOIN="join",d.LEAVE="leave";class t9{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new t5(this.channel.channelAdapter,t)}}class t7{constructor(e,t,r){let s={config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config)};this.channel=e.getSocket().channel(t,s),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,t){return this.channel.on(e,t)}off(e,t){this.channel.off(e,t)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,t,r){let s;try{s=this.channel.push(e,t,r)}catch(t){throw Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>100){let e=this.channel.pushBuffer.shift();e.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${e.event}`,e.payload())}return s}updateJoinPayload(e){let t=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},t),e)}canPush(){return this.socket.isConnected()&&this.state===tA}isJoined(){return this.state===tA}isJoining(){return"joining"===this.state}isClosed(){return"closed"===this.state}isLeaving(){return"leaving"===this.state}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}let re=/[,()"\\]/,rt=e=>{let t=null===e?"null":String(e);return re.test(t)||t!==t.trim()?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t};class rr{constructor(){this.filters=[]}add(e,t,r,s=!1){return this.filters.push(`${e}=${s?"not.":""}${((e,t)=>{if("in"===e){let e=Array.isArray(t)?t:[t];if(0===e.length)throw Error("Realtime `in` filter requires at least one value.");let r=Array.from(new Set(e)).map(e=>rt(e)).join(",");return`in.(${r})`}if("is"===e)return`is.${null===t?"null":String(t)}`;return`${e}.${rt(t)}`})(t,r)}`),this}eq(e,t){return this.add(e,"eq",t)}neq(e,t){return this.add(e,"neq",t)}gt(e,t){return this.add(e,"gt",t)}gte(e,t){return this.add(e,"gte",t)}lt(e,t){return this.add(e,"lt",t)}lte(e,t){return this.add(e,"lte",t)}in(e,t){return this.add(e,"in",t)}like(e,t){return this.add(e,"like",t)}ilike(e,t){return this.add(e,"ilike",t)}match(e,t){return this.add(e,"match",t)}imatch(e,t){return this.add(e,"imatch",t)}is(e,t){return this.add(e,"is",t)}isDistinct(e,t){return this.add(e,"isdistinct",t)}not(e,t,r){return this.add(e,t,r,!0)}build(){return this.filters.join(",")}toString(){return this.build()}}(h=w||(w={})).ALL="*",h.INSERT="INSERT",h.UPDATE="UPDATE",h.DELETE="DELETE",(p=v||(v={})).BROADCAST="broadcast",p.PRESENCE="presence",p.POSTGRES_CHANGES="postgres_changes",p.SYSTEM="system",(f=k||(k={})).SUBSCRIBED="SUBSCRIBED",f.TIMED_OUT="TIMED_OUT",f.CLOSED="CLOSED",f.CHANNEL_ERROR="CHANNEL_ERROR";class rs{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,t={config:{}},r){var s,n;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new t7(this.socket.socketAdapter,e,this.params),this.presence=new t9(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=tL(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null==(n=null==(s=this.params.config)?void 0:s.broadcast)?void 0:n.replay))throw Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,t=this.timeout){var r,s,n,a;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:i,presence:o,private:l,postgres_changes_options:c}}=this.params,u=null!=(s=null==(r=this.bindings.postgres_changes)?void 0:r.map(e=>e.filter))?s:[],d=!!this.bindings[v.PRESENCE]&&this.bindings[v.PRESENCE].length>0||(null==(n=this.params.config.presence)?void 0:n.enabled)===!0,h={},p=Object.assign({broadcast:i,presence:Object.assign(Object.assign({},o),{enabled:d}),postgres_changes:u,private:l},c?{postgres_changes_options:c}:{});this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(k.CHANNEL_ERROR,function(e){if(e instanceof Error)return e;if("string"==typeof e)return Error(e);if(e&&"object"==typeof e){if("number"==typeof e.code){let t="string"==typeof e.reason&&e.reason?` (${e.reason})`:"";return Error(`socket closed: ${e.code}${t}`,{cause:e})}return Error("channel error: transport failure",{cause:e})}return Error("channel error: connection lost")}(t))}),this._onClose(()=>null==e?void 0:e(k.CLOSED)),this.updateJoinPayload(Object.assign({config:p},h)),this._updateFilterMessage();let f=(null==c?void 0:c.wait)&&u.length>0?Math.max(t,(null!=(a=c.timeout)?a:15e3)+1e4):t;this.channelAdapter.subscribe(f).receive("ok",async({postgres_changes:t})=>{if(this.socket._isManualToken()||this.socket.setAuth(),void 0===t){null==e||e(k.SUBSCRIBED);return}this._updatePostgresBindings(t,e)}).receive("error",t=>{this.state=tx;let r=Object.values(t).join(", ")||"error";null==e||e(k.CHANNEL_ERROR,Error(r,{cause:t}))}).receive("timeout",()=>{null==e||e(k.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var r;let s=this.bindings.postgres_changes,n=null!=(r=null==s?void 0:s.length)?r:0,a=[];for(let r=0;r<n;r++){let n=s[r],{filter:{event:i,schema:o,table:l,filter:c}}=n,u=e&&e[r];if(u&&u.event===i&&rs.isFilterValueEqual(u.schema,o)&&rs.isFilterValueEqual(u.table,l)&&rs.isFilterValueEqual(u.filter,c))a.push(Object.assign(Object.assign({},n),{id:u.id}));else{this.unsubscribe(),this.state=tx,null==t||t(k.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=a,this.state!=tx&&t&&t(k.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){let s=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),n=e===v.PRESENCE||e===v.POSTGRES_CHANGES;if(s&&n)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,t,r)}async httpSend(e,t,r={}){var s;if(null==t)return Promise.reject(Error("Payload is required for httpSend()"));let n=t instanceof ArrayBuffer||ArrayBuffer.isView(t),a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":n?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);let i=new URL(this.broadcastEndpointURL);i.pathname+=`/${encodeURIComponent(this.subTopic)}/events/${encodeURIComponent(e)}`,this.private&&i.searchParams.set("private","true");let o={method:"POST",headers:a,body:n?t:JSON.stringify(t)},l=await this._fetchWithTimeout(i.toString(),o,null!=(s=r.timeout)?s:this.timeout);if(202===l.status)return{success:!0};if(404===l.status)return Promise.reject(Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));let c=l.statusText;try{let e=await l.json();c=e.error||e.message||c}catch(e){}return Promise.reject(Error(c))}async send(e,t={}){var r,s;if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,n,a;let i=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(a=null==(n=null==(s=this.params)?void 0:s.config)?void 0:n.broadcast)?void 0:a.ack)||r("ok"),i.receive("ok",()=>r("ok")),i.receive("error",()=>r("error")),i.receive("timeout",()=>r("timed out"))});{let n="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.";this.socket.hasLogger()?this.socket.log("channel",n):console.warn(n);let{event:a,payload:i}=e,o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(o.Authorization=`Bearer ${this.socket.accessTokenValue}`);let l={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:i,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,l,null!=(r=t.timeout)?r:this.timeout);return await (null==(s=e.body)?void 0:s.cancel()),e.ok?"ok":"error"}catch(e){if(e instanceof Error&&"AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(t=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>t("ok")).receive("timeout",()=>t("timed out")).receive("error",()=>t("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,t,r){let s=new AbortController,n=setTimeout(()=>s.abort(),r),a=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(n),a}_on(e,t,r){var s;let n=e.toLocaleLowerCase(),a=null==t?void 0:t.filter;if((a instanceof rr||"object"==typeof a&&null!==a&&"function"==typeof a.build)&&(t=Object.assign(Object.assign({},t),{filter:a.build()})),n===v.POSTGRES_CHANGES&&(null==(s=this.bindings[n])?void 0:s.find(e=>rs.isSamePostgresFilter(e.filter,t))))return this.socket.log("error",`duplicate \`postgres_changes\` binding for ${this.topic} ignored`,t),this;let i=this.channelAdapter.on(e,r),o={type:n,filter:t,callback:r,ref:i};return this.bindings[n]?this.bindings[n].push(o):this.bindings[n]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,r)=>{var s,n,a,i,o,l,c;let u=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(u,r))return!1;let d=null==(s=this.bindings[u])?void 0:s.find(t=>t.ref===e.ref);if(!d)return!0;if(!["broadcast","presence","postgres_changes"].includes(u))return d.type.toLocaleLowerCase()===u;if("id"in d){let e=d.id,r=null==(n=d.filter)?void 0:n.event;return e&&(null==(a=t.ids)?void 0:a.includes(e))&&("*"===r||(null==r?void 0:r.toLocaleLowerCase())===(null==(i=t.data)?void 0:i.type.toLocaleLowerCase()))}{let e=null==(l=null==(o=null==d?void 0:d.filter)?void 0:o.event)?void 0:l.toLocaleLowerCase();return"*"===e||e===(null==(c=null==t?void 0:t.event)?void 0:c.toLocaleLowerCase())}})}_notThisChannelEvent(e,t){let{close:r,error:s,leave:n,join:a}=tT;return t&&[r,s,n,a].includes(e)&&t!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,t,r)=>{if("object"==typeof t&&"ids"in t){let e=t.data,{schema:r,table:s,commit_timestamp:n,type:a,errors:i}=e;return Object.assign(Object.assign({},{schema:r,table:s,commit_timestamp:n,eventType:a,new:{},old:{},errors:i}),this._getPayloadRecords(e))}return t})}copyBindings(e){if(this.joinedOnce)throw Error("cannot copy bindings into joined channel");for(let t in e.bindings)for(let r of e.bindings[t])this._on(r.type,r.filter,r.callback)}static isFilterValueEqual(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}static isSamePostgresFilter(e,t){var r,s,n,a;let i=null!=(s=null==(r=null==e?void 0:e.select)?void 0:r.join())?s:void 0,o=null!=(a=null==(n=null==t?void 0:t.select)?void 0:n.join())?a:void 0;return(null==e?void 0:e.event)===(null==t?void 0:t.event)&&rs.isFilterValueEqual(null==e?void 0:e.schema,null==t?void 0:t.schema)&&rs.isFilterValueEqual(null==e?void 0:e.table,null==t?void 0:t.table)&&rs.isFilterValueEqual(null==e?void 0:e.filter,null==t?void 0:t.filter)&&i===o}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=tE(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=tE(e.columns,e.old_record)),t}}class rn{constructor(e,t){this.socket=new t4(e,t)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,t,r,s=1e4){return new Promise(n=>{setTimeout(()=>n("timeout"),s),this.socket.disconnect(()=>{e(),n("ok")},t,r)})}push(e){this.socket.push(e)}log(e,t,r){this.socket.log(e,t,r)}hasLogger(){return this.socket.hasLogger()}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return"connecting"==this.socket.connectionState()}isDisconnecting(){return"closing"==this.socket.connectionState()}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}let ra=[1e3,2e3,5e3,1e4],ri=`
80
+ Suggested solution: ${e.workaround}`),Error(t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type}catch(e){return!1}}},t$="2.0.0",tC="errored",tP="joined",tN={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"};class tD{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}encode(e,t){return e.event!==this.BROADCAST_EVENT||e.payload instanceof ArrayBuffer||"string"!=typeof e.payload.event?t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload])):t(this._binaryEncodeUserBroadcastPush(e))}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null==(t=e.payload)?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var t,r;let s=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(e){var t,r;let s=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:{},n=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,n)}_encodeUserBroadcastPush(e,t,r){let s=new TextEncoder,n=s.encode(e.topic),a=s.encode(null!=(m=e.ref)?m:""),i=s.encode(null!=(g=e.join_ref)?g:""),o=s.encode(e.payload.event),l=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},c=s.encode(0===Object.keys(l).length?"":JSON.stringify(l));if(i.length>255)throw Error(`joinRef length ${i.length} exceeds maximum of 255`);if(a.length>255)throw Error(`ref length ${a.length} exceeds maximum of 255`);if(n.length>255)throw Error(`topic length ${n.length} exceeds maximum of 255`);if(o.length>255)throw Error(`userEvent length ${o.length} exceeds maximum of 255`);if(c.length>255)throw Error(`metadata length ${c.length} exceeds maximum of 255`);let u=this.USER_BROADCAST_PUSH_META_LENGTH+i.length+a.length+n.length+o.length+c.length,d=new ArrayBuffer(this.HEADER_LENGTH+u),h=new DataView(d),p=new Uint8Array(d),f=0;h.setUint8(f++,this.KINDS.userBroadcastPush),h.setUint8(f++,i.length),h.setUint8(f++,a.length),h.setUint8(f++,n.length),h.setUint8(f++,o.length),h.setUint8(f++,c.length),h.setUint8(f++,t),p.set(i,f),f+=i.length,p.set(a,f),f+=a.length,p.set(n,f),f+=n.length,p.set(o,f),f+=o.length,p.set(c,f),f+=c.length;var m,g,b=new Uint8Array(d.byteLength+r.byteLength);return b.set(new Uint8Array(d),0),b.set(new Uint8Array(r),d.byteLength),b.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,s,n,a,i]=JSON.parse(e);return t({join_ref:r,ref:s,topic:n,event:a,payload:i})}return t({})}_binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),s=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,s)}_decodeUserBroadcast(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=t.getUint8(3),i=t.getUint8(4),o=this.HEADER_LENGTH+4,l=r.decode(e.slice(o,o+s));o+=s;let c=r.decode(e.slice(o,o+n));o+=n;let u=r.decode(e.slice(o,o+a));o+=a;let d=e.slice(o,e.byteLength),h=i===this.JSON_ENCODING?JSON.parse(r.decode(d)):d,p={type:this.BROADCAST_EVENT,event:c,payload:h};return a>0&&(p.meta=JSON.parse(u)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:p}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||(null==(t=null==e?void 0:e.constructor)?void 0:t.name)==="ArrayBuffer"}_pick(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e))):{}}}(u=b||(b={})).abstime="abstime",u.bool="bool",u.date="date",u.daterange="daterange",u.float4="float4",u.float8="float8",u.int2="int2",u.int4="int4",u.int4range="int4range",u.int8="int8",u.int8range="int8range",u.json="json",u.jsonb="jsonb",u.money="money",u.numeric="numeric",u.oid="oid",u.reltime="reltime",u.text="text",u.time="time",u.timestamp="timestamp",u.timestamptz="timestamptz",u.timetz="timetz",u.tsrange="tsrange",u.tstzrange="tstzrange";let tL=(e,t,r={})=>{var s;let n=null!=(s=r.skipTypes)?s:[];return t?Object.keys(t).reduce((r,s)=>(r[s]=tU(s,e,t,n),r),{}):{}},tU=(e,t,r,s)=>{let n=t.find(t=>t.name===e),a=null==n?void 0:n.type,i=r[e];return a&&!s.includes(a)?tq(a,i):tM(i)},tq=(e,t)=>{if("_"===e.charAt(0))return tW(t,e.slice(1,e.length));switch(e){case b.bool:return tB(t);case b.float4:case b.float8:case b.int2:case b.int4:case b.int8:case b.numeric:case b.oid:return tz(t);case b.json:case b.jsonb:return tF(t);case b.timestamp:return tH(t);case b.abstime:case b.date:case b.daterange:case b.int4range:case b.int8range:case b.money:case b.reltime:case b.text:case b.time:case b.timestamptz:case b.timetz:case b.tsrange:case b.tstzrange:default:return tM(t)}},tM=e=>e,tB=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},tz=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},tF=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},tW=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s,n=e.slice(1,r);try{s=JSON.parse("["+n+"]")}catch(e){s=n?n.split(","):[]}return s.map(e=>tq(t,e))}return e},tH=e=>"string"==typeof e?e.replace(" ","T"):e,tG=e=>{let t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var tK=e=>"function"==typeof e?e:function(){return e},tJ=("u">typeof self?self:null)||globalThis,tV="closed",tY="errored",tZ="joined",tX="joining",tQ="leaving",t0="phx_close",t1="phx_error",t2="phx_reply",t3="phx_leave",t4="websocket",t5="base64url.bearer.phx.",t6=class{constructor(e,t,r,s){this.channel=e,this.event=t,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:r}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},t8=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},t9=class{constructor(e,t,r){this.state=tV,this.topic=e,this.params=tK(t||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new t6(this,"phx_join",this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new t8(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=tZ,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=tY,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=tV,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=tY,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new t6(this,t3,tK({}),this.timeout).send(),this.state=tY,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(t2,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(!this.joinedOnce)return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush;throw Error("tried to join multiple times. 'join' can only be called a single time per channel instance")}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=tV,this.bindings=[]}onClose(e){this.on(t0,e)}onError(e){return this.on(t1,t=>e(t))}on(e,t){let r=this.bindingRef++;return this.bindings.push({event:e,ref:r,callback:t}),r}off(e,t){this.bindings=this.bindings.filter(r=>r.event!==e||void 0!==t&&t!==r.ref)}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,r=this.timeout){if(t=t||{},!this.joinedOnce)throw Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new t6(this,e,function(){return t},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=tQ;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(t0,"leave")},r=new t6(this,t3,tK({}),e);return r.receive("ok",()=>t()).receive("timeout",()=>t()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(e,t,r){return t}filterBindings(e,t,r){return!0}isMember(e,t,r,s){return this.topic===e&&(!s||s===this.joinRef()||(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:r,joinRef:s}),!1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=tX,this.joinPush.resend(e))}trigger(e,t,r,s){let n=this.onMessage(e,t,r,s);if(t&&!n)throw Error("channel onMessage callbacks must return the payload, modified or unmodified");let a=this.bindings.filter(s=>s.event===e&&this.filterBindings(s,t,r));for(let e=0;e<a.length;e++)a[e].callback(n,r,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===tV}isErrored(){return this.state===tY}isJoined(){return this.state===tZ}isJoining(){return this.state===tX}isLeaving(){return this.state===tQ}},t7=class{static request(e,t,r,s,n,a,i){if(tJ.XDomainRequest){let r=new tJ.XDomainRequest;return this.xdomainRequest(r,e,t,s,n,a,i)}if(tJ.XMLHttpRequest){let o=new tJ.XMLHttpRequest;return this.xhrRequest(o,e,t,r,s,n,a,i)}if(tJ.fetch&&tJ.AbortController)return this.fetchRequest(e,t,r,s,n,a,i);throw Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,r,s,n,a,i){let o={method:e,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),o.signal=l.signal),tJ.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>i&&i(e)).catch(e=>{"AbortError"===e.name&&a?a():i&&i(null)}),l}static xdomainRequest(e,t,r,s,n,a,i){return e.timeout=n,e.open(t,r),e.onload=()=>{let t=this.parseJSON(e.responseText);i&&i(t)},a&&(e.ontimeout=a),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,r,s,n,a,i,o){for(let[n,i]of(e.open(t,r,!0),e.timeout=a,Object.entries(s)))e.setRequestHeader(n,i);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{4===e.readyState&&o&&o(this.parseJSON(e.responseText))},i&&(e.ontimeout=i),e.send(n),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let r=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let n=t?`${t}[${s}]`:s,a=e[s];"object"==typeof a?r.push(this.serialize(a,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(a))}return r.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?";return`${e}${r}${this.serialize(t)}`}},re=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(t5)&&(this.authToken=atob(t[1].slice(t5.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=0,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(RegExp("(.*)/"+t4),"$1/longpoll")}endpointURL(){return t7.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,r){this.close(e,t,r),this.readyState=0}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return 1===this.readyState||0===this.readyState}poll(){let e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:r,messages:s}=e;if(410===t&&null!==this.token){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=r}else t=0;switch(t){case 200:s.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=1,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw Error(`unhandled poll status ${t}`)}})}send(e){"string"!=typeof e&&(e=(e=>{let t="",r=new Uint8Array(e),s=r.byteLength;for(let e=0;e<s;e++)t+=String.fromCharCode(r[e]);return btoa(t)})(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e,t=0){this.awaitingBatchAck=!0;let r=t+100,s=e.slice(t,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},s.join("\n"),()=>this.onerror("timeout"),t=>{t&&200===t.status?r<e.length?this.batchSend(e,r):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1:(this.awaitingBatchAck=!1,this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,r){for(let e of this.reqs)e.abort();this.readyState=3;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"u">typeof CloseEvent?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,r,s,n){let a,i=()=>{this.reqs.delete(a),s()};a=t7.request(e,this.endpointURL(),t,r,this.timeout,i,e=>{this.reqs.delete(a),this.isActive()&&n(e)}),this.reqs.add(a)}},rt=class e{constructor(t,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,t=>{let{onJoin:r,onLeave:s,onSync:n}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,r,s),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,r,s)}),this.pendingDiffs=[],n()}),this.channel.on(s.diff,t=>{let{onJoin:r,onLeave:s,onSync:n}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,r,s),n())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,r,s){let n=this.toNullProtoObj(this.clone(e));t=this.toNullProtoObj(t);let a=Object.create(null),i=Object.create(null);return this.map(n,(e,r)=>{t[e]||(i[e]=r)}),this.map(t,(e,t)=>{let r=n[e];if(r){let s=t.metas.map(e=>e.phx_ref),n=r.metas.map(e=>e.phx_ref),o=t.metas.filter(e=>0>n.indexOf(e.phx_ref)),l=r.metas.filter(e=>0>s.indexOf(e.phx_ref));o.length>0&&(a[e]=t,a[e].metas=o),l.length>0&&(i[e]=this.clone(r),i[e].metas=l)}else a[e]=t}),this.syncDiff(n,{joins:a,leaves:i},r,s)}static syncDiff(e,t,r,s){e=this.toNullProtoObj(e);let{joins:n,leaves:a}=this.clone(t);return r||(r=function(){}),s||(s=function(){}),this.map(n,(t,s)=>{let n=e[t];if(e[t]=this.clone(s),n){let r=e[t].metas.map(e=>e.phx_ref),s=n.metas.filter(e=>0>r.indexOf(e.phx_ref));e[t].metas.unshift(...s)}r(t,n,s)}),this.map(a,(t,r)=>{let n=e[t];if(!n)return;let a=r.metas.map(e=>e.phx_ref);n.metas=n.metas.filter(e=>0>a.indexOf(e.phx_ref)),s(t,n,r),0===n.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,r)=>t(e,r))}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static toNullProtoObj(e){if(null===Object.getPrototypeOf(e))return e;let t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=e[r]}),t}static clone(e){return JSON.parse(JSON.stringify(e))}},rr={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){return e.payload.constructor===ArrayBuffer?t(this.binaryEncode(e)):t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload]))},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[r,s,n,a,i]=JSON.parse(e);return t({join_ref:r,ref:s,topic:n,event:a,payload:i})}},binaryEncode(e){let{join_ref:t,ref:r,event:s,topic:n,payload:a}=e,i=new TextEncoder,o=i.encode(t),l=i.encode(r),c=i.encode(n),u=i.encode(s);this.assertFieldSize(o.byteLength,"join_ref"),this.assertFieldSize(l.byteLength,"ref"),this.assertFieldSize(c.byteLength,"topic"),this.assertFieldSize(u.byteLength,"event");let d=this.META_LENGTH+o.byteLength+l.byteLength+c.byteLength+u.byteLength,h=new ArrayBuffer(this.HEADER_LENGTH+d),p=new Uint8Array(h),f=new DataView(h),m=0;f.setUint8(m++,this.KINDS.push),f.setUint8(m++,o.byteLength),f.setUint8(m++,l.byteLength),f.setUint8(m++,c.byteLength),f.setUint8(m++,u.byteLength),p.set(o,m),m+=o.byteLength,p.set(l,m),m+=l.byteLength,p.set(c,m),m+=c.byteLength,p.set(u,m),m+=u.byteLength;var g=new Uint8Array(h.byteLength+a.byteLength);return g.set(p,0),g.set(new Uint8Array(a),h.byteLength),g.buffer},assertFieldSize(e,t){if(e>255)throw Error(`unable to convert ${t} to binary: must be less than or equal to 255 bytes, but is ${e} bytes`)},binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=t.getUint8(3),i=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(e.slice(i,i+s));i+=s;let l=r.decode(e.slice(i,i+n));i+=n;let c=r.decode(e.slice(i,i+a));return i+=a,{join_ref:o,ref:null,topic:l,event:c,payload:e.slice(i,e.byteLength)}},decodeReply(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=t.getUint8(3),i=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(e.slice(o,o+s));o+=s;let c=r.decode(e.slice(o,o+n));o+=n;let u=r.decode(e.slice(o,o+a));o+=a;let d=r.decode(e.slice(o,o+i));return o+=i,{join_ref:l,ref:c,topic:u,event:t2,payload:{status:d,response:e.slice(o,e.byteLength)}}},decodeBroadcast(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),a=this.HEADER_LENGTH+2,i=r.decode(e.slice(a,a+s));a+=s;let o=r.decode(e.slice(a,a+n));return a+=n,{join_ref:null,ref:null,topic:i,event:o,payload:e.slice(a,e.byteLength)}}},rs=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||1e4,this.transport=t.transport||tJ.WebSocket||re,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=tJ&&tJ.sessionStorage}catch{}this.sessionStore=t.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=rr.encode.bind(rr),this.defaultDecoder=rr.decode.bind(rr),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==re?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,r)=>{console.log(`${e}: ${t}`,r)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=tK(t.params||{}),this.endPoint=`${e}/${t4}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new t8(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken&&tK(t.authToken)}getLongPollTransport(){return re}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=t7.appendParams(t7.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,r)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=tK(e)),(!this.conn||this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==re?this.connectWithFallback(re,this.longPollFallbackMs):this.transportConnect())}log(e,t,r){this.logger&&this.logger(e,t,r)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-r))});return!0}transportName(e){return e===re?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${t5}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){let r,s;clearTimeout(this.fallbackTimer);let n=!1,a=!0,i=this.transportName(e),o=t=>{this.log("transport",`falling back to ${i}...`,t),this.off([r,s]),a=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${i}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),s=this.onError(e=>{this.log("transport","error",e),a&&!n&&(clearTimeout(this.fallbackTimer),o(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(n=!0,!a){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,"true"),this.log("transport",`established ${t} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,r){if(!this.conn)return e&&e();let s=this.conn;this.waitForBufferDone(s,()=>{t?s.close(t,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,r=1){5!==r&&e.bufferedAmount?setTimeout(()=>{this.waitForBufferDone(e,t,r+1)},150*r):t()}waitForSocketClosed(e,t,r=1){5===r||3===e.readyState?t():setTimeout(()=>{this.waitForSocketClosed(e,t,r+1)},150*r)}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",e,t,r),(t===this.transport||r>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(t1,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case 0:return"connecting";case 1:return"open";case 2:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>-1===e.indexOf(t))}channel(e,t={}){let r=new t9(e,t,this);return this.channels.push(r),r}push(e){if(this.hasLogger()){let{topic:t,event:r,payload:s,ref:n,join_ref:a}=e;this.log("push",`${t} ${r} (${a}, ${n})`,s)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef)return void this.heartbeatTimeout();this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:r,payload:s,ref:n,join_ref:a}=e;if(n&&n===this.pendingHeartbeatRef){let e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===s.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${s.status||""} ${t} ${r} ${n&&"("+n+")"||""}`.trim(),s);for(let e=0;e<this.channels.length;e++){let i=this.channels[e];i.isMember(t,r,s,a)&&i.trigger(r,s,n,a)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([r,s])=>{try{s(...t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};class rn{constructor(e,t){var r;let s=(null==(r=t)?void 0:r.events)&&{events:r.events};this.presence=new rt(e.getChannel(),s),this.presence.onJoin((t,r,s)=>{let n=rn.onJoinPayload(t,r,s);e.getChannel().trigger("presence",n)}),this.presence.onLeave((t,r,s)=>{let n=rn.onLeavePayload(t,r,s);e.getChannel().trigger("presence",n)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return rn.transformState(this.presence.state)}static transformState(e){return Object.getOwnPropertyNames(e=JSON.parse(JSON.stringify(e))).reduce((t,r)=>{let s=e[r];return t[r]=ra(s),t},{})}static onJoinPayload(e,t,r){return{event:"join",key:e,currentPresences:ri(t),newPresences:ra(r)}}static onLeavePayload(e,t,r){return{event:"leave",key:e,currentPresences:ri(t),leftPresences:ra(r)}}}function ra(e){return e.metas.map(e=>{let t=Object.defineProperties({},Object.getOwnPropertyDescriptors(e));return t.presence_ref=t.phx_ref,delete t.phx_ref,delete t.phx_ref_prev,t})}function ri(e){return(null==e?void 0:e.metas)?ra(e):[]}(d=y||(y={})).SYNC="sync",d.JOIN="join",d.LEAVE="leave";class ro{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new rn(this.channel.channelAdapter,t)}}class rl{constructor(e,t,r){let s={config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config)};this.channel=e.getSocket().channel(t,s),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,t){return this.channel.on(e,t)}off(e,t){this.channel.off(e,t)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,t,r){let s;try{s=this.channel.push(e,t,r)}catch(t){throw Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>100){let e=this.channel.pushBuffer.shift();e.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${e.event}`,e.payload())}return s}updateJoinPayload(e){let t=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},t),e)}canPush(){return this.socket.isConnected()&&this.state===tP}isJoined(){return this.state===tP}isJoining(){return"joining"===this.state}isClosed(){return"closed"===this.state}isLeaving(){return"leaving"===this.state}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}let rc=/[,()"\\]/,ru=e=>{let t=null===e?"null":String(e);return rc.test(t)||t!==t.trim()?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t};class rd{constructor(){this.filters=[]}add(e,t,r,s=!1){return this.filters.push(`${e}=${s?"not.":""}${((e,t)=>{if("in"===e){let e=Array.isArray(t)?t:[t];if(0===e.length)throw Error("Realtime `in` filter requires at least one value.");let r=Array.from(new Set(e)).map(e=>ru(e)).join(",");return`in.(${r})`}if("is"===e)return`is.${null===t?"null":String(t)}`;return`${e}.${ru(t)}`})(t,r)}`),this}eq(e,t){return this.add(e,"eq",t)}neq(e,t){return this.add(e,"neq",t)}gt(e,t){return this.add(e,"gt",t)}gte(e,t){return this.add(e,"gte",t)}lt(e,t){return this.add(e,"lt",t)}lte(e,t){return this.add(e,"lte",t)}in(e,t){return this.add(e,"in",t)}like(e,t){return this.add(e,"like",t)}ilike(e,t){return this.add(e,"ilike",t)}match(e,t){return this.add(e,"match",t)}imatch(e,t){return this.add(e,"imatch",t)}is(e,t){return this.add(e,"is",t)}isDistinct(e,t){return this.add(e,"isdistinct",t)}not(e,t,r){return this.add(e,t,r,!0)}build(){return this.filters.join(",")}toString(){return this.build()}}(h=w||(w={})).ALL="*",h.INSERT="INSERT",h.UPDATE="UPDATE",h.DELETE="DELETE",(p=v||(v={})).BROADCAST="broadcast",p.PRESENCE="presence",p.POSTGRES_CHANGES="postgres_changes",p.SYSTEM="system",(f=k||(k={})).SUBSCRIBED="SUBSCRIBED",f.TIMED_OUT="TIMED_OUT",f.CLOSED="CLOSED",f.CHANNEL_ERROR="CHANNEL_ERROR";class rh{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,t={config:{}},r){var s,n;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new rl(this.socket.socketAdapter,e,this.params),this.presence=new ro(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=tG(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null==(n=null==(s=this.params.config)?void 0:s.broadcast)?void 0:n.replay))throw Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,t=this.timeout){var r,s,n,a;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:i,presence:o,private:l,postgres_changes_options:c}}=this.params,u=null!=(s=null==(r=this.bindings.postgres_changes)?void 0:r.map(e=>e.filter))?s:[],d=!!this.bindings[v.PRESENCE]&&this.bindings[v.PRESENCE].length>0||(null==(n=this.params.config.presence)?void 0:n.enabled)===!0,h={},p=Object.assign({broadcast:i,presence:Object.assign(Object.assign({},o),{enabled:d}),postgres_changes:u,private:l},c?{postgres_changes_options:c}:{});this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(k.CHANNEL_ERROR,function(e){if(e instanceof Error)return e;if("string"==typeof e)return Error(e);if(e&&"object"==typeof e){if("number"==typeof e.code){let t="string"==typeof e.reason&&e.reason?` (${e.reason})`:"";return Error(`socket closed: ${e.code}${t}`,{cause:e})}return Error("channel error: transport failure",{cause:e})}return Error("channel error: connection lost")}(t))}),this._onClose(()=>null==e?void 0:e(k.CLOSED)),this.updateJoinPayload(Object.assign({config:p},h)),this._updateFilterMessage();let f=(null==c?void 0:c.wait)&&u.length>0?Math.max(t,(null!=(a=c.timeout)?a:15e3)+1e4):t;this.channelAdapter.subscribe(f).receive("ok",async({postgres_changes:t})=>{if(this.socket._isManualToken()||this.socket.setAuth(),void 0===t){null==e||e(k.SUBSCRIBED);return}this._updatePostgresBindings(t,e)}).receive("error",t=>{this.state=tC;let r=Object.values(t).join(", ")||"error";null==e||e(k.CHANNEL_ERROR,Error(r,{cause:t}))}).receive("timeout",()=>{null==e||e(k.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var r;let s=this.bindings.postgres_changes,n=null!=(r=null==s?void 0:s.length)?r:0,a=[];for(let r=0;r<n;r++){let n=s[r],{filter:{event:i,schema:o,table:l,filter:c}}=n,u=e&&e[r];if(u&&u.event===i&&rh.isFilterValueEqual(u.schema,o)&&rh.isFilterValueEqual(u.table,l)&&rh.isFilterValueEqual(u.filter,c))a.push(Object.assign(Object.assign({},n),{id:u.id}));else{this.unsubscribe(),this.state=tC,null==t||t(k.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=a,this.state!=tC&&t&&t(k.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){let s=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),n=e===v.PRESENCE||e===v.POSTGRES_CHANGES;if(s&&n)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,t,r)}async httpSend(e,t,r={}){var s;if(null==t)return Promise.reject(Error("Payload is required for httpSend()"));let n=t instanceof ArrayBuffer||ArrayBuffer.isView(t),a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":n?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);let i=new URL(this.broadcastEndpointURL);i.pathname+=`/${encodeURIComponent(this.subTopic)}/events/${encodeURIComponent(e)}`,this.private&&i.searchParams.set("private","true");let o={method:"POST",headers:a,body:n?t:JSON.stringify(t)},l=await this._fetchWithTimeout(i.toString(),o,null!=(s=r.timeout)?s:this.timeout);if(202===l.status)return{success:!0};if(404===l.status)return Promise.reject(Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));let c=l.statusText;try{let e=await l.json();c=e.error||e.message||c}catch(e){}return Promise.reject(Error(c))}async send(e,t={}){var r,s;if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,n,a;let i=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(a=null==(n=null==(s=this.params)?void 0:s.config)?void 0:n.broadcast)?void 0:a.ack)||r("ok"),i.receive("ok",()=>r("ok")),i.receive("error",()=>r("error")),i.receive("timeout",()=>r("timed out"))});{let n="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.";this.socket.hasLogger()?this.socket.log("channel",n):console.warn(n);let{event:a,payload:i}=e,o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(o.Authorization=`Bearer ${this.socket.accessTokenValue}`);let l={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:i,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,l,null!=(r=t.timeout)?r:this.timeout);return await (null==(s=e.body)?void 0:s.cancel()),e.ok?"ok":"error"}catch(e){if(e instanceof Error&&"AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(t=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>t("ok")).receive("timeout",()=>t("timed out")).receive("error",()=>t("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,t,r){let s=new AbortController,n=setTimeout(()=>s.abort(),r),a=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(n),a}_on(e,t,r){var s;let n=e.toLocaleLowerCase(),a=null==t?void 0:t.filter;if((a instanceof rd||"object"==typeof a&&null!==a&&"function"==typeof a.build)&&(t=Object.assign(Object.assign({},t),{filter:a.build()})),n===v.POSTGRES_CHANGES&&(null==(s=this.bindings[n])?void 0:s.find(e=>rh.isSamePostgresFilter(e.filter,t))))return this.socket.log("error",`duplicate \`postgres_changes\` binding for ${this.topic} ignored`,t),this;let i=this.channelAdapter.on(e,r),o={type:n,filter:t,callback:r,ref:i};return this.bindings[n]?this.bindings[n].push(o):this.bindings[n]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,r)=>{var s,n,a,i,o,l,c;let u=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(u,r))return!1;let d=null==(s=this.bindings[u])?void 0:s.find(t=>t.ref===e.ref);if(!d)return!0;if(!["broadcast","presence","postgres_changes"].includes(u))return d.type.toLocaleLowerCase()===u;if("id"in d){let e=d.id,r=null==(n=d.filter)?void 0:n.event;return e&&(null==(a=t.ids)?void 0:a.includes(e))&&("*"===r||(null==r?void 0:r.toLocaleLowerCase())===(null==(i=t.data)?void 0:i.type.toLocaleLowerCase()))}{let e=null==(l=null==(o=null==d?void 0:d.filter)?void 0:o.event)?void 0:l.toLocaleLowerCase();return"*"===e||e===(null==(c=null==t?void 0:t.event)?void 0:c.toLocaleLowerCase())}})}_notThisChannelEvent(e,t){let{close:r,error:s,leave:n,join:a}=tN;return t&&[r,s,n,a].includes(e)&&t!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,t,r)=>{if("object"==typeof t&&"ids"in t){let e=t.data,{schema:r,table:s,commit_timestamp:n,type:a,errors:i}=e;return Object.assign(Object.assign({},{schema:r,table:s,commit_timestamp:n,eventType:a,new:{},old:{},errors:i}),this._getPayloadRecords(e))}return t})}copyBindings(e){if(this.joinedOnce)throw Error("cannot copy bindings into joined channel");for(let t in e.bindings)for(let r of e.bindings[t])this._on(r.type,r.filter,r.callback)}static isFilterValueEqual(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}static isSamePostgresFilter(e,t){var r,s,n,a;let i=null!=(s=null==(r=null==e?void 0:e.select)?void 0:r.join())?s:void 0,o=null!=(a=null==(n=null==t?void 0:t.select)?void 0:n.join())?a:void 0;return(null==e?void 0:e.event)===(null==t?void 0:t.event)&&rh.isFilterValueEqual(null==e?void 0:e.schema,null==t?void 0:t.schema)&&rh.isFilterValueEqual(null==e?void 0:e.table,null==t?void 0:t.table)&&rh.isFilterValueEqual(null==e?void 0:e.filter,null==t?void 0:t.filter)&&i===o}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=tL(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=tL(e.columns,e.old_record)),t}}class rp{constructor(e,t){this.socket=new rs(e,t)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,t,r,s=1e4){return new Promise(n=>{setTimeout(()=>n("timeout"),s),this.socket.disconnect(()=>{e(),n("ok")},t,r)})}push(e){this.socket.push(e)}log(e,t,r){this.socket.log(e,t,r)}hasLogger(){return this.socket.hasLogger()}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return"connecting"==this.socket.connectionState()}isDisconnecting(){return"closing"==this.socket.connectionState()}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}let rf=[1e3,2e3,5e3,1e4],rm=`
79
81
  addEventListener("message", (e) => {
80
82
  if (e.data.event === "start") {
81
83
  setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
82
84
  }
83
- });`;class ro{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,t){var r;if(this.channels=[],this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new tR,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),!(null==(r=null==t?void 0:t.params)?void 0:r.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;let s=this._initializeOptions(t);this.socketAdapter=new rn(e,s),this.httpEndpoint=tL(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(t){let e=t.message;throw Error(`WebSocket not available: ${e}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,t){return(this._cancelPendingDisconnect(),this.isDisconnecting())?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,t)}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return"ok"===t&&e.teardown(),t}async removeAllChannels(){let e=this.channels.map(async e=>{let t=await e.unsubscribe();return e.teardown(),t}),t=await Promise.all(e);return await this.disconnect(),t}log(e,t,r){this.socketAdapter.log(e,t,r)}hasLogger(){return this.socketAdapter.hasLogger()}connectionState(){return this.socketAdapter.connectionState()||"closed"}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,t={config:{}}){let r=`realtime:${e}`,s=this.getChannels().find(e=>e.topic===r);if(s)return s;{let r=new rs(`realtime:${e}`,t,this);return this._cancelPendingDisconnect(),this.channels.push(r),r}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){let t=++this._authGeneration,r=this._performAuth(e,t);t===this._authGeneration&&(this._authPromise=r);try{await r}finally{this._authPromise===r&&(this._authPromise=null)}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic),0===this.channels.length&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,0===this.channels.length&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){null!==this._pendingDisconnectTimer&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e,t){let r,s=!1;if(e)r=e,s=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),r=this.accessTokenValue}else r=this.accessTokenValue;t===this._authGeneration&&(this.accessToken?this._manuallySetToken=!1:s&&(this._manuallySetToken=!0),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(e=>{let t={access_token:r,version:"realtime-js/2.117.3"};e.updateJoinPayload(t),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(tT.access_token,{access_token:r})})))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(t=>{this.log("error",`Error setting auth in ${e}`,t)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(e=>{this.log("error","error waiting for auth on connect",e)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(t,r)=>{"disconnected"!==t&&("sent"==t&&this._setAuthSafely(),e&&e(t,r))}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([ri],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,r,s,n,a,i,o,l,c,u,d,h;let p,f;this.worker=null!=(t=null==e?void 0:e.worker)&&t,this.accessToken=null!=(r=null==e?void 0:e.accessToken)?r:null;let m={};m.timeout=null!=(s=null==e?void 0:e.timeout)?s:1e4,m.heartbeatIntervalMs=null!=(n=null==e?void 0:e.heartbeatIntervalMs)?n:25e3,this._disconnectOnEmptyChannelsAfterMs=null!=(a=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)?a:2*(null!=(i=null==e?void 0:e.heartbeatIntervalMs)?i:25e3),m.transport=null!=(o=null==e?void 0:e.transport)?o:t_.getWebSocketConstructor(),m.params=null==e?void 0:e.params,m.logger=null==e?void 0:e.logger,m.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),m.sessionStorage=null!=(l=null==e?void 0:e.sessionStorage)?l:function(){let e;try{if("u">typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}return e=new Map,{get length(){return e.size},clear(){e.clear()},getItem:t=>e.has(t)?e.get(t):null,key(t){var r;return null!=(r=Array.from(e.keys())[t])?r:null},removeItem(t){e.delete(t)},setItem(t,r){e.set(t,String(r))}}}(),m.reconnectAfterMs=null!=(c=null==e?void 0:e.reconnectAfterMs)?c:e=>ra[e-1]||1e4;let g=null!=(u=null==e?void 0:e.vsn)?u:tS;switch(g){case"1.0.0":p=(e,t)=>t(JSON.stringify(e)),f=(e,t)=>t(JSON.parse(e));break;case tS:p=this.serializer.encode.bind(this.serializer),f=this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${m.vsn}`)}return m.vsn=g,m.encode=null!=(d=null==e?void 0:e.encode)?d:p,m.decode=null!=(h=null==e?void 0:e.decode)?h:f,m.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,m.params=Object.assign(Object.assign({},m.params),{log_level:this.logLevel})),this.worker&&(this.workerUrl=null==e?void 0:e.workerUrl,m.autoSendHeartbeat=!this.worker),m}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var rl=class extends Error{constructor(e,t){super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown="CommitStateUnknownException"===t.icebergType||[500,502,504].includes(t.status)&&t.icebergType?.includes("CommitState")===!0}isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}};async function rc(e){return e&&"none"!==e.type?"bearer"===e.type?{Authorization:`Bearer ${e.token}`}:"header"===e.type?{[e.name]:e.value}:"custom"===e.type?await e.getHeaders():{}:{}}function ru(e){return e.join("\x1f")}var rd=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:ru(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let r={namespace:e.namespace,properties:t?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${ru(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${ru(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${ru(e.namespace)}`}),!0}catch(e){if(e instanceof rl&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof rl&&409===e.status)return;throw e}}};function rh(e){return e.join("\x1f")}var rp=class{constructor(e,t="",r){this.client=e,this.prefix=t,this.accessDelegation=r}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${rh(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){let r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${rh(e.namespace)}/tables`,body:t,headers:r})).data.metadata}async updateTable(e,t){let r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${rh(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${rh(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String(t?.purge??!1)}})}async loadTable(e){let t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${rh(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${rh(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof rl&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof rl&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}},rf=class{constructor(e){var t;let r,s="v1";e.catalogName&&(s+=`/${e.catalogName}`);let n=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=(r=(t={baseUrl:n,auth:e.auth,fetchImpl:e.fetch}).fetchImpl??globalThis.fetch,{async request({method:e,path:s,query:n,body:a,headers:i}){let o=function(e,t,r){let s=new URL(t,e);if(r)for(let[e,t]of Object.entries(r))void 0!==t&&s.searchParams.set(e,t);return s.toString()}(t.baseUrl,s,n),l=await rc(t.auth),c=await r(o,{method:e,headers:{...a?{"Content-Type":"application/json"}:{},...l,...i},body:a?JSON.stringify(a):void 0}),u=await c.text(),d=(c.headers.get("content-type")||"").includes("application/json"),h=d&&u?JSON.parse(u):u;if(!c.ok){let e=d?h:void 0,t=e?.error;throw new rl(t?.message??`Request failed with status ${c.status}`,{status:c.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:c.status,headers:c.headers,data:h}}}),this.accessDelegation=e.accessDelegation?.join(","),this.namespaceOps=new rd(this.client,s),this.tableOps=new rp(this.client,s,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}};function rm(e){return(rm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function rg(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function rb(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?rg(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=rm(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=rm(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==rm(s)?s:s+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):rg(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ry=class extends Error{constructor(e,t="storage",r,s){super(e),this.__isStorageError=!0,this.namespace=t,this.name="vectors"===t?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function rw(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}var rv=class extends ry{constructor(e,t,r,s="storage",n){super(e,s,t,r),this.name="vectors"===s?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=r,this.code=n}toJSON(){return rb(rb({},super.toJSON()),{},{code:this.code})}},rk=class extends ry{constructor(e,t,r="storage"){super(e,r),this.name="vectors"===r?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function r_(e,t,r){let s=rb({},e),n=t.toLowerCase();for(let e of Object.keys(s))e.toLowerCase()===n&&delete s[e];return s[n]=r,s}let rS=e=>{if(Array.isArray(e))return e.map(e=>rS(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,r])=>{t[e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=rS(r)}),t},rx=e=>e.split("/").map(encodeURIComponent).join("/"),rA=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error;if("object"==typeof e.error&&null!==e.error){let t=e.error;if("string"==typeof t.message)return t.message}}return JSON.stringify(e)},rT=async(e,t,r,s)=>{if(null!==e&&"object"==typeof e&&"json"in e&&"function"==typeof e.json){let r=parseInt(String(e.status),10);Number.isFinite(r)||(r=500),e.json().then(e=>{let n=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";t(new rv(rA(e),r,n,s,null==e?void 0:e.code))}).catch(()=>{let n=r+"";t(new rv(e.statusText||`HTTP ${r} error`,r,n,s))})}else t(new rk(rA(e),e,s))};async function rR(e,t,r,s,n,a,i){return new Promise((o,l)=>{e(r,((e,t,r,s)=>{let n={method:e,headers:(null==t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!s)return rb(rb({},n),r);if((e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)})(s)){var a;let e,r=(null==t?void 0:t.headers)||{};for(let[t,s]of Object.entries(r))"content-type"===t.toLowerCase()&&(e=s);n.headers=r_(r,"Content-Type",null!=(a=e)?a:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return(null==t?void 0:t.duplex)&&(n.duplex=t.duplex),rb(rb({},n),r)})(t,s,n,a)).then(e=>{if(!e.ok)throw e;if(null==s?void 0:s.noResolveJson)return e;if("vectors"===i){let t=e.headers.get("content-type");if("0"===e.headers.get("content-length")||204===e.status||!t||!t.includes("application/json"))return{}}return e.json()}).then(e=>o(e)).catch(e=>rT(e,l,s,i))})}function rE(e="storage"){return{get:async(t,r,s,n)=>rR(t,"GET",r,s,n,void 0,e),post:async(t,r,s,n,a)=>rR(t,"POST",r,n,a,s,e),put:async(t,r,s,n,a)=>rR(t,"PUT",r,n,a,s,e),head:async(t,r,s,n)=>rR(t,"HEAD",r,rb(rb({},s),{},{noResolveJson:!0}),n,void 0,e),remove:async(t,r,s,n,a)=>rR(t,"DELETE",r,n,a,s,e)}}let{get:rI,post:rj,put:rO,head:rC,remove:r$}=rE("storage"),rP=rE("vectors");var rN=class{constructor(e,t={},r,s="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=function(e){let t={};for(let[r,s]of Object.entries(e))t[r.toLowerCase()]=s;return t}(t),this.fetch=r?(...e)=>r(...e):(...e)=>fetch(...e),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=r_(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rw(e))return{data:null,error:e};throw e}}};t=Symbol.toStringTag;var rD=class{constructor(e,r){this.downloadFn=e,this.shouldThrowOnError=r,this[t]="StreamDownloadBuilder",this.promise=null}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rw(e))return{data:null,error:e};throw e}}};r=Symbol.toStringTag;var rL=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[r]="BlobDownloadBuilder",this.promise=null}asStream(){return new rD(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:await (await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rw(e))return{data:null,error:e};throw e}}};let rU={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},rq={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var rM=class extends rN{constructor(e,t={},r,s){super(e,t,s,"storage"),this.bucketId=r}async uploadOrUpdate(e,t,r,s){var n=this;return n.handleOperation(async()=>{let a,i=rb(rb({},rq),s),o=rb(rb({},n.headers),"POST"===e&&{"x-upsert":String(i.upsert)}),l=i.metadata;if("u">typeof Blob&&r instanceof Blob||"u">typeof FormData&&r instanceof FormData?a=n.prepareUploadFormData(r,i):(a=r,o["cache-control"]=`max-age=${i.cacheControl}`,o["content-type"]=i.contentType,l&&(o["x-metadata"]=n.toBase64(n.encodeMetadata(l))),("u">typeof ReadableStream&&a instanceof ReadableStream||a&&"object"==typeof a&&"pipe"in a&&"function"==typeof a.pipe)&&!i.duplex&&(i.duplex="half")),null==s?void 0:s.headers)for(let[e,t]of Object.entries(s.headers))o=r_(o,e,t);let c=n._removeEmptyFolders(t),u=n._getFinalPath(c),d=await ("PUT"==e?rO:rj)(n.fetch,`${n.url}/object/${u}`,a,rb({headers:o},(null==i?void 0:i.duplex)?{duplex:i.duplex}:{}));return{path:c,id:d.Id,fullPath:d.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,s){var n=this;let a=n._removeEmptyFolders(e),i=n._getFinalPath(a),o=new URL(n.url+`/object/upload/sign/${i}`);return o.searchParams.set("token",t),n.handleOperation(async()=>{let e,t=rb(rb({},rq),s),i=rb(rb({},n.headers),{"x-upsert":String(t.upsert)}),l=t.metadata;if("u">typeof Blob&&r instanceof Blob||"u">typeof FormData&&r instanceof FormData?e=n.prepareUploadFormData(r,t):(e=r,i["cache-control"]=`max-age=${t.cacheControl}`,i["content-type"]=t.contentType,l&&(i["x-metadata"]=n.toBase64(n.encodeMetadata(l))),("u">typeof ReadableStream&&e instanceof ReadableStream||e&&"object"==typeof e&&"pipe"in e&&"function"==typeof e.pipe)&&!t.duplex&&(t.duplex="half")),null==s?void 0:s.headers)for(let[e,t]of Object.entries(s.headers))i=r_(i,e,t);return{path:a,fullPath:(await rO(n.fetch,o.toString(),e,rb({headers:i},(null==t?void 0:t.duplex)?{duplex:t.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(e),n=rb({},r.headers);(null==t?void 0:t.upsert)&&(n["x-upsert"]="true");let a=await rj(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),i=new URL(r.url+a.url),o=i.searchParams.get("token");if(!o)throw new ry("No token returned by API");return{signedUrl:i.toString(),path:e,token:o}})}async update(e,t,r){return this.uploadOrUpdate("PUT",e,t,r)}async move(e,t,r){var s=this;return s.handleOperation(async()=>await rj(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket,sourceVersionId:null==r?void 0:r.sourceVersionId},{headers:s.headers}))}async copy(e,t,r){var s=this;return s.handleOperation(async()=>({path:(await rj(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket,sourceVersionId:null==r?void 0:r.sourceVersionId},{headers:s.headers})).Key}))}async createSignedUrl(e,t,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(e),a="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0,i=await rj(s.fetch,`${s.url}/object/sign/${n}`,rb(rb({expiresIn:t},a?{transform:r.transform}:{}),(null==r?void 0:r.versionId)!=null?{versionId:r.versionId}:{}),{headers:s.headers}),o=new URLSearchParams;(null==r?void 0:r.download)&&o.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&o.set("cacheNonce",String(r.cacheNonce));let l=o.toString();return{signedUrl:encodeURI(`${s.url}${i.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(e,t,r){var s=this;return s.handleOperation(async()=>{let n=await rj(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:t,paths:e},{headers:s.headers}),a=new URLSearchParams;(null==r?void 0:r.download)&&a.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&a.set("cacheNonce",String(r.cacheNonce));let i=a.toString();return n.map(e=>rb(rb({},e),{},{signedUrl:e.signedURL?encodeURI(`${s.url}${e.signedURL}${i?`&${i}`:""}`):null}))})}download(e,t,r){let s="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(n,t.transform),(null==t?void 0:t.cacheNonce)!=null&&n.set("cacheNonce",String(t.cacheNonce)),(null==t?void 0:t.versionId)!=null&&n.set("versionId",String(t.versionId));let a=n.toString(),i=this._getFinalPath(e);return new rL(()=>rI(this.fetch,`${this.url}/${s}/${i}${a?`?${a}`:""}`,{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e,t){var r=this;let s=r._getFinalPath(e),n=new URLSearchParams;(null==t?void 0:t.versionId)!=null&&n.set("versionId",String(t.versionId));let a=n.toString();return r.handleOperation(async()=>rS(await rI(r.fetch,`${r.url}/object/info/${s}${a?`?${a}`:""}`,{headers:r.headers})))}async exists(e){var t;let r=this._getFinalPath(e);try{return await rC(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rw(e)){let r=e instanceof rv?e.status:e instanceof rk?null==(t=e.originalError)?void 0:t.status:void 0;if(void 0!==r&&[400,404].includes(r))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){let r=this._getFinalPath(e),s=new URLSearchParams;(null==t?void 0:t.download)&&s.set("download",!0===t.download?"":t.download),(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(s,t.transform),(null==t?void 0:t.cacheNonce)!=null&&s.set("cacheNonce",String(t.cacheNonce)),(null==t?void 0:t.versionId)!=null&&s.set("versionId",String(t.versionId));let n=s.toString(),a="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}`)+(n?`?${n}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await r$(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async purgeCache(e,t,r){var s=this;return s.handleOperation(async()=>{let n=rx(s._getFinalPath(e)),a=new URLSearchParams;(null==t?void 0:t.transformations)&&a.set("transformations","true");let i=a.toString();return await r$(s.fetch,`${s.url}/cdn/${n}${i?`?${i}`:""}`,{},{headers:s.headers},r)})}async list(e,t,r){var s=this;return s.handleOperation(async()=>{let n=(null==t?void 0:t.sortBy)?rb(rb({},rU.sortBy),t.sortBy):rU.sortBy,a=rb(rb(rb({},rU),t),{},{sortBy:n,prefix:e||""});return await rj(s.fetch,`${s.url}/object/list/${s.bucketId}`,a,{headers:s.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{let s=rb({},e);return await rj(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},t)})}prepareUploadFormData(e,t){let r=new FormData,s=[];for(let[n,a]of(e instanceof FormData?e.forEach((e,t)=>{"string"==typeof e?r.append(t,e):s.push([t,e])}):s.push(["",e]),r.has("cacheControl")||r.append("cacheControl",t.cacheControl),t.metadata&&!r.has("metadata")&&r.append("metadata",this.encodeMetadata(t.metadata)),s))r.append(n,a);return r}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return"u">typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("quality",t.quality.toString()),e}};let rB={"X-Client-Info":"storage-js/2.117.3"};var rz=class extends rN{constructor(e,t={},r,s){let n=new URL(e);(null==s?void 0:s.useNewHostname)&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase.")),super(n.href.replace(/\/$/,""),rb(rb({},rB),t),r,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=t.listBucketOptionsToQueryString(e);return await rI(t.fetch,`${t.url}/bucket${r}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await rI(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var r=this;return r.handleOperation(async()=>await rj(r.fetch,`${r.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes,versioning_status:t.versioningStatus},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await rO(r.fetch,`${r.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes,versioning_status:t.versioningStatus},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await rj(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await r$(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}async getBucketLifecycle(e){var t=this;return t.handleOperation(async()=>await rI(t.fetch,t.bucketLifecycleUrl(e),{headers:t.headers}))}async updateBucketLifecycle(e,t){var r=this;return r.handleOperation(async()=>await rO(r.fetch,r.bucketLifecycleUrl(e),t,{headers:r.headers}))}async deleteBucketLifecycle(e){var t=this;return t.handleOperation(async()=>await r$(t.fetch,t.bucketLifecycleUrl(e),{},{headers:t.headers}))}async purgeBucketCache(e,t,r){var s=this;return s.handleOperation(async()=>{let n=new URLSearchParams;(null==t?void 0:t.transformations)&&n.set("transformations","true");let a=n.toString();return await r$(s.fetch,`${s.url}/cdn/${rx(e)}${a?`?${a}`:""}`,{},{headers:s.headers},r)})}bucketLifecycleUrl(e){return`${this.url}/bucket/${rx(e)}/lifecycle`}listBucketOptionsToQueryString(e){let t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},rF=class extends rN{constructor(e,t={},r){super(e.replace(/\/$/,""),rb(rb({},rB),t),r,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await rj(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=new URLSearchParams;(null==e?void 0:e.limit)!==void 0&&r.set("limit",e.limit.toString()),(null==e?void 0:e.offset)!==void 0&&r.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&r.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&r.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&r.set("search",e.search);let s=r.toString(),n=s?`${t.url}/bucket?${s}`:`${t.url}/bucket`;return await rI(t.fetch,n,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await r$(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(e){var t=this;if(!(!(!e||"string"!=typeof e||0===e.length||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\"))&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e)))throw new ry("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");let r=new rf({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(e,t){let r=e[t];return"function"!=typeof r?r:async(...t)=>{try{return{data:await r.apply(e,t),error:null}}catch(e){if(s)throw e;return{data:null,error:e}}}}})}},rW=class extends rN{constructor(e,t={},r){super(e.replace(/\/$/,""),rb(rb({},rB),{},{"Content-Type":"application/json"},t),r,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await rP.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await rP.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}},rH=class extends rN{constructor(e,t={},r){super(e.replace(/\/$/,""),rb(rb({},rB),{},{"Content-Type":"application/json"},t),r,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},rG=class extends rN{constructor(e,t={},r){super(e.replace(/\/$/,""),rb(rb({},rB),{},{"Content-Type":"application/json"},t),r,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await rP.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},rK=class extends rG{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new rJ(this.url,this.headers,e,this.fetch)}async createBucket(e){return super.createBucket.call(this,e)}async getBucket(e){return super.getBucket.call(this,e)}async listBuckets(e={}){return super.listBuckets.call(this,e)}async deleteBucket(e){return super.deleteBucket.call(this,e)}},rJ=class extends rW{constructor(e,t,r,s){super(e,t,s),this.vectorBucketName=r}async createIndex(e){return super.createIndex.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(e={}){return super.listIndexes.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName}))}async getIndex(e){return super.getIndex.call(this,this.vectorBucketName,e)}async deleteIndex(e){return super.deleteIndex.call(this,this.vectorBucketName,e)}index(e){return new rV(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},rV=class extends rH{constructor(e,t,r,s,n){super(e,t,n),this.vectorBucketName=r,this.indexName=s}async putVectors(e){return super.putVectors.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async getVectors(e){return super.getVectors.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async listVectors(e={}){return super.listVectors.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async queryVectors(e){return super.queryVectors.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async deleteVectors(e){return super.deleteVectors.call(this,rb(rb({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}},rY=class extends rz{constructor(e,t={},r,s){super(e,t,r,s)}from(e){return new rM(this.url,this.headers,e,this.fetch)}get vectors(){return new rK(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new rF(this.url+"/iceberg",this.headers,this.fetch)}};let rX="2.117.3",rZ={"X-Client-Info":`gotrue-js/${rX}`},rQ="X-Supabase-Api-Version",r0={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},r1=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,r2="sb_flow_id",r3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),r4=" \n\r=".split(""),r5=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<r4.length;t+=1)e[r4[t].charCodeAt(0)]=-2;for(let t=0;t<r3.length;t+=1)e[r3[t].charCodeAt(0)]=t;return e})();function r6(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(r3[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6;else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;)r(r3[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function r8(e,t,r){let s=r5[e];if(s>-1)for(t.queue=t.queue<<6|s,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===s)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function r9(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},a=e=>{!function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}}(e,s,r)};for(let t=0;t<e.length;t+=1)r8(e.charCodeAt(t),n,a);return t.join("")}function r7(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)r8(e.charCodeAt(t),r,s);return new Uint8Array(t)}function se(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};return e.forEach(e=>r6(e,r,s)),r6(null,r,s),t.join("")}function st(e){return Math.round(Date.now()/1e3)+e}let sr=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),ss=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},sn=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return null}},sa=async(e,t)=>{await e.removeItem(t)};class si{constructor(){this.promise=new si.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function so(e){let t=e.split(".");if(3!==t.length)throw new e5("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!r1.test(t[e]))throw new e5("JWT not in base64url format");return{header:JSON.parse(r9(t[0])),payload:JSON.parse(r9(t[1])),signature:r7(t[2]),raw:{header:t[0],payload:t[1]}}}async function sl(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function sc(e){return("0"+e.toString(16)).substr(-2)}async function su(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>String.fromCharCode(e)).join("")}async function sd(e){return"u">typeof crypto&&void 0!==crypto.subtle&&"u">typeof TextEncoder?btoa(await su(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):(console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e)}si.promiseConstructor=Promise;let sh=/^[a-zA-Z0-9_-]{8,64}$/;function sp(e){return"string"==typeof e&&sh.test(e)?e:null}let sf=(e,t)=>`${e}-flow-${t}-code-verifier`,sm=e=>`${e}-flows-code-verifier`;async function sg(e,t){let r=await sn(e,sm(t));return Array.isArray(r)?r.filter(e=>null!==sp(e)):[]}async function sb(e,t,r,s,n){await ss(e,sf(t,r),s);let a=(await sg(e,t)).filter(e=>e!==r);for(a.push(r);a.length>5;){let r=a.shift();await sa(e,sf(t,r)),null==n||n(r)}await ss(e,sm(t),a),await ss(e,`${t}-code-verifier`,s)}async function sy(e,t,r){if(r){let s=await sn(e,sf(t,r));return{verifier:"string"==typeof s?s:null,flowId:r}}let s=await sn(e,`${t}-code-verifier`);return{verifier:"string"==typeof s?s:null,flowId:null}}async function sw(e,t,r){let s=`${t}-code-verifier`;if(!r)return void await sa(e,s);let n=sf(t,r),a=await sn(e,n);await sa(e,n);let i=await sg(e,t),o=i.filter(e=>e!==r);o.length!==i.length&&(o.length>0?await ss(e,sm(t),o):await sa(e,sm(t))),null!=a&&a===await sn(e,s)&&await sa(e,s)}async function sv(e,t){for(let r of(await sg(e,t)))await sa(e,sf(t,r));await sa(e,sm(t)),await sa(e,`${t}-code-verifier`)}async function sk(e,t,r=!1,s){let n=function(){let e=new Uint32Array(56);if("u"<typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let s=0;s<56;s++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,sc).join("")}(),a=n;r&&(a+="/recovery");let i=function(){if("u">typeof crypto&&"function"==typeof crypto.getRandomValues){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,sc).join("")}let e="";for(let t=0;t<32;t++)e+=Math.floor(16*Math.random()).toString(16);return e}();await sb(e,t,i,a,s);let o=await sd(n),l=n===o?"plain":"s256";return[o,l,i]}let s_=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,sS=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function sx(e){if(!sS.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function sA(e){if(!e.recoveryCodes)throw Error("@supabase/auth-js: the MFA recovery codes API is experimental and disabled by default. Enable it by passing `auth: { experimental: { recoveryCodes: true } }` to createClient (or to the GoTrueClient constructor).")}function sT(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function sR(e){return JSON.parse(JSON.stringify(e))}let sE=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error}return JSON.stringify(e)},sI=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function sj(e){var t;let r,s;if(!("object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json))throw new e0(sE(e),0);try{r=await e.json()}catch(t){if(sI.includes(e.status))throw new e0(e.statusText||`HTTP ${e.status}`,e.status);throw new eG(sE(t),t)}if(sI.includes(e.status))throw new e0(sE(r),e.status);let n=function(e){let t=e.headers.get(rQ);if(!t||!t.match(s_))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(n&&n.getTime()>=r0["2024-01-01"].timestamp&&"object"==typeof r&&r&&"string"==typeof r.code?s=r.code:"object"==typeof r&&r&&"string"==typeof r.error_code&&(s=r.error_code),s){if("weak_password"===s)throw new e4(sE(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===s)throw new eJ}else if("object"==typeof r&&r&&"object"==typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new e4(sE(r),e.status,r.weak_password.reasons);throw new eW(sE(r),e.status||500,s)}async function sO(e,t,r,s){var n;let a=Object.assign({},null==s?void 0:s.headers);a[rQ]||(a[rQ]=r0["2024-01-01"].name),(null==s?void 0:s.jwt)&&(a.Authorization=`Bearer ${s.jwt}`);let i=null!=(n=null==s?void 0:s.query)?n:{};(null==s?void 0:s.redirectTo)&&(i.redirect_to=s.redirectTo);let o=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await sC(e,t,r+o,{headers:a,noResolveJson:null==s?void 0:s.noResolveJson},{},null==s?void 0:s.body);return(null==s?void 0:s.xform)?null==s?void 0:s.xform(l):{data:Object.assign({},l),error:null}}async function sC(e,t,r,s,n,a){let i,o,l=(o={method:t,headers:(null==s?void 0:s.headers)||{}},"GET"===t?o:(o.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==s?void 0:s.headers),o.body=JSON.stringify(a),Object.assign(Object.assign({},o),n)));try{i=await e(r,Object.assign({},l))}catch(e){throw new e0(sE(e),0)}if(i.ok||await sj(i),null==s?void 0:s.noResolveJson)return i;try{return await i.json()}catch(e){await sj(e)}}function s$(e){var t,r;let s=null;return(r=e).access_token&&r.refresh_token&&r.expires_in&&(s=Object.assign({},e),e.expires_at||(s.expires_at=st(e.expires_in))),{data:{session:s,user:null!=(t=e.user)?t:"string"==typeof(null==e?void 0:e.id)?e:null},error:null}}function sP(e){let t=s$(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function sN(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function sD(e){return{data:e,error:null}}function sL(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a},user:Object.assign({},tn(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function sU(e){return e}let sq=["global","local","others"];class sM{constructor({url:e="",headers:t={},fetch:r,experimental:s}){this.url=e,this.headers=t,this.fetch=sr(r),this.experimental=null!=s?s:{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,t=sq[0]){if(0>sq.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${sq.join(", ")}`);try{return await sO(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eF(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await sO(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:sN})}catch(e){if(eF(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=tn(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=null==r?void 0:r.newEmail,delete s.newEmail),await sO(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:sL,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(eF(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await sO(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:sN})}catch(e){if(eF(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,n,a,i,o;try{let l={nextPage:null,lastPage:0,total:0},c=await sO(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(n=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?n:""},xform:sU});if(c.error)throw c.error;let u=await c.json(),d=null!=(a=c.headers.get("x-total-count"))?a:0,h=null!=(o=null==(i=c.headers.get("link"))?void 0:i.split(","))?o:[];return h.length>0&&(h.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(d)),{data:Object.assign(Object.assign({},u),l),error:null}}catch(e){if(eF(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){sx(e);try{return await sO(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:sN})}catch(e){if(eF(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){sx(e);try{return await sO(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:sN})}catch(e){if(eF(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){sx(e);try{return await sO(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:sN})}catch(e){if(eF(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){sx(e.userId);try{let{data:t,error:r}=await sO(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _deleteFactor(e){sx(e.userId),sx(e.id);try{return{data:await sO(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,s,n,a,i,o;try{let l={nextPage:null,lastPage:0,total:0},c=await sO(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(n=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?n:""},xform:sU});if(c.error)throw c.error;let u=await c.json(),d=null!=(a=c.headers.get("x-total-count"))?a:0,h=null!=(o=null==(i=c.headers.get("link"))?void 0:i.split(","))?o:[];return h.length>0&&(h.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(d)),{data:Object.assign(Object.assign({},u),l),error:null}}catch(e){if(eF(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await sO(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await sO(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await sO(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await sO(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await sO(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _listCustomProviders(e){try{let t={};return(null==e?void 0:e.type)&&(t.type=e.type),await sO(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:t,xform:e=>{var t;return{data:{providers:null!=(t=null==e?void 0:e.providers)?t:[]},error:null}}})}catch(e){if(eF(e))return{data:{providers:[]},error:e};throw e}}async _createCustomProvider(e){try{return await sO(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _getCustomProvider(e){try{return await sO(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _updateCustomProvider(e,t){try{return await sO(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _deleteCustomProvider(e){try{return await sO(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _adminListPasskeys(e){sx(e.userId);try{return await sO(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eF(e))return{data:null,error:e};throw e}}async _adminDeletePasskey(e){sx(e.userId),sx(e.passkeyId);try{return await sO(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eF(e))return{data:null,error:e};throw e}}}function sB(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}class sz extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}function sF(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}class sW extends Error{constructor({message:e,code:t,cause:r,name:s}){var n;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!=(n=null!=s?s:r instanceof Error?r.name:void 0)?n:"Unknown Error",this.code=t}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class sH extends sW{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}let sG=new class{createNewAbortSignal(){if(this.controller){let e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}};function sK(e){if(!e)throw Error("Credential creation options are required");if("u">typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);let{challenge:t,user:r,excludeCredentials:s}=e,n=tn(e,["challenge","user","excludeCredentials"]),a=r7(t).buffer,i=Object.assign(Object.assign({},r),{id:r7(r.id).buffer}),o=Object.assign(Object.assign({},n),{challenge:a,user:i});if(s&&s.length>0){o.excludeCredentials=Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];o.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:r7(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return o}function sJ(e){if(!e)throw Error("Credential request options are required");if("u">typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);let{challenge:t,allowCredentials:r}=e,s=tn(e,["challenge","allowCredentials"]),n=r7(t).buffer,a=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){a.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];a.allowCredentials[e]=Object.assign(Object.assign({},t),{id:r7(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return a}function sV(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:se(new Uint8Array(e.response.attestationObject)),clientDataJSON:se(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function sY(e){var t;if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();let r=e.getClientExtensionResults(),s=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:se(new Uint8Array(s.authenticatorData)),clientDataJSON:se(new Uint8Array(s.clientDataJSON)),signature:se(new Uint8Array(s.signature)),userHandle:s.userHandle?se(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function sX(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}async function sZ(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new sH("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new sH("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){var r,s,n;let{publicKey:a}=t;if(!a)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new sW({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null==(r=a.authenticatorSelection)?void 0:r.requireResidentKey)===!0)return new sW({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});else if("conditional"===t.mediation&&(null==(s=a.authenticatorSelection)?void 0:s.userVerification)==="required")return new sW({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});else if((null==(n=a.authenticatorSelection)?void 0:n.userVerification)==="required")return new sW({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else if("InvalidStateError"===e.name)return new sW({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new sW({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name)return new sW(0===a.pubKeyCredParams.filter(e=>"public-key"===e.type).length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!sX(t))return new sW({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(a.rp.id!==t)return new sW({message:`The RP ID "${a.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new sW({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new sW({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new sW({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}async function sQ(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new sH("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new sH("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new sW({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new sW({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!sX(t))return new sW({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new sW({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new sW({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new sW({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}let s0={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},s1={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function s2(...e){let t=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),s={};for(let n of e)if(n)for(let e in n){let a=n[e];if(void 0!==a)if(Array.isArray(a))s[e]=a;else if(r(a))s[e]=a;else if(t(a)){let r=s[e];t(r)?s[e]=s2(r,a):s[e]=s2(a)}else s[e]=a}return s}class s3{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:s},n){var a,i,o,l,c;try{let{data:u,error:d}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!u)return{data:null,error:d};let h=null!=s?s:sG.createNewAbortSignal();if("create"===u.webauthn.type){let{user:e}=u.webauthn.credential_options.publicKey;if(!e.name)if(r)e.name=`${e.id}:${r}`;else{let t=(await this.client.getUser()).data.user,r=(null==(a=null==t?void 0:t.user_metadata)?void 0:a.name)||(null==t?void 0:t.email)||(null==t?void 0:t.id)||"User";e.name=`${e.id}:${r}`}e.displayName||(e.displayName=e.name)}switch(u.webauthn.type){case"create":{let t=(i=u.webauthn.credential_options.publicKey,o=null==n?void 0:n.create,s2(s0,i,o||{})),{data:r,error:s}=await sZ({publicKey:t,signal:h});if(r)return{data:{factorId:e,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}case"request":{let t=(l=u.webauthn.credential_options.publicKey,c=null==n?void 0:n.request,s2(s1,l,c||{})),{data:r,error:s}=await sQ(Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:t,signal:h}));if(r)return{data:{factorId:e,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}}}catch(e){if(eF(e))return{data:null,error:e};return{data:null,error:new eG("Unexpected error in challenge",e)}}}async _verify({challengeId:e,factorId:t,webauthn:r}){return this.client.mfa.verify({factorId:t,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:t,rpOrigins:r,signal:s}={}},n){if(!t)return{data:null,error:new ez("rpId is required for WebAuthn authentication")};try{1;return{data:null,error:new eG("Browser does not support WebAuthn",null)}}catch(e){if(eF(e))return{data:null,error:e};return{data:null,error:new eG("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t,rpOrigins:r,signal:s}={}},n){if(!t)return{data:null,error:new ez("rpId is required for WebAuthn registration")};try{1;return{data:null,error:new eG("Browser does not support WebAuthn",null)}}catch(e){if(eF(e))return{data:null,error:e};return{data:null,error:new eG("Unexpected error in register",e)}}}}if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"u">typeof self&&(self.globalThis=self)}let s4={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:rZ,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},s5={},s6=!1;class s8{get jwks(){var e,t;return null!=(t=null==(e=s5[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){s5[this.storageKey]=Object.assign(Object.assign({},s5[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=s5[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){s5[this.storageKey]=Object.assign(Object.assign({},s5[this.storageKey]),{cachedAt:e})}constructor(e){var t,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.lastRefreshFailure=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this._pendingInitNotifications=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;let s=Object.assign(Object.assign({},s4),e);this.storageKey=s.storageKey,this.instanceID=null!=(t=s8.nextInstanceID[this.storageKey])?t:0,s8.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!s.debug,"function"==typeof s.debug&&(this.logger=s.debug),this.instanceID,this.persistSession=s.persistSession,this.autoRefreshToken=s.autoRefreshToken,this.experimental=null!=(r=s.experimental)?r:{},this.admin=new sM({url:s.url,headers:s.headers,fetch:s.fetch,experimental:this.experimental}),this.url=s.url,this.headers=s.headers,this.fetch=sr(s.fetch),this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,this.throwOnError=s.throwOnError,this.lockAcquireTimeout=s.lockAcquireTimeout,null!=s.lock&&(this.lock=s.lock,s6||(s6=!0,console.warn(`${this._logPrefix()} The "lock" option is deprecated and will be removed in v3. The client now coordinates session refreshes without a lock, so most apps can drop the option. See https://github.com/supabase/supabase-js/blob/master/packages/core/auth-js/migrations/lockless-coordination.md`))),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new s3(this),recoveryCodes:{getStatus:this._getRecoveryCodesStatus.bind(this),generate:this._generateRecoveryCodes.bind(this),verify:this._verifyRecoveryCode.bind(this),regenerate:this._regenerateRecoveryCodes.bind(this),unenroll:this._unenrollRecoveryCodes.bind(this)}},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(s.storage?this.storage=s.storage:(this.memoryStorage={},this.storage=sB(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=sB(this.memoryStorage)),s.skipAutoInitialize||this.initialize().catch(e=>{this._debug("#initialize()","error",e)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${rX}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){var e;if(this.initializePromise)return await this.initializePromise;this._pendingInitNotifications=[],this.initializePromise=(async()=>null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())();let t=await this.initializePromise,r=null!=(e=this._pendingInitNotifications)?e:[];for(let e of(this._pendingInitNotifications=null,r))await this._notifyAllSubscribers(e.event,e.session,e.broadcast);return t}async _initialize(){try{return await this._recoverAndRefresh(),{error:null}}catch(e){if(eF(e))return this._returnResult({error:e});return this._returnResult({error:new eG("Unexpected error during initialization",e)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{let{data:n,error:a}=await sO(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:null!=(r=null==(t=null==e?void 0:e.options)?void 0:t.data)?r:{},gotrue_meta_security:{captcha_token:null==(s=null==e?void 0:e.options)?void 0:s.captchaToken}},xform:s$});if(a||!n)return this._returnResult({data:{user:null,session:null},error:a});let i=n.session,o=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",i)),this._returnResult({data:{user:o,session:i},error:null})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,r,s;let n=null;try{let a;if("email"in e){let{email:r,password:s,options:i}=e,o=null,l=null;"pkce"===this.flowType&&([o,l,n]=await this._getCodeChallengeAndMethod()),a=await sO(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(null==i?void 0:i.emailRedirectTo,n),body:{email:r,password:s,data:null!=(t=null==i?void 0:i.data)?t:{},gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:o,code_challenge_method:l},xform:s$})}else if("phone"in e){let{phone:t,password:n,options:i}=e;a=await sO(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!=(r=null==i?void 0:i.data)?r:{},channel:null!=(s=null==i?void 0:i.channel)?s:"sms",gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:s$})}else throw new eX("You must provide either an email or phone number and a password");let{data:i,error:o}=a;if(o||!i)return await sw(this.storage,this.storageKey,n),this._returnResult({data:{user:null,session:null},error:o});let l=i.session,c=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(e){if(await sw(this.storage,this.storageKey,n),eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithPassword(e){try{let t;if("email"in e){let{email:r,password:s,options:n}=e;t=await sO(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:sP})}else if("phone"in e){let{phone:r,password:s,options:n}=e;t=await sO(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:sP})}else throw new eX("You must provide either an email or phone number and a password");let{data:r,error:s}=t;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!r||!r.session||!r.user){let e=new eY;return this._returnResult({data:{user:null,session:null},error:e})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOAuth(e){var t,r,s,n;return await this._handleProviderSignIn(e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(r=e.options)?void 0:r.scopes,queryParams:null==(s=e.options)?void 0:s.queryParams,skipBrowserRedirect:null==(n=e.options)?void 0:n.skipBrowserRedirect})}async exchangeCodeForSession(e,t){return(await this.initializePromise,null!=this.lock)?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e,t)):this._exchangeCodeForSession(e,t)}async signInWithWeb3(e){let{chain:t}=e;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,r,s,n,a,i,o,l,c,u,d,h;let p,f;if("message"in e)p=e.message,f=e.signature;else{let{chain:u,wallet:d,statement:m,options:g}=e;if("object"!=typeof d||!(null==g?void 0:g.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");let b=new URL(null!=(t=null==g?void 0:g.url)?t:window.location.href),y=await d.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!y||0===y.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let w=sF(y[0]),v=null==(r=null==g?void 0:g.signInWithEthereum)?void 0:r.chainId;v||(v=parseInt(await d.request({method:"eth_chainId"}),16)),p=function(e){var t;let{chainId:r,domain:s,expirationTime:n,issuedAt:a=new Date,nonce:i,notBefore:o,requestId:l,resources:c,scheme:u,uri:d,version:h}=e;if(!Number.isInteger(r))throw Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(i&&i.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${i}`);if(!d)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==h)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${h}`);if(null==(t=e.statement)?void 0:t.includes("\n"))throw Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`);let p=sF(e.address),f=u?`${u}://${s}`:s,m=e.statement?`${e.statement}
85
+ });`;class rg{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,t){var r;if(this.channels=[],this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new tD,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),!(null==(r=null==t?void 0:t.params)?void 0:r.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;let s=this._initializeOptions(t);this.socketAdapter=new rp(e,s),this.httpEndpoint=tG(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(t){let e=t.message;throw Error(`WebSocket not available: ${e}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,t){return(this._cancelPendingDisconnect(),this.isDisconnecting())?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,t)}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return"ok"===t&&e.teardown(),t}async removeAllChannels(){let e=this.channels.map(async e=>{let t=await e.unsubscribe();return e.teardown(),t}),t=await Promise.all(e);return await this.disconnect(),t}log(e,t,r){this.socketAdapter.log(e,t,r)}hasLogger(){return this.socketAdapter.hasLogger()}connectionState(){return this.socketAdapter.connectionState()||"closed"}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,t={config:{}}){let r=`realtime:${e}`,s=this.getChannels().find(e=>e.topic===r);if(s)return s;{let r=new rh(`realtime:${e}`,t,this);return this._cancelPendingDisconnect(),this.channels.push(r),r}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){let t=++this._authGeneration,r=this._performAuth(e,t);t===this._authGeneration&&(this._authPromise=r);try{await r}finally{this._authPromise===r&&(this._authPromise=null)}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic),0===this.channels.length&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,0===this.channels.length&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){null!==this._pendingDisconnectTimer&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e,t){let r,s=!1;if(e)r=e,s=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),r=this.accessTokenValue}else r=this.accessTokenValue;t===this._authGeneration&&(this.accessToken?this._manuallySetToken=!1:s&&(this._manuallySetToken=!0),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(e=>{let t={access_token:r,version:"realtime-js/2.117.3"};e.updateJoinPayload(t),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(tN.access_token,{access_token:r})})))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(t=>{this.log("error",`Error setting auth in ${e}`,t)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(e=>{this.log("error","error waiting for auth on connect",e)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(t,r)=>{"disconnected"!==t&&("sent"==t&&this._setAuthSafely(),e&&e(t,r))}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([rm],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,r,s,n,a,i,o,l,c,u,d,h;let p,f;this.worker=null!=(t=null==e?void 0:e.worker)&&t,this.accessToken=null!=(r=null==e?void 0:e.accessToken)?r:null;let m={};m.timeout=null!=(s=null==e?void 0:e.timeout)?s:1e4,m.heartbeatIntervalMs=null!=(n=null==e?void 0:e.heartbeatIntervalMs)?n:25e3,this._disconnectOnEmptyChannelsAfterMs=null!=(a=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)?a:2*(null!=(i=null==e?void 0:e.heartbeatIntervalMs)?i:25e3),m.transport=null!=(o=null==e?void 0:e.transport)?o:tO.getWebSocketConstructor(),m.params=null==e?void 0:e.params,m.logger=null==e?void 0:e.logger,m.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),m.sessionStorage=null!=(l=null==e?void 0:e.sessionStorage)?l:function(){let e;try{if("u">typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}return e=new Map,{get length(){return e.size},clear(){e.clear()},getItem:t=>e.has(t)?e.get(t):null,key(t){var r;return null!=(r=Array.from(e.keys())[t])?r:null},removeItem(t){e.delete(t)},setItem(t,r){e.set(t,String(r))}}}(),m.reconnectAfterMs=null!=(c=null==e?void 0:e.reconnectAfterMs)?c:e=>rf[e-1]||1e4;let g=null!=(u=null==e?void 0:e.vsn)?u:t$;switch(g){case"1.0.0":p=(e,t)=>t(JSON.stringify(e)),f=(e,t)=>t(JSON.parse(e));break;case t$:p=this.serializer.encode.bind(this.serializer),f=this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${m.vsn}`)}return m.vsn=g,m.encode=null!=(d=null==e?void 0:e.encode)?d:p,m.decode=null!=(h=null==e?void 0:e.decode)?h:f,m.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,m.params=Object.assign(Object.assign({},m.params),{log_level:this.logLevel})),this.worker&&(this.workerUrl=null==e?void 0:e.workerUrl,m.autoSendHeartbeat=!this.worker),m}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var rb=class extends Error{constructor(e,t){super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown="CommitStateUnknownException"===t.icebergType||[500,502,504].includes(t.status)&&t.icebergType?.includes("CommitState")===!0}isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}};async function ry(e){return e&&"none"!==e.type?"bearer"===e.type?{Authorization:`Bearer ${e.token}`}:"header"===e.type?{[e.name]:e.value}:"custom"===e.type?await e.getHeaders():{}:{}}function rw(e){return e.join("\x1f")}var rv=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:rw(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let r={namespace:e.namespace,properties:t?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${rw(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${rw(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${rw(e.namespace)}`}),!0}catch(e){if(e instanceof rb&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof rb&&409===e.status)return;throw e}}};function rk(e){return e.join("\x1f")}var r_=class{constructor(e,t="",r){this.client=e,this.prefix=t,this.accessDelegation=r}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${rk(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){let r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${rk(e.namespace)}/tables`,body:t,headers:r})).data.metadata}async updateTable(e,t){let r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${rk(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${rk(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String(t?.purge??!1)}})}async loadTable(e){let t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${rk(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${rk(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof rb&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof rb&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}},rS=class{constructor(e){var t;let r,s="v1";e.catalogName&&(s+=`/${e.catalogName}`);let n=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=(r=(t={baseUrl:n,auth:e.auth,fetchImpl:e.fetch}).fetchImpl??globalThis.fetch,{async request({method:e,path:s,query:n,body:a,headers:i}){let o=function(e,t,r){let s=new URL(t,e);if(r)for(let[e,t]of Object.entries(r))void 0!==t&&s.searchParams.set(e,t);return s.toString()}(t.baseUrl,s,n),l=await ry(t.auth),c=await r(o,{method:e,headers:{...a?{"Content-Type":"application/json"}:{},...l,...i},body:a?JSON.stringify(a):void 0}),u=await c.text(),d=(c.headers.get("content-type")||"").includes("application/json"),h=d&&u?JSON.parse(u):u;if(!c.ok){let e=d?h:void 0,t=e?.error;throw new rb(t?.message??`Request failed with status ${c.status}`,{status:c.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:c.status,headers:c.headers,data:h}}}),this.accessDelegation=e.accessDelegation?.join(","),this.namespaceOps=new rv(this.client,s),this.tableOps=new r_(this.client,s,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}};function rx(e){return(rx="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function rA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function rT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?rA(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=rx(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=rx(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==rx(s)?s:s+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):rA(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var rR=class extends Error{constructor(e,t="storage",r,s){super(e),this.__isStorageError=!0,this.namespace=t,this.name="vectors"===t?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function rE(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}var rI=class extends rR{constructor(e,t,r,s="storage",n){super(e,s,t,r),this.name="vectors"===s?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=r,this.code=n}toJSON(){return rT(rT({},super.toJSON()),{},{code:this.code})}},rj=class extends rR{constructor(e,t,r="storage"){super(e,r),this.name="vectors"===r?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function rO(e,t,r){let s=rT({},e),n=t.toLowerCase();for(let e of Object.keys(s))e.toLowerCase()===n&&delete s[e];return s[n]=r,s}let r$=e=>{if(Array.isArray(e))return e.map(e=>r$(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,r])=>{t[e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=r$(r)}),t},rC=e=>e.split("/").map(encodeURIComponent).join("/"),rP=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error;if("object"==typeof e.error&&null!==e.error){let t=e.error;if("string"==typeof t.message)return t.message}}return JSON.stringify(e)},rN=async(e,t,r,s)=>{if(null!==e&&"object"==typeof e&&"json"in e&&"function"==typeof e.json){let r=parseInt(String(e.status),10);Number.isFinite(r)||(r=500),e.json().then(e=>{let n=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";t(new rI(rP(e),r,n,s,null==e?void 0:e.code))}).catch(()=>{let n=r+"";t(new rI(e.statusText||`HTTP ${r} error`,r,n,s))})}else t(new rj(rP(e),e,s))};async function rD(e,t,r,s,n,a,i){return new Promise((o,l)=>{e(r,((e,t,r,s)=>{let n={method:e,headers:(null==t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!s)return rT(rT({},n),r);if((e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)})(s)){var a;let e,r=(null==t?void 0:t.headers)||{};for(let[t,s]of Object.entries(r))"content-type"===t.toLowerCase()&&(e=s);n.headers=rO(r,"Content-Type",null!=(a=e)?a:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return(null==t?void 0:t.duplex)&&(n.duplex=t.duplex),rT(rT({},n),r)})(t,s,n,a)).then(e=>{if(!e.ok)throw e;if(null==s?void 0:s.noResolveJson)return e;if("vectors"===i){let t=e.headers.get("content-type");if("0"===e.headers.get("content-length")||204===e.status||!t||!t.includes("application/json"))return{}}return e.json()}).then(e=>o(e)).catch(e=>rN(e,l,s,i))})}function rL(e="storage"){return{get:async(t,r,s,n)=>rD(t,"GET",r,s,n,void 0,e),post:async(t,r,s,n,a)=>rD(t,"POST",r,n,a,s,e),put:async(t,r,s,n,a)=>rD(t,"PUT",r,n,a,s,e),head:async(t,r,s,n)=>rD(t,"HEAD",r,rT(rT({},s),{},{noResolveJson:!0}),n,void 0,e),remove:async(t,r,s,n,a)=>rD(t,"DELETE",r,n,a,s,e)}}let{get:rU,post:rq,put:rM,head:rB,remove:rz}=rL("storage"),rF=rL("vectors");var rW=class{constructor(e,t={},r,s="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=function(e){let t={};for(let[r,s]of Object.entries(e))t[r.toLowerCase()]=s;return t}(t),this.fetch=r?(...e)=>r(...e):(...e)=>fetch(...e),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=rO(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rE(e))return{data:null,error:e};throw e}}};t=Symbol.toStringTag;var rH=class{constructor(e,r){this.downloadFn=e,this.shouldThrowOnError=r,this[t]="StreamDownloadBuilder",this.promise=null}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rE(e))return{data:null,error:e};throw e}}};r=Symbol.toStringTag;var rG=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[r]="BlobDownloadBuilder",this.promise=null}asStream(){return new rH(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:await (await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rE(e))return{data:null,error:e};throw e}}};let rK={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},rJ={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var rV=class extends rW{constructor(e,t={},r,s){super(e,t,s,"storage"),this.bucketId=r}async uploadOrUpdate(e,t,r,s){var n=this;return n.handleOperation(async()=>{let a,i=rT(rT({},rJ),s),o=rT(rT({},n.headers),"POST"===e&&{"x-upsert":String(i.upsert)}),l=i.metadata;if("u">typeof Blob&&r instanceof Blob||"u">typeof FormData&&r instanceof FormData?a=n.prepareUploadFormData(r,i):(a=r,o["cache-control"]=`max-age=${i.cacheControl}`,o["content-type"]=i.contentType,l&&(o["x-metadata"]=n.toBase64(n.encodeMetadata(l))),("u">typeof ReadableStream&&a instanceof ReadableStream||a&&"object"==typeof a&&"pipe"in a&&"function"==typeof a.pipe)&&!i.duplex&&(i.duplex="half")),null==s?void 0:s.headers)for(let[e,t]of Object.entries(s.headers))o=rO(o,e,t);let c=n._removeEmptyFolders(t),u=n._getFinalPath(c),d=await ("PUT"==e?rM:rq)(n.fetch,`${n.url}/object/${u}`,a,rT({headers:o},(null==i?void 0:i.duplex)?{duplex:i.duplex}:{}));return{path:c,id:d.Id,fullPath:d.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,s){var n=this;let a=n._removeEmptyFolders(e),i=n._getFinalPath(a),o=new URL(n.url+`/object/upload/sign/${i}`);return o.searchParams.set("token",t),n.handleOperation(async()=>{let e,t=rT(rT({},rJ),s),i=rT(rT({},n.headers),{"x-upsert":String(t.upsert)}),l=t.metadata;if("u">typeof Blob&&r instanceof Blob||"u">typeof FormData&&r instanceof FormData?e=n.prepareUploadFormData(r,t):(e=r,i["cache-control"]=`max-age=${t.cacheControl}`,i["content-type"]=t.contentType,l&&(i["x-metadata"]=n.toBase64(n.encodeMetadata(l))),("u">typeof ReadableStream&&e instanceof ReadableStream||e&&"object"==typeof e&&"pipe"in e&&"function"==typeof e.pipe)&&!t.duplex&&(t.duplex="half")),null==s?void 0:s.headers)for(let[e,t]of Object.entries(s.headers))i=rO(i,e,t);return{path:a,fullPath:(await rM(n.fetch,o.toString(),e,rT({headers:i},(null==t?void 0:t.duplex)?{duplex:t.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(e),n=rT({},r.headers);(null==t?void 0:t.upsert)&&(n["x-upsert"]="true");let a=await rq(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),i=new URL(r.url+a.url),o=i.searchParams.get("token");if(!o)throw new rR("No token returned by API");return{signedUrl:i.toString(),path:e,token:o}})}async update(e,t,r){return this.uploadOrUpdate("PUT",e,t,r)}async move(e,t,r){var s=this;return s.handleOperation(async()=>await rq(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket,sourceVersionId:null==r?void 0:r.sourceVersionId},{headers:s.headers}))}async copy(e,t,r){var s=this;return s.handleOperation(async()=>({path:(await rq(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket,sourceVersionId:null==r?void 0:r.sourceVersionId},{headers:s.headers})).Key}))}async createSignedUrl(e,t,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(e),a="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0,i=await rq(s.fetch,`${s.url}/object/sign/${n}`,rT(rT({expiresIn:t},a?{transform:r.transform}:{}),(null==r?void 0:r.versionId)!=null?{versionId:r.versionId}:{}),{headers:s.headers}),o=new URLSearchParams;(null==r?void 0:r.download)&&o.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&o.set("cacheNonce",String(r.cacheNonce));let l=o.toString();return{signedUrl:encodeURI(`${s.url}${i.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(e,t,r){var s=this;return s.handleOperation(async()=>{let n=await rq(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:t,paths:e},{headers:s.headers}),a=new URLSearchParams;(null==r?void 0:r.download)&&a.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&a.set("cacheNonce",String(r.cacheNonce));let i=a.toString();return n.map(e=>rT(rT({},e),{},{signedUrl:e.signedURL?encodeURI(`${s.url}${e.signedURL}${i?`&${i}`:""}`):null}))})}download(e,t,r){let s="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(n,t.transform),(null==t?void 0:t.cacheNonce)!=null&&n.set("cacheNonce",String(t.cacheNonce)),(null==t?void 0:t.versionId)!=null&&n.set("versionId",String(t.versionId));let a=n.toString(),i=this._getFinalPath(e);return new rG(()=>rU(this.fetch,`${this.url}/${s}/${i}${a?`?${a}`:""}`,{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e,t){var r=this;let s=r._getFinalPath(e),n=new URLSearchParams;(null==t?void 0:t.versionId)!=null&&n.set("versionId",String(t.versionId));let a=n.toString();return r.handleOperation(async()=>r$(await rU(r.fetch,`${r.url}/object/info/${s}${a?`?${a}`:""}`,{headers:r.headers})))}async exists(e){var t;let r=this._getFinalPath(e);try{return await rB(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(rE(e)){let r=e instanceof rI?e.status:e instanceof rj?null==(t=e.originalError)?void 0:t.status:void 0;if(void 0!==r&&[400,404].includes(r))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){let r=this._getFinalPath(e),s=new URLSearchParams;(null==t?void 0:t.download)&&s.set("download",!0===t.download?"":t.download),(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(s,t.transform),(null==t?void 0:t.cacheNonce)!=null&&s.set("cacheNonce",String(t.cacheNonce)),(null==t?void 0:t.versionId)!=null&&s.set("versionId",String(t.versionId));let n=s.toString(),a="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}`)+(n?`?${n}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await rz(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async purgeCache(e,t,r){var s=this;return s.handleOperation(async()=>{let n=rC(s._getFinalPath(e)),a=new URLSearchParams;(null==t?void 0:t.transformations)&&a.set("transformations","true");let i=a.toString();return await rz(s.fetch,`${s.url}/cdn/${n}${i?`?${i}`:""}`,{},{headers:s.headers},r)})}async list(e,t,r){var s=this;return s.handleOperation(async()=>{let n=(null==t?void 0:t.sortBy)?rT(rT({},rK.sortBy),t.sortBy):rK.sortBy,a=rT(rT(rT({},rK),t),{},{sortBy:n,prefix:e||""});return await rq(s.fetch,`${s.url}/object/list/${s.bucketId}`,a,{headers:s.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{let s=rT({},e);return await rq(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},t)})}prepareUploadFormData(e,t){let r=new FormData,s=[];for(let[n,a]of(e instanceof FormData?e.forEach((e,t)=>{"string"==typeof e?r.append(t,e):s.push([t,e])}):s.push(["",e]),r.has("cacheControl")||r.append("cacheControl",t.cacheControl),t.metadata&&!r.has("metadata")&&r.append("metadata",this.encodeMetadata(t.metadata)),s))r.append(n,a);return r}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return"u">typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("quality",t.quality.toString()),e}};let rY={"X-Client-Info":"storage-js/2.117.3"};var rZ=class extends rW{constructor(e,t={},r,s){let n=new URL(e);(null==s?void 0:s.useNewHostname)&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase.")),super(n.href.replace(/\/$/,""),rT(rT({},rY),t),r,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=t.listBucketOptionsToQueryString(e);return await rU(t.fetch,`${t.url}/bucket${r}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await rU(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var r=this;return r.handleOperation(async()=>await rq(r.fetch,`${r.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes,versioning_status:t.versioningStatus},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await rM(r.fetch,`${r.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes,versioning_status:t.versioningStatus},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await rq(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await rz(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}async getBucketLifecycle(e){var t=this;return t.handleOperation(async()=>await rU(t.fetch,t.bucketLifecycleUrl(e),{headers:t.headers}))}async updateBucketLifecycle(e,t){var r=this;return r.handleOperation(async()=>await rM(r.fetch,r.bucketLifecycleUrl(e),t,{headers:r.headers}))}async deleteBucketLifecycle(e){var t=this;return t.handleOperation(async()=>await rz(t.fetch,t.bucketLifecycleUrl(e),{},{headers:t.headers}))}async purgeBucketCache(e,t,r){var s=this;return s.handleOperation(async()=>{let n=new URLSearchParams;(null==t?void 0:t.transformations)&&n.set("transformations","true");let a=n.toString();return await rz(s.fetch,`${s.url}/cdn/${rC(e)}${a?`?${a}`:""}`,{},{headers:s.headers},r)})}bucketLifecycleUrl(e){return`${this.url}/bucket/${rC(e)}/lifecycle`}listBucketOptionsToQueryString(e){let t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},rX=class extends rW{constructor(e,t={},r){super(e.replace(/\/$/,""),rT(rT({},rY),t),r,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await rq(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=new URLSearchParams;(null==e?void 0:e.limit)!==void 0&&r.set("limit",e.limit.toString()),(null==e?void 0:e.offset)!==void 0&&r.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&r.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&r.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&r.set("search",e.search);let s=r.toString(),n=s?`${t.url}/bucket?${s}`:`${t.url}/bucket`;return await rU(t.fetch,n,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await rz(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(e){var t=this;if(!(!(!e||"string"!=typeof e||0===e.length||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\"))&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e)))throw new rR("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");let r=new rS({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(e,t){let r=e[t];return"function"!=typeof r?r:async(...t)=>{try{return{data:await r.apply(e,t),error:null}}catch(e){if(s)throw e;return{data:null,error:e}}}}})}},rQ=class extends rW{constructor(e,t={},r){super(e.replace(/\/$/,""),rT(rT({},rY),{},{"Content-Type":"application/json"},t),r,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await rF.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await rF.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}},r0=class extends rW{constructor(e,t={},r){super(e.replace(/\/$/,""),rT(rT({},rY),{},{"Content-Type":"application/json"},t),r,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},r1=class extends rW{constructor(e,t={},r){super(e.replace(/\/$/,""),rT(rT({},rY),{},{"Content-Type":"application/json"},t),r,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await rF.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},r2=class extends r1{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new r3(this.url,this.headers,e,this.fetch)}async createBucket(e){return super.createBucket.call(this,e)}async getBucket(e){return super.getBucket.call(this,e)}async listBuckets(e={}){return super.listBuckets.call(this,e)}async deleteBucket(e){return super.deleteBucket.call(this,e)}},r3=class extends rQ{constructor(e,t,r,s){super(e,t,s),this.vectorBucketName=r}async createIndex(e){return super.createIndex.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(e={}){return super.listIndexes.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName}))}async getIndex(e){return super.getIndex.call(this,this.vectorBucketName,e)}async deleteIndex(e){return super.deleteIndex.call(this,this.vectorBucketName,e)}index(e){return new r4(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},r4=class extends r0{constructor(e,t,r,s,n){super(e,t,n),this.vectorBucketName=r,this.indexName=s}async putVectors(e){return super.putVectors.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async getVectors(e){return super.getVectors.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async listVectors(e={}){return super.listVectors.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async queryVectors(e){return super.queryVectors.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async deleteVectors(e){return super.deleteVectors.call(this,rT(rT({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}},r5=class extends rZ{constructor(e,t={},r,s){super(e,t,r,s)}from(e){return new rV(this.url,this.headers,e,this.fetch)}get vectors(){return new r2(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new rX(this.url+"/iceberg",this.headers,this.fetch)}};let r6="2.117.3",r8={"X-Client-Info":`gotrue-js/${r6}`},r9="X-Supabase-Api-Version",r7={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},se=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,st="sb_flow_id",sr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ss=" \n\r=".split(""),sn=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<ss.length;t+=1)e[ss[t].charCodeAt(0)]=-2;for(let t=0;t<sr.length;t+=1)e[sr[t].charCodeAt(0)]=t;return e})();function sa(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(sr[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6;else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;)r(sr[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function si(e,t,r){let s=sn[e];if(s>-1)for(t.queue=t.queue<<6|s,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===s)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function so(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},a=e=>{!function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}}(e,s,r)};for(let t=0;t<e.length;t+=1)si(e.charCodeAt(t),n,a);return t.join("")}function sl(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)si(e.charCodeAt(t),r,s);return new Uint8Array(t)}function sc(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};return e.forEach(e=>sa(e,r,s)),sa(null,r,s),t.join("")}function su(e){return Math.round(Date.now()/1e3)+e}let sd=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),sh=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},sp=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return null}},sf=async(e,t)=>{await e.removeItem(t)};class sm{constructor(){this.promise=new sm.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function sg(e){let t=e.split(".");if(3!==t.length)throw new tn("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!se.test(t[e]))throw new tn("JWT not in base64url format");return{header:JSON.parse(so(t[0])),payload:JSON.parse(so(t[1])),signature:sl(t[2]),raw:{header:t[0],payload:t[1]}}}async function sb(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function sy(e){return("0"+e.toString(16)).substr(-2)}async function sw(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>String.fromCharCode(e)).join("")}async function sv(e){return"u">typeof crypto&&void 0!==crypto.subtle&&"u">typeof TextEncoder?btoa(await sw(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):(console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e)}sm.promiseConstructor=Promise;let sk=/^[a-zA-Z0-9_-]{8,64}$/;function s_(e){return"string"==typeof e&&sk.test(e)?e:null}let sS=(e,t)=>`${e}-flow-${t}-code-verifier`,sx=e=>`${e}-flows-code-verifier`;async function sA(e,t){let r=await sp(e,sx(t));return Array.isArray(r)?r.filter(e=>null!==s_(e)):[]}async function sT(e,t,r,s,n){await sh(e,sS(t,r),s);let a=(await sA(e,t)).filter(e=>e!==r);for(a.push(r);a.length>5;){let r=a.shift();await sf(e,sS(t,r)),null==n||n(r)}await sh(e,sx(t),a),await sh(e,`${t}-code-verifier`,s)}async function sR(e,t,r){if(r){let s=await sp(e,sS(t,r));return{verifier:"string"==typeof s?s:null,flowId:r}}let s=await sp(e,`${t}-code-verifier`);return{verifier:"string"==typeof s?s:null,flowId:null}}async function sE(e,t,r){let s=`${t}-code-verifier`;if(!r)return void await sf(e,s);let n=sS(t,r),a=await sp(e,n);await sf(e,n);let i=await sA(e,t),o=i.filter(e=>e!==r);o.length!==i.length&&(o.length>0?await sh(e,sx(t),o):await sf(e,sx(t))),null!=a&&a===await sp(e,s)&&await sf(e,s)}async function sI(e,t){for(let r of(await sA(e,t)))await sf(e,sS(t,r));await sf(e,sx(t)),await sf(e,`${t}-code-verifier`)}async function sj(e,t,r=!1,s){let n=function(){let e=new Uint32Array(56);if("u"<typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let s=0;s<56;s++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,sy).join("")}(),a=n;r&&(a+="/recovery");let i=function(){if("u">typeof crypto&&"function"==typeof crypto.getRandomValues){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,sy).join("")}let e="";for(let t=0;t<32;t++)e+=Math.floor(16*Math.random()).toString(16);return e}();await sT(e,t,i,a,s);let o=await sv(n),l=n===o?"plain":"s256";return[o,l,i]}let sO=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,s$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function sC(e){if(!s$.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function sP(e){if(!e.recoveryCodes)throw Error("@supabase/auth-js: the MFA recovery codes API is experimental and disabled by default. Enable it by passing `auth: { experimental: { recoveryCodes: true } }` to createClient (or to the GoTrueClient constructor).")}function sN(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function sD(e){return JSON.parse(JSON.stringify(e))}let sL=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error}return JSON.stringify(e)},sU=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function sq(e){var t;let r,s;if(!("object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json))throw new e7(sL(e),0);try{r=await e.json()}catch(t){if(sU.includes(e.status))throw new e7(e.statusText||`HTTP ${e.status}`,e.status);throw new e1(sL(t),t)}if(sU.includes(e.status))throw new e7(sL(r),e.status);let n=function(e){let t=e.headers.get(r9);if(!t||!t.match(sO))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(n&&n.getTime()>=r7["2024-01-01"].timestamp&&"object"==typeof r&&r&&"string"==typeof r.code?s=r.code:"object"==typeof r&&r&&"string"==typeof r.error_code&&(s=r.error_code),s){if("weak_password"===s)throw new ts(sL(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===s)throw new e3}else if("object"==typeof r&&r&&"object"==typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new ts(sL(r),e.status,r.weak_password.reasons);throw new eQ(sL(r),e.status||500,s)}async function sM(e,t,r,s){var n;let a=Object.assign({},null==s?void 0:s.headers);a[r9]||(a[r9]=r7["2024-01-01"].name),(null==s?void 0:s.jwt)&&(a.Authorization=`Bearer ${s.jwt}`);let i=null!=(n=null==s?void 0:s.query)?n:{};(null==s?void 0:s.redirectTo)&&(i.redirect_to=s.redirectTo);let o=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await sB(e,t,r+o,{headers:a,noResolveJson:null==s?void 0:s.noResolveJson},{},null==s?void 0:s.body);return(null==s?void 0:s.xform)?null==s?void 0:s.xform(l):{data:Object.assign({},l),error:null}}async function sB(e,t,r,s,n,a){let i,o,l=(o={method:t,headers:(null==s?void 0:s.headers)||{}},"GET"===t?o:(o.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==s?void 0:s.headers),o.body=JSON.stringify(a),Object.assign(Object.assign({},o),n)));try{i=await e(r,Object.assign({},l))}catch(e){throw new e7(sL(e),0)}if(i.ok||await sq(i),null==s?void 0:s.noResolveJson)return i;try{return await i.json()}catch(e){await sq(e)}}function sz(e){var t,r;let s=null;return(r=e).access_token&&r.refresh_token&&r.expires_in&&(s=Object.assign({},e),e.expires_at||(s.expires_at=su(e.expires_in))),{data:{session:s,user:null!=(t=e.user)?t:"string"==typeof(null==e?void 0:e.id)?e:null},error:null}}function sF(e){let t=sz(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function sW(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function sH(e){return{data:e,error:null}}function sG(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a},user:Object.assign({},tp(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function sK(e){return e}let sJ=["global","local","others"];class sV{constructor({url:e="",headers:t={},fetch:r,experimental:s}){this.url=e,this.headers=t,this.fetch=sd(r),this.experimental=null!=s?s:{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,t=sJ[0]){if(0>sJ.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${sJ.join(", ")}`);try{return await sM(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eX(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await sM(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:sW})}catch(e){if(eX(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=tp(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=null==r?void 0:r.newEmail,delete s.newEmail),await sM(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:sG,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(eX(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await sM(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:sW})}catch(e){if(eX(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,n,a,i,o;try{let l={nextPage:null,lastPage:0,total:0},c=await sM(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(n=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?n:""},xform:sK});if(c.error)throw c.error;let u=await c.json(),d=null!=(a=c.headers.get("x-total-count"))?a:0,h=null!=(o=null==(i=c.headers.get("link"))?void 0:i.split(","))?o:[];return h.length>0&&(h.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(d)),{data:Object.assign(Object.assign({},u),l),error:null}}catch(e){if(eX(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){sC(e);try{return await sM(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:sW})}catch(e){if(eX(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){sC(e);try{return await sM(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:sW})}catch(e){if(eX(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){sC(e);try{return await sM(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:sW})}catch(e){if(eX(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){sC(e.userId);try{let{data:t,error:r}=await sM(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _deleteFactor(e){sC(e.userId),sC(e.id);try{return{data:await sM(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,s,n,a,i,o;try{let l={nextPage:null,lastPage:0,total:0},c=await sM(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(n=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?n:""},xform:sK});if(c.error)throw c.error;let u=await c.json(),d=null!=(a=c.headers.get("x-total-count"))?a:0,h=null!=(o=null==(i=c.headers.get("link"))?void 0:i.split(","))?o:[];return h.length>0&&(h.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(d)),{data:Object.assign(Object.assign({},u),l),error:null}}catch(e){if(eX(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await sM(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await sM(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await sM(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await sM(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await sM(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _listCustomProviders(e){try{let t={};return(null==e?void 0:e.type)&&(t.type=e.type),await sM(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:t,xform:e=>{var t;return{data:{providers:null!=(t=null==e?void 0:e.providers)?t:[]},error:null}}})}catch(e){if(eX(e))return{data:{providers:[]},error:e};throw e}}async _createCustomProvider(e){try{return await sM(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _getCustomProvider(e){try{return await sM(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _updateCustomProvider(e,t){try{return await sM(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _deleteCustomProvider(e){try{return await sM(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _adminListPasskeys(e){sC(e.userId);try{return await sM(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(eX(e))return{data:null,error:e};throw e}}async _adminDeletePasskey(e){sC(e.userId),sC(e.passkeyId);try{return await sM(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eX(e))return{data:null,error:e};throw e}}}function sY(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}class sZ extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}function sX(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}class sQ extends Error{constructor({message:e,code:t,cause:r,name:s}){var n;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!=(n=null!=s?s:r instanceof Error?r.name:void 0)?n:"Unknown Error",this.code=t}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class s0 extends sQ{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}let s1=new class{createNewAbortSignal(){if(this.controller){let e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}};function s2(e){if(!e)throw Error("Credential creation options are required");if("u">typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);let{challenge:t,user:r,excludeCredentials:s}=e,n=tp(e,["challenge","user","excludeCredentials"]),a=sl(t).buffer,i=Object.assign(Object.assign({},r),{id:sl(r.id).buffer}),o=Object.assign(Object.assign({},n),{challenge:a,user:i});if(s&&s.length>0){o.excludeCredentials=Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];o.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:sl(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return o}function s3(e){if(!e)throw Error("Credential request options are required");if("u">typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);let{challenge:t,allowCredentials:r}=e,s=tp(e,["challenge","allowCredentials"]),n=sl(t).buffer,a=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){a.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];a.allowCredentials[e]=Object.assign(Object.assign({},t),{id:sl(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return a}function s4(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:sc(new Uint8Array(e.response.attestationObject)),clientDataJSON:sc(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function s5(e){var t;if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();let r=e.getClientExtensionResults(),s=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:sc(new Uint8Array(s.authenticatorData)),clientDataJSON:sc(new Uint8Array(s.clientDataJSON)),signature:sc(new Uint8Array(s.signature)),userHandle:s.userHandle?sc(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function s6(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}async function s8(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new s0("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new s0("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){var r,s,n;let{publicKey:a}=t;if(!a)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new sQ({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null==(r=a.authenticatorSelection)?void 0:r.requireResidentKey)===!0)return new sQ({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});else if("conditional"===t.mediation&&(null==(s=a.authenticatorSelection)?void 0:s.userVerification)==="required")return new sQ({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});else if((null==(n=a.authenticatorSelection)?void 0:n.userVerification)==="required")return new sQ({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else if("InvalidStateError"===e.name)return new sQ({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new sQ({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name)return new sQ(0===a.pubKeyCredParams.filter(e=>"public-key"===e.type).length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!s6(t))return new sQ({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(a.rp.id!==t)return new sQ({message:`The RP ID "${a.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new sQ({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new sQ({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new sQ({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}async function s9(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new s0("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new s0("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new sQ({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new sQ({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!s6(t))return new sQ({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new sQ({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new sQ({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new sQ({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}let s7={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},ne={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function nt(...e){let t=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),s={};for(let n of e)if(n)for(let e in n){let a=n[e];if(void 0!==a)if(Array.isArray(a))s[e]=a;else if(r(a))s[e]=a;else if(t(a)){let r=s[e];t(r)?s[e]=nt(r,a):s[e]=nt(a)}else s[e]=a}return s}class nr{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:s},n){var a,i,o,l,c;try{let{data:u,error:d}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!u)return{data:null,error:d};let h=null!=s?s:s1.createNewAbortSignal();if("create"===u.webauthn.type){let{user:e}=u.webauthn.credential_options.publicKey;if(!e.name)if(r)e.name=`${e.id}:${r}`;else{let t=(await this.client.getUser()).data.user,r=(null==(a=null==t?void 0:t.user_metadata)?void 0:a.name)||(null==t?void 0:t.email)||(null==t?void 0:t.id)||"User";e.name=`${e.id}:${r}`}e.displayName||(e.displayName=e.name)}switch(u.webauthn.type){case"create":{let t=(i=u.webauthn.credential_options.publicKey,o=null==n?void 0:n.create,nt(s7,i,o||{})),{data:r,error:s}=await s8({publicKey:t,signal:h});if(r)return{data:{factorId:e,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}case"request":{let t=(l=u.webauthn.credential_options.publicKey,c=null==n?void 0:n.request,nt(ne,l,c||{})),{data:r,error:s}=await s9(Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:t,signal:h}));if(r)return{data:{factorId:e,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}}}catch(e){if(eX(e))return{data:null,error:e};return{data:null,error:new e1("Unexpected error in challenge",e)}}}async _verify({challengeId:e,factorId:t,webauthn:r}){return this.client.mfa.verify({factorId:t,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:t,rpOrigins:r,signal:s}={}},n){if(!t)return{data:null,error:new eZ("rpId is required for WebAuthn authentication")};try{1;return{data:null,error:new e1("Browser does not support WebAuthn",null)}}catch(e){if(eX(e))return{data:null,error:e};return{data:null,error:new e1("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t,rpOrigins:r,signal:s}={}},n){if(!t)return{data:null,error:new eZ("rpId is required for WebAuthn registration")};try{1;return{data:null,error:new e1("Browser does not support WebAuthn",null)}}catch(e){if(eX(e))return{data:null,error:e};return{data:null,error:new e1("Unexpected error in register",e)}}}}if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"u">typeof self&&(self.globalThis=self)}let ns={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:r8,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},nn={},na=!1;class ni{get jwks(){var e,t;return null!=(t=null==(e=nn[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){nn[this.storageKey]=Object.assign(Object.assign({},nn[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=nn[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){nn[this.storageKey]=Object.assign(Object.assign({},nn[this.storageKey]),{cachedAt:e})}constructor(e){var t,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.lastRefreshFailure=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this._pendingInitNotifications=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;let s=Object.assign(Object.assign({},ns),e);this.storageKey=s.storageKey,this.instanceID=null!=(t=ni.nextInstanceID[this.storageKey])?t:0,ni.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!s.debug,"function"==typeof s.debug&&(this.logger=s.debug),this.instanceID,this.persistSession=s.persistSession,this.autoRefreshToken=s.autoRefreshToken,this.experimental=null!=(r=s.experimental)?r:{},this.admin=new sV({url:s.url,headers:s.headers,fetch:s.fetch,experimental:this.experimental}),this.url=s.url,this.headers=s.headers,this.fetch=sd(s.fetch),this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,this.throwOnError=s.throwOnError,this.lockAcquireTimeout=s.lockAcquireTimeout,null!=s.lock&&(this.lock=s.lock,na||(na=!0,console.warn(`${this._logPrefix()} The "lock" option is deprecated and will be removed in v3. The client now coordinates session refreshes without a lock, so most apps can drop the option. See https://github.com/supabase/supabase-js/blob/master/packages/core/auth-js/migrations/lockless-coordination.md`))),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new nr(this),recoveryCodes:{getStatus:this._getRecoveryCodesStatus.bind(this),generate:this._generateRecoveryCodes.bind(this),verify:this._verifyRecoveryCode.bind(this),regenerate:this._regenerateRecoveryCodes.bind(this),unenroll:this._unenrollRecoveryCodes.bind(this)}},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(s.storage?this.storage=s.storage:(this.memoryStorage={},this.storage=sY(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=sY(this.memoryStorage)),s.skipAutoInitialize||this.initialize().catch(e=>{this._debug("#initialize()","error",e)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${r6}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){var e;if(this.initializePromise)return await this.initializePromise;this._pendingInitNotifications=[],this.initializePromise=(async()=>null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())();let t=await this.initializePromise,r=null!=(e=this._pendingInitNotifications)?e:[];for(let e of(this._pendingInitNotifications=null,r))await this._notifyAllSubscribers(e.event,e.session,e.broadcast);return t}async _initialize(){try{return await this._recoverAndRefresh(),{error:null}}catch(e){if(eX(e))return this._returnResult({error:e});return this._returnResult({error:new e1("Unexpected error during initialization",e)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{let{data:n,error:a}=await sM(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:null!=(r=null==(t=null==e?void 0:e.options)?void 0:t.data)?r:{},gotrue_meta_security:{captcha_token:null==(s=null==e?void 0:e.options)?void 0:s.captchaToken}},xform:sz});if(a||!n)return this._returnResult({data:{user:null,session:null},error:a});let i=n.session,o=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",i)),this._returnResult({data:{user:o,session:i},error:null})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,r,s;let n=null;try{let a;if("email"in e){let{email:r,password:s,options:i}=e,o=null,l=null;"pkce"===this.flowType&&([o,l,n]=await this._getCodeChallengeAndMethod()),a=await sM(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(null==i?void 0:i.emailRedirectTo,n),body:{email:r,password:s,data:null!=(t=null==i?void 0:i.data)?t:{},gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:o,code_challenge_method:l},xform:sz})}else if("phone"in e){let{phone:t,password:n,options:i}=e;a=await sM(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!=(r=null==i?void 0:i.data)?r:{},channel:null!=(s=null==i?void 0:i.channel)?s:"sms",gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:sz})}else throw new e6("You must provide either an email or phone number and a password");let{data:i,error:o}=a;if(o||!i)return await sE(this.storage,this.storageKey,n),this._returnResult({data:{user:null,session:null},error:o});let l=i.session,c=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(e){if(await sE(this.storage,this.storageKey,n),eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithPassword(e){try{let t;if("email"in e){let{email:r,password:s,options:n}=e;t=await sM(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:sF})}else if("phone"in e){let{phone:r,password:s,options:n}=e;t=await sM(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:sF})}else throw new e6("You must provide either an email or phone number and a password");let{data:r,error:s}=t;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!r||!r.session||!r.user){let e=new e5;return this._returnResult({data:{user:null,session:null},error:e})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOAuth(e){var t,r,s,n;return await this._handleProviderSignIn(e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(r=e.options)?void 0:r.scopes,queryParams:null==(s=e.options)?void 0:s.queryParams,skipBrowserRedirect:null==(n=e.options)?void 0:n.skipBrowserRedirect})}async exchangeCodeForSession(e,t){return(await this.initializePromise,null!=this.lock)?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e,t)):this._exchangeCodeForSession(e,t)}async signInWithWeb3(e){let{chain:t}=e;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,r,s,n,a,i,o,l,c,u,d,h;let p,f;if("message"in e)p=e.message,f=e.signature;else{let{chain:u,wallet:d,statement:m,options:g}=e;if("object"!=typeof d||!(null==g?void 0:g.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");let b=new URL(null!=(t=null==g?void 0:g.url)?t:window.location.href),y=await d.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!y||0===y.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let w=sX(y[0]),v=null==(r=null==g?void 0:g.signInWithEthereum)?void 0:r.chainId;v||(v=parseInt(await d.request({method:"eth_chainId"}),16)),p=function(e){var t;let{chainId:r,domain:s,expirationTime:n,issuedAt:a=new Date,nonce:i,notBefore:o,requestId:l,resources:c,scheme:u,uri:d,version:h}=e;if(!Number.isInteger(r))throw Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(i&&i.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${i}`);if(!d)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==h)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${h}`);if(null==(t=e.statement)?void 0:t.includes("\n"))throw Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`);let p=sX(e.address),f=u?`${u}://${s}`:s,m=e.statement?`${e.statement}
84
86
  `:"",g=`${f} wants you to sign in with your Ethereum account:
85
87
  ${p}
86
88
 
@@ -93,7 +95,7 @@ Expiration Time: ${n.toISOString()}`),o&&(b+=`
93
95
  Not Before: ${o.toISOString()}`),l&&(b+=`
94
96
  Request ID: ${l}`),c){let e="\nResources:";for(let t of c){if(!t||"string"!=typeof t)throw Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${t}`);e+=`
95
97
  - ${t}`}b+=e}return`${g}
96
- ${b}`}({domain:b.host,address:w,statement:m,uri:b.href,version:"1",chainId:v,nonce:null==(s=null==g?void 0:g.signInWithEthereum)?void 0:s.nonce,issuedAt:null!=(a=null==(n=null==g?void 0:g.signInWithEthereum)?void 0:n.issuedAt)?a:new Date,expirationTime:null==(i=null==g?void 0:g.signInWithEthereum)?void 0:i.expirationTime,notBefore:null==(o=null==g?void 0:g.signInWithEthereum)?void 0:o.notBefore,requestId:null==(l=null==g?void 0:g.signInWithEthereum)?void 0:l.requestId,resources:null==(c=null==g?void 0:g.signInWithEthereum)?void 0:c.resources}),f=await d.request({method:"personal_sign",params:[(h=p,"0x"+Array.from(new TextEncoder().encode(h),e=>e.toString(16).padStart(2,"0")).join("")),w]})}try{let{data:t,error:r}=await sO(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:p,signature:f},(null==(u=e.options)?void 0:u.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:s$});if(r)throw r;if(!t||!t.session||!t.user){let e=new eY;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,r,s,n,a,i,o,l,c,u,d,h;let p,f;if("message"in e)p=e.message,f=e.signature;else{let{chain:d,wallet:h,statement:m,options:g}=e;if("object"!=typeof h||!(null==g?void 0:g.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");let b=new URL(null!=(t=null==g?void 0:g.url)?t:window.location.href);if("signIn"in h&&h.signIn){let e,t=await h.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==g?void 0:g.signInWithSolana),{version:"1",domain:b.host,uri:b.href}),m?{statement:m}:null));if(Array.isArray(t)&&t[0]&&"object"==typeof t[0])e=t[0];else if(t&&"object"==typeof t&&"signedMessage"in t&&"signature"in t)e=t;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in e&&"signature"in e&&("string"==typeof e.signedMessage||e.signedMessage instanceof Uint8Array)&&e.signature instanceof Uint8Array)p="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),f=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in h)||"function"!=typeof h.signMessage||!("publicKey"in h)||"object"!=typeof h||!h.publicKey||!("toBase58"in h.publicKey)||"function"!=typeof h.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=[`${b.host} wants you to sign in with your Solana account:`,h.publicKey.toBase58(),...m?["",m,""]:[""],"Version: 1",`URI: ${b.href}`,`Issued At: ${null!=(s=null==(r=null==g?void 0:g.signInWithSolana)?void 0:r.issuedAt)?s:new Date().toISOString()}`,...(null==(n=null==g?void 0:g.signInWithSolana)?void 0:n.notBefore)?[`Not Before: ${g.signInWithSolana.notBefore}`]:[],...(null==(a=null==g?void 0:g.signInWithSolana)?void 0:a.expirationTime)?[`Expiration Time: ${g.signInWithSolana.expirationTime}`]:[],...(null==(i=null==g?void 0:g.signInWithSolana)?void 0:i.chainId)?[`Chain ID: ${g.signInWithSolana.chainId}`]:[],...(null==(o=null==g?void 0:g.signInWithSolana)?void 0:o.nonce)?[`Nonce: ${g.signInWithSolana.nonce}`]:[],...(null==(l=null==g?void 0:g.signInWithSolana)?void 0:l.requestId)?[`Request ID: ${g.signInWithSolana.requestId}`]:[],...(null==(u=null==(c=null==g?void 0:g.signInWithSolana)?void 0:c.resources)?void 0:u.length)?["Resources",...g.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await h.signMessage(new TextEncoder().encode(p),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");f=e}}try{let{data:t,error:r}=await sO(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:se(f)},(null==(d=e.options)?void 0:d.captchaToken)?{gotrue_meta_security:{captcha_token:null==(h=e.options)?void 0:h.captchaToken}}:null),xform:s$});if(r)throw r;if(!t||!t.session||!t.user){let e=new eY;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e,t){let r=(null==t?void 0:t.flowId)!=null,s=r?sp(null==t?void 0:t.flowId):null;r&&!s&&this._debug("#_exchangeCodeForSession()","provided flowId is not a valid flow id",null==t?void 0:t.flowId);let{verifier:n,flowId:a}=r&&!s?{verifier:null,flowId:null}:await sy(this.storage,this.storageKey,s),[i,o]=(null!=n?n:"").split("/");try{if(!i&&"pkce"===this.flowType)throw new eQ;let{data:t,error:r}=await sO(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:i},xform:s$});if(await sw(this.storage,this.storageKey,a),r)throw r;if(!t||!t.session||!t.user){let e=new eY;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("recovery"===o?"PASSWORD_RECOVERY":"SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=o?o:null}),error:r})}catch(e){if(await sw(this.storage,this.storageKey,a),eF(e))return this._returnResult({data:{user:null,session:null,redirectType:null},error:e});throw e}}async signInWithIdToken(e){try{let{options:t,provider:r,token:s,access_token:n,nonce:a}=e,{data:i,error:o}=await sO(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:n,nonce:a,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:s$});if(o)return this._returnResult({data:{user:null,session:null},error:o});if(!i||!i.session||!i.user){let e=new eY;return this._returnResult({data:{user:null,session:null},error:e})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:i,error:o})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,r,s,n,a;let i=null;try{if("email"in e){let{email:s,options:n}=e,a=null,o=null;"pkce"===this.flowType&&([a,o,i]=await this._getCodeChallengeAndMethod());let{error:l}=await sO(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:null!=(t=null==n?void 0:n.data)?t:{},create_user:null==(r=null==n?void 0:n.shouldCreateUser)||r,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:a,code_challenge_method:o},redirectTo:this._maybeAppendFlowIdToRedirect(null==n?void 0:n.emailRedirectTo,i)});return this._returnResult({data:{user:null,session:null},error:l})}if("phone"in e){let{phone:t,options:r}=e,{data:i,error:o}=await sO(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!=(s=null==r?void 0:r.data)?s:{},create_user:null==(n=null==r?void 0:r.shouldCreateUser)||n,gotrue_meta_security:{captcha_token:null==r?void 0:r.captchaToken},channel:null!=(a=null==r?void 0:r.channel)?a:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:null==i?void 0:i.message_id},error:o})}throw new eX("You must provide either an email or phone number.")}catch(e){if(await sw(this.storage,this.storageKey,i),eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async verifyOtp(e){var t,r;try{let s,n;"options"in e&&(s=null==(t=e.options)?void 0:t.redirectTo,n=null==(r=e.options)?void 0:r.captchaToken);let{data:a,error:i}=await sO(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:n}}),redirectTo:s,xform:s$});if(i)throw i;if(!a)throw Error("An error occurred on token verification.");let o=a.session,l=a.user;return(null==o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,r,s;let n=null;try{let a=null,i=null;"pkce"===this.flowType&&([a,i,n]=await this._getCodeChallengeAndMethod());let o=await sO(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:this._maybeAppendFlowIdToRedirect(null==(t=e.options)?void 0:t.redirectTo,n)}),(null==(r=null==e?void 0:e.options)?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:i}),headers:this.headers,xform:sD});return null==(s=o.data)||s.url,this._returnResult(o)}catch(e){if(await sw(this.storage,this.storageKey,n),eF(e))return this._returnResult({data:null,error:e});throw e}}async reauthenticate(){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new eJ;let{error:s}=await sO(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){let t=null;try{let r=`${this.url}/resend`;if("email"in e){let{email:s,type:n,options:a}=e,i=null,o=null;"pkce"===this.flowType&&([i,o,t]=await this._getCodeChallengeAndMethod());let{error:l}=await sO(this.fetch,"POST",r,{headers:this.headers,body:{email:s,type:n,gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken},code_challenge:i,code_challenge_method:o},redirectTo:this._maybeAppendFlowIdToRedirect(null==a?void 0:a.emailRedirectTo,t)});return l&&await sw(this.storage,this.storageKey,t),this._returnResult({data:{user:null,session:null},error:l})}if("phone"in e){let{phone:t,type:s,options:n}=e,{data:a,error:i}=await sO(this.fetch,"POST",r,{headers:this.headers,body:{phone:t,type:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:i})}throw new eX("You must provide either an email or phone number and a type")}catch(e){if(await sw(this.storage,this.storageKey,t),eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async getSession(){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch(e){}})()),r}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){let e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),null==this.lock||this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let e=null,t=await sn(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let r=!!e.expires_at&&1e3*e.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r)return{data:{session:await this._hydrateSessionUser(e)},error:null};let{data:s,error:n}=await this._callRefreshToken(e.refresh_token);if(n){let e=await sn(this.storage,this.storageKey);if(e&&this._isValidSession(e)&&e.expires_at&&1e3*e.expires_at>Date.now())return this._returnResult({data:{session:await this._hydrateSessionUser(e)},error:null});return this._returnResult({data:{session:null},error:n})}return this._returnResult({data:{session:s},error:null})}finally{this._debug("#__loadSession()","end")}}async _hydrateSessionUser(e){if(this.userStorage){let t=await sn(this.userStorage,this.storageKey+"-user");e.user=(null==t?void 0:t.user)?t.user:sT()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){var t;let r={value:this.suppressGetSessionWarning};t=e.user,e.user=new Proxy(t,{get:(e,t,s)=>{if("__isInsecureUserWarningProxy"===t)return!0;if("symbol"==typeof t){let r=t.toString();if("Symbol(Symbol.toPrimitive)"===r||"Symbol(Symbol.toStringTag)"===r||"Symbol(util.inspect.custom)"===r||"Symbol(nodejs.util.inspect.custom)"===r)return Reflect.get(e,t,s)}return r.value||"string"!=typeof t||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),r.value=!0),Reflect.get(e,t,s)}}),r.value&&(this.suppressGetSessionWarning=!0)}return e}async getUser(e){let t;return e?await this._getUser(e):(await this.initializePromise,(t=null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):await this._getUser()).data.user&&(this.suppressGetSessionWarning=!0),t)}async _getUser(e){try{if(e)return await sO(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:sN});return await this._useSession(async e=>{var t,r,s;let{data:n,error:a}=e;if(a)throw a;return(null==(t=n.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await sO(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!=(s=null==(r=n.session)?void 0:r.access_token)?s:void 0,xform:sN}):{data:{user:null},error:new eJ}})}catch(e){if(eF(e))return eV(e)&&await this._removeSession(),this._returnResult({data:{user:null},error:e});throw e}}async updateUser(e,t={}){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,t)):await this._updateUser(e,t)}async _updateUser(e,t={}){let r=null;try{return await this._useSession(async s=>{let{data:n,error:a}=s;if(a)throw a;if(!n.session)throw new eJ;let i=n.session,o=null,l=null;"pkce"===this.flowType&&null!=e.email&&([o,l,r]=await this._getCodeChallengeAndMethod());let{data:c,error:u}=await sO(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(null==t?void 0:t.emailRedirectTo,r),body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:i.access_token,xform:sN});if(u)throw u;return i.user=c.user,await this._saveSession(i),await this._notifyAllSubscribers("USER_UPDATED",i),this._returnResult({data:{user:i.user},error:null})})}catch(e){if(await sw(this.storage,this.storageKey,r),eF(e))return this._returnResult({data:{user:null},error:e});throw e}}async setSession(e){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new eJ;let t=Date.now()/1e3,r=t,s=!0,n=null,{payload:a}=so(e.access_token);if(a.exp&&(s=(r=a.exp)<=t),s){let{data:t,error:r}=await this._callRefreshToken(e.refresh_token);if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!t)return{data:{user:null,session:null},error:null};n=t}else{let{data:s,error:a}=await this._getUser(e.access_token);if(a)return this._returnResult({data:{user:null,session:null},error:a});n={access_token:e.access_token,refresh_token:e.refresh_token,user:s.user,token_type:"bearer",expires_in:r-t,expires_at:r},await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)}return this._returnResult({data:{user:n.user,session:n},error:null})}catch(e){if(eF(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}}async refreshSession(e){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async t=>{var r;if(!e){let{data:s,error:n}=t;if(n)throw n;e=null!=(r=s.session)?r:void 0}if(!(null==e?void 0:e.refresh_token))throw new eJ;let{data:s,error:n}=await this._callRefreshToken(e.refresh_token);return n?this._returnResult({data:{user:null,session:null},error:n}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(e){if(eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){try{throw new eZ("No browser detected.")}catch(e){if(eF(e))return this._returnResult({data:{session:null,redirectType:null},error:e});throw e}}_isImplicitGrantCallback(e){return"function"==typeof this.detectSessionInUrl?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){if(!e.code)return!1;let t=sp(e[r2]);return!!(t&&await sn(this.storage,sf(this.storageKey,t)))||!!await sn(this.storage,`${this.storageKey}-code-verifier`)}async signOut(e={scope:"global"}){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let s=async()=>{await this._removeSession()},{data:n,error:a}=t;if(a&&!eV(a))return this._returnResult({error:a});let i=null==(r=n.session)?void 0:r.access_token;if(i){let{error:t}=await this.admin.signOut(i,e);if(t&&!(eH(t)&&(404===t.status||401===t.status||403===t.status)||eV(t)))return"others"!==e&&await s(),this._returnResult({error:t})}return"others"!==e&&await s(),this._returnResult({error:null})})}onAuthStateChange(e){let t=Symbol("auth-callback"),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>{await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(t)}):await this._emitInitialSession(t)})(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,s;try{let{data:{session:s},error:n}=t;if(n)throw n;await (null==(r=this.stateChangeEmitters.get(e))?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(t){if(await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),e3(t))return;eV(t)||e1(t)||eH(t)&&("refresh_token_not_found"===t.code||"refresh_token_already_used"===t.code||"session_expired"===t.code)?console.warn(t):console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null,n=null;"pkce"===this.flowType&&([r,s,n]=await this._getCodeChallengeAndMethod(!0));try{return await sO(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(t.redirectTo,n)})}catch(e){if(await sw(this.storage,this.storageKey,n),eF(e))return this._returnResult({data:null,error:e});throw e}}async getUserIdentities(){var e;try{let{data:t,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:null!=(e=t.user.identities)?e:[]},error:null})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){let t=null;try{let{data:r,error:s}=await this._useSession(async r=>{var s,n,a,i,o;let{data:l,error:c}=r;if(c)throw c;let{url:u,flowId:d}=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null==(s=e.options)?void 0:s.redirectTo,scopes:null==(n=e.options)?void 0:n.scopes,queryParams:null==(a=e.options)?void 0:a.queryParams,skipBrowserRedirect:!0});return t=d,await sO(this.fetch,"GET",u,{headers:this.headers,jwt:null!=(o=null==(i=l.session)?void 0:i.access_token)?o:void 0})});if(s)throw s;return this._returnResult({data:{provider:e.provider,url:null==r?void 0:r.url,flowId:t},error:null})}catch(r){if(eF(r))return this._returnResult({data:{provider:e.provider,url:null,flowId:t},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{let{error:s,data:{session:n}}=t;if(s)throw s;let{options:a,provider:i,token:o,access_token:l,nonce:c}=e,{data:u,error:d}=await sO(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:null!=(r=null==n?void 0:n.access_token)?r:void 0,body:{provider:i,id_token:o,access_token:l,nonce:c,link_identity:!0,gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:s$});if(d)return this._returnResult({data:{user:null,session:null},error:d});if(!u||!u.session||!u.user)return this._returnResult({data:{user:null,session:null},error:new eY});return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("USER_UPDATED",u.session)),this._returnResult({data:u,error:d})}catch(e){if(await sw(this.storage,this.storageKey,null),eF(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,s;let{data:n,error:a}=t;if(a)throw a;return await sO(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!=(s=null==(r=n.session)?void 0:r.access_token)?s:void 0})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){let t="#_refreshAccessToken()";this._debug(t,"begin");try{var r,s;let n=Date.now();return await (r=async r=>(r>0&&await sl(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await sO(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:s$})),s=(e,t)=>{let r=200*Math.pow(2,e);return t&&e1(t)&&Date.now()+r-n<3e4},new Promise((e,t)=>{(async()=>{for(let n=0;n<1/0;n++)try{let t=await r(n);if(!s(n,null))return void e(t)}catch(e){if(!s(n,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),eF(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}finally{this._debug(t,"end")}}_isValidSession(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let{url:r,flowId:s}=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),{data:{provider:e,url:r,flowId:s},error:null}}async _recoverAndRefresh(){var e,t;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let s=await sn(this.storage,this.storageKey);if(s&&this.userStorage){let t=await sn(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:s.user},await ss(this.userStorage,this.storageKey+"-user",t)),s.user=null!=(e=null==t?void 0:t.user)?e:sT()}else if(s&&!s.user&&!s.user){let e=await sn(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(s.user=e.user,await sa(this.storage,this.storageKey+"-user"),await ss(this.storage,this.storageKey,s)):s.user=sT()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),null!==s&&await this._removeSession();return}let n=(null!=(t=s.expires_at)?t:1/0)*1e3-Date.now()<9e4;if(this._debug(r,`session has${n?"":" not"} expired with margin of 90000s`),n){if(this.autoRefreshToken&&s.refresh_token){let{error:e}=await this._callRefreshToken(s.refresh_token);e&&(e3(e)?this._debug(r,"refresh discarded by commit guard",e):this._debug(r,"refresh failed",e))}}else if(s.user&&!0===s.user.__isUserNotAvailableProxy)try{let{data:e,error:t}=await this._getUser(s.access_token);!t&&(null==e?void 0:e.user)?(s.user=e.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(e){console.error("Error getting user data:",e),this._debug(r,"error getting user data, skipping SIGNED_IN notification",e)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(e){this._debug(r,"error",e),e1(e)?console.warn(e):console.error(e);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new eJ;if(this.refreshingDeferred)return this.refreshingDeferred.promise;if(this.lastRefreshFailure&&this.lastRefreshFailure.refreshToken===e&&Date.now()<this.lastRefreshFailure.expiresAt)return this._debug("#_callRefreshToken()","returning cached failure (cooldown active)"),this.lastRefreshFailure.result;let s="#_callRefreshToken()";this._debug(s,"begin");try{this.refreshingDeferred=new si,this.refreshingDeferred.promise.then(void 0,()=>{});let t=await sn(this.storage,this.storageKey),{data:r,error:n}=await this._refreshAccessToken(e);if(n)throw n;if(!r.session)throw new eJ;let a=await sn(this.storage,this.storageKey);if(null!==t&&(null===a||a.refresh_token!==t.refresh_token)){this._debug(s,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:a?"replaced":"cleared"});let e={data:null,error:new e2};return this.refreshingDeferred.resolve(e),e}let i=this._sessionRemovalEpoch;if(await this._saveSession(r.session),this._sessionRemovalEpoch!==i){this._debug(s,"commit guard (post-save): _removeSession ran during _saveSession, undoing write"),await sa(this.storage,this.storageKey),this.userStorage&&await sa(this.userStorage,this.storageKey+"-user");let e={data:null,error:new e2};return this.refreshingDeferred.resolve(e),e}await this._notifyAllSubscribers("TOKEN_REFRESHED",r.session);let o={data:r.session,error:null};return this.lastRefreshFailure=null,this.refreshingDeferred.resolve(o),o}catch(n){if(this._debug(s,"error",n),eF(n)){let r={data:null,error:n};if(!e1(n)){let e=await sn(this.storage,this.storageKey);(null==e?void 0:e.expires_at)&&1e3*e.expires_at>Date.now()?this._debug(s,"proactive refresh failed, access token still valid — preserving session"):await this._removeSession()}return this.lastRefreshFailure={refreshToken:e,result:r,expiresAt:Date.now()+6e4},null==(t=this.refreshingDeferred)||t.resolve(r),r}throw null==(r=this.refreshingDeferred)||r.reject(n),n}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){if(null!==this._pendingInitNotifications&&r)return void this._pendingInitNotifications.push({event:e,session:t,broadcast:r});let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let s=[],n=Array.from(this.stateChangeEmitters.values()).map(async r=>{try{await r.callback(e,t)}catch(e){s.push(e)}});if(await Promise.all(n),s.length>0){for(let e=0;e<s.length;e+=1)console.error(s[e]);throw s[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;let t=Object.assign({},e),r=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!r&&t.user&&await ss(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let s=sR(e);await ss(this.storage,this.storageKey,s)}else{let e=sR(t);await ss(this.storage,this.storageKey,e)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.lastRefreshFailure=null,this.suppressGetSessionWarning=!1,await sa(this.storage,this.storageKey),await sv(this.storage,this.storageKey),await sa(this.storage,this.storageKey+"-user"),this.userStorage&&await sa(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()"),this.visibilityChangedCallback,this.visibilityChangedCallback=null}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),3e4);this.autoRefreshTicker=e,e&&"object"==typeof e&&"function"==typeof e.unref?e.unref():"u">typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(e);let t=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=t,t&&"object"==typeof t&&"function"==typeof t.unref?t.unref():"u">typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(t)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);let t=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,t&&clearTimeout(t)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),null==(e=this.broadcastChannel)||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),null!=this.lock){try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof sz)this._debug("auto refresh token tick lock not available");else throw e}return}if(null!==this.refreshingDeferred)return void this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");try{let e=Date.now();try{await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){return this._debug("#_handleVisibilityChange()"),this.autoRefreshToken&&this.startAutoRefresh(),!1}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;if(this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,null!=this.lock)await this._acquireLock(this.lockAcquireTimeout,async()=>{"visible"!==document.visibilityState?this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting"):await this._recoverAndRefresh()});else{if("visible"!==document.visibilityState)return void this._debug(t,"visibilityState is no longer visible, skipping recovery");await this._recoverAndRefresh()}}else"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){let s=null==r?void 0:r.redirectTo,n=null,a=null,i=null;"pkce"===this.flowType&&([n,a,i]=await this._getCodeChallengeAndMethod(),s=this._maybeAppendFlowIdToRedirect(s,i));let o=[`provider=${encodeURIComponent(t)}`];if(s&&o.push(`redirect_to=${encodeURIComponent(s)}`),(null==r?void 0:r.scopes)&&o.push(`scopes=${encodeURIComponent(r.scopes)}`),null!=n&&null!=a){let e=new URLSearchParams({code_challenge:`${encodeURIComponent(n)}`,code_challenge_method:`${encodeURIComponent(a)}`});o.push(e.toString())}if(null==r?void 0:r.queryParams){let e=new URLSearchParams(r.queryParams);o.push(e.toString())}return(null==r?void 0:r.skipBrowserRedirect)&&o.push(`skip_http_redirect=${r.skipBrowserRedirect}`),{url:`${e}?${o.join("&")}`,flowId:i}}_maybeAppendFlowIdToRedirect(e,t){return e&&t&&this.experimental.appendPkceFlowIdToRedirects?function(e,t){let r=e.indexOf("#"),s=-1===r?e:e.slice(0,r),n=-1===r?"":e.slice(r),a=s.indexOf("?");if(-1!==a){let e=s.slice(0,a),t=s.slice(a+1).split("&").filter(e=>""!==e&&e!==r2&&!e.startsWith(`${r2}=`));s=t.length>0?`${e}?${t.join("&")}`:e}let i=s.includes("?")?"&":"?";return`${s}${i}${r2}=${encodeURIComponent(t)}${n}`}(e,t):null!=e?e:void 0}async _getCodeChallengeAndMethod(e=!1){return sk(this.storage,this.storageKey,e,e=>this._debug("#_getCodeChallengeAndMethod()","evicted oldest pending PKCE verifier slot",e))}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;return n?this._returnResult({data:null,error:n}):await sO(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;let{data:n,error:a}=t;if(a)return this._returnResult({data:null,error:a});let i=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:"totp"===e.factorType?{issuer:e.issuer}:{}),{data:o,error:l}=await sO(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:null==(r=null==n?void 0:n.session)?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):("totp"===e.factorType&&"totp"===o.type&&(null==(s=null==o?void 0:o.totp)?void 0:s.qr_code)&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),this._returnResult({data:o,error:null}))})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){let t=async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?sV(e.webauthn.credential_response):sY(e.webauthn.credential_response)})}:{code:e.code}),{data:i,error:o}=await sO(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});return o?this._returnResult({data:null,error:o}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),this._returnResult({data:i,error:o}))})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _challenge(e){let t=async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=await sO(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});if(a.error)return a;let{data:i}=a;if("webauthn"!==i.type)return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:sK(i.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:sJ(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _challengeAndVerify(e){let{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;let{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};let s={all:[],phone:[],totp:[],webauthn:[],recovery_code:[]};for(let r of null!=(e=null==t?void 0:t.factors)?e:[])s.all.push(r),"verified"===r.status&&r.factor_type in s&&Array.isArray(s[r.factor_type])&&s[r.factor_type].push(r);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(e){var t,r,s,n;if(e)try{let{payload:s}=so(e),n=null;s.aal&&(n=s.aal);let a=n,{data:{user:i},error:o}=await this.getUser(e);if(o)return this._returnResult({data:null,error:o});(null!=(r=null==(t=null==i?void 0:i.factors)?void 0:t.filter(e=>"verified"===e.status))?r:[]).length>0&&(a="aal2");let l=s.amr||[];return{data:{currentLevel:n,nextLevel:a,currentAuthenticationMethods:l},error:null}}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}let{data:{session:a},error:i}=await this.getSession();if(i)return this._returnResult({data:null,error:i});if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:o}=so(a.access_token),l=null;o.aal&&(l=o.aal);let c=l;return(null!=(n=null==(s=a.user.factors)?void 0:s.filter(e=>"verified"===e.status))?n:[]).length>0&&(c="aal2"),{data:{currentLevel:l,nextLevel:c,currentAuthenticationMethods:o.amr||[]},error:null}}async _getRecoveryCodesStatus(){sA(this.experimental);try{return await this._useSession(async e=>{var t;let{data:r,error:s}=e;if(s)return this._returnResult({data:null,error:s});let{data:n,error:a}=await sO(this.fetch,"GET",`${this.url}/factors/recovery-codes`,{headers:this.headers,jwt:null==(t=null==r?void 0:r.session)?void 0:t.access_token});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _generateRecoveryCodes(e){sA(this.experimental);try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let{data:a,error:i}=await sO(this.fetch,"POST",`${this.url}/factors/recovery-codes`,{body:(null==e?void 0:e.friendlyName)?{friendly_name:e.friendlyName}:void 0,headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _verifyRecoveryCode(e){sA(this.experimental);let t=async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let{data:a,error:i}=await sO(this.fetch,"POST",`${this.url}/factors/recovery-codes/verify`,{body:{code:e.code},headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});if(i)return this._returnResult({data:null,error:i});let o=Object.assign({expires_at:st(a.expires_in)},a);return await this._saveSession(o),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),this._returnResult({data:a,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _regenerateRecoveryCodes(){sA(this.experimental);try{return await this._useSession(async e=>{var t;let{data:r,error:s}=e;if(s)return this._returnResult({data:null,error:s});let{data:n,error:a}=await sO(this.fetch,"POST",`${this.url}/factors/recovery-codes/regenerate`,{headers:this.headers,jwt:null==(t=null==r?void 0:r.session)?void 0:t.access_token});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _unenrollRecoveryCodes(){sA(this.experimental);try{return await this._useSession(async e=>{var t;let{data:r,error:s}=e;if(s)return this._returnResult({data:null,error:s});let{data:n,error:a}=await sO(this.fetch,"DELETE",`${this.url}/factors/recovery-codes`,{headers:this.headers,jwt:null==(t=null==r?void 0:r.session)?void 0:t.access_token});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?await sO(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new eJ})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new eJ});let n=await sO(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url,n})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new eJ});let n=await sO(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url,n})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _listOAuthGrants(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;return r?this._returnResult({data:null,error:r}):t?await sO(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new eJ})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?(await sO(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new eJ})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(t=>t.kid===e);if(r)return r;let s=Date.now();if((r=this.jwks.keys.find(t=>t.kid===e))&&this.jwks_cached_at+6e5>s)return r;let{data:n,error:a}=await sO(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return n.keys&&0!==n.keys.length&&(this.jwks=n,this.jwks_cached_at=s,r=n.keys.find(t=>t.kid===e))?r:null}async getClaims(e,t={}){try{let n,a=e;if(!a){let{data:e,error:t}=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});a=e.session.access_token}let{header:i,payload:o,signature:l,raw:{header:c,payload:u}}=so(a);if(!(null==t?void 0:t.allowExpired))try{var r,s=o.exp;if(!s)throw Error("Missing exp claim");if(s<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}catch(e){throw new e5(e instanceof Error?e.message:"JWT validation failed")}let d=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!d){let{error:e}=await this.getUser(a);if(e)throw e;return{data:{claims:o,header:i,signature:l},error:null}}let h=function(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw Error("Invalid alg claim")}}(i.alg),p=await crypto.subtle.importKey("jwk",d,h,!0,["verify"]);if(!await crypto.subtle.verify(h,p,l,(r=`${c}.${u}`,n=[],!function(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){let t=(s-55296)*1024&65535;s=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(s,t)}}(r,e=>n.push(e)),new Uint8Array(n))))throw new e5("Invalid JWT signature");return{data:{claims:o,header:i,signature:l},error:null}}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async signInWithPasskey(e){var t,r,s,n;try{1;return this._returnResult({data:null,error:new eG("Browser does not support WebAuthn",null)})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async registerPasskey(e){var t,r;try{1;return this._returnResult({data:null,error:new eG("Browser does not support WebAuthn",null)})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyRegistration(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!t)return this._returnResult({data:null,error:new eJ});let{data:s,error:n}=await sO(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:t.access_token,body:{}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new eJ});let{data:n,error:a}=await sO(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyAuthentication(e){var t;try{let{data:r,error:s}=await sO(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:null==(t=null==e?void 0:e.options)?void 0:t.captchaToken}}});if(s)return this._returnResult({data:null,error:s});return this._returnResult({data:r,error:null})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyAuthentication(e){try{let{data:t,error:r}=await sO(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:s$});if(r)return this._returnResult({data:null,error:r});return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:t,error:null})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _listPasskeys(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!t)return this._returnResult({data:null,error:new eJ});let{data:s,error:n}=await sO(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new eJ});let{data:n,error:a}=await sO(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}async _deletePasskey(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new eJ});let{error:n}=await sO(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,noResolveJson:!0});return n?this._returnResult({data:null,error:n}):this._returnResult({data:null,error:null})})}catch(e){if(eF(e))return this._returnResult({data:null,error:e});throw e}}}s8.nextInstanceID={};let s9=s8,s7="";if("u">typeof Deno)s7="deno",s=null==(_=Deno.version)?void 0:_.deno;else if("u">typeof document)s7="web";else if("u">typeof navigator&&"ReactNative"===navigator.product)s7="react-native";else{s7="node";let e=globalThis.process;s=null==e||null==(S=e.version)?void 0:S.replace(/^v/,"")}let ne=[`runtime=${s7}`];s&&ne.push(`runtime-version=${s}`);let nt={headers:{"X-Client-Info":`supabase-js/2.117.3; ${ne.join("; ")}`}},nr={schema:"public"},ns={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},nn={},na={enabled:!1,respectSamplingDecision:!0};function ni(e){return(ni="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function no(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function nl(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?no(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=ni(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=ni(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==ni(s)?s:s+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):no(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let nc=e=>e.startsWith("sb_publishable_")||e.startsWith("sb_secret_"),nu=new Set,nd=(e,t,r,s,n,a)=>{let i=s?(...e)=>s(...e):(...e)=>fetch(...e),o=Headers,l=(null==n?void 0:n.enabled)===!0,c=(null==n?void 0:n.respectSamplingDecision)!==!1,u=l?function(e){let t=[];try{let r=new URL(e);t.push(r.hostname)}catch(e){}return t.push("*.supabase.co","*.supabase.in"),t.push("localhost","127.0.0.1","[::1]"),t}(t):null,d=!((null==a?void 0:a.omitApiKeyAsBearer)&&nc(e));return async(t,s)=>{let n=await r(),a=new o(null==s?void 0:s.headers);if(a.has("apikey")||a.set("apikey",e),!a.has("Authorization")){let t=null!=n?n:d?e:null;t&&a.set("Authorization",`Bearer ${t}`)}if(u){let e=function(e,t,r){let s=globalThis[e7];if(!s)return nh||(nh=!0,console.warn("@supabase/supabase-js: tracePropagation is enabled but the tracing runtime is not loaded, so trace headers will not be attached. Add `import '@supabase/supabase-js/tracing'` at your application entry point (requires the OpenTelemetry API package to be installed). The CDN/UMD build does not support trace propagation.")),null;if(!function(e,t){let r;if(!e||!t||0===t.length)return!1;if(e instanceof URL)r=e;else try{r=new URL(e)}catch(e){return!1}for(let e of t)try{if("string"==typeof e){if(function(e,t){if(t===e)return!0;if(t.startsWith("*.")){let r=t.slice(2);if(e.endsWith(r)&&(e===r||e.endsWith("."+r)))return!0}return!1}(r.hostname,e))return!0}else if(e instanceof RegExp){if(e.test(r.hostname))return!0}else if("function"==typeof e&&e(r))return!0}catch(e){continue}return!1}("string"==typeof e||e instanceof URL?e:e.url,t))return null;let n=s();if(!n||!n.traceparent){var a;if((null==n||null==(a=n.carrierKeys)?void 0:a.length)&&!np){np=!0;let e=n.carrierKeys.includes("sentry-trace")?" Sentry detected: set `propagateTraceparent: true` in Sentry.init() to emit it.":" Configure your tracing SDK to emit W3C trace context on outgoing requests.";console.warn(`@supabase/supabase-js: tracePropagation is enabled and a tracing SDK is active, but its propagator wrote [${n.carrierKeys.join(", ")}] and no W3C traceparent header, so trace headers will not be attached.`+e)}return null}if(r){let e=function(e){if(!e||"string"!=typeof e)return null;let t=e.split("-");if(4!==t.length)return null;let[r,s,n,a]=t;if(2!==r.length||32!==s.length||16!==n.length||2!==a.length)return null;let i=/^[0-9a-f]+$/i;return i.test(r)&&i.test(s)&&i.test(n)&&i.test(a)&&"00000000000000000000000000000000"!==s&&"0000000000000000"!==n?{version:r,traceId:s,parentId:n,traceFlags:a,isSampled:(1&parseInt(a,16))==1}:null}(n.traceparent);if(e&&!e.isSampled)return{traceparent:n.traceparent}}return n}(t,u,c);e&&(e.traceparent&&!a.has("traceparent")&&a.set("traceparent",e.traceparent),e.tracestate&&!a.has("tracestate")&&a.set("tracestate",e.tracestate),e.baggage&&!a.has("baggage")&&a.set("baggage",e.baggage))}return i(t,nl(nl({},s),{},{headers:a}))}},nh=!1,np=!1;function nf(e){return"boolean"==typeof e?{enabled:e}:e}let nm=!1;var ng=class extends s9{constructor(e){super(e)}},nb=class{constructor(e,t,r){var s,n,a;this.supabaseUrl=e,this.supabaseKey=t;let i=function(e){let t=null==e?void 0:e.trim();if(!t)throw Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(t.endsWith("/")?t:t+"/")}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}(e);if(!t)throw Error("supabaseKey is required.");(e=>{var t,r;if(!e.startsWith("sb_")||nc(e)||e.startsWith("sb_temp_"))return;let s=null!=(t=null==(r=e.match(/^sb_[a-zA-Z0-9]+_/))?void 0:r[0])?t:"unknown";nu.has(s)||(nu.add(s),console.warn("@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed and send this key as-is; if you see authentication errors you may need to upgrade @supabase/supabase-js to a version that recognizes this key type."))})(t),nm||"object"==typeof r&&null!==r&&"schema"in r&&void 0!==r.schema&&(nm=!0,console.warn('@supabase/supabase-js: The "schema" option must be nested under "db", e.g. createClient(url, key, { db: { schema: \'myschema\' } }). A top-level "schema" is ignored and queries go to the default schema.')),this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);let o=`sb-${i.hostname.split(".")[0]}-auth-token`,l=function(e,t){var r,s,n,a,i,o;let{db:l,auth:c,realtime:u,global:d}=e,{db:h,auth:p,realtime:f,global:m}=t,g=nf(e.tracePropagation),b=nf(t.tracePropagation),y={db:nl(nl({},h),l),auth:nl(nl({},p),c),realtime:nl(nl({},f),u),storage:{},global:nl(nl(nl({},m),d),{},{headers:nl(nl({},null!=(r=null==m?void 0:m.headers)?r:{}),null!=(s=null==d?void 0:d.headers)?s:{})}),tracePropagation:{enabled:null!=(n=null!=(a=null==g?void 0:g.enabled)?a:null==b?void 0:b.enabled)&&n,respectSamplingDecision:null==(i=null!=(o=null==g?void 0:g.respectSamplingDecision)?o:null==b?void 0:b.respectSamplingDecision)||i},accessToken:async()=>""};return e.accessToken?y.accessToken=e.accessToken:delete y.accessToken,y}(null!=r?r:{},{db:nr,realtime:nn,auth:nl(nl({},ns),{},{storageKey:o}),global:nt,tracePropagation:na});this.settings=l,this.storageKey=null!=(s=l.auth.storageKey)?s:"",this.headers=null!=(n=l.global.headers)?n:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!=(a=l.auth)?a:{},this.headers,l.global.fetch),this.fetch=nd(t,e,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation),this.functionsFetch=nd(t,e,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation,{omitApiKeyAsBearer:!0}),this.realtime=this._initRealtimeClient(nl({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new tk(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit,retry:l.db.retry}),this.storage=new rY(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new ta(this.functionsUrl.href,{headers:this.headers,customFetch:this.functionsFetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}getOpenApiSpec(){return this.rest.getOpenApiSpec()}rpc(e,t={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getSessionToken(){var e,t;if(this.accessToken)return await this.accessToken();let{data:r}=await this.auth.getSession();return null!=(e=null==(t=r.session)?void 0:t.access_token)?e:null}async _getAccessToken(){var e;return null!=(e=await this._getSessionToken())?e:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:a,flowType:i,lock:o,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:d,skipAutoInitialize:h},p,f){let m={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new ng({url:this.authUrl.href,headers:nl(nl({},m),p),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:n,flowType:i,lock:o,debug:l,throwOnError:c,experimental:u,fetch:f,lockAcquireTimeout:d,skipAutoInitialize:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new ro(this.realtimeUrl.href,nl(nl({},e),{},{params:nl(nl({},{apikey:this.supabaseKey}),null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e||"INITIAL_SESSION"===e)&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}};(function(){if(void 0!==globalThis.Deno)return!1;let e=globalThis.process;if(!e)return!1;let t=e.version;if(null==t)return!1;let r=t.match(/^v(\d+)\./);return!!r&&20>=parseInt(r[1],10)})()&&console.warn("⚠️ Node.js 20 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 22 or later. For more information, visit: https://github.com/orgs/supabase/discussions/45715");var ny=e.i(738458);let nw={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},nv=/^(.*)[.](0|[1-9][0-9]*)$/;function nk(e,t){if(e===t)return!0;let r=e.match(nv);return!!r&&r[1]===t}function n_(e,t,r){let s=r??3180,n=encodeURIComponent(t);if(n.length<=s)return[{name:e,value:t}];let a=[];for(;n.length>0;){let e=n.slice(0,s),t=e.lastIndexOf("%");t>s-3&&(e=e.slice(0,t));let r="";for(;e.length>0;)try{r=decodeURIComponent(e);break}catch(t){if(t instanceof URIError&&"%"===e.at(-3)&&e.length>3)e=e.slice(0,e.length-3);else throw t}a.push(r),n=n.slice(e.length)}return a.map((t,r)=>({name:`${e}.${r}`,value:t}))}async function nS(e,t){let r=await t(e);if(r)return r;let s=[];for(let r=0;;r++){let n=`${e}.${r}`,a=await t(n);if(!a)break;s.push(a)}return s.length>0?s.join(""):null}ny.parse,ny.serialize;let nx="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),nA=" \n\r=".split(""),nT=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<nA.length;t+=1)e[nA[t].charCodeAt(0)]=-2;for(let t=0;t<nx.length;t+=1)e[nx[t].charCodeAt(0)]=t;return e})();function nR(e){let t=[],r=0,s=0;if(function(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){let t=(s-55296)*1024&65535;s=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(s,t)}}(e,e=>{for(r=r<<8|e,s+=8;s>=6;){let e=r>>s-6&63;t.push(nx[e]),s-=6}}),s>0)for(r<<=6-s,s=6;s>=6;){let e=r>>s-6&63;t.push(nx[e]),s-=6}return t.join("")}let nE="base64-",nI=/-flow-[A-Za-z0-9_-]{8,64}-code-verifier$/;function nj(e){let t;if(!e.startsWith(nE))return e;try{t=function(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},n=0,a=0;for(let t=0;t<e.length;t+=1){let i=nT[e.charCodeAt(t)];if(i>-1)for(n=n<<6|i,a+=6;a>=8;)(function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}})(n>>a-8&255,s,r),a-=8;else if(-2===i)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}(e.substring(nE.length))}catch(e){return console.warn("@supabase/ssr: could not base64url-decode chunked cookie value, treating as absent. Cookie chunks may have been written partially across responses.",e),null}try{JSON.parse(t)}catch{return console.warn("@supabase/ssr: chunked cookie decoded to invalid JSON, treating as absent. This usually indicates that cookie chunks from different writes were combined (e.g. response committed before all Set-Cookie headers were sent)."),null}return t}async function nO({getAll:e,setAll:t,setItems:r,removedItems:s},n){let a=n.cookieEncoding,i=n.cookieOptions??null,o=await e([...r?Object.keys(r):[],...s?Object.keys(s):[]]),l=o?.map(({name:e})=>e)||[],c=new Map(o?.map(({name:e,value:t})=>[e,t])||[]),u=Object.keys(s).flatMap(e=>l.filter(t=>nk(t,e))),d=Object.keys(r).flatMap(e=>{let t=new Set(l.filter(t=>nk(t,e))),s=r[e];"base64url"===a&&(s=nE+nR(s));let n=n_(e,s);return n.forEach(e=>{t.delete(e.name)}),u.push(...t),n}).filter(({name:e,value:t})=>c.get(e)!==t),h=u.filter(e=>c.has(e)),p={...nw,...i,maxAge:0},f={...nw,...i,maxAge:nw.maxAge};delete p.name,delete f.name;let m=p.domain&&h.length>0?(()=>{let{domain:e,...t}=p;return t})():null;(0!==h.length||0!==d.length)&&await t([...m?h.map(e=>({name:e,value:"",options:m})):[],...h.map(e=>({name:e,value:"",options:p})),...d.map(({name:e,value:t})=>({name:e,value:t,options:f}))],{"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"})}let nC=new Set,n$=!1,nP=["@supabase/auth-helpers-nextjs","@supabase/auth-helpers-react","@supabase/auth-helpers-remix","@supabase/auth-helpers-sveltekit"];async function nN(){let e=await (0,e6.cookies)();return function(e,t,r){var s;if(!function(){if(n$||"u"<typeof process||!process.env?.npm_package_name)return;let e=process.env.npm_package_name;nP.includes(e)&&(n$=!0,console.warn(`
98
+ ${b}`}({domain:b.host,address:w,statement:m,uri:b.href,version:"1",chainId:v,nonce:null==(s=null==g?void 0:g.signInWithEthereum)?void 0:s.nonce,issuedAt:null!=(a=null==(n=null==g?void 0:g.signInWithEthereum)?void 0:n.issuedAt)?a:new Date,expirationTime:null==(i=null==g?void 0:g.signInWithEthereum)?void 0:i.expirationTime,notBefore:null==(o=null==g?void 0:g.signInWithEthereum)?void 0:o.notBefore,requestId:null==(l=null==g?void 0:g.signInWithEthereum)?void 0:l.requestId,resources:null==(c=null==g?void 0:g.signInWithEthereum)?void 0:c.resources}),f=await d.request({method:"personal_sign",params:[(h=p,"0x"+Array.from(new TextEncoder().encode(h),e=>e.toString(16).padStart(2,"0")).join("")),w]})}try{let{data:t,error:r}=await sM(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:p,signature:f},(null==(u=e.options)?void 0:u.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:sz});if(r)throw r;if(!t||!t.session||!t.user){let e=new e5;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,r,s,n,a,i,o,l,c,u,d,h;let p,f;if("message"in e)p=e.message,f=e.signature;else{let{chain:d,wallet:h,statement:m,options:g}=e;if("object"!=typeof h||!(null==g?void 0:g.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");let b=new URL(null!=(t=null==g?void 0:g.url)?t:window.location.href);if("signIn"in h&&h.signIn){let e,t=await h.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==g?void 0:g.signInWithSolana),{version:"1",domain:b.host,uri:b.href}),m?{statement:m}:null));if(Array.isArray(t)&&t[0]&&"object"==typeof t[0])e=t[0];else if(t&&"object"==typeof t&&"signedMessage"in t&&"signature"in t)e=t;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in e&&"signature"in e&&("string"==typeof e.signedMessage||e.signedMessage instanceof Uint8Array)&&e.signature instanceof Uint8Array)p="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),f=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in h)||"function"!=typeof h.signMessage||!("publicKey"in h)||"object"!=typeof h||!h.publicKey||!("toBase58"in h.publicKey)||"function"!=typeof h.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=[`${b.host} wants you to sign in with your Solana account:`,h.publicKey.toBase58(),...m?["",m,""]:[""],"Version: 1",`URI: ${b.href}`,`Issued At: ${null!=(s=null==(r=null==g?void 0:g.signInWithSolana)?void 0:r.issuedAt)?s:new Date().toISOString()}`,...(null==(n=null==g?void 0:g.signInWithSolana)?void 0:n.notBefore)?[`Not Before: ${g.signInWithSolana.notBefore}`]:[],...(null==(a=null==g?void 0:g.signInWithSolana)?void 0:a.expirationTime)?[`Expiration Time: ${g.signInWithSolana.expirationTime}`]:[],...(null==(i=null==g?void 0:g.signInWithSolana)?void 0:i.chainId)?[`Chain ID: ${g.signInWithSolana.chainId}`]:[],...(null==(o=null==g?void 0:g.signInWithSolana)?void 0:o.nonce)?[`Nonce: ${g.signInWithSolana.nonce}`]:[],...(null==(l=null==g?void 0:g.signInWithSolana)?void 0:l.requestId)?[`Request ID: ${g.signInWithSolana.requestId}`]:[],...(null==(u=null==(c=null==g?void 0:g.signInWithSolana)?void 0:c.resources)?void 0:u.length)?["Resources",...g.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await h.signMessage(new TextEncoder().encode(p),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");f=e}}try{let{data:t,error:r}=await sM(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:sc(f)},(null==(d=e.options)?void 0:d.captchaToken)?{gotrue_meta_security:{captcha_token:null==(h=e.options)?void 0:h.captchaToken}}:null),xform:sz});if(r)throw r;if(!t||!t.session||!t.user){let e=new e5;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e,t){let r=(null==t?void 0:t.flowId)!=null,s=r?s_(null==t?void 0:t.flowId):null;r&&!s&&this._debug("#_exchangeCodeForSession()","provided flowId is not a valid flow id",null==t?void 0:t.flowId);let{verifier:n,flowId:a}=r&&!s?{verifier:null,flowId:null}:await sR(this.storage,this.storageKey,s),[i,o]=(null!=n?n:"").split("/");try{if(!i&&"pkce"===this.flowType)throw new e9;let{data:t,error:r}=await sM(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:i},xform:sz});if(await sE(this.storage,this.storageKey,a),r)throw r;if(!t||!t.session||!t.user){let e=new e5;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("recovery"===o?"PASSWORD_RECOVERY":"SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=o?o:null}),error:r})}catch(e){if(await sE(this.storage,this.storageKey,a),eX(e))return this._returnResult({data:{user:null,session:null,redirectType:null},error:e});throw e}}async signInWithIdToken(e){try{let{options:t,provider:r,token:s,access_token:n,nonce:a}=e,{data:i,error:o}=await sM(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:n,nonce:a,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:sz});if(o)return this._returnResult({data:{user:null,session:null},error:o});if(!i||!i.session||!i.user){let e=new e5;return this._returnResult({data:{user:null,session:null},error:e})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:i,error:o})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,r,s,n,a;let i=null;try{if("email"in e){let{email:s,options:n}=e,a=null,o=null;"pkce"===this.flowType&&([a,o,i]=await this._getCodeChallengeAndMethod());let{error:l}=await sM(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:null!=(t=null==n?void 0:n.data)?t:{},create_user:null==(r=null==n?void 0:n.shouldCreateUser)||r,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:a,code_challenge_method:o},redirectTo:this._maybeAppendFlowIdToRedirect(null==n?void 0:n.emailRedirectTo,i)});return this._returnResult({data:{user:null,session:null},error:l})}if("phone"in e){let{phone:t,options:r}=e,{data:i,error:o}=await sM(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!=(s=null==r?void 0:r.data)?s:{},create_user:null==(n=null==r?void 0:r.shouldCreateUser)||n,gotrue_meta_security:{captcha_token:null==r?void 0:r.captchaToken},channel:null!=(a=null==r?void 0:r.channel)?a:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:null==i?void 0:i.message_id},error:o})}throw new e6("You must provide either an email or phone number.")}catch(e){if(await sE(this.storage,this.storageKey,i),eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async verifyOtp(e){var t,r;try{let s,n;"options"in e&&(s=null==(t=e.options)?void 0:t.redirectTo,n=null==(r=e.options)?void 0:r.captchaToken);let{data:a,error:i}=await sM(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:n}}),redirectTo:s,xform:sz});if(i)throw i;if(!a)throw Error("An error occurred on token verification.");let o=a.session,l=a.user;return(null==o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,r,s;let n=null;try{let a=null,i=null;"pkce"===this.flowType&&([a,i,n]=await this._getCodeChallengeAndMethod());let o=await sM(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:this._maybeAppendFlowIdToRedirect(null==(t=e.options)?void 0:t.redirectTo,n)}),(null==(r=null==e?void 0:e.options)?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:i}),headers:this.headers,xform:sH});return null==(s=o.data)||s.url,this._returnResult(o)}catch(e){if(await sE(this.storage,this.storageKey,n),eX(e))return this._returnResult({data:null,error:e});throw e}}async reauthenticate(){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new e3;let{error:s}=await sM(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){let t=null;try{let r=`${this.url}/resend`;if("email"in e){let{email:s,type:n,options:a}=e,i=null,o=null;"pkce"===this.flowType&&([i,o,t]=await this._getCodeChallengeAndMethod());let{error:l}=await sM(this.fetch,"POST",r,{headers:this.headers,body:{email:s,type:n,gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken},code_challenge:i,code_challenge_method:o},redirectTo:this._maybeAppendFlowIdToRedirect(null==a?void 0:a.emailRedirectTo,t)});return l&&await sE(this.storage,this.storageKey,t),this._returnResult({data:{user:null,session:null},error:l})}if("phone"in e){let{phone:t,type:s,options:n}=e,{data:a,error:i}=await sM(this.fetch,"POST",r,{headers:this.headers,body:{phone:t,type:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:i})}throw new e6("You must provide either an email or phone number and a type")}catch(e){if(await sE(this.storage,this.storageKey,t),eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async getSession(){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch(e){}})()),r}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){let e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),null==this.lock||this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let e=null,t=await sp(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let r=!!e.expires_at&&1e3*e.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r)return{data:{session:await this._hydrateSessionUser(e)},error:null};let{data:s,error:n}=await this._callRefreshToken(e.refresh_token);if(n){let e=await sp(this.storage,this.storageKey);if(e&&this._isValidSession(e)&&e.expires_at&&1e3*e.expires_at>Date.now())return this._returnResult({data:{session:await this._hydrateSessionUser(e)},error:null});return this._returnResult({data:{session:null},error:n})}return this._returnResult({data:{session:s},error:null})}finally{this._debug("#__loadSession()","end")}}async _hydrateSessionUser(e){if(this.userStorage){let t=await sp(this.userStorage,this.storageKey+"-user");e.user=(null==t?void 0:t.user)?t.user:sN()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){var t;let r={value:this.suppressGetSessionWarning};t=e.user,e.user=new Proxy(t,{get:(e,t,s)=>{if("__isInsecureUserWarningProxy"===t)return!0;if("symbol"==typeof t){let r=t.toString();if("Symbol(Symbol.toPrimitive)"===r||"Symbol(Symbol.toStringTag)"===r||"Symbol(util.inspect.custom)"===r||"Symbol(nodejs.util.inspect.custom)"===r)return Reflect.get(e,t,s)}return r.value||"string"!=typeof t||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),r.value=!0),Reflect.get(e,t,s)}}),r.value&&(this.suppressGetSessionWarning=!0)}return e}async getUser(e){let t;return e?await this._getUser(e):(await this.initializePromise,(t=null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):await this._getUser()).data.user&&(this.suppressGetSessionWarning=!0),t)}async _getUser(e){try{if(e)return await sM(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:sW});return await this._useSession(async e=>{var t,r,s;let{data:n,error:a}=e;if(a)throw a;return(null==(t=n.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await sM(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!=(s=null==(r=n.session)?void 0:r.access_token)?s:void 0,xform:sW}):{data:{user:null},error:new e3}})}catch(e){if(eX(e))return e4(e)&&await this._removeSession(),this._returnResult({data:{user:null},error:e});throw e}}async updateUser(e,t={}){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,t)):await this._updateUser(e,t)}async _updateUser(e,t={}){let r=null;try{return await this._useSession(async s=>{let{data:n,error:a}=s;if(a)throw a;if(!n.session)throw new e3;let i=n.session,o=null,l=null;"pkce"===this.flowType&&null!=e.email&&([o,l,r]=await this._getCodeChallengeAndMethod());let{data:c,error:u}=await sM(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(null==t?void 0:t.emailRedirectTo,r),body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:i.access_token,xform:sW});if(u)throw u;return i.user=c.user,await this._saveSession(i),await this._notifyAllSubscribers("USER_UPDATED",i),this._returnResult({data:{user:i.user},error:null})})}catch(e){if(await sE(this.storage,this.storageKey,r),eX(e))return this._returnResult({data:{user:null},error:e});throw e}}async setSession(e){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new e3;let t=Date.now()/1e3,r=t,s=!0,n=null,{payload:a}=sg(e.access_token);if(a.exp&&(s=(r=a.exp)<=t),s){let{data:t,error:r}=await this._callRefreshToken(e.refresh_token);if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!t)return{data:{user:null,session:null},error:null};n=t}else{let{data:s,error:a}=await this._getUser(e.access_token);if(a)return this._returnResult({data:{user:null,session:null},error:a});n={access_token:e.access_token,refresh_token:e.refresh_token,user:s.user,token_type:"bearer",expires_in:r-t,expires_at:r},await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)}return this._returnResult({data:{user:n.user,session:n},error:null})}catch(e){if(eX(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}}async refreshSession(e){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async t=>{var r;if(!e){let{data:s,error:n}=t;if(n)throw n;e=null!=(r=s.session)?r:void 0}if(!(null==e?void 0:e.refresh_token))throw new e3;let{data:s,error:n}=await this._callRefreshToken(e.refresh_token);return n?this._returnResult({data:{user:null,session:null},error:n}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(e){if(eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){try{throw new e8("No browser detected.")}catch(e){if(eX(e))return this._returnResult({data:{session:null,redirectType:null},error:e});throw e}}_isImplicitGrantCallback(e){return"function"==typeof this.detectSessionInUrl?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){if(!e.code)return!1;let t=s_(e[st]);return!!(t&&await sp(this.storage,sS(this.storageKey,t)))||!!await sp(this.storage,`${this.storageKey}-code-verifier`)}async signOut(e={scope:"global"}){return(await this.initializePromise,null!=this.lock)?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let s=async()=>{await this._removeSession()},{data:n,error:a}=t;if(a&&!e4(a))return this._returnResult({error:a});let i=null==(r=n.session)?void 0:r.access_token;if(i){let{error:t}=await this.admin.signOut(i,e);if(t&&!(e0(t)&&(404===t.status||401===t.status||403===t.status)||e4(t)))return"others"!==e&&await s(),this._returnResult({error:t})}return"others"!==e&&await s(),this._returnResult({error:null})})}onAuthStateChange(e){let t=Symbol("auth-callback"),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>{await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(t)}):await this._emitInitialSession(t)})(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,s;try{let{data:{session:s},error:n}=t;if(n)throw n;await (null==(r=this.stateChangeEmitters.get(e))?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(t){if(await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),tr(t))return;e4(t)||te(t)||e0(t)&&("refresh_token_not_found"===t.code||"refresh_token_already_used"===t.code||"session_expired"===t.code)?console.warn(t):console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null,n=null;"pkce"===this.flowType&&([r,s,n]=await this._getCodeChallengeAndMethod(!0));try{return await sM(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(t.redirectTo,n)})}catch(e){if(await sE(this.storage,this.storageKey,n),eX(e))return this._returnResult({data:null,error:e});throw e}}async getUserIdentities(){var e;try{let{data:t,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:null!=(e=t.user.identities)?e:[]},error:null})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){let t=null;try{let{data:r,error:s}=await this._useSession(async r=>{var s,n,a,i,o;let{data:l,error:c}=r;if(c)throw c;let{url:u,flowId:d}=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null==(s=e.options)?void 0:s.redirectTo,scopes:null==(n=e.options)?void 0:n.scopes,queryParams:null==(a=e.options)?void 0:a.queryParams,skipBrowserRedirect:!0});return t=d,await sM(this.fetch,"GET",u,{headers:this.headers,jwt:null!=(o=null==(i=l.session)?void 0:i.access_token)?o:void 0})});if(s)throw s;return this._returnResult({data:{provider:e.provider,url:null==r?void 0:r.url,flowId:t},error:null})}catch(r){if(eX(r))return this._returnResult({data:{provider:e.provider,url:null,flowId:t},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{let{error:s,data:{session:n}}=t;if(s)throw s;let{options:a,provider:i,token:o,access_token:l,nonce:c}=e,{data:u,error:d}=await sM(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:null!=(r=null==n?void 0:n.access_token)?r:void 0,body:{provider:i,id_token:o,access_token:l,nonce:c,link_identity:!0,gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:sz});if(d)return this._returnResult({data:{user:null,session:null},error:d});if(!u||!u.session||!u.user)return this._returnResult({data:{user:null,session:null},error:new e5});return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("USER_UPDATED",u.session)),this._returnResult({data:u,error:d})}catch(e){if(await sE(this.storage,this.storageKey,null),eX(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,s;let{data:n,error:a}=t;if(a)throw a;return await sM(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!=(s=null==(r=n.session)?void 0:r.access_token)?s:void 0})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){let t="#_refreshAccessToken()";this._debug(t,"begin");try{var r,s;let n=Date.now();return await (r=async r=>(r>0&&await sb(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await sM(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:sz})),s=(e,t)=>{let r=200*Math.pow(2,e);return t&&te(t)&&Date.now()+r-n<3e4},new Promise((e,t)=>{(async()=>{for(let n=0;n<1/0;n++)try{let t=await r(n);if(!s(n,null))return void e(t)}catch(e){if(!s(n,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),eX(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}finally{this._debug(t,"end")}}_isValidSession(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let{url:r,flowId:s}=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),{data:{provider:e,url:r,flowId:s},error:null}}async _recoverAndRefresh(){var e,t;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let s=await sp(this.storage,this.storageKey);if(s&&this.userStorage){let t=await sp(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:s.user},await sh(this.userStorage,this.storageKey+"-user",t)),s.user=null!=(e=null==t?void 0:t.user)?e:sN()}else if(s&&!s.user&&!s.user){let e=await sp(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(s.user=e.user,await sf(this.storage,this.storageKey+"-user"),await sh(this.storage,this.storageKey,s)):s.user=sN()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),null!==s&&await this._removeSession();return}let n=(null!=(t=s.expires_at)?t:1/0)*1e3-Date.now()<9e4;if(this._debug(r,`session has${n?"":" not"} expired with margin of 90000s`),n){if(this.autoRefreshToken&&s.refresh_token){let{error:e}=await this._callRefreshToken(s.refresh_token);e&&(tr(e)?this._debug(r,"refresh discarded by commit guard",e):this._debug(r,"refresh failed",e))}}else if(s.user&&!0===s.user.__isUserNotAvailableProxy)try{let{data:e,error:t}=await this._getUser(s.access_token);!t&&(null==e?void 0:e.user)?(s.user=e.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(e){console.error("Error getting user data:",e),this._debug(r,"error getting user data, skipping SIGNED_IN notification",e)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(e){this._debug(r,"error",e),te(e)?console.warn(e):console.error(e);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new e3;if(this.refreshingDeferred)return this.refreshingDeferred.promise;if(this.lastRefreshFailure&&this.lastRefreshFailure.refreshToken===e&&Date.now()<this.lastRefreshFailure.expiresAt)return this._debug("#_callRefreshToken()","returning cached failure (cooldown active)"),this.lastRefreshFailure.result;let s="#_callRefreshToken()";this._debug(s,"begin");try{this.refreshingDeferred=new sm,this.refreshingDeferred.promise.then(void 0,()=>{});let t=await sp(this.storage,this.storageKey),{data:r,error:n}=await this._refreshAccessToken(e);if(n)throw n;if(!r.session)throw new e3;let a=await sp(this.storage,this.storageKey);if(null!==t&&(null===a||a.refresh_token!==t.refresh_token)){this._debug(s,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:a?"replaced":"cleared"});let e={data:null,error:new tt};return this.refreshingDeferred.resolve(e),e}let i=this._sessionRemovalEpoch;if(await this._saveSession(r.session),this._sessionRemovalEpoch!==i){this._debug(s,"commit guard (post-save): _removeSession ran during _saveSession, undoing write"),await sf(this.storage,this.storageKey),this.userStorage&&await sf(this.userStorage,this.storageKey+"-user");let e={data:null,error:new tt};return this.refreshingDeferred.resolve(e),e}await this._notifyAllSubscribers("TOKEN_REFRESHED",r.session);let o={data:r.session,error:null};return this.lastRefreshFailure=null,this.refreshingDeferred.resolve(o),o}catch(n){if(this._debug(s,"error",n),eX(n)){let r={data:null,error:n};if(!te(n)){let e=await sp(this.storage,this.storageKey);(null==e?void 0:e.expires_at)&&1e3*e.expires_at>Date.now()?this._debug(s,"proactive refresh failed, access token still valid — preserving session"):await this._removeSession()}return this.lastRefreshFailure={refreshToken:e,result:r,expiresAt:Date.now()+6e4},null==(t=this.refreshingDeferred)||t.resolve(r),r}throw null==(r=this.refreshingDeferred)||r.reject(n),n}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){if(null!==this._pendingInitNotifications&&r)return void this._pendingInitNotifications.push({event:e,session:t,broadcast:r});let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let s=[],n=Array.from(this.stateChangeEmitters.values()).map(async r=>{try{await r.callback(e,t)}catch(e){s.push(e)}});if(await Promise.all(n),s.length>0){for(let e=0;e<s.length;e+=1)console.error(s[e]);throw s[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;let t=Object.assign({},e),r=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!r&&t.user&&await sh(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let s=sD(e);await sh(this.storage,this.storageKey,s)}else{let e=sD(t);await sh(this.storage,this.storageKey,e)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.lastRefreshFailure=null,this.suppressGetSessionWarning=!1,await sf(this.storage,this.storageKey),await sI(this.storage,this.storageKey),await sf(this.storage,this.storageKey+"-user"),this.userStorage&&await sf(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()"),this.visibilityChangedCallback,this.visibilityChangedCallback=null}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),3e4);this.autoRefreshTicker=e,e&&"object"==typeof e&&"function"==typeof e.unref?e.unref():"u">typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(e);let t=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=t,t&&"object"==typeof t&&"function"==typeof t.unref?t.unref():"u">typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(t)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);let t=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,t&&clearTimeout(t)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),null==(e=this.broadcastChannel)||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),null!=this.lock){try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof sZ)this._debug("auto refresh token tick lock not available");else throw e}return}if(null!==this.refreshingDeferred)return void this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");try{let e=Date.now();try{await this._useSession(async t=>{let{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){return this._debug("#_handleVisibilityChange()"),this.autoRefreshToken&&this.startAutoRefresh(),!1}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;if(this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,null!=this.lock)await this._acquireLock(this.lockAcquireTimeout,async()=>{"visible"!==document.visibilityState?this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting"):await this._recoverAndRefresh()});else{if("visible"!==document.visibilityState)return void this._debug(t,"visibilityState is no longer visible, skipping recovery");await this._recoverAndRefresh()}}else"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){let s=null==r?void 0:r.redirectTo,n=null,a=null,i=null;"pkce"===this.flowType&&([n,a,i]=await this._getCodeChallengeAndMethod(),s=this._maybeAppendFlowIdToRedirect(s,i));let o=[`provider=${encodeURIComponent(t)}`];if(s&&o.push(`redirect_to=${encodeURIComponent(s)}`),(null==r?void 0:r.scopes)&&o.push(`scopes=${encodeURIComponent(r.scopes)}`),null!=n&&null!=a){let e=new URLSearchParams({code_challenge:`${encodeURIComponent(n)}`,code_challenge_method:`${encodeURIComponent(a)}`});o.push(e.toString())}if(null==r?void 0:r.queryParams){let e=new URLSearchParams(r.queryParams);o.push(e.toString())}return(null==r?void 0:r.skipBrowserRedirect)&&o.push(`skip_http_redirect=${r.skipBrowserRedirect}`),{url:`${e}?${o.join("&")}`,flowId:i}}_maybeAppendFlowIdToRedirect(e,t){return e&&t&&this.experimental.appendPkceFlowIdToRedirects?function(e,t){let r=e.indexOf("#"),s=-1===r?e:e.slice(0,r),n=-1===r?"":e.slice(r),a=s.indexOf("?");if(-1!==a){let e=s.slice(0,a),t=s.slice(a+1).split("&").filter(e=>""!==e&&e!==st&&!e.startsWith(`${st}=`));s=t.length>0?`${e}?${t.join("&")}`:e}let i=s.includes("?")?"&":"?";return`${s}${i}${st}=${encodeURIComponent(t)}${n}`}(e,t):null!=e?e:void 0}async _getCodeChallengeAndMethod(e=!1){return sj(this.storage,this.storageKey,e,e=>this._debug("#_getCodeChallengeAndMethod()","evicted oldest pending PKCE verifier slot",e))}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;return n?this._returnResult({data:null,error:n}):await sM(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;let{data:n,error:a}=t;if(a)return this._returnResult({data:null,error:a});let i=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:"totp"===e.factorType?{issuer:e.issuer}:{}),{data:o,error:l}=await sM(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:null==(r=null==n?void 0:n.session)?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):("totp"===e.factorType&&"totp"===o.type&&(null==(s=null==o?void 0:o.totp)?void 0:s.qr_code)&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),this._returnResult({data:o,error:null}))})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){let t=async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?s4(e.webauthn.credential_response):s5(e.webauthn.credential_response)})}:{code:e.code}),{data:i,error:o}=await sM(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});return o?this._returnResult({data:null,error:o}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),this._returnResult({data:i,error:o}))})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _challenge(e){let t=async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=await sM(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});if(a.error)return a;let{data:i}=a;if("webauthn"!==i.type)return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:s2(i.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:s3(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _challengeAndVerify(e){let{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;let{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};let s={all:[],phone:[],totp:[],webauthn:[],recovery_code:[]};for(let r of null!=(e=null==t?void 0:t.factors)?e:[])s.all.push(r),"verified"===r.status&&r.factor_type in s&&Array.isArray(s[r.factor_type])&&s[r.factor_type].push(r);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(e){var t,r,s,n;if(e)try{let{payload:s}=sg(e),n=null;s.aal&&(n=s.aal);let a=n,{data:{user:i},error:o}=await this.getUser(e);if(o)return this._returnResult({data:null,error:o});(null!=(r=null==(t=null==i?void 0:i.factors)?void 0:t.filter(e=>"verified"===e.status))?r:[]).length>0&&(a="aal2");let l=s.amr||[];return{data:{currentLevel:n,nextLevel:a,currentAuthenticationMethods:l},error:null}}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}let{data:{session:a},error:i}=await this.getSession();if(i)return this._returnResult({data:null,error:i});if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:o}=sg(a.access_token),l=null;o.aal&&(l=o.aal);let c=l;return(null!=(n=null==(s=a.user.factors)?void 0:s.filter(e=>"verified"===e.status))?n:[]).length>0&&(c="aal2"),{data:{currentLevel:l,nextLevel:c,currentAuthenticationMethods:o.amr||[]},error:null}}async _getRecoveryCodesStatus(){sP(this.experimental);try{return await this._useSession(async e=>{var t;let{data:r,error:s}=e;if(s)return this._returnResult({data:null,error:s});let{data:n,error:a}=await sM(this.fetch,"GET",`${this.url}/factors/recovery-codes`,{headers:this.headers,jwt:null==(t=null==r?void 0:r.session)?void 0:t.access_token});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _generateRecoveryCodes(e){sP(this.experimental);try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let{data:a,error:i}=await sM(this.fetch,"POST",`${this.url}/factors/recovery-codes`,{body:(null==e?void 0:e.friendlyName)?{friendly_name:e.friendlyName}:void 0,headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _verifyRecoveryCode(e){sP(this.experimental);let t=async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});let{data:a,error:i}=await sM(this.fetch,"POST",`${this.url}/factors/recovery-codes/verify`,{body:{code:e.code},headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token});if(i)return this._returnResult({data:null,error:i});let o=Object.assign({expires_at:su(a.expires_in)},a);return await this._saveSession(o),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),this._returnResult({data:a,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _regenerateRecoveryCodes(){sP(this.experimental);try{return await this._useSession(async e=>{var t;let{data:r,error:s}=e;if(s)return this._returnResult({data:null,error:s});let{data:n,error:a}=await sM(this.fetch,"POST",`${this.url}/factors/recovery-codes/regenerate`,{headers:this.headers,jwt:null==(t=null==r?void 0:r.session)?void 0:t.access_token});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _unenrollRecoveryCodes(){sP(this.experimental);try{return await this._useSession(async e=>{var t;let{data:r,error:s}=e;if(s)return this._returnResult({data:null,error:s});let{data:n,error:a}=await sM(this.fetch,"DELETE",`${this.url}/factors/recovery-codes`,{headers:this.headers,jwt:null==(t=null==r?void 0:r.session)?void 0:t.access_token});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?await sM(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new e3})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new e3});let n=await sM(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url,n})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new e3});let n=await sM(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url,n})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _listOAuthGrants(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;return r?this._returnResult({data:null,error:r}):t?await sM(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new e3})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?(await sM(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new e3})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(t=>t.kid===e);if(r)return r;let s=Date.now();if((r=this.jwks.keys.find(t=>t.kid===e))&&this.jwks_cached_at+6e5>s)return r;let{data:n,error:a}=await sM(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return n.keys&&0!==n.keys.length&&(this.jwks=n,this.jwks_cached_at=s,r=n.keys.find(t=>t.kid===e))?r:null}async getClaims(e,t={}){try{let n,a=e;if(!a){let{data:e,error:t}=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});a=e.session.access_token}let{header:i,payload:o,signature:l,raw:{header:c,payload:u}}=sg(a);if(!(null==t?void 0:t.allowExpired))try{var r,s=o.exp;if(!s)throw Error("Missing exp claim");if(s<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}catch(e){throw new tn(e instanceof Error?e.message:"JWT validation failed")}let d=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!d){let{error:e}=await this.getUser(a);if(e)throw e;return{data:{claims:o,header:i,signature:l},error:null}}let h=function(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw Error("Invalid alg claim")}}(i.alg),p=await crypto.subtle.importKey("jwk",d,h,!0,["verify"]);if(!await crypto.subtle.verify(h,p,l,(r=`${c}.${u}`,n=[],!function(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){let t=(s-55296)*1024&65535;s=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(s,t)}}(r,e=>n.push(e)),new Uint8Array(n))))throw new tn("Invalid JWT signature");return{data:{claims:o,header:i,signature:l},error:null}}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async signInWithPasskey(e){var t,r,s,n;try{1;return this._returnResult({data:null,error:new e1("Browser does not support WebAuthn",null)})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async registerPasskey(e){var t,r;try{1;return this._returnResult({data:null,error:new e1("Browser does not support WebAuthn",null)})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyRegistration(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!t)return this._returnResult({data:null,error:new e3});let{data:s,error:n}=await sM(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:t.access_token,body:{}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new e3});let{data:n,error:a}=await sM(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyAuthentication(e){var t;try{let{data:r,error:s}=await sM(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:null==(t=null==e?void 0:e.options)?void 0:t.captchaToken}}});if(s)return this._returnResult({data:null,error:s});return this._returnResult({data:r,error:null})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyAuthentication(e){try{let{data:t,error:r}=await sM(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:sz});if(r)return this._returnResult({data:null,error:r});return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:t,error:null})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _listPasskeys(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!t)return this._returnResult({data:null,error:new e3});let{data:s,error:n}=await sM(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new e3});let{data:n,error:a}=await sM(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}async _deletePasskey(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new e3});let{error:n}=await sM(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,noResolveJson:!0});return n?this._returnResult({data:null,error:n}):this._returnResult({data:null,error:null})})}catch(e){if(eX(e))return this._returnResult({data:null,error:e});throw e}}}ni.nextInstanceID={};let no=ni,nl="";if("u">typeof Deno)nl="deno",s=null==(_=Deno.version)?void 0:_.deno;else if("u">typeof document)nl="web";else if("u">typeof navigator&&"ReactNative"===navigator.product)nl="react-native";else{nl="node";let e=globalThis.process;s=null==e||null==(S=e.version)?void 0:S.replace(/^v/,"")}let nc=[`runtime=${nl}`];s&&nc.push(`runtime-version=${s}`);let nu={headers:{"X-Client-Info":`supabase-js/2.117.3; ${nc.join("; ")}`}},nd={schema:"public"},nh={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},np={},nf={enabled:!1,respectSamplingDecision:!0};function nm(e){return(nm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ng(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function nb(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ng(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=nm(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=nm(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==nm(s)?s:s+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ng(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let ny=e=>e.startsWith("sb_publishable_")||e.startsWith("sb_secret_"),nw=new Set,nv=(e,t,r,s,n,a)=>{let i=s?(...e)=>s(...e):(...e)=>fetch(...e),o=Headers,l=(null==n?void 0:n.enabled)===!0,c=(null==n?void 0:n.respectSamplingDecision)!==!1,u=l?function(e){let t=[];try{let r=new URL(e);t.push(r.hostname)}catch(e){}return t.push("*.supabase.co","*.supabase.in"),t.push("localhost","127.0.0.1","[::1]"),t}(t):null,d=!((null==a?void 0:a.omitApiKeyAsBearer)&&ny(e));return async(t,s)=>{let n=await r(),a=new o(null==s?void 0:s.headers);if(a.has("apikey")||a.set("apikey",e),!a.has("Authorization")){let t=null!=n?n:d?e:null;t&&a.set("Authorization",`Bearer ${t}`)}if(u){let e=function(e,t,r){let s=globalThis[tl];if(!s)return nk||(nk=!0,console.warn("@supabase/supabase-js: tracePropagation is enabled but the tracing runtime is not loaded, so trace headers will not be attached. Add `import '@supabase/supabase-js/tracing'` at your application entry point (requires the OpenTelemetry API package to be installed). The CDN/UMD build does not support trace propagation.")),null;if(!function(e,t){let r;if(!e||!t||0===t.length)return!1;if(e instanceof URL)r=e;else try{r=new URL(e)}catch(e){return!1}for(let e of t)try{if("string"==typeof e){if(function(e,t){if(t===e)return!0;if(t.startsWith("*.")){let r=t.slice(2);if(e.endsWith(r)&&(e===r||e.endsWith("."+r)))return!0}return!1}(r.hostname,e))return!0}else if(e instanceof RegExp){if(e.test(r.hostname))return!0}else if("function"==typeof e&&e(r))return!0}catch(e){continue}return!1}("string"==typeof e||e instanceof URL?e:e.url,t))return null;let n=s();if(!n||!n.traceparent){var a;if((null==n||null==(a=n.carrierKeys)?void 0:a.length)&&!n_){n_=!0;let e=n.carrierKeys.includes("sentry-trace")?" Sentry detected: set `propagateTraceparent: true` in Sentry.init() to emit it.":" Configure your tracing SDK to emit W3C trace context on outgoing requests.";console.warn(`@supabase/supabase-js: tracePropagation is enabled and a tracing SDK is active, but its propagator wrote [${n.carrierKeys.join(", ")}] and no W3C traceparent header, so trace headers will not be attached.`+e)}return null}if(r){let e=function(e){if(!e||"string"!=typeof e)return null;let t=e.split("-");if(4!==t.length)return null;let[r,s,n,a]=t;if(2!==r.length||32!==s.length||16!==n.length||2!==a.length)return null;let i=/^[0-9a-f]+$/i;return i.test(r)&&i.test(s)&&i.test(n)&&i.test(a)&&"00000000000000000000000000000000"!==s&&"0000000000000000"!==n?{version:r,traceId:s,parentId:n,traceFlags:a,isSampled:(1&parseInt(a,16))==1}:null}(n.traceparent);if(e&&!e.isSampled)return{traceparent:n.traceparent}}return n}(t,u,c);e&&(e.traceparent&&!a.has("traceparent")&&a.set("traceparent",e.traceparent),e.tracestate&&!a.has("tracestate")&&a.set("tracestate",e.tracestate),e.baggage&&!a.has("baggage")&&a.set("baggage",e.baggage))}return i(t,nb(nb({},s),{},{headers:a}))}},nk=!1,n_=!1;function nS(e){return"boolean"==typeof e?{enabled:e}:e}let nx=!1;var nA=class extends no{constructor(e){super(e)}},nT=class{constructor(e,t,r){var s,n,a;this.supabaseUrl=e,this.supabaseKey=t;let i=function(e){let t=null==e?void 0:e.trim();if(!t)throw Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(t.endsWith("/")?t:t+"/")}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}(e);if(!t)throw Error("supabaseKey is required.");(e=>{var t,r;if(!e.startsWith("sb_")||ny(e)||e.startsWith("sb_temp_"))return;let s=null!=(t=null==(r=e.match(/^sb_[a-zA-Z0-9]+_/))?void 0:r[0])?t:"unknown";nw.has(s)||(nw.add(s),console.warn("@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed and send this key as-is; if you see authentication errors you may need to upgrade @supabase/supabase-js to a version that recognizes this key type."))})(t),nx||"object"==typeof r&&null!==r&&"schema"in r&&void 0!==r.schema&&(nx=!0,console.warn('@supabase/supabase-js: The "schema" option must be nested under "db", e.g. createClient(url, key, { db: { schema: \'myschema\' } }). A top-level "schema" is ignored and queries go to the default schema.')),this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);let o=`sb-${i.hostname.split(".")[0]}-auth-token`,l=function(e,t){var r,s,n,a,i,o;let{db:l,auth:c,realtime:u,global:d}=e,{db:h,auth:p,realtime:f,global:m}=t,g=nS(e.tracePropagation),b=nS(t.tracePropagation),y={db:nb(nb({},h),l),auth:nb(nb({},p),c),realtime:nb(nb({},f),u),storage:{},global:nb(nb(nb({},m),d),{},{headers:nb(nb({},null!=(r=null==m?void 0:m.headers)?r:{}),null!=(s=null==d?void 0:d.headers)?s:{})}),tracePropagation:{enabled:null!=(n=null!=(a=null==g?void 0:g.enabled)?a:null==b?void 0:b.enabled)&&n,respectSamplingDecision:null==(i=null!=(o=null==g?void 0:g.respectSamplingDecision)?o:null==b?void 0:b.respectSamplingDecision)||i},accessToken:async()=>""};return e.accessToken?y.accessToken=e.accessToken:delete y.accessToken,y}(null!=r?r:{},{db:nd,realtime:np,auth:nb(nb({},nh),{},{storageKey:o}),global:nu,tracePropagation:nf});this.settings=l,this.storageKey=null!=(s=l.auth.storageKey)?s:"",this.headers=null!=(n=l.global.headers)?n:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!=(a=l.auth)?a:{},this.headers,l.global.fetch),this.fetch=nv(t,e,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation),this.functionsFetch=nv(t,e,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation,{omitApiKeyAsBearer:!0}),this.realtime=this._initRealtimeClient(nb({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new tj(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit,retry:l.db.retry}),this.storage=new r5(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new tf(this.functionsUrl.href,{headers:this.headers,customFetch:this.functionsFetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}getOpenApiSpec(){return this.rest.getOpenApiSpec()}rpc(e,t={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getSessionToken(){var e,t;if(this.accessToken)return await this.accessToken();let{data:r}=await this.auth.getSession();return null!=(e=null==(t=r.session)?void 0:t.access_token)?e:null}async _getAccessToken(){var e;return null!=(e=await this._getSessionToken())?e:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:a,flowType:i,lock:o,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:d,skipAutoInitialize:h},p,f){let m={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new nA({url:this.authUrl.href,headers:nb(nb({},m),p),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:n,flowType:i,lock:o,debug:l,throwOnError:c,experimental:u,fetch:f,lockAcquireTimeout:d,skipAutoInitialize:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new rg(this.realtimeUrl.href,nb(nb({},e),{},{params:nb(nb({},{apikey:this.supabaseKey}),null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e||"INITIAL_SESSION"===e)&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}};(function(){if(void 0!==globalThis.Deno)return!1;let e=globalThis.process;if(!e)return!1;let t=e.version;if(null==t)return!1;let r=t.match(/^v(\d+)\./);return!!r&&20>=parseInt(r[1],10)})()&&console.warn("⚠️ Node.js 20 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 22 or later. For more information, visit: https://github.com/orgs/supabase/discussions/45715");var nR=e.i(738458);let nE={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},nI=/^(.*)[.](0|[1-9][0-9]*)$/;function nj(e,t){if(e===t)return!0;let r=e.match(nI);return!!r&&r[1]===t}function nO(e,t,r){let s=r??3180,n=encodeURIComponent(t);if(n.length<=s)return[{name:e,value:t}];let a=[];for(;n.length>0;){let e=n.slice(0,s),t=e.lastIndexOf("%");t>s-3&&(e=e.slice(0,t));let r="";for(;e.length>0;)try{r=decodeURIComponent(e);break}catch(t){if(t instanceof URIError&&"%"===e.at(-3)&&e.length>3)e=e.slice(0,e.length-3);else throw t}a.push(r),n=n.slice(e.length)}return a.map((t,r)=>({name:`${e}.${r}`,value:t}))}async function n$(e,t){let r=await t(e);if(r)return r;let s=[];for(let r=0;;r++){let n=`${e}.${r}`,a=await t(n);if(!a)break;s.push(a)}return s.length>0?s.join(""):null}nR.parse,nR.serialize;let nC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),nP=" \n\r=".split(""),nN=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<nP.length;t+=1)e[nP[t].charCodeAt(0)]=-2;for(let t=0;t<nC.length;t+=1)e[nC[t].charCodeAt(0)]=t;return e})();function nD(e){let t=[],r=0,s=0;if(function(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){let t=(s-55296)*1024&65535;s=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(s,t)}}(e,e=>{for(r=r<<8|e,s+=8;s>=6;){let e=r>>s-6&63;t.push(nC[e]),s-=6}}),s>0)for(r<<=6-s,s=6;s>=6;){let e=r>>s-6&63;t.push(nC[e]),s-=6}return t.join("")}let nL="base64-",nU=/-flow-[A-Za-z0-9_-]{8,64}-code-verifier$/;function nq(e){let t;if(!e.startsWith(nL))return e;try{t=function(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},n=0,a=0;for(let t=0;t<e.length;t+=1){let i=nN[e.charCodeAt(t)];if(i>-1)for(n=n<<6|i,a+=6;a>=8;)(function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}})(n>>a-8&255,s,r),a-=8;else if(-2===i)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}(e.substring(nL.length))}catch(e){return console.warn("@supabase/ssr: could not base64url-decode chunked cookie value, treating as absent. Cookie chunks may have been written partially across responses.",e),null}try{JSON.parse(t)}catch{return console.warn("@supabase/ssr: chunked cookie decoded to invalid JSON, treating as absent. This usually indicates that cookie chunks from different writes were combined (e.g. response committed before all Set-Cookie headers were sent)."),null}return t}async function nM({getAll:e,setAll:t,setItems:r,removedItems:s},n){let a=n.cookieEncoding,i=n.cookieOptions??null,o=await e([...r?Object.keys(r):[],...s?Object.keys(s):[]]),l=o?.map(({name:e})=>e)||[],c=new Map(o?.map(({name:e,value:t})=>[e,t])||[]),u=Object.keys(s).flatMap(e=>l.filter(t=>nj(t,e))),d=Object.keys(r).flatMap(e=>{let t=new Set(l.filter(t=>nj(t,e))),s=r[e];"base64url"===a&&(s=nL+nD(s));let n=nO(e,s);return n.forEach(e=>{t.delete(e.name)}),u.push(...t),n}).filter(({name:e,value:t})=>c.get(e)!==t),h=u.filter(e=>c.has(e)),p={...nE,...i,maxAge:0},f={...nE,...i,maxAge:nE.maxAge};delete p.name,delete f.name;let m=p.domain&&h.length>0?(()=>{let{domain:e,...t}=p;return t})():null;(0!==h.length||0!==d.length)&&await t([...m?h.map(e=>({name:e,value:"",options:m})):[],...h.map(e=>({name:e,value:"",options:p})),...d.map(({name:e,value:t})=>({name:e,value:t,options:f}))],{"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"})}let nB=new Set,nz=!1,nF=["@supabase/auth-helpers-nextjs","@supabase/auth-helpers-react","@supabase/auth-helpers-remix","@supabase/auth-helpers-sveltekit"];async function nW(){let e=await (0,ta.cookies)();return function(e,t,r){var s;if(!function(){if(nz||"u"<typeof process||!process.env?.npm_package_name)return;let e=process.env.npm_package_name;nF.includes(e)&&(nz=!0,console.warn(`
97
99
  ╔════════════════════════════════════════════════════════════════════════════╗
98
100
  ║ ⚠️ IMPORTANT: Package Consolidation Notice ║
99
101
  ║ ║
@@ -115,6 +117,6 @@ ${b}`}({domain:b.host,address:w,statement:m,uri:b.href,version:"1",chainId:v,non
115
117
 
116
118
  Check your Supabase project's API settings to find these values
117
119
 
118
- https://supabase.com/dashboard/project/_/settings/api`);r?.auth?.storage&&(s="@supabase/ssr: createServerClient always manages the session via cookies, so the `auth.storage` option you passed is ignored. If you want to source the session from somewhere other than the request cookies, use @supabase/supabase-js's createClient directly with your own `storage` instead.",nC.has(s)||(nC.add(s),console.warn(s)));let{storage:n,getAll:a,setAll:i,setItems:o,removedItems:l}=function(e,t){let r,s,n=e.cookies&&("get"in e.cookies||"getAll"in e.cookies)?e.cookies:null,a=e.cookieEncoding,i={},o={};if(n)if("get"in n){let e=async e=>{let t=e.flatMap(e=>[e,...Array.from({length:5}).map((t,r)=>`${e}.${r}`)]),r=[];for(let e=0;e<t.length;e+=1){let s=await n.get(t[e]);(s||"string"==typeof s)&&r.push({name:t[e],value:s})}return r};if(r=async t=>await e(t),"set"in n&&"remove"in n)s=async e=>{for(let t=0;t<e.length;t+=1){let{name:r,value:s,options:a}=e[t];s?await n.set(r,s,a):await n.remove(r,a)}};else if(t)s=async()=>{console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)")}else if("getAll"in n)if(r=async()=>await n.getAll(),"setAll"in n)s=n.setAll;else if(t)s=async()=>{console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).`);else if(t||1)if(t)throw Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");else r=()=>[],s=()=>{throw Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed")};else r=()=>{let e;return Object.keys(e=(0,ny.parse)(document.cookie)).map(t=>({name:t,value:e[t]??""}))},s=e=>{e.forEach(({name:e,value:t,options:r})=>{document.cookie=(0,ny.serialize)(e,t,r)})};if(!t)return{getAll:r,setAll:s,setItems:i,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await r([e]),s=await nS(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?nj(s):null},setItem:async(t,n)=>{let i=await r([t]),o=new Set((i?.map(({name:e})=>e)||[]).filter(e=>nk(e,t))),l=n;"base64url"===a&&(l=nE+nR(n));let c=n_(t,l);c.forEach(({name:e})=>{o.delete(e)});let u={...nw,...e?.cookieOptions,maxAge:0},d={...nw,...e?.cookieOptions,maxAge:nw.maxAge};delete u.name,delete d.name;let h=u.domain?(()=>{let{domain:e,...t}=u;return t})():null,p=[...h?[...o].map(e=>({name:e,value:"",options:h})):[],...[...o].map(e=>({name:e,value:"",options:u})),...c.map(({name:e,value:t})=>({name:e,value:t,options:d}))];p.length>0&&await s(p,{})},removeItem:async t=>{let n=await r([t]),a=(n?.map(({name:e})=>e)||[]).filter(e=>nk(e,t));if(0===a.length)return;let i={...nw,...e?.cookieOptions,maxAge:0};delete i.name;let o=i.domain?(()=>{let{domain:e,...t}=i;return t})():null,l=[...o?a.map(e=>({name:e,value:"",options:o})):[],...a.map(e=>({name:e,value:"",options:i}))];await s(l,{})}}};let l=s,c=!1;return{getAll:r,setAll:s=async(e,t)=>{let r=!c&&Object.keys(t).length>0;await l(e,r?t:{}),r&&(c=!0)},setItems:i,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof i[e])return i[e];if(o[e])return null;let t=await r([e]),s=await nS(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?"string"!=typeof s?s:nj(s):null},setItem:async(t,n)=>{t.endsWith("-code-verifier")&&await nO({getAll:r,setAll:s,setItems:{[t]:n},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:a}),i[t]=n,delete o[t]},removeItem:async t=>{(nI.test(t)||t.endsWith("-flows-code-verifier"))&&await nO({getAll:r,setAll:s,setItems:{},removedItems:{[t]:!0}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:a}),delete i[t],o[t]=!0}}}}({...r,cookieEncoding:r?.cookieEncoding??"base64url"},!0),c=new nb(e,t,{...r,global:{...r?.global,headers:{...r?.global?.headers,"X-Client-Info":"supabase-ssr/0.12.7 createServerClient"}},auth:{...r?.cookieOptions?.name?{storageKey:r.cookieOptions.name}:null,...r?.auth,flowType:"pkce",autoRefreshToken:!1,detectSessionInUrl:!1,persistSession:!0,skipAutoInitialize:!0,storage:n,...r?.cookies&&"encode"in r.cookies&&"tokens-only"===r.cookies.encode?{userStorage:r?.auth?.userStorage??function(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}()}:null}});return c.auth.onAuthStateChange(async e=>{(Object.keys(o).length>0||Object.keys(l).length>0)&&("SIGNED_IN"===e||"TOKEN_REFRESHED"===e||"USER_UPDATED"===e||"PASSWORD_RECOVERY"===e||"SIGNED_OUT"===e||"MFA_CHALLENGE_VERIFIED"===e)&&await nO({getAll:a,setAll:i,setItems:o,removedItems:l},{cookieOptions:r?.cookieOptions??null,cookieEncoding:r?.cookieEncoding??"base64url"})}),c}(process.env.NEXT_PUBLIC_SUPABASE_URL,process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,{cookieOptions:function(e=process.env){return{httpOnly:!0,secure:"production"===e.NODE_ENV,sameSite:"lax",path:"/"}}(),cookies:{getAll:()=>e.getAll(),setAll(t){try{t.forEach(({name:t,value:r,options:s})=>e.set(t,r,s))}catch{}}}})}let nD={async sessionUser(){let e=await nN(),{data:t}=await e.auth.getClaims(),r=t?.claims;return r&&"string"==typeof r.sub?{userId:r.sub,email:String(r.email??"").toLowerCase(),aal:"string"==typeof r.aal?r.aal:void 0}:null},async hasVerifiedFactor(){let e=await nN(),{data:t,error:r}=await e.auth.mfa.listFactors();if(eV(r))return"signed-out";if(r||!t)throw Error("mfa factors unavailable");return t.totp.some(e=>"verified"===e.status)},async signOut(e){let t=await nN();e?await t.auth.signOut({scope:e}):await t.auth.signOut()}},nL={async sessionUser(){let e=(await (0,e6.cookies)()).get(e8.J)?.value;return e?(0,e9.readLocalSession)(e):null},async hasVerifiedFactor(e){let[t]=await (0,T.db)().select({confirmedAt:E.localUsers.totpConfirmedAt}).from(E.localUsers).where((0,x.eq)(E.localUsers.id,e)).limit(1);return t?null!==t.confirmedAt:"signed-out"},async signOut(e="global"){let t=await (0,e6.cookies)(),r=t.get(e8.J)?.value;if(r){if("global"===e){let e=await (0,e9.localSessionUserId)(r);e&&await (0,e9.revokeAllLocalSessions)(e)}await (0,e9.revokeLocalSession)(r)}(0,e8.N)(t)}},nU={async sessionUser(){let[{readDemoVisitor:t},{demoUserId:r}]=await Promise.all([e.A(672170),e.A(152310)]),s=await t();return s?{userId:r(s.seed),email:s.email,aal:"aal2",mustChangePassword:!1}:null},hasVerifiedFactor:async()=>!0,async signOut(){let{clearDemoCookie:t}=await e.A(729873);t(await (0,e6.cookies)())}};function nq(){let e=(0,ej.mode)();return"selfhost"===e?nL:"demo"===e?nU:nD}var nM=e.i(144430);let nB=(0,j.cache)(async()=>nq().sessionUser());async function nz(e,t){var r;if("aal2"===t)return"ok";let s=await nq().hasVerifiedFactor(e.userId);return"signed-out"===s?"signed-out":"aal2"===(r={role:e.role,aal:t,hasVerifiedFactor:s}).aal?"ok":r.hasVerifiedFactor?"challenge":"owner"===r.role||"operator"===r.role?"setup":"ok"}let nF=(0,j.cache)(async e=>{let[t]=await (0,T.db)().select({id:E.members.id,userId:E.members.userId,email:E.members.email,role:E.members.role}).from(E.members).where((0,x.eq)(E.members.userId,e)).limit(1);return t??null});async function nW(e){let[t]=await (0,T.db)().select().from(E.invites).where((0,x.and)((0,x.eq)(E.invites.email,e),(0,x.isNull)(E.invites.acceptedAt),(0,x.gt)(E.invites.expiresAt,new Date))).limit(1);return t??null}async function nH(){let e=await nB();e||(0,eB.redirect)("/signin");let t=await nF(e.userId);if(t){let r=await nz(t,e.aal);return"signed-out"===r&&(0,eB.redirect)("/auth/session-ended"),"setup"===r&&(0,eB.redirect)("/mfa/setup"),"challenge"===r&&(0,eB.redirect)("/mfa"),e.mustChangePassword&&(0,eB.redirect)("/account/password"),t}e.email&&await nW(e.email)&&(0,eB.redirect)("/invite"),(0,eB.redirect)("/auth/not-member")}async function nG(e){let t=await nH();return{ok:(0,nM.L)(t.role,e),member:t}}var nK=e.i(396918),nJ=e.i(518581);let nV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function nY(e,t=new Date){let r=null,s=new Map;if(void 0!==e){if(!nV.test(e))return[];let[t]=await (0,T.db)().select({name:E.resources.name}).from(E.resources).where((0,x.eq)(E.resources.id,e)).limit(1);r=t?[e,t.name]:[e],t&&(s=new Map([[e,t.name]]))}let n=new Date(t.getTime()-2592e6),a=(0,x.and)((0,x.isNull)(nJ.c.dismissedAt),(0,x.gte)(nJ.c.createdAt,n)),i=await (0,T.db)().select({id:nJ.c.id,appId:nJ.c.appId,severity:nJ.c.severity,title:nJ.c.title,body:nJ.c.body,source:nJ.c.source,client:nJ.c.client,model:nJ.c.model,createdAt:nJ.c.createdAt}).from(nJ.c).where(r?(0,x.and)(a,(0,x.inArray)(nJ.c.appId,r)):a).orderBy((0,nK.desc)(nJ.c.createdAt)).limit(20);if(void 0===e){let e=[...new Set(i.map(e=>e.appId).filter(e=>!!e&&nV.test(e)))];e.length&&(s=new Map((await (0,T.db)().select({id:E.resources.id,name:E.resources.name}).from(E.resources).where((0,x.inArray)(E.resources.id,e)).limit(e.length)).map(e=>[e.id,e.name])))}return i.map(e=>{let t;return{id:e.id,appId:e.appId,appName:e.appId?s.get(e.appId)??((t=e.appId,nV.test(t))?null:e.appId):null,severity:e.severity,title:e.title,body:e.body,from:e.client||e.source,model:e.model,at:e.createdAt}})}var nX={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};let nZ=(e,t,r,s)=>{let n=(0,j.forwardRef)(({color:r="currentColor",size:n=24,stroke:a=2,title:i,className:o,children:l,...c},u)=>(0,j.createElement)("svg",{ref:u,...nX[e],width:n,height:n,className:["tabler-icon",`tabler-icon-${t}`,o].filter(Boolean).join(" "),..."filled"===e?{fill:r}:{strokeWidth:a,stroke:r},...c},[i&&(0,j.createElement)("title",{key:"svg-title"},i),...s.map(([e,t])=>(0,j.createElement)(e,t)),...Array.isArray(l)?l:[l]]));return n.displayName=`${r}`,n},nQ=nZ("outline","notes","Notes",[["path",{d:"M5 5a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -14",key:"svg-0"}],["path",{d:"M9 7l6 0",key:"svg-1"}],["path",{d:"M9 11l6 0",key:"svg-2"}],["path",{d:"M9 15l4 0",key:"svg-3"}]]);var n0=e.i(639307);let n1=/(\*\*[^*\n]+\*\*|`[^`\n]+`|\[[^\]\n]+\]\([^)\s]+\))/g;function n2(e){let t=[];for(let r of e.split(n1))if(r)if(r.startsWith("**")&&r.endsWith("**")&&r.length>4)t.push({t:"b",text:r.slice(2,-2)});else if(r.startsWith("`")&&r.endsWith("`")&&r.length>2)t.push({t:"code",text:r.slice(1,-1)});else{let e=/^\[([^\]]+)\]\(([^)\s]+)\)$/.exec(r);e?t.push({t:"text",text:/^https?:\/\//i.test(e[2])?`${e[1]} (${e[2]})`:e[1]}):t.push({t:"text",text:r})}return t}function n3({list:e}){return(0,eM.jsx)(eM.Fragment,{children:e.map((e,t)=>(0,eM.jsx)(j.Fragment,{children:"b"===e.t?(0,eM.jsx)("b",{className:"font-medium",children:(0,eM.jsx)(n0.MaskedText,{text:e.text})}):"code"===e.t?(0,eM.jsx)("code",{className:"rounded bg-sunken px-1 font-mono text-[12.5px]",children:e.text}):(0,eM.jsx)(n0.MaskedText,{text:e.text})},t))})}function n4({b:e}){if("p"===e.t)return(0,eM.jsx)("p",{className:"mt-1.5 first:mt-0",children:(0,eM.jsx)(n3,{list:e.inl})});if("h"===e.t)return(0,eM.jsx)("p",{className:"mt-2 font-medium first:mt-0",children:(0,eM.jsx)(n3,{list:e.inl})});if("code"===e.t)return(0,eM.jsx)("pre",{className:"mt-1.5 overflow-x-auto rounded-md border border-line bg-sunken p-2 font-mono text-[12.5px]",children:e.text});let t="ul"===e.t?"ul":"ol";return(0,eM.jsx)(t,{className:`mt-1.5 space-y-0.5 pl-5 ${"ul"===e.t?"list-disc":"list-decimal"}`,children:e.items.map((e,t)=>(0,eM.jsx)("li",{children:(0,eM.jsx)(n3,{list:e})},t))})}function n5({source:e}){return(0,eM.jsx)("div",{className:"text-[13px]",children:(function(e){let t=e.slice(0,8e3).replace(/\r\n?/g,"\n").split("\n"),r=[],s=[],n=()=>{s.length&&r.push({t:"p",inl:n2(s.join(" "))}),s=[]};for(let e=0;e<t.length;e++){let a=t[e];if(/^\s*```/.test(a)){n();let s=[];for(e++;e<t.length&&!/^\s*```/.test(t[e]);)s.push(t[e++]);r.push({t:"code",text:s.join("\n")});continue}if(!a.trim()){n();continue}let i=/^\s{0,3}#{1,6}\s+(.+)$/.exec(a);if(i){n(),r.push({t:"h",inl:n2(i[1].trim())});continue}let o=/^\s*([-*]|\d+[.)])\s+(.+)$/.exec(a);if(o){n();let e=/\d/.test(o[1])?"ol":"ul",t=r[r.length-1],s=n2(o[2].trim());t&&("ul"===t.t||"ol"===t.t)&&t.t===e?t.items.push(s):r.push({t:e,items:[s]});continue}s.push(a.trim())}return n(),r})(e).map((e,t)=>(0,eM.jsx)(n4,{b:e},t))})}let n6=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),n8=[],n9=(e,t,r)=>{if(0==e.length-t)return r.classGroupId;let s=e[t],n=r.nextPart.get(s);if(n){let r=n9(e,t+1,n);if(r)return r}let a=r.validators;if(null===a)return;let i=0===t?e.join("-"):e.slice(t).join("-"),o=a.length;for(let e=0;e<o;e++){let t=a[e];if(t.validator(i))return t.classGroupId}},n7=(e,t)=>{let r=n6();for(let s in e)ae(e[s],r,s,t);return r},ae=(e,t,r,s)=>{let n=e.length;for(let a=0;a<n;a++)at(e[a],t,r,s)},at=(e,t,r,s)=>{"string"==typeof e?ar(e,t,r):"function"==typeof e?as(e,t,r,s):an(e,t,r,s)},ar=(e,t,r)=>{(""===e?t:aa(t,e)).classGroupId=r},as=(e,t,r,s)=>{ai(e)?ae(e(s),t,r,s):(null===t.validators&&(t.validators=[]),t.validators.push({classGroupId:r,validator:e}))},an=(e,t,r,s)=>{let n=Object.entries(e),a=n.length;for(let e=0;e<a;e++){let[a,i]=n[e];ae(i,aa(t,a),r,s)}},aa=(e,t)=>{let r=e,s=t.split("-"),n=s.length;for(let e=0;e<n;e++){let t=s[e],n=r.nextPart.get(t);n||(n=n6(),r.nextPart.set(t,n)),r=n}return r},ai=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,ao=[],al=(e,t,r,s,n)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:s,isExternal:n}),ac=/\s+/,au=e=>{let t;if("string"==typeof e)return e;let r="";for(let s=0;s<e.length;s++)e[s]&&(t=au(e[s]))&&(r&&(r+=" "),r+=t);return r},ad=[],ah=e=>{let t=t=>t[e]||ad;return t.isThemeGetter=!0,t.themeKey=e,t},ap=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,af=/^\((?:(\w[\w-]*):)?(.+)\)$/i,am=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ag=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ab=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ay=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,aw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,av=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ak=e=>am.test(e),a_=e=>!!e&&!Number.isNaN(Number(e)),aS=e=>!!e&&Number.isInteger(Number(e)),ax=e=>e.endsWith("%")&&a_(e.slice(0,-1)),aA=e=>ag.test(e),aT=()=>!0,aR=e=>ab.test(e)&&!ay.test(e),aE=()=>!1,aI=e=>aw.test(e),aj=e=>av.test(e),aO=e=>!aP(e)&&!az(e),aC=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),a$=e=>aY(e,a0,aE),aP=e=>ap.test(e),aN=e=>aY(e,a1,aR),aD=e=>aY(e,a2,a_),aL=e=>aY(e,a4,aT),aU=e=>aY(e,a3,aE),aq=e=>aY(e,aZ,aE),aM=e=>aY(e,aQ,aj),aB=e=>aY(e,a5,aI),az=e=>af.test(e),aF=e=>aX(e,a1),aW=e=>aX(e,a3),aH=e=>aX(e,aZ),aG=e=>aX(e,a0),aK=e=>aX(e,aQ),aJ=e=>aX(e,a5,!0),aV=e=>aX(e,a4,!0),aY=(e,t,r)=>{let s=ap.exec(e);return!!s&&(s[1]?t(s[1]):r(s[2]))},aX=(e,t,r=!1)=>{let s=af.exec(e);return!!s&&(s[1]?t(s[1]):r)},aZ=e=>"position"===e||"percentage"===e,aQ=e=>"image"===e||"url"===e,a0=e=>"length"===e||"size"===e||"bg-size"===e,a1=e=>"length"===e,a2=e=>"number"===e,a3=e=>"family-name"===e,a4=e=>"number"===e||"weight"===e,a5=e=>"shadow"===e,a6=(m=()=>{let e=ah("color"),t=ah("font"),r=ah("text"),s=ah("font-weight"),n=ah("tracking"),a=ah("leading"),i=ah("breakpoint"),o=ah("container"),l=ah("spacing"),c=ah("radius"),u=ah("shadow"),d=ah("inset-shadow"),h=ah("text-shadow"),p=ah("drop-shadow"),f=ah("blur"),m=ah("perspective"),g=ah("aspect"),b=ah("ease"),y=ah("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...v(),az,aP],_=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],x=()=>[az,aP,l],A=()=>[ak,"full","auto",...x()],T=()=>[aS,"none","subgrid",az,aP],R=()=>["auto",{span:["full",aS,az,aP]},aS,az,aP],E=()=>[aS,"auto",az,aP],I=()=>["auto","min","max","fr",az,aP],j=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],C=()=>["auto",...x()],$=()=>[ak,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],P=()=>[o,ak,"screen","full","dvw","lvw","svw","min","max","fit",...x()],N=()=>[ak,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],D=()=>[e,az,aP],L=()=>[...v(),aH,aq,{position:[az,aP]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",aG,a$,{size:[az,aP]}],M=()=>[ax,aF,aN],B=()=>["","none","full",c,az,aP],z=()=>["",a_,aF,aN],F=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[a_,ax,aH,aq],G=()=>["","none",f,az,aP],K=()=>["none",a_,az,aP],J=()=>["none",a_,az,aP],V=()=>[a_,az,aP],Y=()=>[ak,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[aA],breakpoint:[aA],color:[aT],container:[aA],"drop-shadow":[aA],ease:["in","out","in-out"],font:[aO],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[aA],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[aA],shadow:[aA],spacing:["px",a_],text:[aA],"text-shadow":[aA],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ak,aP,az,g]}],container:["container"],"container-type":[{"@container":["","normal","size",az,aP]}],"container-named":[aC],columns:[{columns:[a_,"auto",aP,az,o]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[aS,"auto",az,aP]}],basis:[{basis:[ak,"full","auto",o,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[a_,ak,"auto","initial","none",aP]}],grow:[{grow:["",a_,az,aP]}],shrink:[{shrink:["",a_,az,aP]}],order:[{order:[aS,"first","last","none",az,aP]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...j(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...j()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":j()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],"inline-size":[{inline:["auto",...P()]}],"min-inline-size":[{"min-inline":["auto",...P()]}],"max-inline-size":[{"max-inline":["none",...P()]}],"block-size":[{block:["auto",...N()]}],"min-block-size":[{"min-block":["auto",...N()]}],"max-block-size":[{"max-block":["none",...N()]}],w:[{w:[o,"screen",...$()]}],"min-w":[{"min-w":[o,"screen","none",...$()]}],"max-w":[{"max-w":[o,"screen","none","prose",{screen:[i]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh","none",...$()]}],"font-size":[{text:["base",r,aF,aN]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,aV,aL]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ax,aP]}],"font-family":[{font:[aW,aU,t]}],"font-features":[{"font-features":[aP]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,az,aP]}],"line-clamp":[{"line-clamp":[a_,"none",az,aD]}],leading:[{leading:["none",a,...x()]}],"list-image":[{"list-image":["none",az,aP]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",az,aP]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:[a_,"from-font","auto",az,aN]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[a_,"auto",az,aP]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[aS,az,aP]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",az,aP]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",az,aP]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},aS,az,aP],radial:["",az,aP],conic:["",aS,az,aP]},aK,aM]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:M()}],"gradient-via-pos":[{via:M()}],"gradient-to-pos":[{to:M()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-bs":[{"border-bs":z()}],"border-w-be":[{"border-be":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...F(),"hidden","none"]}],"divide-style":[{divide:[...F(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...F(),"none","hidden"]}],"outline-offset":[{"outline-offset":[a_,az,aP]}],"outline-w":[{outline:["",a_,aF,aN]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","inner","none",u,aJ,aB]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",d,aJ,aB]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[a_,aN]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",h,aJ,aB]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[a_,az,aP]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[a_]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[az,aP]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[a_]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",az,aP]}],filter:[{filter:["","none",az,aP]}],blur:[{blur:G()}],brightness:[{brightness:[a_,az,aP]}],contrast:[{contrast:[a_,az,aP]}],"drop-shadow":[{"drop-shadow":["","none",p,aJ,aB]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",a_,az,aP]}],"hue-rotate":[{"hue-rotate":[a_,az,aP]}],invert:[{invert:["",a_,az,aP]}],saturate:[{saturate:[a_,az,aP]}],sepia:[{sepia:["",a_,az,aP]}],"backdrop-filter":[{"backdrop-filter":["","none",az,aP]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[a_,az,aP]}],"backdrop-contrast":[{"backdrop-contrast":[a_,az,aP]}],"backdrop-grayscale":[{"backdrop-grayscale":["",a_,az,aP]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[a_,az,aP]}],"backdrop-invert":[{"backdrop-invert":["",a_,az,aP]}],"backdrop-opacity":[{"backdrop-opacity":[a_,az,aP]}],"backdrop-saturate":[{"backdrop-saturate":[a_,az,aP]}],"backdrop-sepia":[{"backdrop-sepia":["",a_,az,aP]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",az,aP]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[a_,"initial",az,aP]}],ease:[{ease:["linear","initial",b,az,aP]}],delay:[{delay:[a_,az,aP]}],animate:[{animate:["none",y,az,aP]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,az,aP]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:J()}],"scale-x":[{"scale-x":J()}],"scale-y":[{"scale-y":J()}],"scale-z":[{"scale-z":J()}],"scale-3d":["scale-3d"],skew:[{skew:V()}],"skew-x":[{"skew-x":V()}],"skew-y":[{"skew-y":V()}],transform:[{transform:[az,aP,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Y()}],"translate-x":[{"translate-x":Y()}],"translate-y":[{"translate-y":Y()}],"translate-z":[{"translate-z":Y()}],"translate-none":["translate-none"],zoom:[{zoom:[aS,az,aP]}],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",az,aP]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":D()}],"scrollbar-track-color":[{"scrollbar-track":D()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",az,aP]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[a_,aF,aN,aD]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},l=e=>{let t=a(e);if(t)return t;let r=((e,t)=>{let{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:n,sortModifiers:a,postfixLookupClassGroupIds:i}=t,o=[],l=e.trim().split(ac),c="";for(let e=l.length-1;e>=0;e-=1){let t,u=l[e],{isExternal:d,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:m}=r(u);if(d){c=u+(c.length>0?" "+c:c);continue}let g=!!m;if(g){let e=(t=s(f.substring(0,m)))&&i[t]?s(f):void 0;e&&e!==t&&(t=e,g=!1)}else t=s(f);if(!t){if(!g||!(t=s(f))){c=u+(c.length>0?" "+c:c);continue}g=!1}let b=0===h.length?"":1===h.length?h[0]:a(h).join(":"),y=p?b+"!":b,w=y+t;if(o.indexOf(w)>-1)continue;o.push(w);let v=n(t,g);for(let e=0;e<v.length;++e){let t=v[e];o.push(y+t)}c=u+(c.length>0?" "+c:c)}return c})(e,n);return i(e,r),r},o=e=>{var t;let r;return a=(n={cache:(e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,r=Object.create(null),s=Object.create(null),n=(n,a)=>{r[n]=a,++t>e&&(t=0,s=r,r=Object.create(null))};return{get(e){let t=r[e];return void 0!==t?t:void 0!==(t=s[e])?(n(e,t),t):void 0},set(e,t){e in r?r[e]=t:n(e,t)}}})((t=[].reduce((e,t)=>t(e),m())).cacheSize),parseClassName:(e=>{let{prefix:t,experimentalParseClassName:r}=e,s=e=>{let t,r=[],s=0,n=0,a=0,i=e.length;for(let o=0;o<i;o++){let i=e[o];if(0===s&&0===n){if(":"===i){r.push(e.slice(a,o)),a=o+1;continue}if("/"===i){t=o;continue}}"["===i?s++:"]"===i?s--:"("===i?n++:")"===i&&n--}let o=0===r.length?e:e.slice(a),l=o,c=!1;return o.endsWith("!")?(l=o.slice(0,-1),c=!0):o.startsWith("!")&&(l=o.slice(1),c=!0),al(r,c,l,t&&t>a?t-a:void 0)};if(t){let e=t+":",r=s;s=t=>t.startsWith(e)?r(t.slice(e.length)):al(ao,!1,t,void 0,!0)}if(r){let e=s;s=t=>r({className:t,parseClassName:e})}return s})(t),sortModifiers:(r=new Map,t.orderSensitiveModifiers.forEach((e,t)=>{r.set(e,1e6+t)}),e=>{let t=[],s=[];for(let n=0;n<e.length;n++){let a=e[n],i="["===a[0],o=r.has(a);i||o?(s.length>0&&(s.sort(),t.push(...s),s=[]),t.push(a)):s.push(a)}return s.length>0&&(s.sort(),t.push(...s)),t}),postfixLookupClassGroupIds:(e=>{let t=Object.create(null),r=e.postfixLookupClassGroups;if(r)for(let e=0;e<r.length;e++)t[r[e]]=!0;return t})(t),...(e=>{let t=(e=>{let{theme:t,classGroups:r}=e;return n7(r,t)})(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]")){var r;let t,s,n;return -1===(r=e).slice(1,-1).indexOf(":")?void 0:(s=(t=r.slice(1,-1)).indexOf(":"),(n=t.slice(0,s))?"arbitrary.."+n:void 0)}let s=e.split("-"),n=+(""===s[0]&&s.length>1);return n9(s,n,t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=s[e],n=r[e];if(t){if(n){let e=Array(n.length+t.length);for(let t=0;t<n.length;t++)e[t]=n[t];for(let r=0;r<t.length;r++)e[n.length+r]=t[r];return e}return t}return n||n8}return r[e]||n8}}})(t)}).cache.get,i=n.cache.set,o=l,l(e)},(...e)=>o(((...e)=>{let t,r,s=0,n="";for(;s<e.length;)(t=e[s++])&&(r=au(t))&&(n&&(n+=" "),n+=r);return n})(...e)));function a8(...e){return a6(function(){for(var e,t,r=0,s="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=function e(t){var r,s,n="";if("string"==typeof t||"number"==typeof t)n+=t;else if("object"==typeof t)if(Array.isArray(t)){var a=t.length;for(r=0;r<a;r++)t[r]&&(s=e(t[r]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}(e))&&(s&&(s+=" "),s+=t);return s}(e))}let a9={brand:"border-l-brand",err:"border-l-err",warn:"border-l-warn-icon"};function a7({icon:e,tone:t="brand",meta:r,action:s,className:n,children:a}){return(0,eM.jsxs)("div",{className:a8("flex gap-2.5 rounded-md border border-line border-l-[3px] bg-surface-2 px-3 py-2.5 text-[13px]",a9[t],n),children:[(0,eM.jsx)("span",{className:"mt-px shrink-0 text-brand",children:e}),(0,eM.jsxs)("div",{className:"min-w-0 flex-1",children:[a,r&&(0,eM.jsx)("span",{className:"mt-1 block text-[12px] text-ink-faint",children:r})]}),s&&(0,eM.jsx)("div",{className:"shrink-0",children:s})]})}var ie=e.i(843305);let it={crit:"err",warn:"warn",info:"brand"};function ir({note:e,now:t,showApp:r}){let s=["AI note",`from ${e.from}`,e.model,(0,eg.ago)(e.at,t),r&&e.appName?e.appName:null,"written by an agent, can be wrong"].filter(Boolean).join(" · ");return(0,eM.jsxs)(a7,{icon:(0,eM.jsx)(nQ,{size:18,"aria-hidden":!0}),tone:it[e.severity]??"brand",meta:s,action:(0,eM.jsx)(ie.DismissNoteButton,{id:e.id}),children:[(0,eM.jsx)("b",{className:"font-medium",children:(0,eM.jsx)(n0.MaskedText,{text:e.title})}),(0,eM.jsx)(n5,{source:e.body})]})}async function is({appId:e}){let{ok:t}=await nG("owner");if(!t)return null;let r=new Date,s=await nY(e,r).catch(()=>[]);return s.length?(0,eM.jsx)("div",{className:"mb-3 flex flex-col gap-2.5",children:s.map(t=>(0,eM.jsx)(ir,{note:t,now:r,showApp:void 0===e},t.id))}):null}e.s(["f",0,is],64858);let ia=nZ("outline","message-2","Message2",[["path",{d:"M8 9h8",key:"svg-0"}],["path",{d:"M8 13h6",key:"svg-1"}],["path",{d:"M9 18h-3a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-3l-3 3l-3 -3",key:"svg-2"}]]);var ii=e.i(133791),io=e.i(547963),il=e.i(515073);async function ic({count:e}){let{ok:t}=await nG("owner");if(!t)return null;if(!await eO.provider().catch(()=>null))return(await nY(void 0,new Date).catch(()=>[])).length?null:(0,eM.jsxs)("p",{className:"mb-3 flex items-center gap-1.5 text-[13px] text-ink-soft",children:[(0,eM.jsx)(nQ,{size:16,"aria-hidden":!0,className:"text-ink-faint"}),(0,eM.jsx)(ii.default,{href:"/ai/connect",children:io.v.recConnect})]});if(0===e)return null;let r=await eL().catch(()=>null);if(!r)return(0,eM.jsxs)("p",{className:"mb-3 flex items-center gap-1.5 text-[13px] text-ink-soft",children:[(0,eM.jsx)(ia,{size:16,"aria-hidden":!0,className:"text-ink-faint"}),"No AI summary yet. ",(0,eM.jsx)(il.RegenerateButton,{label:"Summarise"})]});let s=new Date;return(0,eM.jsxs)(a7,{className:"mb-3",icon:(0,eM.jsx)(ia,{size:18,"aria-hidden":!0}),meta:(0,eM.jsxs)(eM.Fragment,{children:[`AI \xb7 ${r.model} \xb7 ${(0,eg.ago)(new Date(r.at),s)} \xb7 from ${r.count} items, names aliased \xb7 can be wrong, check the items below \xb7 `,(0,eM.jsx)(il.RegenerateButton,{label:"Regenerate"})]}),children:[(0,eM.jsx)("b",{className:"font-medium",children:"Summary"}),(0,eM.jsx)(n5,{source:r.text})]})}e.s(["f",0,ic],248744);var iu=e.i(898757);let id=async()=>({report:null,prefs:{disabled:[],defaultModel:null},allowed:iu._});async function ih(e=new Date){let[t,r]=await Promise.all([id().catch(()=>null),(0,I.M)().then(()=>!0,()=>!1)]),s=!!t&&(t.report,!1);return{agConnected:s,agEnabled:(s&&t&&(t.report,t.prefs,t.allowed),[]),providerReady:r}}let ip={id:nJ.S.id,status:nJ.S.status,answer:nJ.S.answer,client:nJ.S.answeredByClient,model:nJ.S.answeredByModel,requestedModel:nJ.S.requestedModel,createdAt:nJ.S.createdAt,answeredAt:nJ.S.answeredAt};async function im(e,t,r){let s,[n]=await (0,T.db)().select(ip).from(nJ.S).where((0,x.and)((0,x.eq)(nJ.S.contextKind,e),(0,x.eq)(nJ.S.contextId,t))).orderBy((0,nK.desc)(nJ.S.createdAt)).limit(1);return n?(s="pending"===n.status&&r.getTime()-n.createdAt.getTime()>6048e5,{...n,status:s?"expired":n.status}):null}var ig=e.i(813359);async function ib({appId:e}){let{ok:t}=await nG("owner");if(!t)return null;let r=new Date,[s,n,a]=await Promise.all([eO.provider().catch(()=>null),im("app",e,r).catch(()=>null),ih(r).catch(()=>null)]),i=n?{...n,createdAt:n.createdAt.toISOString(),answeredAt:n.answeredAt?.toISOString()??null}:null;return(0,eM.jsx)(ig.WhyAi,{appId:e,provider:s?{model:s.model}:null,question:i,nowMs:r.getTime(),agConnected:a?.agConnected??!1})}function iy({title:e,meta:t,flush:r,className:s,children:n}){return(0,eM.jsxs)("section",{className:a8("min-w-0 rounded-lg border border-line bg-surface",s),children:[e&&(0,eM.jsxs)("div",{className:a8("flex flex-wrap items-center gap-2 px-[18px] pt-3.5",r?"pb-2.5":"pb-1.5"),children:[(0,eM.jsx)("h2",{className:"text-[15px]",children:e}),t&&(0,eM.jsx)("span",{className:"ml-auto flex items-center gap-1.5 text-[12.5px] text-ink-soft",children:t})]}),r?n:(0,eM.jsx)("div",{className:"px-[18px] pb-4 pt-2",children:n})]})}e.s(["f",0,ib],379593),nZ("outline","alert-circle","AlertCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]]),nZ("outline","alert-triangle","AlertTriangle",[["path",{d:"M12 9v4",key:"svg-0"}],["path",{d:"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]]),nZ("outline","circle-check","CircleCheck",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]]),nZ("outline","circle-dashed","CircleDashed",[["path",{d:"M8.56 3.69a9 9 0 0 0 -2.92 1.95",key:"svg-0"}],["path",{d:"M3.69 8.56a9 9 0 0 0 -.69 3.44",key:"svg-1"}],["path",{d:"M3.69 15.44a9 9 0 0 0 1.95 2.92",key:"svg-2"}],["path",{d:"M8.56 20.31a9 9 0 0 0 3.44 .69",key:"svg-3"}],["path",{d:"M15.44 20.31a9 9 0 0 0 2.92 -1.95",key:"svg-4"}],["path",{d:"M20.31 15.44a9 9 0 0 0 .69 -3.44",key:"svg-5"}],["path",{d:"M20.31 8.56a9 9 0 0 0 -1.95 -2.92",key:"svg-6"}],["path",{d:"M15.44 3.69a9 9 0 0 0 -3.44 -.69",key:"svg-7"}]]),nZ("outline","circle-x","CircleX",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]]),nZ("outline","help-circle","HelpCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 16v.01",key:"svg-1"}],["path",{d:"M12 13a2 2 0 0 0 .914 -3.782a1.98 1.98 0 0 0 -2.414 .483",key:"svg-2"}]]),nZ("outline","info-circle","InfoCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]]),nZ("outline","loader-2","Loader2",[["path",{d:"M12 3a9 9 0 1 0 9 9",key:"svg-0"}]]),nZ("outline","moon","Moon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008",key:"svg-0"}]]),nZ("outline","player-pause","PlayerPause",[["path",{d:"M6 6a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -12",key:"svg-0"}],["path",{d:"M14 6a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -12",key:"svg-1"}]]),nZ("outline","tool","Tool",[["path",{d:"M7 10h3v-3l-3.5 -3.5a6 6 0 0 1 8 8l6 6a2 2 0 0 1 -3 3l-6 -6a6 6 0 0 1 -8 -8l3.5 3.5",key:"svg-0"}]]);var iw=e.i(27295),iv=e.i(657753),ik=e.i(783671),i_=e.i(809303),iS=e.i(564769);let ix={recheck:"Runs the monitor's check once, like Check now on the monitor.",neon_wake:"Wakes a suspended Neon compute, like Wake on the database page.",supabase_keepalive:"Sends one keep-alive query to a Supabase project close to auto-pause, like Keep active.",supabase_restore:"Restores a paused Supabase project.",vercel_redeploy:"Redeploys the current production deployment.",vercel_rollback:"Rolls production back to the previous ready deployment.",github_bump_pr:"Opens a pull request on a new branch that raises vulnerable packages to their fixed versions (needs the GitHub PR-write token).",daily_rerun:"Calls the console's daily job again when its heartbeat is down. Always asks for approval.",domain_recheck:"Re-reads a domain's TLS certificate and expiry when its certificate looks close to expiry, like Re-check on Domains.",monitor_update_url:"Points an uptime monitor at its app's new domain when the app moved, keeping the path, like Update monitor on Uptime."};async function iA(){let[e,t,r]=await Promise.all([(0,i_.I)(),(0,i_.K)(),(0,i_.X)()]),s=[10,15,20,30,45,60,90,120].filter(e=>e>=i_.l&&e<=i_.n),n=i_.r.map(e=>({kind:e,label:iS.H[e].label,risky:"risky"===iS.H[e].risk,what:ix[e]}));return(0,eM.jsxs)(iy,{title:"Auto-actions",flush:!0,meta:"All off by default",children:[(0,eM.jsxs)("p",{className:"px-[18px] pb-3 text-ink-soft",children:["When a firing alert brings a proposal for one of these actions, a switched-on kind runs without asking and you get a short Telegram line afterwards. Everything else waits for you on ",(0,eM.jsx)(ii.default,{href:"/auto-actions",children:"Auto-actions"}),". Auto-run only does what the console button does, through the same checks, and every run is in the audit log (Events)."]}),(0,eM.jsx)(iw.AutoRunForm,{saved:e,rows:n}),(0,eM.jsxs)("div",{className:"border-t border-line px-[18px] pb-4 pt-3.5",children:[(0,eM.jsx)("h3",{className:"mb-1.5 text-[14px]",children:"Auto-rollback after a bad deploy"}),(0,eM.jsxs)("p",{className:"mb-2.5 text-ink-soft",children:["Off by default. When on, a new production deploy that breaks the app is rolled back to the previous one without asking. Only ",(0,eM.jsx)("span",{className:"font-mono text-[12.5px]",children:"vercel_rollback"}),", only within the first N minutes after a new production deploy goes live, only when a monitor is down or the logs show an error spike, at most once per deployment (and never twice for one app within 2 hours), and every run is reported on Telegram and in Events. Failed builds never go live on Vercel, so this is for builds that succeed but break at runtime."]}),(0,eM.jsx)(iv.AutoRollbackForm,{saved:t,choices:s})]}),(0,eM.jsxs)("div",{className:"border-t border-line px-[18px] pb-4 pt-3.5",children:[(0,eM.jsx)("h3",{className:"mb-1.5 text-[14px]",children:"Automatic security fixes"}),(0,eM.jsx)("p",{className:"mb-2 text-ink-soft",children:"On by default. When a dependency scan finds a critical, high or moderate advisory with a fix, Watchbell fixes it end to end (the scan and the Next.js check run every 6 hours and right after each production deploy):"}),(0,eM.jsxs)("ol",{className:"mb-2.5 list-decimal pl-5 text-ink-soft [&_li]:mt-0.5",children:[(0,eM.jsx)("li",{children:"opens the update PR itself (package.json only, on a new watchpost/deps-… branch), only for direct packages that stay in their major version, never twice for the same package while a PR is open;"}),(0,eM.jsx)("li",{children:"waits for GitHub's checks (all green), then Vercel's preview of the PR (READY);"}),(0,eM.jsx)("li",{children:'tests the preview: "/" and up to 3 monitor paths must answer 200–399 within 15 s (behind Vercel Authentication: 3 minutes without error lines in the preview\'s logs);'}),(0,eM.jsx)("li",{children:"squash-merges it, only while auto-rollback is on: the production deploy then runs on Vercel and auto-rollback guards its first minutes."})]}),(0,eM.jsx)("p",{className:"mb-2.5 text-ink-soft",children:'Anything failing, or not done within 45 minutes, leaves the PR open marked "needs a look". A major update, a transitive package or a severity you switched off waits for your approval on Auto-actions, as before. Every PR opened and every merge or stop is sent to Telegram and logged in Events. Needs the GitHub PR-write token on Connections.'}),(0,eM.jsx)(ik.AutoSecurityForm,{saved:r,rollbackOn:t.enabled})]})]})}e.s(["f",0,iA],717799)},20019,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call DismissNoteButton() from the server but DismissNoteButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/dismiss-note-button.tsx","DismissNoteButton");e.s(["DismissNoteButton",0,t])},843305,e=>{var t=e.i(20019);e.n(t)},903419,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call RegenerateButton() from the server but RegenerateButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/regenerate-button.tsx","RegenerateButton");e.s(["RegenerateButton",0,t])},515073,e=>{var t=e.i(903419);e.n(t)},637858,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call WhyAi() from the server but WhyAi is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/why-ai.tsx","WhyAi");e.s(["WhyAi",0,t])},813359,e=>{var t=e.i(637858);e.n(t)}],31194,(e,t,r)=>{let{createClientModuleProxy:s}=e.r(310086);e.n(s("[project]/node_modules/next/dist/client/app-dir/link.js"))},547850,(e,t,r)=>{var s={943:function(t,r){!function(s){"use strict";var n="function",a="undefined",i="object",o="string",l="major",c="model",u="name",d="type",h="vendor",p="version",f="architecture",m="console",g="mobile",b="tablet",y="smarttv",w="wearable",v="embedded",k="Amazon",_="Apple",S="ASUS",x="BlackBerry",A="Browser",T="Chrome",R="Firefox",E="Google",I="Huawei",j="Microsoft",O="Motorola",C="Opera",$="Samsung",P="Sharp",N="Sony",D="Xiaomi",L="Zebra",U="Facebook",q="Chromium OS",M="Mac OS",B=function(e,t){var r={};for(var s in e)t[s]&&t[s].length%2==0?r[s]=t[s].concat(e[s]):r[s]=e[s];return r},z=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},F=function(e,t){return typeof e===o&&-1!==W(t).indexOf(W(e))},W=function(e){return e.toLowerCase()},H=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===a?e:e.substring(0,350)},G=function(e,t){for(var r,s,a,o,l,c,u=0;u<t.length&&!l;){var d=t[u],h=t[u+1];for(r=s=0;r<d.length&&!l&&d[r];)if(l=d[r++].exec(e))for(a=0;a<h.length;a++)c=l[++s],typeof(o=h[a])===i&&o.length>0?2===o.length?typeof o[1]==n?this[o[0]]=o[1].call(this,c):this[o[0]]=o[1]:3===o.length?typeof o[1]!==n||o[1].exec&&o[1].test?this[o[0]]=c?c.replace(o[1],o[2]):void 0:this[o[0]]=c?o[1].call(this,c,o[2]):void 0:4===o.length&&(this[o[0]]=c?o[3].call(this,c.replace(o[1],o[2])):void 0):this[o]=c||void 0;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===i&&t[r].length>0){for(var s=0;s<t[r].length;s++)if(F(t[r][s],e))return"?"===r?void 0:r}else if(F(t[r],e))return"?"===r?void 0:r;return e},J={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},V={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[p,[u,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[p,[u,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[u,p],[/opios[\/ ]+([\w\.]+)/i],[p,[u,C+" Mini"]],[/\bopr\/([\w\.]+)/i],[p,[u,C]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[u,p],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[p,[u,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[p,[u,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[p,[u,"WeChat"]],[/konqueror\/([\w\.]+)/i],[p,[u,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[p,[u,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[p,[u,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[u,/(.+)/,"$1 Secure "+A],p],[/\bfocus\/([\w\.]+)/i],[p,[u,R+" Focus"]],[/\bopt\/([\w\.]+)/i],[p,[u,C+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[p,[u,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[p,[u,"Dolphin"]],[/coast\/([\w\.]+)/i],[p,[u,C+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[p,[u,"MIUI "+A]],[/fxios\/([-\w\.]+)/i],[p,[u,R]],[/\bqihu|(qi?ho?o?|360)browser/i],[[u,"360 "+A]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[u,/(.+)/,"$1 "+A],p],[/(comodo_dragon)\/([\w\.]+)/i],[[u,/_/g," "],p],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[u,p],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[u],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[u,U],p],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[u,p],[/\bgsa\/([\w\.]+) .*safari\//i],[p,[u,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[p,[u,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[p,[u,T+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[u,T+" WebView"],p],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[p,[u,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[u,p],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[p,[u,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[p,u],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[u,[p,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[u,p],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[u,"Netscape"],p],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[p,[u,R+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[u,p],[/(cobalt)\/([\w\.]+)/i],[u,[p,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[f,"amd64"]],[/(ia32(?=;))/i],[[f,W]],[/((?:i[346]|x)86)[;\)]/i],[[f,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[f,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[f,"armhf"]],[/windows (ce|mobile); ppc;/i],[[f,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[f,/ower/,"",W]],[/(sun4\w)[;\)]/i],[[f,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[f,W]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[h,$],[d,b]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[c,[h,$],[d,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[c,[h,_],[d,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[h,_],[d,b]],[/(macintosh);/i],[c,[h,_]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[h,P],[d,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[h,I],[d,b]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[h,I],[d,g]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[c,/_/g," "],[h,D],[d,g]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[h,D],[d,b]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[h,"OPPO"],[d,g]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[h,"Vivo"],[d,g]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[c,[h,"Realme"],[d,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[h,O],[d,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[h,O],[d,b]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[h,"LG"],[d,b]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[h,"LG"],[d,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[h,"Lenovo"],[d,b]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[h,"Nokia"],[d,g]],[/(pixel c)\b/i],[c,[h,E],[d,b]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[h,E],[d,g]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[h,N],[d,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[h,N],[d,b]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[h,"OnePlus"],[d,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[h,k],[d,b]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[h,k],[d,g]],[/(playbook);[-\w\),; ]+(rim)/i],[c,h,[d,b]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[h,x],[d,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[h,S],[d,b]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[h,S],[d,g]],[/(nexus 9)/i],[c,[h,"HTC"],[d,b]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[c,/_/g," "],[d,g]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[h,"Acer"],[d,b]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[h,"Meizu"],[d,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,c,[d,g]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,c,[d,b]],[/(surface duo)/i],[c,[h,j],[d,b]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[h,"Fairphone"],[d,g]],[/(u304aa)/i],[c,[h,"AT&T"],[d,g]],[/\bsie-(\w*)/i],[c,[h,"Siemens"],[d,g]],[/\b(rct\w+) b/i],[c,[h,"RCA"],[d,b]],[/\b(venue[\d ]{2,7}) b/i],[c,[h,"Dell"],[d,b]],[/\b(q(?:mv|ta)\w+) b/i],[c,[h,"Verizon"],[d,b]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[h,"Barnes & Noble"],[d,b]],[/\b(tm\d{3}\w+) b/i],[c,[h,"NuVision"],[d,b]],[/\b(k88) b/i],[c,[h,"ZTE"],[d,b]],[/\b(nx\d{3}j) b/i],[c,[h,"ZTE"],[d,g]],[/\b(gen\d{3}) b.+49h/i],[c,[h,"Swiss"],[d,g]],[/\b(zur\d{3}) b/i],[c,[h,"Swiss"],[d,b]],[/\b((zeki)?tb.*\b) b/i],[c,[h,"Zeki"],[d,b]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],c,[d,b]],[/\b(ns-?\w{0,9}) b/i],[c,[h,"Insignia"],[d,b]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[h,"NextBook"],[d,b]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],c,[d,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],c,[d,g]],[/\b(ph-1) /i],[c,[h,"Essential"],[d,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[h,"Envizen"],[d,b]],[/\b(trio[-\w\. ]+) b/i],[c,[h,"MachSpeed"],[d,b]],[/\btu_(1491) b/i],[c,[h,"Rotor"],[d,b]],[/(shield[\w ]+) b/i],[c,[h,"Nvidia"],[d,b]],[/(sprint) (\w+)/i],[h,c,[d,g]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[h,j],[d,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[h,L],[d,b]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[h,L],[d,g]],[/smart-tv.+(samsung)/i],[h,[d,y]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[h,$],[d,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,"LG"],[d,y]],[/(apple) ?tv/i],[h,[c,_+" TV"],[d,y]],[/crkey/i],[[c,T+"cast"],[h,E],[d,y]],[/droid.+aft(\w)( bui|\))/i],[c,[h,k],[d,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[h,P],[d,y]],[/(bravia[\w ]+)( bui|\))/i],[c,[h,N],[d,y]],[/(mitv-\w{5}) bui/i],[c,[h,D],[d,y]],[/Hbbtv.*(technisat) (.*);/i],[h,c,[d,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,H],[c,H],[d,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,c,[d,m]],[/droid.+; (shield) bui/i],[c,[h,"Nvidia"],[d,m]],[/(playstation [345portablevi]+)/i],[c,[h,N],[d,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[h,j],[d,m]],[/((pebble))app/i],[h,c,[d,w]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[c,[h,_],[d,w]],[/droid.+; (glass) \d/i],[c,[h,E],[d,w]],[/droid.+; (wt63?0{2,3})\)/i],[c,[h,L],[d,w]],[/(quest( 2| pro)?)/i],[c,[h,U],[d,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[d,v]],[/(aeobc)\b/i],[c,[h,k],[d,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[c,[d,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[d,b]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,b]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,g]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[p,[u,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[p,[u,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[u,p],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[p,u]],os:[[/microsoft (windows) (vista|xp)/i],[u,p],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[u,[p,K,J]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[u,"Windows"],[p,K,J]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[p,/_/g,"."],[u,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[u,M],[p,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[p,u],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[u,p],[/\(bb(10);/i],[p,[u,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[p,[u,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[p,[u,R+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[p,[u,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[p,[u,"watchOS"]],[/crkey\/([\d\.]+)/i],[p,[u,T+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[u,q],p],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[u,p],[/(sunos) ?([\w\.\d]*)/i],[[u,"Solaris"],p],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[u,p]]},Y=function(e,t){if(typeof e===i&&(t=e,e=void 0),!(this instanceof Y))return new Y(e,t).getResult();var r=typeof s!==a&&s.navigator?s.navigator:void 0,m=e||(r&&r.userAgent?r.userAgent:""),y=r&&r.userAgentData?r.userAgentData:void 0,w=t?B(V,t):V,v=r&&r.userAgent==m;return this.getBrowser=function(){var e,t={};return t[u]=void 0,t[p]=void 0,G.call(t,m,w.browser),t[l]=typeof(e=t[p])===o?e.replace(/[^\d\.]/g,"").split(".")[0]:void 0,v&&r&&r.brave&&typeof r.brave.isBrave==n&&(t[u]="Brave"),t},this.getCPU=function(){var e={};return e[f]=void 0,G.call(e,m,w.cpu),e},this.getDevice=function(){var e={};return e[h]=void 0,e[c]=void 0,e[d]=void 0,G.call(e,m,w.device),v&&!e[d]&&y&&y.mobile&&(e[d]=g),v&&"Macintosh"==e[c]&&r&&typeof r.standalone!==a&&r.maxTouchPoints&&r.maxTouchPoints>2&&(e[c]="iPad",e[d]=b),e},this.getEngine=function(){var e={};return e[u]=void 0,e[p]=void 0,G.call(e,m,w.engine),e},this.getOS=function(){var e={};return e[u]=void 0,e[p]=void 0,G.call(e,m,w.os),v&&!e[u]&&y&&"Unknown"!=y.platform&&(e[u]=y.platform.replace(/chrome os/i,q).replace(/macos/i,M)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return m},this.setUA=function(e){return m=typeof e===o&&e.length>350?H(e,350):e,this},this.setUA(m),this};if(Y.VERSION="1.0.35",Y.BROWSER=z([u,p,l]),Y.CPU=z([f]),Y.DEVICE=z([c,h,d,m,g,y,b,w,v]),Y.ENGINE=Y.OS=z([u,p]),typeof r!==a)t.exports&&(r=t.exports=Y),r.UAParser=Y;else if(typeof define===n&&define.amd)e.r,void 0!==Y&&e.v(Y);else typeof s!==a&&(s.UAParser=Y);var X=typeof s!==a&&(s.jQuery||s.Zepto);if(X&&!X.ua){var Z=new Y;X.ua=Z.getResult(),X.ua.get=function(){return Z.getUA()},X.ua.set=function(e){Z.setUA(e);var t=Z.getResult();for(var r in t)X.ua[r]=t[r]}}}(this)}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}},i=!0;try{s[e].call(r.exports,r,r.exports,a),i=!1}finally{i&&delete n[e]}return r.exports}a.ab="/ROOT/node_modules/next/dist/compiled/ua-parser-js/",t.exports=a(943)},885298,(e,t,r)=>{let s={NextRequest:e.r(641165).NextRequest,NextResponse:e.r(628661).NextResponse,ImageResponse:e.r(853702).ImageResponse,userAgentFromString:e.r(276870).userAgentFromString,userAgent:e.r(276870).userAgent,URLPattern:e.r(374644).URLPattern,after:e.r(910473).after,connection:e.r(476550).connection};t.exports=s,r.NextRequest=s.NextRequest,r.NextResponse=s.NextResponse,r.ImageResponse=s.ImageResponse,r.userAgentFromString=s.userAgentFromString,r.userAgent=s.userAgent,r.URLPattern=s.URLPattern,r.after=s.after,r.connection=s.connection}];
120
+ https://supabase.com/dashboard/project/_/settings/api`);r?.auth?.storage&&(s="@supabase/ssr: createServerClient always manages the session via cookies, so the `auth.storage` option you passed is ignored. If you want to source the session from somewhere other than the request cookies, use @supabase/supabase-js's createClient directly with your own `storage` instead.",nB.has(s)||(nB.add(s),console.warn(s)));let{storage:n,getAll:a,setAll:i,setItems:o,removedItems:l}=function(e,t){let r,s,n=e.cookies&&("get"in e.cookies||"getAll"in e.cookies)?e.cookies:null,a=e.cookieEncoding,i={},o={};if(n)if("get"in n){let e=async e=>{let t=e.flatMap(e=>[e,...Array.from({length:5}).map((t,r)=>`${e}.${r}`)]),r=[];for(let e=0;e<t.length;e+=1){let s=await n.get(t[e]);(s||"string"==typeof s)&&r.push({name:t[e],value:s})}return r};if(r=async t=>await e(t),"set"in n&&"remove"in n)s=async e=>{for(let t=0;t<e.length;t+=1){let{name:r,value:s,options:a}=e[t];s?await n.set(r,s,a):await n.remove(r,a)}};else if(t)s=async()=>{console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)")}else if("getAll"in n)if(r=async()=>await n.getAll(),"setAll"in n)s=n.setAll;else if(t)s=async()=>{console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).`);else if(t||1)if(t)throw Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");else r=()=>[],s=()=>{throw Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed")};else r=()=>{let e;return Object.keys(e=(0,nR.parse)(document.cookie)).map(t=>({name:t,value:e[t]??""}))},s=e=>{e.forEach(({name:e,value:t,options:r})=>{document.cookie=(0,nR.serialize)(e,t,r)})};if(!t)return{getAll:r,setAll:s,setItems:i,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await r([e]),s=await n$(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?nq(s):null},setItem:async(t,n)=>{let i=await r([t]),o=new Set((i?.map(({name:e})=>e)||[]).filter(e=>nj(e,t))),l=n;"base64url"===a&&(l=nL+nD(n));let c=nO(t,l);c.forEach(({name:e})=>{o.delete(e)});let u={...nE,...e?.cookieOptions,maxAge:0},d={...nE,...e?.cookieOptions,maxAge:nE.maxAge};delete u.name,delete d.name;let h=u.domain?(()=>{let{domain:e,...t}=u;return t})():null,p=[...h?[...o].map(e=>({name:e,value:"",options:h})):[],...[...o].map(e=>({name:e,value:"",options:u})),...c.map(({name:e,value:t})=>({name:e,value:t,options:d}))];p.length>0&&await s(p,{})},removeItem:async t=>{let n=await r([t]),a=(n?.map(({name:e})=>e)||[]).filter(e=>nj(e,t));if(0===a.length)return;let i={...nE,...e?.cookieOptions,maxAge:0};delete i.name;let o=i.domain?(()=>{let{domain:e,...t}=i;return t})():null,l=[...o?a.map(e=>({name:e,value:"",options:o})):[],...a.map(e=>({name:e,value:"",options:i}))];await s(l,{})}}};let l=s,c=!1;return{getAll:r,setAll:s=async(e,t)=>{let r=!c&&Object.keys(t).length>0;await l(e,r?t:{}),r&&(c=!0)},setItems:i,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof i[e])return i[e];if(o[e])return null;let t=await r([e]),s=await n$(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?"string"!=typeof s?s:nq(s):null},setItem:async(t,n)=>{t.endsWith("-code-verifier")&&await nM({getAll:r,setAll:s,setItems:{[t]:n},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:a}),i[t]=n,delete o[t]},removeItem:async t=>{(nU.test(t)||t.endsWith("-flows-code-verifier"))&&await nM({getAll:r,setAll:s,setItems:{},removedItems:{[t]:!0}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:a}),delete i[t],o[t]=!0}}}}({...r,cookieEncoding:r?.cookieEncoding??"base64url"},!0),c=new nT(e,t,{...r,global:{...r?.global,headers:{...r?.global?.headers,"X-Client-Info":"supabase-ssr/0.12.7 createServerClient"}},auth:{...r?.cookieOptions?.name?{storageKey:r.cookieOptions.name}:null,...r?.auth,flowType:"pkce",autoRefreshToken:!1,detectSessionInUrl:!1,persistSession:!0,skipAutoInitialize:!0,storage:n,...r?.cookies&&"encode"in r.cookies&&"tokens-only"===r.cookies.encode?{userStorage:r?.auth?.userStorage??function(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}()}:null}});return c.auth.onAuthStateChange(async e=>{(Object.keys(o).length>0||Object.keys(l).length>0)&&("SIGNED_IN"===e||"TOKEN_REFRESHED"===e||"USER_UPDATED"===e||"PASSWORD_RECOVERY"===e||"SIGNED_OUT"===e||"MFA_CHALLENGE_VERIFIED"===e)&&await nM({getAll:a,setAll:i,setItems:o,removedItems:l},{cookieOptions:r?.cookieOptions??null,cookieEncoding:r?.cookieEncoding??"base64url"})}),c}(process.env.NEXT_PUBLIC_SUPABASE_URL,process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,{cookieOptions:function(e=process.env){return{httpOnly:!0,secure:"production"===e.NODE_ENV,sameSite:"lax",path:"/"}}(),cookies:{getAll:()=>e.getAll(),setAll(t){try{t.forEach(({name:t,value:r,options:s})=>e.set(t,r,s))}catch{}}}})}let nH={async sessionUser(){let e=await nW(),{data:t}=await e.auth.getClaims(),r=t?.claims;return r&&"string"==typeof r.sub?{userId:r.sub,email:String(r.email??"").toLowerCase(),aal:"string"==typeof r.aal?r.aal:void 0}:null},async hasVerifiedFactor(){let e=await nW(),{data:t,error:r}=await e.auth.mfa.listFactors();if(e4(r))return"signed-out";if(r||!t)throw Error("mfa factors unavailable");return t.totp.some(e=>"verified"===e.status)},async signOut(e){let t=await nW();e?await t.auth.signOut({scope:e}):await t.auth.signOut()}},nG={async sessionUser(){let e=(await (0,ta.cookies)()).get(ti.J)?.value;return e?(0,to.readLocalSession)(e):null},async hasVerifiedFactor(e){let[t]=await (0,T.db)().select({confirmedAt:E.localUsers.totpConfirmedAt}).from(E.localUsers).where((0,x.eq)(E.localUsers.id,e)).limit(1);return t?null!==t.confirmedAt:"signed-out"},async signOut(e="global"){let t=await (0,ta.cookies)(),r=t.get(ti.J)?.value;if(r){if("global"===e){let e=await (0,to.localSessionUserId)(r);e&&await (0,to.revokeAllLocalSessions)(e)}await (0,to.revokeLocalSession)(r)}(0,ti.N)(t)}},nK={async sessionUser(){let[{readDemoVisitor:t},{demoUserId:r}]=await Promise.all([e.A(672170),e.A(152310)]),s=await t();return s?{userId:r(s.seed),email:s.email,aal:"aal2",mustChangePassword:!1}:null},hasVerifiedFactor:async()=>!0,async signOut(){let{clearDemoCookie:t}=await e.A(729873);t(await (0,ta.cookies)())}};function nJ(){let e=(0,eL.mode)();return"selfhost"===e?nG:"demo"===e?nK:nH}var nV=e.i(144430);let nY=(0,j.cache)(async()=>nJ().sessionUser());async function nZ(e,t){var r;if("aal2"===t)return"ok";let s=await nJ().hasVerifiedFactor(e.userId);return"signed-out"===s?"signed-out":"aal2"===(r={role:e.role,aal:t,hasVerifiedFactor:s}).aal?"ok":r.hasVerifiedFactor?"challenge":"owner"===r.role||"operator"===r.role?"setup":"ok"}let nX=(0,j.cache)(async e=>{let[t]=await (0,T.db)().select({id:E.members.id,userId:E.members.userId,email:E.members.email,role:E.members.role}).from(E.members).where((0,x.eq)(E.members.userId,e)).limit(1);return t??null});async function nQ(e){let[t]=await (0,T.db)().select().from(E.invites).where((0,x.and)((0,x.eq)(E.invites.email,e),(0,x.isNull)(E.invites.acceptedAt),(0,x.gt)(E.invites.expiresAt,new Date))).limit(1);return t??null}async function n0(){let e=await nY();e||(0,eY.redirect)("/signin");let t=await nX(e.userId);if(t){let r=await nZ(t,e.aal);return"signed-out"===r&&(0,eY.redirect)("/auth/session-ended"),"setup"===r&&(0,eY.redirect)("/mfa/setup"),"challenge"===r&&(0,eY.redirect)("/mfa"),e.mustChangePassword&&(0,eY.redirect)("/account/password"),t}e.email&&await nQ(e.email)&&(0,eY.redirect)("/invite"),(0,eY.redirect)("/auth/not-member")}async function n1(e){let t=await n0();return{ok:(0,nV.L)(t.role,e),member:t}}var n2=e.i(396918),n3=e.i(518581);let n4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function n5(e,t=new Date){let r=null,s=new Map;if(void 0!==e){if(!n4.test(e))return[];let[t]=await (0,T.db)().select({name:E.resources.name}).from(E.resources).where((0,x.eq)(E.resources.id,e)).limit(1);r=t?[e,t.name]:[e],t&&(s=new Map([[e,t.name]]))}let n=new Date(t.getTime()-2592e6),a=(0,x.and)((0,x.isNull)(n3.c.dismissedAt),(0,x.gte)(n3.c.createdAt,n)),i=await (0,T.db)().select({id:n3.c.id,appId:n3.c.appId,severity:n3.c.severity,title:n3.c.title,body:n3.c.body,source:n3.c.source,client:n3.c.client,model:n3.c.model,createdAt:n3.c.createdAt}).from(n3.c).where(r?(0,x.and)(a,(0,x.inArray)(n3.c.appId,r)):a).orderBy((0,n2.desc)(n3.c.createdAt)).limit(20);if(void 0===e){let e=[...new Set(i.map(e=>e.appId).filter(e=>!!e&&n4.test(e)))];e.length&&(s=new Map((await (0,T.db)().select({id:E.resources.id,name:E.resources.name}).from(E.resources).where((0,x.inArray)(E.resources.id,e)).limit(e.length)).map(e=>[e.id,e.name])))}return i.map(e=>{let t;return{id:e.id,appId:e.appId,appName:e.appId?s.get(e.appId)??((t=e.appId,n4.test(t))?null:e.appId):null,severity:e.severity,title:e.title,body:e.body,from:e.client||e.source,model:e.model,at:e.createdAt}})}var n6=e.i(843305),n8={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};let n9=(e,t,r,s)=>{let n=(0,j.forwardRef)(({color:r="currentColor",size:n=24,stroke:a=2,title:i,className:o,children:l,...c},u)=>(0,j.createElement)("svg",{ref:u,...n8[e],width:n,height:n,className:["tabler-icon",`tabler-icon-${t}`,o].filter(Boolean).join(" "),..."filled"===e?{fill:r}:{strokeWidth:a,stroke:r},...c},[i&&(0,j.createElement)("title",{key:"svg-title"},i),...s.map(([e,t])=>(0,j.createElement)(e,t)),...Array.isArray(l)?l:[l]]));return n.displayName=`${r}`,n},n7=n9("outline","notes","Notes",[["path",{d:"M5 5a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -14",key:"svg-0"}],["path",{d:"M9 7l6 0",key:"svg-1"}],["path",{d:"M9 11l6 0",key:"svg-2"}],["path",{d:"M9 15l4 0",key:"svg-3"}]]);var ae=e.i(639307);let at=/(\*\*[^*\n]+\*\*|`[^`\n]+`|\[[^\]\n]+\]\([^)\s]+\))/g;function ar(e){let t=[];for(let r of e.split(at))if(r)if(r.startsWith("**")&&r.endsWith("**")&&r.length>4)t.push({t:"b",text:r.slice(2,-2)});else if(r.startsWith("`")&&r.endsWith("`")&&r.length>2)t.push({t:"code",text:r.slice(1,-1)});else{let e=/^\[([^\]]+)\]\(([^)\s]+)\)$/.exec(r);e?t.push({t:"text",text:/^https?:\/\//i.test(e[2])?`${e[1]} (${e[2]})`:e[1]}):t.push({t:"text",text:r})}return t}function as({list:e}){return(0,eV.jsx)(eV.Fragment,{children:e.map((e,t)=>(0,eV.jsx)(j.Fragment,{children:"b"===e.t?(0,eV.jsx)("b",{className:"font-medium",children:(0,eV.jsx)(ae.MaskedText,{text:e.text})}):"code"===e.t?(0,eV.jsx)("code",{className:"rounded bg-sunken px-1 font-mono text-[12.5px]",children:e.text}):(0,eV.jsx)(ae.MaskedText,{text:e.text})},t))})}function an({b:e}){if("p"===e.t)return(0,eV.jsx)("p",{className:"mt-1.5 first:mt-0",children:(0,eV.jsx)(as,{list:e.inl})});if("h"===e.t)return(0,eV.jsx)("p",{className:"mt-2 font-medium first:mt-0",children:(0,eV.jsx)(as,{list:e.inl})});if("code"===e.t)return(0,eV.jsx)("pre",{className:"mt-1.5 overflow-x-auto rounded-md border border-line bg-sunken p-2 font-mono text-[12.5px]",children:e.text});let t="ul"===e.t?"ul":"ol";return(0,eV.jsx)(t,{className:`mt-1.5 space-y-0.5 pl-5 ${"ul"===e.t?"list-disc":"list-decimal"}`,children:e.items.map((e,t)=>(0,eV.jsx)("li",{children:(0,eV.jsx)(as,{list:e})},t))})}function aa({source:e}){return(0,eV.jsx)("div",{className:"text-[13px]",children:(function(e){let t=e.slice(0,8e3).replace(/\r\n?/g,"\n").split("\n"),r=[],s=[],n=()=>{s.length&&r.push({t:"p",inl:ar(s.join(" "))}),s=[]};for(let e=0;e<t.length;e++){let a=t[e];if(/^\s*```/.test(a)){n();let s=[];for(e++;e<t.length&&!/^\s*```/.test(t[e]);)s.push(t[e++]);r.push({t:"code",text:s.join("\n")});continue}if(!a.trim()){n();continue}let i=/^\s{0,3}#{1,6}\s+(.+)$/.exec(a);if(i){n(),r.push({t:"h",inl:ar(i[1].trim())});continue}let o=/^\s*([-*]|\d+[.)])\s+(.+)$/.exec(a);if(o){n();let e=/\d/.test(o[1])?"ol":"ul",t=r[r.length-1],s=ar(o[2].trim());t&&("ul"===t.t||"ol"===t.t)&&t.t===e?t.items.push(s):r.push({t:e,items:[s]});continue}s.push(a.trim())}return n(),r})(e).map((e,t)=>(0,eV.jsx)(an,{b:e},t))})}let ai=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ao=[],al=(e,t,r)=>{if(0==e.length-t)return r.classGroupId;let s=e[t],n=r.nextPart.get(s);if(n){let r=al(e,t+1,n);if(r)return r}let a=r.validators;if(null===a)return;let i=0===t?e.join("-"):e.slice(t).join("-"),o=a.length;for(let e=0;e<o;e++){let t=a[e];if(t.validator(i))return t.classGroupId}},ac=(e,t)=>{let r=ai();for(let s in e)au(e[s],r,s,t);return r},au=(e,t,r,s)=>{let n=e.length;for(let a=0;a<n;a++)ad(e[a],t,r,s)},ad=(e,t,r,s)=>{"string"==typeof e?ah(e,t,r):"function"==typeof e?ap(e,t,r,s):af(e,t,r,s)},ah=(e,t,r)=>{(""===e?t:am(t,e)).classGroupId=r},ap=(e,t,r,s)=>{ag(e)?au(e(s),t,r,s):(null===t.validators&&(t.validators=[]),t.validators.push({classGroupId:r,validator:e}))},af=(e,t,r,s)=>{let n=Object.entries(e),a=n.length;for(let e=0;e<a;e++){let[a,i]=n[e];au(i,am(t,a),r,s)}},am=(e,t)=>{let r=e,s=t.split("-"),n=s.length;for(let e=0;e<n;e++){let t=s[e],n=r.nextPart.get(t);n||(n=ai(),r.nextPart.set(t,n)),r=n}return r},ag=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,ab=[],ay=(e,t,r,s,n)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:s,isExternal:n}),aw=/\s+/,av=e=>{let t;if("string"==typeof e)return e;let r="";for(let s=0;s<e.length;s++)e[s]&&(t=av(e[s]))&&(r&&(r+=" "),r+=t);return r},ak=[],a_=e=>{let t=t=>t[e]||ak;return t.isThemeGetter=!0,t.themeKey=e,t},aS=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ax=/^\((?:(\w[\w-]*):)?(.+)\)$/i,aA=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,aT=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,aR=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,aE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,aI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,aj=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aO=e=>aA.test(e),a$=e=>!!e&&!Number.isNaN(Number(e)),aC=e=>!!e&&Number.isInteger(Number(e)),aP=e=>e.endsWith("%")&&a$(e.slice(0,-1)),aN=e=>aT.test(e),aD=()=>!0,aL=e=>aR.test(e)&&!aE.test(e),aU=()=>!1,aq=e=>aI.test(e),aM=e=>aj.test(e),aB=e=>!aW(e)&&!aX(e),az=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),aF=e=>a6(e,ie,aU),aW=e=>aS.test(e),aH=e=>a6(e,it,aL),aG=e=>a6(e,ir,a$),aK=e=>a6(e,ia,aD),aJ=e=>a6(e,is,aU),aV=e=>a6(e,a9,aU),aY=e=>a6(e,a7,aM),aZ=e=>a6(e,ii,aq),aX=e=>ax.test(e),aQ=e=>a8(e,it),a0=e=>a8(e,is),a1=e=>a8(e,a9),a2=e=>a8(e,ie),a3=e=>a8(e,a7),a4=e=>a8(e,ii,!0),a5=e=>a8(e,ia,!0),a6=(e,t,r)=>{let s=aS.exec(e);return!!s&&(s[1]?t(s[1]):r(s[2]))},a8=(e,t,r=!1)=>{let s=ax.exec(e);return!!s&&(s[1]?t(s[1]):r)},a9=e=>"position"===e||"percentage"===e,a7=e=>"image"===e||"url"===e,ie=e=>"length"===e||"size"===e||"bg-size"===e,it=e=>"length"===e,ir=e=>"number"===e,is=e=>"family-name"===e,ia=e=>"number"===e||"weight"===e,ii=e=>"shadow"===e,io=(m=()=>{let e=a_("color"),t=a_("font"),r=a_("text"),s=a_("font-weight"),n=a_("tracking"),a=a_("leading"),i=a_("breakpoint"),o=a_("container"),l=a_("spacing"),c=a_("radius"),u=a_("shadow"),d=a_("inset-shadow"),h=a_("text-shadow"),p=a_("drop-shadow"),f=a_("blur"),m=a_("perspective"),g=a_("aspect"),b=a_("ease"),y=a_("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...v(),aX,aW],_=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],x=()=>[aX,aW,l],A=()=>[aO,"full","auto",...x()],T=()=>[aC,"none","subgrid",aX,aW],R=()=>["auto",{span:["full",aC,aX,aW]},aC,aX,aW],E=()=>[aC,"auto",aX,aW],I=()=>["auto","min","max","fr",aX,aW],j=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],O=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...x()],C=()=>[aO,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],P=()=>[o,aO,"screen","full","dvw","lvw","svw","min","max","fit",...x()],N=()=>[aO,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],D=()=>[e,aX,aW],L=()=>[...v(),a1,aV,{position:[aX,aW]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",a2,aF,{size:[aX,aW]}],M=()=>[aP,aQ,aH],B=()=>["","none","full",c,aX,aW],z=()=>["",a$,aQ,aH],F=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[a$,aP,a1,aV],G=()=>["","none",f,aX,aW],K=()=>["none",a$,aX,aW],J=()=>["none",a$,aX,aW],V=()=>[a$,aX,aW],Y=()=>[aO,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[aN],breakpoint:[aN],color:[aD],container:[aN],"drop-shadow":[aN],ease:["in","out","in-out"],font:[aB],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[aN],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[aN],shadow:[aN],spacing:["px",a$],text:[aN],"text-shadow":[aN],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aO,aW,aX,g]}],container:["container"],"container-type":[{"@container":["","normal","size",aX,aW]}],"container-named":[az],columns:[{columns:[a$,"auto",aW,aX,o]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[aC,"auto",aX,aW]}],basis:[{basis:[aO,"full","auto",o,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[a$,aO,"auto","initial","none",aW]}],grow:[{grow:["",a$,aX,aW]}],shrink:[{shrink:["",a$,aX,aW]}],order:[{order:[aC,"first","last","none",aX,aW]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...j(),"normal"]}],"justify-items":[{"justify-items":[...O(),"normal"]}],"justify-self":[{"justify-self":["auto",...O()]}],"align-content":[{content:["normal",...j()]}],"align-items":[{items:[...O(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...O(),{baseline:["","last"]}]}],"place-content":[{"place-content":j()}],"place-items":[{"place-items":[...O(),"baseline"]}],"place-self":[{"place-self":["auto",...O()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:C()}],"inline-size":[{inline:["auto",...P()]}],"min-inline-size":[{"min-inline":["auto",...P()]}],"max-inline-size":[{"max-inline":["none",...P()]}],"block-size":[{block:["auto",...N()]}],"min-block-size":[{"min-block":["auto",...N()]}],"max-block-size":[{"max-block":["none",...N()]}],w:[{w:[o,"screen",...C()]}],"min-w":[{"min-w":[o,"screen","none",...C()]}],"max-w":[{"max-w":[o,"screen","none","prose",{screen:[i]},...C()]}],h:[{h:["screen","lh",...C()]}],"min-h":[{"min-h":["screen","lh","none",...C()]}],"max-h":[{"max-h":["screen","lh","none",...C()]}],"font-size":[{text:["base",r,aQ,aH]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,a5,aK]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",aP,aW]}],"font-family":[{font:[a0,aJ,t]}],"font-features":[{"font-features":[aW]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,aX,aW]}],"line-clamp":[{"line-clamp":[a$,"none",aX,aG]}],leading:[{leading:["none",a,...x()]}],"list-image":[{"list-image":["none",aX,aW]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",aX,aW]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:[a$,"from-font","auto",aX,aH]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[a$,"auto",aX,aW]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[aC,aX,aW]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",aX,aW]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",aX,aW]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},aC,aX,aW],radial:["",aX,aW],conic:["",aC,aX,aW]},a3,aY]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:M()}],"gradient-via-pos":[{via:M()}],"gradient-to-pos":[{to:M()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-bs":[{"border-bs":z()}],"border-w-be":[{"border-be":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...F(),"hidden","none"]}],"divide-style":[{divide:[...F(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...F(),"none","hidden"]}],"outline-offset":[{"outline-offset":[a$,aX,aW]}],"outline-w":[{outline:["",a$,aQ,aH]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","inner","none",u,a4,aZ]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",d,a4,aZ]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[a$,aH]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",h,a4,aZ]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[a$,aX,aW]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[a$]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[aX,aW]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[a$]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",aX,aW]}],filter:[{filter:["","none",aX,aW]}],blur:[{blur:G()}],brightness:[{brightness:[a$,aX,aW]}],contrast:[{contrast:[a$,aX,aW]}],"drop-shadow":[{"drop-shadow":["","none",p,a4,aZ]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",a$,aX,aW]}],"hue-rotate":[{"hue-rotate":[a$,aX,aW]}],invert:[{invert:["",a$,aX,aW]}],saturate:[{saturate:[a$,aX,aW]}],sepia:[{sepia:["",a$,aX,aW]}],"backdrop-filter":[{"backdrop-filter":["","none",aX,aW]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[a$,aX,aW]}],"backdrop-contrast":[{"backdrop-contrast":[a$,aX,aW]}],"backdrop-grayscale":[{"backdrop-grayscale":["",a$,aX,aW]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[a$,aX,aW]}],"backdrop-invert":[{"backdrop-invert":["",a$,aX,aW]}],"backdrop-opacity":[{"backdrop-opacity":[a$,aX,aW]}],"backdrop-saturate":[{"backdrop-saturate":[a$,aX,aW]}],"backdrop-sepia":[{"backdrop-sepia":["",a$,aX,aW]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",aX,aW]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[a$,"initial",aX,aW]}],ease:[{ease:["linear","initial",b,aX,aW]}],delay:[{delay:[a$,aX,aW]}],animate:[{animate:["none",y,aX,aW]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,aX,aW]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:J()}],"scale-x":[{"scale-x":J()}],"scale-y":[{"scale-y":J()}],"scale-z":[{"scale-z":J()}],"scale-3d":["scale-3d"],skew:[{skew:V()}],"skew-x":[{"skew-x":V()}],"skew-y":[{"skew-y":V()}],transform:[{transform:[aX,aW,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Y()}],"translate-x":[{"translate-x":Y()}],"translate-y":[{"translate-y":Y()}],"translate-z":[{"translate-z":Y()}],"translate-none":["translate-none"],zoom:[{zoom:[aC,aX,aW]}],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",aX,aW]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":D()}],"scrollbar-track-color":[{"scrollbar-track":D()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",aX,aW]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[a$,aQ,aH,aG]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},l=e=>{let t=a(e);if(t)return t;let r=((e,t)=>{let{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:n,sortModifiers:a,postfixLookupClassGroupIds:i}=t,o=[],l=e.trim().split(aw),c="";for(let e=l.length-1;e>=0;e-=1){let t,u=l[e],{isExternal:d,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:m}=r(u);if(d){c=u+(c.length>0?" "+c:c);continue}let g=!!m;if(g){let e=(t=s(f.substring(0,m)))&&i[t]?s(f):void 0;e&&e!==t&&(t=e,g=!1)}else t=s(f);if(!t){if(!g||!(t=s(f))){c=u+(c.length>0?" "+c:c);continue}g=!1}let b=0===h.length?"":1===h.length?h[0]:a(h).join(":"),y=p?b+"!":b,w=y+t;if(o.indexOf(w)>-1)continue;o.push(w);let v=n(t,g);for(let e=0;e<v.length;++e){let t=v[e];o.push(y+t)}c=u+(c.length>0?" "+c:c)}return c})(e,n);return i(e,r),r},o=e=>{var t;let r;return a=(n={cache:(e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,r=Object.create(null),s=Object.create(null),n=(n,a)=>{r[n]=a,++t>e&&(t=0,s=r,r=Object.create(null))};return{get(e){let t=r[e];return void 0!==t?t:void 0!==(t=s[e])?(n(e,t),t):void 0},set(e,t){e in r?r[e]=t:n(e,t)}}})((t=[].reduce((e,t)=>t(e),m())).cacheSize),parseClassName:(e=>{let{prefix:t,experimentalParseClassName:r}=e,s=e=>{let t,r=[],s=0,n=0,a=0,i=e.length;for(let o=0;o<i;o++){let i=e[o];if(0===s&&0===n){if(":"===i){r.push(e.slice(a,o)),a=o+1;continue}if("/"===i){t=o;continue}}"["===i?s++:"]"===i?s--:"("===i?n++:")"===i&&n--}let o=0===r.length?e:e.slice(a),l=o,c=!1;return o.endsWith("!")?(l=o.slice(0,-1),c=!0):o.startsWith("!")&&(l=o.slice(1),c=!0),ay(r,c,l,t&&t>a?t-a:void 0)};if(t){let e=t+":",r=s;s=t=>t.startsWith(e)?r(t.slice(e.length)):ay(ab,!1,t,void 0,!0)}if(r){let e=s;s=t=>r({className:t,parseClassName:e})}return s})(t),sortModifiers:(r=new Map,t.orderSensitiveModifiers.forEach((e,t)=>{r.set(e,1e6+t)}),e=>{let t=[],s=[];for(let n=0;n<e.length;n++){let a=e[n],i="["===a[0],o=r.has(a);i||o?(s.length>0&&(s.sort(),t.push(...s),s=[]),t.push(a)):s.push(a)}return s.length>0&&(s.sort(),t.push(...s)),t}),postfixLookupClassGroupIds:(e=>{let t=Object.create(null),r=e.postfixLookupClassGroups;if(r)for(let e=0;e<r.length;e++)t[r[e]]=!0;return t})(t),...(e=>{let t=(e=>{let{theme:t,classGroups:r}=e;return ac(r,t)})(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]")){var r;let t,s,n;return -1===(r=e).slice(1,-1).indexOf(":")?void 0:(s=(t=r.slice(1,-1)).indexOf(":"),(n=t.slice(0,s))?"arbitrary.."+n:void 0)}let s=e.split("-"),n=+(""===s[0]&&s.length>1);return al(s,n,t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=s[e],n=r[e];if(t){if(n){let e=Array(n.length+t.length);for(let t=0;t<n.length;t++)e[t]=n[t];for(let r=0;r<t.length;r++)e[n.length+r]=t[r];return e}return t}return n||ao}return r[e]||ao}}})(t)}).cache.get,i=n.cache.set,o=l,l(e)},(...e)=>o(((...e)=>{let t,r,s=0,n="";for(;s<e.length;)(t=e[s++])&&(r=av(t))&&(n&&(n+=" "),n+=r);return n})(...e)));function il(...e){return io(function(){for(var e,t,r=0,s="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=function e(t){var r,s,n="";if("string"==typeof t||"number"==typeof t)n+=t;else if("object"==typeof t)if(Array.isArray(t)){var a=t.length;for(r=0;r<a;r++)t[r]&&(s=e(t[r]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}(e))&&(s&&(s+=" "),s+=t);return s}(e))}let ic={brand:"border-l-brand",err:"border-l-err",warn:"border-l-warn-icon"};function iu({icon:e,tone:t="brand",meta:r,action:s,className:n,children:a}){return(0,eV.jsxs)("div",{className:il("flex gap-2.5 rounded-md border border-line border-l-[3px] bg-surface-2 px-3 py-2.5 text-[13px]",ic[t],n),children:[(0,eV.jsx)("span",{className:"mt-px shrink-0 text-brand",children:e}),(0,eV.jsxs)("div",{className:"min-w-0 flex-1",children:[a,r&&(0,eV.jsx)("span",{className:"mt-1 block text-[12px] text-ink-faint",children:r})]}),s&&(0,eV.jsx)("div",{className:"shrink-0",children:s})]})}let id={crit:"err",warn:"warn",info:"brand"};function ih({note:e,now:t,showApp:r}){let s=["AI note",`from ${e.from}`,e.model,(0,eg.ago)(e.at,t),r&&e.appName?e.appName:null,"written by an agent, can be wrong"].filter(Boolean).join(" · ");return(0,eV.jsxs)(iu,{icon:(0,eV.jsx)(n7,{size:18,"aria-hidden":!0}),tone:id[e.severity]??"brand",meta:s,action:(0,eV.jsx)(n6.DismissNoteButton,{id:e.id}),children:[(0,eV.jsx)("b",{className:"font-medium",children:(0,eV.jsx)(ae.MaskedText,{text:e.title})}),(0,eV.jsx)(aa,{source:e.body})]})}async function ip({appId:e}){let{ok:t}=await n1("owner");if(!t)return null;let r=new Date,s=await n5(e,r).catch(()=>[]);return s.length?(0,eV.jsxs)("div",{className:"mb-3 flex flex-col gap-2.5",children:[s.length>1&&(0,eV.jsx)("div",{className:"flex justify-end",children:(0,eV.jsx)(n6.DismissAllNotesButton,{ids:s.map(e=>e.id)})}),s.map(t=>(0,eV.jsx)(ih,{note:t,now:r,showApp:void 0===e},t.id))]}):null}e.s(["f",0,ip],64858);let im=n9("outline","message-2","Message2",[["path",{d:"M8 9h8",key:"svg-0"}],["path",{d:"M8 13h6",key:"svg-1"}],["path",{d:"M9 18h-3a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-3l-3 3l-3 -3",key:"svg-2"}]]);var ig=e.i(133791),ib=e.i(515073);async function iy({count:e}){let{ok:t}=await n1("owner");if(!t)return null;if(!await eU.provider().catch(()=>null))return(await n5(void 0,new Date).catch(()=>[])).length?null:(0,eV.jsxs)("p",{className:"mb-3 flex items-center gap-1.5 text-[13px] text-ink-soft",children:[(0,eV.jsx)(n7,{size:16,"aria-hidden":!0,className:"text-ink-faint"}),(0,eV.jsx)(ig.default,{href:"/ai/connect",children:ej.v.recConnect})]});if(0===e)return null;let r=await eG().catch(()=>null);if(!r)return(0,eV.jsxs)("p",{className:"mb-3 flex items-center gap-1.5 text-[13px] text-ink-soft",children:[(0,eV.jsx)(im,{size:16,"aria-hidden":!0,className:"text-ink-faint"}),"No AI summary yet. ",(0,eV.jsx)(ib.RegenerateButton,{label:"Summarise"})]});let s=new Date;return(0,eV.jsxs)(iu,{className:"mb-3",icon:(0,eV.jsx)(im,{size:18,"aria-hidden":!0}),meta:(0,eV.jsxs)(eV.Fragment,{children:[`AI \xb7 ${r.model} \xb7 ${(0,eg.ago)(new Date(r.at),s)} \xb7 from ${r.count} items, names aliased \xb7 can be wrong, check the items below \xb7 `,(0,eV.jsx)(ib.RegenerateButton,{label:"Regenerate"})]}),children:[(0,eV.jsx)("b",{className:"font-medium",children:"Summary"}),(0,eV.jsx)(aa,{source:r.text})]})}e.s(["f",0,iy],248744);var iw=e.i(898757);let iv=async()=>({report:null,prefs:{disabled:[],defaultModel:null},allowed:iw._});async function ik(e=new Date){let[t,r]=await Promise.all([iv().catch(()=>null),(0,I.M)().then(()=>!0,()=>!1)]),s=!!t&&(t.report,!1);return{agConnected:s,agEnabled:(s&&t&&(t.report,t.prefs,t.allowed),[]),providerReady:r}}let i_={id:n3.S.id,status:n3.S.status,answer:n3.S.answer,client:n3.S.answeredByClient,model:n3.S.answeredByModel,requestedModel:n3.S.requestedModel,createdAt:n3.S.createdAt,answeredAt:n3.S.answeredAt};async function iS(e,t,r){let s,[n]=await (0,T.db)().select(i_).from(n3.S).where((0,x.and)((0,x.eq)(n3.S.contextKind,e),(0,x.eq)(n3.S.contextId,t))).orderBy((0,n2.desc)(n3.S.createdAt)).limit(1);return n?(s="pending"===n.status&&r.getTime()-n.createdAt.getTime()>6048e5,{...n,status:s?"expired":n.status}):null}var ix=e.i(813359);async function iA({appId:e}){let{ok:t}=await n1("owner");if(!t)return null;let r=new Date,[s,n,a]=await Promise.all([eU.provider().catch(()=>null),iS("app",e,r).catch(()=>null),ik(r).catch(()=>null)]),i=n?{...n,createdAt:n.createdAt.toISOString(),answeredAt:n.answeredAt?.toISOString()??null}:null;return(0,eV.jsx)(ix.WhyAi,{appId:e,provider:s?{model:s.model}:null,question:i,nowMs:r.getTime(),agConnected:a?.agConnected??!1})}function iT({title:e,meta:t,flush:r,className:s,children:n}){return(0,eV.jsxs)("section",{className:il("min-w-0 rounded-lg border border-line bg-surface",s),children:[e&&(0,eV.jsxs)("div",{className:il("flex flex-wrap items-center gap-2 px-[18px] pt-3.5",r?"pb-2.5":"pb-1.5"),children:[(0,eV.jsx)("h2",{className:"text-[15px]",children:e}),t&&(0,eV.jsx)("span",{className:"ml-auto flex items-center gap-1.5 text-[12.5px] text-ink-soft",children:t})]}),r?n:(0,eV.jsx)("div",{className:"px-[18px] pb-4 pt-2",children:n})]})}e.s(["f",0,iA],379593),n9("outline","alert-circle","AlertCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]]),n9("outline","alert-triangle","AlertTriangle",[["path",{d:"M12 9v4",key:"svg-0"}],["path",{d:"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]]),n9("outline","circle-check","CircleCheck",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]]),n9("outline","circle-dashed","CircleDashed",[["path",{d:"M8.56 3.69a9 9 0 0 0 -2.92 1.95",key:"svg-0"}],["path",{d:"M3.69 8.56a9 9 0 0 0 -.69 3.44",key:"svg-1"}],["path",{d:"M3.69 15.44a9 9 0 0 0 1.95 2.92",key:"svg-2"}],["path",{d:"M8.56 20.31a9 9 0 0 0 3.44 .69",key:"svg-3"}],["path",{d:"M15.44 20.31a9 9 0 0 0 2.92 -1.95",key:"svg-4"}],["path",{d:"M20.31 15.44a9 9 0 0 0 .69 -3.44",key:"svg-5"}],["path",{d:"M20.31 8.56a9 9 0 0 0 -1.95 -2.92",key:"svg-6"}],["path",{d:"M15.44 3.69a9 9 0 0 0 -3.44 -.69",key:"svg-7"}]]),n9("outline","circle-x","CircleX",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]]),n9("outline","help-circle","HelpCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 16v.01",key:"svg-1"}],["path",{d:"M12 13a2 2 0 0 0 .914 -3.782a1.98 1.98 0 0 0 -2.414 .483",key:"svg-2"}]]),n9("outline","info-circle","InfoCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]]),n9("outline","loader-2","Loader2",[["path",{d:"M12 3a9 9 0 1 0 9 9",key:"svg-0"}]]),n9("outline","moon","Moon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008",key:"svg-0"}]]),n9("outline","player-pause","PlayerPause",[["path",{d:"M6 6a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -12",key:"svg-0"}],["path",{d:"M14 6a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -12",key:"svg-1"}]]),n9("outline","tool","Tool",[["path",{d:"M7 10h3v-3l-3.5 -3.5a6 6 0 0 1 8 8l6 6a2 2 0 0 1 -3 3l-6 -6a6 6 0 0 1 -8 -8l3.5 3.5",key:"svg-0"}]]);var iR=e.i(27295),iE=e.i(657753),iI=e.i(783671),ij=e.i(809303),iO=e.i(564769);let i$={recheck:"Runs the monitor's check once, like Check now on the monitor.",neon_wake:"Wakes a suspended Neon compute, like Wake on the database page.",supabase_keepalive:"Sends one keep-alive query to a Supabase project close to auto-pause, like Keep active.",supabase_restore:"Restores a paused Supabase project.",vercel_redeploy:"Redeploys the current production deployment.",vercel_rollback:"Rolls production back to the previous ready deployment.",github_bump_pr:"Opens a pull request on a new branch that raises vulnerable packages to their fixed versions (needs the GitHub PR-write token).",daily_rerun:"Calls the console's daily job again when its heartbeat is down. Always asks for approval.",domain_recheck:"Re-reads a domain's TLS certificate and expiry when its certificate looks close to expiry, like Re-check on Domains.",monitor_update_url:"Points an uptime monitor at its app's new domain when the app moved, keeping the path, like Update monitor on Uptime."};async function iC(){let[e,t,r]=await Promise.all([(0,ij.I)(),(0,ij.K)(),(0,ij.X)()]),s=[10,15,20,30,45,60,90,120].filter(e=>e>=ij.l&&e<=ij.n),n=ij.r.map(e=>({kind:e,label:iO.H[e].label,risky:"risky"===iO.H[e].risk,what:i$[e]}));return(0,eV.jsxs)(iT,{title:"Auto-actions",flush:!0,meta:"All off by default",children:[(0,eV.jsxs)("p",{className:"px-[18px] pb-3 text-ink-soft",children:["When a firing alert brings a proposal for one of these actions, a switched-on kind runs without asking and you get a short Telegram line afterwards. Everything else waits for you on ",(0,eV.jsx)(ig.default,{href:"/auto-actions",children:"Auto-actions"}),". Auto-run only does what the console button does, through the same checks, and every run is in the audit log (Events)."]}),(0,eV.jsx)(iR.AutoRunForm,{saved:e,rows:n}),(0,eV.jsxs)("div",{className:"border-t border-line px-[18px] pb-4 pt-3.5",children:[(0,eV.jsx)("h3",{className:"mb-1.5 text-[14px]",children:"Auto-rollback after a bad deploy"}),(0,eV.jsxs)("p",{className:"mb-2.5 text-ink-soft",children:["Off by default. When on, a new production deploy that breaks the app is rolled back to the previous one without asking. Only ",(0,eV.jsx)("span",{className:"font-mono text-[12.5px]",children:"vercel_rollback"}),", only within the first N minutes after a new production deploy goes live, only when a monitor is down or the logs show an error spike, at most once per deployment (and never twice for one app within 2 hours), and every run is reported on Telegram and in Events. Failed builds never go live on Vercel, so this is for builds that succeed but break at runtime."]}),(0,eV.jsx)(iE.AutoRollbackForm,{saved:t,choices:s})]}),(0,eV.jsxs)("div",{className:"border-t border-line px-[18px] pb-4 pt-3.5",children:[(0,eV.jsx)("h3",{className:"mb-1.5 text-[14px]",children:"Automatic security fixes"}),(0,eV.jsx)("p",{className:"mb-2 text-ink-soft",children:"On by default. When a dependency scan finds a critical, high or moderate advisory with a fix, Watchbell fixes it end to end (the scan and the Next.js check run every 6 hours and right after each production deploy):"}),(0,eV.jsxs)("ol",{className:"mb-2.5 list-decimal pl-5 text-ink-soft [&_li]:mt-0.5",children:[(0,eV.jsx)("li",{children:"opens the update PR itself (package.json only, on a new watchpost/deps-… branch), only for direct packages that stay in their major version, never twice for the same package while a PR is open;"}),(0,eV.jsx)("li",{children:"waits for GitHub's checks (all green), then Vercel's preview of the PR (READY);"}),(0,eV.jsx)("li",{children:'tests the preview: "/" and up to 3 monitor paths must answer 200–399 within 15 s (behind Vercel Authentication: 3 minutes without error lines in the preview\'s logs);'}),(0,eV.jsx)("li",{children:"squash-merges it, only while auto-rollback is on: the production deploy then runs on Vercel and auto-rollback guards its first minutes."})]}),(0,eV.jsx)("p",{className:"mb-2.5 text-ink-soft",children:'Anything failing, or not done within 45 minutes, leaves the PR open marked "needs a look". A major update, a transitive package or a severity you switched off waits for your approval on Auto-actions, as before. Every PR opened and every merge or stop is sent to Telegram and logged in Events. Needs the GitHub PR-write token on Connections.'}),(0,eV.jsx)(iI.AutoSecurityForm,{saved:r,rollbackOn:t.enabled})]})]})}e.s(["f",0,iC],717799)},20019,e=>{var t=e.i(310086);let r=(0,t.registerClientReference)(function(){throw Error("Attempted to call DismissAllNotesButton() from the server but DismissAllNotesButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/dismiss-note-button.tsx","DismissAllNotesButton"),s=(0,t.registerClientReference)(function(){throw Error("Attempted to call DismissNoteButton() from the server but DismissNoteButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/dismiss-note-button.tsx","DismissNoteButton");e.s(["DismissAllNotesButton",0,r,"DismissNoteButton",0,s])},843305,e=>{var t=e.i(20019);e.n(t)},903419,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call RegenerateButton() from the server but RegenerateButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/regenerate-button.tsx","RegenerateButton");e.s(["RegenerateButton",0,t])},515073,e=>{var t=e.i(903419);e.n(t)},637858,e=>{let t=(0,e.i(310086).registerClientReference)(function(){throw Error("Attempted to call WhyAi() from the server but WhyAi is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/private/slots/why-ai.tsx","WhyAi");e.s(["WhyAi",0,t])},813359,e=>{var t=e.i(637858);e.n(t)}],31194,(e,t,r)=>{let{createClientModuleProxy:s}=e.r(310086);e.n(s("[project]/node_modules/next/dist/client/app-dir/link.js"))},547850,(e,t,r)=>{var s={943:function(t,r){!function(s){"use strict";var n="function",a="undefined",i="object",o="string",l="major",c="model",u="name",d="type",h="vendor",p="version",f="architecture",m="console",g="mobile",b="tablet",y="smarttv",w="wearable",v="embedded",k="Amazon",_="Apple",S="ASUS",x="BlackBerry",A="Browser",T="Chrome",R="Firefox",E="Google",I="Huawei",j="Microsoft",O="Motorola",$="Opera",C="Samsung",P="Sharp",N="Sony",D="Xiaomi",L="Zebra",U="Facebook",q="Chromium OS",M="Mac OS",B=function(e,t){var r={};for(var s in e)t[s]&&t[s].length%2==0?r[s]=t[s].concat(e[s]):r[s]=e[s];return r},z=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},F=function(e,t){return typeof e===o&&-1!==W(t).indexOf(W(e))},W=function(e){return e.toLowerCase()},H=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===a?e:e.substring(0,350)},G=function(e,t){for(var r,s,a,o,l,c,u=0;u<t.length&&!l;){var d=t[u],h=t[u+1];for(r=s=0;r<d.length&&!l&&d[r];)if(l=d[r++].exec(e))for(a=0;a<h.length;a++)c=l[++s],typeof(o=h[a])===i&&o.length>0?2===o.length?typeof o[1]==n?this[o[0]]=o[1].call(this,c):this[o[0]]=o[1]:3===o.length?typeof o[1]!==n||o[1].exec&&o[1].test?this[o[0]]=c?c.replace(o[1],o[2]):void 0:this[o[0]]=c?o[1].call(this,c,o[2]):void 0:4===o.length&&(this[o[0]]=c?o[3].call(this,c.replace(o[1],o[2])):void 0):this[o]=c||void 0;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===i&&t[r].length>0){for(var s=0;s<t[r].length;s++)if(F(t[r][s],e))return"?"===r?void 0:r}else if(F(t[r],e))return"?"===r?void 0:r;return e},J={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},V={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[p,[u,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[p,[u,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[u,p],[/opios[\/ ]+([\w\.]+)/i],[p,[u,$+" Mini"]],[/\bopr\/([\w\.]+)/i],[p,[u,$]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[u,p],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[p,[u,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[p,[u,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[p,[u,"WeChat"]],[/konqueror\/([\w\.]+)/i],[p,[u,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[p,[u,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[p,[u,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[u,/(.+)/,"$1 Secure "+A],p],[/\bfocus\/([\w\.]+)/i],[p,[u,R+" Focus"]],[/\bopt\/([\w\.]+)/i],[p,[u,$+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[p,[u,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[p,[u,"Dolphin"]],[/coast\/([\w\.]+)/i],[p,[u,$+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[p,[u,"MIUI "+A]],[/fxios\/([-\w\.]+)/i],[p,[u,R]],[/\bqihu|(qi?ho?o?|360)browser/i],[[u,"360 "+A]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[u,/(.+)/,"$1 "+A],p],[/(comodo_dragon)\/([\w\.]+)/i],[[u,/_/g," "],p],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[u,p],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[u],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[u,U],p],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[u,p],[/\bgsa\/([\w\.]+) .*safari\//i],[p,[u,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[p,[u,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[p,[u,T+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[u,T+" WebView"],p],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[p,[u,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[u,p],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[p,[u,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[p,u],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[u,[p,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[u,p],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[u,"Netscape"],p],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[p,[u,R+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[u,p],[/(cobalt)\/([\w\.]+)/i],[u,[p,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[f,"amd64"]],[/(ia32(?=;))/i],[[f,W]],[/((?:i[346]|x)86)[;\)]/i],[[f,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[f,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[f,"armhf"]],[/windows (ce|mobile); ppc;/i],[[f,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[f,/ower/,"",W]],[/(sun4\w)[;\)]/i],[[f,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[f,W]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[h,C],[d,b]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[c,[h,C],[d,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[c,[h,_],[d,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[h,_],[d,b]],[/(macintosh);/i],[c,[h,_]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[h,P],[d,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[h,I],[d,b]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[h,I],[d,g]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[c,/_/g," "],[h,D],[d,g]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[h,D],[d,b]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[h,"OPPO"],[d,g]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[h,"Vivo"],[d,g]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[c,[h,"Realme"],[d,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[h,O],[d,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[h,O],[d,b]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[h,"LG"],[d,b]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[h,"LG"],[d,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[h,"Lenovo"],[d,b]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[h,"Nokia"],[d,g]],[/(pixel c)\b/i],[c,[h,E],[d,b]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[h,E],[d,g]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[h,N],[d,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[h,N],[d,b]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[h,"OnePlus"],[d,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[h,k],[d,b]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[h,k],[d,g]],[/(playbook);[-\w\),; ]+(rim)/i],[c,h,[d,b]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[h,x],[d,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[h,S],[d,b]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[h,S],[d,g]],[/(nexus 9)/i],[c,[h,"HTC"],[d,b]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[c,/_/g," "],[d,g]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[h,"Acer"],[d,b]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[h,"Meizu"],[d,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,c,[d,g]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,c,[d,b]],[/(surface duo)/i],[c,[h,j],[d,b]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[h,"Fairphone"],[d,g]],[/(u304aa)/i],[c,[h,"AT&T"],[d,g]],[/\bsie-(\w*)/i],[c,[h,"Siemens"],[d,g]],[/\b(rct\w+) b/i],[c,[h,"RCA"],[d,b]],[/\b(venue[\d ]{2,7}) b/i],[c,[h,"Dell"],[d,b]],[/\b(q(?:mv|ta)\w+) b/i],[c,[h,"Verizon"],[d,b]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[h,"Barnes & Noble"],[d,b]],[/\b(tm\d{3}\w+) b/i],[c,[h,"NuVision"],[d,b]],[/\b(k88) b/i],[c,[h,"ZTE"],[d,b]],[/\b(nx\d{3}j) b/i],[c,[h,"ZTE"],[d,g]],[/\b(gen\d{3}) b.+49h/i],[c,[h,"Swiss"],[d,g]],[/\b(zur\d{3}) b/i],[c,[h,"Swiss"],[d,b]],[/\b((zeki)?tb.*\b) b/i],[c,[h,"Zeki"],[d,b]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],c,[d,b]],[/\b(ns-?\w{0,9}) b/i],[c,[h,"Insignia"],[d,b]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[h,"NextBook"],[d,b]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],c,[d,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],c,[d,g]],[/\b(ph-1) /i],[c,[h,"Essential"],[d,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[h,"Envizen"],[d,b]],[/\b(trio[-\w\. ]+) b/i],[c,[h,"MachSpeed"],[d,b]],[/\btu_(1491) b/i],[c,[h,"Rotor"],[d,b]],[/(shield[\w ]+) b/i],[c,[h,"Nvidia"],[d,b]],[/(sprint) (\w+)/i],[h,c,[d,g]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[h,j],[d,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[h,L],[d,b]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[h,L],[d,g]],[/smart-tv.+(samsung)/i],[h,[d,y]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[h,C],[d,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,"LG"],[d,y]],[/(apple) ?tv/i],[h,[c,_+" TV"],[d,y]],[/crkey/i],[[c,T+"cast"],[h,E],[d,y]],[/droid.+aft(\w)( bui|\))/i],[c,[h,k],[d,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[h,P],[d,y]],[/(bravia[\w ]+)( bui|\))/i],[c,[h,N],[d,y]],[/(mitv-\w{5}) bui/i],[c,[h,D],[d,y]],[/Hbbtv.*(technisat) (.*);/i],[h,c,[d,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,H],[c,H],[d,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,c,[d,m]],[/droid.+; (shield) bui/i],[c,[h,"Nvidia"],[d,m]],[/(playstation [345portablevi]+)/i],[c,[h,N],[d,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[h,j],[d,m]],[/((pebble))app/i],[h,c,[d,w]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[c,[h,_],[d,w]],[/droid.+; (glass) \d/i],[c,[h,E],[d,w]],[/droid.+; (wt63?0{2,3})\)/i],[c,[h,L],[d,w]],[/(quest( 2| pro)?)/i],[c,[h,U],[d,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[d,v]],[/(aeobc)\b/i],[c,[h,k],[d,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[c,[d,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[d,b]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,b]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,g]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[p,[u,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[p,[u,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[u,p],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[p,u]],os:[[/microsoft (windows) (vista|xp)/i],[u,p],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[u,[p,K,J]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[u,"Windows"],[p,K,J]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[p,/_/g,"."],[u,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[u,M],[p,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[p,u],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[u,p],[/\(bb(10);/i],[p,[u,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[p,[u,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[p,[u,R+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[p,[u,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[p,[u,"watchOS"]],[/crkey\/([\d\.]+)/i],[p,[u,T+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[u,q],p],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[u,p],[/(sunos) ?([\w\.\d]*)/i],[[u,"Solaris"],p],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[u,p]]},Y=function(e,t){if(typeof e===i&&(t=e,e=void 0),!(this instanceof Y))return new Y(e,t).getResult();var r=typeof s!==a&&s.navigator?s.navigator:void 0,m=e||(r&&r.userAgent?r.userAgent:""),y=r&&r.userAgentData?r.userAgentData:void 0,w=t?B(V,t):V,v=r&&r.userAgent==m;return this.getBrowser=function(){var e,t={};return t[u]=void 0,t[p]=void 0,G.call(t,m,w.browser),t[l]=typeof(e=t[p])===o?e.replace(/[^\d\.]/g,"").split(".")[0]:void 0,v&&r&&r.brave&&typeof r.brave.isBrave==n&&(t[u]="Brave"),t},this.getCPU=function(){var e={};return e[f]=void 0,G.call(e,m,w.cpu),e},this.getDevice=function(){var e={};return e[h]=void 0,e[c]=void 0,e[d]=void 0,G.call(e,m,w.device),v&&!e[d]&&y&&y.mobile&&(e[d]=g),v&&"Macintosh"==e[c]&&r&&typeof r.standalone!==a&&r.maxTouchPoints&&r.maxTouchPoints>2&&(e[c]="iPad",e[d]=b),e},this.getEngine=function(){var e={};return e[u]=void 0,e[p]=void 0,G.call(e,m,w.engine),e},this.getOS=function(){var e={};return e[u]=void 0,e[p]=void 0,G.call(e,m,w.os),v&&!e[u]&&y&&"Unknown"!=y.platform&&(e[u]=y.platform.replace(/chrome os/i,q).replace(/macos/i,M)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return m},this.setUA=function(e){return m=typeof e===o&&e.length>350?H(e,350):e,this},this.setUA(m),this};if(Y.VERSION="1.0.35",Y.BROWSER=z([u,p,l]),Y.CPU=z([f]),Y.DEVICE=z([c,h,d,m,g,y,b,w,v]),Y.ENGINE=Y.OS=z([u,p]),typeof r!==a)t.exports&&(r=t.exports=Y),r.UAParser=Y;else if(typeof define===n&&define.amd)e.r,void 0!==Y&&e.v(Y);else typeof s!==a&&(s.UAParser=Y);var Z=typeof s!==a&&(s.jQuery||s.Zepto);if(Z&&!Z.ua){var X=new Y;Z.ua=X.getResult(),Z.ua.get=function(){return X.getUA()},Z.ua.set=function(e){X.setUA(e);var t=X.getResult();for(var r in t)Z.ua[r]=t[r]}}}(this)}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}},i=!0;try{s[e].call(r.exports,r,r.exports,a),i=!1}finally{i&&delete n[e]}return r.exports}a.ab="/ROOT/node_modules/next/dist/compiled/ua-parser-js/",t.exports=a(943)},885298,(e,t,r)=>{let s={NextRequest:e.r(641165).NextRequest,NextResponse:e.r(628661).NextResponse,ImageResponse:e.r(853702).ImageResponse,userAgentFromString:e.r(276870).userAgentFromString,userAgent:e.r(276870).userAgent,URLPattern:e.r(374644).URLPattern,after:e.r(910473).after,connection:e.r(476550).connection};t.exports=s,r.NextRequest=s.NextRequest,r.NextResponse=s.NextResponse,r.ImageResponse=s.ImageResponse,r.userAgentFromString=s.userAgentFromString,r.userAgent=s.userAgent,r.URLPattern=s.URLPattern,r.after=s.after,r.connection=s.connection}];
119
121
 
120
- //# sourceMappingURL=_1e_rbkrukj0x9._.js.map
122
+ //# sourceMappingURL=_13dlt388gceez._.js.map