tanstack_start_ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.wrangler/deploy/config.json +1 -0
- package/bunfig.toml +6 -0
- package/components.json +22 -0
- package/config.json +0 -0
- package/dist/client/.assetsignore +2 -0
- package/dist/client/assets/ProductCard-DbIkJAE-.js +1 -0
- package/dist/client/assets/about-AskxOruL.js +1 -0
- package/dist/client/assets/admin-BZVcAQM3.js +1 -0
- package/dist/client/assets/admin.functions--RdVcuBx.js +1 -0
- package/dist/client/assets/admin.login-QgrF_9Fp.js +1 -0
- package/dist/client/assets/affiliate-disclosure-BIAsA-HO.js +1 -0
- package/dist/client/assets/categories-D0N418mK.js +1 -0
- package/dist/client/assets/category._slug-aCaQm14E.js +1 -0
- package/dist/client/assets/contact-PhvO-V15.js +1 -0
- package/dist/client/assets/faq-BsiHWPM8.js +1 -0
- package/dist/client/assets/hero-bg-BP2eVUIX.jpg +0 -0
- package/dist/client/assets/index-BU9rnkF3.js +1 -0
- package/dist/client/assets/index-BpJWZkva.js +1 -0
- package/dist/client/assets/index-vRX-zAyq.js +1 -0
- package/dist/client/assets/login-DteE0ZGp.js +1 -0
- package/dist/client/assets/logo-pSNfLJQk.png +0 -0
- package/dist/client/assets/privacy-B_Pu7040.js +1 -0
- package/dist/client/assets/product-links-BkZ41Gv3.js +1 -0
- package/dist/client/assets/product._id-BVUysCW-.js +1 -0
- package/dist/client/assets/products.functions-cGzRziKO.js +1 -0
- package/dist/client/assets/profile-CveRcKq2.js +1 -0
- package/dist/client/assets/reset-password-ySEjItX_.js +1 -0
- package/dist/client/assets/saved-CHtdQDJF.js +1 -0
- package/dist/client/assets/search-CXWfET1y.js +1 -0
- package/dist/client/assets/signup-CEx90iuV.js +1 -0
- package/dist/client/assets/styles-DrNJG0BO.css +1 -0
- package/dist/client/assets/terms-VqJ9kX9b.js +1 -0
- package/dist/client/assets/update-password-C-d0ix5e.js +1 -0
- package/dist/client/assets/vendor-aria-hidden-DvXkyWUv.js +1 -0
- package/dist/client/assets/vendor-class-variance-authority-5VPnzWs2.js +1 -0
- package/dist/client/assets/vendor-clsx-B-dksMZM.js +1 -0
- package/dist/client/assets/vendor-cookie-es-CS0aJGDi.js +1 -0
- package/dist/client/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
- package/dist/client/assets/vendor-floating-ui-core-BlUy28sp.js +1 -0
- package/dist/client/assets/vendor-floating-ui-dom-BxK0hn2R.js +1 -0
- package/dist/client/assets/vendor-floating-ui-react-dom-Bas3975S.js +1 -0
- package/dist/client/assets/vendor-floating-ui-utils-BfYUAVcw.js +1 -0
- package/dist/client/assets/vendor-framer-motion-BMdL-cuX.js +9 -0
- package/dist/client/assets/vendor-get-nonce-C-Z93AgS.js +1 -0
- package/dist/client/assets/vendor-iceberg-js-tWD4K6Lg.js +1 -0
- package/dist/client/assets/vendor-lovable.dev-cloud-auth-js-VuzqtJVg.js +1 -0
- package/dist/client/assets/vendor-lucide-react-b5K2fehp.js +1 -0
- package/dist/client/assets/vendor-motion-dom-BETJamZt.js +1 -0
- package/dist/client/assets/vendor-motion-utils-BuWewJbj.js +1 -0
- package/dist/client/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-accordion-C22Rgxe9.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-arrow-DMHj2mKI.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-avatar-CVPBkFXg.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-collapsible-BvM-4sKX.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-collection-D9KtqmHm.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-compose-refs-Cvq0AS8Z.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-context-CAqqn5Nx.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-dialog-DZ01vOLq.js +5 -0
- package/dist/client/assets/vendor-radix-ui-react-direction-DxZwNuei.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-dismissable-layer-Dqgrs55Y.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-dropdown-menu-0uzvrqkn.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-focus-guards-DgWoZ-fP.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-focus-scope-BLIu5QaL.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-id-bpga_rLa.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-menu-D0qf2r6_.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-popper-BafIylxU.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-portal-BnAsfNCS.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-presence-C-f3UKQ2.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-primitive-zTHwXNoz.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-roving-focus-jyJB8K2E.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-slot-6LXHJrHl.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-callback-ref-E91aPc6s.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-controllable-state-Ca3eMtxa.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-effect-event-CPeX4A3c.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-escape-keydown-7n3YsXFo.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-is-hydrated-C1PY1qNv.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-layout-effect-B3AcGWPy.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-size-CXS04sct.js +1 -0
- package/dist/client/assets/vendor-react-dom-BnNs-kzm.js +9 -0
- package/dist/client/assets/vendor-react-gJPiVnX5.js +1 -0
- package/dist/client/assets/vendor-react-remove-scroll-DHKl-IMP.js +4 -0
- package/dist/client/assets/vendor-react-remove-scroll-bar-CSjdInc2.js +38 -0
- package/dist/client/assets/vendor-react-style-singleton-BqHpkgXn.js +1 -0
- package/dist/client/assets/vendor-scheduler-7OC5HNn7.js +1 -0
- package/dist/client/assets/vendor-seroval-B_Fur-nl.js +3 -0
- package/dist/client/assets/vendor-seroval-plugins-CBHnPkZJ.js +1 -0
- package/dist/client/assets/vendor-sonner-71-LdGG1.js +1 -0
- package/dist/client/assets/vendor-supabase-auth-js-DWrN-bIx.js +18 -0
- package/dist/client/assets/vendor-supabase-functions-js-uY_V-TxC.js +1 -0
- package/dist/client/assets/vendor-supabase-phoenix-BzEf37Ve.js +2 -0
- package/dist/client/assets/vendor-supabase-postgrest-js-C4rBWbCx.js +4 -0
- package/dist/client/assets/vendor-supabase-realtime-js-D6BlOYKE.js +23 -0
- package/dist/client/assets/vendor-supabase-storage-js-BG98L3Zz.js +1 -0
- package/dist/client/assets/vendor-supabase-supabase-js-DCCzdwBJ.js +1 -0
- package/dist/client/assets/vendor-tailwind-merge-Ct12j0u0.js +1 -0
- package/dist/client/assets/vendor-tanstack-history-C617CaxG.js +1 -0
- package/dist/client/assets/vendor-tanstack-query-core-7wuJJ5ZL.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-query-HImzo8sX.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-router-sIZLK-LU.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-start-client-GiYCfWmf.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-store-EvTi3ahh.js +1 -0
- package/dist/client/assets/vendor-tanstack-router-core-Cr7bYUZv.js +1 -0
- package/dist/client/assets/vendor-tanstack-start-client-core-C-00BBOu.js +2 -0
- package/dist/client/assets/vendor-tanstack-start-fn-stubs-l0sNRNKZ.js +1 -0
- package/dist/client/assets/vendor-tanstack-store-BC7mA7pq.js +1 -0
- package/dist/client/assets/vendor-tslib-Du-meQkk.js +1 -0
- package/dist/client/assets/vendor-use-callback-ref-C_fIAtot.js +1 -0
- package/dist/client/assets/vendor-use-sidecar-Bh0DDN6h.js +1 -0
- package/dist/client/assets/vendor-use-sync-external-store-ZvKHXaIn.js +1 -0
- package/dist/client/assets/vendor-vercel-analytics-DwPM5BWs.js +1 -0
- package/dist/client/assets/vendor-zod-By9teAtI.js +1 -0
- package/dist/client/robots.txt +2 -0
- package/dist/server/.dev.vars +5 -0
- package/dist/server/.vite/manifest.json +2528 -0
- package/dist/server/assets/ProductCard-CUPXy5Eo.js +149 -0
- package/dist/server/assets/_tanstack-start-manifest_v-do7vTWFD.js +4 -0
- package/dist/server/assets/about-TfKQw0Ga.js +28 -0
- package/dist/server/assets/admin-DspfJOJk.js +578 -0
- package/dist/server/assets/admin.functions-B78ppWLR.js +645 -0
- package/dist/server/assets/admin.functions-BWlKBoTL.js +93 -0
- package/dist/server/assets/admin.login-CV7QfeA6.js +139 -0
- package/dist/server/assets/affiliate-disclosure-B1wI1cDb.js +86 -0
- package/dist/server/assets/auth-middleware-Cn49MidW.js +62 -0
- package/dist/server/assets/categories-Z7jnAYZP.js +108 -0
- package/dist/server/assets/category._slug-D0XY3FGK.js +112 -0
- package/dist/server/assets/contact-IzyONsXs.js +104 -0
- package/dist/server/assets/faq-aRhB_CR3.js +133 -0
- package/dist/server/assets/hero-bg-BP2eVUIX.jpg +0 -0
- package/dist/server/assets/index-BTPHbXw9.js +221 -0
- package/dist/server/assets/index-ByJkHkrU.js +30 -0
- package/dist/server/assets/login-Dvy5Dm0f.js +175 -0
- package/dist/server/assets/logo-pSNfLJQk.png +0 -0
- package/dist/server/assets/privacy-B6Wiez1P.js +93 -0
- package/dist/server/assets/product-links-CGYEPP56.js +16 -0
- package/dist/server/assets/product._id-BpRa-1z0.js +231 -0
- package/dist/server/assets/products.functions-DSlmibYN.js +209 -0
- package/dist/server/assets/products.functions-DlHkRiqi.js +24 -0
- package/dist/server/assets/profile-B0NWzVAZ.js +314 -0
- package/dist/server/assets/reset-password-CY-rmqMr.js +115 -0
- package/dist/server/assets/saved-7FA6Dbom.js +126 -0
- package/dist/server/assets/search-Yw5c_fZa.js +329 -0
- package/dist/server/assets/signup-UPzgZo4i.js +143 -0
- package/dist/server/assets/styles-DrNJG0BO.css +1 -0
- package/dist/server/assets/terms-CMnX95bP.js +89 -0
- package/dist/server/assets/update-password-Cr94ea8n.js +131 -0
- package/dist/server/assets/vendor-aria-hidden-DPa16MWu.js +122 -0
- package/dist/server/assets/vendor-class-variance-authority-0YxJPB9Y.js +44 -0
- package/dist/server/assets/vendor-cloudflare-unenv-preset-ya0VEFBz.js +250 -0
- package/dist/server/assets/vendor-clsx-DgYk2OaC.js +16 -0
- package/dist/server/assets/vendor-cookie-es-DAoofYiI.js +44 -0
- package/dist/server/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
- package/dist/server/assets/vendor-floating-ui-core-3tkK0THV.js +726 -0
- package/dist/server/assets/vendor-floating-ui-dom-C-cPtgJv.js +626 -0
- package/dist/server/assets/vendor-floating-ui-react-dom-CRG6gBpH.js +319 -0
- package/dist/server/assets/vendor-floating-ui-utils-DmXANH-E.js +320 -0
- package/dist/server/assets/vendor-framer-motion-X4zAkX3J.js +1979 -0
- package/dist/server/assets/vendor-get-nonce-DiSj3EHl.js +9 -0
- package/dist/server/assets/vendor-h3-v2-CCobnLY5.js +287 -0
- package/dist/server/assets/vendor-iceberg-js-bHCkXyJn.js +534 -0
- package/dist/server/assets/vendor-isbot-CZ7WjwVs.js +21 -0
- package/dist/server/assets/vendor-lovable.dev-cloud-auth-js-BE03njZw.js +180 -0
- package/dist/server/assets/vendor-lucide-react-Ddew6HYb.js +458 -0
- package/dist/server/assets/vendor-motion-dom-D2MTwGIG.js +5983 -0
- package/dist/server/assets/vendor-motion-utils-LJlIFN6m.js +161 -0
- package/dist/server/assets/vendor-radix-ui-primitive-B-mNdDrH.js +11 -0
- package/dist/server/assets/vendor-radix-ui-react-accordion-1Izf6x00.js +308 -0
- package/dist/server/assets/vendor-radix-ui-react-arrow-B882lnFK.js +23 -0
- package/dist/server/assets/vendor-radix-ui-react-avatar-BVgZt2Ab.js +209 -0
- package/dist/server/assets/vendor-radix-ui-react-collapsible-DCBbMZiS.js +147 -0
- package/dist/server/assets/vendor-radix-ui-react-collection-BZ2srfgU.js +150 -0
- package/dist/server/assets/vendor-radix-ui-react-compose-refs-D3qsKVk1.js +39 -0
- package/dist/server/assets/vendor-radix-ui-react-context-BVoNDLue.js +78 -0
- package/dist/server/assets/vendor-radix-ui-react-dialog-DlxMaNYK.js +406 -0
- package/dist/server/assets/vendor-radix-ui-react-direction-Dt_WDL1t.js +9 -0
- package/dist/server/assets/vendor-radix-ui-react-dismissable-layer-CjsuPohV.js +210 -0
- package/dist/server/assets/vendor-radix-ui-react-dropdown-menu-DVxKumY8.js +263 -0
- package/dist/server/assets/vendor-radix-ui-react-focus-guards-D_6NoePE.js +29 -0
- package/dist/server/assets/vendor-radix-ui-react-focus-scope-DEIhTJJH.js +206 -0
- package/dist/server/assets/vendor-radix-ui-react-id-DFFpgh6m.js +14 -0
- package/dist/server/assets/vendor-radix-ui-react-menu-CiTMLwjT.js +893 -0
- package/dist/server/assets/vendor-radix-ui-react-popper-23Ye2Vyc.js +286 -0
- package/dist/server/assets/vendor-radix-ui-react-portal-CZCH5uPk.js +16 -0
- package/dist/server/assets/vendor-radix-ui-react-presence-CaAULlDU.js +128 -0
- package/dist/server/assets/vendor-radix-ui-react-primitive-BeOk3UYa.js +124 -0
- package/dist/server/assets/vendor-radix-ui-react-roving-focus-DES9GR8l.js +224 -0
- package/dist/server/assets/vendor-radix-ui-react-slot-DUhZbzoH.js +103 -0
- package/dist/server/assets/vendor-radix-ui-react-use-callback-ref-BynBgohw.js +11 -0
- package/dist/server/assets/vendor-radix-ui-react-use-controllable-state-C9KpT6DG.js +69 -0
- package/dist/server/assets/vendor-radix-ui-react-use-effect-event-gpNY2xjS.js +1 -0
- package/dist/server/assets/vendor-radix-ui-react-use-escape-keydown-CcYRQ2pp.js +17 -0
- package/dist/server/assets/vendor-radix-ui-react-use-is-hydrated-D_LcBPXY.js +15 -0
- package/dist/server/assets/vendor-radix-ui-react-use-layout-effect-1LNLXAjr.js +6 -0
- package/dist/server/assets/vendor-radix-ui-react-use-size-D6fiKJQo.js +39 -0
- package/dist/server/assets/vendor-react-DvBrY0qp.js +511 -0
- package/dist/server/assets/vendor-react-dom-yvMLPM0j.js +10484 -0
- package/dist/server/assets/vendor-react-remove-scroll-BNtiEvVN.js +328 -0
- package/dist/server/assets/vendor-react-remove-scroll-bar-hLqRASRk.js +82 -0
- package/dist/server/assets/vendor-react-style-singleton-BXjcXskB.js +69 -0
- package/dist/server/assets/vendor-rou3-3NaGPdI8.js +8 -0
- package/dist/server/assets/vendor-seroval-dJyC-Zhz.js +1775 -0
- package/dist/server/assets/vendor-seroval-plugins-Pq_U2meB.js +58 -0
- package/dist/server/assets/vendor-sonner-CqbjhsRh.js +1086 -0
- package/dist/server/assets/vendor-srvx-BA-baEX9.js +6 -0
- package/dist/server/assets/vendor-supabase-auth-js-D4xjVprw.js +7602 -0
- package/dist/server/assets/vendor-supabase-functions-js-sWy4UYn1.js +322 -0
- package/dist/server/assets/vendor-supabase-phoenix-Bw3Uh2Nn.js +1777 -0
- package/dist/server/assets/vendor-supabase-postgrest-js-AO-BXa7I.js +4938 -0
- package/dist/server/assets/vendor-supabase-realtime-js-BtdNgJbm.js +2111 -0
- package/dist/server/assets/vendor-supabase-storage-js-Dk_MrPYO.js +2679 -0
- package/dist/server/assets/vendor-supabase-supabase-js-D1EEtG3j.js +697 -0
- package/dist/server/assets/vendor-tailwind-merge-BHb_obmC.js +3255 -0
- package/dist/server/assets/vendor-tanstack-history-C4pKJmkt.js +204 -0
- package/dist/server/assets/vendor-tanstack-query-core-PwwTR5ld.js +2552 -0
- package/dist/server/assets/vendor-tanstack-react-query-hhHzXAK1.js +190 -0
- package/dist/server/assets/vendor-tanstack-react-router-XzqpA65A.js +1120 -0
- package/dist/server/assets/vendor-tanstack-react-start-RvWUpvat.js +37 -0
- package/dist/server/assets/vendor-tanstack-react-start-client-gpNY2xjS.js +1 -0
- package/dist/server/assets/vendor-tanstack-react-start-server-uj_Y9pEN.js +15 -0
- package/dist/server/assets/vendor-tanstack-react-store-gpNY2xjS.js +1 -0
- package/dist/server/assets/vendor-tanstack-router-core-6wywV3KN.js +4252 -0
- package/dist/server/assets/vendor-tanstack-start-client-core-DoOKV2pA.js +1741 -0
- package/dist/server/assets/vendor-tanstack-start-fn-stubs-l0sNRNKZ.js +1 -0
- package/dist/server/assets/vendor-tanstack-start-server-core-CsAstXv7.js +1421 -0
- package/dist/server/assets/vendor-tanstack-start-storage-context-DgH9hIJT.js +17 -0
- package/dist/server/assets/vendor-tanstack-store-l0sNRNKZ.js +1 -0
- package/dist/server/assets/vendor-tslib-_8ICaZ64.js +67 -0
- package/dist/server/assets/vendor-unenv-DUvF4YIF.js +544 -0
- package/dist/server/assets/vendor-use-callback-ref-DMFDRvmi.js +66 -0
- package/dist/server/assets/vendor-use-sidecar-DG1tHua4.js +106 -0
- package/dist/server/assets/vendor-use-sync-external-store-rZ8vi0It.js +64 -0
- package/dist/server/assets/vendor-vercel-analytics-oP8BDp0L.js +168 -0
- package/dist/server/assets/vendor-zod-BRyQdbC-.js +3580 -0
- package/dist/server/index.js +158 -0
- package/dist/server/wrangler.json +1 -0
- package/enable-powershell.ps1 +7 -0
- package/eslint.config.js +41 -0
- package/lint.bat +4 -0
- package/package.json +95 -0
- package/public/robots.txt +2 -0
- package/run-npm-build.cjs +20 -0
- package/run-npm-build.js +20 -0
- package/src/assets/hero-bg.jpg +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/scrollsy/Footer.tsx +68 -0
- package/src/components/scrollsy/LiveTicker.tsx +31 -0
- package/src/components/scrollsy/Logo.tsx +28 -0
- package/src/components/scrollsy/Nav.tsx +255 -0
- package/src/components/scrollsy/ProductCard.tsx +190 -0
- package/src/components/scrollsy/ProductFilters.tsx +226 -0
- package/src/components/scrollsy/SupportWidget.tsx +197 -0
- package/src/components/ui/accordion.tsx +51 -0
- package/src/components/ui/alert-dialog.tsx +115 -0
- package/src/components/ui/alert.tsx +49 -0
- package/src/components/ui/aspect-ratio.tsx +5 -0
- package/src/components/ui/avatar.tsx +47 -0
- package/src/components/ui/badge.tsx +32 -0
- package/src/components/ui/breadcrumb.tsx +101 -0
- package/src/components/ui/button.tsx +49 -0
- package/src/components/ui/calendar.tsx +177 -0
- package/src/components/ui/card.tsx +55 -0
- package/src/components/ui/carousel.tsx +240 -0
- package/src/components/ui/chart.tsx +331 -0
- package/src/components/ui/checkbox.tsx +26 -0
- package/src/components/ui/collapsible.tsx +11 -0
- package/src/components/ui/command.tsx +143 -0
- package/src/components/ui/context-menu.tsx +187 -0
- package/src/components/ui/dialog.tsx +104 -0
- package/src/components/ui/drawer.tsx +98 -0
- package/src/components/ui/dropdown-menu.tsx +188 -0
- package/src/components/ui/form.tsx +171 -0
- package/src/components/ui/hover-card.tsx +27 -0
- package/src/components/ui/input-otp.tsx +69 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +21 -0
- package/src/components/ui/menubar.tsx +229 -0
- package/src/components/ui/navigation-menu.tsx +120 -0
- package/src/components/ui/pagination.tsx +98 -0
- package/src/components/ui/popover.tsx +31 -0
- package/src/components/ui/progress.tsx +25 -0
- package/src/components/ui/radio-group.tsx +36 -0
- package/src/components/ui/resizable.tsx +37 -0
- package/src/components/ui/scroll-area.tsx +44 -0
- package/src/components/ui/select.tsx +152 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +122 -0
- package/src/components/ui/sidebar.tsx +744 -0
- package/src/components/ui/skeleton.tsx +7 -0
- package/src/components/ui/slider.tsx +23 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +94 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/textarea.tsx +21 -0
- package/src/components/ui/toggle-group.tsx +57 -0
- package/src/components/ui/toggle.tsx +42 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/hooks/use-auth.ts +26 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/integrations/lovable/index.ts +41 -0
- package/src/lib/admin.functions.ts +564 -0
- package/src/lib/error-capture.ts +27 -0
- package/src/lib/error-page.ts +30 -0
- package/src/lib/product-links.ts +39 -0
- package/src/lib/products.functions.ts +101 -0
- package/src/lib/utils.ts +6 -0
- package/src/routeTree.gen.ts +480 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +177 -0
- package/src/routes/about.tsx +66 -0
- package/src/routes/admin.login.tsx +95 -0
- package/src/routes/admin.tsx +811 -0
- package/src/routes/affiliate-disclosure.tsx +35 -0
- package/src/routes/categories.tsx +57 -0
- package/src/routes/category.$slug.tsx +51 -0
- package/src/routes/contact.tsx +69 -0
- package/src/routes/faq.tsx +63 -0
- package/src/routes/index.tsx +269 -0
- package/src/routes/login.tsx +160 -0
- package/src/routes/privacy.tsx +39 -0
- package/src/routes/product.$id.tsx +212 -0
- package/src/routes/profile.tsx +393 -0
- package/src/routes/reset-password.tsx +71 -0
- package/src/routes/saved.tsx +83 -0
- package/src/routes/search.tsx +136 -0
- package/src/routes/signup.tsx +108 -0
- package/src/routes/sitemap[.]xml.ts +34 -0
- package/src/routes/terms.tsx +40 -0
- package/src/routes/update-password.tsx +91 -0
- package/src/server.ts +80 -0
- package/src/start.ts +24 -0
- package/src/styles.css +333 -0
- package/terminal-test-output.txt +1 -0
- package/tsconfig.json +27 -0
- package/vercel.json +26 -0
- package/vite.config.ts +38 -0
- package/wrangler.jsonc +7 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var _e=(e=>(e[e.AggregateError=1]="AggregateError",e[e.ArrowFunction=2]="ArrowFunction",e[e.ErrorPrototypeStack=4]="ErrorPrototypeStack",e[e.ObjectAssign=8]="ObjectAssign",e[e.BigIntTypedArray=16]="BigIntTypedArray",e[e.RegExp=32]="RegExp",e))(_e||{}),d=Symbol.asyncIterator,q=Symbol.hasInstance,x=Symbol.isConcatSpreadable,g=Symbol.iterator,H=Symbol.match,J=Symbol.matchAll,W=Symbol.replace,X=Symbol.search,Z=Symbol.species,K=Symbol.split,ee=Symbol.toPrimitive,O=Symbol.toStringTag,re=Symbol.unscopables,te={[d]:0,[q]:1,[x]:2,[g]:3,[H]:4,[J]:5,[W]:6,[X]:7,[Z]:8,[K]:9,[ee]:10,[O]:11,[re]:12},Ie={0:d,1:q,2:x,3:g,4:H,5:J,6:W,7:X,8:Z,9:K,10:ee,11:O,12:re},n=void 0,Se={2:!0,3:!1,1:n,0:null,4:-0,5:Number.POSITIVE_INFINITY,6:Number.NEGATIVE_INFINITY,7:Number.NaN},xe={0:"Error",1:"EvalError",2:"RangeError",3:"ReferenceError",4:"SyntaxError",5:"TypeError",6:"URIError"},Oe={0:Error,1:EvalError,2:RangeError,3:ReferenceError,4:SyntaxError,5:TypeError,6:URIError};function f(e,r,t,a,u,s,i,o,c,y,l,p){return{t:e,i:r,s:t,c:a,m:u,p:s,e:i,a:o,f:c,b:y,o:l,l:p}}function E(e){return f(2,n,e,n,n,n,n,n,n,n,n,n)}var ne=E(2),ae=E(3),Re=E(1),je=E(0),Ne=E(4),Ue=E(5),Fe=E(6),Te=E(7);function Pe(e){switch(e){case'"':return'\\"';case"\\":return"\\\\";case`
|
|
2
|
+
`:return"\\n";case"\r":return"\\r";case"\b":return"\\b";case" ":return"\\t";case"\f":return"\\f";case"<":return"\\x3C";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return n}}function A(e){let r="",t=0,a;for(let u=0,s=e.length;u<s;u++)a=Pe(e[u]),a&&(r+=e.slice(t,u)+a,t=u+1);return t===0?r=e:r+=e.slice(t),r}function ke(e){switch(e){case"\\\\":return"\\";case'\\"':return'"';case"\\n":return`
|
|
3
|
+
`;case"\\r":return"\r";case"\\b":return"\b";case"\\t":return" ";case"\\f":return"\f";case"\\x3C":return"<";case"\\u2028":return"\u2028";case"\\u2029":return"\u2029";default:return e}}function _(e){return e.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g,ke)}var N="__SEROVAL_REFS__",ue=new Map,S=new Map;function se(e){return ue.has(e)}function Ce(e){return S.has(e)}function Le(e){if(se(e))return ue.get(e);throw new br(e)}function Be(e){if(Ce(e))return S.get(e);throw new wr(e)}typeof globalThis<"u"?Object.defineProperty(globalThis,N,{value:S,configurable:!0,writable:!1,enumerable:!1}):typeof window<"u"?Object.defineProperty(window,N,{value:S,configurable:!0,writable:!1,enumerable:!1}):typeof self<"u"?Object.defineProperty(self,N,{value:S,configurable:!0,writable:!1,enumerable:!1}):typeof global<"u"&&Object.defineProperty(global,N,{value:S,configurable:!0,writable:!1,enumerable:!1});function V(e){return e instanceof EvalError?1:e instanceof RangeError?2:e instanceof ReferenceError?3:e instanceof SyntaxError?4:e instanceof TypeError?5:e instanceof URIError?6:0}function Ve(e){let r=xe[V(e)];return e.name!==r?{name:e.name}:e.constructor.name!==r?{name:e.constructor.name}:{}}function ie(e,r){let t=Ve(e),a=Object.getOwnPropertyNames(e);for(let u=0,s=a.length,i;u<s;u++)i=a[u],i!=="name"&&i!=="message"&&(i==="stack"?r&4&&(t=t||{},t[i]=e[i]):(t=t||{},t[i]=e[i]));return t}function oe(e){return Object.isFrozen(e)?3:Object.isSealed(e)?2:Object.isExtensible(e)?0:1}function Me(e){switch(e){case Number.POSITIVE_INFINITY:return Ue;case Number.NEGATIVE_INFINITY:return Fe}return e!==e?Te:Object.is(e,-0)?Ne:f(0,n,e,n,n,n,n,n,n,n,n,n)}function ce(e){return f(1,n,A(e),n,n,n,n,n,n,n,n,n)}function ze(e){return f(3,n,""+e,n,n,n,n,n,n,n,n,n)}function De(e){return f(4,e,n,n,n,n,n,n,n,n,n,n)}function Ye(e,r){let t=r.valueOf();return f(5,e,t!==t?"":r.toISOString(),n,n,n,n,n,n,n,n,n)}function Ge(e,r){return f(6,e,n,A(r.source),r.flags,n,n,n,n,n,n,n)}function Qe(e,r){return f(17,e,te[r],n,n,n,n,n,n,n,n,n)}function $e(e,r){return f(18,e,A(Le(r)),n,n,n,n,n,n,n,n,n)}function qe(e,r,t){return f(25,e,t,A(r),n,n,n,n,n,n,n,n)}function He(e,r,t){return f(9,e,n,n,n,n,n,t,n,n,oe(r),n)}function Je(e,r){return f(21,e,n,n,n,n,n,n,r,n,n,n)}function We(e,r,t){return f(15,e,n,r.constructor.name,n,n,n,n,t,r.byteOffset,n,r.length)}function Xe(e,r,t){return f(16,e,n,r.constructor.name,n,n,n,n,t,r.byteOffset,n,r.byteLength)}function Ze(e,r,t){return f(20,e,n,n,n,n,n,n,t,r.byteOffset,n,r.byteLength)}function Ke(e,r,t){return f(13,e,V(r),n,A(r.message),t,n,n,n,n,n,n)}function er(e,r,t){return f(14,e,V(r),n,A(r.message),t,n,n,n,n,n,n)}function rr(e,r){return f(7,e,n,n,n,n,n,r,n,n,n,n)}function tr(e,r){return f(28,n,n,n,n,n,n,[e,r],n,n,n,n)}function nr(e,r){return f(30,n,n,n,n,n,n,[e,r],n,n,n,n)}function ar(e,r,t){return f(31,e,n,n,n,n,n,t,r,n,n,n)}function ur(e,r){return f(32,e,n,n,n,n,n,n,r,n,n,n)}function sr(e,r){return f(33,e,n,n,n,n,n,n,r,n,n,n)}function ir(e,r){return f(34,e,n,n,n,n,n,n,r,n,n,n)}function or(e,r,t,a){return f(35,e,t,n,n,n,n,r,n,n,n,a)}var cr={parsing:1,serialization:2,deserialization:3};function fr(e){return`Seroval Error (step: ${cr[e]})`}var lr=(e,r)=>fr(e),fe=class extends Error{constructor(e,r){super(lr(e)),this.cause=r}},G=class extends fe{constructor(e){super("parsing",e)}},hr=class extends fe{constructor(e){super("deserialization",e)}};function v(e){return`Seroval Error (specific: ${e})`}var F=class extends Error{constructor(e){super(v(1)),this.value=e}},le=class extends Error{constructor(e){super(v(2))}},pr=class extends Error{constructor(e){super(v(3))}},R=class extends Error{constructor(e){super(v(4))}},br=class extends Error{constructor(e){super(v(5)),this.value=e}},wr=class extends Error{constructor(e){super(v(6))}},yr=class extends Error{constructor(e){super(v(7))}},m=class extends Error{constructor(e){super(v(8))}},dr=class extends Error{constructor(e){super(v(9))}},gr=class{constructor(e,r){this.value=e,this.replacement=r}},P=()=>{let e={p:0,s:0,f:0};return e.p=new Promise((r,t)=>{e.s=r,e.f=t}),e},vr=(e,r)=>{e.s(r),e.p.s=1,e.p.v=r},mr=(e,r)=>{e.f(r),e.p.s=2,e.p.v=r};P.toString();vr.toString();mr.toString();var Er=()=>{let e=[],r=[],t=!0,a=!1,u=0,s=(c,y,l)=>{for(l=0;l<u;l++)r[l]&&r[l][y](c)},i=(c,y,l,p)=>{for(y=0,l=e.length;y<l;y++)p=e[y],!t&&y===l-1?c[a?"return":"throw"](p):c.next(p)},o=(c,y)=>(t&&(y=u++,r[y]=c),i(c),()=>{t&&(r[y]=r[u],r[u--]=void 0)});return{__SEROVAL_STREAM__:!0,on:c=>o(c),next:c=>{t&&(e.push(c),s(c,"next"))},throw:c=>{t&&(e.push(c),s(c,"throw"),t=!1,a=!1,r.length=0)},return:c=>{t&&(e.push(c),s(c,"return"),t=!1,a=!0,r.length=0)}}},Ar=e=>r=>()=>{let t=0,a={[e]:()=>a,next:()=>{if(t>r.d)return{done:!0,value:void 0};let u=t++,s=r.v[u];if(u===r.t)throw s;return{done:u===r.d,value:s}}};return a},_r=(e,r)=>t=>()=>{let a=0,u=-1,s=!1,i=[],o=[],c=(l=0,p=o.length)=>{for(;l<p;l++)o[l].s({done:!0,value:void 0})};t.on({next:l=>{let p=o.shift();p&&p.s({done:!1,value:l}),i.push(l)},throw:l=>{let p=o.shift();p&&p.f(l),c(),u=i.length,s=!0,i.push(l)},return:l=>{let p=o.shift();p&&p.s({done:!0,value:l}),c(),u=i.length,i.push(l)}});let y={[e]:()=>y,next:()=>{if(u===-1){let D=a++;if(D>=i.length){let Y=r();return o.push(Y),Y.p}return{done:!1,value:i[D]}}if(a>u)return{done:!0,value:void 0};let l=a++,p=i[l];if(l!==u)return{done:!1,value:p};if(s)throw p;return{done:!0,value:p}}};return y},he=e=>{let r=atob(e),t=r.length,a=new Uint8Array(t);for(let u=0;u<t;u++)a[u]=r.charCodeAt(u);return a.buffer};he.toString();function Ir(e){return"__SEROVAL_SEQUENCE__"in e}function pe(e,r,t){return{__SEROVAL_SEQUENCE__:!0,v:e,t:r,d:t}}function Sr(e){let r=[],t=-1,a=-1,u=e[g]();for(;;)try{let s=u.next();if(r.push(s.value),s.done){a=r.length-1;break}}catch(s){t=r.length,r.push(s)}return pe(r,t,a)}var xr=Ar(g);function Or(e){return xr(e)}var Rr={},jr={},Nr={0:{},1:{},2:{},3:{},4:{},5:{}};function Ur(e){return"__SEROVAL_STREAM__"in e}function be(){return Er()}function Fr(e){let r=be(),t=e[d]();async function a(){try{let u=await t.next();u.done?r.return(u.value):(r.next(u.value),await a())}catch(u){r.throw(u)}}return a().catch(()=>{}),r}var Tr=_r(d,P);function Pr(e){return Tr(e)}async function kr(e){try{return[1,await e]}catch(r){return[0,r]}}function Cr(e,r){return{plugins:r.plugins,mode:e,marked:new Set,features:63^(r.disabledFeatures||0),refs:r.refs||new Map,depthLimit:r.depthLimit||1e3}}function U(e,r){e.marked.add(r)}function Lr(e,r){let t=e.refs.size;return e.refs.set(r,t),t}function k(e,r){let t=e.refs.get(r);return t!=null?(U(e,t),{type:1,value:De(t)}):{type:0,value:Lr(e,r)}}function M(e,r){let t=k(e,r);return t.type===1?t:se(r)?{type:2,value:$e(t.value,r)}:t}function I(e,r){let t=M(e,r);if(t.type!==0)return t.value;if(r in te)return Qe(t.value,r);throw new F(r)}function C(e,r){let t=k(e,Nr[r]);return t.type===1?t.value:f(26,t.value,r,n,n,n,n,n,n,n,n,n)}function Br(e){let r=k(e,Rr);return r.type===1?r.value:f(27,r.value,n,n,n,n,n,n,I(e,g),n,n,n)}function Vr(e){let r=k(e,jr);return r.type===1?r.value:f(29,r.value,n,n,n,n,n,[C(e,1),I(e,d)],n,n,n,n)}function Mr(e,r,t,a){return f(t?11:10,e,n,n,n,a,n,n,n,n,oe(r),n)}function zr(e,r,t,a){return f(8,r,n,n,n,n,{k:t,v:a},n,C(e,0),n,n,n)}function Dr(e,r,t){let a=new Uint8Array(t),u="";for(let s=0,i=a.length;s<i;s++)u+=String.fromCharCode(a[s]);return f(19,r,A(btoa(u)),n,n,n,n,n,C(e,5),n,n,n)}function Yr(e,r){return{base:Cr(e,r),child:void 0}}var Gr=class{constructor(e,r){this._p=e,this.depth=r}parse(e){return b(this._p,this.depth,e)}};async function Qr(e,r,t){let a=[];for(let u=0,s=t.length;u<s;u++)u in t?a[u]=await b(e,r,t[u]):a[u]=0;return a}async function $r(e,r,t,a){return He(t,a,await Qr(e,r,a))}async function z(e,r,t){let a=Object.entries(t),u=[],s=[];for(let i=0,o=a.length;i<o;i++)u.push(A(a[i][0])),s.push(await b(e,r,a[i][1]));return g in t&&(u.push(I(e.base,g)),s.push(tr(Br(e.base),await b(e,r,Sr(t))))),d in t&&(u.push(I(e.base,d)),s.push(nr(Vr(e.base),await b(e,r,Fr(t))))),O in t&&(u.push(I(e.base,O)),s.push(ce(t[O]))),x in t&&(u.push(I(e.base,x)),s.push(t[x]?ne:ae)),{k:u,v:s}}async function L(e,r,t,a,u){return Mr(t,a,u,await z(e,r,a))}async function qr(e,r,t,a){return Je(t,await b(e,r,a.valueOf()))}async function Hr(e,r,t,a){return We(t,a,await b(e,r,a.buffer))}async function Jr(e,r,t,a){return Xe(t,a,await b(e,r,a.buffer))}async function Wr(e,r,t,a){return Ze(t,a,await b(e,r,a.buffer))}async function Q(e,r,t,a){let u=ie(a,e.base.features);return Ke(t,a,u?await z(e,r,u):n)}async function Xr(e,r,t,a){let u=ie(a,e.base.features);return er(t,a,u?await z(e,r,u):n)}async function Zr(e,r,t,a){let u=[],s=[];for(let[i,o]of a.entries())u.push(await b(e,r,i)),s.push(await b(e,r,o));return zr(e.base,t,u,s)}async function Kr(e,r,t,a){let u=[];for(let s of a.keys())u.push(await b(e,r,s));return rr(t,u)}async function we(e,r,t,a){let u=e.base.plugins;if(u)for(let s=0,i=u.length;s<i;s++){let o=u[s];if(o.parse.async&&o.test(a))return qe(t,o.tag,await o.parse.async(a,new Gr(e,r),{id:t}))}return n}async function et(e,r,t,a){let[u,s]=await kr(a);return f(12,t,u,n,n,n,n,n,await b(e,r,s),n,n,n)}function rt(e,r,t,a,u){let s=[],i=t.on({next:o=>{U(this.base,r),b(this,e,o).then(c=>{s.push(ur(r,c))},c=>{u(c),i()})},throw:o=>{U(this.base,r),b(this,e,o).then(c=>{s.push(sr(r,c)),a(s),i()},c=>{u(c),i()})},return:o=>{U(this.base,r),b(this,e,o).then(c=>{s.push(ir(r,c)),a(s),i()},c=>{u(c),i()})}})}async function tt(e,r,t,a){return ar(t,C(e.base,4),await new Promise(rt.bind(e,r,t,a)))}async function nt(e,r,t,a){let u=[];for(let s=0,i=a.v.length;s<i;s++)u[s]=await b(e,r,a.v[s]);return or(t,u,a.t,a.d)}async function at(e,r,t,a){if(Array.isArray(a))return $r(e,r,t,a);if(Ur(a))return tt(e,r,t,a);if(Ir(a))return nt(e,r,t,a);let u=a.constructor;if(u===gr)return b(e,r,a.replacement);let s=await we(e,r,t,a);if(s)return s;switch(u){case Object:return L(e,r,t,a,!1);case n:return L(e,r,t,a,!0);case Date:return Ye(t,a);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return Q(e,r,t,a);case Number:case Boolean:case String:case BigInt:return qr(e,r,t,a);case ArrayBuffer:return Dr(e.base,t,a);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return Hr(e,r,t,a);case DataView:return Wr(e,r,t,a);case Map:return Zr(e,r,t,a);case Set:return Kr(e,r,t,a)}if(u===Promise||a instanceof Promise)return et(e,r,t,a);let i=e.base.features;if(i&32&&u===RegExp)return Ge(t,a);if(i&16)switch(u){case BigInt64Array:case BigUint64Array:return Jr(e,r,t,a)}if(i&1&&typeof AggregateError<"u"&&(u===AggregateError||a instanceof AggregateError))return Xr(e,r,t,a);if(a instanceof Error)return Q(e,r,t,a);if(g in a||d in a)return L(e,r,t,a,!!u);throw new F(a)}async function ut(e,r,t){let a=M(e.base,t);if(a.type!==0)return a.value;let u=await we(e,r,a.value,t);if(u)return u;throw new F(t)}async function b(e,r,t){switch(typeof t){case"boolean":return t?ne:ae;case"undefined":return Re;case"string":return ce(t);case"number":return Me(t);case"bigint":return ze(t);case"object":{if(t){let a=M(e.base,t);return a.type===0?await at(e,r+1,a.value,t):a.value}return je}case"symbol":return I(e.base,t);case"function":return ut(e,r,t);default:throw new F(t)}}async function st(e,r){try{return await b(e,0,r)}catch(t){throw t instanceof G?t:new G(t)}}var it=(e=>(e[e.Vanilla=1]="Vanilla",e[e.Cross=2]="Cross",e))(it||{});function Wt(e){return e}function ye(e,r){for(let t=0,a=r.length;t<a;t++){let u=r[t];e.has(u)||(e.add(u),u.extends&&ye(e,u.extends))}}function de(e){if(e){let r=new Set;return ye(r,e),[...r]}}function ot(e){switch(e){case"Int8Array":return Int8Array;case"Int16Array":return Int16Array;case"Int32Array":return Int32Array;case"Uint8Array":return Uint8Array;case"Uint16Array":return Uint16Array;case"Uint32Array":return Uint32Array;case"Uint8ClampedArray":return Uint8ClampedArray;case"Float32Array":return Float32Array;case"Float64Array":return Float64Array;case"BigInt64Array":return BigInt64Array;case"BigUint64Array":return BigUint64Array;default:throw new yr(e)}}var ct=1e6,ft=1e4,lt=2e4;function ge(e,r){switch(r){case 3:return Object.freeze(e);case 1:return Object.preventExtensions(e);case 2:return Object.seal(e);default:return e}}var ht=1e3;function pt(e,r){var t;let a=r.refs||new Map;return"types"in a||Object.assign(a,{types:new Map}),{mode:e,plugins:r.plugins,refs:a,features:(t=r.features)!=null?t:63^(r.disabledFeatures||0),depthLimit:r.depthLimit||ht}}function bt(e){return{mode:2,base:pt(2,e),child:n}}var wt=class{constructor(e,r){this._p=e,this.depth=r}deserialize(e){return h(this._p,this.depth,e)}};function ve(e,r){if(r<0||!Number.isFinite(r)||!Number.isInteger(r))throw new m({t:4,i:r});if(e.refs.has(r))throw new Error("Conflicted ref id: "+r)}function yt(e,r,t){return ve(e.base,r),e.state.marked.has(r)&&e.base.refs.set(r,t),t}function dt(e,r,t){return ve(e.base,r),e.base.refs.set(r,t),t}function w(e,r,t){return e.mode===1?yt(e,r,t):dt(e,r,t)}function B(e,r,t){if(Object.hasOwn(r,t))return r[t];throw new m(e)}function gt(e,r){return w(e,r.i,Be(_(r.s)))}function vt(e,r,t){let a=t.a,u=a.length,s=w(e,t.i,new Array(u));for(let i=0,o;i<u;i++)o=a[i],o&&(s[i]=h(e,r,o));return ge(s,t.o),s}function mt(e){switch(e){case"constructor":case"__proto__":case"prototype":case"__defineGetter__":case"__defineSetter__":case"__lookupGetter__":case"__lookupSetter__":return!1;default:return!0}}function Et(e){switch(e){case d:case x:case O:case g:return!0;default:return!1}}function $(e,r,t){mt(r)?e[r]=t:Object.defineProperty(e,r,{value:t,configurable:!0,enumerable:!0,writable:!0})}function At(e,r,t,a,u){if(typeof a=="string")$(t,_(a),h(e,r,u));else{let s=h(e,r,a);switch(typeof s){case"string":$(t,s,h(e,r,u));break;case"symbol":Et(s)&&(t[s]=h(e,r,u));break;default:throw new m(a)}}}function me(e,r,t){e.base.refs.types.set(r,t)}function j(e,r,t,a){if(e.base.refs.types.get(t)!==a)throw new m(r)}function Ee(e,r,t,a){let u=t.k;if(u.length>0)for(let s=0,i=t.v,o=u.length;s<o;s++)At(e,r,a,u[s],i[s]);return a}function _t(e,r,t){let a=w(e,t.i,t.t===10?{}:Object.create(null));return Ee(e,r,t.p,a),ge(a,t.o),a}function It(e,r){return w(e,r.i,new Date(r.s))}function St(e,r){if(e.base.features&32){let t=_(r.c);if(t.length>lt)throw new m(r);return w(e,r.i,new RegExp(t,r.m))}throw new le(r)}function xt(e,r,t){let a=w(e,t.i,new Set);for(let u=0,s=t.a,i=s.length;u<i;u++)a.add(h(e,r,s[u]));return a}function Ot(e,r,t){let a=w(e,t.i,new Map);for(let u=0,s=t.e.k,i=t.e.v,o=s.length;u<o;u++)a.set(h(e,r,s[u]),h(e,r,i[u]));return a}function Rt(e,r){if(r.s.length>ct)throw new m(r);return w(e,r.i,he(_(r.s)))}function jt(e,r,t){var a;let u=ot(t.c),s=h(e,r,t.f),i=(a=t.b)!=null?a:0;if(i<0||i>s.byteLength)throw new m(t);return w(e,t.i,new u(s,i,t.l))}function Nt(e,r,t){var a;let u=h(e,r,t.f),s=(a=t.b)!=null?a:0;if(s<0||s>u.byteLength)throw new m(t);return w(e,t.i,new DataView(u,s,t.l))}function Ae(e,r,t,a){if(t.p){let u=Ee(e,r,t.p,{});Object.defineProperties(a,Object.getOwnPropertyDescriptors(u))}return a}function Ut(e,r,t){let a=w(e,t.i,new AggregateError([],_(t.m)));return Ae(e,r,t,a)}function Ft(e,r,t){let a=B(t,Oe,t.s),u=w(e,t.i,new a(_(t.m)));return Ae(e,r,t,u)}function Tt(e,r,t){let a=P(),u=w(e,t.i,a.p),s=h(e,r,t.f);return t.s?a.s(s):a.f(s),u}function Pt(e,r,t){return w(e,t.i,Object(h(e,r,t.f)))}function kt(e,r,t){let a=e.base.plugins;if(a){let u=_(t.c);for(let s=0,i=a.length;s<i;s++){let o=a[s];if(o.tag===u)return w(e,t.i,o.deserialize(t.s,new wt(e,r),{id:t.i}))}}throw new pr(t.c)}function Ct(e,r){let t=w(e,r.i,w(e,r.s,P()).p);return me(e,r.s,22),t}function Lt(e,r,t){let a=e.base.refs.get(t.i);if(a)return j(e,t,t.i,22),a.s(h(e,r,t.a[1])),n;throw new R("Promise")}function Bt(e,r,t){let a=e.base.refs.get(t.i);if(a)return j(e,t,t.i,22),a.f(h(e,r,t.a[1])),n;throw new R("Promise")}function Vt(e,r,t){h(e,r,t.a[0]);let a=h(e,r,t.a[1]);return Or(a)}function Mt(e,r,t){h(e,r,t.a[0]);let a=h(e,r,t.a[1]);return Pr(a)}function zt(e,r,t){let a=w(e,t.i,be());me(e,t.i,31);let u=t.a,s=u.length;if(s)for(let i=0;i<s;i++)h(e,r,u[i]);return a}function Dt(e,r,t){let a=e.base.refs.get(t.i);if(a)return j(e,t,t.i,31),a.next(h(e,r,t.f)),n;throw new R("Stream")}function Yt(e,r,t){let a=e.base.refs.get(t.i);if(a)return j(e,t,t.i,31),a.throw(h(e,r,t.f)),n;throw new R("Stream")}function Gt(e,r,t){let a=e.base.refs.get(t.i);if(a)return j(e,t,t.i,31),a.return(h(e,r,t.f)),n;throw new R("Stream")}function Qt(e,r,t){return h(e,r,t.f),n}function $t(e,r,t){return h(e,r,t.a[1]),n}function qt(e,r,t){let a=w(e,t.i,pe([],t.s,t.l));for(let u=0,s=t.a.length;u<s;u++)a.v[u]=h(e,r,t.a[u]);return a}function h(e,r,t){if(r>e.base.depthLimit)throw new dr(e.base.depthLimit);switch(r+=1,t.t){case 2:return B(t,Se,t.s);case 0:return Number(t.s);case 1:return _(String(t.s));case 3:if(String(t.s).length>ft)throw new m(t);return BigInt(t.s);case 4:return e.base.refs.get(t.i);case 18:return gt(e,t);case 9:return vt(e,r,t);case 10:case 11:return _t(e,r,t);case 5:return It(e,t);case 6:return St(e,t);case 7:return xt(e,r,t);case 8:return Ot(e,r,t);case 19:return Rt(e,t);case 16:case 15:return jt(e,r,t);case 20:return Nt(e,r,t);case 14:return Ut(e,r,t);case 13:return Ft(e,r,t);case 12:return Tt(e,r,t);case 17:return B(t,Ie,t.s);case 21:return Pt(e,r,t);case 25:return kt(e,r,t);case 22:return Ct(e,t);case 23:return Lt(e,r,t);case 24:return Bt(e,r,t);case 28:return Vt(e,r,t);case 30:return Mt(e,r,t);case 31:return zt(e,r,t);case 32:return Dt(e,r,t);case 33:return Yt(e,r,t);case 34:return Gt(e,r,t);case 27:return Qt(e,r,t);case 29:return $t(e,r,t);case 35:return qt(e,r,t);default:throw new le(t)}}function Ht(e,r){try{return h(e,0,r)}catch(t){throw new hr(t)}}var Jt=()=>T;Jt.toString();function Xt(e,r){let t=de(r.plugins),a=bt({plugins:t,refs:r.refs,features:r.features,disabledFeatures:r.disabledFeatures,depthLimit:r.depthLimit});return Ht(a,e)}async function Zt(e,r={}){let t=de(r.plugins),a=Yr(1,{plugins:t,disabledFeatures:r.disabledFeatures});return{t:await st(a,e),f:a.base.features,m:Array.from(a.base.marked)}}export{Zt as I,Wt as a,be as r,Xt as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,r as l}from"./vendor-seroval-B_Fur-nl.js";var t={},u=a=>new ReadableStream({start:e=>{a.on({next:r=>{try{e.enqueue(r)}catch{}},throw:r=>{e.error(r)},return:()=>{try{e.close()}catch{}}})}}),o=c({tag:"seroval-plugins/web/ReadableStreamFactory",test(a){return a===t},parse:{sync(){return t},async async(){return await Promise.resolve(t)},stream(){return t}},serialize(){return u.toString()},deserialize(){return t}});function i(a){let e=l(),r=a.getReader();async function n(){try{let s=await r.read();s.done?e.return(s.value):(e.next(s.value),await n())}catch(s){e.throw(s)}}return n().catch(()=>{}),e}var y=c({tag:"seroval/plugins/web/ReadableStream",extends:[o],test(a){return typeof ReadableStream>"u"?!1:a instanceof ReadableStream},parse:{sync(a,e){return{factory:e.parse(t),stream:e.parse(l())}},async async(a,e){return{factory:await e.parse(t),stream:await e.parse(i(a))}},stream(a,e){return{factory:e.parse(t),stream:e.parse(i(a))}}},serialize(a,e){return"("+e.serialize(a.factory)+")("+e.serialize(a.stream)+")"},deserialize(a,e){let r=e.deserialize(a.stream);return u(r)}}),d=y;export{d as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as a}from"./vendor-react-gJPiVnX5.js";import{R as Ut}from"./vendor-react-dom-BnNs-kzm.js";function Xt(r){if(typeof document>"u")return;let o=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");e.type="text/css",o.appendChild(e),e.styleSheet?e.styleSheet.cssText=r:e.appendChild(document.createTextNode(r))}const Wt=r=>{switch(r){case"success":return Gt;case"info":return Jt;case"warning":return Qt;case"error":return Zt;default:return null}},Kt=Array(12).fill(0),qt=({visible:r,className:o})=>a.createElement("div",{className:["sonner-loading-wrapper",o].filter(Boolean).join(" "),"data-visible":r},a.createElement("div",{className:"sonner-spinner"},Kt.map((e,s)=>a.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),Gt=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Qt=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Jt=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Zt=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),te=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},a.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ee=()=>{const[r,o]=a.useState(document.hidden);return a.useEffect(()=>{const e=()=>{o(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),r};let xt=1;class ae{constructor(){this.subscribe=o=>(this.subscribers.push(o),()=>{const e=this.subscribers.indexOf(o);this.subscribers.splice(e,1)}),this.publish=o=>{this.subscribers.forEach(e=>e(o))},this.addToast=o=>{this.publish(o),this.toasts=[...this.toasts,o]},this.create=o=>{var e;const{message:s,...C}=o,u=typeof o?.id=="number"||((e=o.id)==null?void 0:e.length)>0?o.id:xt++,g=this.toasts.find(b=>b.id===u),_=o.dismissible===void 0?!0:o.dismissible;return this.dismissedToasts.has(u)&&this.dismissedToasts.delete(u),g?this.toasts=this.toasts.map(b=>b.id===u?(this.publish({...b,...o,id:u,title:s}),{...b,...o,id:u,dismissible:_,title:s}):b):this.addToast({title:s,...C,dismissible:_,id:u}),u},this.dismiss=o=>(o?(this.dismissedToasts.add(o),requestAnimationFrame(()=>this.subscribers.forEach(e=>e({id:o,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(s=>s({id:e.id,dismiss:!0}))}),o),this.message=(o,e)=>this.create({...e,message:o}),this.error=(o,e)=>this.create({...e,message:o,type:"error"}),this.success=(o,e)=>this.create({...e,type:"success",message:o}),this.info=(o,e)=>this.create({...e,type:"info",message:o}),this.warning=(o,e)=>this.create({...e,type:"warning",message:o}),this.loading=(o,e)=>this.create({...e,type:"loading",message:o}),this.promise=(o,e)=>{if(!e)return;let s;e.loading!==void 0&&(s=this.create({...e,promise:o,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));const C=Promise.resolve(o instanceof Function?o():o);let u=s!==void 0,g;const _=C.then(async i=>{if(g=["resolve",i],a.isValidElement(i))u=!1,this.create({id:s,type:"default",message:i});else if(se(i)&&!i.ok){u=!1;const t=typeof e.error=="function"?await e.error(`HTTP error! status: ${i.status}`):e.error,x=typeof e.description=="function"?await e.description(`HTTP error! status: ${i.status}`):e.description,E=typeof t=="object"&&!a.isValidElement(t)?t:{message:t};this.create({id:s,type:"error",description:x,...E})}else if(i instanceof Error){u=!1;const t=typeof e.error=="function"?await e.error(i):e.error,x=typeof e.description=="function"?await e.description(i):e.description,E=typeof t=="object"&&!a.isValidElement(t)?t:{message:t};this.create({id:s,type:"error",description:x,...E})}else if(e.success!==void 0){u=!1;const t=typeof e.success=="function"?await e.success(i):e.success,x=typeof e.description=="function"?await e.description(i):e.description,E=typeof t=="object"&&!a.isValidElement(t)?t:{message:t};this.create({id:s,type:"success",description:x,...E})}}).catch(async i=>{if(g=["reject",i],e.error!==void 0){u=!1;const T=typeof e.error=="function"?await e.error(i):e.error,t=typeof e.description=="function"?await e.description(i):e.description,O=typeof T=="object"&&!a.isValidElement(T)?T:{message:T};this.create({id:s,type:"error",description:t,...O})}}).finally(()=>{u&&(this.dismiss(s),s=void 0),e.finally==null||e.finally.call(e)}),b=()=>new Promise((i,T)=>_.then(()=>g[0]==="reject"?T(g[1]):i(g[1])).catch(T));return typeof s!="string"&&typeof s!="number"?{unwrap:b}:Object.assign(s,{unwrap:b})},this.custom=(o,e)=>{const s=e?.id||xt++;return this.create({jsx:o(s),id:s,...e}),s},this.getActiveToasts=()=>this.toasts.filter(o=>!this.dismissedToasts.has(o.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const S=new ae,oe=(r,o)=>{const e=o?.id||xt++;return S.addToast({title:r,...o,id:e}),e},se=r=>r&&typeof r=="object"&&"ok"in r&&typeof r.ok=="boolean"&&"status"in r&&typeof r.status=="number",ne=oe,re=()=>S.toasts,ie=()=>S.getActiveToasts(),xe=Object.assign(ne,{success:S.success,info:S.info,warning:S.warning,error:S.error,custom:S.custom,message:S.message,promise:S.promise,dismiss:S.dismiss,loading:S.loading},{getHistory:re,getToasts:ie});Xt("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function mt(r){return r.label!==void 0}const le=3,de="24px",ce="16px",Mt=4e3,ue=356,fe=14,me=45,pe=200;function H(...r){return r.filter(Boolean).join(" ")}function ge(r){const[o,e]=r.split("-"),s=[];return o&&s.push(o),e&&s.push(e),s}const he=r=>{var o,e,s,C,u,g,_,b,i;const{invert:T,toast:t,unstyled:x,interacting:O,setHeights:E,visibleToasts:pt,heights:U,index:d,toasts:ot,expanded:X,removeToast:st,defaultRichColors:gt,closeButton:z,style:Z,cancelButtonStyle:Y,actionButtonStyle:ht,className:nt="",descriptionClassName:bt="",duration:tt,position:A,gap:rt,expandByDefault:et,classNames:c,icons:v,closeButtonAriaLabel:j="Close toast"}=r,[$,B]=a.useState(null),[F,it]=a.useState(null),[l,p]=a.useState(!1),[m,R]=a.useState(!1),[W,f]=a.useState(!1),[K,lt]=a.useState(!1),[dt,q]=a.useState(!1),[Ct,vt]=a.useState(0),[At,Et]=a.useState(0),at=a.useRef(t.duration||tt||Mt),Tt=a.useRef(null),P=a.useRef(null),Ht=d===0,Ot=d+1<=pt,N=t.type,G=t.dismissible!==!1,zt=t.className||"",Pt=t.descriptionClassName||"",ct=a.useMemo(()=>U.findIndex(n=>n.toastId===t.id)||0,[U,t.id]),jt=a.useMemo(()=>{var n;return(n=t.closeButton)!=null?n:z},[t.closeButton,z]),St=a.useMemo(()=>t.duration||tt||Mt,[t.duration,tt]),yt=a.useRef(0),Q=a.useRef(0),Nt=a.useRef(0),J=a.useRef(null),[Lt,Yt]=A.split("-"),kt=a.useMemo(()=>U.reduce((n,h,w)=>w>=ct?n:n+h.height,0),[U,ct]),_t=ee(),$t=t.invert||T,wt=N==="loading";Q.current=a.useMemo(()=>ct*rt+kt,[ct,kt]),a.useEffect(()=>{at.current=St},[St]),a.useEffect(()=>{p(!0)},[]),a.useEffect(()=>{const n=P.current;if(n){const h=n.getBoundingClientRect().height;return Et(h),E(w=>[{toastId:t.id,height:h,position:t.position},...w]),()=>E(w=>w.filter(k=>k.toastId!==t.id))}},[E,t.id]),a.useLayoutEffect(()=>{if(!l)return;const n=P.current,h=n.style.height;n.style.height="auto";const w=n.getBoundingClientRect().height;n.style.height=h,Et(w),E(k=>k.find(y=>y.toastId===t.id)?k.map(y=>y.toastId===t.id?{...y,height:w}:y):[{toastId:t.id,height:w,position:t.position},...k])},[l,t.title,t.description,E,t.id,t.jsx,t.action,t.cancel]);const L=a.useCallback(()=>{R(!0),vt(Q.current),E(n=>n.filter(h=>h.toastId!==t.id)),setTimeout(()=>{st(t)},pe)},[t,st,E,Q]);a.useEffect(()=>{if(t.promise&&N==="loading"||t.duration===1/0||t.type==="loading")return;let n;return X||O||_t?(()=>{if(Nt.current<yt.current){const k=new Date().getTime()-yt.current;at.current=at.current-k}Nt.current=new Date().getTime()})():at.current!==1/0&&(yt.current=new Date().getTime(),n=setTimeout(()=>{t.onAutoClose==null||t.onAutoClose.call(t,t),L()},at.current)),()=>clearTimeout(n)},[X,O,t,N,_t,L]),a.useEffect(()=>{t.delete&&(L(),t.onDismiss==null||t.onDismiss.call(t,t))},[L,t.delete]);function Ft(){var n;if(v?.loading){var h;return a.createElement("div",{className:H(c?.loader,t==null||(h=t.classNames)==null?void 0:h.loader,"sonner-loader"),"data-visible":N==="loading"},v.loading)}return a.createElement(qt,{className:H(c?.loader,t==null||(n=t.classNames)==null?void 0:n.loader),visible:N==="loading"})}const Vt=t.icon||v?.[N]||Wt(N);var Rt,Dt;return a.createElement("li",{tabIndex:0,ref:P,className:H(nt,zt,c?.toast,t==null||(o=t.classNames)==null?void 0:o.toast,c?.default,c?.[N],t==null||(e=t.classNames)==null?void 0:e[N]),"data-sonner-toast":"","data-rich-colors":(Rt=t.richColors)!=null?Rt:gt,"data-styled":!(t.jsx||t.unstyled||x),"data-mounted":l,"data-promise":!!t.promise,"data-swiped":dt,"data-removed":m,"data-visible":Ot,"data-y-position":Lt,"data-x-position":Yt,"data-index":d,"data-front":Ht,"data-swiping":W,"data-dismissible":G,"data-type":N,"data-invert":$t,"data-swipe-out":K,"data-swipe-direction":F,"data-expanded":!!(X||et&&l),"data-testid":t.testId,style:{"--index":d,"--toasts-before":d,"--z-index":ot.length-d,"--offset":`${m?Ct:Q.current}px`,"--initial-height":et?"auto":`${At}px`,...Z,...t.style},onDragEnd:()=>{f(!1),B(null),J.current=null},onPointerDown:n=>{n.button!==2&&(wt||!G||(Tt.current=new Date,vt(Q.current),n.target.setPointerCapture(n.pointerId),n.target.tagName!=="BUTTON"&&(f(!0),J.current={x:n.clientX,y:n.clientY})))},onPointerUp:()=>{var n,h,w;if(K||!G)return;J.current=null;const k=Number(((n=P.current)==null?void 0:n.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ut=Number(((h=P.current)==null?void 0:h.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),y=new Date().getTime()-((w=Tt.current)==null?void 0:w.getTime()),D=$==="x"?k:ut,ft=Math.abs(D)/y;if(Math.abs(D)>=me||ft>.11){vt(Q.current),t.onDismiss==null||t.onDismiss.call(t,t),it($==="x"?k>0?"right":"left":ut>0?"down":"up"),L(),lt(!0);return}else{var M,I;(M=P.current)==null||M.style.setProperty("--swipe-amount-x","0px"),(I=P.current)==null||I.style.setProperty("--swipe-amount-y","0px")}q(!1),f(!1),B(null)},onPointerMove:n=>{var h,w,k;if(!J.current||!G||((h=window.getSelection())==null?void 0:h.toString().length)>0)return;const y=n.clientY-J.current.y,D=n.clientX-J.current.x;var ft;const M=(ft=r.swipeDirections)!=null?ft:ge(A);!$&&(Math.abs(D)>1||Math.abs(y)>1)&&B(Math.abs(D)>Math.abs(y)?"x":"y");let I={x:0,y:0};const Bt=V=>1/(1.5+Math.abs(V)/20);if($==="y"){if(M.includes("top")||M.includes("bottom"))if(M.includes("top")&&y<0||M.includes("bottom")&&y>0)I.y=y;else{const V=y*Bt(y);I.y=Math.abs(V)<Math.abs(y)?V:y}}else if($==="x"&&(M.includes("left")||M.includes("right")))if(M.includes("left")&&D<0||M.includes("right")&&D>0)I.x=D;else{const V=D*Bt(D);I.x=Math.abs(V)<Math.abs(D)?V:D}(Math.abs(I.x)>0||Math.abs(I.y)>0)&&q(!0),(w=P.current)==null||w.style.setProperty("--swipe-amount-x",`${I.x}px`),(k=P.current)==null||k.style.setProperty("--swipe-amount-y",`${I.y}px`)}},jt&&!t.jsx&&N!=="loading"?a.createElement("button",{"aria-label":j,"data-disabled":wt,"data-close-button":!0,onClick:wt||!G?()=>{}:()=>{L(),t.onDismiss==null||t.onDismiss.call(t,t)},className:H(c?.closeButton,t==null||(s=t.classNames)==null?void 0:s.closeButton)},(Dt=v?.close)!=null?Dt:te):null,(N||t.icon||t.promise)&&t.icon!==null&&(v?.[N]!==null||t.icon)?a.createElement("div",{"data-icon":"",className:H(c?.icon,t==null||(C=t.classNames)==null?void 0:C.icon)},t.promise||t.type==="loading"&&!t.icon?t.icon||Ft():null,t.type!=="loading"?Vt:null):null,a.createElement("div",{"data-content":"",className:H(c?.content,t==null||(u=t.classNames)==null?void 0:u.content)},a.createElement("div",{"data-title":"",className:H(c?.title,t==null||(g=t.classNames)==null?void 0:g.title)},t.jsx?t.jsx:typeof t.title=="function"?t.title():t.title),t.description?a.createElement("div",{"data-description":"",className:H(bt,Pt,c?.description,t==null||(_=t.classNames)==null?void 0:_.description)},typeof t.description=="function"?t.description():t.description):null),a.isValidElement(t.cancel)?t.cancel:t.cancel&&mt(t.cancel)?a.createElement("button",{"data-button":!0,"data-cancel":!0,style:t.cancelButtonStyle||Y,onClick:n=>{mt(t.cancel)&&G&&(t.cancel.onClick==null||t.cancel.onClick.call(t.cancel,n),L())},className:H(c?.cancelButton,t==null||(b=t.classNames)==null?void 0:b.cancelButton)},t.cancel.label):null,a.isValidElement(t.action)?t.action:t.action&&mt(t.action)?a.createElement("button",{"data-button":!0,"data-action":!0,style:t.actionButtonStyle||ht,onClick:n=>{mt(t.action)&&(t.action.onClick==null||t.action.onClick.call(t.action,n),!n.defaultPrevented&&L())},className:H(c?.actionButton,t==null||(i=t.classNames)==null?void 0:i.actionButton)},t.action.label):null)};function It(){if(typeof window>"u"||typeof document>"u")return"ltr";const r=document.documentElement.getAttribute("dir");return r==="auto"||!r?window.getComputedStyle(document.documentElement).direction:r}function be(r,o){const e={};return[r,o].forEach((s,C)=>{const u=C===1,g=u?"--mobile-offset":"--offset",_=u?ce:de;function b(i){["top","right","bottom","left"].forEach(T=>{e[`${g}-${T}`]=typeof i=="number"?`${i}px`:i})}typeof s=="number"||typeof s=="string"?b(s):typeof s=="object"?["top","right","bottom","left"].forEach(i=>{s[i]===void 0?e[`${g}-${i}`]=_:e[`${g}-${i}`]=typeof s[i]=="number"?`${s[i]}px`:s[i]}):b(_)}),e}const Ee=a.forwardRef(function(o,e){const{id:s,invert:C,position:u="bottom-right",hotkey:g=["altKey","KeyT"],expand:_,closeButton:b,className:i,offset:T,mobileOffset:t,theme:x="light",richColors:O,duration:E,style:pt,visibleToasts:U=le,toastOptions:d,dir:ot=It(),gap:X=fe,icons:st,containerAriaLabel:gt="Notifications"}=o,[z,Z]=a.useState([]),Y=a.useMemo(()=>s?z.filter(l=>l.toasterId===s):z.filter(l=>!l.toasterId),[z,s]),ht=a.useMemo(()=>Array.from(new Set([u].concat(Y.filter(l=>l.position).map(l=>l.position)))),[Y,u]),[nt,bt]=a.useState([]),[tt,A]=a.useState(!1),[rt,et]=a.useState(!1),[c,v]=a.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),j=a.useRef(null),$=g.join("+").replace(/Key/g,"").replace(/Digit/g,""),B=a.useRef(null),F=a.useRef(!1),it=a.useCallback(l=>{Z(p=>{var m;return(m=p.find(R=>R.id===l.id))!=null&&m.delete||S.dismiss(l.id),p.filter(({id:R})=>R!==l.id)})},[]);return a.useEffect(()=>S.subscribe(l=>{if(l.dismiss){requestAnimationFrame(()=>{Z(p=>p.map(m=>m.id===l.id?{...m,delete:!0}:m))});return}setTimeout(()=>{Ut.flushSync(()=>{Z(p=>{const m=p.findIndex(R=>R.id===l.id);return m!==-1?[...p.slice(0,m),{...p[m],...l},...p.slice(m+1)]:[l,...p]})})})}),[z]),a.useEffect(()=>{if(x!=="system"){v(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?v("dark"):v("light")),typeof window>"u")return;const l=window.matchMedia("(prefers-color-scheme: dark)");try{l.addEventListener("change",({matches:p})=>{v(p?"dark":"light")})}catch{l.addListener(({matches:m})=>{try{v(m?"dark":"light")}catch(R){console.error(R)}})}},[x]),a.useEffect(()=>{z.length<=1&&A(!1)},[z]),a.useEffect(()=>{const l=p=>{var m;if(g.every(f=>p[f]||p.code===f)){var W;A(!0),(W=j.current)==null||W.focus()}p.code==="Escape"&&(document.activeElement===j.current||(m=j.current)!=null&&m.contains(document.activeElement))&&A(!1)};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[g]),a.useEffect(()=>{if(j.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,F.current=!1)}},[j.current]),a.createElement("section",{ref:e,"aria-label":`${gt} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},ht.map((l,p)=>{var m;const[R,W]=l.split("-");return Y.length?a.createElement("ol",{key:l,dir:ot==="auto"?It():ot,tabIndex:-1,ref:j,className:i,"data-sonner-toaster":!0,"data-sonner-theme":c,"data-y-position":R,"data-x-position":W,style:{"--front-toast-height":`${((m=nt[0])==null?void 0:m.height)||0}px`,"--width":`${ue}px`,"--gap":`${X}px`,...pt,...be(T,t)},onBlur:f=>{F.current&&!f.currentTarget.contains(f.relatedTarget)&&(F.current=!1,B.current&&(B.current.focus({preventScroll:!0}),B.current=null))},onFocus:f=>{f.target instanceof HTMLElement&&f.target.dataset.dismissible==="false"||F.current||(F.current=!0,B.current=f.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{rt||A(!1)},onDragEnd:()=>A(!1),onPointerDown:f=>{f.target instanceof HTMLElement&&f.target.dataset.dismissible==="false"||et(!0)},onPointerUp:()=>et(!1)},Y.filter(f=>!f.position&&p===0||f.position===l).map((f,K)=>{var lt,dt;return a.createElement(he,{key:f.id,icons:st,index:K,toast:f,defaultRichColors:O,duration:(lt=d?.duration)!=null?lt:E,className:d?.className,descriptionClassName:d?.descriptionClassName,invert:C,visibleToasts:U,closeButton:(dt=d?.closeButton)!=null?dt:b,interacting:rt,position:l,style:d?.style,unstyled:d?.unstyled,classNames:d?.classNames,cancelButtonStyle:d?.cancelButtonStyle,actionButtonStyle:d?.actionButtonStyle,closeButtonAriaLabel:d?.closeButtonAriaLabel,removeToast:it,toasts:Y.filter(q=>q.position==f.position),heights:nt.filter(q=>q.position==f.position),setHeights:bt,expandByDefault:_,gap:X,expanded:tt,swipeDirections:o.swipeDirections})})):null}))});export{Ee as T,xe as t};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{b as ie}from"./vendor-tslib-Du-meQkk.js";const Ce="2.106.1",F=30*1e3,ce=3,ae=ce*F,Me="http://localhost:9999",Ge="supabase.auth.token",Be={"X-Client-Info":`gotrue-js/${Ce}`},he="X-Supabase-Api-Version",xe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Fe=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,ze=600*1e3;class J 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 h(i){return typeof i=="object"&&i!==null&&"__isAuthError"in i}class Ve extends J{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function Je(i){return h(i)&&i.name==="AuthApiError"}class x extends J{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class N extends J{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}}class E extends N{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Y(i){return h(i)&&i.name==="AuthSessionMissingError"}class M extends N{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class X extends N{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Z extends N{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})}}function He(i){return h(i)&&i.name==="AuthImplicitGrantRedirectError"}class ge extends N{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 Ye extends N{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 de extends N{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function oe(i){return h(i)&&i.name==="AuthRetryableFetchError"}class we extends N{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 fe extends N{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ye=`
|
|
2
|
+
\r=`.split(""),Xe=(()=>{const i=new Array(128);for(let e=0;e<i.length;e+=1)i[e]=-1;for(let e=0;e<ye.length;e+=1)i[ye[e].charCodeAt(0)]=-2;for(let e=0;e<ee.length;e+=1)i[ee[e].charCodeAt(0)]=e;return i})();function ve(i,e,t){if(i!==null)for(e.queue=e.queue<<8|i,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;t(ee[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;t(ee[r]),e.queuedBits-=6}}function je(i,e,t){const r=Xe[i];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)t(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(i)}"`)}}function pe(i){const e=[],t=a=>{e.push(String.fromCodePoint(a))},r={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},n=a=>{et(a,r,t)};for(let a=0;a<i.length;a+=1)je(i.charCodeAt(a),s,n);return e.join("")}function Ze(i,e){if(i<=127){e(i);return}else if(i<=2047){e(192|i>>6),e(128|i&63);return}else if(i<=65535){e(224|i>>12),e(128|i>>6&63),e(128|i&63);return}else if(i<=1114111){e(240|i>>18),e(128|i>>12&63),e(128|i>>6&63),e(128|i&63);return}throw new Error(`Unrecognized Unicode codepoint: ${i.toString(16)}`)}function Qe(i,e){for(let t=0;t<i.length;t+=1){let r=i.charCodeAt(t);if(r>55295&&r<=56319){const s=(r-55296)*1024&65535;r=(i.charCodeAt(t+1)-56320&65535|s)+65536,t+=1}Ze(r,e)}}function et(i,e,t){if(e.utf8seq===0){if(i<=127){t(i);return}for(let r=1;r<6;r+=1)if((i>>7-r&1)===0){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=i&31;else if(e.utf8seq===3)e.codepoint=i&15;else if(e.utf8seq===4)e.codepoint=i&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(i<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|i&63,e.utf8seq-=1,e.utf8seq===0&&t(e.codepoint)}}function V(i){const e=[],t={queue:0,queuedBits:0},r=s=>{e.push(s)};for(let s=0;s<i.length;s+=1)je(i.charCodeAt(s),t,r);return new Uint8Array(e)}function tt(i){const e=[];return Qe(i,t=>e.push(t)),new Uint8Array(e)}function W(i){const e=[],t={queue:0,queuedBits:0},r=s=>{e.push(s)};return i.forEach(s=>ve(s,t,r)),ve(null,t,r),e.join("")}function rt(i){return Math.round(Date.now()/1e3)+i}function st(){return Symbol("auth-callback")}const I=()=>typeof window<"u"&&typeof document<"u",L={tested:!1,writable:!1},$e=()=>{if(!I())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(L.tested)return L.writable;const i=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(i,i),globalThis.localStorage.removeItem(i),L.tested=!0,L.writable=!0}catch{L.tested=!0,L.writable=!1}return L.writable};function it(i){const e={},t=new URL(i);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((s,n)=>{e[n]=s})}catch{}return t.searchParams.forEach((r,s)=>{e[s]=r}),e}const Ue=i=>i?(...e)=>i(...e):(...e)=>fetch(...e),nt=i=>typeof i=="object"&&i!==null&&"status"in i&&"ok"in i&&"json"in i&&typeof i.json=="function",z=async(i,e,t)=>{await i.setItem(e,JSON.stringify(t))},D=async(i,e)=>{const t=await i.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},T=async(i,e)=>{await i.removeItem(e)};class ne{constructor(){this.promise=new ne.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}ne.promiseConstructor=Promise;function Q(i){const e=i.split(".");if(e.length!==3)throw new fe("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!Fe.test(e[r]))throw new fe("JWT not in base64url format");return{header:JSON.parse(pe(e[0])),payload:JSON.parse(pe(e[1])),signature:V(e[2]),raw:{header:e[0],payload:e[1]}}}async function at(i){return await new Promise(e=>{setTimeout(()=>e(null),i)})}function ot(i,e){return new Promise((r,s)=>{(async()=>{for(let n=0;n<1/0;n++)try{const a=await i(n);if(!e(n,null,a)){r(a);return}}catch(a){if(!e(n,a)){s(a);return}}})()})}function lt(i){return("0"+i.toString(16)).substr(-2)}function ut(){const e=new Uint32Array(56);if(typeof crypto>"u"){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length;let s="";for(let n=0;n<56;n++)s+=t.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(e),Array.from(e,lt).join("")}async function ct(i){const t=new TextEncoder().encode(i),r=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(r);return Array.from(s).map(n=>String.fromCharCode(n)).join("")}async function ht(i){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),i;const t=await ct(i);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function G(i,e,t=!1){const r=ut();let s=r;t&&(s+="/recovery"),await z(i,`${e}-code-verifier`,s);const n=await ht(r);return[n,r===n?"plain":"s256"]}const dt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function ft(i){const e=i.headers.get(he);if(!e||!e.match(dt))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function _t(i){if(!i)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(i<=e)throw new Error("JWT has expired")}function gt(i){switch(i){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 new Error("Invalid alg claim")}}const wt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function U(i){if(!wt.test(i))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function C(i){if(!i.passkey)throw new 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 le(){const i={};return new Proxy(i,{get:(e,t)=>{if(t==="__isUserNotAvailableProxy")return!0;if(typeof t=="symbol"){const r=t.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new 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 new 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 new 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 yt(i,e){return new Proxy(i,{get:(t,r,s)=>{if(r==="__isInsecureUserWarningProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)"||n==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(t,r,s)}return!e.value&&typeof r=="string"&&(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."),e.value=!0),Reflect.get(t,r,s)}})}function be(i){return JSON.parse(JSON.stringify(i))}const K=i=>{if(typeof i=="object"&&i!==null){const e=i;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error}return JSON.stringify(i)},vt=[502,503,504,520,521,522,523,524,530];async function me(i){var e;if(!nt(i))throw new de(K(i),0);if(vt.includes(i.status))throw new de(K(i),i.status);let t;try{t=await i.json()}catch(n){throw new x(K(n),n)}let r;const s=ft(i);if(s&&s.getTime()>=xe["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?r=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(r=t.error_code),r){if(r==="weak_password")throw new we(K(t),i.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new E}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((n,a)=>n&&typeof a=="string",!0))throw new we(K(t),i.status,t.weak_password.reasons);throw new Ve(K(t),i.status||500,r)}const pt=(i,e,t,r)=>{const s={method:i,headers:e?.headers||{}};return i==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),t))};async function d(i,e,t,r){var s;const n=Object.assign({},r?.headers);n[he]||(n[he]=xe["2024-01-01"].name),r?.jwt&&(n.Authorization=`Bearer ${r.jwt}`);const a=(s=r?.query)!==null&&s!==void 0?s:{};r?.redirectTo&&(a.redirect_to=r.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await bt(i,e,t+o,{headers:n,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(l):{data:Object.assign({},l),error:null}}async function bt(i,e,t,r,s,n){const a=pt(e,r,s,n);let o;try{o=await i(t,Object.assign({},a))}catch(l){throw console.error(l),new de(K(l),0)}if(o.ok||await me(o),r?.noResolveJson)return o;try{return await o.json()}catch(l){await me(l)}}function O(i){var e;let t=null;St(i)&&(t=Object.assign({},i),i.expires_at||(t.expires_at=rt(i.expires_in)));const r=(e=i.user)!==null&&e!==void 0?e:null;return{data:{session:t,user:r},error:null}}function ke(i){const e=O(i);return!e.error&&i.weak_password&&typeof i.weak_password=="object"&&Array.isArray(i.weak_password.reasons)&&i.weak_password.reasons.length&&i.weak_password.message&&typeof i.weak_password.message=="string"&&i.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)&&(e.data.weak_password=i.weak_password),e}function q(i){var e;return{data:{user:(e=i.user)!==null&&e!==void 0?e:i},error:null}}function mt(i){return{data:i,error:null}}function kt(i){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:n}=i,a=ie(i,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:n},l=Object.assign({},a);return{data:{properties:o,user:l},error:null}}function Se(i){return i}function St(i){return!!i.access_token&&!!i.refresh_token&&!!i.expires_in}const ue=["global","local","others"];class Rt{_encodePathSegment(e){if(e==="."||e==="..")throw new J("Invalid path segment");return encodeURIComponent(e)}constructor({url:e="",headers:t={},fetch:r,experimental:s}){this.url=e,this.headers=t,this.fetch=Ue(r),this.experimental=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=ue[0]){if(ue.indexOf(t)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${ue.join(", ")}`);try{return await d(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(h(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,t={}){try{return await d(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:q})}catch(r){if(h(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:t}=e,r=ie(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=r?.newEmail,delete s.newEmail),await d(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:kt,redirectTo:t?.redirectTo})}catch(t){if(h(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await d(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:q})}catch(t){if(h(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,r,s,n,a,o,l;try{const u={nextPage:null,lastPage:0,total:0},c=await d(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e?.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(n=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:""},xform:Se});if(c.error)throw c.error;const w=await c.json(),f=(a=c.headers.get("x-total-count"))!==null&&a!==void 0?a:0,_=(l=(o=c.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return _.length>0&&(_.forEach(p=>{const b=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(p.split(";")[1].split("=")[1]);u[`${v}Page`]=b}),u.total=parseInt(f)),{data:Object.assign(Object.assign({},w),u),error:null}}catch(u){if(h(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){U(e);try{return await d(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:q})}catch(t){if(h(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){U(e);try{return await d(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:q})}catch(r){if(h(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,t=!1){U(e);try{return await d(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:q})}catch(r){if(h(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){U(e.userId);try{const{data:t,error:r}=await d(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:r}}catch(t){if(h(t))return{data:null,error:t};throw t}}async _deleteFactor(e){U(e.userId),U(e.id);try{return{data:await d(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(h(t))return{data:null,error:t};throw t}}async _listOAuthClients(e){var t,r,s,n,a,o,l;try{const u={nextPage:null,lastPage:0,total:0},c=await d(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e?.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(n=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:""},xform:Se});if(c.error)throw c.error;const w=await c.json(),f=(a=c.headers.get("x-total-count"))!==null&&a!==void 0?a:0,_=(l=(o=c.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return _.length>0&&(_.forEach(p=>{const b=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(p.split(";")[1].split("=")[1]);u[`${v}Page`]=b}),u.total=parseInt(f)),{data:Object.assign(Object.assign({},w),u),error:null}}catch(u){if(h(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(e){try{return await d(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(h(t))return{data:null,error:t};throw t}}async _getOAuthClient(e){try{const t=this._encodePathSegment(e);return await d(this.fetch,"GET",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(t){if(h(t))return{data:null,error:t};throw t}}async _updateOAuthClient(e,t){try{const r=this._encodePathSegment(e);return await d(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${r}`,{body:t,headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(h(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(e){try{const t=this._encodePathSegment(e);return await d(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if(h(t))return{data:null,error:t};throw t}}async _regenerateOAuthClientSecret(e){try{const t=this._encodePathSegment(e);return await d(this.fetch,"POST",`${this.url}/admin/oauth/clients/${t}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(t){if(h(t))return{data:null,error:t};throw t}}async _listCustomProviders(e){try{const t={};return e?.type&&(t.type=e.type),await d(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:t,xform:r=>{var s;return{data:{providers:(s=r?.providers)!==null&&s!==void 0?s:[]},error:null}}})}catch(t){if(h(t))return{data:{providers:[]},error:t};throw t}}async _createCustomProvider(e){try{return await d(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(h(t))return{data:null,error:t};throw t}}async _getCustomProvider(e){try{const t=this._encodePathSegment(e);return await d(this.fetch,"GET",`${this.url}/admin/custom-providers/${t}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(t){if(h(t))return{data:null,error:t};throw t}}async _updateCustomProvider(e,t){try{const r=this._encodePathSegment(e);return await d(this.fetch,"PUT",`${this.url}/admin/custom-providers/${r}`,{body:t,headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(h(r))return{data:null,error:r};throw r}}async _deleteCustomProvider(e){try{const t=this._encodePathSegment(e);return await d(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if(h(t))return{data:null,error:t};throw t}}async _adminListPasskeys(e){C(this.experimental),U(e.userId);try{return await d(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(h(t))return{data:null,error:t};throw t}}async _adminDeletePasskey(e){C(this.experimental),U(e.userId),U(e.passkeyId);try{return await d(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if(h(t))return{data:null,error:t};throw t}}}function Re(i={}){return{getItem:e=>i[e]||null,setItem:(e,t)=>{i[e]=t},removeItem:e=>{delete i[e]}}}const j={debug:!!(globalThis&&$e()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Ne extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Ee extends Ne{}async function Et(i,e,t){j.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",i,e);const r=new globalThis.AbortController;let s;e>0&&(s=setTimeout(()=>{r.abort(),j.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",i)},e)),await Promise.resolve();try{return await globalThis.navigator.locks.request(i,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async n=>{if(n){clearTimeout(s),j.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",i,n.name);try{return await t()}finally{j.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",i,n.name)}}else{if(e===0)throw j.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",i),new Ee(`Acquiring an exclusive Navigator LockManager lock "${i}" immediately failed`);if(j.debug)try{const a=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}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 t()}})}catch(n){if(e>0&&clearTimeout(s),n!==null&&typeof n=="object"&&"name"in n&&n.name==="AbortError"&&e>0){if(r.signal.aborted)return j.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",i),console.warn(`@supabase/gotrue-js: Lock "${i}" was not released within ${e}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(i,{mode:"exclusive",steal:!0},async a=>{if(a){j.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",i,a.name);try{return await t()}finally{j.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",i,a.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await t()}));throw j.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",i),new Ee(`Lock "${i}" was released because another request stole it`)}throw n}}function At(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function qe(i){if(!/^0x[a-fA-F0-9]{40}$/.test(i))throw new Error(`@supabase/auth-js: Address "${i}" is invalid.`);return i.toLowerCase()}function Tt(i){return parseInt(i,16)}function It(i){const e=new TextEncoder().encode(i);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function Ot(i){var e;const{chainId:t,domain:r,expirationTime:s,issuedAt:n=new Date,nonce:a,notBefore:o,requestId:l,resources:u,scheme:c,uri:w,version:f}=i;{if(!Number.isInteger(t))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${t}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!w)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(f!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${f}`);if(!((e=i.statement)===null||e===void 0)&&e.includes(`
|
|
3
|
+
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${i.statement}`)}const _=qe(i.address),p=c?`${c}://${r}`:r,b=i.statement?`${i.statement}
|
|
4
|
+
`:"",v=`${p} wants you to sign in with your Ethereum account:
|
|
5
|
+
${_}
|
|
6
|
+
|
|
7
|
+
${b}`;let m=`URI: ${w}
|
|
8
|
+
Version: ${f}
|
|
9
|
+
Chain ID: ${t}${a?`
|
|
10
|
+
Nonce: ${a}`:""}
|
|
11
|
+
Issued At: ${n.toISOString()}`;if(s&&(m+=`
|
|
12
|
+
Expiration Time: ${s.toISOString()}`),o&&(m+=`
|
|
13
|
+
Not Before: ${o.toISOString()}`),l&&(m+=`
|
|
14
|
+
Request ID: ${l}`),u){let y=`
|
|
15
|
+
Resources:`;for(const g of u){if(!g||typeof g!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${g}`);y+=`
|
|
16
|
+
- ${g}`}m+=y}return`${v}
|
|
17
|
+
${m}`}class R extends Error{constructor({message:e,code:t,cause:r,name:s}){var n;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(n=s??(r instanceof Error?r.name:void 0))!==null&&n!==void 0?n:"Unknown Error",this.code=t}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class te extends R{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}function Pt({error:i,options:e}){var t,r,s;const{publicKey:n}=e;if(!n)throw Error("options was missing required publicKey property");if(i.name==="AbortError"){if(e.signal instanceof AbortSignal)return new R({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:i})}else if(i.name==="ConstraintError"){if(((t=n.authenticatorSelection)===null||t===void 0?void 0:t.requireResidentKey)===!0)return new R({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:i});if(e.mediation==="conditional"&&((r=n.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new R({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:i});if(((s=n.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new R({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:i})}else{if(i.name==="InvalidStateError")return new R({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:i});if(i.name==="NotAllowedError")return new R({message:i.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:i});if(i.name==="NotSupportedError")return n.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new R({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:i}):new R({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:i});if(i.name==="SecurityError"){const a=window.location.hostname;if(Le(a)){if(n.rp.id!==a)return new R({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:i})}else return new R({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:i})}else if(i.name==="TypeError"){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new R({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:i})}else if(i.name==="UnknownError")return new R({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:i})}return new R({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:i})}function Ct({error:i,options:e}){const{publicKey:t}=e;if(!t)throw Error("options was missing required publicKey property");if(i.name==="AbortError"){if(e.signal instanceof AbortSignal)return new R({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:i})}else{if(i.name==="NotAllowedError")return new R({message:i.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:i});if(i.name==="SecurityError"){const r=window.location.hostname;if(Le(r)){if(t.rpId!==r)return new R({message:`The RP ID "${t.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:i})}else return new R({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:i})}else if(i.name==="UnknownError")return new R({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:i})}return new R({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:i})}class xt{createNewAbortSignal(){if(this.controller){const t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const _e=new xt;function Ae(i){if(!i)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(i);const{challenge:e,user:t,excludeCredentials:r}=i,s=ie(i,["challenge","user","excludeCredentials"]),n=V(e).buffer,a=Object.assign(Object.assign({},t),{id:V(t.id).buffer}),o=Object.assign(Object.assign({},s),{challenge:n,user:a});if(r&&r.length>0){o.excludeCredentials=new Array(r.length);for(let l=0;l<r.length;l++){const u=r[l];o.excludeCredentials[l]=Object.assign(Object.assign({},u),{id:V(u.id).buffer,type:u.type||"public-key",transports:u.transports})}}return o}function Te(i){if(!i)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(i);const{challenge:e,allowCredentials:t}=i,r=ie(i,["challenge","allowCredentials"]),s=V(e).buffer,n=Object.assign(Object.assign({},r),{challenge:s});if(t&&t.length>0){n.allowCredentials=new Array(t.length);for(let a=0;a<t.length;a++){const o=t[a];n.allowCredentials[a]=Object.assign(Object.assign({},o),{id:V(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return n}function Ie(i){var e;if("toJSON"in i&&typeof i.toJSON=="function")return i.toJSON();const t=i;return{id:i.id,rawId:i.id,response:{attestationObject:W(new Uint8Array(i.response.attestationObject)),clientDataJSON:W(new Uint8Array(i.response.clientDataJSON))},type:"public-key",clientExtensionResults:i.getClientExtensionResults(),authenticatorAttachment:(e=t.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Oe(i){var e;if("toJSON"in i&&typeof i.toJSON=="function")return i.toJSON();const t=i,r=i.getClientExtensionResults(),s=i.response;return{id:i.id,rawId:i.id,response:{authenticatorData:W(new Uint8Array(s.authenticatorData)),clientDataJSON:W(new Uint8Array(s.clientDataJSON)),signature:W(new Uint8Array(s.signature)),userHandle:s.userHandle?W(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=t.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Le(i){return i==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(i)}function re(){var i,e;return!!(I()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((i=navigator?.credentials)===null||i===void 0?void 0:i.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function De(i){try{const e=await navigator.credentials.create(i);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new te("Browser returned unexpected credential type",e)}:{data:null,error:new te("Empty credential response",e)}}catch(e){return{data:null,error:Pt({error:e,options:i})}}}async function Ke(i){try{const e=await navigator.credentials.get(i);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new te("Browser returned unexpected credential type",e)}:{data:null,error:new te("Empty credential response",e)}}catch(e){return{data:null,error:Ct({error:e,options:i})}}}const jt={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},$t={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function se(...i){const e=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),t=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),r={};for(const s of i)if(s)for(const n in s){const a=s[n];if(a!==void 0)if(Array.isArray(a))r[n]=a;else if(t(a))r[n]=a;else if(e(a)){const o=r[n];e(o)?r[n]=se(o,a):r[n]=se(a)}else r[n]=a}return r}function Ut(i,e){return se(jt,i,e||{})}function Nt(i,e){return se($t,i,e||{})}class qt{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:s},n){var a;try{const{data:o,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!o)return{data:null,error:l};const u=s??_e.createNewAbortSignal();if(o.webauthn.type==="create"){const{user:c}=o.webauthn.credential_options.publicKey;if(!c.name){const w=r;if(w)c.name=`${c.id}:${w}`;else{const _=(await this.client.getUser()).data.user,p=((a=_?.user_metadata)===null||a===void 0?void 0:a.name)||_?.email||_?.id||"User";c.name=`${c.id}:${p}`}}c.displayName||(c.displayName=c.name)}switch(o.webauthn.type){case"create":{const c=Ut(o.webauthn.credential_options.publicKey,n?.create),{data:w,error:f}=await De({publicKey:c,signal:u});return w?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:w}},error:null}:{data:null,error:f}}case"request":{const c=Nt(o.webauthn.credential_options.publicKey,n?.request),{data:w,error:f}=await Ke(Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:c,signal:u}));return w?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:w}},error:null}:{data:null,error:f}}}}catch(o){return h(o)?{data:null,error:o}:{data:null,error:new x("Unexpected error in challenge",o)}}}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=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},n){if(!t)return{data:null,error:new J("rpId is required for WebAuthn authentication")};try{if(!re())return{data:null,error:new x("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:s},{request:n});if(!a)return{data:null,error:o};const{webauthn:l}=a;return this._verify({factorId:e,challengeId:a.challengeId,webauthn:{type:l.type,rpId:t,rpOrigins:r,credential_response:l.credential_response}})}catch(a){return h(a)?{data:null,error:a}:{data:null,error:new x("Unexpected error in authenticate",a)}}}async _register({friendlyName:e,webauthn:{rpId:t=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},n){if(!t)return{data:null,error:new J("rpId is required for WebAuthn registration")};try{if(!re())return{data:null,error:new x("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this._enroll({friendlyName:e});if(!a)return await this.client.mfa.listFactors().then(c=>{var w;return(w=c.data)===null||w===void 0?void 0:w.all.find(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.status!=="unverified")}).then(c=>c?this.client.mfa.unenroll({factorId:c?.id}):void 0),{data:null,error:o};const{data:l,error:u}=await this._challenge({factorId:a.id,friendlyName:a.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:s},{create:n});return l?this._verify({factorId:a.id,challengeId:l.challengeId,webauthn:{rpId:t,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:u}}catch(a){return h(a)?{data:null,error:a}:{data:null,error:new x("Unexpected error in register",a)}}}}At();const Lt={url:Me,storageKey:Ge,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Be,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Pe(i,e,t){return await t()}const B={};class H{get jwks(){var e,t;return(t=(e=B[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&t!==void 0?t:{keys:[]}}set jwks(e){B[this.storageKey]=Object.assign(Object.assign({},B[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return(t=(e=B[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&t!==void 0?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){B[this.storageKey]=Object.assign(Object.assign({},B[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 a=Object.assign(Object.assign({},Lt),e);if(this.storageKey=a.storageKey,this.instanceID=(t=H.nextInstanceID[this.storageKey])!==null&&t!==void 0?t:0,H.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.instanceID>0&&I()){const o=`${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(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=a.persistSession,this.autoRefreshToken=a.autoRefreshToken,this.experimental=(r=a.experimental)!==null&&r!==void 0?r:{},this.admin=new Rt({url:a.url,headers:a.headers,fetch:a.fetch,experimental:this.experimental}),this.url=a.url,this.headers=a.headers,this.fetch=Ue(a.fetch),this.lock=a.lock||Pe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,this.throwOnError=a.throwOnError,this.lockAcquireTimeout=a.lockAcquireTimeout,a.lock?this.lock=a.lock:this.persistSession&&I()&&(!((s=globalThis?.navigator)===null||s===void 0)&&s.locks)?this.lock=Et:this.lock=Pe,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 qt(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?(a.storage?this.storage=a.storage:$e()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Re(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=Re(this.memoryStorage)),I()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o);try{await this._notifyAllSubscribers(o.data.event,o.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}a.skipAutoInitialize||this.initialize().catch(o=>{this._debug("#initialize()","error",o)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${Ce}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await 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(I()&&(t=it(window.location.href),this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce")),I()&&this.detectSessionInUrl&&r!=="none"){const{data:s,error:n}=await this._getSessionFromURL(t,r);if(n){if(this._debug("#_initialize()","error detecting session from URL",n),He(n)){const l=(e=n.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:n}}return{error:n}}const{session:a,redirectType:o}=s;return this._debug("#_initialize()","detected session in URL",a,"redirect type",o),await this._saveSession(a),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return h(t)?this._returnResult({error:t}):this._returnResult({error:new x("Unexpected error during initialization",t)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{const n=await d(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(t=e?.options)===null||t===void 0?void 0:t.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(s=e?.options)===null||s===void 0?void 0:s.captchaToken}},xform:O}),{data:a,error:o}=n;if(o||!a)return this._returnResult({data:{user:null,session:null},error:o});const l=a.session,u=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:u,session:l},error:null})}catch(n){if(h(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signUp(e){var t,r,s;try{let n;if("email"in e){const{email:c,password:w,options:f}=e;let _=null,p=null;this.flowType==="pkce"&&([_,p]=await G(this.storage,this.storageKey)),n=await d(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f?.emailRedirectTo,body:{email:c,password:w,data:(t=f?.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:f?.captchaToken},code_challenge:_,code_challenge_method:p},xform:O})}else if("phone"in e){const{phone:c,password:w,options:f}=e;n=await d(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:w,data:(r=f?.data)!==null&&r!==void 0?r:{},channel:(s=f?.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:f?.captchaToken}},xform:O})}else throw new X("You must provide either an email or phone number and a password");const{data:a,error:o}=n;if(o||!a)return await T(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:o});const l=a.session,u=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:u,session:l},error:null})}catch(n){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithPassword(e){try{let t;if("email"in e){const{email:n,password:a,options:o}=e;t=await d(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:n,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:ke})}else if("phone"in e){const{phone:n,password:a,options:o}=e;t=await d(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:n,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:ke})}else throw new X("You must provide either an email or phone number and a password");const{data:r,error:s}=t;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!r||!r.session||!r.user){const n=new M;return this._returnResult({data:{user:null,session:null},error:n})}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(t){if(h(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async signInWithOAuth(e){var t,r,s,n;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(n=e.options)===null||n===void 0?void 0:n.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:t}=e;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,r,s,n,a,o,l,u,c,w,f;let _,p;if("message"in e)_=e.message,p=e.signature;else{const{chain:b,wallet:v,statement:m,options:y}=e;let g;if(I())if(typeof v=="object")g=v;else{const $=window;if("ethereum"in $&&typeof $.ethereum=="object"&&"request"in $.ethereum&&typeof $.ethereum.request=="function")g=$.ethereum;else throw new 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(typeof v!="object"||!y?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");g=v}const S=new URL((t=y?.url)!==null&&t!==void 0?t:window.location.href),P=await g.request({method:"eth_requestAccounts"}).then($=>$).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!P||P.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const k=qe(P[0]);let A=(r=y?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!A){const $=await g.request({method:"eth_chainId"});A=Tt($)}const We={domain:S.host,address:k,statement:m,uri:S.href,version:"1",chainId:A,nonce:(s=y?.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(a=(n=y?.signInWithEthereum)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date,expirationTime:(o=y?.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(l=y?.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(u=y?.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(c=y?.signInWithEthereum)===null||c===void 0?void 0:c.resources};_=Ot(We),p=await g.request({method:"personal_sign",params:[It(_),k]})}try{const{data:b,error:v}=await d(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:p},!((w=e.options)===null||w===void 0)&&w.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:O});if(v)throw v;if(!b||!b.session||!b.user){const m=new M;return this._returnResult({data:{user:null,session:null},error:m})}return b.session&&(await this._saveSession(b.session),await this._notifyAllSubscribers("SIGNED_IN",b.session)),this._returnResult({data:Object.assign({},b),error:v})}catch(b){if(h(b))return this._returnResult({data:{user:null,session:null},error:b});throw b}}async signInWithSolana(e){var t,r,s,n,a,o,l,u,c,w,f,_;let p,b;if("message"in e)p=e.message,b=e.signature;else{const{chain:v,wallet:m,statement:y,options:g}=e;let S;if(I())if(typeof m=="object")S=m;else{const k=window;if("solana"in k&&typeof k.solana=="object"&&("signIn"in k.solana&&typeof k.solana.signIn=="function"||"signMessage"in k.solana&&typeof k.solana.signMessage=="function"))S=k.solana;else throw new 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(typeof m!="object"||!g?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");S=m}const P=new URL((t=g?.url)!==null&&t!==void 0?t:window.location.href);if("signIn"in S&&S.signIn){const k=await S.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},g?.signInWithSolana),{version:"1",domain:P.host,uri:P.href}),y?{statement:y}:null));let A;if(Array.isArray(k)&&k[0]&&typeof k[0]=="object")A=k[0];else if(k&&typeof k=="object"&&"signedMessage"in k&&"signature"in k)A=k;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in A&&"signature"in A&&(typeof A.signedMessage=="string"||A.signedMessage instanceof Uint8Array)&&A.signature instanceof Uint8Array)p=typeof A.signedMessage=="string"?A.signedMessage:new TextDecoder().decode(A.signedMessage),b=A.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in S)||typeof S.signMessage!="function"||!("publicKey"in S)||typeof S!="object"||!S.publicKey||!("toBase58"in S.publicKey)||typeof S.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=[`${P.host} wants you to sign in with your Solana account:`,S.publicKey.toBase58(),...y?["",y,""]:[""],"Version: 1",`URI: ${P.href}`,`Issued At: ${(s=(r=g?.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((n=g?.signInWithSolana)===null||n===void 0)&&n.notBefore?[`Not Before: ${g.signInWithSolana.notBefore}`]:[],...!((a=g?.signInWithSolana)===null||a===void 0)&&a.expirationTime?[`Expiration Time: ${g.signInWithSolana.expirationTime}`]:[],...!((o=g?.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${g.signInWithSolana.chainId}`]:[],...!((l=g?.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${g.signInWithSolana.nonce}`]:[],...!((u=g?.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${g.signInWithSolana.requestId}`]:[],...!((w=(c=g?.signInWithSolana)===null||c===void 0?void 0:c.resources)===null||w===void 0)&&w.length?["Resources",...g.signInWithSolana.resources.map(A=>`- ${A}`)]:[]].join(`
|
|
18
|
+
`);const k=await S.signMessage(new TextEncoder().encode(p),"utf8");if(!k||!(k instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");b=k}}try{const{data:v,error:m}=await d(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:W(b)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(_=e.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:O});if(m)throw m;if(!v||!v.session||!v.user){const y=new M;return this._returnResult({data:{user:null,session:null},error:y})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:m})}catch(v){if(h(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async _exchangeCodeForSession(e){const t=await D(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(t??"").split("/");try{if(!r&&this.flowType==="pkce")throw new Ye;const{data:n,error:a}=await d(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:O});if(await T(this.storage,`${this.storageKey}-code-verifier`),a)throw a;if(!n||!n.session||!n.user){const o=new M;return this._returnResult({data:{user:null,session:null,redirectType:null},error:o})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers(s==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",n.session)),this._returnResult({data:Object.assign(Object.assign({},n),{redirectType:s??null}),error:a})}catch(n){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(n))return this._returnResult({data:{user:null,session:null,redirectType:null},error:n});throw n}}async signInWithIdToken(e){try{const{options:t,provider:r,token:s,access_token:n,nonce:a}=e,o=await d(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:n,nonce:a,gotrue_meta_security:{captcha_token:t?.captchaToken}},xform:O}),{data:l,error:u}=o;if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!l||!l.session||!l.user){const c=new M;return this._returnResult({data:{user:null,session:null},error:c})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:u})}catch(t){if(h(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async signInWithOtp(e){var t,r,s,n,a;try{if("email"in e){const{email:o,options:l}=e;let u=null,c=null;this.flowType==="pkce"&&([u,c]=await G(this.storage,this.storageKey));const{error:w}=await d(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(t=l?.data)!==null&&t!==void 0?t:{},create_user:(r=l?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},code_challenge:u,code_challenge_method:c},redirectTo:l?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:w})}if("phone"in e){const{phone:o,options:l}=e,{data:u,error:c}=await d(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(s=l?.data)!==null&&s!==void 0?s:{},create_user:(n=l?.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},channel:(a=l?.channel)!==null&&a!==void 0?a:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:u?.message_id},error:c})}throw new X("You must provide either an email or phone number.")}catch(o){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async verifyOtp(e){var t,r;try{let s,n;"options"in e&&(s=(t=e.options)===null||t===void 0?void 0:t.redirectTo,n=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:a,error:o}=await d(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:n}}),redirectTo:s,xform:O});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const l=a.session,u=a.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:u,session:l},error:null})}catch(s){if(h(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithSSO(e){var t,r,s,n,a;try{let o=null,l=null;this.flowType==="pkce"&&([o,l]=await G(this.storage,this.storageKey));const u=await d(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:(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e?.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:mt});return!((n=u.data)===null||n===void 0)&&n.url&&I()&&!(!((a=e.options)===null||a===void 0)&&a.skipBrowserRedirect)&&window.location.assign(u.data.url),this._returnResult(u)}catch(o){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(o))return this._returnResult({data:null,error:o});throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new E;const{error:s}=await d(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(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const t=`${this.url}/resend`;if("email"in e){const{email:r,type:s,options:n}=e,{error:a}=await d(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:n?.captchaToken}},redirectTo:n?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:a})}else if("phone"in e){const{phone:r,type:s,options:n}=e,{data:a,error:o}=await d(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:n?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:a?.message_id},error:o})}throw new X("You must provide either an email or phone number and a type")}catch(t){if(h(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=t();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}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{const 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!",new Error().stack);try{let e=null;const t=await D(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<ae:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const a=await D(this.userStorage,this.storageKey+"-user");a?.user?e.user=a.user:e.user=le()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const a={value:this.suppressGetSessionWarning};e.user=yt(e.user,a),a.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:s,error:n}=await this._callRefreshToken(e.refresh_token);return n?this._returnResult({data:{session:null},error:n}):this._returnResult({data:{session:s},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const t=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return t.data.user&&(this.suppressGetSessionWarning=!0),t}async _getUser(e){try{return e?await d(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:q}):await this._useSession(async t=>{var r,s,n;const{data:a,error:o}=t;if(o)throw o;return!(!((r=a.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new E}:await d(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(n=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&n!==void 0?n:void 0,xform:q})})}catch(t){if(h(t))return Y(t)&&(await this._removeSession(),await T(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:t});throw t}}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=>{const{data:s,error:n}=r;if(n)throw n;if(!s.session)throw new E;const a=s.session;let o=null,l=null;this.flowType==="pkce"&&e.email!=null&&([o,l]=await G(this.storage,this.storageKey));const{data:u,error:c}=await d(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:a.access_token,xform:q});if(c)throw c;return a.user=u.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),this._returnResult({data:{user:a.user},error:null})})}catch(r){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(r))return this._returnResult({data:{user:null},error:r});throw r}}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 E;const t=Date.now()/1e3;let r=t,s=!0,n=null;const{payload:a}=Q(e.access_token);if(a.exp&&(r=a.exp,s=r<=t),s){const{data:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!o)return{data:{user:null,session:null},error:null};n=o}else{const{data:o,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});n={access_token:e.access_token,refresh_token:e.refresh_token,user:o.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(t){if(h(t))return this._returnResult({data:{session:null,user:null},error:t});throw t}}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){const{data:a,error:o}=t;if(o)throw o;e=(r=a.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new E;const{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(t){if(h(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async _getSessionFromURL(e,t){var r;try{if(!I())throw new Z("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Z(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(this.flowType==="pkce")throw new ge("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Z("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new ge("No code detected.");const{data:g,error:S}=await this._exchangeCodeForSession(e.code);if(S)throw S;const P=new URL(window.location.href);return P.searchParams.delete("code"),window.history.replaceState(window.history.state,"",P.toString()),{data:{session:g.session,redirectType:(r=g.redirectType)!==null&&r!==void 0?r:null},error:null}}const{provider_token:s,provider_refresh_token:n,access_token:a,refresh_token:o,expires_in:l,expires_at:u,token_type:c}=e;if(!a||!l||!o||!c)throw new Z("No session defined in URL");const w=Math.round(Date.now()/1e3),f=parseInt(l);let _=w+f;u&&(_=parseInt(u));const p=_-w;p*1e3<=F&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${f}s`);const b=_-f;w-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,_,w):w-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,_,w);const{data:v,error:m}=await this._getUser(a);if(m)throw m;const y={provider_token:s,provider_refresh_token:n,access_token:a,expires_in:f,expires_at:_,refresh_token:o,token_type:c,user:v.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:y,redirectType:e.type},error:null})}catch(s){if(h(s))return this._returnResult({data:{session:null,redirectType:null},error:s});throw s}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const t=await D(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;const{data:s,error:n}=t;if(n&&!Y(n))return this._returnResult({error:n});const a=(r=s.session)===null||r===void 0?void 0:r.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(Je(o)&&(o.status===404||o.status===401||o.status===403)||Y(o)))return this._returnResult({error:o})}return e!=="others"&&(await this._removeSession(),await T(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const t=st(),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{const{data:{session:n},error:a}=t;if(a)throw a;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",n)),this._debug("INITIAL_SESSION","callback id",e,"session",n)}catch(n){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",n),Y(n)?console.warn(n):console.error(n)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;this.flowType==="pkce"&&([r,s]=await G(this.storage,this.storageKey,!0));try{return await d(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(n){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(n))return this._returnResult({data:null,error:n});throw n}}async getUserIdentities(){var e;try{const{data:t,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var t;try{const{data:r,error:s}=await this._useSession(async n=>{var a,o,l,u,c;const{data:w,error:f}=n;if(f)throw f;const _=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(a=e.options)===null||a===void 0?void 0:a.redirectTo,scopes:(o=e.options)===null||o===void 0?void 0:o.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await d(this.fetch,"GET",_,{headers:this.headers,jwt:(c=(u=w.session)===null||u===void 0?void 0:u.access_token)!==null&&c!==void 0?c:void 0})});if(s)throw s;return I()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(r?.url),this._returnResult({data:{provider:e.provider,url:r?.url},error:null})}catch(r){if(h(r))return this._returnResult({data:{provider:e.provider,url:null},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{const{error:s,data:{session:n}}=t;if(s)throw s;const{options:a,provider:o,token:l,access_token:u,nonce:c}=e,w=await d(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=n?.access_token)!==null&&r!==void 0?r:void 0,body:{provider:o,id_token:l,access_token:u,nonce:c,link_identity:!0,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:O}),{data:f,error:_}=w;return _?this._returnResult({data:{user:null,session:null},error:_}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new M}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:_}))}catch(s){if(await T(this.storage,`${this.storageKey}-code-verifier`),h(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,s;const{data:n,error:a}=t;if(a)throw a;return await d(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(r=n.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _refreshAccessToken(e){const t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{const r=Date.now();return await ot(async s=>(s>0&&await at(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await d(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:O})),(s,n)=>{const a=200*Math.pow(2,s);return n&&oe(n)&&Date.now()+a-r<F})}catch(r){if(this._debug(t,"error",r),h(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(t,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){const 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),I()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,t;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const s=await D(this.storage,this.storageKey);if(s&&this.userStorage){let a=await D(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:s.user},await z(this.userStorage,this.storageKey+"-user",a)),s.user=(e=a?.user)!==null&&e!==void 0?e:le()}else if(s&&!s.user&&!s.user){const a=await D(this.storage,this.storageKey+"-user");a&&a?.user?(s.user=a.user,await T(this.storage,this.storageKey+"-user"),await z(this.storage,this.storageKey,s)):s.user=le()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),s!==null&&await this._removeSession();return}const n=((t=s.expires_at)!==null&&t!==void 0?t:1/0)*1e3-Date.now()<ae;if(this._debug(r,`session has${n?"":" not"} expired with margin of ${ae}s`),n){if(this.autoRefreshToken&&s.refresh_token){const{error:a}=await this._callRefreshToken(s.refresh_token);a&&(console.error(a),oe(a)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",a),await this._removeSession()))}}else if(s.user&&s.user.__isUserNotAvailableProxy===!0)try{const{data:a,error:o}=await this._getUser(s.access_token);!o&&a?.user?(s.user=a.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(r,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(s){this._debug(r,"error",s),console.error(s);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new E;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new ne;const{data:n,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!n.session)throw new E;await this._saveSession(n.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",n.session);const o={data:n.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(n){if(this._debug(s,"error",n),h(n)){const a={data:null,error:n};return oe(n)||await this._removeSession(),(t=this.refreshingDeferred)===null||t===void 0||t.resolve(a),a}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(n),n}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});const n=[],a=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,t)}catch(l){n.push(l)}});if(await Promise.all(a),n.length>0){for(let o=0;o<n.length;o+=1)console.error(n[o]);throw n[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await T(this.storage,`${this.storageKey}-code-verifier`);const t=Object.assign({},e),r=t.user&&t.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&t.user&&await z(this.userStorage,this.storageKey+"-user",{user:t.user});const s=Object.assign({},t);delete s.user;const n=be(s);await z(this.storage,this.storageKey,n)}else{const s=be(t);await z(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await T(this.storage,this.storageKey),await T(this.storage,this.storageKey+"-code-verifier"),await T(this.storage,this.storageKey+"-user"),this.userStorage&&await T(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&I()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),F);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const t=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const 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{const e=Date.now();try{return await this._useSession(async t=>{const{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((r.expires_at*1e3-e)/F);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${F}ms, refresh threshold is ${ce} ticks`),s<=ce&&await this._callRefreshToken(r.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof Ne)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!I()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){const s=[`provider=${encodeURIComponent(t)}`];if(r?.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[n,a]=await G(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(n)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(o.toString())}if(r?.queryParams){const n=new URLSearchParams(r.queryParams);s.push(n.toString())}return r?.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;const{data:s,error:n}=t;return n?this._returnResult({data:null,error:n}):await d(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token})})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;const{data:n,error:a}=t;if(a)return this._returnResult({data:null,error:a});const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:u}=await d(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(r=n?.session)===null||r===void 0?void 0:r.access_token});return u?this._returnResult({data:null,error:u}):(e.factorType==="totp"&&l.type==="totp"&&(!((s=l?.totp)===null||s===void 0)&&s.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async t=>{var r;const{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});const a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Ie(e.webauthn.credential_response):Oe(e.webauthn.credential_response)})}:{code:e.code}),{data:o,error:l}=await d(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),this._returnResult({data:o,error:l}))})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async t=>{var r;const{data:s,error:n}=t;if(n)return this._returnResult({data:null,error:n});const a=await d(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});if(a.error)return a;const{data:o}=a;if(o.type!=="webauthn")return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:Ae(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:Te(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}})}async _challengeAndVerify(e){const{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;const{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};const s={all:[],phone:[],totp:[],webauthn:[]};for(const n of(e=t?.factors)!==null&&e!==void 0?e:[])s.all.push(n),n.status==="verified"&&s[n.factor_type].push(n);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(e){var t,r,s,n;if(e)try{const{payload:_}=Q(e);let p=null;_.aal&&(p=_.aal);let b=p;const{data:{user:v},error:m}=await this.getUser(e);if(m)return this._returnResult({data:null,error:m});((r=(t=v?.factors)===null||t===void 0?void 0:t.filter(S=>S.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(b="aal2");const g=_.amr||[];return{data:{currentLevel:p,nextLevel:b,currentAuthenticationMethods:g},error:null}}catch(_){if(h(_))return this._returnResult({data:null,error:_});throw _}const{data:{session:a},error:o}=await this.getSession();if(o)return this._returnResult({data:null,error:o});if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Q(a.access_token);let u=null;l.aal&&(u=l.aal);let c=u;((n=(s=a.user.factors)===null||s===void 0?void 0:s.filter(_=>_.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(c="aal2");const f=l.amr||[];return{data:{currentLevel:u,nextLevel:c,currentAuthenticationMethods:f},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{const{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?await d(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new E})})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _approveAuthorization(e,t){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new E});const a=await d(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:o=>({data:o,error:null})});return a.data&&a.data.redirect_url&&I()&&!t?.skipBrowserRedirect&&window.location.assign(a.data.redirect_url),a})}catch(r){if(h(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(e,t){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new E});const a=await d(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:o=>({data:o,error:null})});return a.data&&a.data.redirect_url&&I()&&!t?.skipBrowserRedirect&&window.location.assign(a.data.redirect_url),a})}catch(r){if(h(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:t},error:r}=e;return r?this._returnResult({data:null,error:r}):t?await d(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:t.access_token,xform:s=>({data:s,error:null})}):this._returnResult({data:null,error:new E})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async t=>{const{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?(await d(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 E})})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(o=>o.kid===e);if(r)return r;const s=Date.now();if(r=this.jwks.keys.find(o=>o.kid===e),r&&this.jwks_cached_at+ze>s)return r;const{data:n,error:a}=await d(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return!n.keys||n.keys.length===0||(this.jwks=n,this.jwks_cached_at=s,r=n.keys.find(o=>o.kid===e),!r)?null:r}async getClaims(e,t={}){try{let r=e;if(!r){const{data:_,error:p}=await this.getSession();if(p||!_.session)return this._returnResult({data:null,error:p});r=_.session.access_token}const{header:s,payload:n,signature:a,raw:{header:o,payload:l}}=Q(r);t?.allowExpired||_t(n.exp);const u=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,t?.keys?{keys:t.keys}:t?.jwks);if(!u){const{error:_}=await this.getUser(r);if(_)throw _;return{data:{claims:n,header:s,signature:a},error:null}}const c=gt(s.alg),w=await crypto.subtle.importKey("jwk",u,c,!0,["verify"]);if(!await crypto.subtle.verify(c,w,a,tt(`${o}.${l}`)))throw new fe("Invalid JWT signature");return{data:{claims:n,header:s,signature:a},error:null}}catch(r){if(h(r))return this._returnResult({data:null,error:r});throw r}}async signInWithPasskey(e){var t,r,s;C(this.experimental);try{if(!re())return this._returnResult({data:null,error:new x("Browser does not support WebAuthn",null)});const{data:n,error:a}=await this._startPasskeyAuthentication({options:{captchaToken:(t=e?.options)===null||t===void 0?void 0:t.captchaToken}});if(a||!n)return this._returnResult({data:null,error:a});const o=Te(n.options),l=(s=(r=e?.options)===null||r===void 0?void 0:r.signal)!==null&&s!==void 0?s:_e.createNewAbortSignal(),{data:u,error:c}=await Ke({publicKey:o,signal:l});if(c||!u)return this._returnResult({data:null,error:c??new x("WebAuthn ceremony failed",null)});const w=Oe(u);return this._verifyPasskeyAuthentication({challengeId:n.challenge_id,credential:w})}catch(n){if(h(n))return this._returnResult({data:null,error:n});throw n}}async registerPasskey(e){var t,r;C(this.experimental);try{if(!re())return this._returnResult({data:null,error:new x("Browser does not support WebAuthn",null)});const{data:s,error:n}=await this._startPasskeyRegistration();if(n||!s)return this._returnResult({data:null,error:n});const a=Ae(s.options),o=(r=(t=e?.options)===null||t===void 0?void 0:t.signal)!==null&&r!==void 0?r:_e.createNewAbortSignal(),{data:l,error:u}=await De({publicKey:a,signal:o});if(u||!l)return this._returnResult({data:null,error:u??new x("WebAuthn ceremony failed",null)});const c=Ie(l);return this._verifyPasskeyRegistration({challengeId:s.challenge_id,credential:c})}catch(s){if(h(s))return this._returnResult({data:null,error:s});throw s}}async _startPasskeyRegistration(){C(this.experimental);try{return await this._useSession(async e=>{const{data:{session:t},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!t)return this._returnResult({data:null,error:new E});const{data:s,error:n}=await d(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(h(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){C(this.experimental);try{return await this._useSession(async t=>{const{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new E});const{data:n,error:a}=await d(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _startPasskeyAuthentication(e){var t;C(this.experimental);try{const{data:r,error:s}=await d(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(t=e?.options)===null||t===void 0?void 0:t.captchaToken}}});return s?this._returnResult({data:null,error:s}):this._returnResult({data:r,error:null})}catch(r){if(h(r))return this._returnResult({data:null,error:r});throw r}}async _verifyPasskeyAuthentication(e){C(this.experimental);try{const{data:t,error:r}=await d(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:O});return r?this._returnResult({data:null,error:r}):(t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:t,error:null}))}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _listPasskeys(){C(this.experimental);try{return await this._useSession(async e=>{const{data:{session:t},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!t)return this._returnResult({data:null,error:new E});const{data:s,error:n}=await d(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:t.access_token,xform:a=>({data:a,error:null})});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){C(this.experimental);try{return await this._useSession(async t=>{const{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new E});const{data:n,error:a}=await d(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}async _deletePasskey(e){C(this.experimental);try{return await this._useSession(async t=>{const{data:{session:r},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new E});const{error:n}=await d(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(t){if(h(t))return this._returnResult({data:null,error:t});throw t}}}H.nextInstanceID={};const Kt=H;export{Kt as A};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O}from"./vendor-tslib-Du-meQkk.js";const T=e=>e?(...t)=>e(...t):(...t)=>fetch(...t);class x extends Error{constructor(t,c="FunctionsError",o){super(t),this.name=c,this.context=o}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class F extends x{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class A extends x{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class C extends x{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var E;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(E||(E={}));class B{constructor(t,{headers:c={},customFetch:o,region:u=E.Any}={}){this.url=t,this.headers=c,this.region=u,this.fetch=T(o)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return O(this,arguments,void 0,function*(c,o={}){var u;let d,f;try{const{headers:a,method:v,body:s,signal:y,timeout:b}=o;let h={},{region:i}=o;i||(i=this.region);const g=new URL(`${this.url}/${c}`);i&&i!=="any"&&(h["x-region"]=i,g.searchParams.set("forceFunctionRegion",i));let n;s&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&s instanceof Blob||s instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",n=s):typeof s=="string"?(h["Content-Type"]="text/plain",n=s):typeof FormData<"u"&&s instanceof FormData?n=s:(h["Content-Type"]="application/json",n=JSON.stringify(s)):s&&typeof s!="string"&&!(typeof Blob<"u"&&s instanceof Blob)&&!(s instanceof ArrayBuffer)&&!(typeof FormData<"u"&&s instanceof FormData)?n=JSON.stringify(s):n=s;let m=y;b&&(f=new AbortController,d=setTimeout(()=>f.abort(),b),y?(m=f.signal,y.addEventListener("abort",()=>f.abort())):m=f.signal);const r=yield this.fetch(g.toString(),{method:v||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),a),body:n,signal:m}).catch(S=>{throw new F(S)}),w=r.headers.get("x-relay-error");if(w&&w==="true")throw new A(r);if(!r.ok)throw new C(r);let p=((u=r.headers.get("Content-Type"))!==null&&u!==void 0?u:"text/plain").split(";")[0].trim(),l;return p==="application/json"?l=yield r.json():p==="application/octet-stream"||p==="application/pdf"?l=yield r.blob():p==="text/event-stream"?l=r:p==="multipart/form-data"?l=yield r.formData():l=yield r.text(),{data:l,error:null,response:r}}catch(a){return{data:null,error:a,response:a instanceof C||a instanceof A?a.context:void 0}}finally{d&&clearTimeout(d)}})}}export{B as F};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var k=e=>typeof e=="function"?e:function(){return e},H=typeof self<"u"?self:null,v=typeof window<"u"?window:null,d=H||v||globalThis,_="2.0.0",B=1e4,P=1e3,g={connecting:0,open:1,closing:2,closed:3},u={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},p={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},j={longpoll:"longpoll",websocket:"websocket"},N={complete:4},w="base64url.bearer.phx.",y=class{constructor(e,t,i,s){this.channel=e,this.event=t,this.payload=i||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:i}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.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})}},L=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))}},x=class{constructor(e,t,i){this.state=u.closed,this.topic=e,this.params=k(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new y(this,p.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new L(()=>{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=u.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=u.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=u.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=u.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new y(this,p.leave,k({}),this.timeout).send(),this.state=u.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(p.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=u.closed,this.bindings=[]}onClose(e){this.on(p.close,e)}onError(e){return this.on(p.error,t=>e(t))}on(e,t){let i=this.bindingRef++;return this.bindings.push({event:e,ref:i,callback:t}),i}off(e,t){this.bindings=this.bindings.filter(i=>!(i.event===e&&(typeof t>"u"||t===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,i=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new y(this,e,function(){return t},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=u.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(p.close,"leave")},i=new y(this,p.leave,k({}),e);return i.receive("ok",()=>t()).receive("timeout",()=>t()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,i){return t}filterBindings(e,t,i){return!0}isMember(e,t,i,s){return this.topic!==e?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=u.joining,this.joinPush.resend(e))}trigger(e,t,i,s){let n=this.onMessage(e,t,i,s);if(t&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let o=this.bindings.filter(h=>h.event===e&&this.filterBindings(h,t,i));for(let h=0;h<o.length;h++)o[h].callback(n,i,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===u.closed}isErrored(){return this.state===u.errored}isJoined(){return this.state===u.joined}isJoining(){return this.state===u.joining}isLeaving(){return this.state===u.leaving}},E=class{static request(e,t,i,s,n,o,h){if(d.XDomainRequest){let r=new d.XDomainRequest;return this.xdomainRequest(r,e,t,s,n,o,h)}else if(d.XMLHttpRequest){let r=new d.XMLHttpRequest;return this.xhrRequest(r,e,t,i,s,n,o,h)}else{if(d.fetch&&d.AbortController)return this.fetchRequest(e,t,i,s,n,o,h);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(e,t,i,s,n,o,h){let r={method:e,headers:i,body:s},a=null;return n&&(a=new AbortController,setTimeout(()=>a.abort(),n),r.signal=a.signal),d.fetch(t,r).then(l=>l.text()).then(l=>this.parseJSON(l)).then(l=>h&&h(l)).catch(l=>{l.name==="AbortError"&&o?o():h&&h(null)}),a}static xdomainRequest(e,t,i,s,n,o,h){return e.timeout=n,e.open(t,i),e.onload=()=>{let r=this.parseJSON(e.responseText);h&&h(r)},o&&(e.ontimeout=o),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,i,s,n,o,h,r){e.open(t,i,!0),e.timeout=o;for(let[a,l]of Object.entries(s))e.setRequestHeader(a,l);return e.onerror=()=>r&&r(null),e.onreadystatechange=()=>{if(e.readyState===N.complete&&r){let a=this.parseJSON(e.responseText);r(a)}},h&&(e.ontimeout=h),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 i=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let n=t?`${t}[${s}]`:s,o=e[s];typeof o=="object"?i.push(this.serialize(o,n)):i.push(encodeURIComponent(n)+"="+encodeURIComponent(o))}return i.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let i=e.match(/\?/)?"&":"?";return`${e}${i}${this.serialize(t)}`}},$=e=>{let t="",i=new Uint8Array(e),s=i.byteLength;for(let n=0;n<s;n++)t+=String.fromCharCode(i[n]);return btoa(t)},T=class{constructor(e,t){t&&t.length===2&&t[1].startsWith(w)&&(this.authToken=atob(t[1].slice(w.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=g.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+j.websocket),"$1/"+j.longpoll)}endpointURL(){return E.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,i){this.close(e,t,i),this.readyState=g.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===g.open||this.readyState===g.connecting}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),t=>{if(t){var{status:i,token:s,messages:n}=t;if(i===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else i=0;switch(i){case 200:n.forEach(o=>{setTimeout(()=>this.onmessage({data:o}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=g.open,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 new Error(`unhandled poll status ${i}`)}})}send(e){typeof e!="string"&&(e=$(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(`
|
|
2
|
+
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=g.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,i,s,n){let o,h=()=>{this.reqs.delete(o),s()};o=E.request(e,this.endpointURL(),t,i,this.timeout,h,r=>{this.reqs.delete(o),this.isActive()&&n(r)}),this.reqs.add(o)}},O=class C{constructor(t,i={}){let s=i.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,n=>{let{onJoin:o,onLeave:h,onSync:r}=this.caller;this.joinRef=this.channel.joinRef(),this.state=C.syncState(this.state,n,o,h),this.pendingDiffs.forEach(a=>{this.state=C.syncDiff(this.state,a,o,h)}),this.pendingDiffs=[],r()}),this.channel.on(s.diff,n=>{let{onJoin:o,onLeave:h,onSync:r}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=C.syncDiff(this.state,n,o,h),r())})}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}list(t){return C.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(t,i,s,n){let o=this.clone(t),h={},r={};return this.map(o,(a,l)=>{i[a]||(r[a]=l)}),this.map(i,(a,l)=>{let f=o[a];if(f){let c=l.metas.map(b=>b.phx_ref),m=f.metas.map(b=>b.phx_ref),S=l.metas.filter(b=>m.indexOf(b.phx_ref)<0),A=f.metas.filter(b=>c.indexOf(b.phx_ref)<0);S.length>0&&(h[a]=l,h[a].metas=S),A.length>0&&(r[a]=this.clone(f),r[a].metas=A)}else h[a]=l}),this.syncDiff(o,{joins:h,leaves:r},s,n)}static syncDiff(t,i,s,n){let{joins:o,leaves:h}=this.clone(i);return s||(s=function(){}),n||(n=function(){}),this.map(o,(r,a)=>{let l=t[r];if(t[r]=this.clone(a),l){let f=t[r].metas.map(m=>m.phx_ref),c=l.metas.filter(m=>f.indexOf(m.phx_ref)<0);t[r].metas.unshift(...c)}s(r,l,a)}),this.map(h,(r,a)=>{let l=t[r];if(!l)return;let f=a.metas.map(c=>c.phx_ref);l.metas=l.metas.filter(c=>f.indexOf(c.phx_ref)<0),n(r,l,a),l.metas.length===0&&delete t[r]}),t}static list(t,i){return i||(i=function(s,n){return n}),this.map(t,(s,n)=>i(s,n))}static map(t,i){return Object.getOwnPropertyNames(t).map(s=>i(s,t[s]))}static clone(t){return JSON.parse(JSON.stringify(t))}},R={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,o,h]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:o,payload:h})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:o}=e,h=this.META_LENGTH+t.length+i.length+n.length+s.length,r=new ArrayBuffer(this.HEADER_LENGTH+h),a=new DataView(r),l=0;a.setUint8(l++,this.KINDS.push),a.setUint8(l++,t.length),a.setUint8(l++,i.length),a.setUint8(l++,n.length),a.setUint8(l++,s.length),Array.from(t,c=>a.setUint8(l++,c.charCodeAt(0))),Array.from(i,c=>a.setUint8(l++,c.charCodeAt(0))),Array.from(n,c=>a.setUint8(l++,c.charCodeAt(0))),Array.from(s,c=>a.setUint8(l++,c.charCodeAt(0)));var f=new Uint8Array(r.byteLength+o.byteLength);return f.set(new Uint8Array(r),0),f.set(new Uint8Array(o),r.byteLength),f.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){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,i){let s=t.getUint8(1),n=t.getUint8(2),o=t.getUint8(3),h=this.HEADER_LENGTH+this.META_LENGTH-1,r=i.decode(e.slice(h,h+s));h=h+s;let a=i.decode(e.slice(h,h+n));h=h+n;let l=i.decode(e.slice(h,h+o));h=h+o;let f=e.slice(h,e.byteLength);return{join_ref:r,ref:null,topic:a,event:l,payload:f}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),o=t.getUint8(3),h=t.getUint8(4),r=this.HEADER_LENGTH+this.META_LENGTH,a=i.decode(e.slice(r,r+s));r=r+s;let l=i.decode(e.slice(r,r+n));r=r+n;let f=i.decode(e.slice(r,r+o));r=r+o;let c=i.decode(e.slice(r,r+h));r=r+h;let m=e.slice(r,e.byteLength),S={status:c,response:m};return{join_ref:a,ref:l,topic:f,event:p.reply,payload:S}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),o=this.HEADER_LENGTH+2,h=i.decode(e.slice(o,o+s));o=o+s;let r=i.decode(e.slice(o,o+n));o=o+n;let a=e.slice(o,e.byteLength);return{join_ref:null,ref:null,topic:h,event:r,payload:a}}},M=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||B,this.transport=t.transport||d.WebSocket||T,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let i=null;try{i=d&&d.sessionStorage}catch{}this.sessionStore=t.sessionStorage||i,this.establishedConnections=0,this.defaultEncoder=R.encode.bind(R),this.defaultDecoder=R.decode.bind(R),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!==T?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;v&&v.addEventListener&&(v.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),s=this.connectClock)}),v.addEventListener("pageshow",n=>{s===this.connectClock&&(s=null,this.connect())}),v.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?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=n=>t.rejoinAfterMs?t.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>t.reconnectAfterMs?t.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(n,o,h)=>{console.log(`${n}: ${o}`,h)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=k(t.params||{}),this.endPoint=`${e}/${j.websocket}`,this.vsn=t.vsn||_,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new L(()=>{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 T}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=E.appendParams(E.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,i){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,i)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=k(e)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==T?this.connectWithFallback(T,this.longPollFallbackMs):this.transportConnect())}log(e,t,i){this.logger&&this.logger(e,t,i)}hasLogger(){return this.logger!==null}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(),i=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()-i))});return!0}transportName(e){return e===T?"LongPoll":e.name}transportConnect(){this.connectClock++,this.closeWasClean=!1;let e;this.authToken&&(e=["phoenix",`${w}${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=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,n,o,h=this.transportName(e),r=a=>{this.log("transport",`falling back to ${h}...`,a),this.off([n,o]),s=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${h}`))return r("memorized");this.fallbackTimer=setTimeout(r,t),o=this.onError(a=>{this.log("transport","error",a),s&&!i&&(clearTimeout(this.fallbackTimer),r(a))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(i=!0,!s){let a=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${a}`,"true"),this.log("transport",`established ${a} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(r,t),this.ping(a=>{this.log("transport","connected to primary after",a),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(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),P,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,i){if(!this.conn)return e&&e();const s=this.conn;this.waitForBufferDone(s,()=>{t?s.close(t,i||""):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,i=1){if(i===5||!e.bufferedAmount){t();return}setTimeout(()=>{this.waitForBufferDone(e,t,i+1)},150*i)}waitForSocketClosed(e,t,i=1){if(i===5||e.readyState===g.closed){t();return}setTimeout(()=>{this.waitForSocketClosed(e,t,i+1)},150*i)}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,i=this.establishedConnections;this.triggerStateCallbacks("error",e,t,i),(t===this.transport||i>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(p.error,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case g.connecting:return"connecting";case g.open:return"open";case g.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}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(([i])=>e.indexOf(i)===-1)}channel(e,t={}){let i=new x(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:o}=e;this.log("push",`${t} ${i} (${o}, ${n})`,s)}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)))}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){this.heartbeatTimeout();return}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,t=>{let{topic:i,event:s,payload:n,ref:o,join_ref:h}=t;if(o&&o===this.pendingHeartbeatRef){const r=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",r)}catch(a){this.log("error","error in heartbeat callback",a)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${o&&"("+o+")"||""}`.trim(),n);for(let r=0;r<this.channels.length;r++){const a=this.channels[r];a.isMember(i,s,n,h)&&a.trigger(s,n,o,h)}this.triggerStateCallbacks("message",t)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([i,s])=>{try{s(...t)}catch(n){this.log("error",`error in ${e} callback`,n)}})}catch(i){this.log("error",`error triggering ${e} callbacks`,i)}}leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};export{O as P,M as S};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const $=t=>Math.min(1e3*2**t,3e4),T=[520,503],S=["GET","HEAD","OPTIONS"];var E=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function L(t,e){return new Promise(s=>{if(e?.aborted){s();return}const r=setTimeout(()=>{e?.removeEventListener("abort",l),s()},t);function l(){clearTimeout(r),s()}e?.addEventListener("abort",l)})}function x(t,e,s,r){return!(!r||s>=3||!S.includes(t)||!T.includes(e))}var k=class{constructor(t){var e,s,r,l,a;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.shouldStripNulls=(r=t.shouldStripNulls)!==null&&r!==void 0?r:!1,this.urlLengthLimit=(l=t.urlLengthLimit)!==null&&l!==void 0?l:8e3,this.retryEnabled=(a=t.retry)!==null&&a!==void 0?a:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}retry(t){return this.retryEnabled=t,this}then(t,e){var s=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const i=this.headers.get("Accept");i==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!i||i==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const r=this.fetch;let a=(async()=>{let i=0;for(;;){const o=new Headers(s.headers);i>0&&o.set("X-Retry-Count",String(i));let c;try{c=await r(s.url.toString(),{method:s.method,headers:o,body:JSON.stringify(s.body,(n,d)=>typeof d=="bigint"?d.toString():d),signal:s.signal})}catch(n){if(n?.name==="AbortError"||n?.code==="ABORT_ERR"||!S.includes(s.method))throw n;if(s.retryEnabled&&i<3){const d=$(i);i++,await L(d,s.signal);continue}throw n}if(x(s.method,c.status,i,s.retryEnabled)){var u,h;const n=(u=(h=c.headers)===null||h===void 0?void 0:h.get("Retry-After"))!==null&&u!==void 0?u:null,d=n!==null?Math.max(0,parseInt(n,10)||0)*1e3:$(i);await c.text(),i++,await L(d,s.signal);continue}return await s.processResponse(c)}})();return this.shouldThrowOnError||(a=a.catch(i=>{var u;let h="",o="",c="";const n=i?.cause;if(n){var d,p,f,P;const R=(d=n?.message)!==null&&d!==void 0?d:"",w=(p=n?.code)!==null&&p!==void 0?p:"";h=`${(f=i?.name)!==null&&f!==void 0?f:"FetchError"}: ${i?.message}`,h+=`
|
|
2
|
+
|
|
3
|
+
Caused by: ${(P=n?.name)!==null&&P!==void 0?P:"Error"}: ${R}`,w&&(h+=` (${w})`),n?.stack&&(h+=`
|
|
4
|
+
${n.stack}`)}else{var b;h=(b=i?.stack)!==null&&b!==void 0?b:""}const g=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(c="",o="Request was aborted (timeout or manual cancellation)",g>this.urlLengthLimit&&(o+=`. Note: Your request URL is ${g} 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.`)):(n?.name==="HeadersOverflowError"||n?.code==="UND_ERR_HEADERS_OVERFLOW")&&(c="",o="HTTP headers exceeded server limits (typically 16KB)",g>this.urlLengthLimit&&(o+=`. Your request URL is ${g} 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:`${(u=i?.name)!==null&&u!==void 0?u:"FetchError"}: ${i?.message}`,details:h,hint:o,code:c},data:null,count:null,status:0,statusText:""}})),a.then(t,e)}async processResponse(t){var e=this;let s=null,r=null,l=null,a=t.status,i=t.statusText;if(t.ok){var u,h;if(e.method!=="HEAD"){var o;const d=await t.text();d===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((o=e.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?r=d:r=JSON.parse(d))}const c=(u=e.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),n=(h=t.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");c&&n&&n.length>1&&(l=parseInt(n[1])),e.isMaybeSingle&&Array.isArray(r)&&(r.length>1?(s={code:"PGRST116",details:`Results contain ${r.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,l=null,a=406,i="Not Acceptable"):r.length===1?r=r[0]:r=null)}else{const c=await t.text();try{s=JSON.parse(c),Array.isArray(s)&&t.status===404&&(r=[],s=null,a=200,i="OK")}catch{t.status===404&&c===""?(a=204,i="No Content"):s={message:c}}if(s&&e.shouldThrowOnError)throw new E(s)}return{success:s===null,error:s,data:r,count:l,status:a,statusText:i}}returns(){return this}overrideTypes(){return this}},H=class extends k{select(t){let e=!1;const s=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:r,referencedTable:l=r}={}){const a=l?`${l}.order`:"order",i=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${i?`${i},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const r=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:r=s}={}){const l=typeof r>"u"?"offset":`${r}.offset`,a=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(l,`${t}`),this.url.searchParams.set(a,`${e-t+1}`),this}abortSignal(t){return this.signal=t,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:t=!1,verbose:e=!1,settings:s=!1,buffers:r=!1,wal:l=!1,format:a="text"}={}){var i;const u=[t?"analyze":null,e?"verbose":null,s?"settings":null,r?"buffers":null,l?"wal":null].filter(Boolean).join("|"),h=(i=this.headers.get("Accept"))!==null&&i!==void 0?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${h}"; options=${u};`),a==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const A=new RegExp("[,()]");var m=class extends H{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&A.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&A.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:r}={}){let l="";r==="plain"?l="pl":r==="phrase"?l="ph":r==="websearch"&&(l="w");const a=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${l}fts${a}.${e}`),this}match(t){return Object.entries(t).filter(([e,s])=>s!==void 0).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){const r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},D=class{constructor(t,{headers:e={},schema:s,fetch:r,urlLengthLimit:l=8e3,retry:a}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=r,this.urlLengthLimit=l,this.retry=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:s=!1,count:r}=e??{},l=s?"HEAD":"GET";let a=!1;const i=(t??"*").split("").map(o=>/\s/.test(o)&&!a?"":(o==='"'&&(a=!a),o)).join(""),{url:u,headers:h}=this.cloneRequestState();return u.searchParams.set("select",i),r&&h.append("Prefer",`count=${r}`),new m({method:l,url:u,headers:h,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:s=!0}={}){var r;const l="POST",{url:a,headers:i}=this.cloneRequestState();if(e&&i.append("Prefer",`count=${e}`),s||i.append("Prefer","missing=default"),Array.isArray(t)){const u=t.reduce((h,o)=>h.concat(Object.keys(o)),[]);if(u.length>0){const h=[...new Set(u)].map(o=>`"${o}"`);a.searchParams.set("columns",h.join(","))}}return new m({method:l,url:a,headers:i,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:r,defaultToNull:l=!0}={}){var a;const i="POST",{url:u,headers:h}=this.cloneRequestState();if(h.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&u.searchParams.set("on_conflict",e),r&&h.append("Prefer",`count=${r}`),l||h.append("Prefer","missing=default"),Array.isArray(t)){const o=t.reduce((c,n)=>c.concat(Object.keys(n)),[]);if(o.length>0){const c=[...new Set(o)].map(n=>`"${n}"`);u.searchParams.set("columns",c.join(","))}}return new m({method:i,url:u,headers:h,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var s;const r="PATCH",{url:l,headers:a}=this.cloneRequestState();return e&&a.append("Prefer",`count=${e}`),new m({method:r,url:l,headers:a,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;const s="DELETE",{url:r,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new m({method:s,url:r,headers:l,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function y(t){"@babel/helpers - typeof";return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(t)}function N(t,e){if(y(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(y(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function q(t){var e=N(t,"string");return y(e)=="symbol"?e:e+""}function C(t,e,s){return(e=q(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function O(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,r)}return s}function v(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?O(Object(s),!0).forEach(function(r){C(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):O(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var _=class j{constructor(e,{headers:s={},schema:r,fetch:l,timeout:a,urlLengthLimit:i=8e3,retry:u}={}){this.url=e,this.headers=new Headers(s),this.schemaName=r,this.urlLengthLimit=i;const h=l??globalThis.fetch;a!==void 0&&a>0?this.fetch=(o,c)=>{const n=new AbortController,d=setTimeout(()=>n.abort(),a),p=c?.signal;if(p){if(p.aborted)return clearTimeout(d),h(o,c);const f=()=>{clearTimeout(d),n.abort()};return p.addEventListener("abort",f,{once:!0}),h(o,v(v({},c),{},{signal:n.signal})).finally(()=>{clearTimeout(d),p.removeEventListener("abort",f)})}return h(o,v(v({},c),{},{signal:n.signal})).finally(()=>clearTimeout(d))}:this.fetch=h,this.retry=u}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new D(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new j(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,s={},{head:r=!1,get:l=!1,count:a}={}){var i;let u;const h=new URL(`${this.url}/rpc/${e}`);let o;const c=p=>p!==null&&typeof p=="object"&&(!Array.isArray(p)||p.some(c)),n=r&&Object.values(s).some(c);n?(u="POST",o=s):r||l?(u=r?"HEAD":"GET",Object.entries(s).filter(([p,f])=>f!==void 0).map(([p,f])=>[p,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([p,f])=>{h.searchParams.append(p,f)})):(u="POST",o=s);const d=new Headers(this.headers);return n?d.set("Prefer",a?`count=${a},return=minimal`:"return=minimal"):a&&d.set("Prefer",`count=${a}`),new m({method:u,url:h,headers:d,schema:this.schemaName,body:o,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};export{_ as P};
|