import { WebSocialShareWhatsappAttributes } from '../types/web-social-share-attributes' ; import { staticOpenNewWindow , isMobile , shareEncodedUrl } from './utils' ; export const whatsapp = async ( attrs ) => { const mobile = isMobile ( ) ; let urlString = mobile ? 'https://api.whatsapp.com/send?text=' : 'https://web.whatsapp.com/send?text=' ; if ( attrs . socialShareText ) { urlString += encodeURIComponent ( attrs . socialShareText ) + '%0A' ; } urlString += shareEncodedUrl ( attrs . socialShareUrl ) ; if ( mobile ) { staticOpenNewWindow ( urlString ) ; } else { window . open ( urlString , 'WhatsApp' , 'toolbar=0,status=0,resizable=yes,width=' + attrs . socialSharePopupWidth + ',height=' + attrs . socialSharePopupHeight + ',top=' + ( window . innerHeight - attrs . socialSharePopupHeight ) / 2 + ',left=' + ( window . innerWidth - attrs . socialSharePopupWidth ) / 2 ) ; } } ;