/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/redux-fetch-actions@0.0.14/dist.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.reducer=void 0;var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),_lodash=require("lodash"),_lodash2=_interopRequireDefault(_lodash),_pathToRegexp=require("path-to-regexp"),_pathToRegexp2=_interopRequireDefault(_pathToRegexp);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var IS_FETCHING="REDUX_FETCH_ACTIONS_IS_FETCHING",STOP_FETCHING="REDUX_FETCH_ACTIONS_STOP_FETCHING";if(_lodash2.default.isUndefined(global.fetch))var _fetch=require("isomorphic-fetch");var checkStatus=function(e){if(e.status>=200&&e.status<300)return e;throw e},createResponse=function(e){var t=arguments.length<=1||void 0===arguments[1]?"success":arguments[1];return deserialize(e).then((function(n){return{url:e.url,status:e.status,statusText:e.statusText,headers:e.headers,value:n,type:t}}))},createErrorResponse=function(e){return createResponse(e,"fail").then((function(e){return e}))},deserialize=function(e){var t=e.headers.get("Content-Type")||"";return t.indexOf("application/json")>-1||t.indexOf("application/ld+json")>-1?e.json():t.indexOf("application/octet-stream")>-1?e.arrayBuffer():e.text()},abstractActions=function(){function e(t){_classCallCheck(this,e),this.name=t,this.success={name:{},action:{}},this.fail={name:{},action:{}}}return _createClass(e,[{key:"set",value:function(e){var t=this;_lodash2.default.each(e,(function(e,n){t.success.name[n]=t.name+"_"+n.toUpperCase()+"_SUCCESS",t.fail.name[n]=t.name+"_"+n.toUpperCase()+"_FAIL",e.success=t.success.name[n],e.fail=t.fail.name[n],t[n]=t.createRequest.bind(t,e)}))}},{key:"get",value:function(){return{success:this.success.name,fail:this.fail.name}}},{key:"createRequest",value:function(){var e=arguments[0],t=arguments[1]||{body:{},promise:null},n=this.location,a=this.options,s=this.authorization,o=(e.uri,e.success),r=e.fail,i=_pathToRegexp2.default.compile(e.uri)(t.pathKeys);return a.method=e.method,a.body={},_lodash2.default.isEqual(t.body,{})||_lodash2.default.isUndefined(t.body)||(_lodash2.default.isEqual("get",a.method)?i=i+"?"+_lodash2.default.map(t.body,(function(e,t){return encodeURIComponent(t)+"="+encodeURIComponent(e)})).join("&"):a.body=JSON.stringify(t.body)),s()&&(a.headers.Authorization=s()),function(e){return e({type:IS_FETCHING}),fetch(n+i,a).then(checkStatus).then(createResponse,createErrorResponse).then((function(n){return e({type:STOP_FETCHING}),e({payload:{value:n.value,pathKeys:t.pathKeys,body:t.body,response:n.value},type:_lodash2.default.isEqual("success",n.type)?o:r,promise:t.promise})}))}}}]),e}(),actions=function(){function e(t,n,a,s){var o=arguments.length<=4||void 0===arguments[4]?{}:arguments[4];_classCallCheck(this,e);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this));return r.name=t,r.location=n,r.authorization=s,r.options={mode:"cors",credentials:"include",headers:{"Content-type":"application/json","X-Requested-With":"XMLHttpRequest"}},_lodash2.default.isUndefined(o.headers)||(r.options.headers=_lodash2.default.assign(r.options.headers,o.headers),delete o.headers),r.options=_lodash2.default.assign(r.options,o),r.set(a),r}return _inherits(e,abstractActions),_createClass(e,[{key:"constants",get:function(){var e=this.get();return e.initialize=this.name+"_initialize",e.finalize=this.name+"_finalize",e}}]),e}();exports.default=actions;var reducer=exports.reducer=function(){var e=!(arguments.length<=0||void 0===arguments[0])&&arguments[0],t=arguments[1],n=t.type;t.payload;switch(n){case IS_FETCHING:return!0;case STOP_FETCHING:return!1;default:return e}};
//# sourceMappingURL=/sm/36cd5f3618dfa9a8eec99b0a48d2b643173364adab6a45a0affd7551562cc8f8.map