{"version":3,"file":"social_share-DnSpBBqb.js","sources":["../../../app/javascript/apps/customer_page/services/social_share.js"],"sourcesContent":["export default {\n share,\n visit,\n follow,\n}\n\nconst FB_SHARE_URL = 'https://www.facebook.com/dialog/share?'\nconst TWITTER_SHARE_URL = 'https://twitter.com/intent/tweet?'\n\n// This window option helps display all elements for sharing actions with the minimum window size possible\nconst SHARE_SOCIAL_WINDOW_OPTION = {\n default: 'width=1500,height=1500,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,location=no',\n facebook: 'width=500,height=700,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,location=no',\n twitter: 'width=600,height=350,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,location=no',\n whatsapp: 'width=750,height=600,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,location=no',\n instagram: 'width=500,height=700,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,location=no',\n} \n\nfunction visit(url) {\n window.open(url, '_blank')\n}\n\nfunction share({socialName, url, textContent}) {\n const href = buildShareSocialUrl(socialName, url, textContent)\n const window_option = SHARE_SOCIAL_WINDOW_OPTION[socialName] || SHARE_SOCIAL_WINDOW_OPTION['default']\n window.open(href, '_blank', window_option)\n}\n\nfunction follow({socialName, url}) {\n const href = buildFollowSocialUrl(socialName, url)\n const window_option = SHARE_SOCIAL_WINDOW_OPTION[socialName] || SHARE_SOCIAL_WINDOW_OPTION['default']\n window.open(href, '_blank', window_option)\n}\n\n\nfunction buildShareSocialUrl(socialName, url, textContent) {\n switch(socialName) {\n case 'facebook':\n const appId = frcp.wishlist?.socialAppIds.facebook || frcp.loyalty?.socialAppIds.facebook\n if (!appId) return console.error('Facebook App Id not found! Skip build share Facebook url')\n\n return facebookUrl(appId, url)\n case 'twitter':\n return twitterUrl(url, textContent)\n case 'whatsapp':\n return whatsappUrl(url, textContent)\n }\n}\n\nfunction buildFollowSocialUrl(socialName, url) {\n switch (socialName) {\n case 'instagram':\n return instagramUrl(url)\n\n }\n}\n\n// Facebook share dialog with quote is deprecated: \n// https://developers.facebook.com/support/bugs/734680371318112/?comment_id=743056360480513\nfunction facebookUrl(appId, url) {\n let params = {\n app_id: appId,\n display: 'popup',\n href: url,\n }\n\n return `${FB_SHARE_URL}${query(params)}`\n}\n\nfunction twitterUrl(url, textContent) {\n let params = {\n url: url,\n text: textContent,\n }\n \n return `${TWITTER_SHARE_URL}${query(params)}`\n}\n\nfunction whatsappUrl(url, textContent) {\n const host = window.innerWidth <= 767 ? 'whatsapp://' : 'https://web.whatsapp.com/'\n\n return `${host}send?text=${textContent}: ${url}`\n}\n\nfunction instagramUrl(url) {\n return `${url}`;\n}\n\n\nfunction query(params) {\n const array = [];\n\n for (let key in params) {\n array.push(encodeURIComponent(key) + \"=\" + encodeURIComponent(params[key]));\n }\n\n return array.join(\"&\");\n}\n"],"names":["socialShare","share","visit","follow","FB_SHARE_URL","TWITTER_SHARE_URL","SHARE_SOCIAL_WINDOW_OPTION","url","socialName","textContent","href","buildShareSocialUrl","window_option","buildFollowSocialUrl","_a","_b","appId","facebookUrl","twitterUrl","whatsappUrl","instagramUrl","query","params","array","key"],"mappings":"AAAA,MAAeA,EAAA,CACb,MAAAC,EACA,MAAAC,EACA,OAAAC,CACF,EAEMC,EAAe,yCACfC,EAAoB,oCAGpBC,EAA6B,CACjC,QAAS,mGACT,SAAU,iGACV,QAAS,iGACT,SAAU,iGACV,UAAW,gGACb,EAEA,SAASJ,EAAMK,EAAK,CAClB,OAAO,KAAKA,EAAK,QAAQ,CAC3B,CAEA,SAASN,EAAM,CAAC,WAAAO,EAAY,IAAAD,EAAK,YAAAE,CAAW,EAAG,CAC7C,MAAMC,EAAOC,EAAoBH,EAAYD,EAAKE,CAAW,EACvDG,EAAgBN,EAA2BE,CAAU,GAAKF,EAA2B,QAC3F,OAAO,KAAKI,EAAM,SAAUE,CAAa,CAC3C,CAEA,SAAST,EAAO,CAAC,WAAAK,EAAY,IAAAD,CAAG,EAAG,CACjC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