"use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(a):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,o=new Array(t);a<t;a++)o[a]=e[a];return o}var img=require("../../utils/imgbase64"),app=getApp();Object.prototype.hasOwnProperty.call(app,"originRequest")||(app.originRequest=wx.request),Component({data:{interceptors:[],isInjected:!1,isShowManage:!1,addPopupClass:"",isShowMask:!1,addInfo:{key:"",value:"",title:"添加",isRegex:!1,disabled:!1},img:img},lifetimes:{created:function(){},attached:function(){this.setData({addInfo:{key:"",value:"",title:"添加",isRegex:!1,disabled:!1}}),this.setData(getApp().globalData.__HTTP_INJECTOR)},detached:function(){var e=this.data,t=e.interceptors,a=e.isInjected;getApp().globalData.__HTTP_INJECTOR={interceptors:t,isInjected:a}}},methods:{hooksRequestSuccessCallback:function(e){var r=e.data;return this.data.interceptors.forEach(function(e){var t=e.isRegex,a=e.key,o=e.value,n=t?new RegExp(a,"g"):a,i="string"!=typeof r;i&&(r=JSON.stringify(r)),r=r.replace(n,o),i&&(r=JSON.parse(r))}),e.data=r,e},hooksRequest:function(){Object.defineProperty(wx,"request",{writable:!0});var a=this.hooksRequestSuccessCallback;wx.request=function(e){var t=e.success;e.success=function(e){t(a(e))},app.originRequest(e)}},showAddPopup:function(){this.setData({isShowManage:!1,addPopupClass:"add-dialog-active",addInfo:{key:"",value:"",title:"添加",disabled:!1}})},closeAddPopup:function(){this.closeAll()},closeAll:function(){this.setData({isShowManage:!1,isShowMask:!1,addPopupClass:""})},openManageMenu:function(){this.data.isInjected||this.setData({isShowManage:!0,isShowMask:!0})},clearAll:function(){var t=this;this.setData({isShowManage:!1}),wx.showModal({title:"提示",content:"确定要清除所有吗？",success:function(e){e.confirm&&wx.clearStorageSync(),t.closeAll()}})},checkboxChange:function(e){this.setData({checkedStorage:e.detail.value})},modifyItemValue:function(e){this.setData({isShowMask:!0,addPopupClass:"add-dialog-active",addInfo:{key:e.currentTarget.dataset.key,value:e.currentTarget.dataset.value,title:"修改",disabled:!0}})},bingAddInfoKey:function(e){this.setData({"addInfo.key":e.detail.value})},bingAddInfoValue:function(e){this.setData({"addInfo.value":e.detail.value})},bingAddInfoIsRegex:function(e){this.setData({"addInfo.isRegex":e.detail.value})},addStorage:function(){var e=this.data.addInfo,t=e.key,a=e.value,o=e.isRegex;t&&a&&this.setData({interceptors:[].concat(_toConsumableArray(this.data.interceptors),[{key:t,value:a,isRegex:o}])}),this.closeAll()},toggleInjectionState:function(){var e=this;this.setData({isInjected:!this.data.isInjected},function(){e.data.isInjected&&e.hooksRequest()})},onGoBack:function(){this.triggerEvent("toggle",{componentType:"dokit"})}}});