var t = require("../../../@babel/runtime/helpers/slicedToArray");

(0, require("../../../1CD7E003658710DF7AB1880434AFEAA0.js").VantComponent)({
    props: {
        text: {
            type: String,
            value: ""
        },
        mode: {
            type: String,
            value: ""
        },
        url: {
            type: String,
            value: ""
        },
        openType: {
            type: String,
            value: "navigate"
        },
        delay: {
            type: Number,
            value: 2
        },
        speed: {
            type: Number,
            value: 30
        },
        scrollable: {
            type: Boolean,
            value: !0
        },
        leftIcon: {
            type: String,
            value: ""
        },
        color: {
            type: String,
            value: "#ed6a0c"
        },
        backgroundColor: {
            type: String,
            value: "#fffbe8"
        },
        wrapable: Boolean
    },
    data: {
        show: !0
    },
    watch: {
        text: function() {
            this.setData({}, this.init);
        }
    },
    created: function() {
        this.resetAnimation = wx.createAnimation({
            duration: 0,
            timingFunction: "linear"
        });
    },
    destroyed: function() {
        this.timer && clearTimeout(this.timer);
    },
    methods: {
        init: function() {
            var e = this;
            Promise.all([ this.getRect(".van-notice-bar__content"), this.getRect(".van-notice-bar__wrap") ]).then(function(i) {
                var n = t(i, 2), a = n[0], o = n[1];
                if (null != a && null != o && a.width && o.width) {
                    var r = e.data, l = r.speed, s = r.scrollable, c = r.delay;
                    if (s && o.width < a.width) {
                        var u = a.width / l * 1e3;
                        e.wrapWidth = o.width, e.contentWidth = a.width, e.duration = u, e.animation = wx.createAnimation({
                            duration: u,
                            timingFunction: "linear",
                            delay: c
                        }), e.scroll();
                    }
                }
            });
        },
        scroll: function() {
            var t = this;
            this.timer && clearTimeout(this.timer), this.timer = null, this.setData({
                animationData: this.resetAnimation.translateX(this.wrapWidth).step().export()
            }), setTimeout(function() {
                t.setData({
                    animationData: t.animation.translateX(-t.contentWidth).step().export()
                });
            }, 20), this.timer = setTimeout(function() {
                t.scroll();
            }, this.duration);
        },
        onClickIcon: function(t) {
            this.timer && clearTimeout(this.timer), this.timer = null, this.setData({
                show: !1
            }), this.$emit("close", t);
        },
        onClick: function(t) {
            this.$emit("click", t);
        }
    }
});