Your IP : 216.73.217.9


Current Path : /home2/reformindiaorg/public_html/wp-includes/blocks/image/
Upload File :
Current File : //home2/reformindiaorg/public_html/wp-includes/blocks/image/view.min.js

import*as t from"@wordpress/interactivity";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const n=(t=>{var n={};return e.d(n,t),n})({getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store,withSyncEvent:()=>t.withSyncEvent});let r=!1,o=0;function a(t){const e=i.metadata[t];return Object.hasOwn(i.metadata,t)?e:void 0}const{state:i,actions:l,callbacks:c}=(0,n.store)("core/image",{state:{currentImageId:null,get currentImage(){return a(i.currentImageId)},get overlayOpened(){return null!==i.currentImageId},get roleAttribute(){return i.overlayOpened?"dialog":null},get ariaModal(){return i.overlayOpened?"true":null},get enlargedSrc(){return i.currentImage.uploadedSrc||"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},get figureStyles(){return i.overlayOpened&&`${i.currentImage.figureStyles?.replace(/margin[^;]*;?/g,"")};`},get imgStyles(){return i.overlayOpened&&`${i.currentImage.imgStyles?.replace(/;$/,"")}; object-fit:cover;`},get imageButtonRight(){const{imageId:t}=(0,n.getContext)();return a(t)?.imageButtonRight},get imageButtonTop(){const{imageId:t}=(0,n.getContext)();return a(t)?.imageButtonTop},get isContentHidden(){const t=(0,n.getContext)();return i.overlayEnabled&&i.currentImageId===t.imageId},get isContentVisible(){const t=(0,n.getContext)();return!i.overlayEnabled&&i.currentImageId===t.imageId}},actions:{showLightbox(){const{imageId:t}=(0,n.getContext)();a(t)?.imageRef?.complete&&(i.scrollTopReset=document.documentElement.scrollTop,i.scrollLeftReset=document.documentElement.scrollLeft,i.overlayEnabled=!0,i.currentImageId=t,c.setOverlayStyles())},hideLightbox(){i.overlayEnabled&&(i.overlayEnabled=!1,setTimeout((function(){i.currentImage.buttonRef.focus({preventScroll:!0}),i.currentImageId=null}),450))},handleKeydown:(0,n.withSyncEvent)((t=>{if(i.overlayEnabled){if("Tab"===t.key){t.preventDefault();const{ref:e}=(0,n.getElement)();e.querySelector("button").focus()}"Escape"===t.key&&l.hideLightbox()}})),handleTouchMove:(0,n.withSyncEvent)((t=>{i.overlayEnabled&&t.preventDefault()})),handleTouchStart(){r=!0},handleTouchEnd(){o=Date.now(),r=!1},handleScroll(){i.overlayOpened&&!r&&Date.now()-o>450&&window.scrollTo(i.scrollLeftReset,i.scrollTopReset)}},callbacks:{setOverlayStyles(){if(!i.overlayEnabled)return;let{naturalWidth:t,naturalHeight:e,offsetWidth:n,offsetHeight:r}=i.currentImage.imageRef,{x:o,y:a}=i.currentImage.imageRef.getBoundingClientRect();const l=t/e;let c=n/r;if("contain"===i.currentImage.scaleAttr)if(l>c){const t=n/l;a+=(r-t)/2,r=t}else{const t=r*l;o+=(n-t)/2,n=t}c=n/r;let g=parseFloat("none"!==i.currentImage.targetWidth?i.currentImage.targetWidth:t),s=parseFloat("none"!==i.currentImage.targetHeight?i.currentImage.targetHeight:e),u=g/s,d=g,m=s,h=g,p=s;if(l.toFixed(2)!==u.toFixed(2)){if(l>u){const t=g/l;s-t>g?(s=t,g=t*l):s=g/l}else{const t=s*l;g-t>s?(g=t,s=t/l):g=s*l}h=g,p=s,u=g/s,c>u?(d=g,m=d/c):(m=s,d=m*c)}(n>h||r>p)&&(h=n,p=r);let f=0;window.innerWidth>480?f=80:window.innerWidth>1920&&(f=160);const y=Math.min(window.innerWidth-f,h),w=Math.min(window.innerHeight-80,p);c>y/w?(h=y,p=h/c):(p=w,h=p*c);const b=n/h,v=g*(h/d),I=s*(p/m);i.overlayStyles=`\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${a}px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${o}px;\n\t\t\t\t\t--wp--lightbox-container-width: ${h+1}px;\n\t\t\t\t\t--wp--lightbox-container-height: ${p+1}px;\n\t\t\t\t\t--wp--lightbox-image-width: ${v}px;\n\t\t\t\t\t--wp--lightbox-image-height: ${I}px;\n\t\t\t\t\t--wp--lightbox-scale: ${b};\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${window.innerWidth-document.documentElement.clientWidth}px;\n\t\t\t\t`},setButtonStyles(){const{ref:t}=(0,n.getElement)();if(!t)return;const{imageId:e}=(0,n.getContext)(),r=a(e);if(!r)return;r.imageRef=t,r.currentSrc=t.currentSrc;const{naturalWidth:o,naturalHeight:i,offsetWidth:l,offsetHeight:c}=t;if(0===o||0===i)return;const g=t.parentElement,s=t.parentElement.clientWidth;let u=t.parentElement.clientHeight;const d=g.querySelector("figcaption");if(d){const t=window.getComputedStyle(d);["absolute","fixed"].includes(t.position)||(u=u-d.offsetHeight-parseFloat(t.marginTop)-parseFloat(t.marginBottom))}const m=u-c,h=s-l;let p=m+16,f=h+16;if("contain"===r.scaleAttr){const t=o/i;if(t>=l/c){p=(c-l/t)/2+m+16,f=h+16}else{p=m+16,f=(l-c*t)/2+h+16}}r.imageButtonTop=p,r.imageButtonRight=f},setOverlayFocus(){if(i.overlayEnabled){const{ref:t}=(0,n.getElement)();t.focus()}},initTriggerButton(){const{imageId:t}=(0,n.getContext)(),{ref:e}=(0,n.getElement)(),r=a(t);r&&(r.buttonRef=e)}}},{lock:!0});