super-time-tracker-ui 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone/next-output/BUILD_ID +1 -1
- package/dist/standalone/next-output/app-path-routes-manifest.json +7 -1
- package/dist/standalone/next-output/build-manifest.json +8 -8
- package/dist/standalone/next-output/prerender-manifest.json +0 -49
- package/dist/standalone/next-output/routes-manifest.json +36 -0
- package/dist/standalone/next-output/server/app/_global-error/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/_global-error/page.js +1 -1
- package/dist/standalone/next-output/server/app/_global-error/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/_global-error.html +1 -1
- package/dist/standalone/next-output/server/app/_global-error.rsc +8 -8
- package/dist/standalone/next-output/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/dist/standalone/next-output/server/app/_global-error.segments/_full.segment.rsc +8 -8
- package/dist/standalone/next-output/server/app/_global-error.segments/_head.segment.rsc +4 -4
- package/dist/standalone/next-output/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/dist/standalone/next-output/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/standalone/next-output/server/app/_not-found/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/_not-found/page.js +4 -3
- package/dist/standalone/next-output/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/api/backup/route.js +1 -2
- package/dist/standalone/next-output/server/app/api/backup/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/entry/delete-bulk/route.js +2 -3
- package/dist/standalone/next-output/server/app/api/entry/delete-bulk/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/entry/move/route.js +2 -3
- package/dist/standalone/next-output/server/app/api/entry/move/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/entry/move-bulk/route.js +2 -3
- package/dist/standalone/next-output/server/app/api/entry/move-bulk/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/entry/route.js +3 -3
- package/dist/standalone/next-output/server/app/api/entry/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/in/route.js +2 -2
- package/dist/standalone/next-output/server/app/api/in/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/note/route.js +2 -2
- package/dist/standalone/next-output/server/app/api/note/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/out/route.js +2 -2
- package/dist/standalone/next-output/server/app/api/out/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/sheet/active/route/app-paths-manifest.json +3 -0
- package/dist/standalone/next-output/server/app/api/sheet/active/route/build-manifest.json +9 -0
- package/dist/standalone/next-output/server/app/api/sheet/active/route/server-reference-manifest.json +4 -0
- package/dist/standalone/next-output/server/app/api/sheet/active/route.js +7 -0
- package/dist/standalone/next-output/server/app/api/sheet/active/route.js.nft.json +1 -0
- package/dist/standalone/next-output/server/app/api/sheet/active/route_client-reference-manifest.js +3 -0
- package/dist/standalone/next-output/server/app/api/sheet/route.js +2 -3
- package/dist/standalone/next-output/server/app/api/sheet/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/state/route.js +2 -3
- package/dist/standalone/next-output/server/app/api/state/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/sync/import/route.js +1 -1
- package/dist/standalone/next-output/server/app/api/sync/import/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/sync/merge-on-load/route/app-paths-manifest.json +3 -0
- package/dist/standalone/next-output/server/app/api/sync/merge-on-load/route/build-manifest.json +9 -0
- package/dist/standalone/next-output/server/app/api/sync/merge-on-load/route/server-reference-manifest.json +4 -0
- package/dist/standalone/next-output/server/app/api/sync/merge-on-load/route.js +7 -0
- package/dist/standalone/next-output/server/app/api/sync/merge-on-load/route.js.nft.json +1 -0
- package/dist/standalone/next-output/server/app/api/sync/merge-on-load/route_client-reference-manifest.js +3 -0
- package/dist/standalone/next-output/server/app/api/sync/pull/route.js +1 -1
- package/dist/standalone/next-output/server/app/api/sync/pull/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/sync/push/route.js +1 -1
- package/dist/standalone/next-output/server/app/api/sync/push/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/tags/route.js +1 -2
- package/dist/standalone/next-output/server/app/api/tags/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/api/ui-preferences/merge-on-load/route/app-paths-manifest.json +3 -0
- package/dist/standalone/next-output/server/app/api/ui-preferences/merge-on-load/route/build-manifest.json +9 -0
- package/dist/standalone/next-output/server/app/api/ui-preferences/merge-on-load/route/server-reference-manifest.json +4 -0
- package/dist/standalone/next-output/server/app/api/ui-preferences/merge-on-load/route.js +7 -0
- package/dist/standalone/next-output/server/app/api/ui-preferences/merge-on-load/route.js.nft.json +1 -0
- package/dist/standalone/next-output/server/app/api/ui-preferences/merge-on-load/route_client-reference-manifest.js +3 -0
- package/dist/standalone/next-output/server/app/api/ui-preferences/route.js +1 -1
- package/dist/standalone/next-output/server/app/api/ui-preferences/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/auth/callback/route.js +1 -1
- package/dist/standalone/next-output/server/app/auth/callback/route.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/login/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/login/page.js +4 -3
- package/dist/standalone/next-output/server/app/login/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/login/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/page.js +5 -4
- package/dist/standalone/next-output/server/app/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/register/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/register/page.js +4 -3
- package/dist/standalone/next-output/server/app/register/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/register/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/reporting/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/reporting/page.js +5 -5
- package/dist/standalone/next-output/server/app/reporting/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/reporting/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page/app-paths-manifest.json +3 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page/build-manifest.json +17 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page/next-font-manifest.json +11 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page/react-loadable-manifest.json +1 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page/server-reference-manifest.json +4 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page.js +15 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page.js.nft.json +1 -0
- package/dist/standalone/next-output/server/app/settings/cloud-sync/page_client-reference-manifest.js +3 -0
- package/dist/standalone/next-output/server/app/settings/data/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/settings/data/page.js +5 -4
- package/dist/standalone/next-output/server/app/settings/data/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/settings/data/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/settings/display/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/settings/display/page.js +4 -3
- package/dist/standalone/next-output/server/app/settings/display/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/settings/display/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/settings/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/settings/page.js +5 -5
- package/dist/standalone/next-output/server/app/settings/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/settings/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/settings/tags/page/build-manifest.json +5 -5
- package/dist/standalone/next-output/server/app/settings/tags/page.js +5 -5
- package/dist/standalone/next-output/server/app/settings/tags/page.js.nft.json +1 -1
- package/dist/standalone/next-output/server/app/settings/tags/page_client-reference-manifest.js +1 -1
- package/dist/standalone/next-output/server/app/sheets/page/app-paths-manifest.json +3 -0
- package/dist/standalone/next-output/server/app/sheets/page/build-manifest.json +17 -0
- package/dist/standalone/next-output/server/app/sheets/page/next-font-manifest.json +11 -0
- package/dist/standalone/next-output/server/app/sheets/page/react-loadable-manifest.json +1 -0
- package/dist/standalone/next-output/server/app/sheets/page/server-reference-manifest.json +4 -0
- package/dist/standalone/next-output/server/app/sheets/page.js +15 -0
- package/dist/standalone/next-output/server/app/sheets/page.js.nft.json +1 -0
- package/dist/standalone/next-output/server/app/sheets/page_client-reference-manifest.js +3 -0
- package/dist/standalone/next-output/server/app/today/page/app-paths-manifest.json +3 -0
- package/dist/standalone/next-output/server/app/today/page/build-manifest.json +17 -0
- package/dist/standalone/next-output/server/app/today/page/next-font-manifest.json +11 -0
- package/dist/standalone/next-output/server/app/today/page/react-loadable-manifest.json +1 -0
- package/dist/standalone/next-output/server/app/today/page/server-reference-manifest.json +4 -0
- package/dist/standalone/next-output/server/app/today/page.js +15 -0
- package/dist/standalone/next-output/server/app/today/page.js.nft.json +1 -0
- package/dist/standalone/next-output/server/app/today/page_client-reference-manifest.js +3 -0
- package/dist/standalone/next-output/server/app-paths-manifest.json +7 -1
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0-~y~9m._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0.tfxy.._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__045he4k._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__06efo~9._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__09bkv_j._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0bflmy0._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0cbimu4._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0e3._t7._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0goaz9z._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0i1baam._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0mnx_nu._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0szq3qr._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0uvo97t._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0wzuxc6._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0xb8jjk._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__118xfg0._.js +3 -0
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__11e-p11._.js +3 -0
- package/dist/standalone/next-output/server/chunks/_0rz1whw._.js +3 -0
- package/dist/standalone/next-output/server/chunks/_0vvs4p8._.js +3 -0
- package/dist/standalone/next-output/server/chunks/_0y.amf.._.js +3 -0
- package/dist/standalone/next-output/server/chunks/_0ysbhok._.js +3 -0
- package/dist/standalone/next-output/server/chunks/_next-internal_server_app_api_sheet_active_route_actions_0vwkhw..js +3 -0
- package/dist/standalone/next-output/server/chunks/_next-internal_server_app_api_sync_merge-on-load_route_actions_0yu2xg-.js +3 -0
- package/dist/standalone/next-output/server/chunks/_next-internal_server_app_api_ui-preferences_merge-on-load_route_actions_06ep~.j.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/0elt_date-fns_format_0j.rx2u.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/0z~i_next_0pyvy-l._.js +6 -0
- package/dist/standalone/next-output/server/chunks/ssr/0z~i_next_dist_04bpslp._.js +1 -1
- package/dist/standalone/next-output/server/chunks/ssr/{0z~i_next_dist_0u6ij0z._.js → 0z~i_next_dist_0kux32m._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/0z~i_next_dist_esm_build_templates_app-page_0-6~y~c.js +4 -0
- package/dist/standalone/next-output/server/chunks/ssr/0z~i_next_dist_esm_build_templates_app-page_03p53oc.js +4 -0
- package/dist/standalone/next-output/server/chunks/ssr/0z~i_next_dist_esm_build_templates_app-page_08fopnn.js +4 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__04et1.j._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__04rw9_a._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0f.je14._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0ljly6c._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{[root-of-the-server]__0p74awc._.js → [root-of-the-server]__0n8s9zq._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/{[root-of-the-server]__01coapr._.js → [root-of-the-server]__0q7e6b0._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0rf.8qg._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0s84deg._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0sh_dni._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0tynjfp._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0ue-tr6._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0wmfvtj._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{[root-of-the-server]__12q4x7c._.js → [root-of-the-server]__0ygx8l9._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0zxgb-a._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0~rrg79._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__11qrqnz._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0-ov5_n._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_00x~ete._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{_0vrl3h2._.js → _073x~fa._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/_0_aptb7._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0axgv9-._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0bs7t.7._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{_0zp.x0b._.js → _0bu5pcm._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/_0cxipsf._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0dj7qxj._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0k06nbl._.js +61 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0ld3xfd._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{_02np35c._.js → _0ls83bx._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/_0p4r3~t._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0su4mzm._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0thins~._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0v9l~2y._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0ycs85o._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_0zk9gtm._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_113zjr0._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{_0j.-r89._.js → _11amno3._.js} +2 -2
- package/dist/standalone/next-output/server/chunks/ssr/_11d2qve._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_next-internal_server_app_settings_cloud-sync_page_actions_0ld6e8p.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_next-internal_server_app_sheets_page_actions_0cqf0.l.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/_next-internal_server_app_today_page_actions_0of2-iy.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/components_109-aj4._.js +1 -1
- package/dist/standalone/next-output/server/chunks/ssr/components_reporting-view_tsx_0-0ofcv._.js +1 -1
- package/dist/standalone/next-output/server/chunks/ssr/components_tracker-app_tsx_0qs9.7y._.js +1 -1
- package/dist/standalone/next-output/server/chunks/ssr/lib_0c0z4q-._.js +3 -0
- package/dist/standalone/next-output/server/chunks/ssr/{0z~i_next_dist_client_components_0247lue._.js → node_modules__pnpm_0u1tjhh._.js} +2 -2
- package/dist/standalone/next-output/server/middleware-build-manifest.js +8 -8
- package/dist/standalone/next-output/server/middleware-manifest.json +1 -1
- package/dist/standalone/next-output/server/next-font-manifest.js +1 -1
- package/dist/standalone/next-output/server/next-font-manifest.json +12 -0
- package/dist/standalone/next-output/server/pages/500.html +1 -1
- package/dist/standalone/next-output/server/pages-manifest.json +0 -1
- package/dist/standalone/next-output/static/chunks/02h6za.al3c7p.js +1 -0
- package/dist/standalone/next-output/static/chunks/04_2jzw-uhhu0.js +2 -0
- package/dist/standalone/next-output/static/chunks/04niua5h~-1f..js +1 -0
- package/dist/standalone/next-output/static/chunks/06u43x9tl391w.js +1 -0
- package/dist/standalone/next-output/static/chunks/0a5y_udluz6e6.js +1 -0
- package/dist/standalone/next-output/static/chunks/0b0a23hps.ate.js +4 -0
- package/dist/standalone/next-output/static/chunks/0bly.8gr9nkdz.js +1 -0
- package/dist/standalone/next-output/static/chunks/0i8_d5-g6pduc.css +3 -0
- package/dist/standalone/next-output/static/chunks/{0koldw9zjijry.js → 0jcqig-f5dwq7.js} +2 -2
- package/dist/standalone/next-output/static/chunks/0ker2ur7q6j6n.js +1 -0
- package/dist/standalone/next-output/static/chunks/{0n~v8~rri7~t2.js → 0lgo02csmvyps.js} +1 -1
- package/dist/standalone/next-output/static/chunks/0l~uil8w-ewlm.js +1 -0
- package/dist/standalone/next-output/static/chunks/0uik_f_e6e0e6.js +1 -0
- package/dist/standalone/next-output/static/chunks/0uxm1dlh.6xck.js +1 -0
- package/dist/standalone/next-output/static/chunks/0vm3.l6rc2kie.js +1 -0
- package/dist/standalone/next-output/static/chunks/0xo5n.1q2uz95.js +1 -0
- package/dist/standalone/next-output/static/chunks/0yi4m~~80yeqj.js +1 -0
- package/dist/standalone/next-output/static/chunks/0z9uuysy9qb.4.js +1 -0
- package/dist/standalone/next-output/static/chunks/10_mtmf57jsww.js +1 -0
- package/dist/standalone/next-output/static/chunks/10c83.nq801k1.js +1 -0
- package/dist/standalone/next-output/static/chunks/{04i7.d4zi~oe6.js → 12rxdn65.z_85.js} +9 -9
- package/dist/standalone/next-output/static/chunks/15xhm5fbzvyag.js +1 -0
- package/dist/standalone/next-output/static/chunks/18adan1jcwejd.js +1 -0
- package/dist/standalone/next-output/static/chunks/{turbopack-0st0r~j~gn7ke.js → turbopack-00m4i0dy4on-a.js} +1 -1
- package/dist/standalone/package.json +1 -1
- package/package.json +1 -1
- package/dist/standalone/next-output/server/app/_not-found.html +0 -1
- package/dist/standalone/next-output/server/app/_not-found.meta +0 -16
- package/dist/standalone/next-output/server/app/_not-found.rsc +0 -26
- package/dist/standalone/next-output/server/app/_not-found.segments/_full.segment.rsc +0 -26
- package/dist/standalone/next-output/server/app/_not-found.segments/_head.segment.rsc +0 -6
- package/dist/standalone/next-output/server/app/_not-found.segments/_index.segment.rsc +0 -11
- package/dist/standalone/next-output/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +0 -5
- package/dist/standalone/next-output/server/app/_not-found.segments/_not-found.segment.rsc +0 -5
- package/dist/standalone/next-output/server/app/_not-found.segments/_tree.segment.rsc +0 -2
- package/dist/standalone/next-output/server/app/settings/display.html +0 -1
- package/dist/standalone/next-output/server/app/settings/display.meta +0 -16
- package/dist/standalone/next-output/server/app/settings/display.rsc +0 -44
- package/dist/standalone/next-output/server/app/settings/display.segments/_full.segment.rsc +0 -44
- package/dist/standalone/next-output/server/app/settings/display.segments/_head.segment.rsc +0 -6
- package/dist/standalone/next-output/server/app/settings/display.segments/_index.segment.rsc +0 -11
- package/dist/standalone/next-output/server/app/settings/display.segments/_tree.segment.rsc +0 -4
- package/dist/standalone/next-output/server/app/settings/display.segments/settings/display/__PAGE__.segment.rsc +0 -20
- package/dist/standalone/next-output/server/app/settings/display.segments/settings/display.segment.rsc +0 -5
- package/dist/standalone/next-output/server/app/settings/display.segments/settings.segment.rsc +0 -5
- package/dist/standalone/next-output/server/chunks/0z~i_next_dist_esm_build_templates_app-route_0213rdf.js +0 -3
- package/dist/standalone/next-output/server/chunks/0z~i_next_dist_esm_build_templates_app-route_03g03g4.js +0 -3
- package/dist/standalone/next-output/server/chunks/0z~i_next_dist_esm_build_templates_app-route_03tgdq_.js +0 -3
- package/dist/standalone/next-output/server/chunks/0z~i_next_dist_esm_build_templates_app-route_04pkg4k.js +0 -3
- package/dist/standalone/next-output/server/chunks/0z~i_next_dist_esm_build_templates_app-route_04xu.yc.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0-vx9fd._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0.pes14._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__01gv623._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__07steou._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0_iol1b._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0czppph._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0j0740e._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0jki.34._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0p-frp1._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0p1kxjf._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__0rqulo~._.js +0 -3
- package/dist/standalone/next-output/server/chunks/[root-of-the-server]__12h-035._.js +0 -3
- package/dist/standalone/next-output/server/chunks/_0..mseh._.js +0 -3
- package/dist/standalone/next-output/server/chunks/_0900_l.._.js +0 -3
- package/dist/standalone/next-output/server/chunks/_0it7w3b._.js +0 -3
- package/dist/standalone/next-output/server/chunks/_0oz1whe._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__00t2myd._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__045~xw2._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0mc.wxv._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0mjp16u._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0ucb5c~._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0urz1s3._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0uw_dut._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__0wm37im._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__113akjz._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/[root-of-the-server]__13dr511._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/_0.-wxz~._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/_01xe83y._.js +0 -64
- package/dist/standalone/next-output/server/chunks/ssr/_03kx6a3._.js +0 -64
- package/dist/standalone/next-output/server/chunks/ssr/_06.f~a.._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/_06yb2en._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/_0iqbilg._.js +0 -64
- package/dist/standalone/next-output/server/chunks/ssr/_0ox~9uu._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/_0x1bw~i._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/_0ykqba1._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/components_0mwejmt._.js +0 -3
- package/dist/standalone/next-output/server/chunks/ssr/lib_0x8xvli._.js +0 -3
- package/dist/standalone/next-output/server/pages/404.html +0 -1
- package/dist/standalone/next-output/static/chunks/01mevzl3z5cgt.js +0 -1
- package/dist/standalone/next-output/static/chunks/05161-t.3egqv.js +0 -4
- package/dist/standalone/next-output/static/chunks/0708yw9dysifo.js +0 -2
- package/dist/standalone/next-output/static/chunks/0_ksz4lai0fyf.js +0 -1
- package/dist/standalone/next-output/static/chunks/0b41d5ys.-f0z.js +0 -1
- package/dist/standalone/next-output/static/chunks/0dap7q~qaakti.js +0 -1
- package/dist/standalone/next-output/static/chunks/0e9-u5vmtujdj.js +0 -1
- package/dist/standalone/next-output/static/chunks/0g7b1~gza1y3a.js +0 -1
- package/dist/standalone/next-output/static/chunks/0h-q8kc3tbcj8.js +0 -1
- package/dist/standalone/next-output/static/chunks/0pyyx.xdi5hi-.js +0 -1
- package/dist/standalone/next-output/static/chunks/0t2dqc8t4.4r~.js +0 -1
- package/dist/standalone/next-output/static/chunks/0uezeykgodd86.js +0 -1
- package/dist/standalone/next-output/static/chunks/0wf_vm8b1-jq3.js +0 -1
- package/dist/standalone/next-output/static/chunks/0y833~et3ssz2.js +0 -1
- package/dist/standalone/next-output/static/chunks/0yxiwfqfaqly7.css +0 -3
- package/dist/standalone/next-output/static/chunks/10ey~m_2o0rlr.js +0 -1
- /package/dist/standalone/next-output/static/{DquhSHeykhjs4ylW6BQ87 → b-GDdUy-cIcWNA_TGvVQz}/_buildManifest.js +0 -0
- /package/dist/standalone/next-output/static/{DquhSHeykhjs4ylW6BQ87 → b-GDdUy-cIcWNA_TGvVQz}/_clientMiddlewareManifest.js +0 -0
- /package/dist/standalone/next-output/static/{DquhSHeykhjs4ylW6BQ87 → b-GDdUy-cIcWNA_TGvVQz}/_ssgManifest.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,71060,(e,t,r)=>{t.exports=e.r(2052)},72074,e=>{"use strict";e.s(["is_modal_dialog_open",0,function(){return null!==document.querySelector('[role="dialog"][aria-modal="true"]')}])},92629,e=>{"use strict";e.s(["ACCENT_COLOR_STORAGE_KEY",0,"super-time-tracker-accent-color","CHECK_IN_FORM_COLLAPSED_DEFAULT",0,"false","CHECK_IN_FORM_COLLAPSED_STORAGE_KEY",0,"super-time-tracker-check-in-form-collapsed","CLEAR_TAG_FILTERS_ON_SHEET_CHANGE_DEFAULT",0,"false","CLEAR_TAG_FILTERS_ON_SHEET_CHANGE_STORAGE_KEY",0,"super-time-tracker-clear-tag-filters-on-sheet-change","COLOR_PALETTE_DEFAULT",0,"default","COLOR_PALETTE_STORAGE_KEY",0,"super-time-tracker-color-palette","COLOR_PALETTE_VALUES",0,["default","midnight","warm","ocean","forest","contrast"],"CONFIRM_BEFORE_CHECKOUT_DEFAULT",0,"false","CONFIRM_BEFORE_CHECKOUT_STORAGE_KEY",0,"super-time-tracker-confirm-before-checkout","CONFIRM_DESTRUCTIVE_ACTIONS_DEFAULT",0,"true","CONFIRM_DESTRUCTIVE_ACTIONS_STORAGE_KEY",0,"super-time-tracker-confirm-destructive-actions","DEFAULT_REPORTING_RANGE_DEFAULT",0,"none","DEFAULT_REPORTING_RANGE_STORAGE_KEY",0,"super-time-tracker-default-reporting-range","DEFAULT_REPORTING_SORT_DEFAULT",0,"duration","DEFAULT_REPORTING_SORT_STORAGE_KEY",0,"super-time-tracker-default-reporting-sort","DURATION_FORMAT_DEFAULT",0,"humanized","DURATION_FORMAT_STORAGE_KEY",0,"super-time-tracker-duration-format","ENTRY_LIST_SORT_DEFAULT",0,"newest","ENTRY_LIST_SORT_STORAGE_KEY",0,"super-time-tracker-entry-list-sort","TAG_FILTER_MODE_DEFAULT",0,"all","TAG_FILTER_MODE_STORAGE_KEY",0,"super-time-tracker-tag-filter-mode","THEME_MODE_DEFAULT",0,"system","THEME_MODE_STORAGE_KEY",0,"super-time-tracker-theme-mode","TIMER_IN_TITLE_DEFAULT",0,"true","TIMER_IN_TITLE_STORAGE_KEY",0,"super-time-tracker-timer-in-title","TIMER_SHOW_SECONDS_DEFAULT",0,"false","TIMER_SHOW_SECONDS_STORAGE_KEY",0,"super-time-tracker-timer-show-seconds","TIME_FORMAT_DEFAULT",0,"12h","TIME_FORMAT_STORAGE_KEY",0,"super-time-tracker-time-format","WEEK_STARTS_ON_DEFAULT",0,"monday","WEEK_STARTS_ON_STORAGE_KEY",0,"super-time-tracker-week-starts-on"])},72550,e=>{"use strict";e.s(["ACTIVE_SHEET_COOKIE_NAME",0,"stt-active-sheet","ACTIVE_SHEET_STORAGE_KEY",0,"super-time-tracker-active-sheet","COMPACT_LISTS_STORAGE_KEY",0,"super-time-tracker-compact-lists","DEFAULT_SHEET_FIXED_NAME_COOKIE_NAME",0,"stt-default-sheet-fixed-name","DEFAULT_SHEET_FIXED_NAME_STORAGE_KEY",0,"super-time-tracker-default-sheet-fixed-name","DEFAULT_SHEET_SESSION_MODE_COOKIE_NAME",0,"stt-default-sheet-session-mode","DEFAULT_SHEET_SESSION_MODE_DEFAULT",0,"last_viewed","DEFAULT_SHEET_SESSION_MODE_STORAGE_KEY",0,"super-time-tracker-default-sheet-session-mode","SHEET_TAG_FILTERS_STORAGE_KEY",0,"super-time-tracker-sheet-tag-filters"])},89497,38633,e=>{"use strict";var t=e.i(92629),r=e.i(72550);let s="super-time-tracker-theme";e.s(["THEME_STORAGE_KEY",0,s],38633),e.s(["collect_ui_preferences_from_window",0,function(){let e={};for(let n of[t.ACCENT_COLOR_STORAGE_KEY,r.ACTIVE_SHEET_STORAGE_KEY,t.CHECK_IN_FORM_COLLAPSED_STORAGE_KEY,t.CLEAR_TAG_FILTERS_ON_SHEET_CHANGE_STORAGE_KEY,t.COLOR_PALETTE_STORAGE_KEY,r.COMPACT_LISTS_STORAGE_KEY,t.CONFIRM_BEFORE_CHECKOUT_STORAGE_KEY,t.CONFIRM_DESTRUCTIVE_ACTIONS_STORAGE_KEY,t.DEFAULT_REPORTING_RANGE_STORAGE_KEY,t.DEFAULT_REPORTING_SORT_STORAGE_KEY,r.DEFAULT_SHEET_FIXED_NAME_STORAGE_KEY,r.DEFAULT_SHEET_SESSION_MODE_STORAGE_KEY,t.DURATION_FORMAT_STORAGE_KEY,t.ENTRY_LIST_SORT_STORAGE_KEY,r.SHEET_TAG_FILTERS_STORAGE_KEY,t.TAG_FILTER_MODE_STORAGE_KEY,t.THEME_MODE_STORAGE_KEY,s,t.TIME_FORMAT_STORAGE_KEY,t.TIMER_IN_TITLE_STORAGE_KEY,t.TIMER_SHOW_SECONDS_STORAGE_KEY,t.WEEK_STARTS_ON_STORAGE_KEY])try{let t=window.localStorage.getItem(n);null!==t&&(e[n]=t)}catch{}return e}],89497)},66252,(e,t,r)=>{var s={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],s=t[1];return(r+s)*3/4-s},t.toByteArray=function(e){var t,r,i=l(e),a=i[0],o=i[1],u=new n((a+o)*3/4-o),h=0,c=o>0?a-4:a;for(r=0;r<c;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===o&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,u[h++]=255&t),1===o&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,s=e.length,n=s%3,i=[],a=0,o=s-n;a<o;a+=16383)i.push(function(e,t,s){for(var n,i=[],a=t;a<s;a+=3)n=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(r[n>>18&63]+r[n>>12&63]+r[n>>6&63]+r[63&n]);return i.join("")}(e,a,a+16383>o?o:a+16383));return 1===n?i.push(r[(t=e[s-1])>>2]+r[t<<4&63]+"=="):2===n&&i.push(r[(t=(e[s-2]<<8)+e[s-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),i.join("")};for(var r=[],s=[],n="u">typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=i.length;a<o;++a)r[a]=i[a],s[i.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var s=r===t?0:4-r%4;return[r,s]}s[45]=62,s[95]=63},72:function(e,t,r){"use strict";var s=r(675),n=r(783),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var s=e,n=t;if(("string"!=typeof n||""===n)&&(n="utf8"),!o.isEncoding(n))throw TypeError("Unknown encoding: "+n);var i=0|f(s,n),l=a(i),u=l.write(s,n);return u!==i&&(l=l.slice(0,u)),l}if(ArrayBuffer.isView(e))return c(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(C(e,ArrayBuffer)||e&&C(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(C(e,SharedArrayBuffer)||e&&C(e.buffer,SharedArrayBuffer)))return function(e,t,r){var s;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),s}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var h=e.valueOf&&e.valueOf();if(null!=h&&h!==e)return o.from(h,t,r);var p=function(e){if(o.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(p)return p;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return u(e),a(e<0?0:0|d(e))}function c(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),s=0;s<t;s+=1)r[s]=255&e[s];return r}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(u(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return h(e)},o.allocUnsafeSlow=function(e){return h(e)};function d(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||C(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return T(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return R(e).length;default:if(n)return s?-1:T(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n,i,a,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);for(var n="",i=t;i<r;++i)n+=P[e[i]];return n}(this,t,r);case"utf8":case"utf-8":return b(this,t,r);case"ascii":return function(e,t,r){var s="";r=Math.min(e.length,r);for(var n=t;n<r;++n)s+=String.fromCharCode(127&e[n]);return s}(this,t,r);case"latin1":case"binary":return function(e,t,r){var s="";r=Math.min(e.length,r);for(var n=t;n<r;++n)s+=String.fromCharCode(e[n]);return s}(this,t,r);case"base64":return n=this,i=t,a=r,0===i&&a===n.length?s.fromByteArray(n):s.fromByteArray(n.slice(i,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var s=e.slice(t,r),n="",i=0;i<s.length;i+=2)n+=String.fromCharCode(s[i]+256*s[i+1]);return n}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function g(e,t,r){var s=e[t];e[t]=e[r],e[r]=s}function y(e,t,r,s,n){var i;if(0===e.length)return -1;if("string"==typeof r?(s=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(i=r*=1)!=i&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(n)return -1;else r=e.length-1;else if(r<0)if(!n)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,s)),o.isBuffer(t))return 0===t.length?-1:m(e,t,r,s,n);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(n)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return m(e,[t],r,s,n)}throw TypeError("val must be string, number or Buffer")}function m(e,t,r,s,n){var i,a=1,o=e.length,l=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(n){var h=-1;for(i=r;i<o;i++)if(u(e,i)===u(t,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===l)return h*a}else -1!==h&&(i-=i-h),h=-1}else for(r+l>o&&(r=o-l),i=r;i>=0;i--){for(var c=!0,d=0;d<l;d++)if(u(e,i+d)!==u(t,d)){c=!1;break}if(c)return i}return -1}o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(C(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),C(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,s=t.length,n=0,i=Math.min(r,s);n<i;++n)if(e[n]!==t[n]){r=e[n],s=t[n];break}return r<s?-1:+(s<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,s=o.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var i=e[r];if(C(i,Uint8Array)&&(i=o.from(i)),!o.isBuffer(i))throw TypeError('"list" argument must be an Array of Buffers');i.copy(s,n),n+=i.length}return s},o.byteLength=f,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?b(this,0,e):p.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(e,t,r,s,n){if(C(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===n&&(n=this.length),t<0||r>e.length||s<0||n>this.length)throw RangeError("out of range index");if(s>=n&&t>=r)return 0;if(s>=n)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,s>>>=0,n>>>=0,this===e)return 0;for(var i=n-s,a=r-t,l=Math.min(i,a),u=this.slice(s,n),h=e.slice(t,r),c=0;c<l;++c)if(u[c]!==h[c]){i=u[c],a=h[c];break}return i<a?-1:+(a<i)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)};function b(e,t,r){r=Math.min(e.length,r);for(var s=[],n=t;n<r;){var i,a,o,l,u=e[n],h=null,c=u>239?4:u>223?3:u>191?2:1;if(n+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:(192&(i=e[n+1]))==128&&(l=(31&u)<<6|63&i)>127&&(h=l);break;case 3:i=e[n+1],a=e[n+2],(192&i)==128&&(192&a)==128&&(l=(15&u)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:i=e[n+1],a=e[n+2],o=e[n+3],(192&i)==128&&(192&a)==128&&(192&o)==128&&(l=(15&u)<<18|(63&i)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h),n+=c}var d=s,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",g=0;g<f;)p+=String.fromCharCode.apply(String,d.slice(g,g+=4096));return p}function w(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function _(e,t,r,s,n,i){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw RangeError('"value" argument is out of bounds');if(r+s>e.length)throw RangeError("Index out of range")}function v(e,t,r,s,n,i){if(r+s>e.length||r<0)throw RangeError("Index out of range")}function k(e,t,r,s,i){return t*=1,r>>>=0,i||v(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,s,23,4),r+4}function E(e,t,r,s,i){return t*=1,r>>>=0,i||v(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,s,52,8),r+8}o.prototype.write=function(e,t,r,s){if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var n,i,a,o,l,u,h,c,d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var f=!1;;)switch(s){case"hex":return function(e,t,r,s){r=Number(r)||0;var n=e.length-r;s?(s=Number(s))>n&&(s=n):s=n;var i=t.length;s>i/2&&(s=i/2);for(var a=0;a<s;++a){var o,l=parseInt(t.substr(2*a,2),16);if((o=l)!=o)break;e[r+a]=l}return a}(this,e,t,r);case"utf8":case"utf-8":return n=t,i=r,O(T(e,this.length-n),this,n,i);case"ascii":return a=t,o=r,O(A(e),this,a,o);case"latin1":case"binary":return function(e,t,r,s){return O(A(t),e,r,s)}(this,e,t,r);case"base64":return l=t,u=r,O(R(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h=t,c=r,O(function(e,t){for(var r,s,n=[],i=0;i<e.length&&!((t-=2)<0);++i)s=(r=e.charCodeAt(i))>>8,n.push(r%256),n.push(s);return n}(e,this.length-h),this,h,c);default:if(f)throw TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var s=this.subarray(e,t);return Object.setPrototypeOf(s,o.prototype),s},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=this[e],n=1,i=0;++i<t&&(n*=256);)s+=this[e+i]*n;return s},o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=this[e+--t],n=1;t>0&&(n*=256);)s+=this[e+--t]*n;return s},o.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=this[e],n=1,i=0;++i<t&&(n*=256);)s+=this[e+i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=t,n=1,i=this[e+--s];s>0&&(n*=256);)i+=this[e+--s]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},o.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),n.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),n.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),n.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),n.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,s){if(e*=1,t>>>=0,r>>>=0,!s){var n=Math.pow(2,8*r)-1;_(this,e,t,r,n,0)}var i=1,a=0;for(this[t]=255&e;++a<r&&(i*=256);)this[t+a]=e/i&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,s){if(e*=1,t>>>=0,r>>>=0,!s){var n=Math.pow(2,8*r)-1;_(this,e,t,r,n,0)}var i=r-1,a=1;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,s){if(e*=1,t>>>=0,!s){var n=Math.pow(2,8*r-1);_(this,e,t,r,n-1,-n)}var i=0,a=1,o=0;for(this[t]=255&e;++i<r&&(a*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/a|0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,s){if(e*=1,t>>>=0,!s){var n=Math.pow(2,8*r-1);_(this,e,t,r,n-1,-n)}var i=r-1,a=1,o=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/a|0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return k(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return k(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return E(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return E(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,s){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(s<0)throw RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);var n=s-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,s);else if(this===e&&r<t&&t<s)for(var i=n-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,s),t);return n},o.prototype.fill=function(e,t,r,s){if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw TypeError("encoding must be a string");if("string"==typeof s&&!o.isEncoding(s))throw TypeError("Unknown encoding: "+s);if(1===e.length){var n,i=e.charCodeAt(0);("utf8"===s&&i<128||"latin1"===s)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(n=t;n<r;++n)this[n]=e;else{var a=o.isBuffer(e)?e:o.from(e,s),l=a.length;if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<r-t;++n)this[n+t]=a[n%l]}return this};var S=/[^+/0-9A-Za-z-_]/g;function T(e,t){t=t||1/0;for(var r,s=e.length,n=null,i=[],a=0;a<s;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!n){if(r>56319||a+1===s){(t-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return i}function A(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function R(e){return s.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(S,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function O(e,t,r,s){for(var n=0;n<s&&!(n+r>=t.length)&&!(n>=e.length);++n)t[n+r]=e[n];return n}function C(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var P=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var s=16*r,n=0;n<16;++n)t[s+n]=e[r]+e[n];return t}()},783:function(e,t){t.read=function(e,t,r,s,n){var i,a,o=8*n-s-1,l=(1<<o)-1,u=l>>1,h=-7,c=r?n-1:0,d=r?-1:1,f=e[t+c];for(c+=d,i=f&(1<<-h)-1,f>>=-h,h+=o;h>0;i=256*i+e[t+c],c+=d,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=s;h>0;a=256*a+e[t+c],c+=d,h-=8);if(0===i)i=1-u;else{if(i===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,s),i-=u}return(f?-1:1)*a*Math.pow(2,i-s)},t.write=function(e,t,r,s,n,i){var a,o,l,u=8*i-n-1,h=(1<<u)-1,c=h>>1,d=5960464477539062e-23*(23===n),f=s?0:i-1,p=s?1:-1,g=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+c>=1?t+=d/l:t+=d*Math.pow(2,1-c),t*l>=2&&(a++,l/=2),a+c>=h?(o=0,a=h):a+c>=1?(o=(t*l-1)*Math.pow(2,n),a+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,n),a=0));n>=8;e[r+f]=255&o,f+=p,o/=256,n-=8);for(a=a<<n|o,u+=n;u>0;e[r+f]=255&a,f+=p,a/=256,u-=8);e[r+f-p]|=128*g}}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}},a=!0;try{s[e](r,r.exports,i),a=!1}finally{a&&delete n[e]}return r.exports}i.ab="/ROOT/node_modules/.pnpm/next@16.2.6_@babel+core@7.29.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/next/dist/compiled/buffer/",t.exports=i(72)},22792,(e,t,r)=>{"use strict";let s;Object.defineProperty(r,"__esModule",{value:!0}),r.parseCookie=c,r.parse=c,r.stringifyCookie=function(e,t){let r=t?.encode||encodeURIComponent,s=[];for(let t of Object.keys(e)){let a=e[t];if(void 0===a)continue;if(!n.test(t))throw TypeError(`cookie name is invalid: ${t}`);let o=r(a);if(!i.test(o))throw TypeError(`cookie val is invalid: ${a}`);s.push(`${t}=${o}`)}return s.join("; ")},r.stringifySetCookie=d,r.serialize=d,r.parseSetCookie=function(e,t){let r=t?.decode||y,s=e.length,n=f(e,0,s),i=p(e,0,n),a=-1===i?{name:"",value:r(g(e,0,n))}:{name:g(e,0,i),value:r(g(e,i+1,n))},o=n+1;for(;o<s;){let t=f(e,o,s),r=p(e,o,t),n=-1===r?g(e,o,t):g(e,o,r),i=-1===r?void 0:g(e,r+1,t);switch(n.toLowerCase()){case"httponly":a.httpOnly=!0;break;case"secure":a.secure=!0;break;case"partitioned":a.partitioned=!0;break;case"domain":a.domain=i;break;case"path":a.path=i;break;case"max-age":i&&l.test(i)&&(a.maxAge=Number(i));break;case"expires":if(!i)break;let u=new Date(i);Number.isFinite(u.valueOf())&&(a.expires=u);break;case"priority":if(!i)break;let h=i.toLowerCase();("low"===h||"medium"===h||"high"===h)&&(a.priority=h);break;case"samesite":if(!i)break;let c=i.toLowerCase();("lax"===c||"strict"===c||"none"===c)&&(a.sameSite=c)}o=t+1}return a},r.stringifySetCookie=d,r.serialize=d;let n=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,i=/^[\u0021-\u003A\u003C-\u007E]*$/,a=/^([.]?[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+$/,u=Object.prototype.toString,h=((s=function(){}).prototype=Object.create(null),s);function c(e,t){let r=new h,s=e.length;if(s<2)return r;let n=t?.decode||y,i=0;do{let t=p(e,i,s);if(-1===t)break;let a=f(e,i,s);if(t>a){i=e.lastIndexOf(";",t-1)+1;continue}let o=g(e,i,t);void 0===r[o]&&(r[o]=n(g(e,t+1,a))),i=a+1}while(i<s)return r}function d(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 h=s.value?l(s.value):"";if(!i.test(h))throw TypeError(`argument val is invalid: ${s.value}`);let c=s.name+"="+h;if(void 0!==s.maxAge){if(!Number.isInteger(s.maxAge))throw TypeError(`option maxAge is invalid: ${s.maxAge}`);c+="; Max-Age="+s.maxAge}if(s.domain){if(!a.test(s.domain))throw TypeError(`option domain is invalid: ${s.domain}`);c+="; Domain="+s.domain}if(s.path){if(!o.test(s.path))throw TypeError(`option path is invalid: ${s.path}`);c+="; Path="+s.path}if(s.expires){var d;if(d=s.expires,"[object Date]"!==u.call(d)||!Number.isFinite(s.expires.valueOf()))throw TypeError(`option expires is invalid: ${s.expires}`);c+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(c+="; HttpOnly"),s.secure&&(c+="; Secure"),s.partitioned&&(c+="; Partitioned"),s.priority)switch("string"==typeof s.priority?s.priority.toLowerCase():void 0){case"low":c+="; Priority=Low";break;case"medium":c+="; Priority=Medium";break;case"high":c+="; 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":c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"none":c+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${s.sameSite}`)}return c}function f(e,t,r){let s=e.indexOf(";",t);return -1===s?r:s}function p(e,t,r){let s=e.indexOf("=",t);return s<r?s:-1}function g(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 y(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}},32417,e=>{"use strict";e.s(["is_supabase_configured",0,function(){return("https://ctruizaqyeyidujmtxhc.supabase.co".trim()??"").length>0&&("sb_publishable_gTYHeWoWIPPW3SIC4cYaXw_ux7UL_Jb".trim()??"").length>0}])},83105,e=>{"use strict";let t,r,s;class n 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 i extends n{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class a extends n{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class o extends n{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}function l(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}(b=w||(w={})).Any="any",b.ApNortheast1="ap-northeast-1",b.ApNortheast2="ap-northeast-2",b.ApSouth1="ap-south-1",b.ApSoutheast1="ap-southeast-1",b.ApSoutheast2="ap-southeast-2",b.CaCentral1="ca-central-1",b.EuCentral1="eu-central-1",b.EuWest1="eu-west-1",b.EuWest2="eu-west-2",b.EuWest3="eu-west-3",b.SaEast1="sa-east-1",b.UsEast1="us-east-1",b.UsWest1="us-west-1",b.UsWest2="us-west-2";"function"==typeof SuppressedError&&SuppressedError;class u{constructor(e,{headers:t={},customFetch:r,region:s=w.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r)}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;let s,n;try{let l,{headers:u,method:h,body:c,signal:d,timeout:f}=t,p={},{region:g}=t;g||(g=this.region);let y=new URL(`${this.url}/${e}`);g&&"any"!==g&&(p["x-region"]=g,y.searchParams.set("forceFunctionRegion",g)),c&&(u&&!Object.prototype.hasOwnProperty.call(u,"Content-Type")||!u)?"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer?(p["Content-Type"]="application/octet-stream",l=c):"string"==typeof c?(p["Content-Type"]="text/plain",l=c):"u">typeof FormData&&c instanceof FormData?l=c:(p["Content-Type"]="application/json",l=JSON.stringify(c)):l=!c||"string"==typeof c||"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer||"u">typeof FormData&&c instanceof FormData?c:JSON.stringify(c);let m=d;f&&(n=new AbortController,s=setTimeout(()=>n.abort(),f),d?(m=n.signal,d.addEventListener("abort",()=>n.abort())):m=n.signal);let b=yield this.fetch(y.toString(),{method:h||"POST",headers:Object.assign(Object.assign(Object.assign({},p),this.headers),u),body:l,signal:m}).catch(e=>{throw new i(e)}),w=b.headers.get("x-relay-error");if(w&&"true"===w)throw new a(b);if(!b.ok)throw new o(b);let _=(null!=(r=b.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim();return{data:"application/json"===_?yield b.json():"application/octet-stream"===_||"application/pdf"===_?yield b.blob():"text/event-stream"===_?b:"multipart/form-data"===_?yield b.formData():yield b.text(),error:null,response:b}}catch(e){return{data:null,error:e,response:e instanceof o||e instanceof a?e.context:void 0}}finally{s&&clearTimeout(s)}},new(s||(s=Promise))(function(e,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof s?r:new s(function(e){e(r)})).then(a,o)}l((n=n.apply(t,r||[])).next())})}}let h=e=>Math.min(1e3*2**e,3e4),c=[520,503],d=["GET","HEAD","OPTIONS"];var f,p,g,y,m,b,w,_,v,k,E,S,T=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}}};function A(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)})}var R=class{constructor(e){var t,r,s,n,i;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==(i=e.retry)||i,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=0;for(;;){var t,n,i,a,o;let l,u=new Headers(r.headers);e>0&&u.set("X-Retry-Count",String(e));try{l=await s(r.url.toString(),{method:r.method,headers:u,body:JSON.stringify(r.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:r.signal})}catch(t){if((null==t?void 0:t.name)==="AbortError"||(null==t?void 0:t.code)==="ABORT_ERR"||!d.includes(r.method))throw t;if(r.retryEnabled&&e<3){let t=h(e);e++,await A(t,r.signal);continue}throw t}if(t=r.method,n=l.status,i=e,r.retryEnabled&&!(i>=3)&&d.includes(t)&&c.includes(n)&&1){let t=null!=(a=null==(o=l.headers)?void 0:o.get("Retry-After"))?a:null,s=null!==t?1e3*Math.max(0,parseInt(t,10)||0):h(e);await l.text(),e++,await A(s,r.signal);continue}return await r.processResponse(l)}})();return this.shouldThrowOnError||(n=n.catch(e=>{var t,r,s,n,i,a;let o="",l="",u="",h=null==e?void 0:e.cause;if(h){let t=null!=(r=null==h?void 0:h.message)?r:"",a=null!=(s=null==h?void 0:h.code)?s:"";o=`${null!=(n=null==e?void 0:e.name)?n:"FetchError"}: ${null==e?void 0:e.message}
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,71060,(e,t,r)=>{t.exports=e.r(2052)},72074,e=>{"use strict";e.s(["is_modal_dialog_open",0,function(){return null!==document.querySelector('[role="dialog"][aria-modal="true"]')}])},66252,(e,t,r)=>{var s={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],s=t[1];return(r+s)*3/4-s},t.toByteArray=function(e){var t,r,n=l(e),a=n[0],o=n[1],u=new i((a+o)*3/4-o),h=0,c=o>0?a-4:a;for(r=0;r<c;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===o&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,u[h++]=255&t),1===o&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,s=e.length,i=s%3,n=[],a=0,o=s-i;a<o;a+=16383)n.push(function(e,t,s){for(var i,n=[],a=t;a<s;a+=3)i=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),n.push(r[i>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return n.join("")}(e,a,a+16383>o?o:a+16383));return 1===i?n.push(r[(t=e[s-1])>>2]+r[t<<4&63]+"=="):2===i&&n.push(r[(t=(e[s-2]<<8)+e[s-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),n.join("")};for(var r=[],s=[],i="u">typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=n.length;a<o;++a)r[a]=n[a],s[n.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var s=r===t?0:4-r%4;return[r,s]}s[45]=62,s[95]=63},72:function(e,t,r){"use strict";var s=r(675),i=r(783),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var s=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!o.isEncoding(i))throw TypeError("Unknown encoding: "+i);var n=0|f(s,i),l=a(n),u=l.write(s,i);return u!==n&&(l=l.slice(0,u)),l}if(ArrayBuffer.isView(e))return c(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(C(e,ArrayBuffer)||e&&C(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(C(e,SharedArrayBuffer)||e&&C(e.buffer,SharedArrayBuffer)))return function(e,t,r){var s;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),s}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var h=e.valueOf&&e.valueOf();if(null!=h&&h!==e)return o.from(h,t,r);var p=function(e){if(o.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(p)return p;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return u(e),a(e<0?0:0|d(e))}function c(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),s=0;s<t;s+=1)r[s]=255&e[s];return r}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(u(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return h(e)},o.allocUnsafeSlow=function(e){return h(e)};function d(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||C(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return T(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return R(e).length;default:if(i)return s?-1:T(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var i,n,a,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);for(var i="",n=t;n<r;++n)i+=P[e[n]];return i}(this,t,r);case"utf8":case"utf-8":return b(this,t,r);case"ascii":return function(e,t,r){var s="";r=Math.min(e.length,r);for(var i=t;i<r;++i)s+=String.fromCharCode(127&e[i]);return s}(this,t,r);case"latin1":case"binary":return function(e,t,r){var s="";r=Math.min(e.length,r);for(var i=t;i<r;++i)s+=String.fromCharCode(e[i]);return s}(this,t,r);case"base64":return i=this,n=t,a=r,0===n&&a===i.length?s.fromByteArray(i):s.fromByteArray(i.slice(n,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var s=e.slice(t,r),i="",n=0;n<s.length;n+=2)i+=String.fromCharCode(s[n]+256*s[n+1]);return i}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function g(e,t,r){var s=e[t];e[t]=e[r],e[r]=s}function y(e,t,r,s,i){var n;if(0===e.length)return -1;if("string"==typeof r?(s=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(n=r*=1)!=n&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(i)return -1;else r=e.length-1;else if(r<0)if(!i)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,s)),o.isBuffer(t))return 0===t.length?-1:m(e,t,r,s,i);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return m(e,[t],r,s,i)}throw TypeError("val must be string, number or Buffer")}function m(e,t,r,s,i){var n,a=1,o=e.length,l=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var h=-1;for(n=r;n<o;n++)if(u(e,n)===u(t,-1===h?0:n-h)){if(-1===h&&(h=n),n-h+1===l)return h*a}else -1!==h&&(n-=n-h),h=-1}else for(r+l>o&&(r=o-l),n=r;n>=0;n--){for(var c=!0,d=0;d<l;d++)if(u(e,n+d)!==u(t,d)){c=!1;break}if(c)return n}return -1}o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(C(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),C(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,s=t.length,i=0,n=Math.min(r,s);i<n;++i)if(e[i]!==t[i]){r=e[i],s=t[i];break}return r<s?-1:+(s<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,s=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var n=e[r];if(C(n,Uint8Array)&&(n=o.from(n)),!o.isBuffer(n))throw TypeError('"list" argument must be an Array of Buffers');n.copy(s,i),i+=n.length}return s},o.byteLength=f,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?b(this,0,e):p.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(e,t,r,s,i){if(C(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===i&&(i=this.length),t<0||r>e.length||s<0||i>this.length)throw RangeError("out of range index");if(s>=i&&t>=r)return 0;if(s>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,s>>>=0,i>>>=0,this===e)return 0;for(var n=i-s,a=r-t,l=Math.min(n,a),u=this.slice(s,i),h=e.slice(t,r),c=0;c<l;++c)if(u[c]!==h[c]){n=u[c],a=h[c];break}return n<a?-1:+(a<n)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)};function b(e,t,r){r=Math.min(e.length,r);for(var s=[],i=t;i<r;){var n,a,o,l,u=e[i],h=null,c=u>239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:(192&(n=e[i+1]))==128&&(l=(31&u)<<6|63&n)>127&&(h=l);break;case 3:n=e[i+1],a=e[i+2],(192&n)==128&&(192&a)==128&&(l=(15&u)<<12|(63&n)<<6|63&a)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:n=e[i+1],a=e[i+2],o=e[i+3],(192&n)==128&&(192&a)==128&&(192&o)==128&&(l=(15&u)<<18|(63&n)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h),i+=c}var d=s,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",g=0;g<f;)p+=String.fromCharCode.apply(String,d.slice(g,g+=4096));return p}function w(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function _(e,t,r,s,i,n){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<n)throw RangeError('"value" argument is out of bounds');if(r+s>e.length)throw RangeError("Index out of range")}function v(e,t,r,s,i,n){if(r+s>e.length||r<0)throw RangeError("Index out of range")}function k(e,t,r,s,n){return t*=1,r>>>=0,n||v(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,s,23,4),r+4}function E(e,t,r,s,n){return t*=1,r>>>=0,n||v(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,s,52,8),r+8}o.prototype.write=function(e,t,r,s){if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,n,a,o,l,u,h,c,d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var f=!1;;)switch(s){case"hex":return function(e,t,r,s){r=Number(r)||0;var i=e.length-r;s?(s=Number(s))>i&&(s=i):s=i;var n=t.length;s>n/2&&(s=n/2);for(var a=0;a<s;++a){var o,l=parseInt(t.substr(2*a,2),16);if((o=l)!=o)break;e[r+a]=l}return a}(this,e,t,r);case"utf8":case"utf-8":return i=t,n=r,O(T(e,this.length-i),this,i,n);case"ascii":return a=t,o=r,O(A(e),this,a,o);case"latin1":case"binary":return function(e,t,r,s){return O(A(t),e,r,s)}(this,e,t,r);case"base64":return l=t,u=r,O(R(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h=t,c=r,O(function(e,t){for(var r,s,i=[],n=0;n<e.length&&!((t-=2)<0);++n)s=(r=e.charCodeAt(n))>>8,i.push(r%256),i.push(s);return i}(e,this.length-h),this,h,c);default:if(f)throw TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var s=this.subarray(e,t);return Object.setPrototypeOf(s,o.prototype),s},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=this[e],i=1,n=0;++n<t&&(i*=256);)s+=this[e+n]*i;return s},o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=this[e+--t],i=1;t>0&&(i*=256);)s+=this[e+--t]*i;return s},o.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=this[e],i=1,n=0;++n<t&&(i*=256);)s+=this[e+n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var s=t,i=1,n=this[e+--s];s>0&&(i*=256);)n+=this[e+--s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,s){if(e*=1,t>>>=0,r>>>=0,!s){var i=Math.pow(2,8*r)-1;_(this,e,t,r,i,0)}var n=1,a=0;for(this[t]=255&e;++a<r&&(n*=256);)this[t+a]=e/n&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,s){if(e*=1,t>>>=0,r>>>=0,!s){var i=Math.pow(2,8*r)-1;_(this,e,t,r,i,0)}var n=r-1,a=1;for(this[t+n]=255&e;--n>=0&&(a*=256);)this[t+n]=e/a&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,s){if(e*=1,t>>>=0,!s){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var n=0,a=1,o=0;for(this[t]=255&e;++n<r&&(a*=256);)e<0&&0===o&&0!==this[t+n-1]&&(o=1),this[t+n]=(e/a|0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,s){if(e*=1,t>>>=0,!s){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var n=r-1,a=1,o=0;for(this[t+n]=255&e;--n>=0&&(a*=256);)e<0&&0===o&&0!==this[t+n+1]&&(o=1),this[t+n]=(e/a|0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return k(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return k(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return E(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return E(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,s){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(s<0)throw RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);var i=s-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,s);else if(this===e&&r<t&&t<s)for(var n=i-1;n>=0;--n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,s),t);return i},o.prototype.fill=function(e,t,r,s){if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw TypeError("encoding must be a string");if("string"==typeof s&&!o.isEncoding(s))throw TypeError("Unknown encoding: "+s);if(1===e.length){var i,n=e.charCodeAt(0);("utf8"===s&&n<128||"latin1"===s)&&(e=n)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=o.isBuffer(e)?e:o.from(e,s),l=a.length;if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%l]}return this};var S=/[^+/0-9A-Za-z-_]/g;function T(e,t){t=t||1/0;for(var r,s=e.length,i=null,n=[],a=0;a<s;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319||a+1===s){(t-=3)>-1&&n.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&n.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&n.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;n.push(r)}else if(r<2048){if((t-=2)<0)break;n.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;n.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;n.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return n}function A(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function R(e){return s.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(S,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function O(e,t,r,s){for(var i=0;i<s&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function C(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var P=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var s=16*r,i=0;i<16;++i)t[s+i]=e[r]+e[i];return t}()},783:function(e,t){t.read=function(e,t,r,s,i){var n,a,o=8*i-s-1,l=(1<<o)-1,u=l>>1,h=-7,c=r?i-1:0,d=r?-1:1,f=e[t+c];for(c+=d,n=f&(1<<-h)-1,f>>=-h,h+=o;h>0;n=256*n+e[t+c],c+=d,h-=8);for(a=n&(1<<-h)-1,n>>=-h,h+=s;h>0;a=256*a+e[t+c],c+=d,h-=8);if(0===n)n=1-u;else{if(n===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,s),n-=u}return(f?-1:1)*a*Math.pow(2,n-s)},t.write=function(e,t,r,s,i,n){var a,o,l,u=8*n-i-1,h=(1<<u)-1,c=h>>1,d=5960464477539062e-23*(23===i),f=s?0:n-1,p=s?1:-1,g=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+c>=1?t+=d/l:t+=d*Math.pow(2,1-c),t*l>=2&&(a++,l/=2),a+c>=h?(o=0,a=h):a+c>=1?(o=(t*l-1)*Math.pow(2,i),a+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&o,f+=p,o/=256,i-=8);for(a=a<<i|o,u+=i;u>0;e[r+f]=255&a,f+=p,a/=256,u-=8);e[r+f-p]|=128*g}}},i={};function n(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}},a=!0;try{s[e](r,r.exports,n),a=!1}finally{a&&delete i[e]}return r.exports}n.ab="/ROOT/node_modules/.pnpm/next@16.2.6_@babel+core@7.29.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/next/dist/compiled/buffer/",t.exports=n(72)},22792,(e,t,r)=>{"use strict";let s;Object.defineProperty(r,"__esModule",{value:!0}),r.parseCookie=c,r.parse=c,r.stringifyCookie=function(e,t){let r=t?.encode||encodeURIComponent,s=[];for(let t of Object.keys(e)){let a=e[t];if(void 0===a)continue;if(!i.test(t))throw TypeError(`cookie name is invalid: ${t}`);let o=r(a);if(!n.test(o))throw TypeError(`cookie val is invalid: ${a}`);s.push(`${t}=${o}`)}return s.join("; ")},r.stringifySetCookie=d,r.serialize=d,r.parseSetCookie=function(e,t){let r=t?.decode||y,s=e.length,i=f(e,0,s),n=p(e,0,i),a=-1===n?{name:"",value:r(g(e,0,i))}:{name:g(e,0,n),value:r(g(e,n+1,i))},o=i+1;for(;o<s;){let t=f(e,o,s),r=p(e,o,t),i=-1===r?g(e,o,t):g(e,o,r),n=-1===r?void 0:g(e,r+1,t);switch(i.toLowerCase()){case"httponly":a.httpOnly=!0;break;case"secure":a.secure=!0;break;case"partitioned":a.partitioned=!0;break;case"domain":a.domain=n;break;case"path":a.path=n;break;case"max-age":n&&l.test(n)&&(a.maxAge=Number(n));break;case"expires":if(!n)break;let u=new Date(n);Number.isFinite(u.valueOf())&&(a.expires=u);break;case"priority":if(!n)break;let h=n.toLowerCase();("low"===h||"medium"===h||"high"===h)&&(a.priority=h);break;case"samesite":if(!n)break;let c=n.toLowerCase();("lax"===c||"strict"===c||"none"===c)&&(a.sameSite=c)}o=t+1}return a},r.stringifySetCookie=d,r.serialize=d;let i=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,n=/^[\u0021-\u003A\u003C-\u007E]*$/,a=/^([.]?[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+$/,u=Object.prototype.toString,h=((s=function(){}).prototype=Object.create(null),s);function c(e,t){let r=new h,s=e.length;if(s<2)return r;let i=t?.decode||y,n=0;do{let t=p(e,n,s);if(-1===t)break;let a=f(e,n,s);if(t>a){n=e.lastIndexOf(";",t-1)+1;continue}let o=g(e,n,t);void 0===r[o]&&(r[o]=i(g(e,t+1,a))),n=a+1}while(n<s)return r}function d(e,t,r){let s="object"==typeof e?e:{...r,name:e,value:String(t)},l=("object"==typeof t?t:r)?.encode||encodeURIComponent;if(!i.test(s.name))throw TypeError(`argument name is invalid: ${s.name}`);let h=s.value?l(s.value):"";if(!n.test(h))throw TypeError(`argument val is invalid: ${s.value}`);let c=s.name+"="+h;if(void 0!==s.maxAge){if(!Number.isInteger(s.maxAge))throw TypeError(`option maxAge is invalid: ${s.maxAge}`);c+="; Max-Age="+s.maxAge}if(s.domain){if(!a.test(s.domain))throw TypeError(`option domain is invalid: ${s.domain}`);c+="; Domain="+s.domain}if(s.path){if(!o.test(s.path))throw TypeError(`option path is invalid: ${s.path}`);c+="; Path="+s.path}if(s.expires){var d;if(d=s.expires,"[object Date]"!==u.call(d)||!Number.isFinite(s.expires.valueOf()))throw TypeError(`option expires is invalid: ${s.expires}`);c+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(c+="; HttpOnly"),s.secure&&(c+="; Secure"),s.partitioned&&(c+="; Partitioned"),s.priority)switch("string"==typeof s.priority?s.priority.toLowerCase():void 0){case"low":c+="; Priority=Low";break;case"medium":c+="; Priority=Medium";break;case"high":c+="; 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":c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"none":c+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${s.sameSite}`)}return c}function f(e,t,r){let s=e.indexOf(";",t);return -1===s?r:s}function p(e,t,r){let s=e.indexOf("=",t);return s<r?s:-1}function g(e,t,r){let s=t,i=r;do{let t=e.charCodeAt(s);if(32!==t&&9!==t)break}while(++s<i)for(;i>s;){let t=e.charCodeAt(i-1);if(32!==t&&9!==t)break;i--}return e.slice(s,i)}function y(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}},32417,e=>{"use strict";e.s(["is_supabase_configured",0,function(){return("https://ctruizaqyeyidujmtxhc.supabase.co".trim()??"").length>0&&("sb_publishable_gTYHeWoWIPPW3SIC4cYaXw_ux7UL_Jb".trim()??"").length>0}])},83105,e=>{"use strict";let t,r,s;class i 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 n extends i{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class a extends i{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class o extends i{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}function l(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 i=0,s=Object.getOwnPropertySymbols(e);i<s.length;i++)0>t.indexOf(s[i])&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(r[s[i]]=e[s[i]]);return r}(b=w||(w={})).Any="any",b.ApNortheast1="ap-northeast-1",b.ApNortheast2="ap-northeast-2",b.ApSouth1="ap-south-1",b.ApSoutheast1="ap-southeast-1",b.ApSoutheast2="ap-southeast-2",b.CaCentral1="ca-central-1",b.EuCentral1="eu-central-1",b.EuWest1="eu-west-1",b.EuWest2="eu-west-2",b.EuWest3="eu-west-3",b.SaEast1="sa-east-1",b.UsEast1="us-east-1",b.UsWest1="us-west-1",b.UsWest2="us-west-2";"function"==typeof SuppressedError&&SuppressedError;class u{constructor(e,{headers:t={},customFetch:r,region:s=w.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){var t,r,s,i;return t=this,r=arguments,s=void 0,i=function*(e,t={}){var r;let s,i;try{let l,{headers:u,method:h,body:c,signal:d,timeout:f}=t,p={},{region:g}=t;g||(g=this.region);let y=new URL(`${this.url}/${e}`);g&&"any"!==g&&(p["x-region"]=g,y.searchParams.set("forceFunctionRegion",g)),c&&(u&&!Object.prototype.hasOwnProperty.call(u,"Content-Type")||!u)?"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer?(p["Content-Type"]="application/octet-stream",l=c):"string"==typeof c?(p["Content-Type"]="text/plain",l=c):"u">typeof FormData&&c instanceof FormData?l=c:(p["Content-Type"]="application/json",l=JSON.stringify(c)):l=!c||"string"==typeof c||"u">typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer||"u">typeof FormData&&c instanceof FormData?c:JSON.stringify(c);let m=d;f&&(i=new AbortController,s=setTimeout(()=>i.abort(),f),d?(m=i.signal,d.addEventListener("abort",()=>i.abort())):m=i.signal);let b=yield this.fetch(y.toString(),{method:h||"POST",headers:Object.assign(Object.assign(Object.assign({},p),this.headers),u),body:l,signal:m}).catch(e=>{throw new n(e)}),w=b.headers.get("x-relay-error");if(w&&"true"===w)throw new a(b);if(!b.ok)throw new o(b);let _=(null!=(r=b.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim();return{data:"application/json"===_?yield b.json():"application/octet-stream"===_||"application/pdf"===_?yield b.blob():"text/event-stream"===_?b:"multipart/form-data"===_?yield b.formData():yield b.text(),error:null,response:b}}catch(e){return{data:null,error:e,response:e instanceof o||e instanceof a?e.context:void 0}}finally{s&&clearTimeout(s)}},new(s||(s=Promise))(function(e,n){function a(e){try{l(i.next(e))}catch(e){n(e)}}function o(e){try{l(i.throw(e))}catch(e){n(e)}}function l(t){var r;t.done?e(t.value):((r=t.value)instanceof s?r:new s(function(e){e(r)})).then(a,o)}l((i=i.apply(t,r||[])).next())})}}let h=e=>Math.min(1e3*2**e,3e4),c=[520,503],d=["GET","HEAD","OPTIONS"];var f,p,g,y,m,b,w,_,v,k,E,S,T=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}}};function A(e,t){return new Promise(r=>{if(null==t?void 0:t.aborted)return void r();let s=setTimeout(()=>{null==t||t.removeEventListener("abort",i),r()},e);function i(){clearTimeout(s),r()}null==t||t.addEventListener("abort",i)})}var R=class{constructor(e){var t,r,s,i,n;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!=(i=e.urlLengthLimit)?i:8e3,this.retryEnabled=null==(n=e.retry)||n,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,i=(async()=>{let e=0;for(;;){var t,i,n,a,o;let l,u=new Headers(r.headers);e>0&&u.set("X-Retry-Count",String(e));try{l=await s(r.url.toString(),{method:r.method,headers:u,body:JSON.stringify(r.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:r.signal})}catch(t){if((null==t?void 0:t.name)==="AbortError"||(null==t?void 0:t.code)==="ABORT_ERR"||!d.includes(r.method))throw t;if(r.retryEnabled&&e<3){let t=h(e);e++,await A(t,r.signal);continue}throw t}if(t=r.method,i=l.status,n=e,r.retryEnabled&&!(n>=3)&&d.includes(t)&&c.includes(i)&&1){let t=null!=(a=null==(o=l.headers)?void 0:o.get("Retry-After"))?a:null,s=null!==t?1e3*Math.max(0,parseInt(t,10)||0):h(e);await l.text(),e++,await A(s,r.signal);continue}return await r.processResponse(l)}})();return this.shouldThrowOnError||(i=i.catch(e=>{var t,r,s,i,n,a;let o="",l="",u="",h=null==e?void 0:e.cause;if(h){let t=null!=(r=null==h?void 0:h.message)?r:"",a=null!=(s=null==h?void 0:h.code)?s:"";o=`${null!=(i=null==e?void 0:e.name)?i:"FetchError"}: ${null==e?void 0:e.message}
|
|
2
2
|
|
|
3
|
-
Caused by: ${null!=(
|
|
4
|
-
${h.stack}`)}else o=null!=(a=null==e?void 0:e.stack)?a:"";let c=this.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(u="",l="Request was aborted (timeout or manual cancellation)",c>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${c} 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==h?void 0:h.name)==="HeadersOverflowError"||(null==h?void 0:h.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",l="HTTP headers exceeded server limits (typically 16KB)",c>this.urlLengthLimit&&(l+=`. Your request URL is ${c} 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:u},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}async processResponse(e){var t,r,s;let n=null,i=null,a=null,o=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();""===t||(i="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null==(s=this.headers.get("Accept"))?void 0:s.includes("application/vnd.pgrst.plan+text"))?t:JSON.parse(t))}let u=null==(t=this.headers.get("Prefer"))?void 0:t.match(/count=(exact|planned|estimated)/),h=null==(r=e.headers.get("content-range"))?void 0:r.split("/");u&&h&&h.length>1&&(a=parseInt(h[1])),this.isMaybeSingle&&Array.isArray(i)&&(i.length>1?(n={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,a=null,o=406,l="Not Acceptable"):i=1===i.length?i[0]:null)}else{let t=await e.text();try{n=JSON.parse(t),Array.isArray(n)&&404===e.status&&(i=[],n=null,o=200,l="OK")}catch(r){404===e.status&&""===t?(o=204,l="No Content"):n={message:t}}if(n&&this.shouldThrowOnError)throw new T(n)}return{success:null===n,error:n,data:i,count:a,status:o,statusText:l}}returns(){return this}overrideTypes(){return this}},O=class extends R{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 i=n?`${n}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${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`,i=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this.url.searchParams.set(i,`${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:i="text"}={}){var a;let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=null!=(a=this.headers.get("Accept"))?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; 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 C=RegExp("[,()]");var P=class extends O{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&&C.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&&C.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 i=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${n}fts${i}.${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}},I=class{constructor(e,{headers:t={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:i}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=i}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,i=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e)).join(""),{url:a,headers:o}=this.cloneRequestState();return a.searchParams.set("select",i),s&&o.append("Prefer",`count=${s}`),new P({method:r?"HEAD":"GET",url:a,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:i}=this.cloneRequestState();if(t&&i.append("Prefer",`count=${t}`),r||i.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 P({method:"POST",url:n,headers:i,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 i;let{url:a,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&a.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}"`);a.searchParams.set("columns",e.join(","))}}return new P({method:"POST",url:a,headers:o,schema:this.schema,body:e,fetch:null!=(i=this.fetch)?i: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 P({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 P({method:"DELETE",url:r,headers:s,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function j(e){return(j="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 $(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 x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?$(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=j(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=j(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==j(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)):$(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var N=class e{constructor(e,{headers:t={},schema:r,fetch:s,timeout:n,urlLengthLimit:i=8e3,retry:a}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.urlLengthLimit=i;const o=null!=s?s:globalThis.fetch;void 0!==n&&n>0?this.fetch=(e,t)=>{let r=new AbortController,s=setTimeout(()=>r.abort(),n),i=null==t?void 0:t.signal;if(i){if(i.aborted)return clearTimeout(s),o(e,t);let n=()=>{clearTimeout(s),r.abort()};return i.addEventListener("abort",n,{once:!0}),o(e,x(x({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(s),i.removeEventListener("abort",n)})}return o(e,x(x({},t),{},{signal:r.signal})).finally(()=>clearTimeout(s))}:this.fetch=o,this.retry=a}from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new I(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})}rpc(e,t={},{head:r=!1,get:s=!1,count:n}={}){var i;let a,o,l=new URL(`${this.url}/rpc/${e}`),u=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(u)),h=r&&Object.values(t).some(u);h?(a="POST",o=t):r||s?(a=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)})):(a="POST",o=t);let c=new Headers(this.headers);return h?c.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&c.set("Prefer",`count=${n}`),new P({method:a,url:l,headers:c,schema:this.schemaName,body:o,fetch:null!=(i=this.fetch)?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};let U=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){let t=parseInt(e.node.replace(/^v/,"").split(".")[0]);return t>=22?void 0!==globalThis.WebSocket?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${t} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${t} detected without native WebSocket support.`,workaround:'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew RealtimeClient(url, { transport: ws })'}}}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+=`
|
|
3
|
+
Caused by: ${null!=(n=null==h?void 0:h.name)?n:"Error"}: ${t}`,a&&(o+=` (${a})`),(null==h?void 0:h.stack)&&(o+=`
|
|
4
|
+
${h.stack}`)}else o=null!=(a=null==e?void 0:e.stack)?a:"";let c=this.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(u="",l="Request was aborted (timeout or manual cancellation)",c>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${c} 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==h?void 0:h.name)==="HeadersOverflowError"||(null==h?void 0:h.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",l="HTTP headers exceeded server limits (typically 16KB)",c>this.urlLengthLimit&&(l+=`. Your request URL is ${c} 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:u},data:null,count:null,status:0,statusText:""}})),i.then(e,t)}async processResponse(e){var t,r,s;let i=null,n=null,a=null,o=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();""===t||(n="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null==(s=this.headers.get("Accept"))?void 0:s.includes("application/vnd.pgrst.plan+text"))?t:JSON.parse(t))}let u=null==(t=this.headers.get("Prefer"))?void 0:t.match(/count=(exact|planned|estimated)/),h=null==(r=e.headers.get("content-range"))?void 0:r.split("/");u&&h&&h.length>1&&(a=parseInt(h[1])),this.isMaybeSingle&&Array.isArray(n)&&(n.length>1?(i={code:"PGRST116",details:`Results contain ${n.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},n=null,a=null,o=406,l="Not Acceptable"):n=1===n.length?n[0]:null)}else{let t=await e.text();try{i=JSON.parse(t),Array.isArray(i)&&404===e.status&&(n=[],i=null,o=200,l="OK")}catch(r){404===e.status&&""===t?(o=204,l="No Content"):i={message:t}}if(i&&this.shouldThrowOnError)throw new T(i)}return{success:null===i,error:i,data:n,count:a,status:o,statusText:l}}returns(){return this}overrideTypes(){return this}},O=class extends R{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:i=s}={}){let n=i?`${i}.order`:"order",a=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${a?`${a},`:""}${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 i=void 0===s?"offset":`${s}.offset`,n=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(n,`${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:i=!1,format:n="text"}={}){var a;let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=null!=(a=this.headers.get("Accept"))?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${n}; 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 C=RegExp("[,()]");var P=class extends O{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&&C.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&&C.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 i="";"plain"===s?i="pl":"phrase"===s?i="ph":"websearch"===s&&(i="w");let n=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${n}.${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}},I=class{constructor(e,{headers:t={},schema:r,fetch:s,urlLengthLimit:i=8e3,retry:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s,this.urlLengthLimit=i,this.retry=n}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:{},i=!1,n=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!i?"":('"'===e&&(i=!i),e)).join(""),{url:a,headers:o}=this.cloneRequestState();return a.searchParams.set("select",n),s&&o.append("Prefer",`count=${s}`),new P({method:r?"HEAD":"GET",url:a,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:i,headers:n}=this.cloneRequestState();if(t&&n.append("Prefer",`count=${t}`),r||n.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 P({method:"POST",url:i,headers:n,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:i=!0}={}){var n;let{url:a,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&a.searchParams.set("on_conflict",t),s&&o.append("Prefer",`count=${s}`),i||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}"`);a.searchParams.set("columns",e.join(","))}}return new P({method:"POST",url:a,headers:o,schema:this.schema,body:e,fetch:null!=(n=this.fetch)?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var r;let{url:s,headers:i}=this.cloneRequestState();return t&&i.append("Prefer",`count=${t}`),new P({method:"PATCH",url:s,headers:i,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 P({method:"DELETE",url:r,headers:s,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function j(e){return(j="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 $(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 x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?$(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=j(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=j(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==j(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)):$(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var N=class e{constructor(e,{headers:t={},schema:r,fetch:s,timeout:i,urlLengthLimit:n=8e3,retry:a}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.urlLengthLimit=n;const o=null!=s?s:globalThis.fetch;void 0!==i&&i>0?this.fetch=(e,t)=>{let r=new AbortController,s=setTimeout(()=>r.abort(),i),n=null==t?void 0:t.signal;if(n){if(n.aborted)return clearTimeout(s),o(e,t);let i=()=>{clearTimeout(s),r.abort()};return n.addEventListener("abort",i,{once:!0}),o(e,x(x({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(s),n.removeEventListener("abort",i)})}return o(e,x(x({},t),{},{signal:r.signal})).finally(()=>clearTimeout(s))}:this.fetch=o,this.retry=a}from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new I(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})}rpc(e,t={},{head:r=!1,get:s=!1,count:i}={}){var n;let a,o,l=new URL(`${this.url}/rpc/${e}`),u=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(u)),h=r&&Object.values(t).some(u);h?(a="POST",o=t):r||s?(a=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)})):(a="POST",o=t);let c=new Headers(this.headers);return h?c.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&c.set("Prefer",`count=${i}`),new P({method:a,url:l,headers:c,schema:this.schemaName,body:o,fetch:null!=(n=this.fetch)?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};let U=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 i=globalThis.process;if(i){let e=i.versions;if(e&&e.node){let t=parseInt(e.node.replace(/^v/,"").split(".")[0]);return t>=22?void 0!==globalThis.WebSocket?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${t} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${t} detected without native WebSocket support.`,workaround:'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew RealtimeClient(url, { transport: ws })'}}}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+=`
|
|
5
5
|
|
|
6
|
-
Suggested solution: ${e.workaround}`),Error(t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}},L="2.0.0",D="errored",B="joined",M={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"};class q{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=e.topic,n=null!=(f=e.ref)?f:"",i=null!=(p=e.join_ref)?p:"",a=e.payload.event,o=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},l=0===Object.keys(o).length?"":JSON.stringify(o);if(i.length>255)throw Error(`joinRef length ${i.length} exceeds maximum of 255`);if(n.length>255)throw Error(`ref length ${n.length} exceeds maximum of 255`);if(s.length>255)throw Error(`topic length ${s.length} exceeds maximum of 255`);if(a.length>255)throw Error(`userEvent length ${a.length} exceeds maximum of 255`);if(l.length>255)throw Error(`metadata length ${l.length} exceeds maximum of 255`);let u=this.USER_BROADCAST_PUSH_META_LENGTH+i.length+n.length+s.length+a.length+l.length,h=new ArrayBuffer(this.HEADER_LENGTH+u),c=new DataView(h),d=0;c.setUint8(d++,this.KINDS.userBroadcastPush),c.setUint8(d++,i.length),c.setUint8(d++,n.length),c.setUint8(d++,s.length),c.setUint8(d++,a.length),c.setUint8(d++,l.length),c.setUint8(d++,t),Array.from(i,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(n,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(s,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(a,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(l,e=>c.setUint8(d++,e.charCodeAt(0)));var f,p,g=new Uint8Array(h.byteLength+r.byteLength);return g.set(new Uint8Array(h),0),g.set(new Uint8Array(r),h.byteLength),g.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,s,n,i,a]=JSON.parse(e);return t({join_ref:r,ref:s,topic:n,event:i,payload:a})}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),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+4,l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+n));o+=n;let h=r.decode(e.slice(o,o+i));o+=i;let c=e.slice(o,e.byteLength),d=a===this.JSON_ENCODING?JSON.parse(r.decode(c)):c,f={type:this.BROADCAST_EVENT,event:u,payload:d};return i>0&&(f.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:f}}_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))):{}}}(f=_||(_={})).abstime="abstime",f.bool="bool",f.date="date",f.daterange="daterange",f.float4="float4",f.float8="float8",f.int2="int2",f.int4="int4",f.int4range="int4range",f.int8="int8",f.int8range="int8range",f.json="json",f.jsonb="jsonb",f.money="money",f.numeric="numeric",f.oid="oid",f.reltime="reltime",f.text="text",f.time="time",f.timestamp="timestamp",f.timestamptz="timestamptz",f.timetz="timetz",f.tsrange="tsrange",f.tstzrange="tstzrange";let H=(e,t,r={})=>{var s;let n=null!=(s=r.skipTypes)?s:[];return t?Object.keys(t).reduce((r,s)=>(r[s]=K(s,e,t,n),r),{}):{}},K=(e,t,r,s)=>{let n=t.find(t=>t.name===e),i=null==n?void 0:n.type,a=r[e];return i&&!s.includes(i)?F(i,a):G(a)},F=(e,t)=>{if("_"===e.charAt(0))return V(t,e.slice(1,e.length));switch(e){case _.bool:return W(t);case _.float4:case _.float8:case _.int2:case _.int4:case _.int8:case _.numeric:case _.oid:return J(t);case _.json:case _.jsonb:return z(t);case _.timestamp:return Y(t);case _.abstime:case _.date:case _.daterange:case _.int4range:case _.int8range:case _.money:case _.reltime:case _.text:case _.time:case _.timestamptz:case _.timetz:case _.tsrange:case _.tstzrange:default:return G(t)}},G=e=>e,W=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},J=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},z=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},V=(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=>F(t,e))}return e},Y=e=>"string"==typeof e?e.replace(" ","T"):e,X=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 Q=e=>"function"==typeof e?e:function(){return e},Z="u">typeof window?window:null,ee=("u">typeof self?self:null)||Z||globalThis,et="closed",er="errored",es="joined",en="joining",ei="leaving",ea="phx_close",eo="phx_error",el="phx_reply",eu="phx_leave",eh="websocket",ec="base64url.bearer.phx.",ed=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})}},ef=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))}},ep=class{constructor(e,t,r){this.state=et,this.topic=e,this.params=Q(t||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new ed(this,"phx_join",this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new ef(()=>{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=es,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=er,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=et,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=er,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new ed(this,eu,Q({}),this.timeout).send(),this.state=er,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(el,(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=et,this.bindings=[]}onClose(e){this.on(ea,e)}onError(e){return this.on(eo,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 ed(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=ei;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ea,"leave")},r=new ed(this,eu,Q({}),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=en,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 i=this.bindings.filter(s=>s.event===e&&this.filterBindings(s,t,r));for(let e=0;e<i.length;e++)i[e].callback(n,r,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===et}isErrored(){return this.state===er}isJoined(){return this.state===es}isJoining(){return this.state===en}isLeaving(){return this.state===ei}},eg=class{static request(e,t,r,s,n,i,a){if(ee.XDomainRequest){let r=new ee.XDomainRequest;return this.xdomainRequest(r,e,t,s,n,i,a)}if(ee.XMLHttpRequest){let o=new ee.XMLHttpRequest;return this.xhrRequest(o,e,t,r,s,n,i,a)}if(ee.fetch&&ee.AbortController)return this.fetchRequest(e,t,r,s,n,i,a);throw Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,r,s,n,i,a){let o={method:e,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),o.signal=l.signal),ee.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>a&&a(e)).catch(e=>{"AbortError"===e.name&&i?i():a&&a(null)}),l}static xdomainRequest(e,t,r,s,n,i,a){return e.timeout=n,e.open(t,r),e.onload=()=>{let t=this.parseJSON(e.responseText);a&&a(t)},i&&(e.ontimeout=i),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,r,s,n,i,a,o){for(let[n,a]of(e.open(t,r,!0),e.timeout=i,Object.entries(s)))e.setRequestHeader(n,a);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{4===e.readyState&&o&&o(this.parseJSON(e.responseText))},a&&(e.ontimeout=a),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,i=e[s];"object"==typeof i?r.push(this.serialize(i,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}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)}`}},ey=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(ec)&&(this.authToken=atob(t[1].slice(ec.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("(.*)/"+eh),"$1/longpoll")}endpointURL(){return eg.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){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join("\n"),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,e&&200===e.status?this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]):(this.onerror(e&&e.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 i,a=()=>{this.reqs.delete(i),s()};i=eg.request(e,this.endpointURL(),t,r,this.timeout,a,e=>{this.reqs.delete(i),this.isActive()&&n(e)}),this.reqs.add(i)}},em=class e{constructor(t,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state={},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.clone(e),i={},a={};return this.map(n,(e,r)=>{t[e]||(a[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&&(i[e]=t,i[e].metas=o),l.length>0&&(a[e]=this.clone(r),a[e].metas=l)}else i[e]=t}),this.syncDiff(n,{joins:i,leaves:a},r,s)}static syncDiff(e,t,r,s){let{joins:n,leaves:i}=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(i,(t,r)=>{let n=e[t];if(!n)return;let i=r.metas.map(e=>e.phx_ref);n.metas=n.metas.filter(e=>0>i.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 clone(e){return JSON.parse(JSON.stringify(e))}},eb={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,i,a]=JSON.parse(e);return t({join_ref:r,ref:s,topic:n,event:i,payload:a})}},binaryEncode(e){let{join_ref:t,ref:r,event:s,topic:n,payload:i}=e,a=this.META_LENGTH+t.length+r.length+n.length+s.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),l=new DataView(o),u=0;l.setUint8(u++,this.KINDS.push),l.setUint8(u++,t.length),l.setUint8(u++,r.length),l.setUint8(u++,n.length),l.setUint8(u++,s.length),Array.from(t,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(r,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(n,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(s,e=>l.setUint8(u++,e.charCodeAt(0)));var h=new Uint8Array(o.byteLength+i.byteLength);return h.set(new Uint8Array(o),0),h.set(new Uint8Array(i),o.byteLength),h.buffer},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),i=t.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(e.slice(a,a+s));a+=s;let l=r.decode(e.slice(a,a+n));a+=n;let u=r.decode(e.slice(a,a+i));return a+=i,{join_ref:o,ref:null,topic:l,event:u,payload:e.slice(a,e.byteLength)}},decodeReply(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+n));o+=n;let h=r.decode(e.slice(o,o+i));o+=i;let c=r.decode(e.slice(o,o+a));return o+=a,{join_ref:l,ref:u,topic:h,event:el,payload:{status:c,response:e.slice(o,e.byteLength)}}},decodeBroadcast(e,t,r){let s=t.getUint8(1),n=t.getUint8(2),i=this.HEADER_LENGTH+2,a=r.decode(e.slice(i,i+s));i+=s;let o=r.decode(e.slice(i,i+n));return i+=n,{join_ref:null,ref:null,topic:a,event:o,payload:e.slice(i,e.byteLength)}}},ew=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||ee.WebSocket||ey,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=ee&&ee.sessionStorage}catch{}this.sessionStore=t.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=eb.encode.bind(eb),this.defaultDecoder=eb.decode.bind(eb),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!==ey?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;Z&&Z.addEventListener&&(Z.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),s=this.connectClock)}),Z.addEventListener("pageshow",e=>{s===this.connectClock&&(s=null,this.connect())}),Z.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),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=Q(t.params||{}),this.endPoint=`${e}/${eh}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new ef(()=>{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}getLongPollTransport(){return ey}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=eg.appendParams(eg.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=Q(e)),(!this.conn||this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ey?this.connectWithFallback(ey,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===ey?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${ec}${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,i=!0,a=this.transportName(e),o=t=>{this.log("transport",`falling back to ${a}...`,t),this.off([r,s]),i=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${a}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),s=this.onError(e=>{this.log("transport","error",e),i&&!n&&(clearTimeout(this.fallbackTimer),o(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(n=!0,!i){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(eo,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 ep(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:i}=e;this.log("push",`${t} ${r} (${i}, ${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:i}=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 a=this.channels[e];a.isMember(t,r,s,i)&&a.trigger(r,s,n,i)}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 e_{constructor(e,t){const r=function(e){return(null==e?void 0:e.events)&&{events:e.events}}(t);this.presence=new em(e.getChannel(),r),this.presence.onJoin((t,r,s)=>{let n=e_.onJoinPayload(t,r,s);e.getChannel().trigger("presence",n)}),this.presence.onLeave((t,r,s)=>{let n=e_.onLeavePayload(t,r,s);e.getChannel().trigger("presence",n)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return e_.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]=ev(s),t},{})}static onJoinPayload(e,t,r){return{event:"join",key:e,currentPresences:ek(t),newPresences:ev(r)}}static onLeavePayload(e,t,r){return{event:"leave",key:e,currentPresences:ek(t),leftPresences:ev(r)}}}function ev(e){return e.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function ek(e){return(null==e?void 0:e.metas)?ev(e):[]}(p=v||(v={})).SYNC="sync",p.JOIN="join",p.LEAVE="leave";class eE{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new e_(this.channel.channelAdapter,t)}}class eS{constructor(e,t,r){const s=function(e){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},e.config)}}(r);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===B}isJoined(){return this.state===B}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}}(g=k||(k={})).ALL="*",g.INSERT="INSERT",g.UPDATE="UPDATE",g.DELETE="DELETE",(y=E||(E={})).BROADCAST="broadcast",y.PRESENCE="presence",y.POSTGRES_CHANGES="postgres_changes",y.SYSTEM="system",(m=S||(S={})).SUBSCRIBED="SUBSCRIBED",m.TIMED_OUT="TIMED_OUT",m.CLOSED="CLOSED",m.CHANNEL_ERROR="CHANNEL_ERROR";class eT{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 eS(this.socket.socketAdapter,e,this.params),this.presence=new eE(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=X(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;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:i,presence:a,private:o}}=this.params,l=null!=(s=null==(r=this.bindings.postgres_changes)?void 0:r.map(e=>e.filter))?s:[],u=!!this.bindings[E.PRESENCE]&&this.bindings[E.PRESENCE].length>0||(null==(n=this.params.config.presence)?void 0:n.enabled)===!0,h={},c={broadcast:i,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:l,private:o};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(S.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(S.CLOSED)),this.updateJoinPayload(Object.assign({config:c},h)),this._updateFilterMessage(),this.channelAdapter.subscribe(t).receive("ok",async({postgres_changes:t})=>{if(this.socket._isManualToken()||this.socket.setAuth(),void 0===t){null==e||e(S.SUBSCRIBED);return}this._updatePostgresBindings(t,e)}).receive("error",t=>{this.state=D;let r=Object.values(t).join(", ")||"error";null==e||e(S.CHANNEL_ERROR,Error(r,{cause:t}))}).receive("timeout",()=>{null==e||e(S.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,i=[];for(let r=0;r<n;r++){let n=s[r],{filter:{event:a,schema:o,table:l,filter:u}}=n,h=e&&e[r];if(h&&h.event===a&&eT.isFilterValueEqual(h.schema,o)&&eT.isFilterValueEqual(h.table,l)&&eT.isFilterValueEqual(h.filter,u))i.push(Object.assign(Object.assign({},n),{id:h.id}));else{this.unsubscribe(),this.state=D,null==t||t(S.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=i,this.state!=D&&t&&t(S.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}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===E.PRESENCE||e===E.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={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(n.Authorization=`Bearer ${this.socket.accessTokenValue}`);let i={method:"POST",headers:n,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,i,null!=(s=r.timeout)?s:this.timeout);if(202===a.status)return{success:!0};let o=a.statusText;try{let e=await a.json();o=e.error||e.message||o}catch(e){}return Promise.reject(Error(o))}async send(e,t={}){var r,s;if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,n,i;let a=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(i=null==(n=null==(s=this.params)?void 0:s.config)?void 0:n.broadcast)?void 0:i.ack)||r("ok"),a.receive("ok",()=>r("ok")),a.receive("error",()=>r("error")),a.receive("timeout",()=>r("timed out"))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");let{event:n,payload:i}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);let o={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:n,payload:i,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,o,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),i=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(n),i}_on(e,t,r){let s=e.toLocaleLowerCase(),n=this.channelAdapter.on(e,r),i={type:s,filter:t,callback:r,ref:n};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],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,i,a,o,l,u;let h=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(h,r))return!1;let c=null==(s=this.bindings[h])?void 0:s.find(t=>t.ref===e.ref);if(!c)return!0;if(!["broadcast","presence","postgres_changes"].includes(h))return c.type.toLocaleLowerCase()===h;if("id"in c){let e=c.id,r=null==(n=c.filter)?void 0:n.event;return e&&(null==(i=t.ids)?void 0:i.includes(e))&&("*"===r||(null==r?void 0:r.toLocaleLowerCase())===(null==(a=t.data)?void 0:a.type.toLocaleLowerCase()))}{let e=null==(l=null==(o=null==c?void 0:c.filter)?void 0:o.event)?void 0:l.toLocaleLowerCase();return"*"===e||e===(null==(u=null==t?void 0:t.event)?void 0:u.toLocaleLowerCase())}})}_notThisChannelEvent(e,t){let{close:r,error:s,leave:n,join:i}=M;return t&&[r,s,n,i].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:i,errors:a}=e;return Object.assign(Object.assign({},{schema:r,table:s,commit_timestamp:n,eventType:i,new:{},old:{},errors:a}),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)}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=H(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=H(e.columns,e.old_record)),t}}class eA{constructor(e,t){this.socket=new ew(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)}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 eR=[1e3,2e3,5e3,1e4],eO=`
|
|
6
|
+
Suggested solution: ${e.workaround}`),Error(t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}},L="2.0.0",D="errored",B="joined",M={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"};class q{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:{},i=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,i)}_encodeUserBroadcastPush(e,t,r){let s=e.topic,i=null!=(f=e.ref)?f:"",n=null!=(p=e.join_ref)?p:"",a=e.payload.event,o=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},l=0===Object.keys(o).length?"":JSON.stringify(o);if(n.length>255)throw Error(`joinRef length ${n.length} exceeds maximum of 255`);if(i.length>255)throw Error(`ref length ${i.length} exceeds maximum of 255`);if(s.length>255)throw Error(`topic length ${s.length} exceeds maximum of 255`);if(a.length>255)throw Error(`userEvent length ${a.length} exceeds maximum of 255`);if(l.length>255)throw Error(`metadata length ${l.length} exceeds maximum of 255`);let u=this.USER_BROADCAST_PUSH_META_LENGTH+n.length+i.length+s.length+a.length+l.length,h=new ArrayBuffer(this.HEADER_LENGTH+u),c=new DataView(h),d=0;c.setUint8(d++,this.KINDS.userBroadcastPush),c.setUint8(d++,n.length),c.setUint8(d++,i.length),c.setUint8(d++,s.length),c.setUint8(d++,a.length),c.setUint8(d++,l.length),c.setUint8(d++,t),Array.from(n,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(i,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(s,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(a,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(l,e=>c.setUint8(d++,e.charCodeAt(0)));var f,p,g=new Uint8Array(h.byteLength+r.byteLength);return g.set(new Uint8Array(h),0),g.set(new Uint8Array(r),h.byteLength),g.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,s,i,n,a]=JSON.parse(e);return t({join_ref:r,ref:s,topic:i,event:n,payload:a})}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),i=t.getUint8(2),n=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+4,l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=r.decode(e.slice(o,o+n));o+=n;let c=e.slice(o,e.byteLength),d=a===this.JSON_ENCODING?JSON.parse(r.decode(c)):c,f={type:this.BROADCAST_EVENT,event:u,payload:d};return n>0&&(f.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:f}}_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))):{}}}(f=_||(_={})).abstime="abstime",f.bool="bool",f.date="date",f.daterange="daterange",f.float4="float4",f.float8="float8",f.int2="int2",f.int4="int4",f.int4range="int4range",f.int8="int8",f.int8range="int8range",f.json="json",f.jsonb="jsonb",f.money="money",f.numeric="numeric",f.oid="oid",f.reltime="reltime",f.text="text",f.time="time",f.timestamp="timestamp",f.timestamptz="timestamptz",f.timetz="timetz",f.tsrange="tsrange",f.tstzrange="tstzrange";let K=(e,t,r={})=>{var s;let i=null!=(s=r.skipTypes)?s:[];return t?Object.keys(t).reduce((r,s)=>(r[s]=H(s,e,t,i),r),{}):{}},H=(e,t,r,s)=>{let i=t.find(t=>t.name===e),n=null==i?void 0:i.type,a=r[e];return n&&!s.includes(n)?F(n,a):G(a)},F=(e,t)=>{if("_"===e.charAt(0))return V(t,e.slice(1,e.length));switch(e){case _.bool:return W(t);case _.float4:case _.float8:case _.int2:case _.int4:case _.int8:case _.numeric:case _.oid:return J(t);case _.json:case _.jsonb:return z(t);case _.timestamp:return Y(t);case _.abstime:case _.date:case _.daterange:case _.int4range:case _.int8range:case _.money:case _.reltime:case _.text:case _.time:case _.timestamptz:case _.timetz:case _.tsrange:case _.tstzrange:default:return G(t)}},G=e=>e,W=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},J=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},z=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},V=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s,i=e.slice(1,r);try{s=JSON.parse("["+i+"]")}catch(e){s=i?i.split(","):[]}return s.map(e=>F(t,e))}return e},Y=e=>"string"==typeof e?e.replace(" ","T"):e,X=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 Q=e=>"function"==typeof e?e:function(){return e},Z="u">typeof window?window:null,ee=("u">typeof self?self:null)||Z||globalThis,et="closed",er="errored",es="joined",ei="joining",en="leaving",ea="phx_close",eo="phx_error",el="phx_reply",eu="phx_leave",eh="websocket",ec="base64url.bearer.phx.",ed=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})}},ef=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))}},ep=class{constructor(e,t,r){this.state=et,this.topic=e,this.params=Q(t||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new ed(this,"phx_join",this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new ef(()=>{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=es,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=er,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=et,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=er,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new ed(this,eu,Q({}),this.timeout).send(),this.state=er,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(el,(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=et,this.bindings=[]}onClose(e){this.on(ea,e)}onError(e){return this.on(eo,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 ed(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=en;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ea,"leave")},r=new ed(this,eu,Q({}),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=ei,this.joinPush.resend(e))}trigger(e,t,r,s){let i=this.onMessage(e,t,r,s);if(t&&!i)throw Error("channel onMessage callbacks must return the payload, modified or unmodified");let n=this.bindings.filter(s=>s.event===e&&this.filterBindings(s,t,r));for(let e=0;e<n.length;e++)n[e].callback(i,r,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===et}isErrored(){return this.state===er}isJoined(){return this.state===es}isJoining(){return this.state===ei}isLeaving(){return this.state===en}},eg=class{static request(e,t,r,s,i,n,a){if(ee.XDomainRequest){let r=new ee.XDomainRequest;return this.xdomainRequest(r,e,t,s,i,n,a)}if(ee.XMLHttpRequest){let o=new ee.XMLHttpRequest;return this.xhrRequest(o,e,t,r,s,i,n,a)}if(ee.fetch&&ee.AbortController)return this.fetchRequest(e,t,r,s,i,n,a);throw Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,r,s,i,n,a){let o={method:e,headers:r,body:s},l=null;return i&&(l=new AbortController,setTimeout(()=>l.abort(),i),o.signal=l.signal),ee.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>a&&a(e)).catch(e=>{"AbortError"===e.name&&n?n():a&&a(null)}),l}static xdomainRequest(e,t,r,s,i,n,a){return e.timeout=i,e.open(t,r),e.onload=()=>{let t=this.parseJSON(e.responseText);a&&a(t)},n&&(e.ontimeout=n),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,r,s,i,n,a,o){for(let[i,a]of(e.open(t,r,!0),e.timeout=n,Object.entries(s)))e.setRequestHeader(i,a);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{4===e.readyState&&o&&o(this.parseJSON(e.responseText))},a&&(e.ontimeout=a),e.send(i),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 i=t?`${t}[${s}]`:s,n=e[s];"object"==typeof n?r.push(this.serialize(n,i)):r.push(encodeURIComponent(i)+"="+encodeURIComponent(n))}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)}`}},ey=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(ec)&&(this.authToken=atob(t[1].slice(ec.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("(.*)/"+eh),"$1/longpoll")}endpointURL(){return eg.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){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join("\n"),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,e&&200===e.status?this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]):(this.onerror(e&&e.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,i){let n,a=()=>{this.reqs.delete(n),s()};n=eg.request(e,this.endpointURL(),t,r,this.timeout,a,e=>{this.reqs.delete(n),this.isActive()&&i(e)}),this.reqs.add(n)}},em=class e{constructor(t,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state={},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:i}=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=[],i()}),this.channel.on(s.diff,t=>{let{onJoin:r,onLeave:s,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,r,s),i())})}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 i=this.clone(e),n={},a={};return this.map(i,(e,r)=>{t[e]||(a[e]=r)}),this.map(t,(e,t)=>{let r=i[e];if(r){let s=t.metas.map(e=>e.phx_ref),i=r.metas.map(e=>e.phx_ref),o=t.metas.filter(e=>0>i.indexOf(e.phx_ref)),l=r.metas.filter(e=>0>s.indexOf(e.phx_ref));o.length>0&&(n[e]=t,n[e].metas=o),l.length>0&&(a[e]=this.clone(r),a[e].metas=l)}else n[e]=t}),this.syncDiff(i,{joins:n,leaves:a},r,s)}static syncDiff(e,t,r,s){let{joins:i,leaves:n}=this.clone(t);return r||(r=function(){}),s||(s=function(){}),this.map(i,(t,s)=>{let i=e[t];if(e[t]=this.clone(s),i){let r=e[t].metas.map(e=>e.phx_ref),s=i.metas.filter(e=>0>r.indexOf(e.phx_ref));e[t].metas.unshift(...s)}r(t,i,s)}),this.map(n,(t,r)=>{let i=e[t];if(!i)return;let n=r.metas.map(e=>e.phx_ref);i.metas=i.metas.filter(e=>0>n.indexOf(e.phx_ref)),s(t,i,r),0===i.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 clone(e){return JSON.parse(JSON.stringify(e))}},eb={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,i,n,a]=JSON.parse(e);return t({join_ref:r,ref:s,topic:i,event:n,payload:a})}},binaryEncode(e){let{join_ref:t,ref:r,event:s,topic:i,payload:n}=e,a=this.META_LENGTH+t.length+r.length+i.length+s.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),l=new DataView(o),u=0;l.setUint8(u++,this.KINDS.push),l.setUint8(u++,t.length),l.setUint8(u++,r.length),l.setUint8(u++,i.length),l.setUint8(u++,s.length),Array.from(t,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(r,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(i,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(s,e=>l.setUint8(u++,e.charCodeAt(0)));var h=new Uint8Array(o.byteLength+n.byteLength);return h.set(new Uint8Array(o),0),h.set(new Uint8Array(n),o.byteLength),h.buffer},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),i=t.getUint8(2),n=t.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(e.slice(a,a+s));a+=s;let l=r.decode(e.slice(a,a+i));a+=i;let u=r.decode(e.slice(a,a+n));return a+=n,{join_ref:o,ref:null,topic:l,event:u,payload:e.slice(a,e.byteLength)}},decodeReply(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=r.decode(e.slice(o,o+n));o+=n;let c=r.decode(e.slice(o,o+a));return o+=a,{join_ref:l,ref:u,topic:h,event:el,payload:{status:c,response:e.slice(o,e.byteLength)}}},decodeBroadcast(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=this.HEADER_LENGTH+2,a=r.decode(e.slice(n,n+s));n+=s;let o=r.decode(e.slice(n,n+i));return n+=i,{join_ref:null,ref:null,topic:a,event:o,payload:e.slice(n,e.byteLength)}}},ew=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||ee.WebSocket||ey,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=ee&&ee.sessionStorage}catch{}this.sessionStore=t.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=eb.encode.bind(eb),this.defaultDecoder=eb.decode.bind(eb),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!==ey?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;Z&&Z.addEventListener&&(Z.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),s=this.connectClock)}),Z.addEventListener("pageshow",e=>{s===this.connectClock&&(s=null,this.connect())}),Z.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),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=Q(t.params||{}),this.endPoint=`${e}/${eh}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new ef(()=>{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}getLongPollTransport(){return ey}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=eg.appendParams(eg.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=Q(e)),(!this.conn||this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ey?this.connectWithFallback(ey,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(i=>{i.ref===t&&(this.off([s]),e(Date.now()-r))});return!0}transportName(e){return e===ey?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${ec}${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 i=!1,n=!0,a=this.transportName(e),o=t=>{this.log("transport",`falling back to ${a}...`,t),this.off([r,s]),n=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${a}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),s=this.onError(e=>{this.log("transport","error",e),n&&!i&&(clearTimeout(this.fallbackTimer),o(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(i=!0,!n){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(eo,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 ep(e,t,this);return this.channels.push(r),r}push(e){if(this.hasLogger()){let{topic:t,event:r,payload:s,ref:i,join_ref:n}=e;this.log("push",`${t} ${r} (${n}, ${i})`,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:i,join_ref:n}=e;if(i&&i===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} ${i&&"("+i+")"||""}`.trim(),s);for(let e=0;e<this.channels.length;e++){let a=this.channels[e];a.isMember(t,r,s,n)&&a.trigger(r,s,i,n)}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 e_{constructor(e,t){const r=function(e){return(null==e?void 0:e.events)&&{events:e.events}}(t);this.presence=new em(e.getChannel(),r),this.presence.onJoin((t,r,s)=>{let i=e_.onJoinPayload(t,r,s);e.getChannel().trigger("presence",i)}),this.presence.onLeave((t,r,s)=>{let i=e_.onLeavePayload(t,r,s);e.getChannel().trigger("presence",i)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return e_.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]=ev(s),t},{})}static onJoinPayload(e,t,r){return{event:"join",key:e,currentPresences:ek(t),newPresences:ev(r)}}static onLeavePayload(e,t,r){return{event:"leave",key:e,currentPresences:ek(t),leftPresences:ev(r)}}}function ev(e){return e.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function ek(e){return(null==e?void 0:e.metas)?ev(e):[]}(p=v||(v={})).SYNC="sync",p.JOIN="join",p.LEAVE="leave";class eE{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new e_(this.channel.channelAdapter,t)}}class eS{constructor(e,t,r){const s=function(e){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},e.config)}}(r);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===B}isJoined(){return this.state===B}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}}(g=k||(k={})).ALL="*",g.INSERT="INSERT",g.UPDATE="UPDATE",g.DELETE="DELETE",(y=E||(E={})).BROADCAST="broadcast",y.PRESENCE="presence",y.POSTGRES_CHANGES="postgres_changes",y.SYSTEM="system",(m=S||(S={})).SUBSCRIBED="SUBSCRIBED",m.TIMED_OUT="TIMED_OUT",m.CLOSED="CLOSED",m.CHANNEL_ERROR="CHANNEL_ERROR";class eT{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,i;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 eS(this.socket.socketAdapter,e,this.params),this.presence=new eE(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=X(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null==(i=null==(s=this.params.config)?void 0:s.broadcast)?void 0:i.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,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:n,presence:a,private:o}}=this.params,l=null!=(s=null==(r=this.bindings.postgres_changes)?void 0:r.map(e=>e.filter))?s:[],u=!!this.bindings[E.PRESENCE]&&this.bindings[E.PRESENCE].length>0||(null==(i=this.params.config.presence)?void 0:i.enabled)===!0,h={},c={broadcast:n,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:l,private:o};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(S.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(S.CLOSED)),this.updateJoinPayload(Object.assign({config:c},h)),this._updateFilterMessage(),this.channelAdapter.subscribe(t).receive("ok",async({postgres_changes:t})=>{if(this.socket._isManualToken()||this.socket.setAuth(),void 0===t){null==e||e(S.SUBSCRIBED);return}this._updatePostgresBindings(t,e)}).receive("error",t=>{this.state=D;let r=Object.values(t).join(", ")||"error";null==e||e(S.CHANNEL_ERROR,Error(r,{cause:t}))}).receive("timeout",()=>{null==e||e(S.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var r;let s=this.bindings.postgres_changes,i=null!=(r=null==s?void 0:s.length)?r:0,n=[];for(let r=0;r<i;r++){let i=s[r],{filter:{event:a,schema:o,table:l,filter:u}}=i,h=e&&e[r];if(h&&h.event===a&&eT.isFilterValueEqual(h.schema,o)&&eT.isFilterValueEqual(h.table,l)&&eT.isFilterValueEqual(h.filter,u))n.push(Object.assign(Object.assign({},i),{id:h.id}));else{this.unsubscribe(),this.state=D,null==t||t(S.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=n,this.state!=D&&t&&t(S.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){let s=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),i=e===E.PRESENCE||e===E.POSTGRES_CHANGES;if(s&&i)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 i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);let n={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,n,null!=(s=r.timeout)?s:this.timeout);if(202===a.status)return{success:!0};let o=a.statusText;try{let e=await a.json();o=e.error||e.message||o}catch(e){}return Promise.reject(Error(o))}async send(e,t={}){var r,s;if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,i,n;let a=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(n=null==(i=null==(s=this.params)?void 0:s.config)?void 0:i.broadcast)?void 0:n.ack)||r("ok"),a.receive("ok",()=>r("ok")),a.receive("error",()=>r("error")),a.receive("timeout",()=>r("timed out"))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");let{event:i,payload:n}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);let o={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:n,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,o,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,i=setTimeout(()=>s.abort(),r),n=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(i),n}_on(e,t,r){let s=e.toLocaleLowerCase(),i=this.channelAdapter.on(e,r),n={type:s,filter:t,callback:r,ref:i};return this.bindings[s]?this.bindings[s].push(n):this.bindings[s]=[n],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,r)=>{var s,i,n,a,o,l,u;let h=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(h,r))return!1;let c=null==(s=this.bindings[h])?void 0:s.find(t=>t.ref===e.ref);if(!c)return!0;if(!["broadcast","presence","postgres_changes"].includes(h))return c.type.toLocaleLowerCase()===h;if("id"in c){let e=c.id,r=null==(i=c.filter)?void 0:i.event;return e&&(null==(n=t.ids)?void 0:n.includes(e))&&("*"===r||(null==r?void 0:r.toLocaleLowerCase())===(null==(a=t.data)?void 0:a.type.toLocaleLowerCase()))}{let e=null==(l=null==(o=null==c?void 0:c.filter)?void 0:o.event)?void 0:l.toLocaleLowerCase();return"*"===e||e===(null==(u=null==t?void 0:t.event)?void 0:u.toLocaleLowerCase())}})}_notThisChannelEvent(e,t){let{close:r,error:s,leave:i,join:n}=M;return t&&[r,s,i,n].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:i,type:n,errors:a}=e;return Object.assign(Object.assign({},{schema:r,table:s,commit_timestamp:i,eventType:n,new:{},old:{},errors:a}),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)}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=K(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=K(e.columns,e.old_record)),t}}class eA{constructor(e,t){this.socket=new ew(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(i=>{setTimeout(()=>i("timeout"),s),this.socket.disconnect(()=>{e(),i("ok")},t,r)})}push(e){this.socket.push(e)}log(e,t,r){this.socket.log(e,t,r)}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 eR=[1e3,2e3,5e3,1e4],eO=`
|
|
7
7
|
addEventListener("message", (e) => {
|
|
8
8
|
if (e.data.event === "start") {
|
|
9
9
|
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
@@ -21,7 +21,7 @@ Option 2: Install and provide the "ws" package:
|
|
|
21
21
|
const client = new RealtimeClient(url, {
|
|
22
22
|
...options,
|
|
23
23
|
transport: ws
|
|
24
|
-
})`);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)}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 eT(`realtime:${e}`,t,this);return this._cancelPendingDisconnect(),this.channels.push(r),r}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{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=null){let t,r=!1;if(e)t=e,r=!0;else if(this.accessToken)try{t=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),t=this.accessTokenValue}else t=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{let r={access_token:t,version:"realtime-js/2.106.0"};t&&e.updateJoinPayload(r),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(M.access_token,{access_token:t})}))}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)=>{"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([eO],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,r,s,n,i,a,o,l,u,h,c,d;let f,p;this.worker=null!=(t=null==e?void 0:e.worker)&&t,this.accessToken=null!=(r=null==e?void 0:e.accessToken)?r:null;let g={};g.timeout=null!=(s=null==e?void 0:e.timeout)?s:1e4,g.heartbeatIntervalMs=null!=(n=null==e?void 0:e.heartbeatIntervalMs)?n:25e3,this._disconnectOnEmptyChannelsAfterMs=null!=(i=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)?i:2*(null!=(a=null==e?void 0:e.heartbeatIntervalMs)?a:25e3),g.transport=null!=(o=null==e?void 0:e.transport)?o:U.getWebSocketConstructor(),g.params=null==e?void 0:e.params,g.logger=null==e?void 0:e.logger,g.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),g.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))}}}(),g.reconnectAfterMs=null!=(u=null==e?void 0:e.reconnectAfterMs)?u:e=>eR[e-1]||1e4;let y=null!=(h=null==e?void 0:e.vsn)?h:L;switch(y){case"1.0.0":f=(e,t)=>t(JSON.stringify(e)),p=(e,t)=>t(JSON.parse(e));break;case L:f=this.serializer.encode.bind(this.serializer),p=this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${g.vsn}`)}if(g.vsn=y,g.encode=null!=(c=null==e?void 0:e.encode)?c:f,g.decode=null!=(d=null==e?void 0:e.decode)?d:p,g.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,g.params=Object.assign(Object.assign({},g.params),{log_level:this.logLevel})),this.worker){if("u">typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl,g.autoSendHeartbeat=!this.worker}return g}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var eP=e.i(66252),eI=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 ej(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 e$(e){return e.join("\x1f")}var ex=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:e$(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/${e$(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${e$(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${e$(e.namespace)}`}),!0}catch(e){if(e instanceof eI&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof eI&&409===e.status)return;throw e}}};function eN(e){return e.join("\x1f")}var eU=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/${eN(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/${eN(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/${eN(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/${eN(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/${eN(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/${eN(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof eI&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof eI&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}},eL=class{constructor(e){let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);const r=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=function(e){let t=e.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:n,body:i,headers:a}){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()}(e.baseUrl,s,n),l=await ej(e.auth),u=await t(o,{method:r,headers:{...i?{"Content-Type":"application/json"}:{},...l,...a},body:i?JSON.stringify(i):void 0}),h=await u.text(),c=(u.headers.get("content-type")||"").includes("application/json"),d=c&&h?JSON.parse(h):h;if(!u.ok){let e=c?d:void 0,t=e?.error;throw new eI(t?.message??`Request failed with status ${u.status}`,{status:u.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:u.status,headers:u.headers,data:d}}}}({baseUrl:r,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=e.accessDelegation?.join(","),this.namespaceOps=new ex(this.client,t),this.tableOps=new eU(this.client,t,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 eD(e){return(eD="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 eB(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 eM(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?eB(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=eD(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=eD(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==eD(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)):eB(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var eq=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 eH(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}var eK=class extends eq{constructor(e,t,r,s="storage"){super(e,s,t,r),this.name="vectors"===s?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=r}toJSON(){return eM({},super.toJSON())}},eF=class extends eq{constructor(e,t,r="storage"){super(e,r),this.name="vectors"===r?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function eG(e,t,r){let s=eM({},e),n=t.toLowerCase();for(let e of Object.keys(s))e.toLowerCase()===n&&delete s[e];return s[n]=r,s}let eW=e=>{if(Array.isArray(e))return e.map(e=>eW(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,""))]=eW(r)}),t},eJ=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)},ez=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 eK(eJ(e),r,n,s))}).catch(()=>{let n=r+"";t(new eK(e.statusText||`HTTP ${r} error`,r,n,s))})}else t(new eF(eJ(e),e,s))};async function eV(e,t,r,s,n,i,a){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 eM(eM({},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 i;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=eG(r,"Content-Type",null!=(i=e)?i:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return(null==t?void 0:t.duplex)&&(n.duplex=t.duplex),eM(eM({},n),r)})(t,s,n,i)).then(e=>{if(!e.ok)throw e;if(null==s?void 0:s.noResolveJson)return e;if("vectors"===a){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=>ez(e,l,s,a))})}function eY(e="storage"){return{get:async(t,r,s,n)=>eV(t,"GET",r,s,n,void 0,e),post:async(t,r,s,n,i)=>eV(t,"POST",r,n,i,s,e),put:async(t,r,s,n,i)=>eV(t,"PUT",r,n,i,s,e),head:async(t,r,s,n)=>eV(t,"HEAD",r,eM(eM({},s),{},{noResolveJson:!0}),n,void 0,e),remove:async(t,r,s,n,i)=>eV(t,"DELETE",r,n,i,s,e)}}let{get:eX,post:eQ,put:eZ,head:e0,remove:e1}=eY("storage"),e2=eY("vectors");var e8=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=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=eG(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(eH(e))return{data:null,error:e};throw e}}};t=Symbol.toStringTag;var e5=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(eH(e))return{data:null,error:e};throw e}}};r=Symbol.toStringTag;var e6=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[r]="BlobDownloadBuilder",this.promise=null}asStream(){return new e5(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(eH(e))return{data:null,error:e};throw e}}};let e3={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},e4={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var e9=class extends e8{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 i,a=eM(eM({},e4),s),o=eM(eM({},n.headers),"POST"===e&&{"x-upsert":String(a.upsert)}),l=a.metadata;if("u">typeof Blob&&r instanceof Blob?((i=new FormData).append("cacheControl",a.cacheControl),l&&i.append("metadata",n.encodeMetadata(l)),i.append("",r)):"u">typeof FormData&&r instanceof FormData?((i=r).has("cacheControl")||i.append("cacheControl",a.cacheControl),l&&!i.has("metadata")&&i.append("metadata",n.encodeMetadata(l))):(i=r,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=n.toBase64(n.encodeMetadata(l))),("u">typeof ReadableStream&&i instanceof ReadableStream||i&&"object"==typeof i&&"pipe"in i&&"function"==typeof i.pipe)&&!a.duplex&&(a.duplex="half")),null==s?void 0:s.headers)for(let[e,t]of Object.entries(s.headers))o=eG(o,e,t);let u=n._removeEmptyFolders(t),h=n._getFinalPath(u),c=await ("PUT"==e?eZ:eQ)(n.fetch,`${n.url}/object/${h}`,i,eM({headers:o},(null==a?void 0:a.duplex)?{duplex:a.duplex}:{}));return{path:u,id:c.Id,fullPath:c.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,s){var n=this;let i=n._removeEmptyFolders(e),a=n._getFinalPath(i),o=new URL(n.url+`/object/upload/sign/${a}`);return o.searchParams.set("token",t),n.handleOperation(async()=>{let e,t=eM(eM({},e4),s),a=eM(eM({},n.headers),{"x-upsert":String(t.upsert)}),l=t.metadata;if("u">typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),l&&e.append("metadata",n.encodeMetadata(l)),e.append("",r)):"u">typeof FormData&&r instanceof FormData?((e=r).has("cacheControl")||e.append("cacheControl",t.cacheControl),l&&!e.has("metadata")&&e.append("metadata",n.encodeMetadata(l))):(e=r,a["cache-control"]=`max-age=${t.cacheControl}`,a["content-type"]=t.contentType,l&&(a["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))a=eG(a,e,t);return{path:i,fullPath:(await eZ(n.fetch,o.toString(),e,eM({headers:a},(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=eM({},r.headers);(null==t?void 0:t.upsert)&&(n["x-upsert"]="true");let i=await eQ(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),a=new URL(r.url+i.url),o=a.searchParams.get("token");if(!o)throw new eq("No token returned by API");return{signedUrl:a.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 eQ(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:s.headers}))}async copy(e,t,r){var s=this;return s.handleOperation(async()=>({path:(await eQ(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(e,t,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(e),i="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0,a=await eQ(s.fetch,`${s.url}/object/sign/${n}`,eM({expiresIn:t},i?{transform:r.transform}:{}),{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}${a.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(e,t,r){var s=this;return s.handleOperation(async()=>{let n=await eQ(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:t,paths:e},{headers:s.headers}),i=new URLSearchParams;(null==r?void 0:r.download)&&i.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&i.set("cacheNonce",String(r.cacheNonce));let a=i.toString();return n.map(e=>eM(eM({},e),{},{signedUrl:e.signedURL?encodeURI(`${s.url}${e.signedURL}${a?`&${a}`:""}`):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));let i=n.toString(),a=this._getFinalPath(e);return new e6(()=>eX(this.fetch,`${this.url}/${s}/${a}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e){var t=this;let r=t._getFinalPath(e);return t.handleOperation(async()=>eW(await eX(t.fetch,`${t.url}/object/info/${r}`,{headers:t.headers})))}async exists(e){var t;let r=this._getFinalPath(e);try{return await e0(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(eH(e)){let r=e instanceof eK?e.status:e instanceof eF?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));let n=s.toString(),i="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}/${i}/public/${r}`)+(n?`?${n}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await e1(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async list(e,t,r){var s=this;return s.handleOperation(async()=>{let n=eM(eM(eM({},e3),t),{},{prefix:e||""});return await eQ(s.fetch,`${s.url}/object/list/${s.bucketId}`,n,{headers:s.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{let s=eM({},e);return await eQ(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==eP.Buffer?eP.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 e7={"X-Client-Info":"storage-js/2.106.0"};var te=class extends e8{constructor(e,t={},r,s){const 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(/\/$/,""),eM(eM({},e7),t),r,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=t.listBucketOptionsToQueryString(e);return await eX(t.fetch,`${t.url}/bucket${r}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await eX(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var r=this;return r.handleOperation(async()=>await eQ(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},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await eZ(r.fetch,`${r.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await eQ(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await e1(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}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():""}},tt=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),t),r,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await eQ(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 eX(t.fetch,n,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await e1(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 eq("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 eL({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}}}}})}},tr=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),{},{"Content-Type":"application/json"},t),r,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await e2.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await e2.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}},ts=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),{},{"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 e2.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await e2.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 e2.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await e2.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 e2.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},tn=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),{},{"Content-Type":"application/json"},t),r,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},ti=class extends tn{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new ta(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)}},ta=class extends tr{constructor(e,t,r,s){super(e,t,s),this.vectorBucketName=r}async createIndex(e){return super.createIndex.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(e={}){return super.listIndexes.call(this,eM(eM({},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 to(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},to=class extends ts{constructor(e,t,r,s,n){super(e,t,n),this.vectorBucketName=r,this.indexName=s}async putVectors(e){return super.putVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async getVectors(e){return super.getVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async listVectors(e={}){return super.listVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async queryVectors(e){return super.queryVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async deleteVectors(e){return super.deleteVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}},tl=class extends te{constructor(e,t={},r,s){super(e,t,r,s)}from(e){return new e9(this.url,this.headers,e,this.fetch)}get vectors(){return new ti(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new tt(this.url+"/iceberg",this.headers,this.fetch)}};let tu="2.106.0",th={"X-Client-Info":`gotrue-js/${tu}`},tc="X-Supabase-Api-Version",td={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},tf=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;class tp 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 tg(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class ty extends tp{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}class tm extends tp{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class tb extends tp{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}}class tw extends tb{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function t_(e){return tg(e)&&"AuthSessionMissingError"===e.name}class tv extends tb{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class tk extends tb{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class tE extends tb{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 tS extends tb{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class tT extends tb{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 tA extends tb{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function tR(e){return tg(e)&&"AuthRetryableFetchError"===e.name}class tO extends tb{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 tC extends tb{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}let tP="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),tI=" \n\r=".split(""),tj=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<tI.length;t+=1)e[tI[t].charCodeAt(0)]=-2;for(let t=0;t<tP.length;t+=1)e[tP[t].charCodeAt(0)]=t;return e})();function t$(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(tP[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(tP[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function tx(e,t,r){let s=tj[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 tN(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=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)tx(e.charCodeAt(t),n,i);return t.join("")}function tU(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)tx(e.charCodeAt(t),r,s);return new Uint8Array(t)}function tL(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};return e.forEach(e=>t$(e,r,s)),t$(null,r,s),t.join("")}let tD=()=>"u">typeof window&&"u">typeof document,tB={tested:!1,writable:!1},tM=()=>{if(!tD())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(tB.tested)return tB.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),tB.tested=!0,tB.writable=!0}catch(e){tB.tested=!0,tB.writable=!1}return tB.writable},tq=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),tH=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},tK=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return null}},tF=async(e,t)=>{await e.removeItem(t)};class tG{constructor(){this.promise=new tG.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function tW(e){let t=e.split(".");if(3!==t.length)throw new tC("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!tf.test(t[e]))throw new tC("JWT not in base64url format");return{header:JSON.parse(tN(t[0])),payload:JSON.parse(tN(t[1])),signature:tU(t[2]),raw:{header:t[0],payload:t[1]}}}async function tJ(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function tz(e){return("0"+e.toString(16)).substr(-2)}async function tV(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 tY(e){return"u">typeof crypto&&void 0!==crypto.subtle&&"u">typeof TextEncoder?btoa(await tV(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)}async function tX(e,t,r=!1){let s=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,tz).join("")}(),n=s;r&&(n+="/recovery"),await tH(e,`${t}-code-verifier`,n);let i=await tY(s),a=s===i?"plain":"s256";return[i,a]}tG.promiseConstructor=Promise;let tQ=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,tZ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function t0(e){if(!tZ.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function t1(e){if(!e.passkey)throw Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function t2(){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 t8(e){return JSON.parse(JSON.stringify(e))}let t5=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)},t6=[502,503,504,520,521,522,523,524,530];async function t3(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 tA(t5(e),0);if(t6.includes(e.status))throw new tA(t5(e),e.status);try{r=await e.json()}catch(e){throw new tm(t5(e),e)}let n=function(e){let t=e.headers.get(tc);if(!t||!t.match(tQ))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(n&&n.getTime()>=td["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 tO(t5(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===s)throw new tw}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 tO(t5(r),e.status,r.weak_password.reasons);throw new ty(t5(r),e.status||500,s)}async function t4(e,t,r,s){var n;let i=Object.assign({},null==s?void 0:s.headers);i[tc]||(i[tc]=td["2024-01-01"].name),(null==s?void 0:s.jwt)&&(i.Authorization=`Bearer ${s.jwt}`);let a=null!=(n=null==s?void 0:s.query)?n:{};(null==s?void 0:s.redirectTo)&&(a.redirect_to=s.redirectTo);let o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await t9(e,t,r+o,{headers:i,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 t9(e,t,r,s,n,i){let a,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(i),Object.assign(Object.assign({},o),n)));try{a=await e(r,Object.assign({},l))}catch(e){throw console.error(e),new tA(t5(e),0)}if(a.ok||await t3(a),null==s?void 0:s.noResolveJson)return a;try{return await a.json()}catch(e){await t3(e)}}function t7(e){var t,r,s;let n=null;(s=e).access_token&&s.refresh_token&&s.expires_in&&(n=Object.assign({},e),e.expires_at||(n.expires_at=(r=e.expires_in,Math.round(Date.now()/1e3)+r)));return{data:{session:n,user:null!=(t=e.user)?t:null},error:null}}function re(e){let t=t7(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 rt(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function rr(e){return{data:e,error:null}}function rs(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i},user:Object.assign({},l(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function rn(e){return e}let ri=["global","local","others"];class ra{constructor({url:e="",headers:t={},fetch:r,experimental:s}){this.url=e,this.headers=t,this.fetch=tq(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=ri[0]){if(0>ri.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${ri.join(", ")}`);try{return await t4(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await t4(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=l(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 t4(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:rs,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(tg(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,n,i,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await t4(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:rn});if(u.error)throw u.error;let h=await u.json(),c=null!=(i=u.headers.get("x-total-count"))?i:0,d=null!=(o=null==(a=u.headers.get("link"))?void 0:a.split(","))?o:[];return d.length>0&&(d.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(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(tg(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){t0(e);try{return await t4(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){t0(e);try{return await t4(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){t0(e);try{return await t4(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){t0(e.userId);try{let{data:t,error:r}=await t4(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(tg(e))return{data:null,error:e};throw e}}async _deleteFactor(e){t0(e.userId),t0(e.id);try{return{data:await t4(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,s,n,i,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await t4(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:rn});if(u.error)throw u.error;let h=await u.json(),c=null!=(i=u.headers.get("x-total-count"))?i:0,d=null!=(o=null==(a=u.headers.get("link"))?void 0:a.split(","))?o:[];return d.length>0&&(d.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(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(tg(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await t4(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await t4(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await t4(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(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 t4(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(tg(e))return{data:{providers:[]},error:e};throw e}}async _createCustomProvider(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _getCustomProvider(e){try{return await t4(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _updateCustomProvider(e,t){try{return await t4(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _deleteCustomProvider(e){try{return await t4(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _adminListPasskeys(e){t1(this.experimental),t0(e.userId);try{return await t4(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _adminDeletePasskey(e){t1(this.experimental),t0(e.userId),t0(e.passkeyId);try{return await t4(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}}function ro(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}let rl={debug:!!(globalThis&&tM()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};class ru extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class rh extends ru{}async function rc(e,t,r){let s;rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let n=new globalThis.AbortController;t>0&&(s=setTimeout(()=>{n.abort(),rl.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t)),await Promise.resolve();try{return await globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async n=>{if(n){clearTimeout(s),rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,n.name);try{return await r()}finally{rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,n.name)}}if(0===t)throw rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new rh(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(rl.debug)try{let e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(e){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",e)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),clearTimeout(s),await r()})}catch(i){if(t>0&&clearTimeout(s),null!==i&&"object"==typeof i&&"name"in i&&"AbortError"===i.name&&t>0)if(n.signal.aborted)return rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn(`@supabase/gotrue-js: Lock "${e}" was not released within ${t}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},async t=>{if(!t)return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await r();rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,t.name);try{return await r()}finally{rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,t.name)}}));else throw rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",e),new rh(`Lock "${e}" was released because another request stole it`);throw i}}function rd(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}class rf 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 rp extends rf{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}let rg=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 ry(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=l(e,["challenge","user","excludeCredentials"]),i=tU(t).buffer,a=Object.assign(Object.assign({},r),{id:tU(r.id).buffer}),o=Object.assign(Object.assign({},n),{challenge:i,user:a});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:tU(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return o}function rm(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=l(e,["challenge","allowCredentials"]),n=tU(t).buffer,i=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){i.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];i.allowCredentials[e]=Object.assign(Object.assign({},t),{id:tU(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return i}function rb(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:tL(new Uint8Array(e.response.attestationObject)),clientDataJSON:tL(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function rw(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:tL(new Uint8Array(s.authenticatorData)),clientDataJSON:tL(new Uint8Array(s.clientDataJSON)),signature:tL(new Uint8Array(s.signature)),userHandle:s.userHandle?tL(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function r_(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function rv(){var e,t;return!!(tD()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"==typeof(null==(e=null==navigator?void 0:navigator.credentials)?void 0:e.create)&&"function"==typeof(null==(t=null==navigator?void 0:navigator.credentials)?void 0:t.get))}async function rk(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new rp("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new rp("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:i}=t;if(!i)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new rf({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null==(r=i.authenticatorSelection)?void 0:r.requireResidentKey)===!0)return new rf({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=i.authenticatorSelection)?void 0:s.userVerification)==="required")return new rf({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=i.authenticatorSelection)?void 0:n.userVerification)==="required")return new rf({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 rf({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new rf({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name)return new rf(0===i.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(!r_(t))return new rf({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(i.rp.id!==t)return new rf({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new rf({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 rf({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 rf({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}async function rE(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new rp("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new rp("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 rf({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new rf({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!r_(t))return new rf({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new rf({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 rf({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 rf({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}let rS={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},rT={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function rA(...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 i=n[e];if(void 0!==i)if(Array.isArray(i))s[e]=i;else if(r(i))s[e]=i;else if(t(i)){let r=s[e];t(r)?s[e]=rA(r,i):s[e]=rA(i)}else s[e]=i}return s}class rR{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 i,a,o,l,u;try{let{data:h,error:c}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!h)return{data:null,error:c};let d=null!=s?s:rg.createNewAbortSignal();if("create"===h.webauthn.type){let{user:e}=h.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==(i=null==t?void 0:t.user_metadata)?void 0:i.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(h.webauthn.type){case"create":{let t=(a=h.webauthn.credential_options.publicKey,o=null==n?void 0:n.create,rA(rS,a,o||{})),{data:r,error:s}=await rk({publicKey:t,signal:d});if(r)return{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}case"request":{let t=(l=h.webauthn.credential_options.publicKey,u=null==n?void 0:n.request,rA(rT,l,u||{})),{data:r,error:s}=await rE(Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:t,signal:d}));if(r)return{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}}}catch(e){if(tg(e))return{data:null,error:e};return{data:null,error:new tm("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="u">typeof window?window.location.hostname:void 0,rpOrigins:r="u">typeof window?[window.location.origin]:void 0,signal:s}={}},n){if(!t)return{data:null,error:new tp("rpId is required for WebAuthn authentication")};try{if(!rv())return{data:null,error:new tm("Browser does not support WebAuthn",null)};let{data:i,error:a}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:s},{request:n});if(!i)return{data:null,error:a};let{webauthn:o}=i;return this._verify({factorId:e,challengeId:i.challengeId,webauthn:{type:o.type,rpId:t,rpOrigins:r,credential_response:o.credential_response}})}catch(e){if(tg(e))return{data:null,error:e};return{data:null,error:new tm("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t="u">typeof window?window.location.hostname:void 0,rpOrigins:r="u">typeof window?[window.location.origin]:void 0,signal:s}={}},n){if(!t)return{data:null,error:new tp("rpId is required for WebAuthn registration")};try{if(!rv())return{data:null,error:new tm("Browser does not support WebAuthn",null)};let{data:i,error:a}=await this._enroll({friendlyName:e});if(!i)return await this.client.mfa.listFactors().then(t=>{var r;return null==(r=t.data)?void 0:r.all.find(t=>"webauthn"===t.factor_type&&t.friendly_name===e&&"unverified"!==t.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0),{data:null,error:a};let{data:o,error:l}=await this._challenge({factorId:i.id,friendlyName:i.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:s},{create:n});if(!o)return{data:null,error:l};return this._verify({factorId:i.id,challengeId:o.challengeId,webauthn:{rpId:t,rpOrigins:r,type:o.webauthn.type,credential_response:o.webauthn.credential_response}})}catch(e){if(tg(e))return{data:null,error:e};return{data:null,error:new tm("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 rO={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:th,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function rC(e,t,r){return await r()}let rP={};class rI{get jwks(){var e,t;return null!=(t=null==(e=rP[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){rP[this.storageKey]=Object.assign(Object.assign({},rP[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=rP[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){rP[this.storageKey]=Object.assign(Object.assign({},rP[this.storageKey]),{cachedAt:e})}constructor(e){var t,r,s,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},rO),e);if(this.storageKey=i.storageKey,this.instanceID=null!=(t=rI.nextInstanceID[this.storageKey])?t:0,rI.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,"function"==typeof i.debug&&(this.logger=i.debug),this.instanceID>0&&tD()){const e=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(e),this.logDebugMessages&&console.trace(e)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.experimental=null!=(r=i.experimental)?r:{},this.admin=new ra({url:i.url,headers:i.headers,fetch:i.fetch,experimental:this.experimental}),this.url=i.url,this.headers=i.headers,this.fetch=tq(i.fetch),this.lock=i.lock||rC,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,this.lockAcquireTimeout=i.lockAcquireTimeout,i.lock?this.lock=i.lock:this.persistSession&&tD()&&(null==(s=null==globalThis?void 0:globalThis.navigator)?void 0:s.locks)?this.lock=rc:this.lock=rC,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 rR(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?(i.storage?this.storage=i.storage:tM()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ro(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=ro(this.memoryStorage)),tD()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",e)}null==(n=this.broadcastChannel)||n.addEventListener("message",async e=>{this._debug("received broadcast notification from other tab or client",e);try{await this._notifyAllSubscribers(e.data.event,e.data.session,!1)}catch(e){this._debug("#broadcastChannel","error",e)}})}i.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} (${tu}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))()),await this.initializePromise}async _initialize(){var e;try{let t={},r="none";if(tD()&&(t=function(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEach((e,r)=>{t[r]=e})}catch(e){}return r.searchParams.forEach((e,r)=>{t[r]=e}),t}(window.location.href),this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce")),tD()&&this.detectSessionInUrl&&"none"!==r){let{data:s,error:n}=await this._getSessionFromURL(t,r);if(n){(this._debug("#_initialize()","error detecting session from URL",n),tg(n)&&"AuthImplicitGrantRedirectError"===n.name)&&(null==(e=n.details)||e.code);return{error:n}}let{session:i,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",i,"redirect type",a),await this._saveSession(i),setTimeout(async()=>{"recovery"===a?await this._notifyAllSubscribers("PASSWORD_RECOVERY",i):await this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){if(tg(e))return this._returnResult({error:e});return this._returnResult({error:new tm("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:i}=await t4(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:t7});if(i||!n)return this._returnResult({data:{user:null,session:null},error:i});let a=n.session,o=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",a)),this._returnResult({data:{user:o,session:a},error:null})}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,r,s;try{let n;if("email"in e){let{email:r,password:s,options:i}=e,a=null,o=null;"pkce"===this.flowType&&([a,o]=await tX(this.storage,this.storageKey)),n=await t4(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==i?void 0:i.emailRedirectTo,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:a,code_challenge_method:o},xform:t7})}else if("phone"in e){let{phone:t,password:i,options:a}=e;n=await t4(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:i,data:null!=(r=null==a?void 0:a.data)?r:{},channel:null!=(s=null==a?void 0:a.channel)?s:"sms",gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:t7})}else throw new tk("You must provide either an email or phone number and a password");let{data:i,error:a}=n;if(a||!i)return await tF(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});let o=i.session,l=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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 t4(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:re})}else if("phone"in e){let{phone:r,password:s,options:n}=e;t=await t4(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:re})}else throw new tk("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 tv;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(tg(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){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}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,i,a,o,l,u,h,c,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{let h,{chain:c,wallet:g,statement:y,options:m}=e;if(tD())if("object"==typeof g)h=g;else{let e=window;if("ethereum"in e&&"object"==typeof e.ethereum&&"request"in e.ethereum&&"function"==typeof e.ethereum.request)h=e.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if("object"!=typeof g||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");h=g}let b=new URL(null!=(t=null==m?void 0:m.url)?t:window.location.href),w=await h.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!w||0===w.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let _=rd(w[0]),v=null==(r=null==m?void 0:m.signInWithEthereum)?void 0:r.chainId;v||(v=parseInt(await h.request({method:"eth_chainId"}),16)),f=function(e){var t;let{chainId:r,domain:s,expirationTime:n,issuedAt:i=new Date,nonce:a,notBefore:o,requestId:l,resources:u,scheme:h,uri:c,version:d}=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(a&&a.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!c)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==d)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);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 f=rd(e.address),p=h?`${h}://${s}`:s,g=e.statement?`${e.statement}
|
|
24
|
+
})`);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)}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 eT(`realtime:${e}`,t,this);return this._cancelPendingDisconnect(),this.channels.push(r),r}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{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=null){let t,r=!1;if(e)t=e,r=!0;else if(this.accessToken)try{t=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),t=this.accessTokenValue}else t=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{let r={access_token:t,version:"realtime-js/2.106.0"};t&&e.updateJoinPayload(r),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(M.access_token,{access_token:t})}))}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)=>{"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([eO],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,r,s,i,n,a,o,l,u,h,c,d;let f,p;this.worker=null!=(t=null==e?void 0:e.worker)&&t,this.accessToken=null!=(r=null==e?void 0:e.accessToken)?r:null;let g={};g.timeout=null!=(s=null==e?void 0:e.timeout)?s:1e4,g.heartbeatIntervalMs=null!=(i=null==e?void 0:e.heartbeatIntervalMs)?i:25e3,this._disconnectOnEmptyChannelsAfterMs=null!=(n=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)?n:2*(null!=(a=null==e?void 0:e.heartbeatIntervalMs)?a:25e3),g.transport=null!=(o=null==e?void 0:e.transport)?o:U.getWebSocketConstructor(),g.params=null==e?void 0:e.params,g.logger=null==e?void 0:e.logger,g.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),g.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))}}}(),g.reconnectAfterMs=null!=(u=null==e?void 0:e.reconnectAfterMs)?u:e=>eR[e-1]||1e4;let y=null!=(h=null==e?void 0:e.vsn)?h:L;switch(y){case"1.0.0":f=(e,t)=>t(JSON.stringify(e)),p=(e,t)=>t(JSON.parse(e));break;case L:f=this.serializer.encode.bind(this.serializer),p=this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${g.vsn}`)}if(g.vsn=y,g.encode=null!=(c=null==e?void 0:e.encode)?c:f,g.decode=null!=(d=null==e?void 0:e.decode)?d:p,g.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,g.params=Object.assign(Object.assign({},g.params),{log_level:this.logLevel})),this.worker){if("u">typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl,g.autoSendHeartbeat=!this.worker}return g}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var eP=e.i(66252),eI=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 ej(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 e$(e){return e.join("\x1f")}var ex=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:e$(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/${e$(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${e$(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${e$(e.namespace)}`}),!0}catch(e){if(e instanceof eI&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof eI&&409===e.status)return;throw e}}};function eN(e){return e.join("\x1f")}var eU=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/${eN(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/${eN(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/${eN(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/${eN(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/${eN(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/${eN(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof eI&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof eI&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}},eL=class{constructor(e){let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);const r=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=function(e){let t=e.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:i,body:n,headers:a}){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()}(e.baseUrl,s,i),l=await ej(e.auth),u=await t(o,{method:r,headers:{...n?{"Content-Type":"application/json"}:{},...l,...a},body:n?JSON.stringify(n):void 0}),h=await u.text(),c=(u.headers.get("content-type")||"").includes("application/json"),d=c&&h?JSON.parse(h):h;if(!u.ok){let e=c?d:void 0,t=e?.error;throw new eI(t?.message??`Request failed with status ${u.status}`,{status:u.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:u.status,headers:u.headers,data:d}}}}({baseUrl:r,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=e.accessDelegation?.join(","),this.namespaceOps=new ex(this.client,t),this.tableOps=new eU(this.client,t,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 eD(e){return(eD="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 eB(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 eM(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?eB(Object(r),!0).forEach(function(t){!function(e,t,r){var s;(s=function(e,t){if("object"!=eD(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=eD(s))return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==eD(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)):eB(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var eq=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 eK(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}var eH=class extends eq{constructor(e,t,r,s="storage"){super(e,s,t,r),this.name="vectors"===s?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=r}toJSON(){return eM({},super.toJSON())}},eF=class extends eq{constructor(e,t,r="storage"){super(e,r),this.name="vectors"===r?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function eG(e,t,r){let s=eM({},e),i=t.toLowerCase();for(let e of Object.keys(s))e.toLowerCase()===i&&delete s[e];return s[i]=r,s}let eW=e=>{if(Array.isArray(e))return e.map(e=>eW(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,""))]=eW(r)}),t},eJ=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)},ez=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 i=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";t(new eH(eJ(e),r,i,s))}).catch(()=>{let i=r+"";t(new eH(e.statusText||`HTTP ${r} error`,r,i,s))})}else t(new eF(eJ(e),e,s))};async function eV(e,t,r,s,i,n,a){return new Promise((o,l)=>{e(r,((e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!s)return eM(eM({},i),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 n;let e,r=(null==t?void 0:t.headers)||{};for(let[t,s]of Object.entries(r))"content-type"===t.toLowerCase()&&(e=s);i.headers=eG(r,"Content-Type",null!=(n=e)?n:"application/json"),i.body=JSON.stringify(s)}else i.body=s;return(null==t?void 0:t.duplex)&&(i.duplex=t.duplex),eM(eM({},i),r)})(t,s,i,n)).then(e=>{if(!e.ok)throw e;if(null==s?void 0:s.noResolveJson)return e;if("vectors"===a){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=>ez(e,l,s,a))})}function eY(e="storage"){return{get:async(t,r,s,i)=>eV(t,"GET",r,s,i,void 0,e),post:async(t,r,s,i,n)=>eV(t,"POST",r,i,n,s,e),put:async(t,r,s,i,n)=>eV(t,"PUT",r,i,n,s,e),head:async(t,r,s,i)=>eV(t,"HEAD",r,eM(eM({},s),{},{noResolveJson:!0}),i,void 0,e),remove:async(t,r,s,i,n)=>eV(t,"DELETE",r,i,n,s,e)}}let{get:eX,post:eQ,put:eZ,head:e0,remove:e1}=eY("storage"),e2=eY("vectors");var e8=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=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=eG(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(eK(e))return{data:null,error:e};throw e}}};t=Symbol.toStringTag;var e5=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(eK(e))return{data:null,error:e};throw e}}};r=Symbol.toStringTag;var e6=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[r]="BlobDownloadBuilder",this.promise=null}asStream(){return new e5(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(eK(e))return{data:null,error:e};throw e}}};let e3={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},e4={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var e9=class extends e8{constructor(e,t={},r,s){super(e,t,s,"storage"),this.bucketId=r}async uploadOrUpdate(e,t,r,s){var i=this;return i.handleOperation(async()=>{let n,a=eM(eM({},e4),s),o=eM(eM({},i.headers),"POST"===e&&{"x-upsert":String(a.upsert)}),l=a.metadata;if("u">typeof Blob&&r instanceof Blob?((n=new FormData).append("cacheControl",a.cacheControl),l&&n.append("metadata",i.encodeMetadata(l)),n.append("",r)):"u">typeof FormData&&r instanceof FormData?((n=r).has("cacheControl")||n.append("cacheControl",a.cacheControl),l&&!n.has("metadata")&&n.append("metadata",i.encodeMetadata(l))):(n=r,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=i.toBase64(i.encodeMetadata(l))),("u">typeof ReadableStream&&n instanceof ReadableStream||n&&"object"==typeof n&&"pipe"in n&&"function"==typeof n.pipe)&&!a.duplex&&(a.duplex="half")),null==s?void 0:s.headers)for(let[e,t]of Object.entries(s.headers))o=eG(o,e,t);let u=i._removeEmptyFolders(t),h=i._getFinalPath(u),c=await ("PUT"==e?eZ:eQ)(i.fetch,`${i.url}/object/${h}`,n,eM({headers:o},(null==a?void 0:a.duplex)?{duplex:a.duplex}:{}));return{path:u,id:c.Id,fullPath:c.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,s){var i=this;let n=i._removeEmptyFolders(e),a=i._getFinalPath(n),o=new URL(i.url+`/object/upload/sign/${a}`);return o.searchParams.set("token",t),i.handleOperation(async()=>{let e,t=eM(eM({},e4),s),a=eM(eM({},i.headers),{"x-upsert":String(t.upsert)}),l=t.metadata;if("u">typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),l&&e.append("metadata",i.encodeMetadata(l)),e.append("",r)):"u">typeof FormData&&r instanceof FormData?((e=r).has("cacheControl")||e.append("cacheControl",t.cacheControl),l&&!e.has("metadata")&&e.append("metadata",i.encodeMetadata(l))):(e=r,a["cache-control"]=`max-age=${t.cacheControl}`,a["content-type"]=t.contentType,l&&(a["x-metadata"]=i.toBase64(i.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))a=eG(a,e,t);return{path:n,fullPath:(await eZ(i.fetch,o.toString(),e,eM({headers:a},(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),i=eM({},r.headers);(null==t?void 0:t.upsert)&&(i["x-upsert"]="true");let n=await eQ(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:i}),a=new URL(r.url+n.url),o=a.searchParams.get("token");if(!o)throw new eq("No token returned by API");return{signedUrl:a.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 eQ(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:s.headers}))}async copy(e,t,r){var s=this;return s.handleOperation(async()=>({path:(await eQ(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(e,t,r){var s=this;return s.handleOperation(async()=>{let i=s._getFinalPath(e),n="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0,a=await eQ(s.fetch,`${s.url}/object/sign/${i}`,eM({expiresIn:t},n?{transform:r.transform}:{}),{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}${a.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(e,t,r){var s=this;return s.handleOperation(async()=>{let i=await eQ(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:t,paths:e},{headers:s.headers}),n=new URLSearchParams;(null==r?void 0:r.download)&&n.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&n.set("cacheNonce",String(r.cacheNonce));let a=n.toString();return i.map(e=>eM(eM({},e),{},{signedUrl:e.signedURL?encodeURI(`${s.url}${e.signedURL}${a?`&${a}`:""}`):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",i=new URLSearchParams;(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(i,t.transform),(null==t?void 0:t.cacheNonce)!=null&&i.set("cacheNonce",String(t.cacheNonce));let n=i.toString(),a=this._getFinalPath(e);return new e6(()=>eX(this.fetch,`${this.url}/${s}/${a}${n?`?${n}`:""}`,{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e){var t=this;let r=t._getFinalPath(e);return t.handleOperation(async()=>eW(await eX(t.fetch,`${t.url}/object/info/${r}`,{headers:t.headers})))}async exists(e){var t;let r=this._getFinalPath(e);try{return await e0(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(eK(e)){let r=e instanceof eH?e.status:e instanceof eF?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));let i=s.toString(),n="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}/${n}/public/${r}`)+(i?`?${i}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await e1(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async list(e,t,r){var s=this;return s.handleOperation(async()=>{let i=eM(eM(eM({},e3),t),{},{prefix:e||""});return await eQ(s.fetch,`${s.url}/object/list/${s.bucketId}`,i,{headers:s.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{let s=eM({},e);return await eQ(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==eP.Buffer?eP.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 e7={"X-Client-Info":"storage-js/2.106.0"};var te=class extends e8{constructor(e,t={},r,s){const i=new URL(e);(null==s?void 0:s.useNewHostname)&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),super(i.href.replace(/\/$/,""),eM(eM({},e7),t),r,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=t.listBucketOptionsToQueryString(e);return await eX(t.fetch,`${t.url}/bucket${r}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await eX(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var r=this;return r.handleOperation(async()=>await eQ(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},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await eZ(r.fetch,`${r.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await eQ(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await e1(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}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():""}},tt=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),t),r,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await eQ(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(),i=s?`${t.url}/bucket?${s}`:`${t.url}/bucket`;return await eX(t.fetch,i,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await e1(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 eq("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 eL({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}}}}})}},tr=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),{},{"Content-Type":"application/json"},t),r,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await e2.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await e2.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}},ts=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),{},{"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 e2.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await e2.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 e2.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await e2.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 e2.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},ti=class extends e8{constructor(e,t={},r){super(e.replace(/\/$/,""),eM(eM({},e7),{},{"Content-Type":"application/json"},t),r,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await e2.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},tn=class extends ti{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new ta(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)}},ta=class extends tr{constructor(e,t,r,s){super(e,t,s),this.vectorBucketName=r}async createIndex(e){return super.createIndex.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(e={}){return super.listIndexes.call(this,eM(eM({},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 to(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},to=class extends ts{constructor(e,t,r,s,i){super(e,t,i),this.vectorBucketName=r,this.indexName=s}async putVectors(e){return super.putVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async getVectors(e){return super.getVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async listVectors(e={}){return super.listVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async queryVectors(e){return super.queryVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async deleteVectors(e){return super.deleteVectors.call(this,eM(eM({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}},tl=class extends te{constructor(e,t={},r,s){super(e,t,r,s)}from(e){return new e9(this.url,this.headers,e,this.fetch)}get vectors(){return new tn(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new tt(this.url+"/iceberg",this.headers,this.fetch)}};let tu="2.106.0",th={"X-Client-Info":`gotrue-js/${tu}`},tc="X-Supabase-Api-Version",td={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},tf=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;class tp 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 tg(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class ty extends tp{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}class tm extends tp{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class tb extends tp{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}}class tw extends tb{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function t_(e){return tg(e)&&"AuthSessionMissingError"===e.name}class tv extends tb{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class tk extends tb{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class tE extends tb{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 tS extends tb{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class tT extends tb{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 tA extends tb{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function tR(e){return tg(e)&&"AuthRetryableFetchError"===e.name}class tO extends tb{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 tC extends tb{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}let tP="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),tI=" \n\r=".split(""),tj=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<tI.length;t+=1)e[tI[t].charCodeAt(0)]=-2;for(let t=0;t<tP.length;t+=1)e[tP[t].charCodeAt(0)]=t;return e})();function t$(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(tP[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(tP[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function tx(e,t,r){let s=tj[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 tN(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},n=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)tx(e.charCodeAt(t),i,n);return t.join("")}function tU(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)tx(e.charCodeAt(t),r,s);return new Uint8Array(t)}function tL(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};return e.forEach(e=>t$(e,r,s)),t$(null,r,s),t.join("")}let tD=()=>"u">typeof window&&"u">typeof document,tB={tested:!1,writable:!1},tM=()=>{if(!tD())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(tB.tested)return tB.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),tB.tested=!0,tB.writable=!0}catch(e){tB.tested=!0,tB.writable=!1}return tB.writable},tq=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),tK=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},tH=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return null}},tF=async(e,t)=>{await e.removeItem(t)};class tG{constructor(){this.promise=new tG.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function tW(e){let t=e.split(".");if(3!==t.length)throw new tC("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!tf.test(t[e]))throw new tC("JWT not in base64url format");return{header:JSON.parse(tN(t[0])),payload:JSON.parse(tN(t[1])),signature:tU(t[2]),raw:{header:t[0],payload:t[1]}}}async function tJ(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function tz(e){return("0"+e.toString(16)).substr(-2)}async function tV(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 tY(e){return"u">typeof crypto&&void 0!==crypto.subtle&&"u">typeof TextEncoder?btoa(await tV(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)}async function tX(e,t,r=!1){let s=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,tz).join("")}(),i=s;r&&(i+="/recovery"),await tK(e,`${t}-code-verifier`,i);let n=await tY(s),a=s===n?"plain":"s256";return[n,a]}tG.promiseConstructor=Promise;let tQ=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,tZ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function t0(e){if(!tZ.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function t1(e){if(!e.passkey)throw Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function t2(){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 t8(e){return JSON.parse(JSON.stringify(e))}let t5=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)},t6=[502,503,504,520,521,522,523,524,530];async function t3(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 tA(t5(e),0);if(t6.includes(e.status))throw new tA(t5(e),e.status);try{r=await e.json()}catch(e){throw new tm(t5(e),e)}let i=function(e){let t=e.headers.get(tc);if(!t||!t.match(tQ))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(i&&i.getTime()>=td["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 tO(t5(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===s)throw new tw}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 tO(t5(r),e.status,r.weak_password.reasons);throw new ty(t5(r),e.status||500,s)}async function t4(e,t,r,s){var i;let n=Object.assign({},null==s?void 0:s.headers);n[tc]||(n[tc]=td["2024-01-01"].name),(null==s?void 0:s.jwt)&&(n.Authorization=`Bearer ${s.jwt}`);let a=null!=(i=null==s?void 0:s.query)?i:{};(null==s?void 0:s.redirectTo)&&(a.redirect_to=s.redirectTo);let o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await t9(e,t,r+o,{headers:n,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 t9(e,t,r,s,i,n){let a,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(n),Object.assign(Object.assign({},o),i)));try{a=await e(r,Object.assign({},l))}catch(e){throw console.error(e),new tA(t5(e),0)}if(a.ok||await t3(a),null==s?void 0:s.noResolveJson)return a;try{return await a.json()}catch(e){await t3(e)}}function t7(e){var t,r,s;let i=null;(s=e).access_token&&s.refresh_token&&s.expires_in&&(i=Object.assign({},e),e.expires_at||(i.expires_at=(r=e.expires_in,Math.round(Date.now()/1e3)+r)));return{data:{session:i,user:null!=(t=e.user)?t:null},error:null}}function re(e){let t=t7(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 rt(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function rr(e){return{data:e,error:null}}function rs(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:n}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:n},user:Object.assign({},l(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function ri(e){return e}let rn=["global","local","others"];class ra{constructor({url:e="",headers:t={},fetch:r,experimental:s}){this.url=e,this.headers=t,this.fetch=tq(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=rn[0]){if(0>rn.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${rn.join(", ")}`);try{return await t4(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await t4(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=l(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 t4(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:rs,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(tg(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,i,n,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await t4(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!=(i=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?i:""},xform:ri});if(u.error)throw u.error;let h=await u.json(),c=null!=(n=u.headers.get("x-total-count"))?n:0,d=null!=(o=null==(a=u.headers.get("link"))?void 0:a.split(","))?o:[];return d.length>0&&(d.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(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(tg(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){t0(e);try{return await t4(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){t0(e);try{return await t4(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){t0(e);try{return await t4(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:rt})}catch(e){if(tg(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){t0(e.userId);try{let{data:t,error:r}=await t4(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(tg(e))return{data:null,error:e};throw e}}async _deleteFactor(e){t0(e.userId),t0(e.id);try{return{data:await t4(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,s,i,n,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await t4(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!=(i=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?i:""},xform:ri});if(u.error)throw u.error;let h=await u.json(),c=null!=(n=u.headers.get("x-total-count"))?n:0,d=null!=(o=null==(a=u.headers.get("link"))?void 0:a.split(","))?o:[];return d.length>0&&(d.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(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(tg(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await t4(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await t4(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await t4(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(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 t4(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(tg(e))return{data:{providers:[]},error:e};throw e}}async _createCustomProvider(e){try{return await t4(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _getCustomProvider(e){try{return await t4(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _updateCustomProvider(e,t){try{return await t4(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _deleteCustomProvider(e){try{return await t4(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _adminListPasskeys(e){t1(this.experimental),t0(e.userId);try{return await t4(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(tg(e))return{data:null,error:e};throw e}}async _adminDeletePasskey(e){t1(this.experimental),t0(e.userId),t0(e.passkeyId);try{return await t4(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(tg(e))return{data:null,error:e};throw e}}}function ro(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}let rl={debug:!!(globalThis&&tM()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};class ru extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class rh extends ru{}async function rc(e,t,r){let s;rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let i=new globalThis.AbortController;t>0&&(s=setTimeout(()=>{i.abort(),rl.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t)),await Promise.resolve();try{return await globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:i.signal},async i=>{if(i){clearTimeout(s),rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,i.name);try{return await r()}finally{rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,i.name)}}if(0===t)throw rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new rh(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(rl.debug)try{let e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(e){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",e)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),clearTimeout(s),await r()})}catch(n){if(t>0&&clearTimeout(s),null!==n&&"object"==typeof n&&"name"in n&&"AbortError"===n.name&&t>0)if(i.signal.aborted)return rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn(`@supabase/gotrue-js: Lock "${e}" was not released within ${t}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},async t=>{if(!t)return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await r();rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,t.name);try{return await r()}finally{rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,t.name)}}));else throw rl.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",e),new rh(`Lock "${e}" was released because another request stole it`);throw n}}function rd(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}class rf extends Error{constructor({message:e,code:t,cause:r,name:s}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!=(i=null!=s?s:r instanceof Error?r.name:void 0)?i:"Unknown Error",this.code=t}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class rp extends rf{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}let rg=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 ry(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,i=l(e,["challenge","user","excludeCredentials"]),n=tU(t).buffer,a=Object.assign(Object.assign({},r),{id:tU(r.id).buffer}),o=Object.assign(Object.assign({},i),{challenge:n,user:a});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:tU(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return o}function rm(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=l(e,["challenge","allowCredentials"]),i=tU(t).buffer,n=Object.assign(Object.assign({},s),{challenge:i});if(r&&r.length>0){n.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];n.allowCredentials[e]=Object.assign(Object.assign({},t),{id:tU(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return n}function rb(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:tL(new Uint8Array(e.response.attestationObject)),clientDataJSON:tL(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function rw(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:tL(new Uint8Array(s.authenticatorData)),clientDataJSON:tL(new Uint8Array(s.clientDataJSON)),signature:tL(new Uint8Array(s.signature)),userHandle:s.userHandle?tL(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function r_(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function rv(){var e,t;return!!(tD()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"==typeof(null==(e=null==navigator?void 0:navigator.credentials)?void 0:e.create)&&"function"==typeof(null==(t=null==navigator?void 0:navigator.credentials)?void 0:t.get))}async function rk(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new rp("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new rp("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,i;let{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new rf({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null==(r=n.authenticatorSelection)?void 0:r.requireResidentKey)===!0)return new rf({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=n.authenticatorSelection)?void 0:s.userVerification)==="required")return new rf({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==(i=n.authenticatorSelection)?void 0:i.userVerification)==="required")return new rf({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 rf({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new rf({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name)return new rf(0===n.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(!r_(t))return new rf({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new rf({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new rf({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 rf({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 rf({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}async function rE(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new rp("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new rp("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 rf({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new rf({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!r_(t))return new rf({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new rf({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 rf({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 rf({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}let rS={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},rT={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function rA(...e){let t=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),s={};for(let i of e)if(i)for(let e in i){let n=i[e];if(void 0!==n)if(Array.isArray(n))s[e]=n;else if(r(n))s[e]=n;else if(t(n)){let r=s[e];t(r)?s[e]=rA(r,n):s[e]=rA(n)}else s[e]=n}return s}class rR{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},i){var n,a,o,l,u;try{let{data:h,error:c}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!h)return{data:null,error:c};let d=null!=s?s:rg.createNewAbortSignal();if("create"===h.webauthn.type){let{user:e}=h.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==(n=null==t?void 0:t.user_metadata)?void 0:n.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(h.webauthn.type){case"create":{let t=(a=h.webauthn.credential_options.publicKey,o=null==i?void 0:i.create,rA(rS,a,o||{})),{data:r,error:s}=await rk({publicKey:t,signal:d});if(r)return{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}case"request":{let t=(l=h.webauthn.credential_options.publicKey,u=null==i?void 0:i.request,rA(rT,l,u||{})),{data:r,error:s}=await rE(Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:t,signal:d}));if(r)return{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}}}catch(e){if(tg(e))return{data:null,error:e};return{data:null,error:new tm("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="u">typeof window?window.location.hostname:void 0,rpOrigins:r="u">typeof window?[window.location.origin]:void 0,signal:s}={}},i){if(!t)return{data:null,error:new tp("rpId is required for WebAuthn authentication")};try{if(!rv())return{data:null,error:new tm("Browser does not support WebAuthn",null)};let{data:n,error:a}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:s},{request:i});if(!n)return{data:null,error:a};let{webauthn:o}=n;return this._verify({factorId:e,challengeId:n.challengeId,webauthn:{type:o.type,rpId:t,rpOrigins:r,credential_response:o.credential_response}})}catch(e){if(tg(e))return{data:null,error:e};return{data:null,error:new tm("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t="u">typeof window?window.location.hostname:void 0,rpOrigins:r="u">typeof window?[window.location.origin]:void 0,signal:s}={}},i){if(!t)return{data:null,error:new tp("rpId is required for WebAuthn registration")};try{if(!rv())return{data:null,error:new tm("Browser does not support WebAuthn",null)};let{data:n,error:a}=await this._enroll({friendlyName:e});if(!n)return await this.client.mfa.listFactors().then(t=>{var r;return null==(r=t.data)?void 0:r.all.find(t=>"webauthn"===t.factor_type&&t.friendly_name===e&&"unverified"!==t.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0),{data:null,error:a};let{data:o,error:l}=await this._challenge({factorId:n.id,friendlyName:n.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:s},{create:i});if(!o)return{data:null,error:l};return this._verify({factorId:n.id,challengeId:o.challengeId,webauthn:{rpId:t,rpOrigins:r,type:o.webauthn.type,credential_response:o.webauthn.credential_response}})}catch(e){if(tg(e))return{data:null,error:e};return{data:null,error:new tm("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 rO={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:th,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function rC(e,t,r){return await r()}let rP={};class rI{get jwks(){var e,t;return null!=(t=null==(e=rP[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){rP[this.storageKey]=Object.assign(Object.assign({},rP[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=rP[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){rP[this.storageKey]=Object.assign(Object.assign({},rP[this.storageKey]),{cachedAt:e})}constructor(e){var t,r,s,i;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const n=Object.assign(Object.assign({},rO),e);if(this.storageKey=n.storageKey,this.instanceID=null!=(t=rI.nextInstanceID[this.storageKey])?t:0,rI.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!n.debug,"function"==typeof n.debug&&(this.logger=n.debug),this.instanceID>0&&tD()){const e=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(e),this.logDebugMessages&&console.trace(e)}if(this.persistSession=n.persistSession,this.autoRefreshToken=n.autoRefreshToken,this.experimental=null!=(r=n.experimental)?r:{},this.admin=new ra({url:n.url,headers:n.headers,fetch:n.fetch,experimental:this.experimental}),this.url=n.url,this.headers=n.headers,this.fetch=tq(n.fetch),this.lock=n.lock||rC,this.detectSessionInUrl=n.detectSessionInUrl,this.flowType=n.flowType,this.hasCustomAuthorizationHeader=n.hasCustomAuthorizationHeader,this.throwOnError=n.throwOnError,this.lockAcquireTimeout=n.lockAcquireTimeout,n.lock?this.lock=n.lock:this.persistSession&&tD()&&(null==(s=null==globalThis?void 0:globalThis.navigator)?void 0:s.locks)?this.lock=rc:this.lock=rC,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 rR(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?(n.storage?this.storage=n.storage:tM()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ro(this.memoryStorage)),n.userStorage&&(this.userStorage=n.userStorage)):(this.memoryStorage={},this.storage=ro(this.memoryStorage)),tD()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",e)}null==(i=this.broadcastChannel)||i.addEventListener("message",async e=>{this._debug("received broadcast notification from other tab or client",e);try{await this._notifyAllSubscribers(e.data.event,e.data.session,!1)}catch(e){this._debug("#broadcastChannel","error",e)}})}n.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} (${tu}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))()),await this.initializePromise}async _initialize(){var e;try{let t={},r="none";if(tD()&&(t=function(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEach((e,r)=>{t[r]=e})}catch(e){}return r.searchParams.forEach((e,r)=>{t[r]=e}),t}(window.location.href),this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce")),tD()&&this.detectSessionInUrl&&"none"!==r){let{data:s,error:i}=await this._getSessionFromURL(t,r);if(i){(this._debug("#_initialize()","error detecting session from URL",i),tg(i)&&"AuthImplicitGrantRedirectError"===i.name)&&(null==(e=i.details)||e.code);return{error:i}}let{session:n,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",n,"redirect type",a),await this._saveSession(n),setTimeout(async()=>{"recovery"===a?await this._notifyAllSubscribers("PASSWORD_RECOVERY",n):await this._notifyAllSubscribers("SIGNED_IN",n)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){if(tg(e))return this._returnResult({error:e});return this._returnResult({error:new tm("Unexpected error during initialization",e)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{let{data:i,error:n}=await t4(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:t7});if(n||!i)return this._returnResult({data:{user:null,session:null},error:n});let a=i.session,o=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",a)),this._returnResult({data:{user:o,session:a},error:null})}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,r,s;try{let i;if("email"in e){let{email:r,password:s,options:n}=e,a=null,o=null;"pkce"===this.flowType&&([a,o]=await tX(this.storage,this.storageKey)),i=await t4(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:r,password:s,data:null!=(t=null==n?void 0:n.data)?t:{},gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:a,code_challenge_method:o},xform:t7})}else if("phone"in e){let{phone:t,password:n,options:a}=e;i=await t4(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!=(r=null==a?void 0:a.data)?r:{},channel:null!=(s=null==a?void 0:a.channel)?s:"sms",gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:t7})}else throw new tk("You must provide either an email or phone number and a password");let{data:n,error:a}=i;if(a||!n)return await tF(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});let o=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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:i}=e;t=await t4(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:re})}else if("phone"in e){let{phone:r,password:s,options:i}=e;t=await t4(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:re})}else throw new tk("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 tv;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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOAuth(e){var t,r,s,i;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==(i=e.options)?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}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,i,n,a,o,l,u,h,c,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{let h,{chain:c,wallet:g,statement:y,options:m}=e;if(tD())if("object"==typeof g)h=g;else{let e=window;if("ethereum"in e&&"object"==typeof e.ethereum&&"request"in e.ethereum&&"function"==typeof e.ethereum.request)h=e.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if("object"!=typeof g||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");h=g}let b=new URL(null!=(t=null==m?void 0:m.url)?t:window.location.href),w=await h.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!w||0===w.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let _=rd(w[0]),v=null==(r=null==m?void 0:m.signInWithEthereum)?void 0:r.chainId;v||(v=parseInt(await h.request({method:"eth_chainId"}),16)),f=function(e){var t;let{chainId:r,domain:s,expirationTime:i,issuedAt:n=new Date,nonce:a,notBefore:o,requestId:l,resources:u,scheme:h,uri:c,version:d}=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(a&&a.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!c)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==d)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);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 f=rd(e.address),p=h?`${h}://${s}`:s,g=e.statement?`${e.statement}
|
|
25
25
|
`:"",y=`${p} wants you to sign in with your Ethereum account:
|
|
26
26
|
${f}
|
|
27
27
|
|
|
@@ -29,12 +29,12 @@ ${g}`,m=`URI: ${c}
|
|
|
29
29
|
Version: ${d}
|
|
30
30
|
Chain ID: ${r}${a?`
|
|
31
31
|
Nonce: ${a}`:""}
|
|
32
|
-
Issued At: ${
|
|
33
|
-
Expiration Time: ${
|
|
32
|
+
Issued At: ${n.toISOString()}`;if(i&&(m+=`
|
|
33
|
+
Expiration Time: ${i.toISOString()}`),o&&(m+=`
|
|
34
34
|
Not Before: ${o.toISOString()}`),l&&(m+=`
|
|
35
35
|
Request ID: ${l}`),u){let e="\nResources:";for(let t of u){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+=`
|
|
36
36
|
- ${t}`}m+=e}return`${y}
|
|
37
|
-
${m}`}({domain:b.host,address:_,statement:y,uri:b.href,version:"1",chainId:v,nonce:null==(s=null==m?void 0:m.signInWithEthereum)?void 0:s.nonce,issuedAt:null!=(i=null==(n=null==m?void 0:m.signInWithEthereum)?void 0:n.issuedAt)?i:new Date,expirationTime:null==(a=null==m?void 0:m.signInWithEthereum)?void 0:a.expirationTime,notBefore:null==(o=null==m?void 0:m.signInWithEthereum)?void 0:o.notBefore,requestId:null==(l=null==m?void 0:m.signInWithEthereum)?void 0:l.requestId,resources:null==(u=null==m?void 0:m.signInWithEthereum)?void 0:u.resources}),p=await h.request({method:"personal_sign",params:[(d=f,"0x"+Array.from(new TextEncoder().encode(d),e=>e.toString(16).padStart(2,"0")).join("")),_]})}try{let{data:t,error:r}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:p},(null==(h=e.options)?void 0:h.captchaToken)?{gotrue_meta_security:{captcha_token:null==(c=e.options)?void 0:c.captchaToken}}:null),xform:t7});if(r)throw r;if(!t||!t.session||!t.user){let e=new tv;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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,r,s,n,i,a,o,l,u,h,c,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{let c,{chain:d,wallet:g,statement:y,options:m}=e;if(tD())if("object"==typeof g)c=g;else{let e=window;if("solana"in e&&"object"==typeof e.solana&&("signIn"in e.solana&&"function"==typeof e.solana.signIn||"signMessage"in e.solana&&"function"==typeof e.solana.signMessage))c=e.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if("object"!=typeof g||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");c=g}let b=new URL(null!=(t=null==m?void 0:m.url)?t:window.location.href);if("signIn"in c&&c.signIn){let e,t=await c.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==m?void 0:m.signInWithSolana),{version:"1",domain:b.host,uri:b.href}),y?{statement:y}: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)f="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),p=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in c)||"function"!=typeof c.signMessage||!("publicKey"in c)||"object"!=typeof c||!c.publicKey||!("toBase58"in c.publicKey)||"function"!=typeof c.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");f=[`${b.host} wants you to sign in with your Solana account:`,c.publicKey.toBase58(),...y?["",y,""]:[""],"Version: 1",`URI: ${b.href}`,`Issued At: ${null!=(s=null==(r=null==m?void 0:m.signInWithSolana)?void 0:r.issuedAt)?s:new Date().toISOString()}`,...(null==(n=null==m?void 0:m.signInWithSolana)?void 0:n.notBefore)?[`Not Before: ${m.signInWithSolana.notBefore}`]:[],...(null==(i=null==m?void 0:m.signInWithSolana)?void 0:i.expirationTime)?[`Expiration Time: ${m.signInWithSolana.expirationTime}`]:[],...(null==(a=null==m?void 0:m.signInWithSolana)?void 0:a.chainId)?[`Chain ID: ${m.signInWithSolana.chainId}`]:[],...(null==(o=null==m?void 0:m.signInWithSolana)?void 0:o.nonce)?[`Nonce: ${m.signInWithSolana.nonce}`]:[],...(null==(l=null==m?void 0:m.signInWithSolana)?void 0:l.requestId)?[`Request ID: ${m.signInWithSolana.requestId}`]:[],...(null==(h=null==(u=null==m?void 0:m.signInWithSolana)?void 0:u.resources)?void 0:h.length)?["Resources",...m.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await c.signMessage(new TextEncoder().encode(f),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=e}}try{let{data:t,error:r}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:f,signature:tL(p)},(null==(c=e.options)?void 0:c.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:t7});if(r)throw r;if(!t||!t.session||!t.user){let e=new tv;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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e){let t=await tK(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(null!=t?t:"").split("/");try{if(!r&&"pkce"===this.flowType)throw new tT;let{data:t,error:n}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:t7});if(await tF(this.storage,`${this.storageKey}-code-verifier`),n)throw n;if(!t||!t.session||!t.user){let e=new tv;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("recovery"===s?"PASSWORD_RECOVERY":"SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=s?s:null}),error:n})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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:i}=e,{data:a,error:o}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:n,nonce:i,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:t7});if(o)return this._returnResult({data:{user:null,session:null},error:o});if(!a||!a.session||!a.user){let e=new tv;return this._returnResult({data:{user:null,session:null},error:e})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:a,error:o})}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,r,s,n,i;try{if("email"in e){let{email:s,options:n}=e,i=null,a=null;"pkce"===this.flowType&&([i,a]=await tX(this.storage,this.storageKey));let{error:o}=await t4(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:i,code_challenge_method:a},redirectTo:null==n?void 0:n.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}if("phone"in e){let{phone:t,options:r}=e,{data:a,error:o}=await t4(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!=(i=null==r?void 0:r.channel)?i:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:o})}throw new tk("You must provide either an email or phone number.")}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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:i,error:a}=await t4(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:n}}),redirectTo:s,xform:t7});if(a)throw a;if(!i)throw Error("An error occurred on token verification.");let o=i.session,l=i.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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,r,s,n,i;try{let a=null,o=null;"pkce"===this.flowType&&([a,o]=await tX(this.storage,this.storageKey));let l=await t4(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:null!=(r=null==(t=e.options)?void 0:t.redirectTo)?r:void 0}),(null==(s=null==e?void 0:e.options)?void 0:s.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:rr});return(null==(n=l.data)?void 0:n.url)&&tD()&&!(null==(i=e.options)?void 0:i.skipBrowserRedirect)&&window.location.assign(l.data.url),this._returnResult(l)}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(e))return this._returnResult({data:null,error:e});throw e}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>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 tw;let{error:s}=await t4(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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:r,type:s,options:n}=e,{error:i}=await t4(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},redirectTo:null==n?void 0:n.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:i})}if("phone"in e){let{phone:r,type:s,options:n}=e,{data:i,error:a}=await t4(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==i?void 0:i.message_id},error:a})}throw new tk("You must provide either an email or phone number and a type")}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>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"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let t=null,r=await tK(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),null!==r&&(this._isValidSession(r)?t=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};let s=!!t.expires_at&&1e3*t.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",t.expires_at),!s){if(this.userStorage){let e=await tK(this.userStorage,this.storageKey+"-user");(null==e?void 0:e.user)?t.user=e.user:t.user=t2()}if(this.storage.isServer&&t.user&&!t.user.__isUserNotAvailableProxy){var e;let r={value:this.suppressGetSessionWarning};t.user=(e=t.user,new Proxy(e,{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{data:{session:t},error:null}}let{data:n,error:i}=await this._callRefreshToken(t.refresh_token);if(i)return this._returnResult({data:{session:null},error:i});return this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let t=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return t.data.user&&(this.suppressGetSessionWarning=!0),t}async _getUser(e){try{if(e)return await t4(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:rt});return await this._useSession(async e=>{var t,r,s;let{data:n,error:i}=e;if(i)throw i;return(null==(t=n.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await t4(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:rt}):{data:{user:null},error:new tw}})}catch(e){if(tg(e))return t_(e)&&(await this._removeSession(),await tF(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:e});throw e}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async r=>{let{data:s,error:n}=r;if(n)throw n;if(!s.session)throw new tw;let i=s.session,a=null,o=null;"pkce"===this.flowType&&null!=e.email&&([a,o]=await tX(this.storage,this.storageKey));let{data:l,error:u}=await t4(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:o}),jwt:i.access_token,xform:rt});if(u)throw u;return i.user=l.user,await this._saveSession(i),await this._notifyAllSubscribers("USER_UPDATED",i),this._returnResult({data:{user:i.user},error:null})})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(e))return this._returnResult({data:{user:null},error:e});throw e}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new tw;let t=Date.now()/1e3,r=t,s=!0,n=null,{payload:i}=tW(e.access_token);if(i.exp&&(s=(r=i.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:i}=await this._getUser(e.access_token);if(i)return this._returnResult({data:{user:null,session:null},error:i});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(tg(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>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 tw;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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){var r;try{if(!tD())throw new tE("No browser detected.");if(e.error||e.error_description||e.error_code)throw new tE(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new tS("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new tE("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new tS("No code detected.");let{data:t,error:s}=await this._exchangeCodeForSession(e.code);if(s)throw s;let n=new URL(window.location.href);return n.searchParams.delete("code"),window.history.replaceState(window.history.state,"",n.toString()),{data:{session:t.session,redirectType:null!=(r=t.redirectType)?r:null},error:null}}let{provider_token:s,provider_refresh_token:n,access_token:i,refresh_token:a,expires_in:o,expires_at:l,token_type:u}=e;if(!i||!o||!a||!u)throw new tE("No session defined in URL");let h=Math.round(Date.now()/1e3),c=parseInt(o),d=h+c;l&&(d=parseInt(l));let f=d-h;1e3*f<=3e4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${c}s`);let p=d-c;h-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,d,h):h-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,d,h);let{data:g,error:y}=await this._getUser(i);if(y)throw y;let m={provider_token:s,provider_refresh_token:n,access_token:i,expires_in:c,expires_at:d,refresh_token:a,token_type:u,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:m,redirectType:e.type},error:null})}catch(e){if(tg(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_description)}async _isPKCECallback(e){let t=await tK(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let{data:s,error:n}=t;if(n&&!t_(n))return this._returnResult({error:n});let i=null==(r=s.session)?void 0:r.access_token;if(i){let{error:t}=await this.admin.signOut(i,e);if(t&&!(tg(t)&&"AuthApiError"===t.name&&(404===t.status||401===t.status||403===t.status)||t_(t)))return this._returnResult({error:t})}return"others"!==e&&(await this._removeSession(),await tF(this.storage,`${this.storageKey}-code-verifier`)),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,await this._acquireLock(this.lockAcquireTimeout,async()=>{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){await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),t_(t)?console.warn(t):console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;"pkce"===this.flowType&&([r,s]=await tX(this.storage,this.storageKey,!0));try{return await t4(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:t.redirectTo})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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(tg(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){var t;try{let{data:r,error:s}=await this._useSession(async t=>{var r,s,n,i,a;let{data:o,error:l}=t;if(l)throw l;let u=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null==(r=e.options)?void 0:r.redirectTo,scopes:null==(s=e.options)?void 0:s.scopes,queryParams:null==(n=e.options)?void 0:n.queryParams,skipBrowserRedirect:!0});return await t4(this.fetch,"GET",u,{headers:this.headers,jwt:null!=(a=null==(i=o.session)?void 0:i.access_token)?a:void 0})});if(s)throw s;return!tD()||(null==(t=e.options)?void 0:t.skipBrowserRedirect)||window.location.assign(null==r?void 0:r.url),this._returnResult({data:{provider:e.provider,url:null==r?void 0:r.url},error:null})}catch(t){if(tg(t))return this._returnResult({data:{provider:e.provider,url:null},error:t});throw t}}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:i,provider:a,token:o,access_token:l,nonce:u}=e,{data:h,error:c}=await t4(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:a,id_token:o,access_token:l,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:t7});if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!h||!h.session||!h.user)return this._returnResult({data:{user:null,session:null},error:new tv});return h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),this._returnResult({data:h,error:c})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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:i}=t;if(i)throw i;return await t4(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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{var r,s;let n=Date.now();return await (r=async r=>(r>0&&await tJ(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await t4(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:t7})),s=(e,t)=>{let r=200*Math.pow(2,e);return t&&tR(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,t))return void e(t)}catch(e){if(!s(n,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),tg(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 r=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),tD()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,t;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let s=await tK(this.storage,this.storageKey);if(s&&this.userStorage){let t=await tK(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:s.user},await tH(this.userStorage,this.storageKey+"-user",t)),s.user=null!=(e=null==t?void 0:t.user)?e:t2()}else if(s&&!s.user&&!s.user){let e=await tK(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(s.user=e.user,await tF(this.storage,this.storageKey+"-user"),await tH(this.storage,this.storageKey,s)):s.user=t2()}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&&(console.error(e),tR(e)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}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),console.error(e);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new tw;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new tG;let{data:t,error:r}=await this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new tw;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let s={data:t.session,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(this._debug(s,"error",e),tg(e)){let r={data:null,error:e};return tR(e)||await this._removeSession(),null==(t=this.refreshingDeferred)||t.resolve(r),r}throw null==(r=this.refreshingDeferred)||r.reject(e),e}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){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,await tF(this.storage,`${this.storageKey}-code-verifier`);let t=Object.assign({},e),r=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!r&&t.user&&await tH(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let s=t8(e);await tH(this.storage,this.storageKey,s)}else{let e=t8(t);await tH(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await tF(this.storage,this.storageKey),await tF(this.storage,this.storageKey+"-code-verifier"),await tF(this.storage,this.storageKey+"-user"),this.userStorage&&await tF(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&tD()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(e){console.error("removing visibilitychange callback failed",e)}}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 _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");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 ru)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!tD()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,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()}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){let s=[`provider=${encodeURIComponent(t)}`];if((null==r?void 0:r.redirectTo)&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),(null==r?void 0:r.scopes)&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),"pkce"===this.flowType){let[e,t]=await tX(this.storage,this.storageKey),r=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});s.push(r.toString())}if(null==r?void 0:r.queryParams){let e=new URLSearchParams(r.queryParams);s.push(e.toString())}return(null==r?void 0:r.skipBrowserRedirect)&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}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 t4(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(tg(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:i}=t;if(i)return this._returnResult({data:null,error:i});let a=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 t4(this.fetch,"POST",`${this.url}/factors`,{body:a,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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,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 i=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?rb(e.webauthn.credential_response):rw(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:o}=await t4(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:i,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)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:o}))})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,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 i=await t4(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(i.error)return i;let{data:a}=i;if("webauthn"!==a.type)return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:ry(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:rm(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}})}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:[]};for(let r of null!=(e=null==t?void 0:t.factors)?e:[])s.all.push(r),"verified"===r.status&&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}=tW(e),n=null;s.aal&&(n=s.aal);let i=n,{data:{user:a},error:o}=await this.getUser(e);if(o)return this._returnResult({data:null,error:o});(null!=(r=null==(t=null==a?void 0:a.factors)?void 0:t.filter(e=>"verified"===e.status))?r:[]).length>0&&(i="aal2");let l=s.amr||[];return{data:{currentLevel:n,nextLevel:i,currentAuthenticationMethods:l},error:null}}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}let{data:{session:i},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!i)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:o}=tW(i.access_token),l=null;o.aal&&(l=o.aal);let u=l;return(null!=(n=null==(s=i.user.factors)?void 0:s.filter(e=>"verified"===e.status))?n:[]).length>0&&(u="aal2"),{data:{currentLevel:l,nextLevel:u,currentAuthenticationMethods:o.amr||[]},error:null}}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 t4(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 tw})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new tw});let i=await t4(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return i.data&&i.data.redirect_url&&tD()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(i.data.redirect_url),i})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new tw});let i=await t4(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return i.data&&i.data.redirect_url&&tD()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(i.data.redirect_url),i})}catch(e){if(tg(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 t4(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 tw})})}catch(e){if(tg(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 t4(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 tw})})}catch(e){if(tg(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:i}=await t4(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(i)throw i;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{var r;let s,n=e;if(!n){let{data:e,error:t}=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});n=e.session.access_token}let{header:i,payload:a,signature:o,raw:{header:l,payload:u}}=tW(n);(null==t?void 0:t.allowExpired)||function(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}(a.exp);let h=!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(!h){let{error:e}=await this.getUser(n);if(e)throw e;return{data:{claims:a,header:i,signature:o},error:null}}let c=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),d=await crypto.subtle.importKey("jwk",h,c,!0,["verify"]);if(!await crypto.subtle.verify(c,d,o,(r=`${l}.${u}`,s=[],!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=>s.push(e)),new Uint8Array(s))))throw new tC("Invalid JWT signature");return{data:{claims:a,header:i,signature:o},error:null}}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async signInWithPasskey(e){var t,r,s;t1(this.experimental);try{if(!rv())return this._returnResult({data:null,error:new tm("Browser does not support WebAuthn",null)});let{data:n,error:i}=await this._startPasskeyAuthentication({options:{captchaToken:null==(t=null==e?void 0:e.options)?void 0:t.captchaToken}});if(i||!n)return this._returnResult({data:null,error:i});let a=rm(n.options),o=null!=(s=null==(r=null==e?void 0:e.options)?void 0:r.signal)?s:rg.createNewAbortSignal(),{data:l,error:u}=await rE({publicKey:a,signal:o});if(u||!l)return this._returnResult({data:null,error:null!=u?u:new tm("WebAuthn ceremony failed",null)});let h=rw(l);return this._verifyPasskeyAuthentication({challengeId:n.challenge_id,credential:h})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async registerPasskey(e){var t,r;t1(this.experimental);try{if(!rv())return this._returnResult({data:null,error:new tm("Browser does not support WebAuthn",null)});let{data:s,error:n}=await this._startPasskeyRegistration();if(n||!s)return this._returnResult({data:null,error:n});let i=ry(s.options),a=null!=(r=null==(t=null==e?void 0:e.options)?void 0:t.signal)?r:rg.createNewAbortSignal(),{data:o,error:l}=await rk({publicKey:i,signal:a});if(l||!o)return this._returnResult({data:null,error:null!=l?l:new tm("WebAuthn ceremony failed",null)});let u=rb(o);return this._verifyPasskeyRegistration({challengeId:s.challenge_id,credential:u})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyRegistration(){t1(this.experimental);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 tw});let{data:s,error:n}=await t4(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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){t1(this.experimental);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 tw});let{data:n,error:i}=await t4(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyAuthentication(e){var t;t1(this.experimental);try{let{data:r,error:s}=await t4(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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyAuthentication(e){t1(this.experimental);try{let{data:t,error:r}=await t4(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:t7});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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _listPasskeys(){t1(this.experimental);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 tw});let{data:s,error:n}=await t4(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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){t1(this.experimental);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 tw});let{data:n,error:i}=await t4(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _deletePasskey(e){t1(this.experimental);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 tw});let{error:n}=await t4(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(tg(e))return this._returnResult({data:null,error:e});throw e}}}rI.nextInstanceID={};let rj=rI,r$="";r$="u">typeof Deno?"deno":"u">typeof document?"web":"u">typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let rx={headers:{"X-Client-Info":`supabase-js-${r$}/2.106.0`}},rN={schema:"public"},rU={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},rL={},rD={enabled:!1,respectSamplingDecision:!0},rB=null;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 rq(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 rH(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?rq(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)):rq(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}async function rK(e,t,r){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 s=await function(){var e,t,r,s;return e=this,t=void 0,r=void 0,s=function*(){try{let e=yield(null===rB&&(rB=import("@opentelemetry/api").catch(()=>null)),rB);if(!e||!e.propagation||!e.context)return null;let t={};e.propagation.inject(e.context.active(),t);let r=t.traceparent;if(!r)return null;return{traceparent:r,tracestate:t.tracestate,baggage:t.baggage}}catch(e){return null}},new(r||(r=Promise))(function(n,i){function a(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,o)}l((s=s.apply(e,t||[])).next())})}();if(!s||!s.traceparent)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,i]=t;if(2!==r.length||32!==s.length||16!==n.length||2!==i.length)return null;let a=/^[0-9a-f]+$/i;return a.test(r)&&a.test(s)&&a.test(n)&&a.test(i)&&"00000000000000000000000000000000"!==s&&"0000000000000000"!==n?{version:r,traceId:s,parentId:n,traceFlags:i,isSampled:(1&parseInt(i,16))==1}:null}(s.traceparent);if(e&&!e.isSampled)return null}return s}function rF(e){return"boolean"==typeof e?{enabled:e}:e}var rG=class extends rj{constructor(e){super(e)}},rW=class{constructor(e,t,r){var s,n,i;this.supabaseUrl=e,this.supabaseKey=t;const a=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.");this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const o=`sb-${a.hostname.split(".")[0]}-auth-token`,l=function(e,t){var r,s,n,i,a,o;let{db:l,auth:u,realtime:h,global:c}=e,{db:d,auth:f,realtime:p,global:g}=t,y=rF(e.tracePropagation),m=rF(t.tracePropagation),b={db:rH(rH({},d),l),auth:rH(rH({},f),u),realtime:rH(rH({},p),h),storage:{},global:rH(rH(rH({},g),c),{},{headers:rH(rH({},null!=(r=null==g?void 0:g.headers)?r:{}),null!=(s=null==c?void 0:c.headers)?s:{})}),tracePropagation:{enabled:null!=(n=null!=(i=null==y?void 0:y.enabled)?i:null==m?void 0:m.enabled)&&n,respectSamplingDecision:null==(a=null!=(o=null==y?void 0:y.respectSamplingDecision)?o:null==m?void 0:m.respectSamplingDecision)||a},accessToken:async()=>""};return e.accessToken?b.accessToken=e.accessToken:delete b.accessToken,b}(null!=r?r:{},{db:rN,realtime:rL,auth:rH(rH({},rU),{},{storageKey:o}),global:rx,tracePropagation:rD});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!=(i=l.auth)?i:{},this.headers,l.global.fetch),this.fetch=((e,t,r,s,n)=>{let i=s?(...e)=>s(...e):(...e)=>fetch(...e),a=Headers,o=(null==n?void 0:n.enabled)===!0,l=(null==n?void 0:n.respectSamplingDecision)!==!1,u=o?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;return async(t,s)=>{var n;let o=null!=(n=await r())?n:e,h=new a(null==s?void 0:s.headers);if(h.has("apikey")||h.set("apikey",e),h.has("Authorization")||h.set("Authorization",`Bearer ${o}`),u){let e=await rK(t,u,l);e&&(e.traceparent&&!h.has("traceparent")&&h.set("traceparent",e.traceparent),e.tracestate&&!h.has("tracestate")&&h.set("tracestate",e.tracestate),e.baggage&&!h.has("baggage")&&h.set("baggage",e.baggage))}return i(t,rH(rH({},s),{},{headers:h}))}})(t,e,this._getAccessToken.bind(this),l.global.fetch,l.tracePropagation),this.realtime=this._initRealtimeClient(rH({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 N(new URL("rest/v1",a).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new tl(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new u(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}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 _getAccessToken(){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:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:i,flowType:a,lock:o,debug:l,throwOnError:u,experimental:h,lockAcquireTimeout:c,skipAutoInitialize:d},f,p){let g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new rG({url:this.authUrl.href,headers:rH(rH({},g),f),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:n,flowType:a,lock:o,debug:l,throwOnError:u,experimental:h,fetch:p,lockAcquireTimeout:c,skipAutoInitialize:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new eC(this.realtimeUrl.href,rH(rH({},e),{},{params:rH(rH({},{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)&&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("u">typeof window)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&&18>=parseInt(r[1],10)})()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");var rJ=e.i(22792);function rz(){return"u">typeof window&&void 0!==window.document}rJ.parse,rJ.serialize;let rV={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},rY=/^(.*)[.](0|[1-9][0-9]*)$/;function rX(e,t){if(e===t)return!0;let r=e.match(rY);return!!r&&r[1]===t}function rQ(e,t,r){let s=r??3180,n=encodeURIComponent(t);if(n.length<=s)return[{name:e,value:t}];let i=[];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}i.push(r),n=n.slice(e.length)}return i.map((t,r)=>({name:`${e}.${r}`,value:t}))}async function rZ(e,t){let r=await t(e);if(r)return r;let s=[];for(let r=0;;r++){let n=`${e}.${r}`,i=await t(n);if(!i)break;s.push(i)}return s.length>0?s.join(""):null}let r0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),r1=" \n\r=".split(""),r2=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<r1.length;t+=1)e[r1[t].charCodeAt(0)]=-2;for(let t=0;t<r0.length;t+=1)e[r0[t].charCodeAt(0)]=t;return e})();function r8(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(r0[e]),s-=6}}),s>0)for(r<<=6-s,s=6;s>=6;){let e=r>>s-6&63;t.push(r0[e]),s-=6}return t.join("")}let r5="base64-";function r6(e){let t;if(!e.startsWith(r5))return e;try{t=function(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},n=0,i=0;for(let t=0;t<e.length;t+=1){let a=r2[e.charCodeAt(t)];if(a>-1)for(n=n<<6|a,i+=6;i>=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>>i-8&255,s,r),i-=8;else if(-2===a)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}(e.substring(r5.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 r3({getAll:e,setAll:t,setItems:r,removedItems:s},n){let i=n.cookieEncoding,a=n.cookieOptions??null,o=await e([...r?Object.keys(r):[],...s?Object.keys(s):[]]),l=o?.map(({name:e})=>e)||[],u=Object.keys(s).flatMap(e=>l.filter(t=>rX(t,e))),h=Object.keys(r).flatMap(e=>{let t=new Set(l.filter(t=>rX(t,e))),s=r[e];"base64url"===i&&(s=r5+r8(s));let n=rQ(e,s);return n.forEach(e=>{t.delete(e.name)}),u.push(...t),n}),c={...rV,...a,maxAge:0},d={...rV,...a,maxAge:rV.maxAge};delete c.name,delete d.name,await t([...u.map(e=>({name:e,value:"",options:c})),...h.map(({name:e,value:t})=>({name:e,value:t,options:d}))],{"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"})}var r4=e.i(13073);let r9=!1,r7=["@supabase/auth-helpers-nextjs","@supabase/auth-helpers-react","@supabase/auth-helpers-remix","@supabase/auth-helpers-sveltekit"];var se=e.i(32417);e.s(["create_browser_supabase_client",0,function(){let{anon_key:e,url:t}=function(){if(!(0,se.is_supabase_configured)())throw Error("Supabase is not configured");return{url:"https://ctruizaqyeyidujmtxhc.supabase.co".trim(),anon_key:"sb_publishable_gTYHeWoWIPPW3SIC4cYaXw_ux7UL_Jb".trim()}}();return function(e,t){!function(){if(r9||void 0===r4.default||!r4.default.env?.npm_package_name)return;let e=r4.default.env.npm_package_name;r7.includes(e)&&(r9=!0,console.warn(`
|
|
37
|
+
${m}`}({domain:b.host,address:_,statement:y,uri:b.href,version:"1",chainId:v,nonce:null==(s=null==m?void 0:m.signInWithEthereum)?void 0:s.nonce,issuedAt:null!=(n=null==(i=null==m?void 0:m.signInWithEthereum)?void 0:i.issuedAt)?n:new Date,expirationTime:null==(a=null==m?void 0:m.signInWithEthereum)?void 0:a.expirationTime,notBefore:null==(o=null==m?void 0:m.signInWithEthereum)?void 0:o.notBefore,requestId:null==(l=null==m?void 0:m.signInWithEthereum)?void 0:l.requestId,resources:null==(u=null==m?void 0:m.signInWithEthereum)?void 0:u.resources}),p=await h.request({method:"personal_sign",params:[(d=f,"0x"+Array.from(new TextEncoder().encode(d),e=>e.toString(16).padStart(2,"0")).join("")),_]})}try{let{data:t,error:r}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:p},(null==(h=e.options)?void 0:h.captchaToken)?{gotrue_meta_security:{captcha_token:null==(c=e.options)?void 0:c.captchaToken}}:null),xform:t7});if(r)throw r;if(!t||!t.session||!t.user){let e=new tv;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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,r,s,i,n,a,o,l,u,h,c,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{let c,{chain:d,wallet:g,statement:y,options:m}=e;if(tD())if("object"==typeof g)c=g;else{let e=window;if("solana"in e&&"object"==typeof e.solana&&("signIn"in e.solana&&"function"==typeof e.solana.signIn||"signMessage"in e.solana&&"function"==typeof e.solana.signMessage))c=e.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if("object"!=typeof g||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");c=g}let b=new URL(null!=(t=null==m?void 0:m.url)?t:window.location.href);if("signIn"in c&&c.signIn){let e,t=await c.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==m?void 0:m.signInWithSolana),{version:"1",domain:b.host,uri:b.href}),y?{statement:y}: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)f="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),p=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in c)||"function"!=typeof c.signMessage||!("publicKey"in c)||"object"!=typeof c||!c.publicKey||!("toBase58"in c.publicKey)||"function"!=typeof c.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");f=[`${b.host} wants you to sign in with your Solana account:`,c.publicKey.toBase58(),...y?["",y,""]:[""],"Version: 1",`URI: ${b.href}`,`Issued At: ${null!=(s=null==(r=null==m?void 0:m.signInWithSolana)?void 0:r.issuedAt)?s:new Date().toISOString()}`,...(null==(i=null==m?void 0:m.signInWithSolana)?void 0:i.notBefore)?[`Not Before: ${m.signInWithSolana.notBefore}`]:[],...(null==(n=null==m?void 0:m.signInWithSolana)?void 0:n.expirationTime)?[`Expiration Time: ${m.signInWithSolana.expirationTime}`]:[],...(null==(a=null==m?void 0:m.signInWithSolana)?void 0:a.chainId)?[`Chain ID: ${m.signInWithSolana.chainId}`]:[],...(null==(o=null==m?void 0:m.signInWithSolana)?void 0:o.nonce)?[`Nonce: ${m.signInWithSolana.nonce}`]:[],...(null==(l=null==m?void 0:m.signInWithSolana)?void 0:l.requestId)?[`Request ID: ${m.signInWithSolana.requestId}`]:[],...(null==(h=null==(u=null==m?void 0:m.signInWithSolana)?void 0:u.resources)?void 0:h.length)?["Resources",...m.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await c.signMessage(new TextEncoder().encode(f),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=e}}try{let{data:t,error:r}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:f,signature:tL(p)},(null==(c=e.options)?void 0:c.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:t7});if(r)throw r;if(!t||!t.session||!t.user){let e=new tv;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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e){let t=await tH(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(null!=t?t:"").split("/");try{if(!r&&"pkce"===this.flowType)throw new tT;let{data:t,error:i}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:t7});if(await tF(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!t||!t.session||!t.user){let e=new tv;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("recovery"===s?"PASSWORD_RECOVERY":"SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=s?s:null}),error:i})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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:i,nonce:n}=e,{data:a,error:o}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:n,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:t7});if(o)return this._returnResult({data:{user:null,session:null},error:o});if(!a||!a.session||!a.user){let e=new tv;return this._returnResult({data:{user:null,session:null},error:e})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:a,error:o})}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,r,s,i,n;try{if("email"in e){let{email:s,options:i}=e,n=null,a=null;"pkce"===this.flowType&&([n,a]=await tX(this.storage,this.storageKey));let{error:o}=await t4(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:null!=(t=null==i?void 0:i.data)?t:{},create_user:null==(r=null==i?void 0:i.shouldCreateUser)||r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:n,code_challenge_method:a},redirectTo:null==i?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}if("phone"in e){let{phone:t,options:r}=e,{data:a,error:o}=await t4(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==(i=null==r?void 0:r.shouldCreateUser)||i,gotrue_meta_security:{captcha_token:null==r?void 0:r.captchaToken},channel:null!=(n=null==r?void 0:r.channel)?n:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:o})}throw new tk("You must provide either an email or phone number.")}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async verifyOtp(e){var t,r;try{let s,i;"options"in e&&(s=null==(t=e.options)?void 0:t.redirectTo,i=null==(r=e.options)?void 0:r.captchaToken);let{data:n,error:a}=await t4(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:t7});if(a)throw a;if(!n)throw Error("An error occurred on token verification.");let o=n.session,l=n.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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,r,s,i,n;try{let a=null,o=null;"pkce"===this.flowType&&([a,o]=await tX(this.storage,this.storageKey));let l=await t4(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:null!=(r=null==(t=e.options)?void 0:t.redirectTo)?r:void 0}),(null==(s=null==e?void 0:e.options)?void 0:s.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:rr});return(null==(i=l.data)?void 0:i.url)&&tD()&&!(null==(n=e.options)?void 0:n.skipBrowserRedirect)&&window.location.assign(l.data.url),this._returnResult(l)}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(e))return this._returnResult({data:null,error:e});throw e}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>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 tw;let{error:s}=await t4(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(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:r,type:s,options:i}=e,{error:n}=await t4(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},redirectTo:null==i?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:n})}if("phone"in e){let{phone:r,type:s,options:i}=e,{data:n,error:a}=await t4(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:a})}throw new tk("You must provide either an email or phone number and a type")}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>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"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack);try{let t=null,r=await tH(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),null!==r&&(this._isValidSession(r)?t=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};let s=!!t.expires_at&&1e3*t.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",t.expires_at),!s){if(this.userStorage){let e=await tH(this.userStorage,this.storageKey+"-user");(null==e?void 0:e.user)?t.user=e.user:t.user=t2()}if(this.storage.isServer&&t.user&&!t.user.__isUserNotAvailableProxy){var e;let r={value:this.suppressGetSessionWarning};t.user=(e=t.user,new Proxy(e,{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{data:{session:t},error:null}}let{data:i,error:n}=await this._callRefreshToken(t.refresh_token);if(n)return this._returnResult({data:{session:null},error:n});return this._returnResult({data:{session:i},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let t=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return t.data.user&&(this.suppressGetSessionWarning=!0),t}async _getUser(e){try{if(e)return await t4(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:rt});return await this._useSession(async e=>{var t,r,s;let{data:i,error:n}=e;if(n)throw n;return(null==(t=i.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await t4(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!=(s=null==(r=i.session)?void 0:r.access_token)?s:void 0,xform:rt}):{data:{user:null},error:new tw}})}catch(e){if(tg(e))return t_(e)&&(await this._removeSession(),await tF(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:e});throw e}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async r=>{let{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new tw;let n=s.session,a=null,o=null;"pkce"===this.flowType&&null!=e.email&&([a,o]=await tX(this.storage,this.storageKey));let{data:l,error:u}=await t4(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:o}),jwt:n.access_token,xform:rt});if(u)throw u;return n.user=l.user,await this._saveSession(n),await this._notifyAllSubscribers("USER_UPDATED",n),this._returnResult({data:{user:n.user},error:null})})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(e))return this._returnResult({data:{user:null},error:e});throw e}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new tw;let t=Date.now()/1e3,r=t,s=!0,i=null,{payload:n}=tW(e.access_token);if(n.exp&&(s=(r=n.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};i=t}else{let{data:s,error:n}=await this._getUser(e.access_token);if(n)return this._returnResult({data:{user:null,session:null},error:n});i={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(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(e){if(tg(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var r;if(!e){let{data:s,error:i}=t;if(i)throw i;e=null!=(r=s.session)?r:void 0}if(!(null==e?void 0:e.refresh_token))throw new tw;let{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(e){if(tg(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){var r;try{if(!tD())throw new tE("No browser detected.");if(e.error||e.error_description||e.error_code)throw new tE(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new tS("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new tE("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new tS("No code detected.");let{data:t,error:s}=await this._exchangeCodeForSession(e.code);if(s)throw s;let i=new URL(window.location.href);return i.searchParams.delete("code"),window.history.replaceState(window.history.state,"",i.toString()),{data:{session:t.session,redirectType:null!=(r=t.redirectType)?r:null},error:null}}let{provider_token:s,provider_refresh_token:i,access_token:n,refresh_token:a,expires_in:o,expires_at:l,token_type:u}=e;if(!n||!o||!a||!u)throw new tE("No session defined in URL");let h=Math.round(Date.now()/1e3),c=parseInt(o),d=h+c;l&&(d=parseInt(l));let f=d-h;1e3*f<=3e4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${c}s`);let p=d-c;h-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,d,h):h-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,d,h);let{data:g,error:y}=await this._getUser(n);if(y)throw y;let m={provider_token:s,provider_refresh_token:i,access_token:n,expires_in:c,expires_at:d,refresh_token:a,token_type:u,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:m,redirectType:e.type},error:null})}catch(e){if(tg(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_description)}async _isPKCECallback(e){let t=await tH(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i&&!t_(i))return this._returnResult({error:i});let n=null==(r=s.session)?void 0:r.access_token;if(n){let{error:t}=await this.admin.signOut(n,e);if(t&&!(tg(t)&&"AuthApiError"===t.name&&(404===t.status||401===t.status||403===t.status)||t_(t)))return this._returnResult({error:t})}return"others"!==e&&(await this._removeSession(),await tF(this.storage,`${this.storageKey}-code-verifier`)),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,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(t)})})(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,s;try{let{data:{session:s},error:i}=t;if(i)throw i;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){await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),t_(t)?console.warn(t):console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;"pkce"===this.flowType&&([r,s]=await tX(this.storage,this.storageKey,!0));try{return await t4(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:t.redirectTo})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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(tg(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){var t;try{let{data:r,error:s}=await this._useSession(async t=>{var r,s,i,n,a;let{data:o,error:l}=t;if(l)throw l;let u=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null==(r=e.options)?void 0:r.redirectTo,scopes:null==(s=e.options)?void 0:s.scopes,queryParams:null==(i=e.options)?void 0:i.queryParams,skipBrowserRedirect:!0});return await t4(this.fetch,"GET",u,{headers:this.headers,jwt:null!=(a=null==(n=o.session)?void 0:n.access_token)?a:void 0})});if(s)throw s;return!tD()||(null==(t=e.options)?void 0:t.skipBrowserRedirect)||window.location.assign(null==r?void 0:r.url),this._returnResult({data:{provider:e.provider,url:null==r?void 0:r.url},error:null})}catch(t){if(tg(t))return this._returnResult({data:{provider:e.provider,url:null},error:t});throw t}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{let{error:s,data:{session:i}}=t;if(s)throw s;let{options:n,provider:a,token:o,access_token:l,nonce:u}=e,{data:h,error:c}=await t4(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:null!=(r=null==i?void 0:i.access_token)?r:void 0,body:{provider:a,id_token:o,access_token:l,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:t7});if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!h||!h.session||!h.user)return this._returnResult({data:{user:null,session:null},error:new tv});return h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),this._returnResult({data:h,error:c})}catch(e){if(await tF(this.storage,`${this.storageKey}-code-verifier`),tg(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:i,error:n}=t;if(n)throw n;return await t4(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!=(s=null==(r=i.session)?void 0:r.access_token)?s:void 0})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{var r,s;let i=Date.now();return await (r=async r=>(r>0&&await tJ(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await t4(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:t7})),s=(e,t)=>{let r=200*Math.pow(2,e);return t&&tR(t)&&Date.now()+r-i<3e4},new Promise((e,t)=>{(async()=>{for(let i=0;i<1/0;i++)try{let t=await r(i);if(!s(i,null,t))return void e(t)}catch(e){if(!s(i,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),tg(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 r=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),tD()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,t;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let s=await tH(this.storage,this.storageKey);if(s&&this.userStorage){let t=await tH(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:s.user},await tK(this.userStorage,this.storageKey+"-user",t)),s.user=null!=(e=null==t?void 0:t.user)?e:t2()}else if(s&&!s.user&&!s.user){let e=await tH(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(s.user=e.user,await tF(this.storage,this.storageKey+"-user"),await tK(this.storage,this.storageKey,s)):s.user=t2()}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 i=(null!=(t=s.expires_at)?t:1/0)*1e3-Date.now()<9e4;if(this._debug(r,`session has${i?"":" not"} expired with margin of 90000s`),i){if(this.autoRefreshToken&&s.refresh_token){let{error:e}=await this._callRefreshToken(s.refresh_token);e&&(console.error(e),tR(e)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}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),console.error(e);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new tw;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new tG;let{data:t,error:r}=await this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new tw;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let s={data:t.session,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(this._debug(s,"error",e),tg(e)){let r={data:null,error:e};return tR(e)||await this._removeSession(),null==(t=this.refreshingDeferred)||t.resolve(r),r}throw null==(r=this.refreshingDeferred)||r.reject(e),e}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let s=[],i=Array.from(this.stateChangeEmitters.values()).map(async r=>{try{await r.callback(e,t)}catch(e){s.push(e)}});if(await Promise.all(i),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,await tF(this.storage,`${this.storageKey}-code-verifier`);let t=Object.assign({},e),r=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!r&&t.user&&await tK(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let s=t8(e);await tK(this.storage,this.storageKey,s)}else{let e=t8(t);await tK(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await tF(this.storage,this.storageKey),await tF(this.storage,this.storageKey+"-code-verifier"),await tF(this.storage,this.storageKey+"-user"),this.userStorage&&await tF(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&tD()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(e){console.error("removing visibilitychange callback failed",e)}}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 _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");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 ru)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!tD()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,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()}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){let s=[`provider=${encodeURIComponent(t)}`];if((null==r?void 0:r.redirectTo)&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),(null==r?void 0:r.scopes)&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),"pkce"===this.flowType){let[e,t]=await tX(this.storage,this.storageKey),r=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});s.push(r.toString())}if(null==r?void 0:r.queryParams){let e=new URLSearchParams(r.queryParams);s.push(e.toString())}return(null==r?void 0:r.skipBrowserRedirect)&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;return i?this._returnResult({data:null,error:i}):await t4(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(tg(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:i,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=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 t4(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:null==(r=null==i?void 0:i.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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return this._returnResult({data:null,error:i});let n=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?rb(e.webauthn.credential_response):rw(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:o}=await t4(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:n,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)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:o}))})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return this._returnResult({data:null,error:i});let n=await t4(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(n.error)return n;let{data:a}=n;if("webauthn"!==a.type)return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:ry(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:rm(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}})}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:[]};for(let r of null!=(e=null==t?void 0:t.factors)?e:[])s.all.push(r),"verified"===r.status&&s[r.factor_type].push(r);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(e){var t,r,s,i;if(e)try{let{payload:s}=tW(e),i=null;s.aal&&(i=s.aal);let n=i,{data:{user:a},error:o}=await this.getUser(e);if(o)return this._returnResult({data:null,error:o});(null!=(r=null==(t=null==a?void 0:a.factors)?void 0:t.filter(e=>"verified"===e.status))?r:[]).length>0&&(n="aal2");let l=s.amr||[];return{data:{currentLevel:i,nextLevel:n,currentAuthenticationMethods:l},error:null}}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}let{data:{session:n},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:o}=tW(n.access_token),l=null;o.aal&&(l=o.aal);let u=l;return(null!=(i=null==(s=n.user.factors)?void 0:s.filter(e=>"verified"===e.status))?i:[]).length>0&&(u="aal2"),{data:{currentLevel:l,nextLevel:u,currentAuthenticationMethods:o.amr||[]},error:null}}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 t4(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 tw})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new tw});let n=await t4(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&tD()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new tw});let n=await t4(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&tD()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if(tg(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 t4(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 tw})})}catch(e){if(tg(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 t4(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 tw})})}catch(e){if(tg(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:i,error:n}=await t4(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(n)throw n;return i.keys&&0!==i.keys.length&&(this.jwks=i,this.jwks_cached_at=s,r=i.keys.find(t=>t.kid===e))?r:null}async getClaims(e,t={}){try{var r;let s,i=e;if(!i){let{data:e,error:t}=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});i=e.session.access_token}let{header:n,payload:a,signature:o,raw:{header:l,payload:u}}=tW(i);(null==t?void 0:t.allowExpired)||function(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}(a.exp);let h=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!h){let{error:e}=await this.getUser(i);if(e)throw e;return{data:{claims:a,header:n,signature:o},error:null}}let c=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")}}(n.alg),d=await crypto.subtle.importKey("jwk",h,c,!0,["verify"]);if(!await crypto.subtle.verify(c,d,o,(r=`${l}.${u}`,s=[],!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=>s.push(e)),new Uint8Array(s))))throw new tC("Invalid JWT signature");return{data:{claims:a,header:n,signature:o},error:null}}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async signInWithPasskey(e){var t,r,s;t1(this.experimental);try{if(!rv())return this._returnResult({data:null,error:new tm("Browser does not support WebAuthn",null)});let{data:i,error:n}=await this._startPasskeyAuthentication({options:{captchaToken:null==(t=null==e?void 0:e.options)?void 0:t.captchaToken}});if(n||!i)return this._returnResult({data:null,error:n});let a=rm(i.options),o=null!=(s=null==(r=null==e?void 0:e.options)?void 0:r.signal)?s:rg.createNewAbortSignal(),{data:l,error:u}=await rE({publicKey:a,signal:o});if(u||!l)return this._returnResult({data:null,error:null!=u?u:new tm("WebAuthn ceremony failed",null)});let h=rw(l);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:h})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async registerPasskey(e){var t,r;t1(this.experimental);try{if(!rv())return this._returnResult({data:null,error:new tm("Browser does not support WebAuthn",null)});let{data:s,error:i}=await this._startPasskeyRegistration();if(i||!s)return this._returnResult({data:null,error:i});let n=ry(s.options),a=null!=(r=null==(t=null==e?void 0:e.options)?void 0:t.signal)?r:rg.createNewAbortSignal(),{data:o,error:l}=await rk({publicKey:n,signal:a});if(l||!o)return this._returnResult({data:null,error:null!=l?l:new tm("WebAuthn ceremony failed",null)});let u=rb(o);return this._verifyPasskeyRegistration({challengeId:s.challenge_id,credential:u})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyRegistration(){t1(this.experimental);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 tw});let{data:s,error:i}=await t4(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:t.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:s,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){t1(this.experimental);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 tw});let{data:i,error:n}=await t4(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:i,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyAuthentication(e){var t;t1(this.experimental);try{let{data:r,error:s}=await t4(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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyAuthentication(e){t1(this.experimental);try{let{data:t,error:r}=await t4(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:t7});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(tg(e))return this._returnResult({data:null,error:e});throw e}}async _listPasskeys(){t1(this.experimental);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 tw});let{data:s,error:i}=await t4(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:s,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){t1(this.experimental);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 tw});let{data:i,error:n}=await t4(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:i,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}async _deletePasskey(e){t1(this.experimental);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 tw});let{error:i}=await t4(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(e){if(tg(e))return this._returnResult({data:null,error:e});throw e}}}rI.nextInstanceID={};let rj=rI,r$="";r$="u">typeof Deno?"deno":"u">typeof document?"web":"u">typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let rx={headers:{"X-Client-Info":`supabase-js-${r$}/2.106.0`}},rN={schema:"public"},rU={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},rL={},rD={enabled:!1,respectSamplingDecision:!0},rB=null;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 rq(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 rK(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?rq(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)):rq(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}async function rH(e,t,r){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 s=await function(){var e,t,r,s;return e=this,t=void 0,r=void 0,s=function*(){try{let e=yield(null===rB&&(rB=import("@opentelemetry/api").catch(()=>null)),rB);if(!e||!e.propagation||!e.context)return null;let t={};e.propagation.inject(e.context.active(),t);let r=t.traceparent;if(!r)return null;return{traceparent:r,tracestate:t.tracestate,baggage:t.baggage}}catch(e){return null}},new(r||(r=Promise))(function(i,n){function a(e){try{l(s.next(e))}catch(e){n(e)}}function o(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,o)}l((s=s.apply(e,t||[])).next())})}();if(!s||!s.traceparent)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,i,n]=t;if(2!==r.length||32!==s.length||16!==i.length||2!==n.length)return null;let a=/^[0-9a-f]+$/i;return a.test(r)&&a.test(s)&&a.test(i)&&a.test(n)&&"00000000000000000000000000000000"!==s&&"0000000000000000"!==i?{version:r,traceId:s,parentId:i,traceFlags:n,isSampled:(1&parseInt(n,16))==1}:null}(s.traceparent);if(e&&!e.isSampled)return null}return s}function rF(e){return"boolean"==typeof e?{enabled:e}:e}var rG=class extends rj{constructor(e){super(e)}},rW=class{constructor(e,t,r){var s,i,n;this.supabaseUrl=e,this.supabaseKey=t;const a=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.");this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const o=`sb-${a.hostname.split(".")[0]}-auth-token`,l=function(e,t){var r,s,i,n,a,o;let{db:l,auth:u,realtime:h,global:c}=e,{db:d,auth:f,realtime:p,global:g}=t,y=rF(e.tracePropagation),m=rF(t.tracePropagation),b={db:rK(rK({},d),l),auth:rK(rK({},f),u),realtime:rK(rK({},p),h),storage:{},global:rK(rK(rK({},g),c),{},{headers:rK(rK({},null!=(r=null==g?void 0:g.headers)?r:{}),null!=(s=null==c?void 0:c.headers)?s:{})}),tracePropagation:{enabled:null!=(i=null!=(n=null==y?void 0:y.enabled)?n:null==m?void 0:m.enabled)&&i,respectSamplingDecision:null==(a=null!=(o=null==y?void 0:y.respectSamplingDecision)?o:null==m?void 0:m.respectSamplingDecision)||a},accessToken:async()=>""};return e.accessToken?b.accessToken=e.accessToken:delete b.accessToken,b}(null!=r?r:{},{db:rN,realtime:rL,auth:rK(rK({},rU),{},{storageKey:o}),global:rx,tracePropagation:rD});this.settings=l,this.storageKey=null!=(s=l.auth.storageKey)?s:"",this.headers=null!=(i=l.global.headers)?i:{},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!=(n=l.auth)?n:{},this.headers,l.global.fetch),this.fetch=((e,t,r,s,i)=>{let n=s?(...e)=>s(...e):(...e)=>fetch(...e),a=Headers,o=(null==i?void 0:i.enabled)===!0,l=(null==i?void 0:i.respectSamplingDecision)!==!1,u=o?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;return async(t,s)=>{var i;let o=null!=(i=await r())?i:e,h=new a(null==s?void 0:s.headers);if(h.has("apikey")||h.set("apikey",e),h.has("Authorization")||h.set("Authorization",`Bearer ${o}`),u){let e=await rH(t,u,l);e&&(e.traceparent&&!h.has("traceparent")&&h.set("traceparent",e.traceparent),e.tracestate&&!h.has("tracestate")&&h.set("tracestate",e.tracestate),e.baggage&&!h.has("baggage")&&h.set("baggage",e.baggage))}return n(t,rK(rK({},s),{},{headers:h}))}})(t,e,this._getAccessToken.bind(this),l.global.fetch,l.tracePropagation),this.realtime=this._initRealtimeClient(rK({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 N(new URL("rest/v1",a).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new tl(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new u(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}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 _getAccessToken(){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:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:i,storageKey:n,flowType:a,lock:o,debug:l,throwOnError:u,experimental:h,lockAcquireTimeout:c,skipAutoInitialize:d},f,p){let g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new rG({url:this.authUrl.href,headers:rK(rK({},g),f),storageKey:n,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,userStorage:i,flowType:a,lock:o,debug:l,throwOnError:u,experimental:h,fetch:p,lockAcquireTimeout:c,skipAutoInitialize:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new eC(this.realtimeUrl.href,rK(rK({},e),{},{params:rK(rK({},{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)&&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("u">typeof window)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&&18>=parseInt(r[1],10)})()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");var rJ=e.i(22792);function rz(){return"u">typeof window&&void 0!==window.document}rJ.parse,rJ.serialize;let rV={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},rY=/^(.*)[.](0|[1-9][0-9]*)$/;function rX(e,t){if(e===t)return!0;let r=e.match(rY);return!!r&&r[1]===t}function rQ(e,t,r){let s=r??3180,i=encodeURIComponent(t);if(i.length<=s)return[{name:e,value:t}];let n=[];for(;i.length>0;){let e=i.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}n.push(r),i=i.slice(e.length)}return n.map((t,r)=>({name:`${e}.${r}`,value:t}))}async function rZ(e,t){let r=await t(e);if(r)return r;let s=[];for(let r=0;;r++){let i=`${e}.${r}`,n=await t(i);if(!n)break;s.push(n)}return s.length>0?s.join(""):null}let r0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),r1=" \n\r=".split(""),r2=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<r1.length;t+=1)e[r1[t].charCodeAt(0)]=-2;for(let t=0;t<r0.length;t+=1)e[r0[t].charCodeAt(0)]=t;return e})();function r8(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(r0[e]),s-=6}}),s>0)for(r<<=6-s,s=6;s>=6;){let e=r>>s-6&63;t.push(r0[e]),s-=6}return t.join("")}let r5="base64-";function r6(e){let t;if(!e.startsWith(r5))return e;try{t=function(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},i=0,n=0;for(let t=0;t<e.length;t+=1){let a=r2[e.charCodeAt(t)];if(a>-1)for(i=i<<6|a,n+=6;n>=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)}})(i>>n-8&255,s,r),n-=8;else if(-2===a)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}(e.substring(r5.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 r3({getAll:e,setAll:t,setItems:r,removedItems:s},i){let n=i.cookieEncoding,a=i.cookieOptions??null,o=await e([...r?Object.keys(r):[],...s?Object.keys(s):[]]),l=o?.map(({name:e})=>e)||[],u=Object.keys(s).flatMap(e=>l.filter(t=>rX(t,e))),h=Object.keys(r).flatMap(e=>{let t=new Set(l.filter(t=>rX(t,e))),s=r[e];"base64url"===n&&(s=r5+r8(s));let i=rQ(e,s);return i.forEach(e=>{t.delete(e.name)}),u.push(...t),i}),c={...rV,...a,maxAge:0},d={...rV,...a,maxAge:rV.maxAge};delete c.name,delete d.name,await t([...u.map(e=>({name:e,value:"",options:c})),...h.map(({name:e,value:t})=>({name:e,value:t,options:d}))],{"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"})}var r4=e.i(13073);let r9=!1,r7=["@supabase/auth-helpers-nextjs","@supabase/auth-helpers-react","@supabase/auth-helpers-remix","@supabase/auth-helpers-sveltekit"];var se=e.i(32417);e.s(["create_browser_supabase_client",0,function(){let{anon_key:e,url:t}=function(){if(!(0,se.is_supabase_configured)())throw Error("Supabase is not configured");return{url:"https://ctruizaqyeyidujmtxhc.supabase.co".trim(),anon_key:"sb_publishable_gTYHeWoWIPPW3SIC4cYaXw_ux7UL_Jb".trim()}}();return function(e,t){!function(){if(r9||void 0===r4.default||!r4.default.env?.npm_package_name)return;let e=r4.default.env.npm_package_name;r7.includes(e)&&(r9=!0,console.warn(`
|
|
38
38
|
╔════════════════════════════════════════════════════════════════════════════╗
|
|
39
39
|
║ ⚠️ IMPORTANT: Package Consolidation Notice ║
|
|
40
40
|
║ ║
|
|
@@ -56,4 +56,4 @@ ${m}`}({domain:b.host,address:_,statement:y,uri:b.href,version:"1",chainId:v,non
|
|
|
56
56
|
|
|
57
57
|
Check your Supabase project's API settings to find these values
|
|
58
58
|
|
|
59
|
-
https://supabase.com/dashboard/project/_/settings/api`);let{storage:n}=function(e,t){let r,s,n=e.cookies??null,i=e.cookieEncoding,a={},o={},l=()=>{let e=(0,rJ.parse)(document.cookie);return Object.keys(e).map(t=>({name:t,value:e[t]??""}))},u=e=>{e.forEach(({name:e,value:t,options:r})=>{document.cookie=(0,rJ.serialize)(e,t,r)})};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:i}=e[t];s?await n.set(r,s,i):await n.remove(r,i)}};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 if(!t&&rz())r=()=>l(),s=u;else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${rz()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""}`);else if(!t&&rz())r=()=>l(),s=u;else 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")};return t?{getAll:r,setAll:s,setItems:a,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof a[e])return a[e];if(o[e])return null;let t=await r([e]),s=await rZ(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?"string"!=typeof s?s:r6(s):null},setItem:async(t,n)=>{t.endsWith("-code-verifier")&&await r3({getAll:r,setAll:s,setItems:{[t]:n},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:i}),a[t]=n,delete o[t]},removeItem:async e=>{delete a[e],o[e]=!0}}}:{getAll:r,setAll:s,setItems:a,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await r([e]),s=await rZ(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?r6(s):null},setItem:async(t,n)=>{let a=await r([t]),o=new Set((a?.map(({name:e})=>e)||[]).filter(e=>rX(e,t))),l=n;"base64url"===i&&(l=r5+r8(n));let u=rQ(t,l);u.forEach(({name:e})=>{o.delete(e)});let h={...rV,...e?.cookieOptions,maxAge:0},c={...rV,...e?.cookieOptions,maxAge:rV.maxAge};delete h.name,delete c.name;let d=[...[...o].map(e=>({name:e,value:"",options:h})),...u.map(({name:e,value:t})=>({name:e,value:t,options:c}))];d.length>0&&await s(d,{})},removeItem:async t=>{let n=await r([t]),i=(n?.map(({name:e})=>e)||[]).filter(e=>rX(e,t)),a={...rV,...e?.cookieOptions,maxAge:0};delete a.name,i.length>0&&await s(i.map(e=>({name:e,value:"",options:a})),{})}}}}({...void 0,cookieEncoding:(void 0)??"base64url"},!1),i=new rW(e,t,{...void 0,global:{...void 0,headers:{...void 0,"X-Client-Info":"supabase-ssr/0.10.3 createBrowserClient"}},auth:{...void 0,...null,flowType:"pkce",autoRefreshToken:(void 0)??rz(),detectSessionInUrl:(void 0)??rz(),persistSession:(void 0)??!0,storage:n,...null}});return r&&(s=i),i}(t,e)}],83105)},46549,e=>{"use strict";let t=new Set,r="Settings saved",s=null,n=r;e.s(["SETTINGS_SAVED_DEFAULT_MESSAGE",0,r,"notify_settings_saved",0,function(e=r){n=e,null!==s&&clearTimeout(s),s=setTimeout(()=>{s=null;let e=n;t.forEach(t=>{t(e)})},200)},"subscribe_settings_saved",0,function(e){return t.add(e),()=>{t.delete(e)}}])},17798,e=>{"use strict";e.s(["apply_theme",0,function(e){document.documentElement.setAttribute("data-theme",e)}])},35434,e=>{"use strict";let t=new Set;e.s(["notify_theme_subscribers",0,function(){t.forEach(e=>{e()})},"subscribe_theme",0,function(e){return t.add(e),()=>{t.delete(e)}}])},27850,e=>{"use strict";var t=e.i(89497),r=e.i(32417);let s=null;e.s(["schedule_ui_preferences_cloud_sync",0,function(){(0,r.is_supabase_configured)()&&(null!==s&&clearTimeout(s),s=setTimeout(()=>{s=null,fetch("/api/ui-preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:(0,t.collect_ui_preferences_from_window)()})})},800))}])},34869,e=>{"use strict";var t=e.i(27850);e.s(["create_ui_preference_store",0,function(e){let{default_value:r,is_valid:s,storage_key:n}=e,i=new Set,a=()=>{try{let e=window.localStorage.getItem(n);if(null!==e&&s(e))return e}catch{}return r};return{storage_key:n,default_value:r,is_valid:s,read:a,write:e=>{try{window.localStorage.setItem(n,e),(0,t.schedule_ui_preferences_cloud_sync)()}catch{}},subscribe:e=>(i.add(e),()=>{i.delete(e)}),notify:()=>{i.forEach(e=>{e()})},get_snapshot:a,get_server_snapshot:()=>r}}])},10464,e=>{"use strict";var t=e.i(34869),r=e.i(92629);let s=(0,t.create_ui_preference_store)({storage_key:r.THEME_MODE_STORAGE_KEY,default_value:r.THEME_MODE_DEFAULT,is_valid:e=>"light"===e||"dark"===e||"system"===e});e.s(["theme_mode_preference",0,s])},81553,e=>{"use strict";var t=e.i(27850),r=e.i(38633);e.s(["write_stored_theme",0,function(e){try{window.localStorage.setItem(r.THEME_STORAGE_KEY,e),(0,t.schedule_ui_preferences_cloud_sync)()}catch{}}])}]);
|
|
59
|
+
https://supabase.com/dashboard/project/_/settings/api`);let{storage:i}=function(e,t){let r,s,i=e.cookies??null,n=e.cookieEncoding,a={},o={},l=()=>{let e=(0,rJ.parse)(document.cookie);return Object.keys(e).map(t=>({name:t,value:e[t]??""}))},u=e=>{e.forEach(({name:e,value:t,options:r})=>{document.cookie=(0,rJ.serialize)(e,t,r)})};if(i)if("get"in i){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 i.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 i&&"remove"in i)s=async e=>{for(let t=0;t<e.length;t+=1){let{name:r,value:s,options:n}=e[t];s?await i.set(r,s,n):await i.remove(r,n)}};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 i)if(r=async()=>await i.getAll(),"setAll"in i)s=i.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 if(!t&&rz())r=()=>l(),s=u;else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${rz()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""}`);else if(!t&&rz())r=()=>l(),s=u;else 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")};return t?{getAll:r,setAll:s,setItems:a,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof a[e])return a[e];if(o[e])return null;let t=await r([e]),s=await rZ(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?"string"!=typeof s?s:r6(s):null},setItem:async(t,i)=>{t.endsWith("-code-verifier")&&await r3({getAll:r,setAll:s,setItems:{[t]:i},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:n}),a[t]=i,delete o[t]},removeItem:async e=>{delete a[e],o[e]=!0}}}:{getAll:r,setAll:s,setItems:a,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await r([e]),s=await rZ(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return s?r6(s):null},setItem:async(t,i)=>{let a=await r([t]),o=new Set((a?.map(({name:e})=>e)||[]).filter(e=>rX(e,t))),l=i;"base64url"===n&&(l=r5+r8(i));let u=rQ(t,l);u.forEach(({name:e})=>{o.delete(e)});let h={...rV,...e?.cookieOptions,maxAge:0},c={...rV,...e?.cookieOptions,maxAge:rV.maxAge};delete h.name,delete c.name;let d=[...[...o].map(e=>({name:e,value:"",options:h})),...u.map(({name:e,value:t})=>({name:e,value:t,options:c}))];d.length>0&&await s(d,{})},removeItem:async t=>{let i=await r([t]),n=(i?.map(({name:e})=>e)||[]).filter(e=>rX(e,t)),a={...rV,...e?.cookieOptions,maxAge:0};delete a.name,n.length>0&&await s(n.map(e=>({name:e,value:"",options:a})),{})}}}}({...void 0,cookieEncoding:(void 0)??"base64url"},!1),n=new rW(e,t,{...void 0,global:{...void 0,headers:{...void 0,"X-Client-Info":"supabase-ssr/0.10.3 createBrowserClient"}},auth:{...void 0,...null,flowType:"pkce",autoRefreshToken:(void 0)??rz(),detectSessionInUrl:(void 0)??rz(),persistSession:(void 0)??!0,storage:i,...null}});return r&&(s=n),n}(t,e)}],83105)},17798,e=>{"use strict";e.s(["apply_theme",0,function(e){document.documentElement.setAttribute("data-theme",e)}])},92629,e=>{"use strict";e.s(["ACCENT_COLOR_DEFAULT",0,"teal","ACCENT_COLOR_STORAGE_KEY",0,"super-time-tracker-accent-color","ACCENT_COLOR_VALUES",0,["teal","blue","violet","rose","amber","emerald"],"CHECK_IN_FORM_COLLAPSED_DEFAULT",0,"false","CHECK_IN_FORM_COLLAPSED_STORAGE_KEY",0,"super-time-tracker-check-in-form-collapsed","CLEAR_TAG_FILTERS_ON_SHEET_CHANGE_DEFAULT",0,"false","CLEAR_TAG_FILTERS_ON_SHEET_CHANGE_STORAGE_KEY",0,"super-time-tracker-clear-tag-filters-on-sheet-change","COLOR_PALETTE_DEFAULT",0,"default","COLOR_PALETTE_STORAGE_KEY",0,"super-time-tracker-color-palette","COLOR_PALETTE_VALUES",0,["default","midnight","warm","ocean","forest","contrast","sunset","lavender","rose","slate","nord","dracula"],"CONFIRM_BEFORE_CHECKOUT_DEFAULT",0,"false","CONFIRM_BEFORE_CHECKOUT_STORAGE_KEY",0,"super-time-tracker-confirm-before-checkout","CONFIRM_DESTRUCTIVE_ACTIONS_DEFAULT",0,"true","CONFIRM_DESTRUCTIVE_ACTIONS_STORAGE_KEY",0,"super-time-tracker-confirm-destructive-actions","DEFAULT_REPORTING_RANGE_DEFAULT",0,"none","DEFAULT_REPORTING_RANGE_STORAGE_KEY",0,"super-time-tracker-default-reporting-range","DEFAULT_REPORTING_SORT_DEFAULT",0,"duration","DEFAULT_REPORTING_SORT_STORAGE_KEY",0,"super-time-tracker-default-reporting-sort","DURATION_FORMAT_DEFAULT",0,"humanized","DURATION_FORMAT_STORAGE_KEY",0,"super-time-tracker-duration-format","ENTRY_LIST_SORT_DEFAULT",0,"newest","ENTRY_LIST_SORT_STORAGE_KEY",0,"super-time-tracker-entry-list-sort","GREEDY_CLOUD_SYNC_DEFAULT",0,"true","GREEDY_CLOUD_SYNC_STORAGE_KEY",0,"super-time-tracker-greedy-cloud-sync","TAG_FILTER_MODE_DEFAULT",0,"all","TAG_FILTER_MODE_STORAGE_KEY",0,"super-time-tracker-tag-filter-mode","THEME_MODE_DEFAULT",0,"system","THEME_MODE_STORAGE_KEY",0,"super-time-tracker-theme-mode","TIMER_IN_TITLE_DEFAULT",0,"true","TIMER_IN_TITLE_STORAGE_KEY",0,"super-time-tracker-timer-in-title","TIMER_SHOW_SECONDS_DEFAULT",0,"false","TIMER_SHOW_SECONDS_STORAGE_KEY",0,"super-time-tracker-timer-show-seconds","TIME_FORMAT_DEFAULT",0,"12h","TIME_FORMAT_STORAGE_KEY",0,"super-time-tracker-time-format","WEEK_STARTS_ON_DEFAULT",0,"monday","WEEK_STARTS_ON_STORAGE_KEY",0,"super-time-tracker-week-starts-on"])},72550,e=>{"use strict";e.s(["ACTIVE_SHEET_COOKIE_NAME",0,"stt-active-sheet","ACTIVE_SHEET_STORAGE_KEY",0,"super-time-tracker-active-sheet","COMPACT_LISTS_STORAGE_KEY",0,"super-time-tracker-compact-lists","DEFAULT_SHEET_FIXED_NAME_COOKIE_NAME",0,"stt-default-sheet-fixed-name","DEFAULT_SHEET_FIXED_NAME_STORAGE_KEY",0,"super-time-tracker-default-sheet-fixed-name","DEFAULT_SHEET_SESSION_MODE_COOKIE_NAME",0,"stt-default-sheet-session-mode","DEFAULT_SHEET_SESSION_MODE_DEFAULT",0,"last_viewed","DEFAULT_SHEET_SESSION_MODE_STORAGE_KEY",0,"super-time-tracker-default-sheet-session-mode","SHEET_TAG_FILTERS_STORAGE_KEY",0,"super-time-tracker-sheet-tag-filters"])},89497,38633,e=>{"use strict";var t=e.i(92629),r=e.i(72550);let s="super-time-tracker-theme";e.s(["THEME_STORAGE_KEY",0,s],38633),e.s(["collect_ui_preferences_from_window",0,function(){let e={};for(let i of[t.ACCENT_COLOR_STORAGE_KEY,r.ACTIVE_SHEET_STORAGE_KEY,t.CHECK_IN_FORM_COLLAPSED_STORAGE_KEY,t.CLEAR_TAG_FILTERS_ON_SHEET_CHANGE_STORAGE_KEY,t.COLOR_PALETTE_STORAGE_KEY,r.COMPACT_LISTS_STORAGE_KEY,t.CONFIRM_BEFORE_CHECKOUT_STORAGE_KEY,t.CONFIRM_DESTRUCTIVE_ACTIONS_STORAGE_KEY,t.DEFAULT_REPORTING_RANGE_STORAGE_KEY,t.DEFAULT_REPORTING_SORT_STORAGE_KEY,r.DEFAULT_SHEET_FIXED_NAME_STORAGE_KEY,r.DEFAULT_SHEET_SESSION_MODE_STORAGE_KEY,t.DURATION_FORMAT_STORAGE_KEY,t.ENTRY_LIST_SORT_STORAGE_KEY,t.GREEDY_CLOUD_SYNC_STORAGE_KEY,r.SHEET_TAG_FILTERS_STORAGE_KEY,t.TAG_FILTER_MODE_STORAGE_KEY,t.THEME_MODE_STORAGE_KEY,s,t.TIME_FORMAT_STORAGE_KEY,t.TIMER_IN_TITLE_STORAGE_KEY,t.TIMER_SHOW_SECONDS_STORAGE_KEY,t.WEEK_STARTS_ON_STORAGE_KEY])try{let t=window.localStorage.getItem(i);null!==t&&(e[i]=t)}catch{}return e}],89497)},27850,13582,e=>{"use strict";var t=e.i(32417);let r=!1;var s=e.i(89497);function i(){if(!(0,t.is_supabase_configured)())return;let e=(0,s.collect_ui_preferences_from_window)();0!==Object.keys(e).length&&fetch("/api/ui-preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:e})})}let n=0;function a(){return n>0}async function o(e){n+=1;try{return await e()}finally{0==(n-=1)&&r&&(r=!1,1)&&i()}}e.s(["is_ui_preferences_merge_in_progress",0,a,"with_ui_preferences_merge_guard",0,o],13582);let l=null;e.s(["schedule_ui_preferences_cloud_sync",0,function(){if((0,t.is_supabase_configured)()){if(a())return void(r=!0);null!==l&&clearTimeout(l),l=setTimeout(()=>{l=null,i()},800)}}],27850)},34869,e=>{"use strict";var t=e.i(27850);e.s(["create_ui_preference_store",0,function(e){let{default_value:r,is_valid:s,storage_key:i}=e,n=new Set,a=()=>{try{let e=window.localStorage.getItem(i);if(null!==e&&s(e))return e}catch{}return r};return{storage_key:i,default_value:r,is_valid:s,read:a,write:e=>{try{window.localStorage.setItem(i,e),(0,t.schedule_ui_preferences_cloud_sync)()}catch{}},subscribe:e=>(n.add(e),()=>{n.delete(e)}),notify:()=>{n.forEach(e=>{e()})},get_snapshot:a,get_server_snapshot:()=>r}}])},10464,e=>{"use strict";var t=e.i(34869),r=e.i(92629);let s=(0,t.create_ui_preference_store)({storage_key:r.THEME_MODE_STORAGE_KEY,default_value:r.THEME_MODE_DEFAULT,is_valid:e=>"light"===e||"dark"===e||"system"===e});e.s(["theme_mode_preference",0,s])},61834,e=>{"use strict";e.s(["write_document_preference_cookies",0,function(e){if("u"<typeof document)return;let t="path=/; max-age=31536000; SameSite=Lax";void 0!==e.theme_mode&&(document.cookie=`stt-theme-mode=${e.theme_mode}; ${t}`),void 0!==e.theme&&(document.cookie=`stt-theme=${e.theme}; ${t}`),void 0!==e.palette&&(document.cookie=`stt-palette=${e.palette}; ${t}`),void 0!==e.compact_lists&&(document.cookie=`stt-compact-lists=${e.compact_lists?"true":"false"}; ${t}`)}],61834)},35434,e=>{"use strict";let t=new Set;e.s(["notify_theme_subscribers",0,function(){t.forEach(e=>{e()})},"subscribe_theme",0,function(e){return t.add(e),()=>{t.delete(e)}}])},46549,e=>{"use strict";let t=new Set,r="Settings saved",s=null,i=r;e.s(["SETTINGS_SAVED_DEFAULT_MESSAGE",0,r,"notify_settings_saved",0,function(e=r){i=e,null!==s&&clearTimeout(s),s=setTimeout(()=>{s=null;let e=i;t.forEach(t=>{t(e)})},200)},"subscribe_settings_saved",0,function(e){return t.add(e),()=>{t.delete(e)}}])},81553,e=>{"use strict";var t=e.i(27850),r=e.i(38633);e.s(["write_stored_theme",0,function(e){try{window.localStorage.setItem(r.THEME_STORAGE_KEY,e),(0,t.schedule_ui_preferences_cloud_sync)()}catch{}}])}]);
|