import{d as h,a4 as S,c,r as _,m as d,aO as k,aP as B,w,L as x,o as f,f as M,x as m,z as W,y as z,R as t,G as q,W as F,b as I,K as O,S as N,_ as R}from"./index-t2KKsw-3.js";import{W as T}from"./WdsDropdownMenu-KNde-rRu.js";import"./WdsCheckbox-CkRWq0Pz.js";const V=h({__name:"SharedCopyClipboardButton",props:{label:{type:String,required:!1,default:""},value:{type:String,required:!1,default:""},options:{type:Array,required:!1,default:()=>[]}},setup(o){const s=o,{copy:r,copied:l,isSupported:v}=S(),e=c(()=>s.options.length===0),y=c(()=>{if(e.value)return l.value?"Copied to clipboard":s.label}),a=_(!1),n=d("trigger"),i=d("menu"),{floatingStyles:b}=k(n,i,{placement:"bottom-end"}),u=B(n);w(u,()=>{u.value||x().then(()=>{a.value=!1})},{immediate:!0});async function C(){if(e.value){r(s.value);return}a.value=!a.value}function g(p){r(p),a.value=!1}return(p,A)=>(f(),M("div",{ref_key:"trigger",ref:n,class:"SharedCopyClipboardButton"},[m(F,{variant:"tertiary",size:"smallIcon",class:q(["button",{copied:t(l)}]),disabled:!t(v),"aria-label":e.value?o.label||"Copy to clipboard":"Open options","aria-haspopup":e.value?void 0:"menu","aria-expanded":e.value?void 0:String(a.value),"data-writer-tooltip":y.value,"data-writer-tooltip-placement":"top","data-writer-unselectable":"true",onClick:C},{default:W(()=>[m(z,{name:t(l)?"check":"clipboard"},null,8,["name"])]),_:1},8,["class","disabled","aria-label","aria-haspopup","aria-expanded","data-writer-tooltip"]),!e.value&&a.value?(f(),I(T,{key:0,ref_key:"menu",ref:i,class:"menu",options:o.options,style:O(t(b)),onSelect:g},null,8,["options","style"])):N("",!0)],512))}}),K=R(V,[["__scopeId","data-v-c91d971d"]]);export{K as default};
