"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),U=require("../../_util/hooks/useMergedState.js"),j=require("./Image.js"),q=require("./Preview.js"),g=Symbol("previewGroupContext"),P={provide:o=>{t.provide(g,o)},inject:()=>t.inject(g,{isPreviewGroup:t.shallowRef(!1),previewUrls:t.computed(()=>new Map),setPreviewUrls:()=>{},current:t.ref(null),setCurrent:()=>{},setShowPreview:()=>{},setMousePosition:()=>{},registerImage:null,rootClassName:""})},C=()=>({previewPrefixCls:String,preview:{type:[Boolean,Object],default:!0},icons:{type:Object,default:()=>({})}}),O=t.defineComponent({compatConfig:{MODE:3},name:"PreviewGroup",inheritAttrs:!1,props:C(),setup(o,{slots:v}){const n=t.computed(()=>{const e={visible:void 0,onVisibleChange:()=>{},getContainer:void 0,current:0};return typeof o.preview=="object"?j.mergeDefaultValue(o.preview,e):e}),s=t.reactive(new Map),i=t.ref(),u=t.computed(()=>n.value.visible),h=t.computed(()=>n.value.getContainer),b=(e,r)=>{n.value.onVisibleChange?.(e,r)},[l,p]=U.default(!!u.value,{value:u,onChange:b}),d=t.ref(null),y=t.computed(()=>u.value!==void 0),M=t.computed(()=>Array.from(s.keys())),w=t.computed(()=>M.value[n.value.current]),f=t.computed(()=>new Map(Array.from(s).filter(([,{canPreview:e}])=>!!e).map(([e,{url:r}])=>[e,r]))),G=(e,r,c=!0)=>{s.set(e,{url:r,canPreview:c})},a=e=>{i.value=e},m=e=>{d.value=e},S=(e,r,c=!0)=>{const x=()=>{s.delete(e)};return s.set(e,{url:r,canPreview:c}),x},V=e=>{e?.stopPropagation(),p(!1),m(null)};return t.watch(w,e=>{a(e)},{immediate:!0,flush:"post"}),t.watchEffect(()=>{l.value&&y.value&&a(w.value)},{flush:"post"}),P.provide({isPreviewGroup:t.shallowRef(!0),previewUrls:f,setPreviewUrls:G,current:i,setCurrent:a,setShowPreview:p,setMousePosition:m,registerImage:S}),()=>{const{...e}=n.value;return t.createVNode(t.Fragment,null,[v.default&&v.default(),t.createVNode(q.default,{...e,"ria-hidden":!l.value,visible:l.value,prefixCls:o.previewPrefixCls,onClose:V,mousePosition:d.value,src:f.value.get(i.value),icons:o.icons,getContainer:h.value},null)])}}});exports.context=P;exports.default=O;exports.imageGroupProps=C;
