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