<?php
$row = $row ?? [];
$meta = trim((string) ($row['meta'] ?? ''));
$occurrenceId = (int) ($row['occurrence_id'] ?? 0);
$taskId = (int) ($row['task_id'] ?? 0);
$recurring = (int) ($row['is_recurring'] ?? 0) === 1 ? '1' : '0';
$status = (string) ($row['status'] ?? 'pending');
$title = (string) ($row['title'] ?? '');
$editHref = site_url((string) ($row['edit_path'] ?? ('tasks/' . $taskId . '/edit')));
$titleHtml = (string) ($row['title_html'] ?? '');
$showPriority = ! empty($showPriority);
$priorityLabel = trim((string) ($row['priority_label'] ?? ''));
?>
<div class="task-swipe" data-occurrence-id="<?= $occurrenceId ?>" data-task-id="<?= $taskId ?>" data-recurring="<?= $recurring ?>" data-status="<?= esc($status) ?>">
    <div class="task-swipe-actions" aria-hidden="true">
        <button type="button" class="swipe-complete" data-complete>Complete</button>
        <button type="button" class="swipe-delete" data-delete>Delete</button>
    </div>
    <div class="task-swipe-front">
        <a class="task-row" href="<?= esc($editHref) ?>">
            <?php if ($meta !== ''): ?>
                <span class="task-meta"><?= esc($meta) ?></span>
            <?php endif; ?>
            <span class="task-title"><?= $titleHtml !== '' ? $titleHtml : esc($title) ?></span>
            <?php if ($showPriority && $priorityLabel !== ''): ?>
                <span class="task-priority"><?= esc($priorityLabel) ?></span>
            <?php endif; ?>
        </a>
        <div class="task-row-fallback">
            <button type="button" class="fallback-btn" data-complete>Complete</button>
            <button type="button" class="fallback-btn" data-delete>Delete</button>
        </div>
    </div>
</div>
