"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),c=require("lodash"),V=require("vue-countup-v3"),C=require("odometer_countup"),p=require("nanoid"),F=require("../../commons/core/datasource/index.js"),v=require("../../commons/utils/json2css.js"),I=t.defineComponent({name:"zv-text-over-number"}),M=t.defineComponent({...I,props:{basicOption:{},sources:{},useEvents:{},uuid:{}},setup(m,{expose:h}){const r=m,s=t.ref(r.basicOption.countUp.startVal),x=n=>{const a=t.ref(p.nanoid()),l=t.ref(0),d=t.ref(),u=t.ref(),f=()=>{F.SHJDatasourceV2.parse({tId:r.uuid,sources:r.sources,callback:({data:e})=>{try{window.SHJParseEvent(r.useEvents,"dataListener",e),a.value=p.nanoid(),l.value=Number(e[0].data[0].value),d.value={startVal:s.value,separator:n.countUp.separator,decimal:n.countUp.decimal,decimalPlaces:n.countUp.decimalPlaces,duration:n.countUp.duration,prefix:n.countUp.prefix,suffix:n.countUp.suffix},n.countUp.isOdometer&&(d.value.plugin=new C.Odometer({duration:n.countUp.duration,lastDigitDelay:0})),s.value=l.value,n.isImitate?b():u.value&&clearInterval(u.value)}catch{window.SHJParseEvent(r.useEvents,"dataListener",null)}}})},k=e=>{v.autoInstallFont(e.fontFamily);const o={};e.color&&e.color.includes("linear-gradient")&&(o.backgroundImage=e.color,o["-webkit-background-clip"]="text",o.color="transparent");const q={};return e.textAlign==="left"&&(e.justifyContent="flex-start"),e.textAlign==="center"&&(e.justifyContent="center"),e.textAlign==="right"&&(e.justifyContent="flex-end"),{...v.jsonToCssStyle(e),...o,...q,...e.textShadow.show?{textShadow:`${e.textShadow.x}px ${e.textShadow.y}px ${e.textShadow.value}px ${e.textShadow.color}`}:{}}},D=()=>{},b=()=>{u.value&&clearInterval(u.value);const e=n.countUp.isOdometer?Math.floor(Math.random()*6)+5:Math.floor(Math.random()*4)+3;u.value=setInterval(()=>{s.value=l.value,d.value.startVal=s.value;const o=Number((Math.random()*10).toFixed(n.countUp.decimalPlaces));o>3?l.value+=o:l.value-=o},e*1e3)};return t.onMounted(()=>t.nextTick(()=>f())),t.onBeforeUnmount(()=>{u.value&&clearInterval(u.value)}),{key:a,init:f,options:d,endValue:l,onFinished:D,rendererDomStyle:k}},{key:y,init:i,options:w,endValue:S,onFinished:U,rendererDomStyle:g}=x(r.basicOption);return t.watch(()=>c.cloneDeep(r.basicOption),(n,a)=>{c.isEqual(n,a)||i()},{deep:!0}),t.watch(()=>c.cloneDeep(r.sources),(n,a)=>{c.isEqual(n,a)||i()},{deep:!0}),h({refresh:()=>i(),refreshView:()=>i(),refreshData:()=>i()}),(n,a)=>(t.openBlock(),t.createBlock(t.unref(V),{key:t.unref(y),class:"zerov-widget-over-number","end-val":t.unref(S),options:t.unref(w),loop:n.basicOption.countUp.loop,delay:n.basicOption.countUp.delay,style:t.normalizeStyle(t.unref(g)(n.basicOption.css)),onFinished:t.unref(U)},null,8,["end-val","options","loop","delay","style","onFinished"]))}});exports.default=M;
