@capitalos/react 1.4.6-rc.1 → 1.5.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.mts +61 -9
- package/dist/_tsup-dts-rollup.d.ts +61 -9
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -69,6 +69,44 @@ declare type AllowedExitPoints = {
|
|
|
69
69
|
/** @deprecated Use {@link CardsApp} instead */
|
|
70
70
|
export declare const App: typeof CardsApp;
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Renders the CapitalOS Bank Account Selector experience.
|
|
74
|
+
* This component guides users through connecting their bank account via Plaid
|
|
75
|
+
* and returns the account and routing numbers for the selected account.
|
|
76
|
+
*/
|
|
77
|
+
export declare function BankAccountSelector({ onClose, onDone, ...restOfProps }: BankAccountSelectorProps): JSX.Element;
|
|
78
|
+
|
|
79
|
+
export declare type BankAccountSelectorProps = CommonProps & {
|
|
80
|
+
/**
|
|
81
|
+
* Callback to invoke when the user closes the bank account selector screen.
|
|
82
|
+
*/
|
|
83
|
+
onClose: () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Callback to invoke when the bank account selection is completed successfully.
|
|
86
|
+
*
|
|
87
|
+
* @param result - Object containing the bank account and routing numbers
|
|
88
|
+
* @param result.accountNumber - The bank account number
|
|
89
|
+
* @param result.routingNumber - The bank routing number
|
|
90
|
+
* @param result.externalAccountId - The ID of the external account in CapitalOS
|
|
91
|
+
*/
|
|
92
|
+
onDone: (result: BankAccountSelectorResult) => void;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export declare type BankAccountSelectorResult = {
|
|
96
|
+
/**
|
|
97
|
+
* The bank account number
|
|
98
|
+
*/
|
|
99
|
+
accountNumber: string;
|
|
100
|
+
/**
|
|
101
|
+
* The bank routing number
|
|
102
|
+
*/
|
|
103
|
+
routingNumber: string;
|
|
104
|
+
/**
|
|
105
|
+
* The ID of the external account
|
|
106
|
+
*/
|
|
107
|
+
externalAccountId: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
72
110
|
/**
|
|
73
111
|
* Renders the CapitalOS Bill Payment Dashboard experience.
|
|
74
112
|
*/
|
|
@@ -273,7 +311,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
273
311
|
shippedAt: z_2.ZodNullable<z_2.ZodString>;
|
|
274
312
|
trackingUpdates: z_2.ZodArray<z_2.ZodObject<{
|
|
275
313
|
estimatedDeliveryAt: z_2.ZodNullable<z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>>;
|
|
276
|
-
trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "returnedToSender"]>;
|
|
314
|
+
trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "deliveryIssue", "returnedToSender"]>;
|
|
277
315
|
city: z_2.ZodNullable<z_2.ZodString>;
|
|
278
316
|
createdAt: z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>;
|
|
279
317
|
zipcode: z_2.ZodNullable<z_2.ZodString>;
|
|
@@ -283,14 +321,14 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
283
321
|
state: string | null;
|
|
284
322
|
zipcode: string | null;
|
|
285
323
|
estimatedDeliveryAt: string | null;
|
|
286
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
324
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
287
325
|
createdAt: string;
|
|
288
326
|
}, {
|
|
289
327
|
city: string | null;
|
|
290
328
|
state: string | null;
|
|
291
329
|
zipcode: string | null;
|
|
292
330
|
estimatedDeliveryAt: string | Date | null;
|
|
293
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
331
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
294
332
|
createdAt: string | Date;
|
|
295
333
|
}>, "many">;
|
|
296
334
|
status: z_2.ZodEnum<["canceled", "pending", "rejected", "returned", "shipped"]>;
|
|
@@ -314,7 +352,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
314
352
|
state: string | null;
|
|
315
353
|
zipcode: string | null;
|
|
316
354
|
estimatedDeliveryAt: string | null;
|
|
317
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
355
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
318
356
|
createdAt: string;
|
|
319
357
|
}[];
|
|
320
358
|
trackingNumber: string | null;
|
|
@@ -337,7 +375,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
337
375
|
state: string | null;
|
|
338
376
|
zipcode: string | null;
|
|
339
377
|
estimatedDeliveryAt: string | Date | null;
|
|
340
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
378
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
341
379
|
createdAt: string | Date;
|
|
342
380
|
}[];
|
|
343
381
|
trackingNumber: string | null;
|
|
@@ -365,7 +403,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
365
403
|
state: string | null;
|
|
366
404
|
zipcode: string | null;
|
|
367
405
|
estimatedDeliveryAt: string | null;
|
|
368
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
406
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
369
407
|
createdAt: string;
|
|
370
408
|
}[];
|
|
371
409
|
trackingNumber: string | null;
|
|
@@ -392,7 +430,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
392
430
|
state: string | null;
|
|
393
431
|
zipcode: string | null;
|
|
394
432
|
estimatedDeliveryAt: string | Date | null;
|
|
395
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
433
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
396
434
|
createdAt: string | Date;
|
|
397
435
|
}[];
|
|
398
436
|
trackingNumber: string | null;
|
|
@@ -454,7 +492,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
454
492
|
state: string | null;
|
|
455
493
|
zipcode: string | null;
|
|
456
494
|
estimatedDeliveryAt: string | null;
|
|
457
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
495
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
458
496
|
createdAt: string;
|
|
459
497
|
}[];
|
|
460
498
|
trackingNumber: string | null;
|
|
@@ -517,7 +555,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
517
555
|
state: string | null;
|
|
518
556
|
zipcode: string | null;
|
|
519
557
|
estimatedDeliveryAt: string | Date | null;
|
|
520
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
558
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
521
559
|
createdAt: string | Date;
|
|
522
560
|
}[];
|
|
523
561
|
trackingNumber: string | null;
|
|
@@ -1072,6 +1110,14 @@ export declare type ParentFunctions = {
|
|
|
1072
1110
|
policySettings?: {
|
|
1073
1111
|
onClose?: () => void;
|
|
1074
1112
|
};
|
|
1113
|
+
bankAccountSelector?: {
|
|
1114
|
+
onClose?: () => void;
|
|
1115
|
+
onDone?: (result: {
|
|
1116
|
+
accountNumber: string;
|
|
1117
|
+
routingNumber: string;
|
|
1118
|
+
externalAccountId: string;
|
|
1119
|
+
}) => void;
|
|
1120
|
+
};
|
|
1075
1121
|
connectToVendors?: {
|
|
1076
1122
|
onClose?: () => void;
|
|
1077
1123
|
};
|
|
@@ -1266,6 +1312,12 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
1266
1312
|
entryPoint: "connectToVendors";
|
|
1267
1313
|
cardId?: string | undefined;
|
|
1268
1314
|
inlineCardOnFile?: boolean | undefined;
|
|
1315
|
+
}>, z.ZodObject<{
|
|
1316
|
+
entryPoint: z.ZodLiteral<"bankAccountSelector">;
|
|
1317
|
+
}, "strip", z.ZodTypeAny, {
|
|
1318
|
+
entryPoint: "bankAccountSelector";
|
|
1319
|
+
}, {
|
|
1320
|
+
entryPoint: "bankAccountSelector";
|
|
1269
1321
|
}>, z.ZodObject<{
|
|
1270
1322
|
entryPoint: z.ZodLiteral<"insightsDashboard">;
|
|
1271
1323
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -69,6 +69,44 @@ declare type AllowedExitPoints = {
|
|
|
69
69
|
/** @deprecated Use {@link CardsApp} instead */
|
|
70
70
|
export declare const App: typeof CardsApp;
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Renders the CapitalOS Bank Account Selector experience.
|
|
74
|
+
* This component guides users through connecting their bank account via Plaid
|
|
75
|
+
* and returns the account and routing numbers for the selected account.
|
|
76
|
+
*/
|
|
77
|
+
export declare function BankAccountSelector({ onClose, onDone, ...restOfProps }: BankAccountSelectorProps): JSX.Element;
|
|
78
|
+
|
|
79
|
+
export declare type BankAccountSelectorProps = CommonProps & {
|
|
80
|
+
/**
|
|
81
|
+
* Callback to invoke when the user closes the bank account selector screen.
|
|
82
|
+
*/
|
|
83
|
+
onClose: () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Callback to invoke when the bank account selection is completed successfully.
|
|
86
|
+
*
|
|
87
|
+
* @param result - Object containing the bank account and routing numbers
|
|
88
|
+
* @param result.accountNumber - The bank account number
|
|
89
|
+
* @param result.routingNumber - The bank routing number
|
|
90
|
+
* @param result.externalAccountId - The ID of the external account in CapitalOS
|
|
91
|
+
*/
|
|
92
|
+
onDone: (result: BankAccountSelectorResult) => void;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export declare type BankAccountSelectorResult = {
|
|
96
|
+
/**
|
|
97
|
+
* The bank account number
|
|
98
|
+
*/
|
|
99
|
+
accountNumber: string;
|
|
100
|
+
/**
|
|
101
|
+
* The bank routing number
|
|
102
|
+
*/
|
|
103
|
+
routingNumber: string;
|
|
104
|
+
/**
|
|
105
|
+
* The ID of the external account
|
|
106
|
+
*/
|
|
107
|
+
externalAccountId: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
72
110
|
/**
|
|
73
111
|
* Renders the CapitalOS Bill Payment Dashboard experience.
|
|
74
112
|
*/
|
|
@@ -273,7 +311,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
273
311
|
shippedAt: z_2.ZodNullable<z_2.ZodString>;
|
|
274
312
|
trackingUpdates: z_2.ZodArray<z_2.ZodObject<{
|
|
275
313
|
estimatedDeliveryAt: z_2.ZodNullable<z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>>;
|
|
276
|
-
trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "returnedToSender"]>;
|
|
314
|
+
trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "deliveryIssue", "returnedToSender"]>;
|
|
277
315
|
city: z_2.ZodNullable<z_2.ZodString>;
|
|
278
316
|
createdAt: z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>;
|
|
279
317
|
zipcode: z_2.ZodNullable<z_2.ZodString>;
|
|
@@ -283,14 +321,14 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
283
321
|
state: string | null;
|
|
284
322
|
zipcode: string | null;
|
|
285
323
|
estimatedDeliveryAt: string | null;
|
|
286
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
324
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
287
325
|
createdAt: string;
|
|
288
326
|
}, {
|
|
289
327
|
city: string | null;
|
|
290
328
|
state: string | null;
|
|
291
329
|
zipcode: string | null;
|
|
292
330
|
estimatedDeliveryAt: string | Date | null;
|
|
293
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
331
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
294
332
|
createdAt: string | Date;
|
|
295
333
|
}>, "many">;
|
|
296
334
|
status: z_2.ZodEnum<["canceled", "pending", "rejected", "returned", "shipped"]>;
|
|
@@ -314,7 +352,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
314
352
|
state: string | null;
|
|
315
353
|
zipcode: string | null;
|
|
316
354
|
estimatedDeliveryAt: string | null;
|
|
317
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
355
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
318
356
|
createdAt: string;
|
|
319
357
|
}[];
|
|
320
358
|
trackingNumber: string | null;
|
|
@@ -337,7 +375,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
337
375
|
state: string | null;
|
|
338
376
|
zipcode: string | null;
|
|
339
377
|
estimatedDeliveryAt: string | Date | null;
|
|
340
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
378
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
341
379
|
createdAt: string | Date;
|
|
342
380
|
}[];
|
|
343
381
|
trackingNumber: string | null;
|
|
@@ -365,7 +403,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
365
403
|
state: string | null;
|
|
366
404
|
zipcode: string | null;
|
|
367
405
|
estimatedDeliveryAt: string | null;
|
|
368
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
406
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
369
407
|
createdAt: string;
|
|
370
408
|
}[];
|
|
371
409
|
trackingNumber: string | null;
|
|
@@ -392,7 +430,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
392
430
|
state: string | null;
|
|
393
431
|
zipcode: string | null;
|
|
394
432
|
estimatedDeliveryAt: string | Date | null;
|
|
395
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
433
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
396
434
|
createdAt: string | Date;
|
|
397
435
|
}[];
|
|
398
436
|
trackingNumber: string | null;
|
|
@@ -454,7 +492,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
454
492
|
state: string | null;
|
|
455
493
|
zipcode: string | null;
|
|
456
494
|
estimatedDeliveryAt: string | null;
|
|
457
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
495
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
458
496
|
createdAt: string;
|
|
459
497
|
}[];
|
|
460
498
|
trackingNumber: string | null;
|
|
@@ -517,7 +555,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
517
555
|
state: string | null;
|
|
518
556
|
zipcode: string | null;
|
|
519
557
|
estimatedDeliveryAt: string | Date | null;
|
|
520
|
-
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
|
|
558
|
+
trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
|
|
521
559
|
createdAt: string | Date;
|
|
522
560
|
}[];
|
|
523
561
|
trackingNumber: string | null;
|
|
@@ -1072,6 +1110,14 @@ export declare type ParentFunctions = {
|
|
|
1072
1110
|
policySettings?: {
|
|
1073
1111
|
onClose?: () => void;
|
|
1074
1112
|
};
|
|
1113
|
+
bankAccountSelector?: {
|
|
1114
|
+
onClose?: () => void;
|
|
1115
|
+
onDone?: (result: {
|
|
1116
|
+
accountNumber: string;
|
|
1117
|
+
routingNumber: string;
|
|
1118
|
+
externalAccountId: string;
|
|
1119
|
+
}) => void;
|
|
1120
|
+
};
|
|
1075
1121
|
connectToVendors?: {
|
|
1076
1122
|
onClose?: () => void;
|
|
1077
1123
|
};
|
|
@@ -1266,6 +1312,12 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
1266
1312
|
entryPoint: "connectToVendors";
|
|
1267
1313
|
cardId?: string | undefined;
|
|
1268
1314
|
inlineCardOnFile?: boolean | undefined;
|
|
1315
|
+
}>, z.ZodObject<{
|
|
1316
|
+
entryPoint: z.ZodLiteral<"bankAccountSelector">;
|
|
1317
|
+
}, "strip", z.ZodTypeAny, {
|
|
1318
|
+
entryPoint: "bankAccountSelector";
|
|
1319
|
+
}, {
|
|
1320
|
+
entryPoint: "bankAccountSelector";
|
|
1269
1321
|
}>, z.ZodObject<{
|
|
1270
1322
|
entryPoint: z.ZodLiteral<"insightsDashboard">;
|
|
1271
1323
|
}, "strip", z.ZodTypeAny, {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";var Ie=Object.defineProperty,Me=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var ce=(e,n,t)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))de.call(n,t)&&ce(e,t,n[t]);if(W)for(var t of W(n))le.call(n,t)&&ce(e,t,n[t]);return e},p=(e,n)=>Me(e,Oe(n));var k=(e,n)=>{var t={};for(var o in e)de.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&W)for(var o of W(e))n.indexOf(o)<0&&le.call(e,o)&&(t[o]=e[o]);return t};var D=(e,n,t)=>new Promise((o,r)=>{var s=u=>{try{a(t.next(u))}catch(f){r(f)}},i=u=>{try{a(t.throw(u))}catch(f){r(f)}},a=u=>u.done?o(u.value):Promise.resolve(u.value).then(s,i);a((t=t.apply(e,n)).next())});import x,{useMemo as h,useContext as kn}from"react";import B from"react";import $,{createContext as mn,useContext as fn,useState as H,useMemo as Te,useCallback as ie,useEffect as gn}from"react";import Ye,{useMemo as en,useRef as nn,useEffect as tn}from"react";var b=class extends Error{constructor({message:n,code:t}){super(n),this.name="CapitalOSError",this.code=t}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},O=class extends b{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as Be,WindowMessenger as Ue}from"penpal";import{useCallback as Ne,useEffect as F,useMemo as ne,useRef as K,useState as fe}from"react";import{useRef as Ae}from"react";function R(e){let n=Ae(e);return n.current=e,n}var we={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,t=we)=>{try{let o=`${Se}${n}`;t.logger?t.logger[e](o):t.enableLogging&&console[e](o)}catch(o){}}}var j={log:Q("log"),warn:Q("warn"),error:Q("error")};function Y(e){return e?e.length<=12?"***":`${e.substring(0,4)}...${e.substring(e.length-4)}`:"undefined"}function q(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,t,o,r)=>!r||r.length<=12?`${t}${o}=***`:`${t}${o}=${Y(r)}`)}catch(n){return"[URL redacted due to processing error]"}}function ee(e){try{let n=decodeURIComponent(e),t=atob(n);return JSON.parse(t)}catch(n){throw new O}}function V(e){let t=ee(e).path;if(!t||typeof t!="string")throw new O;return{token:e,tokenType:"oneTime",baseUrl:t,paramKey:"token",paramLocation:"search"}}var pe="1.4.6-rc.1";function $e(e){let n=JSON.stringify(e),t=btoa(n);return encodeURIComponent(t)}function He(e){try{return decodeURIComponent(e)}catch(n){return e}}function ue({tokenData:e,renderingContext:n,theme:t,onError:o}){try{let r=n?p(c({},n),{referer:window.location.href}):null,s=r?$e(r):null,i=new URL(e.baseUrl),a=He(e.token);return e.paramLocation==="search"?i.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(i.hash=e.paramKey+"="+encodeURIComponent(a)),i.searchParams.set("sdkVersion",pe),s&&i.searchParams.set("renderingContext",s),t&&i.searchParams.set("theme",t),i.toString()}catch(r){o==null||o(new O);return}}var me=1e4;function _e(e){return(...n)=>{try{let t=n.map(o=>{if(typeof o=="string")return o;if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch(r){return String(o)}}).join(" ");e(t)}catch(t){}}}function te({iframeRef:e,token:n,onError:t,methods:o,iframeLabel:r}){let[s,i]=fe(null),{log:a}=M(),u=R(o),f=R(t),d=R(r),m=ne(()=>_e(a),[a]);return F(()=>{let y=d.current?`[${d.current}] `:"";if(!e.current){a(`${y}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${y}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${y}Establishing Penpal connection to iframe`);let P=!0,E=new Ue({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),g=Be({messenger:E,methods:u.current,timeout:me,log:m});return g.promise.then(()=>{P&&(a(`${y}Penpal connection established successfully`),i(g))}).catch(I=>{var T;P&&(a(`${y}Penpal connection failed: ${I.message}. Timeout: ${me}ms`),(T=f.current)==null||T.call(f,I),i(null))}),()=>{P=!1,a(`${y}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),g.destroy(),i(null)}},[n,a,m]),s}function oe({tokenData:e,renderingContext:n,theme:t,onError:o}){let r=K(o),s=K(n);return ne(()=>{if(e)return ue({tokenData:e,renderingContext:s.current,theme:t,onError:r.current})},[e,t,r,s])}function J(e){let{oneTimeToken:n,enableLogging:t,onError:o,renderingContext:r,theme:s,methods:i}=e,{tokenData:a,error:u,invalidateToken:f}=X(),{log:d,warn:m}=M(t),[y,P]=fe(!1),E=K(null);We(u,o);let g=ne(()=>n?V(n):a,[n,a]);F(()=>{g&&d(`[${r.entryPoint}] Token data available, type: ${g.tokenType}, token: ${Y(g.token)}, location: ${g.paramLocation}, key: ${g.paramKey}, baseUrl: ${g.baseUrl}`)},[g,d,r.entryPoint]);let I=Ne(()=>{if(d("Token expired, invalidating..."),n){o==null||o(new b({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}f(),P(!1)},[d,n,f,o]);F(()=>{n&&a&&m("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,m]);let T=oe({tokenData:g,renderingContext:r,theme:s,onError:o});F(()=>{T?d(`Iframe URL generated: ${q(T).substring(0,1024)}...`):g&&m("Failed to generate iframe URL despite having token data")},[T,g,d,m]);let v=te({iframeRef:E,token:g==null?void 0:g.token,iframeLabel:r.entryPoint,onError:l=>{d(`Connection error: ${l.message}`),o==null||o(l),P(!0)},methods:c({onLoad:()=>{d("Iframe called onLoad()"),P(!0)},onError:l=>{let _=new b(l);d(`Iframe error: ${_.message}`),o==null||o(_)},onTokenExpired:I},i)});return{isLoaded:y,url:T,tokenData:g,iframeRef:E,connection:v}}function We(e,n){let t=K(!1);F(()=>{e&&!t.current&&(n==null||n(e),t.current=!0)},[e,n])}import{iframeResizer as je}from"iframe-resizer";import qe,{forwardRef as Ve,useEffect as Ke,useImperativeHandle as Je,useRef as Xe}from"react";var A=Ve((e,n)=>{let t=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=Qe(e),s=Xe(null);return Ke(()=>{let i=s.current;return je(c({},r),i),()=>i.iFrameResizer&&i.iFrameResizer.removeListeners()}),Je(n,()=>s.current),qe.createElement("iframe",p(c({},o),{title:t,ref:s}))});A.displayName="IframeResizer";var Ze=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Ge=new Set(Ze);function Qe(e){return Object.keys(e).reduce((t,o)=>{let r=e[o];return Ge.has(o)?r!==void 0&&(t.resizerOptions[o]=e[o]):t.iframeHTMLAttributes[o]=e[o],t},{resizerOptions:{},iframeHTMLAttributes:{}})}function ge(e){let{oneTimeToken:n,enableLogging:t,onExchangeComplete:o,onExchangeError:r}=e,s=w(t),{log:i}=M(t),a=nn(null),u=en(()=>V(n),[n]),d=oe({tokenData:u,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return tn(()=>{if(d){let m=q(d),y=m.substring(0,1024),P=m.length>1024;i(`Token exchange iframe URL: ${y}${P?"...":""}`)}},[d,i]),te({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:m=>{i(`Token exchange connection error: ${m.message}`),r==null||r(m)},methods:{onLoad:()=>{i("Token exchange iframe loaded")},onError:m=>{i(`Token exchange iframe error: ${m.message}`),r==null||r(new b(m))},tokenExchange:{onLongLivedToken:m=>{i("Token exchange complete: received long-lived token"),o(m)}}}}),Ye.createElement(A,{src:d,checkOrigin:!1,style:{display:"none"},log:s,ref:a,onLoad:()=>{i("Token exchange iframe HTML loaded successfully")},onError:m=>{i(`Token exchange iframe failed to load: ${m}`)}})}import{useCallback as on,useRef as rn}from"react";function Z(e){let n=rn(e);return n.current=e,on((...t)=>n.current(...t),[])}import z,{createContext as ln,useState as pn,useMemo as ke,useCallback as un}from"react";import sn from"react";import{useMemo as an}from"react";function Ce(u){var f=u,{onDone:e,onCancel:n,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}=f,a=k(f,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let d="mfa",m=an(()=>({entryPoint:d,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}),[d,t,o,r,s,i]);return sn.createElement(C,p(c({},a),{renderingContext:m,methods:{mfa:{onDone:e,onCancel:n}}}))}import xe,{useEffect as cn}from"react";var he={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function ye({onClose:e,children:n,ariaLabel:t="Modal dialog"}){cn(()=>{let r=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let o=r=>{r.target===r.currentTarget&&e()};return xe.createElement("div",{style:he.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":t},xe.createElement("div",{style:he.container},n))}import{useState as dn,useCallback as G}from"react";function Pe(){var f;let[e,n]=dn(null),{log:t}=M(),o=G(d=>(t("MFA requested"),new Promise((m,y)=>{n({context:d,resolve:m,reject:y})})),[t]),r=G(()=>{e&&(t("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,t]),s=G(()=>{e&&(t("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,t]),i=G(d=>{e&&(t("MFA error: "+d.message),e.resolve({success:!1,canceled:!1,error:d}),n(null))},[e,t]),a=!!e,u=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:u,requestMfa:o,handleMfaDone:r,handleMfaCancel:s,handleMfaError:i}}var re=ln(null);function be({children:e}){let[n,t]=pn(null),o=w(),{log:r}=M(),{requestMfa:s,handleMfaDone:i,handleMfaCancel:a,isMfaActive:u,mfaContext:f}=Pe(),d=un(v=>D(null,null,function*(){let l=yield s(v);return l.success?{success:!0}:l.canceled?{success:!1,canceled:!0}:{success:!1,error:l.error.message}}),[s]),m=ke(()=>n?{freezeCard:v=>D(null,null,function*(){try{let l=yield n.freezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}}),unfreezeCard:v=>D(null,null,function*(){try{let l=yield n.unfreezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}})}:null,[n]),y=ke(()=>({"system-messages":{requestMfa:d},mfa:{onDone:i,onCancel:a}}),[d,i,a]),{isLoaded:P,url:E,connection:g,iframeRef:I}=J({renderingContext:{entryPoint:"actions"},methods:y});z.useEffect(()=>{let v=!0;return g&&g.promise.then(l=>{v&&(t(l),r("Actions iframe child functions loaded"))}),()=>{v=!1}},[g,r]);let T=!P||!n;return z.createElement(re.Provider,{value:{childFunctions:n,actions:m,isLoading:T}},e,E&&z.createElement(A,{src:E,style:{display:"none"},checkOrigin:!1,log:o,ref:I,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:v=>{r(`Actions iframe failed to load: ${v}. This may indicate network issues or security policy blocking.`)}}),u&&f&&z.createElement(ye,{onClose:a,ariaLabel:"Multi-factor authentication"},z.createElement(Ce,p(c({mfaId:f.mfaId,destination:f.destination,codeLength:f.codeLength,canResendAfter:f.canResendAfter},f.operationName&&{operationName:f.operationName}),{onDone:i,onCancel:a}))))}var ve=mn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),Cn=({getToken:e,enableLogging:n,logger:t,children:o})=>{let[r,s]=H(void 0),[i,a]=H(void 0),[u,f]=H(void 0),[d,m]=H(!1),[y,P]=H(void 0),E=R(t),g=ie(()=>D(null,null,function*(){m(!0);try{let l=yield e();s(l),P(void 0);let _=ee(l),ae=new URL(_.path);ae.pathname="",a(ae.toString())}catch(l){P(l)}finally{m(!1)}}),[e]),I=ie(()=>{f(void 0)},[]);gn(()=>{u||g()},[u,g]);let T=ie(l=>{f(l),s(void 0),P(void 0)},[]),v=Te(()=>{if(u&&!i)throw new b({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:u?{token:u,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:d,error:y,invalidateToken:I,enableLogging:n!=null?n:!1,loggerRef:E}},[u,d,y,I,i,n]);return $.createElement($.Fragment,null,$.createElement(ve.Provider,{value:v},$.createElement(be,null,o)),r&&!u&&$.createElement(ge,{oneTimeToken:r,onExchangeComplete:T,enableLogging:n,onExchangeError:P}))},X=()=>fn(ve);function w(e){let{enableLogging:n}=X();return e!==void 0?e:n}function M(e){let n=w(e),{loggerRef:t}=X(),o=Z(i=>{var a;j.log(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),r=Z(i=>{var a;j.warn(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),s=Z(i=>{var a;j.error(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})});return Te(()=>({log:o,warn:r,error:s}),[o,r,s])}function C(e){let{token:n,className:t,enableLogging:o,onError:r,loadingComponent:s,renderingContext:i,methods:a,theme:u,sizeWidth:f}=e,d=w(o),{log:m}=M(o),{isLoaded:y,url:P,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:d,onError:r,renderingContext:i,theme:u,methods:a});if(!E||!P)return B.createElement(B.Fragment,null,s||null);let I=i.entryPoint!=="insightsWidget";return B.createElement(B.Fragment,null,!y&&s,B.createElement(A,{src:P,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:t,log:d,ref:g,hidden:!y,onLoad:()=>{m(`Main iframe HTML loaded successfully for entry point: ${i.entryPoint}`)},onError:T=>{m(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!I)return;let v=`${parseInt(T.height)+12}px`;T.iframe.style.height=v},sizeWidth:f}))}import N,{useMemo as xn}from"react";import{useState as hn}from"react";import S,{useState as Le}from"react";var U={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},Ee=()=>S.createElement("svg",{style:U.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},S.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function se({onClick:e,isLoading:n=!1}){let[t,o]=Le(!1),[r,s]=Le(!1),i=c(c(c(c({},U.bugButton),n&&U.loadingButton),!n&&t&&U.bugButtonHover),!n&&r&&U.bugButtonFocus);return n?S.createElement("div",{style:i},S.createElement("style",null,`
|
|
1
|
+
"use client";var Ie=Object.defineProperty,Ae=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var ce=(e,n,t)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))de.call(n,t)&&ce(e,t,n[t]);if(W)for(var t of W(n))le.call(n,t)&&ce(e,t,n[t]);return e},d=(e,n)=>Ae(e,Me(n));var k=(e,n)=>{var t={};for(var o in e)de.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&W)for(var o of W(e))n.indexOf(o)<0&&le.call(e,o)&&(t[o]=e[o]);return t};var D=(e,n,t)=>new Promise((o,r)=>{var s=p=>{try{a(t.next(p))}catch(f){r(f)}},i=p=>{try{a(t.throw(p))}catch(f){r(f)}},a=p=>p.done?o(p.value):Promise.resolve(p.value).then(s,i);a((t=t.apply(e,n)).next())});import x,{useMemo as y,useContext as kn}from"react";import H from"react";import B,{createContext as mn,useContext as fn,useState as $,useMemo as Te,useCallback as ie,useEffect as gn}from"react";import Ye,{useMemo as en,useRef as nn,useEffect as tn}from"react";var b=class extends Error{constructor({message:n,code:t}){super(n),this.name="CapitalOSError",this.code=t}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},M=class extends b{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as He,WindowMessenger as Ue}from"penpal";import{useCallback as Ne,useEffect as F,useMemo as ne,useRef as K,useState as fe}from"react";import{useRef as Oe}from"react";function R(e){let n=Oe(e);return n.current=e,n}var we={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,t=we)=>{try{let o=`${Se}${n}`;t.logger?t.logger[e](o):t.enableLogging&&console[e](o)}catch(o){}}}var j={log:Q("log"),warn:Q("warn"),error:Q("error")};function Y(e){return e?e.length<=12?"***":`${e.substring(0,4)}...${e.substring(e.length-4)}`:"undefined"}function q(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,t,o,r)=>!r||r.length<=12?`${t}${o}=***`:`${t}${o}=${Y(r)}`)}catch(n){return"[URL redacted due to processing error]"}}function ee(e){try{let n=decodeURIComponent(e),t=atob(n);return JSON.parse(t)}catch(n){throw new M}}function V(e){let t=ee(e).path;if(!t||typeof t!="string")throw new M;return{token:e,tokenType:"oneTime",baseUrl:t,paramKey:"token",paramLocation:"search"}}var ue="1.5.0-rc.1";function Be(e){let n=JSON.stringify(e),t=btoa(n);return encodeURIComponent(t)}function $e(e){try{return decodeURIComponent(e)}catch(n){return e}}function pe({tokenData:e,renderingContext:n,theme:t,onError:o}){try{let r=n?d(c({},n),{referer:window.location.href}):null,s=r?Be(r):null,i=new URL(e.baseUrl),a=$e(e.token);return e.paramLocation==="search"?i.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(i.hash=e.paramKey+"="+encodeURIComponent(a)),i.searchParams.set("sdkVersion",ue),s&&i.searchParams.set("renderingContext",s),t&&i.searchParams.set("theme",t),i.toString()}catch(r){o==null||o(new M);return}}var me=1e4;function _e(e){return(...n)=>{try{let t=n.map(o=>{if(typeof o=="string")return o;if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch(r){return String(o)}}).join(" ");e(t)}catch(t){}}}function te({iframeRef:e,token:n,onError:t,methods:o,iframeLabel:r}){let[s,i]=fe(null),{log:a}=A(),p=R(o),f=R(t),l=R(r),m=ne(()=>_e(a),[a]);return F(()=>{let h=l.current?`[${l.current}] `:"";if(!e.current){a(`${h}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${h}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${h}Establishing Penpal connection to iframe`);let P=!0,E=new Ue({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),C=He({messenger:E,methods:p.current,timeout:me,log:m});return C.promise.then(()=>{P&&(a(`${h}Penpal connection established successfully`),i(C))}).catch(I=>{var T;P&&(a(`${h}Penpal connection failed: ${I.message}. Timeout: ${me}ms`),(T=f.current)==null||T.call(f,I),i(null))}),()=>{P=!1,a(`${h}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),C.destroy(),i(null)}},[n,a,m]),s}function oe({tokenData:e,renderingContext:n,theme:t,onError:o}){let r=K(o),s=K(n);return ne(()=>{if(e)return pe({tokenData:e,renderingContext:s.current,theme:t,onError:r.current})},[e,t,r,s])}function J(e){let{oneTimeToken:n,enableLogging:t,onError:o,renderingContext:r,theme:s,methods:i}=e,{tokenData:a,error:p,invalidateToken:f}=X(),{log:l,warn:m}=A(t),[h,P]=fe(!1),E=K(null);We(p,o);let C=ne(()=>n?V(n):a,[n,a]);F(()=>{C&&l(`[${r.entryPoint}] Token data available, type: ${C.tokenType}, token: ${Y(C.token)}, location: ${C.paramLocation}, key: ${C.paramKey}, baseUrl: ${C.baseUrl}`)},[C,l,r.entryPoint]);let I=Ne(()=>{if(l("Token expired, invalidating..."),n){o==null||o(new b({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}f(),P(!1)},[l,n,f,o]);F(()=>{n&&a&&m("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,m]);let T=oe({tokenData:C,renderingContext:r,theme:s,onError:o});F(()=>{T?l(`Iframe URL generated: ${q(T).substring(0,1024)}...`):C&&m("Failed to generate iframe URL despite having token data")},[T,C,l,m]);let v=te({iframeRef:E,token:C==null?void 0:C.token,iframeLabel:r.entryPoint,onError:u=>{l(`Connection error: ${u.message}`),o==null||o(u),P(!0)},methods:c({onLoad:()=>{l("Iframe called onLoad()"),P(!0)},onError:u=>{let _=new b(u);l(`Iframe error: ${_.message}`),o==null||o(_)},onTokenExpired:I},i)});return{isLoaded:h,url:T,tokenData:C,iframeRef:E,connection:v}}function We(e,n){let t=K(!1);F(()=>{e&&!t.current&&(n==null||n(e),t.current=!0)},[e,n])}import{iframeResizer as je}from"iframe-resizer";import qe,{forwardRef as Ve,useEffect as Ke,useImperativeHandle as Je,useRef as Xe}from"react";var O=Ve((e,n)=>{let t=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=Qe(e),s=Xe(null);return Ke(()=>{let i=s.current;return je(c({},r),i),()=>i.iFrameResizer&&i.iFrameResizer.removeListeners()}),Je(n,()=>s.current),qe.createElement("iframe",d(c({},o),{title:t,ref:s}))});O.displayName="IframeResizer";var Ze=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Ge=new Set(Ze);function Qe(e){return Object.keys(e).reduce((t,o)=>{let r=e[o];return Ge.has(o)?r!==void 0&&(t.resizerOptions[o]=e[o]):t.iframeHTMLAttributes[o]=e[o],t},{resizerOptions:{},iframeHTMLAttributes:{}})}function ge(e){let{oneTimeToken:n,enableLogging:t,onExchangeComplete:o,onExchangeError:r}=e,s=w(t),{log:i}=A(t),a=nn(null),p=en(()=>V(n),[n]),l=oe({tokenData:p,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return tn(()=>{if(l){let m=q(l),h=m.substring(0,1024),P=m.length>1024;i(`Token exchange iframe URL: ${h}${P?"...":""}`)}},[l,i]),te({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:m=>{i(`Token exchange connection error: ${m.message}`),r==null||r(m)},methods:{onLoad:()=>{i("Token exchange iframe loaded")},onError:m=>{i(`Token exchange iframe error: ${m.message}`),r==null||r(new b(m))},tokenExchange:{onLongLivedToken:m=>{i("Token exchange complete: received long-lived token"),o(m)}}}}),Ye.createElement(O,{src:l,checkOrigin:!1,style:{display:"none"},log:s,ref:a,onLoad:()=>{i("Token exchange iframe HTML loaded successfully")},onError:m=>{i(`Token exchange iframe failed to load: ${m}`)}})}import{useCallback as on,useRef as rn}from"react";function Z(e){let n=rn(e);return n.current=e,on((...t)=>n.current(...t),[])}import z,{createContext as ln,useState as un,useMemo as ke,useCallback as pn}from"react";import sn from"react";import{useMemo as an}from"react";function Ce(p){var f=p,{onDone:e,onCancel:n,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}=f,a=k(f,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let l="mfa",m=an(()=>({entryPoint:l,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}),[l,t,o,r,s,i]);return sn.createElement(g,d(c({},a),{renderingContext:m,methods:{mfa:{onDone:e,onCancel:n}}}))}import xe,{useEffect as cn}from"react";var ye={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function he({onClose:e,children:n,ariaLabel:t="Modal dialog"}){cn(()=>{let r=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let o=r=>{r.target===r.currentTarget&&e()};return xe.createElement("div",{style:ye.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":t},xe.createElement("div",{style:ye.container},n))}import{useState as dn,useCallback as G}from"react";function Pe(){var f;let[e,n]=dn(null),{log:t}=A(),o=G(l=>(t("MFA requested"),new Promise((m,h)=>{n({context:l,resolve:m,reject:h})})),[t]),r=G(()=>{e&&(t("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,t]),s=G(()=>{e&&(t("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,t]),i=G(l=>{e&&(t("MFA error: "+l.message),e.resolve({success:!1,canceled:!1,error:l}),n(null))},[e,t]),a=!!e,p=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:p,requestMfa:o,handleMfaDone:r,handleMfaCancel:s,handleMfaError:i}}var re=ln(null);function be({children:e}){let[n,t]=un(null),o=w(),{log:r}=A(),{requestMfa:s,handleMfaDone:i,handleMfaCancel:a,isMfaActive:p,mfaContext:f}=Pe(),l=pn(v=>D(null,null,function*(){let u=yield s(v);return u.success?{success:!0}:u.canceled?{success:!1,canceled:!0}:{success:!1,error:u.error.message}}),[s]),m=ke(()=>n?{freezeCard:v=>D(null,null,function*(){try{let u=yield n.freezeCard(v);return u.success?{success:!0,canceled:!1,data:u.data}:u.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}}),unfreezeCard:v=>D(null,null,function*(){try{let u=yield n.unfreezeCard(v);return u.success?{success:!0,canceled:!1,data:u.data}:u.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}})}:null,[n]),h=ke(()=>({"system-messages":{requestMfa:l},mfa:{onDone:i,onCancel:a}}),[l,i,a]),{isLoaded:P,url:E,connection:C,iframeRef:I}=J({renderingContext:{entryPoint:"actions"},methods:h});z.useEffect(()=>{let v=!0;return C&&C.promise.then(u=>{v&&(t(u),r("Actions iframe child functions loaded"))}),()=>{v=!1}},[C,r]);let T=!P||!n;return z.createElement(re.Provider,{value:{childFunctions:n,actions:m,isLoading:T}},e,E&&z.createElement(O,{src:E,style:{display:"none"},checkOrigin:!1,log:o,ref:I,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:v=>{r(`Actions iframe failed to load: ${v}. This may indicate network issues or security policy blocking.`)}}),p&&f&&z.createElement(he,{onClose:a,ariaLabel:"Multi-factor authentication"},z.createElement(Ce,d(c({mfaId:f.mfaId,destination:f.destination,codeLength:f.codeLength,canResendAfter:f.canResendAfter},f.operationName&&{operationName:f.operationName}),{onDone:i,onCancel:a}))))}var ve=mn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),Cn=({getToken:e,enableLogging:n,logger:t,children:o})=>{let[r,s]=$(void 0),[i,a]=$(void 0),[p,f]=$(void 0),[l,m]=$(!1),[h,P]=$(void 0),E=R(t),C=ie(()=>D(null,null,function*(){m(!0);try{let u=yield e();s(u),P(void 0);let _=ee(u),ae=new URL(_.path);ae.pathname="",a(ae.toString())}catch(u){P(u)}finally{m(!1)}}),[e]),I=ie(()=>{f(void 0)},[]);gn(()=>{p||C()},[p,C]);let T=ie(u=>{f(u),s(void 0),P(void 0)},[]),v=Te(()=>{if(p&&!i)throw new b({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:p?{token:p,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:l,error:h,invalidateToken:I,enableLogging:n!=null?n:!1,loggerRef:E}},[p,l,h,I,i,n]);return B.createElement(B.Fragment,null,B.createElement(ve.Provider,{value:v},B.createElement(be,null,o)),r&&!p&&B.createElement(ge,{oneTimeToken:r,onExchangeComplete:T,enableLogging:n,onExchangeError:P}))},X=()=>fn(ve);function w(e){let{enableLogging:n}=X();return e!==void 0?e:n}function A(e){let n=w(e),{loggerRef:t}=X(),o=Z(i=>{var a;j.log(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),r=Z(i=>{var a;j.warn(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),s=Z(i=>{var a;j.error(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})});return Te(()=>({log:o,warn:r,error:s}),[o,r,s])}function g(e){let{token:n,className:t,enableLogging:o,onError:r,loadingComponent:s,renderingContext:i,methods:a,theme:p,sizeWidth:f}=e,l=w(o),{log:m}=A(o),{isLoaded:h,url:P,tokenData:E,iframeRef:C}=J({oneTimeToken:n,enableLogging:l,onError:r,renderingContext:i,theme:p,methods:a});if(!E||!P)return H.createElement(H.Fragment,null,s||null);let I=i.entryPoint!=="insightsWidget";return H.createElement(H.Fragment,null,!h&&s,H.createElement(O,{src:P,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:t,log:l,ref:C,hidden:!h,onLoad:()=>{m(`Main iframe HTML loaded successfully for entry point: ${i.entryPoint}`)},onError:T=>{m(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!I)return;let v=`${parseInt(T.height)+12}px`;T.iframe.style.height=v},sizeWidth:f}))}import N,{useMemo as xn}from"react";import{useState as yn}from"react";import S,{useState as Le}from"react";var U={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},Ee=()=>S.createElement("svg",{style:U.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},S.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function se({onClick:e,isLoading:n=!1}){let[t,o]=Le(!1),[r,s]=Le(!1),i=c(c(c(c({},U.bugButton),n&&U.loadingButton),!n&&t&&U.bugButtonHover),!n&&r&&U.bugButtonFocus);return n?S.createElement("div",{style:i},S.createElement("style",null,`
|
|
2
2
|
@keyframes pulse {
|
|
3
3
|
0%, 100% {
|
|
4
4
|
opacity: 1;
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
opacity: 0.4;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`),S.createElement(Ee,null)):S.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:i,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>s(!0),onBlur:()=>s(!1)},S.createElement(Ee,null))}var
|
|
10
|
+
`),S.createElement(Ee,null)):S.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:i,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>s(!0),onBlur:()=>s(!1)},S.createElement(Ee,null))}var hn={panel:{position:"fixed",bottom:"20px",left:"20px",zIndex:50}};function Pn(e){let n="devTools",t=xn(()=>({entryPoint:n}),[n]),[o,r]=yn(!1);return N.createElement("aside",{"aria-label":"CapitalOS dev tools"},!o&&N.createElement(se,{onClick:()=>r(!o)}),o&&N.createElement("div",{style:hn.panel},N.createElement(g,d(c({},e),{renderingContext:t,methods:{devTools:{onClose:()=>r(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:N.createElement(se,{isLoading:!0})}))))}function bn(e){let n="cardsApp",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}var xo=bn;function yo(s){var i=s,{cardholder:e,onCreate:n,onDone:t,onCancel:o}=i,r=k(i,["cardholder","onCreate","onDone","onCancel"]);let a="createCard",p=y(()=>({entryPoint:a,cardholder:e}),[e]);return x.createElement(g,d(c({},r),{renderingContext:p,methods:{createCard:d(c({},n?{onCreate:n}:{}),{onDone:t,onCancel:o})}}))}function ho(r){var s=r,{transactionId:e,onDone:n,onCancel:t}=s,o=k(s,["transactionId","onDone","onCancel"]);let i="createDispute",a=y(()=>({entryPoint:i,transactionId:e}),[e]);return x.createElement(g,d(c({},o),{renderingContext:a,methods:{createDispute:{onDone:n,onCancel:t}}}))}function Po(e){let n="billPayApp",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}function ko(e){let n="demoBillPayApp",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}function bo(e){let i=e,{onCardCanceled:n,onHideSensitiveDetails:t}=i,o=k(i,["onCardCanceled","onHideSensitiveDetails"]),r="cardDetails",s=y(()=>({entryPoint:r,cardId:e.cardId,cardOnly:e.cardOnly,backOnly:e.backOnly,hideAddress:e.hideAddress}),[r,e.cardId,e.cardOnly,e.backOnly,e.hideAddress]);return x.createElement(g,d(c({},o),{renderingContext:s,methods:{cardDetails:{onCardCanceled:n!=null?n:()=>{},onHideSensitiveDetails:t!=null?t:()=>{}}}}))}function To(e){let n="accountDetails",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}function vo(e){let n="accountActions",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}function Lo(t){var o=t,{onClose:e}=o,n=k(o,["onClose"]);let r="manageBankConnections",s=y(()=>({entryPoint:r}),[r]);return x.createElement(g,d(c({},n),{renderingContext:s,methods:{manageBankConnections:{onClose:e}}}))}function Eo(t){var o=t,{onClose:e}=o,n=k(o,["onClose"]);let r="configureAutoPay",s=y(()=>({entryPoint:r}),[r]);return x.createElement(g,d(c({},n),{renderingContext:s,methods:{configureAutoPay:{onClose:e}}}))}function Io(t){var o=t,{onClose:e}=o,n=k(o,["onClose"]);let r="policySettings",s=y(()=>({entryPoint:r}),[r]);return x.createElement(g,d(c({},n),{renderingContext:s,methods:{policySettings:{onClose:e}}}))}function Ao(r){var s=r,{cardId:e,onClose:n,inlineCardOnFile:t}=s,o=k(s,["cardId","onClose","inlineCardOnFile"]);let i="connectToVendors",a=y(()=>({entryPoint:i,cardId:e,inlineCardOnFile:t}),[i,e,t]);return x.createElement(g,d(c({},o),{renderingContext:a,methods:{connectToVendors:{onClose:n}}}))}function Mo(o){var r=o,{onClose:e,onDone:n}=r,t=k(r,["onClose","onDone"]);let s="bankAccountSelector",i=y(()=>({entryPoint:s}),[s]);return x.createElement(g,d(c({},t),{renderingContext:i,methods:{bankAccountSelector:{onClose:e,onDone:n}}}))}function Oo(e){let n="insightsDashboard",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}function wo(e){let n="insightsWidget",{widget:t,hideTitle:o,height:r,width:s}=e,i=y(()=>({entryPoint:n,widget:t,hideTitle:o,height:r,width:s}),[n,t,o,r,s]);return x.createElement(g,d(c({},e),{renderingContext:i}))}function So(s){var i=s,{onDone:e,entryPoint:n,exitPoint:t,allowExitOnNonApproved:o}=i,r=k(i,["onDone","entryPoint","exitPoint","allowExitOnNonApproved"]);let a="onboarding",p=y(()=>({entryPoint:a,onboardingEntryPoint:n,onboardingExitPoint:t,allowExitOnNonApproved:o}),[a,n,t,o]);return x.createElement(g,d(c({},r),{renderingContext:p,methods:{onboarding:{onDone:e}}}))}function Do(t){var o=t,{onDone:e}=o,n=k(o,["onDone"]);let r="makePayment",s=y(()=>({entryPoint:r}),[r]);return x.createElement(g,d(c({},n),{renderingContext:s,methods:{makePayment:{onDone:e}}}))}function Ro(o){var r=o,{onDone:e,onCancel:n}=r,t=k(r,["onDone","onCancel"]);let s="contactSupport",i=y(()=>({entryPoint:s}),[s]);return x.createElement(g,d(c({},t),{renderingContext:i,methods:{contactSupport:{onDone:e,onCancel:n}}}))}function Fo(t){var o=t,{onDone:e}=o,n=k(o,["onDone"]);let r="statements",s=y(()=>({entryPoint:r}),[r]);return x.createElement(g,d(c({},n),{renderingContext:s,methods:{statements:{onDone:e}}}))}function zo(t){var o=t,{onDone:e}=o,n=k(o,["onDone"]);let r="legalDocuments",s=y(()=>({entryPoint:r}),[r]);return x.createElement(g,d(c({},n),{renderingContext:s,methods:{legalDocuments:{onDone:e}}}))}function Bo(r){var s=r,{cardId:e,onDone:n,onClose:t}=s,o=k(s,["cardId","onDone","onClose"]);let i="replaceCard",a=y(()=>({entryPoint:i,cardId:e}),[e]);return x.createElement(g,d(c({},o),{renderingContext:a,methods:{replaceCard:{onDone:n,onClose:t}}}))}function $o(r){var s=r,{cardId:e,onDone:n,onClose:t}=s,o=k(s,["cardId","onDone","onClose"]);let i="terminateCard",a=y(()=>({entryPoint:i,cardId:e}),[e]);return x.createElement(g,d(c({},o),{renderingContext:a,methods:{terminateCard:{onDone:n,onClose:t}}}))}function Ho(e){let n="transactions",t=y(()=>({entryPoint:n}),[n]);return x.createElement(g,d(c({},e),{renderingContext:t}))}function Uo(){let e=kn(re);if(!e)throw new b({message:"useActions must be used within a CapitalOsAuthenticationProvider",code:L.internal_error});let{childFunctions:n,isLoading:t}=e;return{actions:n,isLoading:t}}export{vo as AccountActions,To as AccountDetails,xo as App,Mo as BankAccountSelector,Po as BillPayApp,Cn as CapitalOsAuthenticationProvider,bo as CardDetails,bn as CardsApp,Eo as ConfigureAutoPay,Ao as ConnectToVendors,Ro as ContactSupport,ko as DemoBillPayApp,Pn as DevTools,ho as DisputeTransaction,Oo as InsightsDashboard,wo as InsightsWidget,yo as IssueCard,zo as LegalDocuments,Do as MakePayment,Lo as ManageBankConnections,So as Onboarding,Io as PolicySettings,Bo as ReplaceCard,Fo as Statements,$o as TerminateCard,Ho as Transactions,Uo as useActions};
|
|
11
11
|
//# sourceMappingURL=index.js.map
|