import{defineComponent as D,inject as I,shallowRef as x,watch as k,provide as R,onMounted as K,onBeforeUnmount as U,createVNode as l}from"vue";import V from"@ant-design/icons-vue/BarsOutlined";import C from"@ant-design/icons-vue/LeftOutlined";import S from"@ant-design/icons-vue/RightOutlined";import O from"../_util/classNames.mjs";import G from"../_util/isNumeric.mjs";import J from"../_util/props-util/initDefaultProps.mjs";import{tuple as W}from"../_util/type.mjs";import n from"../_util/vue-types/index.mjs";import Q from"../config-provider/hooks/useConfigInject.mjs";import{SiderHookProviderKey as X,SiderCollapsedKey as Y}from"./injectionKey.mjs";const L={xs:"479.98px",sm:"575.98px",md:"767.98px",lg:"991.98px",xl:"1199.98px",xxl:"1599.98px",xxxl:"1999.98px"},Z=()=>({prefixCls:String,collapsible:{type:Boolean,default:void 0},collapsed:{type:Boolean,default:void 0},defaultCollapsed:{type:Boolean,default:void 0},reverseArrow:{type:Boolean,default:void 0},zeroWidthTriggerStyle:{type:Object,default:void 0},trigger:n.any,width:n.oneOfType([n.number,n.string]),collapsedWidth:n.oneOfType([n.number,n.string]),breakpoint:n.oneOf(W("xs","sm","md","lg","xl","xxl","xxxl")),theme:n.oneOf(W("light","dark")).def("dark"),onBreakpoint:Function,onCollapse:Function}),_=(()=>{let t=0;return(d="")=>(t+=1,`${d}${t}`)})(),ce=D({compatConfig:{MODE:3},name:"ALayoutSider",inheritAttrs:!1,props:J(Z(),{collapsible:!1,defaultCollapsed:!1,reverseArrow:!1,width:200,collapsedWidth:80}),emits:["breakpoint","update:collapsed","collapse"],setup(t,{emit:d,attrs:p,slots:v}){const{prefixCls:T}=Q("layout-sider",t),c=I(X,void 0),r=x(!!(t.collapsed!==void 0?t.collapsed:t.defaultCollapsed)),f=x(!1);k(()=>t.collapsed,()=>{r.value=!!t.collapsed}),R(Y,r);const y=(e,s)=>{t.collapsed===void 0&&(r.value=e),d("update:collapsed",e),d("collapse",e,s)},B=x(e=>{f.value=e.matches,d("breakpoint",e.matches),r.value!==e.matches&&y(e.matches,"responsive")});let o;function i(e){return B.value(e)}const w=_("ant-sider-");c&&c.addSider(w),K(()=>{k(()=>t.breakpoint,()=>{try{o?.removeEventListener("change",i)}catch{o?.removeListener(i)}if(typeof window<"u"){const{matchMedia:e}=window;if(e&&t.breakpoint&&t.breakpoint in L){o=e(`(max-width: ${L[t.breakpoint]})`);try{o.addEventListener("change",i)}catch{o.addListener(i)}i(o)}}},{immediate:!0})}),U(()=>{try{o?.removeEventListener("change",i)}catch{o?.removeListener(i)}c&&c.removeSider(w)});const b=()=>{y(!r.value,"clickTrigger")};return()=>{const e=T.value,{collapsedWidth:s,width:z,reverseArrow:m,zeroWidthTriggerStyle:A,trigger:u=v.trigger?.(),collapsible:$,theme:M}=t,g=r.value?s:z,a=G(g)?`${g}px`:String(g),h=Number.parseFloat(String(s||0))===0?l("span",{onClick:b,class:O(`${e}-zero-width-trigger`,`${e}-zero-width-trigger-${m?"right":"left"}`),style:A},[u||l(V,null,null)]):null,N={expanded:m?l(S,null,null):l(C,null,null),collapsed:m?l(C,null,null):l(S,null,null)},j=r.value?"collapsed":"expanded",E=N[j],F=u!==null?h||l("div",{class:`${e}-trigger`,onClick:b,style:{width:a}},[u||E]):null,H=[p.style,{flex:`0 0 ${a}`,maxWidth:a,minWidth:a,width:a}],P=O(e,`${e}-${M}`,{[`${e}-collapsed`]:!!r.value,[`${e}-has-trigger`]:$&&u!==null&&!h,[`${e}-below`]:!!f.value,[`${e}-zero-width`]:Number.parseFloat(a)===0},p.class);return l("aside",{...p,class:P,style:H},[l("div",{class:`${e}-children`},[v.default?.()]),$||f.value&&h?F:null])}}});export{ce as default,Z as siderProps};
