"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),z=require("@aplus-frontend/antdv"),L=require("@aplus-frontend/utils"),W=require("lodash-unified");require("../config-provider/index.js");const _=require("./style/index.js"),l=require("./utils/index.js"),q=require("../config-provider/hooks/use-namespace.js"),P=72,S=300,w=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 m=e.useSlots(),t=f,{b:i}=q.useNamespace("ap-action-button"),y=_.default("ap-action-button"),a=e.ref(!1),b=e.computed(()=>t.borderLinkColor||"var(--ap-button-border-link-color)"),u=e.computed(()=>t.type==="borderLink"&&!t.disabled?b.value:void 0),s=e.computed(()=>l.transferOpacityColor(u.value)),v=e.computed(()=>{let o=typeof t.minWidth=="boolean"?t.minWidth?P:void 0:t.minWidth;return l.getPxStr(o)}),h=e.computed(()=>(t.type==="borderLink"?"default":t.type)||"default"),c=e.computed(()=>t.loading??a.value??!1),d=e.computed(()=>t.lazy===!0?S:typeof t.lazy=="number"&&t.lazy>=0?t.lazy:0),g=e.useAttrs(),k=e.computed(()=>{const o=W.omit(t,["type","borderLinkColor","minWidth","onClick","loading"]);return{...g,...o,type:h.value,onClick:C,loading:c.value}});async function C(o){if(c.value)return;const r=l.isAsynchronous(t.onClick,o),p=Date.now();try{r&&(a.value=!0,await r)}finally{if(r){const n=Date.now()-p;n<d.value&&await L.wait(d.value-n),a.value=!1}}}return(o,r)=>(e.openBlock(),e.createBlock(e.unref(z.Button),e.mergeProps({class:{[e.unref(i)()]:!0,[`${e.unref(i)()}-border-link`]:s.value,[`${e.unref(y)}`]:!0}},k.value,{style:{color:u.value,minWidth:v.value,"--button-border-color":s.value}}),e.createSlots({_:2},[e.renderList(m,(p,n)=>({name:n,fn:e.withCtx(B=>[e.renderSlot(o.$slots,n,e.normalizeProps(e.guardReactiveProps(B||{})))])}))]),1040,["class","style"]))}});exports.default=w;
