import{u as h}from"./Note.NSUdvR3c.js";import{b as p,z as d,_ as m}from"./main.2.9.0.js";const _=(e,s,i)=>{const{name:a,value:t}=e.target;i(l=>h(l,r=>{r[a]=t}))},P=e=>{var i,a;if(!(e!=null&&e.mainAction)||e.mainAction!=="sync_all_sites"&&!(e!=null&&e.selectedSite)||e.mainAction==="create_post"&&!((i=e==null?void 0:e.utilities)!=null&&i.post_type))return!1;const s=((a=e==null?void 0:e.mainWPFields)==null?void 0:a.filter(t=>t.required))||[];return s.length?s.every((t,l)=>{var n;const r=(n=e==null?void 0:e.field_map)==null?void 0:n[l];return(r==null?void 0:r.formField)&&(r==null?void 0:r.mainWPField)}):!0},g=e=>{if(!(e!=null&&e.length))return[];const s=e.filter(t=>t.required),i=e.some(t=>!t.required),a=s.map(t=>({formField:"",mainWPField:t.key}));return i&&a.push({formField:"",mainWPField:""}),a},y=(e,s)=>{s("sites"),p(null,"refresh_main_wp_sites").then(i=>{var a;i!=null&&i.success&&((a=i==null?void 0:i.data)!=null&&a.sites)?(e(t=>h(t,l=>{l.allSites=i.data.sites})),d.success(m("Sites fetched successfully","bit-integrations"))):d.error(m("Failed to fetch sites. Please try again.","bit-integrations")),s(!1)}).catch(()=>s(!1))};export{P as c,g,_ as h,y as r};
