"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _mobx = require("mobx");
var _services = _interopRequireWildcard(require("../../services"));
var _utils = require("../../utils");
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
var _resizeImage = _interopRequireDefault(require("../../components/resizeImage"));
var _uploadProgress = _interopRequireDefault(require("./uploadProgress"));
var _lodash = _interopRequireDefault(require("lodash"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class StickerStore {
  constructor() {
    _defineProperty(this, "images", []);
    _defineProperty(this, "stickers", []);
    _defineProperty(this, "stickerLocal", {
      // "64fd39c81c31d84495df73df": require('../../assets/gifs/0.gif'),
      // "64fd39c81c31d84495df73e1": require('../../assets/gifs/1.gif'),
      // "64fd39c81c31d84495df73e3": require('../../assets/gifs/2.gif'),
      // "64fd39c81c31d84495df73e5": require('../../assets/gifs/3.gif'),
      // "64fd39c81c31d84495df73e7": require('../../assets/gifs/4.gif'),
      // "64fd39c81c31d84495df73e9": require('../../assets/gifs/5.gif'),
      // "64fd39c81c31d84495df73eb": require('../../assets/gifs/6.gif'),
      // "64fd39c81c31d84495df73ed": require('../../assets/gifs/7.gif'),
      // "64fd39c81c31d84495df73ef": require('../../assets/gifs/8.gif'),
      // "64fd39c81c31d84495df73f1": require('../../assets/gifs/9.gif'),
      // "64fd39c81c31d84495df73f3": require('../../assets/gifs/10.gif'),
      // "64fd39c81c31d84495df73df": require('../../assets/gifs/11.gif'),
    });
    (0, _mobx.makeAutoObservable)(this);
  }
  async getStickers() {
    try {
      _services.default.create().getStickers({
        page: 1,
        limit: 1000
      }).then(response => {
        if (response.status === 200) {
          if (response.data.status === 200) {
            if (response.data.data) {
              this.data = response.data.data;
            }
          }
        }
      }).catch(e => {});
    } catch (error) {}
  }
  getStickerImage(id) {
    try {
      var _this$data, _stickerFound, _stickerFound$attachm, _stickerFound2, _stickerFound2$attach;
      let stickerFound;
      (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.map(category => {
        var _category$stickers;
        (_category$stickers = category.stickers) === null || _category$stickers === void 0 ? void 0 : _category$stickers.map(sticker => {
          if (sticker._id === id || sticker.attachment_id === id) {
            stickerFound = sticker;
          }
        });
      });
      if (stickerFound && this.stickerLocal[stickerFound.attachment_id]) {
        return this.stickerLocal[stickerFound.attachment_id];
      }
      return {
        uri: (_stickerFound = stickerFound) !== null && _stickerFound !== void 0 && (_stickerFound$attachm = _stickerFound.attachment) !== null && _stickerFound$attachm !== void 0 && _stickerFound$attachm.url ? (_stickerFound2 = stickerFound) === null || _stickerFound2 === void 0 ? void 0 : (_stickerFound2$attach = _stickerFound2.attachment) === null || _stickerFound2$attach === void 0 ? void 0 : _stickerFound2$attach.url : ''
      };
    } catch (e) {
      return {
        uri: ''
      };
    }
  }
}
const stickerStore = new StickerStore();
var _default = stickerStore;
exports.default = _default;
//# sourceMappingURL=StickerStore.js.map