"use strict";
const uni_modules_uviewPlus_components_uAvatar_props = require("./props.js");
const uni_modules_uviewPlus_libs_mixin_mpMixin = require("../../libs/mixin/mpMixin.js");
const uni_modules_uviewPlus_libs_mixin_mixin = require("../../libs/mixin/mixin.js");
const uni_modules_uviewPlus_libs_function_index = require("../../libs/function/index.js");
const common_vendor = require("../../../../common/vendor.js");
const base64Avatar = "data:image/jpg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAA8AAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzYgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjREMEQwRkY0RjgwNDExRUE5OTY2RDgxODY3NkJFODMxIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjREMEQwRkY1RjgwND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AAAAAAAAAAAAAAAAAAYt4tKeFKVNYNSXfRgefAAAAAAAAr7VuSSWPedKaW5v1MCsAAAAAAAAAAAAAAAAAAIe6bj96Ts2n+JPzSXzP3ATgAAAAAAAAFbbt1UUrOQ9FpC4/UwK6aaqtU+DAAAAAAAAAAAAAAA4lKMIuUmoxWrb4ARNx3R3q2rLpa4Sl0y/YCcAAAAAAAAAAANmFud7G8r89r6X0dgFvGzLGRGtuWvTF6NAdwAAAAAAAAAAAy5W442PVN+K59EePp5ARMvOv5MvO6QXCC4AZwAAAAAAAAAAAAAcxlKLUotprg1owN+PvORborq+7Hnwl3gUbO74VzRydt8pKn68ANcJwmqwkpLmnUDkAAAAfNy9atqtyagut0AxXt5xIV8Fbj6lRd7Am5G65V6qUvtwfyx94GMAAAAAAAAAAAAAAAAAAAOU2nVOj5gdsc3LiqRvTpyqwOxbnnrhdfpSfrQB7pnv/AGvuS9gHXPMy5/Fem1yq0v0A6W29XqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf//Z";
const _sfc_main = {
  name: "u-avatar",
  mixins: [uni_modules_uviewPlus_libs_mixin_mpMixin.mpMixin, uni_modules_uviewPlus_libs_mixin_mixin.mixin, uni_modules_uviewPlus_components_uAvatar_props.props],
  data() {
    return {
      // 如果配置randomBgColor参数为true，在图标或者文字的模式下，会随机从中取出一个颜色值当做背景色
      colors: [
        "#ffb34b",
        "#f2bba9",
        "#f7a196",
        "#f18080",
        "#88a867",
        "#bfbf39",
        "#89c152",
        "#94d554",
        "#f19ec2",
        "#afaae4",
        "#e1b0df",
        "#c38cc1",
        "#72dcdc",
        "#9acdcb",
        "#77b1cc",
        "#448aca",
        "#86cefa",
        "#98d1ee",
        "#73d1f1",
        "#80a7dc"
      ],
      avatarUrl: this.src,
      allowMp: false
    };
  },
  watch: {
    // 监听头像src的变化，赋值给内部的avatarUrl变量，因为图片加载失败时，需要修改图片的src为默认值
    // 而组件内部不能直接修改props的值，所以需要一个中间变量
    src: {
      immediate: true,
      handler(newVal) {
        this.avatarUrl = newVal;
        if (!newVal) {
          this.errorHandler();
        }
      }
    }
  },
  computed: {
    imageStyle() {
      const style = {};
      return style;
    }
  },
  created() {
    this.init();
  },
  emits: ["click"],
  methods: {
    addStyle: uni_modules_uviewPlus_libs_function_index.addStyle,
    addUnit: uni_modules_uviewPlus_libs_function_index.addUnit,
    random: uni_modules_uviewPlus_libs_function_index.random,
    init() {
      this.allowMp = true;
    },
    // 判断传入的name属性，是否图片路径，只要带有"/"均认为是图片形式
    isImg() {
      return this.src.indexOf("/") !== -1;
    },
    // 图片加载时失败时触发
    errorHandler() {
      this.avatarUrl = this.defaultUrl || base64Avatar;
    },
    clickHandler() {
      this.$emit("click", this.name);
    }
  }
};
if (!Array) {
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  const _easycom_up_text2 = common_vendor.resolveComponent("up-text");
  (_easycom_u_icon2 + _easycom_up_text2)();
}
const _easycom_u_icon = () => "../u-icon/u-icon.js";
const _easycom_up_text = () => "../u-text/u-text.js";
if (!Math) {
  (_easycom_u_icon + _easycom_up_text)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: _ctx.mpAvatar && $data.allowMp
  }, _ctx.mpAvatar && $data.allowMp ? {
    b: common_vendor.s({
      width: $options.addUnit(_ctx.size),
      height: $options.addUnit(_ctx.size)
    })
  } : {}, {
    c: _ctx.mpAvatar && $data.allowMp
  }, _ctx.mpAvatar && $data.allowMp ? {} : _ctx.icon ? {
    e: common_vendor.p({
      name: _ctx.icon,
      size: _ctx.fontSize,
      color: _ctx.color
    })
  } : _ctx.text ? {
    g: common_vendor.p({
      text: _ctx.text,
      size: _ctx.fontSize,
      color: _ctx.color,
      align: "center",
      customStyle: "justify-content: center"
    })
  } : {
    h: common_vendor.n(`u-avatar__image--${_ctx.shape}`),
    i: $data.avatarUrl || _ctx.defaultUrl,
    j: _ctx.mode,
    k: common_vendor.o((...args) => $options.errorHandler && $options.errorHandler(...args)),
    l: common_vendor.s({
      width: $options.addUnit(_ctx.size),
      height: $options.addUnit(_ctx.size)
    })
  }, {
    d: _ctx.icon,
    f: _ctx.text,
    m: common_vendor.n(`u-avatar--${_ctx.shape}`),
    n: common_vendor.s({
      backgroundColor: _ctx.text || _ctx.icon ? _ctx.randomBgColor ? $data.colors[_ctx.colorIndex !== "" ? _ctx.colorIndex : $options.random(0, 19)] : _ctx.bgColor : "transparent",
      width: $options.addUnit(_ctx.size),
      height: $options.addUnit(_ctx.size)
    }),
    o: common_vendor.s($options.addStyle(_ctx.customStyle)),
    p: common_vendor.o((...args) => $options.clickHandler && $options.clickHandler(...args))
  });
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-34d954f9"]]);
wx.createComponent(Component);
