import{_ as D}from"./UserLayout-D_lxcpvH.js";import{p as S,c as t,o as r,F as _,h as O,g as y,t as o,d as c,n as B,j as E,k as v}from"./app-fEKA3BkQ.js";import w from"./InteractiveMessage-GTvMPNF-.js";import"./assetStore-BSVLrDIW.js";import"./PageHeader-DmRLoM5E.js";import"./ValidationErrors-B24rcOPH.js";const N={class:"rounded-md bg-slate-100 p-4 dark:bg-dark-900"},C={key:0,class:"mb-2 font-bold",id:"headerText"},U=["src"],$=["href"],R={class:"text-cyan-600"},j={key:1,id:"bodyText",class:"mb-2 py-1 text-[12px] font-light"},A={key:2,class:"text-[11px] font-light"},P={key:3,class:"border-t dark:border-dark-700"},Y=["href"],H={key:1,href:"",class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},V={key:2,href:"",class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},F={key:3,href:"",class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},L={__name:"Preview",props:{templateData:{type:Array,default:[]},updatedTemplateSecret:{type:Object,default:{HEADER:null,BODY:[],BUTTONS:{URL:null,COPY_CODE:null}}}},setup(d){const p=d,f=S(()=>(a,s=null)=>{var e,x;if(a&&a.type=="BODY"){let n=a.text;return a&&p.updatedTemplateSecret&&p.updatedTemplateSecret[a.type]&&!((e=p.updatedTemplateSecret[a.type])!=null&&e.length)||(x=p.updatedTemplateSecret[a.type])==null||x.map((u,h)=>{n=n.replace(`{{${h+1}}}`,u)}),n}else if((a==null?void 0:a.type)=="BUTTONS"&&s){if(!p.updatedTemplateSecret[a.type])return"";if(!p.updatedTemplateSecret[a.type][s.type])return s[s.type]??""}else if(a&&a.type=="HEADER"){let n=a.text;return p.updatedTemplateSecret[a.type]?n.replace("{{1}}",p.updatedTemplateSecret[a.type]):n}return""});return(a,s)=>(r(),t("div",N,[(r(!0),t(_,null,O(d.templateData,(e,x)=>{var n,u,h,k,T;return r(),t(_,{key:x},[e.type==="HEADER"?(r(),t(_,{key:0},[e.format==="TEXT"&&(e!=null&&e.text)?(r(),t("p",C,o(f.value(e)),1)):e.format==="IMAGE"&&((n=e==null?void 0:e.example)!=null&&n.header_handle[0])?(r(),t("img",{key:1,src:(u=e==null?void 0:e.example)==null?void 0:u.header_handle[0],class:"h-36 w-full rounded object-cover",alt:""},null,8,U)):e.format==="DOCUMENT"&&((h=e==null?void 0:e.example)!=null&&h.header_handle[0])?(r(),t("a",{key:2,href:(k=e==null?void 0:e.example)==null?void 0:k.header_handle[0],target:"_blank",rel:"noopener noreferrer",class:"flex items-center justify-between gap-3 rounded bg-gray-100 p-3"},[s[0]||(s[0]=c("i",{class:"bx bx-file"},null,-1)),c("span",R,o(a.trans("Click")),1)],8,$)):y("",!0)],64)):y("",!0),e.type==="BODY"?(r(),t("p",j,o(f.value(e)),1)):y("",!0),e.type==="FOOTER"&&(e!=null&&e.text)?(r(),t("p",A,o(e.text),1)):y("",!0),(e==null?void 0:e.type)==="BUTTONS"&&((T=e==null?void 0:e.buttons)!=null&&T.length)?(r(),t("ul",P,[(r(!0),t(_,null,O(e==null?void 0:e.buttons,(l,g)=>(r(),t("li",{key:g,class:B([{"border-b dark:border-dark-700":g!==(e==null?void 0:e.buttons.length)-1},"px-1 py-2 text-center"])},[l.type==="URL"?(r(),t("a",{key:0,href:a.sanitizeUrl(f.value(e,l)),class:"w-full text-center text-sm font-normal text-primary-400 hover:text-primary-600"},[s[1]||(s[1]=c("i",{class:"fa-solid fa-pen-to-square"},null,-1)),E(" "+o(l==null?void 0:l.text),1)],8,Y)):l.type==="PHONE_NUMBER"?(r(),t("a",H,[s[2]||(s[2]=c("i",{class:"fa-solid fa-phone"},null,-1)),E(" "+o(l==null?void 0:l.text),1)])):l.type==="COPY_CODE"?(r(),t("a",V,o(l==null?void 0:l.text),1)):(r(),t("a",F,o(l==null?void 0:l.text),1))],2))),128))])):y("",!0)],64)}),128))]))}},M={class:"mx-auto max-w-2xl"},z={class:"card p-4"},q={class:"mb-2 ml-1 text-lg"},Z=Object.assign({layout:D},{__name:"Show",props:{template:{type:Object,default:{}}},setup(d){return(p,f)=>{var a;return r(),t("div",M,[c("div",z,[c("p",q,o(p.trans("Preview")),1),d.template.type=="interactive"?(r(),v(w,{key:0,components:d.template.meta||[]},null,8,["components"])):(r(),v(L,{key:1,templateData:((a=d.template.meta)==null?void 0:a.components)||[]},null,8,["templateData"]))])])}}});export{Z as default};
