import{dc as he,aY as $,m as r,C as Z,Q as ve,D as ge,bX as Ge,bY as Je,dd as Ke,L as W,J as L,cc as ie,aQ as qe,O as Qe,U as we,f as R,E as eo,aa as V,ad as D,aF as me,G as pe,H as oo,P as X,a4 as to,bc as ro,cg as io,bg as ne,cf as no,aS as Y,F as ae,ab as P,bh as ao,de as lo,ay as so,aP as uo,ai as co,a0 as xe,Y as fo,e as le,Z as se,df as ho,dg as vo}from"./index.3790e358.js";import{u as go}from"./Suffix.40f5c87a.js";function wo(e,s,l,d){var a=-1,m=e==null?0:e.length;for(d&&m&&(l=e[++a]);++a",[L("image-container","position: fixed;")]),L("image-preview-container",` position: fixed; left: 0; right: 0; top: 0; bottom: 0; display: flex; `),L("image-preview-overlay",` z-index: -1; position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, .3); `,[ie()]),L("image-preview-toolbar",` z-index: 1; position: absolute; left: 50%; transform: translateX(-50%); border-radius: var(--n-toolbar-border-radius); height: 48px; bottom: 40px; padding: 0 12px; background: var(--n-toolbar-color); box-shadow: var(--n-toolbar-box-shadow); color: var(--n-toolbar-icon-color); transition: color .3s var(--n-bezier); display: flex; align-items: center; `,[L("base-icon",` padding: 0 8px; font-size: 28px; cursor: pointer; `),ie()]),L("image-preview-wrapper",` position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; pointer-events: none; `,[qe()]),L("image-preview",` user-select: none; -webkit-user-select: none; pointer-events: all; margin: auto; max-height: calc(100vh - 32px); max-width: calc(100vw - 32px); transition: transform .3s var(--n-bezier); `),L("image",` display: inline-flex; max-height: 100%; max-width: 100%; `,[Qe("preview-disabled",` cursor: pointer; `),W("img",` border-radius: inherit; `)])]);const H=32;var Ee=Z({name:"ImagePreview",props:Object.assign(Object.assign({},F),{onNext:Function,onPrev:Function,clsPrefix:{type:String,required:!0}}),setup(e){const s=ve("Image","-image",pt,vt,e,we(e,"clsPrefix"));let l=null;const d=R(null),a=R(null),m=R(void 0),C=R(!1),g=R(!1),{localeRef:h}=go("Image");function n(){const{value:o}=a;if(!l||!o)return;const{style:i}=o,t=l.getBoundingClientRect(),c=t.left+t.width/2,f=t.top+t.height/2;i.transformOrigin=`${c}px ${f}px`}function u(o){var i,t;switch(o.key){case" ":o.preventDefault();break;case"ArrowLeft":(i=e.onPrev)===null||i===void 0||i.call(e);break;case"ArrowRight":(t=e.onNext)===null||t===void 0||t.call(e);break;case"Escape":oe();break}}eo(C,o=>{o?V("keydown",document,u):D("keydown",document,u)}),me(()=>{D("keydown",document,u)});let v=0,E=0,M=0,y=0,_=0,B=0,G=0,J=0,N=!1;function K(o){const{clientX:i,clientY:t}=o;M=i-v,y=t-E,uo(S)}function He(o){const{mouseUpClientX:i,mouseUpClientY:t,mouseDownClientX:c,mouseDownClientY:f}=o,x=c-i,b=f-t,O=`vertical${b>0?"Top":"Bottom"}`,I=`horizontal${x>0?"Left":"Right"}`;return{moveVerticalDirection:O,moveHorizontalDirection:I,deltaHorizontal:x,deltaVertical:b}}function q(o){const{value:i}=d;if(!i)return{offsetX:0,offsetY:0};const t=i.getBoundingClientRect(),{moveVerticalDirection:c,moveHorizontalDirection:f,deltaHorizontal:x,deltaVertical:b}=o||{};let O=0,I=0;return t.width<=window.innerWidth?O=0:t.left>0?O=(t.width-window.innerWidth)/2:t.right0?I=(t.height-window.innerHeight)/2:t.bottom.5){const o=p;k-=1,p=Math.max(.5,Math.pow(j,k));const i=o-p;S(!1);const t=q();p+=i,S(!1),p-=i,M=t.offsetX,y=t.offsetY,S()}}function S(o=!0){var i;const{value:t}=d;if(!t)return;const{style:c}=t,f=lo((i=w==null?void 0:w.previewedImgPropsRef.value)===null||i===void 0?void 0:i.style);let x="";if(typeof f=="string")x=f+";";else for(const O in f)x+=`${lt(O)}: ${f[O]};`;const b=`transform-origin: center; transform: translateX(${M}px) translateY(${y}px) rotate(${z}deg) scale(${p});`;N?c.cssText=x+"cursor: grabbing; transition: none;"+b:c.cssText=x+"cursor: grab;"+b+(o?"":"transition: none;"),o||t.offsetHeight}function oe(){C.value=!C.value,g.value=!0}function Ye(){p=ee(),k=Math.ceil(Math.log(p)/Math.log(j)),M=0,y=0,S()}const Xe={setPreviewSrc:o=>{m.value=o},setThumbnailEl:o=>{l=o},toggleShow:oe};function Fe(o,i){if(e.showToolbarTooltip){const{value:t}=s;return r(so,{to:!1,theme:t.peers.Tooltip,themeOverrides:t.peerOverrides.Tooltip,keepAliveOnHover:!1},{default:()=>h.value[i],trigger:()=>o})}else return o}const te=oo(()=>{const{common:{cubicBezierEaseInOut:o},self:{toolbarIconColor:i,toolbarBorderRadius:t,toolbarBoxShadow:c,toolbarColor:f}}=s.value;return{"--n-bezier":o,"--n-toolbar-icon-color":i,"--n-toolbar-color":f,"--n-toolbar-border-radius":t,"--n-toolbar-box-shadow":c}}),{inlineThemeDisabled:re}=X(),T=re?to("image-preview",void 0,te,e):void 0;return Object.assign({previewRef:d,previewWrapperRef:a,previewSrc:m,show:C,appear:ro(),displayed:g,previewedImgProps:w==null?void 0:w.previewedImgPropsRef,handleWheel(o){o.preventDefault()},handlePreviewMousedown:$e,handlePreviewDblclick:Ze,syncTransformOrigin:n,handleAfterLeave:()=>{U(),z=0,g.value=!1},handleDragStart:o=>{var i,t;(t=(i=w==null?void 0:w.previewedImgPropsRef.value)===null||i===void 0?void 0:i.onDragstart)===null||t===void 0||t.call(i,o),o.preventDefault()},zoomIn:We,zoomOut:Ve,rotateCounterclockwise:Ne,rotateClockwise:je,handleSwitchPrev:_e,handleSwitchNext:Be,withTooltip:Fe,resizeToOrignalImageSize:Ye,cssVars:re?void 0:te,themeClass:T==null?void 0:T.themeClass,onRender:T==null?void 0:T.onRender},Xe)},render(){var e,s;const{clsPrefix:l}=this;return r(ae,null,(s=(e=this.$slots).default)===null||s===void 0?void 0:s.call(e),r(io,{show:this.show},{default:()=>{var d;return this.show||this.displayed?((d=this.onRender)===null||d===void 0||d.call(this),ne(r("div",{class:[`${l}-image-preview-container`,this.themeClass],style:this.cssVars,onWheel:this.handleWheel},r(Y,{name:"fade-in-transition",appear:this.appear},{default:()=>this.show?r("div",{class:`${l}-image-preview-overlay`,onClick:this.toggleShow}):null}),this.showToolbar?r(Y,{name:"fade-in-transition",appear:this.appear},{default:()=>{if(!this.show)return null;const{withTooltip:a}=this;return r("div",{class:`${l}-image-preview-toolbar`},this.onPrev?r(ae,null,a(r(P,{clsPrefix:l,onClick:this.handleSwitchPrev},{default:()=>gt}),"tipPrevious"),a(r(P,{clsPrefix:l,onClick:this.handleSwitchNext},{default:()=>wt}),"tipNext")):null,a(r(P,{clsPrefix:l,onClick:this.rotateCounterclockwise},{default:()=>r(ut,null)}),"tipCounterclockwise"),a(r(P,{clsPrefix:l,onClick:this.rotateClockwise},{default:()=>r(st,null)}),"tipClockwise"),a(r(P,{clsPrefix:l,onClick:this.resizeToOrignalImageSize},{default:()=>r(ft,null)}),"tipOriginalSize"),a(r(P,{clsPrefix:l,onClick:this.zoomOut},{default:()=>r(ct,null)}),"tipZoomOut"),a(r(P,{clsPrefix:l,onClick:this.zoomIn},{default:()=>r(dt,null)}),"tipZoomIn"),a(r(P,{clsPrefix:l,onClick:this.toggleShow},{default:()=>mt}),"tipClose"))}}):null,r(Y,{name:"fade-in-scale-up-transition",onAfterLeave:this.handleAfterLeave,appear:this.appear,onEnter:this.syncTransformOrigin,onBeforeLeave:this.syncTransformOrigin},{default:()=>{const{previewedImgProps:a={}}=this;return ne(r("div",{class:`${l}-image-preview-wrapper`,ref:"previewWrapperRef"},r("img",Object.assign({},a,{draggable:!1,onMousedown:this.handlePreviewMousedown,onDblclick:this.handlePreviewDblclick,class:[`${l}-image-preview`,a.class],key:this.previewSrc,src:this.previewSrc,ref:"previewRef",onDragstart:this.handleDragStart}))),[[ao,this.show]])}})),[[no,{enabled:this.show}]])):null}}))}});const De=ge("n-image-group"),xt=F;var Ot=Z({name:"ImageGroup",props:xt,setup(e){let s;const{mergedClsPrefixRef:l}=X(e),d=`c${co()}`,a=fo(),m=h=>{var n;s=h,(n=g.value)===null||n===void 0||n.setPreviewSrc(h)};function C(h){if(!(a!=null&&a.proxy))return;const u=a.proxy.$el.parentElement.querySelectorAll(`[data-group-id=${d}]:not([data-error=true])`);if(!u.length)return;const v=Array.from(u).findIndex(E=>E.dataset.previewSrc===s);~v?m(u[(v+h+u.length)%u.length].dataset.previewSrc):m(u[0].dataset.previewSrc)}xe(De,{mergedClsPrefixRef:l,setPreviewSrc:m,setThumbnailEl:h=>{var n;(n=g.value)===null||n===void 0||n.setThumbnailEl(h)},toggleShow:()=>{var h;(h=g.value)===null||h===void 0||h.toggleShow()},groupId:d});const g=R(null);return{mergedClsPrefix:l,previewInstRef:g,next:()=>{C(1)},prev:()=>{C(-1)}}},render(){return r(Ee,{theme:this.theme,themeOverrides:this.themeOverrides,clsPrefix:this.mergedClsPrefix,ref:"previewInstRef",onPrev:this.prev,onNext:this.next,showToolbar:this.showToolbar,showToolbarTooltip:this.showToolbarTooltip},this.$slots)}});const Ct=Object.assign({alt:String,height:[String,Number],imgProps:Object,previewedImgProps:Object,lazy:Boolean,intersectionObserverOptions:Object,objectFit:{type:String,default:"fill"},previewSrc:String,fallbackSrc:String,width:[String,Number],src:String,previewDisabled:Boolean,loadDescription:String,onError:Function,onLoad:Function},F);var Rt=Z({name:"Image",props:Ct,inheritAttrs:!1,setup(e){const s=R(null),l=R(!1),d=R(null),a=pe(De,null),{mergedClsPrefixRef:m}=a||X(e),C={click:()=>{if(e.previewDisabled||l.value)return;const n=e.previewSrc||e.src;if(a){a.setPreviewSrc(n),a.setThumbnailEl(s.value),a.toggleShow();return}const{value:u}=d;!u||(u.setPreviewSrc(n),u.setThumbnailEl(s.value),u.toggleShow())}},g=R(!e.lazy);le(()=>{var n;(n=s.value)===null||n===void 0||n.setAttribute("data-group-id",(a==null?void 0:a.groupId)||"")}),le(()=>{if(e.lazy&&e.intersectionObserverOptions){let n;const u=se(()=>{n==null||n(),n=void 0,n=ho(s.value,e.intersectionObserverOptions,g)});me(()=>{u(),n==null||n()})}}),se(()=>{var n;e.src,(n=e.imgProps)===null||n===void 0||n.src,l.value=!1});const h=R(!1);return xe(Ae,{previewedImgPropsRef:we(e,"previewedImgProps")}),Object.assign({mergedClsPrefix:m,groupId:a==null?void 0:a.groupId,previewInstRef:d,imageRef:s,showError:l,shouldStartLoading:g,loaded:h,mergedOnClick:n=>{var u,v;C.click(),(v=(u=e.imgProps)===null||u===void 0?void 0:u.onClick)===null||v===void 0||v.call(u,n)},mergedOnError:n=>{if(!g.value)return;l.value=!0;const{onError:u,imgProps:{onError:v}={}}=e;u==null||u(n),v==null||v(n)},mergedOnLoad:n=>{const{onLoad:u,imgProps:{onLoad:v}={}}=e;u==null||u(n),v==null||v(n),h.value=!0}},C)},render(){var e,s;const{mergedClsPrefix:l,imgProps:d={},loaded:a,$attrs:m,lazy:C}=this,g=(s=(e=this.$slots).placeholder)===null||s===void 0?void 0:s.call(e),h=this.src||d.src,n=r("img",Object.assign(Object.assign({},d),{ref:"imageRef",width:this.width||d.width,height:this.height||d.height,src:this.showError?this.fallbackSrc:C&&this.intersectionObserverOptions?this.shouldStartLoading?h:void 0:h,alt:this.alt||d.alt,"aria-label":this.alt||d.alt,onClick:this.mergedOnClick,onError:this.mergedOnError,onLoad:this.mergedOnLoad,loading:vo&&C&&!this.intersectionObserverOptions?"lazy":"eager",style:[d.style||"",g&&!a?{height:"0",width:"0",visibility:"hidden"}:"",{objectFit:this.objectFit}],"data-error":this.showError,"data-preview-src":this.previewSrc||this.src}));return r("div",Object.assign({},m,{role:"none",class:[m.class,`${l}-image`,(this.previewDisabled||this.showError)&&`${l}-image--preview-disabled`]}),this.groupId?n:r(Ee,{theme:this.theme,themeOverrides:this.themeOverrides,clsPrefix:l,ref:"previewInstRef",showToolbar:this.showToolbar,showToolbarTooltip:this.showToolbarTooltip},{default:()=>n}),!a&&g)}});export{Rt as N,Ot as a};