1import"../chunks/NZTpNUN0.js";import{p as Me,l as R,v as ge,H as Qe,a,b as Ve,s as We,c as d,f as E,e as Xe,j as e,n as f,r as p,d as s,i as m,g as u,o as r,t as O,u as Ie,m as N}from"../chunks/CswluXHk.js";import{s as J}from"../chunks/D5MUd0dc.js";import{i as W}from"../chunks/Cvwav-Rz.js";import{e as Ze,i as et}from"../chunks/DLuIJL9M.js";import{c as l}from"../chunks/DCqg9Lcd.js";import{d as tt,a as at}from"../chunks/BnZqlU5Q.js";import{g as rt}from"../chunks/DvabIYvy.js";import{p as st}from"../chunks/BGX793Ew.js";import"../chunks/aH0YTA77.js";import{t as A}from"../chunks/CFi-xeDB.js";import{B as se}from"../chunks/DltdByd6.js";import{I as ot}from"../chunks/DuX34-Zw.js";import{C as nt}from"../chunks/BFGY4aR1.js";import{C as it}from"../chunks/C3F0Z4bJ.js";import{C as lt,a as ct,b as dt}from"../chunks/DQXZ4mXD.js";import{C as pt}from"../chunks/BcsrqGLJ.js";import{R as mt,S as ut,a as vt,b as _e}from"../chunks/CbCzraWd.js";import{A as ft}from"../chunks/r7UZdRXb.js";var Ce=E("<!> <!>",1),gt=E('<div class="border-t pt-4 mt-4"><h3 class="font-medium text-base mb-3">Step 2: Select a GetResponse Campaign</h3> <div class="space-y-2"><label for="listId" class="text-sm font-medium">Select Campaign</label> <!> <p class="text-sm text-gray-500">Select the GetResponse campaign you want to sync contacts with.</p> <div class="mt-2"><!> <!></div></div></div>'),_t=E('<p class="text-red-500 text-sm"> </p>'),ht=E(`<div class="bg-blue-50 p-3 rounded-md mb-4 text-sm"><p>This integration requires two steps: first enter and save your API 2 key, then select which GetResponse campaign to use.</p></div> <form class="space-y-4"><div><h3 class="font-medium text-base mb-3">Step 1: Connect Your GetResponse Account</h3> <div class="space-y-2"><label for="apiKey" class="text-sm font-medium">API Key</label> <!> <p class="text-sm text-gray-500">Your GetResponse API key can be found in your account settings 3 under API & OAuth.</p> <div class="mt-2"><!></div></div></div> <!> <!></form>`,1),yt=E('<div class="flex items-center gap-4"><p class="text-sm text-gray-500">Need help? <a href="https://apireference.getresponse.com/" 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),$t=E("<!> <!> <!>",1),bt=E('<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 qt(Ge,oe){Me(oe,!0);const Ae=()=>Xe(st,"$page",Ee),[Ee,Le]=We(),L=oe.data.getResponseIntegration||{config:{api_key:"",list_id:""}},X=oe.data.team;let g=R(ge(L?.config?.api_key||"")),$=R(ge(L?.config?.list_id||"")),I=R(ge([])),n=R(""),_=R(!1),ne=R(!1),C=R(!1),j=R(!!L?.config?.api_key);async function Z(){if(e(g))try{r(C,!0);const t=await fetch("/api/integrations/getresponse/lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:X.id})}),h=await t.json();if(!t.ok)throw new Error(h.error||"Failed to fetch GetResponse campaigns");r(I,h.lists||[],!0)}catch(t){console.error("Error fetching GetResponse campaigns:",t),r(n,t instanceof Error?t.message:"Failed to fetch campaigns from GetResponse",!0),A.error(e(n),{position:"top-right"})}finally{r(C,!1)}}async function je(){try{if(r(n,""),r(_,!0),!e(g)){r(n,"API Key is required");return}const t=L?.config?.api_key||"";if(!(!e(j)||e(g)!==t)){await Z();return}const te=await fetch("/api/install/getresponse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:X.id,config:{api_key:e(g)}})}),he=await te.json();if(!te.ok)throw new Error(he.error||"Failed to save API key");r(j,!0),await Z(),A.success("GetResponse API key saved successfully",{position:"top-right"})}catch(t){console.error("Error saving GetResponse API key:",t),r(n,t instanceof Error?t.message:"Failed to save API key",!0),A.error(e(n),{position:"top-right"})}finally{r(_,!1)}}async function Ke(){try{if(r(n,""),r(_,!0),!e($)){r(n,"Please select a campaign");return}const t=await fetch("/api/install/getresponse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:X.id,config:{api_key:e(g),list_id:e($)}})}),h=await t.json();if(!t.ok)throw new Error(h.error||"Failed to save campaign selection");A.success("GetResponse campaign selection saved successfully",{position:"top-right"})}catch(t){console.error("Error saving GetResponse campaign selection:",t),r(n,t instanceof Error?t.message:"Failed to save campaign selection",!0),A.error(e(n),{position:"top-right"})}finally{r(_,!1)}}async function Te(){try{r(ne,!0);const t=await fetch("/api/install/getresponse",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:X.id})}),h=await t.json();if(!t.ok)throw new Error(h.error||"Failed to remove integration");r(g,""),r($,""),r(I,[],!0),r(j,!1),A.success("GetResponse integration removed successfully",{position:"top-right"})}catch(t){console.error("Error removing GetResponse integration:",t),r(n,t instanceof Error?t.message:"Failed to remove integration",!0),A.error(e(n),{position:"top-right"})}finally{r(ne,!1)}}Qe(()=>{e(j)&&!e(I).length&&Z()});var ie=bt(),ee=d(ie),Fe=d(ee);ft(Fe,{class:"w-4 h-4 mr-1"}),f(),p(ee);var Oe=s(ee,2);l(Oe,()=>nt,(t,h)=>{h(t,{class:"my-4",children:(te,he)=>{var ye=$t(),$e=m(ye);l($e,()=>lt,(B,q)=>
3{q(B,{children:(U,xe)=>{var b=Ce(),x=m(b);l(x,()=>ct,(P,v)=>{v(P,{class:"text-lg font-semibold",children:(S,ae)=>{f();var k=u("GetResponse Integration");a(S,k)},$$slots:{default:!0}})});var G=s(x,2);l(G,()=>dt,(P,v)=>{v(P,{children:(S,ae)=>{f();var k=u(`Connect your GetResponse account to sync contacts and manage email 4 campaigns.`);a(S,k)},$$slots:{default:!0}})}),a(U,b)},$$slots:{default:!0}})});var be=s($e,2);l(be,()=>it,(B,q)=>{q(B,{children:(U,xe)=>{var b=ht(),x=s(m(b),2),G=d(x),P=s(d(G),2),v=s(d(P),2);ot(v,{id:"apiKey",type:"text",placeholder:"Enter your GetResponse API key",class:"w-full",get disabled(){return e(_)},get value(){return e(g)},set value(c){r(g,c,!0)}});var S=s(v,4),ae=d(S);{let c=Ie(()=>!e(g));se(ae,{type:"button",onclick:je,get isLoading(){return e(_)},get disabled(){return e(c)},children:(y,Y)=>{f();var D=u();O(()=>J(D,e(j)?"Update API Key":"Save API Key")),a(y,D)},$$slots:{default:!0}})}p(S),p(P),p(G);var k=s(G,2);{var Je=c=>{var y=gt(),Y=s(d(y),2),D=s(d(Y),2);l(D,()=>mt,(H,re)=>{re(H,{type:"single",get value(){return e($)},set value(K){r($,K,!0)},children:(K,le)=>{var ke=Ce(),we=m(ke);l(we,()=>ut,(ce,de)=>{de(ce,{id:"listId",class:"w-full",get disabled(){return e(C)},children:(pe,De)=>{var z=N(),me=m(z);{var ue=w=>{var o=u();O(i=>J(o,i),[()=>e(I).find(i=>i.id===e($))?.name||"Select a GetResponse campaign"]),a(w,o)},ve=w=>{var o=u();O(()=>J(o,e(C)?"Loading campaigns...":"Select a GetResponse campaign")),a(w,o)};W(me,w=>{e($)&&e(I).length>0?w(ue):w(ve,-1)})}a(pe,z)},$$slots:{default:!0}})});var Ye=s(we,2);l(Ye,()=>vt,(ce,de)=>{de(ce,{children:(pe,De)=>{var z=N(),me=m(z);{var ue=o=>{var i=N(),M=m(i);l(M,()=>_e,(Q,T)=>{T(Q,{value:"",disabled:!0,children:(F,fe)=>{f();var V=u("Loading campaigns...");a(F,V)},$$slots:{default:!0}})}),a(o,i)},ve=o=>{var i=N(),M=m(i);l(M,()=>_e,(Q,T)=>{T(Q,{value:"",disabled:!0,children:(F,fe)=>{f();var V=u("No campaigns found");a(F,V)},$$slots:{default:!0}})}),a(o,i)},w=o=>{var i=N(),M=m(i);Ze(M,17,()=>e(I),et,(Q,T)=>{var F=N(),fe=m(F);l(fe,()=>_e,(V,He)=>{He(V,{get value(){return e(T).id},children:(ze,xt)=>{f();var Re=u();O(()=>J(Re,e(T).name)),a(ze,Re)},$$slots:{default:!0}})}),a(Q,F)}),a(o,i)};W(me,o=>{e(C)?o(ue):e(I).length===0?o(ve,1):o(w,-1)})}a(pe,z)},$$slots:{default:!0}})}),a(K,ke)},$$slots:{default:!0}})});var Pe=s(D,4),Se=d(Pe);{let H=Ie(()=>!e($)||e(C));se(Se,{type:"button",onclick:Ke,get isLoading(){return e(_)},get disabled(){return e(H)},children:(re,K)=>{f();var le=u();O(()=>J(le,L?.config?.list_id?"Update Campaign Selection":"Save Campaign Selection")),a(re,le)},$$slots:{default:!0}})}var Ue=s(Se,2);se(Ue,{type:"button",variant:"outline",class:"ml-2",onclick:Z,get isLoading(){return e(C)},get disabled(){return e(_)},children:(H,re)=>{f();var K=u("Refresh Campaigns");a(H,K)},$$slots:{default:!0}}),p(Pe),p(Y),p(y),a(c,y)};W(k,c=>{e(j)&&c(Je)})}var Be=s(k,2);{var qe=c=>{var y=_t(),Y=d(y,!0);p(y),O(()=>J(Y,e(n))),a(c,y)};W(Be,c=>{e(n)&&c(qe)})}p(x),a(U,b)},$$slots:{default:!0}})});var Ne=s(be,2);l(Ne,()=>pt,(B,q)=>{q(B,{class:"flex justify-between items-center border-t bg-gray-50 rounded-b-[11px] py-4",children:(U,xe)=>{var b=yt(),x=s(m(b),2),G=d(x);{var P=v=>{se(v,{variant:"destructive",onclick:Te,get isLoading(){return e(ne)},get disabled(){return e(_)},children:(S,ae)=>{f();var k=u("Remove Connection");a(S,k)},$$slots:{default:!0}})};W(G,v=>{L?.config?.api_key&&v(P)})}p(x),a(U,b)},$$slots:{default:!0}})}),a(te,ye)},$$slots:{default:!0}})}),p(ie),at("click",ee,()=>rt(`/brand/${Ae().params.teamSlug}/settings/integrations`)),a(Ge,ie),Ve(),Le()}tt(["click"]);export{qt as component}; 5//# sourceMappingURL=35.rScyq7lP.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.