"use strict";$(function(){let t,s,a;a=(isDarkStyle?(t=config.colors_dark.borderColor,s=config.colors_dark.bodyBg,config.colors_dark):(t=config.colors.borderColor,s=config.colors.bodyBg,config.colors)).headingColor;var e,n=$(".datatables-customers"),o=$(".select2");o.length&&(o=o).wrap('
').select2({placeholder:"United States ",dropdownParent:o.parent()}),n.length&&(e=n.DataTable({ajax:assetsPath+"json/ecommerce-customer-all.json",columns:[{data:""},{data:"id"},{data:"customer"},{data:"customer_id"},{data:"country"},{data:"order"},{data:"total_spent"}],columnDefs:[{className:"control",searchable:!1,orderable:!1,responsivePriority:2,targets:0,render:function(e,t,s,a){return""}},{targets:1,orderable:!1,searchable:!1,responsivePriority:3,checkboxes:!0,checkboxes:{selectAllRender:''},render:function(){return''}},{targets:2,responsivePriority:1,render:function(e,t,s,a){var n=s.customer,o=s.email,r=s.image;return'
'+(r?'Avatar':''+(r=(((r=(n=s.customer).match(/\b\w/g)||[]).shift()||"")+(r.pop()||"")).toUpperCase())+"")+'
'+n+''+o+"
"}},{targets:3,render:function(e,t,s,a){return"#"+s.customer_id+""}},{targets:4,render:function(e,t,s,a){var n=s.country,s=s.country_code;return'
'+(s?``:'')+"
"+n+"
"}},{targets:5,render:function(e,t,s,a){return""+s.order+""}},{targets:6,render:function(e,t,s,a){return''+s.total_spent+""}}],order:[[2,"desc"]],dom:'<"card-header d-flex flex-wrap py-3"<"me-5 ms-n2"f><"dt-action-buttons text-xl-end text-lg-start text-md-end text-start d-flex align-items-center justify-content-md-end gap-3 gap-sm-2 flex-wrap flex-sm-nowrap"lB>>t<"row mx-2"<"col-sm-12 col-md-6"i><"col-sm-12 col-md-6"p>>',language:{sLengthMenu:"_MENU_",search:"",searchPlaceholder:"Search Order"},buttons:[{extend:"collection",className:"btn btn-label-secondary dropdown-toggle ms-sm-0 me-3",text:'Export',buttons:[{extend:"print",text:'Print',className:"dropdown-item",exportOptions:{columns:[1,2,3,4,5,6],format:{body:function(e,t,s){var a;return e.length<=0?e:(e=$.parseHTML(e),a="",$.each(e,function(e,t){void 0!==t.classList&&t.classList.contains("customer-name")?a+=t.lastChild.firstChild.textContent:void 0===t.innerText?a+=t.textContent:a+=t.innerText}),a)}}},customize:function(e){$(e.document.body).css("color",a).css("border-color",t).css("background-color",s),$(e.document.body).find("table").addClass("compact").css("color","inherit").css("border-color","inherit").css("background-color","inherit")}},{extend:"csv",text:'Csv',className:"dropdown-item",exportOptions:{columns:[1,2,3,4,5,6],format:{body:function(e,t,s){var a;return e.length<=0?e:(e=$.parseHTML(e),a="",$.each(e,function(e,t){void 0!==t.classList&&t.classList.contains("customer-name")?a+=t.lastChild.firstChild.textContent:void 0===t.innerText?a+=t.textContent:a+=t.innerText}),a)}}}},{extend:"excel",text:'Excel',className:"dropdown-item",exportOptions:{columns:[1,2,3,4,5,6],format:{body:function(e,t,s){var a;return e.length<=0?e:(e=$.parseHTML(e),a="",$.each(e,function(e,t){void 0!==t.classList&&t.classList.contains("customer-name")?a+=t.lastChild.firstChild.textContent:void 0===t.innerText?a+=t.textContent:a+=t.innerText}),a)}}}},{extend:"pdf",text:'Pdf',className:"dropdown-item",exportOptions:{columns:[1,2,3,4,5,6],format:{body:function(e,t,s){var a;return e.length<=0?e:(e=$.parseHTML(e),a="",$.each(e,function(e,t){void 0!==t.classList&&t.classList.contains("customer-name")?a+=t.lastChild.firstChild.textContent:void 0===t.innerText?a+=t.textContent:a+=t.innerText}),a)}}}},{extend:"copy",text:'Copy',className:"dropdown-item",exportOptions:{columns:[1,2,3,4,5,6],format:{body:function(e,t,s){var a;return e.length<=0?e:(e=$.parseHTML(e),a="",$.each(e,function(e,t){void 0!==t.classList&&t.classList.contains("customer-name")?a+=t.lastChild.firstChild.textContent:void 0===t.innerText?a+=t.textContent:a+=t.innerText}),a)}}}}]},{text:'Add Customer',className:"add-new btn btn-primary",attr:{"data-bs-toggle":"offcanvas","data-bs-target":"#offcanvasEcommerceCustomerAdd"}}],responsive:{details:{display:$.fn.dataTable.Responsive.display.modal({header:function(e){return"Details of "+e.data().customer}}),type:"column",renderer:function(e,t,s){s=$.map(s,function(e,t){return""!==e.title?''+e.title+": "+e.data+"":""}).join("");return!!s&&$('').append(s)}}}}),$(".dataTables_length").addClass("mt-0 mt-md-3 me-2"),$(".dt-action-buttons").addClass("pt-0"),$(".dt-buttons > .btn-group > button").removeClass("btn-secondary"),$(".dt-buttons").addClass("d-flex flex-wrap")),$(".datatables-customers tbody").on("click",".delete-record",function(){e.row($(this).parents("tr")).remove().draw()}),setTimeout(()=>{$(".dataTables_filter .form-control").removeClass("form-control-sm"),$(".dataTables_length .form-select").removeClass("form-select-sm")},300)}),function(){var e=document.querySelectorAll(".phone-mask"),t=document.getElementById("eCommerceCustomerAddForm");e&&e.forEach(function(e){new Cleave(e,{phone:!0,phoneRegionCode:"US"})}),FormValidation.formValidation(t,{fields:{customerName:{validators:{notEmpty:{message:"Please enter fullname "}}},customerEmail:{validators:{notEmpty:{message:"Please enter your email"},emailAddress:{message:"The value is not a valid email address"}}}},plugins:{trigger:new FormValidation.plugins.Trigger,bootstrap5:new FormValidation.plugins.Bootstrap5({eleValidClass:"",rowSelector:function(e,t){return".mb-3"}}),submitButton:new FormValidation.plugins.SubmitButton,autoFocus:new FormValidation.plugins.AutoFocus}})}();