1import"../chunks/NZTpNUN0.js";import{p as X,l as w,v as Z,a as r,b as tt,s as et,c as f,f as h,e as rt,n as g,r as v,d as c,i as E,g as C,o,j as n,t as ot}from"../chunks/CswluXHk.js";import{s as at}from"../chunks/D5MUd0dc.js";import{i as N}from"../chunks/Cvwav-Rz.js";import{c as y}from"../chunks/DCqg9Lcd.js";import{d as st,a as nt}from"../chunks/BnZqlU5Q.js";import{g as it}from"../chunks/DvabIYvy.js";import{p as lt}from"../chunks/BGX793Ew.js";import"../chunks/aH0YTA77.js";import{t as P}from"../chunks/CFi-xeDB.js";import{B as O}from"../chunks/DltdByd6.js";import{I as pt}from"../chunks/DuX34-Zw.js";import{C as ct}from"../chunks/BFGY4aR1.js";import{C as dt}from"../chunks/C3F0Z4bJ.js";import{C as ut,a as mt,b as ft}from"../chunks/DQXZ4mXD.js";import{C as gt}from"../chunks/BcsrqGLJ.js";import{A as vt}from"../chunks/r7UZdRXb.js";var yt=h("<!> <!>",1),ht=h('<p class="text-red-500 text-sm"> </p>'),_t=h(`<form class="space-y-4"><div class="space-y-2"><label for="apiKey" class="text-sm font-medium">API Key</label> <!> <p class="text-sm text-gray-500">Your HubSpot API key can be found in your account settings under 2 Integrations > API Keys.</p></div> <!></form>`),$t=h('<div class="flex items-center gap-4"><p class="text-sm text-gray-500">Need help? <a href="https://knowledge.hubspot.com/integrations/how-do-i-get-my-hubspot-api-key" 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),bt=h("<!> <!> <!>",1),xt=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 Jt(J,j){X(j,!0);const q=()=>rt(lt,"$page",D),[D,M]=et(),{hubspotIntegration:K,team:F}=j.data;let _=w(Z(K?.config?.api_key||"")),i=w(""),S=w(!1),H=w(!1);async function Y(){try{if(o(i,""),o(S,!0),!n(_)){o(i,"API Key is required");return}const e=await fetch("/api/install/hubspot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:F.id,config:{api_key:n(_)}})}),$=await e.json();if(!e.ok)throw new Error($.error||"Failed to save integration");P.success("HubSpot integration saved successfully",{position:"top-right"})}catch(e){console.error("Error saving HubSpot integration:",e),o(i,e.message||"Failed to save integration",!0),P.error(n(i),{position:"top-right"})}finally{o(S,!1)}}async function z(){try{o(H,!0);const e=await fetch("/api/install/hubspot",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:F.id})}),$=await e.json();if(!e.ok)throw new Error($.error||"Failed to remove integration");o(_,""),P.success("HubSpot integration removed successfully",{position:"top-right"})}catch(e){console.error("Error removing HubSpot integration:",e),o(i,e.message||"Failed to remove integration",!0),P.error(n(i),{position:"top-right"})}finally{o(H,!1)}}var A=xt(),I=f(A),G=f(I);vt(G,{class:"w-4 h-4 mr-1"}),g(),v(I);var Q=c(I,2);y(Q,()=>ct,(e,$)=>{$(e,{class:"my-4",children:(U,kt)=>{var L=bt(),R=E(L);y(R,()=>ut,(b,x)=>{x(b,{children:(k,B)=>{var a=yt(),s=E(a);y(s,()=>mt,(d,u)=>{u(d,{class:"text-lg font-semibold",children:(t,l)=>{g();var p=C("HubSpot Integration");r(t,p)},$$slots:{default:!0}})});var m=c(s,2);y(m,()=>ft,(d,u)=>{u(d,{children:(t,l)=>{g();var p=C("Connect your HubSpot account to sync contacts and manage CRM data.");r(t,p)},$$slots:{default:!0}})}),r(k,a)},$$slots:{default:!0}})});var T=c(R,2);y(T,()=>dt,(b,x)=>{x(b,{children:(k,B)=>{var a=_t(),s=f(a),m=c(f(s),2);pt(m,{id:"apiKey",type:"text",placeholder:"Enter your HubSpot API key",class:"w-full",get value(){return n(_)},set value(t){o(_,t,!0)}}),g(2),v(s);var d=c(s,2);{var u=t=>{var l=ht(),p=f(l,!0);v(l),ot(()=>at(p,n(i))),r(t,l)};N(d,t=>{n(i)&&t(u)})}v(a),r(k,a)},$$slots:{default:!0}})});var V=c(T,2);y(V,()=>gt,(b,x)=>{x(b,{class:"flex justify-between items-center border-t bg-gray-50 rounded-b-[11px] py-4",children:(k,B)=>{var a=$t(),s=c(E(a),2),m=f(s);{var d=t=>{O(t,{variant:"destructive",onclick:z,get isLoading(){return n(H)},children:(l,p)=>{g();var W=C("Remove Connection");r(l,W)},$$slots:{default:!0}})};N(m,t=>{K?.config?.api_key&&t(d)})}var u=c(m,2);O(u,{type:"button",onclick:Y,get isLoading(){return n(S)},children:(t,l)=>{g();var p=C("Save Integration");r(t,p)},$$slots:{default:!0}}),v(s),r(k,a)},$$slots:{default:!0}})}),r(U,L)},$$slots:{default:!0}})}),v(A),nt("click",I,()=>it(`/brand/${q().params.teamSlug}/settings/integrations`)),r(J,A),tt(),M()}st(["click"]);export{Jt as component};
3//# sourceMappingURL=37.BeLZ6ihT.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.