import{h as q,r as R}from"./app-CWjefGxh.js";import{C as c,l as i,A as y,B,n as e,t as l,u as n,x as u,R as p,H as E,g as f,e as m,a as _}from"./Button-1eZ2gOMK.js";import{_ as S}from"./ConversionPixels-BEnlUC-J.js";import{y as h,Y as x}from"./youtubeEmbed-CPQaiurV.js";const U={class:"mx-auto max-w-2xl"},V={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-lg"},W={key:0,class:"aspect-video w-full overflow-hidden bg-gray-200"},D=["src"],L={key:1,class:"aspect-video w-full overflow-hidden bg-black"},M=["src","allow"],N={class:"p-6 sm:p-8"},X={class:"mb-4 text-sm text-gray-600"},F={key:0,class:"mb-6 whitespace-pre-wrap text-sm text-gray-700"},H={key:1,class:"mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700"},T={class:"flex flex-row flex-wrap gap-3 items-start rounded-xl border-2 border-gray-200 bg-gray-50/50 p-4"},P={class:"h-20 w-20 shrink-0 sm:h-28 sm:w-28"},Y=["src","alt"],z={class:"min-w-0 flex-1"},I={class:"font-semibold text-gray-900"},$={key:0,class:"mt-2 text-sm text-gray-600"},G={key:2,class:"mt-3 aspect-video w-full overflow-hidden rounded-lg bg-black"},J=["src","allow"],K={class:"mt-6 flex flex-col gap-3 sm:flex-row sm:gap-4"},Q=["disabled"],Z=["disabled"],se=Object.assign({layout:null},{__name:"Downsell",props:{token:{type:String,required:!0},order:{type:Object,default:()=>({})},offer:{type:Object,required:!0},appearance:{type:Object,default:()=>({})},page:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})},conversion_pixels:{type:Object,default:()=>({})}},setup(t){const o=t,g=f(()=>o.appearance.primary_color||"#0ea5e9"),v=f(()=>o.page?.headline||o.appearance.title||"Última chance com desconto"),w=f(()=>o.page?.subheadline||o.appearance.subtitle||"Uma oferta que não pode ficar de fora"),k=f(()=>o.appearance.button_accept||"Aceitar oferta"),j=f(()=>o.appearance.button_decline||"Não, obrigado"),O=f(()=>o.page?.background_color||"#f3f4f6"),s=m(!1),r=m(!1),d=m("");function b(a){a&&(a.startsWith("http")||a.startsWith("//"))?window.location.href=a:a&&R.visit(a)}async function C(){if(!s.value){s.value=!0,d.value="";try{const{data:a}=await _.post("/checkout/downsell/accept",{token:o.token},{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},validateStatus:()=>!0});if(a.redirect_url){b(a.redirect_url);return}a.message&&(d.value=a.message),s.value=!1}catch(a){d.value=a.response?.data?.message||"Erro ao processar. Tente novamente.",s.value=!1}}}async function A(){if(!r.value){r.value=!0,d.value="";try{const{data:a}=await _.post("/checkout/downsell/decline",{token:o.token},{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},validateStatus:()=>!0});if(a.redirect_url){b(a.redirect_url);return}}catch{r.value=!1}r.value=!1}}return(a,ee)=>(c(),i(E,null,[y(S,{pixels:o.conversion_pixels},null,8,["pixels"]),y(n(q),null,{default:B(()=>[e("title",null,l(v.value),1)]),_:1}),e("div",{class:"min-h-screen px-4 py-6 sm:py-8",style:p({backgroundColor:O.value})},[e("div",U,[e("div",V,[t.page?.hero_image?(c(),i("div",W,[e("img",{src:t.page.hero_image,alt:"",class:"h-full w-full object-cover"},null,8,D)])):u("",!0),t.page?.hero_video_url&&n(h)(t.page.hero_video_url)?(c(),i("div",L,[e("iframe",{src:n(h)(t.page.hero_video_url),title:"Vídeo",class:"h-full w-full",allow:n(x),allowfullscreen:""},null,8,M)])):u("",!0),e("div",N,[e("h2",{class:"mb-1 text-xl font-bold text-gray-900",style:p({color:g.value})},l(v.value),5),e("p",X,l(w.value),1),t.page?.body_text?(c(),i("p",F,l(t.page.body_text),1)):u("",!0),d.value?(c(),i("p",H,l(d.value),1)):u("",!0),e("div",T,[e("div",P,[e("img",{src:t.offer.image_url||"https://placehold.co/96x96/e2e8f0/64748b?text=Oferta",alt:t.offer.name,class:"h-full w-full rounded-lg object-cover"},null,8,Y)]),e("div",z,[e("h3",I,l(t.offer.name),1),t.offer.description?(c(),i("p",$,l(t.offer.description),1)):u("",!0),e("p",{class:"mt-2 text-lg font-bold",style:p({color:g.value})},l(t.offer.price_formatted),5)])]),t.offer.video_url&&n(h)(t.offer.video_url)?(c(),i("div",G,[e("iframe",{src:n(h)(t.offer.video_url),title:"Vídeo da oferta",class:"h-full w-full",allow:n(x),allowfullscreen:""},null,8,J)])):u("",!0),e("div",K,[e("button",{type:"button",class:"flex-1 rounded-xl px-5 py-3 font-semibold text-white transition-opacity hover:opacity-90 disabled:opacity-70",style:p({backgroundColor:g.value}),disabled:s.value||r.value,onClick:C},l(s.value?"Processando...":k.value),13,Q),e("button",{type:"button",class:"flex-1 rounded-xl border-2 border-gray-300 bg-white py-3 font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-70",disabled:s.value||r.value,onClick:A},l(r.value?"Redirecionando...":j.value),9,Z)])])])])],4)],64))}});export{se as default};
