<div >
    @include('parts.overlay', ['target' => 'store, back, files, checkedItem, uncheckedItem, uploadPdf, save'])
    {{-- updatedDataItems --}}

    <form wire:submit.prevent="{{ $form['action'] }}" autocomplete="off">
        <div class="row match-height mt-5">
            <div class="col-12">

                    <div class="card">
                        <div class="card-header">
                            <h4 class="card-title">{{  $form['title']  }}</h4>

                            @if ($client && $car && $price)
                                <h4 class="card-title mt-3">{{ ucfirst($client->name ?? '') }} - {{ HP::getCarNameFull($car) }} - {{ $price }}</h4>
                            @endif
                        </div>
                        <div class="card-content">
                            <div class="card-body">
                                @if (!empty($items))
                                    <div class="outer">
                                        <div class="inner">
                                            <table class="table table-bordered @if (count($insurers) == 1) table-one @elseif (count($insurers) == 2) max-w-906 @else table-plus @endif">
                                                <thead>
                                                    <tr>
                                                        <th scope="col" class="hard_left-th">Usar</th>
                                                        <th scope="col" class="next_left-th">Items a cotizar</th>
                                                        @foreach ($insurers as $insurer)
                                                            <th scope="col" class="th-insurers text-center cart-size">{{ $insurer['name'] }}</th>
                                                        @endforeach
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    @foreach ($items as $item_key =>  $item)
                                                        <tr>
                                                            <td class="use hard_left">
                                                                <div class="mt-4">
                                                                    <label class="checkbox-inline checkbox-bootstrap">
                                                                        <input type="checkbox" data-item-key="{{ $item_key }}" data-item-id="{{ $item['id'] }}" class="use_insurer" {{ $item['select'] ? 'checked' : 'unchecked' }}>
                                                                        <span class="checkbox-placeholder"></span>
                                                                    </label>
                                                                </div>
                                                            </td>
                                                            <td class="next_left">{{ $item['name'] }}</td>
                                                            @foreach ($insurers as $insurer)
                                                                @if (in_array($item['id'], $insurer['item_ids']))
                                                                        <td class="">
                                                                            <div class="row">
                                                                                <div class="{{ HP::InsurerItem($insurer['id'], $item['id'])['deductible'] ? 'col-6' : 'col-12' }}">
                                                                                    @switch($item['type'])
                                                                                        @case('numeric_decimals')
                                                                                            <div class="form-group mb-0">
                                                                                                <label for="name" class="text-capitalize">Monto (Numérico decimal)</label>
                                                                                                <input
                                                                                                type="text"
                                                                                                class="form-control numeric-decimal"
                                                                                                @if (!$item['select']) disabled @endif
                                                                                                data-item-id="{{ $item['id'] }}"
                                                                                                data-insurer-id="{{ $insurer['id'] }}"
                                                                                                data-type-value="value_type"
                                                                                                value="{{ $data['items'][$item['id']]['insurers'][$insurer['id']]['value_type'] ?? '' }}">
                                                                                                @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_type')
                                                                                                    <span class="text-danger">{{ $message }}</span>
                                                                                                @enderror
                                                                                            </div>
                                                                                            @break
                                                                                        @case('numeric')
                                                                                            <div class="form-group mb-0">
                                                                                                <label for="name" class="text-capitalize">Monto (Numérico)</label>
                                                                                                <input
                                                                                                type="text"
                                                                                                class="form-control numeric-money"
                                                                                                @if (!$item['select']) disabled @endif
                                                                                                data-item-id="{{ $item['id'] }}"
                                                                                                data-insurer-id="{{ $insurer['id'] }}"
                                                                                                data-type-value="value_type"
                                                                                                value="{{ $data['items'][$item['id']]['insurers'][$insurer['id']]['value_type'] ?? '' }}">
                                                                                                @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_type')
                                                                                                    <span class="text-danger">{{ $message }}</span>
                                                                                                @enderror
                                                                                            </div>
                                                                                            @break
                                                                                        @case('percentage')
                                                                                            <div class="form-group mb-0">
                                                                                                <label for="name" class="text-capitalize">Monto (Porcentaje)</label>
                                                                                                <input
                                                                                                type="text"
                                                                                                class="form-control percent"
                                                                                                @if (!$item['select']) disabled @endif
                                                                                                data-item-id="{{ $item['id'] }}"
                                                                                                data-insurer-id="{{ $insurer['id'] }}"
                                                                                                data-type-value="value_type"
                                                                                                value="{{ $data['items'][$item['id']]['insurers'][$insurer['id']]['value_type'] ?? '' }}">
                                                                                                @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_type')
                                                                                                    <span class="text-danger">{{ $message }}</span>
                                                                                                @enderror
                                                                                            </div>
                                                                                            @break
                                                                                        @case('yesno')
                                                                                            <div class="form-group mb-0 text-center">
                                                                                                <div>
                                                                                                    <label for="name" class="text-capitalize">Monto (Si/No)</label>
                                                                                                </div>
                                                                                                <label class="checkbox-inline checkbox-bootstrap checkbox-lg">
                                                                                                    <input
                                                                                                    type="checkbox"
                                                                                                    class="click_checkbox"
                                                                                                    @if (!$item['select']) disabled @endif
                                                                                                    data-item-id="{{ $item['id'] }}"
                                                                                                    data-insurer-id="{{ $insurer['id'] }}"
                                                                                                    data-type-value="value_type"
                                                                                                    {{ ($data['items'][$item['id']]['insurers'][$insurer['id']]['value_type'] ?? '') == true ? 'checked' : 'unchecked'  }}>
                                                                                                    <span class="checkbox-placeholder"></span>
                                                                                                </label>
                                                                                                <div class="text-center">
                                                                                                    @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_type')
                                                                                                        <span class="text-danger">{{ $message }}</span>
                                                                                                    @enderror
                                                                                                </div>
                                                                                            </div>
                                                                                            @break
                                                                                        @default
                                                                                    @endswitch
                                                                                </div>
                                                                                @if (HP::InsurerItem($insurer['id'], $item['id'])['deductible'])
                                                                                    @if (HP::InsurerItem($insurer['id'], $item['id'])['deductible_type'] == 'numeric_decimals')
                                                                                        <div class="col-6">
                                                                                            <div class="form-group mb-0">
                                                                                                <label for="name" class="text-capitalize">Deducible (Numérico decimal)</label>
                                                                                                <input
                                                                                                type="text"
                                                                                                class="form-control numeric-decimal @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible') is-invalid @enderror"
                                                                                                @if (!$item['select']) disabled @endif
                                                                                                data-item-id="{{ $item['id'] }}"
                                                                                                data-insurer-id="{{ $insurer['id'] }}"
                                                                                                data-type-value="value_deductible"
                                                                                                value="{{ $data['items'][$item['id']]['insurers'][$insurer['id']]['value_deductible'] ?? '' }}">
                                                                                                {{-- @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible')
                                                                                                    <span class="text-danger">{{ $message }}</span>
                                                                                                @enderror --}}
                                                                                            </div>
                                                                                        </div>
                                                                                    @endif
                                                                                    @if (HP::InsurerItem($insurer['id'], $item['id'])['deductible_type'] == 'numeric')
                                                                                        <div class="col-6">
                                                                                            <div class="form-group mb-0">
                                                                                                <label for="name" class="text-capitalize">Deducible (Numérico)</label>
                                                                                                <input
                                                                                                type="text"
                                                                                                class="form-control numeric-money  @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible') is-invalid @enderror"
                                                                                                @if (!$item['select']) disabled @endif
                                                                                                data-item-id="{{ $item['id'] }}"
                                                                                                data-insurer-id="{{ $insurer['id'] }}"
                                                                                                data-type-value="value_deductible"
                                                                                                value="{{ $data['items'][$item['id']]['insurers'][$insurer['id']]['value_deductible'] ?? '' }}">
                                                                                                {{-- @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible') <span class="text-danger">{{ $message }}</span>@enderror --}}
                                                                                            </div>
                                                                                        </div>
                                                                                    @endif

                                                                                    @if (HP::InsurerItem($insurer['id'], $item['id'])['deductible_type'] == 'percentage')
                                                                                        <div class="col-6">
                                                                                            <div class="form-group mb-0">
                                                                                                <label for="name" class="text-capitalize">Deducible (Porcentaje)</label>
                                                                                                <input
                                                                                                type="text"
                                                                                                class="form-control percent  @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible') is-invalid @enderror"
                                                                                                @if (!$item['select']) disabled @endif
                                                                                                data-item-id="{{ $item['id'] }}"
                                                                                                data-insurer-id="{{ $insurer['id'] }}"
                                                                                                data-type-value="value_deductible"
                                                                                                value="{{ $data['items'][$item['id']]['insurers'][$insurer['id']]['value_deductible'] ?? '' }}">
                                                                                                {{-- @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible') <span class="text-danger">{{ $message }}</span>@enderror --}}
                                                                                            </div>
                                                                                        </div>
                                                                                    @endif

                                                                                    @if (HP::InsurerItem($insurer['id'], $item['id'])['deductible_type'] == 'yesno')
                                                                                        <div class="col-6">
                                                                                            <div class="form-group mb-0 text-center ">
                                                                                                <div>
                                                                                                    <label for="name" class="text-capitalize">Deducible (Si/No)</label>
                                                                                                </div>
                                                                                                <label class="checkbox-inline checkbox-bootstrap checkbox-lg">
                                                                                                    <input
                                                                                                    type="checkbox"
                                                                                                    class="click_checkbox"
                                                                                                    @if (!$item['select']) disabled @endif
                                                                                                    data-item-id="{{ $item['id'] }}"
                                                                                                    data-insurer-id="{{ $insurer['id'] }}"
                                                                                                    data-type-value="value_deductible"
                                                                                                    {{ ($data['items'][$item['id']]['insurers'][$insurer['id']]['value_deductible'] ?? '') == true ? 'checked' : 'unchecked'  }}>
                                                                                                    <span class="checkbox-placeholder @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible') is-invalid-chekbox @enderror"></span>
                                                                                                </label>
                                                                                                {{-- <div class="text-center">
                                                                                                    @error('data.items.'.$item['id'].'.insurers.'.$insurer['id'].'.value_deductible')
                                                                                                        <span class="text-danger">{{ $message }}</span>
                                                                                                    @enderror
                                                                                                </div> --}}
                                                                                            </div>
                                                                                        </div>
                                                                                    @endif

                                                                                @endif
                                                                            </div>
                                                                        </td>
                                                                @else
                                                                    <td class=""></td>
                                                                @endif
                                                            @endforeach
                                                        </tr>
                                                    @endforeach
                                                    <tr>
                                                        <td class="hard_left"></td>
                                                        <td class="next_left"></td>
                                                        @foreach ($insurers as $insurer_key => $insurer)
                                                            <td>
                                                                <div class="row">
                                                                    <div class="col-6">
                                                                        <div class="form-group mb-0">
                                                                            <label for="name" class="text-capitalize">Monto cotización</label>
                                                                            <input
                                                                            type="text"
                                                                            class="form-control numeric-decimal"
                                                                            @if (!$insurer['select']) disabled @endif
                                                                            data-item-id="NULL"
                                                                            data-insurer-id="{{ $insurer['id'] }}"
                                                                            data-type-value="amount"
                                                                            value="{{ $data['insurers'][$insurer['id']]['amount'] ?? '' }}">
                                                                            @error('data.insurers.'.$insurer['id'].'.amount')
                                                                                <span class="text-danger">{{ $message }}</span>
                                                                            @enderror
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-6">
                                                                        <div class="form-group mb-0 text-center mt-1">
                                                                            <label class="mb-0" style="cursor: pointer">
                                                                                <input
                                                                                type="file"
                                                                                class="d-none"
                                                                                wire:model="data.insurers.{{ $insurer['id'] }}.file"
                                                                                wire:change="uploadPdf()"
                                                                                accept="application/pdf"
                                                                                @if (!$insurer['select']) disabled @endif>
                                                                                <i class="far fa-file-pdf fa-3x  @if (!empty($data['insurers'][$insurer['id']]['file'])) text-success @else text-secondary @endif"></i>
                                                                            </label>
                                                                            <div for="name" class="text-capitalize mb-1"><span>Adjuntar PDF</span></div>
                                                                            @error('data.insurers.'.$insurer['id'].'.file')
                                                                                <span class="text-danger">{{ $message }}</span>
                                                                            @enderror
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </td>
                                                        @endforeach
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                    <div class="row mt-3">
                                        <div class="col-12">
                                            <div class="form-group">
                                                <label for="description">Observaciones para el cliente</label>
                                                <textarea class="form-control" id="description" wire:model="data.description" placeholder="Observaciones para el cliente" rows="5"></textarea>
                                                @error('data.description') <span class="text-danger">{{ $message }}</span>@enderror
                                            </div>
                                        </div>
                                    </div>
                                @else
                                    <div class="d-flex align-items-center justify-content-center" style="min-height:300px;">
                                        <h4>{{ $load_title }}</h4>
                                    </div>
                                @endif

                                <div class="row mt-5">
                                    <div class="col-12 d-flex justify-content-end">
                                        <button id="btn-submit" type="submit" class="btn btn-primary mr-1 mb-1" wire:loading.attr="disabled"
                                            wire:target="{{ $form['action'] }}">
                                            {{ $form['label'] }}
                                            <i class="fas fa-arrow-circle-right"></i>
                                        </button>
                                        <a type="button" class="btn btn-secondary mr-1 mb-1" wire:click="back" >
                                            <i class="fa fa-angle-double-left" aria-hidden="true"></i>
                                            Regresar
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

            </div>
        </div>
    </form>

    <div class="modal modal-account-request fade deductibleModal" id="deductibleModal" data-backdrop="static"
        tabindex="-1" role="dialog" aria-labelledby="staticBackdrop" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered modal-xl" role="document" style="max-width: 800px;">
                <div class="modal-content h-100" style="min-height: 400px;">

                    <div class="modal-header">
                        @if ($client && $car)
                            <h3 class="modal-title" id="calendarModalLabel" wire:ignore>Cotización: Vehículo - {{ ucfirst($client->name ?? '') }} - {{ HP::getCarNameFull($car) }}</h3>
                        @endif
                        <button type="button" class="close" aria-label="Close" id="closeDeductibleModal">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="text-center mt-2">
                            <i class="fas fa-exclamation-triangle fa-5x text-warning"></i>
                        </div>
                        <h3 class="text-center my-4">Existen deducibles en 0</h3>
                        <div class="text-center">
                            <button type="button" class="btn btn-primary mr-3" wire:loading.attr="disabled"
                                wire:click="save">
                               CONFIRMAR Y FINALIZAR
                            </button>
                            <button type="button" class="btn btn-secondary" wire:loading.attr="disabled" wire:click="checkDeductibleZero">
                                REVISAR DEDUCIBLES
                            </button>
                        </div>
                    </div>
                </div>
            </div>
    </div>

</div>


@push('styles')
    <style>
        .w-40 {
            width: 40%;
        }

        .th-insurers {
            width: 450px;
            max-width: 450px;
        }

        /* .table-bordered th, .table-bordered td {
            border: 2px solid #dfe3e7 !important;
        } */

        .table-bordered .use {
            vertical-align: middle;
            text-align: center;
        }

        :root {
        /* larger checkbox */
        }
        :root label.checkbox-bootstrap input[type=checkbox] {
        /* hide original check box */
        opacity: 0;
        position: absolute;
        /* find the nearest span with checkbox-placeholder class and draw custom checkbox */
        /* draw checkmark before the span placeholder when original hidden input is checked */
        /* disabled checkbox style */
        /* disabled and checked checkbox style */
        /* when the checkbox is focused with tab key show dots arround */
        }
        :root label.checkbox-bootstrap input[type=checkbox] + span.checkbox-placeholder {
        width: 14px;
        height: 14px;
        border: 1px solid;
        border-radius: 3px;
        /*checkbox border color*/
        border-color: #737373;
        display: inline-block;
        cursor: pointer;
        vertical-align: middle;
        text-align: center;
        }
        :root label.checkbox-bootstrap input[type=checkbox]:checked + span.checkbox-placeholder {
        background: #153073;
        }
        :root label.checkbox-bootstrap input[type=checkbox]:checked + span.checkbox-placeholder:before {
        display: inline-block;
        position: relative;
        vertical-align: text-top;
        width: 5px;
        height: 9px;
        /*checkmark arrow color*/
        border: solid white;
        border-width: 0 2px 2px 0;
        /*can be done with post css autoprefixer*/
        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        -o-transform: rotate(45deg);
        transform: rotate(45deg);
        content: "";
        }
        :root label.checkbox-bootstrap input[type=checkbox]:disabled + span.checkbox-placeholder {
        background: #ececec;
        border-color: #c3c2c2;
        }
        :root label.checkbox-bootstrap input[type=checkbox]:checked:disabled + span.checkbox-placeholder {
        background: #d6d6d6;
        border-color: #bdbdbd;
        }
        :root label.checkbox-bootstrap input[type=checkbox]:focus:not(:hover) + span.checkbox-placeholder {
        outline: 1px dotted black;
        }
        :root label.checkbox-bootstrap.checkbox-lg input[type=checkbox] + span.checkbox-placeholder {
        width: 26px;
        height: 26px;
        border: 2px solid;
        border-radius: 5px;
        /*checkbox border color*/
        border-color: #737373;
        }
        :root label.checkbox-bootstrap.checkbox-lg input[type=checkbox]:checked + span.checkbox-placeholder:before {
        width: 9px;
        height: 15px;
        /*checkmark arrow color*/
        border: solid white;
        border-width: 0 3px 3px 0;
        }

        table.table-plus {
            width: 100% !important;
        }

        table.table-one {
            width: auto !important;
        }

        table {
            table-layout: fixed;
            *margin-left: -100px;/*ie7*/
            margin-bottom: 0px !important;
        }

        .max-w-906 {
            max-width: 900px;
        }

        th.cart-size {
            width: 450px;
        }

        /* td, th {
        vertical-align: top;
        padding:10px;
        width:auto;
        } */
        /* th {
         position:absolute;
        *position: relative;
        left:0;
        width:100px;
        } */
        .hard_left-th {
        position:absolute;
        *position: relative; /*ie7*/
        left:0;
        width:80px;
        }

        .hard_left {
            position:absolute;
            *position: relative; /*ie7*/
            left:0;
            width:80px;
            min-height: 92px;
            height: -webkit-fill-available;
        }

        .next_left-th {
        position:absolute;
        *position: relative; /*ie7*/
        left:80px;
        width:40%;
        }

        .next_left {
        position:absolute;
        *position: relative; /*ie7*/
        left:80px;
        width:40%;
        min-height: 92px;
        height: -webkit-fill-available;
        }
        .outer {
            position:relative;
            max-width: 100%;
        }
        .inner {
        overflow-x: auto;
        overflow-y: auto;
        margin-left:45%;
        border: 1px solid #dfe3e7;
        }

        .inner {
            max-width: 100%;
        }

        .is-invalid-chekbox {
            border: 1px solid #dc3545 !important;`
        }

        @media (max-width: 1720px) {
            .inner {
                margin-left: 47%;
            }
        }

        @media (max-width: 1520px) {
            .inner {
                margin-left: 48%;
            }
        }

        @media (max-width: 1450px) {
            .inner {
                margin-left: 49%;
            }
        }

        @media (max-width: 1300px) {
            .inner {
                margin-left: 51%;
            }
        }

        @media (max-width: 1150px) {
            .inner {
                margin-left: 53%;
            }
        }

    </style>
@endpush

@push('scripts')
    <script>

        $(document).ready(function() {
        $(window).keydown(function(event){
            if(event.keyCode == 13) {
            event.preventDefault();
            return false;
            }
        });
        });

        function init_upload() {

            // Close modal
            $("#closeDeductibleModal").off('click');
            $("#closeDeductibleModal").on('click', function () {
                $('#deductibleModal').modal('hide');
            });

            window.addEventListener('show-modal-deductible', event => {
                $('#deductibleModal').modal('show');
            });

            window.addEventListener('close-modal-deductible', event => {
                $('#deductibleModal').modal('hide');
            });

            Inputmask().mask(document.querySelectorAll("input"));

            // format inputmask no decimales only numbers entero
            $('.numeric-money').inputmask('numeric', {
                onKeyDown: function (e) {
                    if(e.keyCode == 109 || e.keyCode == 107) {
                        e.preventDefault();
                        return false;
                    }
                },
                radixPoint: ".",
                groupSeparator: ",",
                digits: 0,
                autoGroup: true,
                prefix: '$ ', //Space after $, this will not truncate the first character.
                rightAlign: false,
                removeMaskOnSubmit: true,
            });

            //
            $('.numeric-money').off('change');
            $('.numeric-money').on('change', function () {
                let value = $(this).inputmask('unmaskedvalue');
                console.log(value);
                if (value == '') {
                    $(this).val(0);
                }

                let item_id = $(this).data('item-id');
                let insurer_id = $(this).data('insurer-id');
                let type_value = $(this).data('type-value');

                @this.call('updatedDataItems', item_id, insurer_id, type_value, value);
            });

            // format price input mask (money) numeric
            $('.numeric-decimal').inputmask('decimal', {
                onKeyDown: function (e) {
                    if(e.keyCode == 109 || e.keyCode == 107) {
                        e.preventDefault();
                        return false;
                    }
                },
                radixPoint: ".",
                groupSeparator: ",",
                digits: 2,
                autoGroup: true,
                prefix: '$ ', //Space after $, this will not truncate the first character.
                rightAlign: false,
                removeMaskOnSubmit: true,
            });

            //
            $('.numeric-decimal').off('change');
            $('.numeric-decimal').on('change', function () {
                let value = $(this).inputmask('unmaskedvalue');
                if (value == '') {
                    $(this).val(0);
                }

                let item_id = $(this).data('item-id');
                let insurer_id = $(this).data('insurer-id');
                let type_value = $(this).data('type-value');

                @this.call('updatedDataItems', item_id, insurer_id, type_value, value);
            });


            // format percent input mask numeric
            $('.percent').inputmask('percentage', {
                onKeyDown: function (e) {
                    console.log(e.keyCode);
                    if(e.keyCode == 109 || e.keyCode == 107) {
                        e.preventDefault();
                        return false;
                    }
                },
                radixPoint: ".",
                groupSeparator: ",",
                digits: 2,
                max: 100,
                autoGroup: true,
                suffix: ' %', //Space after $, this will not truncate the first character.
                rightAlign: false,
                removeMaskOnSubmit: true,
            });

            //
            $('.percent').off('change');
            $('.percent').on('change', function () {
                let value = $(this).inputmask('unmaskedvalue');
                if (value == '') {
                    $(this).val(0);
                }

                let item_id = $(this).data('item-id');
                let insurer_id = $(this).data('insurer-id');
                let type_value = $(this).data('type-value');

                @this.call('updatedDataItems', item_id, insurer_id, type_value, value);
            });

            //click_checkbox
            $('.click_checkbox').off('change');
            $('.click_checkbox').on('change', function () {
                let item_id = $(this).data('item-id');
                let insurer_id = $(this).data('insurer-id');
                let type_value = $(this).data('type-value');
                let check = $(this).is(':checked');

                @this.call('updatedDataItems', item_id, insurer_id, type_value, check);
            });

            // Valor
            // $('.numeric-money').off('change');
            // $('.numeric-money').on('change', function (e) {
            //     console.log($(this).inputmask('unmaskedvalue'));
            // });


            //
            $('.use_insurer').off('change');
            $('.use_insurer').on('change', function (e) {
                let item_id = $(this).data('item-id');
                let item_key = $(this).data('item-key');
                let check = $(this).is(':checked');
                if(check) {
                    @this.call('checkedItem', item_key, item_id);
                } else {
                    @this.call('uncheckedItem', item_key, item_id);
                }
            });
        }

        init_upload();

        Livewire.hook('message.processed', (message, component) => { init_upload(); });


    </script>
@endpush

