@esri/hub-common 9.18.0 → 9.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/content/_internal.js +211 -20
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +610 -0
- package/dist/es2017/content/compose.js.map +1 -0
- package/dist/es2017/content/get-family.js +42 -0
- package/dist/es2017/content/get-family.js.map +1 -0
- package/dist/es2017/content/index.js +42 -468
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/core/types/IHubAdditionalResource.js +1 -0
- package/dist/es2017/core/types/IHubAdditionalResource.js.map +1 -0
- package/dist/es2017/core/types/IHubContentEnrichments.js +1 -0
- package/dist/es2017/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/es2017/core/types/IServerEnrichments.js +1 -0
- package/dist/es2017/core/types/IServerEnrichments.js.map +1 -0
- package/dist/es2017/core/types/index.js +2 -1
- package/dist/es2017/core/types/index.js.map +1 -1
- package/dist/es2017/projects/HubProjects.js +15 -16
- package/dist/es2017/projects/HubProjects.js.map +1 -1
- package/dist/es2017/search/_searchContent.js +18 -20
- package/dist/es2017/search/_searchContent.js.map +1 -1
- package/dist/es2017/search/_searchGroups.js +18 -19
- package/dist/es2017/search/_searchGroups.js.map +1 -1
- package/dist/es2017/search/_searchUsers.js +16 -16
- package/dist/es2017/search/_searchUsers.js.map +1 -1
- package/dist/es2017/sites/domains/index.js +1 -0
- package/dist/es2017/sites/domains/index.js.map +1 -1
- package/dist/es2017/sites/domains/remove-domains-by-site-id.js +20 -0
- package/dist/es2017/sites/domains/remove-domains-by-site-id.js.map +1 -0
- package/dist/esm/content/_internal.js +214 -21
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +603 -0
- package/dist/esm/content/compose.js.map +1 -0
- package/dist/esm/content/get-family.js +42 -0
- package/dist/esm/content/get-family.js.map +1 -0
- package/dist/esm/content/index.js +44 -476
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/core/types/IHubAdditionalResource.js +1 -0
- package/dist/esm/core/types/IHubAdditionalResource.js.map +1 -0
- package/dist/esm/core/types/IHubContentEnrichments.js +1 -0
- package/dist/esm/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/esm/core/types/IServerEnrichments.js +1 -0
- package/dist/esm/core/types/IServerEnrichments.js.map +1 -0
- package/dist/esm/core/types/index.js +2 -1
- package/dist/esm/core/types/index.js.map +1 -1
- package/dist/esm/projects/HubProjects.js +14 -17
- package/dist/esm/projects/HubProjects.js.map +1 -1
- package/dist/esm/search/_searchContent.js +22 -26
- package/dist/esm/search/_searchContent.js.map +1 -1
- package/dist/esm/search/_searchGroups.js +20 -23
- package/dist/esm/search/_searchGroups.js.map +1 -1
- package/dist/esm/search/_searchUsers.js +17 -19
- package/dist/esm/search/_searchUsers.js.map +1 -1
- package/dist/esm/sites/domains/index.js +1 -0
- package/dist/esm/sites/domains/index.js.map +1 -1
- package/dist/esm/sites/domains/remove-domains-by-site-id.js +20 -0
- package/dist/esm/sites/domains/remove-domains-by-site-id.js.map +1 -0
- package/dist/node/content/_internal.js +216 -22
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +615 -0
- package/dist/node/content/compose.js.map +1 -0
- package/dist/node/content/get-family.js +46 -0
- package/dist/node/content/get-family.js.map +1 -0
- package/dist/node/content/index.js +48 -477
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/core/types/IHubAdditionalResource.js +3 -0
- package/dist/node/core/types/IHubAdditionalResource.js.map +1 -0
- package/dist/node/core/types/IHubContentEnrichments.js +3 -0
- package/dist/node/core/types/IHubContentEnrichments.js.map +1 -0
- package/dist/node/core/types/{IContentEnrichments.js → IServerEnrichments.js} +1 -1
- package/dist/node/core/types/IServerEnrichments.js.map +1 -0
- package/dist/node/core/types/index.js +2 -1
- package/dist/node/core/types/index.js.map +1 -1
- package/dist/node/projects/HubProjects.js +15 -16
- package/dist/node/projects/HubProjects.js.map +1 -1
- package/dist/node/search/_searchContent.js +17 -19
- package/dist/node/search/_searchContent.js.map +1 -1
- package/dist/node/search/_searchGroups.js +17 -18
- package/dist/node/search/_searchGroups.js.map +1 -1
- package/dist/node/search/_searchUsers.js +15 -15
- package/dist/node/search/_searchUsers.js.map +1 -1
- package/dist/node/sites/domains/index.js +1 -0
- package/dist/node/sites/domains/index.js.map +1 -1
- package/dist/node/sites/domains/remove-domains-by-site-id.js +24 -0
- package/dist/node/sites/domains/remove-domains-by-site-id.js.map +1 -0
- package/dist/types/content/_internal.d.ts +101 -22
- package/dist/types/content/compose.d.ts +115 -0
- package/dist/types/content/get-family.d.ts +7 -0
- package/dist/types/content/index.d.ts +4 -86
- package/dist/types/core/types/IHubAdditionalResource.d.ts +10 -0
- package/dist/types/core/types/IHubContent.d.ts +9 -3
- package/dist/types/core/types/IHubContentEnrichments.d.ts +15 -0
- package/dist/types/core/types/IHubItemEntity.d.ts +1 -1
- package/dist/types/core/types/{IContentEnrichments.d.ts → IServerEnrichments.d.ts} +3 -2
- package/dist/types/core/types/index.d.ts +2 -1
- package/dist/types/sites/domains/index.d.ts +1 -0
- package/dist/types/sites/domains/remove-domains-by-site-id.d.ts +8 -0
- package/dist/umd/common.umd.js +1071 -648
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/es2017/core/types/IContentEnrichments.js +0 -1
- package/dist/es2017/core/types/IContentEnrichments.js.map +0 -1
- package/dist/esm/core/types/IContentEnrichments.js +0 -1
- package/dist/esm/core/types/IContentEnrichments.js.map +0 -1
- package/dist/node/core/types/IContentEnrichments.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisHub=e.arcgisHub||{})}(this,function(n){"use strict";function o(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}function i(e,r,n){return n=n||"",Array.isArray(e)?e.map(t):!e||!c(e)||s(e)||l(e)||u(e)?r(e,n):Object.assign({},e,o(e,t));function t(e,t){return i(e,r,""+(n?n+"."+t:t))}}function a(e){return"string"==typeof e||e instanceof String}function s(e){return e instanceof Date}function u(e){return"function"==typeof e}function c(e){return"object"==typeof e}function l(e){return e instanceof RegExp}function f(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e)}function p(e){var t,r={};if(Array.isArray(e))r=e.map(p);else if("object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(null!=(t=e[n])&&"object"==typeof t?t instanceof Date?r[n]=new Date(t.getTime()):r[n]=p(t):r[n]=t);else r=e;return r}function d(e,r,n){return e?e.reduce(function(e,t){return e=f(t,r)===n?t:e},null):null}function r(e){return""+(e=void 0===e?"i":e)+Math.random().toString(36).substr(2,8)}function h(e,t){return null!=e&&(t=p(t)).push(e),t}function m(e){return(e=(e=e.toLowerCase()).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi," ")).replace(/(\-|\_|\.|\s)+(.)?/g,function(e,t,r){return r?r.toUpperCase():""}).replace(/(^|\/)([A-Z])/g,function(e,t,r){return e.toLowerCase()})}function g(e,t,r){return r.indexOf(e)===t}function t(e){return(e=Array.from(e))[0]=e[0].toUpperCase(),e.join("")}function v(e){return e.reduce(function(e,t){return e.concat(t)},[])}function y(e,t,r){void 0===r&&(r={});var t=t.split("."),n=e,o=t.length-1;t.forEach(function(e,t){n.hasOwnProperty(e)&&null!=n[e]?t===o&&("object"!=typeof n[e]||Array.isArray(n[e])?n[e]=r:n[e]=Object.assign(n[e],p(r))):n[e]=t===o?r:{},n=n[e]})}function b(e,t,r){t=f(e,t);return void 0!==t?t:r}function w(e,r,n){return i(e,function(e){if(!a(e))return e;var t=l(r)?r:new RegExp(r,"g");return e.replace(t,n)})}function S(t,r,e){return Array.isArray(e)&&e.length?(e.forEach(function(e){void 0!==f(t,e)&&y(r,e,f(t,e))}),r):t}function C(e,t,r){y(r,e=Array.isArray(e)?e.join("."):e,t)}function k(r,n){return Array.isArray(r)?r.reduce(function(e,t){return n(t)?e=t:!A(t)||(t=k(t,n))&&(e=t),e},void 0):A(r)?n(r)?r:Object.keys(r).reduce(function(e,t){return!A(r[t])||(t=k(r[t],n))&&(e=t),e},void 0):void 0}function A(e){var t=!1;return t=e&&c(e)&&!s(e)&&!l(e)&&!u(e)?!0:t}function T(e,n,o){void 0===o&&(o=5);return e.reduce(function(e,t){var r=e[e.length-1];return r&&r.length!==o||e.push(r=[]),r.push(t),e},[]).reduce(function(e,r){return e.then(function(t){var e=r.map(function(e){return n(e)});return Promise.all(e).then(function(e){return t.concat(e)})})},Promise.resolve([]))}function x(e,t){return-1!==e.indexOf(t)}var P=function(e,t){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function e(e,t){function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var I=function(){return(I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function O(e,a,s,u){return new(s=s||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}i((u=u.apply(e,a||[])).next())})}function E(r,n){var o,i,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&t[0]?i.return:t[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,t[1])).done)return a;switch(i=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,i=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=n.call(r,s)}catch(e){t=[6,e],i=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function _(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),o=0,t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}var D,U=(e(j,D=Error),j);function j(e,t,r){var n=this;return t=t||"UNKNOWN_ERROR",r=b(r,"rootCause",r),(n=D.call(this,t)||this).operation=e,n.name="OperationError",n.rootCause=r,Object.setPrototypeOf(n,j.prototype),n.stack=b(r,"stack",(new Error).stack),n}function N(r,n){return void 0===n&&(n={}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.apply(void 0,e).catch(function(e){return n})}}function R(e){var r=(new Date).getTime();return Array(e).fill(0).reduce(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),e=""+e+t.toString(16)},"")}function M(e){"{"===e[0]&&(e=e.substring(1,e.length-1));return/^(\{){0,1}[0-9a-fA-F]{8}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{12}(\}){0,1}$/gi.test(e)}function L(e){return"string"==typeof e?e.trim().toLowerCase().replace(/ +/g,"-").replace(/[^\w-]/g,"").replace(/-+/g,"-"):e}n.Level=void 0,(At=n.Level||(n.Level={}))[At.all=0]="all",At[At.debug=1]="debug",At[At.info=2]="info",At[At.warn=3]="warn",At[At.error=4]="error",At[At.off=5]="off";var F=(q.setLogLevel=function(e){this.logLevel=e},q.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.log.apply(console,_([e],t))},q.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.debug.apply(console,_([e],t))},q.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.info)&&console.info.apply(console,_([e],t))},q.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.warn)&&console.warn.apply(console,_([e],t))},q.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.error)&&console.error.apply(console,_([e],t))},q.isLevelPermitted=function(e){return this.logLevel<=e},q.logLevel=n.Level.off,q);function q(){}function G(e){return e.capabilities.includes("updateitemcontrol")}function B(t){return Object.keys(t).some(function(e){e=t[e];if(!e)return!1;switch((e=e&&e.toParam?e.toParam():e).constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function H(o){var i={};return Object.keys(o).forEach(function(e){var t=o[e];if((t=t&&t.toParam?t.toParam():t)||0===t||"boolean"==typeof t||"string"==typeof t){switch(t.constructor.name){case"Array":var r=null===(r=null===(r=t[0])||void 0===r?void 0:r.constructor)||void 0===r?void 0:r.name,n="Array"===r?t:"Object"===r?JSON.stringify(t):t.join(",");break;case"Object":n=JSON.stringify(t);break;case"Date":n=t.valueOf();break;case"Function":n=null;break;case"Boolean":n=t+"";break;default:n=t}(n||0===n||"string"==typeof n||Array.isArray(n))&&(i[e]=n)}}),i}function W(e){var t=H(e);return Object.keys(t).map(function(e){return function t(r,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return t(r,e)}).join("&"):encodeURIComponent(r)+"="+encodeURIComponent(e)}(e,t[e])}).join("&")}var Y=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function K(e){console&&console.warn&&console.warn.apply(console,[e])}Y.prototype=Object.create(Error.prototype),Y.prototype.constructor=Y;var z,V="@esri/arcgis-rest-js",J={httpMethod:"POST",params:{f:"json"}},$=(e(X,z=Y),X.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var i=0,a=function(t,r){e(o.url,o.options).then(function(e){e=I(I({},o.options),{authentication:e});return i+=1,Q(o.url,e)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&i<n?a(t,r):"ArcGISAuthError"===e.name&&n<=i?r(o):r(e)})};return new Promise(function(e,t){a(e,t)})},X);function X(e,t,r,n,o){o=z.call(this,e=void 0===e?"AUTHENTICATION_ERROR":e,t=void 0===t?"AUTHENTICATION_ERROR_CODE":t,r,n,o)||this;return o.name="ArcGISAuthError",o.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,o}function Q(n,e){void 0===e&&(e={params:{f:"json"}});var o=I(I(I({httpMethod:"POST"},J),e),{params:I(I({},J.params),e.params),headers:I(I({},J.headers),e.headers)}),t=[],e=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),e.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),e.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),e.push("`isomorphic-form-data`")),!o.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+e.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var e=o.httpMethod,i=o.authentication,a=o.rawResponse,s=I({f:"json"},o.params),r=null,u={method:e,credentials:o.credentials||"same-origin"};return o.headers&&o.headers["X-Esri-Auth-Client-Id"]&&-1<n.indexOf("/oauth2/platformSelf")&&(u.credentials="include"),(i?i.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,r=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(s.token=e),i&&i.getDomainCredentials&&(u.credentials=i.getDomainCredentials(n));var t={};"GET"===u.method&&(s.token&&o.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+s.token,delete s.token),r=""===W(s)?n:n+"?"+W(s),o.maxUrlLength&&r.length>o.maxUrlLength||s.token&&o.hideToken?(u.method="POST",e.length&&o.hideToken&&(s.token=e,delete t["X-Esri-Authorization"])):n=r);var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===u.method&&(u.body=function(e,t){var t=B(e)||t,r=H(e);if(t){var n=new FormData;return Object.keys(r).forEach(function(e){var t;"undefined"!=typeof Blob&&r[e]instanceof Blob?(t=r.fileName||r[e].name||e,n.append(e,r[e],t)):n.append(e,r[e])}),n}return W(e)}(s,r)),u.headers=I(I({},t),o.headers),"undefined"!=typeof window||u.headers.referer||(u.headers.referer=V),B(s)||r||(u.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,u)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new Y(r,"HTTP "+t,e,n,o)}if(a)return e;switch(s.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==s.f&&"geojson"!==s.f||a)return e;var t=function(t,e,r,n){if(400<=t.code){var o=t.message,i=t.code;throw new Y(o,i,t,e,r)}if(t.error){var a=t.error,o=a.message,i=a.code,s=a.messageCode,a=s||i||"UNKNOWN_ERROR_CODE";if(498===i||499===i||"GWM_0003"===s||400===i&&"Unable to generate token."===o)throw n||new $(o,a,t,e,r);throw new Y(o,a,t,e,r)}if("failed"!==t.status&&"failure"!==t.status)return t;o=void 0,i="UNKNOWN_ERROR_CODE";try{o=JSON.parse(t.statusMessage).message,i=JSON.parse(t.statusMessage).code}catch(e){o=t.statusMessage||t.message}throw new Y(o,i,t,e,r)}(e,n,o,r);return r&&(e=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],o.authentication.federatedServers[e]={token:[],expires:new Date(Date.now()+864e5)},r=null),t})}function Z(r,e,t){var n=I(I({params:{}},t),r);return n.params=e.reduce(function(e,t){return!r[t]&&"boolean"!=typeof r[t]||(e[t]=r[t]),e},n.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return n[t]&&(e[t]=n[t]),e},{})}function ee(e){return"string"==typeof e&&"/"===(e=e.trim())[e.length-1]?e.slice(0,-1):e}function te(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r,t=(r=t,r=(t=t.split("="))[0],t=t[1],{key:decodeURIComponent(r),value:decodeURIComponent(t)});return e[t.key]=t.value,e},{})}function re(e,t){return t.rawResponse=!1,Q(e,t).then(function(e){var t={token:e.access_token,username:e.username,expires:new Date(Date.now()+(1e3*e.expires_in-1e3)),ssl:!0===e.ssl};return e.refresh_token&&(t.refreshToken=e.refresh_token),t})}function ne(e,t){return"undefined"!=typeof window&&window.location&&window.location.host?t.params.referer=window.location.host:t.params.referer=V,Q(e,t)}var oe=/^https?:\/\/(\S+)\.arcgis\.com.+/;function ie(e){return oe.test(e)}function ae(e){if(!oe.test(e))return null;e=e.match(oe)[1].split(".").pop();return e.includes("dev")?"dev":e.includes("qa")?"qa":"production"}function se(e,t){t=ee(function(e){if(!oe.test(e))return e;switch(ae(e)){case"dev":return"https://devext.arcgis.com/sharing/rest";case"qa":return"https://qaext.arcgis.com/sharing/rest";default:return"https://www.arcgis.com/sharing/rest"}}(t)).replace(/https?:\/\//,""),e=ee(e).replace(/https?:\/\//,"");return new RegExp(e,"i").test(t)}var ue=(Object.defineProperty(ce.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"tokenExpires",{get:function(){return this._tokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"refreshToken",{get:function(){return this._refreshToken},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"refreshTokenExpires",{get:function(){return this._refreshTokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"trustedServers",{get:function(){return console.log("DEPRECATED: use federatedServers instead"),this.federatedServers},enumerable:!1,configurable:!0}),ce.beginOAuth2=function(e,t){void 0===t&&(t=window),e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=I({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",expiration:20160,popup:!0,popupWindowFeatures:"height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes",state:e.clientId,locale:""},e),n=r.portal,o=r.provider,i=r.clientId,a=r.expiration,s=r.redirectUri,u=r.popup,c=r.popupWindowFeatures,l=r.state,p=r.locale,r=r.params,p="arcgis"===o?n+"/oauth2/authorize?client_id="+i+"&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+l+"&locale="+p:n+"/oauth2/social/authorize?client_id="+i+"&socialLoginProviderName="+o+"&autoAccountCreateForSocial=true&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+l+"&locale="+p;if(r&&(p=p+"&"+W(r)),u){var f,d=((f={promise:null,resolve:null,reject:null}).promise=new Promise(function(e,t){f.resolve=e,f.reject=t}),f);return t["__ESRI_REST_AUTH_HANDLER_"+i]=function(e,t){e?(e=JSON.parse(e),d.reject(new $(e.errorMessage,e.error))):t&&(t=JSON.parse(t),d.resolve(new ce({clientId:i,portal:n,ssl:t.ssl,token:t.token,tokenExpires:new Date(t.expires),username:t.username})))},t.open(p,"oauth-window",c),d.promise}t.location.href=p},ce.completeOAuth2=function(e,o){void 0===o&&(o=window);var t=I({portal:"https://www.arcgis.com/sharing/rest",popup:!0},e),i=t.portal,a=t.clientId,s=t.popup;function r(e,t){try{var r=void 0,n="__ESRI_REST_AUTH_HANDLER_"+a;if(s&&(o.opener?o.opener.parent&&o.opener.parent[n]?r=o.opener.parent[n]:o.opener&&o.opener[n]&&(r=o.opener[n]):o!==o.parent&&o.parent&&o.parent[n]&&(r=o.parent[n]),r))return r(e?JSON.stringify(e):void 0,JSON.stringify(t)),void o.close()}catch(e){throw new $('Unable to complete authentication. It\'s possible you specified popup based oAuth2 but no handler from "beginOAuth2()" present. This generally happens because the "popup" option differs between "beginOAuth2()" and "completeOAuth2()".')}if(e)throw new $(e.errorMessage,e.error);return new ce({clientId:a,portal:i,ssl:t.ssl,token:t.token,tokenExpires:t.expires,username:t.username})}e=te(o.location.hash);if(!e.access_token){var n=void 0,u="Unknown error";return e.error&&(n=e.error,u=e.error_description),r({error:n,errorMessage:u})}t=e.access_token,n=new Date(Date.now()+1e3*parseInt(e.expires_in,10)-6e4),u=e.username;return r(void 0,{token:t,expires:n,ssl:"true"===e.ssl,username:u})},ce.fromParent=function(e,n){var o;return!n&&window&&(n=window),new Promise(function(t,r){o=function(e){if(e.source===n.parent&&e.data)try{return t(ce.parentMessageHandler(e))}catch(e){return r(e)}},n.addEventListener("message",o,!1),n.parent.postMessage({type:"arcgis:auth:requestCredential"},e)}).then(function(e){return n.removeEventListener("message",o,!1),e})},ce.authorize=function(e,t){e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=I({portal:"https://arcgis.com/sharing/rest",expiration:20160},e),n=r.portal,o=r.clientId,i=r.expiration,r=r.redirectUri;t.writeHead(301,{Location:n+"/oauth2/authorize?client_id="+o+"&expiration="+(e.duration||i)+"&response_type=code&redirect_uri="+encodeURIComponent(r)}),t.end()},ce.exchangeAuthorizationCode=function(e,t){var e=I({portal:"https://www.arcgis.com/sharing/rest",refreshTokenTTL:20160},e),r=e.portal,n=e.clientId,o=e.redirectUri,i=e.refreshTokenTTL;return re(r+"/oauth2/token",{params:{grant_type:"authorization_code",client_id:n,redirect_uri:o,code:t}}).then(function(e){return new ce({clientId:n,portal:r,ssl:e.ssl,redirectUri:o,refreshToken:e.refreshToken,refreshTokenTTL:i,refreshTokenExpires:new Date(Date.now()+60*(i-1)*1e3),token:e.token,tokenExpires:e.expires,username:e.username})})},ce.deserialize=function(e){e=JSON.parse(e);return new ce({clientId:e.clientId,refreshToken:e.refreshToken,refreshTokenExpires:new Date(e.refreshTokenExpires),username:e.username,password:e.password,token:e.token,tokenExpires:new Date(e.tokenExpires),portal:e.portal,ssl:e.ssl,tokenDuration:e.tokenDuration,redirectUri:e.redirectUri,refreshTokenTTL:e.refreshTokenTTL})},ce.fromCredential=function(e){var t=void 0===e.ssl||e.ssl,r=e.expires||Date.now()+72e5;return new ce({portal:e.server.includes("sharing/rest")?e.server:e.server+"/sharing/rest",ssl:t,token:e.token,username:e.userId,tokenExpires:new Date(r)})},ce.parentMessageHandler=function(e){if("arcgis:auth:credential"===e.data.type)return ce.fromCredential(e.data.credential);if("arcgis:auth:error"!==e.data.type)throw new Error("Unknown message type.");var t=new Error(e.data.error.message);throw t.name=e.data.error.name,t},ce.prototype.toCredential=function(){return{expires:this.tokenExpires.getTime(),server:this.portal,ssl:this.ssl,token:this.token,userId:this.username}},ce.prototype.getUser=function(e){var t=this;if(this._pendingUserRequest)return this._pendingUserRequest;if(this._user)return Promise.resolve(this._user);var r=this.portal+"/community/self",e=I(I({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingUserRequest=Q(r,e).then(function(e){return t._user=e,t._pendingUserRequest=null,e}),this._pendingUserRequest},ce.prototype.getPortal=function(e){var t=this;if(this._pendingPortalRequest)return this._pendingPortalRequest;if(this._portalInfo)return Promise.resolve(this._portalInfo);var r=this.portal+"/portals/self",e=I(I({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingPortalRequest=Q(r,e).then(function(e){return t._portalInfo=e,t._pendingPortalRequest=null,e}),this._pendingPortalRequest},ce.prototype.getUsername=function(){return this.username?Promise.resolve(this.username):this._user?Promise.resolve(this._user.username):this.getUser().then(function(e){return e.username})},ce.prototype.getToken=function(e,t){return r=this.portal,n=e,o=ie(r),i=ie(n),r=ae(r),n=ae(n),o&&i&&r===n||new RegExp(this.portal,"i").test(e)?this.getFreshToken(t):this.getTokenForServer(e,t);var r,n,o,i},ce.prototype.validateAppAccess=function(r){return this.getToken(this.portal).then(function(e){return Q((t=void 0===t?"https://www.arcgis.com/sharing/rest":t)+"/oauth2/validateAppAccess",{method:"POST",params:{f:"json",client_id:r,token:e}});var t})},ce.prototype.toJSON=function(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires,portal:this.portal,ssl:this.ssl,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,refreshTokenTTL:this.refreshTokenTTL}},ce.prototype.serialize=function(){return JSON.stringify(this)},ce.prototype.enablePostMessageAuth=function(e,t){!t&&window&&(t=window),this._hostHandler=this.createPostMessageHandler(e),t.addEventListener("message",this._hostHandler,!1)},ce.prototype.disablePostMessageAuth=function(e){(e=!e&&window?window:e).removeEventListener("message",this._hostHandler,!1)},ce.prototype.refreshSession=function(e){return this._user=null,this.username&&this.password?this.refreshWithUsernameAndPassword(e):this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new $("Unable to refresh token."))},ce.prototype.getServerRootUrl=function(e){var t=ee(e).split(/\/rest(\/admin)?\/services(?:\/|#|\?|$)/)[0].match(/(https?:\/\/)(.+)/);t[0];var r=t[1],e=t[2].split("/"),t=e[0],e=e.slice(1);return""+r+t.toLowerCase()+"/"+e.join("/")},ce.prototype.getDomainCredentials=function(t){return this.trustedDomains&&this.trustedDomains.length&&this.trustedDomains.some(function(e){return t.startsWith(e)})?"include":"same-origin"},ce.prototype.createPostMessageHandler=function(o){var i=this;return function(e){var t=-1<o.indexOf(e.origin),r="arcgis:auth:requestCredential"===e.data.type,n=i.tokenExpires.getTime()>Date.now();t&&r&&(r={},r=n?((n=i.toCredential()).server=n.server.replace("/sharing/rest",""),{type:"arcgis:auth:credential",credential:n}):{type:"arcgis:auth:error",error:{name:"tokenExpiredError",message:"Session token was expired, and not returned to the child application"}},e.source.postMessage(r,e.origin))}},ce.prototype.getTokenForServer=function(t,r){var n=this,o=this.getServerRootUrl(t),e=this.federatedServers[o];return e&&e.expires&&e.expires.getTime()>Date.now()?Promise.resolve(e.token):this._pendingTokenRequests[o]||(this._pendingTokenRequests[o]=this.fetchAuthorizedDomains().then(function(){return Q(o+"/rest/info",{credentials:n.getDomainCredentials(t)}).then(function(e){if(e.owningSystemUrl){if(se(e.owningSystemUrl,n.portal))return Q(e.owningSystemUrl+"/sharing/rest/info",r);throw new $(t+" is not federated with "+n.portal+".","NOT_FEDERATED")}if(e.authInfo&&void 0!==n.federatedServers[o])return Promise.resolve({authInfo:e.authInfo});throw new $(t+" is not federated with any portal and is not explicitly trusted.","NOT_FEDERATED")}).then(function(e){return e.authInfo.tokenServicesUrl}).then(function(e){return n.token&&n.tokenExpires.getTime()>Date.now()?ne(e,{params:{token:n.token,serverUrl:t,expiration:n.tokenDuration,client:"referer"}}):ne(e,{params:{username:n.username,password:n.password,expiration:n.tokenDuration,client:"referer"}}).then(function(e){return n._token=e.token,n._tokenExpires=new Date(e.expires),e})}).then(function(e){return n.federatedServers[o]={expires:new Date(e.expires),token:e.token},delete n._pendingTokenRequests[o],e.token})}),this._pendingTokenRequests[o])},ce.prototype.getFreshToken=function(e){var t=this;return this.token&&!this.tokenExpires||this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshSession(e).then(function(e){return t._pendingTokenRequests[t.portal]=null,e.token})),this._pendingTokenRequests[this.portal])},ce.prototype.refreshWithUsernameAndPassword=function(e){var t=this,e=I({params:{username:this.username,password:this.password,expiration:this.tokenDuration}},e);return ne(this.portal+"/generateToken",e).then(function(e){return t._token=e.token,t._tokenExpires=new Date(e.expires),t})},ce.prototype.refreshWithRefreshToken=function(e){var t=this;if(this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()<Date.now())return this.refreshRefreshToken(e);e=I({params:{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}},e);return re(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t})},ce.prototype.refreshRefreshToken=function(e){var t=this,e=I({params:{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}},e);return re(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t._refreshToken=e.refreshToken,t._refreshTokenExpires=new Date(Date.now()+60*(t.refreshTokenTTL-1)*1e3),t})},ce.prototype.fetchAuthorizedDomains=function(){var t=this;return this.server||!this.portal?Promise.resolve(this):this.getPortal().then(function(e){return e.authorizedCrossOriginDomains&&e.authorizedCrossOriginDomains.length&&(t.trustedDomains=e.authorizedCrossOriginDomains.filter(function(e){return!e.startsWith("http://")}).map(function(e){return e.startsWith("https://")?e:"https://"+e})),t})},ce);function ce(e){var t;this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.username=e.username,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal?ee(e.portal):"https://www.arcgis.com/sharing/rest",this.ssl=e.ssl,this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.refreshTokenTTL=e.refreshTokenTTL||20160,this.server=e.server,this.federatedServers={},this.trustedDomains=[],e.server&&(t=this.getServerRootUrl(e.server),this.federatedServers[t]={token:e.token,expires:e.tokenExpires}),this._pendingTokenRequests={}}function le(e){e=e.privileges;return x(void 0===e?[]:e,"portal:user:createItem")}function pe(e,t){var r,n=!1,o=e.itemControl,i=e.owner,a=e.orgId,s=t.roleId,u=t.role,c=t.username,l=t.groups,p=t.orgId,u=x(["admin","update"],o)||!!i&&i===c||!!(!!a&&a===p)&&!s&&"org_admin"===u,t=le(t);return t&&u?n=!0:t&&(r=_(f(e,"groupIds")||[],[f(e,"properties.collaborationGroupId")]),n=l.some(function(e){return G(e)&&x(r,e.id)})),n}var fe=["portal:user:createGroup","portal:user:createItem","portal:user:shareToGroup","portal:user:viewOrgGroups","portal:user:viewOrgItems"];function de(e){var t=e.host,r=e.path,e=e.query,t=t.endsWith("/")?t:t+"/",t=new URL(r,t);return t.search=function(r){void 0===r&&(r={});var e=Object.keys(r).filter(function(e){return void 0!==r[e]}).reduce(function(e,t){return e[t]=r[t],e},{});return new URLSearchParams(e).toString()}(e),t.toString()}function he(e){return(e=void 0===e?{}:e).portal?ee(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function me(e){var t=JSON.parse(JSON.stringify(e));return t.data&&("undefined"!=typeof Blob&&e.data instanceof Blob||"ReadStream"===e.data.constructor.name?t.file=e.data:t.text=e.data,delete t.data),t}function ge(e){return e.owner?Promise.resolve(e.owner):e.item&&e.item.owner?Promise.resolve(e.item.owner):e.authentication&&e.authentication.getUsername?e.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function ve(t){return ge(t).then(function(e){e=t.folderId?he(t)+"/content/users/"+e+"/"+t.folderId+"/items/"+t.item.id+"/update":he(t)+"/content/users/"+e+"/items/"+t.item.id+"/update";return t.params=I(I({},t.params),me(t.item)),Q(e,t)})}function ye(e){var r,e=I({folderId:null},e);return(r=e).multipart&&!r.filename?Promise.reject(new Error("The filename is required for a multipart request.")):ge(r).then(function(e){var t=he(r)+"/content/users/"+e,e=t+"/addItem";return r.folderId&&(e=t+"/"+r.folderId+"/addItem"),r.params=I(I({},r.params),me(r.item)),Q(e,Z(r,["owner","folderId","file","dataUrl","text","async","multipart","filename","overwrite"],{params:I({},r.params)}))})}function be(e,t){return Q(we(e,t),I({httpMethod:"GET"},t))}var we=function(e,t){return("string"==typeof t?t:he(t))+"/content/items/"+e};function Se(e,t){e=we(e,t)+"/data",t=I({httpMethod:"GET",params:{}},t);return t.file&&(t.params.f=null),Q(e,t).catch(function(e){var t=RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i);if(!t.test(e.message))throw e})}function Ce(e){var t=we(e.id,e)+"/relatedItems",r=I({httpMethod:"GET",params:{direction:e.direction}},e);return"string"==typeof e.relationshipType?r.params.relationshipType=e.relationshipType:r.params.relationshipTypes=e.relationshipType,delete r.direction,delete r.relationshipType,Q(t,r)}function ke(t){return ge(t).then(function(e){return Q(he(t)+"/content/users/"+e+"/items/"+t.id+"/unprotect",t)})}function Ae(e){return t=e.groupId,Q(he(e=e)+"/community/groups/"+t,I({httpMethod:"GET"},e)).then(function(e){return e.userMembership.memberType}).catch(function(){return"none"});var t}function Te(t){return ge(t).then(function(e){return Q(he(t)+"/content/users/"+e+"/items/"+t.id+"/delete",t)})}var xe=(Pe.prototype.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.termStack=this.termStack.concat(e),this},Pe.prototype.in=function(e){return this.hasRange||this.hasTerms?(e&&"*"!==e&&(this.q+=e+":"),this.commit()):(K("`in("+(e?'"'+e+'"':"")+")`"+" was called with no call to `match(...)` or `from(...)`/`to(...)`. Your query was not modified."),this)},Pe.prototype.startGroup=function(){return this.commit(),0<this.openGroups&&(this.q+=" "),this.openGroups++,this.q+="(",this},Pe.prototype.endGroup=function(){return this.openGroups<=0?K("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."):(this.commit(),this.openGroups--,this.q+=")"),this},Pe.prototype.and=function(){return this.addModifier("and")},Pe.prototype.or=function(){return this.addModifier("or")},Pe.prototype.not=function(){return this.addModifier("not")},Pe.prototype.from=function(e){return this.hasTerms?K('`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[0]=e,this},Pe.prototype.to=function(e){return this.hasTerms?K('`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[1]=e,this},Pe.prototype.boost=function(e){return this.commit(),this.q+="^"+e,this},Pe.prototype.toParam=function(){return this.commit(),this.cleanup(),this.q},Pe.prototype.clone=function(){return this.commit(),this.cleanup(),new Pe(this.q+"")},Pe.prototype.addModifier=function(e){return this.currentModifer?(K("You have called `"+this.currentModifer+"()` after `"+e+"()`. Your current query was not modified."),this):(this.commit(),""===this.q&&"not"!==e?K("You have called `"+e+"()` without calling another method to modify your query first. Try calling `match()` first."):(this.currentModifer=e,this.q+=""===this.q?"":" ",this.q+=e.toUpperCase()+" "),this)},Pe.prototype.needsQuotes=function(e){return/\s|:/g.test(e)},Pe.prototype.formatTerm=function(e){return e instanceof Date?e.getTime():"string"==typeof e&&this.needsQuotes(e)?'"'+e+'"':e},Pe.prototype.commit=function(){var t=this;return this.currentModifer=void 0,this.hasRange&&(this.q+="["+this.formatTerm(this.rangeStack[0])+" TO "+this.formatTerm(this.rangeStack[1])+"]",this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(function(e){return t.formatTerm(e)}).join(" "),this.termStack=[]),this},Object.defineProperty(Pe.prototype,"hasTerms",{get:function(){return 0<this.termStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(Pe.prototype,"hasRange",{get:function(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]},enumerable:!1,configurable:!0}),Pe.prototype.cleanup=function(){if(0<this.openGroups)for(K("Automatically closing "+this.openGroups+" group(s). You can use `endGroup(...)` to remove this warning.");0<this.openGroups;)this.q+=")",this.openGroups--;var e=this.q;this.q=e.replace(/( AND ?| NOT ?| OR ?)*$/,""),e!==this.q&&K("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")},Pe);function Pe(e){void 0===e&&(e=""),this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=e}function Ie(r,n){var e,t="string"==typeof r||r instanceof xe?{httpMethod:"GET",params:{q:r}}:Z(r,["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],{httpMethod:"GET"});switch(n){case"item":e="/search";break;case"group":e="/community/groups";break;case"groupContent":if("string"==typeof r||r instanceof xe||!r.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));e="/content/groups/"+r.groupId+"/search";break;default:e="/portals/self/users/search"}return Q(he(t)+e,t).then(function(t){return t.nextStart&&-1!==t.nextStart&&(t.nextPage=function(){var e;return"string"==typeof r||r instanceof xe?e={q:r,start:t.nextStart}:(e=r).start=t.nextStart,Ie(e,n)}),t})}function Oe(e){return Ie(e,"item")}function Ee(e,t){if(0===e.length)return[];for(var r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function _e(e){var t=e.id,r=he(e)+"/community/groups/"+t+"/addUsers",t=Object.assign({},e,{admins:void 0,users:void 0}),t=_(De("users",e.users,t),De("admins",e.admins,t)).map(function(e){return Q(r,e).catch(function(e){return{errors:[e]}})});return Promise.all(t).then(Ue)}function De(o,e,i){return!e||e.length<1?[]:Ee(e,25).map(function(e){return t=o,r=e,n=i,Object.assign({},n,((e={})[t]=r,e.params=I(I({},n.params),((n={})[t]=r,n)),e));var t,r,n})}function Ue(e){var t=e.filter(function(e){return e.notAdded}).reduce(function(e,t){return e.concat(t.notAdded)},[]),e=e.filter(function(e){return e.errors}).reduce(function(e,t){return e.concat(t.errors)},[]),t={notAdded:t};return 0<e.length&&(t.errors=e),t}function je(t){var e=t.id,r=t.users,n=he(t)+"/community/groups/"+e+"/removeUsers",r=Ee(r,25).map(function(e){e=I(I({},t),{users:e,params:{users:e}});return Q(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(r).then(function(e){var t=function(r){return e.filter(function(e){return e[r]}).reduce(function(e,t){return e.concat(t[r])},[])},r=t("errors"),t={notRemoved:t("notRemoved")};return r.length?I(I({},t),{errors:r}):t})}function Ne(e){var t,r=e.id,n=he(e)+"/community/groups/"+r+"/invite",e=Ee((t=e).users,25).map(function(e){return function(e,t){t=Object.assign({},t);return t.params=I(I({},t.params),{users:e,role:t.role,expiration:t.expiration}),t}(e,t)}).map(function(e){return Q(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Re)}function Re(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function Me(e){return Q(he(e)+"/community/groups/"+e.id+"/unprotect",e)}function Le(e){return Q(he(e)+"/community/groups/"+e.id+"/delete",I({},e))}function Fe(e){var t=he(e)+"/community/groups/"+e.id+"/updateUsers",r={authentication:e.authentication,params:{}};return"admin"===e.newMemberType?r.params.admins=e.users:r.params.users=e.users,Q(t,r)}function qe(e){var n,t=he(e)+"/portals/self/createNotification",e=Ee((n=e).users,n.batchSize||25).map(function(e){return t=e,r=n,(e=Object.assign({},r)).params=I(I({},e.params),{users:t,subject:r.subject,message:r.message,notificationChannelType:e.notificationChannelType}),e;var t,r}).map(function(e){return Q(t,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Ge)}function Ge(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function Be(e){var t,r,n={httpMethod:"GET"};return"string"==typeof e?r="https://www.arcgis.com/sharing/rest/community/users/"+e:(t=e.username||e.authentication.username,r=he(e)+"/community/users/"+encodeURIComponent(t),n=I(I({},e),n)),Q(r,n)}function He(t){return Oe({q:"id: "+t.id+" AND group: "+t.groupId,start:1,num:10,sortField:"title",authentication:t.authentication,httpMethod:"POST"}).then(function(e){if(0<e.total)return e.results.some(function(e){return e.id===t.id})})}function We(a){return He(a).then(function(e){if(e)return{itemId:a.id,shortcut:!0,notSharedWith:[]};var t=a.authentication.username,e=a.owner,n=a.confirmItemControl,e=e||t;if(e===t)return Ye(a);var o=!1,i=!1;return Promise.all([Be({username:t,authentication:a.authentication}),Be({username:e,authentication:a.authentication}),Ae(a)]).then(function(e){var t=e[0],r=e[1],e=e[2];return o="org_admin"===t.role&&!t.roleId,i=t.orgId!==r.orgId,function(e,t,r,n,o,i){var a=[];if(i.groupId!==e.favGroupId)if(t){if(!n)throw Error("This item can not be shared to shared editing group "+i.groupId+" by "+e.username+" as they not the item owner or org admin.");a.push(Ke(e,e,!1,"Error adding "+e.username+" as member to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i),Ke(e,o,!0,"none"===r?"Error adding user "+o.username+" to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.":"Error promoting user "+o.username+" to admin in edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i))}else if(n)a.push(Ke(e,e,!1,"Error adding "+e.username+" as member to view group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i));else if("none"===r)throw new Error("This item can not be shared by "+e.username+" as they are not a member of the specified group "+i.groupId+".");return a}(t,!!n,e,o,r,a)}).then(function(e){var t=e[0],r=(void 0===t?{promise:Promise.resolve({notAdded:[]}),revert:function(e){return Promise.resolve(e)}}:t).revert;return Promise.all(e.map(function(e){return e.promise})).then(function(){return Ye(a,o,i)}).then(function(e){return r(e)})})}).then(function(e){if(e.notSharedWith.length)throw Error("Item "+a.id+" could not be shared to group "+a.groupId+".");return e})}function Ye(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=e.authentication.username,o=e.owner||n,i=he(e)+"/content/items/"+e.id+"/share";return(o===n||t&&!r)&&(i=he(e)+"/content/users/"+o+"/items/"+e.id+"/share"),e.params={groups:e.groupId,confirmItemControl:e.confirmItemControl},Q(i,e)}function Ke(e,t,r,n,o){var i,a,s=t.groups||[],u=s.find(function(e){return e.id===o.groupId});if(e.orgId!==t.orgId)throw Error("User "+t.username+" is not a member of the same org as "+e.username+". Consequently they can not be added added to group "+o.groupId+" nor can item "+o.id+" be shared to the group.");if(!u&&511<s.length)throw Error("User "+t.username+" already has 512 groups, and can not be added to group "+o.groupId+". Consequently item "+o.id+" can not be shared to the group.");return a=u?r&&"member"===u.userMembership.memberType?(i=Fe({id:o.groupId,users:[t.username],newMemberType:"admin",authentication:o.authentication}).then(function(e){e=e.results.reduce(function(e,t){return t.success||e.push(t.username),e},[]);return Promise.resolve({notAdded:e})}).catch(function(){return{notAdded:[t.username]}}),function(e){return Fe({id:o.groupId,users:[t.username],newMemberType:"member",authentication:o.authentication}).then(function(){return e}).catch(function(){return e})}):(i=Promise.resolve({notAdded:[]}),function(e){return Promise.resolve(e)}):(i=_e(((a={id:o.groupId})[r?"admins":"users"]=[t.username],a.authentication=o.authentication,a)).then(function(e){if(e.errors&&e.errors.length)throw e.errors[0];return e}).catch(function(){return{notAdded:[t.username]}}),function(e){return je({id:o.groupId,users:[t.username],authentication:o.authentication}).then(function(){return e})}),{promise:i.then(function(e){if(e.notAdded.length)throw new Error(n);return e}),revert:a}}function ze(o){return He(o).then(function(e){if(!e)return Promise.resolve({itemId:o.id,shortcut:!0,notUnsharedFrom:[]});var r=o.authentication.username,n=o.owner;return Promise.all([Ae(o),Be({username:r,authentication:o.authentication})]).then(function(e){var t=e[0],e=e[1],e="org_admin"===e.role&&!e.roleId;if(!((n||r)===r)&&!e&&["admin","owner"].indexOf(t)<0)throw Error("This item can not be unshared from group "+o.groupId+" by "+r+" as they not the item owner, an org admin, group admin or group owner.");return function(e){var t=e.authentication.username,r=e.owner||t,n=he(e)+"/content/items/"+e.id+"/unshare";r===t&&(n=he(e)+"/content/users/"+r+"/items/"+e.id+"/unshare");return e.params={groups:e.groupId},Q(n,e)}(o)}).then(function(e){if(e.notUnsharedFrom.length)throw Error("Item "+o.id+" could not be unshared to group "+o.groupId);return e})})}function Ve(e){return function(e,t){e=e||"self",e=he(t)+"/portals/"+e,t=I({httpMethod:"GET"},t);return Q(e,t)}(null,e)}function Je(e){if("string"==typeof e)return e.replace(/\/sharing\/rest\/?$/,"");if("object"==typeof e){var t=e.portalSelf||e,r=t.portalHostname,n=t.urlKey,o=t.customBaseUrl;if(r||n&&o)return t.isPortal?"https://"+t.portalHostname:"https://"+t.urlKey+"."+t.customBaseUrl}return Je(he(e))}var $e={devext:"https://d1011m9qpnz5mw.cloudfront.net",qaext:"https://dyq9ux9ryu4qj.cloudfront.net",www:"https://d1iq7pbacwn5rb.cloudfront.net"};function Xe(e){if(e.isPortal)return Je(e)+"/apps/sites";e=e.portalHostname.split(".")[0];return($e[e]||$e.www)+"/opendata-ui/assets"}function Qe(e){return Je(e)+"/sharing/rest"}function Ze(e){return e=(e=e.toLowerCase()).includes("//")?e.split("//")[1]:e}function et(e){var t;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://hubqa.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://hubdev.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://hub.arcgis.com"),t}function tt(e){if(e.isPortal)throw new Error("Hub Url is not available in ArcGIS Enterprise");return et(e.portalHostname)}var rt=function(e,t,r){var n=e.id,e=e.access,t=Qe(t)+"/content/items/"+n,n=new URLSearchParams({f:"json"});return"public"!==e&&r&&n.append("token",r),t+"?"+n.toString()};function nt(e){var t;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://hubqa.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://hubdev.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://hub.arcgis.com"),t}function ot(e){var t=e;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://qaext.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://devext.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://www.arcgis.com"),t}var it=/\/(map|feature)server/i,at=function(e){e=e.match(it),e=e&&e[1];return e&&t(e)+" Service"};function st(e){var t=e&&e.hubApiUrl;return t||et(Qe(e))}var ut="/api/v3/domains",ct="/api/v3/datasets",lt="/api/discussions/v1",pt=(Object.defineProperty(ft.prototype,"session",{get:function(){return this._authentication},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"isAuthenticated",{get:function(){return!!this._authentication},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"userRequestOptions",{get:function(){if(this.isAuthenticated)return{authentication:this._authentication,portal:this.sharingApiUrl}},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"requestOptions",{get:function(){var e={portal:this.sharingApiUrl};return e=this.isAuthenticated?{authentication:this._authentication,portal:this.sharingApiUrl}:e},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"hubRequestOptions",{get:function(){if(this.isAuthenticated)return{authentication:this.session,isPortal:this.isPortal,portalSelf:this.portal,hubApiUrl:this.hubUrl}},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"portalUrl",{get:function(){return this.isAuthenticated?this.isPortal?"https://"+this._portalSelf.portalHostname:"https://"+this._portalSelf.urlKey+"."+this._portalSelf.customBaseUrl:this._portalUrl},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"sharingApiUrl",{get:function(){return this.portalUrl+"/sharing/rest"},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"hubUrl",{get:function(){return this._hubUrl},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"isPortal",{get:function(){return this._portalSelf?this._portalSelf.isPortal:-1===this._portalUrl.indexOf("arcgis.com")},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"discussionsServiceUrl",{get:function(){if(this._hubUrl)return""+this._hubUrl+lt},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"hubSearchServiceUrl",{get:function(){if(this._hubUrl)return""+this._hubUrl+ct},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"domainServiceUrl",{get:function(){if(this._hubUrl)return""+this._hubUrl+ut},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"eventsConfig",{get:function(){if(this._portalSelf)return f(this._portalSelf,"portalProperties.hub.settings.events")},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"hubEnabled",{get:function(){return b(this._portalSelf,"portalProperties.hub.enabled",!1)},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"communityOrgId",{get:function(){if(this._portalSelf)return f(this._portalSelf,"portalProperties.hub.settings.communityOrg.orgId")},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"communityOrgHostname",{get:function(){if(this._portalSelf)return f(this._portalSelf,"portalProperties.hub.settings.communityOrg.portalHostname")},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"communityOrgUrl",{get:function(){if(this.communityOrgHostname)return"https://"+this.communityOrgHostname},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"helperServices",{get:function(){if(this._portalSelf)return this._portalSelf.helperServices},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"currentUser",{get:function(){return this._currentUser},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"portal",{get:function(){return this._portalSelf},enumerable:!1,configurable:!0}),Object.defineProperty(ft.prototype,"properties",{get:function(){return this._properties},enumerable:!1,configurable:!0}),ft);function ft(e){this._portalUrl="https://www.arcgis.com",this.id=e.id,this._portalUrl=e.portalUrl,this._hubUrl=e.hubUrl,e.authentication&&(this._authentication=e.authentication),e.portalSelf&&(this._portalSelf=e.portalSelf),e.currentUser&&(this._currentUser=e.currentUser),e.properties&&(this._properties=e.properties)}var dt=(ht.create=function(r){return void 0===r&&(r={}),O(this,void 0,void 0,function(){var t;return E(this,function(e){switch(e.label){case 0:return[4,(t=new ht(r)).initialize()];case 1:return e.sent(),[2,t]}})})},ht.prototype.setAuthentication=function(t){return O(this,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return this._authentication=t,this._portalUrl=t.portal.replace("/sharing/rest",""),[4,this.initialize()];case 1:return e.sent(),[2]}})})},ht.prototype.setProperties=function(e){this._properties=e,this._context=new pt(this.contextOpts)},ht.prototype.clearAuthentication=function(){this._context.isPortal||(this._portalUrl=ot(this._portalUrl)),this._authentication=null,this._portalSelf=null,this._currentUser=null,this._context=new pt(this.contextOpts)},Object.defineProperty(ht.prototype,"context",{get:function(){return this._context},enumerable:!1,configurable:!0}),ht.prototype.initialize=function(){return O(this,void 0,void 0,function(){var t,r,n;return E(this,function(e){switch(e.label){case 0:if(!this._authentication||this._portalSelf&&this._currentUser)return[3,4];F.debug("ArcGISContextManager-"+this.id+": Initializing"),t=this._authentication.username,t=[Ve({authentication:this._authentication}),Be({username:t,authentication:this._authentication})],e.label=1;case 1:return e.trys.push([1,3,,4]),[4,Promise.all(t)];case 2:return n=e.sent(),r=n[0],n=n[1],this._portalSelf=r,this._currentUser=n,F.debug("ArcGISContextManager-"+this.id+": received portalSelf and currentUser"),[3,4];case 3:throw r=e.sent(),n='ArcGISContextManager could not fetch portal & user for "'+this._authentication.username+'" using '+this._authentication.portal+".",F.error(n),console.error(n),r;case 4:return F.debug("ArcGISContextManager-"+this.id+": updating context"),this._context=new pt(this.contextOpts),[2]}})})},Object.defineProperty(ht.prototype,"contextOpts",{get:function(){var e={id:this.id,portalUrl:this._portalUrl,hubUrl:this._hubUrl,properties:this._properties};return this._authentication&&(e.authentication=this._authentication),this._portalSelf&&(e.portalSelf=this._portalSelf),this._currentUser&&(e.currentUser=this._currentUser),e},enumerable:!1,configurable:!0}),ht);function ht(e){this._portalUrl="https://www.arcgis.com",this._logLevel=n.Level.error,this.id=(new Date).getTime(),e.logLevel&&(this._logLevel=e.logLevel),F.setLogLevel(this._logLevel),F.debug("ArcGISContextManager:ctor: Creating "+this.id),e.properties&&(this._properties=e.properties),e.authentication?(this._authentication=e.authentication,this._portalUrl=this._authentication.portal.replace("/sharing/rest","")):e.portalUrl&&(this._portalUrl=e.portalUrl),this._hubUrl=nt(this._portalUrl),e.portal&&(this._portalSelf=p(e.portal)),e.currentUser&&(this._currentUser=p(e.currentUser))}var mt={app:["Application","City Engine Web Scene","CityEngine Web Scene","Dashboard","Insights Page","Insights Workbook","Operation View","Web Mapping Application","StoryMap","Web Experience","Urban Model"],dataset:["CSV Collection","CSV","Feature Collection Template","Feature Collection","Feature Layer","Feature Service","File Geodatabase","GeoJSON","GeoJson","KML Collection","KML","Microsoft Excel","Raster Layer","Shapefile","Stream Service","Table"],document:["CAD Drawing","Document Link","Hub Page","Site Page","Image","iWork Keynote","iWork Numbers","iWork Pages","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","PDF","Pro Map","Report Template"],event:["Hub Event"],feedback:["Form","Quick Capture Project"],initiative:["Hub Initiative"],template:["Hub Initiative Template"],solution:["Solution"],map:["Image Collection","Image Service","Map Service Layer","Map Service","Scene Service","Scene Layer","Vector Tile Service","Web Map Service","Web Map Tile Service","Web Map","Web Scene","WFS","WMS","WMTS"],other:["360 VR Experience","AppBuilder Widget Package","Application Configuration","ArcPad Package","Code Attachment","Code Sample","Desktop Add In","Desktop Application Template","Desktop Application","Desktop Style","Explorer Add In","Explorer Layer","Geocoding Service","Geometry Service","Geoprocessing Package","Geoprocessing Sample","Geoprocessing Service","Layer File","Layer Package","Layer Template","Layer","Layout","Locator Package","Map Area","Map Document","Map Package","Map Service Definition","Map Template","Mobile Application","Mobile Map Package","Native Application","Network Analysis Service","Operations Dashboard Add In","Project Package","Project Template","Raster Function Template","Rule Package","Scene Package","Service Definition","SQLite Geodatabase","Style","Tile Package","Vector Tile Package","Workflow Manager Package"],site:["Hub Site Application","Site Application"]},gt=mt.app,vt=mt.dataset,yt=mt.document,bt=mt.event,wt=mt.feedback,St=mt.initiative,Ct=mt.map,kt=mt.other,At=mt.site,Tt=["360 VR Experience","Application","CityEngine Web Scene","Code Sample","CSV Collection","CSV","CAD Drawing","Desktop Application","Desktop Application Template","Desktop Style","File Geodatabase","GeoJson","Geoprocessing Package","Geoprocessing Sample","Image","iWork Keynote","iWork Numbers","KML Collection","KML","Layer","Layer File","Layer Package","Layout","Locator Package","Map Package","Map Service Definition","Map Template","Microsoft Excel","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","Operations Dashboard Add In","PDF","Pro Map","Project Package","Project Template","Raster function template","Rule Package","Service Definition","Shapefile","Vector Tile Package","Workflow Manager Package"],xt=["Data"],Pt={app:gt.concat(wt),dataset:vt,document:yt,event:bt,initiative:St,map:Ct,other:kt,site:At,downloadableTypes:Tt,downloadableTypeKeywords:xt,apiTypes:["Feature Service","Map Service","Image Service"]};function It(e){return-1!==Tt.indexOf(e.type)||e.typeKeywords&&xt.some(function(t){return e.typeKeywords.some(function(e){return e===t})})}function Ot(e){return[[e.xmin,e.ymin],[e.xmax,e.ymax]]}var Et={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}};function _t(e){var t=e.portalSelf,r=t.defaultExtent,t=f(t,"helperServices.geometry.url");if(!t)return Promise.resolve(Et);if(!r)return Promise.resolve(Et);t+="/project",r={httpMethod:"POST",params:{geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[r]}),transformForward:!1,transformation:"",inSR:r.spatialReference.wkid,outSR:4326,f:"json"}};return e.authentication&&(r.authentication=e.authentication),Q(t,r).then(function(e){e=e.geometries[0];return{xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:e.ymax,spatialReference:{wkid:4326}}}).catch(function(e){return Et})}var Dt=function(e){return Array.isArray(e)&&Array.isArray(e[0])&&Array.isArray(e[1])};function Ut(e){return console.warn("DEPRECATED: use isBBox() instead"),Dt(e)}function jt(e){var t=(n=e[0])[0],r=n[1],e=(n=e[1])[0],n=n[1];return{rings:[[[t,r],[e,r],[e,n],[t,n],[t,r]]],spatialReference:{wkid:4326}}}var Nt=[{type:"CC0-1.0",abbr:"CC0",name:"Public Domain Dedication",url:"http://creativecommons.org/publicdomain/zero/1.0"},{type:"CC-BY-4.0",abbr:"CC BY",name:"Attribution 4.0 International",url:"http://creativecommons.org/licenses/by/4.0"},{type:"CC-BY-3.0",abbr:"CC BY 3.0",name:"Attribution 3.0 Unported",url:"http://creativecommons.org/licenses/by/3.0"},{type:"CC-BY-2.5",abbr:"CC BY 2.5",name:"Attribution 2.5 Generic",url:"http://creativecommons.org/licenses/by/2.5"},{type:"CC-BY-2.0",abbr:"CC BY 2.0",name:"Attribution 2.0 Generic",url:"http://creativecommons.org/licenses/by/2.0"},{type:"CC-BY-1.0",abbr:"CC BY 1.0",name:"Attribution 1.0 Generic",url:"http://creativecommons.org/licenses/by/1.0"},{type:"CC-BY-SA-4.0",abbr:"CC BY-SA",name:"Attribution-ShareAlike 4.0 International",url:"http://creativecommons.org/licenses/by-sa/4.0"},{type:"CC-BY-SA-3.0",abbr:"CC BY-SA 3.0",name:"Attribution-ShareAlike 3.0 Unported",url:"http://creativecommons.org/licenses/by-sa/3.0"},{type:"CC-BY-SA-2.5",abbr:"CC BY-SA 2.5",name:"Attribution-ShareAlike 2.5 Generic",url:"http://creativecommons.org/licenses/by-sa/2.5"},{type:"CC-BY-SA-2.0",abbr:"CC BY-SA 2.0",name:"Attribution-ShareAlike 2.0 Generic",url:"http://creativecommons.org/licenses/by-sa/2.0"},{type:"CC-BY-SA-1.0",abbr:"CC BY-SA 1.0",name:"Attribution-ShareAlike 1.0 Generic",url:"http://creativecommons.org/licenses/by-sa/1.0"},{type:"CC-BY-ND-4.0",abbr:"CC BY-ND",name:"Attribution-NoDerivatives 4.0 International",url:"http://creativecommons.org/licenses/by-nd/4.0"},{type:"CC-BY-ND-3.0",abbr:"CC BY-ND 3.0",name:"Attribution-NoDerivs 3.0 Unported",url:"http://creativecommons.org/licenses/by-nd/3.0"},{type:"CC-BY-ND-2.5",abbr:"CC BY-ND 2.5",name:"Attribution-NoDerivs 2.5 Generic",url:"http://creativecommons.org/licenses/by-nd/2.5"},{type:"CC-BY-ND-2.0",abbr:"CC BY-ND 2.0",name:"Attribution-NoDerivs 2.0 Generic",url:"http://creativecommons.org/licenses/by-nd/2.0"},{type:"CC-BY-ND-1.0",abbr:"CC BY-ND 1.0",name:"Attribution-NoDerivs 1.0 Generic",url:"http://creativecommons.org/licenses/by-nd/1.0"},{type:"CC-BY-NC-4.0",abbr:"CC BY-NC",name:"Attribution-NonCommercial 4.0 International",url:"https://creativecommons.org/licenses/by-nc/4.0"},{type:"CC-BY-NC-3.0",abbr:"CC BY-NC 3.0",name:"Attribution-NonCommercial 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc/3.0"},{type:"CC-BY-NC-2.5",abbr:"CC BY-NC 2.5",name:"Attribution-NonCommercial 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc/2.5"},{type:"CC-BY-NC-2.0",abbr:"CC BY-NC 2.0",name:"Attribution-NonCommercial 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc/2.0"},{type:"CC-BY-NC-1.0",abbr:"CC BY-NC 1.0",name:"Attribution-NonCommercial 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc/1.0"},{type:"CC-BY-NC-SA-4.0",abbr:"CC BY-NC-SA",name:"Attribution-NonCommercial-ShareAlike 4.0 International",url:"https://creativecommons.org/licenses/by-nc-sa/4.0"},{type:"CC-BY-NC-SA-3.0",abbr:"CC BY-NC-SA 3.0",name:"Attribution-NonCommercial-ShareAlike 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-sa/3.0"},{type:"CC-BY-NC-SA-2.5",abbr:"CC BY-NC-SA 2.5",name:"Attribution-NonCommercial-ShareAlike 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.5"},{type:"CC-BY-NC-SA-2.0",abbr:"CC BY-NC-SA 2.0",name:"Attribution-NonCommercial-ShareAlike 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.0"},{type:"CC-BY-NC-SA-1.0",abbr:"CC BY-NC-SA 1.0",name:"Attribution-NonCommercial-ShareAlike 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/1.0"},{type:"CC-BY-NC-ND-4.0",abbr:"CC BY-NC-ND",name:"Attribution-NonCommercial-NoDerivatives 4.0 International",url:"https://creativecommons.org/licenses/by-nc-nd/4.0"},{type:"CC-BY-NC-ND-3.0",abbr:"CC BY-NC-ND 3.0",name:"Attribution-NonCommercial-NoDerivs 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-nd/3.0"},{type:"CC-BY-NC-ND-2.5",abbr:"CC BY-NC-ND 2.5",name:"Attribution-NonCommercial-NoDerivs 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.5"},{type:"CC-BY-NC-ND-2.0",abbr:"CC BY-NC-ND 2.0",name:"Attribution-NonCommercial-NoDerivs 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.0"},{type:"CC-BY-NC-ND-1.0",abbr:"CC BY-NC-ND 1.0",name:"Attribution-NonCommercial-NoDerivs 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/1.0"},{type:"PDDL-1.0",abbr:"PDDL",name:"ODC Public Domain Dedication and License",url:"http://opendatacommons.org/licenses/pddl/summary"},{type:"ODbL-1.0",abbr:"ODbL",name:"ODC Open Database License",url:"http://opendatacommons.org/licenses/odbl/summary"},{type:"ODC-BY-1.0",abbr:"ODC BY",name:"ODC Attribution License",url:"http://opendatacommons.org/licenses/by/summary"}];function Rt(r){var e={type:(r=r||"")?"custom":"none",text:r},t=!1,n=Nt.filter(function(e){return t=e,(e=(e=r).toLowerCase()).includes(t.name.toLowerCase())||e.includes(t.url.toLowerCase())||e.includes(t.abbr.toLowerCase());var t});return n.length&&(t=!0,e=n.pop()),t||(n=void 0,!function(e){try{return!!new URL(e).protocol}catch(e){return!1}}(r)?(t=r,new RegExp(/^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)>((?:.(?!\<\/a\>))*.)?<\/a>$|^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)\/>/).test(t)&&(t=new RegExp(/href\s?=\s?["'](.*?)["']/),n=r.match(t)[1])):n=r,n&&(e.url=n,e.text="")),e.text||delete e.text,e}var Mt=function(e,t){var r=I(I({},e.item),{extent:t}),r=I(I({},e),{item:r,extent:t}),t=Lt(r);return I(I({},r),{boundary:t})},Lt=function(e){var t,e=e.item,r=e.extent,n=Dt(r),e=(null===(e=e.properties)||void 0===e?void 0:e.boundary)||(n?"item":void 0);switch(e){case"item":t=n?jt(r):null;break;case"none":t=null}return{provenance:e,geometry:t}};var Ft={};function qt(e){void 0===e&&(e=""),console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v10.0.0");e=Bt(e);return"feedback"===e?"app":e}function Gt(e){var t=(e=void 0===e?{}:e).type,r=e.typeKeywords||[];return("Site Application"===e.type||"Web Mapping Application"===e.type&&x(r,"hubSite"))&&(t="Hub Site Application"),("Site Page"===e.type||"Web Mapping Application"===e.type&&x(r,"hubPage"))&&(t="Hub Page"),"Hub Initiative"===e.type&&x(r,"hubInitiativeTemplate")&&(t="Hub Initiative Template"),t="Web Mapping Application"===e.type&&x(r,"hubSolutionTemplate")?"Solution":t}function Bt(e){if(Ft[e=void 0===e?"":e])return Ft[e];for(var t=0,r=Object.keys(mt);t<r.length;t++)for(var n=r[t],o=0,i=mt[n];o<i.length;o++){var a=i[o];if(e.toLowerCase()===a.toLowerCase())return Ft[e]=n}}function Ht(e){return e&&"feature service"===e.toLowerCase()}function Wt(e){return(e=e&&e.match(/\/\d+$/))&&e[0].slice(1)}function Yt(e){return Wt(e.url)||Ht(e.type)&&x(e.typeKeywords,"Singlelayer")&&"0"}function Kt(t,e){if(x(["template","feedback"],t.family))return t.id;if(cr(t)){var r=(f(e,"data.values.pages")||[]).find(function(e){return e.id===t.id});return r?r.slug:t.id}if(t.slug){r=f(e,"domainInfo.orgKey");return f(e,"data.values.isUmbrella")?t.slug:Vt(t.slug,r)}return t.hubId||t.id}function zt(e){e=e?e.split("_"):[];return{itemId:e[0],layerId:e[1]}}function Vt(e,t){return t&&e.match(t+"::")?e.split(t+"::")[1]:e}function Jt(e){if(!e)return e;var t=["categories",""];return e.map(function(e){return e.split("/")}).reduce(function(e,t,r){return _(e,t)},[]).filter(function(e){return!x(t,e.toLowerCase())})}function $t(e){var t,r;switch((e||"").toLowerCase()){case"image service":t="dataset";break;case"feature service":case"raster layer":t="map";break;case"microsoft excel":t="document";break;case"cad drawing":case"feature collection template":case"report template":t="content";break;default:t={other:"content",solution:"template"}[r=Bt(e)]||r}return t}function Xt(e){return console.warn("DEPRECATED: Use getFamily() instead. getItemHubType() will be removed at v10.0.0"),Bt(Gt(e="string"==typeof e?{type:e}:e))}function Qt(e){var t=new Date(e.created),r="item.created",n=e.properties,r=Object.assign({},e,{identifier:e.id,errors:[],item:e,name:e.title,hubType:Xt(e),categories:Jt(e.categories),itemCategories:e.categories,summary:e.snippet||e.description,publisher:{name:e.owner,username:e.owner},permissions:{visibility:e.access,control:e.itemControl||"view"},actionLinks:n&&n.links,hubActions:n&&n.actions,metrics:n&&n.metrics,isDownloadable:It(e),license:{name:"Custom License",description:e.accessInformation},createdDate:t,createdDateSource:r,publishedDate:t,publishedDateSource:r,updatedDate:new Date(e.modified),updatedDateSource:"item.modified",structuredLicense:Rt(e.licenseInfo)});return Mt(rr(r,e.type),e.extent)}function Zt(e){if(e){var t=e.id,r=e.attributes;if(r){var n=zt(t).itemId,o=r.owner,i=r.orgId,a=r.created,s=r.modified,u=r.name,c=r.title,l=r.type,p=r.typeKeywords,f=r.description,d=r.snippet,h=r.tags,m=r.thumbnail,g=r.categories,v=r.contentStatus,y=r.spatialReference,b=r.accessInformation,w=r.licenseInfo,S=r.culture,C=r.url,k=r.access,A=r.proxyFilter,T=r.properties,x=r.appCategories,P=r.industries,I=r.languages,O=r.largeThumbnail,E=r.banner,_=r.screenshots,D=r.listed,U=r.ownerFolder,j=r.size,N=r.protected,R=r.commentsEnabled,M=r.numComments,L=r.numRatings,F=r.avgRating,q=r.numViews,G=r.itemControl,B=r.scoreCompleteness,H=r.itemExtent,e=r.itemModified,t=r.modifiedProvenance,r=r.serviceSpatialReference;return{id:n,owner:o,orgId:i,created:a,modified:e||"item.modified"===t&&s,title:c||u,type:C&&at(C)||l,typeKeywords:p,description:f,tags:h,snippet:d,thumbnail:m,extent:H||[],categories:g,contentStatus:v,spatialReference:y||r,accessInformation:b,licenseInfo:w,culture:S,url:C,access:k,size:j,protected:N,proxyFilter:A,properties:T,appCategories:x,industries:P,languages:I,largeThumbnail:O,banner:E,screenshots:_,listed:D,ownerFolder:U,commentsEnabled:R,numComments:M,numRatings:L,avgRating:F,numViews:q,itemControl:G,scoreCompleteness:B}}}}function er(e,t){var r=e.id,r=e.slug||t||r,r=I(I({},e),{hubId:t,identifier:r});return ar(r,{relative:sr(r)})}function tr(e,t){var r=Kt(e,t);return{relative:r=sr(e,r),absolute:""+f(t,"item.url").replace(/\/$/,"")+r}}var rr=function(e,t){var r=Gt(I(I({},e.item),{type:t})),n=$t(r),o=nr(r),t=or(r,e.isProxied),t=I(I({},e),{type:r,family:n,normalizedType:r,contentTypeIcon:o,contentTypeLabel:t});return ar(t,{relative:sr(t)})},nr=function(e){return null!==(e={appbuilderExtension:"file",appbuilderWidgetPackage:"widgets-source",application:"web",applicationConfiguration:"app-gear",arcgisProMap:"desktop",cadDrawing:"file-cad",cityEngineWebScene:"urban-model",codeAttachment:"file-code",codeSample:"file-code",colorSet:"palette",contentCategorySet:"label",csv:"file-csv",cSV:"file-csv",cSVCollection:"file-csv",dashboard:"dashboard",desktopApplication:"desktop",documentLink:"link",excaliburImageryProject:"file",explorerMap:"file",exportPackage:"file",featureCollection:"data",featureCollectionTemplate:"file",featureLayer:"data",featureService:"collection",fileGeodatabase:"data",form:"survey",geocodingService:"file",geodataService:"file",geometryService:"file",geopackage:"file",geoprocessingService:"file",globeLayer:"layers",globeService:"file",hubInitiative:"initiative",hubInitiativeTemplate:"initiative-template",hubPage:"browser",hubSiteApplication:"web",image:"file-image",imageService:"data",insightsModel:"file",insightsPage:"graph-moving-average",insightsTheme:"palette",insightsWorkbook:"graph-moving-average",iWorkPages:"file-text",iWorkKeynote:"presentation",iWorkNumbers:"file-report",kML:"data",kMLCollection:"data",layer:"layers",layerPackage:"layers",layerTemplate:"file",locatorPackage:"file",mapArea:"file",mapDocument:"map-contents",mapImageLayer:"collection",mapPackage:"file",mapService:"collection",microsoftExcel:"file-report",microsoftPowerpoint:"presentation",microsoftWord:"file-text",mission:"file",mobileMapPackage:"map-contents",nativeApplication:"mobile",nativeApplicationInstaller:"file",nativeApplicationTemplate:"file",mobileApplication:"mobile",networkAnalysisService:"file",notebook:"code",orientedImageryCatalog:"file",orthoMappingProject:"file",orthoMappingTemplate:"file",pDF:"file-pdf",quickCaptureProject:"mobile",rasterFunctionTemplate:"file",rasterLayer:"map",realTimeAnalytic:"file",relationalDatabaseConnection:"file",reportTemplate:"file",sceneLayer:"data",sceneService:"urban-model",serviceDefinition:"file",shapefile:"data",solution:"puzzle-piece",sqliteGeodatabase:"file",statisticalDataCollection:"file",storymap:"tour",storyMap:"tour",storymapTheme:"palette",symbolSet:"file",table:"table",urbanModel:"urban-model",vectorTilePackage:"file-shape",vectorTileService:"map",visioDocument:"conditional-rules",webExperience:"apps",webMap:"map",webMappingApplication:"apps",webScene:"urban-model",wfs:"map",wFS:"map",wMS:"map",wMTS:"map",workflowManagerService:"file",workforceProject:"list-check"}[m(e||"")])&&void 0!==e?e:"file"},or=function(e,t){return t?"CSV":m(e||"")},ir=function(e,t){var r=tr(e,t),t=r.relative,r=r.absolute;return ar(e,{relative:t,site:r})},ar=function(e,t){t=I(I({},e.urls),t);return I(I({},e),{urls:t})},sr=function(e,t){var r=e.family,n=t||e.identifier,o=ur(e);return o||(t="/content","feedback"===e.family?t="/feedback/surveys":cr(e)?t="/pages":-1<["app","dataset","document","map","template"].indexOf(r)&&(t="/"+r+"s"),o=t+"/"+n),o},ur=function(e){var t,r=e.type,n=e.identifier;return"Solution"===r&&(0<(null===(e=e.typeKeywords)||void 0===e?void 0:e.indexOf("Deployed"))&&(t="/content/"+n),t="/templates/"+n+"/about"),t},cr=function(e){return x(["Hub Page","Site Page"],e.type)};const lr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const pr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var fr={atob:function(t){if((t=(t=(t=`${t}`).replace(/[ \t\n\f\r]/g,"")).length%4==0?t.replace(/==?$/,""):t).length%4==1||/[^+/0-9A-Za-z]/.test(t))return null;let r="",n=0,o=0;for(let e=0;e<t.length;e++)n<<=6,n|=function(e){e=lr.indexOf(e);return e<0?void 0:e}(t[e]),o+=6,24===o&&(r+=String.fromCharCode((16711680&n)>>16),r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n),n=o=0);return 12===o?(n>>=4,r+=String.fromCharCode(n)):18===o&&(n>>=2,r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n)),r},btoa:function(e){let t;for(e=`${e}`,t=0;t<e.length;t++)if(255<e.charCodeAt(t))return null;let r="";for(t=0;t<e.length;t+=3){const n=[void 0,void 0,void 0,void 0];n[0]=e.charCodeAt(t)>>2,n[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(n[1]|=e.charCodeAt(t+1)>>4,n[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(n[2]|=e.charCodeAt(t+2)>>6,n[3]=63&e.charCodeAt(t+2));for(let e=0;e<n.length;e++)void 0===n[e]?r+="=":r+=function(e){if(0<=e&&e<64)return pr[e];return}(n[e])}return r}},dr="4326",hr={csv:{name:"CSV",itemTypes:["CSV","CSV Collection"],supportsProjection:!0},kml:{name:"KML",itemTypes:["KML","KML Collection"],supportsProjection:!1},shapefile:{name:"Shapefile",itemTypes:["Shapefile"],supportsProjection:!0},fileGeodatabase:{name:"File Geodatabase",itemTypes:["File Geodatabase"],supportsProjection:!0},geojson:{name:"GeoJson",itemTypes:["GeoJson"],supportsProjection:!1},excel:{name:"Excel",itemTypes:["Microsoft Excel"],supportsProjection:!0},featureCollection:{name:"Feature Collection",itemTypes:["Feature Collection"],supportsProjection:!0}};function mr(e){if("object"!=typeof e)return e;var t=e.wkid,e=e.wkt;return t?t+"":fr.btoa(e)}function gr(e){return"spatialRefId:"+mr(function(t){var r;try{r=JSON.parse(t)}catch(e){r=t}return r}(e))}function vr(e){return"exportItem:"+e}function yr(e){return e?"exportLayer:0"+e:"exportLayer:null"}function br(e){var t,r=e.autoAddResult,n=e.inviteResult,o=e.primaryEmailResult,e=e.secondaryEmailResult;return(o||e)&&(t={success:(e=[o,e].filter(function(e){return e})).every(function(e){return e.success})},(e=e.reduce(function(e,t){return e.concat(b(t,"errors",[]))},[])).length&&(t.errors=e)),{success:[r,n,t].filter(function(e){return e}).every(function(e){return e.success}),autoAdd:r,invite:n,email:t}}function wr(t,e){var r;return t&&(r=!f(t,"notAdded.length")&&!t.errors,e.autoAddResult={success:r},r||(r=t.errors||[],f(t,"notAdded.length")&&r.push(new Y("Users not auto-added: "+t.notAdded.join(", "))),e.autoAddResult.errors=r,r=e.usersToAutoAdd.filter(function(e){return x(t.notAdded,e.username)}),e.usersToInvite=e.usersToInvite.concat(r))),e}function Sr(e,t){return e.orgId===t.orgId}function Cr(e){return"org_admin"===e.role&&!e.roleId}function kr(e,t,r,n){var o=Promise.resolve(null);return e.length&&(e={authentication:r,message:t.body,subject:t.subject,notificationChannelType:"email",users:e.map(function(e){return e.username})},n||(e.batchSize=1),o=qe(e)),o}function Ar(t){var r,e=Promise.resolve(t);return t.email&&t.secondaryRO&&f(t,"inviteResult.success")&&(r=b(t,"secondaryRO.portalSelf.user",{}),e=kr(t.usersToInvite.filter(function(e){return Sr(e,r)}),t.email,t.secondaryRO.authentication,Cr(r)).then(function(e){return t.secondaryEmailResult=e,t})),e}function Tr(e,t,r){var n=Promise.resolve(null);return n=t.length?_e({id:e,users:t.map(function(e){return e.username}),authentication:r}):n}function xr(t){return Tr(f(t,"groupId"),f(t,"usersToAutoAdd"),f(t,"primaryRO.authentication")).then(function(e){return wr(e,t)})}function Pr(e,t,r,n,o){void 0===n&&(n=20160),void 0===o&&(o="group_member");var i=Promise.resolve(null);return i=t.length?Ne({id:e,users:t.map(function(e){return e.username}),authentication:r,role:o,expiration:n}):i}function Ir(t){return Pr(f(t,"groupId"),f(t,"usersToInvite"),f(t,"primaryRO.authentication")).then(function(e){return t.inviteResult=e,t})}function Or(t){var e=Promise.resolve(t);return e=t.email&&f(t,"inviteResult.success")?kr(t.usersToEmail,t.email,t.primaryRO.authentication,Cr(t.requestingUser)).then(function(e){return t.primaryEmailResult=e,t}):e}function Er(e,t){var r,n=[];return-1!==t.privileges.indexOf("portal:admin:assignToGroups")&&(r=[t.orgId,t.cOrgId].filter(function(e){return e}),n=e.filter(function(e){return-1!==r.indexOf(e.orgId)})),n}function _r(e,t){var r=Er(e,t);return e.filter(function(t){return!r.some(function(e){return e.username===t.username})})}function Dr(e,t,r){void 0===r&&(r=!1);e=_r(e,t).filter(function(e){return Sr(e,t)});return r&&e.push(t),e}var Ur=["ar","bs","ca","cs","da","de","en","es","et","el","fi","fr","hr","he","hu","it","id","ja","ko","lt","lv","nb","nl","pl","pt","pt-br","pt-pt","ro","ru","sl","sr","sv","th","tr","uk","vi","zh","zh-cn","zh-tw","zh-hk"];function jr(e,t){if("object"==typeof e&&null!==e&&"string"==typeof t){for(var r=t.split("."),n=0;n<r.length-1;n++){if(!e.hasOwnProperty(r[n]))return;e=e[r[n]]}delete e[r[r.length-1]]}}function Nr(e){var t=p(e.item);return t.text=JSON.stringify(e.data),t}function Rr(e,t){return Promise.all([be(e,t),Se(e,t)]).then(function(e){return{item:e[0],data:e[1]}})}function Mr(e,r){return cn(e,r).then(function(e){var t=[Promise.resolve(e)];return e?t.push(Se(e.id,r)):t.push(Promise.resolve(null)),Promise.all(t)}).then(function(e){return e[0]?{item:e[0],data:e[1]}:null})}function Lr(e,t){var r=p(e),n=p(e.item);return n.data=p(e.data),ye(I({item:n},t)).then(function(e){return r.item.id=e.id,r.item.created=(new Date).getTime(),r.item.modified=r.item.created,r})}function Fr(e,t){var r=p(e),n=p(e.item);return n.data=p(e.data),ve(I({item:n},t)).then(function(){return r.item.modified=(new Date).getTime(),r})}function qr(r,n){return O(this,void 0,void 0,function(){var t;return E(this,function(e){switch(e.label){case 0:return[4,Se(r.id,n)];case 1:return t=e.sent(),[2,{item:r,data:t}]}})})}var Gr=function(e,t,r){return void 0===r&&(r=void 0),t.split(".").reduce(function(e,t){return e?e[t]:r},e)};function Br(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}var Hr=function(e){return e instanceof Date},Wr=function(e){return"function"==typeof e},Yr=function(e){return"object"==typeof e},Kr=function(e){return e instanceof RegExp};var zr=function(e){return"object"==typeof e};function Vr(e){return Array.isArray(e)?function(e){var t=e,e=e.reduce(function(e,t){return Xr(t)&&$r(t)&&(e<(t=Jr(t))&&(e=t)),e},-1);-1<e&&(t=0===e?[]:"{{delete:"+(e-1)+"}}");return t}(e.map(t).filter(function(e){return null!=e})):e&&zr(e)?function(o){var e=Object.keys(o).reduce(function(e,t){var r,n=o[t];return Xr(n)&&$r(n)?(r=Jr(n))>e.maxLevel&&(e.maxLevel=r):e.obj[t]=n,e},{obj:{},maxLevel:-1});e=0<e.maxLevel?1===e.maxLevel?void 0:"{{delete:"+(e.maxLevel-1)+"}}":e.obj;return e}(Br(e,t)):function(e){var t=e;"string"==typeof e&&$r(e)&&(t=function(e){var t=e,e=Jr(e);t=0===e?void 0:"{{delete:"+e+"}}";return t}(e));return t}(e);function t(e,t){return Vr(e)}}var Jr=function(e){return parseInt(e.replace(/{|}/g,"").split(":")[1])};function $r(e){return e&&"string"==typeof e&&-1<e.indexOf("{{delete")}var Xr=function(e){return"string"==typeof e};function Qr(e,t,r,n){return void 0===n&&(n=0),t?t:"{{delete:"+n+"}}"}var Zr=function(e){var t={};if(Array.isArray(e))t=e.map(Zr);else if("object"==typeof e)for(var r in e)null!=e[r]&&"object"==typeof e[r]?t[r]=Zr(e[r]):t[r]=e[r];else t=e;return t},en=/{{\s*?[\w].*?}}/g,tn=function(e){return"string"==typeof e};function rn(e){return e||""===e||0===e}function nn(e,a,s){if((s=Zr(s=void 0===s?null:s)||{}).optional)throw new Error("Please do not pass in an `optional` transform; adlib provides that internally.");return s.optional=Qr,Vr(function r(e,n,o){return o=o||"",Array.isArray(e)?e.map(t):!e||!Yr(e)||Hr(e)||Kr(e)||Wr(e)?n(e,o):Object.assign({},e,Br(e,t));function t(e,t){return r(e,n,o?o+"."+t:t)}}(e,function(t,e){if(!tn(t))return t;var r,n=t.match(en);return n&&n.length?(n.map(function(e){var o,i=!1,t=e.replace(/{|}/g,"").trim();-1<t.indexOf("||")&&(r=t.split("||").map(function(e){return e.trim()}),o=r.length,t=r.find(function(e,t){var r,n;return(n=a,r=(r=e).split(":")[0],null!=(r=Gr(n,r,null)))?e:t+1===o&&(i=!0,isNaN(e)?e:parseInt(e))}));var r={key:e,value:t};return i||(t=function(e,t,r){var n,o=e.split(":");if(1<o.length){var i,a=o[0],s=o[1];if(o[2]&&(i=o[2]),!r||!r[s]||"function"!=typeof r[s])throw new Error("Attempted to apply non-existant transform "+s+" on "+a+" with params "+e);n=Gr(t,a),n=r[s](a,n,t,i)}else n=Gr(t,e);return n}(t,a,s),r.value=rn(t)?t:e),r}).forEach(function(e){t===e.key?("string"==typeof e.value&&(isNaN(e.value)||""===e.value||(-1<e.value.indexOf(".")?e.value=parseFloat(e.value):e.value=parseInt(e.value))),r=e.value):t=t.replace(e.key,e.value)}),rn(r)?r:t):t}))}function on(e,t,r){return nn(e,t,r)}function an(e,t,r){return Oe({q:'title:"'+e+'" AND '+Object.keys(t).map(function(e){return e+':"'+t[e]+'"'}).join(" AND "),authentication:r}).then(function(e){return 0<e.results.length}).catch(function(e){throw Error("Error in doesItemExistWithTitle "+e)})}function sn(e,t){return t.toLowerCase()+"-"+L(e)}function un(e,t){e=e.filter(function(e){return!e.startsWith("slug|")});return e.push("slug|"+t),e}function cn(e,t){return ln({slug:e},t).then(function(e){return e.length?e[0]:null})}function ln(e,t){t={q:"",filter:'typekeywords:"slug|'+e.slug+'"',authentication:t.authentication};return e.exclude&&(t.q="NOT id:"+e.exclude),Oe(t).then(function(e){return e.results}).catch(function(e){throw Error("Error in getItemBySlug "+e)})}function pn(t,r,n){var o=t.slug;return ln({slug:o=(n=void 0===n?0:n)?t.slug+"-"+n:o,exclude:t.existingId},r).then(function(e){return e.length?pn(t,r,++n):o}).catch(function(e){throw Error("Error in getUniqueSlug "+e)})}var fn=["id","isOrgItem","proxyFilter","ownerFolder","protected","owner","created","modified","guid","name","access","size","listed","numComments","numRatings","avgRating","numViews","scoreCompleteness","groupDesignations","listed","screenshots","banner","appCategories","industries","languages","largeThumbnail"];function dn(n,o,i,a){return O(this,void 0,void 0,function(){var t,r;return E(this,function(e){switch(e.label){case 0:t=I({item:{id:n},params:{thumbnail:o},filename:i},a),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,ve(t)];case 2:if(!e.sent().success)throw new Fo("Set Project Thumbnail","Unknown error setting thumbnail.");return[3,4];case 3:throw(r=e.sent())instanceof Error?new Fo("Set Project Thumbnail",r.message,r):new Fo("Set Project Thumbnail","Unknown error setting thumbnail.");case 4:return[2]}})})}var hn=(mn.prototype.modelToObject=function(e,t){return r=this.mappings,gn(e,"modelKey",t,"objectKey",r);var r},mn.prototype.objectToModel=function(e,t){return r=this.mappings,gn(e,"objectKey",t,"modelKey",r);var r},mn);function mn(e){this.mappings=e}function gn(r,n,e,o,t){var i=p(e);return t.forEach(function(e){var t=f(e,n),e=f(e,o),t=f(r,t);null!=t&&y(i,e,t)}),i}var Ct="Web Mapping Application",vn={name:"No title provided",tags:[],typeKeywords:["IHubProject","HubProject"],status:"inactive"},yn={item:{type:Ct,title:"No Title Provided",description:"No Description Provided",snippet:"",tags:[],typeKeywords:["Hub Project"],properties:{slug:""}},data:{display:"about",timeline:{},status:"inactive",contacts:[],schemaVersion:1}};function bn(){var t=[];return["created","culture","description","extent","id","modified","owner","snippet","tags","typeKeywords","url","type"].forEach(function(e){t.push({objectKey:e,modelKey:"item."+e})}),["contacts","display","geometry","headerImage","layout","location","status"].forEach(function(e){t.push({objectKey:e,modelKey:"data."+e})}),t.push({objectKey:"slug",modelKey:"item.properties.slug"}),t.push({objectKey:"orgUrlKey",modelKey:"item.properties.orgUrlKey"}),t.push({objectKey:"name",modelKey:"item.title"}),t}function wn(i,a){return O(this,void 0,void 0,function(){var t,r,n,o;return E(this,function(e){switch(e.label){case 0:return(t=I(I({},vn),i)).slug||(t.slug=sn(t.name,t.orgUrlKey)),[4,pn({slug:(r=t).slug},a)];case 1:return r.slug=e.sent(),t.typeKeywords=un(t.typeKeywords,t.slug),n=new hn(bn()),[4,Lr(o=n.objectToModel(t,p(yn)),a)];case 2:return o=e.sent(),[2,n.modelToObject(o,{})]}})})}function Sn(o,i){return O(this,void 0,void 0,function(){var t,r,n;return E(this,function(e){switch(e.label){case 0:return[4,pn({slug:(t=o).slug,existingId:o.id},i)];case 1:return t.slug=e.sent(),[4,Rr(o.id,i)];case 2:return n=e.sent(),r=new hn(bn()),[4,Fr(r.objectToModel(o,n),i)];case 3:return n=e.sent(),[2,r.modelToObject(n,o)]}})})}function Cn(e,n){e=(M(e)?Rr:Mr)(e,n);return e.then(function(e){var t,r=new hn(bn()).modelToObject(e,{});return n.authentication&&(t=n.authentication.token),r.thumbnailUrl=Rn(e.item,n,t),r})}function kn(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return[4,Te(I(I({},r),{id:t}))];case 1:return e.sent(),[2]}})})}function An(r,n){var o;return O(this,void 0,void 0,function(){var t;return E(this,function(e){return t=Zn([{filterType:"content",typekeywords:{exact:["HubProject"]}},r]),t=eo(t),t=io(t),null!==(o=n.aggregations)&&void 0!==o&&o.length&&(t.countFields=n.aggregations.join(","),t.countSize=200),n.num&&(t.num=n.num),n.sortField&&(t.sortField=n.sortField),n.sortOrder&&(t.sortOrder=n.sortOrder),n.site&&(t.site=p(n.site)),n.authentication&&(t.authentication=n.authentication),[2,Tn(t)]})})}function Tn(s){return O(this,void 0,void 0,function(){var t,r,n,o,i,a;return E(this,function(e){switch(e.label){case 0:return[4,Oe(s)];case 1:return t=e.sent(),r=-1<t.nextStart,i=t.results.map(function(e){return qr(e,{authentication:s.authentication})}),[4,Promise.all(i)];case 2:return a=e.sent(),n=new hn(bn()),s.authentication&&(i=s.authentication,o=i.token),a=a.map(function(e){var t=n.modelToObject(e,{});return t.thumbnailUrl=Rn(e.item,{authentication:s.authentication},o),t}),[2,{total:t.total,results:a,facets:[],hasNext:r,next:Vn(s,t.nextStart,t.total,Tn)}]}})})}var xn=(Pn.init=function(e){return new Pn(e)},Object.defineProperty(Pn.prototype,"context",{get:function(){return this._contextManager?this._contextManager.context:this._context},enumerable:!1,configurable:!0}),Pn.prototype.create=function(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){if(r||this.context.isAuthenticated)return t.orgUrlKey||(t.orgUrlKey=this.context.portal.urlKey),[2,wn(t,r||this.context.userRequestOptions)];throw new Fo("Create Project","Creating Hub Projects requires authentication.")})})},Pn.prototype.update=function(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){if(r||this.context.isAuthenticated)return[2,Sn(t,r||this.context.userRequestOptions)];throw new Fo("Update Project","Updating Hub Projects requires authentication.")})})},Pn.prototype.destroy=function(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){if(r||this.context.isAuthenticated)return[2,kn(t,r||this.context.userRequestOptions)];throw new Fo("Destroy Project","Destroying Hub Projects requires authentication.")})})},Pn.prototype.get=function(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){return console.warn("HubProjectManager.get is deprecated and will be removed. Use .fetch() instead."),[2,this.fetch(t,r)]})})},Pn.prototype.fetch=function(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){if(r||this.context.requestOptions)return[2,Cn(t,r||this.context.requestOptions)];throw new Fo("Fetch Project","Can not retrieve context.requestOptions from Context Manager. HubProjectManager is configured incorrectly.")})})},Pn.prototype.search=function(t,r){return O(this,void 0,void 0,function(){return E(this,function(e){return!r.authentication&&this.context.session&&(r.authentication=this.context.session),[2,An(t,r)]})})},Pn.prototype.updateThumbnail=function(r,n,o,i){return O(this,void 0,void 0,function(){var t;return E(this,function(e){switch(e.label){case 0:return t=i||this.context.userRequestOptions,[4,dn(r.id,n,o,t)];case 1:return e.sent(),[2,this.fetch(r.id,i)]}})})},Pn);function Pn(e){e instanceof dt?this._contextManager=e:this._context=e}var In,On=(e(En,In=Error),En);function En(e,t,r){e=In.call(this,e)||this;return e.status=r,e.url=t,e}function _n(e,t){var r,n,o=I({httpMethod:"GET"},t),i=o.fetch||fetch,t=I({"Content-Type":"application/json"},o.headers);"GET"===o.httpMethod?r=o.params:n=JSON.stringify(o.params);var a=de({host:st(o),path:("/api/v3/"+e).replace(/\/\//g,"/"),query:r});return i(a,{method:o.httpMethod,headers:t,body:n}).then(function(e){if(e.ok)return e.json();throw new On(e.statusText,a,e.status)})}function Dn(e,t){var r=e;return r=-1===e.indexOf("token")&&-1<e.indexOf(t.authentication.portal)?e+"?token="+t.authentication.token:r}function Un(e,t){return(t=void 0===t?{}:t).credentials||(t.credentials="same-origin"),fetch(e,t).then(function(e){return e.blob()})}function jn(r){return Un(r.url).then(function(e){return ge(t={id:r.id,owner:r.owner,name:r.fileName,resource:e,authentication:r.authentication}).then(function(e){e=he(t)+"/content/users/"+e+"/items/"+t.id+"/addResources";return t.params=I({file:t.resource,fileName:t.name,resourcesPrefix:t.prefix,text:t.content,access:t.private?"private":"inherit"},t.params),Q(e,t)});var t})}function Nn(t){return Un(t.url).then(function(e){return ve({item:{id:t.id,owner:t.owner},params:{fileName:t.fileName,thumbnail:e},authentication:t.authentication}).catch(function(e){return Promise.resolve()})}).catch(function(e){return Promise.resolve()})}function Rn(e,t,r){if(!e||!e.thumbnail)return null;var n=r||{},o=n.token,n=n.width,r=rt(e,t,o=!o&&"string"==typeof r?r:o).split("?"),o=r[0],r=r[1],r=new URLSearchParams(r);r.delete("f"),n&&r.append("w",n+"");r=r.toString(),e=o+"/info/"+e.thumbnail;return r?e+"?"+r:e}var Mn={arcgis:{label:"ArcGIS Online",url:"https://www.arcgis.com",type:"arcgis"},arcgisQA:{label:"ArcGIS Online QAEXT",url:"https://qaext.arcgis.com",type:"arcgis"},arcgisDEV:{label:"ArcGIS Online DEVEXT",url:"https://devext.arcgis.com",type:"arcgis"},hub:{label:"ArcGIS Hub",url:"https://hub.arcgis.com/api",type:"arcgis-hub"},hubDEV:{label:"ArcGIS Hub DEV",url:"https://hubdev.arcgis.com/api",type:"arcgis-hub"},hubQA:{label:"ArcGIS Hub QA",url:"https://hubqa.arcgis.com/api",type:"arcgis-hub"}};function Ln(e){return"string"==typeof e&&e in Mn?Mn[e]:e}function Fn(e,t){var r=p(e);return t.from<e.from&&(r.from=t.from),t.to>e.to&&(r.to=t.to),r}function qn(r,n){var o={};return["any","all","not","exact"].forEach(function(e){var t=e,e=_(Gn(r,t),Gn(n,t));e.length&&(o[t]=e.filter(g))}),o}function Gn(e,t){var r=[];return e[t]&&(t=e[t],r=Array.isArray(t)?t:[t]),r}function Bn(e){var t={};return Array.isArray(e)?t={any:e}:("string"==typeof e&&(t={any:[e]}),"object"==typeof e&&(t=e)),t}function Hn(e){var t=new Date,r={type:"date-range",from:t.getTime(),to:t.getTime()};switch(e.unit){case"hours":case"days":case"weeks":r.from=r.to-{min:6e4,hours:36e5,days:864e5,weeks:6048e5}[e.unit]*e.num;break;case"months":t.setMonth(t.getMonth()-e.num),r.from=t.getTime();break;case"years":t.setFullYear(t.getFullYear()-e.num),r.from=t.getTime()}return r}function Wn(e,t,r){var n=p(e),e=t.q,t=t.filter;return e&&(n.q=(n.q?" ("+n.q+" "+r+" "+e+")":e).trim()),t&&(n.filter=(n.filter?"("+n.filter+" "+r+" "+t+")":t).trim()),n}function Yn(e,t){var r={q:"",filter:""};return t.exact&&(_(["username","firstname","lastname","fullname","email"],["title","tags","typekeywords","type","name","owner"],["title","typekeywords","owner"]).includes(e)?r.filter=zn("AND",e,t.exact):("string"==typeof t.exact&&(t.all||(t.all=[]),"string"==typeof t.all&&(t.all=[t.all]),t.all.push(t.exact)),Array.isArray(t.exact)&&(t.all||(t.all=[]),"string"==typeof t.all&&(t.all=[t.all]),t.all=t.all.concat(t.exact)))),t.any&&(r.q=zn("OR",e,t.any)),t.all&&(r.q=(r.q?r.q+" AND ":"")+zn("AND",e,t.all)),t.not&&(r.q=(r.q?r.q+" AND ":"")+zn("OR","-"+e,t.not)),r}function Kn(e,t){return{q:e+":["+t.from+" TO "+t.to+"]",filter:""}}function zn(e,t,r){return Array.isArray(r)?"("+t+':"'+r.join('" '+e+" "+t+':"')+'")':t+':"'+r+'"'}function Vn(e,t,r,n){var o=p(e);return e.authentication&&(o.authentication=ue.deserialize(e.authentication.serialize())),o.start=-1<t?t:r+1,function(e){return e&&(o.authentication=e),n(o)}}function Jn(e,t,r){var n=null;return t.thumbnail&&(n=e+"/community/groups/"+t.id+"/info/"+t.thumbnail,r&&"public"!==t.access&&(n=n+"?token="+r)),n}function $n(e,t,r){var n=null;return t.thumbnail&&(n=e+"/community/users/"+t.username+"/info/"+t.thumbnail,r&&"public"!==t.access&&(n=n+"?token="+r)),n}var Xn={$apps:[{type:{any:["Code Sample","Web Mapping Application","Mobile Application","Application","Desktop Application Template","Desktop Application","Operation View","Dashboard","Operations Dashboard Extension","Workforce Project","Insights Workbook","Insights Page","Insights Model","Hub Page","Hub Initiative","Hub Site Application","StoryMap","Web Experience","Web Experience Template","Form"],not:["Code Attachment","Featured Items","Symbol Set","Color Set","Windows Viewer Add In","Windows Viewer Configuration","Map Area","Indoors Map Configuration"]},typekeywords:{not:["MapAreaPackage","SMX"]}}],$storymap:[{type:"StoryMap"},{type:"Web Mapping Application",typekeywords:["Story Map"]}],$dashboard:[{type:"Dashboard",typekeywords:{any:["Dashboard"],not:["ArcGIS Operation View","Add In","Extension"]}}],$dataset:[],$experience:[{type:{any:["Web Experience"],not:["Web Experience Template"]}}],$site:[{type:["Hub Site Application","Site Application"]},{type:["Web Mapping Application"],typekeywords:["hubSite"]}],$initiative:[{type:{any:"Hub Initiative",not:"Hub Initiative Template"}}],$document:[{typekeywords:{any:"Document",not:["MapAreaPackage","SMX"]},type:{any:["Image","Layout","Desktop Style","Project Template","Report Template","Pro Report","Statistical Data Collection","360 VR Experience","netCDF","PDF","CSV","Administrative Report","Raster function template"],not:["Image Service","Explorer Document","Explorer Map","Globe Document","Scene Document","Code Attachment","Featured Items","Symbol Set","ColorSet","Windows Viewer Add In","Windows Viewer Configuration","Map Area","Indoors Map Configuration"]}}]};function Qn(e){var t,o=[];return null!==(t=e.aggregations)&&void 0!==t&&t.counts&&e.aggregations.counts.forEach(function(r){var e={label:r.fieldName,attribute:r.fieldName,type:"multi-select"},n=[];r.fieldValues.forEach(function(e){var t={filterType:"content"};t[r.fieldName]=e.value;t={label:e.value,value:e.value,count:e.count,selected:!1,filter:t};n.push(t)}),e.options=n,o.push(e)}),o}function Zn(e){var e=e.map(eo),n=["created","modified"],o=_(["filterType","subFilters","term"],n),e=e.reduce(function(r,e){return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];r.hasOwnProperty(t)?o.includes(t)?n.includes(t)?r[t]=Fn(r[t],e):"term"===t?r[t]=r[t]+" "+e:"subFilters"===t&&(r[t]=_(r[t],e)):r[t]=qn(r[t],e):r[t]=p(e)}),r},{});return e.filterType="content",e}function eo(e){var t=to(e);return Array.isArray(e.subFilters)&&(t.subFilters=t.subFilters.reduce(function(e,t){return"string"==typeof t?Xn[t]&&(e=e.concat(Xn[t])):e.push(t),e},[])),oo(t)}function to(e){var r=p(e);return r.subFilters=r.subFilters||[],r.type&&(Array.isArray(r.type)?r.type=r.type.reduce(function(e,t){return ro(t)?r.subFilters=r.subFilters.concat(no(t)):e.push(t),e},[]):ro(r.type)&&(e=r.type,r.subFilters=r.subFilters.concat(no(e)),delete r.type)),r}function ro(e){var t=!1;return t="string"==typeof e?e in Xn:t}function no(e){return Xn[e]}function oo(t){var r={};t.term&&(r.term=t.term);var e,n=["created","modified"],o=_(["filterType","subFilters","term"],n);return Object.entries(t).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r[t]=Bn(e))}),t.subFilters&&Array.isArray(t.subFilters)&&(e=t.subFilters,r.subFilters=e.map(oo)),n.forEach(function(e){t[e]&&("relative-date"===t[e].type?r[e]=Hn(t[e]):r[e]=p(t[e]))}),r}function io(e){var t,r=ao(e);return e.subFilters&&(t=e.subFilters.reduce(function(e,t){return e="object"==typeof t?Wn(e,ao(t),"OR"):e},{q:"",filter:""}),r=Wn(r,t,"AND")),e.term&&(r.q=(e.term+" "+r.q).trim()),r}function ao(e){var r={q:"",filter:""},n=["created","modified"],o=_(["filterType","subFilters","term"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=Wn(r,Yn(t,e),"AND")),n.includes(t)&&(r=Wn(r,Kn(t,e),"AND"))}),r}function so(r){var n={},o=["created","modified"],i=_(["term","searchUserAccess"],o);return Object.entries(r).forEach(function(e){var t=e[0],e=e[1];i.includes(t)||C(t,Bn(e),n),o.includes(t)&&(e=p(f(r,t)),"relative-date"===f(r,t+".type")?C(t,Hn(e),n):C(t,e,n))}),r.hasOwnProperty("searchUserAccess")&&(n.searchUserAccess=r.searchUserAccess),r.term&&(n.term=r.term),n}function uo(e){var r={q:"",filter:""},n=["created","modified"],o=_(["term","searchUserAccess","filterType"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=Wn(r,Yn(t,e),"AND")),n.includes(t)&&(r=Wn(r,Kn(t,e),"AND"))}),e.hasOwnProperty("searchUserAccess")&&(r.searchUserAccess=e.searchUserAccess),e.term&&(r.q=(e.term+" "+r.q).trim()),r}function co(r){var n={},o=["created","modified","lastlogin"],i=_(["disabled","term"],o);return Object.entries(r).forEach(function(e){var t=e[0],e=e[1];i.includes(t)||C(t,Bn(e),n),o.includes(t)&&(e=p(f(r,t)),"relative-date"===f(r,t+".type")?C(t,Hn(e),n):C(t,e,n))}),r.hasOwnProperty("disabled")&&(n.disabled=r.disabled),r.term&&(n.term=r.term),n}function lo(e){var r={q:"",filter:""},n=["created","modified","lastlogin"],o=_(["term","filterType"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=Wn(r,Yn(t,e),"AND")),n.includes(t)&&(r=Wn(r,Kn(t,e),"AND"))}),e.hasOwnProperty("disabled")&&(r.disabled=e.disabled),e.term&&(r.q=("("+e.term+") "+r.q).trim()),r}function po(o){var e,t,r=(null===(e=o.authentication)||void 0===e?void 0:e.portal)||o.portal;o.authentication&&(t=o.authentication.token);function i(e){return e.thumbnailUrl=Rn(e,r,t),e}return Oe(o).then(function(e){var t=-1<e.nextStart,r=e.results.map(Qt),r=(r=o.site?r.map(function(e){return ir(e,o.site)}):r).map(i),n=Qn(e);return{total:e.total,results:r,facets:n,hasNext:t,next:Vn(o,e.nextStart,e.total,po)}})}function fo(o){function i(e){return e.siteTeamUrl=o.site.item.url+"/teams/"+e.id+"/about",e}var e,t,r=(null===(e=o.authentication)||void 0===e?void 0:e.portal)||o.portal;o.authentication&&(t=o.authentication.token);function a(e){return e.thumbnailUrl=Jn(r,e,t),e}return Ie(o,"group").then(function(e){var t,r=-1<e.nextStart,n=e.results.map(a);return null!==(t=null===(t=o.site)||void 0===t?void 0:t.item)&&void 0!==t&&t.url&&(n=e.results.map(i)),{hasNext:r,total:e.total,results:n,next:Vn(o,e.nextStart,e.total,fo)}})}function ho(o){function i(e){return e.profileUrl=o.site.item.url+"/people/"+e.username+"/profile",e}function a(e){return e.thumbnail&&(e.thumbnailUrl=$n(t,e,r)),e}var t=o.authentication.portal,r=o.authentication.token;return Ie(o,"user").then(function(e){var t,r=-1<e.nextStart,n=e.results.map(a);return null!==(t=null===(t=o.site)||void 0===t?void 0:t.item)&&void 0!==t&&t.url&&(n=e.results.map(i)),{hasNext:r,total:e.total,results:n,next:Vn(o,e.nextStart,e.total,ho)}})}function mo(t){return O(this,void 0,void 0,function(){return E(this,function(e){return 200<=t.status&&t.status<300?[2,t.json()]:[2,t.json().then(function(e){if(e.error)throw new Error(e.error.title+" :: "+e.error.detail+" :: "+t.status);throw new Error("Got "+t.status+" "+t.statusText)})]})})}function go(e){var t={},e=f(e,"authentication.token");return e&&(t.Authorization=e),t}function vo(e){return(e||"https://hub.arcgis.com")+"/api/v3/domains"}function yo(e,t){var r=e,n="hubsubdomain|"+(r=-1<e.indexOf("#/")?e.split("#/")[1]:r);return Oe(Object.assign({q:"typekeywords: "+n},t)).then(function(e){return e.results.filter(function(e){return x(e.typeKeywords,n)})[0]}).then(function(e){if(!e)throw new Error("site not found");return{hostname:e.url,siteId:e.id}})}function bo(e,t){if(t.isPortal)throw new Error("domainExists is not available in ArcGIS Enterprise.");e=Ze(e);e=vo(t.hubApiUrl)+"/"+e,t=go(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(function(e){return 404!==e.status})}function wo(e,t){return yo(e,t).then(function(e){return!0}).catch(function(e){return!1})}function So(t,r,n,o){var i=t;return bo((i=(o=void 0===o?0:o)?t+"-"+o:t)+"-"+r,n).then(function(e){return e?So(t,r,n,o+1):i})}function Co(t,r,n){var o=(n=void 0===n?0:n)?t+"-"+n:t;return wo(o,r).then(function(e){return e?Co(t,r,n+1):o})}function ko(e,t){if(t.isPortal)return yo(e,t);e=vo(t.hubApiUrl)+"/"+e,t=go(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(mo)}function Ao(e,t){var r=p(e),e=63;return t&&(e-=t.length+1),r=r.length>e?r.slice(0,e-6)+"-"+R(5):r}function To(e,t){return Rr(e,t).then(Eo)}function xo(e){if(1.4<=f(e,"item.properties.schemaVersion"))return e;var t=p(e),e=f(t,"data.values.gacode");return t.data.values.telemetry={consentNotice:{isTheme:!0,consentText:"",policyURL:""},customAnalytics:{ga:{customerTracker:{enabled:Boolean(e),id:e}}}},jr(t,"data.values.gacode"),C("item.properties.schemaVersion",1.4,t),t}var Po=1.5;function Io(e){if(1.5<=f(e,"item.properties.schemaVersion"))return e;var r,t=p(e),e=t.data.values.dcatConfig;return t.data.feeds={},e&&(t.data.feeds.dcatUS11=(r=JSON.stringify(e),Object.keys(Oo).forEach(function(e){var t=Oo[e];r=r.split(e).join(t)}),JSON.parse(r))),t.item.properties.schemaVersion=1.5,t}var Oo={"{{default.name}}":"{{name}}","{{default.description}}":"{{description}}","{{item.tags}}":"{{tags}}","{{item.created:toISO}}":"{{created:toISO}}","{{item.modified:toISO}}":"{{modified:toISO}}","{{default.source.source}}":"{{source}}","{{item.owner}}":"{{owner}}","{{org.portalProperties.links.contactUs.url}}":"{{orgContactEmail}}","{{org.name}}":"{{orgName}}","{{item.categories}}":"{{categories}}","{{item.licenseInfo}}":"{{licenseInfo}}","{{item.modified}}":"{{modified}}","{{enrichments.categories}}":"{{categories}}","{{default.id}}":"{{id}}","{{item.licenseInfo || No License}}":"{{licenseInfo || No License}}","{{org.portalProperties.links.contactUs.url || mailto:data@tempe.gov}}":"{{orgContactEmail || mailto:data@tempe.gov}}","{{default.description || No Description}}":"{{description || No Description}}","{{item.id}}":"{{id}}"};function Eo(e){return f(e,"item.properties.schemaVersion")===Po?e:e=Io(e=xo(e=function(e){if(1.3<=f(e,"item.properties.schemaVersion"))return e;var t=p(e),e=f(t,"data.catalog.groups")||[];return t.data.catalog.groups=e.filter(M),t.item.properties.schemaVersion=1.3,t}(e=function(e){if(1.2<=f(e,"item.properties.schemaVersion"))return e;var t=p(e),e=f(t,"data.catalog")||{};return f(t,"data.values.groups")&&(e.groups=p(t.data.values.groups),delete t.data.values.groups),t.data.catalog=e,t.item.properties.schemaVersion=1.2,t}(e=function(e){if(1.1<=f(e,"item.properties.schemaVersion"))return e;var t=p(e);return["subdomain","defaultHostname","internalUrl","customHostname","externalUrl"].forEach(function(e){t.data.values[e]&&"string"==typeof t.data.values[e]&&(t.data.values[e]=t.data.values[e].toLowerCase())}),t.item.properties.schemaVersion=1.1,t}(e=function(e){if(1<=f(e,"item.properties.schemaVersion"))return e;var t=p(e);return["groupId","title"].forEach(function(e){delete t.data.values[e]}),t.item.properties||(t.item.properties={}),t.item.properties.schemaVersion=1,t.data.values.groups&&Array.isArray(t.data.values.groups)&&(e=t.data.values.groups.map(function(e){return"object"==typeof e?e.id:e}).filter(function(e){return!!e}),t.data.values.groups=e),t}(e))))))}function _o(e,t){return Ce(I({id:e,relationshipType:"Survey2Service",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function Do(e,t){return Ce(I({id:e,relationshipType:"Service2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function Uo(e,t){return Ce(I({id:e,relationshipType:"Survey2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function jo(t){function e(e){return-1<t.typeKeywords.indexOf(e)}var r=e("FieldworkerView");return r=r||["Survey123","Feature Service","View Service"].every(e)&&!e("StakeholderView")}No.create=function(r){return O(this,void 0,void 0,function(){var t;return E(this,function(e){switch(e.label){case 0:return r.contextManager?[2,new No(r.contextManager)]:[3,1];case 1:return t=r.managerOptions||{},[4,dt.create(t)];case 2:return[2,new No(e.sent())]}})})},Object.defineProperty(No.prototype,"context",{get:function(){return this._contextManager.context},enumerable:!1,configurable:!0}),Object.defineProperty(No.prototype,"projects",{get:function(){return this._projectManager||(this._projectManager=xn.init(this._contextManager)),this._projectManager},enumerable:!1,configurable:!0}),kt=No;function No(e){this._contextManager=e}Ro.prototype.startOperation=function(e){e=p(e);e.startedAt=(new Date).getTime(),e.state="working",this.operations.push(e)},Ro.prototype.start=function(e,t){t={type:e,id:b(t,"id",r(e+"_")),inputs:b(t,"inputs",{}),cleanup:b(t,"cleanup","n/a"),startedAt:(new Date).getTime(),state:"working"};return this.operations.push(t),t.id},Ro.prototype.getOperation=function(t){return this.operations.find(function(e){return e.id===t})},Ro.prototype.getOperations=function(){return this.operations},Ro.prototype.finish=function(e,t){var r=this.getOperation(e);if(!r)throw new Error("No operation with id "+e+" present in stack");r.duration=(new Date).getTime()-r.startedAt,r.state="completed",t&&(r.output=p(t))},Ro.prototype.merge=function(e){this.operations=_(this.operations,e.operations)},Ro.prototype.getCompleted=function(){return p(this.operations.filter(function(e){return"completed"===e.state}))},Ro.prototype.getWorking=function(){return p(this.operations.filter(function(e){return"working"===e.state}))},Ro.prototype.toString=function(){return this.operations.sort(function(e,t){return e.startedAt<t.startedAt?-1:t.startedAt<e.startedAt?1:0}).map(Mo).join("\n")},Ro.prototype.serialize=function(){return{operations:p(this.getOperations())}},At=Ro;function Ro(){this.operations=[]}function Mo(e){var t=e.startedAt+" : Operation "+e.id+" started with inputs "+JSON.stringify(e.inputs)+" but was not completed";return t="completed"===e.state?e.startedAt+" : Operation "+e.id+" took "+e.duration+" ms with inputs "+JSON.stringify(e.inputs)+" and output "+(e.output?JSON.stringify(e.output):"n/a"):t}var Lo,Fo=(e(qo,Lo=U),qo);function qo(e,t,r){var n=this;return t=t||"UNKNOWN_ERROR",r=b(r,"rootCause",r),(n=Lo.call(this,e,t,r)||this).name="HubError",n.stack=b(r,"stack",(new Error).stack),n}n.ArcGISContext=pt,n.ArcGISContextManager=dt,n.GLOBAL_EXTENT=Et,n.HUB_CDN_URLMAP=$e,n.HUB_LOCALES=Ur,n.HUB_PROJECT_ITEM_TYPE=Ct,n.Hub=kt,n.HubError=Fo,n.HubProjectManager=xn,n.Logger=F,n.OperationError=U,n.OperationStack=At,n.PORTAL_EXPORT_TYPES=hr,n.REQUIRED_PRIVS=fe,n.RemoteServerError=On,n.SEARCH_APIS=Mn,n.SITE_SCHEMA_VERSION=Po,n.STANDARD_LICENSES=Nt,n.WGS84_WKID=dr,n._addTokenToResourceUrl=Dn,n._canEmailUser=Sr,n._checkStatusAndParseJson=mo,n._consolidateResults=br,n._deepMapValues=i,n._ensureSafeDomainLength=Ao,n._ensureTelemetry=xo,n._formatAutoAddResponse=wr,n._getAuthHeader=go,n._getAutoAddUsers=Er,n._getDomainServiceUrl=vo,n._getEmailUsers=Dr,n._getHttpAndHttpsUris=function(e){return e?["http://"+(e=e.replace(/^http(s?):\/\//,"")),"https://"+e]:[]},n._getInviteUsers=_r,n._getLocation=function(){if(window)return window.location},n._isDate=s,n._isFunction=u,n._isObject=c,n._isOrgAdmin=Cr,n._isRegExp=l,n._isString=a,n._lookupPortal=yo,n._mapValues=o,n._processAutoAdd=xr,n._processInvite=Ir,n._processPrimaryEmail=Or,n._processSecondaryEmail=Ar,n._searchContent=function(n,o){var i;return O(this,void 0,void 0,function(){var t,r;return E(this,function(e){return r=eo(n),t=Ln(o.api||"arcgis"),[2,"arcgis"===t.type?(r=io(r),o.authentication?r.authentication=o.authentication:r.portal=t.url+"/sharing/rest",null!==(i=o.aggregations)&&void 0!==i&&i.length&&(r.countFields=o.aggregations.join(","),r.countSize=200),o.num&&(r.num=o.num),o.sortField&&(r.sortField=o.sortField),o.sortOrder&&(r.sortOrder=o.sortOrder),o.site&&(r.site=p(o.site)),po(r)):Promise.resolve({total:0,results:[],facets:[],hasNext:!1,next:function(){}})]})})},n._searchGroups=function(n,o){return O(this,void 0,void 0,function(){var t,r;return E(this,function(e){if(r=so(n),"arcgis"===(t=Ln(o.api||"arcgis")).type)return r=uo(r),o.authentication?r.authentication=o.authentication:r.portal=t.url+"/sharing/rest",o.num&&(r.num=o.num),o.sortField&&(r.sortField=o.sortField),o.sortOrder&&(r.sortOrder=o.sortOrder),o.site&&(r.site=p(o.site)),[2,fo(r)];throw new Error("_searchGroups is not implemented for non-arcgis apis")})})},n._searchUsers=function(r,n){return O(this,void 0,void 0,function(){var t;return E(this,function(e){if(!n.authentication)throw new Error("Authentication required to search for users.");if(t=co(r),"arcgis"===Ln(n.api||"arcgis").type)return(t=lo(t)).authentication=n.authentication,n.num&&(t.num=n.num),n.sortField&&(t.sortField=n.sortField),n.sortOrder&&(t.sortOrder=n.sortOrder),n.site&&(t.site=p(n.site)),[2,ho(t)];throw new Error("_searchUsers is not implemented for non-arcgis apis")})})},n._unprotectAndRemoveGroup=function(e){var t=N(Me,{success:!0}),r=N(Le,{success:!0});return t(e).then(function(){return r(e)})},n._unprotectAndRemoveItem=function(e){var t=N(ke,{success:!0}),r=N(Te,{success:!0});return t(e).then(function(){return r(e)})},n.addContextToSlug=function(e,t){return/.+::.+/.test(e)?e:t+"::"+e},n.addDays=function(e,t){try{var r=new Date(e);return new Date(r.setDate(r.getDate()+t)).toISOString().split("T")[0]}catch(e){throw new Error("Invalid Date")}},n.addDomain=function(e,t){if(t.isPortal)throw new Error("addDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=go(t);r["Content-Type"]="application/json";var n=""+vo(t.hubApiUrl);return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"POST",headers:r,mode:"cors",body:JSON.stringify(e)}).then(mo)},n.addSolutionResourceUrlToAssets=function(e,t){var r,n,o=e.assets||e.resources||[];return e.bundleItemId&&(r=Qe(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=o.map(function(e){return{name:e.name,type:e.type||"resource",url:r+"/resources/"+n+"-"+e.name}})),o},n.addUsersToGroup=function(e,t,r,n,o){var i=p(b(r,"portalSelf.user",{}));return i.cOrgId=f(r,"portalSelf.portalProperties.hub.settings.communityOrg.orgId"),xr({groupId:e,allUsers:t,primaryRO:r,email:n,secondaryRO:o,requestingUser:i,usersToAutoAdd:Er(t,i),usersToInvite:_r(t,i),usersToEmail:Dr(t,i,f(n,"copyMe"))}).then(Ir).then(Or).then(Ar).then(br)},n.applyPropertiesToItems=function(e,t){return e.map(function(e){return e.properties||(e.properties={}),Object.assign(e.properties,t),e})},n.arrayToObject=function(e,r){return e.reduce(function(e,t){return e[f(t,r)]=t,e},{})},n.atob=fr.atob,n.autoAddUsers=Tr,n.bBoxToPolygon=jt,n.batch=T,n.btoa=fr.btoa,n.buildDraft=function(e,t){return S(e,{},t)},n.buildExistingExportsPortalQuery=function(e,t){var r,n,o,i,a=(c=function(e){if(e)return{onlyTypes:e.onlyTypes,layerId:e.layerId,spatialRefId:e.spatialRefId};return{}}(t)).onlyTypes,s=c.layerId,u=c.spatialRefId,t=Object.keys(hr).map(function(e){return hr[e]}),c=new Set(v(t.filter(function(e){return!e.supportsProjection}).map(function(e){return e.itemTypes}))),t=a||v(t.map(function(e){return e.itemTypes})),s=(new xe).startGroup().match(vr(e)).in("typekeywords").and().match(yr(s)).in("typekeywords").endGroup().and().startGroup();function l(e,t){var r;t.startGroup().match(/\s/g.test(e)?e:'"'+e+'"').in("type").and().match(gr((r=e,t=dr,t=(e=i)&&!o.has(r)?e:t))).in("typekeywords").endGroup()}return r=s,n=(c={types:t,spatialRefId:u,noProjectionItemTypes:c}).types,o=c.noProjectionItemTypes,i=c.spatialRefId,n.forEach(function(e,t){l(e,r),t<n.length-1&&r.or()}),s.endGroup(),s.toParam()},n.buildUrl=de,n.camelize=m,n.canEditEvent=function(e,t){var r=!1;return le(t)&&(e=f(e,"initiative.item.properties.collaborationGroupId"),t=t.groups,r=!!e&&!!d(void 0===t?[]:t,"id",e)),r},n.canEditItem=pe,n.canEditSite=function(e,t){var r=!1;return r=!f(e,"properties.isDefaultHubHome")&&le(t)?pe(e,t):r},n.canEditSiteContent=function(e,t){var r,n=!1,o=f(e,"properties.isDefaultHubHome"),i=le(t);return!o&&i?n=pe(e,t):i&&(i=t.orgId,e=e.orgId,i&&i===e&&(r=t.privileges||[],n=fe.every(function(e){return x(r,e)}))),n},n.capitalize=t,n.categories=Pt,n.chunkArray=function(e,t){for(var r=[],n=0;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r},n.clearSession=function(e,t){(t=void 0===t?window:t).localStorage&&t.localStorage.removeItem("__CONTEXT_"+e)},n.cloneObject=p,n.completeOAuth2=function(t,e){var r=(e=(e=void 0===e?window:e).location.href.match(/access_token=(.+)&expires_in=.+&username=([^&]+)/))[1],n="https://www.arcgis.com/sharing/rest/community/users/"+decodeURIComponent(e[2]);return Q(n,{params:{token:r},httpMethod:"GET"}).then(function(e){return Date.now()-e.created<5e3?Q(n+"/update",{params:{token:r,tags:["hubRole:participant","org:"+e.orgId],access:"public"}}).then(function(){return ue.completeOAuth2(t)}):ue.completeOAuth2(t)})},n.compose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce(function(r,n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(n.apply(void 0,e))}})},n.constructSlug=sn,n.convertContentDefinitionToFilter=oo,n.convertContentFilterToSearchOptions=ao,n.convertPortalResponseToFacets=Qn,n.convertSolutionTemplateResourcesToAssets=function(e,t){var r,n,o=[];return e.resources&&e.bundleItemId&&(r=Qe(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=e.resources.map(function(e){return{name:e,type:"resource",url:r+"/resources/"+n+"-"+e}})),o},n.convertToWellKnownLocale=function(e){var t="en";return e=(e=void 0===e?"en":e).toLowerCase(),-1<Ur.indexOf(e)?t=e:1<(e=e.split("-")).length&&-1<Ur.indexOf(e[0])&&(t=e[0]),t},n.convertUrlsToAnchorTags=function(t){var e=t.match(/((((ftp|https?):\/\/)|(w{3}\.))[-\w@:%_+.~#?,&//=]+)/g);return e&&e.forEach(function(e){t=t.replace(e,'<a target="_blank" href="'+e+'">'+e+"</a>")}),t.replace("(","<br/>(")},n.createExtent=function(e,t,r,n,o){return{xmin:e,ymin:t,xmax:r,ymax:n,spatialReference:{wkid:o=void 0===o?4326:o}}},n.createId=r,n.createModel=Lr,n.createOperationPipeline=function(e){return function(r){return e.reduce(function(e,t){return e.then(t).catch(function(e){if("OperationError"===e.name)return Promise.reject(e);e="IPipeableFn did not reject with an OperationError \n Operation Stack: \n "+r.stack.toString(),e=new U("pipeline execution error",e);return e.operationStack=r.stack.serialize(),Promise.reject(e)})},Promise.resolve(r))}},n.createProject=wn,n.dasherize=function(e){return e.replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase().replace(/[ _]/g,"-")},n.datasetToContent=function(e){var t=Zt(e),r=Qt(t);delete r.itemCategories;var n=e.id,o=(S=e.attributes).errors,i=S.boundary,a=S.extent,s=S.metadata,u=S.modified,c=S.modifiedProvenance,l=S.slug,p=S.searchDescription,f=S.groupIds,d=S.server,h=S.layers,m=S.layer,g=S.recordCount,v=S.statistics,y=S.orgId,b=S.orgName,w=S.organization,e=S.orgExtent,S=S.type;return r.errors=o,r.boundary=i,!Dt(t.extent)&&a&&Dt(a.coordinates)&&(r.extent=a.coordinates),r.metadata=s||null,r.modified!==u&&(r.modified=u,r.updatedDate=new Date(u),r.updatedDateSource=c),r.slug=l,p&&(r.summary=p),r.groupIds=f,r.server=d,r.layers=h,r.layer=m,r.recordCount=g,r.statistics=v,y&&(r.org={id:y,name:b||w,extent:e}),rr(er(r,n),S)},n.datasetToItem=Zt,n.deepFind=k,n.deepFindById=function(e,t){return k(e,function(e){return e.id===t})},n.deepSet=y,n.deepStringReplace=w,n.deleteProp=jr,n.destroyProject=kn,n.doesItemExistWithTitle=an,n.domainExists=bo,n.domainExistsPortal=wo,n.emailOrgUsers=kr,n.ensureProp=function(e,t){return y(e,t)},n.ensureUniqueDomainName=function(e,t){return(t.isPortal?Co(e,t):So(e,t.portalSelf.urlKey+"."+Ze(st(t)),t)).then(function(e){return Ao(e,t.portalSelf.urlKey)})},n.ensureUniqueString=function(e,t){for(var r=!1,n=0,o=t;!r;)x(e,o)?o=t+"-"+ ++n:r=!0;return o},n.expandApi=Ln,n.expandApis=function(e){return e.map(Ln)},n.expandContentFilter=eo,n.expandGroupFilter=so,n.expandTypeField=to,n.expandUserFilter=co,n.extend=function n(e,o,i){void 0===i&&(i=!0);e=p(e);return Object.keys(o).reduce(function(e,t){var r;return null!==o[t]&&void 0!==o[t]&&(r=p(o[t]),Array.isArray(r)?e[t]=r:e[t]=i&&"object"==typeof r?n(e[t]||{},r,i):r),e},e)},n.extentToBBox=Ot,n.failSafe=N,n.failSafeUpdate=function(e,t){return N(ve,{id:e.item.id,success:!0})(Object.assign({item:Nr(e)},t))},n.fetchAllPages=function(n,o,r,i){var a=o.num||100,e=o.start||1;return(-1===(r=void 0===r?-1:r)?n(I(I({},o),{num:a,start:e})):Promise.resolve({nextStart:e,total:r,results:[],num:a})).then(function(t){if(-1===t.nextStart)return[t];for(var e=[],r=t.nextStart;r<=t.total;r+=a)e.push(r);return T(e,function(e){return n(I(I({},o),{start:e,num:a}))},i).then(function(e){return _([t],e)})}).then(function(e){var t=e.reduce(function(e,t){return _(e,t.results)},[]),e=-1===r?t.length:r;return t.slice(0,e)})},n.fetchAndUploadResource=jn,n.fetchAndUploadThumbnail=Nn,n.fetchHubTranslation=function(t,e,r){void 0===r&&(r="cors");var n=(Xe(e)+"/locales/"+t+".json").toLocaleLowerCase();return fetch(n,{method:"GET",credentials:"same-origin",mode:r}).then(function(e){return e.json()}).catch(function(e){throw Error("Attempt to fetch locale "+t+" from "+n+" failed: "+JSON.stringify(e))})},n.fetchImageAsBlob=Un,n.fetchModelFromItem=qr,n.fetchProject=Cn,n.fetchSite=function(e,t){return M(e)?To(e,t):ko(Ze(e).split("/")[0],t).then(function(e){return To(e.siteId,t)})},n.filterBy=function(e,t,r){return e.filter(function(e){return f(e,t)===r})},n.findBy=d,n.findItemsBySlug=ln,n.flattenArray=v,n.generateRandomString=R,n.getCategory=qt,n.getCollection=Bt,n.getContentIdentifier=Kt,n.getContentSiteUrls=tr,n.getContentTypeIcon=nr,n.getContentTypeLabel=or,n.getCulture=function(e){return f(e,"portalSelf.user.culture")||f(e,"portalSelf.culture")||"en-us"},n.getDomainsForSite=function(e,t){return t.isPortal?Promise.resolve([]):(e=vo(t.hubApiUrl)+"?siteId="+e,t=go(t),fetch(e,{method:"GET",headers:t,mode:"cors"}).then(mo).catch(function(e){throw Error("Error in getDomainsForSite "+e)}))},n.getExportItemTypeKeyword=vr,n.getExportLayerTypeKeyword=yr,n.getFamily=$t,n.getGeographicOrgExtent=_t,n.getGroupThumbnailUrl=Jn,n.getHubApiFromPortalUrl=nt,n.getHubApiUrl=st,n.getHubApiUrlFromPortal=function(e){return tt(e)+"/api/v3"},n.getHubLocaleAssetUrl=Xe,n.getHubProduct=function(e){var t=f(e,"portalProperties.hub.enabled")||!1?"premium":"basic";return t=e.isPortal&&"singletenant"===e.portalMode?"portal":t},n.getHubUrlFromPortal=tt,n.getInputFeatureServiceModel=_o,n.getItemApiUrl=rt,n.getItemAssets=function(e,t){var r=Qe(t.portalSelf)+"/content/items/"+e.id,n=Rn(e,t),o=[];return n&&o.push({name:e.thumbnail,url:n,type:"thumbnail"}),e=e.id,e=we(e,t=t)+"/resources",(t=I({},t)).params=I({num:1e3},t.params),Q(e,t).then(function(e){e=e.resources.map(function(e){return{name:e.resource,type:"resource",url:r+"/resources/"+e.resource}});return o.concat(e)})},n.getItemBySlug=cn,n.getItemDataUrl=function(e,t,r){t=rt(e,t,r),r="\\/"+e.id+"\\?f=json",r=new RegExp(r);return t&&t.replace(r,"/"+e.id+"/data").replace(/\&token/,"?token")},n.getItemHomeUrl=function(e,t){return Je(t)+"/home/item.html?id="+e},n.getItemHubId=function(e){if("public"===e.access){var t=e.id,e=Yt(e);return e?t+"_"+e:t}},n.getItemHubType=Xt,n.getItemLayerId=Yt,n.getItemThumbnailUrl=Rn,n.getLayerIdFromUrl=Wt,n.getModel=Rr,n.getModelBySlug=Mr,n.getModelFromOptions=function(e,t){var r=e+"Model",e=e+"Id";if(t[r])return Promise.resolve(t[r]);if(t[e])return N(Rr,{item:{id:t[e]},isMissing:!0})(t[e],t);throw new Error("getModelFromOptions requires either a ."+r+" or ."+e+" property.")},n.getNextFunction=Vn,n.getOrgExtentAsBBox=function(e){return _t(e).then(Ot)},n.getPortalApiUrl=Qe,n.getPortalBaseFromOrgUrl=ot,n.getPortalUrl=Je,n.getProp=f,n.getProps=function(r,e){return e.reduce(function(e,t){t=f(r,t);return t&&e.push(t),e},[])},n.getProxyUrl=function(e,t){var r,n;return n=e,r=!t.isPortal&&"public"===n.access&&"CSV"===n.type&&n.size<=5e6?t.hubApiUrl+"/datasets/"+e.id+"_0/FeatureServer/0":r},n.getServiceTypeFromUrl=at,n.getSession=function(e,t){var r=null;return!(t=void 0===t?window:t).localStorage||(e=t.localStorage.getItem("__CONTEXT_"+e))&&(r=ue.deserialize(e)),r},n.getSiteById=To,n.getSourceFeatureServiceModelFromFieldworker=Do,n.getSpatialRefTypeKeyword=gr,n.getStakeholderModel=Uo,n.getStructuredLicense=Rt,n.getSubscriptionType=function(e){return b(e,"subscriptionInfo.type","Enterprise")},n.getSurveyModels=function(e,r){var n,o;return("string"==typeof e?be(e,r):Promise.resolve(e)).then(function(t){var e=[_o(t.id,r),Uo(t.id,r)];return Promise.all(e).then(function(e){var t=e[0],e=e[1];return o=e,t&&jo(t.item)?Do((n=t).item.id,r):t}).then(function(e){return{form:{item:t},featureService:e,fieldworker:n,stakeholder:o}})})},n.getTypeCategories=function(e){if(e=qt(Gt(e=void 0===e?{}:e))){e=Array.from(e);return e[0]=e[0].toUpperCase(),[e.join("")]}return["Other"]},n.getTypes=function(e){return Pt[(e=void 0===e?"":e).toLowerCase()]},n.getUniqueDomainName=So,n.getUniqueDomainNamePortal=Co,n.getUniqueItemTitle=function t(r,n,o,i){var a=(i=void 0===i?0:i)?r+" "+i:r;return an(a,n,o).then(function(e){return e?t(r,n,o,++i):a}).catch(function(e){throw Error("Error in getUniqueItemTitle "+e)})},n.getUniqueSlug=pn,n.getUserThumbnailUrl=$n,n.getWithDefault=b,n.hasBasePriv=le,n.hubApiRequest=_n,n.hubApiSearch=function(e){var t=(t=e.authentication)&&t.serialize&&{authentication:t.serialize()};return _n("/search",I(I({},{headers:t,httpMethod:"POST"}),e))},n.includes=x,n.incrementString=function(e){var t=e.match(/-\s(\d+$)/);return t?(t=parseInt(t[1],10),e=e.replace("- "+t,"- "+(t+1))):e+=" - 1",e},n.interpolate=on,n.interpolateItemId=function(e){return on(e,{item:{id:e.item.id},appid:e.item.id},{toISO:function(e,t){return t}})},n.inviteUsers=Pr,n.isBBox=Dt,n.isDomainForLegacySite=function(e){return!M(e.siteId)},n.isDomainUsedElsewhere=function(e,t,r){return ko(e,r).then(function(e){return e.siteId!==t}).catch(function(){return!1})},n.isDownloadable=It,n.isExtentCoordinateArray=Ut,n.isFeatureService=Ht,n.isFieldworkerView=jo,n.isGuid=M,n.isMapOrFeatureServerUrl=function(e){return it.test(e)},n.isNil=function(e){return null==e},n.isSlug=function(e){return!(!(e=zt(e).itemId)||M(e))},n.isUpdateGroup=G,n.isValidDomain=function(t,e){if(e.isPortal)throw new Error("isValidDomain is not available in ArcGIS Enterprise.");var r=vo(e.hubApiUrl)+"/validate?hostname="+t,e=go(e);return fetch(r,{method:"GET",headers:e,mode:"cors"}).then(function(e){return e.json()}).catch(function(e){return{success:!1,input:t,error:{code:400,detail:e,message:"lookupFailed"}}})},n.isValidExtent=function(t){return!!t&&[Ut,function(t){return["xmin","ymin","xmax","ymax"].every(function(e){return"number"==typeof t[e]})}].some(function(e){return e(t)})},n.itemPropsNotInTemplates=fn,n.itemToContent=Qt,n.last=function(e){return e[e.length-1]},n.lookupDomain=ko,n.mapBy=function(t,e){return(e=void 0===e?[]:e).map(function(e){return e[t]})},n.maybeAdd=function(e,t,r){return null!=t&&((r=p(r))[e]=t),r},n.maybePush=h,n.mergeContentFilter=Zn,n.mergeDateRange=Fn,n.mergeGroupFilters=function(e){var e=e.map(so),o=["created","modified"],i=_(["filterType","term"],o);return e.reduce(function(n,e){return Object.entries(e).forEach(function(e){var t=e[0],r=e[1];n.hasOwnProperty(t)?(e=f(n,t),i.includes(t)?o.includes(t)?C(t,Fn(e,r),n):"term"===t&&(n[t]=n[t]+" "+r):C(t,qn(e,r),n)):C(t,p(r),n)}),n},{filterType:"group"})},n.mergeMatchOptions=qn,n.mergeObjects=S,n.mergeSearchOptions=Wn,n.mergeUserFilters=function(e){var e=e.map(co),o=["created","modified","lastlogin"],i=_(["disabled","term","filterType"],o);return e.reduce(function(n,e){return Object.entries(e).forEach(function(e){var t=e[0],r=e[1];n.hasOwnProperty(t)?(e=f(n,t),i.includes(t)?o.includes(t)?C(t,Fn(e,r),n):"term"===t&&(n[t]=n[t]+" "+r):C(t,qn(e,r),n)):C(t,p(r),n)}),n},{filterType:"user"})},n.normalizeItemType=Gt,n.normalizeSolutionTemplateItem=function(e){var t=p(e);return fn.forEach(function(e){delete t[e]}),t.extent="{{organization.defaultExtentBBox}}",t},n.objectToArray=function(r,n){return void 0===n&&(n="id"),Object.keys(r).reduce(function(e,t){return r[t][n]=t,e.push(p(r[t])),e},[])},n.objectToJsonBlob=function(e){if("undefined"!=typeof Blob)return new Blob([JSON.stringify(e)],{type:"application/json"});throw new Error("objectToJsonBlob is not currently supported on Node")},n.parseDatasetId=zt,n.parseItemCategories=Jt,n.processRevertableTasks=function(e){return Promise.all(e).then(function(e){function t(e){return"fullfilled"===e.status}var r=e.filter(t),n=e.filter(function(e){return!t(e)});if(n.length){e=r.map(function(e){return e.revert()});throw Promise.all(e).catch(function(){}),n[0].error}return r.map(function(e){return e.results})})},n.propifyString=function(e){return m(e.replace(/^[0-9]*/g,"").replace(/[^\w\s]/g,""))},n.relativeDateToDateRange=Hn,n.removeContextFromSlug=Vt,n.removeDomain=function(e,t){if(t.isPortal)throw new Error("removeDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=go(t);return r["Content-Type"]="application/json",e=vo(t.hubApiUrl)+"/"+e,fetch(e,{method:"DELETE",headers:r,mode:"cors"}).then(mo)},n.removeEmptyProps=function t(r){return Object.keys(r).forEach(function(e){r[e]&&"object"==typeof r[e]?t(r[e]):null==r[e]&&delete r[e]}),r},n.replaceItemId=function(e,t,r){return void 0===r&&(r="{{appid}}"),w(p(e),new RegExp(t,"g"),r)},n.runRevertableTask=function(e,t){return e().then(function(e){return{status:"fullfilled",results:e,revert:t}}).catch(function(e){return{status:"rejected",error:e}})},n.saveSession=function(e,t,r){(r=void 0===r?window:r).localStorage&&r.localStorage.setItem("__CONTEXT_"+e,t.serialize())},n.searchProjects=An,n.serializeContentFilterForPortal=io,n.serializeDateRange=Kn,n.serializeGroupFilterForPortal=uo,n.serializeMatchOptions=Yn,n.serializeModel=Nr,n.serializeSpatialReference=mr,n.serializeStringOrArray=zn,n.serializeUserFilterForPortal=lo,n.setContentHubId=er,n.setContentSiteUrls=ir,n.setContentType=rr,n.setItemThumbnail=dn,n.setProp=C,n.setSlugKeyword=un,n.shareItemToGroups=function(t,e,r,n){return Promise.all(e.map(function(e){e=Object.assign({},{id:t,groupId:e},r);return n&&(e.owner=n),We(e)}))},n.slugify=L,n.stringToBlob=function(e,t){if(void 0===t&&(t="application/octet-stream"),"undefined"==typeof Blob)throw new Error("stringToBlob is not currently supported on Node");for(var r=[],n=0;n<e.length;n++)r[n]=e.charCodeAt(n);var o=new Uint8Array(r);return new Blob([o],{type:t})},n.stripProtocol=Ze,n.unique=g,n.uniqueBy=function(e,r){return e.reduce(function(e,t){return h(e.find(function(e){return f(e,r)===f(t,r)})?null:t,e)},[])},n.unprotectModel=function(e,t){return e.item.protected?ke(Object.assign({id:e.item.id},t)):Promise.resolve({success:!0})},n.unshareItemFromGroups=function(t,e,r,n){return Promise.all(e.map(function(e){e=Object.assign({},{id:t,groupId:e},r);return n&&(e.owner=n),ze(e)}))},n.updateDomain=function(e,t){if(t.isPortal)throw new Error("updateDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=go(t);r["Content-Type"]="application/json";var n=vo(t.hubApiUrl)+"/"+e.id;return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"PUT",headers:r,mode:"cors",body:JSON.stringify(e)}).then(mo)},n.updateModel=Fr,n.updateProject=Sn,n.upgradeProtocol=function(e){return-1===e.indexOf("http")?"https://"+e:-1!==e.indexOf("http://")?e.replace(/^http:/i,"https:"):e},n.upgradeSiteSchema=Eo,n.uploadResourcesFromUrl=function(n,e,o){if(Array.isArray(e)){e=e.reduce(function(e,t){var r;return t.url&&(r={id:n.item.id,owner:n.item.owner,fileName:t.name,url:Dn(t.url,o),authentication:o.authentication},"thumbnail"===t.type?e.push(Nn(r)):e.push(jn(r))),e},[]);return Promise.all(e)}return Promise.resolve([])},n.valueToMatchOptions=Bn,n.without=function(e,t){return e.filter(function(e){return e!==t})},n.withoutByProp=function(t,r,e){return e.filter(function(e){return e[t]!==r})},Object.defineProperty(n,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisHub=e.arcgisHub||{})}(this,function(n){"use strict";function o(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}function i(e,r,n){return n=n||"",Array.isArray(e)?e.map(t):!e||!c(e)||s(e)||l(e)||u(e)?r(e,n):Object.assign({},e,o(e,t));function t(e,t){return i(e,r,""+(n?n+"."+t:t))}}function a(e){return"string"==typeof e||e instanceof String}function s(e){return e instanceof Date}function u(e){return"function"==typeof e}function c(e){return"object"==typeof e}function l(e){return e instanceof RegExp}function E(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e)}function p(e){var t,r={};if(Array.isArray(e))r=e.map(p);else if("object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(null!=(t=e[n])&&"object"==typeof t?t instanceof Date?r[n]=new Date(t.getTime()):r[n]=p(t):r[n]=t);else r=e;return r}function d(e,r,n){return e?e.reduce(function(e,t){return e=E(t,r)===n?t:e},null):null}function r(e){return""+(e=void 0===e?"i":e)+Math.random().toString(36).substr(2,8)}function f(e,t){return null!=e&&(t=p(t)).push(e),t}function h(e){return(e=(e=e.toLowerCase()).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi," ")).replace(/(\-|\_|\.|\s)+(.)?/g,function(e,t,r){return r?r.toUpperCase():""}).replace(/(^|\/)([A-Z])/g,function(e,t,r){return e.toLowerCase()})}function m(e,t,r){return r.indexOf(e)===t}function O(e){return null==e}function t(e){return(e=Array.from(e))[0]=e[0].toUpperCase(),e.join("")}function g(e){return e.reduce(function(e,t){return e.concat(t)},[])}function y(e,t,r){void 0===r&&(r={});var t=t.split("."),n=e,o=t.length-1;t.forEach(function(e,t){n.hasOwnProperty(e)&&null!=n[e]?t===o&&("object"!=typeof n[e]||Array.isArray(n[e])?n[e]=r:n[e]=Object.assign(n[e],p(r))):n[e]=t===o?r:{},n=n[e]})}function v(e,t,r){t=E(e,t);return void 0!==t?t:r}function b(e,r,n){return i(e,function(e){if(!a(e))return e;var t=l(r)?r:new RegExp(r,"g");return e.replace(t,n)})}function w(t,r,e){return Array.isArray(e)&&e.length?(e.forEach(function(e){void 0!==E(t,e)&&y(r,e,E(t,e))}),r):t}function S(e,t,r){y(r,e=Array.isArray(e)?e.join("."):e,t)}function k(r,n){return Array.isArray(r)?r.reduce(function(e,t){return n(t)?e=t:!C(t)||(t=k(t,n))&&(e=t),e},void 0):C(r)?n(r)?r:Object.keys(r).reduce(function(e,t){return!C(r[t])||(t=k(r[t],n))&&(e=t),e},void 0):void 0}function C(e){var t=!1;return t=e&&c(e)&&!s(e)&&!l(e)&&!u(e)?!0:t}function A(e,n,o){void 0===o&&(o=5);return e.reduce(function(e,t){var r=e[e.length-1];return r&&r.length!==o||e.push(r=[]),r.push(t),e},[]).reduce(function(e,r){return e.then(function(t){var e=r.map(function(e){return n(e)});return Promise.all(e).then(function(e){return t.concat(e)})})},Promise.resolve([]))}function T(e,t){return-1!==e.indexOf(t)}var P=function(e,t){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function e(e,t){function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var D=function(){return(D=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function x(e,a,s,u){return new(s=s||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}i((u=u.apply(e,a||[])).next())})}function I(r,n){var o,i,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&t[0]?i.return:t[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,t[1])).done)return a;switch(i=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,i=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=n.call(r,s)}catch(e){t=[6,e],i=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function _(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),o=0,t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}var U,j=(e(N,U=Error),N);function N(e,t,r){var n=this;return t=t||"UNKNOWN_ERROR",r=v(r,"rootCause",r),(n=U.call(this,t)||this).operation=e,n.name="OperationError",n.rootCause=r,Object.setPrototypeOf(n,N.prototype),n.stack=v(r,"stack",(new Error).stack),n}function R(r,n){return void 0===n&&(n={}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.apply(void 0,e).catch(function(e){return n})}}function M(e){var r=(new Date).getTime();return Array(e).fill(0).reduce(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),e=""+e+t.toString(16)},"")}function q(e){"{"===e[0]&&(e=e.substring(1,e.length-1));return/^(\{){0,1}[0-9a-fA-F]{8}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{12}(\}){0,1}$/gi.test(e)}function F(e){return"string"==typeof e?e.trim().toLowerCase().replace(/ +/g,"-").replace(/[^\w-]/g,"").replace(/-+/g,"-"):e}n.Level=void 0,(It=n.Level||(n.Level={}))[It.all=0]="all",It[It.debug=1]="debug",It[It.info=2]="info",It[It.warn=3]="warn",It[It.error=4]="error",It[It.off=5]="off";var L=(G.setLogLevel=function(e){this.logLevel=e},G.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.log.apply(console,_([e],t))},G.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.debug.apply(console,_([e],t))},G.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.info)&&console.info.apply(console,_([e],t))},G.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.warn)&&console.warn.apply(console,_([e],t))},G.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.error)&&console.error.apply(console,_([e],t))},G.isLevelPermitted=function(e){return this.logLevel<=e},G.logLevel=n.Level.off,G);function G(){}function B(e){return e.capabilities.includes("updateitemcontrol")}function H(t){return Object.keys(t).some(function(e){e=t[e];if(!e)return!1;switch((e=e&&e.toParam?e.toParam():e).constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function W(o){var i={};return Object.keys(o).forEach(function(e){var t=o[e];if((t=t&&t.toParam?t.toParam():t)||0===t||"boolean"==typeof t||"string"==typeof t){switch(t.constructor.name){case"Array":var r=null===(r=null===(r=t[0])||void 0===r?void 0:r.constructor)||void 0===r?void 0:r.name,n="Array"===r?t:"Object"===r?JSON.stringify(t):t.join(",");break;case"Object":n=JSON.stringify(t);break;case"Date":n=t.valueOf();break;case"Function":n=null;break;case"Boolean":n=t+"";break;default:n=t}(n||0===n||"string"==typeof n||Array.isArray(n))&&(i[e]=n)}}),i}function Y(e){var t=W(e);return Object.keys(t).map(function(e){return function t(r,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return t(r,e)}).join("&"):encodeURIComponent(r)+"="+encodeURIComponent(e)}(e,t[e])}).join("&")}var K=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function z(e){console&&console.warn&&console.warn.apply(console,[e])}K.prototype=Object.create(Error.prototype),K.prototype.constructor=K;var V,J="@esri/arcgis-rest-js",$={httpMethod:"POST",params:{f:"json"}},Q=(e(X,V=K),X.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var i=0,a=function(t,r){e(o.url,o.options).then(function(e){e=D(D({},o.options),{authentication:e});return i+=1,Z(o.url,e)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&i<n?a(t,r):"ArcGISAuthError"===e.name&&n<=i?r(o):r(e)})};return new Promise(function(e,t){a(e,t)})},X);function X(e,t,r,n,o){o=V.call(this,e=void 0===e?"AUTHENTICATION_ERROR":e,t=void 0===t?"AUTHENTICATION_ERROR_CODE":t,r,n,o)||this;return o.name="ArcGISAuthError",o.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,o}function Z(n,e){void 0===e&&(e={params:{f:"json"}});var o=D(D(D({httpMethod:"POST"},$),e),{params:D(D({},$.params),e.params),headers:D(D({},$.headers),e.headers)}),t=[],e=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),e.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),e.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),e.push("`isomorphic-form-data`")),!o.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+e.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var e=o.httpMethod,i=o.authentication,a=o.rawResponse,s=D({f:"json"},o.params),r=null,u={method:e,credentials:o.credentials||"same-origin"};return o.headers&&o.headers["X-Esri-Auth-Client-Id"]&&-1<n.indexOf("/oauth2/platformSelf")&&(u.credentials="include"),(i?i.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,r=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(s.token=e),i&&i.getDomainCredentials&&(u.credentials=i.getDomainCredentials(n));var t={};"GET"===u.method&&(s.token&&o.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+s.token,delete s.token),r=""===Y(s)?n:n+"?"+Y(s),o.maxUrlLength&&r.length>o.maxUrlLength||s.token&&o.hideToken?(u.method="POST",e.length&&o.hideToken&&(s.token=e,delete t["X-Esri-Authorization"])):n=r);var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===u.method&&(u.body=function(e,t){var t=H(e)||t,r=W(e);if(t){var n=new FormData;return Object.keys(r).forEach(function(e){var t;"undefined"!=typeof Blob&&r[e]instanceof Blob?(t=r.fileName||r[e].name||e,n.append(e,r[e],t)):n.append(e,r[e])}),n}return Y(e)}(s,r)),u.headers=D(D({},t),o.headers),"undefined"!=typeof window||u.headers.referer||(u.headers.referer=J),H(s)||r||(u.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,u)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new K(r,"HTTP "+t,e,n,o)}if(a)return e;switch(s.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==s.f&&"geojson"!==s.f||a)return e;var t=function(t,e,r,n){if(400<=t.code){var o=t.message,i=t.code;throw new K(o,i,t,e,r)}if(t.error){var a=t.error,o=a.message,i=a.code,s=a.messageCode,a=s||i||"UNKNOWN_ERROR_CODE";if(498===i||499===i||"GWM_0003"===s||400===i&&"Unable to generate token."===o)throw n||new Q(o,a,t,e,r);throw new K(o,a,t,e,r)}if("failed"!==t.status&&"failure"!==t.status)return t;o=void 0,i="UNKNOWN_ERROR_CODE";try{o=JSON.parse(t.statusMessage).message,i=JSON.parse(t.statusMessage).code}catch(e){o=t.statusMessage||t.message}throw new K(o,i,t,e,r)}(e,n,o,r);return r&&(e=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],o.authentication.federatedServers[e]={token:[],expires:new Date(Date.now()+864e5)},r=null),t})}function ee(r,e,t){var n=D(D({params:{}},t),r);return n.params=e.reduce(function(e,t){return!r[t]&&"boolean"!=typeof r[t]||(e[t]=r[t]),e},n.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return n[t]&&(e[t]=n[t]),e},{})}function te(e){return"string"==typeof e&&"/"===(e=e.trim())[e.length-1]?e.slice(0,-1):e}function re(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r,t=(r=t,r=(t=t.split("="))[0],t=t[1],{key:decodeURIComponent(r),value:decodeURIComponent(t)});return e[t.key]=t.value,e},{})}function ne(e,t){return t.rawResponse=!1,Z(e,t).then(function(e){var t={token:e.access_token,username:e.username,expires:new Date(Date.now()+(1e3*e.expires_in-1e3)),ssl:!0===e.ssl};return e.refresh_token&&(t.refreshToken=e.refresh_token),t})}function oe(e,t){return"undefined"!=typeof window&&window.location&&window.location.host?t.params.referer=window.location.host:t.params.referer=J,Z(e,t)}var ie=/^https?:\/\/(\S+)\.arcgis\.com.+/;function ae(e){return ie.test(e)}function se(e){if(!ie.test(e))return null;e=e.match(ie)[1].split(".").pop();return e.includes("dev")?"dev":e.includes("qa")?"qa":"production"}function ue(e,t){t=te(function(e){if(!ie.test(e))return e;switch(se(e)){case"dev":return"https://devext.arcgis.com/sharing/rest";case"qa":return"https://qaext.arcgis.com/sharing/rest";default:return"https://www.arcgis.com/sharing/rest"}}(t)).replace(/https?:\/\//,""),e=te(e).replace(/https?:\/\//,"");return new RegExp(e,"i").test(t)}var ce=(Object.defineProperty(le.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),Object.defineProperty(le.prototype,"tokenExpires",{get:function(){return this._tokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty(le.prototype,"refreshToken",{get:function(){return this._refreshToken},enumerable:!1,configurable:!0}),Object.defineProperty(le.prototype,"refreshTokenExpires",{get:function(){return this._refreshTokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty(le.prototype,"trustedServers",{get:function(){return console.log("DEPRECATED: use federatedServers instead"),this.federatedServers},enumerable:!1,configurable:!0}),le.beginOAuth2=function(e,t){void 0===t&&(t=window),e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=D({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",expiration:20160,popup:!0,popupWindowFeatures:"height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes",state:e.clientId,locale:""},e),n=r.portal,o=r.provider,i=r.clientId,a=r.expiration,s=r.redirectUri,u=r.popup,c=r.popupWindowFeatures,l=r.state,p=r.locale,r=r.params,p="arcgis"===o?n+"/oauth2/authorize?client_id="+i+"&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+l+"&locale="+p:n+"/oauth2/social/authorize?client_id="+i+"&socialLoginProviderName="+o+"&autoAccountCreateForSocial=true&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+l+"&locale="+p;if(r&&(p=p+"&"+Y(r)),u){var d,f=((d={promise:null,resolve:null,reject:null}).promise=new Promise(function(e,t){d.resolve=e,d.reject=t}),d);return t["__ESRI_REST_AUTH_HANDLER_"+i]=function(e,t){e?(e=JSON.parse(e),f.reject(new Q(e.errorMessage,e.error))):t&&(t=JSON.parse(t),f.resolve(new le({clientId:i,portal:n,ssl:t.ssl,token:t.token,tokenExpires:new Date(t.expires),username:t.username})))},t.open(p,"oauth-window",c),f.promise}t.location.href=p},le.completeOAuth2=function(e,o){void 0===o&&(o=window);var t=D({portal:"https://www.arcgis.com/sharing/rest",popup:!0},e),i=t.portal,a=t.clientId,s=t.popup;function r(e,t){try{var r=void 0,n="__ESRI_REST_AUTH_HANDLER_"+a;if(s&&(o.opener?o.opener.parent&&o.opener.parent[n]?r=o.opener.parent[n]:o.opener&&o.opener[n]&&(r=o.opener[n]):o!==o.parent&&o.parent&&o.parent[n]&&(r=o.parent[n]),r))return r(e?JSON.stringify(e):void 0,JSON.stringify(t)),void o.close()}catch(e){throw new Q('Unable to complete authentication. It\'s possible you specified popup based oAuth2 but no handler from "beginOAuth2()" present. This generally happens because the "popup" option differs between "beginOAuth2()" and "completeOAuth2()".')}if(e)throw new Q(e.errorMessage,e.error);return new le({clientId:a,portal:i,ssl:t.ssl,token:t.token,tokenExpires:t.expires,username:t.username})}e=re(o.location.hash);if(!e.access_token){var n=void 0,u="Unknown error";return e.error&&(n=e.error,u=e.error_description),r({error:n,errorMessage:u})}t=e.access_token,n=new Date(Date.now()+1e3*parseInt(e.expires_in,10)-6e4),u=e.username;return r(void 0,{token:t,expires:n,ssl:"true"===e.ssl,username:u})},le.fromParent=function(e,n){var o;return!n&&window&&(n=window),new Promise(function(t,r){o=function(e){if(e.source===n.parent&&e.data)try{return t(le.parentMessageHandler(e))}catch(e){return r(e)}},n.addEventListener("message",o,!1),n.parent.postMessage({type:"arcgis:auth:requestCredential"},e)}).then(function(e){return n.removeEventListener("message",o,!1),e})},le.authorize=function(e,t){e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=D({portal:"https://arcgis.com/sharing/rest",expiration:20160},e),n=r.portal,o=r.clientId,i=r.expiration,r=r.redirectUri;t.writeHead(301,{Location:n+"/oauth2/authorize?client_id="+o+"&expiration="+(e.duration||i)+"&response_type=code&redirect_uri="+encodeURIComponent(r)}),t.end()},le.exchangeAuthorizationCode=function(e,t){var e=D({portal:"https://www.arcgis.com/sharing/rest",refreshTokenTTL:20160},e),r=e.portal,n=e.clientId,o=e.redirectUri,i=e.refreshTokenTTL;return ne(r+"/oauth2/token",{params:{grant_type:"authorization_code",client_id:n,redirect_uri:o,code:t}}).then(function(e){return new le({clientId:n,portal:r,ssl:e.ssl,redirectUri:o,refreshToken:e.refreshToken,refreshTokenTTL:i,refreshTokenExpires:new Date(Date.now()+60*(i-1)*1e3),token:e.token,tokenExpires:e.expires,username:e.username})})},le.deserialize=function(e){e=JSON.parse(e);return new le({clientId:e.clientId,refreshToken:e.refreshToken,refreshTokenExpires:new Date(e.refreshTokenExpires),username:e.username,password:e.password,token:e.token,tokenExpires:new Date(e.tokenExpires),portal:e.portal,ssl:e.ssl,tokenDuration:e.tokenDuration,redirectUri:e.redirectUri,refreshTokenTTL:e.refreshTokenTTL})},le.fromCredential=function(e){var t=void 0===e.ssl||e.ssl,r=e.expires||Date.now()+72e5;return new le({portal:e.server.includes("sharing/rest")?e.server:e.server+"/sharing/rest",ssl:t,token:e.token,username:e.userId,tokenExpires:new Date(r)})},le.parentMessageHandler=function(e){if("arcgis:auth:credential"===e.data.type)return le.fromCredential(e.data.credential);if("arcgis:auth:error"!==e.data.type)throw new Error("Unknown message type.");var t=new Error(e.data.error.message);throw t.name=e.data.error.name,t},le.prototype.toCredential=function(){return{expires:this.tokenExpires.getTime(),server:this.portal,ssl:this.ssl,token:this.token,userId:this.username}},le.prototype.getUser=function(e){var t=this;if(this._pendingUserRequest)return this._pendingUserRequest;if(this._user)return Promise.resolve(this._user);var r=this.portal+"/community/self",e=D(D({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingUserRequest=Z(r,e).then(function(e){return t._user=e,t._pendingUserRequest=null,e}),this._pendingUserRequest},le.prototype.getPortal=function(e){var t=this;if(this._pendingPortalRequest)return this._pendingPortalRequest;if(this._portalInfo)return Promise.resolve(this._portalInfo);var r=this.portal+"/portals/self",e=D(D({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingPortalRequest=Z(r,e).then(function(e){return t._portalInfo=e,t._pendingPortalRequest=null,e}),this._pendingPortalRequest},le.prototype.getUsername=function(){return this.username?Promise.resolve(this.username):this._user?Promise.resolve(this._user.username):this.getUser().then(function(e){return e.username})},le.prototype.getToken=function(e,t){return r=this.portal,n=e,o=ae(r),i=ae(n),r=se(r),n=se(n),o&&i&&r===n||new RegExp(this.portal,"i").test(e)?this.getFreshToken(t):this.getTokenForServer(e,t);var r,n,o,i},le.prototype.validateAppAccess=function(r){return this.getToken(this.portal).then(function(e){return Z((t=void 0===t?"https://www.arcgis.com/sharing/rest":t)+"/oauth2/validateAppAccess",{method:"POST",params:{f:"json",client_id:r,token:e}});var t})},le.prototype.toJSON=function(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires,portal:this.portal,ssl:this.ssl,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,refreshTokenTTL:this.refreshTokenTTL}},le.prototype.serialize=function(){return JSON.stringify(this)},le.prototype.enablePostMessageAuth=function(e,t){!t&&window&&(t=window),this._hostHandler=this.createPostMessageHandler(e),t.addEventListener("message",this._hostHandler,!1)},le.prototype.disablePostMessageAuth=function(e){(e=!e&&window?window:e).removeEventListener("message",this._hostHandler,!1)},le.prototype.refreshSession=function(e){return this._user=null,this.username&&this.password?this.refreshWithUsernameAndPassword(e):this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new Q("Unable to refresh token."))},le.prototype.getServerRootUrl=function(e){var t=te(e).split(/\/rest(\/admin)?\/services(?:\/|#|\?|$)/)[0].match(/(https?:\/\/)(.+)/);t[0];var r=t[1],e=t[2].split("/"),t=e[0],e=e.slice(1);return""+r+t.toLowerCase()+"/"+e.join("/")},le.prototype.getDomainCredentials=function(t){return this.trustedDomains&&this.trustedDomains.length&&this.trustedDomains.some(function(e){return t.startsWith(e)})?"include":"same-origin"},le.prototype.createPostMessageHandler=function(o){var i=this;return function(e){var t=-1<o.indexOf(e.origin),r="arcgis:auth:requestCredential"===e.data.type,n=i.tokenExpires.getTime()>Date.now();t&&r&&(r={},r=n?((n=i.toCredential()).server=n.server.replace("/sharing/rest",""),{type:"arcgis:auth:credential",credential:n}):{type:"arcgis:auth:error",error:{name:"tokenExpiredError",message:"Session token was expired, and not returned to the child application"}},e.source.postMessage(r,e.origin))}},le.prototype.getTokenForServer=function(t,r){var n=this,o=this.getServerRootUrl(t),e=this.federatedServers[o];return e&&e.expires&&e.expires.getTime()>Date.now()?Promise.resolve(e.token):this._pendingTokenRequests[o]||(this._pendingTokenRequests[o]=this.fetchAuthorizedDomains().then(function(){return Z(o+"/rest/info",{credentials:n.getDomainCredentials(t)}).then(function(e){if(e.owningSystemUrl){if(ue(e.owningSystemUrl,n.portal))return Z(e.owningSystemUrl+"/sharing/rest/info",r);throw new Q(t+" is not federated with "+n.portal+".","NOT_FEDERATED")}if(e.authInfo&&void 0!==n.federatedServers[o])return Promise.resolve({authInfo:e.authInfo});throw new Q(t+" is not federated with any portal and is not explicitly trusted.","NOT_FEDERATED")}).then(function(e){return e.authInfo.tokenServicesUrl}).then(function(e){return n.token&&n.tokenExpires.getTime()>Date.now()?oe(e,{params:{token:n.token,serverUrl:t,expiration:n.tokenDuration,client:"referer"}}):oe(e,{params:{username:n.username,password:n.password,expiration:n.tokenDuration,client:"referer"}}).then(function(e){return n._token=e.token,n._tokenExpires=new Date(e.expires),e})}).then(function(e){return n.federatedServers[o]={expires:new Date(e.expires),token:e.token},delete n._pendingTokenRequests[o],e.token})}),this._pendingTokenRequests[o])},le.prototype.getFreshToken=function(e){var t=this;return this.token&&!this.tokenExpires||this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshSession(e).then(function(e){return t._pendingTokenRequests[t.portal]=null,e.token})),this._pendingTokenRequests[this.portal])},le.prototype.refreshWithUsernameAndPassword=function(e){var t=this,e=D({params:{username:this.username,password:this.password,expiration:this.tokenDuration}},e);return oe(this.portal+"/generateToken",e).then(function(e){return t._token=e.token,t._tokenExpires=new Date(e.expires),t})},le.prototype.refreshWithRefreshToken=function(e){var t=this;if(this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()<Date.now())return this.refreshRefreshToken(e);e=D({params:{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}},e);return ne(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t})},le.prototype.refreshRefreshToken=function(e){var t=this,e=D({params:{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}},e);return ne(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t._refreshToken=e.refreshToken,t._refreshTokenExpires=new Date(Date.now()+60*(t.refreshTokenTTL-1)*1e3),t})},le.prototype.fetchAuthorizedDomains=function(){var t=this;return this.server||!this.portal?Promise.resolve(this):this.getPortal().then(function(e){return e.authorizedCrossOriginDomains&&e.authorizedCrossOriginDomains.length&&(t.trustedDomains=e.authorizedCrossOriginDomains.filter(function(e){return!e.startsWith("http://")}).map(function(e){return e.startsWith("https://")?e:"https://"+e})),t})},le);function le(e){var t;this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.username=e.username,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal?te(e.portal):"https://www.arcgis.com/sharing/rest",this.ssl=e.ssl,this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.refreshTokenTTL=e.refreshTokenTTL||20160,this.server=e.server,this.federatedServers={},this.trustedDomains=[],e.server&&(t=this.getServerRootUrl(e.server),this.federatedServers[t]={token:e.token,expires:e.tokenExpires}),this._pendingTokenRequests={}}function pe(e){e=e.privileges;return T(void 0===e?[]:e,"portal:user:createItem")}function de(e,t){var r,n=!1,o=e.itemControl,i=e.owner,a=e.orgId,s=t.roleId,u=t.role,c=t.username,l=t.groups,p=t.orgId,u=T(["admin","update"],o)||!!i&&i===c||!!(!!a&&a===p)&&!s&&"org_admin"===u,t=pe(t);return t&&u?n=!0:t&&(r=_(E(e,"groupIds")||[],[E(e,"properties.collaborationGroupId")]),n=l.some(function(e){return B(e)&&T(r,e.id)})),n}var fe=["portal:user:createGroup","portal:user:createItem","portal:user:shareToGroup","portal:user:viewOrgGroups","portal:user:viewOrgItems"];function he(e){var t=e.host,r=e.path,e=e.query,t=t.endsWith("/")?t:t+"/",t=new URL(r,t);return t.search=function(r){void 0===r&&(r={});var e=Object.keys(r).filter(function(e){return void 0!==r[e]}).reduce(function(e,t){return e[t]=r[t],e},{});return new URLSearchParams(e).toString()}(e),t.toString()}function me(e){return(e=void 0===e?{}:e).portal?te(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function ge(e){var t=JSON.parse(JSON.stringify(e));return t.data&&("undefined"!=typeof Blob&&e.data instanceof Blob||"ReadStream"===e.data.constructor.name?t.file=e.data:t.text=e.data,delete t.data),t}function ye(e){return e.owner?Promise.resolve(e.owner):e.item&&e.item.owner?Promise.resolve(e.item.owner):e.authentication&&e.authentication.getUsername?e.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function ve(t){return ye(t).then(function(e){e=t.folderId?me(t)+"/content/users/"+e+"/"+t.folderId+"/items/"+t.item.id+"/update":me(t)+"/content/users/"+e+"/items/"+t.item.id+"/update";return t.params=D(D({},t.params),ge(t.item)),Z(e,t)})}function be(e){var r,e=D({folderId:null},e);return(r=e).multipart&&!r.filename?Promise.reject(new Error("The filename is required for a multipart request.")):ye(r).then(function(e){var t=me(r)+"/content/users/"+e,e=t+"/addItem";return r.folderId&&(e=t+"/"+r.folderId+"/addItem"),r.params=D(D({},r.params),ge(r.item)),Z(e,ee(r,["owner","folderId","file","dataUrl","text","async","multipart","filename","overwrite"],{params:D({},r.params)}))})}function we(e,t){return Z(Se(e,t),D({httpMethod:"GET"},t))}var Se=function(e,t){return("string"==typeof t?t:me(t))+"/content/items/"+e};function ke(e,t){e=Se(e,t)+"/data",t=D({httpMethod:"GET",params:{}},t);return t.file&&(t.params.f=null),Z(e,t).catch(function(e){var t=RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i);if(!t.test(e.message))throw e})}function Ce(e){var t=Se(e.id,e)+"/relatedItems",r=D({httpMethod:"GET",params:{direction:e.direction}},e);return"string"==typeof e.relationshipType?r.params.relationshipType=e.relationshipType:r.params.relationshipTypes=e.relationshipType,delete r.direction,delete r.relationshipType,Z(t,r)}function Ae(t){return ye(t).then(function(e){return Z(me(t)+"/content/users/"+e+"/items/"+t.id+"/unprotect",t)})}function Te(e){return t=e.groupId,Z(me(e=e)+"/community/groups/"+t,D({httpMethod:"GET"},e)).then(function(e){return e.userMembership.memberType}).catch(function(){return"none"});var t}function Pe(t){return ye(t).then(function(e){return Z(me(t)+"/content/users/"+e+"/items/"+t.id+"/delete",t)})}var xe=(Ie.prototype.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.termStack=this.termStack.concat(e),this},Ie.prototype.in=function(e){return this.hasRange||this.hasTerms?(e&&"*"!==e&&(this.q+=e+":"),this.commit()):(z("`in("+(e?'"'+e+'"':"")+")`"+" was called with no call to `match(...)` or `from(...)`/`to(...)`. Your query was not modified."),this)},Ie.prototype.startGroup=function(){return this.commit(),0<this.openGroups&&(this.q+=" "),this.openGroups++,this.q+="(",this},Ie.prototype.endGroup=function(){return this.openGroups<=0?z("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."):(this.commit(),this.openGroups--,this.q+=")"),this},Ie.prototype.and=function(){return this.addModifier("and")},Ie.prototype.or=function(){return this.addModifier("or")},Ie.prototype.not=function(){return this.addModifier("not")},Ie.prototype.from=function(e){return this.hasTerms?z('`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[0]=e,this},Ie.prototype.to=function(e){return this.hasTerms?z('`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[1]=e,this},Ie.prototype.boost=function(e){return this.commit(),this.q+="^"+e,this},Ie.prototype.toParam=function(){return this.commit(),this.cleanup(),this.q},Ie.prototype.clone=function(){return this.commit(),this.cleanup(),new Ie(this.q+"")},Ie.prototype.addModifier=function(e){return this.currentModifer?(z("You have called `"+this.currentModifer+"()` after `"+e+"()`. Your current query was not modified."),this):(this.commit(),""===this.q&&"not"!==e?z("You have called `"+e+"()` without calling another method to modify your query first. Try calling `match()` first."):(this.currentModifer=e,this.q+=""===this.q?"":" ",this.q+=e.toUpperCase()+" "),this)},Ie.prototype.needsQuotes=function(e){return/\s|:/g.test(e)},Ie.prototype.formatTerm=function(e){return e instanceof Date?e.getTime():"string"==typeof e&&this.needsQuotes(e)?'"'+e+'"':e},Ie.prototype.commit=function(){var t=this;return this.currentModifer=void 0,this.hasRange&&(this.q+="["+this.formatTerm(this.rangeStack[0])+" TO "+this.formatTerm(this.rangeStack[1])+"]",this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(function(e){return t.formatTerm(e)}).join(" "),this.termStack=[]),this},Object.defineProperty(Ie.prototype,"hasTerms",{get:function(){return 0<this.termStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(Ie.prototype,"hasRange",{get:function(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]},enumerable:!1,configurable:!0}),Ie.prototype.cleanup=function(){if(0<this.openGroups)for(z("Automatically closing "+this.openGroups+" group(s). You can use `endGroup(...)` to remove this warning.");0<this.openGroups;)this.q+=")",this.openGroups--;var e=this.q;this.q=e.replace(/( AND ?| NOT ?| OR ?)*$/,""),e!==this.q&&z("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")},Ie);function Ie(e){void 0===e&&(e=""),this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=e}function Ee(r,n){var e,t="string"==typeof r||r instanceof xe?{httpMethod:"GET",params:{q:r}}:ee(r,["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],{httpMethod:"GET"});switch(n){case"item":e="/search";break;case"group":e="/community/groups";break;case"groupContent":if("string"==typeof r||r instanceof xe||!r.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));e="/content/groups/"+r.groupId+"/search";break;default:e="/portals/self/users/search"}return Z(me(t)+e,t).then(function(t){return t.nextStart&&-1!==t.nextStart&&(t.nextPage=function(){var e;return"string"==typeof r||r instanceof xe?e={q:r,start:t.nextStart}:(e=r).start=t.nextStart,Ee(e,n)}),t})}function Oe(e){return Ee(e,"item")}function De(e,t){if(0===e.length)return[];for(var r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function _e(e){var t=e.id,r=me(e)+"/community/groups/"+t+"/addUsers",t=Object.assign({},e,{admins:void 0,users:void 0}),t=_(Ue("users",e.users,t),Ue("admins",e.admins,t)).map(function(e){return Z(r,e).catch(function(e){return{errors:[e]}})});return Promise.all(t).then(je)}function Ue(o,e,i){return!e||e.length<1?[]:De(e,25).map(function(e){return t=o,r=e,n=i,Object.assign({},n,((e={})[t]=r,e.params=D(D({},n.params),((n={})[t]=r,n)),e));var t,r,n})}function je(e){var t=e.filter(function(e){return e.notAdded}).reduce(function(e,t){return e.concat(t.notAdded)},[]),e=e.filter(function(e){return e.errors}).reduce(function(e,t){return e.concat(t.errors)},[]),t={notAdded:t};return 0<e.length&&(t.errors=e),t}function Ne(t){var e=t.id,r=t.users,n=me(t)+"/community/groups/"+e+"/removeUsers",r=De(r,25).map(function(e){e=D(D({},t),{users:e,params:{users:e}});return Z(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(r).then(function(e){var t=function(r){return e.filter(function(e){return e[r]}).reduce(function(e,t){return e.concat(t[r])},[])},r=t("errors"),t={notRemoved:t("notRemoved")};return r.length?D(D({},t),{errors:r}):t})}function Re(e){var t,r=e.id,n=me(e)+"/community/groups/"+r+"/invite",e=De((t=e).users,25).map(function(e){return function(e,t){t=Object.assign({},t);return t.params=D(D({},t.params),{users:e,role:t.role,expiration:t.expiration}),t}(e,t)}).map(function(e){return Z(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Me)}function Me(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function qe(e){return Z(me(e)+"/community/groups/"+e.id+"/unprotect",e)}function Fe(e){return Z(me(e)+"/community/groups/"+e.id+"/delete",D({},e))}function Le(e){var t=me(e)+"/community/groups/"+e.id+"/updateUsers",r={authentication:e.authentication,params:{}};return"admin"===e.newMemberType?r.params.admins=e.users:r.params.users=e.users,Z(t,r)}function Ge(e){var n,t=me(e)+"/portals/self/createNotification",e=De((n=e).users,n.batchSize||25).map(function(e){return t=e,r=n,(e=Object.assign({},r)).params=D(D({},e.params),{users:t,subject:r.subject,message:r.message,notificationChannelType:e.notificationChannelType}),e;var t,r}).map(function(e){return Z(t,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Be)}function Be(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function He(e){var t,r,n={httpMethod:"GET"};return"string"==typeof e?r="https://www.arcgis.com/sharing/rest/community/users/"+e:(t=e.username||e.authentication.username,r=me(e)+"/community/users/"+encodeURIComponent(t),n=D(D({},e),n)),Z(r,n)}function We(t){return Oe({q:"id: "+t.id+" AND group: "+t.groupId,start:1,num:10,sortField:"title",authentication:t.authentication,httpMethod:"POST"}).then(function(e){if(0<e.total)return e.results.some(function(e){return e.id===t.id})})}function Ye(a){return We(a).then(function(e){if(e)return{itemId:a.id,shortcut:!0,notSharedWith:[]};var t=a.authentication.username,e=a.owner,n=a.confirmItemControl,e=e||t;if(e===t)return Ke(a);var o=!1,i=!1;return Promise.all([He({username:t,authentication:a.authentication}),He({username:e,authentication:a.authentication}),Te(a)]).then(function(e){var t=e[0],r=e[1],e=e[2];return o="org_admin"===t.role&&!t.roleId,i=t.orgId!==r.orgId,function(e,t,r,n,o,i){var a=[];if(i.groupId!==e.favGroupId)if(t){if(!n)throw Error("This item can not be shared to shared editing group "+i.groupId+" by "+e.username+" as they not the item owner or org admin.");a.push(ze(e,e,!1,"Error adding "+e.username+" as member to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i),ze(e,o,!0,"none"===r?"Error adding user "+o.username+" to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.":"Error promoting user "+o.username+" to admin in edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i))}else if(n)a.push(ze(e,e,!1,"Error adding "+e.username+" as member to view group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i));else if("none"===r)throw new Error("This item can not be shared by "+e.username+" as they are not a member of the specified group "+i.groupId+".");return a}(t,!!n,e,o,r,a)}).then(function(e){var t=e[0],r=(void 0===t?{promise:Promise.resolve({notAdded:[]}),revert:function(e){return Promise.resolve(e)}}:t).revert;return Promise.all(e.map(function(e){return e.promise})).then(function(){return Ke(a,o,i)}).then(function(e){return r(e)})})}).then(function(e){if(e.notSharedWith.length)throw Error("Item "+a.id+" could not be shared to group "+a.groupId+".");return e})}function Ke(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=e.authentication.username,o=e.owner||n,i=me(e)+"/content/items/"+e.id+"/share";return(o===n||t&&!r)&&(i=me(e)+"/content/users/"+o+"/items/"+e.id+"/share"),e.params={groups:e.groupId,confirmItemControl:e.confirmItemControl},Z(i,e)}function ze(e,t,r,n,o){var i,a,s=t.groups||[],u=s.find(function(e){return e.id===o.groupId});if(e.orgId!==t.orgId)throw Error("User "+t.username+" is not a member of the same org as "+e.username+". Consequently they can not be added added to group "+o.groupId+" nor can item "+o.id+" be shared to the group.");if(!u&&511<s.length)throw Error("User "+t.username+" already has 512 groups, and can not be added to group "+o.groupId+". Consequently item "+o.id+" can not be shared to the group.");return a=u?r&&"member"===u.userMembership.memberType?(i=Le({id:o.groupId,users:[t.username],newMemberType:"admin",authentication:o.authentication}).then(function(e){e=e.results.reduce(function(e,t){return t.success||e.push(t.username),e},[]);return Promise.resolve({notAdded:e})}).catch(function(){return{notAdded:[t.username]}}),function(e){return Le({id:o.groupId,users:[t.username],newMemberType:"member",authentication:o.authentication}).then(function(){return e}).catch(function(){return e})}):(i=Promise.resolve({notAdded:[]}),function(e){return Promise.resolve(e)}):(i=_e(((a={id:o.groupId})[r?"admins":"users"]=[t.username],a.authentication=o.authentication,a)).then(function(e){if(e.errors&&e.errors.length)throw e.errors[0];return e}).catch(function(){return{notAdded:[t.username]}}),function(e){return Ne({id:o.groupId,users:[t.username],authentication:o.authentication}).then(function(){return e})}),{promise:i.then(function(e){if(e.notAdded.length)throw new Error(n);return e}),revert:a}}function Ve(o){return We(o).then(function(e){if(!e)return Promise.resolve({itemId:o.id,shortcut:!0,notUnsharedFrom:[]});var r=o.authentication.username,n=o.owner;return Promise.all([Te(o),He({username:r,authentication:o.authentication})]).then(function(e){var t=e[0],e=e[1],e="org_admin"===e.role&&!e.roleId;if(!((n||r)===r)&&!e&&["admin","owner"].indexOf(t)<0)throw Error("This item can not be unshared from group "+o.groupId+" by "+r+" as they not the item owner, an org admin, group admin or group owner.");return function(e){var t=e.authentication.username,r=e.owner||t,n=me(e)+"/content/items/"+e.id+"/unshare";r===t&&(n=me(e)+"/content/users/"+r+"/items/"+e.id+"/unshare");return e.params={groups:e.groupId},Z(n,e)}(o)}).then(function(e){if(e.notUnsharedFrom.length)throw Error("Item "+o.id+" could not be unshared to group "+o.groupId);return e})})}function Je(e){return function(e,t){e=e||"self",e=me(t)+"/portals/"+e,t=D({httpMethod:"GET"},t);return Z(e,t)}(null,e)}function $e(e){if("string"==typeof e)return e.replace(/\/sharing\/rest\/?$/,"");if("object"==typeof e){var t=e.portalSelf||e,r=t.portalHostname,n=t.urlKey,o=t.customBaseUrl;if(r||n&&o)return t.isPortal?"https://"+t.portalHostname:"https://"+t.urlKey+"."+t.customBaseUrl}return $e(me(e))}var Qe={devext:"https://d1011m9qpnz5mw.cloudfront.net",qaext:"https://dyq9ux9ryu4qj.cloudfront.net",www:"https://d1iq7pbacwn5rb.cloudfront.net"};function Xe(e){if(e.isPortal)return $e(e)+"/apps/sites";e=e.portalHostname.split(".")[0];return(Qe[e]||Qe.www)+"/opendata-ui/assets"}function Ze(e){return $e(e)+"/sharing/rest"}function et(e){return e=(e=e.toLowerCase()).includes("//")?e.split("//")[1]:e}function tt(e){var t;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://hubqa.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://hubdev.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://hub.arcgis.com"),t}function rt(e){if(e.isPortal)throw new Error("Hub Url is not available in ArcGIS Enterprise");return tt(e.portalHostname)}function nt(e,t){return $e(t)+"/home/item.html?id="+e}function ot(e,t,r){return t=it(e,t,r),r="\\/"+e.id+"\\?f=json",r=new RegExp(r),t&&t.replace(r,"/"+e.id+"/data").replace(/\&token/,"?token")}var it=function(e,t,r){var n=e.id,e=e.access,t=Ze(t)+"/content/items/"+n,n=new URLSearchParams({f:"json"});return"public"!==e&&r&&n.append("token",r),t+"?"+n.toString()};function at(e){var t;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://hubqa.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://hubdev.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://hub.arcgis.com"),t}function st(e){var t=e;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://qaext.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://devext.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://www.arcgis.com"),t}var ut=/\/(map|feature)server/i,ct=function(e){e=e.match(ut),e=e&&e[1];return e&&t(e)+" Service"};function lt(e){var t=e&&e.hubApiUrl;return t||tt(Ze(e))}var pt="/api/v3/domains",dt="/api/v3/datasets",ft="/api/discussions/v1",ht=(Object.defineProperty(mt.prototype,"session",{get:function(){return this._authentication},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"isAuthenticated",{get:function(){return!!this._authentication},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"userRequestOptions",{get:function(){if(this.isAuthenticated)return{authentication:this._authentication,portal:this.sharingApiUrl}},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"requestOptions",{get:function(){var e={portal:this.sharingApiUrl};return e=this.isAuthenticated?{authentication:this._authentication,portal:this.sharingApiUrl}:e},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"hubRequestOptions",{get:function(){if(this.isAuthenticated)return{authentication:this.session,isPortal:this.isPortal,portalSelf:this.portal,hubApiUrl:this.hubUrl}},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"portalUrl",{get:function(){return this.isAuthenticated?this.isPortal?"https://"+this._portalSelf.portalHostname:"https://"+this._portalSelf.urlKey+"."+this._portalSelf.customBaseUrl:this._portalUrl},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"sharingApiUrl",{get:function(){return this.portalUrl+"/sharing/rest"},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"hubUrl",{get:function(){return this._hubUrl},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"isPortal",{get:function(){return this._portalSelf?this._portalSelf.isPortal:-1===this._portalUrl.indexOf("arcgis.com")},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"discussionsServiceUrl",{get:function(){if(this._hubUrl)return""+this._hubUrl+ft},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"hubSearchServiceUrl",{get:function(){if(this._hubUrl)return""+this._hubUrl+dt},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"domainServiceUrl",{get:function(){if(this._hubUrl)return""+this._hubUrl+pt},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"eventsConfig",{get:function(){if(this._portalSelf)return E(this._portalSelf,"portalProperties.hub.settings.events")},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"hubEnabled",{get:function(){return v(this._portalSelf,"portalProperties.hub.enabled",!1)},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"communityOrgId",{get:function(){if(this._portalSelf)return E(this._portalSelf,"portalProperties.hub.settings.communityOrg.orgId")},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"communityOrgHostname",{get:function(){if(this._portalSelf)return E(this._portalSelf,"portalProperties.hub.settings.communityOrg.portalHostname")},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"communityOrgUrl",{get:function(){if(this.communityOrgHostname)return"https://"+this.communityOrgHostname},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"helperServices",{get:function(){if(this._portalSelf)return this._portalSelf.helperServices},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"currentUser",{get:function(){return this._currentUser},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"portal",{get:function(){return this._portalSelf},enumerable:!1,configurable:!0}),Object.defineProperty(mt.prototype,"properties",{get:function(){return this._properties},enumerable:!1,configurable:!0}),mt);function mt(e){this._portalUrl="https://www.arcgis.com",this.id=e.id,this._portalUrl=e.portalUrl,this._hubUrl=e.hubUrl,e.authentication&&(this._authentication=e.authentication),e.portalSelf&&(this._portalSelf=e.portalSelf),e.currentUser&&(this._currentUser=e.currentUser),e.properties&&(this._properties=e.properties)}var gt=(yt.create=function(r){return void 0===r&&(r={}),x(this,void 0,void 0,function(){var t;return I(this,function(e){switch(e.label){case 0:return[4,(t=new yt(r)).initialize()];case 1:return e.sent(),[2,t]}})})},yt.prototype.setAuthentication=function(t){return x(this,void 0,void 0,function(){return I(this,function(e){switch(e.label){case 0:return this._authentication=t,this._portalUrl=t.portal.replace("/sharing/rest",""),[4,this.initialize()];case 1:return e.sent(),[2]}})})},yt.prototype.setProperties=function(e){this._properties=e,this._context=new ht(this.contextOpts)},yt.prototype.clearAuthentication=function(){this._context.isPortal||(this._portalUrl=st(this._portalUrl)),this._authentication=null,this._portalSelf=null,this._currentUser=null,this._context=new ht(this.contextOpts)},Object.defineProperty(yt.prototype,"context",{get:function(){return this._context},enumerable:!1,configurable:!0}),yt.prototype.initialize=function(){return x(this,void 0,void 0,function(){var t,r,n;return I(this,function(e){switch(e.label){case 0:if(!this._authentication||this._portalSelf&&this._currentUser)return[3,4];L.debug("ArcGISContextManager-"+this.id+": Initializing"),t=this._authentication.username,t=[Je({authentication:this._authentication}),He({username:t,authentication:this._authentication})],e.label=1;case 1:return e.trys.push([1,3,,4]),[4,Promise.all(t)];case 2:return n=e.sent(),r=n[0],n=n[1],this._portalSelf=r,this._currentUser=n,L.debug("ArcGISContextManager-"+this.id+": received portalSelf and currentUser"),[3,4];case 3:throw r=e.sent(),n='ArcGISContextManager could not fetch portal & user for "'+this._authentication.username+'" using '+this._authentication.portal+".",L.error(n),console.error(n),r;case 4:return L.debug("ArcGISContextManager-"+this.id+": updating context"),this._context=new ht(this.contextOpts),[2]}})})},Object.defineProperty(yt.prototype,"contextOpts",{get:function(){var e={id:this.id,portalUrl:this._portalUrl,hubUrl:this._hubUrl,properties:this._properties};return this._authentication&&(e.authentication=this._authentication),this._portalSelf&&(e.portalSelf=this._portalSelf),this._currentUser&&(e.currentUser=this._currentUser),e},enumerable:!1,configurable:!0}),yt);function yt(e){this._portalUrl="https://www.arcgis.com",this._logLevel=n.Level.error,this.id=(new Date).getTime(),e.logLevel&&(this._logLevel=e.logLevel),L.setLogLevel(this._logLevel),L.debug("ArcGISContextManager:ctor: Creating "+this.id),e.properties&&(this._properties=e.properties),e.authentication?(this._authentication=e.authentication,this._portalUrl=this._authentication.portal.replace("/sharing/rest","")):e.portalUrl&&(this._portalUrl=e.portalUrl),this._hubUrl=at(this._portalUrl),e.portal&&(this._portalSelf=p(e.portal)),e.currentUser&&(this._currentUser=p(e.currentUser))}var vt=function(e){if(e){var t=e.toLocaleLowerCase();return Object.keys(bt).find(function(e){return bt[e].some(function(e){return e.toLocaleLowerCase()===t})})}},bt={app:["Application","City Engine Web Scene","CityEngine Web Scene","Dashboard","Insights Page","Insights Workbook","Operation View","Web Mapping Application","StoryMap","Web Experience","Urban Model"],dataset:["CSV Collection","CSV","Feature Collection Template","Feature Collection","Feature Layer","Feature Service","File Geodatabase","GeoJSON","GeoJson","KML Collection","KML","Microsoft Excel","Raster Layer","Shapefile","Stream Service","Table"],document:["CAD Drawing","Document Link","Hub Page","Site Page","Image","iWork Keynote","iWork Numbers","iWork Pages","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","PDF","Pro Map","Report Template"],event:["Hub Event"],feedback:["Form","Quick Capture Project"],initiative:["Hub Initiative"],template:["Hub Initiative Template"],solution:["Solution"],map:["Image Collection","Image Service","Map Service Layer","Map Service","Scene Service","Scene Layer","Vector Tile Service","Web Map Service","Web Map Tile Service","Web Map","Web Scene","WFS","WMS","WMTS"],other:["360 VR Experience","AppBuilder Widget Package","Application Configuration","ArcPad Package","Code Attachment","Code Sample","Desktop Add In","Desktop Application Template","Desktop Application","Desktop Style","Explorer Add In","Explorer Layer","Geocoding Service","Geometry Service","Geoprocessing Package","Geoprocessing Sample","Geoprocessing Service","Layer File","Layer Package","Layer Template","Layer","Layout","Locator Package","Map Area","Map Document","Map Package","Map Service Definition","Map Template","Mobile Application","Mobile Map Package","Native Application","Network Analysis Service","Operations Dashboard Add In","Project Package","Project Template","Raster Function Template","Rule Package","Scene Package","Service Definition","SQLite Geodatabase","Style","Tile Package","Vector Tile Package","Workflow Manager Package"],site:["Hub Site Application","Site Application"]},wt=bt.app,St=bt.dataset,kt=bt.document,Ct=bt.event,At=bt.feedback,Tt=bt.initiative,Pt=bt.map,xt=bt.other,It=bt.site,Et=["360 VR Experience","Application","CityEngine Web Scene","Code Sample","CSV Collection","CSV","CAD Drawing","Desktop Application","Desktop Application Template","Desktop Style","File Geodatabase","GeoJson","Geoprocessing Package","Geoprocessing Sample","Image","iWork Keynote","iWork Numbers","KML Collection","KML","Layer","Layer File","Layer Package","Layout","Locator Package","Map Package","Map Service Definition","Map Template","Microsoft Excel","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","Operations Dashboard Add In","PDF","Pro Map","Project Package","Project Template","Raster function template","Rule Package","Service Definition","Shapefile","Vector Tile Package","Workflow Manager Package"],Ot=["Data"],Dt={app:wt.concat(At),dataset:St,document:kt,event:Ct,initiative:Tt,map:Pt,other:xt,site:It,downloadableTypes:Et,downloadableTypeKeywords:Ot,apiTypes:["Feature Service","Map Service","Image Service"]};function _t(e){return-1!==Et.indexOf(e.type)||e.typeKeywords&&Ot.some(function(t){return e.typeKeywords.some(function(e){return e===t})})}var Ut=new RegExp(/.+(?:map|feature|image)server/i);function jt(e){var t=e.match(Ut);return t?t[0]:te(e.split("?")[0])}function Nt(e){return[[e.xmin,e.ymin],[e.xmax,e.ymax]]}var Rt={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}};function Mt(e){var t=e.portalSelf,r=t.defaultExtent,t=E(t,"helperServices.geometry.url");if(!t)return Promise.resolve(Rt);if(!r)return Promise.resolve(Rt);t+="/project",r={httpMethod:"POST",params:{geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[r]}),transformForward:!1,transformation:"",inSR:r.spatialReference.wkid,outSR:4326,f:"json"}};return e.authentication&&(r.authentication=e.authentication),Z(t,r).then(function(e){e=e.geometries[0];return{xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:e.ymax,spatialReference:{wkid:4326}}}).catch(function(e){return Rt})}var qt=function(e){return Array.isArray(e)&&Array.isArray(e[0])&&Array.isArray(e[1])};function Ft(e){return console.warn("DEPRECATED: use isBBox() instead"),qt(e)}function Lt(e){var t=(n=e[0])[0],r=n[1],e=(n=e[1])[0],n=n[1];return{rings:[[[t,r],[e,r],[e,n],[t,n],[t,r]]],spatialReference:{wkid:4326}}}function Gt(e){var t,r;switch((e||"").toLowerCase()){case"image service":t="dataset";break;case"feature service":case"raster layer":t="map";break;case"microsoft excel":t="document";break;case"cad drawing":case"feature collection template":case"report template":t="content";break;default:t={other:"content",solution:"template"}[r=vt(e)]||r}return t}function Bt(e){return e&&e.isPortal}function Ht(e,t,r){var n,o=Kt(e,t,r);return o||(n="/content","feedback"===(r=Gt(e))?n="/feedback/surveys":Yt(e)?n="/pages":-1<["app","dataset","document","map","template"].indexOf(r)&&(n="/"+r+"s"),o=n+"/"+t),o}var Wt,Yt=function(e){return["Hub Page","Site Page"].includes(e)},Kt=function(e,t,r){var n;return"Solution"===e&&(0<(null==r?void 0:r.indexOf("Deployed"))&&(n="/content/"+t),n="/templates/"+t+"/about"),n};function zt(e){return{updateFrequency:"metadata.dataIdInfo.resMaint.maintFreq.MaintFreqCd.@_value",reviseDate:"metadata.dataIdInfo.idCitation.date.reviseDate",pubDate:"metadata.dataIdInfo.idCitation.date.pubDate",createDate:"metadata.dataIdInfo.idCitation.date.createDate",metadataUpdateFrequency:"metadata.mdMaint.maintFreq.MaintFreqCd.@_value",metadataUpdatedDate:"metadata.mdDateSt"}[e]}function Vt(e,t){t=zt(t);return t&&E(e,t)}(Pt=Wt=Wt||{}).Year="year",Pt.Month="month",Pt.Day="day",Pt.Time="time";var Jt=function(e,t){t=t.url&&jt(t.url);return t&&e.linkage.includes(t)},$t=function(e,t,r){var n=e.linkage,r=E(r,"authentication.token");return r&&Jt(e,t)&&(t=new URL(e.linkage),(e=new URLSearchParams(t.search)).set("token",r),t.search=e.toString(),n=t.toString()),n},Qt=[{type:"CC0-1.0",abbr:"CC0",name:"Public Domain Dedication",url:"http://creativecommons.org/publicdomain/zero/1.0"},{type:"CC-BY-4.0",abbr:"CC BY",name:"Attribution 4.0 International",url:"http://creativecommons.org/licenses/by/4.0"},{type:"CC-BY-3.0",abbr:"CC BY 3.0",name:"Attribution 3.0 Unported",url:"http://creativecommons.org/licenses/by/3.0"},{type:"CC-BY-2.5",abbr:"CC BY 2.5",name:"Attribution 2.5 Generic",url:"http://creativecommons.org/licenses/by/2.5"},{type:"CC-BY-2.0",abbr:"CC BY 2.0",name:"Attribution 2.0 Generic",url:"http://creativecommons.org/licenses/by/2.0"},{type:"CC-BY-1.0",abbr:"CC BY 1.0",name:"Attribution 1.0 Generic",url:"http://creativecommons.org/licenses/by/1.0"},{type:"CC-BY-SA-4.0",abbr:"CC BY-SA",name:"Attribution-ShareAlike 4.0 International",url:"http://creativecommons.org/licenses/by-sa/4.0"},{type:"CC-BY-SA-3.0",abbr:"CC BY-SA 3.0",name:"Attribution-ShareAlike 3.0 Unported",url:"http://creativecommons.org/licenses/by-sa/3.0"},{type:"CC-BY-SA-2.5",abbr:"CC BY-SA 2.5",name:"Attribution-ShareAlike 2.5 Generic",url:"http://creativecommons.org/licenses/by-sa/2.5"},{type:"CC-BY-SA-2.0",abbr:"CC BY-SA 2.0",name:"Attribution-ShareAlike 2.0 Generic",url:"http://creativecommons.org/licenses/by-sa/2.0"},{type:"CC-BY-SA-1.0",abbr:"CC BY-SA 1.0",name:"Attribution-ShareAlike 1.0 Generic",url:"http://creativecommons.org/licenses/by-sa/1.0"},{type:"CC-BY-ND-4.0",abbr:"CC BY-ND",name:"Attribution-NoDerivatives 4.0 International",url:"http://creativecommons.org/licenses/by-nd/4.0"},{type:"CC-BY-ND-3.0",abbr:"CC BY-ND 3.0",name:"Attribution-NoDerivs 3.0 Unported",url:"http://creativecommons.org/licenses/by-nd/3.0"},{type:"CC-BY-ND-2.5",abbr:"CC BY-ND 2.5",name:"Attribution-NoDerivs 2.5 Generic",url:"http://creativecommons.org/licenses/by-nd/2.5"},{type:"CC-BY-ND-2.0",abbr:"CC BY-ND 2.0",name:"Attribution-NoDerivs 2.0 Generic",url:"http://creativecommons.org/licenses/by-nd/2.0"},{type:"CC-BY-ND-1.0",abbr:"CC BY-ND 1.0",name:"Attribution-NoDerivs 1.0 Generic",url:"http://creativecommons.org/licenses/by-nd/1.0"},{type:"CC-BY-NC-4.0",abbr:"CC BY-NC",name:"Attribution-NonCommercial 4.0 International",url:"https://creativecommons.org/licenses/by-nc/4.0"},{type:"CC-BY-NC-3.0",abbr:"CC BY-NC 3.0",name:"Attribution-NonCommercial 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc/3.0"},{type:"CC-BY-NC-2.5",abbr:"CC BY-NC 2.5",name:"Attribution-NonCommercial 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc/2.5"},{type:"CC-BY-NC-2.0",abbr:"CC BY-NC 2.0",name:"Attribution-NonCommercial 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc/2.0"},{type:"CC-BY-NC-1.0",abbr:"CC BY-NC 1.0",name:"Attribution-NonCommercial 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc/1.0"},{type:"CC-BY-NC-SA-4.0",abbr:"CC BY-NC-SA",name:"Attribution-NonCommercial-ShareAlike 4.0 International",url:"https://creativecommons.org/licenses/by-nc-sa/4.0"},{type:"CC-BY-NC-SA-3.0",abbr:"CC BY-NC-SA 3.0",name:"Attribution-NonCommercial-ShareAlike 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-sa/3.0"},{type:"CC-BY-NC-SA-2.5",abbr:"CC BY-NC-SA 2.5",name:"Attribution-NonCommercial-ShareAlike 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.5"},{type:"CC-BY-NC-SA-2.0",abbr:"CC BY-NC-SA 2.0",name:"Attribution-NonCommercial-ShareAlike 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.0"},{type:"CC-BY-NC-SA-1.0",abbr:"CC BY-NC-SA 1.0",name:"Attribution-NonCommercial-ShareAlike 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/1.0"},{type:"CC-BY-NC-ND-4.0",abbr:"CC BY-NC-ND",name:"Attribution-NonCommercial-NoDerivatives 4.0 International",url:"https://creativecommons.org/licenses/by-nc-nd/4.0"},{type:"CC-BY-NC-ND-3.0",abbr:"CC BY-NC-ND 3.0",name:"Attribution-NonCommercial-NoDerivs 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-nd/3.0"},{type:"CC-BY-NC-ND-2.5",abbr:"CC BY-NC-ND 2.5",name:"Attribution-NonCommercial-NoDerivs 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.5"},{type:"CC-BY-NC-ND-2.0",abbr:"CC BY-NC-ND 2.0",name:"Attribution-NonCommercial-NoDerivs 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.0"},{type:"CC-BY-NC-ND-1.0",abbr:"CC BY-NC-ND 1.0",name:"Attribution-NonCommercial-NoDerivs 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/1.0"},{type:"PDDL-1.0",abbr:"PDDL",name:"ODC Public Domain Dedication and License",url:"http://opendatacommons.org/licenses/pddl/summary"},{type:"ODbL-1.0",abbr:"ODbL",name:"ODC Open Database License",url:"http://opendatacommons.org/licenses/odbl/summary"},{type:"ODC-BY-1.0",abbr:"ODC BY",name:"ODC Attribution License",url:"http://opendatacommons.org/licenses/by/summary"}];function Xt(r){var e={type:(r=r||"")?"custom":"none",text:r},t=!1,n=Qt.filter(function(e){return t=e,(e=(e=r).toLowerCase()).includes(t.name.toLowerCase())||e.includes(t.url.toLowerCase())||e.includes(t.abbr.toLowerCase());var t});return n.length&&(t=!0,e=n.pop()),t||(n=void 0,!function(e){try{return!!new URL(e).protocol}catch(e){return!1}}(r)?(t=r,new RegExp(/^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)>((?:.(?!\<\/a\>))*.)?<\/a>$|^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)\/>/).test(t)&&(t=new RegExp(/href\s?=\s?["'](.*?)["']/),n=r.match(t)[1])):n=r,n&&(e.url=n,e.text="")),e.text||delete e.text,e}function Zt(e,t,r){if(!e||!e.thumbnail)return null;var n=r||{},o=n.token,n=n.width,r=it(e,t,o=!o&&"string"==typeof r?r:o).split("?"),o=r[0],r=r[1],r=new URLSearchParams(r);r.delete("f"),n&&r.append("w",n+"");r=r.toString(),e=o+"/info/"+e.thumbnail;return r?e+"?"+r:e}n.UpdateFrequency=void 0,(xt=n.UpdateFrequency||(n.UpdateFrequency={})).Continual="continual",xt.Daily="daily",xt.Weekly="weekly",xt.Fortnightly="fortnightly",xt.Monthly="monthly",xt.Quarterly="quarterly",xt.Biannually="biannually",xt.Annually="annually",xt.AsNeeded="as-needed",xt.Irregular="irregular",xt.NotPlanned="not-planned",xt.Unknown="unknown",xt.Semimonthly="semimonthly";function er(e,t){return{"001":n.UpdateFrequency.Continual,"002":n.UpdateFrequency.Daily,"003":n.UpdateFrequency.Weekly,"004":n.UpdateFrequency.Fortnightly,"005":n.UpdateFrequency.Monthly,"006":n.UpdateFrequency.Quarterly,"007":n.UpdateFrequency.Biannually,"008":n.UpdateFrequency.Annually,"009":n.UpdateFrequency.AsNeeded,"010":n.UpdateFrequency.Irregular,"011":n.UpdateFrequency.NotPlanned,"012":n.UpdateFrequency.Unknown,"013":n.UpdateFrequency.Semimonthly}[Vt(e,t||"updateFrequency")]}function tr(e,t){var r,n,o=(e=Vt(e,t),/^\d{4}$/.test(e=""+e)?(r=new Date(+e,0,1),o=Wt.Year):/^\d{4}-\d{1,2}$/.test(e)?(n=e.split("-"),r=new Date(+n[0],+n[1]-1,1),o=Wt.Month):/^\d{4}-\d{1,2}-\d{1,2}$/.test(e)?(n=e.split("-"),r=new Date(+n[0],+n[1]-1,+n[2]),o=Wt.Day):Number.isNaN(Date.parse(e))||(r=new Date(e),o=e.includes("T")?Wt.Time:Wt.Day),r&&o&&{date:r,precision:o});return o&&D(D({},o),{source:"metadata."+zt(t)})}function rr(e,t){return(e=E(e,t+=".editingInfo.lastEditDate"))&&{date:new Date(e),source:t,precision:Wt.Day}}function nr(e,t){return{date:new Date(e[t]),precision:Wt.Day,source:"item."+t}}function or(e){return null!==(e={appbuilderExtension:"file",appbuilderWidgetPackage:"widgets-source",application:"web",applicationConfiguration:"app-gear",arcgisProMap:"desktop",cadDrawing:"file-cad",cityEngineWebScene:"urban-model",codeAttachment:"file-code",codeSample:"file-code",colorSet:"palette",contentCategorySet:"label",csv:"file-csv",cSV:"file-csv",cSVCollection:"file-csv",dashboard:"dashboard",desktopApplication:"desktop",documentLink:"link",excaliburImageryProject:"file",explorerMap:"file",exportPackage:"file",featureCollection:"data",featureCollectionTemplate:"file",featureLayer:"data",featureService:"collection",fileGeodatabase:"data",form:"survey",geocodingService:"file",geodataService:"file",geometryService:"file",geopackage:"file",geoprocessingService:"file",globeLayer:"layers",globeService:"file",hubInitiative:"initiative",hubInitiativeTemplate:"initiative-template",hubPage:"browser",hubSiteApplication:"web",image:"file-image",imageService:"data",insightsModel:"file",insightsPage:"graph-moving-average",insightsTheme:"palette",insightsWorkbook:"graph-moving-average",iWorkPages:"file-text",iWorkKeynote:"presentation",iWorkNumbers:"file-report",kML:"data",kMLCollection:"data",layer:"layers",layerPackage:"layers",layerTemplate:"file",locatorPackage:"file",mapArea:"file",mapDocument:"map-contents",mapImageLayer:"collection",mapPackage:"file",mapService:"collection",microsoftExcel:"file-report",microsoftPowerpoint:"presentation",microsoftWord:"file-text",mission:"file",mobileMapPackage:"map-contents",nativeApplication:"mobile",nativeApplicationInstaller:"file",nativeApplicationTemplate:"file",mobileApplication:"mobile",networkAnalysisService:"file",notebook:"code",orientedImageryCatalog:"file",orthoMappingProject:"file",orthoMappingTemplate:"file",pDF:"file-pdf",quickCaptureProject:"mobile",rasterFunctionTemplate:"file",rasterLayer:"map",realTimeAnalytic:"file",relationalDatabaseConnection:"file",reportTemplate:"file",sceneLayer:"data",sceneService:"urban-model",serviceDefinition:"file",shapefile:"data",solution:"puzzle-piece",sqliteGeodatabase:"file",statisticalDataCollection:"file",storymap:"tour",storyMap:"tour",storymapTheme:"palette",symbolSet:"file",table:"table",urbanModel:"urban-model",vectorTilePackage:"file-shape",vectorTileService:"map",visioDocument:"conditional-rules",webExperience:"apps",webMap:"map",webMappingApplication:"apps",webScene:"urban-model",wfs:"map",wFS:"map",wMS:"map",wMTS:"map",workflowManagerService:"file",workforceProject:"list-check"}[h(e||"")])&&void 0!==e?e:"file"}function ir(e,t){var r=(r=t.authentication)&&r.token;return{portalHome:nt(e.id,t),portalApi:it(e,t,r),portalData:ot(e,t,r),thumbnail:Zt(e,t,{token:r})}}function ar(e,t){var r,n;return n=e,r=!Bt(t)&&"public"===n.access&&"CSV"===n.type&&n.size<=5e6?lt(t)+"/datasets/"+e.id+"_0/FeatureServer/0":r}function sr(e){return e&&"feature service"===e.toLowerCase()}var ur=function(e){e=e&&e.match(/\/\d+$/);return e&&e[0].slice(1)};function cr(e){var t=(e=void 0===e?{}:e).type,r=e.typeKeywords||[];return("Site Application"===e.type||"Web Mapping Application"===e.type&&T(r,"hubSite"))&&(t="Hub Site Application"),("Site Page"===e.type||"Web Mapping Application"===e.type&&T(r,"hubPage"))&&(t="Hub Page"),"Hub Initiative"===e.type&&T(r,"hubInitiativeTemplate")&&(t="Hub Initiative Template"),t="Web Mapping Application"===e.type&&T(r,"hubSolutionTemplate")?"Solution":t}function lr(e){return ur(e.url)||sr(e.type)&&e.typeKeywords&&T(e.typeKeywords,"Singlelayer")&&"0"}function pr(e){if("public"===e.access){var t=e.id,e=lr(e);return e?t+"_"+e:t}}function dr(e){if(!e)return e;var t=["categories",""];return e.map(function(e){return e.split("/")}).reduce(function(e,t,r){return _(e,t)},[]).filter(function(e){return!T(t,e.toLowerCase())})}var fr=function(r,e){var t=e||{},n=t.slug,o=t.requestOptions,i=t.data,a=t.metadata,s=t.groupIds,u=t.ownerUser,c=t.org,l=t.errors,p=t.server,d=t.layers,f=t.recordCount,h=t.boundary,m=t.statistics,g=ur(r.url),y=g?parseInt(g,10):null==e?void 0:e.layerId,v=d&&(O(y)?sr(r.type)&&function(e){e=e&&1===e.length&&e[0];return e&&e.capabilities.includes("Query")&&e}(d):d.find(function(e){return e.id===y})),b=!Bt(o)&&"public"===r.access?v?r.id+"_"+v.id:pr(r):void 0,t=n||b||r.id,w=(g=d,e=r.url,v&&g&&1<g.length&&!ur(e)),S=w?v.name:r.title,k=w&&v.description,C=v?v.type:cr(r),A=D({relative:Ht(C,t,r.typeKeywords)},o&&ir(r,o)),T=ar(r,o),P=(e=r,tr((o={metadata:a,layer:v,server:p}).metadata,"reviseDate")||rr(o,"layer")||rr(o,"server")||nr(e,"modified")),x=(o=r,tr(e=a,"pubDate")||tr(e,"createDate")||nr(o,"created")),I=(o=r,tr(a,"metadataUpdatedDate")||nr(o,"modified"));return D(D({item:r},r),{slug:n,data:i,metadata:a,groupIds:s,ownerUser:u,org:c,errors:l||[],server:p,layers:d,recordCount:f,statistics:m,hubId:b,identifier:t,get isProxied(){return!!T},layer:v,name:S,get title(){return S},get description(){return k||r.description},type:C,get family(){return Gt(C)},get url(){return T||(w?jt(r.url)+"/"+v.id:r.url)},get categories(){return dr(r.categories)},get actionLinks(){return r.properties&&r.properties.links},get hubActions(){return r.properties&&r.properties.actions},get isDownloadable(){return _t(r)},get structuredLicense(){return Xt(r.licenseInfo)},get permissions(){return{visibility:r.access,control:r.itemControl||"view"}},get boundary(){return h||function(e){var t,r=e.extent,n=qt(r),e=(null===(e=e.properties)||void 0===e?void 0:e.boundary)||(n?"item":void 0);switch(e){case"item":t=n?Lt(r):null;break;case"none":t=null}return{provenance:e,geometry:t}}(r)},get summary(){return k||r.snippet||r.description},urls:A,get portalHomeUrl(){return A.portalHome},get portalDataUrl(){return A.portalData},get portalApiUrl(){return A.portalApi},get thumbnailUrl(){return A.thumbnail},get createdDate(){return new Date(r.created)},createdDateSource:"item.created",get updatedDate(){return P.date},get updatedDateSource(){return P.source},get updatedDatePrecision(){return P.precision},get modified(){return P.date.getTime()},get publishedDate(){return x.date},get publishedDateSource(){return x.source},get publishedDatePrecision(){return x.precision},get metadataUpdatedDate(){return I.date},get metadataUpdatedDateSource(){return I.source},get metadataUpdatedDatePrecision(){return I.precision},get updateFrequency(){return er(a)},get metadataUpdateFrequency(){return er(a,"metadataUpdateFrequency")},get publisher(){return{name:r.owner,username:r.owner}},get metrics(){return r.properties&&r.properties.metrics},get spatialReference(){return function(e){var t=e.spatialReference;if(!t||"object"==typeof t)return t;e=t+"",t=parseInt(e,10);return isNaN(t)?{wkt:e}:{wkid:t}}(r)||(e=p,(null===(t=null==(t=v)?void 0:t.extent)||void 0===t?void 0:t.spatialReference)||(null==e?void 0:e.spatialReference))||null;var e,t},get orgId(){return c?c.id:r.orgId},get contentTypeIcon(){return console.warn("DEPRECATED: it is now the responsibility of the consuming package to determine the icon"),or(C)},get license(){return console.warn("DEPRECATED: use structuredLicense instead"),{name:"Custom License",description:r.accessInformation}},get hubType(){return console.warn("DEPRECATED: use family instead"),Gt(C)},get additionalResources(){return function(t,e,r){e=E(e,"metadata.distInfo.distTranOps.onLineSrc")||null;return null===e?null:(e=Array.isArray(e)?e:[e]).map(function(e){return{name:e.orName,url:$t(e,t,r),isDataSource:Jt(e,t)}})}(r,a)}})};function hr(e){void 0===e&&(e=""),console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v10.0.0");e=vt(e);return"feedback"===e?"app":e}function mr(t,e){if(T(["template","feedback"],t.family))return t.id;if(Yt(t.type)){var r=(E(e,"data.values.pages")||[]).find(function(e){return e.id===t.id});return r?r.slug:t.id}if(t.slug){r=E(e,"domainInfo.orgKey");return E(e,"data.values.isUmbrella")?t.slug:yr(t.slug,r)}return t.hubId||t.id}function gr(e){e=e?e.split("_"):[];return{itemId:e[0],layerId:e[1]}}function yr(e,t){return t&&e.match(t+"::")?e.split(t+"::")[1]:e}function vr(e){return fr(e)}function br(e){if(e){var t=e.id,r=e.attributes;if(r){var n=gr(t).itemId,o=r.owner,i=r.orgId,a=r.created,s=r.modified,u=r.name,c=r.title,l=r.type,p=r.typeKeywords,d=r.description,f=r.snippet,h=r.tags,m=r.thumbnail,g=r.categories,y=r.contentStatus,v=r.spatialReference,b=r.accessInformation,w=r.licenseInfo,S=r.culture,k=r.url,C=r.access,A=r.proxyFilter,T=r.properties,P=r.appCategories,x=r.industries,I=r.languages,E=r.largeThumbnail,O=r.banner,D=r.screenshots,_=r.listed,U=r.ownerFolder,j=r.size,N=r.protected,R=r.commentsEnabled,M=r.numComments,q=r.numRatings,F=r.avgRating,L=r.numViews,G=r.itemControl,B=r.scoreCompleteness,H=r.itemExtent,e=r.itemModified,t=r.modifiedProvenance,r=r.serviceSpatialReference;return{id:n,owner:o,orgId:i,created:a,modified:e||"item.modified"===t&&s,title:c||u,type:k&&ct(k)||l,typeKeywords:p,description:d,tags:h,snippet:f,thumbnail:m,extent:H||[],categories:g,contentStatus:y,spatialReference:v||r,accessInformation:b,licenseInfo:w,culture:S,url:k,access:C,size:j,protected:N,proxyFilter:A,properties:T,appCategories:P,industries:x,languages:I,largeThumbnail:E,banner:O,screenshots:D,listed:_,ownerFolder:U,commentsEnabled:R,numComments:M,numRatings:q,avgRating:F,numViews:L,itemControl:G,scoreCompleteness:B}}}}function wr(e,t){var r=mr(e,t);return{relative:r=Ar(e,r),absolute:""+E(t,"item.url").replace(/\/$/,"")+r}}var Sr=function(e,t){return t?"CSV":h(e||"")},kr=function(e,t){var r=wr(e,t),t=r.relative,r=r.absolute;return Cr(e,{relative:t,site:r})},Cr=function(e,t){t=D(D({},e.urls),t);return D(D({},e),{urls:t})},Ar=function(e,t){return Ht(e.type,t||e.identifier,e.typeKeywords)};const Tr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const Pr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var xr={atob:function(t){if((t=(t=(t=`${t}`).replace(/[ \t\n\f\r]/g,"")).length%4==0?t.replace(/==?$/,""):t).length%4==1||/[^+/0-9A-Za-z]/.test(t))return null;let r="",n=0,o=0;for(let e=0;e<t.length;e++)n<<=6,n|=function(e){e=Tr.indexOf(e);return e<0?void 0:e}(t[e]),o+=6,24===o&&(r+=String.fromCharCode((16711680&n)>>16),r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n),n=o=0);return 12===o?(n>>=4,r+=String.fromCharCode(n)):18===o&&(n>>=2,r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n)),r},btoa:function(e){let t;for(e=`${e}`,t=0;t<e.length;t++)if(255<e.charCodeAt(t))return null;let r="";for(t=0;t<e.length;t+=3){const n=[void 0,void 0,void 0,void 0];n[0]=e.charCodeAt(t)>>2,n[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(n[1]|=e.charCodeAt(t+1)>>4,n[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(n[2]|=e.charCodeAt(t+2)>>6,n[3]=63&e.charCodeAt(t+2));for(let e=0;e<n.length;e++)void 0===n[e]?r+="=":r+=function(e){if(0<=e&&e<64)return Pr[e];return}(n[e])}return r}},Ir="4326",Er={csv:{name:"CSV",itemTypes:["CSV","CSV Collection"],supportsProjection:!0},kml:{name:"KML",itemTypes:["KML","KML Collection"],supportsProjection:!1},shapefile:{name:"Shapefile",itemTypes:["Shapefile"],supportsProjection:!0},fileGeodatabase:{name:"File Geodatabase",itemTypes:["File Geodatabase"],supportsProjection:!0},geojson:{name:"GeoJson",itemTypes:["GeoJson"],supportsProjection:!1},excel:{name:"Excel",itemTypes:["Microsoft Excel"],supportsProjection:!0},featureCollection:{name:"Feature Collection",itemTypes:["Feature Collection"],supportsProjection:!0}};function Or(e){if("object"!=typeof e)return e;var t=e.wkid,e=e.wkt;return t?t+"":xr.btoa(e)}function Dr(e){return"spatialRefId:"+Or(function(t){var r;try{r=JSON.parse(t)}catch(e){r=t}return r}(e))}function _r(e){return"exportItem:"+e}function Ur(e){return e?"exportLayer:0"+e:"exportLayer:null"}function jr(e){var t,r=e.autoAddResult,n=e.inviteResult,o=e.primaryEmailResult,e=e.secondaryEmailResult;return(o||e)&&(t={success:(e=[o,e].filter(function(e){return e})).every(function(e){return e.success})},(e=e.reduce(function(e,t){return e.concat(v(t,"errors",[]))},[])).length&&(t.errors=e)),{success:[r,n,t].filter(function(e){return e}).every(function(e){return e.success}),autoAdd:r,invite:n,email:t}}function Nr(t,e){var r;return t&&(r=!E(t,"notAdded.length")&&!t.errors,e.autoAddResult={success:r},r||(r=t.errors||[],E(t,"notAdded.length")&&r.push(new K("Users not auto-added: "+t.notAdded.join(", "))),e.autoAddResult.errors=r,r=e.usersToAutoAdd.filter(function(e){return T(t.notAdded,e.username)}),e.usersToInvite=e.usersToInvite.concat(r))),e}function Rr(e,t){return e.orgId===t.orgId}function Mr(e){return"org_admin"===e.role&&!e.roleId}function qr(e,t,r,n){var o=Promise.resolve(null);return e.length&&(e={authentication:r,message:t.body,subject:t.subject,notificationChannelType:"email",users:e.map(function(e){return e.username})},n||(e.batchSize=1),o=Ge(e)),o}function Fr(t){var r,e=Promise.resolve(t);return t.email&&t.secondaryRO&&E(t,"inviteResult.success")&&(r=v(t,"secondaryRO.portalSelf.user",{}),e=qr(t.usersToInvite.filter(function(e){return Rr(e,r)}),t.email,t.secondaryRO.authentication,Mr(r)).then(function(e){return t.secondaryEmailResult=e,t})),e}function Lr(e,t,r){var n=Promise.resolve(null);return n=t.length?_e({id:e,users:t.map(function(e){return e.username}),authentication:r}):n}function Gr(t){return Lr(E(t,"groupId"),E(t,"usersToAutoAdd"),E(t,"primaryRO.authentication")).then(function(e){return Nr(e,t)})}function Br(e,t,r,n,o){void 0===n&&(n=20160),void 0===o&&(o="group_member");var i=Promise.resolve(null);return i=t.length?Re({id:e,users:t.map(function(e){return e.username}),authentication:r,role:o,expiration:n}):i}function Hr(t){return Br(E(t,"groupId"),E(t,"usersToInvite"),E(t,"primaryRO.authentication")).then(function(e){return t.inviteResult=e,t})}function Wr(t){var e=Promise.resolve(t);return e=t.email&&E(t,"inviteResult.success")?qr(t.usersToEmail,t.email,t.primaryRO.authentication,Mr(t.requestingUser)).then(function(e){return t.primaryEmailResult=e,t}):e}function Yr(e,t){var r,n=[];return-1!==t.privileges.indexOf("portal:admin:assignToGroups")&&(r=[t.orgId,t.cOrgId].filter(function(e){return e}),n=e.filter(function(e){return-1!==r.indexOf(e.orgId)})),n}function Kr(e,t){var r=Yr(e,t);return e.filter(function(t){return!r.some(function(e){return e.username===t.username})})}function zr(e,t,r){void 0===r&&(r=!1);e=Kr(e,t).filter(function(e){return Rr(e,t)});return r&&e.push(t),e}var Vr=["ar","bs","ca","cs","da","de","en","es","et","el","fi","fr","hr","he","hu","it","id","ja","ko","lt","lv","nb","nl","pl","pt","pt-br","pt-pt","ro","ru","sl","sr","sv","th","tr","uk","vi","zh","zh-cn","zh-tw","zh-hk"];function Jr(e,t){if("object"==typeof e&&null!==e&&"string"==typeof t){for(var r=t.split("."),n=0;n<r.length-1;n++){if(!e.hasOwnProperty(r[n]))return;e=e[r[n]]}delete e[r[r.length-1]]}}function $r(e){var t=p(e.item);return t.text=JSON.stringify(e.data),t}function Qr(e,t){return Promise.all([we(e,t),ke(e,t)]).then(function(e){return{item:e[0],data:e[1]}})}function Xr(e,r){return An(e,r).then(function(e){var t=[Promise.resolve(e)];return e?t.push(ke(e.id,r)):t.push(Promise.resolve(null)),Promise.all(t)}).then(function(e){return e[0]?{item:e[0],data:e[1]}:null})}function Zr(e,t){var r=p(e),n=p(e.item);return n.data=p(e.data),be(D({item:n},t)).then(function(e){return r.item.id=e.id,r.item.created=(new Date).getTime(),r.item.modified=r.item.created,r})}function en(e,t){var r=p(e),n=p(e.item);return n.data=p(e.data),ve(D({item:n},t)).then(function(){return r.item.modified=(new Date).getTime(),r})}function tn(r,n){return x(this,void 0,void 0,function(){var t;return I(this,function(e){switch(e.label){case 0:return[4,ke(r.id,n)];case 1:return t=e.sent(),[2,{item:r,data:t}]}})})}var rn=function(e,t,r){return void 0===r&&(r=void 0),t.split(".").reduce(function(e,t){return e?e[t]:r},e)};function nn(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}var on=function(e){return e instanceof Date},an=function(e){return"function"==typeof e},sn=function(e){return"object"==typeof e},un=function(e){return e instanceof RegExp};var cn=function(e){return"object"==typeof e};function ln(e){return Array.isArray(e)?function(e){var t=e,e=e.reduce(function(e,t){return fn(t)&&dn(t)&&(e<(t=pn(t))&&(e=t)),e},-1);-1<e&&(t=0===e?[]:"{{delete:"+(e-1)+"}}");return t}(e.map(t).filter(function(e){return null!=e})):e&&cn(e)?function(o){var e=Object.keys(o).reduce(function(e,t){var r,n=o[t];return fn(n)&&dn(n)?(r=pn(n))>e.maxLevel&&(e.maxLevel=r):e.obj[t]=n,e},{obj:{},maxLevel:-1});e=0<e.maxLevel?1===e.maxLevel?void 0:"{{delete:"+(e.maxLevel-1)+"}}":e.obj;return e}(nn(e,t)):function(e){var t=e;"string"==typeof e&&dn(e)&&(t=function(e){var t=e,e=pn(e);t=0===e?void 0:"{{delete:"+e+"}}";return t}(e));return t}(e);function t(e,t){return ln(e)}}var pn=function(e){return parseInt(e.replace(/{|}/g,"").split(":")[1])};function dn(e){return e&&"string"==typeof e&&-1<e.indexOf("{{delete")}var fn=function(e){return"string"==typeof e};function hn(e,t,r,n){return void 0===n&&(n=0),t?t:"{{delete:"+n+"}}"}var mn=function(e){var t={};if(Array.isArray(e))t=e.map(mn);else if("object"==typeof e)for(var r in e)null!=e[r]&&"object"==typeof e[r]?t[r]=mn(e[r]):t[r]=e[r];else t=e;return t},gn=/{{\s*?[\w].*?}}/g,yn=function(e){return"string"==typeof e};function vn(e){return e||""===e||0===e}function bn(e,a,s){if((s=mn(s=void 0===s?null:s)||{}).optional)throw new Error("Please do not pass in an `optional` transform; adlib provides that internally.");return s.optional=hn,ln(function r(e,n,o){return o=o||"",Array.isArray(e)?e.map(t):!e||!sn(e)||on(e)||un(e)||an(e)?n(e,o):Object.assign({},e,nn(e,t));function t(e,t){return r(e,n,o?o+"."+t:t)}}(e,function(t,e){if(!yn(t))return t;var r,n=t.match(gn);return n&&n.length?(n.map(function(e){var o,i=!1,t=e.replace(/{|}/g,"").trim();-1<t.indexOf("||")&&(r=t.split("||").map(function(e){return e.trim()}),o=r.length,t=r.find(function(e,t){var r,n;return(n=a,r=(r=e).split(":")[0],null!=(r=rn(n,r,null)))?e:t+1===o&&(i=!0,isNaN(e)?e:parseInt(e))}));var r={key:e,value:t};return i||(t=function(e,t,r){var n,o=e.split(":");if(1<o.length){var i,a=o[0],s=o[1];if(o[2]&&(i=o[2]),!r||!r[s]||"function"!=typeof r[s])throw new Error("Attempted to apply non-existant transform "+s+" on "+a+" with params "+e);n=rn(t,a),n=r[s](a,n,t,i)}else n=rn(t,e);return n}(t,a,s),r.value=vn(t)?t:e),r}).forEach(function(e){t===e.key?("string"==typeof e.value&&(isNaN(e.value)||""===e.value||(-1<e.value.indexOf(".")?e.value=parseFloat(e.value):e.value=parseInt(e.value))),r=e.value):t=t.replace(e.key,e.value)}),vn(r)?r:t):t}))}function wn(e,t,r){return bn(e,t,r)}function Sn(e,t,r){return Oe({q:'title:"'+e+'" AND '+Object.keys(t).map(function(e){return e+':"'+t[e]+'"'}).join(" AND "),authentication:r}).then(function(e){return 0<e.results.length}).catch(function(e){throw Error("Error in doesItemExistWithTitle "+e)})}function kn(e,t){return t.toLowerCase()+"-"+F(e)}function Cn(e,t){e=e.filter(function(e){return!e.startsWith("slug|")});return e.push("slug|"+t),e}function An(e,t){return Tn({slug:e},t).then(function(e){return e.length?e[0]:null})}function Tn(e,t){t={q:"",filter:'typekeywords:"slug|'+e.slug+'"',authentication:t.authentication};return e.exclude&&(t.q="NOT id:"+e.exclude),Oe(t).then(function(e){return e.results}).catch(function(e){throw Error("Error in getItemBySlug "+e)})}function Pn(t,r,n){var o=t.slug;return Tn({slug:o=(n=void 0===n?0:n)?t.slug+"-"+n:o,exclude:t.existingId},r).then(function(e){return e.length?Pn(t,r,++n):o}).catch(function(e){throw Error("Error in getUniqueSlug "+e)})}var xn=["id","isOrgItem","proxyFilter","ownerFolder","protected","owner","created","modified","guid","name","access","size","listed","numComments","numRatings","avgRating","numViews","scoreCompleteness","groupDesignations","listed","screenshots","banner","appCategories","industries","languages","largeThumbnail"];function In(n,o,i,a){return x(this,void 0,void 0,function(){var t,r;return I(this,function(e){switch(e.label){case 0:t=D({item:{id:n},params:{thumbnail:o},filename:i},a),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,ve(t)];case 2:if(!e.sent().success)throw new Zo("Set Project Thumbnail","Unknown error setting thumbnail.");return[3,4];case 3:throw(r=e.sent())instanceof Error?new Zo("Set Project Thumbnail",r.message,r):new Zo("Set Project Thumbnail","Unknown error setting thumbnail.");case 4:return[2]}})})}var En=(On.prototype.modelToObject=function(e,t){return r=this.mappings,Dn(e,"modelKey",t,"objectKey",r);var r},On.prototype.objectToModel=function(e,t){return r=this.mappings,Dn(e,"objectKey",t,"modelKey",r);var r},On);function On(e){this.mappings=e}function Dn(r,n,e,o,t){var i=p(e);return t.forEach(function(e){var t=E(e,n),e=E(e,o),t=E(r,t);null!=t&&y(i,e,t)}),i}var It="Web Mapping Application",_n={name:"No title provided",tags:[],typeKeywords:["IHubProject","HubProject"],status:"inactive"},Un={item:{type:It,title:"No Title Provided",description:"No Description Provided",snippet:"",tags:[],typeKeywords:["Hub Project"],properties:{slug:""}},data:{display:"about",timeline:{},status:"inactive",contacts:[],schemaVersion:1}};function jn(){var t=[];return["created","culture","description","extent","id","modified","owner","snippet","tags","typeKeywords","url","type"].forEach(function(e){t.push({objectKey:e,modelKey:"item."+e})}),["contacts","display","geometry","headerImage","layout","location","status"].forEach(function(e){t.push({objectKey:e,modelKey:"data."+e})}),t.push({objectKey:"slug",modelKey:"item.properties.slug"}),t.push({objectKey:"orgUrlKey",modelKey:"item.properties.orgUrlKey"}),t.push({objectKey:"name",modelKey:"item.title"}),t}function Nn(i,a){return x(this,void 0,void 0,function(){var t,r,n,o;return I(this,function(e){switch(e.label){case 0:return(t=D(D({},_n),i)).slug||(t.slug=kn(t.name,t.orgUrlKey)),[4,Pn({slug:(r=t).slug},a)];case 1:return r.slug=e.sent(),t.typeKeywords=Cn(t.typeKeywords,t.slug),n=new En(jn()),[4,Zr(o=n.objectToModel(t,p(Un)),a)];case 2:return o=e.sent(),[2,n.modelToObject(o,{})]}})})}function Rn(o,i){return x(this,void 0,void 0,function(){var t,r,n;return I(this,function(e){switch(e.label){case 0:return[4,Pn({slug:(t=o).slug,existingId:o.id},i)];case 1:return t.slug=e.sent(),[4,Qr(o.id,i)];case 2:return n=e.sent(),r=new En(jn()),[4,en(r.objectToModel(o,n),i)];case 3:return n=e.sent(),[2,r.modelToObject(n,o)]}})})}function Mn(e,n){e=(q(e)?Qr:Xr)(e,n);return e.then(function(e){var t,r=new En(jn()).modelToObject(e,{});return n.authentication&&(t=n.authentication.token),r.thumbnailUrl=Zt(e.item,n,t),r})}function qn(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){switch(e.label){case 0:return[4,Pe(D(D({},r),{id:t}))];case 1:return e.sent(),[2]}})})}function Fn(n,o){var i;return x(this,void 0,void 0,function(){var t,r;return I(this,function(e){return t=ho([{filterType:"content",typekeywords:{exact:["HubProject"]}},n]),t=mo(t),r=wo(t),null!==(i=o.aggregations)&&void 0!==i&&i.length&&(r.countFields=o.aggregations.join(","),r.countSize=200),["authentication","num","sortField","sortOrder","site"].forEach(function(e){o.hasOwnProperty(e)&&(r[e]=o[e])}),[2,Ln(r)]})})}function Ln(s){return x(this,void 0,void 0,function(){var t,r,n,o,i,a;return I(this,function(e){switch(e.label){case 0:return[4,Oe(s)];case 1:return t=e.sent(),r=-1<t.nextStart,i=t.results.map(function(e){return tn(e,{authentication:s.authentication})}),[4,Promise.all(i)];case 2:return a=e.sent(),n=new En(jn()),s.authentication&&(i=s.authentication,o=i.token),a=a.map(function(e){var t=n.modelToObject(e,{});return t.thumbnailUrl=Zt(e.item,{authentication:s.authentication},o),t}),[2,{total:t.total,results:a,facets:[],hasNext:r,next:uo(s,t.nextStart,t.total,Ln)}]}})})}var Gn=(Bn.init=function(e){return new Bn(e)},Object.defineProperty(Bn.prototype,"context",{get:function(){return this._contextManager?this._contextManager.context:this._context},enumerable:!1,configurable:!0}),Bn.prototype.create=function(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){if(r||this.context.isAuthenticated)return t.orgUrlKey||(t.orgUrlKey=this.context.portal.urlKey),[2,Nn(t,r||this.context.userRequestOptions)];throw new Zo("Create Project","Creating Hub Projects requires authentication.")})})},Bn.prototype.update=function(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){if(r||this.context.isAuthenticated)return[2,Rn(t,r||this.context.userRequestOptions)];throw new Zo("Update Project","Updating Hub Projects requires authentication.")})})},Bn.prototype.destroy=function(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){if(r||this.context.isAuthenticated)return[2,qn(t,r||this.context.userRequestOptions)];throw new Zo("Destroy Project","Destroying Hub Projects requires authentication.")})})},Bn.prototype.get=function(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){return console.warn("HubProjectManager.get is deprecated and will be removed. Use .fetch() instead."),[2,this.fetch(t,r)]})})},Bn.prototype.fetch=function(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){if(r||this.context.requestOptions)return[2,Mn(t,r||this.context.requestOptions)];throw new Zo("Fetch Project","Can not retrieve context.requestOptions from Context Manager. HubProjectManager is configured incorrectly.")})})},Bn.prototype.search=function(t,r){return x(this,void 0,void 0,function(){return I(this,function(e){return!r.authentication&&this.context.session&&(r.authentication=this.context.session),[2,Fn(t,r)]})})},Bn.prototype.updateThumbnail=function(r,n,o,i){return x(this,void 0,void 0,function(){var t;return I(this,function(e){switch(e.label){case 0:return t=i||this.context.userRequestOptions,[4,In(r.id,n,o,t)];case 1:return e.sent(),[2,this.fetch(r.id,i)]}})})},Bn);function Bn(e){e instanceof gt?this._contextManager=e:this._context=e}var Hn,Wn=(e(Yn,Hn=Error),Yn);function Yn(e,t,r){e=Hn.call(this,e)||this;return e.status=r,e.url=t,e}function Kn(e,t){var r,n,o=D({httpMethod:"GET"},t),i=o.fetch||fetch,t=D({"Content-Type":"application/json"},o.headers);"GET"===o.httpMethod?r=o.params:n=JSON.stringify(o.params);var a=he({host:lt(o),path:("/api/v3/"+e).replace(/\/\//g,"/"),query:r});return i(a,{method:o.httpMethod,headers:t,body:n}).then(function(e){if(e.ok)return e.json();throw new Wn(e.statusText,a,e.status)})}function zn(e,t){var r=e;return r=-1===e.indexOf("token")&&-1<e.indexOf(t.authentication.portal)?e+"?token="+t.authentication.token:r}function Vn(e,t){return(t=void 0===t?{}:t).credentials||(t.credentials="same-origin"),fetch(e,t).then(function(e){return e.blob()})}function Jn(r){return Vn(r.url).then(function(e){return ye(t={id:r.id,owner:r.owner,name:r.fileName,resource:e,authentication:r.authentication}).then(function(e){e=me(t)+"/content/users/"+e+"/items/"+t.id+"/addResources";return t.params=D({file:t.resource,fileName:t.name,resourcesPrefix:t.prefix,text:t.content,access:t.private?"private":"inherit"},t.params),Z(e,t)});var t})}function $n(t){return Vn(t.url).then(function(e){return ve({item:{id:t.id,owner:t.owner},params:{fileName:t.fileName,thumbnail:e},authentication:t.authentication}).catch(function(e){return Promise.resolve()})}).catch(function(e){return Promise.resolve()})}var Qn={arcgis:{label:"ArcGIS Online",url:"https://www.arcgis.com",type:"arcgis"},arcgisQA:{label:"ArcGIS Online QAEXT",url:"https://qaext.arcgis.com",type:"arcgis"},arcgisDEV:{label:"ArcGIS Online DEVEXT",url:"https://devext.arcgis.com",type:"arcgis"},hub:{label:"ArcGIS Hub",url:"https://hub.arcgis.com/api",type:"arcgis-hub"},hubDEV:{label:"ArcGIS Hub DEV",url:"https://hubdev.arcgis.com/api",type:"arcgis-hub"},hubQA:{label:"ArcGIS Hub QA",url:"https://hubqa.arcgis.com/api",type:"arcgis-hub"}};function Xn(e){return"string"==typeof e&&e in Qn?Qn[e]:e}function Zn(e,t){var r=p(e);return t.from<e.from&&(r.from=t.from),t.to>e.to&&(r.to=t.to),r}function eo(r,n){var o={};return["any","all","not","exact"].forEach(function(e){var t=e,e=_(to(r,t),to(n,t));e.length&&(o[t]=e.filter(m))}),o}function to(e,t){var r=[];return e[t]&&(t=e[t],r=Array.isArray(t)?t:[t]),r}function ro(e){var t={};return Array.isArray(e)?t={any:e}:("string"==typeof e&&(t={any:[e]}),"object"==typeof e&&(t=e)),t}function no(e){var t=new Date,r={type:"date-range",from:t.getTime(),to:t.getTime()};switch(e.unit){case"hours":case"days":case"weeks":r.from=r.to-{min:6e4,hours:36e5,days:864e5,weeks:6048e5}[e.unit]*e.num;break;case"months":t.setMonth(t.getMonth()-e.num),r.from=t.getTime();break;case"years":t.setFullYear(t.getFullYear()-e.num),r.from=t.getTime()}return r}function oo(e,t,r){var n=p(e),e=t.q,t=t.filter;return e&&(n.q=(n.q?" ("+n.q+" "+r+" "+e+")":e).trim()),t&&(n.filter=(n.filter?"("+n.filter+" "+r+" "+t+")":t).trim()),n}function io(e,t){var r={q:"",filter:""};return t.exact&&(_(["username","firstname","lastname","fullname","email"],["title","tags","typekeywords","type","name","owner"],["title","typekeywords","owner"]).includes(e)?r.filter=so("AND",e,t.exact):("string"==typeof t.exact&&(t.all||(t.all=[]),"string"==typeof t.all&&(t.all=[t.all]),t.all.push(t.exact)),Array.isArray(t.exact)&&(t.all||(t.all=[]),"string"==typeof t.all&&(t.all=[t.all]),t.all=t.all.concat(t.exact)))),t.any&&(r.q=so("OR",e,t.any)),t.all&&(r.q=(r.q?r.q+" AND ":"")+so("AND",e,t.all)),t.not&&(r.q=(r.q?r.q+" AND ":"")+so("OR","-"+e,t.not)),r}function ao(e,t){return{q:e+":["+t.from+" TO "+t.to+"]",filter:""}}function so(e,t,r){return Array.isArray(r)?"("+t+':"'+r.join('" '+e+" "+t+':"')+'")':t+':"'+r+'"'}function uo(e,t,r,n){var o=p(e);return e.authentication&&(o.authentication=ce.deserialize(e.authentication.serialize())),o.start=-1<t?t:r+1,function(e){return e&&(o.authentication=e),n(o)}}function co(e,t,r){var n=null;return t.thumbnail&&(n=e+"/community/groups/"+t.id+"/info/"+t.thumbnail,r&&"public"!==t.access&&(n=n+"?token="+r)),n}function lo(e,t,r){var n=null;return t.thumbnail&&(n=e+"/community/users/"+t.username+"/info/"+t.thumbnail,r&&"public"!==t.access&&(n=n+"?token="+r)),n}var po={$apps:[{type:{any:["Code Sample","Web Mapping Application","Mobile Application","Application","Desktop Application Template","Desktop Application","Operation View","Dashboard","Operations Dashboard Extension","Workforce Project","Insights Workbook","Insights Page","Insights Model","Hub Page","Hub Initiative","Hub Site Application","StoryMap","Web Experience","Web Experience Template","Form"],not:["Code Attachment","Featured Items","Symbol Set","Color Set","Windows Viewer Add In","Windows Viewer Configuration","Map Area","Indoors Map Configuration"]},typekeywords:{not:["MapAreaPackage","SMX"]}}],$storymap:[{type:"StoryMap"},{type:"Web Mapping Application",typekeywords:["Story Map"]}],$dashboard:[{type:"Dashboard",typekeywords:{any:["Dashboard"],not:["ArcGIS Operation View","Add In","Extension"]}}],$dataset:[],$experience:[{type:{any:["Web Experience"],not:["Web Experience Template"]}}],$site:[{type:["Hub Site Application","Site Application"]},{type:["Web Mapping Application"],typekeywords:["hubSite"]}],$initiative:[{type:{any:"Hub Initiative",not:"Hub Initiative Template"}}],$document:[{typekeywords:{any:"Document",not:["MapAreaPackage","SMX"]},type:{any:["Image","Layout","Desktop Style","Project Template","Report Template","Pro Report","Statistical Data Collection","360 VR Experience","netCDF","PDF","CSV","Administrative Report","Raster function template"],not:["Image Service","Explorer Document","Explorer Map","Globe Document","Scene Document","Code Attachment","Featured Items","Symbol Set","ColorSet","Windows Viewer Add In","Windows Viewer Configuration","Map Area","Indoors Map Configuration"]}}]};function fo(e){var t,o=[];return null!==(t=e.aggregations)&&void 0!==t&&t.counts&&e.aggregations.counts.forEach(function(r){var e={label:r.fieldName,attribute:r.fieldName,type:"multi-select"},n=[];r.fieldValues.forEach(function(e){var t={filterType:"content"};t[r.fieldName]=e.value;t={label:e.value,value:e.value,count:e.count,selected:!1,filter:t};n.push(t)}),e.options=n,o.push(e)}),o}function ho(e){var e=e.map(mo),n=["created","modified"],o=_(["filterType","subFilters","term"],n),e=e.reduce(function(r,e){return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];r.hasOwnProperty(t)?o.includes(t)?n.includes(t)?r[t]=Zn(r[t],e):"term"===t?r[t]=r[t]+" "+e:"subFilters"===t&&(r[t]=_(r[t],e)):r[t]=eo(r[t],e):r[t]=p(e)}),r},{});return e.filterType="content",e}function mo(e){var t=go(e);return Array.isArray(e.subFilters)&&(t.subFilters=t.subFilters.reduce(function(e,t){return"string"==typeof t?po[t]&&(e=e.concat(po[t])):e.push(t),e},[])),bo(t)}function go(e){var r=p(e);return r.subFilters=r.subFilters||[],r.type&&(Array.isArray(r.type)?r.type=r.type.reduce(function(e,t){return yo(t)?r.subFilters=r.subFilters.concat(vo(t)):e.push(t),e},[]):yo(r.type)&&(e=r.type,r.subFilters=r.subFilters.concat(vo(e)),delete r.type)),r}function yo(e){var t=!1;return t="string"==typeof e?e in po:t}function vo(e){return po[e]}function bo(t){var r={};t.term&&(r.term=t.term);var e,n=["created","modified"],o=_(["filterType","subFilters","term"],n);return Object.entries(t).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r[t]=ro(e))}),t.subFilters&&Array.isArray(t.subFilters)&&(e=t.subFilters,r.subFilters=e.map(bo)),n.forEach(function(e){t[e]&&("relative-date"===t[e].type?r[e]=no(t[e]):r[e]=p(t[e]))}),r}function wo(e){var t,r=So(e);return e.subFilters&&(t=e.subFilters.reduce(function(e,t){return e="object"==typeof t?oo(e,So(t),"OR"):e},{q:"",filter:""}),r=oo(r,t,"AND")),e.term&&(r.q=(e.term+" "+r.q).trim()),r}function So(e){var r={q:"",filter:""},n=["created","modified"],o=_(["filterType","subFilters","term"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=oo(r,io(t,e),"AND")),n.includes(t)&&(r=oo(r,ao(t,e),"AND"))}),r}function ko(r){var n={},o=["created","modified"],i=_(["term","searchUserAccess"],o);return Object.entries(r).forEach(function(e){var t=e[0],e=e[1];i.includes(t)||S(t,ro(e),n),o.includes(t)&&(e=p(E(r,t)),"relative-date"===E(r,t+".type")?S(t,no(e),n):S(t,e,n))}),r.hasOwnProperty("searchUserAccess")&&(n.searchUserAccess=r.searchUserAccess),r.term&&(n.term=r.term),n}function Co(e){var r={q:"",filter:""},n=["created","modified"],o=_(["term","searchUserAccess","filterType"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=oo(r,io(t,e),"AND")),n.includes(t)&&(r=oo(r,ao(t,e),"AND"))}),e.hasOwnProperty("searchUserAccess")&&(r.searchUserAccess=e.searchUserAccess),e.term&&(r.q=(e.term+" "+r.q).trim()),r}function Ao(r){var n={},o=["created","modified","lastlogin"],i=_(["disabled","term"],o);return Object.entries(r).forEach(function(e){var t=e[0],e=e[1];i.includes(t)||S(t,ro(e),n),o.includes(t)&&(e=p(E(r,t)),"relative-date"===E(r,t+".type")?S(t,no(e),n):S(t,e,n))}),r.hasOwnProperty("disabled")&&(n.disabled=r.disabled),r.term&&(n.term=r.term),n}function To(e){var r={q:"",filter:""},n=["created","modified","lastlogin"],o=_(["term","filterType"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=oo(r,io(t,e),"AND")),n.includes(t)&&(r=oo(r,ao(t,e),"AND"))}),e.hasOwnProperty("disabled")&&(r.disabled=e.disabled),e.term&&(r.q=("("+e.term+") "+r.q).trim()),r}function Po(o){var e,t,r=(null===(e=o.authentication)||void 0===e?void 0:e.portal)||o.portal;o.authentication&&(t=o.authentication.token);function i(e){return e.thumbnailUrl=Zt(e,r,t),e}return Oe(o).then(function(e){var t=-1<e.nextStart,r=e.results.map(vr),r=(r=o.site?r.map(function(e){return kr(e,o.site)}):r).map(i),n=fo(e);return{total:e.total,results:r,facets:n,hasNext:t,next:uo(o,e.nextStart,e.total,Po)}})}function xo(o){function i(e){return e.siteTeamUrl=o.site.item.url+"/teams/"+e.id+"/about",e}var e,t,r=(null===(e=o.authentication)||void 0===e?void 0:e.portal)||o.portal;o.authentication&&(t=o.authentication.token);function a(e){return e.thumbnailUrl=co(r,e,t),e}return Ee(o,"group").then(function(e){var t,r=-1<e.nextStart,n=e.results.map(a);return null!==(t=null===(t=o.site)||void 0===t?void 0:t.item)&&void 0!==t&&t.url&&(n=e.results.map(i)),{hasNext:r,total:e.total,results:n,next:uo(o,e.nextStart,e.total,xo)}})}function Io(o){function i(e){return e.profileUrl=o.site.item.url+"/people/"+e.username+"/profile",e}function a(e){return e.thumbnail&&(e.thumbnailUrl=lo(t,e,r)),e}var t=o.authentication.portal,r=o.authentication.token;return Ee(o,"user").then(function(e){var t,r=-1<e.nextStart,n=e.results.map(a);return null!==(t=null===(t=o.site)||void 0===t?void 0:t.item)&&void 0!==t&&t.url&&(n=e.results.map(i)),{hasNext:r,total:e.total,results:n,next:uo(o,e.nextStart,e.total,Io)}})}function Eo(t){return x(this,void 0,void 0,function(){return I(this,function(e){return 200<=t.status&&t.status<300?[2,t.json()]:[2,t.json().then(function(e){if(e.error)throw new Error(e.error.title+" :: "+e.error.detail+" :: "+t.status);throw new Error("Got "+t.status+" "+t.statusText)})]})})}function Oo(e){var t={},e=E(e,"authentication.token");return e&&(t.Authorization=e),t}function Do(e){return(e||"https://hub.arcgis.com")+"/api/v3/domains"}function _o(e,t){var r=e,n="hubsubdomain|"+(r=-1<e.indexOf("#/")?e.split("#/")[1]:r);return Oe(Object.assign({q:"typekeywords: "+n},t)).then(function(e){return e.results.filter(function(e){return T(e.typeKeywords,n)})[0]}).then(function(e){if(!e)throw new Error("site not found");return{hostname:e.url,siteId:e.id}})}function Uo(e,t){if(t.isPortal)throw new Error("domainExists is not available in ArcGIS Enterprise.");e=et(e);e=Do(t.hubApiUrl)+"/"+e,t=Oo(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(function(e){return 404!==e.status})}function jo(e,t){return _o(e,t).then(function(e){return!0}).catch(function(e){return!1})}function No(t,r,n,o){var i=t;return Uo((i=(o=void 0===o?0:o)?t+"-"+o:t)+"-"+r,n).then(function(e){return e?No(t,r,n,o+1):i})}function Ro(t,r,n){var o=(n=void 0===n?0:n)?t+"-"+n:t;return jo(o,r).then(function(e){return e?Ro(t,r,n+1):o})}function Mo(e,t){if(t.isPortal)return _o(e,t);e=Do(t.hubApiUrl)+"/"+e,t=Oo(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(Eo)}function qo(e,t){var r=p(e),e=63;return t&&(e-=t.length+1),r=r.length>e?r.slice(0,e-6)+"-"+M(5):r}function Fo(e,t){return Qr(e,t).then(Wo)}function Lo(e){if(1.4<=E(e,"item.properties.schemaVersion"))return e;var t=p(e),e=E(t,"data.values.gacode");return t.data.values.telemetry={consentNotice:{isTheme:!0,consentText:"",policyURL:""},customAnalytics:{ga:{customerTracker:{enabled:Boolean(e),id:e}}}},Jr(t,"data.values.gacode"),S("item.properties.schemaVersion",1.4,t),t}var Go=1.5;function Bo(e){if(1.5<=E(e,"item.properties.schemaVersion"))return e;var r,t=p(e),e=t.data.values.dcatConfig;return t.data.feeds={},e&&(t.data.feeds.dcatUS11=(r=JSON.stringify(e),Object.keys(Ho).forEach(function(e){var t=Ho[e];r=r.split(e).join(t)}),JSON.parse(r))),t.item.properties.schemaVersion=1.5,t}var Ho={"{{default.name}}":"{{name}}","{{default.description}}":"{{description}}","{{item.tags}}":"{{tags}}","{{item.created:toISO}}":"{{created:toISO}}","{{item.modified:toISO}}":"{{modified:toISO}}","{{default.source.source}}":"{{source}}","{{item.owner}}":"{{owner}}","{{org.portalProperties.links.contactUs.url}}":"{{orgContactEmail}}","{{org.name}}":"{{orgName}}","{{item.categories}}":"{{categories}}","{{item.licenseInfo}}":"{{licenseInfo}}","{{item.modified}}":"{{modified}}","{{enrichments.categories}}":"{{categories}}","{{default.id}}":"{{id}}","{{item.licenseInfo || No License}}":"{{licenseInfo || No License}}","{{org.portalProperties.links.contactUs.url || mailto:data@tempe.gov}}":"{{orgContactEmail || mailto:data@tempe.gov}}","{{default.description || No Description}}":"{{description || No Description}}","{{item.id}}":"{{id}}"};function Wo(e){return E(e,"item.properties.schemaVersion")===Go?e:e=Bo(e=Lo(e=function(e){if(1.3<=E(e,"item.properties.schemaVersion"))return e;var t=p(e),e=E(t,"data.catalog.groups")||[];return t.data.catalog.groups=e.filter(q),t.item.properties.schemaVersion=1.3,t}(e=function(e){if(1.2<=E(e,"item.properties.schemaVersion"))return e;var t=p(e),e=E(t,"data.catalog")||{};return E(t,"data.values.groups")&&(e.groups=p(t.data.values.groups),delete t.data.values.groups),t.data.catalog=e,t.item.properties.schemaVersion=1.2,t}(e=function(e){if(1.1<=E(e,"item.properties.schemaVersion"))return e;var t=p(e);return["subdomain","defaultHostname","internalUrl","customHostname","externalUrl"].forEach(function(e){t.data.values[e]&&"string"==typeof t.data.values[e]&&(t.data.values[e]=t.data.values[e].toLowerCase())}),t.item.properties.schemaVersion=1.1,t}(e=function(e){if(1<=E(e,"item.properties.schemaVersion"))return e;var t=p(e);return["groupId","title"].forEach(function(e){delete t.data.values[e]}),t.item.properties||(t.item.properties={}),t.item.properties.schemaVersion=1,t.data.values.groups&&Array.isArray(t.data.values.groups)&&(e=t.data.values.groups.map(function(e){return"object"==typeof e?e.id:e}).filter(function(e){return!!e}),t.data.values.groups=e),t}(e))))))}function Yo(e,t){return Ce(D({id:e,relationshipType:"Survey2Service",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function Ko(e,t){return Ce(D({id:e,relationshipType:"Service2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function zo(e,t){return Ce(D({id:e,relationshipType:"Survey2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function Vo(t){function e(e){return-1<t.typeKeywords.indexOf(e)}var r=e("FieldworkerView");return r=r||["Survey123","Feature Service","View Service"].every(e)&&!e("StakeholderView")}Jo.create=function(r){return x(this,void 0,void 0,function(){var t;return I(this,function(e){switch(e.label){case 0:return r.contextManager?[2,new Jo(r.contextManager)]:[3,1];case 1:return t=r.managerOptions||{},[4,gt.create(t)];case 2:return[2,new Jo(e.sent())]}})})},Object.defineProperty(Jo.prototype,"context",{get:function(){return this._contextManager.context},enumerable:!1,configurable:!0}),Object.defineProperty(Jo.prototype,"projects",{get:function(){return this._projectManager||(this._projectManager=Gn.init(this._contextManager)),this._projectManager},enumerable:!1,configurable:!0}),Pt=Jo;function Jo(e){this._contextManager=e}$o.prototype.startOperation=function(e){e=p(e);e.startedAt=(new Date).getTime(),e.state="working",this.operations.push(e)},$o.prototype.start=function(e,t){t={type:e,id:v(t,"id",r(e+"_")),inputs:v(t,"inputs",{}),cleanup:v(t,"cleanup","n/a"),startedAt:(new Date).getTime(),state:"working"};return this.operations.push(t),t.id},$o.prototype.getOperation=function(t){return this.operations.find(function(e){return e.id===t})},$o.prototype.getOperations=function(){return this.operations},$o.prototype.finish=function(e,t){var r=this.getOperation(e);if(!r)throw new Error("No operation with id "+e+" present in stack");r.duration=(new Date).getTime()-r.startedAt,r.state="completed",t&&(r.output=p(t))},$o.prototype.merge=function(e){this.operations=_(this.operations,e.operations)},$o.prototype.getCompleted=function(){return p(this.operations.filter(function(e){return"completed"===e.state}))},$o.prototype.getWorking=function(){return p(this.operations.filter(function(e){return"working"===e.state}))},$o.prototype.toString=function(){return this.operations.sort(function(e,t){return e.startedAt<t.startedAt?-1:t.startedAt<e.startedAt?1:0}).map(Qo).join("\n")},$o.prototype.serialize=function(){return{operations:p(this.getOperations())}},xt=$o;function $o(){this.operations=[]}function Qo(e){var t=e.startedAt+" : Operation "+e.id+" started with inputs "+JSON.stringify(e.inputs)+" but was not completed";return t="completed"===e.state?e.startedAt+" : Operation "+e.id+" took "+e.duration+" ms with inputs "+JSON.stringify(e.inputs)+" and output "+(e.output?JSON.stringify(e.output):"n/a"):t}var Xo,Zo=(e(ei,Xo=j),ei);function ei(e,t,r){var n=this;return t=t||"UNKNOWN_ERROR",r=v(r,"rootCause",r),(n=Xo.call(this,e,t,r)||this).name="HubError",n.stack=v(r,"stack",(new Error).stack),n}n.ArcGISContext=ht,n.ArcGISContextManager=gt,n.GLOBAL_EXTENT=Rt,n.HUB_CDN_URLMAP=Qe,n.HUB_LOCALES=Vr,n.HUB_PROJECT_ITEM_TYPE=It,n.Hub=Pt,n.HubError=Zo,n.HubProjectManager=Gn,n.Logger=L,n.OperationError=j,n.OperationStack=xt,n.PORTAL_EXPORT_TYPES=Er,n.REQUIRED_PRIVS=fe,n.RemoteServerError=Wn,n.SEARCH_APIS=Qn,n.SITE_SCHEMA_VERSION=Go,n.STANDARD_LICENSES=Qt,n.WGS84_WKID=Ir,n._addTokenToResourceUrl=zn,n._canEmailUser=Rr,n._checkStatusAndParseJson=Eo,n._consolidateResults=jr,n._deepMapValues=i,n._ensureSafeDomainLength=qo,n._ensureTelemetry=Lo,n._formatAutoAddResponse=Nr,n._getAuthHeader=Oo,n._getAutoAddUsers=Yr,n._getDomainServiceUrl=Do,n._getEmailUsers=zr,n._getHttpAndHttpsUris=function(e){return e?["http://"+(e=e.replace(/^http(s?):\/\//,"")),"https://"+e]:[]},n._getInviteUsers=Kr,n._getLocation=function(){if(window)return window.location},n._isDate=s,n._isFunction=u,n._isObject=c,n._isOrgAdmin=Mr,n._isRegExp=l,n._isString=a,n._lookupPortal=_o,n._mapValues=o,n._processAutoAdd=Gr,n._processInvite=Hr,n._processPrimaryEmail=Wr,n._processSecondaryEmail=Fr,n._searchContent=function(o,i){var a;return x(this,void 0,void 0,function(){var t,r,n;return I(this,function(e){return t=mo(o),r=Xn(i.api||"arcgis"),[2,"arcgis"===r.type?(n=wo(t),["authentication","num","sortField","sortOrder","site"].forEach(function(e){i.hasOwnProperty(e)&&(n[e]=i[e])}),n.authentication||(n.portal=r.url+"/sharing/rest"),null!==(a=i.aggregations)&&void 0!==a&&a.length&&(n.countFields=i.aggregations.join(","),n.countSize=200),Po(n)):Promise.resolve({total:0,results:[],facets:[],hasNext:!1,next:function(){}})]})})},n._searchGroups=function(o,i){return x(this,void 0,void 0,function(){var t,r,n;return I(this,function(e){if(t=ko(o),"arcgis"===(r=Xn(i.api||"arcgis")).type)return n=Co(t),["authentication","num","sortField","sortOrder","site"].forEach(function(e){i.hasOwnProperty(e)&&(n[e]=i[e])}),n.authentication||(n.portal=r.url+"/sharing/rest"),[2,xo(n)];throw new Error("_searchGroups is not implemented for non-arcgis apis")})})},n._searchUsers=function(n,o){return x(this,void 0,void 0,function(){var t,r;return I(this,function(e){if(!o.authentication)throw new Error("Authentication required to search for users.");if(t=Ao(n),"arcgis"===Xn(o.api||"arcgis").type)return r=To(t),["authentication","num","sortField","sortOrder","site"].forEach(function(e){o.hasOwnProperty(e)&&(r[e]=o[e])}),[2,Io(r)];throw new Error("_searchUsers is not implemented for non-arcgis apis")})})},n._unprotectAndRemoveGroup=function(e){var t=R(qe,{success:!0}),r=R(Fe,{success:!0});return t(e).then(function(){return r(e)})},n._unprotectAndRemoveItem=function(e){var t=R(Ae,{success:!0}),r=R(Pe,{success:!0});return t(e).then(function(){return r(e)})},n.addContextToSlug=function(e,t){return/.+::.+/.test(e)?e:t+"::"+e},n.addDays=function(e,t){try{var r=new Date(e);return new Date(r.setDate(r.getDate()+t)).toISOString().split("T")[0]}catch(e){throw new Error("Invalid Date")}},n.addDomain=function(e,t){if(t.isPortal)throw new Error("addDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Oo(t);r["Content-Type"]="application/json";var n=""+Do(t.hubApiUrl);return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"POST",headers:r,mode:"cors",body:JSON.stringify(e)}).then(Eo)},n.addSolutionResourceUrlToAssets=function(e,t){var r,n,o=e.assets||e.resources||[];return e.bundleItemId&&(r=Ze(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=o.map(function(e){return{name:e.name,type:e.type||"resource",url:r+"/resources/"+n+"-"+e.name}})),o},n.addUsersToGroup=function(e,t,r,n,o){var i=p(v(r,"portalSelf.user",{}));return i.cOrgId=E(r,"portalSelf.portalProperties.hub.settings.communityOrg.orgId"),Gr({groupId:e,allUsers:t,primaryRO:r,email:n,secondaryRO:o,requestingUser:i,usersToAutoAdd:Yr(t,i),usersToInvite:Kr(t,i),usersToEmail:zr(t,i,E(n,"copyMe"))}).then(Hr).then(Wr).then(Fr).then(jr)},n.applyPropertiesToItems=function(e,t){return e.map(function(e){return e.properties||(e.properties={}),Object.assign(e.properties,t),e})},n.arrayToObject=function(e,r){return e.reduce(function(e,t){return e[E(t,r)]=t,e},{})},n.atob=xr.atob,n.autoAddUsers=Lr,n.bBoxToPolygon=Lt,n.batch=A,n.btoa=xr.btoa,n.buildDraft=function(e,t){return w(e,{},t)},n.buildExistingExportsPortalQuery=function(e,t){var r,n,o,i,a=(c=function(e){if(e)return{onlyTypes:e.onlyTypes,layerId:e.layerId,spatialRefId:e.spatialRefId};return{}}(t)).onlyTypes,s=c.layerId,u=c.spatialRefId,t=Object.keys(Er).map(function(e){return Er[e]}),c=new Set(g(t.filter(function(e){return!e.supportsProjection}).map(function(e){return e.itemTypes}))),t=a||g(t.map(function(e){return e.itemTypes})),s=(new xe).startGroup().match(_r(e)).in("typekeywords").and().match(Ur(s)).in("typekeywords").endGroup().and().startGroup();function l(e,t){var r;t.startGroup().match(/\s/g.test(e)?e:'"'+e+'"').in("type").and().match(Dr((r=e,t=Ir,t=(e=i)&&!o.has(r)?e:t))).in("typekeywords").endGroup()}return r=s,n=(c={types:t,spatialRefId:u,noProjectionItemTypes:c}).types,o=c.noProjectionItemTypes,i=c.spatialRefId,n.forEach(function(e,t){l(e,r),t<n.length-1&&r.or()}),s.endGroup(),s.toParam()},n.buildUrl=he,n.camelize=h,n.canEditEvent=function(e,t){var r=!1;return pe(t)&&(e=E(e,"initiative.item.properties.collaborationGroupId"),t=t.groups,r=!!e&&!!d(void 0===t?[]:t,"id",e)),r},n.canEditItem=de,n.canEditSite=function(e,t){var r=!1;return r=!E(e,"properties.isDefaultHubHome")&&pe(t)?de(e,t):r},n.canEditSiteContent=function(e,t){var r,n=!1,o=E(e,"properties.isDefaultHubHome"),i=pe(t);return!o&&i?n=de(e,t):i&&(i=t.orgId,e=e.orgId,i&&i===e&&(r=t.privileges||[],n=fe.every(function(e){return T(r,e)}))),n},n.capitalize=t,n.categories=Dt,n.chunkArray=function(e,t){for(var r=[],n=0;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r},n.clearSession=function(e,t){(t=void 0===t?window:t).localStorage&&t.localStorage.removeItem("__CONTEXT_"+e)},n.cloneObject=p,n.completeOAuth2=function(t,e){var r=(e=(e=void 0===e?window:e).location.href.match(/access_token=(.+)&expires_in=.+&username=([^&]+)/))[1],n="https://www.arcgis.com/sharing/rest/community/users/"+decodeURIComponent(e[2]);return Z(n,{params:{token:r},httpMethod:"GET"}).then(function(e){return Date.now()-e.created<5e3?Z(n+"/update",{params:{token:r,tags:["hubRole:participant","org:"+e.orgId],access:"public"}}).then(function(){return ce.completeOAuth2(t)}):ce.completeOAuth2(t)})},n.compose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce(function(r,n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(n.apply(void 0,e))}})},n.composeContent=fr,n.constructSlug=kn,n.convertContentDefinitionToFilter=bo,n.convertContentFilterToSearchOptions=So,n.convertPortalResponseToFacets=fo,n.convertSolutionTemplateResourcesToAssets=function(e,t){var r,n,o=[];return e.resources&&e.bundleItemId&&(r=Ze(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=e.resources.map(function(e){return{name:e,type:"resource",url:r+"/resources/"+n+"-"+e}})),o},n.convertToWellKnownLocale=function(e){var t="en";return e=(e=void 0===e?"en":e).toLowerCase(),-1<Vr.indexOf(e)?t=e:1<(e=e.split("-")).length&&-1<Vr.indexOf(e[0])&&(t=e[0]),t},n.convertUrlsToAnchorTags=function(t){var e=t.match(/((((ftp|https?):\/\/)|(w{3}\.))[-\w@:%_+.~#?,&//=]+)/g);return e&&e.forEach(function(e){t=t.replace(e,'<a target="_blank" href="'+e+'">'+e+"</a>")}),t.replace("(","<br/>(")},n.createExtent=function(e,t,r,n,o){return{xmin:e,ymin:t,xmax:r,ymax:n,spatialReference:{wkid:o=void 0===o?4326:o}}},n.createId=r,n.createModel=Zr,n.createOperationPipeline=function(e){return function(r){return e.reduce(function(e,t){return e.then(t).catch(function(e){if("OperationError"===e.name)return Promise.reject(e);e="IPipeableFn did not reject with an OperationError \n Operation Stack: \n "+r.stack.toString(),e=new j("pipeline execution error",e);return e.operationStack=r.stack.serialize(),Promise.reject(e)})},Promise.resolve(r))}},n.createProject=Nn,n.dasherize=function(e){return e.replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase().replace(/[ _]/g,"-")},n.datasetToContent=function(e){var t=br(e),r=(m=e.attributes).errors,n=m.boundary,o=m.metadata,i=m.slug,a=m.groupIds,s=m.orgId,u=m.orgName,c=m.organization,l=m.orgExtent,p=m.server,d=m.layers,f=m.layer,h=m.recordCount,e=m.statistics,m=m.searchDescription,f=f&&f.id,e=fr(t,{layerId:f,slug:i,errors:r,metadata:o||null,groupIds:a,org:s&&{id:s,name:u||c,extent:l},server:p,layers:d,recordCount:h,boundary:n,statistics:e});return m&&(e.summary=m),e},n.datasetToItem=br,n.deepFind=k,n.deepFindById=function(e,t){return k(e,function(e){return e.id===t})},n.deepSet=y,n.deepStringReplace=b,n.deleteProp=Jr,n.destroyProject=qn,n.doesItemExistWithTitle=Sn,n.domainExists=Uo,n.domainExistsPortal=jo,n.emailOrgUsers=qr,n.ensureProp=function(e,t){return y(e,t)},n.ensureUniqueDomainName=function(e,t){return(t.isPortal?Ro(e,t):No(e,t.portalSelf.urlKey+"."+et(lt(t)),t)).then(function(e){return qo(e,t.portalSelf.urlKey)})},n.ensureUniqueString=function(e,t){for(var r=!1,n=0,o=t;!r;)T(e,o)?o=t+"-"+ ++n:r=!0;return o},n.expandApi=Xn,n.expandApis=function(e){return e.map(Xn)},n.expandContentFilter=mo,n.expandGroupFilter=ko,n.expandTypeField=go,n.expandUserFilter=Ao,n.extend=function n(e,o,i){void 0===i&&(i=!0);e=p(e);return Object.keys(o).reduce(function(e,t){var r;return null!==o[t]&&void 0!==o[t]&&(r=p(o[t]),Array.isArray(r)?e[t]=r:e[t]=i&&"object"==typeof r?n(e[t]||{},r,i):r),e},e)},n.extentToBBox=Nt,n.failSafe=R,n.failSafeUpdate=function(e,t){return R(ve,{id:e.item.id,success:!0})(Object.assign({item:$r(e)},t))},n.fetchAllPages=function(n,o,r,i){var a=o.num||100,e=o.start||1;return(-1===(r=void 0===r?-1:r)?n(D(D({},o),{num:a,start:e})):Promise.resolve({nextStart:e,total:r,results:[],num:a})).then(function(t){if(-1===t.nextStart)return[t];for(var e=[],r=t.nextStart;r<=t.total;r+=a)e.push(r);return A(e,function(e){return n(D(D({},o),{start:e,num:a}))},i).then(function(e){return _([t],e)})}).then(function(e){var t=e.reduce(function(e,t){return _(e,t.results)},[]),e=-1===r?t.length:r;return t.slice(0,e)})},n.fetchAndUploadResource=Jn,n.fetchAndUploadThumbnail=$n,n.fetchHubTranslation=function(t,e,r){void 0===r&&(r="cors");var n=(Xe(e)+"/locales/"+t+".json").toLocaleLowerCase();return fetch(n,{method:"GET",credentials:"same-origin",mode:r}).then(function(e){return e.json()}).catch(function(e){throw Error("Attempt to fetch locale "+t+" from "+n+" failed: "+JSON.stringify(e))})},n.fetchImageAsBlob=Vn,n.fetchModelFromItem=tn,n.fetchProject=Mn,n.fetchSite=function(e,t){return q(e)?Fo(e,t):Mo(et(e).split("/")[0],t).then(function(e){return Fo(e.siteId,t)})},n.filterBy=function(e,t,r){return e.filter(function(e){return E(e,t)===r})},n.findBy=d,n.findItemsBySlug=Tn,n.flattenArray=g,n.generateRandomString=M,n.getCategory=hr,n.getContentIdentifier=mr,n.getContentSiteUrls=wr,n.getContentTypeIcon=or,n.getContentTypeLabel=Sr,n.getCulture=function(e){return E(e,"portalSelf.user.culture")||E(e,"portalSelf.culture")||"en-us"},n.getDomainsForSite=function(e,t){return t.isPortal?Promise.resolve([]):(e=Do(t.hubApiUrl)+"?siteId="+e,t=Oo(t),fetch(e,{method:"GET",headers:t,mode:"cors"}).then(Eo).catch(function(e){throw Error("Error in getDomainsForSite "+e)}))},n.getExportItemTypeKeyword=_r,n.getExportLayerTypeKeyword=Ur,n.getFamily=Gt,n.getGeographicOrgExtent=Mt,n.getGroupThumbnailUrl=co,n.getHubApiFromPortalUrl=at,n.getHubApiUrl=lt,n.getHubApiUrlFromPortal=function(e){return rt(e)+"/api/v3"},n.getHubLocaleAssetUrl=Xe,n.getHubProduct=function(e){var t=E(e,"portalProperties.hub.enabled")||!1?"premium":"basic";return t=e.isPortal&&"singletenant"===e.portalMode?"portal":t},n.getHubUrlFromPortal=rt,n.getInputFeatureServiceModel=Yo,n.getItemApiUrl=it,n.getItemAssets=function(e,t){var r=Ze(t.portalSelf)+"/content/items/"+e.id,n=Zt(e,t),o=[];return n&&o.push({name:e.thumbnail,url:n,type:"thumbnail"}),e=e.id,e=Se(e,t=t)+"/resources",(t=D({},t)).params=D({num:1e3},t.params),Z(e,t).then(function(e){e=e.resources.map(function(e){return{name:e.resource,type:"resource",url:r+"/resources/"+e.resource}});return o.concat(e)})},n.getItemBySlug=An,n.getItemDataUrl=ot,n.getItemHomeUrl=nt,n.getItemHubId=pr,n.getItemHubType=function(e){return console.warn("DEPRECATED: Use getFamily() instead. getItemHubType() will be removed at v10.0.0"),e=cr(e="string"==typeof e?{type:e}:e),vt(e)},n.getItemLayerId=lr,n.getItemThumbnailUrl=Zt,n.getLayerIdFromUrl=ur,n.getModel=Qr,n.getModelBySlug=Xr,n.getModelFromOptions=function(e,t){var r=e+"Model",e=e+"Id";if(t[r])return Promise.resolve(t[r]);if(t[e])return R(Qr,{item:{id:t[e]},isMissing:!0})(t[e],t);throw new Error("getModelFromOptions requires either a ."+r+" or ."+e+" property.")},n.getNextFunction=uo,n.getOrgExtentAsBBox=function(e){return Mt(e).then(Nt)},n.getPortalApiUrl=Ze,n.getPortalBaseFromOrgUrl=st,n.getPortalUrl=$e,n.getPortalUrls=ir,n.getProp=E,n.getProps=function(r,e){return e.reduce(function(e,t){t=E(r,t);return t&&e.push(t),e},[])},n.getProxyUrl=ar,n.getServiceTypeFromUrl=ct,n.getSession=function(e,t){var r=null;return!(t=void 0===t?window:t).localStorage||(e=t.localStorage.getItem("__CONTEXT_"+e))&&(r=ce.deserialize(e)),r},n.getSiteById=Fo,n.getSourceFeatureServiceModelFromFieldworker=Ko,n.getSpatialRefTypeKeyword=Dr,n.getStakeholderModel=zo,n.getStructuredLicense=Xt,n.getSubscriptionType=function(e){return v(e,"subscriptionInfo.type","Enterprise")},n.getSurveyModels=function(e,r){var n,o;return("string"==typeof e?we(e,r):Promise.resolve(e)).then(function(t){var e=[Yo(t.id,r),zo(t.id,r)];return Promise.all(e).then(function(e){var t=e[0],e=e[1];return o=e,t&&Vo(t.item)?Ko((n=t).item.id,r):t}).then(function(e){return{form:{item:t},featureService:e,fieldworker:n,stakeholder:o}})})},n.getTypeCategories=function(e){if(e=hr(cr(e=void 0===e?{}:e))){e=Array.from(e);return e[0]=e[0].toUpperCase(),[e.join("")]}return["Other"]},n.getTypes=function(e){return Dt[(e=void 0===e?"":e).toLowerCase()]},n.getUniqueDomainName=No,n.getUniqueDomainNamePortal=Ro,n.getUniqueItemTitle=function t(r,n,o,i){var a=(i=void 0===i?0:i)?r+" "+i:r;return Sn(a,n,o).then(function(e){return e?t(r,n,o,++i):a}).catch(function(e){throw Error("Error in getUniqueItemTitle "+e)})},n.getUniqueSlug=Pn,n.getUserThumbnailUrl=lo,n.getWithDefault=v,n.hasBasePriv=pe,n.hubApiRequest=Kn,n.hubApiSearch=function(e){var t=(t=e.authentication)&&t.serialize&&{authentication:t.serialize()};return Kn("/search",D(D({},{headers:t,httpMethod:"POST"}),e))},n.includes=T,n.incrementString=function(e){var t=e.match(/-\s(\d+$)/);return t?(t=parseInt(t[1],10),e=e.replace("- "+t,"- "+(t+1))):e+=" - 1",e},n.interpolate=wn,n.interpolateItemId=function(e){return wn(e,{item:{id:e.item.id},appid:e.item.id},{toISO:function(e,t){return t}})},n.inviteUsers=Br,n.isBBox=qt,n.isDomainForLegacySite=function(e){return!q(e.siteId)},n.isDomainUsedElsewhere=function(e,t,r){return Mo(e,r).then(function(e){return e.siteId!==t}).catch(function(){return!1})},n.isDownloadable=_t,n.isExtentCoordinateArray=Ft,n.isFeatureService=sr,n.isFieldworkerView=Vo,n.isGuid=q,n.isMapOrFeatureServerUrl=function(e){return ut.test(e)},n.isNil=O,n.isSlug=function(e){return!(!(e=gr(e).itemId)||q(e))},n.isUpdateGroup=B,n.isValidDomain=function(t,e){if(e.isPortal)throw new Error("isValidDomain is not available in ArcGIS Enterprise.");var r=Do(e.hubApiUrl)+"/validate?hostname="+t,e=Oo(e);return fetch(r,{method:"GET",headers:e,mode:"cors"}).then(function(e){return e.json()}).catch(function(e){return{success:!1,input:t,error:{code:400,detail:e,message:"lookupFailed"}}})},n.isValidExtent=function(t){return!!t&&[Ft,function(t){return["xmin","ymin","xmax","ymax"].every(function(e){return"number"==typeof t[e]})}].some(function(e){return e(t)})},n.itemPropsNotInTemplates=xn,n.itemToContent=vr,n.last=function(e){return e[e.length-1]},n.lookupDomain=Mo,n.mapBy=function(t,e){return(e=void 0===e?[]:e).map(function(e){return e[t]})},n.maybeAdd=function(e,t,r){return null!=t&&((r=p(r))[e]=t),r},n.maybePush=f,n.mergeContentFilter=ho,n.mergeDateRange=Zn,n.mergeGroupFilters=function(e){var e=e.map(ko),o=["created","modified"],i=_(["filterType","term"],o);return e.reduce(function(n,e){return Object.entries(e).forEach(function(e){var t=e[0],r=e[1];n.hasOwnProperty(t)?(e=E(n,t),i.includes(t)?o.includes(t)?S(t,Zn(e,r),n):"term"===t&&(n[t]=n[t]+" "+r):S(t,eo(e,r),n)):S(t,p(r),n)}),n},{filterType:"group"})},n.mergeMatchOptions=eo,n.mergeObjects=w,n.mergeSearchOptions=oo,n.mergeUserFilters=function(e){var e=e.map(Ao),o=["created","modified","lastlogin"],i=_(["disabled","term","filterType"],o);return e.reduce(function(n,e){return Object.entries(e).forEach(function(e){var t=e[0],r=e[1];n.hasOwnProperty(t)?(e=E(n,t),i.includes(t)?o.includes(t)?S(t,Zn(e,r),n):"term"===t&&(n[t]=n[t]+" "+r):S(t,eo(e,r),n)):S(t,p(r),n)}),n},{filterType:"user"})},n.normalizeItemType=cr,n.normalizeSolutionTemplateItem=function(e){var t=p(e);return xn.forEach(function(e){delete t[e]}),t.extent="{{organization.defaultExtentBBox}}",t},n.objectToArray=function(r,n){return void 0===n&&(n="id"),Object.keys(r).reduce(function(e,t){return r[t][n]=t,e.push(p(r[t])),e},[])},n.objectToJsonBlob=function(e){if("undefined"!=typeof Blob)return new Blob([JSON.stringify(e)],{type:"application/json"});throw new Error("objectToJsonBlob is not currently supported on Node")},n.parseDatasetId=gr,n.parseItemCategories=dr,n.processRevertableTasks=function(e){return Promise.all(e).then(function(e){function t(e){return"fullfilled"===e.status}var r=e.filter(t),n=e.filter(function(e){return!t(e)});if(n.length){e=r.map(function(e){return e.revert()});throw Promise.all(e).catch(function(){}),n[0].error}return r.map(function(e){return e.results})})},n.propifyString=function(e){return h(e.replace(/^[0-9]*/g,"").replace(/[^\w\s]/g,""))},n.relativeDateToDateRange=no,n.removeContextFromSlug=yr,n.removeDomain=function(e,t){if(t.isPortal)throw new Error("removeDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Oo(t);return r["Content-Type"]="application/json",e=Do(t.hubApiUrl)+"/"+e,fetch(e,{method:"DELETE",headers:r,mode:"cors"}).then(Eo)},n.removeDomainsBySiteId=function(e,t){if(t.isPortal)throw new Error("removeDomainsBySiteId is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Oo(t);return r["Content-Type"]="application/json",e=Do(t.hubApiUrl)+"/?siteId="+e,fetch(e,{method:"DELETE",headers:r,mode:"cors"}).then(Eo)},n.removeEmptyProps=function t(r){return Object.keys(r).forEach(function(e){r[e]&&"object"==typeof r[e]?t(r[e]):null==r[e]&&delete r[e]}),r},n.replaceItemId=function(e,t,r){return void 0===r&&(r="{{appid}}"),b(p(e),new RegExp(t,"g"),r)},n.runRevertableTask=function(e,t){return e().then(function(e){return{status:"fullfilled",results:e,revert:t}}).catch(function(e){return{status:"rejected",error:e}})},n.saveSession=function(e,t,r){(r=void 0===r?window:r).localStorage&&r.localStorage.setItem("__CONTEXT_"+e,t.serialize())},n.searchProjects=Fn,n.serializeContentFilterForPortal=wo,n.serializeDateRange=ao,n.serializeGroupFilterForPortal=Co,n.serializeMatchOptions=io,n.serializeModel=$r,n.serializeSpatialReference=Or,n.serializeStringOrArray=so,n.serializeUserFilterForPortal=To,n.setContentHubId=function(e,t){var r=e.id,r=e.slug||t||r,r=D(D({},e),{hubId:t,identifier:r});return Cr(r,{relative:Ar(r)})},n.setContentSiteUrls=kr,n.setContentType=function(e,t){var r=cr(D(D({},e.item),{type:t})),n=Gt(r),o=or(r),t=Sr(r,e.isProxied),t=D(D({},e),{type:r,family:n,normalizedType:r,contentTypeIcon:o,contentTypeLabel:t});return Cr(t,{relative:Ar(t)})},n.setItemThumbnail=In,n.setProp=S,n.setSlugKeyword=Cn,n.shareItemToGroups=function(t,e,r,n){return Promise.all(e.map(function(e){e=Object.assign({},{id:t,groupId:e},r);return n&&(e.owner=n),Ye(e)}))},n.slugify=F,n.stringToBlob=function(e,t){if(void 0===t&&(t="application/octet-stream"),"undefined"==typeof Blob)throw new Error("stringToBlob is not currently supported on Node");for(var r=[],n=0;n<e.length;n++)r[n]=e.charCodeAt(n);var o=new Uint8Array(r);return new Blob([o],{type:t})},n.stripProtocol=et,n.unique=m,n.uniqueBy=function(e,r){return e.reduce(function(e,t){return f(e.find(function(e){return E(e,r)===E(t,r)})?null:t,e)},[])},n.unprotectModel=function(e,t){return e.item.protected?Ae(Object.assign({id:e.item.id},t)):Promise.resolve({success:!0})},n.unshareItemFromGroups=function(t,e,r,n){return Promise.all(e.map(function(e){e=Object.assign({},{id:t,groupId:e},r);return n&&(e.owner=n),Ve(e)}))},n.updateDomain=function(e,t){if(t.isPortal)throw new Error("updateDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Oo(t);r["Content-Type"]="application/json";var n=Do(t.hubApiUrl)+"/"+e.id;return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"PUT",headers:r,mode:"cors",body:JSON.stringify(e)}).then(Eo)},n.updateModel=en,n.updateProject=Rn,n.upgradeProtocol=function(e){return-1===e.indexOf("http")?"https://"+e:-1!==e.indexOf("http://")?e.replace(/^http:/i,"https:"):e},n.upgradeSiteSchema=Wo,n.uploadResourcesFromUrl=function(n,e,o){if(Array.isArray(e)){e=e.reduce(function(e,t){var r;return t.url&&(r={id:n.item.id,owner:n.item.owner,fileName:t.name,url:zn(t.url,o),authentication:o.authentication},"thumbnail"===t.type?e.push($n(r)):e.push(Jn(r))),e},[]);return Promise.all(e)}return Promise.resolve([])},n.valueToMatchOptions=ro,n.without=function(e,t){return e.filter(function(e){return e!==t})},n.withoutByProp=function(t,r,e){return e.filter(function(e){return e[t]!==r})},Object.defineProperty(n,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=common.umd.min.js.map
|