You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
2.8 KiB

import{r as y,ae as P,af as R,ag as k,ah as g,$ as A,W as L,ai as C,Y as q,aj as G,ak as $}from"./index-BLqts8WY.js";function T(e){return R()?(k(e),!0):!1}const w=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const B=Object.prototype.toString,D=e=>B.call(e)==="[object Object]",F=()=>{};function I(e){let t;function n(){return t||(t=e()),t}return n.reset=async()=>{const a=t;t=void 0,a&&await a},n}function _(e){return Array.isArray(e)?e:[e]}function N(e,t,n={}){const{immediate:a=!0}=n,i=y(!1);let o=null;function l(){o&&(clearTimeout(o),o=null)}function d(){i.value=!1,l()}function f(...c){l(),i.value=!0,o=setTimeout(()=>{i.value=!1,o=null,e(...c)},g(t))}return a&&(i.value=!0,w&&f()),T(d),{isPending:P(i),start:f,stop:d}}const V=w?window:void 0,E=w?window.navigator:void 0;function Y(e){var t;const n=g(e);return(t=n==null?void 0:n.$el)!=null?t:n}function W(...e){let t,n,a,i;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,a,i]=e,t=V):[t,n,a,i]=e,!t)return F;n=_(n),a=_(a);const o=[],l=()=>{o.forEach(r=>r()),o.length=0},d=(r,s,m,v)=>(r.addEventListener(s,m,v),()=>r.removeEventListener(s,m,v)),f=L(()=>[Y(t),g(i)],([r,s])=>{if(l(),!r)return;const m=D(s)?{...s}:s;o.push(...n.flatMap(v=>a.map(b=>d(r,v,b,m))))},{immediate:!0,flush:"post"}),c=()=>{f(),l()};return T(c),c}function z(){const e=y(!1),t=G();return t&&q(()=>{e.value=!0},t),e}function j(e){const t=z();return A(()=>(t.value,!!e()))}function x(e,t={}){const{controls:n=!1,navigator:a=E}=t,i=j(()=>a&&"permissions"in a),o=C(),l=typeof e=="string"?{name:e}:e,d=C(),f=()=>{var r,s;d.value=(s=(r=o.value)==null?void 0:r.state)!=null?s:"prompt"};W(o,"change",f);const c=I(async()=>{if(i.value){if(!o.value)try{o.value=await a.permissions.query(l)}catch{o.value=void 0}finally{f()}if(n)return $(o.value)}});return c(),n?{state:d,isSupported:i,query:c}:d}function J(e={}){const{navigator:t=E,read:n=!1,source:a,copiedDuring:i=1500,legacy:o=!1}=e,l=j(()=>t&&"clipboard"in t),d=x("clipboard-read"),f=x("clipboard-write"),c=A(()=>l.value||o),r=y(""),s=y(!1),m=N(()=>s.value=!1,i,{immediate:!1});function v(){l.value&&S(d.value)?t.clipboard.readText().then(u=>{r.value=u}):r.value=O()}c.value&&n&&W(["copy","cut"],v);async function b(u=g(a)){c.value&&u!=null&&(l.value&&S(f.value)?await t.clipboard.writeText(u):M(u),r.value=u,s.value=!0,m.start())}function M(u){const p=document.createElement("textarea");p.value=u??"",p.style.position="absolute",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),p.remove()}function O(){var u,p,h;return(h=(p=(u=document==null?void 0:document.getSelection)==null?void 0:u.call(document))==null?void 0:p.toString())!=null?h:""}function S(u){return u==="granted"||u==="prompt"}return{isSupported:c,text:r,copied:s,copy:b}}export{J as u};