import { TextInput, NumberInput } from '@/components/inputs' import { Stack, Text } from '@chakra-ui/react' import { EmbedBubbleBlock, Variable } from '@typebot.io/schemas' import { sanitizeUrl } from '@typebot.io/lib' import { useTranslate } from '@tolgee/react' import { defaultEmbedBubbleContent } from '@typebot.io/schemas/features/blocks/bubbles/embed/constants' import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings' import { VariableSearchInput } from '@/components/inputs/VariableSearchInput' type Props = { content: EmbedBubbleBlock['content'] onSubmit: (content: EmbedBubbleBlock['content']) => void } export const EmbedUploadContent = ({ content, onSubmit }: Props) => { const { t } = useTranslate() const handleUrlChange = (url: string) => { const iframeUrl = sanitizeUrl( url.trim().startsWith('['height'] ) => height && onSubmit({ ...content, height }) const updateWaitEventName = (name: string) => onSubmit({ ...content, waitForEvent: { ...content?.waitForEvent, name } }) const updateWaitForEventEnabled = (isEnabled: boolean) => onSubmit({ ...content, waitForEvent: { ...content?.waitForEvent, isEnabled }, }) const updateSaveDataInVariableId = (variable?: Pick) => onSubmit({ ...content, waitForEvent: { ...content?.waitForEvent, saveDataInVariableId: variable?.id, }, }) return ( {t('editor.blocks.bubbles.embed.settings.worksWith.text')} ) } const extractUrlFromIframe = (iframe: string) => [...iframe.matchAll(/src="([^"]+)"/g)][0][1]