import"./bootstrap.esm-Bb7dPm-H.js";import{d as O}from"./datatables-I6jthWPb.js";import{i as j}from"./tooltip-manager-D9RaGGY4.js";import{g as E}from"./api-DZ3cXm1m.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */document.addEventListener("DOMContentLoaded",function(){var f,g;const u=document.getElementById("productConfigOptionGroups");if(!u)return;const T=u.getAttribute("data-records-url"),{permissions:d,routes:l}=window,p=$("#productConfigOptionGroups").DataTable({...O.getDefaultConfig(),serverSide:!0,searching:!0,dom:'<"d-flex justify-content-between align-items-center mb-3"<"d-flex align-items-center"l><"d-flex align-items-center"f>>t<"d-flex justify-content-between align-items-center mt-3"<"d-flex align-items-center"i><"d-flex align-items-center"p>>',ajax:{url:T,type:"GET",headers:{Authorization:"Bearer "+E()},data:function(e){var n;e.archived=((n=document.querySelector("[data-archived-filter]"))==null?void 0:n.value)||"no"}},columns:[{data:"name",name:"name",render:function(e,n,t){return n==="display"?`<strong>${e}</strong>`:e}},{data:"description",name:"description",render:function(e,n,t){return n==="display"?e||'<span class="text-muted">-</span>':e}},{data:"options_count",name:"options_count",render:function(e,n,t){return n==="display"?`<span class="badge bg-info">${e}</span>`:e}},{data:"order",name:"order",render:function(e,n,t){return n==="display"?`<span class="badge bg-secondary">${e}</span>`:e}},{data:"status_key",name:"status_key",render:function(e,n,t){var o,i;if(n==="display"){const s={active:"success",hidden:"secondary",archived:"warning"},r=e||"active",a=((i=(o=window.pageConfig)==null?void 0:o.translations)==null?void 0:i["status_"+r])||r;return`<span class="badge bg-${s[r]||"secondary"}">${a}</span>`}return e}},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e,n,t){var i,s,r,a,m,w,h,b,y,x,C,_,v;const o=[];if((i=d.productConfigOptionGroups)!=null&&i.update){const c=l.productConfigOptionGroups.edit.replace(":id",e)+"#tab-options";o.push(`
                            <a href="${c}"
                               class="btn btn-sm btn-outline-info d-inline-flex align-items-center justify-content-center me-1"
                               style="width: 32px; height: 32px;"
                               data-bs-toggle="tooltip"
                               title="${((r=(s=window.pageConfig)==null?void 0:s.translations)==null?void 0:r.btn_view_options)||"Options"}">
                                <i class="fas fa-sliders-h"></i>
                            </a>`)}if((a=d.productConfigOptionGroups)!=null&&a.update){const c=l.productConfigOptionGroups.edit.replace(":id",e);o.push(`
                            <a href="${c}"
                               class="btn btn-sm btn-outline-primary d-inline-flex align-items-center justify-content-center"
                               style="width: 32px; height: 32px;"
                               data-bs-toggle="tooltip"
                               title="${((b=(h=(w=(m=window.translations)==null?void 0:m.admin)==null?void 0:w.product_config_option_groups)==null?void 0:h.buttons)==null?void 0:b.edit)||"Edit"}">
                                <i class="fas fa-edit"></i>
                            </a>`)}return(y=d.productConfigOptionGroups)!=null&&y.delete&&o.push(`
                            <button type="button"
                                    class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-group"
                                    style="width: 32px; height: 32px;"
                                    data-id="${e}"
                                    data-name="${t.name}"
                                    data-bs-toggle="tooltip"
                                    title="${((v=(_=(C=(x=window.translations)==null?void 0:x.admin)==null?void 0:C.product_config_option_groups)==null?void 0:_.buttons)==null?void 0:v.delete)||"Delete"}">
                                <i class="fas fa-trash"></i>
                            </button>`),o.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex">${o.join("")}</div>`}}],drawCallback:function(){j()}});(f=document.getElementById("productConfigOptionGroupsToggleFilters"))==null||f.addEventListener("click",()=>{const e=document.getElementById("productConfigOptionGroupsFilters");e&&(e.style.display=e.style.display==="none"?"":"none")}),(g=document.querySelector("[data-archived-filter]"))==null||g.addEventListener("change",()=>p.ajax.reload()),$(document).on("click",".delete-group",async function(){var t,o,i,s;const e=this.getAttribute("data-id");this.getAttribute("data-name"),await window.showConfirm(((s=(i=(o=(t=window.translations)==null?void 0:t.admin)==null?void 0:o.product_config_option_groups)==null?void 0:i.confirmation)==null?void 0:s.delete)||"Bu grubu arşivlemek istediğine emin misin?",{confirmClass:"btn-danger",icon:"warning"})&&G(e)});function G(e){const n=l.productConfigOptionGroups.delete.replace(":id",e);fetch(n,{method:"DELETE",headers:{Authorization:"Bearer "+E()}}).then(t=>t.json()).then(t=>{t.success?(window.showToast?window.showToast("success",t.message):window.showSuccess(t.message),p.ajax.reload()):window.showToast?window.showToast("error",t.message):window.showError(t.message)}).catch(t=>{console.error("Error:",t),window.showToast?window.showToast("error","Bir hata oluştu. Lütfen tekrar deneyin."):window.showError("Bir hata oluştu. Lütfen tekrar deneyin.")})}});
