var F=Object.defineProperty;var _=Object.getOwnPropertySymbols;var f=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var h=(e,i,t)=>i in e?F(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,l=(e,i)=>{for(var t in i||(i={}))f.call(i,t)&&h(e,t,i[t]);if(_)for(var t of _(i))k.call(i,t)&&h(e,t,i[t]);return e};import{_ as a,b as g,z as d}from"./main.2.9.0.js";import{u as m}from"./Note.NSUdvR3c.js";const P=(e,i,t)=>{const{name:r,value:s}=e.target;t(o=>m(o,p=>{p[r]=s}))},q=(e,i,t,r)=>{if(!e.api_key){i({api_key:a("API Key can't be empty","bit-integrations")});return}i({}),r(!0),g({api_key:e.api_key},"heffl_crm_authorize").then(s=>{if(r(!1),s!=null&&s.success){t(!0),d.success(a("Authorized Successfully","bit-integrations"));return}d.error(s!=null&&s.data&&typeof s.data=="string"?s.data:a("Authorization failed","bit-integrations"))})},c=(e,i,t,r,s,o,p,u={})=>{if(!(e!=null&&e.api_key)){d.error(a("Authorize first to refresh","bit-integrations"));return}t(!0),g(l({api_key:e.api_key},u),r).then(n=>{if(t(!1),n!=null&&n.success){i(b=>m(b,y=>{y[s]=Array.isArray(n.data)?n.data:[]})),d.success(o);return}d.error(p)}).catch(()=>t(!1))},L=(e,i,t)=>c(e,i,t,"refresh_heffl_crm_lead_sources","leadSources",a("Lead sources fetched","bit-integrations"),a("Failed to fetch lead sources","bit-integrations")),v=(e,i,t)=>c(e,i,t,"refresh_heffl_crm_lead_stages","leadStages",a("Lead stages fetched","bit-integrations"),a("Failed to fetch lead stages","bit-integrations")),K=(e,i,t)=>c(e,i,t,"refresh_heffl_crm_pipelines","pipelines",a("Pipelines fetched","bit-integrations"),a("Failed to fetch pipelines","bit-integrations")),V=(e,i,t,r)=>c(e,i,t,"refresh_heffl_crm_pipeline_stages","pipelineStages",a("Pipeline stages fetched","bit-integrations"),a("Failed to fetch pipeline stages","bit-integrations"),{pipelineId:r}),x=(e,i,t)=>c(e,i,t,"refresh_heffl_crm_clients","clients",a("Clients fetched","bit-integrations"),a("Failed to fetch clients","bit-integrations")),j=(e,i,t)=>c(e,i,t,"refresh_heffl_crm_leads","leads",a("Leads fetched","bit-integrations"),a("Failed to fetch leads","bit-integrations")),w=e=>{if(!(e!=null&&e.mainAction))return!1;const i=((e==null?void 0:e.hefflCRMFields)||[]).filter(r=>r.required).map(r=>r.key),t=(e==null?void 0:e.field_map)||[];return i.every(r=>t.some(s=>s.hefflCRMField===r&&s.formField&&(s.formField!=="custom"||s.customValue&&s.customValue!=="")))},B=e=>{const i=e.filter(t=>t.required);return i.length>0?i.map(t=>({formField:"",hefflCRMField:t.key})):[{formField:"",hefflCRMField:""}]};export{v as a,V as b,w as c,K as d,x as e,j as f,B as g,P as h,q as i,L as r};
