<script>
(function () {
    const packageSelect = document.getElementById('package_id');
    const monthsInput = document.getElementById('contract_months');
    const preview = document.getElementById('total_price_preview');

    function formatTL(value) {
        return value.toLocaleString('tr-TR', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ' TL';
    }

    function recalc() {
        if (!packageSelect || !monthsInput || !preview) return;
        const selected = packageSelect.options[packageSelect.selectedIndex];
        const monthlyFee = parseFloat(selected?.dataset.monthlyFee ?? '0') || 0;
        const months = parseInt(monthsInput.value, 10) || 0;
        preview.value = formatTL(monthlyFee * months);
    }

    packageSelect?.addEventListener('change', recalc);
    monthsInput?.addEventListener('input', recalc);
    recalc();
})();
</script>
<?php /**PATH C:\Users\a-azr\Desktop\kolayabonelik\resources\views/panel/subscriptions/_total-price-script.blade.php ENDPATH**/ ?>