1import{_ as f}from"./xQsgplWM.js";import{s as y}from"./DAe7hB9S.js";import{_ as p,c as h,o as n,m,p as u,e as v,d as V,E as b,J as g,n as w}from"./Dwsn2kna.js";import"./C4zdMHou.js";import"./CKzQpmBl.js";const P={name:"Video",inheritAttrs:!1,data(){return{load:!1,shouldBePlaying:!1,isClientReady:!1,exitedView:!0,desiredVideoWidth:780,isNearView:!1,hasPresentedVideoFrame:!1,autoPlayInterval:void 0,activeTimeouts:[],isNearViewObserver:void 0,isFullyInViewObserver:void 0,isInViewObserver:void 0}},computed:{shouldRenderSources(){return this.critical?!0:this.loadOnInteraction?this.isClientReady&&this.load:this.isClientReady&&(this.load||this.loadImmediately)},aspectRatioFormatted(){if(this.aspectRatio)return this.aspectRatio.replace(/^([0-9]+)\s?\/\s?([0-9]+)/,"$1:$2")},baseUrl(){return`https://pestie.com/videos/q_${this.quality},${this.aspectRatioFormatted?`ar_${this.aspectRatioFormatted},`:""}${this.cropFill?"c_fill,":""}${this.muted?"ac_none,":""}${this.videoWidthParam}`},preload(){return this.loadOnInteraction&&!this.load?"none":this.loadImmediately?"auto":this.showControls||this.allowPause||this.autoplay?"metadata":"none"},videoWidthParam(){const t=Math.min(window.devicePixelRatio,2)||1;return`w_${Math.ceil(this.desiredVideoWidth*t)},`},posterUrl(){return this.hidePoster||!this.isNearView&&this.preload==="none"?"":`/so_0.001,e_gamma:9${this.src}`},posterFetchPriority(){return this.$attrs.fetchpriority||this.$attrs.fetchPriority},posterLoading(){return this.loadImmediately||this.posterFetchPriority==="high"?"eager":"lazy"},posterPreload(){return this.posterFetchPriority?{fetchPriority:this.posterFetchPriority}:this.loadImmediately},posterImgAttrs(){const t={class:"h-full w-full object-cover",decoding:"async",draggable:!1};return this.posterFetchPriority&&(t.fetchpriority=this.posterFetchPriority),t},videoAttrs(){const{class:t,style:e,controls:i,fetchpriority:a,fetchPriority:l,...s}=this.$attrs;return s},videoControls(){return this.showControls||this.$attrs.controls===""||this.$attrs.controls===!0},shouldRevealVideoAfterPlaybackStarts(){return!!this.posterUrl&&!this.videoControls},shouldRenderPoster(){return!!this.posterUrl&&!this.hasPresentedVideoFrame}},beforeMount(){this.calculateVideoSizeBasedOnSizes(window.innerWidth)},mounted(){this.isClientReady=!0,this.setObservers(),document.readyState==="complete"&&!this.loadOnInteraction&&setTimeout(()=>this.load=!0,5e3),this.autoplay&&(this.loadImmediately||this.load)&&(this.shouldBePlaying=!0,this.play()),this.autoplay&&!this.allowPause&&(this.autoPlayInterval=y(()=>{this.shouldBePlaying&&this.play()},1e3)),document.addEventListener("fullscreenchange",this.handleFullScreenChangeEvent)},unmounted(){var t,e,i;clearInterval(this.autoPlayInterval),document.removeEventListener("fullscreenchange",this.handleFullScreenChangeEvent),(t=this.isNearViewObserver)==null||t.disconnect(),(e=this.isFullyInViewObserver)==null||e.disconnect(),(i=this.isInViewObserver)==null||i.disconnect()},methods:{async play(){var t;try{this.shouldRenderSources||(this.load=!0,await this.$nextTick());const e=this.$refs.player||this.$el;if(await((t=e==null?void 0:e.play)==null?void 0:t.call(e)),window.innerWidth<767&&!this.autoplay){const i=(e==null?void 0:e.requestFullscreen)||(e==null?void 0:e.mozRequestFullScreen)||(e==null?void 0:e.webkitEnterFullScreen)||(e==null?void 0:e.msRequestFullscreen);i&&await i.call(e)}}catch{}},pause(){var t,e;(t=this.$refs.player)!=null&&t.pause?this.$refs.player.pause():(e=this.$el)!=null&&e.pause&&this.$el.pause()},onVideoLoad(){this.$refs.player&&(this.$refs.player.style.backgroundColor="transparent")},onVideoPlaying(){if(this.hasPresentedVideoFrame)return;const t=this.$refs.player,e=()=>{this.hasPresentedVideoFrame=!0};if(t!=null&&t.requestVideoFrameCallback){const i=setTimeout(e,500);t.requestVideoFrameCallback(()=>{clearTimeout(i),requestAnimationFrame(e)})}else requestAnimationFrame(e)},onVideoEnd(){this.loop||(this.shouldBePlaying=!1)},setVideoWidth(t,e){const i=e.includes("vw")?parseInt(t):parseInt(e.replace("px",""));this.desiredVideoWidth=i},calculateVideoSizeBasedOnSizes(t){if(this.sizes&&this.sizes!==""){const e=new RegExp(/^(\d{1,4}[a-z]{2})?\s?(?:xs:)?(\d{1,4}[a-z]{2})?\s?(?:sm:)?(\d{1,4}[a-z]{2})?\s?(?:md:)?(\d{1,4}[a-z]{2})?\s?(?:lg:)?(\d{1,4}[a-z]{2})?\s?(?:xl:)?(\d{1,4}[a-z]{2})?\s?/),[i,a,l,s,d,o,c]=this.sizes.match(e),r={xl:1280,lg:1024,md:768,sm:640,xs:320};t>=r.xl&&c?this.setVideoWidth(r.xl,c):t>=r.lg&&o?this.setVideoWidth(r.lg,o):t>=r.md&&d?this.setVideoWidth(r.md,d):t>
1=r.sm&&s?this.setVideoWidth(r.sm,s):t>=r.xs&&(l||a)&&this.setVideoWidth(r.xs,l??a)}},handleFullScreenChangeEvent(){var t,e;(t=window==null?void 0:window.document)!=null&&t.fullscreenEnabled&&!((e=window==null?void 0:window.document)!=null&&e.fullscreenElement)&&this.pause()},setObservers(){var e;this.isNearViewObserver=new IntersectionObserver(i=>{i[0].isIntersecting&&(this.isNearView=!0,!this.loadOnInteraction&&(this.load=!0,this.autoplay&&this.loop&&(this.shouldBePlaying=!0,this.$nextTick(()=>this.play()))))},{rootMargin:"10%",threshold:.4}),this.isFullyInViewObserver=new IntersectionObserver(i=>{if(i[0].isIntersecting&&!(!this.autoplay||this.loop)&&this.exitedView){if(this.exitedView=!1,this.autoplayDelay>0&&this.shouldApplyAutoplayDelay()){const a=setTimeout(()=>{this.shouldBePlaying=!0,this.$nextTick(()=>this.play())},this.autoplayDelay);this.activeTimeouts.push(a);return}this.shouldBePlaying=!0,this.$nextTick(()=>this.play())}},{rootMargin:"0px 0px -150px 0px",threshold:1});const t=((e=getComputedStyle(document==null?void 0:document.documentElement))==null?void 0:e.getPropertyValue("--bottom-safe-area-offset"))??"0px";this.isInViewObserver=new IntersectionObserver(i=>{var a,l;if(!i[0].isIntersecting){this.shouldBePlaying=!1,this.exitedView=!0,this.activeTimeouts.forEach(s=>clearTimeout(s)),this.activeTimeouts=[],this.loop||((a=this.$refs.player)!=null&&a.currentTime&&(this.$refs.player.currentTime=.001),(l=this.$el)!=null&&l.currentTime&&(this.$el.currentTime=.001),this.hasPresentedVideoFrame=!1);return}},{rootMargin:`-68px 0px -${t} 0px`,threshold:.1}),this.$refs.player?(this.isNearViewObserver.observe(this.$refs.player),this.isFullyInViewObserver.observe(this.$refs.player),this.isInViewObserver.observe(this.$refs.player)):this.$el&&(this.isNearViewObserver.observe(this.$el),this.isFullyInViewObserver.observe(this.$el),this.isInViewObserver.observe(this.$el))},shouldApplyAutoplayDelay(){if(this.applyAutoplayDelayOn==="desktop")return window.innerWidth>=1024;if(this.applyAutoplayDelayOn==="mobile")return window.innerWidth<1024;if(this.applyAutoplayDelayOn==="all")return!0}},watch:{"$nuxt.$currentWindowWidth":{handler({value:t}){this.calculateVideoSizeBasedOnSizes(t)},deep:!0}},props:{src:{type:String,required:!0},autoplay:{type:Boolean,default:!1},allowPause:{type:Boolean,default:!1},muted:{default:!0,type:Boolean},loop:{type:Boolean,default:!1},autoplayDelay:{type:Number,default:0},applyAutoplayDelayOn:{type:String,required:!1,validator:t=>["desktop","mobile","all"].includes(t)},quality:{type:String,default:"auto"},aspectRatio:{type:String,required:!1},cropFill:{type:Boolean,required:!1,default:!1},showControls:{type:Boolean,default:!1},hidePoster:{type:Boolean,required:!1,default:!1},loadImmediately:{type:Boolean,required:!1,default:!1},critical:{type:Boolean,required:!1,default:!1},loadOnInteraction:{type:Boolean,required:!1,default:!1},sizes:{type:String,required:!1}}},I=["preload","autoplay","loop","controls","muted","playsinline"],x=["src"],F=["src"],O=["src"];function S(t,e,i,a,l,s){const d=f;return n(),h("div",{class:w(["relative isolate block overflow-hidden",t.$attrs.class]),style:g([{"aspect-ratio":i.aspectRatio},t.$attrs.style])},[s.shouldRenderPoster?(n(),m(d,{key:0,preset:"videoPoster",src:s.posterUrl,sizes:i.sizes,alt:"","aria-hidden":"true",preload:s.posterPreload,loading:s.posterLoading,class:"absolute inset-0 z-0 h-full w-full pointer-events-none",imgAttrs:s.posterImgAttrs},null,8,["src","sizes","preload","loading","imgAttrs"])):u("",!0),v("video",b({ref:"player"},s.videoAttrs,{class:["absolute inset-0 z-1 h-full w-full object-cover",s.shouldRevealVideoAfterPlaybackStarts&&!l.hasPresentedVideoFrame?"invisible":"visible"],preload:s.preload,autoplay:i.autoplay&&l.shouldBePlaying,loop:i.loop,controls:s.videoControls,muted:i.muted,playsinline:i.autoplay,onPlaying:e[0]||(e[0]=(...o)=>s.onVideoPlaying&&s.onVideoPlaying(...o)),onCanplaythrough:e[1]||(e[1]=(...o)=>s.onVideoLoad&&s.onVideoLoad(...o)),onEnded:e[2]||(e[2]=(...o)=>s.onVideoEnd&&s.onVideoEnd(...o))}
1),[s.shouldRenderSources?(n(),h("source",{key:0,type:"video/mp4; codecs=hvc1",src:`${s.baseUrl}vc_h265,f_mp4${i.src}`},null,8,x)):u("",!0),s.shouldRenderSources?(n(),h("source",{key:1,type:"video/webm; codecs=vp9",src:`${s.baseUrl}f_webm${i.src}`},null,8,F)):u("",!0),s.shouldRenderSources?(n(),h("source",{key:2,type:"video/mp4",src:`${s.baseUrl}f_mp4${i.src}`},null,8,O)):u("",!0),e[3]||(e[3]=V(" Whoops, there was a problem. "))],16,I)],6)}const k=p(P,[["render",S]]);export{k as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.