"use strict";const e=require("../../../../common/vendor.js"),t=require("../common/util.js"),a=require("./types.js");Math||n();const n=()=>"../wd-icon/wd-icon.js",o=e.defineComponent({name:"wd-notice-bar",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"},props:a.noticeBarProps,emits:["close","next","click"],setup(a,{expose:n,emit:o}){const l=a,i=o,r=e.ref(0),u=e.ref(!0),s=e.ref(0),c=e.computed((()=>Array.isArray(l.text)?l.text:[l.text])),d=e.computed((()=>c.value[s.value])),v=e.ref(0),p=e.ref(null),h=e.ref(null),f=e.computed((()=>"horizontal"===l.direction)),m=e.computed((()=>"vertical"===l.direction)),y=e.reactive({transitionProperty:"unset",transitionDelay:"unset",transitionDuration:"unset",transform:"none",transitionTimingFunction:"linear"}),w=e.computed((()=>t.objToStyle(y))),x=e.computed((()=>{const e={};return t.isDef(l.color)&&(e.color=l.color),t.isDef(l.backgroundColor)&&(e.background=l.backgroundColor),`${t.objToStyle(e)}${l.customStyle}`})),b=e.computed((()=>{const{type:e,wrapable:t,scrollable:a}=l;let n=[];return e&&n.push(`is-${e}`),f.value?!t&&!a&&n.push("wd-notice-bar--ellipse"):n.push("wd-notice-bar--ellipse"),t&&!a&&n.push("wd-notice-bar--wrap"),n.join(" ")})),{proxy:g}=e.getCurrentInstance();function _(){D(),$()}function $(){e.nextTick$1((()=>async function(){const[e,t]=await k();if(!e.width||!t.width||!t.height)return;p.value=e,h.value=t,r.value=e.width,f.value?l.scrollable&&j({duration:t.width/l.speed,delay:l.delay,translate:-t.width}):c.value.length>1&&C(t.height)}()))}function D(){y.transitionProperty="unset",y.transitionDelay="unset",y.transitionDuration="unset",y.transform="none",y.transitionTimingFunction="linear",s.value=0,v.value=0}function T(){u.value=!1,i("close")}function j({duration:e,delay:t,translate:a}){y.transitionProperty="all",y.transitionDelay=`${t}s`,y.transitionDuration=`${e}s`,y.transform=`${"vertical"===l.direction?"translateY":"translateX"}(${a}px)`,y.transitionTimingFunction="linear"}function k(){return Promise.all([t.getRect(".wd-notice-bar__wrap",!1,g),t.getRect(".wd-notice-bar__content",!1,g)])}async function C(e){const t=-e/(c.value.length+1)*(s.value+1);j({duration:e/(c.value.length+1)/l.speed,delay:l.delay,translate:t})}function P(){f.value?j({duration:0,delay:0,translate:r.value+1}):++v.value>=c.value.length&&(v.value=0,j({duration:0,delay:0,translate:0}));const t=setTimeout((()=>{s.value>=c.value.length-1?s.value=0:s.value++,i("next",s.value),e.nextTick$1((async()=>{try{const[e,t]=await k();p.value=e,h.value=t,r.value=e.width||0}catch(e){}h.value&&h.value.width&&h.value.height&&(f.value?j({duration:(r.value+h.value.width)/l.speed,delay:l.delay,translate:-h.value.width}):C(h.value.height))})),clearTimeout(t)}),20)}function A(){const e=t.isArray(l.text)?{index:s.value,text:l.text[s.value]}:{index:0,text:l.text};i("click",e)}return e.watch((()=>l.text),(()=>{_()}),{deep:!0}),e.onMounted((()=>{$()})),e.onActivated((()=>{$()})),e.onDeactivated((()=>{D()})),n({reset:_}),(t,a)=>e.e({a:u.value},u.value?e.e({b:t.prefix},t.prefix?{c:e.p({"custom-class":"wd-notice-bar__prefix",name:t.prefix})}:{},{d:m.value},m.value?e.e({e:e.f(c.value,((t,a,n)=>({a:e.t(t),b:t}))),f:c.value.length>1},c.value.length>1?{g:e.t(c.value[0])}:{}):{h:e.t(d.value)},{i:e.s(w.value),j:e.o(P),k:e.o(A),l:t.closable},t.closable?{m:e.o(T),n:e.p({"custom-class":"wd-notice-bar__suffix",name:"close-bold"})}:{},{o:e.n(`wd-notice-bar ${t.customClass} ${b.value}`),p:e.s(x.value)}):{})}}),l=e._export_sfc(o,[["__scopeId","data-v-cd588750"]]);wx.createComponent(l);
