"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),B=require("@aplus-frontend/antdv"),W=require("@aplus-frontend/utils"),z=require("lodash-unified");require("../config-provider/index.js");const L=require("./style/index.js"),p=require("./utils/index.js"),q=require("../config-provider/hooks/use-namespace.js"),_=72,w=300,P=e.defineComponent({__name:"ap-button",props:{prefixCls:{},htmlType:{},shape:{},size:{},loading:{type:[Boolean,Object],default:void 0},disabled:{type:Boolean},ghost:{type:Boolean},block:{type:Boolean},danger:{type:Boolean},icon:{},href:{},target:{},title:{},onMousedown:{},autoInsertSpace:{type:Boolean},iconPosition:{},color:{},variant:{},type:{default:"default"},borderLinkColor:{},minWidth:{type:[Boolean,Number,String],default:!1},lazy:{type:[Boolean,Number],default:!0},onClick:{}},setup(f){const y=e.useSlots(),t=f,{b:i}=q.useNamespace("ap-action-button"),m=L.default("ap-action-button"),a=e.ref(!1),b=e.computed(()=>t.borderLinkColor||"var(--ap-button-border-link-color)"),l=e.computed(()=>t.type==="borderLink"&&!t.disabled?b.value:void 0),u=e.computed(()=>p.transferOpacityColor(l.value)),v=e.computed(()=>t.minWidth===!0?`${_}px`:typeof t.minWidth=="number"?`${t.minWidth}px`:typeof t.minWidth=="string"?t.minWidth:void 0),h=e.computed(()=>(t.type==="borderLink"?"default":t.type)||"default"),s=e.computed(()=>t.loading??a.value??!1),c=e.computed(()=>t.lazy===!0?w:typeof t.lazy=="number"&&t.lazy>=0?t.lazy:0);function g(){const o=z.omit(t,["type","borderLinkColor","minWidth","onClick","loading"]);return o?{...o,type:h.value,onclick:k}:{}}async function k(o){if(s.value)return;const r=p.isAsynchronous(t.onClick,o),d=Date.now();try{r&&(a.value=!0,await r)}finally{if(r){const n=Date.now()-d;n<c.value&&await W.wait(c.value-n),a.value=!1}}}return(o,r)=>(e.openBlock(),e.createBlock(e.unref(B.Button),e.mergeProps({class:{[e.unref(i)()]:!0,[`${e.unref(i)()}-border-link`]:u.value,[`${e.unref(m)}`]:!0}},{...o.$attrs,...g()},{style:{color:l.value,minWidth:v.value,"--button-border-color":u.value},loading:s.value}),e.createSlots({_:2},[e.renderList(y,(d,n)=>({name:n,fn:e.withCtx(C=>[e.renderSlot(o.$slots,n,e.normalizeProps(e.guardReactiveProps(C||{})))])}))]),1040,["class","style","loading"]))}});exports.default=P;
