import{aq as p,F as l,P as i,Q as _,R as d,X as m,T as c,_ as g,W as h,a0 as f,Z as k,aY as v,b2 as C,e as M}from"./vendor-DJC-2VPc.js";import{u as R}from"./index-BsIL0hak.js";import{Z as y,$ as P,a0 as D}from"./index-BZco6cza.js";import{O as U,P as $,M as b}from"./types-zo7pMMkl.js";function z(){return p(b,{optimisticResponse:{markPushMessageUnread:!0},update(a,s,{variables:t}){if(!s.data?.markPushMessageUnread)return;let o=null;a.updateFragment({id:`${y}${t?.command?.messageId}`,fragment:$},e=>(o=e,e?{...e,isRead:!1}:null)),a.modify({fields:{[D]:e=>{const n=e;return o?.isHidden?n:{totalCount:(n.totalCount??0)+1}},[P]:e=>({totalCount:(e.totalCount??0)+1})}})},refetchQueries:[U.Query.GetPushMessages]})}function B(a){const{mutate:s}=R();async function t(){await s({command:{messageId:a.value.id}})}const{mutate:o}=z();async function e(){await o({command:{messageId:a.value.id}})}async function n(){a.value.isRead?await e():await t()}return{pushMessage:a,markRead:t,markUnread:e,toggleRead:n}}const E={class:"vc-push-message__info"},H={class:"vc-push-message__date"},N=l({__name:"vc-push-message",props:{pushMessage:{},removable:{type:Boolean},size:{default:"md"}},emits:["remove"],setup(a){return(s,t)=>{const o=i("VcBadge"),e=i("VcMarkdownRender"),n=i("VcButton");return d(),_("div",{class:k(["vc-push-message",`vc-push-message--size--${s.size}`,{"vc-push-message--unread":!s.pushMessage.isRead}])},[m(o,{class:"vc-push-message__badge",color:"info",rounded:""}),c("div",E,[m(e,{class:"vc-push-message__content",src:s.pushMessage.shortMessage},null,8,["src"]),c("div",H,f(s.$d(s.pushMessage.createdDate,{key:"long",second:void 0})),1)]),s.removable?(d(),g(n,{key:0,class:"vc-push-message__button",size:"xs",color:"neutral",variant:"no-background",icon:"delete-thin",onClick:t[0]||(t[0]=u=>{s.$emit("remove"),u.stopPropagation()})})):h("",!0)],2)}}}),O=l({__name:"push-message",props:{pushMessage:{},size:{}},emits:["toggleRead"],setup(a,{emit:s}){const t=s,o=a,{pushMessage:e}=v(o),{toggleRead:n}=B(e);async function u(){await n(),t("toggleRead")}return(r,V)=>(d(),g(N,{size:r.size,"push-message":M(e),role:"button",tabindex:"0","aria-label":r.pushMessage.isRead?r.$t("push_messages.mark_as_unread"):r.$t("push_messages.mark_as_read"),title:r.pushMessage.isRead?r.$t("push_messages.mark_as_unread"):r.$t("push_messages.mark_as_read"),onClick:u,onKeypress:C(u,["enter"])},null,8,["size","push-message","aria-label","title"]))}});export{O as _};
//# sourceMappingURL=push-message.vue_vue_type_script_setup_true_lang-DwfTPuTj.js.map
