import{f as m,i as t,a4 as N,a5 as V,a6 as G,a2 as v,M as x,w as $,g as _,n as F}from"./app-JmgyQoR0.js";import{b as H,a as T,c as b,D as f,h as u,i as g,j as l,l as o,u as p,t as k,G as z,K as r,E as d,z as n,H as y,F as A,x as D}from"./vue-y3KLWBaS.js";const E={class:"_card _gap announcements"},j={class:"_content announcement"},I={key:1},K={class:"buttons"},L=p("i",{class:"ph-floppy-disk-back ph-bold ph-lg"},null,-1),R=p("i",{class:"ph-trash ph-bold ph-lg"},null,-1),W=H({__name:"announcements",setup(O){let c=T([]);m("admin/announcements/list").then(a=>{c.value=a});function U(){c.value.unshift({id:null,title:"",text:"",imageUrl:null,showPopup:!1,isGoodNews:!1})}function w(a){$({type:"warning",text:t.t("removeAreYouSure",{x:a.title})}).then(({canceled:i})=>{i||(c.value=c.value.filter(h=>h!==a),m("admin/announcements/delete",a))})}function M(a){a.id==null?m("admin/announcements/create",a).then(()=>{_({type:"success",text:t.ts.saved})}).catch(i=>{_({type:"error",text:i})}):m("admin/announcements/update",a).then(()=>{_({type:"success",text:t.ts.saved})}).catch(i=>{_({type:"error",text:i})})}const C=b(()=>[{asFullButton:!0,icon:"ph-plus ph-bold ph-lg",text:t.ts.add,handler:U}]),B=b(()=>[]);return N({title:t.ts.announcements,icon:"ph-megaphone-simple ph-bold ph-lg"}),(a,i)=>{const h=f("MkPageHeader"),P=f("MkSpacer"),S=f("MkStickyContainer");return u(),g(S,null,{header:l(()=>[o(h,{actions:C.value,tabs:B.value,"display-back-button":!0},null,8,["actions","tabs"])]),default:l(()=>[o(P,{"content-max":900},{default:l(()=>[p("div",{class:D(a.$style.root)},[(u(!0),k(A,null,z(c.value,e=>(u(),k("section",E,[p("div",j,[o(V,{modelValue:e.title,"onUpdate:modelValue":s=>e.title=s},{label:l(()=>[r(d(n(t).ts.title),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]),o(G,{modelValue:e.text,"onUpdate:modelValue":s=>e.text=s},{label:l(()=>[r(d(n(t).ts.text),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]),o(V,{modelValue:e.imageUrl,"onUpdate:modelValue":s=>e.imageUrl=s},{label:l(()=>[r(d(n(t).ts.imageUrl),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]),o(v,{modelValue:e.showPopup,"onUpdate:modelValue":s=>e.showPopup=s,class:"_formBlock"},{default:l(()=>[r(d(n(t).ts.showPopup),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]),e.showPopup?(u(),g(v,{key:0,modelValue:e.isGoodNews,"onUpdate:modelValue":s=>e.isGoodNews=s,class:"_formBlock"},{default:l(()=>[r(d(n(t).ts.showWithSparkles),1)]),_:2},1032,["modelValue","onUpdate:modelValue"])):y("",!0),e.reads?(u(),k("p",I,d(n(t).t("nUsersRead",{n:e.reads})),1)):y("",!0),p("div",K,[o(x,{class:"button",inline:"",primary:"",onClick:s=>M(e)},{default:l(()=>[L,r(" "+d(n(t).ts.save),1)]),_:2},1032,["onClick"]),o(x,{class:"button",inline:"",onClick:s=>w(e)},{default:l(()=>[R,r(" "+d(n(t).ts.remove),1)]),_:2},1032,["onClick"])])])]))),256))],2)]),_:1})]),_:1})}}}),Y="_root_tnw0h_1",q={root:Y},J={$style:q},Z=F(W,[["__cssModules",J]]);export{Z as default};
