var _=Object.defineProperty;var S=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var I=(t,s,a)=>s in t?_(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,x=(t,s)=>{for(var a in s||(s={}))q.call(s,a)&&I(t,a,s[a]);if(S)for(var a of S(s))w.call(s,a)&&I(t,a,s[a]);return t};import{r as c,j as e,_ as l,L as P,c as z,v as F,a as H,S as T,B as L,x as B,d as E}from"./main-40.js";/* empty css          */import{B as K}from"./bf-586-70.js";import{S as M}from"./bf-679-136.js";import{b as C}from"./bf-132-75.js";import{I as D}from"./bf-94-335.js";import{N as R}from"./bf-492-405.js";import{A as G}from"./bf-541-403.js";import{N as J}from"./bf-504-404.js";import{H as V,h as W,c as Z}from"./bf-185-370.js";import"./bf-141-80.js";import"./bf-860-126.js";import"./bf-892-199.js";import"./bf-528-128.js";import"./bf-200-122.js";import"./bf-689-131.js";function O({hubspotConf:t,setHubspotConf:s,step:a,setstep:j,isInfo:p}){const[d,g]=c.useState(!1),[n,u]=c.useState({name:"",api_key:""}),[v,h]=c.useState(!1),[y,k]=c.useState(!1),N=()=>{const r=x({},t);if(!r.name||!r.api_key){u({name:r.name?"":l("Integration name cann't be empty"),api_key:r.api_key?"":l("API Key cann't be empty")});return}k("auth");const m={api_key:r.api_key};z(m,"bitforms_hubspot_authorize").then(o=>{const{data:A}=o;A&&g(!0),h(!0),k(!1)})},f=r=>{const m=x({},t),o=x({},n);o[r.target.name]="",m[r.target.name]=r.target.value,u(o),s(m)},i=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),j(2)},b=`
    <h4> Step of generating  Access Token:</h4>
    <ul>
      <li>Login to your HubSpot account, click the <b>Settings</b> icon settings in the main navigation bar..</li>
      <li>In the left sidebar menu, navigate to <b>Integrations > Private App</b>.</li>
      <li>Give name and description and select all necessary scope.</li>
      <li>Then create Access token.</li>
  </ul>
  `;return e.jsxs("div",{className:"btcd-stp-page",style:{width:a===1&&900,height:a===1&&"auto"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:l("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:f,name:"name",value:t==null?void 0:t.name,type:"text",placeholder:l("Integration Name..."),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:n.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:l("API Key:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:f,name:"api_key",value:t==null?void 0:t.api_key,type:"text",placeholder:l("API Key..."),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:n.api_key}),e.jsxs("small",{className:"d-blk mt-5",children:[l("To get API , Please Visit")," ",e.jsx("a",{className:"btcd-link",href:"https://app.hubspot.com/api-key",target:"_blank",rel:"noreferrer",children:l("Hubspot API Console")})]}),y==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(P,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),v&&!d&&!y&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),"Sorry, API key is invalid"]}),!p&&e.jsxs(e.Fragment,{children:[e.jsx(G,{handleAuthorize:N,isAuthorized:d,isLoading:y}),e.jsx("br",{}),e.jsx(J,{nextPageHandler:()=>i(),disabled:!d})]}),e.jsx(R,{note:b})]})}function pe({formFields:t,setIntegration:s,integrations:a,allIntegURL:j}){const p=F(),[d,g]=c.useState(!1),[n,u]=c.useState(1),[v,h]=c.useState({show:!1}),{css:y}=H(),k=[{key:"email",label:"Email",required:!0},{key:"firstname",label:"First Name",required:!1},{key:"lastname",label:"Last Name",required:!1},{key:"website",label:"Website",required:!1},{key:"company",label:"Company",required:!1},{key:"phone",label:"Phone",required:!1},{key:"address",label:"Address",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"zip",label:"Zip",required:!1},{key:"jobtitle",label:"Job Title",required:!1}],N=[{key:"dealname",label:"Deal Name",required:!0},{key:"amount",label:"Amount",required:!1},{key:"closedate",label:"Close Date",required:!1}],f=[{key:"subject",label:"Ticket Name",required:!0},{key:"content",label:"Ticket description",required:!1}],[i,b]=c.useState({name:"Hubspot",type:"Hubspot",api_key:"",field_map:[{formField:"",hubspotField:""}],actions:{},contactFields:k,dealFields:N,ticketFields:f}),r=()=>{C(a,s,j,i,p)},m=o=>{if(!Z(i)){E.error("Please map mandatory fields");return}i.field_map.length>0&&u(o)};return e.jsxs("div",{children:[e.jsx(T,{snack:v,setSnackbar:h}),e.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:e.jsx(M,{step:3,active:n})}),e.jsx(O,{hubspotConf:i,setHubspotConf:b,step:n,setstep:u,isLoading:d,setIsLoading:g,setSnackbar:h}),e.jsxs("div",{className:"btcd-stp-page",style:x({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[e.jsx(V,{formFields:t,handleInput:o=>W(o,i,b),hubspotConf:i,setHubspotConf:b,isLoading:d,setIsLoading:g,setSnackbar:h}),e.jsxs(L,{variant:"success",onClick:()=>m(3),disabled:!(i!=null&&i.actionName),className:y(B.ftRight),children:[l("Next"),e.jsx(K,{className:"ml-1 rev-icn"})]})]}),e.jsx(D,{step:n,saveConfig:()=>r()})]})}export{pe as default};
