import{a as k,r as x,j as e,H as v,L as p,b as f}from"./app-2gKhTNh_.js";import{A as w}from"./AdminKampusLayout-QLddaMo-.js";import{F as t,a2 as u,T as M,g as V,j as C,d as B,a4 as T,I as D,k as A,l as E}from"./index-DQiLWVLj.js";import{S as l}from"./sweetalert2.esm.all-NNS-RXd7.js";import"./proxy-N6hiut4S.js";const S=({isOpen:d,onClose:a,onConfirm:c,visiMisi:i})=>d?e.jsx("div",{className:"fixed inset-0 bg-gray-900 bg-opacity-75 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-md",children:[e.jsxs("div",{className:"p-6 border-b border-gray-100 flex justify-between items-center bg-red-50 rounded-t-xl",children:[e.jsxs("h3",{className:"text-xl font-bold text-red-700 flex items-center",children:[e.jsx(t,{icon:A,className:"mr-3 w-5 h-5"}),"Konfirmasi Penghapusan"]}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-600 transition",children:e.jsx(t,{icon:E,className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"text-gray-700",children:"Anda yakin ingin menghapus data **Visi Misi** ini? Data ini tidak bisa dipulihkan, dan setelah dihapus Anda bisa membuat data Visi Misi baru."}),i?.title&&e.jsxs("blockquote",{className:"mt-4 p-3 border-l-4 border-red-300 bg-red-50 text-sm italic text-gray-600",children:["Menghapus: **",i.title,"**"]})]}),e.jsxs("div",{className:"p-6 border-t border-gray-100 flex justify-end space-x-3 rounded-b-xl",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 transition duration-150",children:"Batal"}),e.jsx("button",{onClick:c,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 transition duration-150",children:"Ya, Hapus"})]})]})}):null;function z({auth:d,visiMisi:a}){const{props:c}=k(),i=c.flash||{},[j,o]=x.useState(!1),[h,m]=x.useState(null),g=a?[a]:[],b=s=>{m(s),o(!0)},y=()=>{h&&f.delete(route("admin.kampus.visimisi.destroy"),{preserveScroll:!0,onSuccess:()=>{o(!1),m(null)},onError:s=>{console.error("Gagal menghapus Visi Misi:",s),o(!1),m(null);const n=s.error||"Terjadi kesalahan saat menghapus data Visi Misi.";l.fire("Gagal!",n,"error")}})},N=s=>{a&&(s.preventDefault(),l.fire({title:"Data Visi Misi Sudah Ada",icon:"info",html:`
                    <div style="text-align: center; margin-top: 10px;">
                        <p style="font-size: 1.05rem; color: #4b5563;">
                            Kampus Anda hanya diizinkan memiliki **satu data Visi & Misi**.
                        </p>
                        <p style="margin-top: 15px; font-size: 0.95rem; color: #1f2937;">
                            Untuk melakukan perubahan, silakan gunakan:
                        </p>
                        <ul style="list-style: none; padding: 0; margin-top: 10px; font-weight: 600;">
                            <li style="margin-bottom: 5px;"><span style="color: #4f46e5;">Ikon Pensil</span> untuk Mengedit data yang ada.</li>
                            <li><span style="color: #dc2626;">Ikon Tempat Sampah</span> untuk Menghapus data (jika ingin membuat yang baru).</li>
                        </ul>
                    </div>
                `,showCancelButton:!0,confirmButtonText:"Lanjut Edit Data",cancelButtonText:"Oke, Saya Mengerti",confirmButtonColor:"#4F46E5",cancelButtonColor:"#6B7280"}).then(n=>{n.isConfirmed&&f.get(route("admin.kampus.visimisi.edit"))}))};return x.useEffect(()=>{i.success?l.fire({title:"Berhasil! 🎉",text:i.success,icon:"success",timer:3e3,showConfirmButton:!1}):i.error?l.fire("Gagal!",i.error,"error"):i.info&&l.fire({title:"Informasi",text:i.info,icon:"info",confirmButtonColor:"#3B82F6"})},[i]),e.jsxs(w,{user:d.user,header:e.jsx("h2",{className:"font-semibold text-xl text-gray-800 leading-tight",children:"Manajemen Visi & Misi Kampus"}),children:[e.jsx(v,{title:"Visi & Misi Kampus"}),e.jsx(S,{isOpen:j,onClose:()=>o(!1),onConfirm:y,visiMisi:h}),e.jsx("div",{className:"max-w-7xl mx-auto sm:px-6 lg:px-8 py-12",children:e.jsxs("div",{className:"bg-white overflow-hidden shadow-xl sm:rounded-lg p-6",children:[e.jsxs("h3",{className:"text-2xl font-bold text-gray-800 mb-6 flex items-center",children:[e.jsx(t,{icon:u,className:"mr-3 text-indigo-600"}),"Data Visi & Misi Kampus"]}),e.jsx("div",{className:"flex justify-end mb-6",children:e.jsxs(p,{href:route("admin.kampus.visimisi.create"),onClick:N,className:`inline-flex items-center px-4 py-2 border border-transparent rounded-lg font-semibold text-xs uppercase tracking-widest transition ease-in-out duration-150 shadow-md justify-center
                                ${a?"bg-gray-400 text-gray-700 cursor-pointer opacity-90":"bg-indigo-600 text-white hover:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:border-indigo-900 focus:ring ring-indigo-300"}`,title:a?"Klik untuk Edit atau Hapus data yang ada.":"Tambah Visi Misi Baru",children:[e.jsx(t,{icon:a?M:V,className:"w-4 h-4 mr-2"}),a?"Tambah Visi Misi (Edit Data)":"Tambah Visi Misi Baru"]})}),g.length>0?e.jsx("div",{className:"border border-gray-200 rounded-lg shadow-lg overflow-hidden",children:g.map(s=>e.jsxs("div",{className:"divide-y divide-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 bg-gray-50 flex justify-between items-center",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:s.title||"Visi & Misi Kampus"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(p,{href:route("admin.kampus.visimisi.edit"),className:"transition duration-150 p-2 rounded-full text-indigo-600 hover:text-indigo-900 hover:bg-indigo-100",title:"Edit Visi & Misi",children:e.jsx(t,{icon:C,className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>b(s),className:"transition duration-150 p-2 rounded-full text-red-600 hover:text-red-900 hover:bg-red-100",title:"Hapus Visi & Misi",children:e.jsx(t,{icon:B,className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-3",children:[e.jsx(t,{icon:u,className:"w-5 h-5 mr-3 text-indigo-600"}),e.jsx("h5",{className:"font-semibold text-gray-800",children:"Visi:"})]}),e.jsxs("p",{className:"text-gray-700 italic border-l-4 border-indigo-200 pl-4 py-2 bg-indigo-50 rounded-r-md",children:['"',s.visi,'"']})]}),e.jsxs("div",{className:"p-6 pt-0",children:[e.jsxs("div",{className:"flex items-center mb-3",children:[e.jsx(t,{icon:T,className:"w-5 h-5 mr-3 text-indigo-600"}),e.jsx("h5",{className:"font-semibold text-gray-800",children:"Misi:"})]}),Array.isArray(s.misi)&&s.misi.length>0?e.jsx("ol",{className:"list-inside space-y-2 text-gray-700",children:s.misi.map((n,r)=>e.jsxs("li",{className:"flex",children:[e.jsxs("span",{className:"mr-2 font-medium text-indigo-600",children:[r+1,"."]}),e.jsx("p",{className:"flex-grow",children:n})]},r))}):e.jsx("p",{className:"text-gray-500 italic",children:"Misi belum diisi."})]}),e.jsxs("div",{className:"p-6 pt-0",children:[e.jsxs("div",{className:"flex items-center mb-3",children:[e.jsx(t,{icon:D,className:"w-5 h-5 mr-3 text-orange-600"}),e.jsxs("h5",{className:"font-semibold text-gray-800",children:["Tujuan ",e.jsx("span",{className:"text-gray-500 text-sm",children:"(Opsional)"}),":"]})]}),Array.isArray(s.tujuan)&&s.tujuan.length>0?e.jsx("ol",{className:"list-inside space-y-2 text-gray-700",children:s.tujuan.map((n,r)=>e.jsxs("li",{className:"flex",children:[e.jsxs("span",{className:"mr-2 font-medium text-orange-600",children:[r+1,"."]}),e.jsx("p",{className:"flex-grow",children:n})]},`tujuan-${r}`))}):e.jsx("p",{className:"text-gray-500 italic",children:"Tujuan belum diisi."})]})]},s.id))}):e.jsxs("div",{className:"text-center py-10 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50",children:[e.jsx(t,{icon:u,className:"w-10 h-10 text-gray-400 mb-4"}),e.jsx("p",{className:"text-lg text-gray-600 font-semibold",children:"Data Visi & Misi kampus belum tersedia."}),e.jsx("p",{className:"text-gray-500 mt-2",children:"Silakan klik tombol di atas untuk **Tambah Visi Misi Baru**."})]})]})})]})}export{z as default};
