import{aj as t,aJ as e,k as o,E as a,e as i}from"./vendor-element-plus.js?ver=3.1.0";import{_ as s,I as n}from"./fc-bits-ui.js?ver=3.1.0";import{r as c,a as p,o as l,w as r,d,L as u}from"./vendor.js?ver=3.1.0";const m=s({name:"ItemCopier",components:{Icons:n,Check:t},props:{text:{type:String,required:!0},showViewButton:{type:Boolean,default:!1}},data:()=>({copy_success:!1}),computed:{copyTooltipText(){return this.copy_success?this.$t("Copied"):this.$t("Copy")},viewTooltipText(){return this.$t("View in new tab")}},methods:{copyItem(){this.copy_success=!1;const t=this.text;let e=!1;if(window.clipboardData&&window.clipboardData.setData)window.clipboardData.clipboardData.setData("Text",t),e=!0;else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){const a=document.createElement("textarea");a.textContent=t,a.style.position="fixed",document.body.appendChild(a),a.select();try{document.execCommand("copy"),e=!0}catch(o){console.warn("Copy to clipboard failed.",o),e=!1}finally{document.body.removeChild(a)}}e?(this.copy_success=!0,this.$notify({message:this.$t("Copied to your clipboard"),position:"bottom-right",customClass:"bottom_right",type:"success"}),setTimeout(()=>{this.copy_success=!1},2e3)):this.$notify({message:this.$t("Your Browser does not support JS copy. Please copy manually"),position:"bottom-right",customClass:"bottom_right",type:"error"})},openUrl(){if(this.text){const t=window.open(this.text,"_blank");t&&(t.opener=null)}}}},[["render",function(t,s,n,m,y,h){const b=c("Check"),w=a,f=c("Icons"),v=o,C=e,x=i;return l(),p(x,{size:"small",readonly:!0,"model-value":n.text,"aria-label":t.$t("Copyable item value"),class:"fc-item-copier-input"},{append:r(()=>[d(C,{content:h.copyTooltipText,placement:"top"},{default:r(()=>[d(v,{class:"copy-btn","native-type":"button","aria-label":h.copyTooltipText,onClick:h.copyItem},{default:r(()=>[y.copy_success?(l(),p(w,{key:0,"aria-hidden":"true"},{default:r(()=>[d(b)],void 0,!0),_:1})):(l(),p(f,{key:1,"icon-name":"duplicate","aria-hidden":"true"}))],void 0,!0),_:1},8,["aria-label","onClick"])],void 0,!0),_:1},8,["content"]),n.showViewButton?(l(),p(C,{key:0,content:h.viewTooltipText,placement:"top"},{default:r(()=>[d(v,{type:"primary",class:"view-btn","native-type":"button","aria-label":h.viewTooltipText,onClick:h.openUrl},{default:r(()=>[d(f,{"icon-name":"externalLink","aria-hidden":"true"})],void 0,!0),_:1},8,["aria-label","onClick"])],void 0,!0),_:1},8,["content"])):u("",!0)]),_:1},8,["model-value","aria-label"])}]]);export{m as I};
