@objectstack/console 17.5.0 → 17.6.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/CHANGELOG.md +378 -0
- package/dist/.objectstack-injection.json +2 -2
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{ActionResultDialog-CLdIyOW6.js → ActionResultDialog-4kHDGnT3.js} +3 -3
- package/dist/assets/{AiPendingActionsPage-OKYz66yR.js → AiPendingActionsPage-JjOddm0h.js} +1 -1
- package/dist/assets/{ApiConsolePage-CcrKovu8.js → ApiConsolePage-BgS26lbp.js} +1 -1
- package/dist/assets/AppDocsIndex-BDoH5ECM.js +1 -0
- package/dist/assets/{AppManagementPage-D_xz8cTZ.js → AppManagementPage-CCgKmNTj.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-C6S1vk0X.js +1 -0
- package/dist/assets/AuditLogPage-v2dKXMuk.js +1 -0
- package/dist/assets/BookPage-DwFMcTSN.js +1 -0
- package/dist/assets/{ComponentNavView-BxsixSU9.js → ComponentNavView-B5g9c6fx.js} +1 -1
- package/dist/assets/{CreateViewDialog-xyKlpLEW.js → CreateViewDialog-D3l-tYHM.js} +1 -1
- package/dist/assets/DashboardView-BOcovpPd.js +1 -0
- package/dist/assets/DocPage-B6AkH5WI.js +1 -0
- package/dist/assets/{DocsIndex-B2zw_HAp.js → DocsIndex-DwW2QsYY.js} +1 -1
- package/dist/assets/{DocsLayout-DezZ8x7_.js → DocsLayout-D63StSgd.js} +1 -1
- package/dist/assets/DocsSlug-CP9fcabi.js +1 -0
- package/dist/assets/ExpressionProvider-CrL6jhVq.js +1 -0
- package/dist/assets/{FlowRunsPage-CvY3nJMF.js → FlowRunsPage-CxdaiUyk.js} +1 -1
- package/dist/assets/{IntegrationsPage-2leVkVDH.js → IntegrationsPage-DvG0x0Nb.js} +2 -2
- package/dist/assets/{InterfaceListPage-BdECC_i3.js → InterfaceListPage-C4wPYohR.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-EPPHSitW.js → MarketplaceInstalledPage-B7KETQG2.js} +1 -1
- package/dist/assets/MarketplacePackagePage-CfgKDpNH.js +4 -0
- package/dist/assets/{MarketplacePage-BnQKykgv.js → MarketplacePage-DNEyU5AE.js} +1 -1
- package/dist/assets/{MetadataInspector-BWxLkr0O.js → MetadataInspector-EP0I3-Kq.js} +1 -1
- package/dist/assets/{ObjectDataPage-BIzp65Mo.js → ObjectDataPage-CykEm9MD.js} +1 -1
- package/dist/assets/PageView-C6u86tni.js +1 -0
- package/dist/assets/{ProfilePage-D2qGgxPK.js → ProfilePage-C3SjXMzi.js} +1 -1
- package/dist/assets/{PublicFormsPage-DlE6tck_.js → PublicFormsPage-D3uCTR-8.js} +1 -1
- package/dist/assets/RecordDetailView-DgR_zhP4.js +3 -0
- package/dist/assets/RecordFormPage-kiJI-ieF.js +1 -0
- package/dist/assets/ReportDefaultInspector-BIinF0EQ.js +1 -0
- package/dist/assets/{ReportView-GIdKJdOt.js → ReportView-BREO-ADE.js} +1 -1
- package/dist/assets/{RuntimeDraftBar-BbMdi3Kp.js → RuntimeDraftBar-BCWfd2yS.js} +1 -1
- package/dist/assets/SchemaForm-C4uMMZ13.js +3 -0
- package/dist/assets/SearchResultsPage-C6Hw_Lpn.js +1 -0
- package/dist/assets/{SettingsHub-BGKIj-Zq.js → SettingsHub-DP1mrzEN.js} +1 -1
- package/dist/assets/SettingsView-u7mc6pcc.js +1 -0
- package/dist/assets/{SkeletonDetail-C8fMI-Mu.js → SkeletonDetail-DIwlbHTr.js} +1 -1
- package/dist/assets/{af-BfSmLD34.js → af-DPUgkQl0.js} +1 -1
- package/dist/assets/ai-DPBykF2N.js +3 -0
- package/dist/assets/{app-shell-eager-leaves-CDVclng4.js → app-shell-eager-leaves-Cf2bM6uT.js} +1 -1
- package/dist/assets/{ar-B9ttrM75.js → ar-B-6GTIRU.js} +1 -1
- package/dist/assets/{ar-DZ-C1rn-cyl.js → ar-DZ-wEl298ti.js} +1 -1
- package/dist/assets/{ar-EG-BaDxKP_o.js → ar-EG-YBT90_S0.js} +1 -1
- package/dist/assets/{ar-MA-DbxNEcmd.js → ar-MA-3uT-EYh6.js} +1 -1
- package/dist/assets/{ar-SA-DeC5LXcX.js → ar-SA-SiQsjhhc.js} +1 -1
- package/dist/assets/{ar-TN-C9KpTFJz.js → ar-TN-CfzXjKzS.js} +1 -1
- package/dist/assets/{az-cMerDwRO.js → az-BqAfcNza.js} +1 -1
- package/dist/assets/{be-ZTSbszQh.js → be-CQgWXa9_.js} +1 -1
- package/dist/assets/{be-tarask-BXZEUrgX.js → be-tarask-BmNg0Sir.js} +1 -1
- package/dist/assets/{bg-BDogpmn5.js → bg-D3evgRuS.js} +1 -1
- package/dist/assets/{bn-Cz04uxmh.js → bn-uItkARwm.js} +1 -1
- package/dist/assets/{bs-CpFnCl-j.js → bs-DueReOpO.js} +1 -1
- package/dist/assets/{ca-CHC4M52Z.js → ca-Cr3AHktR.js} +1 -1
- package/dist/assets/{ckb-Dxw-RNm8.js → ckb-CTi5BET7.js} +1 -1
- package/dist/assets/contracts-DieHW666.js +1 -0
- package/dist/assets/{createDerive-DvA_JGNq.js → createDerive-CjN1i5vn.js} +1 -1
- package/dist/assets/{cs-DsFaJ5Z7.js → cs-43mFX9jr.js} +1 -1
- package/dist/assets/{cy-FH4JFDTs.js → cy-BBSkg3F8.js} +1 -1
- package/dist/assets/{da-D1pVjaAq.js → da-C5oA5qcs.js} +1 -1
- package/dist/assets/data-adapter-Cymvlczj.js +1 -0
- package/dist/assets/{de-AT-DUMQCisj.js → de-AT-CApxwJzu.js} +1 -1
- package/dist/assets/{de-DKrxSvnP.js → de-CPtbLlAf.js} +1 -1
- package/dist/assets/default-inspector-registry-Bs6GBn00.js +1 -0
- package/dist/assets/dist-BF-ssUpn.js +14 -0
- package/dist/assets/{el-l3-bHySV.js → el-Dto2xBQU.js} +1 -1
- package/dist/assets/en-AU-FVwCiDJO.js +1 -0
- package/dist/assets/{en-CA-DGH5NF0a.js → en-CA-DKuJPN1U.js} +1 -1
- package/dist/assets/en-GB-DQ_y5VbJ.js +1 -0
- package/dist/assets/en-IE-DaXOhsZW.js +1 -0
- package/dist/assets/en-IN-CnRZnAom.js +1 -0
- package/dist/assets/en-NZ-CBZLEToK.js +1 -0
- package/dist/assets/en-ZA-BE59v0wZ.js +1 -0
- package/dist/assets/{eo-CL6CXHZx.js → eo-BL8JXIWd.js} +1 -1
- package/dist/assets/{es-BIJ0rksI.js → es-BnoaNxsu.js} +1 -1
- package/dist/assets/{et-BGgMzjm1.js → et-tPYLNenO.js} +1 -1
- package/dist/assets/{eu-CqvAoRrX.js → eu-CUBG6bT0.js} +1 -1
- package/dist/assets/{fa-IR-DNz3oA1-.js → fa-IR-Rr2d9xSs.js} +1 -1
- package/dist/assets/{fi-DNSfKWuW.js → fi-B0NVIZsV.js} +1 -1
- package/dist/assets/{formatLong-CHb9WA3O.js → formatLong-1-gt9bpo.js} +1 -1
- package/dist/assets/{fr-DYRJCirJ.js → fr-BbhHek8e.js} +1 -1
- package/dist/assets/{fr-CA-CotiswPx.js → fr-CA-CBDvLXFg.js} +1 -1
- package/dist/assets/{fr-CH-CpiEYWpc.js → fr-CH-WPNmwPn7.js} +1 -1
- package/dist/assets/framework-DFR4HNtj.js +35 -0
- package/dist/assets/{fy-B69yM3FE.js → fy-DvOBbvEF.js} +1 -1
- package/dist/assets/{gd-BAy8AsX6.js → gd-BQPiTPX5.js} +1 -1
- package/dist/assets/getIcon-Cfwf-Egt.js +1 -0
- package/dist/assets/{gl-soLn_weL.js → gl-BJCXK8uO.js} +1 -1
- package/dist/assets/{gu-B19Yo9yC.js → gu-CctPRz3V.js} +1 -1
- package/dist/assets/{he-DYTPo33p.js → he-CVFMk6p2.js} +1 -1
- package/dist/assets/{hi-D2dIK7Oy.js → hi-Ba30-RwS.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-CExufvVt.js → highlighted-body-OFNGDK62-BQ57IrBV.js} +1 -1
- package/dist/assets/{hr-BV-VOPMu.js → hr-BZUqTbZs.js} +1 -1
- package/dist/assets/{ht-C7MM4qkS.js → ht-BLe05tPx.js} +1 -1
- package/dist/assets/{hu-Rha1m2Ym.js → hu-2CQ_Mkww.js} +1 -1
- package/dist/assets/{hy-CiTNgbdV.js → hy-CclcPG4H.js} +1 -1
- package/dist/assets/i18n-BnUsCaSC.js +17 -0
- package/dist/assets/i18n-locale-ar-92O_xtDZ.js +4 -0
- package/dist/assets/i18n-locale-de-T5ic3yH9.js +4 -0
- package/dist/assets/i18n-locale-en-rxr7WJYl.js +4 -0
- package/dist/assets/i18n-locale-es-D_WOifJ_.js +4 -0
- package/dist/assets/i18n-locale-fr-3cvyjMkp.js +4 -0
- package/dist/assets/i18n-locale-ja-DXlIkB8I.js +4 -0
- package/dist/assets/i18n-locale-ko-DngRpS45.js +4 -0
- package/dist/assets/i18n-locale-pt-BkPaFCqZ.js +4 -0
- package/dist/assets/i18n-locale-ru-E5wLh-y6.js +4 -0
- package/dist/assets/i18n-locale-zh-BL4_Yand.js +4 -0
- package/dist/assets/{i18n-runtime-CTgAQF4N.js → i18n-runtime-97_bDVjP.js} +1 -1
- package/dist/assets/{id-Cijsfjt-.js → id-6JLB8s-f.js} +1 -1
- package/dist/assets/index-Cadlh4t_.css +2 -0
- package/dist/assets/index-D98sa5GF.js +20 -0
- package/dist/assets/{infrastructure-BHSync5f.js → infrastructure-Cc34lEqb.js} +2 -2
- package/dist/assets/integration-CeAF4JFT.js +1 -0
- package/dist/assets/{is-xS1WTyeC.js → is-to0CWzm1.js} +1 -1
- package/dist/assets/isSameWeek-DBXaA1Gd.js +1 -0
- package/dist/assets/{it-CH-l516ZNXj.js → it-CH-DhdfjP5Z.js} +1 -1
- package/dist/assets/{it-C2i_c9sd.js → it-ea0B8Ujp.js} +1 -1
- package/dist/assets/{ja-D9_ewLny.js → ja-B1bzkgDW.js} +1 -1
- package/dist/assets/{ja-Hira-D_6ExgHw.js → ja-Hira-CMrY5hXO.js} +1 -1
- package/dist/assets/{ka-BYHGyees.js → ka-DKSXLnXP.js} +1 -1
- package/dist/assets/{kk-CbTFtuqb.js → kk-DHwMv8Dn.js} +1 -1
- package/dist/assets/{km-Dr2gwhIn.js → km-tpLG1xNr.js} +1 -1
- package/dist/assets/{kn-CprH8JD7.js → kn-MLreVnHA.js} +1 -1
- package/dist/assets/{ko-CsFS2u5i.js → ko-CI0DBazn.js} +1 -1
- package/dist/assets/{lb-CbFKN7Ob.js → lb-CmL572Xe.js} +1 -1
- package/dist/assets/{lt-Bq0xkLp0.js → lt-DRtUOLdw.js} +1 -1
- package/dist/assets/{lv-Cj6vg6Qo.js → lv-COSHgkOP.js} +1 -1
- package/dist/assets/{match-C_jFGO9e.js → match-B-ergJQb.js} +1 -1
- package/dist/assets/{match-CiPp9BME.js → match-BQoOW8Cj.js} +1 -1
- package/dist/assets/{match-Co4ivumx.js → match-dfBS0YSQ.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-Bb17TtNP.js +1 -0
- package/dist/assets/metadata-admin-CABUxbJl.js +9 -0
- package/dist/assets/{mk-MXFM99YL.js → mk-B0IH_YL_.js} +1 -1
- package/dist/assets/{mn-D5Q9B6Jt.js → mn-P-QdQ2n3.js} +1 -1
- package/dist/assets/{ms-CCzPRldx.js → ms-CtyEOINy.js} +1 -1
- package/dist/assets/{mt-mjJpN6xW.js → mt-DfuZ2HRm.js} +1 -1
- package/dist/assets/{nb-BIlNqdEb.js → nb-2Hp-5Tnt.js} +1 -1
- package/dist/assets/{nl-BE-FwXjQsmV.js → nl-BE-mmxbfNoR.js} +1 -1
- package/dist/assets/{nl-D2uBtIxG.js → nl-CZ_nLREz.js} +1 -1
- package/dist/assets/{nn-B0loJ7SV.js → nn-ccWhYsNa.js} +1 -1
- package/dist/assets/{oc-U7-yH1sO.js → oc-z504BFRV.js} +1 -1
- package/dist/assets/{pl-mTy0JYgi.js → pl-DeQ7ASt-.js} +1 -1
- package/dist/assets/plugin-calendar-Cn5HaZU8.js +1 -0
- package/dist/assets/plugin-charts-B6RcFWbo.js +7 -0
- package/dist/assets/plugin-chatbot-Ck47EhDX.js +122 -0
- package/dist/assets/plugin-dashboard-DjEx8e5Y.js +6 -0
- package/dist/assets/plugin-form-CLDvL0up.js +1 -0
- package/dist/assets/plugin-gantt-CrVrxVdi.js +63 -0
- package/dist/assets/plugin-grid-D2rmQEW_.js +11 -0
- package/dist/assets/plugin-kanban-BUNHFfIC.js +1 -0
- package/dist/assets/plugin-map-y-7RQQC5.js +1 -0
- package/dist/assets/{plugin-markdown-D1nTQc1T.js → plugin-markdown-BOkHcir_.js} +1 -1
- package/dist/assets/plugin-report-mT3jpna0.js +59 -0
- package/dist/assets/plugin-timeline-B1EF83D3.js +1 -0
- package/dist/assets/plugin-tree-MTHUt3_S.js +1 -0
- package/dist/assets/plugin-view-DHJI-ahf.js +1 -0
- package/dist/assets/plugins-views-CfkgqD30.js +3 -0
- package/dist/assets/{pt-BR-2KtO5Js1.js → pt-BR-D80_lPYF.js} +1 -1
- package/dist/assets/{pt-Bet5OOQf.js → pt-CJJ1RmXd.js} +1 -1
- package/dist/assets/{ro-37U6sgzi.js → ro-EuFb2TCj.js} +1 -1
- package/dist/assets/{ru-CyuAY-5E.js → ru-CMaVQScp.js} +1 -1
- package/dist/assets/{runtime-metadata-persistence-afAW-MeD.js → runtime-metadata-persistence-ClOTznqa.js} +1 -1
- package/dist/assets/{se-DeJabuC6.js → se-DsfdKLdF.js} +1 -1
- package/dist/assets/{sk-DWEpjfkR.js → sk-BNV9omI8.js} +1 -1
- package/dist/assets/{sl-4oSvNhIR.js → sl-DJS_nINU.js} +1 -1
- package/dist/assets/{sq-BjkBCaXW.js → sq-HEgjcbHe.js} +1 -1
- package/dist/assets/{sr-Dxm1DsRS.js → sr-CO0CFu4X.js} +1 -1
- package/dist/assets/{sr-Latn-Dawg6oP2.js → sr-Latn-eE1Idzey.js} +1 -1
- package/dist/assets/{src-C8NYjdVm.js → src-BU7L2v4J.js} +1 -1
- package/dist/assets/src-BUtIBFDA.js +1 -0
- package/dist/assets/src-C0eXlKtx.js +16 -0
- package/dist/assets/{studioEntry-nXQP3iL0.js → studioEntry-WeMfaSGn.js} +1 -1
- package/dist/assets/{submitRedirect-jK-cEIbP.js → submitRedirect-C2lfZSHt.js} +1 -1
- package/dist/assets/{sv-CROOGJGz.js → sv-5uTzgQT3.js} +1 -1
- package/dist/assets/{ta-BZnTmFI_.js → ta-BzgdkBZG.js} +1 -1
- package/dist/assets/{te-BN0v0x5t.js → te-Ct_pl7ZJ.js} +1 -1
- package/dist/assets/{th-CBjKhp_U.js → th-DouAlk0-.js} +1 -1
- package/dist/assets/{tr-x0Ne4N4H.js → tr-3XNBsI40.js} +1 -1
- package/dist/assets/types-zod-DXpXw10W.js +1 -0
- package/dist/assets/{ug-sgzNhsKo.js → ug-B9n24h9G.js} +1 -1
- package/dist/assets/ui-components-D6cEVg0T.js +37 -0
- package/dist/assets/ui-layout-DgVDuPEM.js +1 -0
- package/dist/assets/{uk-o_DQ5VHJ.js → uk-DCAenByf.js} +1 -1
- package/dist/assets/use-book-data-CwRldFxP.js +1 -0
- package/dist/assets/{useActionModal-CSvbHkQ7.js → useActionModal-Blp4rhOk.js} +1 -1
- package/dist/assets/useCanAuthorMetadata-BxCMgFRf.js +1 -0
- package/dist/assets/useNavSelDeepLink-67Y4qCNO.js +1 -0
- package/dist/assets/useNavTargetLabel-BOJncjIb.js +1 -0
- package/dist/assets/{useOpenRecordList-B5-qaFUx.js → useOpenRecordList-BrwJFojQ.js} +1 -1
- package/dist/assets/{usePackageL10n-CMx66am-.js → usePackageL10n-Ci9uVkRZ.js} +1 -1
- package/dist/assets/{useSettingsLabel-Kkr2q0Oo.js → useSettingsLabel-CeMnMWsh.js} +1 -1
- package/dist/assets/{uz-Cyrl-DbtkQtz_.js → uz-Cyrl-JSeHEqu-.js} +1 -1
- package/dist/assets/{uz-Be41d4jl.js → uz-DT3s9bZS.js} +1 -1
- package/dist/assets/vendor-objectstack-DFqu45yM.js +138 -0
- package/dist/assets/{vi-84mZmklk.js → vi-D2p-h6bY.js} +1 -1
- package/dist/assets/{zh-CN-DD1reegJ.js → zh-CN-DHOKqAit.js} +1 -1
- package/dist/assets/{zh-HK-B05u30WI.js → zh-HK-D4iIPY7I.js} +1 -1
- package/dist/assets/{zh-TW-Bb-WimPD.js → zh-TW-gORQ_tZh.js} +1 -1
- package/dist/chunk-membership.json +100 -90
- package/dist/eager-closure.json +110 -110
- package/dist/index.html +4 -4
- package/dist/sdui.manifest.json +520 -60
- package/package.json +1 -1
- package/dist/assets/AppDocsIndex-F4zDq2zz.js +0 -1
- package/dist/assets/ApprovalsInboxPage-DrEUmaDb.js +0 -1
- package/dist/assets/AuditLogPage-CoghqsZb.js +0 -1
- package/dist/assets/DashboardView-CGC-_Om8.js +0 -1
- package/dist/assets/DocPage-CIZE5kdj.js +0 -1
- package/dist/assets/DocsSlug-DXdFdwlS.js +0 -1
- package/dist/assets/ExpressionProvider-DZfMwyMs.js +0 -1
- package/dist/assets/MarketplacePackagePage-C7NOu2Ir.js +0 -4
- package/dist/assets/PageView-CVLgCRSF.js +0 -1
- package/dist/assets/RecordDetailView-DQKydU7X.js +0 -3
- package/dist/assets/RecordFormPage-BTjwxJIA.js +0 -1
- package/dist/assets/ReportDefaultInspector-DdsQAkd7.js +0 -1
- package/dist/assets/SchemaForm-C8X1ve4p.js +0 -3
- package/dist/assets/SearchResultsPage-Jwhqsdyo.js +0 -1
- package/dist/assets/SettingsView-D8SMKdrc.js +0 -1
- package/dist/assets/appRoute-DbnWDEa1.js +0 -1
- package/dist/assets/data-adapter-DMbe6Njk.js +0 -1
- package/dist/assets/default-inspector-registry-CpL3fFhl.js +0 -1
- package/dist/assets/dist-BXrEV1ag.js +0 -13
- package/dist/assets/en-AU-C6x7mDhH.js +0 -1
- package/dist/assets/en-GB-0-nho2eK.js +0 -1
- package/dist/assets/en-IE-2fC3BkfV.js +0 -1
- package/dist/assets/en-IN-C1QcFhxn.js +0 -1
- package/dist/assets/en-NZ-C80ptZT7.js +0 -1
- package/dist/assets/en-ZA-ByZDrjeb.js +0 -1
- package/dist/assets/framework-DcWkeiND.js +0 -35
- package/dist/assets/getIcon-BEVyC4y3.js +0 -1
- package/dist/assets/i18n-CEKxYdmD.js +0 -9
- package/dist/assets/i18n-locale-ar-DN7sl3GF.js +0 -4
- package/dist/assets/i18n-locale-de-C40JErvb.js +0 -4
- package/dist/assets/i18n-locale-en-CITPDIHy.js +0 -4
- package/dist/assets/i18n-locale-es-C8DdWN6c.js +0 -4
- package/dist/assets/i18n-locale-fr-COIdEZZl.js +0 -4
- package/dist/assets/i18n-locale-ja-DYF_rU_s.js +0 -4
- package/dist/assets/i18n-locale-ko-B-ODYAtX.js +0 -4
- package/dist/assets/i18n-locale-pt-CK1SyBIm.js +0 -4
- package/dist/assets/i18n-locale-ru-jLzvShMO.js +0 -4
- package/dist/assets/i18n-locale-zh-Bf9Gbbvl.js +0 -4
- package/dist/assets/index-CLyvpiGc.css +0 -2
- package/dist/assets/index-CfnfGw5W.js +0 -20
- package/dist/assets/isSameWeek-DWYeNyh8.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-DVLc_uym.js +0 -1
- package/dist/assets/metadata-admin-CybaOCdO.js +0 -9
- package/dist/assets/nav-selection-Dzm_mA3C.js +0 -1
- package/dist/assets/plugin-calendar-CKRBcML7.js +0 -1
- package/dist/assets/plugin-charts-DGTJxXCB.js +0 -7
- package/dist/assets/plugin-chatbot-DwtwNA-y.js +0 -122
- package/dist/assets/plugin-dashboard-C1AYKmGX.js +0 -6
- package/dist/assets/plugin-form-CV8ZY04-.js +0 -1
- package/dist/assets/plugin-gantt-BRIb2_8G.js +0 -63
- package/dist/assets/plugin-grid-C9h7mRVv.js +0 -11
- package/dist/assets/plugin-kanban-BcJ0Dhys.js +0 -1
- package/dist/assets/plugin-map-D24ZUOUj.js +0 -1
- package/dist/assets/plugin-report-BfGintAq.js +0 -59
- package/dist/assets/plugin-timeline-CbBRq_qt.js +0 -1
- package/dist/assets/plugin-tree-BNX2A5J5.js +0 -1
- package/dist/assets/plugin-view-DzWQWYyH.js +0 -1
- package/dist/assets/plugins-views-DraK4xz0.js +0 -3
- package/dist/assets/src-B8lv0plz.js +0 -18
- package/dist/assets/src-DoDvT77T.js +0 -1
- package/dist/assets/types-zod-Y2RwUUeJ.js +0 -1
- package/dist/assets/ui-components-BTB1NkUW.js +0 -37
- package/dist/assets/ui-layout-bZfafwJa.js +0 -1
- package/dist/assets/use-book-data-C3eyZJSG.js +0 -1
- package/dist/assets/vendor-objectstack-XuWC71M9.js +0 -266
- package/dist/assets/vendor-zod-CHLW1iCr.js +0 -64
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t,v as n}from"./vendor-react-BggL7APJ.js";import{Br as r,Ir as i,Lr as a,Rr as o,zr as s}from"./vendor-objectstack-XuWC71M9.js";var c=e(n(),1),l=new Set,u={emit(e){for(let t of Array.from(l))try{t(e)}catch{}},subscribe(e){return l.add(e),()=>{l.delete(e)}}};function d(e,t){if(e!==403||!t||typeof t!=`object`)return null;let n=t.error;if(!n||typeof n!=`object`)return null;let r=n.code;if(r===`MFA_REQUIRED`||r===`PASSWORD_EXPIRED`){let e=n.message;return{code:r,message:typeof e==`string`?e:``}}return null}var f=(0,c.createContext)(null);f.displayName=`AuthContext`;var p=`1.7.2`,m=Symbol.for(`better-auth:broadcast-channel`),h=()=>Math.floor(Date.now()/1e3),g=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(!(typeof window>`u`))try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:h()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function _(e=`better-auth.message`){return globalThis[m]||(globalThis[m]=new g(e)),globalThis[m]}var v=[],y=0,b=null,x=4,S=globalThis.nanostoresGlobal||={epoch:0},C=()=>{let e;for(y=0;y<v.length;y+=x)try{v[y](v[y+1].value,v[y+2],v[y+3])}catch(t){e=t}if(v.length=0,e)throw e},w=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=y+x;t<v.length;)v[t]===e?v.splice(t,x):t+=x;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){S.epoch++;let i=!v.length&&!0;for(let i of t)b?.has(i)||(b?.add(i),v.push(i,n,e,r));i&&C()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},T=2,E=5,D=6,O=10,ee=(e,t,n,r)=>(e.events=e.events||{},e.events[n+O]||(e.events[n+O]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);r.splice(i,1),r.length||(delete e.events[n],e.events[n+O](),delete e.events[n+O])}),k=(e,t)=>ee(e,t,T,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),A=1e3,j=(e,t)=>ee(e,n=>{let r=t(n);r&&e.events[D].push(r)},E,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[D]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[D])t();e.events[D]=[]}},A)},()=>{e.listen=n,e.off=r}});function M(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function N(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!N(e[n],t[n]))return!1;return!0}if(M(e)&&M(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!N(e[r],t[r]))return!1;return!0}return!1}function P(e,t){return k(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var F=Symbol.for(`better-auth:focus-manager`),I=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function L(){return globalThis[F]||(globalThis[F]=new I),globalThis[F]}var R=Symbol.for(`better-auth:online-manager`),te=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function z(){return globalThis[R]||(globalThis[R]=new te),globalThis[R]}var ne={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},re=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,B={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},ie=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ae(e){return e instanceof Date&&!isNaN(e.getTime())}function oe(e){let t=ie.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return ae(f)?f:null}function se(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in B)return B[s];if(!re.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(ne).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=oe(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function ce(e,t={strict:!0}){return se(e,t)}var le=()=>typeof window>`u`;function ue(e,t){return N(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var de=(e,t,n,r)=>{let i=w({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>a(e)});j(i,()=>P(i,ue));let a=async e=>new Promise(a=>{let o=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...o,query:{...o?.query,...e?.query},async onSuccess(e){let t=i.get(),n=t.data!=null&&e.data!=null&&N(t.data,e.data)?t.data:e.data;i.set({data:n,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(n&&r<n)return;let a=e.error.status===401;i.set({error:e.error,data:a?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onError?.(e)},async onRequest(e){let t=i.get();i.set({isPending:t.data===null,data:t.data,error:null,isRefetching:!0,refetch:i.value.refetch}),await o?.onRequest?.(e)}}).catch(e=>{i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{a(void 0)})});e=Array.isArray(e)?e:[e];let o=!1,s=!1,c=!1,l=()=>{if(o){c=!0;return}o=!0,a().finally(()=>{o=!1;let e=c&&s;c=!1,e&&l()})};return j(i,()=>{if(le())return;s=!0;let t=!1,n,r=e.map(e=>e.listen(()=>{t?a():(t=!0,clearTimeout(n),l())}));return n=setTimeout(()=>{t=!0,l()},0),()=>{s=!1;for(let e of r)e();clearTimeout(n)}}),i},V=()=>Math.floor(Date.now()/1e3),fe=5;function pe(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},l=()=>s||z().isOnline,u=e=>{if(l()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){c.lastSessionRequest=V(),t();return}if(e?.event===`visibilitychange`){if(V()-c.lastSessionRequest<fe)return;c.lastSessionRequest=V(),t();return}t()}},d=e=>{_().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{n()&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=_().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=L().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=z().subscribe(e=>{e&&u({event:`visibilitychange`})})},g=()=>{c.unsubscribeSignal=r.listen(()=>{t()})};return{init:()=>{c.isInitialized||(c.isInitialized=!0,f(),p(),m(),h(),g(),c.cleanupBroadcastSetup=_().setup(),c.cleanupFocusSetup=L().setup(),c.cleanupOnlineSetup=z().setup())},cleanup:()=>{c.isInitialized&&(c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.unsubscribeSignal&&=(c.unsubscribeSignal(),void 0),c.cleanupBroadcastSetup&&=(c.cleanupBroadcastSetup(),void 0),c.cleanupFocusSetup&&=(c.cleanupFocusSetup(),void 0),c.cleanupOnlineSetup&&=(c.cleanupOnlineSetup(),void 0),c.isInitialized=!1,c.lastSessionRequest=0)},triggerRefetch:u,broadcastSessionUpdate:d}}var me=Object.create(null),he=e=>({}),H=new Proxy(me,{get(e,t){return he()[t]??me[t]},has(e,t){return t in he()||t in me},set(e,t,n){let r=he(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=he(!0);return delete n[t],!0},ownKeys(){let e=he(!0);return Object.keys(e)}});H.NODE_ENV;function U(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return U(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return U(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return U(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return U(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return U(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return U(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return U(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function ge(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}function _e(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function ve(e){let t=e.split(`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t,v as n}from"./vendor-react-BggL7APJ.js";import{Gi as r,Ji as i,Ki as a,Wi as o,qi as s}from"./vendor-objectstack-DFqu45yM.js";var c=e(n(),1),l=new Set,u={emit(e){for(let t of Array.from(l))try{t(e)}catch{}},subscribe(e){return l.add(e),()=>{l.delete(e)}}};function d(e,t){if(e!==403||!t||typeof t!=`object`)return null;let n=t.error;if(!n||typeof n!=`object`)return null;let r=n.code;if(r===`MFA_REQUIRED`||r===`PASSWORD_EXPIRED`){let e=n.message;return{code:r,message:typeof e==`string`?e:``}}return null}var f=(0,c.createContext)(null);f.displayName=`AuthContext`;var p=`1.7.2`,m=Symbol.for(`better-auth:broadcast-channel`),h=()=>Math.floor(Date.now()/1e3),g=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(!(typeof window>`u`))try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:h()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function _(e=`better-auth.message`){return globalThis[m]||(globalThis[m]=new g(e)),globalThis[m]}var v=[],y=0,b=null,x=4,S=globalThis.nanostoresGlobal||={epoch:0},C=()=>{let e;for(y=0;y<v.length;y+=x)try{v[y](v[y+1].value,v[y+2],v[y+3])}catch(t){e=t}if(v.length=0,e)throw e},w=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=y+x;t<v.length;)v[t]===e?v.splice(t,x):t+=x;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){S.epoch++;let i=!v.length&&!0;for(let i of t)b?.has(i)||(b?.add(i),v.push(i,n,e,r));i&&C()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},T=2,E=5,D=6,O=10,ee=(e,t,n,r)=>(e.events=e.events||{},e.events[n+O]||(e.events[n+O]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);r.splice(i,1),r.length||(delete e.events[n],e.events[n+O](),delete e.events[n+O])}),k=(e,t)=>ee(e,t,T,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),A=1e3,j=(e,t)=>ee(e,n=>{let r=t(n);r&&e.events[D].push(r)},E,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[D]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[D])t();e.events[D]=[]}},A)},()=>{e.listen=n,e.off=r}});function M(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function N(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!N(e[n],t[n]))return!1;return!0}if(M(e)&&M(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!N(e[r],t[r]))return!1;return!0}return!1}function P(e,t){return k(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var F=Symbol.for(`better-auth:focus-manager`),I=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function L(){return globalThis[F]||(globalThis[F]=new I),globalThis[F]}var R=Symbol.for(`better-auth:online-manager`),te=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function z(){return globalThis[R]||(globalThis[R]=new te),globalThis[R]}var ne={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},re=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,B={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},ie=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ae(e){return e instanceof Date&&!isNaN(e.getTime())}function oe(e){let t=ie.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return ae(f)?f:null}function se(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in B)return B[s];if(!re.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(ne).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=oe(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function ce(e,t={strict:!0}){return se(e,t)}var le=()=>typeof window>`u`;function ue(e,t){return N(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var de=(e,t,n,r)=>{let i=w({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>a(e)});j(i,()=>P(i,ue));let a=async e=>new Promise(a=>{let o=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...o,query:{...o?.query,...e?.query},async onSuccess(e){let t=i.get(),n=t.data!=null&&e.data!=null&&N(t.data,e.data)?t.data:e.data;i.set({data:n,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(n&&r<n)return;let a=e.error.status===401;i.set({error:e.error,data:a?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onError?.(e)},async onRequest(e){let t=i.get();i.set({isPending:t.data===null,data:t.data,error:null,isRefetching:!0,refetch:i.value.refetch}),await o?.onRequest?.(e)}}).catch(e=>{i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{a(void 0)})});e=Array.isArray(e)?e:[e];let o=!1,s=!1,c=!1,l=()=>{if(o){c=!0;return}o=!0,a().finally(()=>{o=!1;let e=c&&s;c=!1,e&&l()})};return j(i,()=>{if(le())return;s=!0;let t=!1,n,r=e.map(e=>e.listen(()=>{t?a():(t=!0,clearTimeout(n),l())}));return n=setTimeout(()=>{t=!0,l()},0),()=>{s=!1;for(let e of r)e();clearTimeout(n)}}),i},V=()=>Math.floor(Date.now()/1e3),fe=5;function pe(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},l=()=>s||z().isOnline,u=e=>{if(l()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){c.lastSessionRequest=V(),t();return}if(e?.event===`visibilitychange`){if(V()-c.lastSessionRequest<fe)return;c.lastSessionRequest=V(),t();return}t()}},d=e=>{_().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{n()&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=_().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=L().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=z().subscribe(e=>{e&&u({event:`visibilitychange`})})},g=()=>{c.unsubscribeSignal=r.listen(()=>{t()})};return{init:()=>{c.isInitialized||(c.isInitialized=!0,f(),p(),m(),h(),g(),c.cleanupBroadcastSetup=_().setup(),c.cleanupFocusSetup=L().setup(),c.cleanupOnlineSetup=z().setup())},cleanup:()=>{c.isInitialized&&(c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.unsubscribeSignal&&=(c.unsubscribeSignal(),void 0),c.cleanupBroadcastSetup&&=(c.cleanupBroadcastSetup(),void 0),c.cleanupFocusSetup&&=(c.cleanupFocusSetup(),void 0),c.cleanupOnlineSetup&&=(c.cleanupOnlineSetup(),void 0),c.isInitialized=!1,c.lastSessionRequest=0)},triggerRefetch:u,broadcastSessionUpdate:d}}var me=Object.create(null),he=e=>({}),H=new Proxy(me,{get(e,t){return he()[t]??me[t]},has(e,t){return t in he()||t in me},set(e,t,n){let r=he(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=he(!0);return delete n[t],!0},ownKeys(){let e=he(!0);return Object.keys(e)}});H.NODE_ENV;function U(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return U(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return U(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return U(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return U(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return U(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return U(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return U(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function ge(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}function _e(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function ve(e){let t=e.split(`
|
|
2
2
|
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
3
|
-
at `))}function ye(e,t){class n extends e{#e;constructor(...e){if(_e()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=ve(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var be={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};ye(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:be[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var W=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},xe=47;function Se(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===xe;)t--;return t===e.length?e:e.slice(0,t)}function Ce(e){try{return(Se(new URL(e).pathname)||`/`)!==`/`}catch{throw new W(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function we(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new W(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof W?t:new W(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function Te(e,t=`/api/auth`){if(we(e),Ce(e))return e;let n=Se(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function Ee(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function De(e,t,n,r,i){if(e)return Te(e,t);if(r!==!1){let e=H.BETTER_AUTH_URL||H.NEXT_PUBLIC_BETTER_AUTH_URL||H.PUBLIC_BETTER_AUTH_URL||H.NUXT_PUBLIC_BETTER_AUTH_URL||H.NUXT_PUBLIC_AUTH_URL||(H.BASE_URL===`/`?void 0:H.BASE_URL);if(e)return Te(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&Ee(o,`proto`)&&Ee(a,`host`))try{return Te(`${o}://${a}`,t)}catch{}if(n){let e=Oe(n.url);if(!e)throw new W(`Could not get origin from request. Please provide a valid base URL.`);return Te(e,t)}if(typeof window<`u`&&window.location)return Te(window.location.origin,t)}function Oe(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ke=[`javascript:`,`data:`,`vbscript:`];function Ae(e){let t;try{t=new URL(e)}catch{return!0}return!ke.includes(t.protocol)}var je={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Ae(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},Me=()=>typeof window>`u`,Ne=A;function Pe(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function Fe(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function Ie(e){return!e||e.session===null&&e.user===null?null:e}function Le(e,t){return N(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function Re(e,t){let n=w(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>u(e),s=w({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});P(s,Le);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=Fe(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=Fe(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=Ie(i),u=s.value,d=u.data!=null&&l!=null&&N(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+Ne,t)},u=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},d=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():u(),f=()=>{};return j(s,()=>{let e;Me()||(e=setTimeout(()=>{d()},0));let r=pe({fetchSession:u,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),f=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>f(e)}}function ze(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function Be(e,t,n=`.`,r){if(!ze(t))return Be(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:ze(a)&&ze(i[t])?Be(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function Ve(e){return(...t)=>t.reduce((t,n)=>Be(t,n,``,e),{})}var He=Ve(),Ue=Object.defineProperty,We=Object.defineProperties,Ge=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Ye=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,G=(e,t)=>{for(var n in t||={})qe.call(t,n)&&Ye(e,n,t[n]);if(Ke)for(var n of Ke(t))Je.call(t,n)&&Ye(e,n,t[n]);return e},K=(e,t)=>We(e,Ge(t)),Xe=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},Ze=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let r=await i.init?.call(i,e.toString(),t);n=r.options||n,e=r.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},Qe=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},$e=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function et(e){if(typeof e==`number`)return new Qe({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new Qe(e);case`exponential`:return new $e(e);default:throw Error(`Invalid retry strategy`)}}var tt=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},nt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function rt(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return nt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function it(e){try{return JSON.parse(e),!0}catch{return!1}}function at(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function ot(e){try{return JSON.parse(e)}catch{return e}}function st(e){return typeof e==`function`}function ct(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&st(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&st(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function lt(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function ut(e){let t=new Headers(lt(e?.headers,await tt(e)));if(!t.has(`content-type`)){let n=dt(e?.body);n&&t.set(`content-type`,n)}return t}function dt(e){return at(e)?`application/json`:null}function ft(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function pt(e,t){let{body:n}=e;return n?!at(n)||typeof n==`string`?n:ft(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function mt(e,t){if(t?.method)return t.method.toUpperCase();if(e.startsWith(`@`)){let n=e.split(`@`)[1]?.split(`/`)[0];return vt.includes(n)?n.toUpperCase():t?.body?`POST`:`GET`}return t?.body?`POST`:`GET`}function ht(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var gt=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function _t(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new gt(n.issues);return n.value}var vt=[`get`,`post`,`put`,`patch`,`delete`],yt=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){let r=e.plugins?.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1)?.schema||e.schema;if(r){let e=t;r.config?.prefix&&e.startsWith(r.config.prefix)&&(e=e.replace(r.config.prefix,``),r.config.baseURL&&(t=t.replace(r.config.prefix,r.config.baseURL))),r.config?.baseURL&&e.startsWith(r.config.baseURL)&&(e=e.replace(r.config.baseURL,``)),e.startsWith(`/`)&&e.charAt(1)===`@`&&(e=e.substring(1));let i=r.schema[e];if(i){let e=n?.headers;if(i.headers&&!n?.disableValidation){let t={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((e,n)=>{t[n.toLowerCase()]=e});else if(typeof n.headers==`object`)for(let[e,r]of Object.entries(n.headers))r!=null&&(t[e.toLowerCase()]=r)}let r=await _t(i.headers,t),a={};for(let[e,t]of Object.entries(r))a[e.toLowerCase()]=t;e=a}let r=K(G({},n),{method:i.method,output:i.output,headers:e});return n?.disableValidation||(r=K(G({},r),{body:i.input?await _t(i.input,n?.body):n?.body,params:i.params?await _t(i.params,n?.params):n?.params,query:i.query?await _t(i.query,n?.query):n?.query})),{url:t,options:r}}}return{url:t,options:n}}}),bt=e=>{async function t(t,n){let r=K(G(G({},e),n),{headers:lt(e?.headers,n?.headers),plugins:[...e?.plugins||[],yt(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await wt(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await wt(t,r)}return t},xt=e=>e===`.`||e===`..`;function St(e,t){let n=e;for(let[e,r]of t)n=n.replace(e,r);if(xt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function Ct(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``;if(e.startsWith(`@`)){let t=e.toString().split(`@`)[1].split(`/`)[0];vt.includes(t)&&(e=e.replace(`@${t}/`,`/`))}a.endsWith(`/`)||(a+=`/`);let[o,s]=e.replace(a,``).split(`?`),c=new URLSearchParams(s);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)c.append(e,n);continue}else n=JSON.stringify(t);c.set(e,n)}let l=new Map;if(r){if(Array.isArray(r)){let e=o.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];l.set(n,String(e))}}else for(let[e,t]of Object.entries(r))l.set(`:${e}`,String(t))}o=o.split(`/`).map(e=>St(e,l)).join(`/`),o=o.replace(/^\/+/,``);let u=c.toString();return u=u.length>0?`?${u}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${o}${u}`,a):`${a}${o}${u}`}var wt=async(e,t)=>{let{hooks:n,url:r,options:i}=await Ze(e,t),a=ct(i),o=new AbortController,s=i.signal??o.signal,c=Ct(r,i),l=await ut(i),u=pt(i,l),d=mt(r,i),f=K(G({},i),{url:c,headers:l,body:u,method:d,signal:s});for(let e of n.onRequest)if(e){let t=await e(f);typeof t==`object`&&t&&Object.assign(f,t)}(`pipeTo`in f&&typeof f.pipeTo==`function`||typeof t?.body?.pipe==`function`)&&(`duplex`in f||(f.duplex=`half`));let{clearTimeout:p}=ht(i,o),m=await a(f.url,f);p();let h={response:m,request:f};for(let e of n.onResponse)if(e){let n=await e(K(G({},h),{response:t?.hookOptions?.cloneResponse?m.clone():m}));n instanceof Response?m=n:typeof n==`object`&&n&&(m=n.response)}if(m.ok){if(f.method===`HEAD`)return{data:``,error:null};let e=rt(m),r={data:null,response:m,request:f};if(e===`json`||e===`text`){let e=await m.text();r.data=await(f.jsonParser??ot)(e)}else r.data=await m[e]();f?.output&&f.output&&!f.disableValidation&&(r.data=await _t(f.output,r.data));for(let e of n.onSuccess)e&&await e(K(G({},r),{response:t?.hookOptions?.cloneResponse?m.clone():m}));return t?.throw?r.data:{data:r.data,error:null}}let g=t?.jsonParser??ot,_=await m.text(),v=it(_),y=v?await g(_):null,b={response:m,responseText:_,request:f,error:K(G({},y),{status:m.status,statusText:m.statusText})};for(let e of n.onError)e&&await e(K(G({},b),{response:t?.hookOptions?.cloneResponse?m.clone():m}));if(t?.retry){let r=et(t.retry),i=t.retryAttempt??0;if(await r.shouldAttemptRetry(i,m)){for(let e of n.onRetry)e&&await e(h);let a=r.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await wt(e,K(G({},t),{retryAttempt:i+1}))}}if(t?.throw)throw new Xe(m.status,m.statusText,v?y:_);return{data:null,error:K(G({},y),{status:m.status,statusText:m.statusText})}},Tt=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},Et=(e,t)=>{let n=`credentials`in Request.prototype,r=De(e?.baseURL,e?.basePath,void 0,t)??Tt(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=bt({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?ce(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[je],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=Re(d,e),h=!1,g=e=>{h||e===null||(h=!0,Pe(p,e))},_=e?.plugins||[],v={},y={$sessionSignal:f,session:p},b={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},x=[{signal:`$sessionSignal`,matcher(e){return e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`},callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of _)e.getAtoms&&Object.assign(y,e.getAtoms?.(d)),e.pathMethods&&Object.assign(b,e.pathMethods),e.atomListeners&&x.push(...e.atomListeners);let S={notify:e=>{y[e].set(!y[e].get())},listen:(e,t)=>{y[e].subscribe(t)},atoms:y};for(let t of _)t.getActions&&(v=He(t.getActions?.(d,S,e)??{},v));return{get baseURL(){return r},pluginsActions:v,pluginsAtoms:y,pluginPathMethods:b,atomListeners:x,hydrateSession:g,$fetch:d,$store:S}};function Dt(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function Ot(e){return e.charAt(0).toUpperCase()+e.slice(1)}var kt=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,At=/['\u2019]/g;function jt(e){return e.replace(At,``).match(kt)??[]}function Mt(e){return jt(e).map(e=>e.toLowerCase()).join(`-`)}function Nt(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function Pt(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||Dt(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(Mt).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Nt(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function Ft(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=Et(e),c={};for(let[e,t]of Object.entries(r))c[`use${Ot(e)}`]=t;return Pt({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}function It(e){return{success:!1,error:`You are not allowed to access resource: ${e}`}}function Lt(e){return{success:!1,error:`unauthorized to access resource "${e}"`}}function Rt(e){return e===`OR`?`OR`:`AND`}function zt(e){return Array.isArray(e)}function Bt(e){if(zt(e))return{actions:e,connector:`AND`};if(!e||typeof e!=`object`)throw new W(`Invalid access control request`);let{actions:t,connector:n}=e;return zt(t)?{actions:t,connector:Rt(n)}:{actions:[],connector:Rt(n)}}function Vt(e,t){return typeof t==`string`&&e.includes(t)}function Ht(e,{actions:t,connector:n}){return t.length===0?!1:n===`OR`?t.some(t=>Vt(e,t)):t.every(t=>Vt(e,t))}function Ut(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t){if(n===`AND`)return It(i);continue}let o=Ht(t,Bt(a));if(o&&(r=!0),o&&n===`OR`)return{success:!0};if(!o&&n===`AND`)return Lt(i)}return r?{success:!0}:{success:!1,error:`Not authorized`}},statements:e}}function Wt(e){return{newRole(e){return Ut(e)},statements:e}}var Gt=ge({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:`You are not allowed to create a new organization`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:`You have reached the maximum number of organizations`,ORGANIZATION_ALREADY_EXISTS:`Organization already exists`,ORGANIZATION_SLUG_ALREADY_TAKEN:`Organization slug already taken`,ORGANIZATION_NOT_FOUND:`Organization not found`,USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:`User is not a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:`You are not allowed to update this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:`You are not allowed to delete this organization`,NO_ACTIVE_ORGANIZATION:`No active organization`,USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:`User is already a member of this organization`,MEMBER_NOT_FOUND:`Member not found`,ROLE_NOT_FOUND:`Role not found`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:`You are not allowed to create a new team`,TEAM_ALREADY_EXISTS:`Team already exists`,TEAM_NOT_FOUND:`Team not found`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:`You cannot leave the organization as the only owner`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:`You cannot leave the organization without an owner`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:`You are not allowed to delete this member`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:`You are not allowed to invite users to this organization`,USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:`User is already invited to this organization`,INVITATION_NOT_FOUND:`Invitation not found`,YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:`You are not the recipient of the invitation`,EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:`Email verification required before accepting or rejecting invitation`,EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION:`Email verification required to view or list invitations for the session email`,YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:`You are not allowed to cancel this invitation`,INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:`Inviter is no longer a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:`You are not allowed to invite a user with this role`,FAILED_TO_RETRIEVE_INVITATION:`Failed to retrieve invitation`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:`You have reached the maximum number of teams`,UNABLE_TO_REMOVE_LAST_TEAM:`Unable to remove last team`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:`You are not allowed to update this member`,ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:`Organization membership limit reached`,YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to create teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to delete teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:`You are not allowed to update this team`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:`You are not allowed to delete this team`,INVITATION_LIMIT_REACHED:`Invitation limit reached`,TEAM_MEMBER_LIMIT_REACHED:`Team member limit reached`,USER_IS_NOT_A_MEMBER_OF_THE_TEAM:`User is not a member of the team`,YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:`You are not allowed to list the members of this team`,YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:`You do not have an active team`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:`You are not allowed to create a new member`,YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:`You are not allowed to remove a team member`,YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:`You are not allowed to access this organization as an owner`,YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:`You are not a member of this organization`,MISSING_AC_INSTANCE:`Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information`,YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:`You must be in an organization to create a role`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:`You are not allowed to create a role`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:`You are not allowed to update a role`,YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:`You are not allowed to delete a role`,YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:`You are not allowed to read a role`,YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:`You are not allowed to list a role`,YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:`You are not allowed to get a role`,TOO_MANY_ROLES:`This organization has too many roles`,INVALID_RESOURCE:`The provided permission includes an invalid resource`,ROLE_NAME_IS_ALREADY_TAKEN:`That role name is already taken`,CANNOT_DELETE_A_PRE_DEFINED_ROLE:`Cannot delete a pre-defined role`,ROLE_IS_ASSIGNED_TO_MEMBERS:`Cannot delete a role that is assigned to members. Please reassign the members to a different role first`,INVALID_TEAM_ID:`Team id contains a reserved character`}),Kt=Wt({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),qt=Kt.newRole({organization:[`update`],invitation:[`create`,`cancel`],member:[`create`,`update`,`delete`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),Jt=Kt.newRole({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),Yt=Kt.newRole({organization:[],member:[],invitation:[],team:[],ac:[`read`]}),Xt={admin:qt,owner:Jt,member:Yt},Zt=(e,t)=>{if(!e.permissions)return!1;let n=e.role.split(`,`),r=e.options.creatorRole||`owner`,i=n.includes(r),a=e.allowCreatorAllPermissions||!1;if(i&&a)return!0;for(let r of n)if(t[r]?.authorize(e.permissions)?.success)return!0;return!1},Qt=e=>Zt(e,e.options.roles||Xt),$t=e=>{let t=w(!1),n=w(!1),r=w(!1),i=w(!1),a={admin:qt,member:Yt,owner:Jt,...e?.roles};return{id:`organization`,version:p,$InferServerPlugin:{},getActions:(t,n,r)=>({$Infer:{ActiveOrganization:{},Organization:{},Invitation:{},Member:{},Team:{}},organization:{checkRolePermission:t=>Qt({role:t.role,options:{ac:e?.ac,roles:a},permissions:t.permissions})}}),getAtoms:e=>{let a=de(t,`/organization/list`,e,{method:`GET`});return{$listOrg:t,$activeOrgSignal:n,$activeMemberSignal:r,$activeMemberRoleSignal:i,activeOrganization:de([n],`/organization/get-full-organization`,e,()=>({method:`GET`})),listOrganizations:a,activeMember:de([n,r],`/organization/get-active-member`,e,{method:`GET`}),activeMemberRole:de([n,i],`/organization/get-active-member-role`,e,{method:`GET`})}},pathMethods:{"/organization/get-full-organization":`GET`,"/organization/list-user-teams":`GET`},atomListeners:[{matcher(e){return e===`/organization/create`||e===`/organization/delete`||e===`/organization/update`},signal:`$listOrg`},{matcher(e){return e===`/sign-out`||e.startsWith(`/organization`)},signal:`$activeOrgSignal`},{matcher(e){return e.startsWith(`/organization/set-active`)||e===`/organization/create`||e===`/organization/delete`||e===`/organization/remove-member`||e===`/organization/leave`||e===`/organization/accept-invitation`},signal:`$sessionSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberRoleSignal`}],$ERROR_CODES:Gt}},en=ge({OTP_NOT_ENABLED:`OTP not enabled`,OTP_NOT_CONFIGURED:`OTP is not available`,OTP_HAS_EXPIRED:`OTP has expired`,TOTP_NOT_ENABLED:`TOTP not enabled`,TOTP_NOT_CONFIGURED:`TOTP is not available`,TWO_FACTOR_NOT_ENABLED:`Two factor isn't enabled`,BACKUP_CODES_NOT_ENABLED:`Backup codes aren't enabled`,INVALID_BACKUP_CODE:`Invalid backup code`,INVALID_CODE:`Invalid code`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`Too many attempts. Please request a new code.`,ACCOUNT_TEMPORARILY_LOCKED:`Too many failed verification attempts. Your account is temporarily locked. Please try again later.`,INVALID_TWO_FACTOR_COOKIE:`Invalid two factor cookie`}),tn=e=>({id:`two-factor`,version:p,$InferServerPlugin:{},atomListeners:[{matcher:e=>e.startsWith(`/two-factor/`),signal:`$sessionSignal`}],pathMethods:{"/two-factor/disable":`POST`,"/two-factor/enable":`POST`,"/two-factor/send-otp":`POST`,"/two-factor/generate-backup-codes":`POST`,"/two-factor/get-totp-uri":`POST`,"/two-factor/verify-totp":`POST`,"/two-factor/verify-otp":`POST`,"/two-factor/verify-backup-code":`POST`},fetchPlugins:[{id:`two-factor`,name:`two-factor`,hooks:{async onSuccess(t){if(t.data?.twoFactorRedirect){if(e?.onTwoFactorRedirect){await e.onTwoFactorRedirect({twoFactorMethods:t.data.twoFactorMethods});return}e?.twoFactorPage&&typeof window<`u`&&Ae(e.twoFactorPage)&&(window.location.href=e.twoFactorPage)}}}}],$ERROR_CODES:en}),nn=Object.values({pending:`pending`,accepted:`accepted`,rejected:`rejected`,canceled:`canceled`}),rn=new Set(nn);function an(e){return typeof e==`string`&&rn.has(e)}var on=`auth-session-token`,q={_memoryToken:null,_rotationListeners:new Set,get(){try{if(typeof localStorage<`u`)return localStorage.getItem(on)}catch{}return this._memoryToken},set(e){let t=this.get();this._memoryToken=e;try{typeof localStorage<`u`&&localStorage.setItem(on,e)}catch{}if(t&&t!==e)for(let e of[...this._rotationListeners])try{e()}catch{}},clear(){this._memoryToken=null;try{typeof localStorage<`u`&&localStorage.removeItem(on)}catch{}},subscribeRotation(e){return this._rotationListeners.add(e),()=>{this._rotationListeners.delete(e)}}};function J(e,t){let n=Error(e.message??t??`Auth request failed with status ${e.status}`);return e.code&&(n.code=e.code),n}function sn(e,t){let n=e?.status;if(!an(n))throw Error(`${t}: unexpected invitation status ${JSON.stringify(n)} — expected one of ${nn.join(` | `)}`);return e}function cn(e,t){return(Array.isArray(e)?e:[]).map(e=>sn(e,t))}function ln(e){try{let t=new URL(e);return{origin:t.origin,basePath:t.pathname.replace(/\/$/,``)}}catch{return{origin:un()??`http://localhost`,basePath:e.replace(/\/$/,``)}}}function un(){try{if(typeof window<`u`&&window.location?.origin)return window.location.origin}catch{}}function dn(){try{if(typeof document<`u`){let e=document.querySelector(`base`)?.getAttribute(`href`);if(e)return`${new URL(e,un()??`http://localhost`).pathname.replace(/\/$/,``)}/reset-password`}}catch{}return`/reset-password`}function fn(e){let t=e||globalThis.fetch.bind(globalThis);return async(e,n)=>{let r=new Headers(n?.headers),i=q.get();if(i){let t=typeof e==`string`?e:e instanceof URL?e.href:e.url;/\/api\//i.test(t)&&r.set(`Authorization`,`Bearer ${i}`)}let a=await t(e,{...n,headers:r}),o=a.headers.get(`set-auth-token`);return o&&q.set(o),a}}function pn(e){let{baseURL:t,fetchFn:n}=e,{origin:r,basePath:i}=ln(t),a=fn(n),o=Ft({baseURL:r,basePath:i,disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:a},plugins:[$t(),tn()]});async function s(e,t){let n=await a(`${r}${i}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify(t)}),o=await n.json().catch(()=>({}));if(!n.ok){let e=Error(o?.message??`Auth request failed with status ${n.status}`);throw o?.code&&(e.code=o.code),e.status=n.status,e}return o??{}}async function c(e){let t=typeof AbortController<`u`?new AbortController:void 0,n=t?setTimeout(()=>t.abort(),e):void 0;try{let e=`${r}${i}/config`,n=await a(e,{method:`GET`,headers:{"Content-Type":`application/json`},...t?{signal:t.signal}:{}});if(!n.ok)throw Error(`Failed to load auth config (status ${n.status})`);let o=await n.json();return o&&typeof o==`object`&&`data`in o&&o.data?o.data:o}finally{n!==void 0&&clearTimeout(n)}}let l=[500,1500,3500],u=null;async function d(){let e;for(let t=0;t<=l.length;t++)try{return await c(8e3)}catch(n){e=n,t<l.length&&await new Promise(e=>setTimeout(e,l[t]))}throw e instanceof Error?e:Error(String(e))}return{async signIn(e){let{data:t,error:n}=await o.signIn.email({email:e.email,password:e.password});if(n)throw J(n);let r=t;return r.session?.token&&q.set(r.session.token),{user:r.user,session:r.session}},async signUp(e){let{data:t,error:n}=await o.signUp.email({email:e.email,password:e.password,name:e.name,...e.callbackURL?{callbackURL:e.callbackURL}:{}});if(n)throw J(n);let r=t,i=r.token??r.session?.token??null;i&&q.set(i);let a=r.session??null;return!a&&i&&(a={token:i}),{user:r.user,session:a,requiresVerification:i===null}},async sendVerificationEmail(e,t){let{error:n}=await o.sendVerificationEmail({email:e,callbackURL:t});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`)},async signOut(){let{error:e}=await o.signOut();if(q.clear(),e)throw Error(e.message??`Auth request failed with status ${e.status}`)},async getSession(){let e=null;try{let t=await o.getSession();t.error||(e=t.data)}catch{}if(e){let t=e;return t.session?.token&&q.set(t.session.token),{user:t.user,session:t.session}}if(q.get())try{let e=await(n||globalThis.fetch.bind(globalThis))(`${r}${i}/get-session`,{method:`GET`,credentials:`include`,headers:{"Content-Type":`application/json`}});if(e.ok){let t=await e.json().catch(()=>null);if(t?.user&&t?.session)return t.session.token?q.set(t.session.token):q.clear(),{user:t.user,session:t.session};q.clear()}}catch{}return null},async forgotPassword(e){let t=o,n=t.requestPasswordReset??t.forgetPassword;if(typeof n!=`function`)throw Error(`password reset is not available on this auth backend`);let{error:r}=await n({email:e,redirectTo:dn()});if(r)throw Error(r.message??`Auth request failed with status ${r.status}`)},async resetPassword(e,t){let{error:n}=await o.resetPassword({token:e,newPassword:t});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`)},async sendPhoneOtp(e){await s(`/phone-number/send-otp`,{phoneNumber:e})},async signInWithPhoneOtp(e,t){let n=await s(`/phone-number/verify`,{phoneNumber:e,code:t}),r=typeof n.token==`string`?n.token:void 0,i=n.user??null;if(!r||!i)throw Error(`No account is registered for this phone number.`);return q.set(r),{user:i,session:{token:r}}},async signInWithPhonePassword(e,t){let n=await s(`/sign-in/phone-number`,{phoneNumber:e,password:t}),r=typeof n.token==`string`?n.token:void 0,i=n.user??null;if(!r||!i)throw Error(`Invalid phone number or password.`);return q.set(r),{user:i,session:{token:r}}},async requestPhonePasswordReset(e){await s(`/phone-number/request-password-reset`,{phoneNumber:e})},async resetPasswordWithPhoneOtp(e,t,n){await s(`/phone-number/reset-password`,{phoneNumber:e,otp:t,newPassword:n})},async changePassword(e,t,n){let r=o.changePassword;if(typeof r!=`function`)throw Error(`change-password is not available on this auth backend`);let{error:i}=await r({currentPassword:e,newPassword:t,...n?.revokeOtherSessions==null?{}:{revokeOtherSessions:n.revokeOtherSessions}});if(i)throw Error(i.message??`Auth request failed with status ${i.status}`)},async enrollTotp(e){let t=o.twoFactor;if(!t||typeof t.enable!=`function`)throw Error(`two-factor enrollment is not available on this auth backend`);let{data:n,error:r}=await t.enable({password:e});if(r)throw Error(r.message??`Two-factor enable failed (${r.status??`?`})`);return{totpURI:n?.totpURI??``,backupCodes:n?.backupCodes??[]}},async verifyTotp(e){let t=o.twoFactor;if(!t||typeof t.verifyTotp!=`function`)throw Error(`two-factor verification is not available on this auth backend`);let{error:n}=await t.verifyTotp({code:e});if(n)throw Error(n.message??`Two-factor verification failed (${n.status??`?`})`)},async setInitialPassword(e){let t=`${r}${i}/set-initial-password`,n=await a(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newPassword:e})});if(!n.ok){let e=`Set password failed with status ${n.status}`;try{let t=await n.json();t?.error?.message&&(e=t.error.message)}catch{}throw Error(e)}},async hasLocalPassword(){let e=`${r}${i}/list-accounts`;try{let t=await a(e,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!t.ok)return!1;let n=await t.json();return(Array.isArray(n)?n:n&&`data`in n&&Array.isArray(n.data)?n.data:[]).some(e=>e?.providerId===`credential`)}catch{return!1}},async updateUser(e){let{data:t,error:n}=await o.updateUser(e);if(n)throw Error(n.message??`Auth request failed with status ${n.status}`);if(!t)throw Error(`Update user returned no data`);let r=t;return r&&typeof r==`object`&&`user`in r?r.user:r},async describeDelegableScope(){try{let e=i.replace(/\/auth$/,`/security`),t=await a(`${r}${e}/my-delegable-scope`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!t.ok)return null;let n=await t.json(),o=n&&typeof n==`object`&&`data`in n?n.data:n;return o&&typeof o==`object`&&Array.isArray(o.placeableBusinessUnitIds)?o:null}catch{return null}},async getConfig(){return u||=d().catch(e=>{throw u=null,e}),u},async signInWithProvider(e,t={}){let{type:n=`social`,callbackURL:r,errorCallbackURL:i}=t,a=e=>new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`Sign-in timed out — the server did not respond. Please try again.`)),2e4);e.then(e=>{clearTimeout(r),t(e)},e=>{clearTimeout(r),n(e)})}),s=async()=>await a(o.signIn.social({provider:e,callbackURL:r,errorCallbackURL:i})),c;if(n===`oidc`){if(c=await s(),c.error){let t=o.signIn.oauth2,n=t?await a(t({providerId:e,callbackURL:r,errorCallbackURL:i})).catch(()=>null):null;n&&!n.error&&(c=n)}}else c=await s();let{data:l,error:u}=c;if(u)throw Error(u.message??`Auth request failed with status ${u.status}`);if(!l?.url)throw Error(`Sign-in with "${e}" did not return a redirect URL — please try again or contact your administrator.`);typeof window<`u`&&(window.location.href=l.url)},async listOrganizations(){let{data:e,error:t}=await o.organization.list();if(t)throw J(t,`Failed to list organizations`);return e??[]},async createOrganization(e){let{data:t,error:n}=await o.organization.create({name:e.name,slug:e.slug,logo:e.logo});if(n)throw J(n,`Failed to create organization`);return t},async setActiveOrganization(e){let{data:t,error:n}=await o.organization.setActive({organizationId:e});if(n)throw J(n,`Failed to set active organization`);return t??null},async getActiveOrganization(){let{data:e,error:t}=await o.organization.getFullOrganization();return t||!e?null:e},async getActiveMember(){let e=o.organization?.getActiveMember;if(typeof e!=`function`)return null;let{data:t,error:n}=await e();return n||!t?null:t},async getMembers(e){let{data:t,error:n}=await o.organization.listMembers({query:{organizationId:e}});if(n)throw J(n,`Failed to get members`);let r=t;return Array.isArray(r)?r:r?.members??[]},async inviteMember(e){let{data:t,error:n}=await o.organization.inviteMember({organizationId:e.organizationId,email:e.email,role:e.role,...e.businessUnitId?{businessUnitId:e.businessUnitId}:{},...e.positions?.length?{positions:e.positions}:{}});if(n)throw J(n,`Failed to invite member`);return sn(t,`inviteMember`)},async removeMember(e){let{error:t}=await o.organization.removeMember({organizationId:e.organizationId,memberIdOrUserId:e.memberIdOrUserId});if(t)throw J(t,`Failed to remove member`)},async updateMemberRole(e){let{error:t}=await o.organization.updateMemberRole({organizationId:e.organizationId,memberId:e.memberId,role:e.role});if(t)throw J(t,`Failed to update member role`)},async updateOrganization(e,t){let{data:n,error:r}=await o.organization.update({organizationId:e,data:t});if(r)throw J(r,`Failed to update organization`);return n},async deleteOrganization(e){let{error:t}=await o.organization.delete({organizationId:e});if(t)throw J(t,`Failed to delete organization`)},async leaveOrganization(e){let{error:t}=await o.organization.leave({organizationId:e});if(t)throw J(t,`Failed to leave organization`)},async listInvitations(e){let{data:t,error:n}=await o.organization.listInvitations({query:{organizationId:e}});if(n)throw J(n,`Failed to list invitations`);return cn(t,`listInvitations`)},async cancelInvitation(e){let{error:t}=await o.organization.cancelInvitation({invitationId:e});if(t)throw J(t,`Failed to cancel invitation`)},async getInvitation(e){let{data:t,error:n}=await o.organization.getInvitation({query:{id:e}});if(n)throw J(n,`Failed to load invitation`);return sn(t,`getInvitation`)},async acceptInvitation(e){let{error:t}=await o.organization.acceptInvitation({invitationId:e});if(t)throw J(t,`Failed to accept invitation`)},async rejectInvitation(e){let{error:t}=await o.organization.rejectInvitation({invitationId:e});if(t)throw J(t,`Failed to reject invitation`)},async listUserInvitations(){let{data:e,error:t}=await o.organization.listUserInvitations();if(t)throw J(t,`Failed to list invitations`);return cn(e,`listUserInvitations`)}}}var mn=`auth-session-user-id`,hn=`auth-active-organization-id`,gn=hn,_n=new Set([`auth-session-token`,mn,`vite-ui-theme`]);function vn(e){try{return e===`local`?typeof localStorage<`u`?localStorage:void 0:typeof sessionStorage<`u`?sessionStorage:void 0}catch{return}}function yn(e){try{return vn(`local`)?.getItem(e)??null}catch{return null}}function bn(e,t){try{vn(`local`)?.setItem(e,t)}catch{}}function xn(e){try{vn(`local`)?.removeItem(e)}catch{}return yn(e)===null}function Sn(e){if(!e)return;let t;try{t=Object.keys(e)}catch{return}let n=[];for(let r of t)if(!_n.has(r))try{e.removeItem(r)}catch{n.push(r)}n.length>0&&console.warn(`[purgePreviousUserClientState] could not remove ${n.length} key(s) from storage: ${n.join(`, `)}. The previous user's state may still be readable under these keys.`)}function Cn(){Y.clear(),Sn(vn(`local`)),Sn(vn(`session`))}var wn=new Set,Tn=0;function En(){return Tn}function Dn(e){return wn.add(e),()=>{wn.delete(e)}}function On(){Tn+=1;for(let e of[...wn])try{e()}catch(e){console.warn(`[SessionUserScope] an owner-change listener threw:`,e)}}var kn={_userId:null,current(){return this._userId===null?yn(mn):this._userId},adopt(e){if(!e||this._userId===e)return!1;let t=yn(mn),n=t!==null&&t!==e;return n&&Cn(),this._userId=e,bn(mn,e),xn(gn),n&&On(),n},_resetForTests(){this._userId=null}};function An(){let e=kn.current();return e?`${hn}:u:${e}`:null}var Y={_memoryValue:null,_unremovedKeys:new Set,get(){let e=An();if(e&&!this._unremovedKeys.has(e))try{let t=vn(`local`)?.getItem(e)??null;if(t!==null)return t}catch{}return this._memoryValue},set(e){this._memoryValue=e;let t=An();t&&bn(t,e)},clear(){this._memoryValue=null;let e=An();e&&(xn(e)?this._unremovedKeys.delete(e):(this._unremovedKeys.add(e),console.warn(`[ActiveOrganizationStorage] clear() could not remove "${e}" from localStorage — it is still readable. Reads for it are answered from memory for the rest of this page-load, so the cleared organization is not re-stamped as X-Tenant-ID.`))),xn(gn)}},X=t(),jn=`objectui:metadata:`;function Mn(){if(typeof sessionStorage<`u`){let e;try{e=Object.keys(sessionStorage)}catch{e=[]}let t=[];for(let n of e)if(n.startsWith(jn))try{sessionStorage.removeItem(n)}catch{t.push(n)}t.length>0&&console.warn(`[purgeSignedOutClientCaches] could not remove ${t.length} key(s) from sessionStorage: ${t.join(`, `)}. The signed-out user's metadata seed cache may still be readable under these keys.`)}Y.clear()}function Nn({authUrl:e,client:t,onAuthStateChange:n,enabled:r=!0,previewMode:i,children:a}){let o=(0,c.useMemo)(()=>t??pn({baseURL:e}),[t,e]),[s,l]=(0,c.useState)(null),[d,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(!0),[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(null),[b,x]=(0,c.useState)([]),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(null),[E,D]=(0,c.useState)(!1),[O,ee]=(0,c.useState)(!1),[k,A]=(0,c.useState)(!1),j=i!=null,M=r&&!j?s!==null&&d!==null:!0,N=(0,c.useRef)(!1),P=(0,c.useRef)(null),F=(0,c.useRef)(0),I=(0,c.useCallback)(async e=>{N.current=!0;try{let t=await o.getSession();if(e?.())return;t?(l(t.user),p(t.session)):(l(null),p(null))}catch(t){if(e?.())return;_(t instanceof Error?t:Error(String(t)))}finally{N.current=!1,e?.()||h(!1)}},[o]),L=(0,c.useCallback)(async()=>{r&&!j&&await I()},[r,j,I]);(0,c.useEffect)(()=>{if(r&&!j)return q.subscribeRotation(()=>{N.current||I()})},[r,j,I]),(0,c.useEffect)(()=>{if(j){let e=i.simulatedRole??`admin`,t=i.simulatedUserName??`Preview User`,n=i.expiresInSeconds??0;l({id:`preview-user`,email:`preview@preview.local`,name:t,role:e,positions:[e]}),p({token:`preview-token`,expiresAt:n>0?new Date(Date.now()+n*1e3):new Date(Date.now()+31536e6)}),h(!1);return}if(!r){l({id:`guest`,email:`guest@local`,name:`Guest User`,role:`admin`}),p({token:`guest-token`,expiresAt:new Date(Date.now()+31536e6)}),h(!1);return}let e=!1;return I(()=>e),()=>{e=!0}},[o,r,j,i,I]),(0,c.useEffect)(()=>{n?.({user:s,session:d,isAuthenticated:M,isLoading:m,error:g})},[s,d,M,m,g,n]);let R=(0,c.useCallback)(async(e,t)=>{h(!0),_(null);try{let n=await o.signIn({email:e,password:t});l(n.user),p(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),te=(0,c.useCallback)(async(e,t,n,r)=>{h(!0),_(null);try{let i=await o.signUp({name:e,email:t,password:n,...r?{callbackURL:r}:{}});return i.requiresVerification?{requiresVerification:!0}:(l(i.user),p(i.session),{requiresVerification:!1})}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),z=(0,c.useCallback)(async()=>{h(!0);try{await o.signOut(),l(null),p(null),_(null),x([]),C(null)}catch(e){_(e instanceof Error?e:Error(String(e)))}finally{Mn(),h(!1)}},[o]),ne=(0,c.useCallback)(async e=>{_(null);try{let t=await o.updateUser(e);l(t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),re=(0,c.useCallback)(async e=>{_(null);try{await o.forgotPassword(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),B=(0,c.useCallback)(async(e,t)=>{_(null);try{await o.sendVerificationEmail(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),ie=(0,c.useCallback)(async(e,t)=>{_(null);try{await o.resetPassword(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),ae=(0,c.useCallback)(async e=>{_(null);try{await o.sendPhoneOtp(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),oe=(0,c.useCallback)(async(e,t)=>{h(!0),_(null);try{let n=await o.signInWithPhoneOtp(e,t);l(n.user),p(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),se=(0,c.useCallback)(async(e,t)=>{h(!0),_(null);try{let n=await o.signInWithPhonePassword(e,t);l(n.user),p(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),ce=(0,c.useCallback)(async e=>{_(null);try{await o.requestPhonePasswordReset(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),le=(0,c.useCallback)(async(e,t,n)=>{_(null);try{await o.resetPasswordWithPhoneOtp(e,t,n)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]);(0,c.useEffect)(()=>u.subscribe(e=>{y(t=>t??e)}),[]);let ue=(0,c.useCallback)(e=>o.enrollTotp(e),[o]),de=(0,c.useCallback)(e=>o.verifyTotp(e),[o]),V=(0,c.useCallback)(async(e,t,n)=>{_(null);try{await o.changePassword(e,t,n)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),fe=(0,c.useCallback)(async e=>{_(null);try{await o.setInitialPassword(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),pe=(0,c.useCallback)(()=>o.hasLocalPassword(),[o]),me=(0,c.useCallback)(()=>o.getConfig(),[o]),he=(0,c.useCallback)(async(e,t)=>{_(null);try{await o.signInWithProvider(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),H=(0,c.useCallback)(async e=>{if(r&&!j){D(!0);try{let t=await o.listOrganizations();if(e?.())return t;if(x(t),t.length>0&&!S){let n=null;try{n=await o.getActiveOrganization()}catch{n=null}if(!n&&t.length===1)try{n=await o.setActiveOrganization(t[0].id)}catch{n=null}n&&!e?.()&&(C(n),Y.set(n.id))}return t}catch(t){e?.()||console.warn(`[AuthProvider] Failed to load organizations:`,t)}finally{e?.()||(D(!1),ee(!0))}}},[o,r,j,S]),U=(0,c.useCallback)(async()=>{if(!r||j){let e=j?i?.simulatedRole??`admin`:`admin`;T({id:`preview-member`,organizationId:S?.id??`preview-org`,userId:`preview-user`,role:e}),ee(!0),A(!0);return}if(!S){T(null),A(!0);return}A(!1);try{let e=await o.getActiveMember();T(e)}catch(e){console.warn(`[AuthProvider] Failed to load active member:`,e),T(null)}finally{A(!0)}},[o,r,j,i,S]);(0,c.useEffect)(()=>{if(!r||j)return;let e=s?.id;e&&kn.adopt(e)},[s?.id,r,j]),(0,c.useEffect)(()=>{U()},[U]),(0,c.useEffect)(()=>{if(!(s&&r&&!j))return;let e=!1;return H(()=>e),()=>{e=!0}},[s,r,j]),(0,c.useEffect)(()=>{P.current=S?.id??null},[S]);let ge=(0,c.useCallback)(async e=>{_(null);let t=P.current;N.current=!0;try{let n=await o.setActiveOrganization(e);C(n),n?Y.set(n.id):Y.clear();let r=n?.id??null;if(r!==t){P.current=r;let e=++F.current;await I(()=>F.current!==e)}}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{N.current=!1}},[o,I]),_e=(0,c.useCallback)(async e=>{_(null);try{let t=await o.createOrganization(e);return await H(),await ge(t.id),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o,H,ge]),ve=(0,c.useCallback)(async(e,t)=>{let n=await o.updateOrganization(e,t);return await H(),S?.id===e&&C(n),n},[o,H,S]),ye=(0,c.useCallback)(async e=>{await o.deleteOrganization(e),S?.id===e&&(C(null),Y.clear()),await H()},[o,S,H]),be=(0,c.useCallback)(async e=>{await o.leaveOrganization(e),S?.id===e&&(C(null),Y.clear()),await H()},[o,S,H]),W=(0,c.useCallback)(e=>o.getMembers(e),[o]),xe=(0,c.useCallback)(e=>o.inviteMember(e),[o]),Se=(0,c.useCallback)(()=>o.describeDelegableScope(),[o]),Ce=(0,c.useCallback)(e=>o.removeMember(e),[o]),we=(0,c.useCallback)(e=>o.updateMemberRole(e),[o]),Te=(0,c.useCallback)(e=>o.listInvitations(e),[o]),Ee=(0,c.useCallback)(e=>o.cancelInvitation(e),[o]),De=(0,c.useCallback)(e=>o.getInvitation(e),[o]),Oe=(0,c.useCallback)(async e=>{await o.acceptInvitation(e),await H()},[o,H]),ke=(0,c.useCallback)(e=>o.rejectInvitation(e),[o]),Ae=(0,c.useCallback)(()=>o.listUserInvitations(),[o]),je=r&&!j,Me=je?s==null||O&&k:k,Ne=(0,c.useMemo)(()=>({user:s,session:d,isAuthenticated:M,isAuthEnabled:je,isLoading:m,error:g,isPreviewMode:j,previewMode:j?i:null,signIn:R,signUp:te,signOut:z,refreshSession:L,updateUser:ne,forgotPassword:re,sendVerificationEmail:B,resetPassword:ie,sendPhoneOtp:ae,signInWithPhoneOtp:oe,signInWithPhonePassword:se,requestPhonePasswordReset:ce,resetPasswordWithPhoneOtp:le,changePassword:V,remediationRequired:v,setRemediationRequired:y,enrollTotp:ue,verifyTotp:de,setInitialPassword:fe,hasLocalPassword:pe,getAuthConfig:me,signInWithProvider:he,organizations:b,activeOrganization:S,activeMember:w,isOrganizationsLoading:E,isMembershipResolved:Me,switchOrganization:ge,createOrganization:_e,refreshOrganizations:H,updateOrganization:ve,deleteOrganization:ye,leaveOrganization:be,getMembers:W,inviteMember:xe,describeDelegableScope:Se,removeMember:Ce,updateMemberRole:we,listInvitations:Te,cancelInvitation:Ee,getInvitation:De,acceptInvitation:Oe,rejectInvitation:ke,listUserInvitations:Ae}),[s,d,M,je,m,g,j,i,R,te,z,L,ne,re,B,ie,V,fe,pe,me,he,ae,oe,se,ce,le,v,ue,de,b,S,w,E,Me,ge,_e,H,ve,ye,be,W,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae]);return(0,X.jsx)(f.Provider,{value:Ne,children:a})}function Pn(){return(0,c.useContext)(f)||{user:null,session:null,isAuthenticated:!1,isAuthEnabled:!1,isLoading:!1,error:null,isPreviewMode:!1,previewMode:null,signIn:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signUp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signOut:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},refreshSession:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateUser:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},forgotPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},sendVerificationEmail:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},resetPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},sendPhoneOtp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signInWithPhoneOtp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signInWithPhonePassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},requestPhonePasswordReset:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},resetPasswordWithPhoneOtp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},changePassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},remediationRequired:null,setRemediationRequired:()=>{},enrollTotp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},verifyTotp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},setInitialPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},hasLocalPassword:async()=>!1,getAuthConfig:async()=>({}),describeDelegableScope:async()=>null,signInWithProvider:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},organizations:[],activeOrganization:null,activeMember:null,isOrganizationsLoading:!1,isMembershipResolved:!0,switchOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},createOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},refreshOrganizations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},deleteOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},leaveOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},getMembers:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},inviteMember:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},removeMember:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateMemberRole:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},listInvitations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},cancelInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},getInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},acceptInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},rejectInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},listUserInvitations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)}}}var Fn=new Set([`owner`,`admin`,`super_admin`,`superadmin`,`platform_admin`,`system_admin`,`org_owner`,`org_admin`]),In=new Set([`org_owner`,`org_admin`]);function Ln(e){return typeof e==`string`&&Fn.has(e.toLowerCase())}function Rn(e){return typeof e==`string`&&In.has(e.toLowerCase())}function zn(){let{activeMember:e,user:t,isLoading:n,isMembershipResolved:r}=Pn(),i=t?.positions;return Ln(e?.role)||Ln(t?.role)||t?.isPlatformAdmin===!0||Array.isArray(i)&&i.some(Rn)?{isAdmin:!0,isResolved:!0}:{isAdmin:!1,isResolved:!n&&r}}function Bn({fallback:e=null,requiredRoles:t,loadingFallback:n,children:r}){let{isAuthenticated:i,isLoading:a,user:o}=Pn();if(a)return(0,X.jsx)(X.Fragment,{children:n??null});if(!i)return(0,X.jsx)(X.Fragment,{children:e});if(t&&t.length>0&&o){let n=o.positions??(o.role?[o.role]:[]);if(!t.some(e=>n.includes(e)))return(0,X.jsx)(X.Fragment,{children:e})}return(0,X.jsx)(X.Fragment,{children:r})}var Z=`flex h-11 w-full rounded-lg border border-input bg-background px-3.5 py-2 text-sm shadow-sm ring-offset-background transition-colors placeholder:text-muted-foreground hover:border-primary/40 focus-visible:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50`,Vn=`inline-flex h-11 w-full items-center justify-center gap-2 rounded-lg bg-gradient-to-r from-primary to-primary/85 px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm ring-offset-background transition-[box-shadow,background-color,transform] hover:shadow-md hover:from-primary hover:to-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 active:scale-[0.99] disabled:pointer-events-none disabled:opacity-60 motion-reduce:transition-none motion-reduce:active:transform-none`,Q=`text-sm font-medium leading-none text-foreground`;function $(){return(0,X.jsxs)(`svg`,{className:`h-4 w-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,X.jsx)(`path`,{className:`opacity-90`,d:`M4 12a8 8 0 018-8`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`})]})}function Hn({className:e}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e??`h-4 w-4 shrink-0`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,X.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,X.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}function Un({className:e}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e??`h-7 w-7`,"aria-hidden":`true`,children:[(0,X.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,X.jsx)(`path`,{d:`m22 6-10 7L2 6`})]})}function Wn({icon:e,title:t,description:n}){return(0,X.jsxs)(`div`,{className:`flex flex-col items-center space-y-3 text-center`,children:[e&&(0,X.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/15`,children:e}),(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground sm:text-[1.6rem]`,children:t}),n&&(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:n})]})}function Gn({message:e}){return(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:[(0,X.jsx)(Hn,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{className:`leading-snug`,children:e})]})}var Kn={google:`Google`,github:`GitHub`,microsoft:`Microsoft`,apple:`Apple`,facebook:`Facebook`,twitter:`Twitter`,discord:`Discord`,gitlab:`GitLab`,linkedin:`LinkedIn`},qn={google:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#EA4335`,d:`M12 10.2v3.9h5.5c-.24 1.4-1.7 4.1-5.5 4.1-3.3 0-6-2.74-6-6.1s2.7-6.1 6-6.1c1.88 0 3.14.8 3.86 1.5l2.64-2.55C16.84 3.36 14.66 2.4 12 2.4 6.92 2.4 2.8 6.52 2.8 11.6S6.92 20.8 12 20.8c6.92 0 9.2-4.86 9.2-7.4 0-.5-.06-.88-.14-1.2H12z`})}),github:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56v-2.07c-3.2.7-3.87-1.37-3.87-1.37-.52-1.33-1.27-1.69-1.27-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.18 1.76 1.18 1.02 1.75 2.68 1.25 3.34.96.1-.74.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.18-3.1-.12-.29-.51-1.46.11-3.04 0 0 .97-.31 3.18 1.18a11.04 11.04 0 015.79 0c2.21-1.49 3.18-1.18 3.18-1.18.62 1.58.23 2.75.11 3.04.74.81 1.18 1.84 1.18 3.1 0 4.42-2.7 5.39-5.27 5.68.41.36.78 1.06.78 2.13v3.16c0 .31.21.68.8.56C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5z`})}),microsoft:(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{fill:`#F25022`,d:`M2 2h9.5v9.5H2z`}),(0,X.jsx)(`path`,{fill:`#7FBA00`,d:`M12.5 2H22v9.5h-9.5z`}),(0,X.jsx)(`path`,{fill:`#00A4EF`,d:`M2 12.5h9.5V22H2z`}),(0,X.jsx)(`path`,{fill:`#FFB900`,d:`M12.5 12.5H22V22h-9.5z`})]}),apple:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M16.37 12.55c-.02-2.27 1.85-3.36 1.94-3.42-1.06-1.55-2.71-1.76-3.3-1.79-1.4-.14-2.74.83-3.45.83-.71 0-1.81-.81-2.98-.79-1.53.02-2.95.89-3.74 2.27-1.6 2.77-.41 6.86 1.14 9.11.76 1.1 1.66 2.34 2.83 2.3 1.14-.05 1.57-.74 2.94-.74 1.37 0 1.76.74 2.96.71 1.22-.02 2-1.12 2.75-2.23.87-1.28 1.22-2.52 1.24-2.59-.03-.01-2.38-.91-2.4-3.66zM14.1 5.31c.62-.76 1.05-1.81.93-2.86-.9.04-2 .6-2.65 1.35-.58.66-1.1 1.74-.96 2.76 1.01.08 2.04-.51 2.68-1.25z`})}),facebook:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#1877F2`,d:`M24 12C24 5.37 18.63 0 12 0S0 5.37 0 12c0 5.99 4.39 10.95 10.13 11.85V15.47H7.08V12h3.05V9.36c0-3.01 1.79-4.67 4.53-4.67 1.31 0 2.69.23 2.69.23v2.96h-1.51c-1.49 0-1.96.93-1.96 1.88V12h3.33l-.53 3.47h-2.8v8.38C19.61 22.95 24 17.99 24 12z`})}),twitter:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),discord:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#5865F2`,d:`M20.32 4.37A19.79 19.79 0 0016.56 3l-.18.36a18.27 18.27 0 00-8.76 0L7.44 3a19.79 19.79 0 00-3.76 1.37C.99 8.4.27 12.34.63 16.22a19.94 19.94 0 006.07 3.07l.49-.7a13.2 13.2 0 01-2.07-.99c.17-.13.34-.27.5-.41a14.13 14.13 0 0012.76 0c.16.14.33.28.5.41-.66.4-1.36.73-2.07.99l.49.7a19.92 19.92 0 006.07-3.07c.43-4.5-.66-8.41-2.95-11.85zM8.52 14.12c-1.18 0-2.15-1.08-2.15-2.41 0-1.33.95-2.42 2.15-2.42 1.2 0 2.17 1.09 2.15 2.42 0 1.33-.96 2.41-2.15 2.41zm6.96 0c-1.18 0-2.15-1.08-2.15-2.41 0-1.33.95-2.42 2.15-2.42 1.2 0 2.17 1.09 2.15 2.42 0 1.33-.95 2.41-2.15 2.41z`})}),gitlab:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#FC6D26`,d:`M23.6 9.6L23.57 9.5 20.3.81a.84.84 0 00-1.6.05L16.5 7.6H7.5L5.3.86a.84.84 0 00-1.6-.05L.43 9.5l-.03.1a5.84 5.84 0 001.94 6.74l.01.01.03.02 4.8 3.6 2.38 1.8 1.45 1.1a1 1 0 001.2 0l1.45-1.1 2.38-1.8 4.83-3.62.01-.01a5.84 5.84 0 001.93-6.74z`})}),linkedin:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#0A66C2`,d:`M20.45 20.45h-3.55v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.13 1.45-2.13 2.94v5.67H9.36V9h3.41v1.56h.05c.48-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.45v6.29zM5.34 7.43a2.06 2.06 0 11.01-4.13 2.06 2.06 0 010 4.13zM7.12 20.45H3.56V9h3.56v11.45zM22.22 0H1.77C.79 0 0 .77 0 1.72v20.56C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.72V1.72C24 .77 23.2 0 22.22 0z`})})};function Jn({id:e}){let t=qn[e];return t?(0,X.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center`,children:t}):(0,X.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center rounded-sm bg-muted text-[10px] font-bold uppercase`,children:e[0]})}function Yn({mode:e=`sign-in`,callbackURL:t,errorCallbackURL:n,dividerText:r=`or continue with email`,onProvidersResolved:i}){let{getAuthConfig:a,signInWithProvider:o}=Pn(),[s,l]=(0,c.useState)([]),[u,d]=(0,c.useState)(!0),[f,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(null);if((0,c.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>a()).then(t=>{if(e)return;let n=(t?.socialProviders??[]).filter(e=>e.enabled);l(n),i?.(n.length>0)}).catch(t=>{e||(console.warn(`[SocialSignInButtons] failed to load auth config`,t),i?.(!1))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[a]),u||s.length===0)return null;let g=e===`sign-in`?`Continue with`:`Sign up with`,_=typeof window<`u`?window.location.href:void 0,v=async e=>{if(!m){p(null),h(e.id);try{await o(e.id,{callbackURL:t??_,errorCallbackURL:n??t??_,type:e.type??`social`})}catch(e){p(e instanceof Error?e.message:String(e)),h(null)}}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f&&(0,X.jsx)(`div`,{className:`rounded-md bg-destructive/15 p-3 text-sm text-destructive`,role:`alert`,children:f}),s.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>v(e),disabled:m!==null,"aria-busy":m===e.id,className:`inline-flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,children:[m===e.id?(0,X.jsx)($,{}):(0,X.jsx)(Jn,{id:e.id}),g,` `,Kn[e.id]??e.name]},e.id)),(0,X.jsxs)(`div`,{className:`relative my-1`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,X.jsx)(`span`,{className:`w-full border-t`})}),(0,X.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,X.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:r})})]})]})}function Xn(e){let t=String(e??``).replace(/[\s\-().]/g,``);return/^\+?[0-9]{6,15}$/.test(t)?t:null}function Zn(e){return typeof e!=`string`||e.includes(`@`)?!1:Xn(e)!==null}var Qn=({href:e,className:t,children:n})=>(0,X.jsx)(`a`,{href:e,className:t,children:n}),$n=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`}),(0,X.jsx)(`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`})]});function er({onSuccess:e,onError:t,registerUrl:n=`/register`,forgotPasswordUrl:r=`/forgot-password`,title:i=`Sign in to your account`,description:a=`Enter your email and password to continue`,icon:o,hideIcon:s=!1,linkComponent:l=Qn,labels:u={},errorMessages:d}){let{signIn:f,isLoading:p,getAuthConfig:m,sendPhoneOtp:h,signInWithPhoneOtp:g,signInWithPhonePassword:_}=Pn(),[v,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(!1),[O,ee]=(0,c.useState)(`password`),[k,A]=(0,c.useState)(``),[j,M]=(0,c.useState)(``),[N,P]=(0,c.useState)(!1),[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(0),[te,z]=(0,c.useState)(!1),[ne,re]=(0,c.useState)(!1),[B,ie]=(0,c.useState)(!1),[ae,oe]=(0,c.useState)(!1),[se,ce]=(0,c.useState)(!1),[le,ue]=(0,c.useState)(!0);(0,c.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>m()).then(t=>{e||(re(t?.features?.sso===!0),T(t?.features?.phoneNumberOtp===!0),D(t?.features?.phoneNumber===!0),ie(t?.features?.ssoEnforced===!0||t?.emailPassword?.enabled===!1))}).catch(()=>{}).finally(()=>{e||ue(!1)}),()=>{e=!0}},[m]);let de=!B||ae,V={emailLabel:u.emailLabel??`Email`,emailPlaceholder:u.emailPlaceholder??`name@example.com`,emailOrPhoneLabel:u.emailOrPhoneLabel??`Email or phone number`,emailOrPhonePlaceholder:u.emailOrPhonePlaceholder??`name@example.com or +1 555 000 0000`,passwordLabel:u.passwordLabel??`Password`,passwordPlaceholder:u.passwordPlaceholder??`Enter your password`,forgotPasswordText:u.forgotPasswordText??`Forgot password?`,submitButton:u.submitButton??`Sign In`,submittingButton:u.submittingButton??`Signing in…`,noAccountText:u.noAccountText??`Don't have an account?`,signUpText:u.signUpText??`Sign up`,orText:u.orText??`or`,ssoButton:u.ssoButton??`Sign in with SSO`,usePasswordText:u.usePasswordText??`Use a password instead`,backToSsoText:u.backToSsoText??`Back to single sign-on`,ssoOnlyDescription:u.ssoOnlyDescription??`Sign in with your organization's single sign-on`,phoneLabel:u.phoneLabel??`Phone number`,phonePlaceholder:u.phonePlaceholder??`+1 555 000 0000`,otpCodeLabel:u.otpCodeLabel??`Verification code`,otpCodePlaceholder:u.otpCodePlaceholder??`6-digit code`,sendOtpButton:u.sendOtpButton??`Get code`,resendOtpCountdownText:u.resendOtpCountdownText??`Resend in {seconds}s`,usePhoneOtpText:u.usePhoneOtpText??`Sign in with verification code`,usePasswordSignInText:u.usePasswordSignInText??`Sign in with password instead`};(0,c.useEffect)(()=>{if(L<=0)return;let e=setTimeout(()=>R(e=>e>1?e-1:0),1e3);return()=>clearTimeout(e)},[L]);let fe=async n=>{n.preventDefault(),C(null);let r=v.trim();try{O===`phone-otp`?await g(k.trim(),j.trim()):E&&Zn(r)?await _(Xn(r)??r,b):await f(r,b),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e)),r=n.code;C(r&&d?.[r]||n.message),t?.(n)}},pe=async()=>{if(!(!k.trim()||N||L>0)){C(null),P(!0);try{await h(k.trim()),I(!0),R(60)}catch(e){let n=e instanceof Error?e:Error(String(e)),r=n.code;C(r&&d?.[r]||n.message),t?.(n)}finally{P(!1)}}},me=e=>{ee(e),C(null)};return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:s?void 0:o??(0,X.jsx)($n,{}),title:i,description:B&&!ae?V.ssoOnlyDescription:a}),(0,X.jsx)(`div`,{className:`space-y-5`,children:le?(0,X.jsx)(`div`,{className:`flex justify-center py-10`,role:`status`,"aria-live":`polite`,"data-testid":`login-config-loading`,children:(0,X.jsx)($,{})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Yn,{mode:`sign-in`,onProvidersResolved:e=>z(e)}),de?O===`phone-otp`?(0,X.jsxs)(`form`,{onSubmit:fe,className:`space-y-4`,children:[S&&(0,X.jsx)(Gn,{message:S}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`login-phone`,className:Q,children:V.phoneLabel}),(0,X.jsx)(`input`,{id:`login-phone`,type:`tel`,placeholder:V.phonePlaceholder,value:k,onChange:e=>A(e.target.value),required:!0,autoComplete:`tel`,disabled:p,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`login-otp`,className:Q,children:V.otpCodeLabel}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{id:`login-otp`,type:`text`,inputMode:`numeric`,placeholder:V.otpCodePlaceholder,value:j,onChange:e=>M(e.target.value),required:!0,autoComplete:`one-time-code`,disabled:p,className:Z}),(0,X.jsxs)(`button`,{type:`button`,onClick:pe,disabled:N||L>0||!k.trim()||p,className:`shrink-0 rounded-md border border-input bg-background px-3 py-2 text-sm font-medium transition-colors hover:bg-accent disabled:opacity-50`,children:[N&&(0,X.jsx)($,{}),L>0?V.resendOtpCountdownText.replace(`{seconds}`,String(L)):V.sendOtpButton]})]})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:p||!F,className:Vn,children:[p&&(0,X.jsx)($,{}),p?V.submittingButton:V.submitButton]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>me(`password`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.usePasswordSignInText})]}):(0,X.jsxs)(`form`,{onSubmit:fe,className:`space-y-4`,children:[S&&(0,X.jsx)(Gn,{message:S}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`login-email`,className:Q,children:E?V.emailOrPhoneLabel:V.emailLabel}),(0,X.jsx)(`input`,{id:`login-email`,type:E?`text`:`email`,inputMode:E?`text`:`email`,placeholder:E?V.emailOrPhonePlaceholder:V.emailPlaceholder,value:v,onChange:e=>y(e.target.value),required:!0,autoComplete:`username`,disabled:p,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`label`,{htmlFor:`login-password`,className:Q,children:V.passwordLabel}),r&&(0,X.jsx)(l,{href:r,className:`text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.forgotPasswordText})]}),(0,X.jsx)(`input`,{id:`login-password`,type:`password`,placeholder:V.passwordPlaceholder,value:b,onChange:e=>x(e.target.value),required:!0,autoComplete:`current-password`,disabled:p,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:p,className:Vn,children:[p&&(0,X.jsx)($,{}),p?V.submittingButton:V.submitButton]}),ne&&(0,X.jsxs)(`button`,{type:`button`,onClick:async()=>{if(se)return;C(null);let e=v.trim();if(Zn(e)){C(`Enter your email address to sign in with SSO.`);return}ce(!0);try{let t=window.location.pathname.replace(/\/login(?:\/.*)?$/,``),n=await fetch(`/api/v1/auth/sign-in/sso`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e,callbackURL:t+`/home`}),credentials:`include`}),r=await n.json().catch(()=>({}));if(n.ok&&typeof r.url==`string`){window.location.href=r.url;return}C(r.message||`No SSO provider is configured for this email domain.`),ce(!1)}catch(e){C(e instanceof Error?e.message:String(e)),ce(!1)}},disabled:p||se,"aria-busy":se,className:`flex w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent disabled:opacity-50`,children:[se&&(0,X.jsx)($,{}),V.ssoButton]}),w&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>me(`phone-otp`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.usePhoneOtpText}),B&&ae&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>oe(!1),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.backToSsoText})]}):(0,X.jsxs)(`div`,{className:`space-y-4`,children:[S&&(0,X.jsx)(Gn,{message:S}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>oe(!0),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.usePasswordText})]})]})}),n&&!B&&(0,X.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[V.noAccountText,` `,(0,X.jsx)(l,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:V.signUpText})]})]})}var tr=({href:e,className:t,children:n})=>(0,X.jsx)(`a`,{href:e,className:t,children:n}),nr=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`}),(0,X.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,X.jsx)(`line`,{x1:`19`,y1:`8`,x2:`19`,y2:`14`}),(0,X.jsx)(`line`,{x1:`22`,y1:`11`,x2:`16`,y2:`11`})]});function rr({onSuccess:e,onVerificationRequired:t,verificationCallbackURL:n,onError:r,loginUrl:i=`/login`,title:a=`Create an account`,description:o=`Enter your information to get started`,icon:s,hideIcon:l=!1,linkComponent:u=tr,labels:d={},errorMessages:f}){let{signUp:p,isLoading:m}=Pn(),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(``),[y,b]=(0,c.useState)(``),[x,S]=(0,c.useState)(``),[C,w]=(0,c.useState)(null),T={nameLabel:d.nameLabel??`Name`,namePlaceholder:d.namePlaceholder??`John Doe`,emailLabel:d.emailLabel??`Email`,emailPlaceholder:d.emailPlaceholder??`name@example.com`,passwordLabel:d.passwordLabel??`Password`,passwordPlaceholder:d.passwordPlaceholder??`Create a password (min. 8 characters)`,confirmPasswordLabel:d.confirmPasswordLabel??`Confirm Password`,confirmPasswordPlaceholder:d.confirmPasswordPlaceholder??`Confirm your password`,passwordMismatchError:d.passwordMismatchError??`Passwords do not match`,passwordTooShortError:d.passwordTooShortError??`Password must be at least 8 characters`,submitButton:d.submitButton??`Create Account`,submittingButton:d.submittingButton??`Creating account…`,hasAccountText:d.hasAccountText??`Already have an account?`,signInText:d.signInText??`Sign in`,orText:d.orText??`or`};return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:l?void 0:s??(0,X.jsx)(nr,{}),title:a,description:o}),(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.jsx)(Yn,{mode:`sign-up`}),(0,X.jsxs)(`form`,{onSubmit:async i=>{if(i.preventDefault(),w(null),y!==x){w(T.passwordMismatchError);return}if(y.length<8){w(T.passwordTooShortError);return}let a=_.trim();try{if((await p(h,a,y,n))?.requiresVerification){t?.(a);return}e?.()}catch(e){let t=e instanceof Error?e:Error(String(e)),n=t.code;w(n&&f?.[n]||t.message),r?.(t)}},className:`space-y-4`,children:[C&&(0,X.jsx)(Gn,{message:C}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-name`,className:Q,children:T.nameLabel}),(0,X.jsx)(`input`,{id:`register-name`,type:`text`,placeholder:T.namePlaceholder,value:h,onChange:e=>g(e.target.value),required:!0,autoComplete:`name`,disabled:m,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-email`,className:Q,children:T.emailLabel}),(0,X.jsx)(`input`,{id:`register-email`,type:`email`,placeholder:T.emailPlaceholder,value:_,onChange:e=>v(e.target.value),required:!0,autoComplete:`email`,disabled:m,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-password`,className:Q,children:T.passwordLabel}),(0,X.jsx)(`input`,{id:`register-password`,type:`password`,placeholder:T.passwordPlaceholder,value:y,onChange:e=>b(e.target.value),required:!0,minLength:8,autoComplete:`new-password`,disabled:m,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-confirm-password`,className:Q,children:T.confirmPasswordLabel}),(0,X.jsx)(`input`,{id:`register-confirm-password`,type:`password`,placeholder:T.confirmPasswordPlaceholder,value:x,onChange:e=>S(e.target.value),required:!0,minLength:8,autoComplete:`new-password`,disabled:m,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:m,className:Vn,children:[m&&(0,X.jsx)($,{}),m?T.submittingButton:T.submitButton]})]})]}),i&&(0,X.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[T.hasAccountText,` `,(0,X.jsx)(u,{href:i,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:T.signInText})]})]})}var ir=({href:e,className:t,children:n})=>(0,X.jsx)(`a`,{href:e,className:t,children:n}),ar=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4`})});function or({onSuccess:e,onError:t,loginUrl:n=`/login`,title:r=`Reset your password`,description:i=`Enter your email address and we'll send you a link to reset your password`,icon:a,hideIcon:o=!1,linkComponent:s=ir,labels:l={}}){let{forgotPassword:u,isLoading:d,getAuthConfig:f,requestPhonePasswordReset:p,resetPasswordWithPhoneOtp:m}=Pn(),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(null),[y,b]=(0,c.useState)(!1),[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(`email`),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(``),[ee,k]=(0,c.useState)(``),[A,j]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(0),[I,L]=(0,c.useState)(!1),[R,te]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>f()).then(t=>{e||S(t?.features?.phoneNumberOtp===!0)}).catch(()=>{}),()=>{e=!0}},[f]),(0,c.useEffect)(()=>{if(P<=0)return;let e=setTimeout(()=>F(e=>e>1?e-1:0),1e3);return()=>clearTimeout(e)},[P]);let z={emailLabel:l.emailLabel??`Email`,emailPlaceholder:l.emailPlaceholder??`name@example.com`,submitButton:l.submitButton??`Send Reset Link`,submittingButton:l.submittingButton??`Sending…`,successTitle:l.successTitle??`Check your email`,successDescription:l.successDescription??`We've sent a password reset link to {email}. Please check your inbox.`,backToSignInText:l.backToSignInText??`Back to sign in`,rememberPasswordText:l.rememberPasswordText??`Remember your password?`,signInText:l.signInText??`Sign in`,phoneLabel:l.phoneLabel??`Phone number`,phonePlaceholder:l.phonePlaceholder??`+1 555 000 0000`,otpCodeLabel:l.otpCodeLabel??`Verification code`,otpCodePlaceholder:l.otpCodePlaceholder??`6-digit code`,sendOtpButton:l.sendOtpButton??`Get code`,resendOtpCountdownText:l.resendOtpCountdownText??`Resend in {seconds}s`,newPasswordLabel:l.newPasswordLabel??`New password`,newPasswordPlaceholder:l.newPasswordPlaceholder??`Enter a new password`,resetButton:l.resetButton??`Reset Password`,usePhoneResetText:l.usePhoneResetText??`Reset via SMS code`,useEmailResetText:l.useEmailResetText??`Reset via email instead`,phoneSuccessTitle:l.phoneSuccessTitle??`Password reset`,phoneSuccessDescription:l.phoneSuccessDescription??`Your password has been reset. You can now sign in with your new password.`},ne=async n=>{n.preventDefault(),v(null);try{await u(h.trim()),b(!0),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e));v(n.message),t?.(n)}},re=async()=>{if(!(!T.trim()||A||P>0)){v(null),j(!0);try{await p(T.trim()),N(!0),F(60)}catch(e){let n=e instanceof Error?e:Error(String(e));v(n.message),t?.(n)}finally{j(!1)}}},B=async n=>{n.preventDefault(),v(null),te(!0);try{await m(T.trim(),D.trim(),ee),L(!0),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e));v(n.message),t?.(n)}finally{te(!1)}},ie=e=>{w(e),v(null)};if(I)return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:(0,X.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 ring-1 ring-emerald-500/15 dark:text-emerald-400`,children:(0,X.jsx)(Un,{})}),title:z.phoneSuccessTitle,description:z.phoneSuccessDescription}),n&&(0,X.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:(0,X.jsxs)(s,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:[`← `,z.backToSignInText]})})]});if(y){let e=z.successDescription.includes(`{email}`)?z.successDescription.replace(`{email}`,h):`${z.successDescription} ${h}`;return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:(0,X.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 ring-1 ring-emerald-500/15 dark:text-emerald-400`,children:(0,X.jsx)(Un,{})}),title:z.successTitle,description:e}),n&&(0,X.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:(0,X.jsxs)(s,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:[`← `,z.backToSignInText]})})]})}return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:o?void 0:a??(0,X.jsx)(ar,{}),title:r,description:i}),C===`phone`?(0,X.jsxs)(`form`,{onSubmit:B,className:`space-y-4`,children:[_&&(0,X.jsx)(Gn,{message:_}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-phone`,className:Q,children:z.phoneLabel}),(0,X.jsx)(`input`,{id:`forgot-phone`,type:`tel`,placeholder:z.phonePlaceholder,value:T,onChange:e=>E(e.target.value),required:!0,autoComplete:`tel`,disabled:R,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-otp`,className:Q,children:z.otpCodeLabel}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{id:`forgot-otp`,type:`text`,inputMode:`numeric`,placeholder:z.otpCodePlaceholder,value:D,onChange:e=>O(e.target.value),required:!0,autoComplete:`one-time-code`,disabled:R,className:Z}),(0,X.jsxs)(`button`,{type:`button`,onClick:re,disabled:A||P>0||!T.trim()||R,className:`shrink-0 rounded-md border border-input bg-background px-3 py-2 text-sm font-medium transition-colors hover:bg-accent disabled:opacity-50`,children:[A&&(0,X.jsx)($,{}),P>0?z.resendOtpCountdownText.replace(`{seconds}`,String(P)):z.sendOtpButton]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-new-password`,className:Q,children:z.newPasswordLabel}),(0,X.jsx)(`input`,{id:`forgot-new-password`,type:`password`,placeholder:z.newPasswordPlaceholder,value:ee,onChange:e=>k(e.target.value),required:!0,autoComplete:`new-password`,disabled:R,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:R||!M,className:Vn,children:[R&&(0,X.jsx)($,{}),R?z.submittingButton:z.resetButton]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ie(`email`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:z.useEmailResetText})]}):(0,X.jsxs)(`form`,{onSubmit:ne,className:`space-y-4`,children:[_&&(0,X.jsx)(Gn,{message:_}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-email`,className:Q,children:z.emailLabel}),(0,X.jsx)(`input`,{id:`forgot-email`,type:`email`,placeholder:z.emailPlaceholder,value:h,onChange:e=>g(e.target.value),required:!0,autoComplete:`email`,disabled:d,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:d,className:Vn,children:[d&&(0,X.jsx)($,{}),d?z.submittingButton:z.submitButton]}),x&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>ie(`phone`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:z.usePhoneResetText})]}),n&&(0,X.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[z.rememberPasswordText,` `,(0,X.jsx)(s,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:z.signInText})]})]})}function sr(e){return e?e.name?e.name.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2):e.email?.[0]?.toUpperCase()??`?`:`?`}function cr(e){if(typeof window>`u`||!window.location)return!0;try{return new URL(e,window.location.href).origin!==window.location.origin}catch{return!0}}function lr(e){return async(t,n)=>{let r=new Headers(n?.headers),i=typeof t==`string`?t:t instanceof URL?t.href:t.url;if(e?.sameOriginOnly&&cr(i))return fetch(t,n);let a=/\/api\//i.test(i),o=q.get();o&&a&&r.set(`Authorization`,`Bearer ${o}`);let s=Y.get();if(s&&r.set(`X-Tenant-ID`,s),a&&!r.has(`Accept-Language`)&&typeof document<`u`){let e=document.documentElement.lang;e&&r.set(`Accept-Language`,e)}let c=await fetch(t,{...n,headers:r});if(a){let e=c.headers.get(`set-auth-token`);e&&q.set(e)}if(a&&c.status===403)try{let e=d(c.status,await c.clone().json());e&&u.emit(e)}catch{}return c}}var ur=[...i],dr={[r]:{key:`organization.roles.owner`,defaultValue:`Owner`},[a]:{key:`organization.roles.admin`,defaultValue:`Admin`},[o]:{key:`organization.roles.delegatedAdmin`,defaultValue:`Delegated Admin`},[s]:{key:`organization.roles.member`,defaultValue:`Member`}},fr=0,pr=1,mr=2,hr=3;function gr(e){if(typeof e!=`string`)return fr;let t=e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);if(t.length===0)return fr;let n=pr;for(let e of t)e===`owner`?n=Math.max(n,hr):e===`admin`&&(n=Math.max(n,mr));return n}function _r(e){let t=gr(e);return t<mr?[s]:ur.filter(e=>gr(e)<=t)}function vr(e,t){let n=gr(e);if(n<mr)return[];let r=n>=hr;return!r&&gr(t)>=hr?[]:ur.filter(e=>e!==`owner`||r)}export{Dn as _,lr as a,rr as c,Bn as d,zn as f,En as g,Y as h,gr as i,er as l,Nn as m,vr as n,sr as o,Pn as p,_r as r,or as s,dr as t,Gn as u,q as v};
|
|
3
|
+
at `))}function ye(e,t){class n extends e{#e;constructor(...e){if(_e()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=ve(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var be={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};ye(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:be[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var W=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},xe=47;function Se(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===xe;)t--;return t===e.length?e:e.slice(0,t)}function Ce(e){try{return(Se(new URL(e).pathname)||`/`)!==`/`}catch{throw new W(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function we(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new W(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof W?t:new W(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function Te(e,t=`/api/auth`){if(we(e),Ce(e))return e;let n=Se(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function Ee(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function De(e,t,n,r,i){if(e)return Te(e,t);if(r!==!1){let e=H.BETTER_AUTH_URL||H.NEXT_PUBLIC_BETTER_AUTH_URL||H.PUBLIC_BETTER_AUTH_URL||H.NUXT_PUBLIC_BETTER_AUTH_URL||H.NUXT_PUBLIC_AUTH_URL||(H.BASE_URL===`/`?void 0:H.BASE_URL);if(e)return Te(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&Ee(o,`proto`)&&Ee(a,`host`))try{return Te(`${o}://${a}`,t)}catch{}if(n){let e=Oe(n.url);if(!e)throw new W(`Could not get origin from request. Please provide a valid base URL.`);return Te(e,t)}if(typeof window<`u`&&window.location)return Te(window.location.origin,t)}function Oe(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ke=[`javascript:`,`data:`,`vbscript:`];function Ae(e){let t;try{t=new URL(e)}catch{return!0}return!ke.includes(t.protocol)}var je={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Ae(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},Me=()=>typeof window>`u`,Ne=A;function Pe(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function Fe(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function Ie(e){return!e||e.session===null&&e.user===null?null:e}function Le(e,t){return N(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function Re(e,t){let n=w(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>u(e),s=w({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});P(s,Le);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=Fe(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=Fe(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=Ie(i),u=s.value,d=u.data!=null&&l!=null&&N(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+Ne,t)},u=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},d=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():u(),f=()=>{};return j(s,()=>{let e;Me()||(e=setTimeout(()=>{d()},0));let r=pe({fetchSession:u,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),f=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>f(e)}}function ze(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function Be(e,t,n=`.`,r){if(!ze(t))return Be(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:ze(a)&&ze(i[t])?Be(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function Ve(e){return(...t)=>t.reduce((t,n)=>Be(t,n,``,e),{})}var He=Ve(),Ue=Object.defineProperty,We=Object.defineProperties,Ge=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Ye=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,G=(e,t)=>{for(var n in t||={})qe.call(t,n)&&Ye(e,n,t[n]);if(Ke)for(var n of Ke(t))Je.call(t,n)&&Ye(e,n,t[n]);return e},K=(e,t)=>We(e,Ge(t)),Xe=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},Ze=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let r=await i.init?.call(i,e.toString(),t);n=r.options||n,e=r.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},Qe=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},$e=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function et(e){if(typeof e==`number`)return new Qe({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new Qe(e);case`exponential`:return new $e(e);default:throw Error(`Invalid retry strategy`)}}var tt=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},nt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function rt(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return nt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function it(e){try{return JSON.parse(e),!0}catch{return!1}}function at(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function ot(e){try{return JSON.parse(e)}catch{return e}}function st(e){return typeof e==`function`}function ct(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&st(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&st(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function lt(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function ut(e){let t=new Headers(lt(e?.headers,await tt(e)));if(!t.has(`content-type`)){let n=dt(e?.body);n&&t.set(`content-type`,n)}return t}function dt(e){return at(e)?`application/json`:null}function ft(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function pt(e,t){let{body:n}=e;return n?!at(n)||typeof n==`string`?n:ft(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function mt(e,t){if(t?.method)return t.method.toUpperCase();if(e.startsWith(`@`)){let n=e.split(`@`)[1]?.split(`/`)[0];return vt.includes(n)?n.toUpperCase():t?.body?`POST`:`GET`}return t?.body?`POST`:`GET`}function ht(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var gt=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function _t(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new gt(n.issues);return n.value}var vt=[`get`,`post`,`put`,`patch`,`delete`],yt=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){let r=e.plugins?.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1)?.schema||e.schema;if(r){let e=t;r.config?.prefix&&e.startsWith(r.config.prefix)&&(e=e.replace(r.config.prefix,``),r.config.baseURL&&(t=t.replace(r.config.prefix,r.config.baseURL))),r.config?.baseURL&&e.startsWith(r.config.baseURL)&&(e=e.replace(r.config.baseURL,``)),e.startsWith(`/`)&&e.charAt(1)===`@`&&(e=e.substring(1));let i=r.schema[e];if(i){let e=n?.headers;if(i.headers&&!n?.disableValidation){let t={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((e,n)=>{t[n.toLowerCase()]=e});else if(typeof n.headers==`object`)for(let[e,r]of Object.entries(n.headers))r!=null&&(t[e.toLowerCase()]=r)}let r=await _t(i.headers,t),a={};for(let[e,t]of Object.entries(r))a[e.toLowerCase()]=t;e=a}let r=K(G({},n),{method:i.method,output:i.output,headers:e});return n?.disableValidation||(r=K(G({},r),{body:i.input?await _t(i.input,n?.body):n?.body,params:i.params?await _t(i.params,n?.params):n?.params,query:i.query?await _t(i.query,n?.query):n?.query})),{url:t,options:r}}}return{url:t,options:n}}}),bt=e=>{async function t(t,n){let r=K(G(G({},e),n),{headers:lt(e?.headers,n?.headers),plugins:[...e?.plugins||[],yt(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await wt(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await wt(t,r)}return t},xt=e=>e===`.`||e===`..`;function St(e,t){let n=e;for(let[e,r]of t)n=n.replace(e,r);if(xt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function Ct(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``;if(e.startsWith(`@`)){let t=e.toString().split(`@`)[1].split(`/`)[0];vt.includes(t)&&(e=e.replace(`@${t}/`,`/`))}a.endsWith(`/`)||(a+=`/`);let[o,s]=e.replace(a,``).split(`?`),c=new URLSearchParams(s);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)c.append(e,n);continue}else n=JSON.stringify(t);c.set(e,n)}let l=new Map;if(r){if(Array.isArray(r)){let e=o.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];l.set(n,String(e))}}else for(let[e,t]of Object.entries(r))l.set(`:${e}`,String(t))}o=o.split(`/`).map(e=>St(e,l)).join(`/`),o=o.replace(/^\/+/,``);let u=c.toString();return u=u.length>0?`?${u}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${o}${u}`,a):`${a}${o}${u}`}var wt=async(e,t)=>{let{hooks:n,url:r,options:i}=await Ze(e,t),a=ct(i),o=new AbortController,s=i.signal??o.signal,c=Ct(r,i),l=await ut(i),u=pt(i,l),d=mt(r,i),f=K(G({},i),{url:c,headers:l,body:u,method:d,signal:s});for(let e of n.onRequest)if(e){let t=await e(f);typeof t==`object`&&t&&Object.assign(f,t)}(`pipeTo`in f&&typeof f.pipeTo==`function`||typeof t?.body?.pipe==`function`)&&(`duplex`in f||(f.duplex=`half`));let{clearTimeout:p}=ht(i,o),m=await a(f.url,f);p();let h={response:m,request:f};for(let e of n.onResponse)if(e){let n=await e(K(G({},h),{response:t?.hookOptions?.cloneResponse?m.clone():m}));n instanceof Response?m=n:typeof n==`object`&&n&&(m=n.response)}if(m.ok){if(f.method===`HEAD`)return{data:``,error:null};let e=rt(m),r={data:null,response:m,request:f};if(e===`json`||e===`text`){let e=await m.text();r.data=await(f.jsonParser??ot)(e)}else r.data=await m[e]();f?.output&&f.output&&!f.disableValidation&&(r.data=await _t(f.output,r.data));for(let e of n.onSuccess)e&&await e(K(G({},r),{response:t?.hookOptions?.cloneResponse?m.clone():m}));return t?.throw?r.data:{data:r.data,error:null}}let g=t?.jsonParser??ot,_=await m.text(),v=it(_),y=v?await g(_):null,b={response:m,responseText:_,request:f,error:K(G({},y),{status:m.status,statusText:m.statusText})};for(let e of n.onError)e&&await e(K(G({},b),{response:t?.hookOptions?.cloneResponse?m.clone():m}));if(t?.retry){let r=et(t.retry),i=t.retryAttempt??0;if(await r.shouldAttemptRetry(i,m)){for(let e of n.onRetry)e&&await e(h);let a=r.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await wt(e,K(G({},t),{retryAttempt:i+1}))}}if(t?.throw)throw new Xe(m.status,m.statusText,v?y:_);return{data:null,error:K(G({},y),{status:m.status,statusText:m.statusText})}},Tt=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},Et=(e,t)=>{let n=`credentials`in Request.prototype,r=De(e?.baseURL,e?.basePath,void 0,t)??Tt(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=bt({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?ce(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[je],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=Re(d,e),h=!1,g=e=>{h||e===null||(h=!0,Pe(p,e))},_=e?.plugins||[],v={},y={$sessionSignal:f,session:p},b={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},x=[{signal:`$sessionSignal`,matcher(e){return e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`},callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of _)e.getAtoms&&Object.assign(y,e.getAtoms?.(d)),e.pathMethods&&Object.assign(b,e.pathMethods),e.atomListeners&&x.push(...e.atomListeners);let S={notify:e=>{y[e].set(!y[e].get())},listen:(e,t)=>{y[e].subscribe(t)},atoms:y};for(let t of _)t.getActions&&(v=He(t.getActions?.(d,S,e)??{},v));return{get baseURL(){return r},pluginsActions:v,pluginsAtoms:y,pluginPathMethods:b,atomListeners:x,hydrateSession:g,$fetch:d,$store:S}};function Dt(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function Ot(e){return e.charAt(0).toUpperCase()+e.slice(1)}var kt=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,At=/['\u2019]/g;function jt(e){return e.replace(At,``).match(kt)??[]}function Mt(e){return jt(e).map(e=>e.toLowerCase()).join(`-`)}function Nt(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function Pt(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||Dt(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(Mt).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Nt(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function Ft(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=Et(e),c={};for(let[e,t]of Object.entries(r))c[`use${Ot(e)}`]=t;return Pt({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}function It(e){return{success:!1,error:`You are not allowed to access resource: ${e}`}}function Lt(e){return{success:!1,error:`unauthorized to access resource "${e}"`}}function Rt(e){return e===`OR`?`OR`:`AND`}function zt(e){return Array.isArray(e)}function Bt(e){if(zt(e))return{actions:e,connector:`AND`};if(!e||typeof e!=`object`)throw new W(`Invalid access control request`);let{actions:t,connector:n}=e;return zt(t)?{actions:t,connector:Rt(n)}:{actions:[],connector:Rt(n)}}function Vt(e,t){return typeof t==`string`&&e.includes(t)}function Ht(e,{actions:t,connector:n}){return t.length===0?!1:n===`OR`?t.some(t=>Vt(e,t)):t.every(t=>Vt(e,t))}function Ut(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t){if(n===`AND`)return It(i);continue}let o=Ht(t,Bt(a));if(o&&(r=!0),o&&n===`OR`)return{success:!0};if(!o&&n===`AND`)return Lt(i)}return r?{success:!0}:{success:!1,error:`Not authorized`}},statements:e}}function Wt(e){return{newRole(e){return Ut(e)},statements:e}}var Gt=ge({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:`You are not allowed to create a new organization`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:`You have reached the maximum number of organizations`,ORGANIZATION_ALREADY_EXISTS:`Organization already exists`,ORGANIZATION_SLUG_ALREADY_TAKEN:`Organization slug already taken`,ORGANIZATION_NOT_FOUND:`Organization not found`,USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:`User is not a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:`You are not allowed to update this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:`You are not allowed to delete this organization`,NO_ACTIVE_ORGANIZATION:`No active organization`,USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:`User is already a member of this organization`,MEMBER_NOT_FOUND:`Member not found`,ROLE_NOT_FOUND:`Role not found`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:`You are not allowed to create a new team`,TEAM_ALREADY_EXISTS:`Team already exists`,TEAM_NOT_FOUND:`Team not found`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:`You cannot leave the organization as the only owner`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:`You cannot leave the organization without an owner`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:`You are not allowed to delete this member`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:`You are not allowed to invite users to this organization`,USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:`User is already invited to this organization`,INVITATION_NOT_FOUND:`Invitation not found`,YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:`You are not the recipient of the invitation`,EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:`Email verification required before accepting or rejecting invitation`,EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION:`Email verification required to view or list invitations for the session email`,YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:`You are not allowed to cancel this invitation`,INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:`Inviter is no longer a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:`You are not allowed to invite a user with this role`,FAILED_TO_RETRIEVE_INVITATION:`Failed to retrieve invitation`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:`You have reached the maximum number of teams`,UNABLE_TO_REMOVE_LAST_TEAM:`Unable to remove last team`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:`You are not allowed to update this member`,ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:`Organization membership limit reached`,YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to create teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to delete teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:`You are not allowed to update this team`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:`You are not allowed to delete this team`,INVITATION_LIMIT_REACHED:`Invitation limit reached`,TEAM_MEMBER_LIMIT_REACHED:`Team member limit reached`,USER_IS_NOT_A_MEMBER_OF_THE_TEAM:`User is not a member of the team`,YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:`You are not allowed to list the members of this team`,YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:`You do not have an active team`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:`You are not allowed to create a new member`,YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:`You are not allowed to remove a team member`,YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:`You are not allowed to access this organization as an owner`,YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:`You are not a member of this organization`,MISSING_AC_INSTANCE:`Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information`,YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:`You must be in an organization to create a role`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:`You are not allowed to create a role`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:`You are not allowed to update a role`,YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:`You are not allowed to delete a role`,YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:`You are not allowed to read a role`,YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:`You are not allowed to list a role`,YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:`You are not allowed to get a role`,TOO_MANY_ROLES:`This organization has too many roles`,INVALID_RESOURCE:`The provided permission includes an invalid resource`,ROLE_NAME_IS_ALREADY_TAKEN:`That role name is already taken`,CANNOT_DELETE_A_PRE_DEFINED_ROLE:`Cannot delete a pre-defined role`,ROLE_IS_ASSIGNED_TO_MEMBERS:`Cannot delete a role that is assigned to members. Please reassign the members to a different role first`,INVALID_TEAM_ID:`Team id contains a reserved character`}),Kt=Wt({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),qt=Kt.newRole({organization:[`update`],invitation:[`create`,`cancel`],member:[`create`,`update`,`delete`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),Jt=Kt.newRole({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),Yt=Kt.newRole({organization:[],member:[],invitation:[],team:[],ac:[`read`]}),Xt={admin:qt,owner:Jt,member:Yt},Zt=(e,t)=>{if(!e.permissions)return!1;let n=e.role.split(`,`),r=e.options.creatorRole||`owner`,i=n.includes(r),a=e.allowCreatorAllPermissions||!1;if(i&&a)return!0;for(let r of n)if(t[r]?.authorize(e.permissions)?.success)return!0;return!1},Qt=e=>Zt(e,e.options.roles||Xt),$t=e=>{let t=w(!1),n=w(!1),r=w(!1),i=w(!1),a={admin:qt,member:Yt,owner:Jt,...e?.roles};return{id:`organization`,version:p,$InferServerPlugin:{},getActions:(t,n,r)=>({$Infer:{ActiveOrganization:{},Organization:{},Invitation:{},Member:{},Team:{}},organization:{checkRolePermission:t=>Qt({role:t.role,options:{ac:e?.ac,roles:a},permissions:t.permissions})}}),getAtoms:e=>{let a=de(t,`/organization/list`,e,{method:`GET`});return{$listOrg:t,$activeOrgSignal:n,$activeMemberSignal:r,$activeMemberRoleSignal:i,activeOrganization:de([n],`/organization/get-full-organization`,e,()=>({method:`GET`})),listOrganizations:a,activeMember:de([n,r],`/organization/get-active-member`,e,{method:`GET`}),activeMemberRole:de([n,i],`/organization/get-active-member-role`,e,{method:`GET`})}},pathMethods:{"/organization/get-full-organization":`GET`,"/organization/list-user-teams":`GET`},atomListeners:[{matcher(e){return e===`/organization/create`||e===`/organization/delete`||e===`/organization/update`},signal:`$listOrg`},{matcher(e){return e===`/sign-out`||e.startsWith(`/organization`)},signal:`$activeOrgSignal`},{matcher(e){return e.startsWith(`/organization/set-active`)||e===`/organization/create`||e===`/organization/delete`||e===`/organization/remove-member`||e===`/organization/leave`||e===`/organization/accept-invitation`},signal:`$sessionSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberRoleSignal`}],$ERROR_CODES:Gt}},en=ge({OTP_NOT_ENABLED:`OTP not enabled`,OTP_NOT_CONFIGURED:`OTP is not available`,OTP_HAS_EXPIRED:`OTP has expired`,TOTP_NOT_ENABLED:`TOTP not enabled`,TOTP_NOT_CONFIGURED:`TOTP is not available`,TWO_FACTOR_NOT_ENABLED:`Two factor isn't enabled`,BACKUP_CODES_NOT_ENABLED:`Backup codes aren't enabled`,INVALID_BACKUP_CODE:`Invalid backup code`,INVALID_CODE:`Invalid code`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`Too many attempts. Please request a new code.`,ACCOUNT_TEMPORARILY_LOCKED:`Too many failed verification attempts. Your account is temporarily locked. Please try again later.`,INVALID_TWO_FACTOR_COOKIE:`Invalid two factor cookie`}),tn=e=>({id:`two-factor`,version:p,$InferServerPlugin:{},atomListeners:[{matcher:e=>e.startsWith(`/two-factor/`),signal:`$sessionSignal`}],pathMethods:{"/two-factor/disable":`POST`,"/two-factor/enable":`POST`,"/two-factor/send-otp":`POST`,"/two-factor/generate-backup-codes":`POST`,"/two-factor/get-totp-uri":`POST`,"/two-factor/verify-totp":`POST`,"/two-factor/verify-otp":`POST`,"/two-factor/verify-backup-code":`POST`},fetchPlugins:[{id:`two-factor`,name:`two-factor`,hooks:{async onSuccess(t){if(t.data?.twoFactorRedirect){if(e?.onTwoFactorRedirect){await e.onTwoFactorRedirect({twoFactorMethods:t.data.twoFactorMethods});return}e?.twoFactorPage&&typeof window<`u`&&Ae(e.twoFactorPage)&&(window.location.href=e.twoFactorPage)}}}}],$ERROR_CODES:en}),nn=Object.values({pending:`pending`,accepted:`accepted`,rejected:`rejected`,canceled:`canceled`}),rn=new Set(nn);function an(e){return typeof e==`string`&&rn.has(e)}var on=`auth-session-token`,q={_memoryToken:null,_rotationListeners:new Set,get(){try{if(typeof localStorage<`u`)return localStorage.getItem(on)}catch{}return this._memoryToken},set(e){let t=this.get();this._memoryToken=e;try{typeof localStorage<`u`&&localStorage.setItem(on,e)}catch{}if(t&&t!==e)for(let e of[...this._rotationListeners])try{e()}catch{}},clear(){this._memoryToken=null;try{typeof localStorage<`u`&&localStorage.removeItem(on)}catch{}},subscribeRotation(e){return this._rotationListeners.add(e),()=>{this._rotationListeners.delete(e)}}};function J(e,t){let n=Error(e.message??t??`Auth request failed with status ${e.status}`);return e.code&&(n.code=e.code),n}function sn(e,t){let n=e?.status;if(!an(n))throw Error(`${t}: unexpected invitation status ${JSON.stringify(n)} — expected one of ${nn.join(` | `)}`);return e}function cn(e,t){return(Array.isArray(e)?e:[]).map(e=>sn(e,t))}function ln(e){try{let t=new URL(e);return{origin:t.origin,basePath:t.pathname.replace(/\/$/,``)}}catch{return{origin:un()??`http://localhost`,basePath:e.replace(/\/$/,``)}}}function un(){try{if(typeof window<`u`&&window.location?.origin)return window.location.origin}catch{}}function dn(){try{if(typeof document<`u`){let e=document.querySelector(`base`)?.getAttribute(`href`);if(e)return`${new URL(e,un()??`http://localhost`).pathname.replace(/\/$/,``)}/reset-password`}}catch{}return`/reset-password`}function fn(e){let t=e||globalThis.fetch.bind(globalThis);return async(e,n)=>{let r=new Headers(n?.headers),i=q.get();if(i){let t=typeof e==`string`?e:e instanceof URL?e.href:e.url;/\/api\//i.test(t)&&r.set(`Authorization`,`Bearer ${i}`)}let a=await t(e,{...n,headers:r}),o=a.headers.get(`set-auth-token`);return o&&q.set(o),a}}function pn(e){let{baseURL:t,fetchFn:n}=e,{origin:r,basePath:i}=ln(t),a=fn(n),o=Ft({baseURL:r,basePath:i,disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:a},plugins:[$t(),tn()]});async function s(e,t){let n=await a(`${r}${i}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify(t)}),o=await n.json().catch(()=>({}));if(!n.ok){let e=Error(o?.message??`Auth request failed with status ${n.status}`);throw o?.code&&(e.code=o.code),e.status=n.status,e}return o??{}}async function c(e){let t=typeof AbortController<`u`?new AbortController:void 0,n=t?setTimeout(()=>t.abort(),e):void 0;try{let e=`${r}${i}/config`,n=await a(e,{method:`GET`,headers:{"Content-Type":`application/json`},...t?{signal:t.signal}:{}});if(!n.ok)throw Error(`Failed to load auth config (status ${n.status})`);let o=await n.json();return o&&typeof o==`object`&&`data`in o&&o.data?o.data:o}finally{n!==void 0&&clearTimeout(n)}}let l=[500,1500,3500],u=null;async function d(){let e;for(let t=0;t<=l.length;t++)try{return await c(8e3)}catch(n){e=n,t<l.length&&await new Promise(e=>setTimeout(e,l[t]))}throw e instanceof Error?e:Error(String(e))}return{async signIn(e){let{data:t,error:n}=await o.signIn.email({email:e.email,password:e.password});if(n)throw J(n);let r=t;return r.session?.token&&q.set(r.session.token),{user:r.user,session:r.session}},async signUp(e){let{data:t,error:n}=await o.signUp.email({email:e.email,password:e.password,name:e.name,...e.callbackURL?{callbackURL:e.callbackURL}:{}});if(n)throw J(n);let r=t,i=r.token??r.session?.token??null;i&&q.set(i);let a=r.session??null;return!a&&i&&(a={token:i}),{user:r.user,session:a,requiresVerification:i===null}},async sendVerificationEmail(e,t){let{error:n}=await o.sendVerificationEmail({email:e,callbackURL:t});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`)},async signOut(){let{error:e}=await o.signOut();if(q.clear(),e)throw Error(e.message??`Auth request failed with status ${e.status}`)},async getSession(){let e=null;try{let t=await o.getSession();t.error||(e=t.data)}catch{}if(e){let t=e;return t.session?.token&&q.set(t.session.token),{user:t.user,session:t.session}}if(q.get())try{let e=await(n||globalThis.fetch.bind(globalThis))(`${r}${i}/get-session`,{method:`GET`,credentials:`include`,headers:{"Content-Type":`application/json`}});if(e.ok){let t=await e.json().catch(()=>null);if(t?.user&&t?.session)return t.session.token?q.set(t.session.token):q.clear(),{user:t.user,session:t.session};q.clear()}}catch{}return null},async forgotPassword(e){let t=o,n=t.requestPasswordReset??t.forgetPassword;if(typeof n!=`function`)throw Error(`password reset is not available on this auth backend`);let{error:r}=await n({email:e,redirectTo:dn()});if(r)throw Error(r.message??`Auth request failed with status ${r.status}`)},async resetPassword(e,t){let{error:n}=await o.resetPassword({token:e,newPassword:t});if(n)throw Error(n.message??`Auth request failed with status ${n.status}`)},async sendPhoneOtp(e){await s(`/phone-number/send-otp`,{phoneNumber:e})},async signInWithPhoneOtp(e,t){let n=await s(`/phone-number/verify`,{phoneNumber:e,code:t}),r=typeof n.token==`string`?n.token:void 0,i=n.user??null;if(!r||!i)throw Error(`No account is registered for this phone number.`);return q.set(r),{user:i,session:{token:r}}},async signInWithPhonePassword(e,t){let n=await s(`/sign-in/phone-number`,{phoneNumber:e,password:t}),r=typeof n.token==`string`?n.token:void 0,i=n.user??null;if(!r||!i)throw Error(`Invalid phone number or password.`);return q.set(r),{user:i,session:{token:r}}},async requestPhonePasswordReset(e){await s(`/phone-number/request-password-reset`,{phoneNumber:e})},async resetPasswordWithPhoneOtp(e,t,n){await s(`/phone-number/reset-password`,{phoneNumber:e,otp:t,newPassword:n})},async changePassword(e,t,n){let r=o.changePassword;if(typeof r!=`function`)throw Error(`change-password is not available on this auth backend`);let{error:i}=await r({currentPassword:e,newPassword:t,...n?.revokeOtherSessions==null?{}:{revokeOtherSessions:n.revokeOtherSessions}});if(i)throw Error(i.message??`Auth request failed with status ${i.status}`)},async enrollTotp(e){let t=o.twoFactor;if(!t||typeof t.enable!=`function`)throw Error(`two-factor enrollment is not available on this auth backend`);let{data:n,error:r}=await t.enable({password:e});if(r)throw Error(r.message??`Two-factor enable failed (${r.status??`?`})`);return{totpURI:n?.totpURI??``,backupCodes:n?.backupCodes??[]}},async verifyTotp(e){let t=o.twoFactor;if(!t||typeof t.verifyTotp!=`function`)throw Error(`two-factor verification is not available on this auth backend`);let{error:n}=await t.verifyTotp({code:e});if(n)throw Error(n.message??`Two-factor verification failed (${n.status??`?`})`)},async setInitialPassword(e){let t=`${r}${i}/set-initial-password`,n=await a(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newPassword:e})});if(!n.ok){let e=`Set password failed with status ${n.status}`;try{let t=await n.json();t?.error?.message&&(e=t.error.message)}catch{}throw Error(e)}},async hasLocalPassword(){let e=`${r}${i}/list-accounts`;try{let t=await a(e,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!t.ok)return!1;let n=await t.json();return(Array.isArray(n)?n:n&&`data`in n&&Array.isArray(n.data)?n.data:[]).some(e=>e?.providerId===`credential`)}catch{return!1}},async updateUser(e){let{data:t,error:n}=await o.updateUser(e);if(n)throw Error(n.message??`Auth request failed with status ${n.status}`);if(!t)throw Error(`Update user returned no data`);let r=t;return r&&typeof r==`object`&&`user`in r?r.user:r},async describeDelegableScope(){try{let e=i.replace(/\/auth$/,`/security`),t=await a(`${r}${e}/my-delegable-scope`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!t.ok)return null;let n=await t.json(),o=n&&typeof n==`object`&&`data`in n?n.data:n;return o&&typeof o==`object`&&Array.isArray(o.placeableBusinessUnitIds)?o:null}catch{return null}},async getConfig(){return u||=d().catch(e=>{throw u=null,e}),u},async signInWithProvider(e,t={}){let{type:n=`social`,callbackURL:r,errorCallbackURL:i}=t,a=e=>new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`Sign-in timed out — the server did not respond. Please try again.`)),2e4);e.then(e=>{clearTimeout(r),t(e)},e=>{clearTimeout(r),n(e)})}),s=async()=>await a(o.signIn.social({provider:e,callbackURL:r,errorCallbackURL:i})),c;if(n===`oidc`){if(c=await s(),c.error){let t=o.signIn.oauth2,n=t?await a(t({providerId:e,callbackURL:r,errorCallbackURL:i})).catch(()=>null):null;n&&!n.error&&(c=n)}}else c=await s();let{data:l,error:u}=c;if(u)throw Error(u.message??`Auth request failed with status ${u.status}`);if(!l?.url)throw Error(`Sign-in with "${e}" did not return a redirect URL — please try again or contact your administrator.`);typeof window<`u`&&(window.location.href=l.url)},async listOrganizations(){let{data:e,error:t}=await o.organization.list();if(t)throw J(t,`Failed to list organizations`);return e??[]},async createOrganization(e){let{data:t,error:n}=await o.organization.create({name:e.name,slug:e.slug,logo:e.logo});if(n)throw J(n,`Failed to create organization`);return t},async setActiveOrganization(e){let{data:t,error:n}=await o.organization.setActive({organizationId:e});if(n)throw J(n,`Failed to set active organization`);return t??null},async getActiveOrganization(){let{data:e,error:t}=await o.organization.getFullOrganization();return t||!e?null:e},async getActiveMember(){let e=o.organization?.getActiveMember;if(typeof e!=`function`)return null;let{data:t,error:n}=await e();return n||!t?null:t},async getMembers(e){let{data:t,error:n}=await o.organization.listMembers({query:{organizationId:e}});if(n)throw J(n,`Failed to get members`);let r=t;return Array.isArray(r)?r:r?.members??[]},async inviteMember(e){let{data:t,error:n}=await o.organization.inviteMember({organizationId:e.organizationId,email:e.email,role:e.role,...e.businessUnitId?{businessUnitId:e.businessUnitId}:{},...e.positions?.length?{positions:e.positions}:{}});if(n)throw J(n,`Failed to invite member`);return sn(t,`inviteMember`)},async removeMember(e){let{error:t}=await o.organization.removeMember({organizationId:e.organizationId,memberIdOrUserId:e.memberIdOrUserId});if(t)throw J(t,`Failed to remove member`)},async updateMemberRole(e){let{error:t}=await o.organization.updateMemberRole({organizationId:e.organizationId,memberId:e.memberId,role:e.role});if(t)throw J(t,`Failed to update member role`)},async updateOrganization(e,t){let{data:n,error:r}=await o.organization.update({organizationId:e,data:t});if(r)throw J(r,`Failed to update organization`);return n},async deleteOrganization(e){let{error:t}=await o.organization.delete({organizationId:e});if(t)throw J(t,`Failed to delete organization`)},async leaveOrganization(e){let{error:t}=await o.organization.leave({organizationId:e});if(t)throw J(t,`Failed to leave organization`)},async listInvitations(e){let{data:t,error:n}=await o.organization.listInvitations({query:{organizationId:e}});if(n)throw J(n,`Failed to list invitations`);return cn(t,`listInvitations`)},async cancelInvitation(e){let{error:t}=await o.organization.cancelInvitation({invitationId:e});if(t)throw J(t,`Failed to cancel invitation`)},async getInvitation(e){let{data:t,error:n}=await o.organization.getInvitation({query:{id:e}});if(n)throw J(n,`Failed to load invitation`);return sn(t,`getInvitation`)},async acceptInvitation(e){let{error:t}=await o.organization.acceptInvitation({invitationId:e});if(t)throw J(t,`Failed to accept invitation`)},async rejectInvitation(e){let{error:t}=await o.organization.rejectInvitation({invitationId:e});if(t)throw J(t,`Failed to reject invitation`)},async listUserInvitations(){let{data:e,error:t}=await o.organization.listUserInvitations();if(t)throw J(t,`Failed to list invitations`);return cn(e,`listUserInvitations`)}}}var mn=`auth-session-user-id`,hn=`auth-active-organization-id`,gn=hn,_n=new Set([`auth-session-token`,mn,`vite-ui-theme`]);function vn(e){try{return e===`local`?typeof localStorage<`u`?localStorage:void 0:typeof sessionStorage<`u`?sessionStorage:void 0}catch{return}}function yn(e){try{return vn(`local`)?.getItem(e)??null}catch{return null}}function bn(e,t){try{vn(`local`)?.setItem(e,t)}catch{}}function xn(e){try{vn(`local`)?.removeItem(e)}catch{}return yn(e)===null}function Sn(e){if(!e)return;let t;try{t=Object.keys(e)}catch{return}let n=[];for(let r of t)if(!_n.has(r))try{e.removeItem(r)}catch{n.push(r)}n.length>0&&console.warn(`[purgePreviousUserClientState] could not remove ${n.length} key(s) from storage: ${n.join(`, `)}. The previous user's state may still be readable under these keys.`)}function Cn(){Y.clear(),Sn(vn(`local`)),Sn(vn(`session`))}var wn=new Set,Tn=0;function En(){return Tn}function Dn(e){return wn.add(e),()=>{wn.delete(e)}}function On(){Tn+=1;for(let e of[...wn])try{e()}catch(e){console.warn(`[SessionUserScope] an owner-change listener threw:`,e)}}var kn={_userId:null,current(){return this._userId===null?yn(mn):this._userId},adopt(e){if(!e||this._userId===e)return!1;let t=yn(mn),n=t!==null&&t!==e;return n&&Cn(),this._userId=e,bn(mn,e),xn(gn),n&&On(),n},_resetForTests(){this._userId=null}};function An(){let e=kn.current();return e?`${hn}:u:${e}`:null}var Y={_memoryValue:null,_unremovedKeys:new Set,get(){let e=An();if(e&&!this._unremovedKeys.has(e))try{let t=vn(`local`)?.getItem(e)??null;if(t!==null)return t}catch{}return this._memoryValue},set(e){this._memoryValue=e;let t=An();t&&bn(t,e)},clear(){this._memoryValue=null;let e=An();e&&(xn(e)?this._unremovedKeys.delete(e):(this._unremovedKeys.add(e),console.warn(`[ActiveOrganizationStorage] clear() could not remove "${e}" from localStorage — it is still readable. Reads for it are answered from memory for the rest of this page-load, so the cleared organization is not re-stamped as X-Tenant-ID.`))),xn(gn)}},X=t(),jn=`objectui:metadata:`;function Mn(){if(typeof sessionStorage<`u`){let e;try{e=Object.keys(sessionStorage)}catch{e=[]}let t=[];for(let n of e)if(n.startsWith(jn))try{sessionStorage.removeItem(n)}catch{t.push(n)}t.length>0&&console.warn(`[purgeSignedOutClientCaches] could not remove ${t.length} key(s) from sessionStorage: ${t.join(`, `)}. The signed-out user's metadata seed cache may still be readable under these keys.`)}Y.clear()}function Nn({authUrl:e,client:t,onAuthStateChange:n,enabled:r=!0,previewMode:i,children:a}){let o=(0,c.useMemo)(()=>t??pn({baseURL:e}),[t,e]),[s,l]=(0,c.useState)(null),[d,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(!0),[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(null),[b,x]=(0,c.useState)([]),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(null),[E,D]=(0,c.useState)(!1),[O,ee]=(0,c.useState)(!1),[k,A]=(0,c.useState)(!1),j=i!=null,M=r&&!j?s!==null&&d!==null:!0,N=(0,c.useRef)(!1),P=(0,c.useRef)(null),F=(0,c.useRef)(0),I=(0,c.useCallback)(async e=>{N.current=!0;try{let t=await o.getSession();if(e?.())return;t?(l(t.user),p(t.session)):(l(null),p(null))}catch(t){if(e?.())return;_(t instanceof Error?t:Error(String(t)))}finally{N.current=!1,e?.()||h(!1)}},[o]),L=(0,c.useCallback)(async()=>{r&&!j&&await I()},[r,j,I]);(0,c.useEffect)(()=>{if(r&&!j)return q.subscribeRotation(()=>{N.current||I()})},[r,j,I]),(0,c.useEffect)(()=>{if(j){let e=i.simulatedRole??`admin`,t=i.simulatedUserName??`Preview User`,n=i.expiresInSeconds??0;l({id:`preview-user`,email:`preview@preview.local`,name:t,role:e,positions:[e]}),p({token:`preview-token`,expiresAt:n>0?new Date(Date.now()+n*1e3):new Date(Date.now()+31536e6)}),h(!1);return}if(!r){l({id:`guest`,email:`guest@local`,name:`Guest User`,role:`admin`}),p({token:`guest-token`,expiresAt:new Date(Date.now()+31536e6)}),h(!1);return}let e=!1;return I(()=>e),()=>{e=!0}},[o,r,j,i,I]),(0,c.useEffect)(()=>{n?.({user:s,session:d,isAuthenticated:M,isLoading:m,error:g})},[s,d,M,m,g,n]);let R=(0,c.useCallback)(async(e,t)=>{h(!0),_(null);try{let n=await o.signIn({email:e,password:t});l(n.user),p(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),te=(0,c.useCallback)(async(e,t,n,r)=>{h(!0),_(null);try{let i=await o.signUp({name:e,email:t,password:n,...r?{callbackURL:r}:{}});return i.requiresVerification?{requiresVerification:!0}:(l(i.user),p(i.session),{requiresVerification:!1})}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),z=(0,c.useCallback)(async()=>{h(!0);try{await o.signOut(),l(null),p(null),_(null),x([]),C(null)}catch(e){_(e instanceof Error?e:Error(String(e)))}finally{Mn(),h(!1)}},[o]),ne=(0,c.useCallback)(async e=>{_(null);try{let t=await o.updateUser(e);l(t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),re=(0,c.useCallback)(async e=>{_(null);try{await o.forgotPassword(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),B=(0,c.useCallback)(async(e,t)=>{_(null);try{await o.sendVerificationEmail(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),ie=(0,c.useCallback)(async(e,t)=>{_(null);try{await o.resetPassword(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),ae=(0,c.useCallback)(async e=>{_(null);try{await o.sendPhoneOtp(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),oe=(0,c.useCallback)(async(e,t)=>{h(!0),_(null);try{let n=await o.signInWithPhoneOtp(e,t);l(n.user),p(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),se=(0,c.useCallback)(async(e,t)=>{h(!0),_(null);try{let n=await o.signInWithPhonePassword(e,t);l(n.user),p(n.session)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{h(!1)}},[o]),ce=(0,c.useCallback)(async e=>{_(null);try{await o.requestPhonePasswordReset(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),le=(0,c.useCallback)(async(e,t,n)=>{_(null);try{await o.resetPasswordWithPhoneOtp(e,t,n)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]);(0,c.useEffect)(()=>u.subscribe(e=>{y(t=>t??e)}),[]);let ue=(0,c.useCallback)(e=>o.enrollTotp(e),[o]),de=(0,c.useCallback)(e=>o.verifyTotp(e),[o]),V=(0,c.useCallback)(async(e,t,n)=>{_(null);try{await o.changePassword(e,t,n)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),fe=(0,c.useCallback)(async e=>{_(null);try{await o.setInitialPassword(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),pe=(0,c.useCallback)(()=>o.hasLocalPassword(),[o]),me=(0,c.useCallback)(()=>o.getConfig(),[o]),he=(0,c.useCallback)(async(e,t)=>{_(null);try{await o.signInWithProvider(e,t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o]),H=(0,c.useCallback)(async e=>{if(r&&!j){D(!0);try{let t=await o.listOrganizations();if(e?.())return t;if(x(t),t.length>0&&!S){let n=null;try{n=await o.getActiveOrganization()}catch{n=null}if(!n&&t.length===1)try{n=await o.setActiveOrganization(t[0].id)}catch{n=null}n&&!e?.()&&(C(n),Y.set(n.id))}return t}catch(t){e?.()||console.warn(`[AuthProvider] Failed to load organizations:`,t)}finally{e?.()||(D(!1),ee(!0))}}},[o,r,j,S]),U=(0,c.useCallback)(async()=>{if(!r||j){let e=j?i?.simulatedRole??`admin`:`admin`;T({id:`preview-member`,organizationId:S?.id??`preview-org`,userId:`preview-user`,role:e}),ee(!0),A(!0);return}if(!S){T(null),A(!0);return}A(!1);try{let e=await o.getActiveMember();T(e)}catch(e){console.warn(`[AuthProvider] Failed to load active member:`,e),T(null)}finally{A(!0)}},[o,r,j,i,S]);(0,c.useEffect)(()=>{if(!r||j)return;let e=s?.id;e&&kn.adopt(e)},[s?.id,r,j]),(0,c.useEffect)(()=>{U()},[U]),(0,c.useEffect)(()=>{if(!(s&&r&&!j))return;let e=!1;return H(()=>e),()=>{e=!0}},[s,r,j]),(0,c.useEffect)(()=>{P.current=S?.id??null},[S]);let ge=(0,c.useCallback)(async e=>{_(null);let t=P.current;N.current=!0;try{let n=await o.setActiveOrganization(e);C(n),n?Y.set(n.id):Y.clear();let r=n?.id??null;if(r!==t){P.current=r;let e=++F.current;await I(()=>F.current!==e)}}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}finally{N.current=!1}},[o,I]),_e=(0,c.useCallback)(async e=>{_(null);try{let t=await o.createOrganization(e);return await H(),await ge(t.id),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw _(t),t}},[o,H,ge]),ve=(0,c.useCallback)(async(e,t)=>{let n=await o.updateOrganization(e,t);return await H(),S?.id===e&&C(n),n},[o,H,S]),ye=(0,c.useCallback)(async e=>{await o.deleteOrganization(e),S?.id===e&&(C(null),Y.clear()),await H()},[o,S,H]),be=(0,c.useCallback)(async e=>{await o.leaveOrganization(e),S?.id===e&&(C(null),Y.clear()),await H()},[o,S,H]),W=(0,c.useCallback)(e=>o.getMembers(e),[o]),xe=(0,c.useCallback)(e=>o.inviteMember(e),[o]),Se=(0,c.useCallback)(()=>o.describeDelegableScope(),[o]),Ce=(0,c.useCallback)(e=>o.removeMember(e),[o]),we=(0,c.useCallback)(e=>o.updateMemberRole(e),[o]),Te=(0,c.useCallback)(e=>o.listInvitations(e),[o]),Ee=(0,c.useCallback)(e=>o.cancelInvitation(e),[o]),De=(0,c.useCallback)(e=>o.getInvitation(e),[o]),Oe=(0,c.useCallback)(async e=>{await o.acceptInvitation(e),await H()},[o,H]),ke=(0,c.useCallback)(e=>o.rejectInvitation(e),[o]),Ae=(0,c.useCallback)(()=>o.listUserInvitations(),[o]),je=r&&!j,Me=je?s==null||O&&k:k,Ne=(0,c.useMemo)(()=>({user:s,session:d,isAuthenticated:M,isAuthEnabled:je,isLoading:m,error:g,isPreviewMode:j,previewMode:j?i:null,signIn:R,signUp:te,signOut:z,refreshSession:L,updateUser:ne,forgotPassword:re,sendVerificationEmail:B,resetPassword:ie,sendPhoneOtp:ae,signInWithPhoneOtp:oe,signInWithPhonePassword:se,requestPhonePasswordReset:ce,resetPasswordWithPhoneOtp:le,changePassword:V,remediationRequired:v,setRemediationRequired:y,enrollTotp:ue,verifyTotp:de,setInitialPassword:fe,hasLocalPassword:pe,getAuthConfig:me,signInWithProvider:he,organizations:b,activeOrganization:S,activeMember:w,isOrganizationsLoading:E,isMembershipResolved:Me,switchOrganization:ge,createOrganization:_e,refreshOrganizations:H,updateOrganization:ve,deleteOrganization:ye,leaveOrganization:be,getMembers:W,inviteMember:xe,describeDelegableScope:Se,removeMember:Ce,updateMemberRole:we,listInvitations:Te,cancelInvitation:Ee,getInvitation:De,acceptInvitation:Oe,rejectInvitation:ke,listUserInvitations:Ae}),[s,d,M,je,m,g,j,i,R,te,z,L,ne,re,B,ie,V,fe,pe,me,he,ae,oe,se,ce,le,v,ue,de,b,S,w,E,Me,ge,_e,H,ve,ye,be,W,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae]);return(0,X.jsx)(f.Provider,{value:Ne,children:a})}function Pn(){return(0,c.useContext)(f)||{user:null,session:null,isAuthenticated:!1,isAuthEnabled:!1,isLoading:!1,error:null,isPreviewMode:!1,previewMode:null,signIn:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signUp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signOut:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},refreshSession:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateUser:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},forgotPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},sendVerificationEmail:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},resetPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},sendPhoneOtp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signInWithPhoneOtp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},signInWithPhonePassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},requestPhonePasswordReset:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},resetPasswordWithPhoneOtp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},changePassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},remediationRequired:null,setRemediationRequired:()=>{},enrollTotp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},verifyTotp:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},setInitialPassword:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},hasLocalPassword:async()=>!1,getAuthConfig:async()=>({}),describeDelegableScope:async()=>null,signInWithProvider:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},organizations:[],activeOrganization:null,activeMember:null,isOrganizationsLoading:!1,isMembershipResolved:!0,switchOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},createOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},refreshOrganizations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},deleteOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},leaveOrganization:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},getMembers:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},inviteMember:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},removeMember:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},updateMemberRole:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},listInvitations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},cancelInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},getInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},acceptInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},rejectInvitation:async()=>{throw Error(`useAuth must be used within an AuthProvider`)},listUserInvitations:async()=>{throw Error(`useAuth must be used within an AuthProvider`)}}}var Fn=new Set([`owner`,`admin`,`super_admin`,`superadmin`,`platform_admin`,`system_admin`,`org_owner`,`org_admin`]),In=new Set([`org_owner`,`org_admin`]);function Ln(e){return typeof e==`string`&&Fn.has(e.toLowerCase())}function Rn(e){return typeof e==`string`&&In.has(e.toLowerCase())}function zn(){let{activeMember:e,user:t,isLoading:n,isMembershipResolved:r}=Pn(),i=t?.positions;return Ln(e?.role)||Ln(t?.role)||t?.isPlatformAdmin===!0||Array.isArray(i)&&i.some(Rn)?{isAdmin:!0,isResolved:!0}:{isAdmin:!1,isResolved:!n&&r}}function Bn({fallback:e=null,requiredRoles:t,loadingFallback:n,children:r}){let{isAuthenticated:i,isLoading:a,user:o}=Pn();if(a)return(0,X.jsx)(X.Fragment,{children:n??null});if(!i)return(0,X.jsx)(X.Fragment,{children:e});if(t&&t.length>0&&o){let n=o.positions??(o.role?[o.role]:[]);if(!t.some(e=>n.includes(e)))return(0,X.jsx)(X.Fragment,{children:e})}return(0,X.jsx)(X.Fragment,{children:r})}var Z=`flex h-11 w-full rounded-lg border border-input bg-background px-3.5 py-2 text-sm shadow-sm ring-offset-background transition-colors placeholder:text-muted-foreground hover:border-primary/40 focus-visible:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50`,Vn=`inline-flex h-11 w-full items-center justify-center gap-2 rounded-lg bg-gradient-to-r from-primary to-primary/85 px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm ring-offset-background transition-[box-shadow,background-color,transform] hover:shadow-md hover:from-primary hover:to-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 active:scale-[0.99] disabled:pointer-events-none disabled:opacity-60 motion-reduce:transition-none motion-reduce:active:transform-none`,Q=`text-sm font-medium leading-none text-foreground`;function $(){return(0,X.jsxs)(`svg`,{className:`h-4 w-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,X.jsx)(`path`,{className:`opacity-90`,d:`M4 12a8 8 0 018-8`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`})]})}function Hn({className:e}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e??`h-4 w-4 shrink-0`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,X.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,X.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}function Un({className:e}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e??`h-7 w-7`,"aria-hidden":`true`,children:[(0,X.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,X.jsx)(`path`,{d:`m22 6-10 7L2 6`})]})}function Wn({icon:e,title:t,description:n}){return(0,X.jsxs)(`div`,{className:`flex flex-col items-center space-y-3 text-center`,children:[e&&(0,X.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/15`,children:e}),(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground sm:text-[1.6rem]`,children:t}),n&&(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:n})]})}function Gn({message:e}){return(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:[(0,X.jsx)(Hn,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{className:`leading-snug`,children:e})]})}var Kn={google:`Google`,github:`GitHub`,microsoft:`Microsoft`,apple:`Apple`,facebook:`Facebook`,twitter:`Twitter`,discord:`Discord`,gitlab:`GitLab`,linkedin:`LinkedIn`},qn={google:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#EA4335`,d:`M12 10.2v3.9h5.5c-.24 1.4-1.7 4.1-5.5 4.1-3.3 0-6-2.74-6-6.1s2.7-6.1 6-6.1c1.88 0 3.14.8 3.86 1.5l2.64-2.55C16.84 3.36 14.66 2.4 12 2.4 6.92 2.4 2.8 6.52 2.8 11.6S6.92 20.8 12 20.8c6.92 0 9.2-4.86 9.2-7.4 0-.5-.06-.88-.14-1.2H12z`})}),github:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56v-2.07c-3.2.7-3.87-1.37-3.87-1.37-.52-1.33-1.27-1.69-1.27-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.18 1.76 1.18 1.02 1.75 2.68 1.25 3.34.96.1-.74.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.18-3.1-.12-.29-.51-1.46.11-3.04 0 0 .97-.31 3.18 1.18a11.04 11.04 0 015.79 0c2.21-1.49 3.18-1.18 3.18-1.18.62 1.58.23 2.75.11 3.04.74.81 1.18 1.84 1.18 3.1 0 4.42-2.7 5.39-5.27 5.68.41.36.78 1.06.78 2.13v3.16c0 .31.21.68.8.56C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5z`})}),microsoft:(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{fill:`#F25022`,d:`M2 2h9.5v9.5H2z`}),(0,X.jsx)(`path`,{fill:`#7FBA00`,d:`M12.5 2H22v9.5h-9.5z`}),(0,X.jsx)(`path`,{fill:`#00A4EF`,d:`M2 12.5h9.5V22H2z`}),(0,X.jsx)(`path`,{fill:`#FFB900`,d:`M12.5 12.5H22V22h-9.5z`})]}),apple:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M16.37 12.55c-.02-2.27 1.85-3.36 1.94-3.42-1.06-1.55-2.71-1.76-3.3-1.79-1.4-.14-2.74.83-3.45.83-.71 0-1.81-.81-2.98-.79-1.53.02-2.95.89-3.74 2.27-1.6 2.77-.41 6.86 1.14 9.11.76 1.1 1.66 2.34 2.83 2.3 1.14-.05 1.57-.74 2.94-.74 1.37 0 1.76.74 2.96.71 1.22-.02 2-1.12 2.75-2.23.87-1.28 1.22-2.52 1.24-2.59-.03-.01-2.38-.91-2.4-3.66zM14.1 5.31c.62-.76 1.05-1.81.93-2.86-.9.04-2 .6-2.65 1.35-.58.66-1.1 1.74-.96 2.76 1.01.08 2.04-.51 2.68-1.25z`})}),facebook:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#1877F2`,d:`M24 12C24 5.37 18.63 0 12 0S0 5.37 0 12c0 5.99 4.39 10.95 10.13 11.85V15.47H7.08V12h3.05V9.36c0-3.01 1.79-4.67 4.53-4.67 1.31 0 2.69.23 2.69.23v2.96h-1.51c-1.49 0-1.96.93-1.96 1.88V12h3.33l-.53 3.47h-2.8v8.38C19.61 22.95 24 17.99 24 12z`})}),twitter:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 fill-current`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),discord:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#5865F2`,d:`M20.32 4.37A19.79 19.79 0 0016.56 3l-.18.36a18.27 18.27 0 00-8.76 0L7.44 3a19.79 19.79 0 00-3.76 1.37C.99 8.4.27 12.34.63 16.22a19.94 19.94 0 006.07 3.07l.49-.7a13.2 13.2 0 01-2.07-.99c.17-.13.34-.27.5-.41a14.13 14.13 0 0012.76 0c.16.14.33.28.5.41-.66.4-1.36.73-2.07.99l.49.7a19.92 19.92 0 006.07-3.07c.43-4.5-.66-8.41-2.95-11.85zM8.52 14.12c-1.18 0-2.15-1.08-2.15-2.41 0-1.33.95-2.42 2.15-2.42 1.2 0 2.17 1.09 2.15 2.42 0 1.33-.96 2.41-2.15 2.41zm6.96 0c-1.18 0-2.15-1.08-2.15-2.41 0-1.33.95-2.42 2.15-2.42 1.2 0 2.17 1.09 2.15 2.42 0 1.33-.95 2.41-2.15 2.41z`})}),gitlab:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#FC6D26`,d:`M23.6 9.6L23.57 9.5 20.3.81a.84.84 0 00-1.6.05L16.5 7.6H7.5L5.3.86a.84.84 0 00-1.6-.05L.43 9.5l-.03.1a5.84 5.84 0 001.94 6.74l.01.01.03.02 4.8 3.6 2.38 1.8 1.45 1.1a1 1 0 001.2 0l1.45-1.1 2.38-1.8 4.83-3.62.01-.01a5.84 5.84 0 001.93-6.74z`})}),linkedin:(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{fill:`#0A66C2`,d:`M20.45 20.45h-3.55v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.13 1.45-2.13 2.94v5.67H9.36V9h3.41v1.56h.05c.48-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.45v6.29zM5.34 7.43a2.06 2.06 0 11.01-4.13 2.06 2.06 0 010 4.13zM7.12 20.45H3.56V9h3.56v11.45zM22.22 0H1.77C.79 0 0 .77 0 1.72v20.56C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.72V1.72C24 .77 23.2 0 22.22 0z`})})};function Jn({id:e}){let t=qn[e];return t?(0,X.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center`,children:t}):(0,X.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center rounded-sm bg-muted text-[10px] font-bold uppercase`,children:e[0]})}function Yn({mode:e=`sign-in`,callbackURL:t,errorCallbackURL:n,dividerText:r=`or continue with email`,buttonText:i,onProvidersResolved:a}){let{getAuthConfig:o,signInWithProvider:s}=Pn(),[l,u]=(0,c.useState)([]),[d,f]=(0,c.useState)(!0),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(null);if((0,c.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>o()).then(t=>{if(e)return;let n=(t?.socialProviders??[]).filter(e=>e.enabled);u(n),a?.(n.length>0)}).catch(t=>{e||(console.warn(`[SocialSignInButtons] failed to load auth config`,t),a?.(!1))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[o]),d||l.length===0)return null;let _=i??(e===`sign-in`?`Continue with {provider}`:`Sign up with {provider}`),v=typeof window<`u`?window.location.href:void 0,y=async e=>{if(!h){m(null),g(e.id);try{await s(e.id,{callbackURL:t??v,errorCallbackURL:n??t??v,type:e.type??`social`})}catch(e){m(e instanceof Error?e.message:String(e)),g(null)}}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,X.jsx)(`div`,{className:`rounded-md bg-destructive/15 p-3 text-sm text-destructive`,role:`alert`,children:p}),l.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>y(e),disabled:h!==null,"aria-busy":h===e.id,className:`inline-flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,children:[h===e.id?(0,X.jsx)($,{}):(0,X.jsx)(Jn,{id:e.id}),_.replace(`{provider}`,()=>Kn[e.id]??e.name)]},e.id)),(0,X.jsxs)(`div`,{className:`relative my-1`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,X.jsx)(`span`,{className:`w-full border-t`})}),(0,X.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,X.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:r})})]})]})}function Xn(e){let t=String(e??``).replace(/[\s\-().]/g,``);return/^\+?[0-9]{6,15}$/.test(t)?t:null}function Zn(e){return typeof e!=`string`||e.includes(`@`)?!1:Xn(e)!==null}var Qn=({href:e,className:t,children:n})=>(0,X.jsx)(`a`,{href:e,className:t,children:n}),$n=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`}),(0,X.jsx)(`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`})]});function er({onSuccess:e,onError:t,registerUrl:n=`/register`,forgotPasswordUrl:r=`/forgot-password`,title:i=`Sign in to your account`,description:a=`Enter your email and password to continue`,icon:o,hideIcon:s=!1,linkComponent:l=Qn,labels:u={},errorMessages:d}){let{signIn:f,isLoading:p,getAuthConfig:m,sendPhoneOtp:h,signInWithPhoneOtp:g,signInWithPhonePassword:_}=Pn(),[v,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(!1),[O,ee]=(0,c.useState)(`password`),[k,A]=(0,c.useState)(``),[j,M]=(0,c.useState)(``),[N,P]=(0,c.useState)(!1),[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(0),[te,z]=(0,c.useState)(!1),[ne,re]=(0,c.useState)(!1),[B,ie]=(0,c.useState)(!1),[ae,oe]=(0,c.useState)(!1),[se,ce]=(0,c.useState)(!1),[le,ue]=(0,c.useState)(!0);(0,c.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>m()).then(t=>{e||(re(t?.features?.sso===!0),T(t?.features?.phoneNumberOtp===!0),D(t?.features?.phoneNumber===!0),ie(t?.features?.ssoEnforced===!0||t?.emailPassword?.enabled===!1))}).catch(()=>{}).finally(()=>{e||ue(!1)}),()=>{e=!0}},[m]);let de=!B||ae,V={emailLabel:u.emailLabel??`Email`,emailPlaceholder:u.emailPlaceholder??`name@example.com`,emailOrPhoneLabel:u.emailOrPhoneLabel??`Email or phone number`,emailOrPhonePlaceholder:u.emailOrPhonePlaceholder??`name@example.com or +1 555 000 0000`,passwordLabel:u.passwordLabel??`Password`,passwordPlaceholder:u.passwordPlaceholder??`Enter your password`,forgotPasswordText:u.forgotPasswordText??`Forgot password?`,submitButton:u.submitButton??`Sign In`,submittingButton:u.submittingButton??`Signing in…`,noAccountText:u.noAccountText??`Don't have an account?`,signUpText:u.signUpText??`Sign up`,ssoButton:u.ssoButton??`Sign in with SSO`,usePasswordText:u.usePasswordText??`Use a password instead`,backToSsoText:u.backToSsoText??`Back to single sign-on`,ssoOnlyDescription:u.ssoOnlyDescription??`Sign in with your organization's single sign-on`,phoneLabel:u.phoneLabel??`Phone number`,phonePlaceholder:u.phonePlaceholder??`+1 555 000 0000`,otpCodeLabel:u.otpCodeLabel??`Verification code`,otpCodePlaceholder:u.otpCodePlaceholder??`6-digit code`,sendOtpButton:u.sendOtpButton??`Get code`,resendOtpCountdownText:u.resendOtpCountdownText??`Resend in {seconds}s`,usePhoneOtpText:u.usePhoneOtpText??`Sign in with verification code`,usePasswordSignInText:u.usePasswordSignInText??`Sign in with password instead`};(0,c.useEffect)(()=>{if(L<=0)return;let e=setTimeout(()=>R(e=>e>1?e-1:0),1e3);return()=>clearTimeout(e)},[L]);let fe=async n=>{n.preventDefault(),C(null);let r=v.trim();try{O===`phone-otp`?await g(k.trim(),j.trim()):E&&Zn(r)?await _(Xn(r)??r,b):await f(r,b),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e)),r=n.code;C(r&&d?.[r]||n.message),t?.(n)}},pe=async()=>{if(!(!k.trim()||N||L>0)){C(null),P(!0);try{await h(k.trim()),I(!0),R(60)}catch(e){let n=e instanceof Error?e:Error(String(e)),r=n.code;C(r&&d?.[r]||n.message),t?.(n)}finally{P(!1)}}},me=e=>{ee(e),C(null)};return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:s?void 0:o??(0,X.jsx)($n,{}),title:i,description:B&&!ae?V.ssoOnlyDescription:a}),(0,X.jsx)(`div`,{className:`space-y-5`,children:le?(0,X.jsx)(`div`,{className:`flex justify-center py-10`,role:`status`,"aria-live":`polite`,"data-testid":`login-config-loading`,children:(0,X.jsx)($,{})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Yn,{mode:`sign-in`,dividerText:u.orText,buttonText:u.socialButton,onProvidersResolved:e=>z(e)}),de?O===`phone-otp`?(0,X.jsxs)(`form`,{onSubmit:fe,className:`space-y-4`,children:[S&&(0,X.jsx)(Gn,{message:S}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`login-phone`,className:Q,children:V.phoneLabel}),(0,X.jsx)(`input`,{id:`login-phone`,type:`tel`,placeholder:V.phonePlaceholder,value:k,onChange:e=>A(e.target.value),required:!0,autoComplete:`tel`,disabled:p,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`login-otp`,className:Q,children:V.otpCodeLabel}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{id:`login-otp`,type:`text`,inputMode:`numeric`,placeholder:V.otpCodePlaceholder,value:j,onChange:e=>M(e.target.value),required:!0,autoComplete:`one-time-code`,disabled:p,className:Z}),(0,X.jsxs)(`button`,{type:`button`,onClick:pe,disabled:N||L>0||!k.trim()||p,className:`shrink-0 rounded-md border border-input bg-background px-3 py-2 text-sm font-medium transition-colors hover:bg-accent disabled:opacity-50`,children:[N&&(0,X.jsx)($,{}),L>0?V.resendOtpCountdownText.replace(`{seconds}`,String(L)):V.sendOtpButton]})]})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:p||!F,className:Vn,children:[p&&(0,X.jsx)($,{}),p?V.submittingButton:V.submitButton]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>me(`password`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.usePasswordSignInText})]}):(0,X.jsxs)(`form`,{onSubmit:fe,className:`space-y-4`,children:[S&&(0,X.jsx)(Gn,{message:S}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`login-email`,className:Q,children:E?V.emailOrPhoneLabel:V.emailLabel}),(0,X.jsx)(`input`,{id:`login-email`,type:E?`text`:`email`,inputMode:E?`text`:`email`,placeholder:E?V.emailOrPhonePlaceholder:V.emailPlaceholder,value:v,onChange:e=>y(e.target.value),required:!0,autoComplete:`username`,disabled:p,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`label`,{htmlFor:`login-password`,className:Q,children:V.passwordLabel}),r&&(0,X.jsx)(l,{href:r,className:`text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.forgotPasswordText})]}),(0,X.jsx)(`input`,{id:`login-password`,type:`password`,placeholder:V.passwordPlaceholder,value:b,onChange:e=>x(e.target.value),required:!0,autoComplete:`current-password`,disabled:p,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:p,className:Vn,children:[p&&(0,X.jsx)($,{}),p?V.submittingButton:V.submitButton]}),ne&&(0,X.jsxs)(`button`,{type:`button`,onClick:async()=>{if(se)return;C(null);let e=v.trim();if(Zn(e)){C(`Enter your email address to sign in with SSO.`);return}ce(!0);try{let t=window.location.pathname.replace(/\/login(?:\/.*)?$/,``),n=await fetch(`/api/v1/auth/sign-in/sso`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e,callbackURL:t+`/home`}),credentials:`include`}),r=await n.json().catch(()=>({}));if(n.ok&&typeof r.url==`string`){window.location.href=r.url;return}C(r.message||`No SSO provider is configured for this email domain.`),ce(!1)}catch(e){C(e instanceof Error?e.message:String(e)),ce(!1)}},disabled:p||se,"aria-busy":se,className:`flex w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent disabled:opacity-50`,children:[se&&(0,X.jsx)($,{}),V.ssoButton]}),w&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>me(`phone-otp`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.usePhoneOtpText}),B&&ae&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>oe(!1),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.backToSsoText})]}):(0,X.jsxs)(`div`,{className:`space-y-4`,children:[S&&(0,X.jsx)(Gn,{message:S}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>oe(!0),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:V.usePasswordText})]})]})}),n&&!B&&(0,X.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[V.noAccountText,` `,(0,X.jsx)(l,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:V.signUpText})]})]})}var tr=({href:e,className:t,children:n})=>(0,X.jsx)(`a`,{href:e,className:t,children:n}),nr=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`}),(0,X.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,X.jsx)(`line`,{x1:`19`,y1:`8`,x2:`19`,y2:`14`}),(0,X.jsx)(`line`,{x1:`22`,y1:`11`,x2:`16`,y2:`11`})]});function rr({onSuccess:e,onVerificationRequired:t,verificationCallbackURL:n,onError:r,loginUrl:i=`/login`,title:a=`Create an account`,description:o=`Enter your information to get started`,icon:s,hideIcon:l=!1,linkComponent:u=tr,labels:d={},errorMessages:f}){let{signUp:p,isLoading:m}=Pn(),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(``),[y,b]=(0,c.useState)(``),[x,S]=(0,c.useState)(``),[C,w]=(0,c.useState)(null),T={nameLabel:d.nameLabel??`Name`,namePlaceholder:d.namePlaceholder??`John Doe`,emailLabel:d.emailLabel??`Email`,emailPlaceholder:d.emailPlaceholder??`name@example.com`,passwordLabel:d.passwordLabel??`Password`,passwordPlaceholder:d.passwordPlaceholder??`Create a password (min. 8 characters)`,confirmPasswordLabel:d.confirmPasswordLabel??`Confirm Password`,confirmPasswordPlaceholder:d.confirmPasswordPlaceholder??`Confirm your password`,passwordMismatchError:d.passwordMismatchError??`Passwords do not match`,passwordTooShortError:d.passwordTooShortError??`Password must be at least 8 characters`,submitButton:d.submitButton??`Create Account`,submittingButton:d.submittingButton??`Creating account…`,hasAccountText:d.hasAccountText??`Already have an account?`,signInText:d.signInText??`Sign in`};return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:l?void 0:s??(0,X.jsx)(nr,{}),title:a,description:o}),(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.jsx)(Yn,{mode:`sign-up`,dividerText:d.orText,buttonText:d.socialButton}),(0,X.jsxs)(`form`,{onSubmit:async i=>{if(i.preventDefault(),w(null),y!==x){w(T.passwordMismatchError);return}if(y.length<8){w(T.passwordTooShortError);return}let a=_.trim();try{if((await p(h,a,y,n))?.requiresVerification){t?.(a);return}e?.()}catch(e){let t=e instanceof Error?e:Error(String(e)),n=t.code;w(n&&f?.[n]||t.message),r?.(t)}},className:`space-y-4`,children:[C&&(0,X.jsx)(Gn,{message:C}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-name`,className:Q,children:T.nameLabel}),(0,X.jsx)(`input`,{id:`register-name`,type:`text`,placeholder:T.namePlaceholder,value:h,onChange:e=>g(e.target.value),required:!0,autoComplete:`name`,disabled:m,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-email`,className:Q,children:T.emailLabel}),(0,X.jsx)(`input`,{id:`register-email`,type:`email`,placeholder:T.emailPlaceholder,value:_,onChange:e=>v(e.target.value),required:!0,autoComplete:`email`,disabled:m,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-password`,className:Q,children:T.passwordLabel}),(0,X.jsx)(`input`,{id:`register-password`,type:`password`,placeholder:T.passwordPlaceholder,value:y,onChange:e=>b(e.target.value),required:!0,minLength:8,autoComplete:`new-password`,disabled:m,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`register-confirm-password`,className:Q,children:T.confirmPasswordLabel}),(0,X.jsx)(`input`,{id:`register-confirm-password`,type:`password`,placeholder:T.confirmPasswordPlaceholder,value:x,onChange:e=>S(e.target.value),required:!0,minLength:8,autoComplete:`new-password`,disabled:m,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:m,className:Vn,children:[m&&(0,X.jsx)($,{}),m?T.submittingButton:T.submitButton]})]})]}),i&&(0,X.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[T.hasAccountText,` `,(0,X.jsx)(u,{href:i,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:T.signInText})]})]})}var ir=({href:e,className:t,children:n})=>(0,X.jsx)(`a`,{href:e,className:t,children:n}),ar=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-6 w-6`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4`})});function or({onSuccess:e,onError:t,loginUrl:n=`/login`,title:r=`Reset your password`,description:i=`Enter your email address and we'll send you a link to reset your password`,icon:a,hideIcon:o=!1,linkComponent:s=ir,labels:l={}}){let{forgotPassword:u,isLoading:d,getAuthConfig:f,requestPhonePasswordReset:p,resetPasswordWithPhoneOtp:m}=Pn(),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(null),[y,b]=(0,c.useState)(!1),[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(`email`),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(``),[ee,k]=(0,c.useState)(``),[A,j]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(0),[I,L]=(0,c.useState)(!1),[R,te]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>f()).then(t=>{e||S(t?.features?.phoneNumberOtp===!0)}).catch(()=>{}),()=>{e=!0}},[f]),(0,c.useEffect)(()=>{if(P<=0)return;let e=setTimeout(()=>F(e=>e>1?e-1:0),1e3);return()=>clearTimeout(e)},[P]);let z={emailLabel:l.emailLabel??`Email`,emailPlaceholder:l.emailPlaceholder??`name@example.com`,submitButton:l.submitButton??`Send Reset Link`,submittingButton:l.submittingButton??`Sending…`,successTitle:l.successTitle??`Check your email`,successDescription:l.successDescription??`We've sent a password reset link to {email}. Please check your inbox.`,backToSignInText:l.backToSignInText??`Back to sign in`,rememberPasswordText:l.rememberPasswordText??`Remember your password?`,signInText:l.signInText??`Sign in`,phoneLabel:l.phoneLabel??`Phone number`,phonePlaceholder:l.phonePlaceholder??`+1 555 000 0000`,otpCodeLabel:l.otpCodeLabel??`Verification code`,otpCodePlaceholder:l.otpCodePlaceholder??`6-digit code`,sendOtpButton:l.sendOtpButton??`Get code`,resendOtpCountdownText:l.resendOtpCountdownText??`Resend in {seconds}s`,newPasswordLabel:l.newPasswordLabel??`New password`,newPasswordPlaceholder:l.newPasswordPlaceholder??`Enter a new password`,resetButton:l.resetButton??`Reset Password`,usePhoneResetText:l.usePhoneResetText??`Reset via SMS code`,useEmailResetText:l.useEmailResetText??`Reset via email instead`,phoneSuccessTitle:l.phoneSuccessTitle??`Password reset`,phoneSuccessDescription:l.phoneSuccessDescription??`Your password has been reset. You can now sign in with your new password.`},ne=async n=>{n.preventDefault(),v(null);try{await u(h.trim()),b(!0),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e));v(n.message),t?.(n)}},re=async()=>{if(!(!T.trim()||A||P>0)){v(null),j(!0);try{await p(T.trim()),N(!0),F(60)}catch(e){let n=e instanceof Error?e:Error(String(e));v(n.message),t?.(n)}finally{j(!1)}}},B=async n=>{n.preventDefault(),v(null),te(!0);try{await m(T.trim(),D.trim(),ee),L(!0),e?.()}catch(e){let n=e instanceof Error?e:Error(String(e));v(n.message),t?.(n)}finally{te(!1)}},ie=e=>{w(e),v(null)};if(I)return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:(0,X.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 ring-1 ring-emerald-500/15 dark:text-emerald-400`,children:(0,X.jsx)(Un,{})}),title:z.phoneSuccessTitle,description:z.phoneSuccessDescription}),n&&(0,X.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:(0,X.jsxs)(s,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:[`← `,z.backToSignInText]})})]});if(y){let e=z.successDescription.includes(`{email}`)?z.successDescription.replace(`{email}`,h):`${z.successDescription} ${h}`;return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:(0,X.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 ring-1 ring-emerald-500/15 dark:text-emerald-400`,children:(0,X.jsx)(Un,{})}),title:z.successTitle,description:e}),n&&(0,X.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:(0,X.jsxs)(s,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:[`← `,z.backToSignInText]})})]})}return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full flex-col justify-center space-y-7 sm:w-[400px]`,children:[(0,X.jsx)(Wn,{icon:o?void 0:a??(0,X.jsx)(ar,{}),title:r,description:i}),C===`phone`?(0,X.jsxs)(`form`,{onSubmit:B,className:`space-y-4`,children:[_&&(0,X.jsx)(Gn,{message:_}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-phone`,className:Q,children:z.phoneLabel}),(0,X.jsx)(`input`,{id:`forgot-phone`,type:`tel`,placeholder:z.phonePlaceholder,value:T,onChange:e=>E(e.target.value),required:!0,autoComplete:`tel`,disabled:R,className:Z})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-otp`,className:Q,children:z.otpCodeLabel}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{id:`forgot-otp`,type:`text`,inputMode:`numeric`,placeholder:z.otpCodePlaceholder,value:D,onChange:e=>O(e.target.value),required:!0,autoComplete:`one-time-code`,disabled:R,className:Z}),(0,X.jsxs)(`button`,{type:`button`,onClick:re,disabled:A||P>0||!T.trim()||R,className:`shrink-0 rounded-md border border-input bg-background px-3 py-2 text-sm font-medium transition-colors hover:bg-accent disabled:opacity-50`,children:[A&&(0,X.jsx)($,{}),P>0?z.resendOtpCountdownText.replace(`{seconds}`,String(P)):z.sendOtpButton]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-new-password`,className:Q,children:z.newPasswordLabel}),(0,X.jsx)(`input`,{id:`forgot-new-password`,type:`password`,placeholder:z.newPasswordPlaceholder,value:ee,onChange:e=>k(e.target.value),required:!0,autoComplete:`new-password`,disabled:R,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:R||!M,className:Vn,children:[R&&(0,X.jsx)($,{}),R?z.submittingButton:z.resetButton]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ie(`email`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:z.useEmailResetText})]}):(0,X.jsxs)(`form`,{onSubmit:ne,className:`space-y-4`,children:[_&&(0,X.jsx)(Gn,{message:_}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`forgot-email`,className:Q,children:z.emailLabel}),(0,X.jsx)(`input`,{id:`forgot-email`,type:`email`,placeholder:z.emailPlaceholder,value:h,onChange:e=>g(e.target.value),required:!0,autoComplete:`email`,disabled:d,className:Z})]}),(0,X.jsxs)(`button`,{type:`submit`,disabled:d,className:Vn,children:[d&&(0,X.jsx)($,{}),d?z.submittingButton:z.submitButton]}),x&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>ie(`phone`),className:`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline`,children:z.usePhoneResetText})]}),n&&(0,X.jsxs)(`p`,{className:`px-8 text-center text-sm text-muted-foreground`,children:[z.rememberPasswordText,` `,(0,X.jsx)(s,{href:n,className:`font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:underline`,children:z.signInText})]})]})}function sr(e){return e?e.name?e.name.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2):e.email?.[0]?.toUpperCase()??`?`:`?`}function cr(e){if(typeof window>`u`||!window.location)return!0;try{return new URL(e,window.location.href).origin!==window.location.origin}catch{return!0}}function lr(e){return async(t,n)=>{let r=new Headers(n?.headers),i=typeof t==`string`?t:t instanceof URL?t.href:t.url;if(e?.sameOriginOnly&&cr(i))return fetch(t,n);let a=/\/api\//i.test(i),o=q.get();o&&a&&r.set(`Authorization`,`Bearer ${o}`);let s=Y.get();if(s&&r.set(`X-Tenant-ID`,s),a&&!r.has(`Accept-Language`)&&typeof document<`u`){let e=document.documentElement.lang;e&&r.set(`Accept-Language`,e)}let c=await fetch(t,{...n,headers:r});if(a){let e=c.headers.get(`set-auth-token`);e&&q.set(e)}if(a&&c.status===403)try{let e=d(c.status,await c.clone().json());e&&u.emit(e)}catch{}return c}}var ur=[...o],dr={[i]:{key:`organization.roles.owner`,defaultValue:`Owner`},[r]:{key:`organization.roles.admin`,defaultValue:`Admin`},[a]:{key:`organization.roles.delegatedAdmin`,defaultValue:`Delegated Admin`},[s]:{key:`organization.roles.member`,defaultValue:`Member`}},fr=0,pr=1,mr=2,hr=3;function gr(e){if(typeof e!=`string`)return fr;let t=e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);if(t.length===0)return fr;let n=pr;for(let e of t)e===`owner`?n=Math.max(n,hr):e===`admin`&&(n=Math.max(n,mr));return n}function _r(e){let t=gr(e);return t<mr?[s]:ur.filter(e=>gr(e)<=t)}function vr(e,t){let n=gr(e);if(n<mr)return[];let r=n>=hr;return!r&&gr(t)>=hr?[]:ur.filter(e=>e!==`owner`||r)}export{Dn as _,lr as a,rr as c,Bn as d,zn as f,En as g,Y as h,gr as i,er as l,Nn as m,vr as n,sr as o,Pn as p,_r as r,or as s,dr as t,Gn as u,q as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Da as e,Sa as t,_a as n,ca as r,fa as i,ha as a,la as o,ra as s,ta as c,va as l,wa as u,xa as d,ya as f}from"./vendor-objectstack-DFqu45yM.js";c();var p=l().int().describe(`Unix timestamp in milliseconds (epoch)`);function m(e){if(typeof process<`u`&&{}.OS_EAGER_SCHEMAS===`1`)return e();let t,n=()=>(t===void 0&&(t=e()),t),r=function(){},i,a=e=>{let t=e._zod;if(!t||typeof t.processJSONSchema!=`function`)return t;let n=t.processJSONSchema;return Object.create(t,{processJSONSchema:{enumerable:!0,value:(t,r,i)=>{let a=t?.seen;if(a&&typeof a.get==`function`){let t=a.get(s);t!==void 0&&!a.has(e)&&a.set(e,t)}let c=n(t,r,i);return o(t?.metadataRegistry,e),c}}})},o=(e,t)=>{if(!e||typeof e.get!=`function`||typeof e.has!=`function`||typeof e.add!=`function`||e.has(s))return;let n=e.get(t);if(!n)return;let r={...n};delete r.id,Object.keys(r).length>0&&e.add(s,r)},s=new Proxy(r,{get(e,t){let r=n();if(t===`_zod`)return i??=a(r),i;let o=r[t];return typeof o==`function`?o.bind(r):o},set(e,t,r){let i=n();return i[t]=r,!0},has(e,t){return t in n()},ownKeys(){return Reflect.ownKeys(n())},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(n(),t)},getPrototypeOf(){return Reflect.getPrototypeOf(n())}});return s}var h=m(()=>f({type:a(`oauth2`),authorizationUrl:u().url().describe(`OAuth2 authorization endpoint`),tokenUrl:u().url().describe(`OAuth2 token endpoint`),clientId:u().describe(`OAuth2 client ID`),clientSecret:u().describe(`OAuth2 client secret (typically from ENV)`),scopes:r(u()).optional().describe(`Requested OAuth2 scopes`),redirectUri:u().url().optional().describe(`OAuth2 redirect URI`),refreshToken:u().optional().describe(`Refresh token for token renewal`),tokenExpiry:p.optional().describe(`Token expiry timestamp (Unix milliseconds)`)})),g=m(()=>f({type:a(`api-key`),key:u().describe(`API key value`),headerName:u().default(`X-API-Key`).describe(`HTTP header name for API key`),paramName:u().optional().describe(`Query parameter name (alternative to header)`)})),_=m(()=>f({type:a(`basic`),username:u().describe(`Username`),password:u().describe(`Password`)})),v=m(()=>f({type:a(`bearer`),token:u().describe(`Bearer token`)})),y=m(()=>f({type:a(`none`)})),b=m(()=>i(`type`,[h,g,_,v,y])),x=m(()=>f({type:a(`none`)})),S=m(()=>f({type:a(`bearer`),credentialRef:u().min(1).describe(`Secrets-layer reference (e.g. an env-var name in the open tier) resolved to the bearer token at materialization. Never an inline token.`)})),C=m(()=>f({type:a(`api-key`),credentialRef:u().min(1).describe(`Secrets-layer reference resolved to the API key at materialization. Never an inline key.`),headerName:u().optional().describe(`HTTP header carrying the key (default X-API-Key).`),paramName:u().optional().describe(`Query parameter carrying the key (alternative to header).`)})),w=m(()=>f({type:a(`basic`),username:u().describe(`Username (not a secret; safe to keep in metadata).`),credentialRef:u().min(1).describe(`Secrets-layer reference resolved to the password at materialization. Never an inline password.`)})),T=m(()=>i(`type`,[x,S,C,w])),E=s([`none`,`no-overlay`,`no-delete`,`full`]),D=s([`artifact`,`package`,`env-forced`]),O=s([`package`,`org`,`env-forced`]),k={_lock:E.optional().describe(`Item-level lock — controls overlay & delete (ADR-0010).`),_lockReason:u().max(500).optional().describe(`Human-readable reason shown when a write is refused by _lock.`),_lockSource:D.optional().describe(`Layer that set _lock (artifact | package | env-forced).`),_provenance:O.optional().describe(`Origin of the item (package | org | env-forced).`),_packageId:u().optional().describe(`Owning package machine id.`),_packageVersion:u().optional().describe(`Owning package version.`),_lockDocsUrl:u().optional().describe(`Optional documentation link surfaced next to _lockReason.`)};function A(e){return n({error:()=>e}).optional().describe(`[REMOVED] ${e}`)}function j(e,t){let n=Object.keys(t),r=d(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let r;for(let i of n)Object.prototype.hasOwnProperty.call(e,i)&&e[i]===t[i]&&(r??={...e},delete r[i]);return r??e},e);return Object.defineProperty(r,"shape",{configurable:!0,get:()=>e.shape}),r}var M="`connector.syncConfig` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — no engine ever ran a connector-attached sync: nothing read `strategy`, `direction`, `realtimeSync`, `timestampField`, `conflictResolution`, `batchSize`, `deleteMode` or `filters`, so the `latest_wins` and `soft_delete` defaults resolved and deleted nothing. Delete the key; the `DataSyncConfig` shape leaves with it. A sync is defined on its TARGET: a `mapping` (`targetObject`, `fieldMapping`, `mode`, `upsertKey`) whose `connectorSource` names the `rest` or `openapi` connector it pulls from, the read action and an optional timestamp `watermark`, with a `job` for the cadence. Its pull runs when a `job` drives it; nothing schedules one yet, so the binding alone moves no rows. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",N="`connector.fieldMappings` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — no engine ever moved a value through a connector field mapping: nothing read `source`, `target`, `defaultValue`, `dataType`, `required` or `syncMode`. Delete the key; the `ConnectorFieldMapping` shape leaves with it. Map fields on the sync's TARGET instead: a `mapping`'s `fieldMapping` (`source` → `target`, with a `transform` the import path executes), which its `connectorSource` pulls through. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",P=m(()=>s([`exponential_backoff`,`linear_backoff`,`fixed_delay`,`no_retry`]).describe(`Retry strategy`)),F=m(()=>f({strategy:P.optional().default(`exponential_backoff`),maxAttempts:l().min(0).max(10).optional().default(3).describe(`Maximum retry attempts`),initialDelayMs:l().min(100).optional().default(1e3).describe(`Initial retry delay in ms`),maxDelayMs:l().min(1e3).optional().default(6e4).describe(`Maximum retry delay in ms`),backoffMultiplier:l().min(1).optional().default(2).describe(`Exponential backoff multiplier`),retryableStatusCodes:r(l()).optional().default([408,429,500,502,503,504]).describe(`HTTP status codes to retry`),retryOnNetworkError:o().optional().default(!0).describe(`Retry on network errors`),jitter:o().optional().default(!0).describe(`Add jitter to retry delays`)})),I="`connector.errorMapping` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — nothing ever read it: no provider, dispatcher or materializer mapped an external error through the rules, so `unmappedBehavior` configured nothing and a rule's `userMessage` was never shown to anyone (that spelling is the live API-error channel, `ApiError.userMessage`, which a thrown HTTP error declares — not connector metadata). Delete the key; the whole shape leaves with it (`ErrorMappingConfig`, `ErrorMappingRule` and the `ConnectorErrorCategory` enum). There is no replacement, because no error-mapping engine exists: a connector's failures reach callers as the provider's own errors (ADR-0097). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",L="`connector.connectionTimeoutMs` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — the platform never honoured it and cannot honour it where it was declared: a connector's outbound call is a WHATWG `fetch`, whose only cancellation surface is one `AbortSignal` over the whole operation, so nothing there observes the connection phase separately, and the value only ever travelled (onto the reported def and the materialization fingerprint) without ever bounding a connect. Delete the key. Use `requestTimeoutMs` for the deadline the platform does keep — it is applied as `resilientFetch`'s per-attempt timeout — and bound the connect phase at a connector provider or upstream gateway on a transport that can separate the phases. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",R={connectionTimeoutMs:3e4,status:`inactive`},z="`connector.health` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — no connector health probe or circuit breaker ever existed: nothing scheduled a `healthCheck` request, counted consecutive failures against a threshold, or opened, half-opened or closed a `circuitBreaker`, and no `fallbackStrategy` was ever applied, so every key in the block configured nothing. That includes `circuitBreaker.monitoringWindowMs` and the `monitoringWindow` spelling it was renamed from: the renamed key is removed with the rest. Delete the key; the whole shape leaves with it (`ConnectorHealth`, `HealthCheckConfig`, `CircuitBreakerConfig`). Whether a connector can be dispatched is computed, not authored: `GET /api/v1/automation/connectors` reports each connector's `state` (`ready` or `degraded`). Put health probes and circuit breaking in the connector provider or an upstream gateway. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",B="`connector.status` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — nothing ever read it: `status: 'active'` neither enabled nor advertised a connector, and `'error'` or `'configuring'` changed nothing either. Delete the key; the `ConnectorStatus` enum leaves with it. On a declarative entry, `enabled: false` is what withdraws a materialized instance or marks a catalog-only descriptor, and whether a registered connector can be dispatched is computed by the runtime and reported as `state` (`ready` or `degraded`) on `GET /api/v1/automation/connectors` — no authored value sets it. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",V="`connector.webhooks` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — a webhook nested inside a connector was never registered as a `webhook` item, so it was never materialized into `sys_webhook` and never delivered, and nothing emits the connector events its `events` list could name (`sync.completed`, `auth.expired` and the rest). Delete the key; the nested shape leaves with it (`WebhookConfig`, `WebhookEvent`, `WebhookSignatureAlgorithm`). To have a webhook actually sent, declare it in the stack's top-level `webhooks:` collection, which is materialized into `sys_webhook` and delivered on record events — note that doing so STARTS deliveries this connector never made. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",H="`connector.triggers` was removed in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — a connector trigger never started anything: `AutomationEngine.registerConnector` registers a connector's actions only, no polling loop read `intervalSeconds` (or the `interval` spelling it was renamed from), and no receiver was driven by a `webhook` trigger. Delete the key; the `ConnectorTrigger` shape leaves with it. To start work from an external system, write a flow that calls the connector's action in a `connector_action` node: for an external event, an `api` flow that the event's sender calls; for a scheduled pull, a `schedule` flow. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; apply them by hand.",U=m(()=>s([`saas`,`database`,`file_storage`,`message_queue`,`api`,`custom`]).describe(`Connector type`)),W=m(()=>s([`read`,`write`]).describe(`What the action does upstream: 'read' never mutates (reports acted:0); 'write' does (a successful dispatch reports acted:1). Omit when the effect is not knowable — the step is then reported as unmeasured, not as zero`)),G=m(()=>f({key:u().describe(`Action key (machine name)`),label:u().describe(`Human readable label`),description:u().optional(),inputSchema:t(u(),e()).optional().describe(`Input parameters schema (JSON Schema)`),outputSchema:t(u(),e()).optional().describe(`Output schema (JSON Schema)`),effect:W.optional()})),K=m(()=>f({name:u().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique connector identifier`),label:u().describe(`Display label`),type:U.describe(`Connector type`),description:u().optional().describe(`Connector description`),icon:u().optional().describe(`Icon identifier`),authentication:b.optional().default({type:`none`}).describe("Authentication configuration (runtime shape with inline secrets — plugin-supplied at registerConnector). Authored entries must not inline secrets: use `auth.credentialRef` on a provider-bound instance."),provider:u().regex(/^[a-z][a-z0-9_]*$/).optional().describe(`Generic-executor key that materializes this declarative entry at boot (e.g. openapi/mcp/rest). Omit for a catalog-only descriptor. Unknown provider ⇒ hard boot error (ADR-0097).`),providerConfig:t(u(),e()).optional().describe("Provider-specific config validated by the provider factory at boot (e.g. { spec, baseUrl } for openapi, where spec is an inline document, a package-relative file path like './billing-openapi.json', or an http(s) URL). Requires `provider`."),auth:T.optional().describe("Declarative instance auth — references credentials via `credentialRef` (resolved at boot), never inline secrets. Requires `provider` (ADR-0097)."),actions:r(G).optional(),triggers:A(H),syncConfig:A(M),fieldMappings:A(N),webhooks:A(V),rateLimitConfig:A("`connector.rateLimitConfig` was removed in @objectstack/spec 17.0.0 (ADR-0049 D2) — the entire shape is gone, not just this key: `ConnectorRateLimitConfig` and its `RateLimitStrategy` enum were removed with it, because no outbound rate-limiting engine ever existed. The platform's only token bucket (runtime `security/rate-limit.ts`) throttles INBOUND requests to us; nothing throttled the calls a connector makes out, so every knob here was inert while reading like a configured cap. Delete the key. Do NOT substitute `shared` `RateLimitConfig` — that is the inbound limiter and would cap the wrong direction; until an outbound throttle exists, rate-limit at the connector provider or upstream gateway. Run `os migrate meta --from 16` to list the mechanical edits for existing sources; apply them by hand."),retryConfig:F.optional().describe(`Retry configuration`),connectionTimeoutMs:A(L),requestTimeoutMs:l().min(1e3).max(3e5).optional().default(3e4).describe(`Request timeout in ms`),status:A(B),enabled:o().optional().default(!0).describe(`Enable connector. On declarative stack entries, false marks a deliberate catalog-only descriptor.`),errorMapping:A(I),health:A(z),metadata:t(u(),e()).optional().describe(`Custom connector metadata`),...k})),q=m(()=>j(K.superRefine((e,t)=>{let n=typeof e.provider==`string`&&e.provider.length>0;if(e.authentication&&e.authentication.type!==`none`&&t.addIssue({code:`custom`,path:[`authentication`],message:n?`Provider-bound connector instance '${e.name}' must not inline secrets via \`authentication\`; reference credentials with \`auth: { type, credentialRef }\` instead (ADR-0097 \xA73).`:`Connector '${e.name}' must not inline secrets via \`authentication\` \u2014 a published connector row is stored whole in \`sys_metadata\`, so the credential would land in cleartext. A catalog descriptor holds no live credentials: drop \`authentication\` (or set \`{ type: 'none' }\`) and describe the auth scheme in \`description\`. A dispatchable instance declares \`provider\` and references its credential with \`auth: { type, credentialRef }\` (ADR-0097 \xA73).`}),!n){e.providerConfig!==void 0&&t.addIssue({code:`custom`,path:[`providerConfig`],message:"`providerConfig` requires a `provider` — a connector entry with no provider is a catalog descriptor (ADR-0097)."}),e.auth!==void 0&&t.addIssue({code:`custom`,path:[`auth`],message:"`auth` requires a `provider` — declarative instance auth applies only to a provider-bound entry (ADR-0097)."});return}e.actions&&e.actions.length>0&&t.addIssue({code:`custom`,path:[`actions`],message:`Provider-bound connector instance '${e.name}' must not author \`actions\` \u2014 the '${e.provider}' provider derives them from the upstream at boot (ADR-0097 \xA75).`})}),R));export{q as DeclarativeConnectorEntrySchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Jr as e,Qr as t,Xr as n,qr as r}from"./ui-components-D6cEVg0T.js";var i={lessThanXSeconds:{one:`minna en 1 sekúnda`,other:`minna en {{count}} sekúndur`},xSeconds:{one:`1 sekúnda`,other:`{{count}} sekúndur`},halfAMinute:`hálf mínúta`,lessThanXMinutes:{one:`minna en 1 mínúta`,other:`minna en {{count}} mínútur`},xMinutes:{one:`1 mínúta`,other:`{{count}} mínútur`},aboutXHours:{one:`u.þ.b. 1 klukkustund`,other:`u.þ.b. {{count}} klukkustundir`},xHours:{one:`1 klukkustund`,other:`{{count}} klukkustundir`},xDays:{one:`1 dagur`,other:`{{count}} dagar`},aboutXWeeks:{one:`um viku`,other:`um {{count}} vikur`},xWeeks:{one:`1 viku`,other:`{{count}} vikur`},aboutXMonths:{one:`u.þ.b. 1 mánuður`,other:`u.þ.b. {{count}} mánuðir`},xMonths:{one:`1 mánuður`,other:`{{count}} mánuðir`},aboutXYears:{one:`u.þ.b. 1 ár`,other:`u.þ.b. {{count}} ár`},xYears:{one:`1 ár`,other:`{{count}} ár`},overXYears:{one:`meira en 1 ár`,other:`meira en {{count}} ár`},almostXYears:{one:`næstum 1 ár`,other:`næstum {{count}} ár`}},a=(e,t,n)=>{let r,a=i[e];return r=typeof a==`string`?a:t===1?a.one:a.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`í `+r:r+` síðan`:r},o={date:t({formats:{full:`EEEE, do MMMM y`,long:`do MMMM y`,medium:`do MMM y`,short:`d.MM.y`},defaultWidth:`full`}),time:t({formats:{full:`'kl'. HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:t({formats:{full:`{{date}} 'kl.' {{time}}`,long:`{{date}} 'kl.' {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},s={lastWeek:`'síðasta' dddd 'kl.' p`,yesterday:`'í gær kl.' p`,today:`'í dag kl.' p`,tomorrow:`'á morgun kl.' p`,nextWeek:`dddd 'kl.' p`,other:`P`},c={code:`is`,formatDistance:a,formatLong:o,formatRelative:(e,t,n,r)=>s[e],localize:{ordinalNumber:(e,t)=>Number(e)+`.`,era:n({values:{narrow:[`f.Kr.`,`e.Kr.`],abbreviated:[`f.Kr.`,`e.Kr.`],wide:[`fyrir Krist`,`eftir Krist`]},defaultWidth:`wide`}),quarter:n({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`1F`,`2F`,`3F`,`4F`],wide:[`1. fjórðungur`,`2. fjórðungur`,`3. fjórðungur`,`4. fjórðungur`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:n({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`Á`,`S`,`Ó`,`N`,`D`],abbreviated:[`jan.`,`feb.`,`mars`,`apríl`,`maí`,`júní`,`júlí`,`ágúst`,`sept.`,`okt.`,`nóv.`,`des.`],wide:[`janúar`,`febrúar`,`mars`,`apríl`,`maí`,`júní`,`júlí`,`ágúst`,`september`,`október`,`nóvember`,`desember`]},defaultWidth:`wide`}),day:n({values:{narrow:[`S`,`M`,`Þ`,`M`,`F`,`F`,`L`],short:[`Su`,`Má`,`Þr`,`Mi`,`Fi`,`Fö`,`La`],abbreviated:[`sun.`,`mán.`,`þri.`,`mið.`,`fim.`,`fös.`,`lau.`],wide:[`sunnudagur`,`mánudagur`,`þriðjudagur`,`miðvikudagur`,`fimmtudagur`,`föstudagur`,`laugardagur`]},defaultWidth:`wide`}),dayPeriod:n({values:{narrow:{am:`f`,pm:`e`,midnight:`miðnætti`,noon:`hádegi`,morning:`morgunn`,afternoon:`síðdegi`,evening:`kvöld`,night:`nótt`},abbreviated:{am:`f.h.`,pm:`e.h.`,midnight:`miðnætti`,noon:`hádegi`,morning:`morgunn`,afternoon:`síðdegi`,evening:`kvöld`,night:`nótt`},wide:{am:`fyrir hádegi`,pm:`eftir hádegi`,midnight:`miðnætti`,noon:`hádegi`,morning:`morgunn`,afternoon:`síðdegi`,evening:`kvöld`,night:`nótt`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`f`,pm:`e`,midnight:`á miðnætti`,noon:`á hádegi`,morning:`að morgni`,afternoon:`síðdegis`,evening:`um kvöld`,night:`um nótt`},abbreviated:{am:`f.h.`,pm:`e.h.`,midnight:`á miðnætti`,noon:`á hádegi`,morning:`að morgni`,afternoon:`síðdegis`,evening:`um kvöld`,night:`um nótt`},wide:{am:`fyrir hádegi`,pm:`eftir hádegi`,midnight:`á miðnætti`,noon:`á hádegi`,morning:`að morgni`,afternoon:`síðdegis`,evening:`um kvöld`,night:`um nótt`}},defaultFormattingWidth:`wide`})},match:{ordinalNumber:r({matchPattern:/^(\d+)(\.)?/i,parsePattern:/\d+(\.)?/i,valueCallback:e=>parseInt(e,10)}),era:e({matchPatterns:{narrow:/^(f\.Kr\.|e\.Kr\.)/i,abbreviated:/^(f\.Kr\.|e\.Kr\.)/i,wide:/^(fyrir Krist|eftir Krist)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^(f\.Kr\.)/i,/^(e\.Kr\.)/i]},defaultParseWidth:`any`}),quarter:e({matchPatterns:{narrow:/^[1234]\.?/i,abbreviated:/^q[1234]\.?/i,wide:/^[1234]\.? fjórðungur/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1\.?/i,/2\.?/i,/3\.?/i,/4\.?/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:e({matchPatterns:{narrow:/^[jfmásónd]/i,abbreviated:/^(jan\.|feb\.|mars\.|apríl\.|maí|júní|júlí|águst|sep\.|oct\.|nov\.|dec\.)/i,wide:/^(januar|febrúar|mars|apríl|maí|júní|júlí|águst|september|október|nóvember|desember)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^á/i,/^s/i,/^ó/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^maí/i,/^jún/i,/^júl/i,/^áu/i,/^s/i,/^ó/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:e({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|má|þr|mi|fi|fö|la)/i,abbreviated:/^(sun|mán|þri|mið|fim|fös|lau)\.?/i,wide:/^(sunnudagur|mánudagur|þriðjudagur|miðvikudagur|fimmtudagur|föstudagur|laugardagur)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^þ/i,/^m/i,/^f/i,/^f/i,/^l/i],any:[/^su/i,/^má/i,/^þr/i,/^mi/i,/^fi/i,/^fö/i,/^la/i]},defaultParseWidth:`any`}),dayPeriod:e({matchPatterns:{narrow:/^(f|e|síðdegis|(á|að|um) (morgni|kvöld|nótt|miðnætti))/i,any:/^(fyrir hádegi|eftir hádegi|[ef]\.?h\.?|síðdegis|morgunn|(á|að|um) (morgni|kvöld|nótt|miðnætti))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^f/i,pm:/^e/i,midnight:/^mi/i,noon:/^há/i,morning:/morgunn/i,afternoon:/síðdegi/i,evening:/kvöld/i,night:/nótt/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:4}};export{c as default,c as is};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ei as e,ti as t}from"./ui-components-D6cEVg0T.js";function n(n,r,i){let[a,o]=e(i?.in,n,r);return+t(a,i)==+t(o,i)}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Qr as e}from"./ui-components-D6cEVg0T.js";import{i as t,n,r,t as i}from"./match-B-ergJQb.js";var a={date:e({formats:{full:`EEEE d MMMM y`,long:`d MMMM y`,medium:`d MMM y`,short:`dd.MM.y`},defaultWidth:`full`}),time:e({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:e({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},o={code:`it-CH`,formatDistance:t,formatLong:a,formatRelative:r,localize:n,match:i,options:{weekStartsOn:1,firstWeekContainsDate:4}};export{o as default,o as itCH};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Qr as e}from"./ui-components-D6cEVg0T.js";import{i as t,n,r,t as i}from"./match-B-ergJQb.js";var a={date:e({formats:{full:`EEEE d MMMM y`,long:`d MMMM y`,medium:`d MMM y`,short:`dd/MM/y`},defaultWidth:`full`}),time:e({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:e({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},o={code:`it`,formatDistance:t,formatLong:a,formatRelative:r,localize:n,match:i,options:{weekStartsOn:1,firstWeekContainsDate:4}};export{o as default,o as it};
|