!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function e(){const e={default:{sms:"SMS",messenger:"Messenger",whatsapp:"WhatsApp",twitter:"Twitter",linkedin:"Linkedin",telegram:"Telegram",facebook:"Facebook",skype:"Skype"},zh:{shareTitle:"分享",cancel:"取消",copy:"複製連結",print:"列印",email:"E-mail",selectSms:"選擇聯絡人"},pt:{shareTitle:"Compartilhar",cancel:"Cancelar",copy:"Copiar",print:"Imprimir",email:"E-mail",selectSms:"Selecione um contato"},en:{shareTitle:"Share",cancel:"Cancel",copy:"Copy",print:"Print",email:"E-mail",selectSms:"Pick a contact"},es:{shareTitle:"Compartir",cancel:"Cancelar",copy:"Copiar",print:"Imprimir",email:"Correo",selectSms:"Seleccionar un contacto"},de:{shareTitle:"Teilen",cancel:"Abbrechen",copy:"Kopieren",print:"Drucken",email:"E-mail",selectSms:"Wählen Sie einen Kontakt aus"},nl:{shareTitle:"Delen",cancel:"Annuleren",copy:"Kopiëren",print:"Printen",email:"E-mail",selectSms:"Selecteer een contact"}};let t=navigator.userAgent.match(/Android/i),n=navigator.userAgent.match(/iPhone|iPad|iPod/i),o=navigator.userAgent.match(/iPhone|iPad|iPod|Macintosh/i);const i=!(n||t),a=o?'':'',l='',s='',r='',c='',h='',d='',p='',m='',f='',u='',w='';return function(t={},n={}){return new Promise((g,y)=>{t.title&&"string"==typeof t.title&&t.text&&"string"==typeof t.text||y("Invalid Params");const{title:v,url:b,fbId:P,hashtags:k}=t,x={copy:!0,print:!0,email:!0,sms:!0,messenger:!0,facebook:!0,whatsapp:!0,twitter:!0,linkedin:!0,telegram:!0,skype:!0,language:"en",...n},A={...e.default,...e[x.language]?e[x.language]:e[navigator.language]||e[navigator.language.substr(0,2).toLowerCase()]||e.en},I=t.text||v;function $(){const e=()=>{S.removeEventListener("transitionend",e),document.body.removeChild(S)},t=()=>{z.removeEventListener("transitionend",t),document.body.removeChild(z),document.head.removeChild(document.querySelector("#shareAPIPolyfill-style")),document.removeEventListener("keyup",E)};S.classList.remove("visible"),z.classList.remove("visible"),S.addEventListener("transitionend",e),z.addEventListener("transitionend",t)}!function(e){var t=e,n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t)),o.id="shareAPIPolyfill-style",n.appendChild(o)}(` \n#shareAPIPolyfill-backdrop,#shareAPIPolyfill-container{opacity:0;pointer-events:none;position:fixed;left:0;top:0;bottom:0;right:0;margin:auto;width:100%;height:100%;will-change:opacity; z-index: 99999;}#shareAPIPolyfill-backdrop{transition:opacity linear 250ms;background-color:rgba(0,0,0,.6)}#shareAPIPolyfill-container{background-color:#f9f9f9;top:auto;max-width:400px;height:auto;transition-property:transform,opacity;transition-timing-function:linear;transition-duration:250ms;transition-delay:150ms;transform:translateY(100%);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",arial,sans-serif,"Microsoft JhengHei"}#shareAPIPolyfill-backdrop.visible,#shareAPIPolyfill-container.visible{opacity:1;pointer-events:all}#shareAPIPolyfill-container.visible{transform:translateY(0)}#shareAPIPolyfill-container .shareAPIPolyfill-header{background:#EEE}#shareAPIPolyfill-container .shareAPIPolyfill-header .shareAPIPolyfill-icons-container{display:flex}#shareAPIPolyfill-container .shareAPIPolyfill-header-title{background-color:#E0E0E0;padding:10px 18px;color:#424242;font-weight:600}#shareAPIPolyfill-container .shareAPIPolyfill-body{border-top:solid 1px #EEE}#shareAPIPolyfill-container .shareAPIPolyfill-footer{width:100%;display:block;border:none;transition:opacity ease-in 250ms;border-top:solid 1px #EEE;background-color:#EEE;text-align:center;padding:10px;font-size:13px;cursor:pointer;opacity:.5}#shareAPIPolyfill-container .shareAPIPolyfill-footer:hover{opacity:1}#shareAPIPolyfill-container .shareAPIPolyfill-icons-container{display:flex;flex-wrap:wrap}#shareAPIPolyfill-container .tool-icon{border:none;display:inline-block;width:25%;box-sizing:border-box;font-weight:400;font-size:12px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;cursor:pointer;background-color:transparent;padding:20px 0}#shareAPIPolyfill-container .tool-icon:hover{box-shadow:inset 0 0 20px rgba(0,0,0,.125)}#shareAPIPolyfill-container .the-icon-title{padding-top:10px;display:block}.shareAPIPolyfill-header-title .the-icon{display:inline-block;height:20px;width:20px;padding-right:5px;vertical-align:${o?"-2px":"-4px"}}.shareAPIPolyfill-icons-container.web-share-title .tool-icon .the-icon,.shareAPIPolyfill-icons-container.web-share-body .tool-icon .the-icon{display:block;margin:auto;width:42px;height:36px}.shareAPIPolyfill-icons-container.web-share-title .tool-icon .the-icon{height:24px}.shareAPIPolyfill-icons-container .hidden{display:none!important}[web-sharer-theme="dark"] #shareAPIPolyfill-container{background-color:#212121}[web-sharer-theme="dark"] #shareAPIPolyfill-container .shareAPIPolyfill-header{background:#212121}[web-sharer-theme="dark"] #shareAPIPolyfill-container .shareAPIPolyfill-header-title{background-color:#212121;color:white}[web-sharer-theme="dark"] #shareAPIPolyfill-container .shareAPIPolyfill-body{border-top:solid 1px #212121}[web-sharer-theme="dark"] #shareAPIPolyfill-container .shareAPIPolyfill-footer{color:white;border-top:solid 1px #212121;background-color:#212121}[web-sharer-theme="dark"] #shareAPIPolyfill-container .the-icon-title{color:white}\n`);const S=document.createElement("div"),z=document.createElement("div");function E(e){27===e.keyCode&&$()}S.id="shareAPIPolyfill-backdrop",z.id="shareAPIPolyfill-container",z.setAttribute("tabindex","0"),z.innerHTML=`\n
\n \n`,S.addEventListener("click",()=>{$()}),!1!==x.skype&&function(e,t,n){e.loadSkypeWebSdkAsync=e.loadSkypeWebSdkAsync||function(e){var o,i=t.getElementsByTagName(n)[0];t.getElementById(e.id)||((o=t.createElement(n)).id=e.id,o.src=e.scriptToLoad,o.onload=e.callback,i.parentNode.insertBefore(o,i))},e.loadSkypeWebSdkAsync({scriptToLoad:"https://swx.cdn.skype.com/shared/v/latest/skypewebsdk.js",id:"skype_web_sdk"})}(window,document,"script"),requestAnimationFrame(e=>{document.body.appendChild(S),document.body.appendChild(z),document.addEventListener("keyup",E),Array.from(z.querySelectorAll(".tool-icon")).forEach(e=>{e.addEventListener("click",t=>{const n=I+": "+b;switch(e.dataset.tool){case"copy":navigator.clipboard.writeText(b);break;case"print":self.print();break;case"email":window.open("mailto:?subject="+v+"&body="+b);break;case"sms":location.href=`sms:${A.selectSms}?&body=${v}: ${b}`;break;case"messenger":window.open("http://www.facebook.com/dialog/send?app_id="+P+"&display=popup&href="+encodeURIComponent(b)+"&link="+encodeURIComponent(b)+"&redirect_uri="+encodeURIComponent(b)+""e="+v+": "+b);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${b}`);break;case"whatsapp":window.open((i?"https://api.whatsapp.com/send?text=":"whatsapp://send?text=")+n);break;case"twitter":window.open(`http://twitter.com/share?text=${I}&url=${b}&hashtags=${k||""}`);break;case"linkedin":window.open(`https://www.linkedin.com/shareArticle?mini=true&url=${b}&title=${v}&summary=${I}&source=LinkedIn`);break;case"telegram":window.open(i?"https://telegram.me/share/msg?url="+b+"&text="+I:"tg://msg?text="+n)}g(),$()})}),z.querySelector(".shareAPIPolyfill-footer").addEventListener("click",$),requestAnimationFrame(()=>{S.classList.add("visible"),z.classList.add("visible")}),document.getElementById("shareAPIPolyfill-container").focus()})})}}var t=function(){function t(e){var t=this;switch(void 0===e&&(e="auto"),this.nativeSupport=navigator.share,this.mode=e,this.nativeSupport||this.polyfill(),this.mode){case"auto":!function(e){var t=window.matchMedia("(prefers-color-scheme: dark)").matches,n=window.matchMedia("(prefers-color-scheme: light)").matches,o=window.matchMedia("(prefers-color-scheme: no-preference)").matches,i=!t&&!n&&!o;window.matchMedia("(prefers-color-scheme: dark)").addListener(function(t){return t.matches&&e("dark")}),window.matchMedia("(prefers-color-scheme: light)").addListener(function(t){return t.matches&&e("light")}),t&&e("dark");n&&e("light");if(o||i){var a=new Date,l=a.getHours();e(l<4||l>=16?"dark":"light")}}(function(e){return t.enableTheme(e)});break;case"dark":this.enableTheme("dark");break;case"light":this.enableTheme("light")}}return t.prototype.enableTheme=function(e){document.body.setAttribute("web-sharer-theme",e)},t.prototype.share=function(e){this.nativeSupport?navigator.share(e):this.polyfilledSharer(e)},t.prototype.polyfill=function(){this.polyfilledSharer=new e},t}();var n=function(){return function(e,t){var n=this;if(this.sharer=t,e.closest(".w-dyn-item")){var o=e.closest(".w-dyn-item");o.querySelector('[web-share="title"]')?this.title=o.querySelector('[web-share="title"]').textContent||"":o.querySelector("h1, h2, h3, h4, h5, h6")&&(this.title=o.querySelector("h1, h2, h3, h4, h5, h6").textContent||""),o.querySelector('[web-share="description"]')?this.text=o.querySelector('[web-share="description"]').textContent||"":o.querySelector("p")&&(this.text=o.querySelector("p").textContent||""),this.url="#"==e.getAttribute("href")?document.location.href:e.getAttribute("href")||""}else{this.title=document.title;var i=document.querySelector('meta[name="description"]');this.text=i&&i.getAttribute("content")||"",this.url="#"==e.getAttribute("href")?document.location.href:e.getAttribute("href")||""}this.url?e.addEventListener("click",function(e){e.preventDefault();var t={url:n.url||""};""!=n.title&&(t.title=n.title),""!=n.text&&(t.text=n.text),n.sharer.share(t)}):e.remove()}}(),o=null;document.querySelectorAll("[udesly-web-share]").forEach(function(e){var i=e.getAttribute("udesly-web-share")||"auto";"auto"!==i&&"dark"!==i&&"light"!==i&&(i="auto"),o||(o=new t(i)),new n(e,o)})}); //# sourceMappingURL=udesly-web-share-api.1.0.2.umd.js.map