// @bun
var{defineProperty:G,getOwnPropertyNames:J,getOwnPropertyDescriptor:K}=Object,L=Object.prototype.hasOwnProperty;function N(j){return this[j]}var U=(j)=>{var q=(H??=new WeakMap).get(j),A;if(q)return q;if(q=G({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var B of J(j))if(!L.call(q,B))G(q,B,{get:N.bind(j,B),enumerable:!(A=K(j,B))||A.enumerable})}return H.set(j,q),q},H;var O=(j)=>j;function P(j,q){this[j]=O.bind(null,q)}var V=(j,q)=>{for(var A in q)G(j,A,{get:q[A],enumerable:!0,configurable:!0,set:P.bind(q,A)})};var W=(j,q)=>()=>(j&&(q=j(j=0)),q);var X=import.meta.require;function Q(){return typeof navigator<"u"&&"share"in navigator}function R(){return typeof navigator<"u"&&"canShare"in navigator}function I(){let j=Q(),q=R(),A=(z)=>{if(!j)return!1;if(!z)return!0;if(z.files&&z.files.length>0){if(!q)return!1;try{return navigator.canShare(z)}catch{return!1}}return!!(z.title||z.text||z.url)};return{isSupported:()=>j,isFileShareSupported:()=>q,canShare:A,share:async(z)=>{if(!j)return{success:!1,error:Error("Web Share API is not supported")};if(!z.title&&!z.text&&!z.url&&(!z.files||z.files.length===0))return{success:!1,error:Error("Share data must include at least one of: title, text, url, or files")};if(!A(z))return{success:!1,error:Error("This content cannot be shared on this device")};try{return await navigator.share(z),{success:!0}}catch(D){if(D instanceof Error&&D.name==="AbortError")return{success:!1,cancelled:!0};return{success:!1,error:D instanceof Error?D:Error(String(D))}}}}}async function E(j){return I().share(j)}async function Z(j,q,A){return E({url:j,title:q,text:A})}async function _(j,q){return E({text:j,title:q})}async function $(j,q,A){return E({files:j,title:q,text:A})}function v(j,q,A){return new File([j],q,{type:A||j.type})}async function w(j){if(typeof document>"u"||typeof location>"u")return{success:!1,error:Error("Not in browser environment")};return E({title:document.title,url:location.href,text:j})}async function F(j,q){let A=I();if(A.isSupported()&&A.canShare(j)){let z=await A.share(j);if(z.success||z.cancelled)return z}let B=j.url||j.text||j.title||"";if(!B)return{success:!1,error:Error("Nothing to copy")};try{if(await navigator.clipboard.writeText(B),q)alert(q);return{success:!0,usedFallback:!0}}catch(z){return{success:!1,error:z instanceof Error?z:Error(String(z)),usedFallback:!0}}}export{I as useShare,F as shareWithFallback,Z as shareURL,_ as shareText,$ as shareFiles,w as shareCurrentPage,E as share,v as createShareableFile};
