/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../Error","../maybe"],(function(e,t,r,s){"use strict";let a;function n(e,n){let o=n.responseType;o?"array-buffer"!==o&&"blob"!==o&&"json"!==o&&"native"!==o&&"native-request-init"!==o&&"text"!==o&&(o="text"):o="json",n.responseType=o;const l=s.unwrap(n.signal);return delete n.signal,globalThis.invokeStaticMessage("request",{url:e,options:n},{signal:l}).then(function(){var s=t._asyncToGenerator((function*(t){let s,i,u,c,f;if(t.data)if(t.data instanceof ArrayBuffer){if(!("json"!==o&&"text"!==o&&"blob"!==o||(s=new Blob([t.data]),"json"!==o&&"text"!==o||(a||(a=new FileReaderSync),c=a.readAsText(s),"json"!==o)))){try{i=JSON.parse(c||null)}catch(b){const t={...b,url:e,requestOptions:n};throw new r("request:server",b.message,t)}if(i.error){const t={...i.error,url:e,requestOptions:n};throw new r("request:server",i.error.message,t)}}}else"native"===o&&(t.data.signal=l,u=yield fetch(t.data.url,t.data));switch(o){case"blob":f=s;break;case"json":f=i;break;case"native":f=u;break;case"text":f=c;break;default:f=t.data}return{data:f,requestOptions:n,ssl:t.ssl,url:e}}));return function(e){return s.apply(this,arguments)}}())}e.execute=n,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
