1import"../chunks/NZTpNUN0.js";import{p as ae,l as w,v as q,a as o,b as oe,s as se,c as f,f as h,e as ne,n as g,r as u,d as s,i as K,g as P,o as t,j as r,t as ie}from"../chunks/CswluXHk.js";import{s as le}from"../chunks/D5MUd0dc.js";import{i as D}from"../chunks/Cvwav-Rz.js";import{c as _}from"../chunks/DCqg9Lcd.js";import{d as de,a as ce}from"../chunks/BnZqlU5Q.js";import{g as pe}from"../chunks/CdQ3TTyj.js";import{p as me}from"../chunks/BfpkmJ9v.js";import"../chunks/aH0YTA77.js";import{t as E}from"../chunks/CFi-xeDB.js";import{B as Y}from"../chunks/DltdByd6.js";import{I as z}from"../chunks/DuX34-Zw.js";import{C as fe}from"../chunks/BFGY4aR1.js";import{C as ue}from"../chunks/C3F0Z4bJ.js";import{C as ve,a as ge,b as ye}from"../chunks/DQXZ4mXD.js";import{C as _e}from"../chunks/BcsrqGLJ.js";import{A as he}from"../chunks/r7UZdRXb.js";var $e=h("<!> <!>",1),xe=h('<p class="text-red-500 text-sm"> </p>'),be=h('<form class="space-y-4"><div class="space-y-4"><div class="space-y-2"><label for="apiUrl" class="text-sm font-medium">Installation URL</label> <!> <p class="text-sm text-gray-500">The URL where your Sendy installation is hosted.</p></div> <div class="space-y-2"><label for="apiKey" class="text-sm font-medium">API Key</label> <!> <p class="text-sm text-gray-500">Your Sendy API key can be found in your Sendy settings.</p></div></div> <!></form>'),Se=h('<div class="flex items-center gap-4"><p class="text-sm text-gray-500">Need help? <a href="https://sendy.co/api" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline">Learn how to get your API key</a></p></div> <div class="space-x-2"><!> <!></div>',1),Ie=h("<!> <!> <!>",1),ke=h('<div class="mb-20"><button class="flex items-center text-sm text-gray-600 hover:text-gray-900 mb-4"><!> Back to Integrations</button> <!></div>');function Ye(G,T){ae(T,!0);const H=()=>ne(me,"$page",M),[M,Q]=se(),{sendyIntegration:L,team:F}=T.data;let $=w(q(L?.config?.api_key||"")),x=w(q(L?.config?.api_url||"")),d=w(""),A=w(!1),R=w(!1);async function V(){try{if(t(d,""),t(A,!0),!r($)||!r(x)){t(d,"API Key and Installation URL are required");return}const e=await fetch("/api/install/sendy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:F.id,config:{api_key:r($),api_url:r(x)}})}),b=await e.json();if(!e.ok)throw new Error(b.error||"Failed to save integration");E.success("Sendy integration saved successfully",{position:"top-right"})}catch(e){console.error("Error saving Sendy integration:",e),t(d,e.message||"Failed to save integration",!0),E.error(r(d),{position:"top-right"})}finally{t(A,!1)}}async function W(){try{t(R,!0);const e=await fetch("/api/install/sendy",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:F.id})}),b=await e.json();if(!e.ok)throw new Error(b.error||"Failed to remove integration");t($,""),t(x,""),E.success("Sendy integration removed successfully",{position:"top-right"})}catch(e){console.error("Error removing Sendy integration:",e),t(d,e.message||"Failed to remove integration",!0),E.error(r(d),{position:"top-right"})}finally{t(R,!1)}}var U=ke(),C=f(U),X=f(C);he(X,{class:"w-4 h-4 mr-1"}),g(),u(C);var Z=s(C,2);_(Z,()=>fe,(e,b)=>{b(e,{class:"my-4",children:(ee,we)=>{var B=Ie(),N=K(B);_(N,()=>ve,(S,I)=>{I(S,{children:(k,J)=>{var n=$e(),i=K(n);_(i,()=>ge,(v,p)=>{p(v,{class:"text-lg font-semibold",children:(a,y)=>{g();var m=P("Sendy Integration");o(a,m)},$$slots:{default:!0}})});var c=s(i,2);_(c,()=>ye,(v,p)=>{p(v,{children:(a,y)=>{g();var m=P(`Connect your self-hosted Sendy installation to sync contacts and manage 2 email campaigns.`);o(a,m)},$$slots:{default:!0}})}),o(k,n)},$$slots:{default:!0}})});var O=s(N,2);_(O,()=>ue,(S,I)=>{I(S,{children:(k,J)=>{var n=be(),i=f(n),c=f(i),v=s(f(c),2);z(v,{id:"apiUrl",type:"text",placeholder:"Enter your Sendy installation URL (e.g., https://your-sendy-domain.com)",class:"w-full",get value(){return r(x)},set value(l){t(x,l,!0)}}),g(2),u(c);var p=s(c,2),a=s(f(p),2);z(a,{id:"apiKey",type:"text",placeholder:"Enter your Sendy API key",class:"w-full",get value(){return r($)},set value(l){t($,l,!0)}}),g(2),u(p),u(i);var y=s(i,2);{var m=l=>{var j=xe(),re=f(j,!0);u(j),ie(()=>le(re,r(d))),o(l,j)};D(y,l=>{r(d)&&l(m)})}u(n),o(k,n)},$$slots:{default:!0}})});var te=s(O,2);_(te,()=>_e,(S,I)=>{I(S,{class:"flex justify-between items-center border-t bg-gray-50 rounded-b-[11px] py-4",children:(k,J)=>{var n=Se(),i=s(K(n),2),c=f(i);{var v=a=>{Y(a,{variant:"destructive",onclick:W,get isLoading(){return r(R)},children:(y,m)=>{g();var l=P("Remove Connection");o(y,l)},$$slots:{default:!0}})};D(c,a=>{L?.config?.api_key&&a(v)})}var p=s(c,2);
2Y(p,{type:"button",onclick:V,get isLoading(){return r(A)},children:(a,y)=>{g();var m=P("Save Integration");o(a,m)},$$slots:{default:!0}}),u(i),o(k,n)},$$slots:{default:!0}})}),o(ee,B)},$$slots:{default:!0}})}),u(U),ce("click",C,()=>pe(`/brand/${H().params.teamSlug}/settings/integrations`)),o(G,U),oe(),Q()}de(["click"]);export{Ye as component}; 3//# sourceMappingURL=48.BF_vCQws.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.