import{r as o,L as h,B as i,j as e,a as k,b as g,c as R,D as C}from"./index.Bzd-hLkw.js";import{c as L}from"./createDownloadLinkElement.ZaXNnPK4.js";function x(d){const{disabled:c,element:l,widgetMgr:u,endpoints:t,fragmentId:f}=d,{help:m,label:B,icon:w,ignoreRerun:D,type:s,url:r}=l,{libConfig:{enforceDownloadInNewTab:p=!1}}=o.useContext(h);let n=i.SECONDARY;s==="primary"?n=i.PRIMARY:s==="tertiary"&&(n=i.TERTIARY);const a=o.useMemo(()=>t.buildDownloadUrl(r),[t,r]);o.useEffect(()=>{t.checkSourceUrlResponse(a,"Download Button")},[a,t]);const b=()=>{D||u.setTriggerValue(l,{fromUi:!0},f),L({filename:"",url:a,enforceDownloadInNewTab:p}).click()};return e("div",{className:"stDownloadButton","data-testid":"stDownloadButton",children:e(k,{help:m,containerWidth:!0,children:e(g,{kind:n,size:R.SMALL,disabled:c,onClick:b,containerWidth:!0,children:e(C,{icon:w,label:B})})})})}const A=o.memo(x);export{A as default};
