System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, AudioClip, Button, _decorator, game, oops, _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _crd, ccclass, property, menu, UIButton;

  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

  function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }

  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

  function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }

  function _reportPossibleCrUseOfoops(extras) {
    _reporterNs.report("oops", "../../../core/Oops", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      AudioClip = _cc.AudioClip;
      Button = _cc.Button;
      _decorator = _cc._decorator;
      game = _cc.game;
    }, function (_unresolved_2) {
      oops = _unresolved_2.oops;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "86cefAWukVE77lEwgfFdYeD", "UIButton", undefined);

      __checkObsolete__(['AudioClip', 'Button', 'EventTouch', '_decorator', 'game']);

      ({
        ccclass,
        property,
        menu
      } = _decorator);
      /** 
       * 通用按钮
       * 1、防连点
       * 2、按钮点击触发音效
       */

      _export("default", UIButton = (_dec = ccclass("UIButton"), _dec2 = menu('OopsFramework/Button/UIButton （通用按钮）'), _dec3 = property({
        tooltip: "每次触发间隔"
      }), _dec4 = property({
        tooltip: "是否只触发一次"
      }), _dec5 = property({
        tooltip: "触摸音效",
        type: AudioClip
      }), _dec(_class = _dec2(_class = (_class2 = class UIButton extends Button {
        constructor() {
          super(...arguments);

          _initializerDefineProperty(this, "interval", _descriptor, this);

          _initializerDefineProperty(this, "once", _descriptor2, this);

          _initializerDefineProperty(this, "effect", _descriptor3, this);

          // private effectIds: number[] = [];

          /** 触摸次数 */
          this._touchCount = 0;

          /** 触摸结束时间 */
          this._touchEndTime = 0;
        }

        /** 触摸结束 */
        _onTouchEnded(event) {
          // 是否只触发一次
          if (this.once) {
            if (this._touchCount > 0) {
              event.propagationStopped = true;
              return;
            }

            this._touchCount++;
          } // 防连点500毫秒出发一次事件


          if (this._touchEndTime && game.totalTime - this._touchEndTime < this.interval) {
            event.propagationStopped = true;
          } else {
            this._touchEndTime = game.totalTime;

            super._onTouchEnded(event); // 短按触摸音效


            this.playEffect();
          }
        }
        /** 短按触摸音效 */


        playEffect() {
          var _this = this;

          return _asyncToGenerator(function* () {
            if (_this.effect) {
              (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
                error: Error()
              }), oops) : oops).audio.playEffect(_this.effect); // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
              //     this.effectIds.remove(effectId);
              // });
              // if (effectId > 0) this.effectIds.push(effectId);
            }
          })();
        } // onDestroy() {
        //     if (this.effect) {
        //         this.effectIds.forEach(effectId => {
        //             console.log(effectId);
        //             oops.audio.putEffect(effectId, this.effect);
        //         });
        //     }
        // }


      }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "interval", [_dec3], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return 500;
        }
      }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "once", [_dec4], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return false;
        }
      }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "effect", [_dec5], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function initializer() {
          return null;
        }
      })), _class2)) || _class) || _class));

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=7989d8cb6c85fbdf08a762b3a256de27539b84b2.js.map