UNPKG

rn-kore-bot-sdk-v79

Version:
1,563 lines (1,539 loc) 1.28 MB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // node_modules/tsup/assets/cjs_shims.js var init_cjs_shims = __esm({ "node_modules/tsup/assets/cjs_shims.js"() { "use strict"; } }); // bot-sdk/utils/LazyLoader.tsx var import_react4, import_react_native6, LazyLoader, DefaultLoader, ErrorFallback, styles4; var init_LazyLoader = __esm({ "bot-sdk/utils/LazyLoader.tsx"() { "use strict"; init_cjs_shims(); import_react4 = __toESM(require("react")); import_react_native6 = require("react-native"); LazyLoader = class { static cache = /* @__PURE__ */ new Map(); /** * Dynamically import a module with caching */ static async importModule(importFn, moduleKey) { if (this.cache.has(moduleKey)) { return this.cache.get(moduleKey); } const modulePromise = importFn().then((module2) => module2.default); this.cache.set(moduleKey, modulePromise); return modulePromise; } /** * Create a lazy React component with error boundary */ static createLazyComponent(importFn, fallback, errorFallback) { return import_react4.default.lazy(importFn); } /** * Higher-order component for lazy loading with custom loading states */ static withLazyLoading(importFn, options = {}) { const LazyComponent = import_react4.default.lazy(importFn); return (props) => /* @__PURE__ */ import_react4.default.createElement( import_react4.Suspense, { fallback: options.fallback || /* @__PURE__ */ import_react4.default.createElement(import_react_native6.View, { style: styles4.loadingContainer }, /* @__PURE__ */ import_react4.default.createElement(import_react_native6.ActivityIndicator, { size: "small", color: "#4ECDC4" }), /* @__PURE__ */ import_react4.default.createElement(import_react_native6.Text, { style: styles4.loadingText }, options.loadingText || "Loading...")) }, /* @__PURE__ */ import_react4.default.createElement(LazyComponent, { ...props }) ); } }; DefaultLoader = ({ text = "Loading..." }) => /* @__PURE__ */ import_react4.default.createElement(import_react_native6.View, { style: styles4.loadingContainer }, /* @__PURE__ */ import_react4.default.createElement(import_react_native6.ActivityIndicator, { size: "small", color: "#4ECDC4" }), /* @__PURE__ */ import_react4.default.createElement(import_react_native6.Text, { style: styles4.loadingText }, text)); ErrorFallback = ({ error = "Failed to load component" }) => /* @__PURE__ */ import_react4.default.createElement(import_react_native6.View, { style: styles4.errorContainer }, /* @__PURE__ */ import_react4.default.createElement(import_react_native6.Text, { style: styles4.errorText }, error)); styles4 = import_react_native6.StyleSheet.create({ loadingContainer: { flex: 1, justifyContent: "center", alignItems: "center", padding: 20 }, loadingText: { marginTop: 8, fontSize: 14, color: "#666", textAlign: "center" }, errorContainer: { flex: 1, justifyContent: "center", alignItems: "center", padding: 20, backgroundColor: "#ffebee" }, errorText: { fontSize: 14, color: "#c62828", textAlign: "center" } }); } }); // bot-sdk/utils/PlatformCheck.tsx var import_react_native13, isIOS, isAndroid; var init_PlatformCheck = __esm({ "bot-sdk/utils/PlatformCheck.tsx"() { "use strict"; init_cjs_shims(); import_react_native13 = require("react-native"); isIOS = import_react_native13.Platform.OS === "ios"; isAndroid = import_react_native13.Platform.OS === "android"; } }); // bot-sdk/components/LazyCommunications.tsx var LazyCommunications_exports = {}; __export(LazyCommunications_exports, { FallbackCommunications: () => FallbackCommunications, FallbackCommunicationsAPI: () => FallbackCommunicationsAPI, LazyCommunications: () => LazyCommunications, default: () => LazyCommunications_default, useLazyCommunications: () => useLazyCommunications }); var import_react15, import_react_native23, LazyCommunications, useLazyCommunications, FallbackCommunications, FallbackCommunicationsAPI, styles17, LazyCommunications_default; var init_LazyCommunications = __esm({ "bot-sdk/components/LazyCommunications.tsx"() { "use strict"; init_cjs_shims(); import_react15 = __toESM(require("react")); import_react_native23 = require("react-native"); init_LazyLoader(); LazyCommunications = class extends import_react15.Component { mounted = true; constructor(props) { super(props); this.state = { CommunicationsModule: null, isLoading: false, loadError: null }; } componentDidMount() { if (this.props.autoLoad !== false) { this.loadCommunications(); } } componentWillUnmount() { this.mounted = false; } async loadCommunications() { if (this.state.CommunicationsModule || this.state.isLoading) { return this.state.CommunicationsModule; } this.setState({ isLoading: true, loadError: null }); try { const CommunicationsModule = await LazyLoader.importModule( () => import("react-native-communications"), "communications" ); if (this.mounted) { const Communications = CommunicationsModule || null; if (!Communications || !Communications.phonecall) { throw new Error("Communications module or required methods not found"); } this.setState({ CommunicationsModule: Communications, isLoading: false, loadError: null }); if (this.props.onModuleLoaded) { this.props.onModuleLoaded(Communications); } return Communications; } } catch (error) { console.warn("Failed to load Communications:", error); if (this.mounted) { const errorMessage = error instanceof Error ? error.message : "Unknown error"; this.setState({ CommunicationsModule: null, isLoading: false, loadError: errorMessage }); if (this.props.onModuleLoaded) { this.props.onModuleLoaded(null); } } } return null; } async phonecall(phoneNumber, prompt = false) { const communications = await this.loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.phonecall(phoneNumber, prompt); } async email(to, cc, bcc, subject, body) { const communications = await this.loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.email(to, cc, bcc, subject, body); } async text(phoneNumber, body) { const communications = await this.loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.text(phoneNumber, body); } async web(url) { const communications = await this.loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.web(url); } render() { const { fallbackComponent: FallbackComponent, loadingComponent: LoadingComponent, errorComponent: ErrorComponent } = this.props; const { CommunicationsModule, isLoading, loadError } = this.state; if (isLoading) { if (LoadingComponent) { return /* @__PURE__ */ import_react15.default.createElement(LoadingComponent, null); } return /* @__PURE__ */ import_react15.default.createElement(DefaultLoader, { text: "Loading communications..." }); } if (loadError) { if (ErrorComponent) { return /* @__PURE__ */ import_react15.default.createElement(ErrorComponent, { error: loadError }); } if (FallbackComponent) { return /* @__PURE__ */ import_react15.default.createElement(FallbackComponent, null); } return /* @__PURE__ */ import_react15.default.createElement(ErrorFallback, { error: `Communications unavailable: ${loadError}` }); } if (CommunicationsModule) { return /* @__PURE__ */ import_react15.default.createElement(import_react_native23.View, { style: styles17.readyContainer }, /* @__PURE__ */ import_react15.default.createElement(import_react_native23.Text, { style: styles17.readyText }, "Communications ready")); } return /* @__PURE__ */ import_react15.default.createElement(DefaultLoader, { text: "Initializing communications..." }); } }; useLazyCommunications = () => { const [state, setState] = import_react15.default.useState({ CommunicationsModule: null, isLoading: false, loadError: null }); const loadCommunications = import_react15.default.useCallback(async () => { if (state.CommunicationsModule || state.isLoading) { return state.CommunicationsModule; } setState((prev) => ({ ...prev, isLoading: true, loadError: null })); try { const CommunicationsModule = await LazyLoader.importModule( () => import("react-native-communications"), "communications" ); const Communications = CommunicationsModule || null; if (!Communications || !Communications.phonecall) { throw new Error("Communications module or required methods not found"); } setState({ CommunicationsModule: Communications, isLoading: false, loadError: null }); return Communications; } catch (error) { console.warn("Failed to load Communications:", error); setState({ CommunicationsModule: null, isLoading: false, loadError: error instanceof Error ? error.message : "Unknown error" }); return null; } }, [state.CommunicationsModule, state.isLoading]); const phonecall = import_react15.default.useCallback(async (phoneNumber, prompt = false) => { const communications = await loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.phonecall(phoneNumber, prompt); }, [loadCommunications]); const email = import_react15.default.useCallback(async (to, cc, bcc, subject, body) => { const communications = await loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.email(to, cc, bcc, subject, body); }, [loadCommunications]); const text = import_react15.default.useCallback(async (phoneNumber, body) => { const communications = await loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.text(phoneNumber, body); }, [loadCommunications]); const web = import_react15.default.useCallback(async (url) => { const communications = await loadCommunications(); if (!communications) { throw new Error("Communications not available"); } return communications.web(url); }, [loadCommunications]); import_react15.default.useEffect(() => { loadCommunications(); }, [loadCommunications]); return { CommunicationsModule: state.CommunicationsModule, isLoading: state.isLoading, loadError: state.loadError, loadCommunications, phonecall, email, text, web }; }; FallbackCommunications = ({ onError }) => { import_react15.default.useEffect(() => { if (onError) { onError("Communications not available, using basic Linking fallback"); } }, [onError]); return /* @__PURE__ */ import_react15.default.createElement(import_react_native23.View, { style: styles17.fallbackContainer }, /* @__PURE__ */ import_react15.default.createElement(import_react_native23.Text, { style: styles17.fallbackText }, "Communications not available"), /* @__PURE__ */ import_react15.default.createElement(import_react_native23.Text, { style: styles17.fallbackSubText }, "Using basic device linking capabilities")); }; FallbackCommunicationsAPI = { phonecall: (phoneNumber, prompt = false) => { const url = `tel:${phoneNumber}`; if (prompt) { import_react_native23.Alert.alert( "Make Phone Call", `Call ${phoneNumber}?`, [ { text: "Cancel", style: "cancel" }, { text: "Call", onPress: () => import_react_native23.Linking.openURL(url) } ] ); } else { import_react_native23.Linking.openURL(url).catch((err) => console.error("Failed to make phone call:", err)); } }, email: (to, cc, bcc, subject, body) => { let url = "mailto:"; if (to && to.length > 0) { url += to.join(","); } const params = []; if (subject) params.push(`subject=${encodeURIComponent(subject)}`); if (body) params.push(`body=${encodeURIComponent(body)}`); if (cc && cc.length > 0) params.push(`cc=${cc.join(",")}`); if (bcc && bcc.length > 0) params.push(`bcc=${bcc.join(",")}`); if (params.length > 0) { url += "?" + params.join("&"); } import_react_native23.Linking.openURL(url).catch((err) => console.error("Failed to open email:", err)); }, text: (phoneNumber, body) => { let url = "sms:"; if (phoneNumber) { url += phoneNumber; } if (body) { url += import_react_native23.Platform.OS === "ios" ? `&body=${encodeURIComponent(body)}` : `?body=${encodeURIComponent(body)}`; } import_react_native23.Linking.openURL(url).catch((err) => console.error("Failed to open SMS:", err)); }, web: (url) => { import_react_native23.Linking.openURL(url).catch((err) => console.error("Failed to open URL:", err)); } }; styles17 = import_react_native23.StyleSheet.create({ readyContainer: { padding: 16, backgroundColor: "#e8f5e8", borderRadius: 8, alignItems: "center", justifyContent: "center" }, readyText: { fontSize: 14, color: "#2e7d2e", fontWeight: "500" }, fallbackContainer: { padding: 16, backgroundColor: "#f5f5f5", borderRadius: 8, alignItems: "center", justifyContent: "center", minHeight: 100 }, fallbackText: { fontSize: 16, color: "#666", fontWeight: "500", textAlign: "center", marginBottom: 8 }, fallbackSubText: { fontSize: 12, color: "#999", textAlign: "center" } }); LazyCommunications_default = LazyCommunications; } }); // bot-sdk/utils/PermissionAlert.js function showPermissionsAlert(title, on) { let message = "It seems you denied the access for " + title + " earlier, To enable access tap Settings and turn on " + on; import_react_native95.Alert.alert(isAndroid ? "" : message, isAndroid ? message : "", [ { text: "Cancel", onPress: () => console.log("Cancel Pressed"), style: "Cancel" }, { text: "Settings", onPress: () => import_react_native95.Linking.openSettings() } ]); } var import_react_native95; var init_PermissionAlert = __esm({ "bot-sdk/utils/PermissionAlert.js"() { "use strict"; init_cjs_shims(); import_react_native95 = require("react-native"); init_PlatformCheck(); } }); // bot-sdk/utils/PermissionsUtils.js var PermissionsUtils_exports = {}; __export(PermissionsUtils_exports, { cameraPermission: () => cameraPermission, documentPickIOSPermission: () => documentPickIOSPermission, documentPickPermission: () => documentPickPermission }); function documentPickPermission(callback = (isSuccess) => { }) { if (import_react_native96.Platform.OS !== "android") { callback(false); return; } const androidVersion = import_react_native96.Platform.Version; let permissions = []; if (androidVersion >= 33) { permissions = [ import_react_native96.PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES, import_react_native96.PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO ]; } else { permissions = [import_react_native96.PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE]; } console.log("Requesting Android permissions:", permissions, "for API level:", androidVersion); import_react_native96.PermissionsAndroid.requestMultiple(permissions).then((result) => { console.log("Permission request result:", result); let allGranted = true; let hasBlockedPermissions = false; for (const permission of permissions) { const status = result[permission]; if (status !== import_react_native96.PermissionsAndroid.RESULTS.GRANTED) { allGranted = false; if (status === import_react_native96.PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) { hasBlockedPermissions = true; } } } if (allGranted) { console.log("All Android permissions granted"); callback(true); } else { console.log("Some Android permissions denied"); callback(false); if (hasBlockedPermissions) { import_react_native96.Alert.alert( "Permission Required", "This app needs access to your photos and media files to upload images. Please enable the permissions in your device settings.", [ { text: "Cancel", style: "cancel" }, { text: "Settings", onPress: () => import_react_native96.Linking.openSettings() } ] ); } else { let title = "photos, media and files"; let on = "permission"; showPermissionsAlert(title, on); } } }).catch((error) => { console.error("Error requesting Android permissions:", error); callback(false); }); } function documentPickIOSPermission(callback = (isSuccess) => { }) { if (import_react_native96.Platform.OS !== "ios") { callback(false); return; } if (!import_react_native_permissions.PERMISSIONS || !import_react_native_permissions.check || !import_react_native_permissions.request || !import_react_native_permissions.RESULTS) { console.warn("react-native-permissions not available, trying native fallback"); tryIOSNativePermission(callback); return; } const permission = import_react_native_permissions.PERMISSIONS.IOS.PHOTO_LIBRARY; console.log("Checking iOS photo library permission"); (0, import_react_native_permissions.check)(permission).then((result) => { console.log("iOS permission check result:", result); if (result === import_react_native_permissions.RESULTS.GRANTED || result === import_react_native_permissions.RESULTS.LIMITED) { console.log("iOS photo library permission already granted"); callback(true); } else if (result === import_react_native_permissions.RESULTS.DENIED) { console.log("iOS photo library permission denied, requesting..."); return (0, import_react_native_permissions.request)(permission); } else if (result === import_react_native_permissions.RESULTS.UNAVAILABLE) { console.error("iOS photo library permission unavailable - check Podfile configuration"); tryIOSNativePermission(callback); return; } else { console.log("iOS photo library permission blocked:", result); callback(false); showPermissionBlockedAlert(); } }).then((requestResult) => { if (requestResult) { console.log("iOS permission request result:", requestResult); if (requestResult === import_react_native_permissions.RESULTS.GRANTED || requestResult === import_react_native_permissions.RESULTS.LIMITED) { console.log("iOS photo library permission granted after request"); callback(true); } else { console.log("iOS photo library permission denied after request"); callback(false); if (requestResult === import_react_native_permissions.RESULTS.BLOCKED) { showPermissionBlockedAlert(); } } } }).catch((error) => { console.error("Error with iOS photo library permission:", error); tryIOSNativePermission(callback); }); } async function tryIOSNativePermission(callback) { console.log("Trying iOS native permission fallback"); try { const ImagePicker = await import("react-native-image-picker"); if (ImagePicker && ImagePicker.requestMediaLibraryPermission) { ImagePicker.requestMediaLibraryPermission().then((granted) => { console.log("iOS native permission result:", granted); callback(granted); }).catch((error) => { console.error("iOS native permission error:", error); callback(false); }); } else { console.log("No native permission fallback available, proceeding..."); callback(true); } } catch (error) { console.error("Error with iOS native permission fallback:", error); callback(false); } } function showPermissionBlockedAlert() { import_react_native96.Alert.alert( "Permission Required", "This app needs access to your photo library to select and share images. Please enable photo library access in your device settings.", [ { text: "Cancel", style: "cancel" }, { text: "Settings", onPress: () => import_react_native96.Linking.openSettings() } ] ); } function cameraPermission(callback = (isSuccess) => { }) { if (!import_react_native_permissions.PERMISSIONS || !import_react_native_permissions.check || !import_react_native_permissions.request || !import_react_native_permissions.RESULTS) { console.warn("react-native-permissions not available for camera, trying native fallback"); tryNativeCameraPermission(callback); return; } const permission = import_react_native96.Platform.select({ android: import_react_native_permissions.PERMISSIONS.ANDROID.CAMERA, ios: import_react_native_permissions.PERMISSIONS.IOS.CAMERA }); if (!permission) { console.error("Camera permission not supported on this platform"); callback(false); return; } console.log("Checking camera permission"); (0, import_react_native_permissions.check)(permission).then((result) => { console.log("Camera permission check result:", result); if (result === import_react_native_permissions.RESULTS.GRANTED) { callback(true); } else if (result === import_react_native_permissions.RESULTS.DENIED) { console.log("Camera permission denied, requesting..."); return (0, import_react_native_permissions.request)(permission); } else if (result === import_react_native_permissions.RESULTS.UNAVAILABLE) { console.error("Camera permission unavailable - trying native fallback"); tryNativeCameraPermission(callback); return; } else { console.log("Camera permission blocked or unavailable:", result); callback(false); showCameraPermissionBlockedAlert(); } }).then((requestResult) => { if (requestResult) { console.log("Camera permission request result:", requestResult); if (requestResult === import_react_native_permissions.RESULTS.GRANTED) { callback(true); } else { callback(false); if (requestResult === import_react_native_permissions.RESULTS.BLOCKED) { showCameraPermissionBlockedAlert(); } } } }).catch((error) => { console.error("Error with camera permission:", error); tryNativeCameraPermission(callback); }); } async function tryNativeCameraPermission(callback) { console.log("Trying native camera permission fallback"); try { const ImagePicker = await import("react-native-image-picker"); if (ImagePicker && ImagePicker.requestCameraPermission) { ImagePicker.requestCameraPermission().then((granted) => { console.log("Native camera permission result:", granted); callback(granted); }).catch((error) => { console.error("Native camera permission error:", error); callback(false); }); } else { console.log("No native camera permission fallback available, proceeding..."); callback(true); } } catch (error) { console.error("Error with native camera permission fallback:", error); callback(false); } } function showCameraPermissionBlockedAlert() { import_react_native96.Alert.alert( "Camera Permission Required", "This app needs camera access to take photos. Please enable camera permission in your device settings.", [ { text: "Cancel", style: "cancel" }, { text: "Settings", onPress: () => import_react_native96.Linking.openSettings() } ] ); } var import_react_native96, import_react_native_permissions; var init_PermissionsUtils = __esm({ "bot-sdk/utils/PermissionsUtils.js"() { "use strict"; init_cjs_shims(); import_react_native96 = require("react-native"); init_PermissionAlert(); import_react_native_permissions = require("react-native-permissions"); } }); // src/index.tsx var src_exports = {}; __export(src_exports, { BOT_ICON_URL: () => BOT_ICON_URL, BRANDING_RESPONSE_FILE: () => BRANDING_RESPONSE_FILE, BotTemplate: () => BotTemplate, ChatHeaderType: () => ChatHeaderType, CustomTemplate: () => CustomTemplate_default, DATE_FORMAT: () => DATE_FORMAT, DEFAULT_PLACEHOLDER: () => DEFAULT_PLACEHOLDER, FILE_CONTEXT: () => FILE_CONTEXT, FallbackCommunications: () => FallbackCommunications, FallbackCommunicationsAPI: () => FallbackCommunicationsAPI, FallbackSound: () => FallbackSound, FallbackSoundAPI: () => FallbackSoundAPI, HeaderIconsId: () => HeaderIconsId, InputToolbar: () => InputToolbar, KORA_ITEM_CLICK: () => KORA_ITEM_CLICK, LIMIT_MESSAGE: () => LIMIT_MESSAGE, LazyCommunications: () => LazyCommunications_default, LazySound: () => LazySound_default, MAX_COMPOSER_HEIGHT: () => MAX_COMPOSER_HEIGHT, MAX_FILE_NAME_LENGTH: () => MAX_FILE_NAME_LENGTH, MAX_INPUT_TEXT_LENGTH: () => MAX_INPUT_TEXT_LENGTH, MAX_SOURCE_LIMIT: () => MAX_SOURCE_LIMIT, MAX_TOOL_BAR_HEIGHT: () => MAX_TOOL_BAR_HEIGHT, MIN_COMPOSER_HEIGHT: () => MIN_COMPOSER_HEIGHT, MIN_HEADER_HEIGHT: () => MIN_HEADER_HEIGHT, MIN_TOOL_BAR_HEIGHT: () => MIN_TOOL_BAR_HEIGHT, QuickReplies: () => QuickReplies, RENDER_KORA_BUBBLE: () => RENDER_KORA_BUBBLE, SHOW_BUTTONS_LIMIT: () => SHOW_BUTTONS_LIMIT, TEMPLATE_TYPES: () => TEMPLATE_TYPES, TIME_FORMAT: () => TIME_FORMAT, URL_VERSION: () => URL_VERSION, UUID: () => UUID, WelcomeHeaderConstants: () => WelcomeHeaderConstants, attach_menu_buttons: () => attach_menu_buttons, default: () => src_default, useLazyCommunications: () => useLazyCommunications, useLazySound: () => useLazySound }); module.exports = __toCommonJS(src_exports); init_cjs_shims(); // bot-sdk/constants/Constant.tsx init_cjs_shims(); var import_react_native = require("react-native"); var MAX_SOURCE_LIMIT = 1; var LIMIT_MESSAGE = "Only " + MAX_SOURCE_LIMIT + " sources are allowed"; var MAX_FILE_NAME_LENGTH = 24; var FILE_CONTEXT = "workflows"; var attach_menu_buttons = [ { id: 1, title: "Take Photo" }, { id: 2, title: "Upload Photo" }, { id: 3, title: "Upload File" }, { id: 4, title: "Upload Video" } ]; var HeaderIconsId = { BACK: "BACK", HELP: "HELP", LIVE_AGENT: "live_agent", MINIMISE: "Minimise", CLOSE: "CLOSE", THREE_DOTS: "THREE_DOTS", RECONNECT: "Reconnect", EXPAND: "Expand" }; var ChatHeaderType = { COMPACT: "compact", LARGE: "large", MEDIUM: "medium", REGULAR: "regular" }; var SHOW_BUTTONS_LIMIT = 4; var MAX_INPUT_TEXT_LENGTH = 256; var MIN_COMPOSER_HEIGHT = import_react_native.Platform.select({ ios: 30, android: 30 }); var MIN_TOOL_BAR_HEIGHT = import_react_native.Platform.select({ ios: 76, android: 72 }); var MAX_TOOL_BAR_HEIGHT = import_react_native.Platform.select({ ios: 180, android: 180 }); var MIN_HEADER_HEIGHT = import_react_native.Platform.select({ ios: 55, android: 55, web: 34 }); var BRANDING_RESPONSE_FILE = "branding"; var MAX_COMPOSER_HEIGHT = 200; var DEFAULT_PLACEHOLDER = "Type a message"; var DATE_FORMAT = "ll"; var TIME_FORMAT = "LT, ddd"; var BOT_ICON_URL = "BOT_ICON_URL"; var URL_VERSION = "/1.1"; var TEMPLATE_TYPES = { TEXT: "text", BUTTON: "button", CUSTOM: "custom", OTHER: "other", AUDIO_MESSAGE: "message", VIDEO_MESSAGE: "video_message", LINK_MESSAGE: "link", IMAGE_MESSAGE: "image", CARD_TEMPLATE: "cardTemplate", LIST_TEMPLATE: "list", IMAGE_TEMPLATE: "image", TABLE_TEMPLATE: "table", QUICK_REPLIES: "quick_replies", HIDDEN_DIALOG: "hidden_dialog", ERROR_TEMPLATE: "error", CAROUSEL_TEMPLATE: "carousel", LIVE_AGENT_TEMPLATE: "live_agent", SYSTEM_TEMPLATE: "SYSTEM", START_TIMER: "start_timer", ADVANCED_LIST_TEMPLATE: "advancedListTemplate", MINI_TABLE_TEMPLATE: "mini_table", BAR_CHART_TEMPLATE: "barchart", PIE_CHART_TEMPLATE: "piechart", LINE_CHART_TEMPLATE: "linechart", DATE_TEMPLATE: "dateTemplate", DATE_RANGE_TEMPLATE: "daterange", TABLE_LIST_TEMPLATE: "tableList", ADVANCED_MULTI_SELECT_TEMPLATE: "advanced_multi_select", MULTI_SELECT_TEMPLATE: "multi_select", RADIO_OPTION_TEMPLATE: "radioOptionTemplate", LIST_VIEW_TEMPLATE: "listView", DROPDOWN_TEMPLATE: "dropdown_template", FEEDBACK_TEMPLATE: "feedbackTemplate", FORM_TEMPLATE: "form_template", CLOCK_TEMPLATE: "clockTemplate", LISTWIDGET_TEMPLATE: "listWidget", USER_ATTACHEMENT_TEMPLATE: "user_attachement", ARTICLE_TEMPLATE: "articleTemplate", ANSWER_TEMPLATE: "answerTemplate", OTP_TEMPLATE: "otpValidationTemplate", RESET_PIN_TEMPLATE: "resetPinTemplate", DIGITALFORM_TEMPLATE: "digitalform" }; var RENDER_KORA_BUBBLE = "RENDER_KORA_BUBBLE"; var KORA_ITEM_CLICK = "KORA_ITEM_CLICK"; var WelcomeHeaderConstants = { COMPACT: "compact", LARGE: "large", MEDIUM: "medium", REGULAR: "regular" }; // bot-sdk/theme/IThemeType.tsx init_cjs_shims(); // bot-sdk/templates/BotTemplate.tsx init_cjs_shims(); var React80 = __toESM(require("react")); var import_react_native74 = require("react-native"); // bot-sdk/templates/AdvancedListTemplate.tsx init_cjs_shims(); var React20 = __toESM(require("react")); // bot-sdk/templates/BaseView.tsx init_cjs_shims(); var React3 = __toESM(require("react")); // bot-sdk/theme/ThemeContext.tsx init_cjs_shims(); var import_react = __toESM(require("react")); var import_async_storage = __toESM(require("@react-native-async-storage/async-storage")); // bot-sdk/theme/AppTheme.tsx init_cjs_shims(); var defaultTheme = { _id: "wsth-b578c51a-0518-57ad-bbb3-7f404a053528", streamId: "st-b0439232-9345-508f-a1fb-cfcb5099c1fa", __v: 0, activeTheme: true, createdBy: "u-e10dd737-167e-5e46-88d0-a2b55394f0f3", createdOn: "2023-11-28T09:33:19.921Z", defaultTheme: true, lastModifiedBy: "u-e10dd737-167e-5e46-88d0-a2b55394f0f3", lastModifiedOn: "2023-11-28T11:05:43.265Z", refId: "06ad9db9-fb35-5632-b9b1-7dabacc323b1", state: "published", themeName: "Default dark theme 2", v3: { general: { bot_icon: "url", size: "small", themeType: "light", colors: { primary: "#a37645", secondary: "#101828", primary_text: "#ffffff", secondary_text: "#1d2939", useColorPaletteOnly: false } }, chat_bubble: { style: "rounded", icon: { icon_url: "icon-1.svg", size: "medium", type: "default" }, minimise: { icon: "m-icon-1.svg", theme: "rounded", type: "default" }, sound: "themeOne", alignment: "block", animation: "slide", expand_animation: "quick", primary_color: "#a37645", secondary_color: "#1d2939" }, welcome_screen: { show: true, layout: "medium", logo: { logo_url: "/images/sc-small.svg" }, title: { name: "Hello" }, sub_title: { name: "Welcome to Kore.ai" }, note: { name: "Our Community is ready to help you to join our best platform" }, background: { type: "color", color: "#a37645", img: "https://picsum.photos/seed/picsum/200/300" }, top_fonts: { color: "#ffffff" }, bottom_background: { color: "#1d2939" }, templates: [], starter_box: { show: true, icon: { show: true }, title: "Start New Conversation", sub_text: "I'm your personal assistant I'm here to help", start_conv_button: { color: "#a37645" }, start_conv_text: { color: "#ffffff" }, quick_start_buttons: { show: true, style: "slack", buttons: [ { title: "Contact Sales", action: { type: "postback", value: "Contact Sales" } }, { title: "Free Trail", action: { type: "postback", value: "Free Trail" } }, { title: "Support", action: { type: "postback", value: "Support" } }, { title: "Hours of Operation", action: { type: "postback", value: "Hours of Operation" } }, { title: "Kore.ai", action: { type: "postback", value: "https://kore.ai/" } } ], input: "button", action: { type: "postback", value: "Hello" } } }, static_links: { show: true, layout: "carousel", links: [ { title: "Kore.ai", description: "Kore.ai automates front-office and back-office interactions", action: { type: "url", value: "https://kore.ai/" } }, { title: "Kore", description: "Kore.ai automates front-office and back-office interactions", action: { type: "url", value: "https://kore.ai/" } } ] }, promotional_content: { show: true, promotions: [ { banner: "https://picsum.photos/seed/picsum/200/300", action: { type: "url", value: "http://abc.com" } }, { banner: "https://picsum.photos/seed/picsum/200/300", action: { type: "url", value: "http://abc.com" } } ] } }, header: { bg_color: "#EAECF0", size: "compact", icon: { show: true, icon_url: "/images/avatar-bot.svg", //icon_url : "icon-1" type: "default" }, icons_color: "#000000", title: { name: "Support", color: "#000000" }, sub_title: { name: "Your personal assistant", color: "#000000" }, buttons: { close: { show: true, icon: "/images/close-large.svg" }, minimise: { show: true, icon: "url|icomoon" }, expand: { show: false, icon: "url|icomoon" }, reconnect: { show: false, icon: "url|icomoon" }, help: { show: true, action: { type: "postback|url", value: "https://kore.ai", icon: "url|icomoon" } }, live_agent: { show: true, action: { type: "postback|url", value: "https://kore.ai", icon: "url|icomoon" } } } }, footer: { bg_color: "#EAECF0", layout: "keypad", compose_bar: { bg_color: "#fffffe", "outline-color": "#E5E5E5", placeholder: "Type a message" }, icons_color: "#000000", buttons: { menu: { show: true, icon_color: "#000000", actions: [ { title: "About", type: "postback", value: "About", icon: "url|icomoon" }, { title: "Kore.ai", type: "url", value: "https://kore.ai/", icon: "url|icomoon" } ] }, emoji: { show: true, icon: "url|icomoon" }, microphone: { show: true, icon: "url|icomoon" }, speaker: { show: false, icon: "" }, attachment: { show: true, icon: "url|icomoon" } } }, body: { background: { type: "color", color: "#FFFFFF", img: "https://picsum.photos/id/237/200/300" }, font: { family: "Inter", size: "medium", style: "1|2|3" }, user_message: { bg_color: "#a37645", color: "#FFFFFF" }, bot_message: { bg_color: "#4B4EDE", color: "#ffffff" }, agent_message: { bg_color: "#4B4EDE", color: "#0D6EFD", separator: "2", icon: { show: "true|false", icon_url: "icomoon|url" }, title: { name: "Agent Support", color: "#1d2939" }, sub_title: { name: "Agent support", color: "#0D6EFD" } }, time_stamp: { show: true, show_type: "always", position: "bottom", separator: "line", color: "#1d2939" }, icon: { show: true, user_icon: false, bot_icon: true, agent_icon: true }, buttons: { bg_color: "#a37645", color: "white" }, bubble_style: "balloon", primaryColor: "#3f42d4", primaryHoverColor: "#de4bbc", secondaryColor: "#3639e6", secondaryHoverColor: "#b1b2f9", img: "6495705b0d5bbd027d2e39ad" } }, version: "3.0.0" }; // bot-sdk/theme/ThemeContext.tsx var ThemeContext = (0, import_react.createContext)(void 0); var ThemeProvider = class extends import_react.Component { state = { theme: defaultTheme }; componentDidMount() { this.fetchThemeFromDB(); } fetchThemeFromDB = async () => { try { import_async_storage.default.getItem(BRANDING_RESPONSE_FILE, (error, result) => { if (result) { const savedTheme = JSON.parse(result); this.setState({ theme: savedTheme }); } }); } catch (error) { console.log("Error fetching theme from local storage:", error); } }; render() { return /* @__PURE__ */ import_react.default.createElement(ThemeContext.Provider, { value: this.state.theme }, this.props.children); } }; // bot-sdk/templates/BaseView.tsx var BaseView = class extends React3.Component { static contextType = ThemeContext; static propTypes; constructor(props) { super(props); } static defaultProps; isViewDisable = () => { return this.props.onBottomSheetClose ? false : !this.props.payload?.isLastMessage || false; }; // protected getTemplateWidth = () => { // const value = this.props?.theme?.v3?.body?.icon?.show // ? normalize(50) // : normalize(30); // return windowWidth - value; // }; }; var BaseView_default = BaseView; // bot-sdk/templates/AdvancedListTemplate.tsx var import_react_native11 = require("react-native"); // bot-sdk/utils/helpers.tsx init_cjs_shims(); var React5 = __toESM(require("react")); var import_react_native3 = require("react-native"); var import_dayjs = __toESM(require("dayjs")); // bot-sdk/theme/Color.tsx init_cjs_shims(); var Color_default = { defaultColor: "#b2b2b2", backgroundTransparent: "transparent", transparent: "transparent", defaultBlue: "#0084ff", leftBubbleBackground: "#f0f0f0", carrot: "#e67e22", emerald: "#2ecc71", peterRiver: "#3498db", wisteria: "#8e44ad", alizarin: "#e74c3c", midnightBlue: "#2c3e50", optionTintColor: "#007AFF", timeTextColor: "#aaa", bot_blue: "#4B4EDE", red: "#FF0000", green: "#009933", //'#00FF00', blue: "#0000FF", cyan: "#00FFFF", magenta: "#FF00FF", yellow: "#FFFF00", black: "#000000", white: "#FFFFFF", gray: "#808080", silver: "#C0C0C0", maroon: "#800000", olive: "#808000", navy: "#000080", purple: "#800080", teal: "#008080", indigo: "#4B0082", orange: "#FFA500", pink: "#FFC0CB", violet: "#EE82EE", peach: "#FFDAB9", lavender: "#E6E6FA", coral: "#FF7F50", turquoise: "#40E0D0", chocolate: "#D2691E", lime: "#00FF00", gold: "#FFD700", crimson: "#DC143C", plum: "#DDA0DD", slate: "#708090", khaki: "#F0E68C", aquamarine: "#7FFFD4", bisque: "#FFE4C4", cornsilk: "#FFF8DC", firebrick: "#B22222", midnightblue: "#191970", text_color: "#444444", sub_text_color: "#A4A4A4", button_blue: "#303f9f", header_blue: "#2D5BCC" }; // bot-sdk/utils/colorMappings.tsx init_cjs_shims(); var ColorMappings = { ...Color_default }; var colorMappings_default = ColorMappings; // bot-sdk/utils/RenderImage.tsx init_cjs_shims(); var import_react2 = __toESM(require("react")); var import_react_native2 = require("react-native"); var import_css = require("react-native-svg/css"); // bot-sdk/assets/index.tsx init_cjs_shims(); var images = { article: require("./images/article.png"), back: require("./images/back.png"), blur: require("./images/blur.png"), close: require("./images/close.png"), decrease10Seconds: require("./images/decrease10Seconds.png"), dot: require("./images/dot.png"), error: require("./images/error.png"), exitFullScreen: require("./images/exitFullScreen.png"), expand: require("./images/expand.png"), eye: require("./images/eye.png"), fullScreen: require("./images/fullScreen.png"), fullSound: require("./images/fullSound.png"), ic_automation_ai: require("./images/ic_automation_ai.png"), increase10Seconds: require("./images/increase10Seconds.png"), muteSound: require("./images/muteSound.png"), pause: require("./images/pause.png"), play: require("./images/play.png"), playlist: require("./images/playlist.png"), quality: require("./images/quality.png"), settings: require("./images/settings.png"), soundMixer: require("./images/soundMixer.png"), speed: require("./images/speed.png") }; var placeholder = { default_bot_icon: require("./placeholder/default_bot_icon.png"), digitalForm: require("./placeholder/digitalForm.png"), download: require("./placeholder/download.png"), image: require("./placeholder/image.png"), mobile: require("./placeholder/mobile.png"), pdf: require("./placeholder/pdf.png") }; // bot-sdk/utils/RenderImage.tsx var RenderImage = class extends import_react2.Component { constructor(props) { super(props); this.state = { error: false }; } handleSvgError = () => { this.setState({ error: true }); }; render() { let { image = "", iconShape = void 0, iconSize = "", width: width8 = 10, height = 10 } = this.props; const { error } = this.state; if (!image || image.length === 0) { return null; } let fileExtension = image?.split?.(".")?.pop()?.toLowerCase(); if (iconSize && iconSize.trim() !== "") { switch (iconSize) { case "small": width8 = 16; height = 16; break; case "medium": width8 = 22; height = 22; break; case "large": width8 = 35; height = 35; break; default: width8 = 16; height = 16; } } return /* @__PURE__ */ import_react2.default.createElement( import_react_native2.View, { style: { ...styles.image_container, height: normalize(height), width: normalize(width8) } }, fileExtension === "svg" ? /* @__PURE__ */ import_react2.default.createElement( import_css.SvgCssUri, { uri: error ? placeholder.image : image, height: normalize(height), width: normalize(width8), style: { overflow: "hidden", borderWidth: iconShape !== ICON_SHAPE.CIRCLE_IMG ? 1 : 0, borderRadius: iconShape !== ICON_SHAPE.CIRCLE_IMG ? 5 : 0 }, onError: this.handleSvgError } ) : this.state.error ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null) : /* @__PURE__ */ import_react2.default.createElement( import_react_native2.Image, { source: { uri: image }, style: { ...styles.unfurlUrl4, borderRadius: iconShape === ICON_SHAPE.CIRCLE_IMG ? 150 / 2 : 0, overflow: "hidden", height: normalize(height), width: normalize(width8) }, resizeMode: "contain", onError: () => { this.setState({ error: true }); console.log("Image loading error:"); } } ) ); } }; var ICON_SHAPE = { CIRCLE_IMG: "circle-img" }; var styles = { image_container: {}, // Define your image container styles unfurlUrl4: { borderColor: "gray", resizeMode: "cover", //alignSelf: 'center', // borderRadius: 6, //alignContent: 'center', overflow: "hidden" } }; var RenderImage_default = RenderImage; // bot-sdk/utils/helpers.tsx var { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = import_react_native3.Dimensions.get("window"); var NEW_SCREEN_WIDTH = SCREEN_WIDTH > SCREEN_HEIGHT ? SCREEN_HEIGHT : SCREEN_WIDTH; var scale = NEW_SCREEN_WIDTH / 375; var imageTypes = [ "bmp", "dds", "gif", "heic", "jpg", "png", "psd", "pspimage", "tga", "thm", "tif", "tiff", "yuv", "jpeg" ]; var videoTypes = [ "3g2", "3gp", "asf", "avi", "flv", "m4v", "mov", "mp4", "mpg", "rm", "srt", "swf", "vob", "wmv" ]; var renderImage = ({ image, iconShape = void 0, iconSize = "", width: width8 = 10, height = 10 }) => { return /* @__PURE__ */ React5.createElement( RenderImage_default, { image, iconShape, iconSize, width: width8, height } ); }; function createDateRange(start, end) { const startDate = (0, import_dayjs.default)(start); const endDate = (0, import_dayjs.default)(end); let currentDate = startDate; const dateArray = []; while (currentDate.isBefore(endDate) || currentDate.isSame(endDate)) { dateArray.push(currentDate.toDate()); currentDate = currentDate.add(1, "day"); } return dateArray; } function padZero(str, len) { len = len || 2; var zeros = new Array(len).join("0"); return (zeros + str).slice(-len); } function invertColor(hex, bw) { if (hex.indexOf("#") === 0) { hex = hex.slice(1); } if (hex.length !== 6) { const hexValue = colorMappings_default[hex?.toLowerCase()]; if (!hexValue) { return Color_default.black; } hex = hexValue; } if (!hex