import{A as e,D as t,K as n,M as r,U as i,b as a,gt as o,j as s,jt as c,mt as l,ot as u,p as d,st as f,v as p,w as m,wt as h}from"./dist-B4ulKgpj.js";import{n as g}from"./usetoast-BF8L6V7u.js";import{t as _}from"./toast-CIOCHy8g.js";import{t as v}from"./Label-CFnMyEie.js";import{t as y}from"./button-DVjHqmFH.js";import{t as b}from"./inputtext-BlE0mOXw.js";import{t as x}from"./textarea-BEctI9xX.js";import{t as S}from"./InputError-whMZ-BCS.js";var C={class:`grid gap-2`},w={class:`grid gap-2`},T={class:`grid gap-2`},E={class:`grid gap-2`},D={class:`grid gap-2`},O={class:`flex flex-wrap items-center gap-6`},k={class:`flex items-center gap-2 text-sm`},A={class:`flex items-center gap-2 text-sm`},j={class:`flex justify-end`},M=r({__name:`UpdateArticle`,props:{articleDetails:{}},setup(r){let M=r,N=g(),P=o(!1),F=l({title:``,subtitle:``,articleContent:``,articleImage:``,link:``,isFeatured:!1,isActive:!0}),I=o(``),L=o(``),R=o(``),z=o(``),B=o(``);i(()=>{F.title=M.articleDetails?.title??``,F.subtitle=M.articleDetails?.subtitle??``,F.articleContent=M.articleDetails?.article_content??``,F.articleImage=M.articleDetails?.article_image??``,F.link=M.articleDetails?.link??``,F.isFeatured=!!M.articleDetails?.is_featured,F.isActive=!!(M.articleDetails?.is_active??!0)});let V=()=>{I.value=``,L.value=``,R.value=``,z.value=``,B.value=``};function H(){V(),P.value=!0,c.put(`/article-management/${M.articleDetails.id}`,F,{onSuccess:()=>{P.value=!1,N.add({severity:`success`,summary:`Success`,detail:`Article updated successfully`,life:2500}),setTimeout(()=>c.visit(`/article-management`),800)},onError:e=>{P.value=!1,I.value=e.title||``,L.value=e.subtitle||``,R.value=e.articleContent||``,z.value=e.articleImage||``,B.value=e.link||``}})}return(r,i)=>(n(),t(a,null,[s(h(_)),m(`form`,{onSubmit:p(H,[`prevent`]),class:`space-y-4`},[m(`div`,C,[s(h(v),{for:`title`},{default:u(()=>[...i[7]||=[e(`Title `,-1),m(`span`,{class:`text-red-600`},`*`,-1)]]),_:1}),s(h(b),{id:`title`,modelValue:F.title,"onUpdate:modelValue":i[0]||=e=>F.title=e,invalid:!!I.value},null,8,[`modelValue`,`invalid`]),s(S,{message:I.value},null,8,[`message`])]),m(`div`,w,[s(h(v),{for:`subtitle`},{default:u(()=>[...i[8]||=[e(`Subtitle`,-1)]]),_:1}),s(h(b),{id:`subtitle`,modelValue:F.subtitle,"onUpdate:modelValue":i[1]||=e=>F.subtitle=e,invalid:!!L.value},null,8,[`modelValue`,`invalid`]),s(S,{message:L.value},null,8,[`message`])]),m(`div`,T,[s(h(v),{for:`articleImage`},{default:u(()=>[...i[9]||=[e(`Image URL`,-1)]]),_:1}),s(h(b),{id:`articleImage`,modelValue:F.articleImage,"onUpdate:modelValue":i[2]||=e=>F.articleImage=e,invalid:!!z.value},null,8,[`modelValue`,`invalid`]),s(S,{message:z.value},null,8,[`message`])]),m(`div`,E,[s(h(v),{for:`link`},{default:u(()=>[...i[10]||=[e(`External Link`,-1)]]),_:1}),s(h(b),{id:`link`,modelValue:F.link,"onUpdate:modelValue":i[3]||=e=>F.link=e,invalid:!!B.value},null,8,[`modelValue`,`invalid`]),s(S,{message:B.value},null,8,[`message`])]),m(`div`,D,[s(h(v),{for:`articleContent`},{default:u(()=>[...i[11]||=[e(`Article Content `,-1),m(`span`,{class:`text-red-600`},`*`,-1)]]),_:1}),s(h(x),{id:`articleContent`,modelValue:F.articleContent,"onUpdate:modelValue":i[4]||=e=>F.articleContent=e,rows:`7`,invalid:!!R.value},null,8,[`modelValue`,`invalid`]),s(S,{message:R.value},null,8,[`message`])]),m(`div`,O,[m(`label`,k,[f(m(`input`,{"onUpdate:modelValue":i[5]||=e=>F.isFeatured=e,type:`checkbox`},null,512),[[d,F.isFeatured]]),i[12]||=e(` Featured `,-1)]),m(`label`,A,[f(m(`input`,{"onUpdate:modelValue":i[6]||=e=>F.isActive=e,type:`checkbox`},null,512),[[d,F.isActive]]),i[13]||=e(` Active `,-1)])]),m(`div`,j,[s(h(y),{type:`submit`,severity:`warn`,loading:P.value},{default:u(()=>[...i[14]||=[m(`span`,null,[m(`i`,{class:`pi pi-save`})],-1),m(`span`,null,` Update Article`,-1)]]),_:1},8,[`loading`])])],32)],64))}});export{M as t};