@rhinestone/deposit-modal 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +43 -2
  2. package/bridge-transcript.json +653 -0
  3. package/dist/ClaimModal-IKTJU43Y.cjs +13 -0
  4. package/dist/ClaimModal-SEKNWRMA.mjs +13 -0
  5. package/dist/{DepositModalReown-YNNHLAV2.cjs → DepositModalReown-46LPVFB6.cjs} +16 -15
  6. package/dist/{DepositModalReown-3H75G3XQ.mjs → DepositModalReown-Q2JMLT47.mjs} +6 -5
  7. package/dist/WithdrawModal-5ICGD4HJ.mjs +12 -0
  8. package/dist/WithdrawModal-VP6PMIRO.cjs +12 -0
  9. package/dist/{chunk-GACIGCSN.cjs → chunk-6KG642KH.cjs} +1 -1
  10. package/dist/{chunk-RAADLTSW.cjs → chunk-7ICSHJFE.cjs} +179 -138
  11. package/dist/{chunk-COCBCQQC.mjs → chunk-7SR7ENVJ.mjs} +46 -5
  12. package/dist/{chunk-OLCD75JK.mjs → chunk-CFKC77SV.mjs} +451 -131
  13. package/dist/{chunk-EOMT5LKX.mjs → chunk-IN77XSWO.mjs} +526 -3
  14. package/dist/{chunk-FZ5FZFIG.mjs → chunk-K4H6TGBE.mjs} +1 -1
  15. package/dist/{chunk-DSIZNRWA.mjs → chunk-KTUVSKR4.mjs} +979 -360
  16. package/dist/{chunk-HOGZKHHY.cjs → chunk-LZFRL2AL.cjs} +3 -3
  17. package/dist/{chunk-7N77GIP4.cjs → chunk-MTFJSE52.cjs} +465 -171
  18. package/dist/{chunk-LTMMETAB.mjs → chunk-PKML3XVS.mjs} +404 -110
  19. package/dist/{chunk-ZMT4ATHR.cjs → chunk-V2OBGLJD.cjs} +564 -41
  20. package/dist/{chunk-XYJFEN5D.mjs → chunk-WUJIKCFU.mjs} +1 -1
  21. package/dist/{chunk-CVGNCUVU.cjs → chunk-X2IPAPXU.cjs} +22 -13
  22. package/dist/{chunk-2G2EIN4A.cjs → chunk-YCQZJQO6.cjs} +1272 -653
  23. package/dist/{chunk-5NUIKYSF.cjs → chunk-YWMWI7PZ.cjs} +458 -138
  24. package/dist/{chunk-YREVFB64.mjs → chunk-ZEO6ADM3.mjs} +16 -7
  25. package/dist/claim.cjs +6 -6
  26. package/dist/claim.d.cts +3 -3
  27. package/dist/claim.d.ts +3 -3
  28. package/dist/claim.mjs +5 -5
  29. package/dist/constants.cjs +2 -2
  30. package/dist/constants.d.cts +1 -1
  31. package/dist/constants.d.ts +1 -1
  32. package/dist/constants.mjs +1 -1
  33. package/dist/deposit.cjs +6 -6
  34. package/dist/deposit.d.cts +2 -2
  35. package/dist/deposit.d.ts +2 -2
  36. package/dist/deposit.mjs +5 -5
  37. package/dist/embed.cjs +310 -102
  38. package/dist/embed.d.cts +7 -1
  39. package/dist/embed.d.ts +7 -1
  40. package/dist/embed.mjs +285 -77
  41. package/dist/index.cjs +9 -9
  42. package/dist/index.d.cts +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.mjs +8 -8
  45. package/dist/types-Bho4OA03.d.ts +982 -0
  46. package/dist/types-DP_3KwlD.d.cts +982 -0
  47. package/dist/withdraw.cjs +5 -5
  48. package/dist/withdraw.d.cts +3 -3
  49. package/dist/withdraw.d.ts +3 -3
  50. package/dist/withdraw.mjs +4 -4
  51. package/package.json +28 -7
  52. package/dist/ClaimModal-CREZO27I.mjs +0 -11
  53. package/dist/ClaimModal-JRIA32U2.cjs +0 -11
  54. package/dist/WithdrawModal-NVRX44IZ.mjs +0 -10
  55. package/dist/WithdrawModal-YYSBPCJJ.cjs +0 -10
  56. package/dist/types-B89I8_8H.d.ts +0 -638
  57. package/dist/types-nnDR4tqA.d.cts +0 -638
@@ -1,6 +1,7 @@
1
1
  import {
2
+ MODAL_VERSION,
2
3
  serviceHeaders
3
- } from "./chunk-FZ5FZFIG.mjs";
4
+ } from "./chunk-K4H6TGBE.mjs";
4
5
  import {
5
6
  CHAIN_DISPLAY_ORDER,
6
7
  HYPERCORE_CHAIN_ID,
@@ -83,7 +84,7 @@ function Modal({
83
84
  (event) => {
84
85
  if (event.key === "Escape") {
85
86
  event.preventDefault();
86
- onClose();
87
+ onClose("escape");
87
88
  return;
88
89
  }
89
90
  if (event.key === "Tab" && contentRef.current) {
@@ -109,7 +110,7 @@ function Modal({
109
110
  const handleOverlayClick = useCallback(
110
111
  (event) => {
111
112
  if (closeOnOverlayClick && event.target === overlayRef.current) {
112
- onClose();
113
+ onClose("overlay");
113
114
  }
114
115
  },
115
116
  [closeOnOverlayClick, onClose]
@@ -2875,6 +2876,524 @@ function formatReceiveEstimate(params) {
2875
2876
  return sameSymbol ? `${formatted} ${params.targetSymbol}` : `~${formatted} ${params.targetSymbol}`;
2876
2877
  }
2877
2878
 
2879
+ // src/core/analytics.tsx
2880
+ import {
2881
+ createContext as createContext3,
2882
+ useCallback as useCallback2,
2883
+ useContext as useContext3,
2884
+ useEffect as useEffect4,
2885
+ useMemo as useMemo3,
2886
+ useRef as useRef3
2887
+ } from "react";
2888
+
2889
+ // src/core/analytics-ingest.ts
2890
+ var DEFAULT_ANALYTICS_INGEST_URL = "https://v1.orchestrator.rhinestone.dev/deposit-processor/analytics/events";
2891
+ var MAX_BATCH = 20;
2892
+ var MAX_QUEUE = 200;
2893
+ var FLUSH_DELAY_MS = 5e3;
2894
+ var MAX_BODY_BYTES = 48 * 1024;
2895
+ var TOKEN_REFRESH_MARGIN_MS = 6e4;
2896
+ var TOKEN_TIMEOUT_MS = 3e3;
2897
+ var MAX_ATTEMPTS = 3;
2898
+ var MAX_BACKOFF_MS = 3e4;
2899
+ var ENVELOPE_FIELDS = /* @__PURE__ */ new Set([
2900
+ "type",
2901
+ "timestamp",
2902
+ "session_id",
2903
+ "modal",
2904
+ "widget_version",
2905
+ "session_properties",
2906
+ "funding_method"
2907
+ ]);
2908
+ function createIngestTransport(options) {
2909
+ const {
2910
+ ingestUrl,
2911
+ backendUrl,
2912
+ proxyOrigin,
2913
+ sessionId,
2914
+ modal,
2915
+ widgetVersion,
2916
+ sessionProperties,
2917
+ onFailure
2918
+ } = options;
2919
+ const fetchImpl = options.fetchImpl ?? (typeof globalThis.fetch === "function" ? globalThis.fetch.bind(globalThis) : void 0);
2920
+ const now = options.now ?? (() => Date.now());
2921
+ const createEventId = options.createEventId ?? randomUuid;
2922
+ const mintUrl = `${backendUrl.replace(/\/$/, "")}/analytics/ingest-token`;
2923
+ const queue = [];
2924
+ let sequence = 0;
2925
+ let dropped = 0;
2926
+ let token = null;
2927
+ let mintUnavailable = false;
2928
+ let mintFailures = 0;
2929
+ let mintBackoffUntil = 0;
2930
+ let timer = null;
2931
+ let sending = false;
2932
+ let disposed = false;
2933
+ let pendingTerminal = false;
2934
+ let terminalRequested = false;
2935
+ let mintAbort = null;
2936
+ const sleepers = /* @__PURE__ */ new Set();
2937
+ function report(reason, status) {
2938
+ try {
2939
+ onFailure({ reason, status, droppedEvents: dropped });
2940
+ } catch {
2941
+ }
2942
+ }
2943
+ function drop(batch, reason, status) {
2944
+ dropped += batch.length;
2945
+ report(reason, status);
2946
+ }
2947
+ function toWireEvent(event) {
2948
+ const payload = {};
2949
+ for (const [key, value] of Object.entries(event)) {
2950
+ if (!ENVELOPE_FIELDS.has(key)) payload[key] = value;
2951
+ }
2952
+ const wire = {
2953
+ event_id: createEventId(),
2954
+ session_id: sessionId,
2955
+ sequence: sequence++,
2956
+ type: String(event.type),
2957
+ timestamp: String(event.timestamp),
2958
+ widget_version: widgetVersion,
2959
+ proxy_origin: proxyOrigin,
2960
+ modal,
2961
+ session_properties: sessionProperties,
2962
+ payload
2963
+ };
2964
+ if (modal === "deposit") wire.funding_method = event.funding_method ?? null;
2965
+ return wire;
2966
+ }
2967
+ function takeBatch() {
2968
+ const batch = queue.slice(0, MAX_BATCH);
2969
+ while (batch.length > 1 && bodyOf(batch).length > MAX_BODY_BYTES) {
2970
+ batch.pop();
2971
+ }
2972
+ queue.splice(0, batch.length);
2973
+ return batch;
2974
+ }
2975
+ function bodyOf(batch) {
2976
+ return JSON.stringify({ events: batch });
2977
+ }
2978
+ function backoff(attempt) {
2979
+ return Math.min(1e3 * 2 ** (attempt - 1), MAX_BACKOFF_MS);
2980
+ }
2981
+ function sleep(ms) {
2982
+ return new Promise((resolve) => {
2983
+ const timeout = setTimeout(finish, ms);
2984
+ function finish() {
2985
+ clearTimeout(timeout);
2986
+ sleepers.delete(finish);
2987
+ resolve();
2988
+ }
2989
+ sleepers.add(finish);
2990
+ });
2991
+ }
2992
+ function interruptForUnload() {
2993
+ for (const wake of [...sleepers]) wake();
2994
+ mintAbort?.abort();
2995
+ }
2996
+ function retryDelay(response, attempt) {
2997
+ const seconds = Number(response.headers?.get?.("Retry-After"));
2998
+ if (Number.isFinite(seconds) && seconds > 0) {
2999
+ return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
3000
+ }
3001
+ return backoff(attempt);
3002
+ }
3003
+ async function mintToken() {
3004
+ if (mintUnavailable || !fetchImpl) return;
3005
+ const controller = typeof AbortController === "function" ? new AbortController() : null;
3006
+ mintAbort = controller;
3007
+ const timeout = controller ? setTimeout(() => controller.abort(), TOKEN_TIMEOUT_MS) : null;
3008
+ let response;
3009
+ try {
3010
+ response = await fetchImpl(mintUrl, {
3011
+ method: "POST",
3012
+ headers: serviceHeaders(),
3013
+ signal: controller?.signal
3014
+ });
3015
+ } catch {
3016
+ if (!terminalRequested) {
3017
+ mintFailures += 1;
3018
+ mintBackoffUntil = now() + backoff(mintFailures);
3019
+ }
3020
+ return;
3021
+ } finally {
3022
+ if (timeout !== null) clearTimeout(timeout);
3023
+ mintAbort = null;
3024
+ }
3025
+ if (response.status === 404 || response.status === 401 || response.status === 403) {
3026
+ mintUnavailable = true;
3027
+ report("token_unavailable", response.status);
3028
+ return;
3029
+ }
3030
+ if (!response.ok) {
3031
+ mintFailures += 1;
3032
+ mintBackoffUntil = now() + backoff(mintFailures);
3033
+ return;
3034
+ }
3035
+ try {
3036
+ const data = await response.json();
3037
+ const value = typeof data.token === "string" ? data.token : "";
3038
+ const expiresAt = Date.parse(String(data.expiresAt));
3039
+ if (!value || Number.isNaN(expiresAt)) throw new Error("malformed");
3040
+ token = { value, expiresAt };
3041
+ mintFailures = 0;
3042
+ mintBackoffUntil = 0;
3043
+ } catch {
3044
+ mintUnavailable = true;
3045
+ report("token_unavailable", response.status);
3046
+ }
3047
+ }
3048
+ async function ensureToken() {
3049
+ if (mintUnavailable) return;
3050
+ if (token && token.expiresAt - now() > TOKEN_REFRESH_MARGIN_MS) return;
3051
+ if (now() < mintBackoffUntil) return;
3052
+ await mintToken();
3053
+ }
3054
+ async function deliver(batch, isTerminal) {
3055
+ if (!fetchImpl) return drop(batch, "unsupported");
3056
+ let attempt = 0;
3057
+ let refreshed = false;
3058
+ let unattributed = false;
3059
+ for (; ; ) {
3060
+ const terminal = isTerminal || terminalRequested;
3061
+ attempt += 1;
3062
+ const headers = {
3063
+ "Content-Type": "application/json"
3064
+ };
3065
+ if (token && !unattributed) headers.Authorization = `Bearer ${token.value}`;
3066
+ let response;
3067
+ try {
3068
+ response = await fetchImpl(ingestUrl, {
3069
+ method: "POST",
3070
+ headers,
3071
+ body: bodyOf(batch),
3072
+ keepalive: true
3073
+ });
3074
+ } catch {
3075
+ if (terminal || attempt >= MAX_ATTEMPTS) {
3076
+ return drop(batch, "network");
3077
+ }
3078
+ await sleep(backoff(attempt));
3079
+ continue;
3080
+ }
3081
+ if (response.ok) return;
3082
+ const status = response.status;
3083
+ if (status === 401) {
3084
+ token = null;
3085
+ if (!refreshed && !terminal) {
3086
+ refreshed = true;
3087
+ await mintToken();
3088
+ if (token) continue;
3089
+ }
3090
+ if (!unattributed) {
3091
+ unattributed = true;
3092
+ continue;
3093
+ }
3094
+ return drop(batch, "unauthorized", status);
3095
+ }
3096
+ if (status === 409) return drop(batch, "conflict", status);
3097
+ if (status === 429 || status >= 500) {
3098
+ if (terminal || attempt >= MAX_ATTEMPTS) {
3099
+ return drop(batch, status === 429 ? "throttled" : "unavailable", status);
3100
+ }
3101
+ await sleep(retryDelay(response, attempt));
3102
+ continue;
3103
+ }
3104
+ return drop(batch, "rejected", status);
3105
+ }
3106
+ }
3107
+ async function run(requestedTerminal) {
3108
+ if (requestedTerminal) terminalRequested = true;
3109
+ if (sending) {
3110
+ if (requestedTerminal) {
3111
+ pendingTerminal = true;
3112
+ interruptForUnload();
3113
+ }
3114
+ return;
3115
+ }
3116
+ sending = true;
3117
+ try {
3118
+ while (queue.length > 0) {
3119
+ const terminal = requestedTerminal || terminalRequested;
3120
+ const batch = takeBatch();
3121
+ if (!terminal) await ensureToken();
3122
+ await deliver(batch, terminal);
3123
+ if (!terminal && disposed) break;
3124
+ }
3125
+ } finally {
3126
+ sending = false;
3127
+ }
3128
+ if (pendingTerminal) {
3129
+ pendingTerminal = false;
3130
+ await run(true);
3131
+ return;
3132
+ }
3133
+ if (!disposed && queue.length === 0) terminalRequested = false;
3134
+ }
3135
+ function clearFlushTimer() {
3136
+ if (timer !== null) {
3137
+ clearTimeout(timer);
3138
+ timer = null;
3139
+ }
3140
+ }
3141
+ function scheduleFlush() {
3142
+ if (timer !== null || disposed) return;
3143
+ timer = setTimeout(() => {
3144
+ timer = null;
3145
+ void run(false);
3146
+ }, FLUSH_DELAY_MS);
3147
+ }
3148
+ return {
3149
+ enqueue(event) {
3150
+ if (disposed) return;
3151
+ queue.push(toWireEvent(event));
3152
+ if (queue.length > MAX_QUEUE) {
3153
+ dropped += queue.length - MAX_QUEUE;
3154
+ queue.splice(0, queue.length - MAX_QUEUE);
3155
+ }
3156
+ if (queue.length >= MAX_BATCH) {
3157
+ clearFlushTimer();
3158
+ void run(false);
3159
+ } else {
3160
+ scheduleFlush();
3161
+ }
3162
+ },
3163
+ flush(flushOptions) {
3164
+ const terminal = flushOptions?.terminal ?? false;
3165
+ if (disposed && !terminal) return;
3166
+ clearFlushTimer();
3167
+ void run(terminal);
3168
+ },
3169
+ dispose() {
3170
+ if (disposed) return;
3171
+ disposed = true;
3172
+ clearFlushTimer();
3173
+ void run(true);
3174
+ }
3175
+ };
3176
+ }
3177
+ function randomUuid() {
3178
+ if (typeof globalThis.crypto?.randomUUID === "function") {
3179
+ return globalThis.crypto.randomUUID();
3180
+ }
3181
+ const bytes = new Uint8Array(16);
3182
+ globalThis.crypto?.getRandomValues?.(bytes);
3183
+ if (!bytes.some(Boolean)) {
3184
+ for (let index = 0; index < bytes.length; index += 1) {
3185
+ bytes[index] = Math.floor(Math.random() * 256);
3186
+ }
3187
+ }
3188
+ bytes[6] = bytes[6] & 15 | 64;
3189
+ bytes[8] = bytes[8] & 63 | 128;
3190
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
3191
+ return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
3192
+ }
3193
+ function resolveProxyOrigin(backendUrl) {
3194
+ if (!backendUrl.trim()) return null;
3195
+ try {
3196
+ const { origin } = new URL(backendUrl, globalThis.location?.href);
3197
+ return origin.startsWith("http") ? origin : null;
3198
+ } catch {
3199
+ return null;
3200
+ }
3201
+ }
3202
+
3203
+ // src/core/analytics.tsx
3204
+ import { jsx as jsx11 } from "react/jsx-runtime";
3205
+ var AnalyticsContext = createContext3(null);
3206
+ var noopDepositEmitter = () => {
3207
+ };
3208
+ var noopWithdrawEmitter = () => {
3209
+ };
3210
+ var noopClaimEmitter = () => {
3211
+ };
3212
+ function cloneAndFreeze(value) {
3213
+ if (Array.isArray(value)) {
3214
+ return Object.freeze(value.map(cloneAndFreeze));
3215
+ }
3216
+ if (value && typeof value === "object") {
3217
+ const clone = Object.fromEntries(
3218
+ Object.entries(value).map(([key, child]) => [key, cloneAndFreeze(child)])
3219
+ );
3220
+ return Object.freeze(clone);
3221
+ }
3222
+ return value;
3223
+ }
3224
+ function AnalyticsSession(props) {
3225
+ const sessionIdRef = useRef3(void 0);
3226
+ if (sessionIdRef.current === void 0) {
3227
+ sessionIdRef.current = (props.createSessionId ?? randomUuid)();
3228
+ }
3229
+ const sessionPropertiesRef = useRef3(void 0);
3230
+ if (sessionPropertiesRef.current === void 0) {
3231
+ sessionPropertiesRef.current = cloneAndFreeze(props.sessionProperties);
3232
+ }
3233
+ const onEventRef = useRef3(props.onEvent);
3234
+ onEventRef.current = props.onEvent;
3235
+ const nowRef = useRef3(props.now ?? (() => /* @__PURE__ */ new Date()));
3236
+ nowRef.current = props.now ?? (() => /* @__PURE__ */ new Date());
3237
+ const modal = props.modal;
3238
+ const reportedFailuresRef = useRef3(/* @__PURE__ */ new Set());
3239
+ const emitFailure = useCallback2(
3240
+ ({ reason, status, droppedEvents }) => {
3241
+ if (reportedFailuresRef.current.has(reason)) return;
3242
+ reportedFailuresRef.current.add(reason);
3243
+ const event = {
3244
+ type: "analytics_ingest_failure",
3245
+ session_id: sessionIdRef.current,
3246
+ modal,
3247
+ widget_version: MODAL_VERSION,
3248
+ timestamp: nowRef.current().toISOString(),
3249
+ reason,
3250
+ ...status === void 0 ? {} : { status },
3251
+ dropped_events: droppedEvents
3252
+ };
3253
+ onEventRef.current?.(event);
3254
+ },
3255
+ [modal]
3256
+ );
3257
+ function createIngest() {
3258
+ if (props.enableIngest === false) {
3259
+ return { transport: null, initialFailure: null };
3260
+ }
3261
+ const proxyOrigin = resolveProxyOrigin(props.backendUrl ?? "");
3262
+ if (!proxyOrigin || typeof globalThis.fetch !== "function") {
3263
+ return {
3264
+ transport: null,
3265
+ initialFailure: { reason: "unsupported", droppedEvents: 0 }
3266
+ };
3267
+ }
3268
+ return {
3269
+ transport: createIngestTransport({
3270
+ ingestUrl: props.ingestUrl ?? DEFAULT_ANALYTICS_INGEST_URL,
3271
+ backendUrl: props.backendUrl,
3272
+ proxyOrigin,
3273
+ sessionId: sessionIdRef.current,
3274
+ modal,
3275
+ widgetVersion: MODAL_VERSION,
3276
+ sessionProperties: sessionPropertiesRef.current,
3277
+ onFailure: (failure) => emitFailure(failure),
3278
+ fetchImpl: props.fetchImpl,
3279
+ createEventId: props.createEventId
3280
+ }),
3281
+ initialFailure: null
3282
+ };
3283
+ }
3284
+ const ingestRef = useRef3(void 0);
3285
+ if (ingestRef.current === void 0) {
3286
+ ingestRef.current = createIngest();
3287
+ }
3288
+ const pendingDisposalRef = useRef3(null);
3289
+ const enqueue = useCallback2(
3290
+ (event) => {
3291
+ try {
3292
+ ingestRef.current?.transport?.enqueue(
3293
+ event
3294
+ );
3295
+ } catch {
3296
+ }
3297
+ },
3298
+ []
3299
+ );
3300
+ useEffect4(() => {
3301
+ if (pendingDisposalRef.current !== null) {
3302
+ clearTimeout(pendingDisposalRef.current);
3303
+ pendingDisposalRef.current = null;
3304
+ }
3305
+ const setup = ingestRef.current;
3306
+ if (setup.initialFailure) emitFailure(setup.initialFailure);
3307
+ const transport = setup.transport;
3308
+ if (!transport) return;
3309
+ const flush = () => transport.flush({ terminal: true });
3310
+ const onVisibilityChange = () => {
3311
+ if (document.visibilityState === "hidden") flush();
3312
+ };
3313
+ window.addEventListener("pagehide", flush);
3314
+ document.addEventListener("visibilitychange", onVisibilityChange);
3315
+ return () => {
3316
+ window.removeEventListener("pagehide", flush);
3317
+ document.removeEventListener("visibilitychange", onVisibilityChange);
3318
+ pendingDisposalRef.current = setTimeout(() => {
3319
+ pendingDisposalRef.current = null;
3320
+ transport.dispose();
3321
+ }, 0);
3322
+ };
3323
+ }, [emitFailure]);
3324
+ const emitDeposit = useCallback2(
3325
+ (...[payload, fundingMethod]) => {
3326
+ if (modal !== "deposit") return;
3327
+ const event = {
3328
+ ...payload,
3329
+ session_id: sessionIdRef.current,
3330
+ modal,
3331
+ widget_version: MODAL_VERSION,
3332
+ timestamp: nowRef.current().toISOString(),
3333
+ session_properties: sessionPropertiesRef.current,
3334
+ funding_method: fundingMethod
3335
+ };
3336
+ onEventRef.current?.(
3337
+ event
3338
+ );
3339
+ enqueue(event);
3340
+ },
3341
+ [enqueue, modal, nowRef, onEventRef]
3342
+ );
3343
+ const emitWithdraw = useCallback2(
3344
+ (payload) => {
3345
+ if (modal !== "withdraw") return;
3346
+ const event = {
3347
+ ...payload,
3348
+ session_id: sessionIdRef.current,
3349
+ modal,
3350
+ widget_version: MODAL_VERSION,
3351
+ timestamp: nowRef.current().toISOString(),
3352
+ session_properties: sessionPropertiesRef.current
3353
+ };
3354
+ onEventRef.current?.(event);
3355
+ enqueue(event);
3356
+ },
3357
+ [enqueue, modal, nowRef, onEventRef]
3358
+ );
3359
+ const emitClaim = useCallback2(
3360
+ (payload) => {
3361
+ if (modal !== "claim") return;
3362
+ const event = {
3363
+ ...payload,
3364
+ session_id: sessionIdRef.current,
3365
+ modal,
3366
+ widget_version: MODAL_VERSION,
3367
+ timestamp: nowRef.current().toISOString(),
3368
+ session_properties: sessionPropertiesRef.current
3369
+ };
3370
+ onEventRef.current?.(event);
3371
+ enqueue(event);
3372
+ },
3373
+ [enqueue, modal, nowRef, onEventRef]
3374
+ );
3375
+ const context = useMemo3(
3376
+ () => modal === "deposit" ? { modal, emit: emitDeposit } : modal === "withdraw" ? { modal, emit: emitWithdraw } : { modal, emit: emitClaim },
3377
+ [modal, emitDeposit, emitWithdraw, emitClaim]
3378
+ );
3379
+ return /* @__PURE__ */ jsx11(AnalyticsContext.Provider, { value: context, children: props.children });
3380
+ }
3381
+ function useDepositAnalyticsEmitter() {
3382
+ const context = useContext3(AnalyticsContext);
3383
+ if (!context || context.modal !== "deposit") return noopDepositEmitter;
3384
+ return context.emit;
3385
+ }
3386
+ function useWithdrawAnalyticsEmitter() {
3387
+ const context = useContext3(AnalyticsContext);
3388
+ if (!context || context.modal !== "withdraw") return noopWithdrawEmitter;
3389
+ return context.emit;
3390
+ }
3391
+ function useClaimAnalyticsEmitter() {
3392
+ const context = useContext3(AnalyticsContext);
3393
+ if (!context || context.modal !== "claim") return noopClaimEmitter;
3394
+ return context.emit;
3395
+ }
3396
+
2878
3397
  // src/core/theme.ts
2879
3398
  var RADIUS_SCALE = {
2880
3399
  none: { sm: "0", md: "0", lg: "0" },
@@ -3139,6 +3658,10 @@ export {
3139
3658
  estimateReceiveAmount,
3140
3659
  formatQuotedReceive,
3141
3660
  formatReceiveEstimate,
3661
+ AnalyticsSession,
3662
+ useDepositAnalyticsEmitter,
3663
+ useWithdrawAnalyticsEmitter,
3664
+ useClaimAnalyticsEmitter,
3142
3665
  resolveThemeMode,
3143
3666
  followSystemAppearance,
3144
3667
  applyTheme,
@@ -1,5 +1,5 @@
1
1
  // src/core/version.ts
2
- var MODAL_VERSION = "0.13.0";
2
+ var MODAL_VERSION = "0.14.0";
3
3
  var SERVICE_HEADERS = {
4
4
  "Content-Type": "application/json",
5
5
  "x-deposit-modal-version": MODAL_VERSION