<script lang="ts">
import { widgetOptions } from '@/modules/options'
import { t } from '@/modules/translations'
import { escape } from '@/utils/escapeHtml'
import { linkify } from '@/utils/linkify'

import { GDPR_PLACEHOLDER_URL } from '../constants'
import PrivacyNotice from './content/PrivacyNotice.svelte'

export let text: string
export let replaceText = ''
export let clamp = widgetOptions.getOptions().urlCardsEnabled
const isGdprNoticeText = text.match(GDPR_PLACEHOLDER_URL)
</script>

{#if isGdprNoticeText}
	{@html escape(text.replace(GDPR_PLACEHOLDER_URL, ''))}
	<div class="flex items-left -mt-3 pb-1">
		<PrivacyNotice label={$t('topBar.gdprTitle')} />
	</div>
{:else}
	{@html linkify(text, { replaceText, clamp })}
{/if}
