"use strict";const e=require("../../../../common/vendor.js"),t=require("../common/util.js"),o=require("./types.js");Math||i();const i=()=>"../wd-swiper-nav/wd-swiper-nav.js",n=e.defineComponent({name:"wd-swiper",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"},props:o.swiperProps,emits:["click","change","animationfinish","update:current"],setup(o,{emit:i}){const n=e.useSlots(),s=o,u=i,a=e.ref(s.current),r=e.ref(s.current),l=(e,t=!1)=>{r.value=e,t&&(a.value=e),u("update:current",e)},c=e.ref(!1),{proxy:d}=e.getCurrentInstance(),p=e.ref(t.uuid());e.watch((()=>s.current),(e=>{e<0?s.loop?y():w():e>=s.list.length?s.loop?w():y():h(e)}));const v=e.computed((()=>"wd-swiper__item "+(n.default?"wd-swiper__item--slot":""))),m=e.computed((()=>{const{list:e,direction:o,indicatorPosition:i,indicator:n}=s,u={current:r.value||0,total:e.length||0,direction:o||"horizontal",indicatorPosition:i||"bottom"};return t.isObj(n)&&(u.type=n.type||"dots",u.minShowNum=n.minShowNum||2,u.showControls=n.showControls||!1),u})),f=e=>((e,o)=>{const i=e=>"video"===o?t.isVideoUrl(e):t.isImageUrl(e);return t.isObj(e)?e.type&&["video","image"].includes(e.type)?e.type===o:i(e[s.valueKey]):i(e)})(e,"video");function h(e){e!==r.value&&l(e,!0)}function w(){h(0)}function y(){h(s.list.length-1)}function g(){s.stopAutoplayWhenVideoPlay&&(c.value=!0)}function x(){c.value=!1}function C(e,t,o){let i="";return function(e,t,o){return(e-1+o.length)%o.length===t}(e,t,o)&&(i=s.customPrevClass||s.customPrevImageClass),function(e,t,o){return(e+1+o.length)%o.length===t}(e,t,o)&&(i=s.customNextClass||s.customNextImageClass),i}function j(o){const{current:i,source:n}=o.detail,a=r.value;if(u("change",{current:i,source:n}),i!==r.value){l(i,"autoplay"===n||"touch"===n)}!function(o,i){(function(o){if(s.stopPreviousVideo){const i=s.list[o];if(t.isDef(i)&&f(i)){e.index.createVideoContext(`video-${o}-${p.value}`,d).pause()}}else s.stopAutoplayWhenVideoPlay&&x()})(o),function(o){if(s.autoplayVideo){const i=s.list[o];if(t.isDef(i)&&f(i)){e.index.createVideoContext(`video-${o}-${p.value}`,d).play()}}}(i)}(a,i)}function $(e){const{current:t,source:o}=e.detail;if(t!==r.value){l(t,"autoplay"===o||"touch"===o)}u("animationfinish",{current:t,source:o})}function _(e,t){u("click",{index:e,item:t})}function b({dir:e}){const{list:t,loop:o}=s,i=t.length;let n="next"===e?r.value+1:r.value-1;n=o?"next"===e?(r.value+1)%i:(r.value-1+i)%i:n<0||n>=i?r.value:n,n!==r.value&&h(n)}return(o,i)=>e.e({a:e.f(o.list,((i,n,s)=>e.e({a:f(i)},f(i)?{b:`video-${n}-${p.value}`,c:e.unref(t.addUnit)(o.height),d:e.unref(t.isObj)(i)?i[o.valueKey]:i,e:e.unref(t.isObj)(i)?i.poster:"",f:e.n(`wd-swiper__video ${o.customItemClass} ${C(r.value,n,o.list)}`),g:e.o(g,n),h:e.o(x,n),i:o.videoLoop,j:o.muted,k:o.autoplayVideo,l:e.o((e=>_(n,i)),n)}:{m:e.unref(t.isObj)(i)?i[o.valueKey]:i,n:e.n(`wd-swiper__image ${o.customImageClass} ${o.customItemClass} ${C(r.value,n,o.list)}`),o:e.unref(t.addUnit)(o.height),p:o.imageMode,q:e.o((e=>_(n,i)),n)},{r:e.unref(t.isObj)(i)&&i[o.textKey]},e.unref(t.isObj)(i)&&i[o.textKey]?{s:e.t(i[o.textKey]),t:e.n(`wd-swiper__text ${o.customTextClass}`),v:e.s(o.customTextStyle)}:{},{w:"d-"+s,x:e.r("d",{item:i,index:n},s),y:n}))),b:e.n(v.value),c:o.adjustHeight,d:o.adjustVerticalHeight,e:o.autoplay&&!c.value,f:a.value,g:o.interval,h:o.duration,i:o.loop,j:"vertical"==o.direction,k:o.easingFunction,l:e.unref(t.addUnit)(o.previousMargin),m:e.unref(t.addUnit)(o.nextMargin),n:o.snapToEdge,o:o.displayMultipleItems,p:e.unref(t.addUnit)(o.height),q:e.o(j),r:e.o($),s:o.indicator},o.indicator?e.e({t:e.r("indicator",{current:r.value,total:o.list.length}),v:!o.$slots.indicator},o.$slots.indicator?{}:{w:e.o(b),x:e.p({"custom-class":o.customIndicatorClass,type:m.value.type,current:m.value.current,total:m.value.total,direction:m.value.direction,"indicator-position":m.value.indicatorPosition,"min-show-num":m.value.minShowNum,"show-controls":m.value.showControls})}):{},{y:e.n(`wd-swiper ${o.customClass}`),z:e.s(o.customStyle)})}}),s=e._export_sfc(n,[["__scopeId","data-v-9cd4e584"]]);wx.createComponent(s);
