import{p as j,c as r,o as s,F as C,h as L,g as p,t as l,d,n as B,j as b}from"./app-fEKA3BkQ.js";const D={class:"m-1 rounded-md bg-slate-100 p-4 text-black dark:bg-dark-800 dark:text-white"},N={key:0},E={key:0,class:"mb-2 font-bold",id:"headerText"},F=["src"],q=["href"],z={class:"text-cyan-600"},M={key:1,id:"bodyText",class:"mb-2 py-1 text-[12px]"},R={key:2},S={class:"text-[11px]"},U={key:3},$={class:"mt-3 border-t dark:border-dark-700"},A=["href"],G={key:1,href:"#",class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},H={key:2,href:"#",class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},I={key:3,href:"#",class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},K={__name:"TemplateMessage",props:["message","templateData"],setup(T){const k=T,f=o=>{var x,n,c;const t=o.text??"",e=((x=o.example)==null?void 0:x.header_text)??((c=(n=o.example)==null?void 0:n.body_text)==null?void 0:c[0])??[];return t.includes("{{")&&t.includes("}}")&&e.length?e.reduce((h,y,_)=>h.replace(`{{${_+1}}}`,y),t):t},V=j(()=>{var o;return k.templateData||((o=k.message)==null?void 0:o.meta)||[]});return(o,t)=>(s(),r("div",D,[(s(!0),r(C,null,L(V.value,(e,x)=>{var n,c,h,y,_,u,g,w;return s(),r("div",{key:x},[((n=e.type)==null?void 0:n.toLowerCase())=="header"?(s(),r("div",N,[((c=e.format)==null?void 0:c.toLowerCase())=="text"&&(e!=null&&e.text)?(s(),r("p",E,l(f(e)),1)):e.format.toLowerCase()=="image"&&((h=e==null?void 0:e.example)!=null&&h.header_handle[0])?(s(),r("img",{key:1,src:(y=e==null?void 0:e.example)==null?void 0:y.header_handle[0],class:"h-36 w-full rounded object-cover",alt:""},null,8,F)):e.format.toLowerCase()=="document"&&((_=e==null?void 0:e.example)!=null&&_.header_handle[0])?(s(),r("a",{key:2,href:e,target:"_blank",rel:"noopener noreferrer",class:"flex items-center justify-between gap-3 rounded bg-gray-100 p-3 dark:bg-dark-700"},[t[0]||(t[0]=d("i",{class:"bx bx-file"},null,-1)),d("span",z,l(o.trans("Click")),1)],8,q)):p("",!0)])):p("",!0),((u=e.type)==null?void 0:u.toLowerCase())=="body"?(s(),r("p",M,l(f(e)),1)):p("",!0),((g=e.type)==null?void 0:g.toLowerCase())=="footer"&&(e!=null&&e.text)?(s(),r("div",R,[d("p",S,l(f(e)),1)])):p("",!0),(e==null?void 0:e.type)=="buttons"&&((w=e==null?void 0:e.buttons)!=null&&w.length)?(s(),r("div",U,[d("ul",$,[(s(!0),r(C,null,L(e==null?void 0:e.buttons,(a,v)=>(s(),r("li",{key:v,class:B([{"border-b":v!==(e==null?void 0:e.buttons.length)-1},"px-1 py-2 text-center dark:border-dark-700"])},[a.type=="URL"?(s(),r("a",{key:0,href:e,class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},[t[1]||(t[1]=d("i",{class:"fa-solid fa-pen-to-square"},null,-1)),b(" "+l(a==null?void 0:a.text),1)],8,A)):a.type=="phone_number"?(s(),r("a",G,[t[2]||(t[2]=d("i",{class:"fa-solid fa-phone"},null,-1)),b(" "+l(a==null?void 0:a.text),1)])):a.type=="copy_code"?(s(),r("a",H,l(a==null?void 0:a.text),1)):(s(),r("a",I,l(a==null?void 0:a.text),1))],2))),128))])])):p("",!0)])}),128))]))}};export{K as default};
