import{u as s}from"./Note.DalStCGz.js";import{_ as f,b as m}from"./main.2.8.10.js";const g=(a,n,t)=>{const o=s(n,i=>{i[a.target.name]=a.target.value});t(o)},p=a=>{const n=a.filter(t=>t.required===!0);return n.length>0?n.map(t=>({formField:"",notificationXField:t.key})):[{formField:"",notificationXField:""}]},F=a=>(a!=null&&a.field_map?a.field_map.filter(t=>!t.formField||!t.notificationXField||t.formField==="custom"&&!t.customValue):[]).length===0,_=(a,n,t,o)=>{a&&(t(!0),m({action:a},"notificationx_get_notifications_by_source").then(i=>{if(i&&i.success)n(c=>s(c,e=>{e.notifications=i.data}));else{const c=typeof(i==null?void 0:i.data)=="string"?i.data:i==null?void 0:i.message;o({msg:c||f("Failed to fetch notifications","bit-integrations"),show:!0})}t(!1)}).catch(()=>{o({msg:f("Failed to fetch notifications","bit-integrations"),show:!0}),t(!1)}))},b=(a,n,t,o,i)=>{if(!a.name){t({name:a.name?"":f("Integration name can't be empty","bit-integrations")});return}t({}),i(!0);const c={name:a.name};m(c,"notificationx_authorize").then(e=>{if(e&&e.success)o(!0);else{const r=typeof(e==null?void 0:e.data)=="string"?e.data:e==null?void 0:e.message;t({name:r||f("Authorization failed","bit-integrations")})}i(!1)}).catch(()=>{t({name:f("Authorization failed","bit-integrations")}),i(!1)})};export{F as c,p as g,g as h,b as n,_ as r};
