@1interface/chat-shell 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExportResult-eb4TcH7k.cjs +1 -0
- package/dist/ExportResult-vKWGlZZX.js +1 -0
- package/dist/NoopLogger-B-ce52_l.cjs +1 -0
- package/dist/NoopLogger-aeNt0r6v.js +1 -0
- package/dist/PaymentProviderHost-BeHcCUZx.js +1 -0
- package/dist/PaymentProviderHost-Dph4wPYb.cjs +1 -0
- package/dist/ResourceImpl-DPkc_ob9.js +1 -0
- package/dist/ResourceImpl-yQJWLZDn.cjs +1 -0
- package/dist/assets/Orb_logo.webp +0 -0
- package/dist/assets/hamburger-icon.png +0 -0
- package/dist/chat-shell.css +1 -0
- package/dist/diag-api-BepQpXrk.js +1 -0
- package/dist/diag-api-DsVI4ljU.cjs +1 -0
- package/dist/index-32QtQw41.cjs +1 -0
- package/dist/index-65-Yxkqs.cjs +1 -0
- package/dist/index-AAKj44J6.cjs +1 -0
- package/dist/index-AVWXcG-i.js +1 -0
- package/dist/index-BQf9Yax1.js +1 -0
- package/dist/index-Bs9yNhX-.js +1 -0
- package/dist/index-CS2Ktaql.cjs +1 -0
- package/dist/index-CwetZEW6.js +1 -0
- package/dist/index-_NPuwCXg.js +1 -0
- package/dist/index-iR-pnjyZ.cjs +1 -0
- package/dist/index.d.ts +413 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/native/assets/Orb_logo.webp +0 -0
- package/native/assets/hamburger-icon.png +0 -0
- package/native/hooks/useOAuthBrowser.native.js +1 -0
- package/native/index.js +1 -0
- package/native/index.native.js +1 -0
- package/native/payment/PaymentProvider.js +1 -0
- package/native/payment/PaymentProviderHost.js +1 -0
- package/native/payment/PaymentProviderHostLazy.js +1 -0
- package/native/payment/PaymentResultChannel.js +1 -0
- package/native/payment/adapters/ChargebeePaymentAdapter.js +83 -0
- package/native/payment/adapters/MoyasarPaymentAdapter.js +1 -0
- package/native/payment/adapters/StripePaymentAdapter.js +1 -0
- package/native/payment/adapters/chargebeeModalSize.js +1 -0
- package/native/payment/adapters/index.js +1 -0
- package/native/payment/adapters/moyasar/ApplePayButton.js +12 -0
- package/native/payment/adapters/moyasar/CardBrandIcon.js +1 -0
- package/native/payment/adapters/moyasar/CustomCardForm.js +1 -0
- package/native/payment/adapters/moyasar/Moyasar3DSIframe.js +1 -0
- package/native/payment/adapters/moyasar/api.js +1 -0
- package/native/payment/adapters/moyasar/applePayApi.js +1 -0
- package/native/payment/adapters/moyasar/cardValidation.js +1 -0
- package/native/payment/adapters/moyasar/constants.js +1 -0
- package/native/payment/adapters/moyasar/index.js +1 -0
- package/native/payment/adapters/moyasar/metadata.js +1 -0
- package/native/payment/adapters/moyasar/useApplePaySupported.js +1 -0
- package/native/payment/adapters/stripe/appearance.js +1 -0
- package/native/payment/adapters/stripe/index.js +1 -0
- package/native/payment/adapters/stripe/providerWrapper.js +1 -0
- package/native/payment/createPaymentAdapter.js +1 -0
- package/native/payment/index.js +1 -0
- package/native/protocol/ProtocolProvider.js +1 -0
- package/native/providers/BrandingProvider.js +1 -0
- package/native/providers/BrandingProvider.native.js +1 -0
- package/native/providers/ChatCallbacksProvider.js +1 -0
- package/native/providers/ChatClientProvider.js +1 -0
- package/native/providers/ConfigurationProvider.js +1 -0
- package/native/providers/MessageContextProvider.js +1 -0
- package/native/providers/SessionInitializer.js +1 -0
- package/native/providers/SettingsProvider.js +1 -0
- package/native/providers/StorageProvider.js +1 -0
- package/native/store/index.js +1 -0
- package/package.json +98 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { Action } from '@reduxjs/toolkit';
|
|
2
|
+
import { AppBrandingResponse } from '@1interface/shared-core';
|
|
3
|
+
import { AppearanceMode } from '@1interface/shared-core';
|
|
4
|
+
import { AudioPlatform } from '@1interface/voice-core';
|
|
5
|
+
import { AuthState } from '@1interface/shared-core';
|
|
6
|
+
import { BaseQueryFn } from '@reduxjs/toolkit/query';
|
|
7
|
+
import { ChatProps } from '@1interface/chat-core';
|
|
8
|
+
import { ChatSettings } from '@1interface/chat-core';
|
|
9
|
+
import { ChatThemeStyles } from '@1interface/shared-core';
|
|
10
|
+
import { ClientConfigResponse } from '@1interface/chat-core';
|
|
11
|
+
import { CombinedState } from '@reduxjs/toolkit/query';
|
|
12
|
+
import { default as default_2 } from 'react';
|
|
13
|
+
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
14
|
+
import { ExtraHydration } from '@1interface/shared-core';
|
|
15
|
+
import { FetchArgs } from '@reduxjs/toolkit/query';
|
|
16
|
+
import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
17
|
+
import { MutationDefinition } from '@reduxjs/toolkit/query';
|
|
18
|
+
import { NetworkMonitor } from '@1interface/shared-core';
|
|
19
|
+
import { PaymentInitPayload } from '@1interface/shared-core';
|
|
20
|
+
import { PaymentResult } from '@1interface/chat-core';
|
|
21
|
+
import { Profile } from '@1interface/chat-core';
|
|
22
|
+
import { ProtocolType } from '@1interface/chat-core';
|
|
23
|
+
import { QueryDefinition } from '@reduxjs/toolkit/query';
|
|
24
|
+
import { ReactNode } from 'react';
|
|
25
|
+
import { Reducer } from '@reduxjs/toolkit';
|
|
26
|
+
import { Storage as Storage_2 } from '@1interface/shared-core';
|
|
27
|
+
import { StoreEnhancer } from '@reduxjs/toolkit';
|
|
28
|
+
import { SttImplementation } from '@1interface/shared-core';
|
|
29
|
+
import { ThunkDispatch } from '@reduxjs/toolkit';
|
|
30
|
+
import { ToolServer } from '@1interface/chat-core';
|
|
31
|
+
import { Tuple } from '@reduxjs/toolkit';
|
|
32
|
+
import { UnknownAction } from '@reduxjs/toolkit';
|
|
33
|
+
import { UnsubscribeListener } from '@reduxjs/toolkit';
|
|
34
|
+
import { UpdateProfilePayload } from '@1interface/chat-core';
|
|
35
|
+
import { VoiceState } from '@1interface/voice-core';
|
|
36
|
+
|
|
37
|
+
export declare type AppDispatch = typeof store.dispatch;
|
|
38
|
+
|
|
39
|
+
export declare const BrandingProvider: default_2.FC<BrandingProviderProps>;
|
|
40
|
+
|
|
41
|
+
declare interface BrandingProviderProps {
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
orgId?: string | null;
|
|
44
|
+
fallbackThemeStyles?: ChatThemeStyles | null;
|
|
45
|
+
initialAppearanceMode?: AppearanceMode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare const ChatClientProvider: default_2.FC<ChatClientProviderProps>;
|
|
49
|
+
|
|
50
|
+
export declare interface ChatClientProviderProps extends Pick<ChatProps, "baseUrl" | "customHeaders" | "token" | "user" | "protocol" | "paymentProvider" | "onConversationChange" | "onConversationTitleChange" | "onMessagesChange" | "onLogoutRequested" | "onSessionExpired"> {
|
|
51
|
+
storage?: Storage_2;
|
|
52
|
+
storageFallback?: ReactNode;
|
|
53
|
+
extraHydrations?: ExtraHydration[];
|
|
54
|
+
orgId?: string;
|
|
55
|
+
initialThemeStyles?: ChatThemeStyles | null;
|
|
56
|
+
initialAppearanceMode?: AppearanceMode;
|
|
57
|
+
audioPlatform?: AudioPlatform;
|
|
58
|
+
networkMonitor?: NetworkMonitor;
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare const MessageContextProvider: React.FC<MessageContextProviderProps>;
|
|
63
|
+
|
|
64
|
+
declare interface MessageContextProviderProps {
|
|
65
|
+
children: ReactNode;
|
|
66
|
+
messageId?: string;
|
|
67
|
+
isDisabled?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare interface MessageContextType {
|
|
71
|
+
messageContext: Record<string, unknown>;
|
|
72
|
+
setMessageContext: (context: Record<string, unknown>) => void;
|
|
73
|
+
updateMessageContext: (key: string, value: unknown) => void;
|
|
74
|
+
messageId?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare const PaymentProviderHost: default_2.FC<PaymentProviderHostProps>;
|
|
78
|
+
|
|
79
|
+
export declare interface PaymentProviderHostProps {
|
|
80
|
+
provider?: string;
|
|
81
|
+
paymentInit?: PaymentInitPayload | null;
|
|
82
|
+
onResult?: (result: PaymentResult) => void;
|
|
83
|
+
conversationId?: string | null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare const preloadPaymentModal: () => Promise<unknown>;
|
|
87
|
+
|
|
88
|
+
export declare const rootReducer: Reducer< {
|
|
89
|
+
auth: AuthState;
|
|
90
|
+
chat: {
|
|
91
|
+
isAgentWorking: boolean;
|
|
92
|
+
statusText: string | null;
|
|
93
|
+
responseStartTime: number | null;
|
|
94
|
+
messageQueue: {
|
|
95
|
+
id: string;
|
|
96
|
+
text: string;
|
|
97
|
+
queuedAt: string;
|
|
98
|
+
}[];
|
|
99
|
+
};
|
|
100
|
+
conversations: {
|
|
101
|
+
activeConversationId: string | null;
|
|
102
|
+
titles: {
|
|
103
|
+
[x: string]: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
voice: VoiceState;
|
|
107
|
+
indicator: {
|
|
108
|
+
lastResponseTime: number | null;
|
|
109
|
+
};
|
|
110
|
+
chatApi: CombinedState< {
|
|
111
|
+
getConversationHistory: QueryDefinition< {
|
|
112
|
+
skip?: number;
|
|
113
|
+
limit?: number;
|
|
114
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
115
|
+
conversations: any[];
|
|
116
|
+
}, "chatApi", unknown>;
|
|
117
|
+
getConversationById: QueryDefinition< {
|
|
118
|
+
conversationId: string;
|
|
119
|
+
skip?: number;
|
|
120
|
+
limit?: number;
|
|
121
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
122
|
+
createConversatons: MutationDefinition< {
|
|
123
|
+
protocol: ProtocolType;
|
|
124
|
+
body?: any;
|
|
125
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
126
|
+
transcribeAudio: MutationDefinition< {
|
|
127
|
+
audioFile: File;
|
|
128
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
129
|
+
success: boolean;
|
|
130
|
+
data: {
|
|
131
|
+
text: string;
|
|
132
|
+
filename?: string;
|
|
133
|
+
};
|
|
134
|
+
}, "chatApi", unknown>;
|
|
135
|
+
getToolServers: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
136
|
+
tool_servers: ToolServer[];
|
|
137
|
+
}, "chatApi", unknown>;
|
|
138
|
+
startToolServerOAuth: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
139
|
+
authorize_url: string;
|
|
140
|
+
}, "chatApi", unknown>;
|
|
141
|
+
deleteToolServerConnection: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
142
|
+
exchangeOAuthCode: MutationDefinition< {
|
|
143
|
+
code: string;
|
|
144
|
+
state: string;
|
|
145
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
146
|
+
deleteConversation: MutationDefinition< {
|
|
147
|
+
conversationId: string;
|
|
148
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
149
|
+
}, "chat" | "toolServers", "chatApi">;
|
|
150
|
+
brandingApi: CombinedState< {
|
|
151
|
+
getBranding: QueryDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, AppBrandingResponse, "brandingApi", unknown>;
|
|
152
|
+
}, never, "brandingApi">;
|
|
153
|
+
configApi: CombinedState< {
|
|
154
|
+
getConfig: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, ClientConfigResponse, "configApi", unknown>;
|
|
155
|
+
}, never, "configApi">;
|
|
156
|
+
profileApi: CombinedState< {
|
|
157
|
+
getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", Profile, "profileApi", unknown>;
|
|
158
|
+
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
159
|
+
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
160
|
+
}, "profile", "profileApi">;
|
|
161
|
+
}, UnknownAction, Partial<{
|
|
162
|
+
auth: AuthState;
|
|
163
|
+
chat: {
|
|
164
|
+
isAgentWorking: boolean;
|
|
165
|
+
statusText: string | null;
|
|
166
|
+
responseStartTime: number | null;
|
|
167
|
+
messageQueue: {
|
|
168
|
+
id: string;
|
|
169
|
+
text: string;
|
|
170
|
+
queuedAt: string;
|
|
171
|
+
}[];
|
|
172
|
+
};
|
|
173
|
+
conversations: {
|
|
174
|
+
activeConversationId: string | null;
|
|
175
|
+
titles: {
|
|
176
|
+
[x: string]: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
voice: VoiceState;
|
|
180
|
+
indicator: {
|
|
181
|
+
lastResponseTime: number | null;
|
|
182
|
+
};
|
|
183
|
+
chatApi: CombinedState< {
|
|
184
|
+
getConversationHistory: QueryDefinition< {
|
|
185
|
+
skip?: number;
|
|
186
|
+
limit?: number;
|
|
187
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
188
|
+
conversations: any[];
|
|
189
|
+
}, "chatApi", unknown>;
|
|
190
|
+
getConversationById: QueryDefinition< {
|
|
191
|
+
conversationId: string;
|
|
192
|
+
skip?: number;
|
|
193
|
+
limit?: number;
|
|
194
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
195
|
+
createConversatons: MutationDefinition< {
|
|
196
|
+
protocol: ProtocolType;
|
|
197
|
+
body?: any;
|
|
198
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
199
|
+
transcribeAudio: MutationDefinition< {
|
|
200
|
+
audioFile: File;
|
|
201
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
202
|
+
success: boolean;
|
|
203
|
+
data: {
|
|
204
|
+
text: string;
|
|
205
|
+
filename?: string;
|
|
206
|
+
};
|
|
207
|
+
}, "chatApi", unknown>;
|
|
208
|
+
getToolServers: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
209
|
+
tool_servers: ToolServer[];
|
|
210
|
+
}, "chatApi", unknown>;
|
|
211
|
+
startToolServerOAuth: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
212
|
+
authorize_url: string;
|
|
213
|
+
}, "chatApi", unknown>;
|
|
214
|
+
deleteToolServerConnection: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
215
|
+
exchangeOAuthCode: MutationDefinition< {
|
|
216
|
+
code: string;
|
|
217
|
+
state: string;
|
|
218
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
219
|
+
deleteConversation: MutationDefinition< {
|
|
220
|
+
conversationId: string;
|
|
221
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
222
|
+
}, "chat" | "toolServers", "chatApi">;
|
|
223
|
+
brandingApi: CombinedState< {
|
|
224
|
+
getBranding: QueryDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, AppBrandingResponse, "brandingApi", unknown>;
|
|
225
|
+
}, never, "brandingApi">;
|
|
226
|
+
configApi: CombinedState< {
|
|
227
|
+
getConfig: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, ClientConfigResponse, "configApi", unknown>;
|
|
228
|
+
}, never, "configApi">;
|
|
229
|
+
profileApi: CombinedState< {
|
|
230
|
+
getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", Profile, "profileApi", unknown>;
|
|
231
|
+
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
232
|
+
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
233
|
+
}, "profile", "profileApi">;
|
|
234
|
+
}>>;
|
|
235
|
+
|
|
236
|
+
export declare type RootState = ReturnType<typeof store.getState>;
|
|
237
|
+
|
|
238
|
+
export declare const SettingsProvider: default_2.FC<{
|
|
239
|
+
children: ReactNode;
|
|
240
|
+
defaultSttImplementation?: SttImplementation;
|
|
241
|
+
}>;
|
|
242
|
+
|
|
243
|
+
export declare const StorageProvider: default_2.FC<StorageProviderProps>;
|
|
244
|
+
|
|
245
|
+
declare interface StorageProviderProps {
|
|
246
|
+
value: Storage_2;
|
|
247
|
+
children: ReactNode;
|
|
248
|
+
fallback?: ReactNode;
|
|
249
|
+
extraHydrations?: Array<ExtraHydration>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare const store: EnhancedStore< {
|
|
253
|
+
auth: AuthState;
|
|
254
|
+
chat: {
|
|
255
|
+
isAgentWorking: boolean;
|
|
256
|
+
statusText: string | null;
|
|
257
|
+
responseStartTime: number | null;
|
|
258
|
+
messageQueue: {
|
|
259
|
+
id: string;
|
|
260
|
+
text: string;
|
|
261
|
+
queuedAt: string;
|
|
262
|
+
}[];
|
|
263
|
+
};
|
|
264
|
+
conversations: {
|
|
265
|
+
activeConversationId: string | null;
|
|
266
|
+
titles: {
|
|
267
|
+
[x: string]: string;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
voice: VoiceState;
|
|
271
|
+
indicator: {
|
|
272
|
+
lastResponseTime: number | null;
|
|
273
|
+
};
|
|
274
|
+
chatApi: CombinedState< {
|
|
275
|
+
getConversationHistory: QueryDefinition< {
|
|
276
|
+
skip?: number;
|
|
277
|
+
limit?: number;
|
|
278
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
279
|
+
conversations: any[];
|
|
280
|
+
}, "chatApi", unknown>;
|
|
281
|
+
getConversationById: QueryDefinition< {
|
|
282
|
+
conversationId: string;
|
|
283
|
+
skip?: number;
|
|
284
|
+
limit?: number;
|
|
285
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
286
|
+
createConversatons: MutationDefinition< {
|
|
287
|
+
protocol: ProtocolType;
|
|
288
|
+
body?: any;
|
|
289
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
290
|
+
transcribeAudio: MutationDefinition< {
|
|
291
|
+
audioFile: File;
|
|
292
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
293
|
+
success: boolean;
|
|
294
|
+
data: {
|
|
295
|
+
text: string;
|
|
296
|
+
filename?: string;
|
|
297
|
+
};
|
|
298
|
+
}, "chatApi", unknown>;
|
|
299
|
+
getToolServers: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
300
|
+
tool_servers: ToolServer[];
|
|
301
|
+
}, "chatApi", unknown>;
|
|
302
|
+
startToolServerOAuth: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
303
|
+
authorize_url: string;
|
|
304
|
+
}, "chatApi", unknown>;
|
|
305
|
+
deleteToolServerConnection: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
306
|
+
exchangeOAuthCode: MutationDefinition< {
|
|
307
|
+
code: string;
|
|
308
|
+
state: string;
|
|
309
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
310
|
+
deleteConversation: MutationDefinition< {
|
|
311
|
+
conversationId: string;
|
|
312
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
313
|
+
}, "chat" | "toolServers", "chatApi">;
|
|
314
|
+
brandingApi: CombinedState< {
|
|
315
|
+
getBranding: QueryDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, AppBrandingResponse, "brandingApi", unknown>;
|
|
316
|
+
}, never, "brandingApi">;
|
|
317
|
+
configApi: CombinedState< {
|
|
318
|
+
getConfig: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, ClientConfigResponse, "configApi", unknown>;
|
|
319
|
+
}, never, "configApi">;
|
|
320
|
+
profileApi: CombinedState< {
|
|
321
|
+
getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", Profile, "profileApi", unknown>;
|
|
322
|
+
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
323
|
+
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
324
|
+
}, "profile", "profileApi">;
|
|
325
|
+
}, UnknownAction, Tuple<[StoreEnhancer< {
|
|
326
|
+
dispatch: ((action: Action<"listenerMiddleware/add">) => UnsubscribeListener) & ThunkDispatch< {
|
|
327
|
+
auth: AuthState;
|
|
328
|
+
chat: {
|
|
329
|
+
isAgentWorking: boolean;
|
|
330
|
+
statusText: string | null;
|
|
331
|
+
responseStartTime: number | null;
|
|
332
|
+
messageQueue: {
|
|
333
|
+
id: string;
|
|
334
|
+
text: string;
|
|
335
|
+
queuedAt: string;
|
|
336
|
+
}[];
|
|
337
|
+
};
|
|
338
|
+
conversations: {
|
|
339
|
+
activeConversationId: string | null;
|
|
340
|
+
titles: {
|
|
341
|
+
[x: string]: string;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
voice: VoiceState;
|
|
345
|
+
indicator: {
|
|
346
|
+
lastResponseTime: number | null;
|
|
347
|
+
};
|
|
348
|
+
chatApi: CombinedState< {
|
|
349
|
+
getConversationHistory: QueryDefinition< {
|
|
350
|
+
skip?: number;
|
|
351
|
+
limit?: number;
|
|
352
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
353
|
+
conversations: any[];
|
|
354
|
+
}, "chatApi", unknown>;
|
|
355
|
+
getConversationById: QueryDefinition< {
|
|
356
|
+
conversationId: string;
|
|
357
|
+
skip?: number;
|
|
358
|
+
limit?: number;
|
|
359
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
360
|
+
createConversatons: MutationDefinition< {
|
|
361
|
+
protocol: ProtocolType;
|
|
362
|
+
body?: any;
|
|
363
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
364
|
+
transcribeAudio: MutationDefinition< {
|
|
365
|
+
audioFile: File;
|
|
366
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
367
|
+
success: boolean;
|
|
368
|
+
data: {
|
|
369
|
+
text: string;
|
|
370
|
+
filename?: string;
|
|
371
|
+
};
|
|
372
|
+
}, "chatApi", unknown>;
|
|
373
|
+
getToolServers: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
374
|
+
tool_servers: ToolServer[];
|
|
375
|
+
}, "chatApi", unknown>;
|
|
376
|
+
startToolServerOAuth: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", {
|
|
377
|
+
authorize_url: string;
|
|
378
|
+
}, "chatApi", unknown>;
|
|
379
|
+
deleteToolServerConnection: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
380
|
+
exchangeOAuthCode: MutationDefinition< {
|
|
381
|
+
code: string;
|
|
382
|
+
state: string;
|
|
383
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", void, "chatApi", unknown>;
|
|
384
|
+
deleteConversation: MutationDefinition< {
|
|
385
|
+
conversationId: string;
|
|
386
|
+
}, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "chat" | "toolServers", any, "chatApi", unknown>;
|
|
387
|
+
}, "chat" | "toolServers", "chatApi">;
|
|
388
|
+
brandingApi: CombinedState< {
|
|
389
|
+
getBranding: QueryDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, AppBrandingResponse, "brandingApi", unknown>;
|
|
390
|
+
}, never, "brandingApi">;
|
|
391
|
+
configApi: CombinedState< {
|
|
392
|
+
getConfig: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, ClientConfigResponse, "configApi", unknown>;
|
|
393
|
+
}, never, "configApi">;
|
|
394
|
+
profileApi: CombinedState< {
|
|
395
|
+
getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", Profile, "profileApi", unknown>;
|
|
396
|
+
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
397
|
+
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
398
|
+
}, "profile", "profileApi">;
|
|
399
|
+
}, undefined, UnknownAction>;
|
|
400
|
+
}>, StoreEnhancer]>>;
|
|
401
|
+
|
|
402
|
+
export declare const useMessageContext: () => MessageContextType;
|
|
403
|
+
|
|
404
|
+
export declare const useMessageDisabled: () => boolean;
|
|
405
|
+
|
|
406
|
+
export declare const useMessageId: () => string;
|
|
407
|
+
|
|
408
|
+
export declare const useSettings: () => ChatSettings;
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
export * from "@1interface/widgets";
|
|
412
|
+
|
|
413
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-AAKj44J6.cjs");exports.BrandingProvider=e.BrandingProvider,exports.ChatClientProvider=e.ChatClientProvider,exports.MessageContextProvider=e.MessageContextProvider,exports.PaymentProviderHost=e.PaymentProviderHost,exports.SettingsProvider=e.SettingsProvider,exports.StorageProvider=e.StorageProvider,exports.preloadPaymentModal=e.preloadPaymentModal,exports.rootReducer=e.rootReducer,exports.store=e.store,exports.useMessageContext=e.useMessageContext,exports.useMessageDisabled=e.useMessageDisabled,exports.useMessageId=e.useMessageId,exports.useSettings=e.useSettings;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,C as s,M as a,P as r,S as o,a as t,c as d,r as i,s as n,u as g,e as P,f as v,g as u}from"./index-CwetZEW6.js";export{e as BrandingProvider,s as ChatClientProvider,a as MessageContextProvider,r as PaymentProviderHost,o as SettingsProvider,t as StorageProvider,d as preloadPaymentModal,i as rootReducer,n as store,g as useMessageContext,P as useMessageDisabled,v as useMessageId,u as useSettings};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as h,useRef as m}from"react";import*as p from"expo-web-browser";import{useExchangeOAuthCodeMutation as y}from"@1interface/chat-core";import{logger as w}from"@1interface/shared-core";import{Alert as o}from"react-native";function A(e){try{const r=(new URL(e).searchParams.get("scope")??"").match(/\/auth\/([^./]+)/);if(r?.[1])return r[1].charAt(0).toUpperCase()+r[1].slice(1)}catch{}return"Service"}function P(e){try{return new URL(e).searchParams.get("redirect_uri")??""}catch{return""}}function F({signInInit:e,sendMessageRef:c,clearSignInInit:r,sendResumeMessage:i=!0}){const[u]=y(),n=m(!1);h(()=>{if(!e){n.current=!1;return}if(n.current)return;const s=A(e.authorize_url),d=P(e.authorize_url);let a=!1;return(async()=>{try{const t=await p.openAuthSessionAsync(e.authorize_url,d||void 0);if(a||n.current)return;if(n.current=!0,t.type==="cancel"||t.type==="dismiss"){r();return}if(t.type!=="success"||!t.url){o.alert("Error",`Failed to sign in to ${s}. Please try again.`),r();return}const l=new URL(t.url),f=l.searchParams.get("code"),g=l.searchParams.get("state");if(!f){o.alert("Error",`Failed to sign in to ${s}. Missing authorization code.`),r();return}"error"in await u({code:f,state:g??""})?o.alert("Error",`Failed to sign in to ${s}. Please try again.`):i?c.current?.(`${s} is now signed in, please continue`):o.alert("Success",`${s} connected successfully`)}catch(t){a||(w.error({message:"OAuth browser session failed",component:"useOAuthBrowser",error_message:t instanceof Error?t.message:String(t)}),o.alert("Error",`Failed to sign in to ${s}. Please try again.`))}finally{a||r()}})(),()=>{a=!0}},[e,c,r,u,i])}export{F as useOAuthBrowser};
|
package/native/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./index.css";import{store as s,rootReducer as p}from"./store";import{SettingsProvider as a,useSettings as m}from"./providers/SettingsProvider";import{MessageContextProvider as d,useMessageContext as P,useMessageId as x,useMessageDisabled as f}from"./providers/MessageContextProvider";import{BrandingProvider as g}from"./providers/BrandingProvider";import{ChatClientProvider as C}from"./providers/ChatClientProvider";const r=()=>import("./payment/PaymentProviderHost").catch(()=>{});import{PaymentProviderHost as l}from"./payment/PaymentProviderHostLazy";import{StorageProvider as h}from"./providers/StorageProvider";export{g as BrandingProvider,C as ChatClientProvider,d as MessageContextProvider,l as PaymentProviderHost,a as SettingsProvider,h as StorageProvider,r as preloadPaymentModal,p as rootReducer,s as store,P as useMessageContext,f as useMessageDisabled,x as useMessageId,m as useSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{store as o,rootReducer as t}from"./store";import{BrandingProvider as a}from"./providers/BrandingProvider.native";import{StorageProvider as p}from"./providers/StorageProvider";import{ChatClientProvider as x}from"./providers/ChatClientProvider";import{SettingsProvider as f,useSettings as n}from"./providers/SettingsProvider";import{MessageContextProvider as P,useMessageContext as g,useMessageId as u,useMessageDisabled as v}from"./providers/MessageContextProvider";import{useOAuthBrowser as h}from"./hooks/useOAuthBrowser.native";import{tokenizeCard as y,createPayment as S,MoyasarApiError as c}from"./payment/adapters/moyasar/api";import{buildMetadata as b}from"./payment/adapters/moyasar/metadata";export{a as BrandingProvider,x as ChatClientProvider,P as MessageContextProvider,c as MoyasarApiError,f as SettingsProvider,p as StorageProvider,b as buildMetadata,S as createPayment,t as rootReducer,o as store,y as tokenizeCard,g as useMessageContext,v as useMessageDisabled,u as useMessageId,h as useOAuthBrowser,n as useSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as p}from"react/jsx-runtime";import{createContext as s,useContext as l,useMemo as P}from"react";import{createPaymentAdapter as v}from"./createPaymentAdapter";import{DEFAULT_PAYMENT_PROVIDER as c}from"@1interface/chat-core";const y=s(void 0),f=({children:e,paymentProvider:d,paymentInit:r=null,conversationId:o=null})=>{const t=r?.provider||d||c,n=P(()=>v(t),[t]),m=P(()=>({adapter:n,paymentProvider:t,paymentInit:r,conversationId:o}),[n,t,r,o]),a=n.ProviderWrapper,i=a?p(a,{children:e}):e;return p(y.Provider,{value:m,children:i})},A=()=>{const e=l(y);if(!e)throw new Error("usePaymentAdapter must be used within a PaymentProvider");return e};export{f as PaymentProvider,A as usePaymentAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r,jsxs as i}from"react/jsx-runtime";import{useCallback as g,useMemo as R,useState as S}from"react";import{Loader2 as x}from"lucide-react";import{buildBrandSkin as w,formatAmount as k}from"@1interface/chat-core";import{useBranding as C,getPaymentProviderHint as F}from"@1interface/shared-core";import{PaymentProvider as N,usePaymentAdapter as B}from"./PaymentProvider";import{PaymentResultChannelProvider as H,useConfirmHandle as I,useReportedSummary as L}from"./PaymentResultChannel";const A=(t,o)=>k(t,o)??"",O=({provider:t,paymentInit:o=null,onResult:a,conversationId:l=null})=>{const n=s=>{a?.(s)};return r(N,{paymentInit:o,conversationId:l,paymentProvider:F(),children:r(H,{onResult:n,children:r(j,{provider:t,paymentInit:o})})},o?.provider??"default")},j=({provider:t,paymentInit:o})=>{const{themeStyles:a,theme:l}=C(),{adapter:n}=B(),s=L(),[c,p]=S(!1),P=g(()=>p(!0),[]),e=R(()=>w(a,l),[a,l]),d=o?.provider==="moyasar"?o.config:null,m=o?.provider==="chargebee"?o.config:null,u=s?.amount??d?.amount??m?.amount??0,y=s?.currency??d?.currency??m?.currency??"usd",v=s?.amount!=null||d?.amount!=null||m?.amount!=null,b=A(u,y),f=t??n.label,h=n.FormComponent;return i("div",{className:"w-full flex-1 min-h-0 overflow-y-auto [&::-webkit-scrollbar]:hidden [scrollbar-width:none] relative",style:{background:e.pageBg,color:e.text,fontFamily:e.fontFamily,colorScheme:e.colorScheme},children:[!c&&r(D,{skin:e}),r("div",{className:"min-h-full flex items-center justify-center p-4",style:{visibility:c?"visible":"hidden"},children:i("div",{className:"w-full max-w-sm p-5",style:{background:e.cardBg,borderRadius:e.radius,boxShadow:e.cardShadow,color:e.text},children:[r("h1",{className:"text-base font-semibold text-center mb-3.5",style:{color:e.heading},children:"Payment Options"}),r("div",{className:"mb-3.5",children:r(h,{amount:u,currency:y,skin:e,onReady:P})}),!n.hideShellSubmit&&v&&r(z,{label:`Pay ${b}`,background:a.statusDiscovery.solid,color:a.statusDiscovery.text,radius:e.radius}),!n.hideShellFooter&&i("p",{className:"text-xs text-center mt-2.5",style:{color:e.muted},children:["Powered by ",f]})]})})]})},D=({skin:t})=>i("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3",style:{background:t.pageBg,color:t.text},"aria-live":"polite","aria-busy":"true",children:[r(x,{className:"h-8 w-8 animate-spin",style:{color:t.accent}}),r("p",{className:"text-sm",style:{color:t.muted},children:"Loading payment\u2026"})]}),z=({label:t,background:o,color:a,radius:l})=>{const n=I(),s=!n||n.isConfirming;return r("button",{type:"button",onClick:()=>n?.confirm(),disabled:s,className:"w-full p-2.5 text-sm font-semibold border-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70",style:{background:o,color:a,borderRadius:l},children:n?.isConfirming?"Processing\u2026":t})};var K=O;export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{lazy as e,Suspense as r}from"react";const s=e(()=>import("./PaymentProviderHost")),a=t=>o(r,{fallback:null,children:o(s,{...t})});export{a as PaymentProviderHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as v}from"react/jsx-runtime";import{createContext as C,useCallback as r,useContext as f,useMemo as p,useRef as h,useState as y}from"react";const i=C(null),x=({onResult:e,children:d})=>{const[a,P]=y(null),[m,c]=y(null),l=h(e);l.current=e;const u=r(n=>{l.current(n)},[]),o=r(n=>{P(n)},[]),s=r(n=>{c(n)},[]),R=p(()=>({emitResult:u,registerConfirm:o,confirmHandle:a,reportSummary:s,summary:m}),[u,o,a,s,m]);return v(i.Provider,{value:R,children:d})},t=()=>{const e=f(i);if(!e)throw new Error("Payment result channel hooks must be used inside PaymentResultChannelProvider");return e},g=()=>t().emitResult,V=()=>t().registerConfirm,b=()=>t().confirmHandle,k=()=>t().reportSummary,w=()=>t().summary;export{x as PaymentResultChannelProvider,b as useConfirmHandle,V as useConfirmRegistration,w as useReportedSummary,g as useResultEmitter,k as useSummaryReporter};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{useEffect as S,useRef as k}from"react";import{useConfirmRegistration as D,useResultEmitter as O,useSummaryReporter as F}from"../PaymentResultChannel";import{usePaymentAdapter as H}from"../PaymentProvider";import{CHARGEBEE_MODAL_INSET_H as v,CHARGEBEE_MODAL_INSET_V as w,CHARGEBEE_MODAL_MAX_WIDTH_PX as E}from"./chargebeeModalSize";function $(e){if(window.Chargebee)return Promise.resolve();const t=document.querySelector('script[src*="js.chargebee.com"]');return t?t.dataset.cbLoaded==="1"?Promise.resolve():new Promise((n,r)=>{t.addEventListener("load",()=>n()),t.addEventListener("error",()=>r(new Error("Chargebee.js failed to load")))}):new Promise((n,r)=>{const o=document.createElement("script");o.src="https://js.chargebee.com/v2/chargebee.js",o.setAttribute("data-cb-site",e),o.onload=()=>{o.dataset.cbLoaded="1",n()},o.onerror=()=>r(new Error("Chargebee.js failed to load")),document.head.appendChild(o)})}const x="aiatcore-chargebee-modal-style",T="aiatcore-chargebee-close-button",P="aiatcore-chargebee-loader",B="aiatcore-cb-spin",_='#cb-container, .cb-container, [id^="cb-modal"], [class*="cb-modal"], [class*="cb-checkout"], div[class*="cb-"][class*="overlay"]',u="aiatcore-chargebee-open";function j(){const e=document.getElementById(x)??document.createElement("style");e.id=x,e.textContent=`
|
|
2
|
+
/* Prevent horizontal page scroll only while Chargebee's overlay is mounted */
|
|
3
|
+
html.${u}, body.${u} {
|
|
4
|
+
overflow-x: hidden !important;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/* Outer Chargebee overlay container \u2014 broad selector net so we catch
|
|
8
|
+
whatever wrapper Chargebee actually uses */
|
|
9
|
+
#cb-container,
|
|
10
|
+
.cb-container,
|
|
11
|
+
[id^="cb-modal"],
|
|
12
|
+
[class*="cb-modal"],
|
|
13
|
+
[class*="cb-checkout"],
|
|
14
|
+
div[class*="cb-"][class*="overlay"] {
|
|
15
|
+
position: fixed !important;
|
|
16
|
+
inset: ${w} max(${v}, calc((100vw - ${E}px) / 2)) !important;
|
|
17
|
+
width: auto !important;
|
|
18
|
+
height: auto !important;
|
|
19
|
+
max-width: none !important;
|
|
20
|
+
max-height: none !important;
|
|
21
|
+
margin: 0 !important;
|
|
22
|
+
border-radius: 12px !important;
|
|
23
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;
|
|
24
|
+
overflow: hidden !important;
|
|
25
|
+
z-index: 2147483646 !important;
|
|
26
|
+
pointer-events: all !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Inner iframe \u2014 fill the container fully and ensure it receives clicks */
|
|
30
|
+
[id^="cb-frame"] {
|
|
31
|
+
width: 100% !important;
|
|
32
|
+
height: 100% !important;
|
|
33
|
+
border: none !important;
|
|
34
|
+
display: block !important;
|
|
35
|
+
z-index: 2147483646 !important;
|
|
36
|
+
pointer-events: all !important;
|
|
37
|
+
outline: none !important;
|
|
38
|
+
box-shadow: none !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@keyframes ${B} {
|
|
42
|
+
to { transform: rotate(360deg); }
|
|
43
|
+
}
|
|
44
|
+
`,e.parentElement||document.head.appendChild(e),document.documentElement.classList.add(u),document.body.classList.add(u)}function q(){document.documentElement.classList.remove(u),document.body.classList.remove(u),document.getElementById(x)?.remove()}function p(){document.getElementById(T)?.remove()}function N(){document.querySelectorAll(_).forEach(e=>{e instanceof HTMLElement&&(e.style.display="none")})}function z(e){p();const t=document.createElement("button");t.id=T,t.type="button",t.setAttribute("aria-label","Close payment"),t.textContent="\xD7",t.style.cssText=`
|
|
45
|
+
position: fixed;
|
|
46
|
+
top: calc(${w} + 12px);
|
|
47
|
+
right: calc(max(${v}, calc((100vw - ${E}px) / 2)) + 12px);
|
|
48
|
+
z-index: 2147483647;
|
|
49
|
+
width: 32px;
|
|
50
|
+
height: 32px;
|
|
51
|
+
border: 0;
|
|
52
|
+
border-radius: 9999px;
|
|
53
|
+
background: rgba(17, 24, 39, 0.72);
|
|
54
|
+
color: #ffffff;
|
|
55
|
+
font: 600 16px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
pointer-events: auto;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
|
|
62
|
+
`,t.addEventListener("click",e),document.body.appendChild(t)}const R=5e3;function l(){document.getElementById(P)?.remove()}function U(){l();const e=document.createElement("div");e.id=P,e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.style.cssText=`
|
|
63
|
+
position: fixed;
|
|
64
|
+
inset: ${w} max(${v}, calc((100vw - ${E}px) / 2));
|
|
65
|
+
z-index: 2147483646;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
gap: 14px;
|
|
71
|
+
background: #f8f8f8;
|
|
72
|
+
border-radius: 12px;
|
|
73
|
+
color: #6b7280;
|
|
74
|
+
font: 500 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
`;const t=document.createElement("div");t.style.cssText=`
|
|
77
|
+
width: 32px;
|
|
78
|
+
height: 32px;
|
|
79
|
+
border: 2.5px solid rgba(17, 24, 39, 0.08);
|
|
80
|
+
border-top-color: #6366f1;
|
|
81
|
+
border-radius: 50%;
|
|
82
|
+
animation: ${B} 0.8s linear infinite;
|
|
83
|
+
`;const n=document.createElement("p");n.textContent="Loading payment\u2026",n.style.cssText="margin: 0;",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}const W=400;function G(e){let t=0,n=0,r=0,o=null,i=null;const c=Date.now()+R,a=()=>{if(e())return;const d=document.querySelector(_);if(d instanceof HTMLElement){const f=d.getBoundingClientRect();if(f.width>0&&f.height>0){U();const g=document.querySelector('[id^="cb-frame"]');g instanceof HTMLIFrameElement&&(o=g,i=()=>{r=window.setTimeout(l,W)},o.addEventListener("load",i));return}}Date.now()>=c||(t=window.requestAnimationFrame(a))};return n=window.setTimeout(a,100),()=>{window.clearTimeout(n),window.clearTimeout(r),t&&window.cancelAnimationFrame(t),o&&i&&o.removeEventListener("load",i),l()}}function Y(e,t){let n=0,r=0;const o=Date.now()+R,i=()=>{if(t())return;const c=document.querySelector(_);if(c instanceof HTMLElement){const a=c.getBoundingClientRect();if(a.width>0&&a.height>0){z(e);return}}Date.now()>=o||(n=window.requestAnimationFrame(i))};return r=window.setTimeout(i,100),()=>{window.clearTimeout(r),n&&window.cancelAnimationFrame(n)}}const V=({amount:e,currency:t,onReady:n})=>{const{paymentInit:r}=H(),o=O(),i=F(),c=D(),a=k(!1);return S(()=>(c(null),()=>c(null)),[c]),S(()=>{if(r?.provider!=="chargebee")return;const{site:d,hosted_page_url:f,amount:g,currency:M,expires_at:L}=r.config,b=g??e,y=M??t;b!=null&&y&&i({amount:b,currency:y}),a.current=!1;let h=!1,A=null,I=null;const m=s=>{a.current||(a.current=!0,o(s))};return n?.(),L!=null&&Date.now()>=L*1e3?(m({status:"failure",provider:"chargebee",message:"Payment link has expired. Please request a new one."}),()=>{h=!0}):(j(),$(d).then(()=>{if(h)return;let s;try{s=window.Chargebee.getInstance()??window.Chargebee.init({site:d})}catch{s=window.Chargebee.init({site:d})}s.openCheckout({hostedPage:()=>Promise.resolve({id:r.payment_id,url:f,type:"checkout_one_time",state:"created"}),success:C=>{p(),l(),m({status:"success",provider:"chargebee",paymentId:C,amount:b??void 0,currency:y??void 0})},close:()=>{p(),l(),m({status:"cancel",provider:"chargebee"})},error:C=>{p(),l(),m({status:"failure",provider:"chargebee",message:C?.message??"Payment failed"})}}),I=G(()=>h||a.current),A=Y(()=>{p(),l(),N(),m({status:"cancel",provider:"chargebee"});try{s.closeAll()}catch{}},()=>h||a.current)}).catch(s=>{m({status:"failure",provider:"chargebee",message:s?.message??"Failed to load payment form"})}),()=>{h=!0,A?.(),I?.(),p(),l(),q();try{window.Chargebee?.getInstance?.()?.closeAll?.()}catch{}})},[r,e,t,i,n,o]),null},ee={type:"chargebee",label:"Chargebee",FormComponent:V,hideShellSubmit:!0};export{ee as chargebeePaymentAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as c}from"react/jsx-runtime";import{useEffect as d,useRef as l}from"react";import{usePaymentAdapter as y}from"../PaymentProvider";import{ApplePayButton as u}from"./moyasar/ApplePayButton";import{CustomCardForm as f}from"./moyasar/CustomCardForm";import{useApplePaySupported as P}from"./moyasar/useApplePaySupported";const v=["creditcard","applepay"],F=({skin:e,onReady:o})=>{const{paymentInit:a}=y(),r=a&&a.provider==="moyasar"?a:null,i=P(),s=l(o);if(s.current=o,d(()=>{s.current?.()},[]),!r)return null;const n=r.config.methods??v,p=n.includes("creditcard"),m=n.includes("applepay")&&i;return c("div",{className:"space-y-4",children:[p&&t(f,{skin:e}),p&&m&&t(A,{skin:e}),m&&t(u,{skin:e})]})},A=({skin:e})=>c("div",{className:"relative",children:[t("div",{className:"absolute inset-x-0 top-1/2",style:{borderTop:`1px solid ${e.divider}`}}),t("div",{className:"relative flex justify-center",children:t("span",{className:"px-2 text-xs uppercase tracking-wide",style:{background:e.cardBg,color:e.muted,fontFamily:e.fontFamily},children:"or"})})]}),b={type:"moyasar",label:"Moyasar",FormComponent:F};export{b as moyasarPaymentAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{useCallback as C,useEffect as S,useMemo as y,useState as v}from"react";import{Elements as E,PaymentElement as R,useElements as b,useStripe as g}from"@stripe/react-stripe-js";import{buildBrandSkin as F}from"@1interface/chat-core";import{useBranding as I}from"@1interface/shared-core";import{useConfirmRegistration as h,useResultEmitter as w,useSummaryReporter as A}from"../PaymentResultChannel";import{usePaymentAdapter as P}from"../PaymentProvider";import{buildStripeAppearance as _,StripeProviderWrapper as k,useStripeContext as O}from"./stripe";const q=({amount:l,currency:r,skin:m,onReady:u})=>{const{themeStyles:o,theme:n}=I(),{stripePromise:a}=O(),{paymentInit:c}=P(),p=y(()=>F(o,n),[o,n]),t=y(()=>_(o,n,p),[o,n,p]),i=c?.provider==="stripe"?c.config.client_secret:null,s=y(()=>i?{clientSecret:i,appearance:t}:null,[i,t]);return!a||!s?null:d(E,{stripe:a,options:s,children:d(B,{onReady:u})},i)},B=({onReady:l})=>{const r=g(),m=b(),{paymentInit:u}=P(),o=w(),n=h(),a=A(),[c,p]=v(!1),t=u?.provider==="stripe"?u.config.client_secret:null;S(()=>{if(!r||!t)return;let s=!1;return r.retrievePaymentIntent(t).then(f=>{if(s)return;const e=f.paymentIntent;e&&typeof e.amount=="number"&&e.currency&&a({amount:e.amount,currency:e.currency})}),()=>{s=!0}},[r,t,a]);const i=C(async()=>{if(!r||!m||!t)return;p(!0);const{error:s}=await m.submit();if(s){p(!1);return}const{error:f,paymentIntent:e}=await r.confirmPayment({elements:m,clientSecret:t,confirmParams:{return_url:window.location.href},redirect:"if_required"});p(!1),!f&&e&&(e.status==="succeeded"||e.status==="requires_capture")&&o({status:"success",provider:"stripe",paymentId:e.id,amount:e.amount,currency:e.currency})},[r,m,t,o]);return S(()=>(n({confirm:i,isConfirming:c}),()=>n(null)),[i,c,n]),d(R,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:l})},J={type:"stripe",label:"Stripe",ProviderWrapper:k,FormComponent:q};export{J as stripePaymentAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const E=1500,_="5vh",A="5vw";export{A as CHARGEBEE_MODAL_INSET_H,_ as CHARGEBEE_MODAL_INSET_V,E as CHARGEBEE_MODAL_MAX_WIDTH_PX};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stripePaymentAdapter as t}from"./StripePaymentAdapter";import{moyasarPaymentAdapter as m}from"./MoyasarPaymentAdapter";import{chargebeePaymentAdapter as p}from"./ChargebeePaymentAdapter";export{p as chargebeePaymentAdapter,m as moyasarPaymentAdapter,t as stripePaymentAdapter};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{Fragment as q,jsx as A,jsxs as z}from"react/jsx-runtime";import{useCallback as U,useEffect as k,useRef as C,useState as E}from"react";import{buildCallbackUrl as T}from"@1interface/chat-core";import{showErrorToast as u}from"@1interface/shared-core";import{usePaymentAdapter as R}from"../../PaymentProvider";import{useResultEmitter as w}from"../../PaymentResultChannel";import{buildMetadata as I}from"./metadata";import{createPayment as L,MoyasarApiError as F}from"./api";import{validateApplePayMerchant as M}from"./applePayApi";import{Moyasar3DSIframe as N}from"./Moyasar3DSIframe";const D=5,x="SA",O=["mada","visa","masterCard"],b="data-aiatcore-apple-pay";function Y(){if(typeof document>"u"||document.querySelector(`style[${b}]`))return;const i=document.createElement("style");i.setAttribute(b,"true"),i.textContent=`
|
|
2
|
+
.aiatcore-apple-pay-button {
|
|
3
|
+
-webkit-appearance: -apple-pay-button;
|
|
4
|
+
-apple-pay-button-type: pay;
|
|
5
|
+
-apple-pay-button-style: black;
|
|
6
|
+
width: 100%;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
border: none;
|
|
9
|
+
padding: 0;
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
`,document.head.appendChild(i)}const X=({skin:i})=>{const{paymentInit:p}=R(),e=p&&p.provider==="moyasar"?p:null,s=w(),[m,y]=E(null),d=C(s);d.current=s,k(()=>{Y()},[]);const P=U(()=>{if(!e)return;const o=window.ApplePaySession;if(!o){u("Apple Pay is not available on this device.");return}const f=e.config.apple_pay?.label??e.config.description??"Payment",v=e.config.apple_pay?.country??x,g=e.config.currency.toUpperCase(),h=(e.config.amount/100).toFixed(2),_={countryCode:v,currencyCode:g,supportedNetworks:O,merchantCapabilities:["supports3DS","supportsDebit","supportsCredit"],total:{label:f,amount:h}};let a;try{a=new o(D,_)}catch(r){u(r instanceof Error?r.message:"Failed to start Apple Pay");return}a.onvalidatemerchant=async r=>{try{const n=await M({validationUrl:r.validationURL,displayName:f,publishableApiKey:e.config.publishable_key});a.completeMerchantValidation(n)}catch(n){const t=n instanceof Error?n.message:"Merchant validation failed";a.abort(),s({status:"failure",provider:"moyasar",message:t,paymentId:e.config.given_id})}},a.onpaymentauthorized=async r=>{try{const n=I(e),t=await L({publishable_api_key:e.config.publishable_key,given_id:e.config.given_id,amount:e.config.amount,currency:g,description:e.config.description,callback_url:T(e.config.given_id),source:{type:"applepay",token:r.payment.token},...Object.keys(n).length>0?{metadata:n}:{}}),S=t.source?.transaction_url??t.transaction_url;if(S){a.completePayment({status:o.STATUS_SUCCESS}),y(S);return}const c=t.status;if(c==="paid"||c==="authorized"||c==="captured")a.completePayment({status:o.STATUS_SUCCESS}),s({status:"success",provider:"moyasar",paymentId:t.id,amount:t.amount,currency:t.currency});else if(c==="failed"){const l=t.source?.message??"Payment failed";a.completePayment({status:o.STATUS_FAILURE}),s({status:"failure",provider:"moyasar",code:"failed",message:l,paymentId:t.id})}else{const l=`Unexpected payment status: ${c}`;a.completePayment({status:o.STATUS_FAILURE}),s({status:"failure",provider:"moyasar",code:c,message:l,paymentId:t.id})}}catch(n){const t=n instanceof F||n instanceof Error?n.message:"Payment failed";a.completePayment({status:o.STATUS_FAILURE}),s({status:"failure",provider:"moyasar",message:t,paymentId:e.config.given_id})}},a.oncancel=()=>{};try{a.begin()}catch(r){u(r instanceof Error?r.message:"Failed to start Apple Pay")}},[e,s]);return e?z(q,{children:[A("button",{type:"button",onClick:P,className:"aiatcore-apple-pay-button",style:{borderRadius:i.radius,height:44},"aria-label":"Pay with Apple Pay"}),m&&A(N,{url:m,skin:i,onResult:o=>{y(null),d.current(o)}})]}):null};export{X as ApplePayButton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";const g=({brand:t,fallbackColor:r,height:i=22})=>{if(!t)return null;switch(t){case"Visa":return e(a,{height:i});case"Mastercard":return e(c,{height:i});case"American Express":return e(s,{height:i});case"Mada":return e(n,{height:i});case"Discover":return e(o,{height:i});case"JCB":return e(h,{height:i});default:return e("span",{className:"text-xs font-medium",style:{color:r},"aria-label":`Card brand: ${t}`,children:t})}},a=({height:t})=>l("svg",{role:"img","aria-label":"Visa",viewBox:"0 0 48 16",height:t,width:t*48/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#1A1F71"}),e("text",{x:"24",y:"12",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"11",fill:"#FFFFFF",letterSpacing:"1.4",children:"VISA"})]}),c=({height:t})=>l("svg",{role:"img","aria-label":"Mastercard",viewBox:"0 0 32 20",height:t,width:t*32/20,style:{display:"block"},children:[e("circle",{cx:"12",cy:"10",r:"7",fill:"#EB001B"}),e("circle",{cx:"20",cy:"10",r:"7",fill:"#F79E1B"}),e("path",{d:"M16 4.5a7 7 0 0 1 0 11 7 7 0 0 1 0-11Z",fill:"#FF5F00","aria-hidden":"true"})]}),s=({height:t})=>l("svg",{role:"img","aria-label":"American Express",viewBox:"0 0 48 16",height:t,width:t*48/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#2E77BB"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.4",children:"AMEX"})]}),n=({height:t})=>l("svg",{role:"img","aria-label":"Mada",viewBox:"0 0 48 16",height:t,width:t*48/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#84B740"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.6",children:"mada"})]}),o=({height:t})=>l("svg",{role:"img","aria-label":"Discover",viewBox:"0 0 56 16",height:t,width:t*56/16,style:{display:"block"},children:[e("rect",{width:"56",height:"16",rx:"2",fill:"#FFFFFF",stroke:"#E5E7EB"}),e("text",{x:"20",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"8",fill:"#231F20",letterSpacing:"0.2",children:"DISCOVER"}),e("circle",{cx:"44",cy:"8",r:"4",fill:"#FF6000"})]}),h=({height:t})=>l("svg",{role:"img","aria-label":"JCB",viewBox:"0 0 32 16",height:t,width:t*32/16,style:{display:"block"},children:[e("rect",{x:"0",y:"0",width:"10.66",height:"16",rx:"2",fill:"#0E4C96"}),e("rect",{x:"10.66",y:"0",width:"10.66",height:"16",fill:"#B41E25"}),e("rect",{x:"21.33",y:"0",width:"10.66",height:"16",rx:"2",fill:"#1B8A3A"}),e("text",{x:"16",y:"11",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"9",fill:"#FFFFFF",children:"JCB"})]});export{g as CardBrandIcon};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as ne,jsx as i,jsxs as M}from"react/jsx-runtime";import{useCallback as K,useEffect as T,useLayoutEffect as z,useMemo as A,useRef as S,useState as C}from"react";import{buildCallbackUrl as Y}from"@1interface/chat-core";import{usePaymentAdapter as $}from"../../PaymentProvider";import{useConfirmRegistration as O,useResultEmitter as V,useSummaryReporter as j}from"../../PaymentResultChannel";import{buildMetadata as q}from"./metadata";import{createPayment as G,MoyasarApiError as J,tokenizeCard as Q}from"./api";import{detectCardBrand as W,formatCardNumber as X,formatCvc as Z,formatExpiry as ee,validateCard as te}from"./cardValidation";import{Moyasar3DSIframe as re}from"./Moyasar3DSIframe";import{CardBrandIcon as ae}from"./CardBrandIcon";const ge=({skin:a})=>{const{paymentInit:l}=$(),e=l&&l.provider==="moyasar"?l:null,g=V(),h=O(),R=j(),[u,y]=C(""),[x,k]=C(""),[E,b]=C(""),[p,N]=C(""),[_,I]=C(!1),[t,n]=C({}),[o,s]=C(null),F=S({number:u,expiry:x,cvc:E,name:p});F.current={number:u,expiry:x,cvc:E,name:p};const m=S(g);m.current=g,T(()=>{e&&R({amount:e.config.amount,currency:e.config.currency.toUpperCase()})},[e,R]);const U=K(async()=>{if(!e)return;const r=te(F.current);if(r.ok===!1){const c={};for(const f of r.errors)c[f.field]||(c[f.field]=f.message);n(c);return}n({}),I(!0);try{const c=await Q({publishable_api_key:e.config.publishable_key,name:r.card.name,number:r.card.number,month:r.card.month,year:r.card.year,cvc:r.card.cvc}),f=q(e),d=await G({publishable_api_key:e.config.publishable_key,given_id:e.config.given_id,amount:e.config.amount,currency:e.config.currency.toUpperCase(),description:e.config.description,callback_url:Y(e.config.given_id),source:{type:"token",token:c.id},...Object.keys(f).length>0?{metadata:f}:{}}),L=d.source?.transaction_url??d.transaction_url;if(L){s(L);return}const v=d.status;if(v==="paid"||v==="authorized"||v==="captured")m.current({status:"success",provider:"moyasar",paymentId:d.id,amount:d.amount,currency:d.currency});else if(v==="failed"){const D=d.source?.message??"Payment failed";m.current({status:"failure",provider:"moyasar",code:"failed",message:D,paymentId:d.id})}else{const D=`Unexpected payment status: ${v}`;m.current({status:"failure",provider:"moyasar",code:v,message:D,paymentId:d.id})}}catch(c){const f=c instanceof J||c instanceof Error?c.message:"Payment failed";m.current({status:"failure",provider:"moyasar",message:f,paymentId:e.config.given_id})}finally{I(!1)}},[e]);T(()=>(h({confirm:U,isConfirming:_}),()=>h(null)),[U,_,h]);const P=A(()=>Math.max(a.radius-4,4),[a.radius]),B=A(()=>W(u),[u]);return e?M(ne,{children:[M("div",{className:"space-y-3",style:{fontFamily:a.fontFamily},children:[i(w,{label:"Card number",value:u,onChange:r=>y(X(r)),autoComplete:"cc-number",inputMode:"numeric",placeholder:"1234 5678 9012 3456",error:t.number,skin:a,radius:P,endAdornment:B?i(ae,{brand:B,fallbackColor:a.muted}):null}),M("div",{className:"grid grid-cols-2 gap-3",children:[i(w,{label:"Expiry",value:x,onChange:r=>k(ee(r)),autoComplete:"cc-exp",inputMode:"numeric",placeholder:"MM / YY",error:t.expiry,skin:a,radius:P}),i(w,{label:"CVC",value:E,onChange:r=>b(Z(r)),autoComplete:"cc-csc",inputMode:"numeric",placeholder:"123",error:t.cvc,skin:a,radius:P})]}),i(w,{label:"Name on card",value:p,onChange:N,autoComplete:"cc-name",inputMode:"text",placeholder:"Full name",error:t.name,skin:a,radius:P})]}),o&&i(re,{url:o,skin:a,onResult:r=>{s(null),m.current(r)}})]}):null};function H(a){let l=0;for(let e=0;e<a.length;e++){const g=a.charCodeAt(e);g>=48&&g<=57&&l++}return l}const w=({label:a,value:l,onChange:e,placeholder:g,autoComplete:h,inputMode:R,error:u,skin:y,radius:x,endAdornment:k})=>{const E=u?"#dc2626":y.divider,b=S(null),p=S(null),N=R==="numeric",_=t=>{if(N){const n=t.target.selectionStart??t.target.value.length;p.current=H(t.target.value.slice(0,n))}e(t.target.value)},I=t=>{if(!N||t.key!=="Backspace")return;const n=t.currentTarget,o=n.selectionStart??0,s=n.selectionEnd??0;if(o!==s||o<2)return;const F=n.value[o-1];if(!F||/\d/.test(F))return;t.preventDefault();const m=n.value.slice(0,o-2)+n.value.slice(o);p.current=H(m.slice(0,o-2)),e(m)};return z(()=>{const t=p.current;if(t===null||!b.current)return;p.current=null;const n=b.current.value;let o=0,s=0;for(;s<n.length&&!(o>=t);)/\d/.test(n[s])&&o++,s++;b.current.setSelectionRange(s,s)},[l]),M("label",{className:"block",children:[i("span",{className:"block text-xs mb-1",style:{color:y.muted},children:a}),M("div",{className:"relative",children:[i("input",{ref:b,type:"text",value:l,onChange:_,onKeyDown:I,placeholder:g,autoComplete:h,inputMode:R,spellCheck:!1,className:"w-full py-2.5 px-3 outline-none text-sm transition-colors",style:{background:y.pillBg,color:y.text,border:`1px solid ${E}`,borderRadius:x,paddingRight:k?96:void 0}}),k&&i("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium pointer-events-none",style:{color:y.muted},"aria-label":"Card brand",children:k})]}),u&&i("span",{className:"block mt-1 text-xs",style:{color:"#dc2626"},children:u})]})};export{ge as CustomCardForm};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as f,jsxs as S}from"react/jsx-runtime";import{useCallback as h,useEffect as m,useRef as l,useState as y}from"react";import{parseMoyasarCallbackFromUrl as b}from"@1interface/chat-core";const w="moyasar-iframe-callback",k=6e4;function v(e){if(!e||typeof e!="object")return!1;const a=e;return a.type===w&&typeof a.search=="string"}const E=({url:e,onResult:a,skin:o})=>{const s=l(a);s.current=a;const r=l(!1),[p,g]=y(!1),c=l(!1),n=h(t=>{r.current||(r.current=!0,s.current({status:"failure",provider:"moyasar",message:t}))},[]);return m(()=>{const t=window.location.origin,u=i=>{if(i.origin!==t||r.current||!v(i.data))return;const d=b(i.data.search);d&&(r.current=!0,s.current(d.result))};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]),m(()=>{const t=setTimeout(()=>{c.current||n("3D Secure challenge failed to load")},k);return()=>clearTimeout(t)},[n]),S("div",{className:"absolute inset-0 z-[105]",style:{background:o.cardBg},role:"dialog","aria-label":"3D Secure authentication",children:[!p&&f("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:o.muted,fontFamily:o.fontFamily},children:"Loading\u2026"}),f("iframe",{src:e,title:"3D Secure",className:"w-full h-full",style:{border:0,background:"white"},onLoad:()=>{c.current=!0,g(!0)},onError:()=>{n("3D Secure challenge failed to load")},allow:"payment *",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation-by-user-activation",referrerPolicy:"no-referrer"})]})};export{E as Moyasar3DSIframe};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MOYASAR_API_TIMEOUT_MS as l}from"./constants";const m="https://api.moyasar.com/v1/tokens",g="https://api.moyasar.com/v1/payments";class s extends Error{constructor(t,o,r){super(t);this.status=o;this.body=r;this.name="MoyasarApiError"}}async function k(n){const e=await u(m,{...n,save_only:!0});if(!e.ok)throw new s(c(e.body)??`Tokenization failed (${e.status})`,e.status,e.body);const t=e.body;if(!t||typeof t.id!="string")throw new s("Tokenization returned no token id",e.status,t);return{id:t.id}}async function b(n){const e=await u(g,n);if(!e.ok)throw new s(c(e.body)??`Payment creation failed (${e.status})`,e.status,e.body);const t=e.body;if(!t||typeof t.id!="string"||typeof t.status!="string")throw new s("Payment creation returned no id/status",e.status,t);return t}async function u(n,e){const t=new AbortController,o=setTimeout(()=>t.abort(new DOMException("Request timed out","TimeoutError")),l);let r;try{r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t.signal})}catch(a){const y=a instanceof DOMException&&a.name==="TimeoutError"?"Payment request timed out \u2014 please try again.":a instanceof Error?a.message:"Network request failed";throw new s(y)}finally{clearTimeout(o)}let i=null;try{i=await r.json()}catch{i=null}return{ok:r.ok,status:r.status,body:i}}function c(n){if(!n||typeof n!="object")return null;const e=n;if(typeof e.message=="string"&&e.message.length>0)return e.message;if(e.errors&&typeof e.errors=="object"){const t=e.errors;for(const[o,r]of Object.entries(t)){if(Array.isArray(r)&&typeof r[0]=="string")return`${p(o)}: ${r[0]}`;if(typeof r=="string")return`${p(o)}: ${r}`}}return null}function p(n){return n.replace(/_/g," ")}export{s as MoyasarApiError,b as createPayment,k as tokenizeCard};
|