import{d as C,k as V,m as p,r as M,u as A,o as n,a,b as v,e as l,h as S,w as $,f as e,t as g,s as j,F as h,n as B,q as y,g as F,j as N}from"./app-bWy6VYs1.js";import{a as c,_ as q}from"./AppLayout.vue_vue_type_script_setup_true_lang-BwuDxc8O.js";import{m as d}from"./modules-DrjChSMk.js";import{C as z}from"./check-QVwPCuu6.js";import"./index-C32fBP6Q.js";import"./index-CMWG4mbA.js";import"./useForwardExpose-Cx2E44RD.js";import"./VisuallyHidden-0BfmsMPn.js";import"./RovingFocusGroup-D20OvR_w.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./_plugin-vue_export-helper-DmjF0He4.js";const D={class:"p-4"},E={class:"rounded-lg border bg-white p-6 shadow-sm"},H={class:"mb-4 flex items-center justify-between"},L={class:"text-sm text-gray-600"},P={class:"grid gap-3 md:grid-cols-2 lg:grid-cols-3"},U=["onClick"],G={class:"font-medium text-gray-900"},I={class:"mt-6 flex gap-3"},J=["disabled"],O={key:0},Q={key:1},re=C({__name:"ModuleVisibility",setup(R){const f=V(),m=p(()=>f.props.currentCompany),b=p(()=>m.value?.visible_modules===null),s=M(b.value?d.map(t=>t.key):m.value?.visible_modules??[]),o=A({visible_modules:b.value?null:s.value}),_=t=>{s.value.includes(t)?s.value=s.value.filter(i=>i!==t):s.value.push(t),o.visible_modules=s.value.length===d.length?null:s.value},x=()=>{s.value=d.map(t=>t.key),o.visible_modules=null},k=()=>{s.value=[],o.visible_modules=[]},u=t=>s.value.includes(t),w=()=>{o.put(c.moduleVisibility.update().url,{preserveScroll:!0,onSuccess:()=>{window.location.reload()}})};return(t,i)=>(n(),a(h,null,[v(l(S),{title:"Module Visibility"}),v(q,{breadcrumbs:[{title:"Administration",href:l(c).index().url},{title:"Module Visibility",href:"/administration/module-visibility"}]},{default:$(()=>[e("div",D,[i[2]||(i[2]=e("div",{class:"mb-6"},[e("h1",{class:"text-2xl font-bold"},"Module Visibility"),e("p",{class:"mt-2 text-sm text-gray-600"}," Select which modules should be visible in the sidebar menu. Unselected modules will be hidden from all users. ")],-1)),e("div",E,[e("div",H,[e("div",null,[i[1]||(i[1]=e("h2",{class:"text-lg font-semibold"},"Available Modules",-1)),e("p",L,g(l(o).visible_modules===null?"All modules visible":`${s.value.length} of ${l(d).length} modules selected`),1)]),e("div",{class:"flex gap-2"},[e("button",{onClick:x,class:"rounded bg-blue-600 px-3 py-2 text-sm text-white hover:bg-blue-700"}," Show All "),e("button",{onClick:k,class:"rounded border px-3 py-2 text-sm hover:bg-gray-50"}," Hide All ")])]),e("form",{onSubmit:j(w,["prevent"])},[e("div",P,[(n(!0),a(h,null,B(l(d),r=>(n(),a("div",{key:r.key,onClick:T=>_(r.key),class:y(["flex cursor-pointer items-center justify-between rounded-lg border p-4 transition-colors",u(r.key)?"border-green-500 bg-green-50":"border-gray-200 bg-white hover:border-gray-300"])},[e("span",G,g(r.label),1),e("div",{class:y(["flex h-5 w-5 items-center justify-center rounded border-2",u(r.key)?"border-green-500 bg-green-500":"border-gray-300 bg-white"])},[u(r.key)?(n(),F(l(z),{key:0,class:"h-3 w-3 text-white"})):N("",!0)],2)],10,U))),128))]),e("div",I,[e("button",{type:"submit",disabled:l(o).processing,class:"rounded bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"},[l(o).processing?(n(),a("span",O,"Saving...")):(n(),a("span",Q,"Save Changes"))],8,J),e("button",{type:"button",onClick:i[0]||(i[0]=r=>t.$inertia.visit(l(c).index().url)),class:"rounded border px-4 py-2 text-sm font-medium hover:bg-gray-50"}," Cancel ")])],32)])])]),_:1},8,["breadcrumbs"])],64))}});export{re as default};
