document.addEventListener("DOMContentLoaded",function(e){let t,s,a,o,r;t=isDarkStyle?"dark":"",config.colors.cardColor,s=config.colors.textMuted,a=config.colors.headingColor,o=config.colors.borderColor,r=config.colors.bodyBg;var n=document.querySelector("#reviewsChart"),l={chart:{height:160,width:190,type:"bar",toolbar:{show:!1}},plotOptions:{bar:{barHeight:"75%",columnWidth:"40%",startingShape:"rounded",endingShape:"rounded",borderRadius:5,distributed:!0}},grid:{show:!1,padding:{top:-25,bottom:-12}},colors:[config.colors_label.success,config.colors_label.success,config.colors_label.success,config.colors_label.success,config.colors.success,config.colors_label.success,config.colors_label.success],dataLabels:{enabled:!1},series:[{data:[20,40,60,80,100,80,60]}],legend:{show:!1},xaxis:{categories:["M","T","W","T","F","S","S"],axisBorder:{show:!1},axisTicks:{show:!1},labels:{style:{colors:s,fontSize:"13px"}}},yaxis:{labels:{show:!1}},responsive:[{breakpoint:0,options:{chart:{width:"100%"},plotOptions:{bar:{columnWidth:"40%"}}}},{breakpoint:1440,options:{chart:{height:150,width:190,toolbar:{show:!1}},plotOptions:{bar:{borderRadius:6,columnWidth:"40%"}}}},{breakpoint:1400,options:{plotOptions:{bar:{borderRadius:6,columnWidth:"40%"}}}},{breakpoint:1200,options:{chart:{height:130,width:190,toolbar:{show:!1}},plotOptions:{bar:{borderRadius:6,columnWidth:"40%"}}}},{breakpoint:992,chart:{height:150,width:190,toolbar:{show:!1}},options:{plotOptions:{bar:{borderRadius:5,columnWidth:"40%"}}}},{breakpoint:883,options:{plotOptions:{bar:{borderRadius:5,columnWidth:"40%"}}}},{breakpoint:768,options:{chart:{height:150,width:190,toolbar:{show:!1}},plotOptions:{bar:{borderRadius:4,columnWidth:"40%"}}}},{breakpoint:576,options:{chart:{width:"100%",height:"200",type:"bar"},plotOptions:{bar:{borderRadius:6,columnWidth:"30% "}}}},{breakpoint:420,options:{plotOptions:{chart:{width:"100%",height:"200",type:"bar"},bar:{borderRadius:3,columnWidth:"30%"}}}}]},n=(null!==n&&new ApexCharts(n,l).render(),document.querySelector(".datatables-review")),i={Pending:{title:"Pending",class:"bg-label-warning"},Published:{title:"Published",class:"bg-label-success"}};if(n){let e=document.createElement("div");e.classList.add("review_filter");var c=new DataTable(n,{ajax:assetsPath+"json/app-ecommerce-reviews.json",columns:[{data:"id"},{data:"id",orderable:!1,render:DataTable.render.select()},{data:"product"},{data:"reviewer"},{data:"review"},{data:"date"},{data:"status"},{data:"id"}],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:'<input type="checkbox" class="form-check-input">'},render:function(){return'<input type="checkbox" class="dt-checkboxes form-check-input">'}},{targets:2,render:function(e,t,s,a){var o=s.product,r=s.company_name,n=s.product_image;let l;return`
              <div class="d-flex justify-content-start align-items-center customer-name">
                <div class="avatar-wrapper">
                  <div class="avatar me-4 rounded-2 bg-label-secondary">${l=n?`
                <img src="${assetsPath}img/ecommerce-images/${n}" alt="Product-${s.id}" class="rounded">
              `:`<span class="avatar-initial rounded bg-label-${["success","danger","warning","info","dark","primary","secondary"][Math.floor(6*Math.random())]}">${(o.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()}</span>`}</div>
                </div>
                <div class="d-flex flex-column">
                  <span class="fw-medium text-nowrap text-heading">${o}</span>
                  <small>${r}</small>
                </div>
              </div>`}},{targets:3,responsivePriority:1,render:function(e,t,s,a){var o=s.reviewer,r=s.email,s=s.avatar;let n;return`
              <div class="d-flex justify-content-start align-items-center customer-name">
                <div class="avatar-wrapper">
                  <div class="avatar avatar-sm me-4">${n=s?`<img src="${assetsPath}img/avatars/${s}" alt="Avatar" class="rounded-circle">`:`<span class="avatar-initial rounded-circle bg-label-${["success","danger","warning","info","dark","primary","secondary"][Math.floor(6*Math.random())]}">${(o.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()}</span>`}</div>
                </div>
                <div class="d-flex flex-column">
                  <a href="app-ecommerce-customer-details-overview.html"><span class="fw-medium">${o}</span></a>
                  <small class="text-nowrap">${r}</small>
                </div>
              </div>`}},{targets:4,responsivePriority:2,sortable:!1,render:function(e,t,s,a){var o=s.review,r=s.para;var s="string"!=typeof(s=s.head)||0===s.length?s:s.charAt(0).toUpperCase()+s.slice(1),n=document.createElement("div"),l=(n.className="read-only-ratings raty mb-1",n.setAttribute("data-number","5"),parseInt(window.Helpers.getCssVar("gray-200",!0).slice(1,3),16)),i=parseInt(window.Helpers.getCssVar("gray-200",!0).slice(3,5),16),c=parseInt(window.Helpers.getCssVar("gray-200",!0).slice(5,7),16);if(n)return new Raty(n,{score:o,readOnly:!0,starOn:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' %3E%3Cpath fill='%23FFD700' d='M21.947 9.179a1 1 0 0 0-.868-.676l-5.701-.453l-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107l-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4l4.536-4.082c.297-.268.406-.686.278-1.065'/%3E%3C/svg%3E",starOff:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' %3E%3Cpath fill='rgb("+l+","+i+","+c+")' d='M21.947 9.179a1 1 0 0 0-.868-.676l-5.701-.453l-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107l-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4l4.536-4.082c.297-.268.406-.686.278-1.065'/%3E%3C/svg%3E"}).init(),`
              <div>
                ${n.outerHTML}
                <p class="h6 mb-1 text-truncate">${s}</p>
                <small class="text-break">${r}</small>
              </div>
            `}},{targets:5,render:function(e,t,s,a){return'<span class="text-nowrap">'+new Date(s.date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+"</span>"}},{targets:6,render:function(e,t,s,a){s=s.status;return'<span class="badge '+i[s].class+'" text-capitalize>'+i[s].title+"</span>"}},{targets:-1,title:"Actions",searchable:!1,orderable:!1,render:function(e,t,s,a){return`
              <div class="text-xxl-center">
                <div class="dropdown">
                  <a href="javascript:void(0);" class="btn btn-icon dropdown-toggle hide-arrow p-0" data-bs-toggle="dropdown">
                    <i class="icon-base bx bx-dots-vertical-rounded icon-md"></i>
                  </a>
                  <div class="dropdown-menu dropdown-menu-end">
                    <a href="javascript:void(0);" class="dropdown-item">Download</a>
                    <a href="javascript:void(0);" class="dropdown-item">Edit</a>
                    <a href="javascript:void(0);" class="dropdown-item">Duplicate</a>
                    <div class="dropdown-divider"></div>
                    <a href="javascript:void(0);" class="dropdown-item delete-record text-danger">Delete</a>
                  </div>
                </div>
              </div>
            `}}],select:{style:"multi",selector:"td:nth-child(2)"},order:[[2,"asc"]],layout:{topStart:{rowClass:"row m-3 my-0 justify-content-between",features:[{search:{placeholder:"Search Review",text:"_INPUT_"}}]},topEnd:{features:[{pageLength:{menu:[10,25,50,100],text:"_MENU_"}},e,{buttons:[{extend:"collection",className:"btn btn-label-primary dropdown-toggle",text:'<span class="d-flex align-items-center gap-2"><i class="icon-base bx bx-export me-sm-1"></i> <span class="d-none d-sm-inline-block">Export</span></span>',buttons:[{extend:"print",text:'<span class="d-flex align-items-center"><i class="icon-base bx bx-printer me-1"></i>Print</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}},customize:function(e){e.document.body.style.color=a,e.document.body.style.borderColor=o,e.document.body.style.backgroundColor=r;e=e.document.body.querySelector("table");e.classList.add("compact"),e.style.color="inherit",e.style.borderColor="inherit",e.style.backgroundColor="inherit"}},{extend:"csv",text:'<span class="d-flex align-items-center"><i class="icon-base bx bx-file me-1"></i>Csv</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}},{extend:"excel",text:'<span class="d-flex align-items-center"><i class="icon-base bx bxs-file-export me-1"></i>Excel</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}},{extend:"pdf",text:'<span class="d-flex align-items-center"><i class="icon-base bx bxs-file-pdf me-1"></i>Pdf</span>',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}},{extend:"copy",text:'<i class="icon-base bx bx-copy me-1"></i>Copy',className:"dropdown-item",exportOptions:{columns:[3,4,5,6,7],format:{body:function(e,t,s){if(e.length<=0)return e;e=(new DOMParser).parseFromString(e,"text/html").body.childNodes;let a="";return e.forEach(e=>{e.classList&&e.classList.contains("user-name")?a+=e.lastChild.firstChild.textContent:a+=e.textContent||e.innerText||""}),a}}}}]}]}]},bottomStart:{rowClass:"row mx-3 justify-content-between",features:["info"]},bottomEnd:{paging:{firstLast:!1}}},language:{paginate:{next:'<i class="icon-base bx bx-chevron-right scaleX-n1-rtl icon-18px"></i>',previous:'<i class="icon-base bx bx-chevron-left scaleX-n1-rtl icon-18px"></i>'}},responsive:{details:{display:DataTable.Responsive.display.modal({header:function(e){return"Details of "+e.data().reviewer}}),type:"column",renderer:function(e,t,s){var a,o,r,s=s.map(function(e){return""!==e.title?`<tr data-dt-row="${e.rowIndex}" data-dt-column="${e.columnIndex}">
                      <td>${e.title}:</td>
                      <td>${e.data}</td>
                    </tr>`:""}).join("");return!!s&&((a=document.createElement("div")).classList.add("table-responsive"),o=document.createElement("table"),a.appendChild(o),o.classList.add("table"),(r=document.createElement("tbody")).innerHTML=s,o.appendChild(r),a)}}},initComplete:function(){this.api().columns(6).every(function(){let t=this;if(e){let s=document.createElement("select");s.className="form-select",s.innerHTML='<option value=""> All </option>',e.appendChild(s),s.addEventListener("change",function(){var e=s.value?"^"+s.value+"$":"";t.search(e,!0,!1).draw()}),t.data().unique().sort().each(function(e){var t=document.createElement("option");t.value=e,t.className="text-capitalize",t.textContent=e,s.appendChild(t)})}})}})}document.addEventListener("click",function(e){e.target.classList.contains("delete-record")&&(c.row(e.target.closest("tr")).remove().draw(),e=document.querySelector(".dtr-bs-modal"))&&e.classList.contains("show")&&bootstrap.Modal.getInstance(e)?.hide()}),setTimeout(()=>{[{selector:".dt-buttons .btn",classToRemove:"btn-secondary",classToAdd:"btn-label-secondary"},{selector:".dt-search .form-control",classToRemove:"form-control-sm",classToAdd:"ms-0"},{selector:".dt-search",classToAdd:"mb-md-6 mb-0"},{selector:".dt-length .form-select",classToRemove:"form-select-sm",classToAdd:"me-md-4 me-0"},{selector:".dt-layout-table",classToRemove:"row mt-2"},{selector:".dt-layout-start",classToAdd:"px-3"},{selector:".dt-layout-end",classToAdd:"px-3"},{selector:".review_filter",classToAdd:"me-md-4"},{selector:".review_filter .form-select",classToAdd:"w-px-100"},{selector:".dt-buttons",classToAdd:"mb-0"},{selector:".dt-layout-end",classToAdd:"d-flex gap-md-0 gap-4"},{selector:".dt-layout-full",classToRemove:"col-md col-12",classToAdd:"table-responsive"}].forEach(({selector:e,classToRemove:s,classToAdd:a})=>{document.querySelectorAll(e).forEach(t=>{s&&s.split(" ").forEach(e=>t.classList.remove(e)),a&&a.split(" ").forEach(e=>t.classList.add(e))})})},100)});