Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/utils/request",["module","exports","require","frontend-js-web","./constants"],(function(e,r,t){window;{Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,o,i=t("frontend-js-web"),s=t("./constants");function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}!function(e){e[e.BadRequest=400]="BadRequest",e[e.Forbidden=403]="Forbidden",e[e.InternalServerError=500]="InternalServerError",e[e.MultipleChoices=300]="MultipleChoices",e[e.NoContent=204]="NoContent",e[e.NotFound=404]="NotFound",e[e.Unauthorized=401]="Unauthorized"}(n||(n={})),function(e){e.Error="Request Error",e.Unauthorized="Unauthorized Access"}(o||(o={}));const error=e=>({error:new Error(e)}),e={[n.NoContent]:{ok:!0},[n.BadRequest]:error(o.Error),[n.InternalServerError]:error(o.Error),[n.Unauthorized]:error(o.Unauthorized),[n.Forbidden]:error(o.Error),[n.NotFound]:error(o.Error),[n.MultipleChoices]:error(o.Error)};var a=async function request(r,t,o=s.ERROR_MESSAGE){const a="/o/analytics-settings-rest/v1.0".concat(r),u=await(0,i.fetch)(a,_objectSpread(_objectSpread({},t),{},{headers:{"Content-Type":"application/json"}})),c=e[u.status];if(u.status===n.Forbidden)window.location.reload();else{if(u.status===n.NoContent)return c;if(u.status>=n.MultipleChoices||c)return Liferay.Util.openToast({message:o,type:"danger"}),c;if("GET"===t.method)return u.json()}return u};r.default=a}}));
//# sourceMappingURL=request.js.map