var y=Object.defineProperty;var w=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var m=(t,e,a)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,h=(t,e)=>{for(var a in e||(e={}))I.call(e,a)&&m(t,a,e[a]);if(w)for(var a of w(e))k.call(e,a)&&m(t,a,e[a]);return t};import{_ as c,b as _,s as b}from"./main.2.8.10.js";const R=t=>{const e={},l=window.location.href.replace(`${window.opener.location.href}`,"").split("&");l&&l.forEach(s=>{const o=s.split("=");o[1]&&(e[o[0]]=o[1])}),localStorage.setItem(`__${t}`,JSON.stringify(e)),window.close()},z=(t,e,a,l,s,o,i,r,n)=>{let f=h({},e);f[t.target.name]=t.target.value,a(h({},f))},A=(t,e,a,l,s)=>{l(!0);const o={formID:t,clientId:e.clientId,accessToken:e.tokenDetails.access_token,clientSecret:e.clientSecret,refreshToken:e.tokenDetails.refresh_token,tokenDetails:e.tokenDetails};_(o,"zoom_webinar_fetch_all_webinar").then(i=>{if(i&&i.success){const r=h({},e);r.default||(r.default={}),i.data.allWebinar&&(r.default.allWebinar=i.data.allWebinar),s({show:!0,msg:c("Webinar list refreshed","bit-integrations")}),a(h({},r))}else i&&i.data&&i.data.data||!i.success&&typeof i.data=="string"?s({show:!0,msg:b(c("All Webinar list refresh failed Cause: %s. please try again","bit-integrations"),i.data.data||i.data)}):s({show:!0,msg:c("All Webinar list failed. please try again","bit-integrations")});l(!1)}).catch(()=>l(!1))},v=(t,e,a,l,s,o,i)=>{if(!t.clientId||!t.clientSecret){a({clientId:t.clientId?"":c("Client Id can't be empty","bit-integrations"),clientSecret:t.clientSecret?"":c("Secret key can't be empty","bit-integrations")});return}s(!0);const r=`https://zoom.us/oauth/authorize?response_type=code&client_id=${t.clientId}&state=${encodeURIComponent(window.location.href)}/redirect&redirect_uri=${encodeURIComponent(`${i.api}/redirect`)}`,n=window.open(r,"zoom","width=400,height=609,toolbar=off"),f=setInterval(()=>{if(n.closed){clearInterval(f);let d={},p=!1;const u=localStorage.getItem("__zoom");if(u&&(p=!0,d=JSON.parse(u),localStorage.removeItem("__zoom")),!d.code||d.error||!d||!p){const g=d.error?`Cause: ${d.error}`:"";o({show:!0,msg:`${c("Authorization Failed","bit-integrations")} ${g}. ${c("please try again","bit-integrations")}`}),s(!1)}else{const g=h({},t);g.accountServer=d["accounts-server"],$(d,g,e,l,s,o,i)}}},500)},$=(t,e,a,l,s,o,i)=>{const r=h({},t);r.clientId=e.clientId,r.clientSecret=e.clientSecret,r.redirectURI=`${i.api}/redirect`,_(r,"zoom_webinar_generate_token").then(n=>n).then(n=>{if(n&&n.success){const f=h({},e);f.tokenDetails=n.data,a(f),l(!0),o({show:!0,msg:c("Authorized Successfully","bit-integrations")})}else n&&n.data&&n.data.data||!n.success&&typeof n.data=="string"?o({show:!0,msg:`${c("Authorization failed Cause:","bit-integrations")}${n.data.data||n.data}. ${c("please try again","bit-integrations")}`}):o({show:!0,msg:c("Authorization failed. please try again","bit-integrations")});s(!1)})},D=t=>!((t.field_map?t.field_map.filter(a=>!a.formField&&!a.zoomWebinarConf):[]).length>0),q=t=>{const e=t==null?void 0:t.zoomWebinarFields.filter(a=>a.required===!0);return e.length>0?e.map(a=>({formField:"",zoomField:a.key})):[{formField:"",zoomField:""}]};export{v as a,D as c,q as g,z as h,R as s,A as z};
