
<?php
    $itMode = $itMode ?? 'day';
    $isDayIt = $itMode === 'day';
    $items = $items ?? $tour->activeItineraries;

    $storeUrl = route("$editBase.itinerary.store", $tour);

    $actTypes = \App\Support\ItineraryActivity::LABELS;
    $actOptions = \App\Support\ItineraryActivity::options();

    /** Tek satır tanımı — ledger-row ile aynı sözleşme. */
    $itRow = function (string $label, ?string $field, $value, ?string $text = null, array $o = []) {
        return [
            'label' => $label,
            'field' => $field,
            'type' => $o['type'] ?? 'text',
            'value' => $value === null ? '' : (string) $value,
            'text' => $text === null ? ($value === null ? '' : (string) $value) : $text,
            'options' => $o['options'] ?? null,
            'mono' => $o['mono'] ?? false,
            'ph' => $o['ph'] ?? null,
        ];
    };

    /** HTML açıklamadan tek satırlık özet metin. */
    $itPlain = fn ($html) => trim(preg_replace('/\s+/u', ' ', html_entity_decode(strip_tags((string) $html), ENT_QUOTES, 'UTF-8')));

    $itCount = $items->count();
    $itMinutes = $isDayIt ? (int) $items->sum('duration_minutes') : 0;
    $itDays = $isDayIt ? 0 : $items->pluck('day_number')->filter()->unique()->count();
    $itNextDay = $isDayIt ? null : (int) ($items->max('day_number') ?? 0) + 1;
    $itCols = $isDayIt ? 6 : 4;
?>

<div class="pit" data-pit>

    
    <div class="pit-bar">
        <span class="pit-t"><i class="fas fa-route"></i> Tur Programı</span>
        <span class="pit-m"><b><?php echo e($itCount); ?></b> başlık</span>
        <?php if($isDayIt && $itMinutes > 0): ?>
            <span class="pit-sep"></span>
            <span class="pit-m"><b><?php echo e(intdiv($itMinutes, 60)); ?></b> sa <b><?php echo e($itMinutes % 60); ?></b> dk toplam</span>
        <?php elseif(!$isDayIt && $itDays > 0): ?>
            <span class="pit-sep"></span>
            <span class="pit-m"><b><?php echo e($itDays); ?></b> gün</span>
        <?php endif; ?>

        <span class="pit-grow"></span>

        <?php if($itCount > 1): ?>
            <button type="button" class="pfx-chip" data-pit-all title="Tüm başlıkların alanlarını aç / kapat">
                <i class="fas fa-chevron-down"></i> Tümünü aç
            </button>
        <?php endif; ?>
        <button type="button" class="pit-add" data-pqv-toggle="#itin-add">
            <i class="fas fa-plus"></i> Başlık Ekle
        </button>
    </div>

    
    <form id="itin-add" class="pit-new pqv-collapse" data-pqv-save data-method="POST"
          data-reload-tab="itinerary" action="<?php echo e($storeUrl); ?>">
        <div class="pit-new-h"><i class="fas fa-plus"></i> Yeni Program Başlığı</div>
        <div class="pit-new-g">
            <?php if($isDayIt): ?>
                <label class="pit-f pit-f-s"><span>Saat</span><input type="time" name="time"></label>
                <label class="pit-f pit-f-w"><span>Başlık <b>*</b></span><input type="text" name="title" required placeholder="Örn. Kahvaltı molası"></label>
                <label class="pit-f"><span>Konum</span><input type="text" name="location" placeholder="Örn. Şile sahil"></label>
                <label class="pit-f pit-f-s"><span>Süre (dk)</span><input type="number" name="duration_minutes" min="0" placeholder="45"></label>
                <label class="pit-f"><span>Aktivite Tipi</span>
                    <select name="activity_type">
                        <option value="">—</option>
                        <?php $__currentLoopData = $actTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v => $l): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($v); ?>"><?php echo e($l); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </label>
            <?php else: ?>
                <label class="pit-f pit-f-s"><span>Gün <b>*</b></span><input type="number" name="day_number" min="1" value="<?php echo e($itNextDay); ?>" required></label>
                <label class="pit-f pit-f-w"><span>Başlık <b>*</b></span><input type="text" name="title" required placeholder="Örn. İstanbul şehir turu"></label>
                <label class="pit-f"><span>Konum</span><input type="text" name="location" placeholder="Örn. Sultanahmet Meydanı"></label>
            <?php endif; ?>
        </div>
        <div class="pit-new-f">
            <span><i class="fas fa-bolt"></i> Açıklamayı ekledikten sonra satırı açıp yazabilirsiniz.</span>
            <button type="button" class="pit-cancel" data-pqv-toggle="#itin-add">Vazgeç</button>
            <button type="submit" class="pit-save"><i class="fas fa-check"></i> Ekle</button>
        </div>
    </form>

    
    <?php if($itCount): ?>
        <div class="pit-wrap">
            <table class="pit-tbl">
                <colgroup>
                    <col style="width:64px">
                    <col>
                    <col style="width:<?php echo e($isDayIt ? '20%' : '26%'); ?>">
                    <?php if($isDayIt): ?>
                        <col style="width:66px">
                        <col style="width:96px">
                    <?php endif; ?>
                    <col style="width:58px">
                </colgroup>
                <thead>
                    <tr>
                        <th><?php echo e($isDayIt ? 'Saat' : 'Gün'); ?></th>
                        <th>Başlık</th>
                        <th>Konum</th>
                        <?php if($isDayIt): ?><th class="ta-r">Süre</th><th>Tip</th><?php endif; ?>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $it): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $fieldUrl = route("$editBase.itinerary.update-field", [$tour, $it]);
                            $itTime = $isDayIt ? substr((string) ($it->time ?? ''), 0, 5) : '';
                            $snip = $itPlain($it->description);

                            $rows = $isDayIt
                                ? [
                                    $itRow('Başlık', 'title', $it->title, null, ['ph' => 'Program başlığı']),
                                    $itRow('Saat', 'time', $itTime, $itTime, ['type' => 'time', 'mono' => true]),
                                    $itRow('Süre (dk)', 'duration_minutes', $it->duration_minutes, $it->duration_minutes ? $it->duration_minutes . ' dk' : '', ['type' => 'number', 'mono' => true]),
                                    $itRow('Konum', 'location', $it->location, null, ['ph' => 'Buluşma / gezi noktası']),
                                    $itRow('Aktivite Tipi', 'activity_type', $it->activity_type, $actTypes[$it->activity_type] ?? '', ['type' => 'select', 'options' => $actOptions]),
                                    $itRow('Sıra', 'sort_order', $it->sort_order, null, ['type' => 'number', 'mono' => true]),
                                ]
                                : [
                                    $itRow('Gün No', 'day_number', $it->day_number, null, ['type' => 'number', 'mono' => true]),
                                    $itRow('Başlık', 'title', $it->title, null, ['ph' => 'Gün başlığı']),
                                    $itRow('Konum', 'location', $it->location, null, ['ph' => 'Şehir / bölge']),
                                ];
                        ?>

                        <tr class="pit-r" data-pit-row tabindex="0">
                            <td class="pit-key">
                                <?php if($isDayIt): ?>
                                    <span class="pit-time <?php echo e($itTime === '' ? 'none' : ''); ?>" data-pit-cell="time"><?php echo e($itTime ?: '—'); ?></span>
                                <?php else: ?>
                                    <span class="pit-day"><small>GÜN</small><b data-pit-cell="day_number"><?php echo e($it->day_number); ?></b></span>
                                <?php endif; ?>
                            </td>
                            <td class="pit-main">
                                <span class="pit-tt">
                                    <b data-pit-cell="title"><?php echo e($it->title); ?></b>
                                    <em data-pit-cell="snip" title="<?php echo e($snip); ?>"><?php echo e($snip); ?></em>
                                </span>
                            </td>
                            <td class="pit-loc">
                                <span data-pit-cell="location" class="<?php echo e($it->location ? '' : 'none'); ?>">
                                    <?php if($it->location): ?><i class="fas fa-location-dot"></i><?php endif; ?><?php echo e($it->location ?: '—'); ?>

                                </span>
                            </td>
                            <?php if($isDayIt): ?>
                                <td class="pit-dur ta-r"><span data-pit-cell="duration_minutes" class="<?php echo e($it->duration_minutes ? '' : 'none'); ?>"><?php echo e($it->duration_minutes ? $it->duration_minutes . ' dk' : '—'); ?></span></td>
                                <td class="pit-typ">
                                    <span data-pit-cell="activity_type" class="pit-tag <?php echo e($it->activity_type ? '' : 'none'); ?>"><?php echo e($actTypes[$it->activity_type] ?? '—'); ?></span>
                                </td>
                            <?php endif; ?>
                            <td class="pit-acts">
                                <button type="button" class="pit-b" data-pit-open tabindex="-1" title="Alanları aç / kapat"><i class="fas fa-chevron-down"></i></button>
                                <button type="button" class="pit-b danger" tabindex="-1" title="Başlığı sil"
                                        data-pqv-delete="<?php echo e(route("$editBase.itinerary.destroy", [$tour, $it])); ?>" data-reload-tab="itinerary">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </td>
                        </tr>

                        <tr class="pit-d">
                            <td colspan="<?php echo e($itCols); ?>">
                                <div class="pfx pit-pfx show-empty" data-url="<?php echo e($fieldUrl); ?>">
                                    <div class="pfx-top">
                                        <span class="pfx-top-t">
                                            <i class="fas <?php echo e($isDayIt ? 'fa-clock' : 'fa-calendar-day'); ?>"></i>
                                            <?php echo e($isDayIt ? ($itTime ?: 'Saatsiz başlık') : 'Gün ' . $it->day_number); ?>

                                        </span>
                                        <button type="button" class="pfx-chip" data-a="empties" title="Doldurulmamış alanları göster / gizle">
                                            <i class="fas fa-eye-slash"></i> <span data-role="empties-n"><?php echo e(collect($rows)->filter(fn ($r) => blank(trim((string) $r['text'])))->count()); ?></span> boş
                                        </button>
                                        <button type="button" class="pfx-chip" data-a="copy-all" title="Başlığın tüm bilgilerini kopyala">
                                            <i class="fas fa-clone"></i> Tümü
                                        </button>
                                    </div>

                                    <section class="pfx-sec">
                                        <?php $__currentLoopData = $rows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php echo $__env->make('components.quick-view.ledger-row', ['r' => $r], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </section>

                                    <div class="pfx-body">
                                        <?php echo $__env->make('agency.products._qv-quill-inline', [
                                            'name' => 'description',
                                            'label' => 'Açıklama',
                                            'value' => $it->description,
                                            'uf' => $fieldUrl,
                                            'defs' => $attractions ?? null,
                                            'defsMode' => 'item',
                                            'defsLabel' => 'Gezilecek yer ekle',
                                            'defsIcon' => 'fa-map-location-dot',
                                        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>

        <div class="pit-foot">
            <i class="fas fa-bolt"></i> Satıra tıklayın, alanı tıklayıp yazın — değişiklik anında kaydedilir.
        </div>
    <?php else: ?>
        <div class="pit-empty">
            <i class="fas fa-route"></i>
            <b>Henüz program başlığı yok</b>
            <span><?php echo e($isDayIt ? 'Turun gün içindeki akışını saat saat ekleyin.' : 'Turun gün gün akışını ekleyin.'); ?></span>
            <button type="button" class="pit-add" data-pqv-toggle="#itin-add"><i class="fas fa-plus"></i> İlk Başlığı Ekle</button>
        </div>
    <?php endif; ?>
</div>


<?php echo $__env->make('components.quick-view.ledger-ui', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<?php if (! $__env->hasRenderedOnce('187536d5-cd35-41cc-9ea9-b08fc631b4f2')): $__env->markAsRenderedOnce('187536d5-cd35-41cc-9ea9-b08fc631b4f2'); ?>
<style>
    /* ═══ Program tablosu (pit) — ledger diliyle aynı palet ═══ */
    .pit-bar { display: flex; align-items: center; gap: .5rem; padding: 0 .1rem .55rem; }
    .pit-t { font-size: .74rem; font-weight: 800; color: #0f172a; letter-spacing: -.01em; white-space: nowrap; }
    .pit-t i { color: #2563eb; margin-right: 6px; }
    .pit-m { font-size: .66rem; font-weight: 650; color: #94a3b8; white-space: nowrap; }
    .pit-m b { color: #475569; font-weight: 800; font-variant-numeric: tabular-nums; }
    .pit-sep { width: 1px; height: 11px; background: #e2e8f0; }
    .pit-grow { flex: 1; }

    .pit-add {
        display: inline-flex; align-items: center; gap: 5px;
        border: 0; border-radius: 8px; padding: 4px 10px; cursor: pointer;
        background: #0f172a; color: #fff;
        font: inherit; font-size: .68rem; font-weight: 700;
        transition: background .14s, transform .14s;
    }
    .pit-add:hover { background: #1d4ed8; transform: translateY(-1px); }
    .pit-add i { font-size: .62rem; }

    /* ── Yeni başlık formu ── */
    .pit-new {
        border: 1px solid #dbeafe; border-radius: 14px; background: #f8fbff;
        padding: .6rem .7rem .55rem; margin-bottom: .7rem;
    }
    .pit-new-h { font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #1d4ed8; margin-bottom: .5rem; }
    .pit-new-h i { font-size: .6rem; margin-right: 4px; }
    .pit-new-g { display: flex; flex-wrap: wrap; gap: .45rem; }
    .pit-f { display: flex; flex-direction: column; gap: 3px; flex: 1 1 150px; min-width: 0; margin: 0; }
    .pit-f.pit-f-s { flex: 0 0 92px; }
    .pit-f.pit-f-w { flex: 2 1 220px; }
    .pit-f > span { font-size: .6rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #94a3b8; }
    .pit-f > span b { color: #ef4444; font-weight: 800; }
    .pit-f input, .pit-f select {
        width: 100%; border: 1px solid #dbe6f5; border-radius: 8px; background: #fff;
        padding: 4px 8px; font: inherit; font-size: .78rem; font-weight: 600; color: #0f172a;
        outline: none; transition: border-color .13s, box-shadow .13s;
    }
    .pit-f input:focus, .pit-f select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
    .pit-new-f { display: flex; align-items: center; gap: .45rem; margin-top: .55rem; }
    .pit-new-f > span { flex: 1; min-width: 0; font-size: .63rem; font-weight: 600; color: #a9b7ca; }
    .pit-new-f > span i { color: #cbd5e1; margin-right: 3px; }
    .pit-cancel, .pit-save {
        border: 1px solid transparent; border-radius: 8px; padding: 4px 11px; cursor: pointer;
        font: inherit; font-size: .68rem; font-weight: 700; transition: background .14s, color .14s;
    }
    .pit-cancel { background: #fff; border-color: #e2e8f0; color: #64748b; }
    .pit-cancel:hover { color: #0f172a; border-color: #cbd5e1; }
    .pit-save { background: #2563eb; color: #fff; }
    .pit-save:hover { background: #1d4ed8; }
    .pit-save i { font-size: .62rem; margin-right: 3px; }

    /* ── Tablo ── */
    .pit-wrap {
        border: 1px solid #e6ecf5; border-radius: 16px; background: #fff; overflow: hidden;
        box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    }
    .pit-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
    .pit-tbl thead th {
        padding: .42rem .7rem .34rem; text-align: left;
        background: linear-gradient(180deg, #fbfdff, #f5f9ff); border-bottom: 1px solid #eef2f7;
        font-size: .58rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; color: #9aa7bb;
    }
    .pit-tbl .ta-r { text-align: right; }

    .pit-r { cursor: pointer; transition: background .12s; }
    .pit-r > td { padding: 4px .7rem; border-top: 1px solid #f4f7fb; vertical-align: middle; position: relative; }
    .pit-r:hover > td, .pit-r.is-open > td { background: #f7faff; }
    .pit-r:focus-visible { outline: none; }
    .pit-r:focus-visible > td { background: #eff6ff; }
    /* Açık satırın sol kenarındaki mavi işaret — ledger satırındaki ile aynı dil */
    .pit-r > td:first-child::before {
        content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 2px;
        border-radius: 0 2px 2px 0; background: transparent; transition: background .16s;
    }
    .pit-r.is-open > td:first-child::before { background: #2563eb; }

    .pit-key { white-space: nowrap; }
    .pit-time { font-size: .8rem; font-weight: 750; color: #0f172a; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
    .pit-time.none { color: #cbd5e1; font-weight: 500; }
    .pit-day { display: inline-flex; align-items: baseline; gap: 4px; }
    .pit-day small { font-size: .52rem; font-weight: 800; letter-spacing: .1em; color: #b6c2d2; }
    .pit-day b { font-size: .84rem; font-weight: 800; color: #1d4ed8; font-variant-numeric: tabular-nums; }

    .pit-tt { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
    .pit-tt b { font-size: .815rem; font-weight: 650; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; flex: none; }
    .pit-tt em {
        flex: 1; min-width: 0; font-style: normal;
        font-size: .69rem; font-weight: 550; color: #a9b7ca; line-height: 1.3;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .pit-tt em:not(:empty)::before { content: "— "; color: #d7e0ec; }

    .pit-loc span { font-size: .72rem; font-weight: 600; color: #64748b; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .pit-loc i { color: #cbd5e1; font-size: .62rem; margin-right: 4px; }
    .pit-loc span.none, .pit-dur span.none { color: #cbd5e1; font-weight: 500; }
    .pit-dur span { font-size: .74rem; font-weight: 650; color: #475569; font-variant-numeric: tabular-nums; }

    .pit-tag {
        display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        font-size: .6rem; font-weight: 800; line-height: 1;
        color: #4338ca; background: #eef2ff; border-radius: 6px; padding: 3px 6px;
    }
    .pit-tag.none { color: #cbd5e1; background: transparent; padding: 0; font-weight: 500; }

    .pit-acts { text-align: right; white-space: nowrap; }
    .pit-acts .pit-b { opacity: 0; transition: opacity .13s, color .13s, background .13s, transform .2s; }
    .pit-r:hover .pit-b, .pit-r.is-open .pit-b, .pit-r:focus-within .pit-b { opacity: 1; }
    @media (hover: none) { .pit-acts .pit-b { opacity: 1; } }
    .pit-b {
        width: 20px; height: 20px; border: 0; border-radius: 6px; background: transparent;
        color: #c3cddc; cursor: pointer; display: inline-grid; place-items: center; font-size: .62rem;
    }
    .pit-b:hover { color: #2563eb; background: #eff6ff; }
    .pit-b.danger:hover { color: #ef4444; background: #fee2e2; }
    .pit-r.is-open [data-pit-open] i { transform: rotate(180deg); }
    [data-pit-open] i { transition: transform .2s; }

    /* ── Açılan defter paneli ── */
    .pit-d { display: none; }
    .pit-d.on { display: table-row; }
    .pit-d > td { padding: 0; background: #fbfdff; border-top: 1px solid #eef2f7; }
    .pit-pfx { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
    .pit-pfx > .pfx-top { background: transparent; border-radius: 0; border-bottom-color: #eef2f7; }
    .pit-pfx .pfx-sec:last-child { border-radius: 0; }
    .pit-pfx .pfx-body { padding-top: .35rem; }
    .pit-pfx .qv-quill-wrap { margin-bottom: 0 !important; }

    .pit-foot {
        display: flex; align-items: baseline; gap: 6px;
        padding: .4rem .2rem 0; font-size: .64rem; font-weight: 600; color: #b6c2d2;
    }
    .pit-foot i { color: #cbd5e1; font-size: .6rem; }

    .pit-empty {
        display: flex; flex-direction: column; align-items: center; gap: .3rem;
        padding: 2rem 1rem; border: 1px dashed #dbe6f5; border-radius: 16px; background: #fbfdff; text-align: center;
    }
    .pit-empty > i { font-size: 1.5rem; color: #dbe6f5; margin-bottom: .2rem; }
    .pit-empty b { font-size: .82rem; font-weight: 750; color: #475569; }
    .pit-empty span { font-size: .7rem; font-weight: 600; color: #a9b7ca; margin-bottom: .5rem; }

    @media (max-width: 640px) {
        .pit-tbl { table-layout: auto; }
        .pit-tt b { max-width: none; }
        .pit-loc, .pit-tbl thead th:nth-child(3) { display: none; }
    }
</style>

<script>
/**
 * Program tablosu: satır aç/kapa + defter kaydından sonra özet hücreyi tazeleme.
 * Drawer her açılışta içeriği yeniden ürettiği için olaylar document'a bir kez bağlanır.
 */
(function () {
    if (window.__qvItinBound) return;
    window.__qvItinBound = true;

    function detailOf(row) {
        var d = row.nextElementSibling;
        return (d && d.classList.contains('pit-d')) ? d : null;
    }

    function toggle(row, force) {
        var d = detailOf(row);
        if (!d) return;
        var open = force === undefined ? !d.classList.contains('on') : force;
        d.classList.toggle('on', open);
        row.classList.toggle('is-open', open);
    }

    document.addEventListener('click', function (e) {
        // Tümünü aç / kapat
        var all = e.target.closest('[data-pit-all]');
        if (all) {
            e.preventDefault();
            var box = all.closest('[data-pit]');
            var opening = !all.classList.contains('is-on');
            all.classList.toggle('is-on', opening);
            all.innerHTML = '<i class="fas fa-chevron-' + (opening ? 'up' : 'down') + '"></i> ' + (opening ? 'Tümünü kapat' : 'Tümünü aç');
            box.querySelectorAll('.pit-r').forEach(function (r) { toggle(r, opening); });
            return;
        }

        var row = e.target.closest('.pit-r');
        if (!row) return;
        // Silme düğmesi kendi akışını yürütür
        if (e.target.closest('[data-pqv-delete]')) return;
        toggle(row);
    });

    document.addEventListener('keydown', function (e) {
        if (e.key !== 'Enter' && e.key !== ' ') return;
        var row = e.target.closest('.pit-r');
        if (!row || e.target !== row) return;
        e.preventDefault();
        toggle(row);
    });

    /** Defter satırı kaydedince tablodaki özet hücreyi eşitle. */
    document.addEventListener('pfx:saved', function (e) {
        var det = e.target.closest('.pit-d');
        if (!det) return;
        var row = det.previousElementSibling;
        if (!row || !row.classList.contains('pit-r')) return;

        var cell = row.querySelector('[data-pit-cell="' + e.detail.field + '"]');
        if (!cell) return;

        var text = (e.detail.text || '').trim();
        if (e.detail.field === 'location') {
            cell.innerHTML = text ? '<i class="fas fa-location-dot"></i>' : '';
            cell.appendChild(document.createTextNode(text || '—'));
        } else {
            cell.textContent = text || (e.detail.field === 'title' ? '' : '—');
        }
        cell.classList.toggle('none', text === '');
    });

    /** Açıklama editöründen çıkınca satırdaki özet metni tazele. */
    document.addEventListener('focusout', function (e) {
        var det = e.target.closest ? e.target.closest('.pit-d') : null;
        if (!det) return;
        var ed = e.target.closest('.ql-editor');
        if (!ed) return;
        var row = det.previousElementSibling;
        var snip = row && row.querySelector('[data-pit-cell="snip"]');
        if (!snip) return;
        var t = (ed.textContent || '').replace(/\s+/g, ' ').trim();
        snip.textContent = t;
        snip.setAttribute('title', t);
    });
})();
</script>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\acente\resources\views/agency/products/_qv-itinerary.blade.php ENDPATH**/ ?>