import{d as O,t as V,r as l,G as r,X as $,o as s,c as o,b as u,e as v,u as t,a as n,Q as q,g as k,h as R,H as Y,Y as j}from"../../../../common/index.DXvi0yH9.js";/* empty css                                                                                       *//* empty css                                                                                 */import{_ as z}from"../../../../common/Notification.vue_vue_type_script_setup_true_lang.D_vuSbU1.js";import{_ as D}from"../../../../common/Confirmation.vue_vue_type_script_setup_true_lang.BvpajMdU.js";import{_ as E}from"../../../../common/LabelControl.vue_vue_type_script_setup_true_lang.B_b65Eg0.js";import"../../../../common/x.ClCP0MsD.js";import"../../../../common/createLucideIcon.D3XWtEmL.js";import"../../../../common/transition.CRNcmuQX.js";import"../../../../common/keyboard.D4P2wQc7.js";import"../../../../common/open-closed.CQX5sZkx.js";import"../../../../common/micro-task.CxIZtCgj.js";const G={key:0},I={class:"stwlite-tw-flex stwlite-tw-items-center stwlite-tw-mb-2 stwlite-tw-gap-2"},Q={class:"stwlite-tw-flex stwlite-tw-items-center stwlite-tw-mb-2 stwlite-tw-gap-2"},S={class:"stwlite-tw-flex stwlite-tw-items-center stwlite-tw-space-x-2"},X=["disabled"],F={key:0},J={key:1},K=["disabled"],P={key:0},U={key:1},W=["for"],Z=["innerHTML"],tt={key:1,class:"stw-button-control"},et=["id","href","target"],st=["id","type"],dt=O({__name:"ButtonControl",props:{params:{type:Object,required:!0}},setup(x){const C=x,{params:T}=V(C),e=T.value,b=l(!!e.link),B=l(e.external?"_blank":"_self"),p=l(!0),_=l(e.action),c=l(!1),i=l(!1),d=l(""),w=l(""),f=l("");(_.value==="submit"||_.value==="button")&&(p.value=!1),b.value&&(p.value=!1);const N=r("confirmText",wp.i18n.__("Are you sure?","saveto-wishlist-lite-for-woocommerce")),A=()=>{c.value=!0},g=async()=>{i.value=!0;try{const m={action:_.value},a=await j(m);a.type,c.value=!1,i.value=!1,w.value=a.message,d.value=a.title,f.value=a.type}catch(m){console.error(m)}},L=()=>{c.value=!1,i.value=!1},M=()=>{w.value=""};return(m,a)=>{var y,h;const H=$("Tooltip");return p.value?(s(),o("div",G,[u("div",I,[v(t(E),{params:t(e)},null,8,["params"])]),u("div",Q,[u("div",S,[t(e).confirmation?(s(),o("button",{key:0,class:"stwlite-tw-bg-blue-600 stwlite-tw-text-white stwlite-tw-px-4 stwlite-tw-py-2 stwlite-tw-rounded-md stwlite-tw-font-medium hover:stwlite-tw-bg-blue-700 stwlite-tw-transition-colors stwlite-tw-border-0 stwlite-tw-cursor-pointer stwlite-tw-mb-3 stwlite-tw-bg-blue-600 hover:stwlite-tw-bg-blue-700",type:"button",disabled:i.value,onClick:A},[i.value?(s(),o("span",F,n(t(r)("loading",t(wp.i18n.__)("Loading...","saveto-wishlist-lite-for-woocommerce"))),1)):(s(),o("span",J,n(t(e).button_label),1))],8,X)):(s(),o("button",{key:1,class:"stwlite-tw-bg-blue-600 stwlite-tw-text-white stwlite-tw-px-4 stwlite-tw-py-2 stwlite-tw-rounded-md stwlite-tw-font-medium hover:stwlite-tw-bg-blue-700 stwlite-tw-transition-colors stwlite-tw-border-0 stwlite-tw-cursor-pointer stwlite-tw-mb-3 stwlite-tw-bg-blue-600 hover:stwlite-tw-bg-blue-700",type:"button",disabled:i.value,onClick:g},[i.value?(s(),o("span",P,n(t(r)("loading",t(wp.i18n.__)("Loading...","saveto-wishlist-lite-for-woocommerce"))),1)):(s(),o("span",U,n(t(e).button_label),1))],8,K)),u("label",{for:t(e).id,class:"stwlite-tw-text-sm stwlite-tw-text-gray-700"},n(t(e).input_label),9,W)]),v(H,{params:t(e)},null,8,["params"])]),t(e).description!=="undefined"?(s(),o("p",{key:0,class:"stwlite-tw-text-sm stwlite-tw-text-gray-600 stwlite-tw-mt-2",innerHTML:t(q)((h=(y=t(e))==null?void 0:y.description)!=null?h:"")},null,8,Z)):k("",!0),v(D,{isOpen:c.value,processing:i.value,title:t(r)("confirmation_title",t(wp.i18n.__)("Confirmation","saveto-wishlist-lite-for-woocommerce")),message:t(N),confirmText:t(r)("yes",t(wp.i18n.__)("Yes","saveto-wishlist-lite-for-woocommerce")),cancelText:t(r)("no",t(wp.i18n.__)("No","saveto-wishlist-lite-for-woocommerce")),onCloseAction:L,onConfirmAction:g},null,8,["isOpen","processing","title","message","confirmText","cancelText"]),w.value?(s(),R(z,{key:1,message:w.value,type:f.value,messageTitle:d.value,onCloseNotification:M},null,8,["message","type","messageTitle"])):k("",!0)])):(s(),o("div",tt,[u("div",{class:Y(t(e).classes)},[b.value?(s(),o("a",{key:0,id:t(e).id,href:t(e).link,target:B.value},n(t(e).button_label),9,et)):(s(),o("button",{key:1,id:t(e).id,type:t(e).action},n(t(e).button_label),9,st))],2)]))}}});export{dt as default};
