@microsoft/microsoft-graph-client
Version:
Microsoft Graph Client Library
8 lines • 77.1 kB
JavaScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
var MicrosoftGraph=function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==r(t)?t:t+""}function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s,u,c,l,d={exports:{}},h={exports:{}};function f(){return s||(s=1,function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(h)),h.exports}var p,v=function(){if(l)return c;l=1;var e=(u||(u=1,function(e){var t=f().default;function r(){e.exports=r=function(){return o},e.exports.__esModule=!0,e.exports.default=e.exports;var n,o={},a=Object.prototype,i=a.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",d=u.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(n){h=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var o=t&&t.prototype instanceof x?t:x,a=Object.create(o.prototype),i=new D(n||[]);return s(a,"_invoke",{value:P(e,r,i)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}o.wrap=f;var v="suspendedStart",y="suspendedYield",m="executing",g="completed",w={};function x(){}function b(){}function E(){}var k={};h(k,c,(function(){return this}));var R=Object.getPrototypeOf,O=R&&R(R(U([])));O&&O!==a&&i.call(O,c)&&(k=O);var A=E.prototype=x.prototype=Object.create(k);function T(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,r){function n(o,a,s,u){var c=p(e[o],e,a);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==t(d)&&i.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):r.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var o;s(this,"_invoke",{value:function(e,t){function a(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(a,a):a()}})}function P(e,t,r){var o=v;return function(a,i){if(o===m)throw Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:n,done:!0}}for(r.method=a,r.arg=i;;){var s=r.delegate;if(s){var u=C(s,r);if(u){if(u===w)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===v)throw o=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=m;var c=p(e,t,r);if("normal"===c.type){if(o=r.done?g:y,c.arg===w)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=g,r.method="throw",r.arg=c.arg)}}}function C(e,t){var r=t.method,o=e.iterator[r];if(o===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,C(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),w;var a=p(o,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,w;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,w):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,w)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function U(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function t(){for(;++o<e.length;)if(i.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=n,t.done=!0,t};return a.next=a}}throw new TypeError(t(e)+" is not iterable")}return b.prototype=E,s(A,"constructor",{value:E,configurable:!0}),s(E,"constructor",{value:b,configurable:!0}),b.displayName=h(E,d,"GeneratorFunction"),o.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,h(e,d,"GeneratorFunction")),e.prototype=Object.create(A),e},o.awrap=function(e){return{__await:e}},T(S.prototype),h(S.prototype,l,(function(){return this})),o.AsyncIterator=S,o.async=function(e,t,r,n,a){void 0===a&&(a=Promise);var i=new S(f(e,t,r,n),a);return o.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},T(A),h(A,d,"Generator"),h(A,c,(function(){return this})),h(A,"toString",(function(){return"[object Generator]"})),o.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},o.values=U,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,o){return s.type="throw",s.arg=e,t.next=r,o&&(t.method="next",t.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,w):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),w},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),w}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:U(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),w}},o}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(d)),d.exports)();c=e;try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return c}(),y=i(v);function m(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function g(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return w(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}}(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}"function"==typeof SuppressedError&&SuppressedError,function(e){e.GET="GET",e.PATCH="PATCH",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(p||(p={}));var x=function(){function e(r){if(t(this,e),this.requests=new Map,void 0!==r){var n=e.requestLimit;if(r.length>n){var o=new Error("Maximum requests limit exceeded, Max allowed number of requests are ".concat(n));throw o.name="Limit Exceeded Error",o}var a,i=g(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;this.addRequest(s)}}catch(e){i.e(e)}finally{i.f()}}}return a(e,[{key:"addRequest",value:function(t){var r=e.requestLimit;if(""===t.id){var n=new Error("Id for a request is empty, Please provide an unique id");throw n.name="Empty Id For Request",n}if(this.requests.size===r){var o=new Error("Maximum requests limit exceeded, Max allowed number of requests are ".concat(r));throw o.name="Limit Exceeded Error",o}if(this.requests.has(t.id)){var a=new Error("Adding request with duplicate id ".concat(t.id,", Make the id of the requests unique"));throw a.name="Duplicate RequestId Error",a}return this.requests.set(t.id,t),t.id}},{key:"removeRequest",value:function(e){for(var t=this.requests.delete(e),r=this.requests.entries(),n=r.next();!n.done;){var o=n.value[1].dependsOn;if(void 0!==o){var a=o.indexOf(e);-1!==a&&o.splice(a,1),0===o.length&&delete n.value[1].dependsOn}n=r.next()}return t}},{key:"getContent",value:function(){return m(this,void 0,void 0,y.mark((function t(){var r,n,o,a,i,s,u,c,l;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n={requests:r=[]},o=this.requests.entries(),!(a=o.next()).done){t.next=8;break}throw(i=new Error("No requests added yet, Please add at least one request.")).name="Empty Payload",i;case 8:if(e.validateDependencies(this.requests)){t.next=12;break}throw(s=new Error("Invalid dependency found, Dependency should be:\n1. Parallel - no individual request states a dependency in the dependsOn property.\n2. Serial - all individual requests depend on the previous individual request.\n3. Same - all individual requests that state a dependency in the dependsOn property, state the same dependency.")).name="Invalid Dependency",s;case 12:if(a.done){t.next=27;break}return u=a.value[1],t.next=16,e.getRequestData(u.request);case 16:if(void 0===(c=t.sent).body||void 0!==c.headers&&void 0!==c.headers["content-type"]){t.next=21;break}throw(l=new Error("Content-type header is not mentioned for request #".concat(u.id,", For request having body, Content-type header should be mentioned"))).name="Invalid Content-type header",l;case 21:c.id=u.id,void 0!==u.dependsOn&&u.dependsOn.length>0&&(c.dependsOn=u.dependsOn),r.push(c),a=o.next(),t.next=12;break;case 27:return n.requests=r,t.abrupt("return",n);case 29:case"end":return t.stop()}}),t,this)})))}},{key:"addDependency",value:function(e,t){if(!this.requests.has(e)){var r=new Error("Dependent ".concat(e," does not exists, Please check the id"));throw r.name="Invalid Dependent",r}if(void 0!==t&&!this.requests.has(t)){var n=new Error("Dependency ".concat(t," does not exists, Please check the id"));throw n.name="Invalid Dependency",n}if(void 0!==t){var o=this.requests.get(e);if(void 0===o.dependsOn&&(o.dependsOn=[]),-1!==o.dependsOn.indexOf(t)){var a=new Error("Dependency ".concat(t," is already added for the request ").concat(e));throw a.name="Duplicate Dependency",a}o.dependsOn.push(t)}else{for(var i,s=this.requests.entries(),u=s.next();!u.done&&u.value[1].id!==e;)i=u,u=s.next();if(void 0===i){var c=new Error("Can't add dependency ".concat(t,", There is only a dependent request in the batch"));throw c.name="Invalid Dependency Addition",c}var l=i.value[0];if(void 0===u.value[1].dependsOn&&(u.value[1].dependsOn=[]),-1!==u.value[1].dependsOn.indexOf(l)){var d=new Error("Dependency ".concat(l," is already added for the request ").concat(e));throw d.name="Duplicate Dependency",d}u.value[1].dependsOn.push(l)}}},{key:"removeDependency",value:function(e,t){var r=this.requests.get(e);if(void 0===r||void 0===r.dependsOn||0===r.dependsOn.length)return!1;if(void 0!==t){var n=r.dependsOn.indexOf(t);return-1!==n&&(r.dependsOn.splice(n,1),!0)}return delete r.dependsOn,!0}}],[{key:"validateDependencies",value:function(e){if(0===e.size){var t=new Error("Empty requests map, Please provide at least one request.");throw t.name="Empty Requests Error",t}return function(e){for(var t=e.entries(),r=t.next();!r.done;){var n=r.value[1];if(void 0!==n.dependsOn&&n.dependsOn.length>0)return!1;r=t.next()}return!0}(e)||function(e){var t=e.entries(),r=t.next(),n=r.value[1];if(void 0!==n.dependsOn&&n.dependsOn.length>0)return!1;var o=r;for(r=t.next();!r.done;){var a=r.value[1];if(void 0===a.dependsOn||1!==a.dependsOn.length||a.dependsOn[0]!==o.value[1].id)return!1;o=r,r=t.next()}return!0}(e)||function(e){var t,r=e.entries(),n=r.next(),o=n.value[1];if(void 0===o.dependsOn||0===o.dependsOn.length)t=o.id;else{if(1!==o.dependsOn.length)return!1;var a=o.dependsOn[0];if(a===o.id||!e.has(a))return!1;t=a}for(n=r.next();!n.done;){var i=n.value[1];if((void 0===i.dependsOn||0===i.dependsOn.length)&&t!==i.id)return!1;if(void 0!==i.dependsOn&&0!==i.dependsOn.length){if(1===i.dependsOn.length&&(i.id===t||i.dependsOn[0]!==t))return!1;if(i.dependsOn.length>1)return!1}n=r.next()}return!0}(e)}},{key:"getRequestData",value:function(t){return m(this,void 0,void 0,y.mark((function r(){var n,o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if((n={url:""}).url=t.url.replace(/^(?:http)?s?:?(?:\/\/)?[^/]+\/(?:v1.0|beta)?/i,""),n.method=t.method,o={},t.headers.forEach((function(e,t){o[t]=e})),Object.keys(o).length&&(n.headers=o),t.method!==p.PATCH&&t.method!==p.POST&&t.method!==p.PUT){r.next=10;break}return r.next=9,e.getRequestBody(t);case 9:n.body=r.sent;case 10:return r.abrupt("return",n);case 11:case"end":return r.stop()}}),r)})))}},{key:"getRequestBody",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r,n,o,a,i,s;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=!1,t.prev=1,o=e.clone(),t.next=5,o.json();case 5:n=t.sent,r=!0,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:if(r){t.next=33;break}if(t.prev=12,"undefined"==typeof Blob){t.next=23;break}return t.next=16,e.blob();case 16:return a=t.sent,i=new FileReader,t.next=20,new Promise((function(e){i.addEventListener("load",(function(){var t=i.result,r=new RegExp("^s*data:(.+?/.+?(;.+?=.+?)*)?(;base64)?,(.*)s*$").exec(t);e(r[4])}),!1),i.readAsDataURL(a)}));case 20:n=t.sent,t.next=28;break;case 23:if("undefined"==typeof Buffer){t.next=28;break}return t.next=26,e.buffer();case 26:s=t.sent,n=s.toString("base64");case 28:r=!0,t.next=33;break;case 31:t.prev=31,t.t1=t.catch(12);case 33:return t.abrupt("return",n);case 34:case"end":return t.stop()}}),t,null,[[1,9],[12,31]])})))}}])}();x.requestLimit=20;var b=function(){return a((function e(r){t(this,e),this.responses=new Map,this.update(r)}),[{key:"createResponseObject",value:function(e){var t=e.body,r={};if(r.status=e.status,void 0!==e.statusText&&(r.statusText=e.statusText),r.headers=e.headers,void 0!==r.headers&&void 0!==r.headers["Content-Type"]&&"application/json"===r.headers["Content-Type"].split(";")[0]){var n=JSON.stringify(t);return new Response(n,r)}return new Response(t,r)}},{key:"update",value:function(e){this.nextLink=e["@odata.nextLink"];for(var t=e.responses,r=0,n=t.length;r<n;r++)this.responses.set(t[r].id,this.createResponseObject(t[r]))}},{key:"getResponseById",value:function(e){return this.responses.get(e)}},{key:"getResponses",value:function(){return this.responses}},{key:"getResponsesIterator",value:y.mark((function e(){var t,r;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.responses.entries(),r=t.next();case 2:if(r.done){e.next=8;break}return e.next=5,r.value;case 5:r=t.next(),e.next=2;break;case 8:case"end":return e.stop()}}),e,this)}))}])}(),E=new Set(["graph.microsoft.com","graph.microsoft.us","dod-graph.microsoft.us","graph.microsoft.de","microsoftgraph.chinacloudapi.cn","canary.graph.microsoft.com"]);function k(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}function O(e,t){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},O(e,t)}function A(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&O(e,t)}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(T=function(){return!!e})()}function S(e,t,r){if(T())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&O(o,r.prototype),o}function P(e){var t="function"==typeof Map?new Map:void 0;return P=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return S(e,arguments,R(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),O(r,e)},P(e)}function C(e,t,r){return t=R(t),k(e,L()?Reflect.construct(t,r||[],R(e).constructor):t.apply(e,r))}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(L=function(){return!!e})()}var _=function(e){function r(e){var n;return t(this,r),n=C(this,r,[e]),Object.setPrototypeOf(n,r.prototype),n}return A(r,e),a(r,null,[{key:"setGraphClientError",value:function(e){var t;return e instanceof Error?t=e:(t=new r).customError=e,t}}])}(P(Error)),D=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],U=function(e){var t=e&&e.constructor&&e.constructor.name;if("Buffer"===t||"Blob"===t||"File"===t||"FormData"===t||"string"==typeof e)return e;if("ArrayBuffer"===t)e=Buffer.from(e);else if("Int8Array"===t||"Int16Array"===t||"Int32Array"===t||"Uint8Array"===t||"Uint16Array"===t||"Uint32Array"===t||"Uint8ClampedArray"===t||"Float32Array"===t||"Float64Array"===t||"DataView"===t)e=Buffer.from(e.buffer);else try{e=JSON.stringify(e)}catch(e){throw new Error("Unable to stringify the content")}return e},M=function(e){return q(e)},N=function(e,t){return t.forEach((function(e){return I(e)})),q(e,t)},q=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E;try{t=new URL(e)}catch(e){return!1}return"https:"===t.protocol&&(""===t.username&&""===t.password&&r.has(t.hostname.toLowerCase()))},I=function(e){if(-1!==e.indexOf("/"))throw new _("Please add only hosts or hostnames to the CustomHosts config. If the url is `http://example.com:3000/`, host is `example:3000`")};function F(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return H(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(e,t):void 0}}(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var j=function(){return a((function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t(this,e),this.middlewareOptions=new Map;var n,o=F(r);try{for(o.s();!(n=o.n()).done;){var a=n.value,i=a.constructor;this.middlewareOptions.set(i,a)}}catch(e){o.e(e)}finally{o.f()}}),[{key:"getMiddlewareOptions",value:function(e){return this.middlewareOptions.get(e)}},{key:"setMiddlewareOptions",value:function(e,t){this.middlewareOptions.set(e,t)}}])}();function B(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Q,V=function(){for(var e="",t=0;t<32;t++)8!==t&&12!==t&&16!==t&&20!==t||(e+="-"),e+=Math.floor(16*Math.random()).toString(16);return e},X=function(e,t,r){var n=null;if("undefined"!=typeof Request&&e instanceof Request)n=e.headers.get(r);else if(void 0!==t&&void 0!==t.headers)if("undefined"!=typeof Headers&&t.headers instanceof Headers)n=t.headers.get(r);else if(t.headers instanceof Array){for(var o=t.headers,a=0,i=o.length;a<i;a++)if(o[a][0]===r){n=o[a][1];break}}else void 0!==t.headers[r]&&(n=t.headers[r]);return n},G=function(e,t,r,n){if("undefined"!=typeof Request&&e instanceof Request)e.headers.set(r,n);else if(void 0!==t)if(void 0===t.headers)t.headers=new Headers(B({},r,n));else if("undefined"!=typeof Headers&&t.headers instanceof Headers)t.headers.set(r,n);else if(t.headers instanceof Array){for(var o=0,a=t.headers.length;o<a;o++){var i=t.headers[o];if(i[0]===r){i[1]=n;break}}o===a&&t.headers.push([r,n])}else Object.assign(t.headers,B({},r,n))},$=function(e,t,r,n){"undefined"!=typeof Request&&e instanceof Request?e.headers.append(r,n):void 0!==t&&(void 0===t.headers?t.headers=new Headers(B({},r,n)):"undefined"!=typeof Headers&&t.headers instanceof Headers?t.headers.append(r,n):t.headers instanceof Array?t.headers.push([r,n]):void 0===t.headers?t.headers=B({},r,n):void 0===t.headers[r]?t.headers[r]=n:t.headers[r]+=", ".concat(n))},z=function(e,t,r){if("undefined"!=typeof Request&&e instanceof Request&&e.headers.delete(r),void 0!==t&&void 0!==t.headers)if("undefined"!=typeof Headers&&t.headers instanceof Headers)t.headers.delete(r);else if(t.headers instanceof Array)for(var n=t.headers,o=r.toLowerCase(),a=n.length-1;a>=0;a--)n[a][0].toLowerCase()===o&&n.splice(a,1);else for(var i=t.headers,s=0,u=Object.keys(i);s<u.length;s++){var c=u[s];c.toLowerCase()===r.toLowerCase()&&delete i[c]}},Y=function(e,t){return m(void 0,void 0,void 0,y.mark((function r(){var n,o,a,i,s,u,c,l,d,h,f,p;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.headers.get("Content-Type")){r.next=6;break}return r.next=3,t.blob();case 3:r.t0=r.sent,r.next=9;break;case 6:return r.next=8,Promise.resolve(void 0);case 8:r.t0=r.sent;case 9:return n=r.t0,o=t.method,a=t.headers,i=t.referrer,s=t.referrerPolicy,u=t.mode,c=t.credentials,l=t.cache,d=t.redirect,h=t.integrity,f=t.keepalive,p=t.signal,r.abrupt("return",new Request(e,{method:o,headers:a,body:n,referrer:i,referrerPolicy:s,mode:u,credentials:c,cache:l,redirect:d,integrity:h,keepalive:f,signal:p}));case 12:case"end":return r.stop()}}),r)})))},W=a((function e(r,n){t(this,e),this.authenticationProvider=r,this.authenticationProviderOptions=n}));e.FeatureUsageFlag=void 0,(Q=e.FeatureUsageFlag||(e.FeatureUsageFlag={}))[Q.NONE=0]="NONE",Q[Q.REDIRECT_HANDLER_ENABLED=1]="REDIRECT_HANDLER_ENABLED",Q[Q.RETRY_HANDLER_ENABLED=2]="RETRY_HANDLER_ENABLED",Q[Q.AUTHENTICATION_HANDLER_ENABLED=4]="AUTHENTICATION_HANDLER_ENABLED";var J=function(){function r(){t(this,r),this.featureUsage=e.FeatureUsageFlag.NONE}return a(r,[{key:"setFeatureUsage",value:function(e){this.featureUsage=this.featureUsage|e}},{key:"getFeatureUsage",value:function(){return this.featureUsage.toString(16)}}],[{key:"updateFeatureUsageFlag",value:function(e,t){var n;e.middlewareControl instanceof j?n=e.middlewareControl.getMiddlewareOptions(r):e.middlewareControl=new j,void 0===n&&(n=new r,e.middlewareControl.setMiddlewareOptions(r,n)),n.setFeatureUsage(t)}}])}(),K=function(){function r(e){t(this,r),this.authenticationProvider=e}return a(r,[{key:"execute",value:function(t){return m(this,void 0,void 0,y.mark((function n(){var o,a,i,s,u,c;return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o="string"==typeof t.request?t.request:t.request.url,!(M(o)||t.customHosts&&N(o,t.customHosts))){n.next=13;break}return t.middlewareControl instanceof j&&(a=t.middlewareControl.getMiddlewareOptions(W)),a&&(i=a.authenticationProvider,s=a.authenticationProviderOptions),i||(i=this.authenticationProvider),n.next=7,i.getAccessToken(s);case 7:u=n.sent,c="Bearer ".concat(u),$(t.request,t.options,r.AUTHORIZATION_HEADER,c),J.updateFeatureUsageFlag(t,e.FeatureUsageFlag.AUTHENTICATION_HANDLER_ENABLED),n.next=14;break;case 13:t.options.headers&&delete t.options.headers[r.AUTHORIZATION_HEADER];case 14:return n.next=16,this.nextMiddleware.execute(t);case 16:return n.abrupt("return",n.sent);case 17:case"end":return n.stop()}}),n,this)})))}},{key:"setNext",value:function(e){this.nextMiddleware=e}}])}();K.AUTHORIZATION_HEADER="Authorization";var Z=function(){return a((function e(){t(this,e)}),[{key:"execute",value:function(e){return m(this,void 0,void 0,y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e.request,e.options);case 2:e.response=t.sent;case 3:case"end":return t.stop()}}),t)})))}}])}(),ee=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.DEFAULT_DELAY,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.DEFAULT_MAX_RETRIES,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.defaultShouldRetry;if(t(this,e),r>e.MAX_DELAY&&n>e.MAX_MAX_RETRIES){var a=new Error("Delay and MaxRetries should not be more than ".concat(e.MAX_DELAY," and ").concat(e.MAX_MAX_RETRIES));throw a.name="MaxLimitExceeded",a}if(r>e.MAX_DELAY){var i=new Error("Delay should not be more than ".concat(e.MAX_DELAY));throw i.name="MaxLimitExceeded",i}if(n>e.MAX_MAX_RETRIES){var s=new Error("MaxRetries should not be more than ".concat(e.MAX_MAX_RETRIES));throw s.name="MaxLimitExceeded",s}if(r<0&&n<0){var u=new Error("Delay and MaxRetries should not be negative");throw u.name="MinExpectationNotMet",u}if(r<0){var c=new Error("Delay should not be negative");throw c.name="MinExpectationNotMet",c}if(n<0){var l=new Error("MaxRetries should not be negative");throw l.name="MinExpectationNotMet",l}this.delay=Math.min(r,e.MAX_DELAY),this.maxRetries=Math.min(n,e.MAX_MAX_RETRIES),this.shouldRetry=o}return a(e,[{key:"getMaxDelay",value:function(){return e.MAX_DELAY}}])}();ee.DEFAULT_DELAY=3,ee.DEFAULT_MAX_RETRIES=3,ee.MAX_DELAY=180,ee.MAX_MAX_RETRIES=10,ee.defaultShouldRetry=function(){return!0};var te=function(){function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ee;t(this,r),this.options=e}return a(r,[{key:"isRetry",value:function(e){return-1!==r.RETRY_STATUS_CODES.indexOf(e.status)}},{key:"isBuffered",value:function(e,t){var r="string"==typeof e?t.method:e.method;if((r===p.PUT||r===p.PATCH||r===p.POST)&&"application/octet-stream"===X(e,t,"Content-Type"))return!1;return!0}},{key:"getDelay",value:function(e,t,n){var o,a=function(){return Number(Math.random().toFixed(3))},i=void 0!==e.headers?e.headers.get(r.RETRY_AFTER_HEADER):null;return o=null!==i?Number.isNaN(Number(i))?Math.round((new Date(i).getTime()-Date.now())/1e3):Number(i):t>=2?this.getExponentialBackOffTime(t)+n+a():n+a(),Math.min(o,this.options.getMaxDelay()+a())}},{key:"getExponentialBackOffTime",value:function(e){return Math.round(.5*(Math.pow(2,e)-1))}},{key:"sleep",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=1e3*e,t.abrupt("return",new Promise((function(e){return setTimeout(e,r)})));case 2:case"end":return t.stop()}}),t)})))}},{key:"getOptions",value:function(e){var t;return e.middlewareControl instanceof j&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor)),void 0===t&&(t=Object.assign(new ee,this.options)),t}},{key:"executeWithRetry",value:function(e,t,n){return m(this,void 0,void 0,y.mark((function o(){var a;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.nextMiddleware.execute(e);case 2:if(!(t<n.maxRetries&&this.isRetry(e.response)&&this.isBuffered(e.request,e.options)&&n.shouldRetry(n.delay,t,e.request,e.options,e.response))){o.next=13;break}return++t,G(e.request,e.options,r.RETRY_ATTEMPT_HEADER,t.toString()),a=this.getDelay(e.response,t,n.delay),o.next=8,this.sleep(a);case 8:return o.next=10,this.executeWithRetry(e,t,n);case 10:return o.abrupt("return",o.sent);case 13:return o.abrupt("return");case 14:case"end":return o.stop()}}),o,this)})))}},{key:"execute",value:function(t){return m(this,void 0,void 0,y.mark((function r(){var n;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return 0,n=this.getOptions(t),J.updateFeatureUsageFlag(t,e.FeatureUsageFlag.RETRY_HANDLER_ENABLED),r.next=5,this.executeWithRetry(t,0,n);case 5:return r.abrupt("return",r.sent);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"setNext",value:function(e){this.nextMiddleware=e}}])}();te.RETRY_STATUS_CODES=[429,503,504],te.RETRY_ATTEMPT_HEADER="Retry-Attempt",te.RETRY_AFTER_HEADER="Retry-After";var re=a((function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.DEFAULT_MAX_REDIRECTS,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.defaultShouldRedirect;if(t(this,e),r>e.MAX_MAX_REDIRECTS){var o=new Error("MaxRedirects should not be more than ".concat(e.MAX_MAX_REDIRECTS));throw o.name="MaxLimitExceeded",o}if(r<0){var a=new Error("MaxRedirects should not be negative");throw a.name="MinExpectationNotMet",a}this.maxRedirects=r,this.shouldRedirect=n}));re.DEFAULT_MAX_REDIRECTS=5,re.MAX_MAX_REDIRECTS=20,re.defaultShouldRedirect=function(){return!0};var ne=function(){function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new re;t(this,r),this.options=e}return a(r,[{key:"isRedirect",value:function(e){return-1!==r.REDIRECT_STATUS_CODES.indexOf(e.status)}},{key:"hasLocationHeader",value:function(e){return e.headers.has(r.LOCATION_HEADER)}},{key:"getLocationHeader",value:function(e){return e.headers.get(r.LOCATION_HEADER)}},{key:"isRelativeURL",value:function(e){return-1===e.indexOf("://")}},{key:"shouldDropAuthorizationHeader",value:function(e,t){var r,n,o=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,a=o.exec(e);null!==a&&(r=a[0]);var i=o.exec(t);return null!==i&&(n=i[0]),void 0!==r&&void 0!==n&&r!==n}},{key:"updateRequestUrl",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("string"!=typeof t.request){r.next=4;break}r.t0=e,r.next=7;break;case 4:return r.next=6,Y(e,t.request);case 6:r.t0=r.sent;case 7:t.request=r.t0;case 8:case"end":return r.stop()}}),r)})))}},{key:"getOptions",value:function(e){var t;return e.middlewareControl instanceof j&&(t=e.middlewareControl.getMiddlewareOptions(re)),void 0===t&&(t=Object.assign(new re,this.options)),t}},{key:"executeWithRedirect",value:function(e,t,n){return m(this,void 0,void 0,y.mark((function o(){var a,i;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.nextMiddleware.execute(e);case 2:if(a=e.response,!(t<n.maxRedirects&&this.isRedirect(a)&&this.hasLocationHeader(a)&&n.shouldRedirect(a))){o.next=18;break}if(++t,a.status!==r.STATUS_CODE_SEE_OTHER){o.next=10;break}e.options.method=p.GET,delete e.options.body,o.next=14;break;case 10:return i=this.getLocationHeader(a),!this.isRelativeURL(i)&&this.shouldDropAuthorizationHeader(a.url,i)&&(z(e.request,e.options,r.AUTHORIZATION_HEADER),z(e.request,e.options,r.COOKIE_HEADER)),o.next=14,this.updateRequestUrl(i,e);case 14:return o.next=16,this.executeWithRedirect(e,t,n);case 16:o.next=19;break;case 18:return o.abrupt("return");case 19:case"end":return o.stop()}}),o,this)})))}},{key:"execute",value:function(t){return m(this,void 0,void 0,y.mark((function n(){var o;return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return 0,o=this.getOptions(t),t.options.redirect=r.MANUAL_REDIRECT,J.updateFeatureUsageFlag(t,e.FeatureUsageFlag.REDIRECT_HANDLER_ENABLED),n.next=6,this.executeWithRedirect(t,0,o);case 6:return n.abrupt("return",n.sent);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"setNext",value:function(e){this.nextMiddleware=e}}])}();ne.REDIRECT_STATUS_CODES=[301,302,303,307,308],ne.STATUS_CODE_SEE_OTHER=303,ne.LOCATION_HEADER="Location",ne.AUTHORIZATION_HEADER="Authorization",ne.COOKIE_HEADER="Cookie",ne.MANUAL_REDIRECT="manual";var oe=function(){function e(){t(this,e)}return a(e,[{key:"execute",value:function(t){return m(this,void 0,void 0,y.mark((function r(){var n,o,a,i,s;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n="string"==typeof t.request?t.request:t.request.url,M(n)||t.customHosts&&N(n,t.customHosts)?((o=X(t.request,t.options,e.CLIENT_REQUEST_ID_HEADER))||(o=V(),G(t.request,t.options,e.CLIENT_REQUEST_ID_HEADER,o)),a="".concat(e.PRODUCT_NAME,"/").concat("3.1.0"),t.middlewareControl instanceof j&&(i=t.middlewareControl.getMiddlewareOptions(J)),i&&(s=i.getFeatureUsage(),a+=" (".concat(e.FEATURE_USAGE_STRING,"=").concat(s,")")),$(t.request,t.options,e.SDK_VERSION_HEADER,a)):(delete t.options.headers[e.CLIENT_REQUEST_ID_HEADER],delete t.options.headers[e.SDK_VERSION_HEADER]),r.next=4,this.nextMiddleware.execute(t);case 4:return r.abrupt("return",r.sent);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"setNext",value:function(e){this.nextMiddleware=e}}])}();oe.CLIENT_REQUEST_ID_HEADER="client-request-id",oe.SDK_VERSION_HEADER="SdkVersion",oe.PRODUCT_NAME="graph-js",oe.FEATURE_USAGE_STRING="featureUsage";var ae,ie=function(){return a((function e(){t(this,e)}),null,[{key:"getDefaultMiddlewareChain",value:function(e){var t=[],n=new K(e),o=new te(new ee),a=new oe,i=new Z;if(t.push(n),t.push(o),"object"===("undefined"==typeof process?"undefined":r(process))&&"function"==typeof require){var s=new ne(new re);t.push(s)}return t.push(a),t.push(i),t}}])}();e.ChaosStrategy=void 0,(ae=e.ChaosStrategy||(e.ChaosStrategy={}))[ae.MANUAL=0]="MANUAL",ae[ae.RANDOM=1]="RANDOM";var se,ue,ce,le,de=a((function r(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.ChaosStrategy.RANDOM,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Some error Happened",a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,u=arguments.length>5?arguments[5]:void 0;if(t(this,r),this.chaosStrategy=n,this.statusCode=a,this.statusMessage=o,this.chaosPercentage=void 0!==i?i:10,this.responseBody=s,this.headers=u,this.chaosPercentage>100)throw new Error("Error Pecentage can not be more than 100")})),he={GET:[429,500,502,503,504],POST:[429,500,502,503,504,507],PUT:[429,500,502,503,504,507],PATCH:[429,500,502,503,504],DELETE:[429,500,502,503,504,507]},fe={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},pe=function(){return a((function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new de,n=arguments.length>1?arguments[1]:void 0;t(this,e),this.options=r,this.manualMap=n}),[{key:"createResponseHeaders",value:function(e,t,r){var n=e.headers?new Headers(e.headers):new Headers;return n.append("Cache-Control","no-store"),n.append("request-id",t),n.append("client-request-id",t),n.append("x-ms-ags-diagnostic",""),n.append("Date",r),n.append("Strict-Transport-Security",""),429===e.statusCode&&n.append("retry-after","3"),n}},{key:"createResponseBody",value:function(e,t,r){if(e.responseBody)return e.responseBody;var n;e.statusCode>=400?n={error:{code:fe[e.statusCode],message:e.statusMessage,innerError:{"request-id":t,date:r}}}:n={};return n}},{key:"createResponse",value:function(e,t){var r=t.request,n=V(),o=new Date,a=this.createResponseHeaders(e,n,o.toString()),i=this.createResponseBody(e,n,o.toString()),s={url:r,status:e.statusCode,statusText:e.statusMessage,headers:a};t.response=new Response("string"==typeof i?i:JSON.stringify(i),s)}},{key:"sendRequest",value:function(t,r){return m(this,void 0,void 0,y.mark((function n(){return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.setStatusCode(t,r.request,r.options.method),!(t.chaosStrategy===e.ChaosStrategy.MANUAL&&!this.nextMiddleware||Math.floor(100*Math.random())<t.chaosPercentage)){n.next=5;break}this.createResponse(t,r),n.next=8;break;case 5:if(!this.nextMiddleware){n.next=8;break}return n.next=8,this.nextMiddleware.execute(r);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"getRandomStatusCode",value:function(e){var t=he[e];return t[Math.floor(Math.random()*t.length)]}},{key:"getRelativeURL",value:function(e){var t,r=/https?:\/\/graph\.microsoft\.com\/[^/]+(.+?)(\?|$)/;return null!==r.exec(e)&&(t=r.exec(e)[1]),t}},{key:"setStatusCode",value:function(t,r,n){var o=this;if(t.chaosStrategy===e.ChaosStrategy.MANUAL){if(void 0===t.statusCode){var a=this.getRelativeURL(r);void 0!==this.manualMap.get(a)?void 0!==this.manualMap.get(a).get(n)&&(t.statusCode=this.manualMap.get(a).get(n)):this.manualMap.forEach((function(e,r){new RegExp(r+"$").test(a)&&void 0!==o.manualMap.get(r).get(n)&&(t.statusCode=o.manualMap.get(r).get(n))}))}}else t.statusCode=this.getRandomStatusCode(n)}},{key:"getOptions",value:function(e){var t;return e.middlewareControl instanceof j&&(t=e.middlewareControl.getMiddlewareOptions(de)),void 0===t&&(t=Object.assign(new de,this.options)),t}},{key:"execute",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.getOptions(e),t.next=3,this.sendRequest(r,e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setNext",value:function(e){this.nextMiddleware=e}}])}();e.ResponseType=void 0,(se=e.ResponseType||(e.ResponseType={})).ARRAYBUFFER="arraybuffer",se.BLOB="blob",se.DOCUMENT="document",se.JSON="json",se.RAW="raw",se.STREAM="stream",se.TEXT="text",function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(ue||(ue={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(ce||(ce={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(le||(le={}));var ve=function(){function r(){t(this,r)}return a(r,null,[{key:"parseDocumentResponse",value:function(e,t){return"undefined"!=typeof DOMParser?new Promise((function(r,n){e.text().then((function(e){try{var o=(new DOMParser).parseFromString(e,t);r(o)}catch(e){n(e)}}))})):Promise.resolve(e.body)}},{key:"convertResponse",value:function(t,n){return m(this,void 0,void 0,y.mark((function o(){var a,i,s;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(204!==t.status){o.next=2;break}return o.abrupt("return",Promise.resolve());case 2:i=t.headers.get("Content-type"),o.t0=n,o.next=o.t0===e.ResponseType.ARRAYBUFFER?6:o.t0===e.ResponseType.BLOB?10:o.t0===e.ResponseType.DOCUMENT?14:o.t0===e.ResponseType.JSON?18:o.t0===e.ResponseType.STREAM?22:o.t0===e.ResponseType.TEXT?26:30;break;case 6:return o.next=8,t.arrayBuffer();case 8:return a=o.sent,o.abrupt("break",59);case 10:return o.next=12,t.blob();case 12:return a=o.sent,o.abrupt("break",59);case 14:return o.next=16,r.parseDocumentResponse(t,ue.TEXT_XML);case 16:return a=o.sent,o.abrupt("break",59);case 18:return o.next=20,t.json();case 20:return a=o.sent,o.abrupt("break",59);case 22:return o.next=24,Promise.resolve(t.body);case 24:return a=o.sent,o.abrupt("break",59);case 26:return o.next=28,t.text();case 28:return a=o.sent,o.abrupt("break",59);case 30:if(null===i){o.next=57;break}if(s=i.split(";")[0],!new RegExp(le.DOCUMENT).test(s)){o.next=38;break}return o.next=35,r.parseDocumentResponse(t,s);case 35:a=o.sent,o.next=55;break;case 38:if(!new RegExp(le.IMAGE).test(s)){o.next=42;break}a=t.blob(),o.next=55;break;case 42:if(s!==ce.TEXT_PLAIN){o.next=48;break}return o.next=45,t.text();case 45:a=o.sent,o.next=55;break;case 48:if(s!==ce.APPLICATION_JSON){o.next=54;break}return o.next=51,t.json();case 51:a=o.sent,o.next=55;break;case 54:a=Promise.resolve(t.body);case 55:o.next=58;break;case 57:a=Promise.resolve(t.body);case 58:return o.abrupt("break",59);case 59:return o.abrupt("return",a);case 60:case"end":return o.stop()}}),o)})))}},{key:"getResponse",value:function(t,n,o){return m(this,void 0,void 0,y.mark((function a(){var i;return y.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(n!==e.ResponseType.RAW){a.next=4;break}return a.abrupt("return",Promise.resolve(t));case 4:return a.next=6,r.convertResponse(t,n);case 6:if(i=a.sent,!t.ok){a.next=15;break}if("function"!=typeof o){a.next=12;break}o(null,i),a.next=13;break;case 12:return a.abrupt("return",i);case 13:a.next=16;break;case 15:throw i;case 16:case"end":return a.stop()}}),a)})))}}])}(),ye=a((function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;t(this,e),this.minValue=r,this.maxValue=n})),me=function(){function e(r,n){t(this,e),this._location=n,this._responseBody=r}return a(e,[{key:"location",get:function(){return this._location},set:function(e){this._location=e}},{key:"responseBody",get:function(){return this._responseBody},set:function(e){this._responseBody=e}}],[{key:"CreateUploadResult",value:function(t,r){return new e(t,r.get("location"))}}])}(),ge=function(){return a((function e(r,n,o){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t(this,e),this.DEFAULT_FILE_SIZE=5242880,this.client=r,!n.sliceFile)throw new _("Please pass the FileUpload object, StreamUpload object or any custom implementation of the FileObject interface");this.file=n,this.file=n,a.rangeSize||(a.rangeSize=this.DEFAULT_FILE_SIZE),this.options=a,this.uploadSession=o,this.nextRange=new ye(0,this.options.rangeSize-1)}),[{key:"parseRange",value:function(e){var t=e[0];if(void 0===t||""===t)return new ye;var r=t.split("-"),n=parseInt(r[0],10),o=parseInt(r[1],10);return Number.isNaN(o)&&(o=this.file.size-1),new ye(n,o)}},{key:"updateTaskStatus",value:function(e){this.uploadSession.expiry=new Date(e.expirationDateTime),this.nextRange=this.parseRange(e.nextExpectedRanges)}},{key:"getNextRange",value:function(){if(-1===this.nextRange.minValue)return this.nextRange;var e=this.nextRange.minValue,t=e+this.options.rangeSize-1;return t>=this.file.size&&(t=this.file.size-1),new ye(e,t)}},{key:"sliceFile",value:function(e){if(console.warn("The LargeFileUploadTask.sliceFile() function has been deprecated and moved into the FileObject interface."),this.file.content instanceof ArrayBuffer||this.file.content instanceof Blob||this.file.content instanceof Uint8Array)return this.file.content.slice(e.minValue,e.maxValue+1);throw new _("The LargeFileUploadTask.sliceFile() function expects only Blob, ArrayBuffer or Uint8Array file content. Please note that the sliceFile() function is deprecated.")}},{key:"upload",value:function(){return m(this,void 0,void 0,y.mark((function e(){var t,r,n,o,a,i,s;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.options&&this.options.uploadEventHandlers;case 1:if(this.uploadSession.isCancelled){e.next=26;break}if(-1!==(r=this.getNextRange()).maxValue){e.next=7;break}throw(n=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file")).name="Invalid Session",n;case 7:return e.next=9,this.file.sliceFile(r);case 9:return o=e.sent,e.next=12,this.uploadSliceGetRawResponse(o,r,this.file.size);case 12:if(a=e.sent){e.next=15;break}throw new _("Something went wrong! Large file upload slice response is null.");case 15:return e.next=17,ve.getResponse(a);case 17:if(i=e.sent,!(201===a.status||200===a.status&&i.id)){e.next=21;break}return this.reportProgress(t,r),e.abrupt("return",me.CreateUploadResult(i,a.headers));case 21:s={expirationDateTime:i.expirationDateTime||i.ExpirationDateTime,nextExpectedRanges:i.NextExpectedRanges||i.nextExpectedRanges},this.updateTaskStatus(s),this.reportProgress(t,r),e.next=1;break;case 26:case"end":return e.stop()}}),e,this)})))}},{key:"reportProgress",value:function(e,t){e&&e.progress&&e.progress(t,e.extraCallbackParam)}},{key:"uploadSlice",value:function(e,t,r){return m(this,void 0,void 0,y.mark((function n(){return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.client.api(this.uploadSession.url).headers({"Content-Length":"".concat(t.maxValue-t.minValue+1),"Content-Range":"bytes ".concat(t.minValue,"-").concat(t.maxValue,"/").concat(r),"Content-Type":"application/octet-stream"}).put(e);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"uploadSliceGetRawResponse",value:function(t,r,n){return m(this,void 0,void 0,y.mark((function o(){return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.client.api(this.uploadSession.url).headers({"Content-Length":"".concat(r.maxValue-r.minValue+1),"Content-Range":"bytes ".concat(r.minValue,"-").concat(r.maxValue,"/").concat(n),"Content-Type":"application/octet-stream"}).responseType(e.ResponseType.RAW).put(t);case 2:return o.abrupt("return",o.sent);case 3:case"end":return o.stop()}}),o,this)})))}},{key:"cancel",value:function(){return m(this,void 0,void 0,y.mark((function t(){var r;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.api(this.uploadSession.url).responseType(e.ResponseType.RAW).delete();case 2:return 204===(r=t.sent).status&&(this.uploadSession.isCancelled=!0),t.abrupt("return",r);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getStatus",value:function(){return m(this,void 0,void 0,y.mark((function e(){var t;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.api(this.uploadSession.url).get();case 2:return t=e.sent,this.updateTaskStatus(t),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){return m(this,void 0,void 0,y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getStatus();case 2:return e.next=4,this.upload();case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getUploadSession",value:function(){return this.uploadSession}}],[{key:"createUploadSession",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return m(this,void 0,void 0,y.mark((function o(){var a,i;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,e.api(t).headers(n).post(r);case 2:return a=o.sent,i={url:a.uploadUrl,expiry:new Date(a.expirationDateTime),isCancelled:!1},o.abrupt("return",i);case 5:case"end":return o.stop()}}),o)})))}}])}();function we(){return we="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=R(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},we.apply(null,arguments)}var xe=function(){return a((function e(r,n,o){if(t(this,e),this.content=r,this.name=n,this.size=o,!r||!n||!o)throw new _("Please provide the upload content, name of the file and size of the file")}),[{key:"sliceFile",value:function(e){return this.content.slice(e.minValue,e.maxValue+1)}}])}(),be=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5242880,r=62914560;return t>r&&(t=r),(e=t)>327680&&(e=320*Math.floor(e/327680)*1024),e};function Ee(e,t,r){return t=R(t),k(e,ke()?Reflect.construct(t,r||[],R(e).constructor):t.apply(e,r))}function ke(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ke=function(){return!!e})()}var Re=function(e){function r(e,n,o,a){return t(this,r),Ee(this,r,[e,n,o,a])}return A(r,e),a(r,[{key:"commit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rename";return m(this,void 0,void 0,y.mark((function r(){var n;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n={name:this.file.name,"@microsoft.graph.conflictBehavior":t,"@microsoft.graph.sourceUrl":this.uploadSession.url},r.next=3,this.client.api(e).put(n);case 3:return r.abrupt("return",r.sent);case 4:case"end":return r.stop()}}),r,this)})))}}],[{key:"constructCreateSessionUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.DEFAULT_UPLOAD_PATH;return e=e.trim(),""===(t=t.trim())&&(t="/"),"/"!==t[0]&&(t="/".concat(t)),"/"!==t[t.length-1]&&(t="".concat(t,"/")),"/me/drive/root:".concat(t.split("/").map((function(e){return encodeURIComponent(e)})).join("/")).concat(encodeURIComponent(e),":/createUploadSession")}},{key:"getFileInfo",value:function(e,t){var r,n;if("undefined"!=typeof Blob&&e instanceof Blob)n=(r=new File([e],t)).size;else if("undefined"!=typeof File&&e instanceof File)n=(r=e).size;else if("undefined"!=typeof Uint8Array&&e instanceof Uint8Array){var o=e;n=o.byteLength,r=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}return{content:r,size:n}}},{key:"create",value:function(e,t,n){return m(this,void 0,void 0,y.mark((function o(){var a,i,s;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(e&&t&&n){o.next=2;break}throw new _("Please provide the Graph client instance, file object and OneDriveLargeFileUploadOptions value");case 2:return a=n.fileName,i=r.getFileInfo(t,a),s=new xe(i.content,a,i.size),o.abrupt("return",this.createTaskWithFileObject(e,s,n));case 6:case"end":return o.stop()}}),o,this)})))}},{key:"createTaskWithFileObject",value:function(e,t,n){return m(this,void 0,void 0,y.mark((function o(){var a,i,s,u;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(e&&t&&n){o.next=2;break}throw new _("Please provide the Graph client instance, FileObject interface implementation and OneDriveLargeFileUploadOptions value");case 2:return a=n.uploadSessionURL?n.uploadSessionURL:r.constructCreateSessionUrl(n.fileName,n.path),i={fileName:n.fileName,fileDescription:n.fileDescription,conflictBehavior:n.conflictBehavior},o.next=6,r.createUploadSession(e,a,i);case 6:return s=o.sent,u=be(n.rangeSize),o.abrupt("return",new r(e,t,s,{rangeSize:u,uploadEventHandlers:n.uploadEventHandlers}));case 9:case"end":return o.stop()}}),o)})))}},{key:"createUploadSession",value:function(e,t,n){var o=this,a=Object.create(null,{createUploadSession:{get:function(){return e="createUploadSession",t=o,we(R(r),e,t);var e,t}}});return m(this,void 0,void 0,y.mark((function r(){var o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o={item:{"@microsoft.graph.conflictBehavior":(null==n?void 0:n.conflictBehavior)||"rename",name:null==n?void 0:n.fileName,description:null==n?void 0:n.fileDescription}},r.abrupt("return",a.createUploadSession.call(this,e,t,o));case 2:case"end":return r.stop()}}),r,this)})))}}])}(ge);Re.DEFAULT_UPLOAD_PATH="/";var Oe=function(){return a((function e(r,n,o){if(t(this,e),this.content=r,this.name=n,this.size=o,!r||!n||!o)throw new _("Please provide the Readable Stream content, name of the file and size of the file")}),[{key:"sliceFile",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r,n,o,a,i;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.maxValue-e.minValue+1,n=[],!this.previousSlice){t.next=14;break}if(!(e.minValue<this.previousSlice.range.minValue)){t.next=5;break}throw new _("An error occurred while uploading the stream. Please restart the stream upload from the first byte of the file.");case 5:if(!(e.minValue<this.previousSlice.range.maxValue)){t.next=14;break}if(o=this.previousSlice.range.minValue,a=this.previousSlice.range.maxValue,e.minValue!==o||e.maxValue!==a){t.next=10;break}return t.abrupt("return",this.previousSlice.fileSlice);case 10:if(e.maxValue!==a){t.next=12;break}return t.abrupt("return",this.previousSlice.fileSlice.slice(e.minValue,e.maxValue+1));case 12:n.push(this.previousSlice.fileSlice.slice(e.minValue,a+1)),r=e.maxValue-a;case 14:if(!this.content||!this.content.readable){t.next=26;break}if(!(this.content.readableLength>=r)){t.next=19;break}n.push(this.content.read(r)),t.next=24;break;case 19:return t.t0=n,t.next=22,this.readNBytesFromStream(r);case 22:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 24:t.next=27;break;case 26:throw new _("Stream is not readable.");case 27:return i=Buffer.concat(n),this.previousSlice={fileSlice:i,range:e},t.abrupt("return",i);case 30:case"end":return t.stop()}}),t,this)})))}},{key:"readNBytesFromStream",value:function(e){var t=this;return new Promise((function(r,n){var o=[],a=e,i=0;t.content.on("end",(function(){if(a>0)return n(new _("Stream ended before reading required range size"))})),t.content.on("readable",(function(){for(var s;i<e&&null!==(s=t.content.read(a));)i+=s.length,o.push(s),a>0&&(a=e-i);return i===e?r(Buffer.concat(o)):t.content&&t.content.readable?void 0:n(new _("Error encountered while reading the stream during the upload"))}))}))}}])}(),Ae=function(){return a((function e(r,n,o,a){t(this,e),this.client=r,this.collection=n.value,this.nextLink=n["@odata.nextLink"],this.deltaLink=n["@odata.deltaLink"],this.callback=o,this.cursor=0,this.complete=!1,this.requestOptions=a}),[{key:"iterationHelper",value:function(){if(void 0===this.collection)return!1;for(var e=!0;e&&this.cursor<this.collection.length;){var t=this.collection[this.cursor];e=this.callback(t),this.cursor++}return e}},{key:"fetchAndUpdateNextPageData",value:function(){return m(this,void 0,void 0,y.mark((function e(){var t,r;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.client.api(this.nextLink),this.requestOptions&&(this.requestOptions.headers&&(t=t.headers(this.requestOptions.headers)),this.requestOptions.middlewareOptions&&(t=t.middlewareOptions(this.requestOptions.middlewareOptions)),this.requestOptions.options&&(t=t.options(this.requestOptions.options))),e.next=4,t.get();case 4:r=e.sent,this.collection=r.value,this.cursor=0,this.nextLink=r["@odata.nextLink"],this.deltaLink=r["@odata.deltaLink"];case 9:case"end":return e.stop()}}),e,this)})))}},{key:"getDeltaLink",value:function(){return this.deltaLink}},{key:"iterate",value:function(){return m(this,void 0,void 0,y.mark((function e(){var t;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.iterationHelper();case 1:if(!t){e.next=11;break}if(void 0===this.nextLink){e.next=8;break}return e.next=5,this.fetchAndUpdateNextPageData();case 5:t=this.iterationHelper(),e.next=9;break;case 8:t=!1;case 9:e.next=1;break;case 11:void 0===this.nextLink&&this.cursor>=this.collection.length&&(this.complete=!0);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){return m(this,void 0,void 0,y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.iterate());case 1:case"end":return e.stop()}}),e,this)})))}},{key:"isComplete",value:function(){return this.complete}}])}();function Te(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Se(e){return function(e){if(Array.isArray(e))return Te(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Te(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Te(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Pe=function(){return a((function e(r){t(this,e),this.provider=r}),[{key:"getAccessToken",value:function(){return m(this,void 0,void 0,y.mark((function e(){var t=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){t.provider((function(n,o){return m(t,void 0,void 0,y.mark((function t(){var a;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!o){t.next=4;break}e(o),t.next=9;break;case 4:return n||("Access token is undefined or empty.\t\t\t\t\t\tPlease provide a valid token.\t\t\t\t\t\tFor more help - https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CustomAuthenticationProvider.md",n=new _("Access token is undefined or empty.\t\t\t\t\t\tPlease provide a valid token.\t\t\t\t\t\tFor more help - https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CustomAuthenticationProvider.md")),t.next=7,_.setGraphClientError(n);case 7:a=t.sent,r(a);case 9:case"end":return t.stop()}}),t)})))}))})));case 1:case"end":return e.stop()}}),e)})))}}])}();function Ce(e,t,r){return t=R(t),k(e,Le()?Reflect.construct(t,r||[],R(e).constructor):t.apply(e,r))}function Le(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Le=function(){return!!e})()}var _e=function(e){function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,o=arguments.length>1?arguments[1]:void 0,a=arguments.length>2?arguments[2]:void 0;return t(this,r),e=Ce(this,r,[o||a&&a.message]),Object.setPrototypeOf(e,r.prototype),e.statusCode=n,e.code=null,e.requestId=null,e.date=new Date,e.body=null,e.stack=a?a.stack:e.stack,e}return A(r,e),a(r)}(P(Error)),De=function(){function e(){t(this,e)}return a(e,null,[{key:"constructError",value:function(e,t,r){var n=new _e(t,"",e);return void 0!==e.name&&(n.code=e.name),n.body=e.toString(),n.date=new Date,n.headers=null==r?void 0:r.headers,n}},{key:"constructErrorFromResponse",value:function(e,t,r){var n=e.error,o=new _e(t,n.message);return o.code=n.code,void 0!==n.innerError&&(o.requestId=n.innerError["request-id"],o.date=new Date(n.innerError.date)),o.body=JSON.stringify(n),o.headers=null==r?void 0:r.headers,o}},{key:"getError",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0;return m(this,void 0,void 0,y.mark((function a(){var i;return y.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(t&&t.error?i=e.constructErrorFromResponse(t,r,o):t instanceof Error?i=e.constructError(t,r,o):(i=new _e(r)).body=t,"function"!=typeof n){a.next=5;break}n(i,null),a.next=6;break;case 5:return a.abrupt("return",i);case 6:case"end":return a.stop()}}),a)})))}}])}();function Ue(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Me(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Me(e,t):void 0}}(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function Me(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Ne=function(){return a((function e(r,n,o){var a=this;t(this,e),this.parsePath=function(e){if(-1!==e.indexOf("https://")){var t;try{t=new URL(e)}catch(t){throw new _("Unable to parse the URL: "+e)}if(""!==t.username||""!==t.password)throw new _("URL cannot contain user credentials: "+e);var r=e.substring(8),n=r.indexOf("/");-1!==n&&(a.urlComponents.host="https://"+r.substring(0,n),e=r.substring(n+1,r.length));var o=e.indexOf("/");-1!==o&&(a.urlComponents.version=e.substring(0,o),e=e.substring(o+1,e.length))}"/"===e.charAt(0)&&(e=e.substr(1));var i=e.indexOf("?");if(-1===i)a.urlComponents.path=e;else{a.urlComponents.path=e.substr(0,i);var s,u=Ue(e.substring(i+1,e.length).split("&"));try{for(u.s();!(s=u.n()).done;){var c=s.value;a.parseQueryParameter(c)}}catch(e){u.e(e)}finally{u.f()}}},this.httpClient=r,this.config=n,this.urlComponents={host:this.config.baseUrl,version:this.config.defaultVersion,oDataQueryParams:{},otherURLQueryParams:{},otherURLQueryOptions:[]},this._headers={},this._options={},this._middlewareOptions=[],this.parsePath(o)}),[{key:"addCsvQueryParameter",value:function(e,t,r){this.urlComponents.oDataQueryParams[e]=this.urlComponents.oDataQueryParams[e]?this.urlComponents.oDataQueryParams[e]+",":"";var n=[];r.length>1&&"string"==typeof t?n=Array.prototype.slice.call(r):"string"==typeof t?n.push(t):n=n.concat(t),this.urlComponents.oDataQueryParams[e]+=n.join(",")}},{key:"buildFullUrl",value:function(){var e,t,r=(e=[this.urlComponents.host,this.urlComponents.version,this.urlComponents.path],t=function(e){return e.replace(/^\/+/,"")},Array.prototype.slice.call(e).reduce((function(e,r){return[(n=e,n.replace(/\/+$/,"")),t(r)].join("/");var n}))+this.createQueryString());return this.config.debugLogging&&console.log(r),r}},{key:"createQueryString",value:function(){var e=this.urlComponents,t=[];if(0!==Object.keys(e.oDataQueryParams).length)for(var r in e.oDataQueryParams)Object.prototype.hasOwnProperty.call(e.oDataQueryParams,r)&&t.push(r+"="+e.oDataQueryParams[r]);if(0!==Object.keys(e.otherURLQueryParams).length)for(var n in e.otherURLQueryParams)Object.prototype.hasOwnProperty.call(e.otherURLQueryParams,n)&&t.push(n+"="+e.otherURLQueryParams[n]);if(0!==e.otherURLQueryOptions.length){var o,a=Ue(e.otherURLQueryOptions);try{for(a.s();!(o=a.n()).done;){var i=o.value;t.push(i)}}catch(e){a.e(e)}finally{a.f()}}return t.length>0?"?"+t.join("&"):""}},{key:"parseQueryParameter",value:function(e){if("string"==typeof e)if("?"===e.charAt(0)&&(e=e.substring(1)),-1!==e.indexOf("&")){var t,r=Ue(e.split("&"));try{for(r.s();!(t=r.n()).done;){var n=t.value;this.parseQueryParamenterString(n)}}catch(e){r.e(e)}finally{r.f()}}else this.parseQueryParamenterString(e);else if(e.constructor===Object)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&this.setURLComponentsQueryParamater(o,e[o]);return this}},{key:"parseQueryParamenterString",value:function(e){if(this.isValidQueryKeyValuePair(e)){var t=e.indexOf("="),r=e.substring(0,t),n=e.substring(t+1);this.setURLComponentsQueryParamater(r,n)}else this.urlComponents.otherURLQueryOptions.push(e)}},{key:"setURLComponentsQueryParamater",value:function(e,t){if(-1!==D.indexOf(e)){var r=this.urlComponents.oDataQueryParams[e],n=r&&("$expand"===e||"$select"===e||"$orderby"===e);this.urlComponents.oDataQueryParams[e]=n?r+","+t:t}else this.urlComponents.otherURLQueryParams[e]=t}},{key:"isValidQueryKeyValuePair",value:function(e){var t=e.indexOf("=");return-1!==t&&!(-1!==e.indexOf("(")&&e.indexOf("(")<t)}},{key:"updateRequestOptions",value:function(e){var t=Object.assign({},e.headers);if(void 0!==this.config.fetchOptions){var n=Object.assign({},this.config.fetchOptions);Object.assign(e,n),void 0!==r(this.config.fetchOptions.headers)&&(e.headers=Object.assign({},this.config.fetchOptions.headers))}Object.assign(e,this._options),void 0!==e.headers&&Object.assign(t,e.headers),Object.assign(t,this._headers),e.headers=t}},{key:"send",value:function(e,t,r){var n;return m(this,void 0,void 0,y.mark((function o(){var a,i,s,u,c,l;return y.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=new j(this._middlewareOptions),this.updateRequestOptions(t),s=null===(n=this.config)||void 0===n?void 0:n.customHosts,o.prev=3,o.next=6,this.httpClient.sendRequest({request:e,options:t,middlewareControl:i,customHosts:s});case 6:return u=o.sent,a=u.response,o.next=10,ve.getResponse(a,this._responseType,r);case 10:return c=o.sent,o.abrupt("return",c);case 14:if(o.prev=14,o.t0=o.catch(3),!(o.t0 instanceof _)){o.next=18;break}throw o.t0;case 18:return a&&(l=a.status),o.next=21,De.getError(o.t0,l,r,a);case 21:throw o.sent;case 23:case"end":return o.stop()}}),o,this,[[3,14]])})))}},{key:"setHeaderContentType",value:function(){if(this._headers){for(var e=0,t=Object.keys(this._headers);e<t.length;e++){if("content-type"===t[e].toLowerCase())return}this.header("Content-Type","application/json")}else this.header("Content-Type","application/json")}},{key:"header",value:function(e,t){return this._headers[e]=t,this}},{key:"headers",value:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this._headers[t]=e[t]);return this}},{key:"option",value:function(e,t){return this._options[e]=t,this}},{key:"options",value:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this._options[t]=e[t]);return this}},{key:"middlewareOptions",value:function(e){return this._middlewareOptions=e,this}},{key:"version",value:function(e){return this.urlComponents.version=e,this}},{key:"responseType",value:function(e){return this._responseType=e,this}},{key:"select",value:function(e){return this.addCsvQueryParameter("$select",e,arguments),this}},{key:"expand",value:function(e){return this.addCsvQueryParameter("$expand",e,arguments),this}},{key:"orderby",value:function(e){return this.addCsvQueryParameter("$orderby",e,arguments),this}},{key:"filter",value:function(e){return this.urlComponents.oDataQueryParams.$filter=e,this}},{key:"search",value:function(e){return this.urlComponents.oDataQueryParams.$search=e,this}},{key:"top",value:function(e){return this.urlComponents.oDataQueryParams.$top=e,this}},{key:"skip",value:function(e){return this.urlComponents.oDataQueryParams.$skip=e,this}},{key:"skipToken",value:function(e){return this.urlComponents.oDataQueryParams.$skipToken=e,this}},{key:"count",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.urlComponents.oDataQueryParams.$count=e.toString(),this}},{key:"query",value:function(e){return this.parseQueryParameter(e)}},{key:"get",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r,n,o;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.buildFullUrl(),n={method:p.GET},t.next=4,this.send(r,n,e);case 4:return o=t.sent,t.abrupt("return",o);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"post",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){var n,o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=this.buildFullUrl(),o={method:p.POST,body:U(e)},"FormData"===(e&&e.constructor&&e.constructor.name)?o.headers={}:(this.setHeaderContentType(),o.headers=this._headers),r.next=6,this.send(n,o,t);case 6:return r.abrupt("return",r.sent);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"create",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.post(e,t);case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"put",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){var n,o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=this.buildFullUrl(),this.setHeaderContentType(),o={method:p.PUT,body:U(e)},r.next=5,this.send(n,o,t);case 5:return r.abrupt("return",r.sent);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"patch",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){var n,o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=this.buildFullUrl(),this.setHeaderContentType(),o={method:p.PATCH,body:U(e)},r.next=5,this.send(n,o,t);case 5:return r.abrupt("return",r.sent);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"update",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.patch(e,t);case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r,this)})))}},{key:"delete",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r,n;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.buildFullUrl(),n={method:p.DELETE},t.next=4,this.send(r,n,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"del",value:function(e){return m(this,void 0,void 0,y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delete(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getStream",value:function(t){return m(this,void 0,void 0,y.mark((function r(){var n,o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=this.buildFullUrl(),o={method:p.GET},this.responseType(e.ResponseType.STREAM),r.next=5,this.send(n,o,t);case 5:return r.abrupt("return",r.sent);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"putStream",value:function(e,t){return m(this,void 0,void 0,y.mark((function r(){var n,o;return y.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=this.buildFullUrl(),o={method:p.PUT,headers:{"Content-Type":"application/octet-stream"},body:e},r.next=4,this.send(n,o,t);case 4:return r.abrupt("return",r.sent);case 5:case"end":return r.stop()}}),r,this)})))}}])}(),qe=function(){return a((function e(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];if(t(this,e),!n||!n.length){var a=new Error;throw a.name="InvalidMiddlewareChain",a.message="Please provide a default middleware chain or custom middleware chain",a}this.setMiddleware.apply(this,n)}),[{key:"setMiddleware",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.length>1?this.parseMiddleWareArray(t):this.middleware=t[0]}},{key:"parseMiddleWareArray",value:function(e){e.forEach((function(t,r){r<e.length-1&&t.setNext(e[r+1])})),this.middleware=e[0]}},{key:"sendRequest",value:function(e){return m(this,void 0,void 0,y.mark((function t(){var r;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e.request||void 0!==e.options){t.next=5;break}throw(r=new Error).name="InvalidRequestOptions",r.message="Unable to execute the middleware, Please provide valid options for a request",r;case 5:return t.next=7,this.middleware.execute(e);case 7:return t.abrupt("return",e);case 8:case"end":return t.stop()}}),t,this)})))}}])}(),Ie=function(){function e(){t(this,e)}return a(e,null,[{key:"createWithAuthenticationProvider",value:function(t){var n=new K(t),o=new te(new ee),a=new oe,i=new Z;if(n.setNext(o),"object"===("undefined"==typeof process?"undefined":r(process))&&"function"==typeof require){var s=new ne(new re);o.setNext(s),s.setNext(a)}else o.setNext(a);return a.setNext(i),e.createWithMiddleware(n)}},{key:"createWithMiddleware",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return S(qe,t)}}])}(),Fe=function(){function e(r){for(var n in t(this,e),this.config={baseUrl:"https://graph.microsoft.com/",debugLogging:!1,defaultVersion:"v1.0"},function(){if("undefined"==typeof Promise&&"undefined"==typeof fetch){var e=new Error("Library cannot function without Promise and fetch. So, please provide polyfill for them.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof Promise){var t=new Error("Library cannot function without Promise. So, please provide polyfill for it.");throw t.name="PolyFillNotAvailable",t}if("undefined"==typeof fetch){var r=new Error("Library cannot function without fetch. So, please provide polyfill for it.");throw r.name="PolyFillNotAvailable",r}}(),r)Object.prototype.hasOwnProperty.call(r,n)&&(this.config[n]=r[n]);var o;if(void 0!==r.authProvider&&void 0!==r.middleware){var a=new Error;throw a.name="AmbiguityInInitialization",a.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain not both",a}if(void 0!==r.authProvider)o=Ie.createWithAuthenticationProvider(r.authProvider);else{if(void 0===r.middleware){var i=new Error;throw i.name="InvalidMiddlewareChain",i.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain",i}o=S(qe,Se([].concat(r.middleware)))}this.httpClient=o}return a(e,[{key:"api",value:function(e){return new Ne(this.httpClient,this.config,e)}}],[{key:"init",value:function(t){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]="authProvider"===n?new Pe(t[n]):t[n]);return e.initWithMiddleware(r)}},{key:"initWithMiddleware",value:function(t){return new e(t)}}])}();return e.AuthenticationHandler=K,e.AuthenticationHandlerOptions=W,e.BatchRequestContent=x,e.BatchResponseContent=b,e.ChaosHandler=pe,e.ChaosHandlerOptions=de,e.Client=Fe,e.CustomAuthenticationProvider=Pe,e.FileUpload=xe,e.GraphClientError=_,e.GraphError=_e,e.GraphRequest=Ne,e.HTTPMessageHandler=Z,e.LargeFileUploadTask=ge,e.MiddlewareFactory=ie,e.OneDriveLargeFileUploadTask=Re,e.PageIterator=Ae,e.Range=ye,e.RedirectHandler=ne,e.RedirectHandlerOptions=re,e.RetryHandler=te,e.RetryHandlerOptions=ee,e.StreamUpload=Oe,e.TelemetryHandler=oe,e.TelemetryHandlerOptions=J,e.UploadResult=me,e.getValidRangeSize=be,e}({});