@hiai-gg/docsmint 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/backend/src/lib/logger.ts +45 -15
  2. package/dist/backend/index.js +238 -150
  3. package/dist/client.d.ts +11 -0
  4. package/dist/client.js +9 -0
  5. package/dist/frontend/CategoryDialog-CxVyaBV5.js +611 -0
  6. package/dist/frontend/ConfirmDialog-NFGXRa3E.js +214 -0
  7. package/dist/frontend/CreateSnapshotDialog-BDgFTeFn.js +216 -0
  8. package/dist/frontend/DatePicker-BZRBluzF.js +256 -0
  9. package/dist/frontend/DeleteDialog-CvAr2WPu.js +174 -0
  10. package/dist/frontend/FolderNode-C6FJv99G.js +298 -0
  11. package/dist/frontend/FolderTreeSelector-CyB8y2Sm.js +103 -0
  12. package/dist/frontend/HiaiDocsExtensionProvider-DHWLzRUu.js +11 -0
  13. package/dist/frontend/Icon-CooFj4Ee.js +64 -0
  14. package/dist/frontend/SettingsDialog-BHh68rTB.js +1016 -0
  15. package/dist/frontend/ShareDialog-BUOkYSlw.js +165 -0
  16. package/dist/frontend/Sidebar-Cu3JrKDC.js +2021 -0
  17. package/dist/frontend/TagCreateDialog-B9YZBNHi.js +260 -0
  18. package/dist/frontend/api/settings.js +1 -1
  19. package/dist/frontend/app-shell.d.ts +8 -0
  20. package/dist/frontend/app-shell.js +291 -0
  21. package/dist/frontend/{bundle-mjs-CP6Owz-8.js → bundle-mjs-DllmqUxV.js} +583 -568
  22. package/dist/frontend/camera-iKXDOOWT.js +29 -0
  23. package/dist/frontend/check-D-UuvBuh.js +25 -0
  24. package/dist/frontend/chevron-down-CiPtYyFh.js +25 -0
  25. package/dist/frontend/circle-check-tSPE1V6t.js +29 -0
  26. package/dist/frontend/clock-DJHbHZb8.js +29 -0
  27. package/dist/frontend/components/category-dialog.js +1 -1
  28. package/dist/frontend/components/create-snapshot-dialog.js +1 -1
  29. package/dist/frontend/components/delete-dialog.js +1 -1
  30. package/dist/frontend/components/editor/document-editor.js +1367 -1356
  31. package/dist/frontend/components/editor/document-title.js +25 -25
  32. package/dist/frontend/components/editor/markdown-toggle.js +45 -45
  33. package/dist/frontend/components/folder-node.js +1 -1
  34. package/dist/frontend/components/folder-tree-selector.js +1 -1
  35. package/dist/frontend/components/save-as-dialog.js +169 -151
  36. package/dist/frontend/components/settings.js +1 -1
  37. package/dist/frontend/components/share-dialog.js +1 -1
  38. package/dist/frontend/components/sidebar.js +2 -2013
  39. package/dist/frontend/components/tag-create-dialog.js +1 -1
  40. package/dist/frontend/components/version-history.js +188 -187
  41. package/dist/frontend/confirm-dialog-C4jTRbiS.js +250 -0
  42. package/dist/frontend/copy-GppwRMjX.js +32 -0
  43. package/dist/frontend/dashboard.js +1187 -1155
  44. package/dist/frontend/dialog-Bevp9mmM.js +213 -0
  45. package/dist/frontend/{loader-circle-Bk-WFz9g.js → dist-C3857Spp.js} +93 -92
  46. package/dist/frontend/doc-tabs.js +2 -2
  47. package/dist/frontend/dropdown-menu-CRSby3e9.js +530 -0
  48. package/dist/frontend/extension.js +2 -11
  49. package/dist/frontend/{floating-layer-anchor-C51M4l6v.js → floating-layer-anchor-BDs7vO-M.js} +1414 -1412
  50. package/dist/frontend/folder-DeWhnD7O.js +45 -0
  51. package/dist/frontend/folder-refresh.js +1 -1
  52. package/dist/frontend/frontend.css +1 -1
  53. package/dist/frontend/i18n.js +2 -2
  54. package/dist/frontend/input-BWlOML_m.js +23 -0
  55. package/dist/frontend/keyboard.js +1 -1
  56. package/dist/frontend/{keyboard.svelte-D7H8DihC.js → keyboard.svelte-CApmX0vl.js} +53 -53
  57. package/dist/frontend/label-C2HfJNQ2.js +30 -0
  58. package/dist/frontend/{messages-BpYaLbzE.js → messages-C5Q890i2.js} +8 -8
  59. package/dist/frontend/rotate-ccw-B4Q7brmV.js +25 -0
  60. package/dist/frontend/search.js +673 -647
  61. package/dist/frontend/select-value-GXwx90Pr.js +1446 -0
  62. package/dist/frontend/{settings-blyobazp.js → settings-DSrUl4hW.js} +9 -9
  63. package/dist/frontend/shared-document.js +94 -94
  64. package/dist/frontend/subfolders-refresh-store.svelte-B2dKVmgz.js +65 -0
  65. package/dist/frontend/tag-HxRazVN_.js +54 -0
  66. package/dist/frontend/tag-store.svelte-CqrUXo0o.js +29 -0
  67. package/dist/frontend/textarea-DOAE-h42.js +23 -0
  68. package/dist/frontend/theme.js +1 -1
  69. package/dist/frontend/theme.svelte-DKfCy12k.js +49 -0
  70. package/dist/frontend/{utils-D8kmM3ub.js → utils-BPDRytUU.js} +2 -3
  71. package/dist/frontend/{utils-C0OW2678.js → utils-DrfHTcei.js} +2 -3
  72. package/dist/frontend/utils.js +1 -1
  73. package/dist/frontend/x-CzBsnJ2x.js +25 -0
  74. package/dist/frontend-ssr/api/attachments.js +2 -0
  75. package/dist/frontend-ssr/api/categories.js +2 -0
  76. package/dist/frontend-ssr/api/documents.js +2 -0
  77. package/dist/frontend-ssr/api/folders.js +2 -0
  78. package/dist/frontend-ssr/api/settings.js +2 -0
  79. package/dist/frontend-ssr/api/share.js +2 -0
  80. package/dist/frontend-ssr/api/tags.js +2 -0
  81. package/dist/frontend-ssr/app-shell.js +294 -0
  82. package/dist/frontend-ssr/assets/CategoryDialog-BcGW8-Kf.js +584 -0
  83. package/dist/frontend-ssr/assets/ConfirmDialog-DjMFKc0V.js +420 -0
  84. package/dist/frontend-ssr/assets/CreateSnapshotDialog-1bROJ-Rn.js +214 -0
  85. package/dist/frontend-ssr/assets/DatePicker-B1ML8OVz.js +312 -0
  86. package/dist/frontend-ssr/assets/DeleteDialog-tBYaP0L3.js +154 -0
  87. package/dist/frontend-ssr/assets/FolderNode-BZ0Q2QUS.js +171 -0
  88. package/dist/frontend-ssr/assets/FolderTreeSelector-DZNZ2oI6.js +147 -0
  89. package/dist/frontend-ssr/assets/HiaiDocsExtensionProvider-DAM-lX4R.js +13 -0
  90. package/dist/frontend-ssr/assets/Icon-B0Zqppjo.js +231 -0
  91. package/dist/frontend-ssr/assets/SettingsDialog-B8L_YqNA.js +1107 -0
  92. package/dist/frontend-ssr/assets/ShareDialog-vMvJLRfn.js +54 -0
  93. package/dist/frontend-ssr/assets/Sidebar-EHuUAx3W.js +2033 -0
  94. package/dist/frontend-ssr/assets/TagCreateDialog-B0DPEfmQ.js +264 -0
  95. package/dist/frontend-ssr/assets/api-keys-DFqX39MT.js +35 -0
  96. package/dist/frontend-ssr/assets/attachments-CWBxE3Vz.js +85 -0
  97. package/dist/frontend-ssr/assets/auth-client-x26kqY8Z.js +1286 -0
  98. package/dist/frontend-ssr/assets/camera-CdxscTw-.js +84 -0
  99. package/dist/frontend-ssr/assets/categories-AOqgcsn4.js +75 -0
  100. package/dist/frontend-ssr/assets/chevron-down-CSSNGNh_.js +80 -0
  101. package/dist/frontend-ssr/assets/chevron-right-B4p7Sk6X.js +80 -0
  102. package/dist/frontend-ssr/assets/circle-check-CI1v4vYh.js +84 -0
  103. package/dist/frontend-ssr/assets/client-DZMkDkDn.js +129 -0
  104. package/dist/frontend-ssr/assets/clipboard-CXOaoz2W.js +30 -0
  105. package/dist/frontend-ssr/assets/clock-IL-eX2di.js +84 -0
  106. package/dist/frontend-ssr/assets/confirm-dialog-BCthVwUY.js +429 -0
  107. package/dist/frontend-ssr/assets/context-jz1GGEUi.js +45 -0
  108. package/dist/frontend-ssr/assets/copy-CjV57nGQ.js +87 -0
  109. package/dist/frontend-ssr/assets/db-CnxeO66n.js +65 -0
  110. package/dist/frontend-ssr/assets/dialog-BOV1u6zP.js +157 -0
  111. package/dist/frontend-ssr/assets/dndzone-DMvTO_Jz.js +2114 -0
  112. package/dist/frontend-ssr/assets/document-drop-coordinator-CEaYACsC.js +109 -0
  113. package/dist/frontend-ssr/assets/documents-BnOTRdTY.js +108 -0
  114. package/dist/frontend-ssr/assets/dropdown-menu-Bj5rbqbB.js +555 -0
  115. package/dist/frontend-ssr/assets/editorExtensions-DUzwndMy.js +186 -0
  116. package/dist/frontend-ssr/assets/floating-layer-anchor-CYIE8Oj6.js +6114 -0
  117. package/dist/frontend-ssr/assets/folder-DChhG7qN.js +80 -0
  118. package/dist/frontend-ssr/assets/folders-CTfbS24J.js +127 -0
  119. package/dist/frontend-ssr/assets/identity-B3uHoDtf.js +99 -0
  120. package/dist/frontend-ssr/assets/input-DezGsU3y.js +19 -0
  121. package/dist/frontend-ssr/assets/keyboard.svelte-BgF47N3L.js +174 -0
  122. package/dist/frontend-ssr/assets/label-Bj8-TfFN.js +21 -0
  123. package/dist/frontend-ssr/assets/loader-circle-DZsrZ-er.js +80 -0
  124. package/dist/frontend-ssr/assets/markdown-CjqvGi5W.js +20 -0
  125. package/dist/frontend-ssr/assets/messages-CvqpZNJe.js +11125 -0
  126. package/dist/frontend-ssr/assets/resolve-BqHozBXl.js +32 -0
  127. package/dist/frontend-ssr/assets/rotate-ccw-BlgWwaiq.js +80 -0
  128. package/dist/frontend-ssr/assets/select-value-6Lk0ToYd.js +1526 -0
  129. package/dist/frontend-ssr/assets/settings-Bk5Hk9Vq.js +64 -0
  130. package/dist/frontend-ssr/assets/share-BTBJelxA.js +30 -0
  131. package/dist/frontend-ssr/assets/subfolders-refresh-store.svelte-DAh4gT16.js +77 -0
  132. package/dist/frontend-ssr/assets/tag-GZEuGWk1.js +166 -0
  133. package/dist/frontend-ssr/assets/tag-store.svelte-DPodKj6Z.js +21 -0
  134. package/dist/frontend-ssr/assets/tags-BId2wdYd.js +49 -0
  135. package/dist/frontend-ssr/assets/textarea-Dev-qSEc.js +21 -0
  136. package/dist/frontend-ssr/assets/theme.svelte-Co0-ssaD.js +67 -0
  137. package/dist/frontend-ssr/assets/utils-DtlPPXpJ.js +9 -0
  138. package/dist/frontend-ssr/assets/utils-DvZnctjz.js +23 -0
  139. package/dist/frontend-ssr/collaboration.js +39 -0
  140. package/dist/frontend-ssr/components/category-dialog.js +2 -0
  141. package/dist/frontend-ssr/components/create-snapshot-dialog.js +2 -0
  142. package/dist/frontend-ssr/components/delete-dialog.js +2 -0
  143. package/dist/frontend-ssr/components/editor/document-editor.js +2499 -0
  144. package/dist/frontend-ssr/components/editor/document-title.js +11 -0
  145. package/dist/frontend-ssr/components/editor/docx-serializer.js +186 -0
  146. package/dist/frontend-ssr/components/editor/extensions.js +2 -0
  147. package/dist/frontend-ssr/components/editor/markdown-toggle.js +20 -0
  148. package/dist/frontend-ssr/components/editor/markdown.js +2 -0
  149. package/dist/frontend-ssr/components/folder-node.js +2 -0
  150. package/dist/frontend-ssr/components/folder-tree-selector.js +2 -0
  151. package/dist/frontend-ssr/components/save-as-dialog.js +280 -0
  152. package/dist/frontend-ssr/components/settings.js +2 -0
  153. package/dist/frontend-ssr/components/share-dialog.js +2 -0
  154. package/dist/frontend-ssr/components/sidebar.js +2 -0
  155. package/dist/frontend-ssr/components/tag-create-dialog.js +2 -0
  156. package/dist/frontend-ssr/components/version-history.js +370 -0
  157. package/dist/frontend-ssr/dashboard.js +2542 -0
  158. package/dist/frontend-ssr/doc-tabs.js +23 -0
  159. package/dist/frontend-ssr/document-drop-coordinator.js +2 -0
  160. package/dist/frontend-ssr/extension.js +2 -0
  161. package/dist/frontend-ssr/folder-refresh.js +2 -0
  162. package/dist/frontend-ssr/i18n.js +10 -0
  163. package/dist/frontend-ssr/keyboard.js +2 -0
  164. package/dist/frontend-ssr/offline/identity.js +2 -0
  165. package/dist/frontend-ssr/search.js +332 -0
  166. package/dist/frontend-ssr/shared-document.js +273 -0
  167. package/dist/frontend-ssr/theme.js +9 -0
  168. package/dist/frontend-ssr/types.js +1 -0
  169. package/dist/frontend-ssr/utils/clipboard.js +2 -0
  170. package/dist/frontend-ssr/utils/dndzone.js +2 -0
  171. package/dist/frontend-ssr/utils.js +2 -0
  172. package/package.json +28 -1
  173. package/packages/cli/src/index.ts +1 -1
  174. package/packages/db/src/schema.ts +3 -0
  175. package/packages/mcp-server/src/index.ts +1 -1
  176. package/dist/frontend/CategoryDialog--rIE7FrH.js +0 -580
  177. package/dist/frontend/ConfirmDialog-Cpzyb55f.js +0 -212
  178. package/dist/frontend/CreateSnapshotDialog-CmkV-n2A.js +0 -216
  179. package/dist/frontend/DatePicker-Byynca7V.js +0 -257
  180. package/dist/frontend/DeleteDialog-ap6nOywZ.js +0 -174
  181. package/dist/frontend/FolderDialog-DmN_trV0.js +0 -247
  182. package/dist/frontend/FolderNode-C4B8a2fd.js +0 -317
  183. package/dist/frontend/FolderTreeSelector-D6ijiZTA.js +0 -100
  184. package/dist/frontend/Icon-DtNo0N1U.js +0 -64
  185. package/dist/frontend/SettingsDialog-2kTaTXAs.js +0 -992
  186. package/dist/frontend/ShareDialog-BBDGNF5n.js +0 -165
  187. package/dist/frontend/TagCreateDialog-DiLZnJo4.js +0 -258
  188. package/dist/frontend/camera-B7dAOd4s.js +0 -28
  189. package/dist/frontend/check-CDwRlG9T.js +0 -24
  190. package/dist/frontend/chevron-down-B7ZrjUmT.js +0 -24
  191. package/dist/frontend/circle-check-CDqeMB2d.js +0 -28
  192. package/dist/frontend/client-Bc5Fzx40.js +0 -2785
  193. package/dist/frontend/clock-Ck5Sn-Zl.js +0 -28
  194. package/dist/frontend/clsx-nmtDPO_P.js +0 -16
  195. package/dist/frontend/copy-CMAA6GP0.js +0 -31
  196. package/dist/frontend/dialog-BDkiG42a.js +0 -213
  197. package/dist/frontend/disclose-version-5I57E3LD.js +0 -3
  198. package/dist/frontend/ellipsis-vertical-BBuPldbW.js +0 -519
  199. package/dist/frontend/folder-TQjKY4yn.js +0 -44
  200. package/dist/frontend/index-client-jobkrWVL.js +0 -86
  201. package/dist/frontend/input-CBI6p4Xl.js +0 -23
  202. package/dist/frontend/label-C-GkhEp4.js +0 -30
  203. package/dist/frontend/rotate-ccw-CleZtJ5D.js +0 -24
  204. package/dist/frontend/select-value-CvrWRkXW.js +0 -1436
  205. package/dist/frontend/subfolders-refresh-store.svelte-BsheoQma.js +0 -65
  206. package/dist/frontend/tag-Dx3SmucJ.js +0 -53
  207. package/dist/frontend/tag-store.svelte-CIaF4sdZ.js +0 -29
  208. package/dist/frontend/textarea-Dfp78XlL.js +0 -23
  209. package/dist/frontend/theme.svelte-CROg1Hi5.js +0 -49
  210. package/dist/frontend/x-DaTdeDXv.js +0 -24
@@ -0,0 +1,1286 @@
1
+ import { env } from "@better-auth/core/env";
2
+ import { BetterAuthError } from "@better-auth/core/error";
3
+ import { isSafeUrlScheme } from "@better-auth/core/utils/url";
4
+ import { atom, onMount, onSet } from "nanostores";
5
+ import { capitalizeFirstLetter, toKebabCase } from "@better-auth/core/utils/string";
6
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/utils/url.mjs
7
+ var SLASH_CHAR_CODE = "/".charCodeAt(0);
8
+ function trimTrailingSlashes(value) {
9
+ let end = value.length;
10
+ while (end > 0 && value.charCodeAt(end - 1) === SLASH_CHAR_CODE) end--;
11
+ return end === value.length ? value : value.slice(0, end);
12
+ }
13
+ function checkHasPath(url) {
14
+ try {
15
+ return (trimTrailingSlashes(new URL(url).pathname) || "/") !== "/";
16
+ } catch {
17
+ throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
18
+ }
19
+ }
20
+ function assertHasProtocol(url) {
21
+ try {
22
+ const parsedUrl = new URL(url);
23
+ if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
24
+ } catch (error) {
25
+ if (error instanceof BetterAuthError) throw error;
26
+ throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
27
+ }
28
+ }
29
+ function withPath(url, path = "/api/auth") {
30
+ assertHasProtocol(url);
31
+ if (checkHasPath(url)) return url;
32
+ const trimmedUrl = trimTrailingSlashes(url);
33
+ if (!path || path === "/") return trimmedUrl;
34
+ path = path.startsWith("/") ? path : `/${path}`;
35
+ return `${trimmedUrl}${path}`;
36
+ }
37
+ function validateProxyHeader(header, type) {
38
+ if (!header || header.trim() === "") return false;
39
+ if (type === "proto") return header === "http" || header === "https";
40
+ if (type === "host") {
41
+ if ([
42
+ /\.\./,
43
+ /\0/,
44
+ /[\s]/,
45
+ /^[.]/,
46
+ /[<>'"]/,
47
+ /javascript:/i,
48
+ /file:/i,
49
+ /data:/i
50
+ ].some((pattern) => pattern.test(header))) return false;
51
+ return /^[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(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
52
+ }
53
+ return false;
54
+ }
55
+ function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
56
+ if (url) return withPath(url, path);
57
+ if (loadEnv !== false) {
58
+ const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
59
+ if (fromEnv) return withPath(fromEnv, path);
60
+ }
61
+ const fromRequest = request?.headers.get("x-forwarded-host");
62
+ const fromRequestProto = request?.headers.get("x-forwarded-proto");
63
+ if (fromRequest && fromRequestProto && trustedProxyHeaders) {
64
+ if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
65
+ return withPath(`${fromRequestProto}://${fromRequest}`, path);
66
+ } catch (_error) {}
67
+ }
68
+ if (request) {
69
+ const url = getOrigin(request.url);
70
+ if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
71
+ return withPath(url, path);
72
+ }
73
+ if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
74
+ }
75
+ function getOrigin(url) {
76
+ try {
77
+ const parsedUrl = new URL(url);
78
+ return parsedUrl.origin === "null" ? null : parsedUrl.origin;
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+ //#endregion
84
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/parser.mjs
85
+ var PROTO_POLLUTION_PATTERNS = {
86
+ 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*:/,
87
+ 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*:/,
88
+ protoShort: /"__proto__"\s*:/,
89
+ constructorShort: /"constructor"\s*:/
90
+ };
91
+ var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
92
+ var SPECIAL_VALUES = {
93
+ true: true,
94
+ false: false,
95
+ null: null,
96
+ undefined: void 0,
97
+ nan: NaN,
98
+ infinity: Number.POSITIVE_INFINITY,
99
+ "-infinity": Number.NEGATIVE_INFINITY
100
+ };
101
+ var ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
102
+ function isValidDate(date) {
103
+ return date instanceof Date && !isNaN(date.getTime());
104
+ }
105
+ function parseISODate(value) {
106
+ const match = ISO_DATE_REGEX.exec(value);
107
+ if (!match) return null;
108
+ const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
109
+ const date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
110
+ if (offsetSign) {
111
+ const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
112
+ date.setUTCMinutes(date.getUTCMinutes() + offset);
113
+ }
114
+ return isValidDate(date) ? date : null;
115
+ }
116
+ function betterJSONParse(value, options = {}) {
117
+ const { strict = false, warnings = false, reviver, parseDates = true } = options;
118
+ if (typeof value !== "string") return value;
119
+ const trimmed = value.trim();
120
+ const lowerValue = trimmed.toLowerCase();
121
+ if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
122
+ if (!JSON_SIGNATURE.test(trimmed)) {
123
+ if (strict) throw new SyntaxError("[better-json] Invalid JSON");
124
+ return value;
125
+ }
126
+ if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key, pattern]) => {
127
+ const matches = pattern.test(trimmed);
128
+ if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key} pattern`);
129
+ return matches;
130
+ }) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
131
+ try {
132
+ const secureReviver = (key, value) => {
133
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
134
+ if (warnings) console.warn(`[better-json] Dropping "${key}" key to prevent prototype pollution`);
135
+ return;
136
+ }
137
+ if (parseDates && typeof value === "string") {
138
+ const date = parseISODate(value);
139
+ if (date) return date;
140
+ }
141
+ return reviver ? reviver(key, value) : value;
142
+ };
143
+ return JSON.parse(trimmed, secureReviver);
144
+ } catch (error) {
145
+ if (strict) throw error;
146
+ return value;
147
+ }
148
+ }
149
+ function parseJSON(value, options = { strict: true }) {
150
+ return betterJSONParse(value, options);
151
+ }
152
+ //#endregion
153
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/fetch-plugins.mjs
154
+ var redirectPlugin = {
155
+ id: "redirect",
156
+ name: "Redirect",
157
+ hooks: { onSuccess(context) {
158
+ if (context.data?.url && context.data?.redirect && isSafeUrlScheme(context.data.url)) {
159
+ if (typeof window !== "undefined" && window.location) {
160
+ if (window.location) try {
161
+ window.location.href = context.data.url;
162
+ } catch {}
163
+ }
164
+ }
165
+ } }
166
+ };
167
+ //#endregion
168
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/equality.mjs
169
+ function isPlainObject$1(value) {
170
+ if (typeof value !== "object" || value === null) return false;
171
+ const prototype = Object.getPrototypeOf(value);
172
+ return prototype === Object.prototype || prototype === null;
173
+ }
174
+ /**
175
+ * Deep structural equality for JSON-serializable values.
176
+ * Handles: primitives, null, arrays, and plain objects.
177
+ * Short-circuits on referential equality at every recursion level.
178
+ */
179
+ function isJsonEqual(a, b) {
180
+ if (a === b) return true;
181
+ if (Array.isArray(a) && Array.isArray(b)) {
182
+ if (a.length !== b.length) return false;
183
+ for (let i = 0; i < a.length; i++) if (!isJsonEqual(a[i], b[i])) return false;
184
+ return true;
185
+ }
186
+ if (isPlainObject$1(a) && isPlainObject$1(b)) {
187
+ const keysA = Object.keys(a);
188
+ const keysB = Object.keys(b);
189
+ if (keysA.length !== keysB.length) return false;
190
+ for (const key of keysA) if (!(key in b) || !isJsonEqual(a[key], b[key])) return false;
191
+ return true;
192
+ }
193
+ return false;
194
+ }
195
+ /**
196
+ * Attach an equality gate to a nanostores atom via `onSet`.
197
+ * When `isEqual(currentValue, newValue)` returns true, the `set()` call
198
+ * is aborted: no listeners fire, no framework re-renders occur.
199
+ *
200
+ * Returns the unsubscribe function from `onSet`.
201
+ */
202
+ function withEquality(store, isEqual) {
203
+ return onSet(store, ({ newValue, abort }) => {
204
+ if (isEqual(store.value, newValue)) abort();
205
+ });
206
+ }
207
+ //#endregion
208
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/broadcast-channel.mjs
209
+ var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
210
+ var now$1 = () => Math.floor(Date.now() / 1e3);
211
+ var WindowBroadcastChannel = class {
212
+ listeners = /* @__PURE__ */ new Set();
213
+ name;
214
+ constructor(name = "better-auth.message") {
215
+ this.name = name;
216
+ }
217
+ subscribe(listener) {
218
+ this.listeners.add(listener);
219
+ return () => {
220
+ this.listeners.delete(listener);
221
+ };
222
+ }
223
+ post(message) {
224
+ if (typeof window === "undefined") return;
225
+ try {
226
+ localStorage.setItem(this.name, JSON.stringify({
227
+ ...message,
228
+ timestamp: now$1()
229
+ }));
230
+ } catch {}
231
+ }
232
+ setup() {
233
+ if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
234
+ const handler = (event) => {
235
+ if (event.key !== this.name) return;
236
+ const message = JSON.parse(event.newValue ?? "{}");
237
+ if (message?.event !== "session" || !message?.data) return;
238
+ this.listeners.forEach((listener) => listener(message));
239
+ };
240
+ window.addEventListener("storage", handler);
241
+ return () => {
242
+ window.removeEventListener("storage", handler);
243
+ };
244
+ }
245
+ };
246
+ function getGlobalBroadcastChannel(name = "better-auth.message") {
247
+ if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
248
+ return globalThis[kBroadcastChannel];
249
+ }
250
+ //#endregion
251
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/focus-manager.mjs
252
+ var kFocusManager = Symbol.for("better-auth:focus-manager");
253
+ var WindowFocusManager = class {
254
+ listeners = /* @__PURE__ */ new Set();
255
+ subscribe(listener) {
256
+ this.listeners.add(listener);
257
+ return () => {
258
+ this.listeners.delete(listener);
259
+ };
260
+ }
261
+ setFocused(focused) {
262
+ this.listeners.forEach((listener) => listener(focused));
263
+ }
264
+ setup() {
265
+ if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {};
266
+ const visibilityHandler = () => {
267
+ if (document.visibilityState === "visible") this.setFocused(true);
268
+ };
269
+ document.addEventListener("visibilitychange", visibilityHandler, false);
270
+ return () => {
271
+ document.removeEventListener("visibilitychange", visibilityHandler, false);
272
+ };
273
+ }
274
+ };
275
+ function getGlobalFocusManager() {
276
+ if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
277
+ return globalThis[kFocusManager];
278
+ }
279
+ //#endregion
280
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/online-manager.mjs
281
+ var kOnlineManager = Symbol.for("better-auth:online-manager");
282
+ var WindowOnlineManager = class {
283
+ listeners = /* @__PURE__ */ new Set();
284
+ isOnline = typeof navigator !== "undefined" ? navigator.onLine : true;
285
+ subscribe(listener) {
286
+ this.listeners.add(listener);
287
+ return () => {
288
+ this.listeners.delete(listener);
289
+ };
290
+ }
291
+ setOnline(online) {
292
+ this.isOnline = online;
293
+ this.listeners.forEach((listener) => listener(online));
294
+ }
295
+ setup() {
296
+ if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
297
+ const onOnline = () => this.setOnline(true);
298
+ const onOffline = () => this.setOnline(false);
299
+ window.addEventListener("online", onOnline, false);
300
+ window.addEventListener("offline", onOffline, false);
301
+ return () => {
302
+ window.removeEventListener("online", onOnline, false);
303
+ window.removeEventListener("offline", onOffline, false);
304
+ };
305
+ }
306
+ };
307
+ function getGlobalOnlineManager() {
308
+ if (!globalThis[kOnlineManager]) globalThis[kOnlineManager] = new WindowOnlineManager();
309
+ return globalThis[kOnlineManager];
310
+ }
311
+ //#endregion
312
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/session-refresh.mjs
313
+ var now = () => Math.floor(Date.now() / 1e3);
314
+ /**
315
+ * Rate limit: don't refetch on focus if a session request was made within this many seconds
316
+ */
317
+ var FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
318
+ function createSessionRefreshManager(opts) {
319
+ const { fetchSession, shouldPollSession = () => true, sessionSignal, options = {} } = opts;
320
+ const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
321
+ const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
322
+ const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
323
+ const state = {
324
+ isInitialized: false,
325
+ lastSessionRequest: 0
326
+ };
327
+ const shouldRefetch = () => {
328
+ return refetchWhenOffline || getGlobalOnlineManager().isOnline;
329
+ };
330
+ const triggerRefetch = (event) => {
331
+ if (!shouldRefetch()) return;
332
+ if (event?.event === "storage") {
333
+ fetchSession();
334
+ return;
335
+ }
336
+ if (event?.event === "poll") {
337
+ state.lastSessionRequest = now();
338
+ fetchSession();
339
+ return;
340
+ }
341
+ if (event?.event === "visibilitychange") {
342
+ if (now() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS) return;
343
+ state.lastSessionRequest = now();
344
+ fetchSession();
345
+ return;
346
+ }
347
+ fetchSession();
348
+ };
349
+ const broadcastSessionUpdate = (trigger) => {
350
+ getGlobalBroadcastChannel().post({
351
+ event: "session",
352
+ data: { trigger },
353
+ clientId: Math.random().toString(36).substring(7)
354
+ });
355
+ };
356
+ const setupPolling = () => {
357
+ if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
358
+ if (shouldPollSession()) triggerRefetch({ event: "poll" });
359
+ }, refetchInterval * 1e3);
360
+ };
361
+ const setupBroadcast = () => {
362
+ state.unsubscribeBroadcast = getGlobalBroadcastChannel().subscribe(() => {
363
+ triggerRefetch({ event: "storage" });
364
+ });
365
+ };
366
+ const setupFocusRefetch = () => {
367
+ if (!refetchOnWindowFocus) return;
368
+ state.unsubscribeFocus = getGlobalFocusManager().subscribe(() => {
369
+ triggerRefetch({ event: "visibilitychange" });
370
+ });
371
+ };
372
+ const setupOnlineRefetch = () => {
373
+ state.unsubscribeOnline = getGlobalOnlineManager().subscribe((online) => {
374
+ if (online) triggerRefetch({ event: "visibilitychange" });
375
+ });
376
+ };
377
+ const setupSignalSubscription = () => {
378
+ state.unsubscribeSignal = sessionSignal.listen(() => {
379
+ fetchSession();
380
+ });
381
+ };
382
+ const init = () => {
383
+ if (state.isInitialized) return;
384
+ state.isInitialized = true;
385
+ setupPolling();
386
+ setupBroadcast();
387
+ setupFocusRefetch();
388
+ setupOnlineRefetch();
389
+ setupSignalSubscription();
390
+ state.cleanupBroadcastSetup = getGlobalBroadcastChannel().setup();
391
+ state.cleanupFocusSetup = getGlobalFocusManager().setup();
392
+ state.cleanupOnlineSetup = getGlobalOnlineManager().setup();
393
+ };
394
+ const cleanup = () => {
395
+ if (!state.isInitialized) return;
396
+ if (state.pollInterval) {
397
+ clearInterval(state.pollInterval);
398
+ state.pollInterval = void 0;
399
+ }
400
+ if (state.unsubscribeBroadcast) {
401
+ state.unsubscribeBroadcast();
402
+ state.unsubscribeBroadcast = void 0;
403
+ }
404
+ if (state.unsubscribeFocus) {
405
+ state.unsubscribeFocus();
406
+ state.unsubscribeFocus = void 0;
407
+ }
408
+ if (state.unsubscribeOnline) {
409
+ state.unsubscribeOnline();
410
+ state.unsubscribeOnline = void 0;
411
+ }
412
+ if (state.unsubscribeSignal) {
413
+ state.unsubscribeSignal();
414
+ state.unsubscribeSignal = void 0;
415
+ }
416
+ if (state.cleanupBroadcastSetup) {
417
+ state.cleanupBroadcastSetup();
418
+ state.cleanupBroadcastSetup = void 0;
419
+ }
420
+ if (state.cleanupFocusSetup) {
421
+ state.cleanupFocusSetup();
422
+ state.cleanupFocusSetup = void 0;
423
+ }
424
+ if (state.cleanupOnlineSetup) {
425
+ state.cleanupOnlineSetup();
426
+ state.cleanupOnlineSetup = void 0;
427
+ }
428
+ state.isInitialized = false;
429
+ state.lastSessionRequest = 0;
430
+ };
431
+ return {
432
+ init,
433
+ cleanup,
434
+ triggerRefetch,
435
+ broadcastSessionUpdate
436
+ };
437
+ }
438
+ //#endregion
439
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/session-atom.mjs
440
+ var isServer = () => typeof window === "undefined";
441
+ /**
442
+ * Normalize $fetch response: `throw: true` returns data directly,
443
+ * otherwise `{ data, error }`.
444
+ */
445
+ function normalizeSessionResponse(res) {
446
+ if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
447
+ return {
448
+ data: res,
449
+ error: null
450
+ };
451
+ }
452
+ function normalizeSessionData(data) {
453
+ if (!data) return null;
454
+ if (data.session === null && data.user === null) return null;
455
+ return data;
456
+ }
457
+ function isSessionAtomEqual(a, b) {
458
+ return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
459
+ }
460
+ function getSessionAtom($fetch, options) {
461
+ const $signal = atom(false);
462
+ let abortController;
463
+ const refetch = (queryParams) => fetchSession(queryParams);
464
+ const session = atom({
465
+ data: null,
466
+ error: null,
467
+ isPending: true,
468
+ isRefetching: false,
469
+ refetch
470
+ });
471
+ withEquality(session, isSessionAtomEqual);
472
+ const settleAbortedFetch = (controller) => {
473
+ if (abortController !== controller) return;
474
+ const current = session.get();
475
+ abortController = void 0;
476
+ if (!current.isPending && !current.isRefetching) return;
477
+ session.set({
478
+ ...current,
479
+ isPending: false,
480
+ isRefetching: false,
481
+ refetch
482
+ });
483
+ };
484
+ const fetchSession = async (queryParams) => {
485
+ abortController?.abort();
486
+ const controller = new AbortController();
487
+ abortController = controller;
488
+ const current = session.get();
489
+ session.set({
490
+ ...current,
491
+ isPending: current.data === null,
492
+ isRefetching: true,
493
+ error: null,
494
+ refetch
495
+ });
496
+ try {
497
+ const res = await $fetch("/get-session", {
498
+ method: "GET",
499
+ query: queryParams?.query,
500
+ signal: controller.signal
501
+ });
502
+ if (controller.signal.aborted) {
503
+ settleAbortedFetch(controller);
504
+ return;
505
+ }
506
+ let { data, error } = normalizeSessionResponse(res);
507
+ if (data?.needsRefresh) try {
508
+ const refreshRes = await $fetch("/get-session", {
509
+ method: "POST",
510
+ signal: controller.signal
511
+ });
512
+ if (controller.signal.aborted) {
513
+ settleAbortedFetch(controller);
514
+ return;
515
+ }
516
+ ({data, error} = normalizeSessionResponse(refreshRes));
517
+ } catch {
518
+ if (controller.signal.aborted) {
519
+ settleAbortedFetch(controller);
520
+ return;
521
+ }
522
+ }
523
+ if (error) {
524
+ const latest = session.get();
525
+ const isUnauthorized = error?.status === 401;
526
+ session.set({
527
+ data: isUnauthorized ? null : latest.data,
528
+ error,
529
+ isPending: false,
530
+ isRefetching: false,
531
+ refetch
532
+ });
533
+ return;
534
+ }
535
+ const sessionData = normalizeSessionData(data);
536
+ const current = session.get();
537
+ const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
538
+ session.set({
539
+ data: stableData,
540
+ error: null,
541
+ isPending: false,
542
+ isRefetching: false,
543
+ refetch
544
+ });
545
+ } catch (fetchError) {
546
+ if (controller.signal.aborted) {
547
+ settleAbortedFetch(controller);
548
+ return;
549
+ }
550
+ const latest = session.get();
551
+ session.set({
552
+ data: latest.data,
553
+ error: fetchError,
554
+ isPending: false,
555
+ isRefetching: false,
556
+ refetch
557
+ });
558
+ }
559
+ };
560
+ let broadcastSessionUpdate = () => {};
561
+ onMount(session, () => {
562
+ let timeoutId;
563
+ if (!isServer()) timeoutId = setTimeout(() => {
564
+ fetchSession();
565
+ }, 0);
566
+ const refreshManager = createSessionRefreshManager({
567
+ fetchSession,
568
+ shouldPollSession: () => session.get().data != null,
569
+ sessionSignal: $signal,
570
+ options
571
+ });
572
+ refreshManager.init();
573
+ broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
574
+ return () => {
575
+ if (timeoutId) clearTimeout(timeoutId);
576
+ const controller = abortController;
577
+ controller?.abort();
578
+ if (controller) settleAbortedFetch(controller);
579
+ refreshManager.cleanup();
580
+ };
581
+ });
582
+ return {
583
+ session,
584
+ $sessionSignal: $signal,
585
+ broadcastSessionUpdate: (trigger) => broadcastSessionUpdate(trigger)
586
+ };
587
+ }
588
+ //#endregion
589
+ //#region ../node_modules/.bun/defu@6.1.7/node_modules/defu/dist/defu.mjs
590
+ function isPlainObject(value) {
591
+ if (value === null || typeof value !== "object") return false;
592
+ const prototype = Object.getPrototypeOf(value);
593
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
594
+ if (Symbol.iterator in value) return false;
595
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
596
+ return true;
597
+ }
598
+ function _defu(baseObject, defaults, namespace = ".", merger) {
599
+ if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
600
+ const object = { ...defaults };
601
+ for (const key of Object.keys(baseObject)) {
602
+ if (key === "__proto__" || key === "constructor") continue;
603
+ const value = baseObject[key];
604
+ if (value === null || value === void 0) continue;
605
+ if (merger && merger(object, key, value, namespace)) continue;
606
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
607
+ else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
608
+ else object[key] = value;
609
+ }
610
+ return object;
611
+ }
612
+ function createDefu(merger) {
613
+ return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
614
+ }
615
+ var defu = createDefu();
616
+ //#endregion
617
+ //#region ../node_modules/.bun/@better-fetch+fetch@1.3.1/node_modules/@better-fetch/fetch/dist/index.js
618
+ var __defProp = Object.defineProperty;
619
+ var __defProps = Object.defineProperties;
620
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
621
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
622
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
623
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
624
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
625
+ enumerable: true,
626
+ configurable: true,
627
+ writable: true,
628
+ value
629
+ }) : obj[key] = value;
630
+ var __spreadValues = (a, b) => {
631
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
632
+ if (__getOwnPropSymbols) {
633
+ for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
634
+ }
635
+ return a;
636
+ };
637
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
638
+ var BetterFetchError = class extends Error {
639
+ constructor(status, statusText, error) {
640
+ super(statusText || status.toString(), { cause: error });
641
+ this.status = status;
642
+ this.statusText = statusText;
643
+ this.error = error;
644
+ Error.captureStackTrace(this, this.constructor);
645
+ }
646
+ };
647
+ var initializePlugins = async (url, options) => {
648
+ var _a, _b, _c, _d, _e, _f;
649
+ let opts = options || {};
650
+ const hooks = {
651
+ onRequest: [options == null ? void 0 : options.onRequest],
652
+ onResponse: [options == null ? void 0 : options.onResponse],
653
+ onSuccess: [options == null ? void 0 : options.onSuccess],
654
+ onError: [options == null ? void 0 : options.onError],
655
+ onRetry: [options == null ? void 0 : options.onRetry]
656
+ };
657
+ if (!options || !(options == null ? void 0 : options.plugins)) return {
658
+ url,
659
+ options: opts,
660
+ hooks
661
+ };
662
+ for (const plugin of (options == null ? void 0 : options.plugins) || []) {
663
+ if (plugin.init) {
664
+ const pluginRes = await ((_a = plugin.init) == null ? void 0 : _a.call(plugin, url.toString(), options));
665
+ opts = pluginRes.options || opts;
666
+ url = pluginRes.url;
667
+ }
668
+ hooks.onRequest.push((_b = plugin.hooks) == null ? void 0 : _b.onRequest);
669
+ hooks.onResponse.push((_c = plugin.hooks) == null ? void 0 : _c.onResponse);
670
+ hooks.onSuccess.push((_d = plugin.hooks) == null ? void 0 : _d.onSuccess);
671
+ hooks.onError.push((_e = plugin.hooks) == null ? void 0 : _e.onError);
672
+ hooks.onRetry.push((_f = plugin.hooks) == null ? void 0 : _f.onRetry);
673
+ }
674
+ return {
675
+ url,
676
+ options: opts,
677
+ hooks
678
+ };
679
+ };
680
+ var LinearRetryStrategy = class {
681
+ constructor(options) {
682
+ this.options = options;
683
+ }
684
+ shouldAttemptRetry(attempt, response) {
685
+ if (this.options.shouldRetry) return Promise.resolve(attempt < this.options.attempts && this.options.shouldRetry(response));
686
+ return Promise.resolve(attempt < this.options.attempts);
687
+ }
688
+ getDelay() {
689
+ return this.options.delay;
690
+ }
691
+ };
692
+ var ExponentialRetryStrategy = class {
693
+ constructor(options) {
694
+ this.options = options;
695
+ }
696
+ shouldAttemptRetry(attempt, response) {
697
+ if (this.options.shouldRetry) return Promise.resolve(attempt < this.options.attempts && this.options.shouldRetry(response));
698
+ return Promise.resolve(attempt < this.options.attempts);
699
+ }
700
+ getDelay(attempt) {
701
+ return Math.min(this.options.maxDelay, this.options.baseDelay * 2 ** attempt);
702
+ }
703
+ };
704
+ function createRetryStrategy(options) {
705
+ if (typeof options === "number") return new LinearRetryStrategy({
706
+ type: "linear",
707
+ attempts: options,
708
+ delay: 1e3
709
+ });
710
+ switch (options.type) {
711
+ case "linear": return new LinearRetryStrategy(options);
712
+ case "exponential": return new ExponentialRetryStrategy(options);
713
+ default: throw new Error("Invalid retry strategy");
714
+ }
715
+ }
716
+ var getAuthHeader = async (options) => {
717
+ const headers = {};
718
+ const getValue = async (value) => typeof value === "function" ? await value() : value;
719
+ if (options == null ? void 0 : options.auth) {
720
+ if (options.auth.type === "Bearer") {
721
+ const token = await getValue(options.auth.token);
722
+ if (!token) return headers;
723
+ headers["authorization"] = `Bearer ${token}`;
724
+ } else if (options.auth.type === "Basic") {
725
+ const [username, password] = await Promise.all([getValue(options.auth.username), getValue(options.auth.password)]);
726
+ if (!username || !password) return headers;
727
+ headers["authorization"] = `Basic ${btoa(`${username}:${password}`)}`;
728
+ } else if (options.auth.type === "Custom") {
729
+ const [prefix, value] = await Promise.all([getValue(options.auth.prefix), getValue(options.auth.value)]);
730
+ if (!value) return headers;
731
+ headers["authorization"] = `${prefix != null ? prefix : ""} ${value}`;
732
+ }
733
+ }
734
+ return headers;
735
+ };
736
+ var JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
737
+ function detectResponseType(request) {
738
+ const _contentType = request.headers.get("content-type");
739
+ const textTypes = /* @__PURE__ */ new Set([
740
+ "image/svg",
741
+ "application/xml",
742
+ "application/xhtml",
743
+ "application/html"
744
+ ]);
745
+ if (!_contentType) return "json";
746
+ const contentType = _contentType.split(";").shift() || "";
747
+ if (JSON_RE.test(contentType)) return "json";
748
+ if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
749
+ return "blob";
750
+ }
751
+ function isJSONParsable(value) {
752
+ try {
753
+ JSON.parse(value);
754
+ return true;
755
+ } catch (error) {
756
+ return false;
757
+ }
758
+ }
759
+ function isJSONSerializable(value) {
760
+ if (value === void 0) return false;
761
+ const t = typeof value;
762
+ if (t === "string" || t === "number" || t === "boolean" || t === null) return true;
763
+ if (t !== "object") return false;
764
+ if (Array.isArray(value)) return true;
765
+ if (value.buffer) return false;
766
+ return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
767
+ }
768
+ function jsonParse(text) {
769
+ try {
770
+ return JSON.parse(text);
771
+ } catch (error) {
772
+ return text;
773
+ }
774
+ }
775
+ function isFunction(value) {
776
+ return typeof value === "function";
777
+ }
778
+ function getFetch(options) {
779
+ if (options == null ? void 0 : options.customFetchImpl) return options.customFetchImpl;
780
+ if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
781
+ if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
782
+ throw new Error("No fetch implementation found");
783
+ }
784
+ function mergeHeaders(...sources) {
785
+ const merged = {};
786
+ for (const source of sources) {
787
+ if (!source) continue;
788
+ if (source instanceof Headers) source.forEach((value, key) => {
789
+ merged[key] = value;
790
+ });
791
+ else {
792
+ const entries = Array.isArray(source) ? source : Object.entries(source);
793
+ for (const [key, value] of entries) if (value !== null && value !== void 0) merged[key] = value;
794
+ }
795
+ }
796
+ return merged;
797
+ }
798
+ async function getHeaders(opts) {
799
+ const headers = new Headers(mergeHeaders(opts == null ? void 0 : opts.headers, await getAuthHeader(opts)));
800
+ if (!headers.has("content-type")) {
801
+ const contentType = detectContentType(opts == null ? void 0 : opts.body);
802
+ if (contentType) headers.set("content-type", contentType);
803
+ }
804
+ return headers;
805
+ }
806
+ function detectContentType(body) {
807
+ if (isJSONSerializable(body)) return "application/json";
808
+ return null;
809
+ }
810
+ function getMediaType(headers) {
811
+ const contentType = headers.get("content-type");
812
+ return contentType ? contentType.split(";")[0].trim().toLowerCase() : null;
813
+ }
814
+ function getBody(options, headers) {
815
+ const { body } = options;
816
+ if (!body) return null;
817
+ if (!isJSONSerializable(body)) return body;
818
+ if (typeof body === "string") return body;
819
+ if (getMediaType(headers) === "application/x-www-form-urlencoded") return new URLSearchParams(body).toString();
820
+ return JSON.stringify(body);
821
+ }
822
+ function getMethod$1(url, options) {
823
+ var _a;
824
+ if (options == null ? void 0 : options.method) return options.method.toUpperCase();
825
+ if (url.startsWith("@")) {
826
+ const pMethod = (_a = url.split("@")[1]) == null ? void 0 : _a.split("/")[0];
827
+ if (!methods.includes(pMethod)) return (options == null ? void 0 : options.body) ? "POST" : "GET";
828
+ return pMethod.toUpperCase();
829
+ }
830
+ return (options == null ? void 0 : options.body) ? "POST" : "GET";
831
+ }
832
+ function getTimeout(options, controller) {
833
+ let abortTimeout;
834
+ if (!(options == null ? void 0 : options.signal) && (options == null ? void 0 : options.timeout)) abortTimeout = setTimeout(() => controller == null ? void 0 : controller.abort(), options == null ? void 0 : options.timeout);
835
+ return {
836
+ abortTimeout,
837
+ clearTimeout: () => {
838
+ if (abortTimeout) clearTimeout(abortTimeout);
839
+ }
840
+ };
841
+ }
842
+ var ValidationError = class _ValidationError extends Error {
843
+ constructor(issues, message) {
844
+ super(message || JSON.stringify(issues, null, 2));
845
+ this.issues = issues;
846
+ Object.setPrototypeOf(this, _ValidationError.prototype);
847
+ }
848
+ };
849
+ async function parseStandardSchema(schema, input) {
850
+ const result = await schema["~standard"].validate(input);
851
+ if (result.issues) throw new ValidationError(result.issues);
852
+ return result.value;
853
+ }
854
+ var methods = [
855
+ "get",
856
+ "post",
857
+ "put",
858
+ "patch",
859
+ "delete"
860
+ ];
861
+ var applySchemaPlugin = (config) => ({
862
+ id: "apply-schema",
863
+ name: "Apply Schema",
864
+ version: "1.0.0",
865
+ async init(url, options) {
866
+ var _a, _b, _c, _d;
867
+ const schema = ((_b = (_a = config.plugins) == null ? void 0 : _a.find((plugin) => {
868
+ var _a2;
869
+ return ((_a2 = plugin.schema) == null ? void 0 : _a2.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
870
+ })) == null ? void 0 : _b.schema) || config.schema;
871
+ if (schema) {
872
+ let urlKey = url;
873
+ if ((_c = schema.config) == null ? void 0 : _c.prefix) {
874
+ if (urlKey.startsWith(schema.config.prefix)) {
875
+ urlKey = urlKey.replace(schema.config.prefix, "");
876
+ if (schema.config.baseURL) url = url.replace(schema.config.prefix, schema.config.baseURL);
877
+ }
878
+ }
879
+ if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
880
+ if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
881
+ }
882
+ if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
883
+ const keySchema = schema.schema[urlKey];
884
+ if (keySchema) {
885
+ let validatedHeaders = options == null ? void 0 : options.headers;
886
+ if (keySchema.headers && !(options == null ? void 0 : options.disableValidation)) {
887
+ const normalizedHeaders = {};
888
+ if (options == null ? void 0 : options.headers) {
889
+ if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
890
+ normalizedHeaders[key.toLowerCase()] = value;
891
+ });
892
+ else if (typeof options.headers === "object") {
893
+ for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
894
+ }
895
+ }
896
+ const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
897
+ const finalHeaders = {};
898
+ for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
899
+ validatedHeaders = finalHeaders;
900
+ }
901
+ let opts = __spreadProps(__spreadValues({}, options), {
902
+ method: keySchema.method,
903
+ output: keySchema.output,
904
+ headers: validatedHeaders
905
+ });
906
+ if (!(options == null ? void 0 : options.disableValidation)) opts = __spreadProps(__spreadValues({}, opts), {
907
+ body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
908
+ params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
909
+ query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
910
+ });
911
+ return {
912
+ url,
913
+ options: opts
914
+ };
915
+ }
916
+ }
917
+ return {
918
+ url,
919
+ options
920
+ };
921
+ }
922
+ });
923
+ var createFetch = (config) => {
924
+ async function $fetch(url, options) {
925
+ const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
926
+ headers: mergeHeaders(config == null ? void 0 : config.headers, options == null ? void 0 : options.headers),
927
+ plugins: [
928
+ ...(config == null ? void 0 : config.plugins) || [],
929
+ applySchemaPlugin(config || {}),
930
+ ...(options == null ? void 0 : options.plugins) || []
931
+ ]
932
+ });
933
+ if (config == null ? void 0 : config.catchAllError) try {
934
+ return await betterFetch(url, opts);
935
+ } catch (error) {
936
+ return {
937
+ data: null,
938
+ error: {
939
+ status: 500,
940
+ statusText: "Fetch Error",
941
+ message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
942
+ error
943
+ }
944
+ };
945
+ }
946
+ return await betterFetch(url, opts);
947
+ }
948
+ return $fetch;
949
+ };
950
+ var isReservedPathSegment = (value) => value === "." || value === "..";
951
+ function encodePathSegment(segment, pathParams) {
952
+ let pathSegment = segment;
953
+ for (const [key, value] of pathParams) pathSegment = pathSegment.replace(key, value);
954
+ if (isReservedPathSegment(pathSegment)) throw new TypeError("Path parameters cannot be reserved path segments");
955
+ return encodeURIComponent(pathSegment);
956
+ }
957
+ function getURL2(url, option) {
958
+ const { baseURL, params, query } = option || {
959
+ query: {},
960
+ params: {},
961
+ baseURL: ""
962
+ };
963
+ let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
964
+ if (url.startsWith("@")) {
965
+ const m = url.toString().split("@")[1].split("/")[0];
966
+ if (methods.includes(m)) url = url.replace(`@${m}/`, "/");
967
+ }
968
+ if (!basePath.endsWith("/")) basePath += "/";
969
+ let [path, urlQuery] = url.replace(basePath, "").split("?");
970
+ const queryParams = new URLSearchParams(urlQuery);
971
+ for (const [key, value] of Object.entries(query || {})) {
972
+ if (value == null) continue;
973
+ let serializedValue;
974
+ if (typeof value === "string") serializedValue = value;
975
+ else if (Array.isArray(value)) {
976
+ for (const val of value) queryParams.append(key, val);
977
+ continue;
978
+ } else serializedValue = JSON.stringify(value);
979
+ queryParams.set(key, serializedValue);
980
+ }
981
+ const pathParams = /* @__PURE__ */ new Map();
982
+ if (params) if (Array.isArray(params)) {
983
+ const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
984
+ for (const [index, key] of paramPaths.entries()) {
985
+ const value = params[index];
986
+ pathParams.set(key, String(value));
987
+ }
988
+ } else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
989
+ path = path.split("/").map((segment) => encodePathSegment(segment, pathParams)).join("/");
990
+ path = path.replace(/^\/+/, "");
991
+ let queryParamString = queryParams.toString();
992
+ queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
993
+ if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
994
+ return new URL(`${path}${queryParamString}`, basePath);
995
+ }
996
+ var betterFetch = async (url, options) => {
997
+ var _a, _b, _c, _d, _e, _f, _g, _h;
998
+ const { hooks, url: __url, options: opts } = await initializePlugins(url, options);
999
+ const fetch = getFetch(opts);
1000
+ const controller = new AbortController();
1001
+ const signal = (_a = opts.signal) != null ? _a : controller.signal;
1002
+ const _url = getURL2(__url, opts);
1003
+ const headers = await getHeaders(opts);
1004
+ const body = getBody(opts, headers);
1005
+ const method = getMethod$1(__url, opts);
1006
+ const context = __spreadProps(__spreadValues({}, opts), {
1007
+ url: _url,
1008
+ headers,
1009
+ body,
1010
+ method,
1011
+ signal
1012
+ });
1013
+ for (const onRequest of hooks.onRequest) if (onRequest) {
1014
+ const res = await onRequest(context);
1015
+ if (typeof res === "object" && res !== null) Object.assign(context, res);
1016
+ }
1017
+ if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
1018
+ if (!("duplex" in context)) context.duplex = "half";
1019
+ }
1020
+ const { clearTimeout: clearTimeout2 } = getTimeout(opts, controller);
1021
+ let response = await fetch(context.url, context);
1022
+ clearTimeout2();
1023
+ const responseContext = {
1024
+ response,
1025
+ request: context
1026
+ };
1027
+ for (const onResponse of hooks.onResponse) if (onResponse) {
1028
+ const r = await onResponse(__spreadProps(__spreadValues({}, responseContext), { response: ((_c = options == null ? void 0 : options.hookOptions) == null ? void 0 : _c.cloneResponse) ? response.clone() : response }));
1029
+ if (r instanceof Response) response = r;
1030
+ else if (typeof r === "object" && r !== null) response = r.response;
1031
+ }
1032
+ if (response.ok) {
1033
+ if (!(context.method !== "HEAD")) return {
1034
+ data: "",
1035
+ error: null
1036
+ };
1037
+ const responseType = detectResponseType(response);
1038
+ const successContext = {
1039
+ data: null,
1040
+ response,
1041
+ request: context
1042
+ };
1043
+ if (responseType === "json" || responseType === "text") {
1044
+ const text = await response.text();
1045
+ successContext.data = await ((_d = context.jsonParser) != null ? _d : jsonParse)(text);
1046
+ } else successContext.data = await response[responseType]();
1047
+ if (context == null ? void 0 : context.output) {
1048
+ if (context.output && !context.disableValidation) successContext.data = await parseStandardSchema(context.output, successContext.data);
1049
+ }
1050
+ for (const onSuccess of hooks.onSuccess) if (onSuccess) await onSuccess(__spreadProps(__spreadValues({}, successContext), { response: ((_e = options == null ? void 0 : options.hookOptions) == null ? void 0 : _e.cloneResponse) ? response.clone() : response }));
1051
+ if (options == null ? void 0 : options.throw) return successContext.data;
1052
+ return {
1053
+ data: successContext.data,
1054
+ error: null
1055
+ };
1056
+ }
1057
+ const parser = (_f = options == null ? void 0 : options.jsonParser) != null ? _f : jsonParse;
1058
+ const responseText = await response.text();
1059
+ const isJSONResponse = isJSONParsable(responseText);
1060
+ const errorObject = isJSONResponse ? await parser(responseText) : null;
1061
+ const errorContext = {
1062
+ response,
1063
+ responseText,
1064
+ request: context,
1065
+ error: __spreadProps(__spreadValues({}, errorObject), {
1066
+ status: response.status,
1067
+ statusText: response.statusText
1068
+ })
1069
+ };
1070
+ for (const onError of hooks.onError) if (onError) await onError(__spreadProps(__spreadValues({}, errorContext), { response: ((_g = options == null ? void 0 : options.hookOptions) == null ? void 0 : _g.cloneResponse) ? response.clone() : response }));
1071
+ if (options == null ? void 0 : options.retry) {
1072
+ const retryStrategy = createRetryStrategy(options.retry);
1073
+ const _retryAttempt = (_h = options.retryAttempt) != null ? _h : 0;
1074
+ if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
1075
+ for (const onRetry of hooks.onRetry) if (onRetry) await onRetry(responseContext);
1076
+ const delay = retryStrategy.getDelay(_retryAttempt);
1077
+ await new Promise((resolve) => setTimeout(resolve, delay));
1078
+ return await betterFetch(url, __spreadProps(__spreadValues({}, options), { retryAttempt: _retryAttempt + 1 }));
1079
+ }
1080
+ }
1081
+ if (options == null ? void 0 : options.throw) throw new BetterFetchError(response.status, response.statusText, isJSONResponse ? errorObject : responseText);
1082
+ return {
1083
+ data: null,
1084
+ error: __spreadProps(__spreadValues({}, errorObject), {
1085
+ status: response.status,
1086
+ statusText: response.statusText
1087
+ })
1088
+ };
1089
+ };
1090
+ //#endregion
1091
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/config.mjs
1092
+ var resolvePublicAuthUrl = (basePath) => {
1093
+ if (typeof process === "undefined") return void 0;
1094
+ const path = basePath ?? "/api/auth";
1095
+ if (process.env.NEXT_PUBLIC_AUTH_URL) return process.env.NEXT_PUBLIC_AUTH_URL;
1096
+ if (typeof window === "undefined") {
1097
+ if (process.env.NEXTAUTH_URL) try {
1098
+ return process.env.NEXTAUTH_URL;
1099
+ } catch {}
1100
+ if (process.env.VERCEL_URL) try {
1101
+ const protocol = process.env.VERCEL_URL.startsWith("http") ? "" : "https://";
1102
+ return `${new URL(`${protocol}${process.env.VERCEL_URL}`).origin}${path}`;
1103
+ } catch {}
1104
+ }
1105
+ };
1106
+ var getClientConfig = (options, loadEnv) => {
1107
+ const isCredentialsSupported = "credentials" in Request.prototype;
1108
+ const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? resolvePublicAuthUrl(options?.basePath) ?? "/api/auth";
1109
+ const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
1110
+ const lifeCyclePlugin = {
1111
+ id: "lifecycle-hooks",
1112
+ name: "lifecycle-hooks",
1113
+ hooks: {
1114
+ onSuccess: options?.fetchOptions?.onSuccess,
1115
+ onError: options?.fetchOptions?.onError,
1116
+ onRequest: options?.fetchOptions?.onRequest,
1117
+ onResponse: options?.fetchOptions?.onResponse
1118
+ }
1119
+ };
1120
+ const { onSuccess: _onSuccess, onError: _onError, onRequest: _onRequest, onResponse: _onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
1121
+ const $fetch = createFetch({
1122
+ baseURL,
1123
+ ...isCredentialsSupported ? { credentials: "include" } : {},
1124
+ method: "GET",
1125
+ jsonParser(text) {
1126
+ if (!text) return null;
1127
+ return parseJSON(text, { strict: false });
1128
+ },
1129
+ customFetchImpl: fetch,
1130
+ ...restOfFetchOptions,
1131
+ plugins: [
1132
+ lifeCyclePlugin,
1133
+ ...restOfFetchOptions.plugins || [],
1134
+ ...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
1135
+ ...pluginsFetchPlugins
1136
+ ]
1137
+ });
1138
+ const { $sessionSignal, session, broadcastSessionUpdate } = getSessionAtom($fetch, options);
1139
+ const plugins = options?.plugins || [];
1140
+ let pluginsActions = {};
1141
+ const pluginsAtoms = {
1142
+ $sessionSignal,
1143
+ session
1144
+ };
1145
+ const pluginPathMethods = {
1146
+ "/sign-out": "POST",
1147
+ "/revoke-sessions": "POST",
1148
+ "/revoke-other-sessions": "POST",
1149
+ "/delete-user": "POST"
1150
+ };
1151
+ const atomListeners = [{
1152
+ signal: "$sessionSignal",
1153
+ matcher(path) {
1154
+ return path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
1155
+ },
1156
+ callback(path) {
1157
+ if (path === "/sign-out") broadcastSessionUpdate("signout");
1158
+ else if (path === "/update-user" || path === "/update-session") broadcastSessionUpdate("updateUser");
1159
+ }
1160
+ }];
1161
+ for (const plugin of plugins) {
1162
+ if (plugin.getAtoms) Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
1163
+ if (plugin.pathMethods) Object.assign(pluginPathMethods, plugin.pathMethods);
1164
+ if (plugin.atomListeners) atomListeners.push(...plugin.atomListeners);
1165
+ }
1166
+ const $store = {
1167
+ notify: (signal) => {
1168
+ pluginsAtoms[signal].set(!pluginsAtoms[signal].get());
1169
+ },
1170
+ listen: (signal, listener) => {
1171
+ pluginsAtoms[signal].subscribe(listener);
1172
+ },
1173
+ atoms: pluginsAtoms
1174
+ };
1175
+ for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
1176
+ return {
1177
+ get baseURL() {
1178
+ return baseURL;
1179
+ },
1180
+ pluginsActions,
1181
+ pluginsAtoms,
1182
+ pluginPathMethods,
1183
+ atomListeners,
1184
+ $fetch,
1185
+ $store
1186
+ };
1187
+ };
1188
+ //#endregion
1189
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/utils/is-atom.mjs
1190
+ function isAtom(value) {
1191
+ return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
1192
+ }
1193
+ //#endregion
1194
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/proxy.mjs
1195
+ function getMethod(path, knownPathMethods, args) {
1196
+ const method = knownPathMethods[path];
1197
+ const { fetchOptions, query: _query, ...body } = args || {};
1198
+ if (method) return method;
1199
+ if (fetchOptions?.method) return fetchOptions.method;
1200
+ if (body && Object.keys(body).length > 0) return "POST";
1201
+ return "GET";
1202
+ }
1203
+ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomListeners) {
1204
+ function createProxy(path = []) {
1205
+ return new Proxy(function() {}, {
1206
+ get(_, prop) {
1207
+ if (typeof prop !== "string") return;
1208
+ if (prop === "then" || prop === "catch" || prop === "finally") return;
1209
+ const fullPath = [...path, prop];
1210
+ let current = routes;
1211
+ for (const segment of fullPath) if (current && typeof current === "object" && segment in current) current = current[segment];
1212
+ else {
1213
+ current = void 0;
1214
+ break;
1215
+ }
1216
+ if (typeof current === "function") return current;
1217
+ if (isAtom(current)) return current;
1218
+ return createProxy(fullPath);
1219
+ },
1220
+ apply: async (_, __, args) => {
1221
+ const routePath = "/" + path.map(toKebabCase).join("/");
1222
+ const arg = args[0] || {};
1223
+ const fetchOptions = args[1] || {};
1224
+ const { query, fetchOptions: argFetchOptions, ...body } = arg;
1225
+ const options = {
1226
+ ...fetchOptions,
1227
+ ...argFetchOptions
1228
+ };
1229
+ const method = getMethod(routePath, knownPathMethods, arg);
1230
+ return await client(routePath, {
1231
+ ...options,
1232
+ body: method === "GET" ? void 0 : {
1233
+ ...body,
1234
+ ...options?.body || {}
1235
+ },
1236
+ query: query || options?.query,
1237
+ method,
1238
+ async onSuccess(context) {
1239
+ await options?.onSuccess?.(context);
1240
+ if (!atomListeners || options.disableSignal) return;
1241
+ /**
1242
+ * We trigger listeners
1243
+ */
1244
+ const matches = atomListeners.filter((s) => s.matcher(routePath));
1245
+ if (!matches.length) return;
1246
+ const visited = /* @__PURE__ */ new Set();
1247
+ for (const match of matches) {
1248
+ const signal = atoms[match.signal];
1249
+ if (!signal) return;
1250
+ if (visited.has(match.signal)) continue;
1251
+ visited.add(match.signal);
1252
+ /**
1253
+ * To avoid race conditions we set the signal in a setTimeout
1254
+ */
1255
+ const val = signal.get();
1256
+ setTimeout(() => {
1257
+ signal.set(!val);
1258
+ }, 10);
1259
+ match.callback?.(routePath);
1260
+ }
1261
+ }
1262
+ });
1263
+ }
1264
+ });
1265
+ }
1266
+ return createProxy();
1267
+ }
1268
+ //#endregion
1269
+ //#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/vanilla.mjs
1270
+ function createAuthClient(options) {
1271
+ const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
1272
+ const resolvedHooks = {};
1273
+ for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;
1274
+ return createDynamicPathProxy({
1275
+ ...pluginsActions,
1276
+ ...resolvedHooks,
1277
+ $fetch,
1278
+ $store
1279
+ }, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
1280
+ }
1281
+ //#endregion
1282
+ //#region src/lib/auth-client.ts
1283
+ var authClient = createAuthClient({ baseURL: typeof window !== "undefined" ? window.location.origin : "" });
1284
+ var { signIn, signUp, signOut, getSession } = authClient;
1285
+ //#endregion
1286
+ export { getSession as n, signOut as r, authClient as t };