import{a2 as _,a3 as I,a4 as ee,a8 as se,a5 as ae,aN as re,a7 as oe,ap as te,Z as n,dg as ne,bf as ie,r as u,dh as g,as as le,di as ce,w as ue,e as de,o as i,c as d,aa as v,v as j,x as ve,n as l,N as C,F as M,b2 as F,t as y,y as me,bz as pe,q as S,dj as N,dk as P,ac as fe,ay as ge,dl as ye,av as we,cm as he,dm as ke,dn as Se,ad as Le}from"./index.8d733f79.js";import{E as be}from"./el-image-viewer.42b4b63f.js";const ze=_({hideOnClickModal:Boolean,src:{type:String,default:""},fit:{type:String,values:["","contain","cover","fill","none","scale-down"],default:""},loading:{type:String,values:["eager","lazy"]},lazy:Boolean,scrollContainer:{type:I([String,Object])},previewSrcList:{type:I(Array),default:()=>ee([])},previewTeleported:Boolean,zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},scale:{type:Number,default:1},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7},showProgress:Boolean,crossorigin:{type:I(String)}}),Ee={load:o=>o instanceof Event,error:o=>o instanceof Event,switch:o=>se(o),close:()=>!0,show:()=>!0},Ie=["src","loading","crossorigin"],Ce={key:0},Ne=ae({name:"ElImage",inheritAttrs:!1,__name:"image",props:ze,emits:Ee,setup(o,{expose:H,emit:R}){const a=o,m=R,{t:q}=re(),t=oe("image"),K=te(),$=n(()=>ne(Object.entries(K).filter(([e])=>/^(data-|on[A-Z])/i.test(e)||["id","style"].includes(e)))),Z=ie({excludeListeners:!0,excludeKeys:n(()=>Object.keys($.value))}),L=u(),p=u(!1),c=u(!0),b=u(!1),w=u(),f=u(),D=g&&"loading"in HTMLImageElement.prototype;let h;const W=n(()=>[t.e("inner"),z.value&&t.e("preview"),c.value&&t.is("loading")]),G=n(()=>{const{fit:e}=a;return g&&e?{objectFit:e}:{}}),z=n(()=>{const{previewSrcList:e}=a;return le(e)&&e.length>0}),J=n(()=>{const{previewSrcList:e,initialIndex:r}=a;let s=r;return r>e.length-1&&(s=0),s}),B=n(()=>a.loading==="eager"?!1:!D&&a.loading==="lazy"||a.lazy),E=()=>{!g||(c.value=!0,p.value=!1,L.value=a.src)};function Q(e){c.value=!1,p.value=!1,m("load",e)}function U(e){c.value=!1,p.value=!0,m("error",e)}function X(e){e&&(E(),T())}const A=ce(X,200,!0);async function O(){var e;if(!g)return;await ge();const{scrollContainer:r}=a;if(ye(r))f.value=r;else if(we(r)&&r!=="")f.value=(e=document.querySelector(r))!=null?e:void 0;else if(w.value){const k=he(w.value);f.value=ke(k)?void 0:k}const{stop:s}=Se(w,([k])=>{A(k.isIntersecting)},{root:f});h=s}function T(){!g||!A||(h==null||h(),f.value=void 0,h=void 0)}function V(){!z.value||(b.value=!0,m("show"))}function Y(){b.value=!1,m("close")}function x(e){m("switch",e)}return ue(()=>a.src,()=>{B.value?(c.value=!0,p.value=!1,T(),O()):E()}),de(()=>{B.value?O():E()}),H({showPreview:V}),(e,r)=>(i(),d("div",F({ref_key:"container",ref:w},$.value,{class:[l(t).b(),e.$attrs.class]}),[p.value?v(e.$slots,"error",{key:0},()=>[j("div",{class:C(l(t).e("error"))},ve(l(q)("el.image.error")),3)]):(i(),d(M,{key:1},[L.value!==void 0?(i(),d("img",F({key:0},l(Z),{src:L.value,loading:e.loading,style:G.value,class:W.value,crossorigin:e.crossorigin,onClick:V,onLoad:Q,onError:U}),null,16,Ie)):y("v-if",!0),c.value?(i(),d("div",{key:1,class:C(l(t).e("wrapper"))},[v(e.$slots,"placeholder",{},()=>[j("div",{class:C(l(t).e("placeholder"))},null,2)])],2)):y("v-if",!0)],64)),z.value?(i(),d(M,{key:2},[b.value?(i(),me(l(be),{key:0,"z-index":e.zIndex,"initial-index":J.value,infinite:e.infinite,"zoom-rate":e.zoomRate,"min-scale":e.minScale,"max-scale":e.maxScale,"show-progress":e.showProgress,"url-list":e.previewSrcList,scale:e.scale,crossorigin:e.crossorigin,"hide-on-click-modal":e.hideOnClickModal,teleported:e.previewTeleported,"close-on-press-escape":e.closeOnPressEscape,onClose:Y,onSwitch:x},pe({toolbar:S(s=>[v(e.$slots,"toolbar",N(P(s)))]),default:S(()=>[e.$slots.viewer?(i(),d("div",Ce,[v(e.$slots,"viewer")])):y("v-if",!0)]),_:2},[e.$slots.progress?{name:"progress",fn:S(s=>[v(e.$slots,"progress",N(P(s)))]),key:"0"}:void 0,e.$slots["viewer-error"]?{name:"viewer-error",fn:S(s=>[v(e.$slots,"viewer-error",N(P(s)))]),key:"1"}:void 0]),1032,["z-index","initial-index","infinite","zoom-rate","min-scale","max-scale","show-progress","url-list","scale","crossorigin","hide-on-click-modal","teleported","close-on-press-escape"])):y("v-if",!0)],64)):y("v-if",!0)],16))}});var Pe=fe(Ne,[["__file","/home/runner/work/element-plus/element-plus/packages/components/image/src/image.vue"]]);const Ae=Le(Pe);export{Ae as E};
