/**
* @license
* v1.2.8-4
* MIT (https://github.com/pnp/pnpjs/blob/master/LICENSE)
* Copyright (c) 2019 Microsoft
* docs: https://pnp.github.io/pnpjs/
* source: https://github.com/pnp/pnpjs
* bugs: https://github.com/pnp/pnpjs/issues
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@pnp/common"),require("@pnp/odata"),require("@pnp/sp"),require("@pnp/logging")):"function"==typeof define&&define.amd?define(["exports","@pnp/common","@pnp/odata","@pnp/sp","@pnp/logging"],e):e((t.pnp=t.pnp||{},t.pnp["sp-clientsvc"]={}),t.pnp.common,t.pnp.odata,t.pnp.sp,t.pnp.logging)}(this,function(t,p,h,l,i){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function e(){return''}function a(t,e){void 0===t&&(t=null),void 0===e&&(e=null);var n=[];return n.push(''),null===t||t.length<1?(n.push(''),n.push("")):(n.push(''),n.push(""),[].push.apply(n,t.map(function(t){return''})),n.push("")),n.push(""),null!==e&&(e.length<1?(n.push(''),n.push("")):(n.push(''),n.push(""),[].push.apply(n,e.map(function(t){return''})),n.push("")),n.push("")),n.push(""),n.join("")}function o(t,e,n){var r=[];return r.push(''),r.push(''+n+""),r.push(""),r.join("")}function u(t,e){var n=[];if(n.push(''),null!==e){var r=e.toArray();r.length<1?n.push(""):(n.push(""),[].push.apply(n,r.map(function(t){return''+t.value+""})),n.push(""))}return n.push(""),n.join("")}function c(n){return Object.getOwnPropertyNames(n).map(function(t){var e=n[t];return"boolean"==typeof e?o(t,"Boolean",""+e):"number"==typeof e?o(t,"Number",""+e):"string"==typeof e?o(t,"String",""+e):""},[])}function d(t){for(var e=[],n=1;n',e)}function f(t,e){for(var n=[],r=2;r',n)}function n(t,e){for(var n=[],r=2;r',n)}var y=function(){function n(t){void 0===t&&(t=[]),this._p=t}return n.build=function(t){void 0===t&&(t=[]);var e=new n;return[].push.apply(e._p,t),e},n.prototype.string=function(t){return this.a("String",t)},n.prototype.number=function(t){return this.a("Number",t.toString())},n.prototype.boolean=function(t){return this.a("Boolean",t.toString())},n.prototype.strArray=function(t){return this.a("Array",t.map(function(t){return'"}).join(""))},n.prototype.objectPath=function(t){return this.a("ObjectPath",t.toString())},n.prototype.toArray=function(){return this._p},n.prototype.a=function(t,e){return this._p.push({type:t,value:e}),this},n}();function b(t,e){for(var n=[],r=2;r'),null!==e){var i=e.toArray();i.length<1?o.push(""):(o.push(""),[].push.apply(o,i.map(function(t){return"ObjectPath"===t.type?'':''+t.value+""})),o.push(""))}return o.push(""),new P(o.join(""),n)}function _(t){var e=[],n=[];return t.forEach(function(t){n.push(t.path),e.push.apply(e,t.actions)}),['',"",e.join(""),"","",n.join(""),"",""].join("")}var P=function(t,e,n,r){void 0===e&&(e=[]),void 0===n&&(n=-1),void 0===r&&(r=[]),this.path=t,this.actions=e,this.id=n,this.replaceAfter=r};function I(t,e){return e.replace(/\$\$ID\$\$/g,t)}function $(t,e){return e.replace(/\$\$PATH_ID\$\$/g,t)}function g(t,e){return e.replace(/\$\$PARENT_ID\$\$/g,t)}function v(t,e,n){void 0===n&&(n=function(t){return t});var r=/\$\$OP_PARAM_ID_(\d+)\$\$/gi.exec(e);if(null!==r)for(var o=1;o')),this.addChildRelationship(t,this._siteIndex)}return this._siteIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webIndex",{get:function(){if(this._webIndex<0){var t=this.contextIndex;this._webIndex=this.add(d("Web",'')),this.addChildRelationship(t,this._webIndex)}return this._webIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contextIndex",{get:function(){return this._contextIndex<0&&(this._contextIndex=this.add(n("Current","{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}",''))),this._contextIndex},enumerable:!0,configurable:!0}),e.prototype.toBody=function(){return p.objectDefinedNotNull(this._xml)||(this._xml=_(this.toIndexedTree())),this._xml},e.prototype.toIndexedTree=function(){var o=this,i=-1,s=-1,a=[];return this.toArray().map(function(t,e,n){var r=++i;return a.push(r),t.path=v(a,I(r.toString(),t.path)),0<=s&&(t.path=g(s.toString(),t.path)),t.actions=t.actions.map(function(t){return I((++i).toString(),$(r.toString(),t))}),o.getChildRelationship(e).forEach(function(t){n[t].path=g(r.toString(),n[t].path)}),s=r,t})},e.prototype.dirty=function(){this._xml=null},e}(),j=function(){function t(t){this.op=t}return t.prototype.parse=function(t){var e=this;return t.text().then(function(e){if(!t.ok)throw Error(e);try{return JSON.parse(e)}catch(t){throw Error(e)}}).then(function(t){if(0')),new t(this,r)},t.prototype.getChildProperty=function(t,e){var n=this._objectPaths.copy();return n.add(d(e)),new t(this,n)},t.prototype.send=function(t,e,n){void 0===e&&(e={}),void 0===n&&(n=null);var r=t.clone();return p.objectDefinedNotNull(n)||(n=new j(r.last)),this.hasBatch?e=p.extend(e,{clientsvc_ObjectPaths:r}):p.hOP(e,"body")||(e=p.extend(e,{body:r.toBody()})),o.prototype.postCore.call(this,e,n)},t.prototype.sendGet=function(e){var n=this,t=this._objectPaths.copy().appendActionToLast(a(this.getSelects()));return this.send(t).then(function(t){return p.extend(new e(n),t)})},t.prototype.sendGetCollection=function(e){var t=this._objectPaths.copy().appendActionToLast(a([],this.getSelects()));return this.send(t).then(function(t){return t.map(function(t){return p.extend(e(t),t)})})},t.prototype.invokeMethod=function(t,e){void 0===e&&(e=null);for(var n=[],r=2;r'].concat(n,[r])))),this.send(i)},t}(h.Queryable),A=function(r){function t(t,e){var n=r.call(this,e)||this;return n.parentUrl=t,n}return s(t,r),t.prototype.executeImpl=function(){if(this.requests.length<1)return i.Logger.write("Resolving empty batch.",1),Promise.resolve();var t=new D(this.parentUrl,this.batchId);return t.appendRequests(this.requests),t.execute()},t}(h.ODataBatch),D=function(o){function t(t,e){var n=o.call(this,t)||this;n.batchId=e,n._requests=[],n._builderIndex=1;var r=f("GetTaxonomySession","{981cbc68-9edc-4f8d-872f-71146fcbb84f}");return r.path=I("0",r.path),r.actions.push(I("1",$("0",''))),n._objectPaths.add(r),n}return s(t,o),t.prototype.appendRequests=function(t){var p=this;t.forEach(function(t){var s=t.options.clientsvc_ObjectPaths,e=s.toArray();if(!(e.length<0)){var a=function(t){return t};/GetTaxonomySession/i.test(e[0].path)&&((e=e.slice(1))[0].path=g("0",e[0].path),a=function(t){return t-1});var u=-1,c=[];e.map(function(t,e,n){var r=++p._builderIndex;c.push(r);var o=v(c,I(r.toString(),t.path),a);0<=u&&(o=g(u.toString(),o));var i=t.actions.map(function(t){return I((++p._builderIndex).toString(),$(r.toString(),t))});return s.getChildRelationship(e+1).map(function(t){return t-1}).forEach(function(t){n[t].path=g(r.toString(),n[t].path)}),u=r,new P(o,i)}).forEach(function(t){return p._objectPaths.add(t)});var n=p._objectPaths.toArray(),r=new j(n[n.length-1]);t.parser instanceof h.CachingParserWrapper?t.parser=new S(r,t.parser):t.parser=r,p._requests.push(t),delete t.options.clientsvc_ObjectPaths}})},t.prototype.execute=function(){var r=this;i.Logger.write("["+this.batchId+"] ("+(new Date).getTime()+") Executing batch with "+this._requests.length+" requests.",1);var t={body:_(this._objectPaths.toArray())};return i.Logger.write("["+this.batchId+"] ("+(new Date).getTime()+") Sending batch request.",1),o.prototype.postCore.call(this,t,new w).then(function(n){return i.Logger.write("["+r.batchId+"] ("+(new Date).getTime()+") Resolving batched requests.",1),r._requests.reduce(function(t,e){return i.Logger.write("["+e.id+"] ("+(new Date).getTime()+") Resolving request in batch "+r.batchId+".",1),t.then(function(t){return e.parser.findResult(n).then(e.resolve).catch(e.reject)})},Promise.resolve())})},t}(O),w=function(t){function e(){return t.call(this,null)||this}return s(e,t),e.prototype.findResult=function(t){return t},e}(j),S=function(n){function t(t,e){return n.call(this,t,e.cacheOptions)||this}return s(t,n),t.prototype.findResult=function(t){var e=this;return this.parser.findResult(t).then(function(t){return e.cacheData(t)})},t}(h.CachingParserWrapper);t.ObjectPathBatch=A,t.ClientSvcQueryable=O,t.ObjectPath=P,t.opSetId=I,t.opSetPathId=$,t.opSetParentId=g,t.opSetPathParamId=v,t.ObjectPathQueue=m,t.objectPath=e,t.identityQuery=function(){return''},t.opQuery=a,t.setProperty=o,t.methodAction=u,t.objectProperties=c,t.property=d,t.staticMethod=f,t.staticProperty=n,t.objConstructor=function(t){for(var e=[],n=1;n',e)},t.MethodParams=y,t.method=b,t.ProcessQueryParser=j,t.writeObjectPathBody=_,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=sp-clientsvc.es5.umd.min.js.map