import{be as u,c3 as a}from"./app-q0jdcHwC.js";const p={baidu:"http://cang.baidu.com/do/add?iu=@u&it=@t",bluesky:"https://bsky.app/intent/compose?text=@t%0A@u",buffer:"https://bufferapp.com/add?text=@t&url=@u",email:"mailto:?subject=@t&body=@u%0D%0A@d",evernote:"https://www.evernote.com/clip.action?url=@u&title=@t",facebook:"https://www.facebook.com/sharer/sharer.php?u=@u&title=@t&description=@d&quote=@q&hashtag=@h",flipboard:"https://share.flipboard.com/bookmarklet/popout?v=2&url=@u&title=@t",hackernews:"https://news.ycombinator.com/submitlink?u=@u&t=@t",instapaper:"http://www.instapaper.com/edit?url=@u&title=@t&description=@d",line:"http://line.me/R/msg/text/?@t%0D%0A@u%0D%0A@d",linkedin:"https://www.linkedin.com/sharing/share-offsite/?url=@u",messenger:"fb-messenger://share/?link=@u",odnoklassniki:"https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=@u&st.comments=@t",pinterest:"https://pinterest.com/pin/create/button/?url=@u&media=@m&description=@t",pocket:"https://getpocket.com/save?url=@u&title=@t",quora:"https://www.quora.com/share?url=@u&title=@t",reddit:"https://www.reddit.com/submit?url=@u&title=@t",skype:"https://web.skype.com/share?url=@t%0D%0A@u%0D%0A@d",sms:"sms:?body=@t%0D%0A@u%0D%0A@d",stumbleupon:"https://www.stumbleupon.com/submit?url=@u&title=@t",telegram:"https://t.me/share/url?url=@u&text=@t%0D%0A@d",tumblr:"https://www.tumblr.com/share/link?url=@u&name=@t&description=@d",twitter:"https://twitter.com/intent/tweet?text=@t&url=@u&hashtags=@h&via=@tu",x:"https://x.com/intent/post?text=@t&url=@u&hashtags=@h&via=@tu",viber:"viber://forward?text=@t%0D%0A@u%0D%0A@d",vk:"https://vk.com/share.php?url=@u&title=@t&image=@m&noparse=true",weibo:"http://service.weibo.com/share/share.php?url=@u&title=@t&pic=@m",whatsapp:"https://api.whatsapp.com/send?text=@t%0D%0A@u%0D%0A@d",wordpress:"https://wordpress.com/press-this.php?u=@u&t=@t&s=@d&i=@m",xing:"https://www.xing.com/social/share/spi?op=share&url=@u&title=@t",yammer:"https://www.yammer.com/messages/new?login=true&status=@t%0D%0A@u%0D%0A@d",threads:"https://www.threads.net/intent/post?url=@u&text=@t"},i=()=>typeof window<"u",h=(e,t)=>{if(!i())return null;const r=window.innerWidth||document.documentElement.clientWidth||window.screenX,s=window.innerHeight||document.documentElement.clientHeight||window.screenY,n=r/window.screen.availWidth,o=(r-e)/2/n+(window.screenLeft!==void 0?window.screenLeft:window.screenX);return{top:(s-t)/2/n+(window.screenTop!==void 0?window.screenTop:window.screenY),left:o,width:e,height:t}},w=e=>Object.entries(e).map(([t,r])=>r?`${t}=${r}`:"").filter(t=>t).join(","),l=e=>{if(!i())return null;if(e.substring(0,4)!=="http")return window.open(e,"_blank");const t=h(500,500);return t?window.open(e,"sharer",w(t)):null},c=(e,t)=>{const r=window.navigator.userAgent.toLowerCase();return e==="sms"&&(r.includes("iphone")||r.includes("ipad"))?t[e].replace(":?",":&"):t[e]},d=(e,t)=>t==="facebook"&&e&&e.length>0?`%23${e.split(",")[0]}`:e,m=()=>({network:"",url:"",title:"",description:"",quote:"",hashtags:"",twitterUser:"",media:""}),g=e=>{const t=m();return Object.fromEntries(Object.keys(t).map(r=>{let s=a(e[r])||t[r];return s=r==="hashtags"?d(s,r):encodeURIComponent(s),[r,s]}))},b=(e,t)=>e.replace(/@tu/g,t.twitterUser).replace(/@u/g,t.url).replace(/@t/g,t.title).replace(/@d/g,t.description).replace(/@q/g,t.quote).replace(/@h/g,t.hashtags).replace(/@m/g,t.media),f=()=>{const e=Object.assign({},p,u("share-networks",{})),t=r=>{const s=g(r);if(!s.network||!e[s.network])throw new Error(`Network ${s.network} does not exist`);let n=c(s.network,e);return s.network==="twitter"&&(s.hashtags.length||(n=n.replace("&hashtags=@h","")),s.twitterUser.length||(n=n.replace("&via=@tu",""))),b(n,s)};return{getSharingLink:t,shareLink:r=>{const s=t(r);return l(s)}}};export{f as v};
