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