import{withInstall as e}from"../_util/type.mjs";import{useLocaleReceiver as t}from"../locale/LocaleReceiver.mjs";import{useToken as n}from"../theme/internal.mjs";import r from"../config-provider/hooks/useConfigInject.mjs";import i from"../button/index.mjs";import a from"../spin/index.mjs";import{qrcodeProps as o}from"./interface.mjs";import{QRCodeCanvas as s,QRCodeSVG as c}from"./QRCode.mjs";import l from"./style/index.mjs";import{Fragment as u,computed as d,createVNode as f,defineComponent as p,ref as m}from"vue";import{ReloadOutlined as h}from"@antsoo-lib/icons";var g=e(p({name:`AQrcode`,inheritAttrs:!1,props:o(),emits:[`refresh`],setup(e,{emit:o,attrs:p,expose:g}){let[_]=t(`QRCode`),{prefixCls:v}=r(`qrcode`,e),[y,b]=l(v),[,x]=n(),S=m();g({toDataURL:(e,t)=>S.value?.toDataURL(e,t)});let C=d(()=>{let{value:t,icon:n=``,size:r=160,iconSize:i=40,color:a=x.value.colorText,bgColor:o=`transparent`,errorLevel:s=`M`}=e,c={src:n,x:void 0,y:void 0,height:i,width:i,excavate:!0};return{value:t,size:r-(x.value.paddingSM+x.value.lineWidth)*2,level:s,bgColor:o,fgColor:a,imageSettings:n?c:void 0}});return()=>{let t=v.value;return y(f(`div`,{...p,style:[p.style,{width:`${e.size}px`,height:`${e.size}px`,backgroundColor:C.value.bgColor}],class:[b.value,t,{[`${t}-borderless`]:!e.bordered}]},[e.status!==`active`&&f(`div`,{class:`${t}-mask`},[e.status===`loading`&&f(a,null,null),e.status===`expired`&&f(u,null,[f(`p`,{class:`${t}-expired`},[_.value.expired]),f(i,{type:`link`,onClick:e=>o(`refresh`,e)},{default:()=>[_.value.refresh],icon:()=>f(h,null,null)})]),e.status===`scanned`&&f(`p`,{class:`${t}-scanned`},[_.value.scanned])]),e.type===`canvas`?f(s,{ref:S,...C.value},null):f(c,C.value,null)]))}}}));export{g as default};