UNPKG

buefy

Version:

Lightweight UI components for Vue.js (v3) based on Bulma

3 lines (2 loc) 24.2 kB
/*! Buefy v3.0.2 | MIT License | github.com/buefy/buefy */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Carousel={},e.Vue)}(this,(function(e,t){"use strict";let i="mdi",s=null,r="chevron-left",o="chevron-right",n=3500,a=null,l=!0,c=!0,h=null;const d=Math.sign||function(e){return e<0?-1:e>0?1:0};function u(e,t){return(e&t)===t}function p(e,t){return(e%t+t)%t}function m(e,t,i){return Math.max(t,Math.min(i,e))}const f={sizes:{default:"mdi-24px","is-small":null,"is-medium":"mdi-36px","is-large":"mdi-48px"},iconPrefix:"mdi-"},g=()=>{const e="fa-";return{sizes:{default:null,"is-small":null,"is-medium":e+"lg","is-large":e+"2x"},iconPrefix:e,internalIcons:{information:"info-circle",alert:"exclamation-triangle","alert-circle":"exclamation-circle","chevron-right":"angle-right","chevron-left":"angle-left","chevron-down":"angle-down","eye-off":"eye-slash","menu-down":"caret-down","menu-up":"caret-up","close-circle":"times-circle"}}};var v=(e,t)=>{const i=e.__vccOpts||e;for(const[e,s]of t)i[e]=s;return i};var y=v(t.defineComponent({name:"BIcon",props:{type:[String,Object],component:String,pack:String,icon:{type:String,required:!0},size:String,customSize:String,customClass:String,both:Boolean},computed:{iconConfig(){return{mdi:f,fa:g(),fas:g(),far:g(),fad:g(),fab:g(),fal:g(),"fa-solid":g(),"fa-regular":g(),"fa-light":g(),"fa-thin":g(),"fa-duotone":g(),"fa-brands":g()}[this.newPack]},iconPrefix(){return this.iconConfig&&this.iconConfig.iconPrefix?this.iconConfig.iconPrefix:""},newIcon(){return`${this.iconPrefix}${this.getEquivalentIconOf(this.icon)}`},newPack(){return this.pack||i},newType(){if(!this.type)return;let e=[];if("string"==typeof this.type)e=this.type.split("-");else for(const t in this.type)if(this.type[t]){e=t.split("-");break}if(e.length<=1)return;const[,...t]=e;return`has-text-${t.join("-")}`},newCustomSize(){return this.customSize||this.customSizeByPack},customSizeByPack(){if(this.iconConfig&&this.iconConfig.sizes){if(this.size&&void 0!==this.iconConfig.sizes[this.size])return this.iconConfig.sizes[this.size];if(this.iconConfig.sizes.default)return this.iconConfig.sizes.default}return null},useIconComponent(){return this.component||s}},methods:{getEquivalentIconOf(e){if(!this.both)return e;if(null==this.iconConfig)return e;const t=this.iconConfig;return t&&t.internalIcons&&t.internalIcons[e]?t.internalIcons[e]:e}}}),[["render",function(e,i,s,r,o,n){return t.openBlock(),t.createElementBlock("span",{class:t.normalizeClass(["icon",[e.newType,e.size]])},[e.useIconComponent?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.useIconComponent),{key:1,icon:[e.newPack,e.newIcon],size:e.newCustomSize,class:t.normalizeClass([e.customClass])},null,8,["icon","size","class"])):(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass([e.newPack,e.newIcon,e.newCustomSize,e.customClass])},null,2))],2)}]]),w=Object.defineProperty,b=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,S=(e,t,i)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var I=t.defineComponent({name:"BCarousel",components:{BIcon:y},mixins:[((e,t)=>{const i={provide(){return{["b"+e]:this}}};return u(t,1)&&(i.data=function(){return((e,t)=>{for(var i in t||(t={}))C.call(t,i)&&S(e,i,t[i]);if(b)for(var i of b(t))k.call(t,i)&&S(e,i,t[i]);return e})({childItems:[]},u(t,3)?{nextIndex:0}:{})},i.methods={_registerItem(e){u(t,3)&&(e.dynamicIndex=this.nextIndex,++this.nextIndex),this.childItems.push(e)},_unregisterItem(e){this.childItems=this.childItems.filter((t=>t.uniqueValue!==e.uniqueValue))}},u(t,3)&&(i.computed={sortedItems(){return this.childItems.slice().sort(((e,t)=>e.index-t.index))}})),i})("carousel",3)],props:{modelValue:{type:Number,default:0},animated:{type:String,default:"slide"},interval:Number,hasDrag:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!0},pauseHover:{type:Boolean,default:!0},pauseInfo:{type:Boolean,default:!0},pauseInfoType:{type:String,default:"is-white"},pauseText:{type:String,default:"Pause"},arrow:{type:Boolean,default:!0},arrowHover:{type:Boolean,default:!0},repeat:{type:Boolean,default:!0},iconPack:String,iconSize:String,iconPrev:{type:String,default:()=>r},iconNext:{type:String,default:()=>o},indicator:{type:Boolean,default:!0},indicatorBackground:Boolean,indicatorCustom:Boolean,indicatorCustomSize:{type:String,default:"is-small"},indicatorInside:{type:Boolean,default:!0},indicatorMode:{type:String,default:"click"},indicatorPosition:{type:String,default:"is-bottom"},indicatorStyle:{type:String,default:"is-dots"},overlay:Boolean,progress:Boolean,progressType:{type:String,default:"is-primary"},withCarouselList:Boolean},emits:{change:e=>!0,click:()=>!0,"update:modelValue":e=>!0},data(){return{transition:"next",activeChild:this.modelValue||0,isPause:!1,dragX:!1,timer:void 0}},computed:{indicatorClasses(){return[{"has-background":this.indicatorBackground,"has-custom":this.indicatorCustom,"is-inside":this.indicatorInside},this.indicatorCustom&&this.indicatorCustomSize,this.indicatorInside&&this.indicatorPosition]},hasPrev(){return this.repeat||0!==this.activeChild},hasNext(){return this.repeat||this.activeChild<this.childItems.length-1},activeChildIndex(){const e=this.sortedItems[this.activeChild];return null!=e?e.index:void 0}},watch:{modelValue(e){this.changeActive(e)},sortedItems(e){this.activeChild>=e.length&&this.activeChild>0&&this.changeActive(this.activeChild-1)},autoplay(e){e?this.startTimer():this.pauseTimer()},repeat(e){e&&this.startTimer()}},methods:{startTimer(){this.autoplay&&!this.timer&&(this.isPause=!1,this.timer=setInterval((()=>{!this.repeat&&this.activeChild>=this.childItems.length-1?this.pauseTimer():this.next()}),this.interval||n))},pauseTimer(){this.isPause=!0,this.timer&&(clearInterval(this.timer),this.timer=void 0)},restartTimer(){this.pauseTimer(),this.startTimer()},checkPause(){this.pauseHover&&this.autoplay&&this.pauseTimer()},changeActive(e,t=0){this.activeChild===e||isNaN(e)||(t=t||e-this.activeChild,e=this.repeat?p(e,this.childItems.length):m(e,0,this.childItems.length-1),this.transition=t>0?"prev":"next",this.activeChild=e,e!==this.modelValue&&this.$emit("update:modelValue",e),this.restartTimer(),this.$emit("change",e))},modeChange(e,t){if(this.indicatorMode===e)return this.changeActive(t)},prev(){this.changeActive(this.activeChild-1,-1)},next(){this.changeActive(this.activeChild+1,1)},dragStart(e){if(!this.hasDrag||!e.target.draggable)return;const t=e.touches;this.dragX=t?e.changedTouches[0].pageX:e.pageX,t?this.pauseTimer():e.preventDefault()},dragEnd(e){if(!1===this.dragX)return;const t=e.touches,i=(t?e.changedTouches[0].pageX:e.pageX)-this.dragX;Math.abs(i)>30?i<0?this.next():this.prev():(e.target.click(),this.sortedItems[this.activeChild].$emit("click"),this.$emit("click")),t&&this.startTimer(),this.dragX=!1}},mounted(){this.startTimer()},beforeUnmount(){this.pauseTimer()}});const z=["value","max"],x={key:1,class:"carousel-pause"},B=["onMouseover","onClick"];var E=v(I,[["render",function(e,i,s,r,o,n){const a=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["carousel",{"is-overlay":e.overlay}]),onMouseenter:i[4]||(i[4]=(...t)=>e.checkPause&&e.checkPause(...t)),onMouseleave:i[5]||(i[5]=(...t)=>e.startTimer&&e.startTimer(...t))},[e.progress?(t.openBlock(),t.createElementBlock("progress",{key:0,class:t.normalizeClass(["progress",e.progressType]),value:e.activeChild,max:e.childItems.length-1},t.toDisplayString(e.childItems.length-1),11,z)):t.createCommentVNode("v-if",!0),t.createElementVNode("div",{class:"carousel-items",onMousedown:i[0]||(i[0]=(...t)=>e.dragStart&&e.dragStart(...t)),onMouseup:i[1]||(i[1]=(...t)=>e.dragEnd&&e.dragEnd(...t)),onTouchstart:i[2]||(i[2]=t.withModifiers(((...t)=>e.dragStart&&e.dragStart(...t)),["stop"])),onTouchend:i[3]||(i[3]=t.withModifiers(((...t)=>e.dragEnd&&e.dragEnd(...t)),["stop"]))},[t.renderSlot(e.$slots,"default"),e.arrow?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["carousel-arrow",{"is-hovered":e.arrowHover}])},[t.withDirectives(t.createVNode(a,{class:"has-icons-left",onClick:e.prev,pack:e.iconPack,icon:e.iconPrev,size:e.iconSize,both:""},null,8,["onClick","pack","icon","size"]),[[t.vShow,e.hasPrev]]),t.withDirectives(t.createVNode(a,{class:"has-icons-right",onClick:e.next,pack:e.iconPack,icon:e.iconNext,size:e.iconSize,both:""},null,8,["onClick","pack","icon","size"]),[[t.vShow,e.hasNext]])],2)):t.createCommentVNode("v-if",!0)],32),e.autoplay&&e.pauseHover&&e.pauseInfo&&e.isPause?(t.openBlock(),t.createElementBlock("div",x,[t.createElementVNode("span",{class:t.normalizeClass(["tag",e.pauseInfoType])},t.toDisplayString(e.pauseText),3)])):t.createCommentVNode("v-if",!0),e.withCarouselList&&!e.indicator?t.renderSlot(e.$slots,"list",{key:2,active:e.activeChild,switch:e.changeActive}):t.createCommentVNode("v-if",!0),e.indicator?(t.openBlock(),t.createElementBlock("div",{key:3,class:t.normalizeClass(["carousel-indicator",e.indicatorClasses])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.sortedItems,((i,s)=>(t.openBlock(),t.createElementBlock("a",{class:t.normalizeClass(["indicator-item",{"is-active":i.isActive}]),onMouseover:t=>e.modeChange("hover",s),onClick:t=>e.modeChange("click",s),key:i.uniqueValue},[t.renderSlot(e.$slots,"indicators",{i:s},(()=>[t.createElementVNode("span",{class:t.normalizeClass(["indicator-style",e.indicatorStyle])},null,2)]))],42,B)))),128))],2)):t.createCommentVNode("v-if",!0),e.overlay?t.renderSlot(e.$slots,"overlay",{key:4}):t.createCommentVNode("v-if",!0)],34)}]]),P=Object.defineProperty,T=Object.defineProperties,V=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,A=(e,t,i)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))$.call(t,i)&&A(e,i,t[i]);if(N)for(var i of N(t))O.call(t,i)&&A(e,i,t[i]);return e},W=(e,t)=>T(e,V(t));var M=t.defineComponent({name:"BCarouselItem",mixins:[((e,t)=>{const i={inject:{parent:{from:"b"+e,default:""}},props:{value:{type:String,default:null}},computed:{uniqueValue(){return null!=this.value?this.value:this.$.uid}},created(){if(this.parent)this.parent._registerItem&&this.parent._registerItem(this);else if(!u(t,2))throw new Error("You should wrap "+this.$options.name+" in a "+e)},beforeUnmount(){this.parent&&this.parent._unregisterItem&&this.parent._unregisterItem(this)}};return u(t,1)&&(i.props=W(L({},i.props),{order:{type:Number,required:!1}}),i.data=()=>({dynamicIndex:void 0}),i.computed=W(L({},i.computed),{index(){return null!=this.order?this.order:this.dynamicIndex}})),i})("carousel",1)],data:()=>({transitionName:null}),computed:{transition(){return"fade"===this.parent.animated?"fade":this.parent.transition?"slide-"+this.parent.transition:void 0},isActive(){return this.parent.activeChildIndex===this.index}}});const j={class:"carousel-item"};var F=v(M,[["render",function(e,i,s,r,o,n){return t.openBlock(),t.createBlock(t.Transition,{name:e.transition,persisted:""},{default:t.withCtx((()=>[t.withDirectives(t.createElementVNode("div",j,[t.renderSlot(e.$slots,"default")],512),[[t.vShow,e.isActive]])])),_:3},8,["name"])}]]),X=Object.defineProperty,D=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,R=(e,t,i)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;const H=["square","1by1","5by4","4by3","3by2","5by3","16by9","b2y1","3by1","4by5","3by4","2by3","3by5","9by16","1by2","1by3"];function U(e){return-1!==H.indexOf(e)}var Q=t.defineComponent({name:"BImage",props:{src:String,alt:String,srcFallback:String,webpFallback:{type:String,default:()=>a},lazy:{type:Boolean,default:()=>l},responsive:{type:Boolean,default:()=>c},ratio:{type:String,default:()=>h},placeholder:String,srcset:String,srcsetSizes:Array,srcsetFormatter:{type:Function,default:(e,t,i)=>i.formatSrcset(e,t)},rounded:{type:Boolean,default:!1},captionFirst:{type:Boolean,default:!1},customClass:String},emits:{load:(e,t)=>!0,error:(e,t)=>!0},data:()=>({clientWidth:0,webpSupportVerified:!1,webpSupported:!1,useNativeLazy:!1,observer:null,inViewPort:!1,loaded:!1,failed:!1}),computed:{ratioPattern:()=>/([0-9]+)by([0-9]+)/,hasRatio(){return null!=this.ratio&&this.ratioPattern.test(this.ratio)},figureClasses(){const e={image:this.responsive};return this.hasRatio&&U(this.ratio)&&(e[`is-${this.ratio}`]=!0),e},figureStyles(){if(this.hasRatio&&!U(this.ratio)){const e=this.ratioPattern.exec(this.ratio);return{paddingTop:+e[2]/+e[1]*100+"%"}}},imgClasses(){return((e,t)=>{for(var i in t||(t={}))_.call(t,i)&&R(e,i,t[i]);if(D)for(var i of D(t))q.call(t,i)&&R(e,i,t[i]);return e})({"is-rounded":this.rounded,"has-ratio":this.hasRatio},this.customClass?{[this.customClass]:!!this.customClass}:{})},srcExt(){return this.getExt(this.src)},isWepb(){return"webp"===this.srcExt},computedSrc(){let e=this.src;return this.failed&&this.srcFallback&&(e=this.srcFallback),!this.webpSupported&&this.isWepb&&this.webpFallback?this.webpFallback.startsWith(".")?e.replace(/\.webp/gi,`${this.webpFallback}`):this.webpFallback:e},computedWidth(){if(this.responsive&&this.clientWidth>0)return this.clientWidth},computedNativeLazy(){if(this.lazy&&this.useNativeLazy)return"lazy"},isDisplayed(){return(this.webpSupportVerified||!this.isWepb)&&(!this.lazy||this.useNativeLazy||this.inViewPort)},placeholderExt(){if(this.placeholder)return this.getExt(this.placeholder)},isPlaceholderWepb(){return!!this.placeholder&&"webp"===this.placeholderExt},computedPlaceholder(){return!this.webpSupported&&this.isPlaceholderWepb&&this.webpFallback&&this.webpFallback.startsWith(".")?this.placeholder.replace(/\.webp/gi,`${this.webpFallback}`):this.placeholder},isPlaceholderDisplayed(){return!this.loaded&&(this.$slots.placeholder||this.placeholder&&(this.webpSupportVerified||!this.isPlaceholderWepb))},computedSrcset(){return this.srcset?!this.webpSupported&&this.isWepb&&this.webpFallback&&this.webpFallback.startsWith(".")?this.srcset.replace(/\.webp/gi,`${this.webpFallback}`):this.srcset:this.srcsetSizes&&Array.isArray(this.srcsetSizes)&&this.srcsetSizes.length>0?this.srcsetSizes.map((e=>`${this.srcsetFormatter(this.computedSrc,e,this)} ${e}w`)).join(","):void 0},computedSizes(){if(this.computedSrcset&&this.computedWidth)return`${this.computedWidth}px`},isCaptionFirst(){return this.$slots.caption&&this.captionFirst},isCaptionLast(){return this.$slots.caption&&!this.captionFirst}},methods:{getExt(e,t=!0){if(e){return(t?e.split("?")[0]:e).split(".").pop()}return""},setWidth(){this.clientWidth=this.$el.clientWidth},formatSrcset(e,t){const i=this.getExt(e,!1);return`${e.split(".").slice(0,-1).join(".")}-${t}.${i}`},onLoad(e){this.loaded=!0,this.emitSrc(e,(t=>this.$emit("load",e,t)))},onError(e){this.emitSrc(e,(t=>this.$emit("error",e,t))),this.failed||(this.failed=!0)},emitSrc(e,t){const i=e.target;t(i.currentSrc||i.src||this.computedSrc)}},created(){if(this.isWepb&&new Promise((e=>{const t=new Image;t.onerror=()=>e(!1),t.onload=()=>e(1===t.width),t.src="data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA="})).catch((()=>!1)).then((e=>{this.webpSupportVerified=!0,this.webpSupported=e})),this.lazy){const e="undefined"!=typeof window&&"HTMLImageElement"in window&&"loading"in HTMLImageElement.prototype,t="undefined"!=typeof window&&"IntersectionObserver"in window;!e&&t?this.observer=new IntersectionObserver((e=>{const{target:t,isIntersecting:i}=e[0];i&&!this.inViewPort&&(this.inViewPort=!0,this.observer.unobserve(t))})):this.useNativeLazy=!0}},mounted(){this.lazy&&this.observer&&this.observer.observe(this.$el),this.setWidth(),"undefined"!=typeof window&&window.addEventListener("resize",this.setWidth)},beforeUnmount(){this.observer&&this.observer.disconnect(),"undefined"!=typeof window&&window.removeEventListener("resize",this.setWidth)}});const G={key:0},J=["srcset","src","alt","width","sizes","loading"],K=["src","alt"],Y={key:1};var Z=v(Q,[["render",function(e,i,s,r,o,n){return t.openBlock(),t.createElementBlock("figure",{class:t.normalizeClass(["b-image-wrapper",e.figureClasses]),style:t.normalizeStyle(e.figureStyles)},[e.isCaptionFirst?(t.openBlock(),t.createElementBlock("figcaption",G,[t.renderSlot(e.$slots,"caption")])):t.createCommentVNode("v-if",!0),t.createVNode(t.Transition,{name:"fade"},{default:t.withCtx((()=>[e.isDisplayed?(t.openBlock(),t.createElementBlock("img",{key:0,srcset:e.computedSrcset,src:e.computedSrc,alt:e.alt,class:t.normalizeClass(e.imgClasses),width:e.computedWidth,sizes:e.computedSizes,loading:e.computedNativeLazy,onLoad:i[0]||(i[0]=(...t)=>e.onLoad&&e.onLoad(...t)),onError:i[1]||(i[1]=(...t)=>e.onError&&e.onError(...t))},null,42,J)):t.createCommentVNode("v-if",!0)])),_:1}),t.createVNode(t.Transition,{name:"fade"},{default:t.withCtx((()=>[e.isPlaceholderDisplayed?t.renderSlot(e.$slots,"placeholder",{key:0},(()=>[t.createElementVNode("img",{src:e.computedPlaceholder,alt:e.alt,class:t.normalizeClass([e.imgClasses,"placeholder"])},null,10,K)])):t.createCommentVNode("v-if",!0)])),_:3}),e.isCaptionLast?(t.openBlock(),t.createElementBlock("figcaption",Y,[t.renderSlot(e.$slots,"caption")])):t.createCommentVNode("v-if",!0)],6)}]]),ee=Object.defineProperty,te=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,re=(e,t,i)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,oe=(e,t)=>{for(var i in t||(t={}))ie.call(t,i)&&re(e,i,t[i]);if(te)for(var i of te(t))se.call(t,i)&&re(e,i,t[i]);return e},ne=t.defineComponent({name:"BCarouselList",components:{BIcon:y,BImage:Z},props:{data:{type:Array,default:()=>[]},modelValue:{type:Number,default:0},scrollValue:{type:Number,default:0},hasDrag:{type:Boolean,default:!0},hasGrayscale:Boolean,hasOpacity:Boolean,repeat:Boolean,itemsToShow:{type:Number,default:4},itemsToList:{type:Number,default:1},asIndicator:Boolean,arrow:{type:Boolean,default:!0},arrowHover:{type:Boolean,default:!0},iconPack:String,iconSize:String,iconPrev:{type:String,default:()=>r},iconNext:{type:String,default:()=>o},breakpoints:{type:Object,default:()=>({})}},emits:{switch:e=>!0,"update:modelValue":e=>!0,"updated:scroll":e=>!0},data(){return{activeItem:this.modelValue,scrollIndex:this.asIndicator?this.scrollValue:this.modelValue,delta:0,dragX:!1,hold:0,windowWidth:0,touch:!1,observer:null,refresh_:0}},computed:{dragging(){return!1!==this.dragX},listClass(){return[{"has-grayscale":this.settings.hasGrayscale,"has-opacity":this.settings.hasOpacity,"is-dragging":this.dragging}]},itemStyle(){return`width: ${this.itemWidth}px;`},translation(){return-m(this.delta+this.scrollIndex*this.itemWidth,0,(this.data.length-this.settings.itemsToShow)*this.itemWidth)},total(){return this.data.length-this.settings.itemsToShow},hasPrev(){return this.settings.repeat||this.scrollIndex>0},hasNext(){return this.settings.repeat||this.scrollIndex<this.total},breakpointKeys(){return Object.keys(this.breakpoints).sort(((e,t)=>+t-+e))},settings(){const e=this.breakpointKeys.filter((e=>this.windowWidth>=+e))[0];return e?oe(oe({},this.$props),this.breakpoints[+e]):this.$props},itemWidth(){if(this.windowWidth){this.refresh_;return this.$el.getBoundingClientRect().width/this.settings.itemsToShow}return 0}},watch:{modelValue(e){this.switchTo(this.asIndicator?e-(this.itemsToShow-3)/2:e),this.activeItem!==e&&(this.activeItem=m(e,0,this.data.length-1))},scrollValue(e){this.switchTo(e)}},methods:{resized(){this.windowWidth=window.innerWidth},switchTo(e){e===this.scrollIndex||isNaN(e)||(this.settings.repeat&&(e=p(e,this.total+1)),e=m(e,0,this.total),this.scrollIndex=e,this.asIndicator||this.modelValue===e?this.scrollIndex!==e&&this.$emit("updated:scroll",e):this.$emit("update:modelValue",e))},next(){this.switchTo(this.scrollIndex+this.settings.itemsToList)},prev(){this.switchTo(this.scrollIndex-this.settings.itemsToList)},checkAsIndicator(e,t){if(!this.asIndicator)return;const i=t.changedTouches?t.changedTouches[0].clientX:t.clientX;this.hold-Date.now()>2e3||Math.abs(+this.dragX-i)>10||(this.dragX=!1,this.hold=0,t.preventDefault(),this.activeItem=e,this.$emit("switch",e))},dragStart(e){this.dragging||!this.settings.hasDrag||0!==e.button&&"touchstart"!==e.type||(this.hold=Date.now(),this.touch=!!e.touches,this.dragX=this.touch?e.touches[0].clientX:e.clientX,window.addEventListener(this.touch?"touchmove":"mousemove",this.dragMove),window.addEventListener(this.touch?"touchend":"mouseup",this.dragEnd))},dragMove(e){if(!this.dragging)return;const t=e.touches?(e.changedTouches[0]||e.touches[0]).clientX:e.clientX;this.delta=+this.dragX-t,e.touches||e.preventDefault()},dragEnd(){if(this.dragging||this.hold){if(this.hold){const e=d(this.delta),t=Math.round(Math.abs(this.delta/this.itemWidth)+.15);this.switchTo(this.scrollIndex+e*t)}this.delta=0,this.dragX=!1,window.removeEventListener(this.touch?"touchmove":"mousemove",this.dragMove),window.removeEventListener(this.touch?"touchend":"mouseup",this.dragEnd)}},refresh(){this.$nextTick((()=>{this.refresh_++}))}},mounted(){if("undefined"!=typeof window&&(window.ResizeObserver&&(this.observer=new ResizeObserver(this.refresh),this.observer.observe(this.$el)),window.addEventListener("resize",this.resized),document.addEventListener("animationend",this.refresh),document.addEventListener("transitionend",this.refresh),document.addEventListener("transitionstart",this.refresh),this.resized()),this.$attrs.config)throw new Error("The config prop was removed, you need to use v-bind instead")},beforeUnmount(){"undefined"!=typeof window&&(window.ResizeObserver&&this.observer.disconnect(),window.removeEventListener("resize",this.resized),document.removeEventListener("animationend",this.refresh),document.removeEventListener("transitionend",this.refresh),document.removeEventListener("transitionstart",this.refresh),this.dragEnd())}});const ae=["onMouseup","onTouchend"];var le=v(ne,[["render",function(e,i,s,r,o,n){const a=t.resolveComponent("b-image"),l=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["carousel-list",{"has-shadow":e.scrollIndex>0}]),onMousedown:i[0]||(i[0]=t.withModifiers(((...t)=>e.dragStart&&e.dragStart(...t)),["prevent"])),onTouchstart:i[1]||(i[1]=(...t)=>e.dragStart&&e.dragStart(...t))},[t.createElementVNode("div",{class:t.normalizeClass(["carousel-slides",e.listClass]),style:t.normalizeStyle("transform:translateX("+e.translation+"px)")},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.data,((i,s)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["carousel-slide",{"is-active":e.asIndicator?e.activeItem===s:e.scrollIndex===s}]),onMouseup:t=>e.checkAsIndicator(s,t),onTouchend:t=>e.checkAsIndicator(s,t),key:s,style:t.normalizeStyle(e.itemStyle)},[t.renderSlot(e.$slots,"item",t.mergeProps({index:s,active:e.activeItem,scroll:e.scrollIndex},i,{list:i}),(()=>[t.createVNode(a,t.mergeProps({src:i.image},i),null,16,["src"])]))],46,ae)))),128))],6),e.arrow?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["carousel-arrow",{"is-hovered":e.settings.arrowHover}])},[t.withDirectives(t.createVNode(l,{class:"has-icons-left",onClick:t.withModifiers(e.prev,["prevent"]),pack:e.settings.iconPack,icon:e.settings.iconPrev,size:e.settings.iconSize,both:""},null,8,["onClick","pack","icon","size"]),[[t.vShow,e.hasPrev]]),t.withDirectives(t.createVNode(l,{class:"has-icons-right",onClick:t.withModifiers(e.next,["prevent"]),pack:e.settings.iconPack,icon:e.settings.iconNext,size:e.settings.iconSize,both:""},null,8,["onClick","pack","icon","size"]),[[t.vShow,e.hasNext]])],2)):t.createCommentVNode("v-if",!0)],34)}]]);const ce=(e,t,i)=>{const s=t.name;if(null==s)throw new Error("Buefy.registerComponent: missing component name");e.component(s,t)},he={install(e){ce(e,E),ce(e,F),ce(e,le)}};e.BCarousel=E,e.BCarouselItem=F,e.BCarouselList=le,e.default=he,Object.defineProperty(e,"__esModule",{value:!0})}));