1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4489],{33146:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/integrations/hubspot",function(){return n(93993)}])},80144:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var s=n(37876),a=n(7818),i=n(4655),o=n.n(i);let l=e=>{let{t,ready:n}=(0,a.B)(["admin.integrations","common"]);return n&&(0,s.jsxs)("div",{className:"".concat(o().integrationDetailsBox," ").concat(o().setupBox),children:[(0,s.jsxs)("h3",{className:o().helpTitle,children:[t("integrations.help.helpTitle")," ",e.integrationName,"?"]}),(0,s.jsx)("p",{className:o().helpText,children:"children"in e?e.children:(0,s.jsxs)(s.Fragment,{children:[t("integrations.help.helpText"),(0,s.jsx)("span",{children:(0,s.jsx)("a",{href:e.helpArticle,target:"_blank",rel:"noreferrer",children:t("integrations.help.viewArticle")})})]})})]})}},93993:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>eC});var s=n(37876),a=n(15039),i=n.n(a),o=n(89099),l=n(14232),c=n(39829),r=n(56293),d=n(80144),p=n(55098),u=n(40727),m=n(7818),h=n(69233),g=n(66064),x=n(29581),b=n(15340),f=n(1640),y=n(38532),v=n.n(y),j=n(4655),_=n.n(j);let S="".concat(r.J6j,"/custom-objects");function N(e){var t,n,a,i;let{t:o}=(0,m.B)(["admin.integrations","common"]),r=(0,g.jL)(),d=null==(t=e.config)?void 0:t.custom_object_config,[y,j]=(0,l.useState)([]),[N,w]=(0,l.useState)([]),[I,C]=(0,l.useState)(null!=(n=null==d?void 0:d.object_type_id)?n:null),[A,k]=(0,l.useState)(null!=(a=null==d?void 0:d.stop_property)?a:""),[H,P]=(0,l.useState)(null!=(i=null==d?void 0:d.stop_value)?i:""),[F,E]=(0,l.useState)(!1),[M,T]=(0,l.useState)(!1),[O,R]=(0,l.useState)(!1),[L,U]=(0,l.useState)(!1);(0,l.useEffect)(()=>{B()},[]),(0,l.useEffect)(()=>{I?G(I):w([])},[I]);let B=async()=>{try{var e,t;let n=await c.get({path:"".concat(S,"/objects")});j(null!=(t=null==(e=n.data)?void 0:e.objects)?t:[])}catch(e){r((0,f.P0)({title:"Error Encountered",message:"Unable to load HubSpot custom objects.",type:"negative"})),(0,x.OP)("Error fetching custom objects: ",e)}},G=async e=>{try{var t,n;let s=await c.get({path:"".concat(S,"/").concat(e,"/properties")});w(null!=(n=null==(t=s.data)?void 0:t.properties)?n:[])}catch(e){r((0,f.P0)({title:"Error Encountered",message:"Unable to load custom object properties.",type:"negative"})),(0,x.OP)("Error fetching custom object properties: ",e)}},D=async()=>{if(!I)return;let t=y.find(e=>e.id===I);if(t){E(!0);try{let n=await c.post({path:"".concat(S,"/config/object"),data:{object_type:t.name,object_type_id:t.id},spinner:!0});e.setConfig({...e.config,custom_object_config:n.data}),r((0,f.P0)({title:"Saved",message:"Custom object selection saved.",type:"positive"}))}catch(e){r((0,f.P0)({title:"Error Encountered",message:"Failed to save custom object selection.",type:"negative"})),(0,x.OP)("Error saving custom object selection: ",e)}finally{E(!1)}}},J=async()=>{if(!A||!H)return void r((0,f.P0)({title:"Missing Fields",message:"Stop property and value are required.",type:"negative"}));T(!0);try{let t=await c.post({path:"".concat(S,"/config/stop-condition"),data:{stop_property:A,stop_value:H},spinner:!0});e.setConfig({...e.config,custom_object_config:t.data}),r((0,f.P0)({title:"Saved",message:"Stop condition saved.",type:"positive"}))}catch(e){r((0,f.P0)({title:"Error Encountered",message:"Failed to save stop condition.",type:"negative"})),(0,x.OP)("Error saving stop condition: ",e)}finally{T(!1)}},z=async()=>{R(!0);try{await c.deleteRequest({path:"".concat(S,"/config"),spinner:!0}),e.setConfig({...e.config,custom_object_config:void 0}),C(null),k(""),P(""),w([]),r((0,f.P0)({title:"Removed",message:"Custom object SMS logging removed.",type:"positive"}))}catch(e){r((0,f.P0)({title:"Error Encountered",message:"Failed to remove custom object configuration.",type:"negative"})),(0,x.OP)("Error removing custom object config: ",e)}finally{R(!1)}},V=async()=>{U(!0);try{let t=await c.deleteRequest({path:"".concat(S,"/config/stop-condition"),spinner:!0});e.setConfig({...e.config,custom_object_config:t.data}),k(""),P(""),r((0,f.P0)({title:"Cleared",message:"Stop condition cleared.",type:"positive"}))}catch(e){r((0,f.P0)({title:"Error Encountered",message:"Failed to clear stop condition.",type:"negative"})),(0,x.OP)("Error clearing stop condition: ",e)}finally{U(!1)}},q=y.map(e=>({label:e.name,value:e.id})),Y=N.filter(e=>"string"===e.type).map(e=>({label:e.label,value:e.name})),K=!!(null==d?void 0:d.object_type_id),W=K&&(null==d?void 0:d.object_type_id)===I,X=!!((null==d?void 0:d.stop_property)&&(null==d?void 0:d.stop_value));return(0,s.jsxs)("div",{className:"".concat(v().settingsContainer),children:[(0,s.jsxs)("div",{className:"".concat(_().mappingHeader),children:[(0,s.jsxs)("span",{className:"".concat(_().title),children:["Custom Object SMS Logging",(0,s.jsx)("span",{className:"beta-label",children:" Beta"})]}),(0,s.jsx)("div",{className:"help-text",children:"Log SMS communications on a HubSpot custom object linked to the contact. Logging stops when a property on the custom object record matches the configured value."})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Custom Object"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:X?"Clear the stop condition first to change the custom object.":"The HubSpot custom object on which SMS communications are logged."})]}),(0,s.jsxs)("div",{className:"".concat(v().contentRight),style:{display:"flex",gap:8,alignItems:"center"},children:[(0,s.jsx)(p.A,{size:"large",style:{width:290},suffixIcon:(0,s.jsx)(h.F,{}),placeholder:"Select a custom object",value:null!=I?I:void 0,onChange:e=>{if(C(e),e!==(null==d?void 0:d.object_type_id))k(""),P("");else{var t,n;k(null!=(t=null==d?void 0:d.stop_property)?t:""),P(null!=(n=null==d?void 0:d.stop_value)?n:"")}},options:q,disabled:X}),(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:D,disabled:!I||X||F,children:o("button.save",{ns:"common"})}),K&&(0,s.jsx)("button",{className:"white-button ".concat(_().removeMappingButton),onClick:()=>{var e;let t=null!=(e=null==d?void 0:d.object_type)?e:"this custom object";(0,b.to)({type:"confirm",props:{title:"Remove Custom Object SMS Logging?",okText:"Remove",cancelText:"Cancel",content:"This will stop logging SMS to ".concat(t," records, clear your stop condition, and discard any SMS logs currently waiting to be sent. You can reconfigure logging later by selecting a custom object again."),onOk:()=>{z()}}})},disabled:O,children:o("button.remove",{ns:"common"})})]})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Stop Condition"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:W?"When the selected property on the custom object record matches this value, SMS logging stops.":"Save a custom object first to configure the stop condition."})]}),(0,s.jsxs)("div",{className:"".concat(v().contentRight),style:{display:"flex",gap:8,alignItems:"center"},children:[(0,s.jsx)(p.A,{size:"large",style:{width:200},suffixIcon:(0,s.jsx)(h.F,{}),placeholder:"Select a property",value:A||void 0,onChange:k,options:Y,disabled:!W}),(0,s.jsx)(u.A,{size:"large",style:{width:200},placeholder:"e.g. hired",value:H,onChange:e=>P(e.target.value),disabled:!W}),(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:J,disabled:!W||!A||!H||M,children:o("button.save",{ns:"common"})}),X&&(0,s.jsx)("button",{className:"white-button ".concat(_().removeMappingButton),onClick:V,disabled:L,children:o("button.remove",{ns:"common"})})]})]})]})}var w=n(25064),I=n(1171),C=n(74038),A=n(74741),k=n(30637),H=n(39760),P=n(44986
1),F=n(23246);function E(e){let{t,ready:n}=(0,m.B)(["admin.integrations","common"]),a=(0,g.jL)(),i=(0,l.useRef)(null),[o,d]=(0,l.useState)(null),[x,f]=(0,l.useState)(null),[y,v]=(0,l.useState)(""),[j,S]=(0,l.useState)(!1),N=(0,g.GV)(C.h),E=(0,g.GV)(A.kW);(0,l.useEffect)(()=>{(0,H.Iy)(e.config)&&S(!1)},[e.config]);let M=async()=>{if(!o||!x)return void(0,b.to)({type:"error",props:{title:"Invalid Data",content:"Please make sure you have selected valid data for each field."}});try{let t=(await c.post({path:"".concat(r.J6j,"/fields"),data:{hubspot_field_id:o,field_id:x},spinner:!0})).data,n=e.config.fields?[...e.config.fields,t]:[t];e.setConfig({...e.config,fields:n}),S(!0),d(null),f(null)}catch(e){(0,b.to)({type:"error",props:{title:"Error Encountered",content:"There was an error in creating the field mapping. Please try again."}})}},T=()=>{let e={first:y,team_id:E,order:N.length+1,field_type:"text"};a((0,F.AA)(e)).unwrap().then(e=>{f(e.id),i.current.blur()}).catch(()=>{(0,b.to)({type:"error",props:{title:"Oops...",content:"There was an error while creating the field. Please contact us for further assistance."}})})},O=[{title:"HubSpot Contact Property",dataIndex:"hubspot_field_id",width:"35%",render:t=>(0,s.jsxs)("div",{className:"".concat(_().mappingArrowInput," ").concat(_().blackText),children:[(0,s.jsx)(u.A,{value:(t=>{let n=(0,P.Jb)(e.config.hubspot_fields,"hubspot_field_id",t);return n?n.hubspot_field_name:"Unknown HubSpot Field"})(t),disabled:!0,className:_().mappingInput}),(0,s.jsx)(w.A,{className:_().mappingArrow})]})},{title:"Heymarket Contact Field",dataIndex:"field_id",width:"35%",render:e=>(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:(e=>{let t=(0,P.Jb)(N,"id",e);return t?t.title:"Unknown Heymarket Field"})(e),disabled:!0,className:_().mappingInput})})},{title:"Action",dataIndex:"id",width:"20%",render:(n,a)=>(0,s.jsx)("button",{className:"white-button ".concat(_().removeMappingButton),onClick:()=>{e.removeMapping("fields",a.id)},children:t("button.remove",{ns:"common"})})}];return n&&(0,s.jsx)(I.A,{title:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{children:"Contact Field Mapping"}),(0,s.jsx)("div",{className:"help-text",children:"Map contact properties from HubSpot to Heymarket. First Name, Last Name, Email and Phone number are auto synced."})]}),className:"compact-table hide-empty-row",loading:!1,rowKey:"id",columns:O,dataSource:e.config?e.config.fields:[],showSorterTooltip:!1,pagination:!1,summary:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(I.A.Summary.Row,{className:"summary-row",children:[(0,s.jsxs)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:[(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:o,placeholder:"Select HubSpot Contact Propery",options:(()=>{if(!e.config)return[];let t=e.config&&e.config.fields?e.config.fields.map(e=>e.hubspot_field_id):null;return(0,P.yG)(e.config.hubspot_fields,"hubspot_field_name","hubspot_field_id",t)})(),disabled:e.syncInProgress,onSelect:e=>d(e)}),(0,s.jsx)(w.A,{className:_().mappingArrow})]}),(0,s.jsx)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:(0,s.jsx)(p.A,{ref:i,showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:x,placeholder:"Select Heymarket Contact Field",options:(()=>{if(!N.length)return[];let t=e.config&&e.config.fields?e.config.fields.map(e=>e.field_id):null;return(0,P.yG)(N,"title","id",t)})(),disabled:e.syncInProgress,notFoundContent:(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("button",{className:"text-only",onClick:T,children:"Create Field: ".concat(y)})}),onSearch:v,onSelect:e=>f(e)})}),(0,s.jsx)(I.A.Summary.Cell,{index:3,children:(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:M,disabled:e.syncInProgress,children:t("button.add",{ns:"common"})})})]}),e.syncInProgress&&(0,s.jsx)(I.A.Summary.Row,{className:"summary-row",children:(0,s.jsx)(I.A.Summary.Cell,{index:1,children:(0,s.jsxs)("div",{className:" ".concat(_().syncMessageRow),children:[(0,s.jsx)("img",{className:"rotate",src:"/icons/rotate-green.svg",width:24,height:24,alt:"Sync Icon"}),(0,s.jsx)("span",{className:_().syncMessage,children:"Sync: In Progress"})]})})}),!e.syncInProgress&&j&&(0,s.jsx)(I.A.Summary.Row,{className:"summary-row",children:(0,s.jsx)(I.A.Summary.Cell,{colSpan:3,index:1,children:(0,s.jsx)("div",{className:" ".concat(_().syncMessageRow),children:(0,s.jsxs)("span",{className:_().syncMessage,children:["A full sync is required for the new mappings to be applied on existing contacts.",(0,s.jsx)("button",{className:"text-only",onClick:e.syncData,children:"Synchronize"})]})})})})]})})}var M=n(1001),T=n(47696);let O=(e,t)=>String(e)===String(t);function R(e){var t,n,a,o,d,g,x;let{t:f,ready:y}=(0,m.B)(["admin.integrations","common"]),[v,j]=(0,l.useState)(null),[S,N]=(0,l.useState)(""),[C,A]=(0,l.useState)(null),{groups:H,groupsById:F,settled:E}=(0,T.S)(),R=(0,l.useMemo)(()=>{var t,n,s,a;let i=new Set((null!=(s=null==(t=e.config)?void 0:t.fields)?s:[]).map(e=>String(e.hubspot_field_id))),o=(null!=(a=null==(n=e.config)?void 0:n.hubspot_fields)?a:[]).filter(e=>i.has(String(e.hubspot_field_id)));return(0,P.yG)(o,"hubspot_field_name","hubspot_field_id")},[null==(t=e.config)?void 0:t.fields,null==(n=e.config)?void 0:n.hubspot_fields]),L=null==(d=e.config)||null==(o=d.group_mappings)||null==(a=o[0])?void 0:a.hs_property;(0,l.useEffect)(()=>{!v&&L&&R.some(e=>String(e.value)===String(L))&&j(L)},[L,v,R]);let U=async()=>{var t,n;if(!v||!S.trim()||!C)return void(0,b.Hm)("Invalid Data","Please make sure you have selected a HubSpot property, entered a value, and selected a user group.");let s=S.trim();if((null!=(n=null==(t=e.config)?void 0:t.group_mappings)?n:[]).some(e=>O(e.hs_property,v)&&e.hs_value.trim().toLowerCase()===s.toLowerCase()&&e.hm_group_id===C))return void(0,b.Hm)("Already Mapped","This property value is already mapped to that user group.");try{let t=(await c.post({path:"".concat(r.J6j,"/groups"),data:{hs_property:v,hs_value:s,hm_group_id:C},spinner:!0})).data;e.setConfig(e=>({...e,group_mappings:e.group_mappings?[...e.group_mappings,t]:[t]})),N(""),A(null)}catch(e){(0,b.Hm)("Error Encountered","There was an error in creating the group mapping. Please try again.")}},B=[{title:"HubSpot Property Value",dataIndex:"hs_value",width:"35%",render:(e,t)=>{let n=O(t.hs_property,v)?e:"".concat(e," (").concat(t.hs_property,")");return(0,s.jsxs)("div",{className:_().blackText,children:[(0,s.jsx)(u.A,{value:n,disabled:!0,className:_().mappingInput}),(0,s.jsx)(w.A,{className:_().mappingArrow})]})}},{title:"Heymarket User Group",dataIndex:"hm_group_id",width:"35%",render:e=>{var t,n;return(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:null!=(n=null==(t=F[e])?void 0:t.name)?n:"Unknown group (".concat(e,")"),disabled:!0,className:_().mappingInput})})}},{title:"Action",dataIndex:"id",width:"20%",render:(t,n)=>(0,s.jsx)(M.Ay,{className:i()("white-button",_().removeMappingButton),onClick:()=>e.removeMapping("groups",n.id),disabled:e.syncInProgress,children:f("button.remove",{ns:"common"})})}];return y&&(0,s.jsx)(I.A,{title:()=>{var t;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("h2",{children:["User Group Mapping",(0,s.jsx)("span",{className:"beta-label",children:" Beta"})]}),(0,s.jsx)("div",{className:"help-text",children:"Assign synced contacts to Heymarket user groups based on a HubSpot contact property."}),(null==(t=e.config)?void 0:t.group_mappings_available)===!1&&(0,s.jsx)("div",{className:"help-text",children:"Group rules could not be loaded from the integration. Refresh to try again."}),(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:v,placeholder:"Select HubSpot
1Contact Property",options:R,disabled:e.syncInProgress,onSelect:e=>j(e)})]})},className:"compact-table hide-empty-row",loading:!1,rowKey:"id",columns:B,dataSource:null!=(x=null==(g=e.config)?void 0:g.group_mappings)?x:[],showSorterTooltip:!1,pagination:!1,summary:()=>(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(I.A.Summary.Row,{className:"summary-row",children:[(0,s.jsxs)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:[(0,s.jsx)(u.A,{className:_().mappingInputField,size:"large",value:S,placeholder:"Enter HubSpot Property Value",disabled:e.syncInProgress,onChange:e=>N(e.target.value)}),(0,s.jsx)(w.A,{className:_().mappingArrow})]}),(0,s.jsx)(I.A.Summary.Cell,{index:2,children:(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:C,placeholder:"Select Heymarket User Group",options:(0,P.yG)(H,"name","id"),disabled:e.syncInProgress||!E,onSelect:e=>A(e)})}),(0,s.jsx)(I.A.Summary.Cell,{index:3,children:(0,s.jsx)(M.Ay,{className:i()("white-button",_().addMappingButton),onClick:U,disabled:e.syncInProgress,children:f("button.add",{ns:"common"})})})]})})})}var L=n(38993),U=n.n(L),B=n(86690),G=n(1297),D=n(14019),J=n(56932),z=n(13560),V=n(9721),q=n(86203);let Y=e=>e&&"enabled"==e.settings.has_inbox_access;function K(e){let{t,ready:n}=(0,m.B)(["admin.integrations","common"]),a=(0,g.jL)(),[i,o]=(0,l.useState)(null),[d,x]=(0,l.useState)(null),[f,y]=(0,l.useState)(null),[v,j]=(0,l.useState)(null),[S,N]=(0,l.useState)({}),[C,A]=(0,l.useState)({});(0,l.useEffect)(()=>{if(!e.config||!e.config.users)return;let t=e.config.users.map(e=>e.inbox_id);a((0,z.g7)(t,S)).then(e=>{N(e)});let n=e.config.users.map(e=>e.user_id);a((0,q.Xs)(n,C)).then(e=>{A(e)})},[e.config.users]);let H=t=>{if(!e.config||!e.config.users)return[];let n=e.config.inbox_mappings?e.config.inbox_mappings.map(e=>e.inbox_id):null;if(!t){let t=[];for(let n of e.config.users){let e=(0,B.i5)(Object.values(S),n.user_id);t=U()(t,e)}return(0,P.yG)(t,"name","id",n)}let s=(0,B.i5)(Object.values(S),t);return(0,P.yG)(s,"name","id",n)},F=async()=>{if(!(0,J.xf)(v))return void(0,b.to)({type:"error",props:{title:"Invalid HubSpot Inbox Email",content:"Please make sure you have entered a valid email."}});if(!i||!f||!d)return void(0,b.to)({type:"error",props:{title:"Invalid Data",content:"Please make sure you have selected valid data for each field."}});let t={external_id:parseInt(i),default_inbox_user:f,inbox_id:d,hs_inbox_email:v};try{let n=(await c.post({path:"".concat(r.J6j,"/inbox/mapping"),data:t,spinner:!0})).data;n.hubspot_inbox_id=n.external_id.toString();let s=e.config.inbox_mappings?[...e.config.inbox_mappings,n]:[n];e.setConfig({...e.config,inbox_mappings:s}),x(null),o(null),y(null),j(null),a((0,D.u4)("Hubspot: Inbox Mapping Created"))}catch(e){(0,b.to)({type:"error",props:{title:"Error Encountered",content:"There was an error in creating the inbox mapping. Please try again."}})}},E=()=>{a((0,V.qv)(!0))},M=[{title:"HubSpot Inbox",dataIndex:"hubspot_inbox_id",width:"22%",render:t=>(0,s.jsxs)("div",{className:"".concat(_().mappingArrowInput," ").concat(_().blackText),children:[(0,s.jsx)(u.A,{value:(t=>{let n=(0,P.Jb)(e.config.hubspot_inboxes,"hubspot_inbox_id",t);return n?n.hubspot_inbox_name:"Unknown HubSpot Inbox"})(t),disabled:!0,className:_().mappingInput}),(0,s.jsx)(w.A,{className:_().mappingArrow})]})},{title:"Heymarket Inbox",dataIndex:"inbox_id",width:"22%",render:e=>(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:(0,G.fK)(S,e),disabled:!0,className:_().mappingInput})})},{title:"Heymarket User",dataIndex:"default_inbox_user",width:"22%",render:e=>(0,s.jsxs)("div",{className:"".concat(_().mappingArrowInput," ").concat(_().blackText),children:[(0,s.jsx)(u.A,{value:(e=>{let t=C[e];return t?t.name:"Unknown Heymarket User"})(e),disabled:!0,className:_().mappingInput}),(0,s.jsx)(w.A,{className:_().mappingArrow})]})},{title:"HubSpot Inbox Fallback Email",dataIndex:"hs_inbox_email",width:"22%",render:e=>(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:e,disabled:!0,className:_().mappingInput})})},{title:"Action",dataIndex:"id",width:"10%",render:(n,a)=>(0,s.jsx)("button",{className:"white-button ".concat(_().removeMappingButton),onClick:()=>{e.removeMapping("inbox/mapping",a.id)},children:t("button.remove",{ns:"common"})})}];return n&&(0,s.jsx)(I.A,{title:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{children:"Inbox Mapping"}),(0,s.jsx)("div",{className:"help-text",children:"Map HubSpot Inboxes to Heymarket Inboxes."})]}),className:"compact-table hide-empty-row",loading:!1,rowKey:"id",columns:M,dataSource:e.config?e.config.inbox_mappings:[],showSorterTooltip:!1,pagination:!1,summary:()=>(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(I.A.Summary.Row,{className:"summary-row",children:[(0,s.jsxs)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:[(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:i,placeholder:"Select HubSpot Inbox",options:e.config&&Y(e.config)&&e.config.hub
1spot_inboxes?(0,P.yG)(e.config.hubspot_inboxes,"hubspot_inbox_name","hubspot_inbox_id"):[],notFoundContent:(0,s.jsxs)(s.Fragment,{children:[Y(e.config)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"heading-14-600",children:"No Available Inboxes"}),(0,s.jsx)("p",{children:e.config&&e.config.hubspot_inboxes&&e.config.inbox_mappings&&e.config.inbox_mappings.length==e.config.hubspot_inboxes.length?"All existing HubSpot Inboxes have already been mapped.":"No available HubSpot Inboxes were found."})]}),!Y(e.config)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"heading-14-600",children:"Enable Access to HubSpot Inboxes"}),(0,s.jsx)("p",{children:"You will need to update your authentication to setup Inbox Mappings. Select Authenticate to continue to HubSpot for login."}),(0,s.jsx)("button",{className:"orange-button",onClick:E,children:"Authenticate"})]})]}),onSelect:e=>o(e)}),(0,s.jsx)(w.A,{className:_().mappingArrow})]}),(0,s.jsx)(I.A.Summary.Cell,{index:2,className:_().mappingInput,children:(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:d,placeholder:"Select Heymarket Inbox",options:H(f),notFoundContent:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"heading-14-600",children:"No Available Inboxes"}),(0,s.jsx)("p",{children:"You must have User Mappings configured in order to select inboxes and users for Inbox Mappings."})]}),onSelect:e=>(e=>{if(x(e),f){let t=S[e];(!t||!t.members||0>t.members.indexOf(f))&&y(null)}})(e)})}),(0,s.jsxs)(I.A.Summary.Cell,{index:3,className:_().mappingInput,children:[(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:f,placeholder:"Select Heymarket User",options:(()=>{if(!e.config||!e.config.users)return[];let t=e.config.users.map(e=>C[e.user_id]?C[e.user_id]:{id:e.user_id,name:"Unknown Heymarket User"});if(d){let e=S[d];t=t.filter(t=>e.members&&e.members.indexOf(t.id)>=0)}return(0,P.yG)(t,"name","id")})(),notFoundContent:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"heading-14-600",children:"No Available Users"}),(0,s.jsx)("p",{children:"You must have User Mappings configured in order to select users."})]}),onSelect:e=>(e=>{if(y(e),d){let t=H(e);(0,P.Jb)(t,"value",d)||x(null)}})(e)}),(0,s.jsx)(w.A,{className:_().mappingArrow})]}),(0,s.jsx)(I.A.Summary.Cell,{index:4,children:(0,s.jsx)(u.A,{placeholder:"Enter Inbox Fallback Email",value:v,onChange:e=>j(e.target.value.trim())})}),(0,s.jsx)(I.A.Summary.Cell,{index:5,children:(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:F,children:t("button.add",{ns:"common"})})})]})})})}var W=n(14833);function X(e){let{value:t,options:n,disabled:a,className:i,onChange:o,onDropdownVisibleChange:l}=e;return(0,s.jsx)(p.A,{mode:"multiple",showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:i,size:"large",value:t,placeholder:"Select User Groups",options:n,disabled:a,notFoundContent:(0,s.jsx)("div",{className:"heading-14-600",children:"No User Group Found"}),onChange:o,onDropdownVisibleChange:l})}let $=[];function Q(e){let{value:t,onCommit:n,...a}=e,[i,o]=(0,l.useState)(t),[c,r]=(0,l.useState)(!1),d=i.length!==t.length||i.some(e=>!t.includes(e));return(0,l.useEffect)(()=>{d&&o(t)},[t]),(0,s.jsx)(X,{...a,value:i,onChange:e=>{o(e),c||n(e)},onDropdownVisibleChange:e=>{r(e),!e&&d&&n(i)}})}function Z(e){let{t,ready:n}=(0,m.B)(["admin.integrations","common"]),a=(0,g.GV)(A.kW),[i,o]=(0,l.useState)(null),[d,x]=(0,l.useState)(null),[f,y]=(0,l.useState)([]),[v,j]=(0,l.useState)([]),{groups:S,groupsById:N,enabled:C,settled:H}=(0,T.S)();(0,l.useEffect)(()=>{let t=e.config&&e.config.lists?e.config.lists.map(e=>e.list_id):null;if(t){let e=v.map(e=>e.id),n=t.filter(t=>0>e.indexOf(t));n.length&&(0,G.qm)(n,"lists",a,e=>{j(e)})}},[e.config]);let F=e=>{x(e.id),j([...v,e])},E=async()=>{if(!i||!d)return void(0,b.to)({type:"error",props:{title:"Invalid Data",content:"Please make sure you have selected valid data for each field."}});try{let t=(await c.post({path:"".concat(r.J6j,"/lists"),data:{hubspot_list_id:i,list_id:d,group_ids:f},spinner:!0})).data,n=e.config.lists?[...e.config.lists,t]:[t];e.setConfig({...e.config,lists:n}),o(null),x(null),y([])}catch(e){(0,b.to)({type:"error",props:{title:"Error Encountered",content:"There was an error in creating the field mapping. Please try again."}})}},M=async(t,n)=>{var s;let a=null!=(s=t.group_ids)?s:[],i=n=>e.setConfig(e=>{var s;return{...e,lists:(null!=(s=e.lists)?s:[]).map(e=>e.id===t.id?{...e,group_ids:n}:e)}});i(n);try{await c.put({path:"".concat(r.J6j,"/lists/").concat(t.id),data:{hubspot_list_id:t.hubspot_list_id,list_id:t.list_id,group_ids:n}})}catch(e){i(a),(0,b.to)({type:"error",props:{title:"Error Encountered",content:"There was an error in updating the user groups. Please try again."}})}},O=(0,l.useMemo)(()=>(0,P.yG)(S,"name","id"),[S]),R=e=>[...O,...e.filter(e=>!N[e]).map(e=>({label:"Unknown group (".concat(e,")"),value:e}))],L=e.syncInProgress||!H,U={title:(0,s.jsxs)(s.Fragment,{children:["User Groups",(0,s.jsx)("span",{className:"beta-label",children:" Beta"})]}),dataIndex:"group_ids",width:"25%",render:(e,t)=>{let n=null!=e?e:$;return(0,s.jsx)(Q,{value:n,options:R(n),disabled:L,className:_().mappingInputField,onCommit:e=>M(t,e)})}},B=[{title:"HubSpot List",dataIndex:"hubspot_list_id",width:"35%",render:t=>(0,s.jsxs)("div",{className:"".concat(_().mappingArrowInput," ").concat(_().blackText),children:[(0,s.jsx)(u.A,{value:(t=>
1{let n=(0,P.Jb)(e.config.hubspot_lists,"hubspot_list_id",t);return n?n.hubspot_list_name:"Unknown HubSpot List"})(t),disabled:!0,className:_().mappingInput}),(0,s.jsx)(w.A,{className:_().mappingArrow})]})},{title:"Heymarket List",dataIndex:"list_id",width:"25%",render:e=>(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:(e=>{let t=(0,P.Jb)(v,"id",e);return t?t.name:"Unknown Heymarket List"})(e),disabled:!0,className:_().mappingInput})})},...C?[U]:[],{title:"Action",dataIndex:"id",width:"15%",render:(n,a)=>(0,s.jsx)("button",{className:"white-button ".concat(_().removeMappingButton),onClick:()=>{e.removeMapping("lists",a.id)},children:t("button.remove",{ns:"common"})})}];return n&&(0,s.jsx)(I.A,{title:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{children:"List Mapping"}),(0,s.jsx)("div",{className:"help-text",children:"Map lists from HubSpot to Heymarket."})]}),className:"compact-table hide-empty-row",loading:!1,rowKey:"id",columns:B,dataSource:e.config?e.config.lists:[],showSorterTooltip:!1,pagination:!1,summary:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(I.A.Summary.Row,{className:"summary-row",children:[(0,s.jsxs)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:[(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:i,placeholder:"Select HubSpot List",options:(()=>{if(!e.config)return[];let t=e.config&&e.config.lists?e.config.lists.map(e=>e.hubspot_list_id):null;return(0,P.yG)(e.config.hubspot_lists,"hubspot_list_name","hubspot_list_id",t)})(),disabled:e.syncInProgress,notFoundContent:(0,s.jsx)("div",{className:"heading-14-600",children:"No HubSpot List Found"}),onSelect:e=>o(e)}),(0,s.jsx)(w.A,{className:_().mappingArrow})]}),(0,s.jsx)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:(0,s.jsx)(W.A,{allowCreate:!1,variant:"outlined",disabled:e.syncInProgress,className:_().mappingInputField,excludedListIds:[],value:d,onSelect:F})}),C&&(0,s.jsx)(I.A.Summary.Cell,{index:3,className:_().mappingInput,children:(0,s.jsx)(X,{value:f,options:R(f),disabled:L,className:_().mappingInputField,onChange:y})}),(0,s.jsx)(I.A.Summary.Cell,{index:4,children:(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:E,disabled:e.syncInProgress,children:t("button.add",{ns:"common"})})})]}),e.syncInProgress&&(0,s.jsx)(I.A.Summary.Row,{className:"summary-row",children:(0,s.jsx)(I.A.Summary.Cell,{index:1,children:(0,s.jsxs)("div",{className:" ".concat(_().syncMessageRow),children:[(0,s.jsx)("img",{className:"rotate",src:"/icons/rotate-green.svg",width:24,height:24,alt:"Sync Icon"}),(0,s.jsx)("span",{className:_().syncMessage,children:"Sync: In Progress"})]})})})]})})}var ee=n(87539),et=n(91336),en=n(25510),es=n(20916),ea=n(92222);let ei=0,eo=()=>({_id:++ei,property:"",operator:"equals",value:""}),el=e=>{var t;return(null==e||null==(t=e.conditions)?void 0:t.length)?e.conditions.map(e=>({...e,_id:++ei})):[eo()]};function ec(e){var t,n,a,i,o,d,m,b,y,j;let S=(0,g.jL)(),N=null==(t=e.config)?void 0:t.selective_sync,[w,I]=(0,l.useState)(null!=(o=null==N?void 0:N.enabled)&&o),[C,A]=(0,l.useState)((null==N?void 0:N.match_type)||"all"),[H,F]=(0,l.useState)(el(N)),[E,M]=(0,l.useState)(!1),T=JSON.stringify(null!=(d=null==(n=e.config)?void 0:n.selective_sync)?d:null);(0,l.useEffect)(()=>{var t,n;let s=null==(t=e.config)?void 0:t.selective_sync;I(null!=(n=null==s?void 0:s.enabled)&&n),A((null==s?void 0:s.match_type)||"all"),F(el(s))},[T]);let O=new Set((null!=(m=null==(a=e.config)?void 0:a.fields)?m:[]).map(e=>String(e.hubspot_field_id))),R=(null!=(b=null==(i=e.config)?void 0:i.hubspot_fields)?b:[]).filter(e=>O.has(e.hubspot_field_id)),L=(0,P.yG)(R,"hubspot_field_name","hubspot_field_id"),U="all"===C?new Set(H.map(e=>e.property).filter(Boolean)):new Set,B=(e,t,n)=>{F(s=>s.map((s,a)=>a===e?{...s,[t]:n}:s))},G=async()=>{let t=H.filter(e=>e.property&&e.value).map(e=>({property:e.property,operator:e.operator,value:e.value}));if(w&&0===t.length)return void S((0,f.P0)({title:"Missing Conditions",message:"Add at least one condition, or turn off selective sync.",type:"negative"}));if(w&&"all"===C){let e=t.map(e=>e.property);if(new Set(e).size!==e.length)return void S((0,f.P0)({title:"Duplicate Property",message:'With "all", each property can be used once. Switch to "any" to match multiple values for the same property.',type:"negative"}))}M(!0);try{let n=await c.put({path:"".concat(r.J6j,"/config/selective-sync"),data:{enabled:w,match_type:C,conditions:t},spinner:!0});e.setConfig({...e.config,selective_sync:n.data}),S((0,f.P0)({title:"Saved",message:"Selective sync settings saved.",type:"positive"}))}catch(e){S((0,f.P0)({title:"Error Encountered",message:"Failed to save selective sync settings.",type:"negative"})),(0,x.OP)("Error saving selective sync: ",e)}finally{M(!1)}},D="any"===C?"or":"and",J=H.filter(e=>e.property).map(e=>"".concat((e=>{let t=L.find(t=>t.value===e);return t?String(t.label):e})(e.property)," is ").concat(e.value||"â¦")),z=J.length?"A new contact will sync
1when ".concat(J.join(" ".concat(D," ")),"."):"A new contact will sync when it matches your conditions.",V=JSON.stringify({enabled:w,match_type:C,conditions:H.filter(e=>e.property&&e.value).map(e=>({property:e.property,operator:e.operator,value:e.value}))})!==JSON.stringify({enabled:null!=(y=null==N?void 0:N.enabled)&&y,match_type:(null==N?void 0:N.match_type)||"all",conditions:(null!=(j=null==N?void 0:N.conditions)?j:[]).filter(e=>e.property&&e.value).map(e=>({property:e.property,operator:e.operator,value:e.value}))});return(0,s.jsxs)("div",{id:"hubspot-selective-sync",className:v().settingsContainer,children:[(0,s.jsxs)("div",{className:v().settingRow,children:[(0,s.jsxs)("div",{className:v().contentLeft,children:[(0,s.jsxs)("div",{className:v().title,children:["Selective sync",(0,s.jsx)("span",{className:"beta-label",children:" Beta"})]}),(0,s.jsx)("span",{className:v().helpText,children:"Only new contacts that match the conditions below will sync. Contacts already in Heymarket are never affected."})]}),(0,s.jsx)("div",{className:v().contentRight,children:(0,s.jsx)(en.A,{checked:w,onChange:I})})]}),w&&(0,s.jsxs)("div",{className:v().settingRow,style:{flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",gap:12},children:[(0,s.jsx)("div",{className:v().title,children:"Conditions"}),(0,s.jsx)("span",{className:v().helpText,children:"Sync a contact that matches"}),(0,s.jsx)(p.A,{size:"large",style:{width:320},suffixIcon:(0,s.jsx)(h.F,{}),value:C,onChange:A,options:[{label:"all (AND)",value:"all"},{label:"any (OR)",value:"any"}]}),(0,s.jsx)("span",{className:v().helpText,children:"of these:"}),H.map((e,t)=>{let n=L.map(t=>({...t,disabled:t.value!==e.property&&U.has(t.value)}));return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"},children:[t>0&&(0,s.jsx)(es.A,{children:"any"===C?"OR":"AND"}),(0,s.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,size:"large",style:{width:200},suffixIcon:(0,s.jsx)(h.F,{}),placeholder:"Select a property",value:e.property||void 0,onChange:e=>B(t,"property",e),options:n}),(0,s.jsx)("span",{className:"help-text",children:"is"}),(0,s.jsx)(u.A,{size:"large",style:{width:200},placeholder:"Enter a value",value:e.value,onChange:e=>B(t,"value",e.target.value)}),(0,s.jsx)("button",{className:"icon-button",onClick:()=>{F(e=>e.filter((e,n)=>n!==t))},"aria-label":"Remove condition",children:(0,s.jsx)(ee.A,{})})]})]},e._id)}),(0,s.jsx)("button",{className:"white-button",onClick:()=>{F(e=>[...e,eo()])},disabled:H.length>=5,children:"+ Add condition"}),(0,s.jsx)(ea.A,{style:{width:"100%"},type:"info",showIcon:!0,icon:(0,s.jsx)(et.A,{}),message:z})]}),(0,s.jsxs)("div",{className:v().settingRow,children:[(0,s.jsx)("div",{className:v().contentLeft,children:V&&(0,s.jsx)("span",{className:v().helpText,children:"Unsaved changes"})}),(0,s.jsxs)("div",{className:v().contentRight,style:{display:"flex",gap:8},children:[(0,s.jsx)("button",{className:"white-button",onClick:()=>{var t,n;let s=null==(t=e.config)?void 0:t.selective_sync;I(null!=(n=null==s?void 0:s.enabled)&&n),A((null==s?void 0:s.match_type)||"all"),F(el(s))},disabled:!V||E,children:"Cancel"}),(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:G,disabled:E,children:"Save"})]})]})]})}var er=n(75537);let ed=[{name:"Phone Number (primary only)",type:"phone"},{name:"Mobile Phone Number (primary only)",type:"mobilephone"},{name:"Phone Number (primary), Mobile Phone Number (backup)",type:"phone,mobilephone"},{name:"Mobile Phone Number (primary), Phone Number (backup)",type:"mobilephone,phone"}],ep=["create_new_contact","owner_sync","hm_conversation_status","hm_to_hs_sync","hs_to_hm_sync","email_sync"];function eu(e){var t,n,a,i;let o,l=(0,g.jL)(),d=t=>{var n;return(null==(n=e.config)?void 0:n.settings[t])==="enabled"},u=async(t,n)=>{if((0,H.Iy)(e.config)&&ep.indexOf(t)>=0)return void(0,b.to)({type:"error",props:{title:"Sync In Progress",content:"Please wait for contact sync to complete."}});let s={},a="";"phone"==t?s={name:"phone",value:a=n}:(a=d(t)?"disabled":"enabled",s={name:"hm_conversation_status"==t?"conversation_status":t,value:a});try{await c.put({path:"".concat(r.J6j,"/config"),data:s}),e.setConfig({...e.config,settings:{...e.config.settings,[t]:a}})}catch(e){l((0,f.P0)({title:"Error Encountered",message:"There was an error updating the HubSpot config. Please try again.",type:"negative"})),(0,x.OP)("Error updating hubspot config data: ",e)}},{Option:m}=p.A;return(0,s.jsxs)("div",{className:"".concat(v().settingsContainer),children:[(0,s.jsx)("div",{className:"".concat(_().mappingHeader),children:(0,s.jsx)("span",{className:"".concat(_().title),children:"Settings"})}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"User"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"User who authenticated and linked HubSpot to Heymarket"})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:null==(t=e.config)?void 0:t.user})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"HubSpot Domain"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"The HubSpot domain connected to Heymarket"})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:null==(n=e.config)?void 0:n.hubspot_domain})]}),(null==(a=e.config)?void 0:a.last_synced_at)&&(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Last Sync Date"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"The last time data was synced with your HubSpot account"})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,er.eW)(null==(i=e.config)?void 0:i.last_synced_at)})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Timeline Events"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Create a timeline event when a new message is sent or received"})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("timeline"),checkedChildren:"On",unCheckedChildren:"Off",onChange:()=>u("timeline")})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Mobile Phone Property"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Choose the phone number property in HubSpot which contains the mobile number"})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(p.A,{size:"large",style:{width:290},suffixIcon:(0,s.jsx)(h.F,{}),value:e.config?(o=e.config.settings.phone,ed.find(e=>e.type==o).name):null,onChange:e=>{u("phone",e)},children:ed.map(e=>(0,s.jsx)(m,{value:e.type,children:e.name},e.type))})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Create New Contacts in HubSpot"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"When an unknown contact sends a text to your dedicated phone number, should this contact also be created in HubSpot?"})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("create_new_contact"),onChange:()=>u("create_new_contact"),checkedChildren:"On",unCheckedChildren:"Off"})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Contact Owners"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Sync Contact Owners in HubSpot with Contact Owners in Heymarket."})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("owner_sync"),onChange:()=>u("owner_sync"),checkedChildren:"On",unCheckedChildren:"Off"})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Conversation Status Sync"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Enable or disable the conversation status sync."})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("hm_conversation_status"),onChange:()=>u("hm_conversation_status"),checkedChildren:"On",unCheckedChildren:"Off"})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"HubSpot to Heymarket Sync"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Sync HubSpot data to Heymarket."})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("hs_to_hm_sync"),onChange:()=>u("hs_to_hm_sync"),checkedChildren:"On",unCheckedChildren:"Off"})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsx)("div",{className:"".concat(v().title),children:"Heymarket to HubSpot Sync"}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Sync Heymarket data to HubSpot."})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("hm_to_hs_sync"),onChange:()=>
1u("hm_to_hs_sync"),checkedChildren:"On",unCheckedChildren:"Off"})})]}),(0,s.jsxs)("div",{className:"".concat(v().settingRow),children:[(0,s.jsxs)("div",{className:"".concat(v().contentLeft),children:[(0,s.jsxs)("div",{className:"".concat(v().title),children:["Email Sync ",(0,s.jsx)("span",{className:"beta-label",children:" Beta"})]}),(0,s.jsx)("span",{className:"".concat(v().helpText),children:"Enable or disable email sync with HubSpot."})]}),(0,s.jsx)("div",{className:"".concat(v().contentRight),children:(0,s.jsx)(en.A,{checked:d("email_sync"),onChange:()=>u("email_sync"),checkedChildren:"On",unCheckedChildren:"Off"})})]})]})}var em=n(4917),eh=n.n(em),eg=n(4444);let ex=(0,l.forwardRef)((e,t)=>{let{filterFunction:n,setDefaultWithFirstUser:a=!0,showSuffixIcon:i=!0,className:o,placeholder:c="Select Heymarket User",onUserChange:r,showSearch:d=!0,placement:u="bottomLeft",style:m,notFoundContent:x,initialValue:b,selectFirst:y=!1,onUserNotFound:v}=e,j=(0,g.jL)(),_=(0,g.GV)(e=>e.members.scrollFetchedMembers),S=(0,g.GV)(e=>e.members.searchedResults),N=(0,g.GV)(e=>e.members.scrollFetchPaginateOptions),w=(0,g.GV)(e=>e.members.count),I=(0,l.useMemo)(()=>_.filter(e=>"ai_agent"!==e.role),[_]),[C,A]=(0,l.useState)([]),[k,H]=(0,l.useState)(null),[F,E]=(0,l.useState)(b),[M,T]=(0,l.useState)(null),[O,R]=(0,l.useState)(!1);(0,l.useImperativeHandle)(t,()=>({getAvailableUserCount:()=>C.length}));let L=(0,l.useCallback)(eh()(e=>{e&&e.length>2&&j((0,q.Yl)(e.toLowerCase()))},300),[]);(0,l.useEffect)(()=>{b&&j((0,q.Xs)([b],{})).then(e=>{e[b]?T(e[b]):E(null)})},[]),(0,l.useEffect)(()=>{0==I.length&&j((0,q.O$)(!0))},[]),(0,l.useEffect)(()=>{y&&C.length>0&&!F&&U(C[0].id)},[C,F]),(0,l.useEffect)(()=>{let e=(null==k?void 0:k.length)>2,t=e?S:I;t.length&&n&&(t=n(t)),!e&&M&&M.id==F&&(t.find(e=>e.id==F)||(t=[...t,M]),r&&r(M)),0==t.length&&N.page>0&&!e&&v&&v(),A(t)},[I,S,k,M,N]);let U=e=>{let t=C.find(t=>t.id===e);t&&r&&r(t),E(null==t?void 0:t.id)},B=e=>{e!=k&&(H(e),L(e))},G=(0,l.useMemo)(()=>(0,P.yG)(C,"name","id"),[C]);return(0,s.jsx)(p.A,{style:m,autoClearSearchValue:!0,showSearch:d,searchValue:k,placement:u,filterOption:!1,suffixIcon:i?(0,s.jsx)(h.F,{}):null,className:o,size:"large",placeholder:c,defaultValue:a&&(null==C?void 0:C.length)>0?C[0].label:null,value:F,options:G,notFoundContent:x,onBlur:()=>{setTimeout(()=>{k&&B("")},300)},onChange:U,onSearch:B,onPopupScroll:eh()(e=>{(0,eg.uH)(e.target)&&(w&&N.page>0&&N.page*N.size>=w||O||(R(!0),j((0,q.O$)(!0)).then(e=>{R(!1),e||j((0,f.P0)({title:"Failed to fetch members...",duration:5,type:"negative"}))})))},300)})});function eb(e){let{t,ready:n}=(0,m.B)(["admin.integrations","common"]),a=(0,g.jL)(),[i,o]=(0,l.useState)(null),[d,x]=(0,l.useState)(null),[f,y]=(0,l.useState)(null),[v,j]=(0,l.useState)({}),[S,N]=(0,l.useState)([]),[C,A]=(0,l.useState)({});(0,l.useEffect)(()=>{if(!e.config||!e.config.users)return;let t=e.config.users.map(e=>e.inbox_id);a((0,z.g7)(t,v)).then(e=>{j(e)});let n=e.config.users.map(e=>e.user_id);a((0,q.Xs)(n,C)).then(e=>{A(e)})},[e.config.users]),(0,l.useEffect)(()=>{if(!f){N([]),x(null);return}a((0,z.KF)(f)).then(e=>{N((0,P.yG)(e,"name","id")),d&&((0,P.Jb)(e,"value",d)||x(null))})},[f]);let H=e=>{y(null==e?void 0:e.id)},F=async()=>{if(!i||!f||!d)return void(0,b.to)({type:"error",props:{title:"Invalid Data",content:"Please make sure you have selected valid data for each field."}});try{let t=(await c.post({path:"".concat(r.J6j,"/users"),data:{hubspot_owner_id:i,user_id:f,inbox_id:d},spinner:!0})).data,n=e.config.users?[...e.config.users,t]:[t];e.setConfig({...e.config,users:n}),x(null),o(null),y(null)}catch(e){(0,b.to)({type:"error",props:{title:"Error Encountered",content:"There was an error in creating the user mapping. Please try again."}})}},E=[{title:"HubSpot User",dataIndex:"hubspot_owner_id",width:"30%",render:t=>(0,s.jsxs)("div",{className:"".concat(_().mappingArrowInput," ").concat(_().blackText),children:[(0,s.jsx)(u.A,{value:(t=>{let n=(0,P.Jb)(e.config.hubspot_users,"hubspot_owner_id",t);return n?n.hubspot_user_name:"Unknown HubSpot User"})(t),disabled:!0,className:_().mappingInput}),(0,s.jsx)(w.A,{className:_().mappingArrow})]})},{title:"Heymarket User",dataIndex:"user_id",width:"30%",render:e=>(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:(e=>{let t=C[e];return t?t.name:"Unknown Heymarket User"})(e),disabled:!0,className:_().mappingInput})})},{title:"Heymarket Inbox",dataIndex:"inbox_id",width:"30%",render:e=>(0,s.jsx)("div",{className:_().blackText,children:(0,s.jsx)(u.A,{value:(0,B.u4)(v,e),disabled:!0,className:_().mappingInput})})},{title:"Action",dataIndex:"id",width:"10%",render:(n,a)=>(0,s.jsx)("button",{className:"white-button ".concat(_().removeMappingButton),onClick:()=>{var t;let n;(n=!1,(t=a)&&e.config.inbox_mappings&&(n=e.config.inbox_mappings.some(e=>{if(t.user_id==e.default_inbox_user)return!0})),n)?(0,b.to)({type:"error",props:{title:"Cannot Remove User Mapping",content:"This user is currently assigned to an Inbox Mapping. To remove this User Mapping, please remove their Inbox Mapping and try again."}}):e.removeMapping("users",a.id)},children:t("button.remove",{ns:"common"})})}];return n&&(0,s.jsx)(I.A,{title:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{children:"User Mapping"}),(0,s.jsx)("div",{className:"help-text",children:"Map Heymarket users to HubSpot users."})]}),className:"compact-table hide-empty-row",loading:!1,rowKey:"id",columns:E,dataSource:e.config?e.config.users:[],showSorterTooltip:!1,pagination:!1,summary:()=>(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(I.A.Summary.Row,{className:"summary-row",children:[(0,s.jsxs)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:[(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:i,placeholder:"Select HubSpot User",options:(()=>
1{if(!e.config)return[];let t=e.config.users?e.config.users.map(e=>e.hubspot_owner_id):null;return(0,P.yG)(e.config.hubspot_users,"hubspot_user_name","hubspot_owner_id",t)})(),onSelect:e=>o(e)}),(0,s.jsx)(w.A,{className:_().mappingArrow})]}),(0,s.jsx)(I.A.Summary.Cell,{index:1,className:_().mappingInput,children:(0,s.jsx)(ex,{className:_().mappingInputField,onUserChange:H})}),(0,s.jsx)(I.A.Summary.Cell,{index:2,children:(0,s.jsx)(p.A,{showSearch:!0,filterOption:k.IL,suffixIcon:(0,s.jsx)(h.F,{}),className:_().mappingInputField,size:"large",value:d,placeholder:"Select Heymarket Inbox",options:S,notFoundContent:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"heading-14-600",children:"No Inbox Found"}),(0,s.jsx)("p",{children:"Please make sure you have selected a Heymarket user who is associated with at least one inbox."})]}),onSelect:e=>x(e)})}),(0,s.jsx)(I.A.Summary.Cell,{index:3,children:(0,s.jsx)("button",{className:"white-button ".concat(_().addMappingButton),onClick:F,children:t("button.add",{ns:"common"})})})]})})})}var ef=n(87432),ey=n(81109),ev=n(64090),ej=n(62007),e_=n(54192),eS=n(7598),eN=n(54625);let ew=0,eI=null,eC=()=>{let e=(0,o.useRouter)(),t=(0,g.jL)(),n=(0,g.GV)(e=>(0,ej.Sv)([e,"hubspot_integration"])),a=(0,g.GV)(e=>(0,e_.NX)([e,"integrations"])),p=(0,g.GV)(A.kW),u=(0,g.GV)(ej.$y),m=(0,g.GV)(ev.bv),h=(0,g.GV)(ev.xu),[y,v]=(0,l.useState)(null);(0,l.useEffect)(()=>(ew=0,()=>{clearTimeout(eI),c.cancelRequest("hubspot-config"),t((0,f.tR)("hubspot","remove"))}),[]),(0,l.useEffect)(()=>{y&&(m&&m["hubspot-inited"]&&(t((0,eN.gG)("hubspot-inited")),(0,b.to)({type:"info",props:{title:"Congratulations on installing the HubSpot integration",content:(0,b._S)({message:"You will need to configure your contacts, custom fields, and lists that you wish to sync. Once you have configured them, click on the synchronize button.",type:ey.vT.HubspotOnboarding})}}),t((0,D.u4)("Hubspot: Installed Integration",{user_id:h.user_id,email:h.email}))),m&&m["hubspot-reauth"]&&(t((0,eN.gG)("hubspot-reauth")),(0,b.to)({type:"info",props:{title:"Successfully re-authenticated the HubSpot integration",content:"You can now create Inbox Mappings with HubSpot Inboxes."}})))},[y]),(0,l.useEffect)(()=>{if(a){if(!n){t((0,eS.wo)({feature:"hubspot_integration"})),e.replace(ef.BVt.Integrations);return}}else{(0,eS.MH)("integrations"),e.replace(ef.BVt.Admin);return}t((0,V.Je)("hubspot")).then(e=>{e.isEnabled&&j()})},[a,n]),(0,l.useEffect)(()=>{clearTimeout(eI),(0,H.Iy)(y)&&C()},[y]);let j=async()=>{try{t((0,f.tR)("hubspot","add",null,!0)),ew++;let e=await c.get({path:r.J6j+"/config"},!0,"hubspot-config");200===e.status&&v(e.data)}catch(t){ew>=3?(0,b.to)({type:"error",props:{title:"Unable to Configure HubSpot Integration",content:"There was an issue with accessing the HubSpot integration. Please try again in a few minutes or contact Heymarket Support.",onOk:()=>{e.push(ef.BVt.Integrations)}}}):eI=setTimeout(()=>{j()},5e3),(0,x.OP)("Error getting hubspot config data: ",t)}finally{t((0,f.tR)("hubspot","remove"))}},S=async(e,n)=>{try{let s=await c.deleteRequest({path:"".concat(r.J6j,"/").concat(e,"/").concat(n)});if(200===s.status){let s=y["inbox/mapping"==e?"inbox_mappings":"groups"==e?"group_mappings":e].filter(e=>e.id!=n);"users"==e?v({...y,users:s}):"fields"==e?v({...y,fields:s}):"lists"==e?v({...y,lists:s}):"groups"==e?v(e=>{var t;return{...e,group_mappings:(null!=(t=e.group_mappings)?t:[]).filter(e=>e.id!=n)}}):(v({...y,inbox_mappings:s}),t((0,D.u4)("Hubspot: Inbox Mapping Removed")))}}catch(n){var s;(0,x.yA)("error: ",n);let t="fields"==e&&(null==n||null==(s=n.response)?void 0:s.status)===409;(0,b.to)({type:"error",props:{title:t?"Mapping In Use":"Error Encountered",content:t?"This field mapping is used by your User Group Mapping. Remove the group mappings for this property first.":"There was an error in removing the mapping. Please try again."}})}},w=()=>{c.post({path:"".concat(r.J6j,"/sync"),data:{team_id:p}}).then(()=>{v({...y,initial_sync_status:"active"})}).catch(()=>{t((0,f.P0)({title:"Error",message:"Could not initiate sync at this time.",type:"negative"}))})},I=()=>{var e;return(e=>{let t="disabled";return e.settings.hs_to_hm_sync==t&&e.settings.hm_to_hs_sync==t})(y)?void t((0,f.P0)({message:"Please enable at least one sync o
1ption.",type:"negative"})):y.last_synced_at||(null==(e=y.selective_sync)?void 0:e.enabled)?void w():void(0,b.to)({type:"confirm",props:{title:"Set up selective sync?",content:"You can sync only the HubSpot contacts that match a property filter (for example, pincode = 123). Configure it in the Selective Sync section, or continue to sync all contacts.",okText:"Continue sync",cancelText:"Configure selective sync property",onOk:()=>{w()},onCancel:()=>{var e;null==(e=document.getElementById("hubspot-selective-sync"))||e.scrollIntoView({behavior:"smooth",block:"start"})}}})},C=async()=>{clearTimeout(eI),eI=setTimeout(async()=>{let e=await c.get({path:r.J6j+"/config"});200===e.status&&(v(e.data),C())},15e3)},k=(0,H.Iy)(y);return y?(0,s.jsxs)("div",{children:[k&&(0,s.jsxs)("div",{className:"status-banner info-banner",id:"hubspot-sync-banner",children:[(0,s.jsx)("img",{className:"rotate",src:"/icons/rotate-black.svg",width:24,height:24,alt:"Sync Icon"}),(0,s.jsx)("div",{children:"Updating contacts ..."})]}),(0,s.jsxs)("header",{className:"page-header",children:[(0,s.jsx)("h1",{className:"page-header-title",children:"HubSpot"}),(0,s.jsx)("button",{className:"orange-button",onClick:I,disabled:k,children:"Synchronize"})]}),(0,s.jsxs)("section",{className:_().integrationDetailsContent,children:[(0,s.jsx)(ec,{config:y,setConfig:v}),(0,s.jsx)(eu,{config:y,setConfig:v}),(0,s.jsx)(eb,{config:y,removeMapping:S,setConfig:v}),(0,s.jsx)(E,{config:y,removeMapping:S,setConfig:v,syncInProgress:k,syncData:I}),u&&(0,s.jsx)(R,{config:y,removeMapping:S,setConfig:v,syncInProgress:k}),(0,s.jsx)(Z,{config:y,removeMapping:S,setConfig:v,syncInProgress:k}),(0,s.jsx)(K,{config:y,removeMapping:S,setConfig:v}),(0,s.jsx)(N,{config:y,setConfig:v})]}),(0,s.jsx)("section",{className:_().integrationDetailsContent,children:(0,s.jsx)(d.A,{integrationName:"HubSpot",helpArticle:"https://help.heymarket.com/hc/en-us/articles/360042385112-HubSpot-Integration"})}),(0,s.jsx)("footer",{className:"".concat(_().pageFooter),children:(0,s.jsx)("button",{className:i()("orange-button",_().btnDisableIntegration),onClick:()=>{(0,b.to)({type:"confirm",isNegative:!0,props:{title:"Disable HubSpot",content:"Please confirm disabling your HubSpot integration.",okText:"Disable",onOk:async()=>{await c.post({path:"".concat(r.J6j,"/disable")}),v(null),e.push(ef.BVt.Integrations)}}})},children:"Disable Integration"})})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("header",{className:"page-header",children:(0,s.jsx)("h1",{className:"page-header-title",children:"HubSpot"})}),(0,s.jsx)("section",{className:_().integrationDetailsContent,children:(0,s.jsxs)("div",{className:"".concat(_().integrationDetailsBox," ").concat(_().setupBox),children:[(0,s.jsx)("p",{children:"Integrate your existing HubSpot account with Heymarket."}),(0,s.jsx)("button",{className:"orange-button",onClick:()=>{t((0,V.qv)(!1))},children:"Setup"})]})}),(0,s.jsx)("section",{className:_().integrationDetailsContent,children:(0,s.jsx)(d.A,{integrationName:"HubSpot",helpArticle:"https://help.heymarket.com/hc/en-us/articles/360042385112-HubSpot-Integration"})})]})}}},e=>{e.O(0,[5525,4655,8532,636,6593,8792],()=>e(e.s=33146)),_N_E=e.O()}]);
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.