(function(){"use strict";functiond(n,e,r,t,o,l,a,i){vars=typeofn=="function"?n.options:n;returns.render=e,s.staticRenderFns=r,s._compiled=!0,s._scopeId="data-v-"+l,{exports:n,options:s}}const_={__name:"SendButtonField",props:{pageUri:String,pageStatus:String},setup(n){const{pageUri:e}=n,r=Vue.ref({icon:"plane",text:"Tester",theme:null,error:null}),t=Vue.ref({icon:"plane",text:"Envoyer",theme:"orange",error:null});asyncfunctiono(l,a=!1){l.preventDefault();consti=a?r:t;i.value={theme:"blue",text:"En cours…",icon:"loader",error:null};consts={method:"POST",body:JSON.stringify({pageUri:e,isTest:a})};try{constc=await(awaitfetch("/send-newsletter.json",s)).json();if(console.log(c),c.status==="success")i.value={theme:"green",icon:"check",text:a?"Test envoyé":"Envoi réussi",error:null},setTimeout(()=>{location.href=location.href},2e3);else{leth=c.message||"Erreur inconnue";thrownewError(h)}}catch(u){i.value={theme:"red",icon:"alert",text:a?"Échec du test":"Erreur",error:u.message}}}return{__sfc:!0,testBtnState:r,sendBtnState:t,send:o}}};varf=function(){vare=this,r=e._self._c,t=e._self._setupProxy;returne.pageStatus!=="listed"?r("div",{staticClass:"wrapper"},[r("div",{staticClass:"test-wrapper"},[r("k-button",{staticStyle:{width:"max-content"},attrs:{variant:"filled",help:"test",theme:t.testBtnState.theme,icon:t.testBtnState.icon},on:{click:function(o){returnt.send(o,!0)}}},[e._v(e._s(t.testBtnState.text))]),e._m(0),t.testBtnState.error?r("k-box",{staticStyle:{"margin-top":"var(--spacing-1)"},attrs:{theme:"error"}},[e._v(e._s(t.testBtnState.error))]):e._e()],1),r("div",{staticClass:"send-wrapper"},[r("k-button",{attrs:{variant:"filled",theme:t.sendBtnState.theme,icon:t.sendBtnState.icon},on:{click:function(o){returnt.send(o)}}},[e._v(e._s(t.sendBtnState.text))]),t.sendBtnState.error?r("k-box",{staticStyle:{"margin-top":"var(--spacing-1)"},attrs:{theme:"error"}},[e._v(e._s(t.sendBtnState.error))]):e._e(),e._m(1)],1)]):e._e()},p=[function(){varn=this,e=n._self._c;returnn._self._setupProxy,e("footer",{staticClass:"k-field-footer"},[e("div",{staticClass:"k-help k-field-help k-text"},[e("p",[n._v("Envoie seulement à la liste ci-dessus")])])])},function(){varn=this,e=n._self._c;returnn._self._setupProxy,e("footer",{staticClass:"k-field-footer"},[e("div",{staticClass:"k-help k-field-help k-text"},[e("strong",[n._v("⚠ Envoie à tous les abonnés.")])])])}],v=d(_,f,p,!1,null,"17f2f6fa");constm=v.exports;window.panel.plugin("adrienpayet/send-button",{fields:{"send-button":m}})})();