text: "use strict";
  var __assign = (this && this.__assign) || function () {
      __assign = Object.assign || function(t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
              s = arguments[i];
              for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                  t[p] = s[p];
          }
          return t;
      };
      return __assign.apply(this, arguments);
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var component_1 = require("../common/component");
  var utils_1 = require("../common/utils");
  component_1.VantComponent({
      field: true,
      classes: ['icon-class'],
      props: {
          value: Number,
          readonly: Boolean,
          disabled: Boolean,
          allowHalf: Boolean,
          size: {
              type: null,
              observer: 'setSizeWithUnit'
          },
          icon: {
              type: String,
              value: 'star'
          },
          voidIcon: {
              type: String,
              value: 'star-o'
          },
          color: {
              type: String,
              value: '#ffd21e'
          },
          voidColor: {
              type: String,
              value: '#c7c7c7'
          },
          disabledColor: {
              type: String,
              value: '#bdbdbd'
          },
          count: {
              type: Number,
              value: 5
          },
          gutter: {
              type: null,
              observer: 'setGutterWithUnit'
          },
          touchable: {
              type: Boolean,
              value: true
          }
      },
      data: {
          innerValue: 0,
          gutterWithUnit: undefined,
          sizeWithUnit: '20px'
      },
      watch: {
          value: function (value) {
              if (value !== this.data.innerValue) {
                  this.setData({ innerValue: value });
              }
          }
      },
      methods: {
          setSizeWithUnit: function (val) {
              this.setData({
                  sizeWithUnit: utils_1.addUnit(val)
              });
          },
          setGutterWithUnit: function (val) {
              this.setData({
                  gutterWithUnit: utils_1.addUnit(val)
              });
          },
          onSelect: function (event) {
              var data = this.data;
              var score = event.currentTarget.dataset.score;
              if (!data.disabled && !data.readonly) {
                  this.setData({ innerValue: score + 1 });
                  this.$emit('input', score + 1);
                  this.$emit('change', score + 1);
              }
          },
          onTouchMove: function (event) {
              var _this = this;
              var touchable = this.data.touchable;
              if (!touchable)
                  return;
              var clientX = event.touches[0].clientX;
              this.getRect('.van-rate__icon', true).then(function (list) {
                  var target = list
                      .sort(function (item) { return item.right - item.left; })
                      .find(function (item) { return clientX >= item.left && clientX <= item.right; });
                  if (target != null) {
                      _this.onSelect(__assign(__assign({}, event), { currentTarget: target }));
                  }
              });
          }
      }
  });
  