
/*************************************************************************
 * ADOBE CONFIDENTIAL
 * ___________________
 *
 * Copyright 2019 Adobe. All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains
 * the property of Adobe and its suppliers, if any. The intellectual
 * and technical concepts contained herein are proprietary to Adobe
 * and its suppliers and are protected by all applicable intellectual
 * property laws, including trade secret and copyright laws.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe.
 **************************************************************************/

(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{gokG:function(e,t,n){(function(t){
/************************************************************************!
 *
 * ADOBE CONFIDENTIAL
 * ___________________
 *
 * Copyright 2015-2019 Adobe Systems Incorporated
 * All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any. The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/
window,e.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=38)}([function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=n(26);function r(){this.uuid=n(28),window.nodeRequire&&(this.fs=window.nodeRequire("fs"),this.path=window.nodeRequire("path")),this._initDCX()}r.prototype._initDCX=function(){var e=this;this.dcx=new i(this.fs,{preserveFileExtensions:!0,logCallback:function(t){e._log&&e._log("DCX: "+t)}})},r.prototype.uuid=function(){return this.uuid()},r.prototype.log=function(e){this._log&&this._log("CC Libraries: "+e)},r.prototype.getDisplayName=function(e){return this._getDisplayName?this._getDisplayName(e):e.name},r.prototype.hasFileSystem=function(){return void 0!==this.fs},r.prototype.setFileSystem=function(e){this.fs=e,this._initDCX()},r.prototype.hasRenditionGenerator=function(){return void 0!==this.renditionGenerator},r.prototype.setRenditionGenerator=function(e){this.renditionGenerator=e},r.prototype.getVulcanInterface=function(){if("undefined"!==("undefined"==typeof VulcanInterface?"undefined":o(VulcanInterface)))return VulcanInterface},r.prototype.getVulcanMessage=function(){if("undefined"!==("undefined"==typeof VulcanMessage?"undefined":o(VulcanMessage)))return VulcanMessage},r.prototype.hasCEPVulcan=function(){return void 0!==this.getVulcanInterface()&&void 0!==this.getVulcanMessage()},r.prototype.getNodeTunnelOptions=function(e){return this._getNodeTunnelOptions?this._getNodeTunnelOptions(e):{}},r.prototype.getPathSeparator=function(){return"/"},r.prototype.getFileNameFromPath=function(e){return-1===e.indexOf("/")&&-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),e.split("/").pop()},Object.freeze(r),Object.seal(r.prototype),e.exports=new r},function(e,t,n){var o=n(2),i=["ROOT_DIR","POLL_INTERVAL","RENDITION_SIZES","FULL_RENDITION_CONFIG","EXTERNAL_LINK_PREFETCH","LOCALE","STORAGE_API_KEY","USER_AGENT_HEADER","SYNC_POLICY","ELEMENT_TYPE_FILTERS","AUTO_START_POLLING","SHARED_LOCAL_STORAGE","WHITELISTED_DOMAINS","CLIENT_DESCRIPTION","DEVICE_ID","DEVICE_DESCRIPTION","APP_DESCRIPTION","DEFAULT_RENDITION_404_BACKOFF","LOCAL_SETTINGS"];function r(){this.name="config"}r.prototype.VERSION=1,r.prototype.MAX_ELEMENTS=1e4,r.prototype.MAX_REMOVED_ELEMENTS=2e3,r.prototype.MAX_COMPONENT_SIZE=1073741824,r.prototype.VALID_RELATIONS=["rendition","primary","alternate"],r.prototype.VALID_LIBRARY_RENDITION_TYPES=["banner","cover"],r.prototype.VALID_SYNC_POLICIES=["manifestAndAssets","manifestOnly"],r.prototype.ELEMENT_TYPE_FILTERS=[],r.prototype.VECTOR_RENDITION_ELEMENT_TYPES=["application/illustrator"],r.prototype.DL_NAMESPACE="library",r.prototype.DL_PREFIX=r.prototype.DL_NAMESPACE+"#",r.prototype.VERSION_KEY=r.prototype.DL_PREFIX+"version",r.prototype.RELATIONSHIP_KEY=r.prototype.DL_PREFIX+"rel",r.prototype.WIDTH_KEY=r.prototype.DL_PREFIX+"width",r.prototype.HEIGHT_KEY=r.prototype.DL_PREFIX+"height",r.prototype.LENGTH_KEY=r.prototype.DL_PREFIX+"length",r.prototype.IS_FULL_SIZE_KEY=r.prototype.DL_PREFIX+"isFullSize",r.prototype.IS_PREFERRED_THUMBNAIL_KEY=r.prototype.DL_PREFIX+"isPreferredThumbnail",r.prototype.MODIFIED_KEY=r.prototype.DL_PREFIX+"modified",r.prototype.CREATED_KEY=r.prototype.DL_PREFIX+"created",r.prototype.REMOVED_KEY=r.prototype.DL_PREFIX+"removed",r.prototype.MODIFIED_DATA_KEY=r.prototype.DL_PREFIX+"modifiedData",r.prototype.CREATED_DATA_KEY=r.prototype.DL_PREFIX+"createdData",r.prototype.REMOVED_DATA_KEY=r.prototype.DL_PREFIX+"removedData",r.prototype.DESCRIPTION_KEY=r.prototype.DL_PREFIX+"description",r.prototype.DESCRIPTION_DATA_KEY=r.prototype.DL_PREFIX+"descriptionData",r.prototype.GROUPS_KEY=r.prototype.DL_PREFIX+"groups",r.prototype.ORDER_KEY=r.prototype.DL_PREFIX+"order",r.prototype.CLASSIFIER_KEY=r.prototype.DL_PREFIX+"classifier",r.prototype.SOURCE_REF_KEY=r.prototype.DL_PREFIX+"sourceRef",r.prototype.ANIMATION_ELEMENT_TYPE="application/vnd.adobe.element.animation+dcx",r.prototype.BRUSH_ELEMENT_TYPE="application/vnd.adobe.element.brush+dcx",r.prototype.COLOR_ELEMENT_TYPE="application/vnd.adobe.element.color+dcx",r.prototype.IMAGE_ELEMENT_TYPE="application/vnd.adobe.element.image+dcx",r.prototype.LAYER_STYLE_ELEMENT_TYPE="application/vnd.adobe.element.layerstyle+dcx",r.prototype.REPRESENTATION_CONTENT_VALUES={"application/vnd.adobe.color+json":{namespace:"color",key:"data"},"application/vnd.adobe.text+json":{namespace:"text",key:"data",contentFromData:!0}},r.prototype.LINK_TYPE_KEY=r.prototype.DL_PREFIX+"linktype",r.prototype.LINK_URL_KEY=r.prototype.DL_PREFIX+"linkurl",r.prototype.LINK_LOCAL_PATH_KEY=r.prototype.DL_PREFIX+"linklocalpath",r.prototype.REPRESENTATION_ORDER_KEY=r.prototype.DL_PREFIX+"representationOrder",r.prototype.RENDITION_TYPE_KEY=r.prototype.DL_PREFIX+"renditiontype",r.prototype.SHA_KEY=r.prototype.DL_PREFIX+"sha256",r.prototype.DEFAULT_GROUP_CLASSIFIER="$default",r.prototype.COMPOSITE_TYPE="application/vnd.adobe.library+dcx",r.prototype.LINK_REPRESENTATION_TYPE="application/vnd.adobe.library.link+dcx",r.prototype.GROUP_TYPE="application/vnd.adobe.library.group+dcx",r.prototype.ELEMENTS_NAME="elements",r.prototype.REMOVED_ELEMENTS_NAME="removed_elements",r.prototype.GROUPS_NAME="groups",r.prototype.DATA_COLLABORATION_ROLE="collaborationRole",r.prototype.FS_RETRY_INTERVAL=100,r.prototype.FS_MAX_RETRIES=10,r.prototype.MAX_DCX_CONCURRENT_COPIES=10,r.prototype.REMOVE_OPERATION_TIMEOUT=100,r.prototype.EXPORT_VERSION=1,r.prototype.EXPORT_EXTENSION=".cclibs",r.prototype.ANALYTICS_ENABLED=!1,r.prototype.ANALYTICS_ELEMENT_UPDATE_THRESHOLD=500,r.prototype.BOOKMARKS_FILENAME="bookmarks.json",r.prototype.BOOKMARKS_PATH="/bookmarks",r.prototype.BOOKMARKS_MONITOR_PATH="/sync/adobe-libraries/"+r.prototype.BOOKMARKS_FILENAME,r.prototype.PUBLIC_USER_ID="public",r.prototype.DEFAULT_CLOUD_ID="creative_cloud",r.prototype.DEFAULT_CORESYNC_CLOUD_ID="00000000-0000-0000-0000-000000000000",r.prototype.STORAGE_ASSETS_PATH="/assets/",r.prototype.LIBRARY_SYNC_GROUP="adobe-libraries",r.prototype.CP_CLOUD_ID="community-platform",r.prototype.CP_STORAGE_ASSETS_PATH="/content/2/",r.prototype.STORAGE_API_KEY="",r.prototype.USER_AGENT_HEADER=void 0,r.prototype.SYNCING_ENABLED=!0,r.prototype.VULCAN_QUERY_TIMEOUT=8e3,r.prototype.DEFAULT_MAX_SYNC_INTERVAL=1e4,r.prototype.RETRY_FAIL_MAX_SYNC_INTERVAL=6e4,r.prototype.MAX_SYNC_INTERVAL=r.prototype.DEFAULT_MAX_SYNC_INTERVAL,r.prototype.POLL_INTERVAL=1,r.prototype.AUTO_START_POLLING=!1,r.prototype.RENDITION_SIZES={},r.prototype.FULL_RENDITION_CONFIG={},r.prototype.BACKOFF_INTERVALS=[1,1,2,3,5,8,13,21,34,55],r.prototype.ERROR_RETRY_INTERVALS=[30,60,120],r.prototype.NETWORK_TIMEOUT=6e5,r.prototype.IMAGE_SERVICE_NETWORK_TIMEOUT=18e4,r.prototype.RETRY_RANDOM_SECONDS=30,r.prototype.RENDITION_MAX_RETRIES=2,r.prototype.DEFAULT_RENDITION_RETRY_INTERVAL=1e3,r.prototype.RENDITION_RETRY_INTERVAL=r.prototype.DEFAULT_RENDITION_RETRY_INTERVAL,r.prototype.DEFAULT_RENDITION_404_BACKOFF=3e5,r.prototype.RENDITION_404_BACKOFF=r.prototype.DEFAULT_RENDITION_404_BACKOFF,r.prototype.LOCAL_RENDITION_MAX_RETRIES=5,r.prototype.LOCAL_RENDITION_RETRY_INTERVAL=200,r.prototype.MAX_UPDATE_CONFLICTS=5,r.prototype.MAX_REDIRECT_FOLLOW=5,r.prototype.MAX_HEAD_REDIRECT_FOLLOW=0,r.prototype.ADOBE_AUTHENTICATED_DOMAINS=["stock.adobe.com","stock.stage.adobe.com","adobe.io","adobestock.com","fotolia.net"],r.prototype.WHITELISTED_DOMAINS=["cclibraries-defaults-cdn.adobe.com","cclibraries-defaults-cdn.stage.adobe.com"],r.prototype.DISALLOWED_DOMAINS={"cc-api-storage-stage.adobe.io":["stock.adobe.com"],"cc-api-storage.adobe.io":["stock.stage.adobe.com"]},r.prototype.SHA_CACHE={},r.prototype.DEFAULT_CONTENT_LOCATIONS=[],r.prototype.SYNC_POLICY="manifestAndAssets",r.prototype.REMOVED_ELEMENTS_CACHE_TIMEOUT=6e5,r.prototype.RENDITION_CACHE_FILE="cache.json",r.prototype.RENDITION_CACHE_PLACEHOLDER="<placeholder>",r.prototype.SHARED_LOCAL_STORAGE=!0,r.prototype.SHARED_LOCAL_STORAGE_VERSION=15,r.prototype.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION=6,r.prototype.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION=15,r.prototype.VULCAN_PREFIX="vulcan.SuiteMessage.",r.prototype.VULCAN_STARTUP_MESSAGE="cclibraries.service.Initialized",r.prototype.VULCAN_SHUTDOWN_REQUEST="cclibraries.service.TerminateServiceRequest",r.prototype.VULCAN_QUERY_REQUEST="cclibraries.service.QueryRequest",r.prototype.VULCAN_QUERY_RESPONSE="cclibraries.service.QueryResponse",r.prototype.VULCAN_LIBRARY_CHANGED_LOCAL_TYPE="cclibraries.service.LibraryChangedLocal",r.prototype.VULCAN_LIBRARY_CHANGED_REMOTE_TYPE="cclibraries.service.LibraryChangedRemote",r.prototype.VULCAN_LIBRARY_DELETED_TYPE="cclibraries.service.LibraryDeleted",r.prototype.VULCAN_COLLECTIONS_LOADED_TYPE="cclibraries.service.LibrariesLoaded",r.prototype.VULCAN_COLLECTIONS_UNLOADED_TYPE="cclibraries.service.LibrariesUnloaded",r.prototype.VULCAN_PROXY_QUERY_REQUEST="cclibraries.service.QueryProxySettingsRequest",r.prototype.VULCAN_PROXY_QUERY_RESPONSE="cclibraries.service.QueryProxySettingsResponse",r.prototype.VULCAN_PROXY_CHANGE_MESSAGE="cclibraries.service.ProxySettingsChanged",r.prototype.VULCAN_APP_READY_MESSAGE="cclibraries.accessor.AppReady",r.prototype.VULCAN_APP_SEND_ACTION_MESSAGE="cclibraries.accessor.EditElementRequest",r.prototype.VULCAN_APP_ACTION_ACCEPTED_MESSAGE="cclibraries.accessor.EditAcceptedMessage",r.prototype.LOCAL_SETTINGS={},r.prototype.ELEMENT_ACTIONS=["edit","openStock"],r.prototype.ELEMENT_ACTION_PRODUCT_MAP={types:{"application/vnd.adobe.element.image+dcx":{"application/illustrator":["ILST_EDIT","ILST_PLACE","IDSN_PLACE"],"image/svg+xml":["ILST_EDIT","ILST_PLACE"],"application/vnd.adobe.indesign-idms":["IDSN_EDIT","IDSN_PLACE"],"image/vnd.adobe.photoshop":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"application/photoshop":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"application/photoshop.large":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"image/png":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/jpeg":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/jpg":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE","ILST_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/gif":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/bmp":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/x-portable-bitmap":["PHXS_EDIT","PHXS_PLACE"],"image/x-pict":["PHXS_EDIT","PHXS_PLACE"],"image/x-pcx":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-graymap":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-anymap":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-pixmap":["PHXS_EDIT","PHXS_PLACE"],"image/x-tga":["PHXS_EDIT","PHXS_PLACE"],"image/tiff":["PHXS_EDIT","PHXS_PLACE"],"image/vnd.wap.wbmp":["PHXS_EDIT","PHXS_PLACE"]},"application/vnd.adobe.element.text+dcx":{"application/illustrator-text":["ILST_EDIT_TEXT"],"application/vnd.adobe.indesign-idms-text":["IDSN_EDIT_TEXT"]},"application/vnd.adobe.element.template+dcx":{"image/vnd.adobe.photoshop.template":["PHXS_PLACE"],"application/illustrator.template":["ILST_PLACE"],"application/vnd.adobe.indesign.template":["IDSN_PLACE"]},"application/vnd.adobe.element.3d+dcx":{"application/vnd.adobe.obj.3d+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.material+dcx":{"application/vnd.adobe.mdl.material+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.light+dcx":{"application/vnd.adobe.ibl.light+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.animation+dcx":{"application/vnd.adobe.animate-xfl+zip":["FLPR_EDIT"],"application/vnd.adobe.animate-sym+zip":["FLPR_EDIT"]}},products:{ILST_EDIT:{minVersion:"19.2",appCode:"ILST",appName:"Illustrator",action:"edit"},ILST_EDIT_TEXT:{minVersion:"22",appCode:"ILST",appName:"Illustrator",action:"edit"},IDSN_EDIT:{minVersion:"11.2",appCode:"IDSN",appName:"InDesign",action:"edit"},IDSN_EDIT_TEXT:{minVersion:"13",appCode:"IDSN",appName:"InDesign",action:"edit"},PHXS_EDIT:{minVersion:"16.1.2",appCode:"PHXS",appName:"Photoshop",action:"edit"},FLPR_EDIT:{minVersion:"16.1",appCode:"FLPR",appName:"Flash",action:"edit"},PHXS_PLACE:{minVersion:"17.0.0",appCode:"PHXS",appName:"Photoshop",action:"openStock"},ILST_PLACE:{minVersion:"20.0.0",appCode:"ILST",appName:"Illustrator",action:"openStock"},IDSN_PLACE:{minVersion:"11.4.0",appCode:"IDSN",appName:"InDesign",action:"openStock"},PPRO_PLACE:{minVersion:"10.3.0",appCode:"PPRO",appName:"Premiere Pro",action:"openStock"},AEFT_PLACE:{minVersion:"13.8.0",appCode:"AEFT",appName:"After Effects",action:"openStock"},ESHR_PLACE:{minVersion:"0.1",appCode:"ESHR",appName:"Project Felix",action:"openStock"}},installedApps:[]},r.prototype.STOCK_NAMESPACE="adobestock",r.prototype.STOCK_DATA_KEY="trackingdata",r.prototype.STOCK_STATE_PURCHASED="purchased",r.prototype.TOOLKIT_NAMESPACE="toolkit",r.prototype.TOOLKIT_ID_KEY="id",r.prototype.RELATIONSHIP_CHILD="child",r.prototype.TLS_DISCOVERY_PORT_RANGE=[45623,45625],r.prototype.TLS_DELAY_ON_DECLINE=500,r.prototype.TLS_DELAY_ON_READY=250,r.prototype.setParameter=function(e,t){if(-1===i.indexOf(e))throw new o(o.INVALID_PARAMETER,"Parameter not configurable");if("SYNC_POLICY"===e&&-1===this.VALID_SYNC_POLICIES.indexOf(t))throw new o(o.INVALID_PARAMETER,"Invalid value for SYNC_POLICY");"POLL_INTERVAL"===e&&(t=Math.max(1,t)),this[e]=t},Object.freeze(r),Object.seal(r.prototype),e.exports=new r},function(e,t){var n=["INVALID_PARAMETER","READ_ONLY","NOT_IMPLEMENTED","NOT_SUPPORTED","REQUIRES_FILESYSTEM","DELETED_LOCALLY"];function o(e,t,i,r){if(-1!==n.indexOf(e))if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,o);else{var a=new Error;a.name=this.name,this.stack=a.stack}this.code=e,this._message=t,this.message="["+e+"] "+t,this.libraryId=i,this.underlyingError=r}o.prototype=Object.create(Error.prototype),o.prototype.name="AdobeLibraryError",o.INVALID_PARAMETER="INVALID_PARAMETER",o.READ_ONLY="READ_ONLY",o.NOT_IMPLEMENTED="NOT_IMPLEMENTED",o.NOT_SUPPORTED="NOT_SUPPORTED",o.REQUIRES_FILESYSTEM="REQUIRES_FILESYSTEM",o.DELETED_LOCALLY="DELETED_LOCALLY",o.NOT_ALLOWED="NOT_ALLOWED",o.FILE_TOO_LARGE="FILE_TOO_LARGE",o.EXCEEDS_MAX_LIBRARY_SIZE="EXCEEDS_MAX_LIBRARY_SIZE",o.CORRUPTED_LIBRARY="CORRUPTED_LIBRARY",o.THUMBNAIL_NOT_AVAILABLE="THUMBNAIL_NOT_AVAILABLE",o.STALE_THUMBNAIL="STALE_THUMBNAIL",o.RENDITION_NOT_AVAILABLE="RENDITION_NOT_AVAILABLE",o.FS_ERROR="FS_ERROR",o.OUT_OF_SPACE="OUT_OF_SPACE",o.LOGGED_OUT="LOGGED_OUT",o.EXCEEDS_QUOTA="EXCEEDS_QUOTA",o.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",o.TRANSFER_ERROR="TRANSFER_ERROR",o.TRANSFER_ABORTED="TRANSFER_ABORTED",o.NETWORK_ERROR="NETWORK_ERROR",o.ACCESS_DENIED="ACCESS_DENIED",o.URL_VALIDATION_FAILED="URL_VALIDATION_FAILED",o.NO_COMPATIBLE_APP_FOUND="NO_COMPATIBLE_APP_FOUND",o.APP_LAUNCH_FAILED="APP_LAUNCH_FAILED",o.OPERATION_CANCELLED="OPERATION_CANCELLED",o.INVALID_DATA="INVALID_DATA",Object.freeze(o),Object.seal(o.prototype),e.exports=o},function(e,t){function n(e,t,o){if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,n);else{var i=new Error;i.name=this.name,this.stack=i.stack}this.code=e,this.message="["+e+"] "+t,this.underlyingError=o}n.prototype=Object.create(Error.prototype),n.prototype.name="AdobeDCXError",n.INVALID_JSON="INVALID_JSON",n.READ_ONLY="READ_ONLY",n.INVALID_PARAMS="",n.INVALID_DATA="INVALID_DATA",n.DUPLICATE_VALUE="DUPLICATE_VALUE",n.NO_LOCAL_STORAGE="NO_LOCAL_STORAGE",n.INVALID_STATE="INVALID_STATE",n.DELETED_COMPOSITE="DELETED_COMPOSITE",n.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",n.NETWORK_ERROR="NETWORK_ERROR",n.COMPONENT_DOWNLOAD_ERROR="COMPONENT_DOWNLOAD_ERROR",n.COMPONENT_UPLOAD_ERROR="COMPONENT_UPLOAD_ERROR",n.COMPONENT_MODIFIED_ERROR="COMPONENT_MODIFIED_ERROR",n.UPDATE_CONFLICT="UPDATE_CONFLICT",n.NO_COMPOSITE="NO_COMPOSITE",n.ALREADY_EXISTS="ALREADY_EXISTS",n.SERVICE_IS_INACTIVE="SERVICE_IS_INACTIVE",n.EXCEEDS_QUOTA="EXCEEDS_QUOTA",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",n.TIMED_OUT="TIMED_OUT",n.UNEXPECTED="UNEXPECTED",n.TERMINATED_INPUTSTREAM="TERMINATED_INPUTSTREAM",n.WRONG_ENDPOINT="WRONG_ENDPOINT",n.OUT_OF_SPACE="ENOSPC";var o={};o[n.SERVICE_IS_INACTIVE]=1,o[n.NOT_IMPLEMENTED]=1,o[n.EXCEEDS_QUOTA]=1,o[n.RETRYABLE_SERVER_ERROR]=1,o[n.TIMED_OUT]=1,o[n.TERMINATED_INPUTSTREAM]=1,o[n.WRONG_ENDPOINT]=1,o[n.OUT_OF_SPACE]=1,n.wrapError=function(e,t,i,r){if(!i||!o[i.code]){if(r){var a=r.statusCode;a>=500&&a<600&&(501===a?(e=n.NOT_IMPLEMENTED,t="Unimplemented request"):507===a?(e=n.EXCEEDS_QUOTA,t="Quota exceeded"):(e=n.RETRYABLE_SERVER_ERROR,t="Server error"))}i=new n(e,t,i)}return r&&(i.response=r),i},n.networkError=function(e,t,o){return n.wrapError(n.NETWORK_ERROR,e,t,o)},n.unexpectedResponse=function(e,t,o){return n.wrapError(n.UNEXPECTED_RESPONSE,e,t,o)},e.exports=n},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i,r;i=n(28);var a={_setLogCallback:function(e){r=e},merge:function(e){var t,n;for(t=1;t<arguments.length;++t){var i=arguments[t];if("object"===o(i))for(n in i)i.hasOwnProperty(n)&&(e[n]=i[n])}return e},parentDirectory:function(e){var t=e.split("/");return t.pop(),t.join("/")},filePathComponents:function(e){var t=e.split("/"),n=t.pop(),o=n.split("."),i=o.length>1?o.pop():null;return{directory:t.join("/"),fileName:n,baseName:o.join("."),extension:i}},appendPathElements:function(){var e,t=[],n=arguments.length;for(e=0;e<n;e++){var o=arguments[e];"string"==typeof o&&""!==o&&(0===e&&1!==o.length||"/"===o.charAt(0)&&(o=o.slice(1)),e!==n-1&&"/"===o.charAt(o.length-1)&&(o=o.slice(0,o.length-1)),t.push(o))}return t.join("/")}},s=/^[^\u0000-\u001F\u0022\u002A\u003A\u003C\u003E\u003F\u005C\u007F]*[^\u0000-\u001F\u0022\u002A\u002E\u003A\u003C\u003E\u003F\u005C\u007F]{1}$/;a.isValidPath=function(e,t){try{if(e.length>65535)return!1;var n=(t?e.slice(1):e).split("/");if(!n||0===n.length)return!1;var o,i=n.length;for(o=0;o<i;o++)if(n[o].length>255||!s.test(n[o]))return!1;if(t&&n.length>0){var r=n[0];if("manifest"===r||"mimetype"===r)return!1}return!0}catch(e){return!1}},a.isValidAbsolutePath=function(e){return a.isValidPath(e,!0)};var c=a.noOp=function(){};a.consumeStream=function(e,t,n){e.on("data",n||c),e.on("end",t||c)},a.flatCopy=function(e){var t,n={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++){var r=o[t];n[r]=e[r]}return n},a.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},a.objectsEqual=function(e,t,n){var i,r,s={},c=Object.keys(e),l=c.length;for(r=0;r<l;r++){if(i=c[r],!n||!n[i]){var p=e[i],d=t[i],h=o(p);if(h!==o(d))return!1;if("object"===h){if(!a.objectsEqual(p,d,n))return!1}else if(p!==d)return!1}s[i]=!0}for(l=(c=Object.keys(t)).length,r=0;r<l;r++)if(!s[i=c[r]])return!1;return!0};var l=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");a.parseURI=function(e){var t=e.match(l);return{scheme:t[2],authority:t[4],path:t[5],query:t[7],fragment:t[9]}},a.endPointOf=function(e){var t,n=a.parseURI(e),o=n.scheme,i=n.authority,r="https"===o?443:"http"===o?80:-1;return o&&i&&(t=(o+"://"+i).toLowerCase(),r>=0&&i.indexOf(":")<0&&(t=t+":"+r)),t},a.ensureRelativeHrefStartsWithSlash=function(e){if(e){var t=a.parseURI(e),n=t.scheme,o=t.authority;n||o||"/"!==e.charAt(0)&&(e="/"+e)}return e};var p=/^([^:]+):(.*)$/,d=/^\s+|\s+$/g;a.parseHeaders=function(e){var t,n,o,i={},r=e.split(/\r?\n/);for(t=0;t<r.length;++t){var a=r[t];if(a.length>0){var s=a.charCodeAt(0);if(!n||9!==s&&32!==s){var c=p.exec(a);c&&c.length>1&&(n=c[1].toLowerCase(),o=(o=c[2]||"").replace(d,""),i[n]?i[n]=i[n]+","+o:i[n]=o)}else i[n]=i[n]+" "+a.replace(d,"")}}return i},a.timeStamp=function(e){var t=(new Date).getTime();return e&&(t-=t%1e3),t},a.generateUuid=i,a.log=function(e){if("function"==typeof r)try{r(e)}catch(e){}},e.exports=a},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var r=n(0),a=n(8),s=n(6),c=n(1),l=n(2),p=["bmp","cur","gif","ico","jpeg","jpg","png","psd","tiff","tif","webp","svg","dds"],d={},h=function(e){return e+".TEMP_"+r.uuid()},u=function e(t){for(var n=r.fs,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];var l=a.find((function(e){return"function"==typeof e})),p=a.slice(0,a.indexOf(l)),d=a.indexOf(l)===a.length-1?0:a[a.length-1];n[t].apply(n,p.concat((function(n){if(n&&"EPERM"===n.code&&d<c.FS_MAX_RETRIES)setTimeout((function(){e.apply(void 0,[t].concat(i(p),[l,d+1]))}),c.FS_RETRY_INTERVAL);else{for(var o=arguments.length,r=new Array(o>1?o-1:0),a=1;a<o;a++)r[a-1]=arguments[a];l.apply(void 0,[n].concat(r))}})))};d.ensurePathExists=function(e,t){var n=r.getPathSeparator(),o=r.fs;!function e(t,i,r){var a=i.slice(0,t).join(n),s=function(){t<i.length?e(t+1,i,r):r(null)};o.exists(a,(function(e){e?s():o.mkdir(a,s)}))}(2,e.replace(/\\/g,n).split(n),t)},d.copyFile=function(e,t,n){var o=r.fs;try{var i=h(t),a=o.createWriteStream(i),s=o.createReadStream(e),c=!1;s.on("end",(function(){c||u("rename",i,t,n)})),s.on("error",(function(e){c=!0,n(e)})),s.pipe(a)}catch(e){n(e)}},d.getAvailablePath=function(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=t.lastIndexOf(".");i=-1===i?t.length:i;var r=t.substring(0,i),a=t.substring(i+1),s="".concat(o?" (".concat(o,")"):"").concat(a?".".concat(a):""),c=255-h("").length-s.length,l=r.substr(0,c);l[l.length-1].charCodeAt(0)>=55296&&l[l.length-1].charCodeAt(0)<=56319&&(l=l.substr(0,l.length-1));var p="".concat(e).concat(l).concat(s);d.statFile(p,(function(i){i&&i.underlyingError&&"ENOENT"===i.underlyingError.code?n(null,p):i?n(i):d.getAvailablePath(e,t,n,o+1)}))},d.rename=function(e,t,n){u("rename",e,t,n)},d.deleteFile=function(e,t){u("unlink",e,t)},d.normaliseTempFileName=function(e){return function(e){var t=e.match(/(.*)\.TEMP_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i);return t&&t[1]?t[1]:e}(e)},d.getFileExtension=function(e){var t=e&&e.replace(/^.*[\\/]/,""),n=t?t.lastIndexOf("."):-1;if(-1!==n)return t.substr(n+1).toLowerCase()},d.recursiveDeleteDirectory=function(e,t){var n=r.getPathSeparator(),o=r.fs,i=function(e){e&&"ENOENT"===e.code&&(e=null),t&&t(e)};u("readdir",e,(function(t,r){if(t)i(t);else if(r&&0!==r.length){var a=null,s=0;r.forEach((function(t){var i=e+n+t;u("readdir",i,(function(e){e?o.unlink(i,c):d.recursiveDeleteDirectory(i,c)}))}))}else o.rmdir(e,i);function c(t){t&&"ENOENT"===t.code&&(t=null),a=a||t,++s===r.length&&(a?i(a):o.rmdir(e,i))}}))},d.getUserDir=function(e){var t=r.getPathSeparator(),n=e.replace(/@/g,"_");return c.ROOT_DIR+t+n},d.moveLibrary=function(e,t,n){if(t!==e.id){var o=e._collection._getCompositeDir(t),i=e._getCompositeDir(),r=e._collection._getRenditionCacheDir(t),a=e._getRenditionCacheDir();d.rename(o,i,(function(t){t?n(t):(e._dcxComposite.path=i,d.rename(r,a,(function(e){return n(e&&"ENOENT"===e.code?null:e)})))}))}else n(null)},d.readLibraryDirectory=function(e,t){var n=e._getTempDir();d.recursiveDeleteDirectory(n,(function(){var n=e._getCompositeDir();u("readdir",n,t)}))},d.doesRootDirExist=function(e,t){var n=r.fs,o=e._getCompositeDir();n.exists(o,(function(e){t(null,e)}))},d.deleteLibraryFromDisk=function(e,t,n){var o=a.wrapCallback(n);if(r.hasFileSystem()){var i=e._getCompositeDir(t),s=e._getRenditionCacheDir(t);d.recursiveDeleteDirectory(i,(function(){d.recursiveDeleteDirectory(s,o)}))}else o(null)},d.writeJSONData=function(e,t,n){var o=r.fs;return new Promise((function(i,a){d.ensurePathExists(e,(function(s){if(s)a(s);else{var c=e+r.getPathSeparator()+t,l=c+".TEMP_"+r.uuid();o.writeFile(l,JSON.stringify(n,void 0,2),"utf8",(function(e){e?a(e):u("rename",l,c,(function(e){return e?a(e):i(c)}))}))}}))}))},d.readJSONData=function(e){var t=r.fs;return new Promise((function(n,i){t.readFile(e,"utf8",(function(e,t){if(e)"ENOENT"===e.code?n():i(e);else try{var r=t&&JSON.parse(t);n("object"===o(r)?r:void 0)}catch(e){i(e)}}))}))},d.statFile=function(e,t){r.fs.stat(e,(function(e,n){e?t(s.getFileSystemError(e,"unable to stat file")):t(null,n)}))},d.checkFileSize=function(e,t){d.statFile(e,(function(e,n){e?t(e):n&&n.size>c.MAX_COMPONENT_SIZE?t(new l(l.FILE_TOO_LARGE,"Exceeds maximum file size")):t(null)}))},d.computeSHA=function(e){var t=r.fs,n=r.crypto;return new Promise((function(o,i){var r=n.createHash("sha256");r.setEncoding("hex");var a=t.createReadStream(e);a.on("error",(function(e){return i(e)})),r.on("finish",(function(){return o(r.read())})),a.pipe(r)}))},d.getImageDimensions=function(e,t){var n=d.getFileExtension(e);!n||p.includes(n)?c.SHARED_LOCAL_STORAGE?r.storageInterface.getImageDimensions(e,t):r.imageSize(e,(function(e,n){t(n)})):t()},Object.seal(d),e.exports=d},function(e,t,n){var o=n(3),i=n(2),r={getErrorStatusCode:function(e){if(e)return e.code===o.UNEXPECTED_RESPONSE&&e.response&&e.response.statusCode||(e.underlyingError?r.getErrorStatusCode(e.underlyingError):void 0)},getSyncError:function(e,t,n){if(e){var a=r.getErrorStatusCode(e);return e.code===o.SERVICE_IS_INACTIVE?new i(i.LOGGED_OUT,"no access token: call updateAccessToken() and try again",t,e):e.code===o.NETWORK_ERROR?new i(i.NETWORK_ERROR,"error connecting to server",t,e):e.code===o.EXCEEDS_QUOTA?new i(i.EXCEEDS_QUOTA,"push failed due to insufficient remaining quota",t,e):e.code===o.OUT_OF_SPACE?new i(i.OUT_OF_SPACE,"not enough disk space",t,e):e.code===o.NOT_IMPLEMENTED?new i(i.NOT_IMPLEMENTED,"tried to call an API not implemented on the server",t,e):e.code===o.RETRYABLE_SERVER_ERROR?new i(i.RETRYABLE_SERVER_ERROR,"intermittent server failure - can retry later",t,e):e.code===o.INVALID_DATA||e.code===o.INVALID_JSON?new i(i.CORRUPTED_LIBRARY,"unable to read manifest",t,e):a&&n&&n[a]?new i(n[a],"server returned "+a+"response",t,e):new i(i.TRANSFER_ERROR,"something went wrong during a push/pull operation",t,e)}},getCommitError:function(e,t,n){if(e){var r=n?" - "+n:"";return e.code===o.INVALID_DATA||e.code===o.INVALID_JSON?new i(i.CORRUPTED_LIBRARY,"unable to read manifest"+r,t,e):e.code===o.OUT_OF_SPACE?new i(i.OUT_OF_SPACE,"not enough disk space"+r,t,e):new i(i.FS_ERROR,"filesystem error"+r,t,e)}},getFileSystemError:function(e,t,n){if(e)return"ENOSPC"===e.code?new i(i.OUT_OF_SPACE,t,n,e):new i(i.FS_ERROR,t,n,e)},getSnapshotError:function(e,t,n){if(e)return e.code===o.INVALID_DATA||e.code===o.INVALID_PARAMS?new i(i.INVALID_DATA,n,t,e):r.getFileSystemError(e,n,t)},getErrorPriority:function(e){var t=[i.OPERATION_CANCELLED,i.EXCEEDS_MAX_LIBRARY_SIZE,i.THUMBNAIL_NOT_AVAILABLE,i.RENDITION_NOT_AVAILABLE,i.URL_VALIDATION_FAILED,i.CORRUPTED_LIBRARY,i.TRANSFER_ABORTED,i.TRANSFER_ERROR,i.NETWORK_ERROR,i.EXCEEDS_QUOTA,i.RETRYABLE_SERVER_ERROR,i.LOGGED_OUT,i.FILE_TOO_LARGE,i.INVALID_DATA,i.FS_ERROR,i.OUT_OF_SPACE,i.ACCESS_DENIED,i.NOT_ALLOWED,i.DELETED_LOCALLY,i.REQUIRES_FILESYSTEM,i.NOT_SUPPORTED,i.NOT_IMPLEMENTED,i.INVALID_PARAMETER,i.READ_ONLY],n=e&&e.code&&t.indexOf(e.code);return void 0!==n?n:-1},errorToString:function(e){var t="";return e&&(e.message&&(t+=e.message),e.libraryId&&(t+=" library: "+e.libraryId),e.underlyingError?t+="\n<- "+r.errorToString(e.underlyingError):e.response&&e.response.statusCode&&(t+=": "+e.response.statusCode),e.failedComponents&&(t+="\n<- Failed Components:",e.failedComponents.forEach((function(e){var n=e.component&&e.component.id,o=e.error,i=o&&o.message,r=o&&o.response&&o.response.statusCode;t+="\n    ["+n+"] "+i+(r?": "+r:"")})))),t},isErrorCode:function(e){return!!e&&i.hasOwnProperty(e)&&i[e]===e}};Object.seal(r),e.exports=r},function(e,t,n){var o,i=n(4),r={canUseFileSystem:!1,_setFS:function(e){o=e,r.canUseFileSystem=!!e},ensureDirectoryExists:function(e,t){var n=function(e){e&&"EEXIST"===e.code?t():t(e)},a=function(a){if(a)t();else{var s=i.parentDirectory(e);s?r.ensureDirectoryExists(s,(function(i){i?t(i):o.mkdir(e,n)})):o.mkdir(e,n)}};e?o.exists(e,a):a(!0)},getTempFilePathAt:function(e,t){!function n(){var o=e+i.generateUuid();r.exists(o,(function(e){e?n():t(o)}))}()},exists:function(e,t){o.exists(e,t)},deleteFile:function(e,t){o.unlink(e,(function(e){e&&"ENOENT"!==e.code?t(e):t()}))},readFile:function(e,t,n){o.readFile(e,t,n)},writeFile:function(e,t,n,a){var s=i.parentDirectory(e);r.ensureDirectoryExists(s,(function(i){i?a(i):o.writeFile(e,t,n,a)}))},writeFileAtomically:function(e,t,n,a){var s=i.parentDirectory(e);r.ensureDirectoryExists(s,(function(i){i?a(i):r.getTempFilePathAt(s+"/",(function(i){o.writeFile(i,t,n,(function(t){t?a(t):o.rename(i,e,a)}))}))}))},createWriteStream:function(e,t){return o.createWriteStream(e,t)},createReadStream:function(e,t){return o.createReadStream(e,t)},move:function(e,t,n,a){var s=i.parentDirectory(t);r.ensureDirectoryExists(s,(function(i){if(i)a(i);else if(n){var r=(new Date).getTime()/1e3;o.utimes(e,r,r,(function(n){n?a(n):o.rename(e,t,a)}))}else o.rename(e,t,a)}))},info:function(e,t){o.stat(e,t)},directoryListing:function(e,t){var n,i,r=[],a=function(a){o.stat(e+"/"+a,(function(e,o){if(!e)try{r.push({name:a,info:o}),n--}catch(t){e=t}e?i||(i=e,t(e)):0===n&&t(void 0,r)}))};o.readdir(e,(function(e,o){if(!e)try{var i,r=o.length;for(n=r,i=0;i<r;i++)a(o[i])}catch(t){e=t}e?t(e):0===n&&t(void 0,[])}))},deleteDirectory:function(e,t){var n,i,a=function(){try{o.rmdir(e,t)}catch(e){t(e)}},s=function(e){e&&!n&&(n=e),--i<1&&(n?t(n):a())},c=function(t){var n=e+"/"+t;o.unlink(n,(function(e){try{e?r.deleteDirectory(n,(function(e){s(e)})):s()}catch(e){s(e)}}))};o.readdir(e,(function(e,n){if(!e)try{var o,r=n.length;if(r<1)a();else for(i=r,o=0;o<r;o++)c(n[o])}catch(t){e=t}e&&t(e)}))},copyFile:function(e,t,n){var a=i.parentDirectory(t);r.ensureDirectoryExists(a,(function(r){r?n(r):function(e,t,n){try{var r=t+i.generateUuid(),a=o.createWriteStream(r),s=o.createReadStream(e);s.on("end",(function(){o.rename(r,t,n)})),s.on("error",(function(e){n(e)})),s.pipe(a)}catch(e){n(e)}}(e,t,n)}))},getMD5Hash:function(e,t){var n=(void 0).createHash("md5").setEncoding("base64");try{var i=o.createReadStream(e);i.pipe(n).on("finish",(function(){return t(null,n.read())})),i.on("error",(function(e){return t(e)}))}catch(e){t(e)}}};e.exports=r},function(e,t){var n={wrapCallback:function(e){return function(){e&&e.apply(this,arguments)}},constructStringFromTemplate:function(e,t){var n=e;return Object.keys(t).forEach((function(e){n=n.replace("{{"+e+"}}",t[e])})),n},parseLocalisationFile:function(e){var t,n,o,i,r={},a=0,s=e.split(/\n/);for(a=0;a<s.length;a++)if(s[a]=s[a].replace(/^\s\s*/,"").replace(/\s\s*$/,""),s[a].length>0&&"#"!==s[a].match("^#")){for(n=(t=s[a].split("="))[0].replace(/^\s\s*/,"").replace(/\s\s*$/,""),o=1===t.length?"":t[1];o.match(/\\$/)&&"\\"===o.match(/\\$/).toString();)o=o.substring(0,o.length-1),o+=s[++a].replace(/\s\s*$/,"");for(i=2;i<t.length;i++)o+="="+t[i];o=o.replace(/^\s\s*/,"").replace(/\s\s*$/,""),r[n]=o}return r},compareVersions:function(e,t){if(e=(e||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),t=(t||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),(isNaN(parseInt(e,10))||parseInt(e,10)>250)&&(e="0"),(isNaN(parseInt(t,10))||parseInt(t,10)>250)&&(t="0"),e===t)return 0;var n,o,i=e.split("."),r=t.split(".");for(n=0;n<i.length&&n<r.length;n++){if(o=parseInt(i[n],10)-parseInt(r[n],10),isNaN(o))return isNaN(parseInt(i[n],10))?1:-1;if(o>0)return-1;if(o<0)return 1}return(o=i.length-r.length)>0?-1:o<0?1:0}};Object.seal(n),e.exports=n},function(e,t,n){var o=n(0),i=n(2);function r(e){this._restrictedTypes=e,this._listeners={}}r.prototype._checkType=function(e){if(this._restrictedTypes&&-1===this._restrictedTypes.indexOf(e)){var t="["+this._restrictedTypes.join(", ")+"]";throw new i(i.INVALID_PARAMETER,e+" is not allowed. Should be one of: "+t)}},r.prototype.add=function(e,t){this._checkType(e),this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t)},r.prototype.remove=function(e,t){this._checkType(e);var n=this._listeners[e];if(n){var o=n.indexOf(t);-1!==o&&n.splice(o,1)}},r.prototype.removeAll=function(e){e?(this._checkType(e),delete this._listeners[e]):this._listeners={}},r.prototype.notify=function(e,t){this._checkType(e);var n=this._listeners[e];n&&n.slice(0).forEach((function(e){try{e.apply(void 0,t||[])}catch(e){o.log("Error in listener callback: "+(e?e.toString():"")),e&&e.stack&&o.log(e.stack)}}))},r.prototype.hasListeners=function(e){this._checkType(e);var t=this._listeners[e];return!!(t&&t.length>0)},r.prototype.forEach=function(e){var t=this._listeners;Object.keys(t).forEach((function(n){t[n].forEach((function(t){e(n,t)}))}))},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(26),i=n(3),r=n(1),a=n(0),s=n(18),c=n(2),l=n(11),p=n(12),d={},h={};d.isCompatibleType=function(e,t){return e===t||e===h[t]},d.validateLibraryId=function(e,t){if(t){if(e&&e.length>=30&&e.match(/^[0-9A-Z-]+$/i))return!0}else if(e&&e.match(/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i))return!0;return!1},d.validateLibrary=function(e){return(e.current&&e.current.rootNode.getValue(r.VERSION_KEY))===r.VERSION},d.areManifestsEqual=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;var n=JSON.parse(e),o=JSON.parse(t);delete n["manifest-format-version"],delete o["manifest-format-version"];try{if(JSON.stringify(n)===JSON.stringify(o))return!0}catch(e){}return!1},d.getDCXKey=function(e,t){if(!e||!("string"==typeof e||e instanceof String)||""===e)throw new c(c.INVALID_PARAMETER,"Invalid namespace");if(!t||!("string"==typeof t||t instanceof String)||""===t)throw new c(c.INVALID_PARAMETER,"Invalid key");return e+"#"+t},d.getCustomDCXData=function(e){var t=[];return e.getCustomKeys().forEach((function(n){var o=n.split("#"),i=o.length>=2;i&&o.forEach((function(e){""===e&&(i=!1)}));var a=0===n.indexOf(r.DL_PREFIX);i&&!a&&t.push({namespace:o.shift(),key:o.join("#"),value:e.getValue(n)})})),t},d.copyCustomDCXData=function(e,t){d.getCustomDCXData(e).forEach((function(e){t.setValue(d.getDCXKey(e.namespace,e.key),e.value)})),[r.REPRESENTATION_ORDER_KEY,r.IS_PREFERRED_THUMBNAIL_KEY,r.SHA_KEY].forEach((function(n){var o=e.getValue(n);o&&t.setValue(n,o)}))},d.checkDeletedState=function(e,t){if(e.isDeletedLocally){if(t)return t(new c(c.DELETED_LOCALLY,"deleted/orphan object")),!0;throw new c(c.DELETED_LOCALLY,"deleted/orphan object")}return!1},d.checkEncoding=function(e,t,n){if(-1===t.indexOf(e)){var o=t.join(", ");return n(new c(c.INVALID_PARAMETER,"Unsupported encoding. Supported encodings are: "+o)),!1}return!0},d.sortRepresentations=function(e){if(!(e.length<2))for(var t=!0;t;){t=!1;for(var n=1;n<e.length;n++){var o=e[n-1],i=e[n];i._getOrder()<o._getOrder()&&(e[n-1]=i,e[n]=o,t=!0)}}},d.removeMissingComponents=function(e,t){if(e&&t){var n=0,o=0;return t.forEach((function(t){var i=t.component,r=t.error;i&&r&&r.response&&404===r.response.statusCode&&(e.removeComponent(i),n++,a.log("Removed missing component: "+i.id+" from library "+e.compositeId)),i&&r&&"[UNEXPECTED_RESPONSE] Incorrect content length"===r.message&&(o++,a.log("Skipped length-mismatch component: "+i.id+" from library "+e.compositeId))})),a.log("Fixed "+n+" of "+t.length+" components that failed to download"),l.reportRemoveMissingComponents(e.compositeId,t,n),t.length===n+o?e:void 0}},d.removeMissingLocalComponents=function(e,t){if(e&&t){var n=0,o=[];t.forEach((function(t){var r=t.component,s=t.error;if(r&&s&&s.code===i.INVALID_STATE){var c=function(e,t){var n;return e.elements.some((function(e){return e.representations.some((function(e){if(e.id===t)return n=e,!0}))})),n}(e,r.id);c?o.push(c):e._dcxBranch.removeComponent(r),n++,a.log("Removed missing local component: "+r.id+" from library "+e.id)}})),n>0&&(e._beginOperation(),o.forEach((function(e){e.element.removeRepresentation(e)})),e._endOperation()),a.log("Fixed "+n+" of "+t.length+" components that failed to upload")}},d.recoverReadOnlyEdits=function(e,t,n){var o=[];e.elements.forEach((function(e){var n=t&&t.getChildWithId(e.id);(n&&n.getValue(r.MODIFIED_KEY))!==e.modified&&o.push(e)}));var i=new p;if(o.length>0){var c,l=s.translate("LIBS_RECOVERED_LIBRARY",{name:e.name});e.collection.libraries.some((function(e){if(e.name===l&&e.isWritable&&"incoming"!==e.collaboration&&e.elements.length<r.MAX_ELEMENTS)return c=e,!0})),c||(c=e.collection.createLibrary(l)),o.forEach((function(t){i.addOperation(e.copyElement,[t,c],e)})),a.log("Recovering "+o.length+" elements from read-only library")}i.run(n)},d.ensureBranchDataValid=function(e){var t=[r.ELEMENTS_NAME,r.REMOVED_ELEMENTS_NAME],n=!1;return e.getChildrenOf().forEach((function(o){if(-1!==t.indexOf(o.name)){var i=o.name===r.REMOVED_ELEMENTS_NAME;e.getChildrenOf(o).forEach((function(e){var t=e.getValue(r.REMOVED_KEY);!i&&t?(e.removeValue(r.REMOVED_KEY),n=!0):i&&!t&&(e.setValue(r.REMOVED_KEY,(new Date).valueOf()),n=!0)}))}})),n},d.collaborationStateToDCX=function(e){return"incoming"===e?o.COLLABORATION.SHARED_WITH_USER:"outgoing"===e?o.COLLABORATION.SHARED_BY_USER:o.COLLABORATION.PRIVATE},d.collaborationStateFromDCX=function(e){return e===o.COLLABORATION.SHARED_WITH_USER?"incoming":e===o.COLLABORATION.SHARED_BY_USER?"outgoing":void 0},d.getCompositeRenditionMap=function(e){var t=e.getComponentsOf(),n={};return t&&t.forEach((function(e){if("rendition"===e.relationship){var t=e.getValue(r.RENDITION_TYPE_KEY);t&&(n[t]=e)}})),n},Object.seal(d),e.exports=d},function(e,t,n){var o,i,r=n(0),a=n(1);function s(e){if(!e)return{};var t={libraryID:e.id,libraryElementCount:e._elements.length,libraryGroupCount:e._groups?e._groups.length:0};return e.collection.isPublic?t.libraryShared="incoming-public":e.collaboration&&(t.libraryShared=e.collaboration,e.isWritable||(t.libraryShared+="-readonly")),t}function c(e){if(!e)return{};var t=s(e._library);t.elementID=e.id,t.elementType=function(e){if(e.type){var t=e.type.match(/application\/vnd\.adobe\.element\.(.*)\+dcx/);return t&&2===t.length?t[1]:e.type}return null}(e),t.elementGroupIDs=e.getGroups(/.*/).map((function(e){return e.id}));var n=e.getPrimaryRepresentation();if(n){var o=function(e){var t=null;return e.getValues().forEach((function(e){"trackingdata"===e.key&&(t||(t={}),t[e.namespace]=e.value)})),t}(n);o&&(t.trackingData=JSON.stringify(o)),t.elementPrimaryType=n.type}return t}function l(e,t){if(!e)return{};var n=t?{}:s(e._library);return n.groupID=e.id,n.groupClassifierName=e.classifierName,n}function p(e){if(!e)return{};var t=c(e.element);return t.appCode=e.appCode,t.elementAction=e.id,t}function d(){return null!==r.analytics&&void 0!==r.analytics}var h={reportError:function(e){d()&&e&&r.analytics.reportError(e.code+(e.underlyingError?":"+e.underlyingError.code:""))},reportCreateLibrary:function(e){d()&&r.analytics.reportEvent("createLibrary",{libraryID:e.id})},reportDeleteLibrary:function(e){d()&&r.analytics.reportEvent("deleteLibrary",s(e))},reportExportLibrary:function(e,t){if(d()){var n=t?s(t):{};e&&(n.error=e.code),r.analytics.reportEvent("exportLibrary",n)}},reportImportLibrary:function(e,t){if(d()){var n=t?s(t):{};e&&(n.error=e.code),r.analytics.reportEvent("importLibrary",n)}},reportCreateElement:function(e){d()&&(o=e,i=Date.now(),r.analytics.reportEvent("createElement",c(e)))},reportUpdateElement:function(e,t){if(d()){if(e===o&&Date.now()-i<a.ANALYTICS_ELEMENT_UPDATE_THRESHOLD)return;o=e,i=Date.now();var n=c(e);n.updateType=t?"info":"representation",r.analytics.reportEvent("updateElement",n)}},_reportUpdateElementMetadata:function(e,t,n){if(d()){var o=c(e);o.updateType=t,n&&Object.assign(o,n),r.analytics.reportEvent("updateElementMetadata",o)}},reportSetOrderInGroup:function(e,t,n){var o=l(t,!0);o.elementOrderInGroup=e.getOrderInGroup(t),o.removeExistingGroups=n,this._reportUpdateElementMetadata(e,"order",o)},reportSetDescription:function(e){this._reportUpdateElementMetadata(e,"description")},reportUseElement:function(e,t,n){if(d()){var o=function(e){if(!e)return{};var t=c(e._element);return t.representationType=e.type,t}(e);o.opType=t,o.details=n,r.analytics.reportEvent("useElement",o)}},reportCheckoutElement:function(e,t,n){if(d()){var o=c(e);o.opType=t,o.details=n,r.analytics.reportEvent("checkoutElement",o)}},reportDeleteElement:function(e,t){if(d()){var n=c(e);n.isPermanent=!!t,r.analytics.reportEvent("deleteElement",n)}},reportRestoreElement:function(e){d()&&r.analytics.reportEvent("restoreElement",c(e))},reportCopyElement:function(e,t){if(d()){o=e,i=Date.now();var n=c(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,r.analytics.reportEvent("copyElement",n)}},reportMoveElement:function(e,t){if(d()){o=e,i=Date.now();var n=c(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,r.analytics.reportEvent("moveElement",n)}},reportCreateGroup:function(e){d()&&r.analytics.reportEvent("createGroup",l(e))},reportUpdateGroup:function(e){if(d()){var t=l(e);t.updateType="name",r.analytics.reportEvent("updateGroup",t)}},reportUpdateGroupMetadata:function(e,t){if(d()){var n=l(e);n.updateType="order",n.groupOrder=t,r.analytics.reportEvent("updateGroupMetadata",n)}},reportDeleteGroup:function(e,t,n){if(d()){var o=l(e);o.includeContents=t,t&&(o.numberElementsInGroup=n),r.analytics.reportEvent("deleteGroup",o)}},reportCopyGroup:function(e,t,n,o){if(d()){var i=l(e);i.oldLibraryID=t._library.id,i.oldGroupID=t.id,i.includeContents=n,n&&(i.numberElementsInGroup=o),r.analytics.reportEvent("copyGroup",i)}},reportMoveGroup:function(e,t,n,o){if(d()){var i=l(e);i.oldLibraryID=t._library.id,i.oldGroupID=t.id,i.includeContents=n,n&&(i.numberElementsInGroup=o),r.analytics.reportEvent("moveGroup",i)}},reportCollisionElement:function(e){d()&&r.analytics.reportEvent("collisionLibrary",c(e))},reportCreateLink:function(e,t){if(d()){var n=c(e);n.opType=t,r.analytics.reportEvent("createLink",n)}},reportShareElementLink:function(e){d()&&r.analytics.reportEvent("shareElementLink",c(e))},reportShareLibraryLink:function(e){d()&&r.analytics.reportEvent("shareLibraryLink",s(e))},reportElementActionInvoked:function(e){d()&&r.analytics.reportEvent("elementActionInvoked",p(e))},reportElementActionSuccessful:function(e,t){if(d()){var n=p(e);n.appVersion=t&&t.version,n.appLaunchStatus=t?t.isAlreadyRunning?"Running":"Launched":"Unknown",r.analytics.reportEvent("elementActionSuccessful",n)}},reportElementActionFailed:function(e,t){if(d()){var n=p(e);n.error=t?t.code+":"+t.message:"",r.analytics.reportEvent("elementActionFailed",n)}},reportUnexpectedState:function(e,t){if(d()){var n=s(e);n.details=t,r.analytics.reportEvent("unexpectedState",n)}},reportRemoveMissingComponents:function(e,t,n){if(d()){var o={libraryID:e,numMissing:t.length,numFixed:n,componentErrors:[]};t.forEach((function(e){var t=e.error,n=t&&t.code,i=t&&t.response&&t.response.statusCode,r=(n||"UNKNOWN_ERROR")+(i?": "+i:"");o.componentErrors.push(r)})),r.analytics.reportEvent("removeMissingComponents",o)}}};Object.seal(h),e.exports=h},function(e,t,n){var o=n(2);function i(){this._operations=[],this._isRunning=!1}i.prototype.addOperation=function(e,t,n){if(this._isRunning)throw new o(o.INVALID_PARAMETER,"Cannot add operations after calling run()");this._operations.push({operation:e,argsArray:t||[],thisObject:n})},i.prototype.run=function(e,t){function n(t,n,o){e&&e(t,n,o)}if(this._isRunning)throw new o(o.INVALID_PARAMETER,"Cannot call run() more than once");this._isRunning=!0;var i=this._operations.length;0===i&&n(null,!1,[]);var r,a=0,s=!1,c=[],l=[];this._operations.forEach((function(e,p){e.argsArray.push((function(e,d){!function(e,p,d){if(e&&t&&t(e),!s){if(r=r||e,c[d])return s=!0,void n(new o(o.INVALID_PARAMETER,"Operation not valid: calls callback multiple times"));if(a++,l[d]=p,c[d]=!0,a===i){s=!0;var h=!!l.reduce((function(e,t){return e||t}),!1);n(r||null,h,l)}}}(e,d,p)})),e.operation.apply(e.thisObject,e.argsArray)}))},Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o=n(3),i=n(17),r=n(29),a=n(44),s=n(20).STATES,c=n(7),l=n(4),p={PRIVATE:void 0,SHARED_BY_USER:"sharedByUser",SHARED_WITH_USER:"sharedWithUser"};function d(e,t,n,o,r,a){r=l.ensureRelativeHrefStartsWithSlash(r),this._options=a||{},n?this._setPath(n):r?(this._href=r,e&&(this._name=e),t&&(this._type=t),o&&(this._id=o)):t&&(this._current=new i,e&&(this._current._data.name=e),this._current._data.type=t,o&&(this._current.compositeId=o)),this._autoRemoveUnusedLocalFiles=!0,this._options.xhrBaseBranchSupport&&(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0),this._collaborationType=p.PRIVATE}d.newCompositeAsCopyOf=function(e,t,n,r,a,s,c){var p=e._core;if(p||e.current&&(p=e.current._core),!p)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var h=new d(void 0,void 0,void 0,void 0,void 0,c);return r&&(h.path=r),h._current=i._newBranchAsCopyOfCore(p,this._localStorage),h.id=a||l.generateUuid(),t&&(h.name=t),n&&(h.type=n),s&&(h.href=s),h},d.COLLABORATION=p,Object.defineProperties(d.prototype,{id:{get:function(){return this._current?this._current.compositeId:this._id},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.compositeId=e),this._id=e}},name:{get:function(){return this._current?this._current.name:this._name},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.name=e),this._name=e}},type:{get:function(){return this._current?this._current.type:this._type},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.type=e),this._type=e}},href:{get:function(){return this._current?this._current.compositeHref:this._href},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");e=l.ensureRelativeHrefStartsWithSlash(e),this._current&&(this._current.compositeHref=e),this._href=e}},collaborationType:{get:function(){return this._current?this._current._collaborationType:this._collaborationType},set:function(e){if(e!==p.PRIVATE&&e!==p.SHARED_BY_USER&&e!==p.SHARED_WITH_USER)throw new o(o.INVALID_PARAMS,"Invalid value: ."+e);this._current&&(this._current._collaborationType=e),this._collaborationType=e}},clientDataString:{get:function(){return this._current?this._current._clientDataString:this._clientDataString},set:function(e){if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: must be a string or undefined.");var t=this._options.maxClientDataLength||1024;if(e&&e.length>t)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: cannot be greater than 1KB");this._current&&(this._current._clientDataString=e),this._clientDataString=e}},path:{get:function(){return this._path},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._setPath(e)}},isBound:{get:function(){return this._current&&this._current.isBound||!this._current&&this._href},set:function(){throw new o(o.READ_ONLY,"Cannot set the property isBound. Use resetIdentity or resetBinding instead.")}},hasLocalStorage:{get:function(){return this._localStorage},set:function(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},autoRemoveUnusedLocalFiles:{get:function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._autoRemoveUnusedLocalFiles},set:function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._autoRemoveUnusedLocalFiles=e}},clientDataStoragePath:{get:function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.clientDataPath()},set:function(){throw new o(o.READ_ONLY,'Property "clientDataStoragePath" is read-only.')}},current:{get:function(){return this._current},set:function(){throw new o(o.READ_ONLY,'Property "current" is read-only.')}}}),d.prototype.loadCurrentFromLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._loadBranch(this._localStorage.currentManifestPath(),!1,(function(n,o){if(!n&&o)try{t._current=o,t._currentBranchCommittedAtDate=l.timeStamp(!0)}catch(e){n=e}e(n,n?void 0:o)}))},d.prototype.commitChanges=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._current)return e(new o(o.INVALID_STATE,"Current branch is not in memory."));var t=this;c.writeFileAtomically(this._localStorage.currentManifestPath(),this._current.localData,"utf8",(function(n){if(!n)try{t._currentBranchCommittedAtDate=l.timeStamp(!0),t._current._isDirty=!1}catch(e){n=e}e(n)}))},d.prototype.tempAssetPath=function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.tempPathForComponent()},d.prototype.deleteTempFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.deleteTempFiles((function(t){e&&e(t)}))},d.prototype.removeUnusedLocalFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.removeUnusedLocalFiles(this._currentBranchCommittedAtDate,e)},d.prototype.removeLocalFilesForComponentsWithIDs=function(e,t){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,"Param componentIds must not be nil.");var n=this,i=this._current;n._loadBranch(n._localStorage.currentManifestPath(),!0,(function(r,a){r&&"ENOENT"!==r.code?t([r]):n.loadBaseBranch((function(r,l){if(r&&"ENOENT"!==r.code)t([r]);else{var p,d,h=[],u={};for(p=0;p<e.length;++p){var _=e[p],f=i.getComponentWithId(_),m=a?a.getComponentWithId(_):void 0,y=l?l.getComponentWithId(_):void 0;if(!(f&&"/META-INF/metadata.xml"===f.absolutePath||m&&"/META-INF/metadata.xml"===m.absolutePath||y&&"/META-INF/metadata.xml"===y.absolutePath))if(f&&f.state===s.modified||m&&m.state===s.modified){var E=new o(o.COMPONENT_MODIFIED_ERROR,"Cannot remove the file of a modified component.");E.componentId=_,h.push(E)}else f&&(d=i.assetOfComponent(f))&&(void 0===u[d]&&(u[d]=_),n._localStorage.removeComponentAsset(f,i._local()),i._setDirty(!0)),m&&(d=a.assetOfComponent(m))&&void 0===u[d]&&(u[d]=_),y&&(d=l.assetOfComponent(y))&&void 0===u[d]&&(u[d]=_)}var g=Object.keys(u),v=g.length;if(v>0){var A=function(e){c.deleteFile(e,(function(n){n&&(n.componentId=u[e],h.push(n)),0==--v&&t(h.length>0?h:void 0)}))};for(p=0;p<g.length;++p)A(g[p])}else t(h.length>0?h:void 0)}}))}))},d.prototype.removeLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._path)return e(new o(o.INVALID_STATE,"No path set."));c.deleteDirectory(this._path,e)},d.prototype.loadBaseBranch=function(e){if(!this._localStorage&&!this._baseBranchData)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(this._localStorage)this._loadBranch(this._localStorage.currentBaseManifestPath(),!0,e);else{var t,n;try{n=new i(void 0,!0).parse(this._baseBranchData)}catch(e){t=e}e(t,n)}},d.prototype.loadPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pulledManifestPath(),!1,e)},d.prototype.loadPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pushedManifestPath(),!1,e)},d.prototype.resolvePullWithBranch=function(e,t){if(!e)throw new o(o.INVALID_PARAMS,"Need a branch.");if(e===this._current)throw new o(o.INVALID_PARAMS,"Cannot resolve current.");if(this._localStorage&&!t)throw new o(o.INVALID_PARAMS,"Need a callback function.");var n=this,i=function(){e.readOnly=!1,e._collaborationType=n.collaborationType,e._clientDataString=n.clientDataString,n._current=e};if(this._localStorage)n._localStorage.resolvePulledBranch(e,(function(e){if(!e)try{i(),n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,(function(){}))}catch(t){e=t}t(e,e?void 0:n._current)}));else{if(this._options.xhrBaseBranchSupport&&(this._baseBranchData=this._pulledBranchData,this._pulledBranchData=void 0),i(),!t)return this._current;t(void 0,this._current)}},d.prototype.acceptPush=function(e){if(this._localStorage&&!e)throw new o(o.INVALID_PARAMS,"Need a callback function.");var t,n,i=this,a=function(o){if(!o)if(t)try{i._localStorage?(t.applyToBranch(n),i._localStorage.acceptPushedBranch(n,(function(n){if(!n)try{t.applyToBranch(i._current,!0),i._autoRemoveUnusedLocalFiles&&i._localStorage.removeUnusedLocalFiles(i._currentBranchCommittedAtDate,(function(){}))}catch(e){n=e}e(n)}))):(t.applyToBranch(i._current,!0),i._options.xhrBaseBranchSupport&&(i._baseBranchData=i._pushedBranchData,i._pushedBranchData=void 0),i._pushJournal=void 0,e&&e())}catch(e){o=e}else e&&e();if(o){if(!e)throw o;e(o)}};if(!this._localStorage)return t=this._pushJournal,a();var s,c=2;r.readJournal(i._localStorage.pushJournalPath(),i,!1,(function(e,n){c--,s?a():(e?"ENOENT"!==e.code&&(s=new o(o.INVALID_STATE,"Failed to load push journal.",e)):t=n,c||a())})),this._loadBranch(this._localStorage.currentManifestPath(),!1,(function(e,t){c--,s?a():(e?s=new o(o.INVALID_STATE,"Failed to load current manifest.",e):n=t,c||a())}))},d.prototype.discardPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPulledBranch((function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,(function(){}))}catch(e){n=e}e(n)}n&&e(n)}))},d.prototype.discardPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPushedBranch((function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,(function(){}))}catch(e){n=e}e(n)}n&&e(n)}))},d.prototype.resetBinding=function(e){delete this._href,this._current&&this._current._resetBinding(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e())},d.prototype.resetIdentity=function(e){delete this._href,this._current?(this._current._resetIdentity(),this._id=this._current.compositeId):this._id=l.generateUuid(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e())},d.prototype._loadBranch=function(e,t,n){if("function"!=typeof n)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');var r=this;c.exists(e,(function(o){o?c.readFile(e,"utf8",(function(o,a){var s;if(!o)try{(s=new i(void 0,t,e).parse(a))._localStorage=r._localStorage}catch(e){o=e}n(o,s)})):n()}))},d.prototype._discardEveryBranchButCurrent=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t,n=this,i=3,r=function(o){o&&!t&&(t=o),0==--i&&(!t&&n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,(function(){})),e(t))};this._localStorage.discardPushedBranch(r),this._localStorage.discardPulledBranch(r),this._localStorage.discardBaseBranch(r)},d.prototype._setPath=function(e){this._localStorage?this._localStorage.compositePath=e:c.canUseFileSystem&&(this._localStorage=new a(e,this._options.preserveFileExtensions),this._current&&(this._current._localStorage=this._localStorage)),this._path=e},e.exports=d},function(e,t){function n(){this._isLocked=!1,this._pendingContinuations=[]}n.prototype.obtain=function(e,t){this._isLocked?this._pendingContinuations.push({continuation:e,thisObject:t}):(this._isLocked=!0,e.apply(t,[null]))},n.prototype.release=function(){if(this._pendingContinuations.length>0){var e=this._pendingContinuations.shift();setTimeout((function(){e.continuation.apply(e.thisObject,[null])}))}else this._isLocked=!1},n.prototype.abortPendingOperations=function(e){var t=this._pendingContinuations;this._pendingContinuations=[],t.forEach((function(t){t.continuation.apply(t.thisObject,[e])}))},n.prototype.isLocked=function(){return this._isLocked},n.prototype.hasPendingRequest=function(){return this._pendingContinuations.length>0},Object.freeze(n),Object.seal(n.prototype),e.exports=n},function(e,t){var n={},o={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/illustrator":["ai"],"application/illustrator-text":["ai"],"application/illustrator.template":["ait"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/photoshop":["psd"],"application/photoshop.large":["psb"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.animate-xfl+zip":["fla","xfl"],"application/vnd.adobe.animate-oam+zip":["oam"],"application/vnd.adobe.animate-sym+zip":["sym"],"application/vnd.adobe.animate-swf+zip":["swa"],"application/vnd.adobe.characterstyle+json":["style"],"application/vnd.adobe.characterstyle+snippet":["idms"],"application/vnd.adobe.charts+zip":["zip"],"application/vnd.adobe.ch.puppet+zip":["puppet"],"application/vnd.adobe.color+json":["ase"],"application/vnd.adobe.colortheme+json":["ase"],"application/vnd.adobe.cube+txt":["cube"],"application/vnd.adobe.element.agc+dcx":["agc"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.ibl.light+zip":["zip"],"application/vnd.adobe.indesign-idms":["idms"],"application/vnd.adobe.indesign-idms-text":["idms"],"application/vnd.adobe.indesign.template":["indt"],"application/vnd.adobe.layerstyle":["asl"],"application/vnd.adobe.look+xml":["look"],"application/vnd.adobe.ppro.graphic+zip":["prgraphic"],"application/vnd.adobe.ae.graphic+zip":["aegraphic"],"application/vnd.adobe.graphic+json":["json"],"application/vnd.adobe.mdl.material+zip":["zip"],"application/vnd.adobe.muse-collection":["muse"],"application/vnd.adobe.obj.3d+zip":["zip"],"application/vnd.adobe.paragraphstyle+json":["style"],"application/vnd.adobe.paragraphstyle+snippet":["idms"],"application/vnd.adobe.ribbon.brush+zip":["brush"],"application/vnd.adobe.scatter.brush+zip":["brush"],"application/vnd.adobe.vector.brush+zip":["brush"],"application/vnd.adobe.text+json":["text-json"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/font-woff":["woff"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dng":["dng"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpg":["jpg"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.adobe.photoshop.template":["psdt"],"image/vnd.adobe.pattern+png":["png"],"image/vnd.adobe.shape+svg":["shape"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-adobe-dng":["dng"],"image/x-adobe-photoshop-brush":["abr"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.adobe.dn+dcx":["dn"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache"],"text/calendar":["ics","ifb"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-fortran":["f","for","f77","f90"],"text/x-java-source":["java"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-nfo":["nfo"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]},i={};Object.keys(o).forEach((function(e){o[e].forEach((function(t){i[t]=i[t]||[],i[t].push(e)}))})),n.getExtensions=function(e){return e?o[e.toLowerCase()]||function(e){var t=e.match(/application\/x-adobe-libraries-(.+)/);return t?[t[1]]:[]}(e.toLowerCase()):[]},n.getMimeTypes=function(e){return e?i[e.toLowerCase()]||function(e){return["application/x-adobe-libraries-"+e]}(e.toLowerCase()):[]},Object.seal(n),e.exports=n},function(e,t,n){var o=n(1),i=n(0),r=n(12),a=n(8),s={},c={"application/x-indesign":!0,"application/postscript":!0,"application/illustrator":!0,"application/pdf":!0,"application/vnd.adobe.psremix":!0,"application/vnd.adobe.pstouch":!0,"application/vnd.adobe.ideas":!0,"application/vnd.adobe.ase":!0,"image/jpeg":!0,"image/jpg":!0,"image/pjpeg":!0,"image/tiff":!0,"image/gif":!0,"image/bmp":!0,"image/x-ms-bmp":!0,"image/svg+xml":!0,"image/png":!0,"image/x-png":!0,"image/jp2":!0,"image/psd":!0,"image/vnd.adobe.photoshop":!0,"application/photoshop":!0,"application/x-photoshop":!0,"image/raw":!0,"image/dng":!0,"image/x-adobe-dng":!0,"video/mp4":!0,"video/mpeg":!0,"video/x-ms-wmv":!0,"video/3gpp":!0,"video/3gpp2":!0,"video/quicktime":!0,"video/x-msvideo":!0,"video/x-flv":!0,"video/x-ms-asf":!0,"video/x-m4v":!0,"video/mp2t":!0,"application/mxf":!0,"application/x-shockwave-flash":!0,"application/vnd.adobe.brushes.brush+ucf":!0,"application/vnd.adobe.collage":!0,"application/vnd.adobe.proto":!0,"application/msword":!0,"application/msexcel":!0,"application/mspowerpoint":!0,"application/vnd.ms-publisher":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":!0,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":!0,"application/vnd.openxmlformats-officedocument.presentationml.presentation":!0,"application/vnd.adobe.charts+zip":!0,"text/plain":!0,"text/rtf":!0};s.canComputeRenditionFromMimeType=function(e){return!!c[e]},s.canComputeRendition=function(e){return!(void 0===e._dcxComponent||!s.canComputeRenditionFromMimeType(e.type))},s.shouldPrefetchFullRendition=function(e){var t=(o.FULL_RENDITION_CONFIG||{})[e.type];if(!t)return!1;var n=!1;return Object.keys(t).forEach((function(o){var i=t[o];if("IF_NO_MATCHING_REPRESENTATION"===i.condition&&i.types){var r=e.representations.every((function(e){return-1===i.types.indexOf(e.type)}));n=n||r}})),n},s.shouldPrefetchExternalLink=function(e){if(!e.isExternalLink)return!1;var t=(o.EXTERNAL_LINK_PREFETCH||{})[e.element.type];return void 0===t||t},s.prefetchRenditionsForElement=function(e,t){var n=a.wrapCallback(t);if(i.hasFileSystem()){var c=new r,l=o.RENDITION_SIZES||{};(l[e.type]||l["*"]||[]).forEach((function(t){c.addOperation(e.getThumbnailPath,[t],e)})),s.shouldPrefetchFullRendition(e)&&c.addOperation(e.getThumbnailPath,[void 0],e),e._forEachRepresentation((function(e){s.shouldPrefetchExternalLink(e)?c.addOperation(e.getContentPath,[],e):e.isExternalLink&&c.addOperation(e.testExternalLink,[],e)})),c.run(n)}else n(null)},s.prefetchRenditions=function(e,t){var n=a.wrapCallback(t);if(i.hasFileSystem()){var o=new r;e.elements.forEach((function(e){o.addOperation(s.prefetchRenditionsForElement,[e],s)})),o.run(n)}else n(null)},s.addToRenditionSizeConfig=function(e){var t=o.RENDITION_SIZES,n=t["*"]||[];n=JSON.parse(JSON.stringify(n));var i=e["*"]||[];Object.keys(t).forEach((function(n){if(!e[n]){var o=t[n];i.forEach((function(e){-1===o.indexOf(e)&&o.push(e)})),t[n]=o}})),Object.keys(e).forEach((function(o){var i=t[o]||JSON.parse(JSON.stringify(n));e[o].forEach((function(e){-1===i.indexOf(e)&&i.push(e)})),t[o]=i})),o.setParameter("RENDITION_SIZES",t)},s.addToFullRenditionConfig=function(e){var t=o.FULL_RENDITION_CONFIG;Object.keys(e).forEach((function(n){var o=t[n]||{};e[n].forEach((function(e){e.id&&(o[e.id]=e)})),t[n]=o})),o.setParameter("FULL_RENDITION_CONFIG",t)},Object.seal(s),e.exports=s},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=n(27),r=n(43),a=n(3),s=n(4),c=6;function l(e,t,n){if(e)e=this._setData(e,t);else{var o=s.generateUuid();e={"manifest-format-version":c,id:o},this.originalManifestFormatVersion=c,this._core=new i(e,this,t),this._data=e}this._pendingElements=[],this.manifestPath=n}l._newBranchAsCopyOfCore=function(e,t){var n=new l(JSON.parse(JSON.stringify(e._data))),o=n._core;return n._localStorage=t,n._resetIdentity((function(n){var i=e.getComponentWithId(n.id);if(!i)throw new a(a.INVALID_STATE,"Could not find original component.");if("modified"===i.state||!i.etag)throw new a(a.INVALID_STATE,"Cannot create a new composite from a branch that contains modified or unbound components.");var r=e._getHrefOfComponent(i);if(!r)throw new a(a.INVALID_STATE,"Cannot determine the href of component id "+i.id);o._setSourceHrefOfComponent(r,n),t&&t.removeComponentAsset(n,o._local())})),n},Object.defineProperties(l.prototype,{compositeId:{get:function(){return this._core.rootNode.id},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new a(a.INVALID_PARAMS,"Expecting a non-empty string.");if(t._allNodes[e])throw new a(a.DUPLICATE_VALUE,"There is already a node with the same id.");delete t._allNodes[this._data.id],this._data.id=e,t._allNodes[e]=this._core.rootNode,t._setDirty()}},rootNode:{get:function(){return this._core.rootNode},set:function(e){this._core.rootNode=e}},name:{get:function(){return this._core.rootNode.name},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new a(a.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get:function(){return this._core.rootNode.type},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new a(a.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get:function(){return this._data.local?this._data.local.compositeHref:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new a(a.INVALID_PARAMS,"Expecting a string or undefined.");t._local().compositeHref=s.ensureRelativeHrefStartsWithSlash(e),t._setDirty(!0)}},_collaborationType:{get:function(){return this._data.local?this._data.local.collaborationType:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");e?t._local().collaborationType=e:delete t._local().collaborationType,t._setDirty(!0)}},_clientDataString:{get:function(){return this._data.local?this._data.local.clientDataString:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");e?t._local().clientDataString=e:delete t._local().clientDataString,t._setDirty(!0)}},manifestEtag:{get:function(){return this._data.local?this._data.local.manifestEtag:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new a(a.INVALID_PARAMS,"Expecting a string or undefined.");t._local().manifestEtag=e,t._setDirty(!0)}},compositeState:{get:function(){return this._data.state||"unmodified"},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new a(a.INVALID_PARAMS,"Expecting a string.");if("unmodified"!==e&&"modified"!==e&&"pendingDelete"!==e&&"committedDelete"!==e)throw new a(a.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDelete", or "committedDelete".');if("pendingDelete"===e&&"committedDelete"===e&&("pending"===this.compositeArchivalState||"archived"===this.compositeArchivalState))throw new a(a.INVALID_STATE,"Cannot delete an archived composite.");this._data.state=e,t._setDirty(!0)}},compositeArchivalState:{get:function(){return this._core._local().archivalState||"active"},set:function(e){var t=this._core;if(t._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new a(a.INVALID_PARAMS,"Expecting a string.");if("pending"!==e&&"archived"!==e&&"active"!==e)throw new a(a.INVALID_PARAMS,'State must be "pending", "archived", or undefined.');if("archived"===this.compositeArchivalState)throw new a(a.INVALID_STATE,"Composite has already been archived.");if("active"!==e&&("pendingDelete"===this.compositeState||"committedDelete"===this.compositeState))throw new a(a.INVALID_STATE,"Cannot archive a deleted composite.");"active"===e?delete this._core._local().archivalState:this._core._local().archivalState=e,t._setDirty(!0)}},isBound:{get:function(){return this.manifestEtag&&this.compositeHref},set:function(){throw new a(a.READ_ONLY,"Cannot set the property isBound. Use resetIdentity instead.")}},_localStorage:{get:function(){return this._core._localStorage},set:function(e){this._core._localStorage=e}},hasLocalStorage:{get:function(){return this._core.hasLocalStorage},set:function(e){this._core.hasLocalStorage=e}},_isDirty:{get:function(){return this._core._isDirty},set:function(e){this._core._isDirty=e}},isDirty:{get:function(){return this._core.isDirty},set:function(e){this._core.isDirty=e}},localData:{get:function(){return this._core._stringify(!1,!0)},set:function(){throw new a(a.READ_ONLY,"Cannot set the property localData.")}},remoteData:{get:function(){return this._core._stringify(!0)},set:function(){throw new a(a.READ_ONLY,"Cannot set the property remoteData.")}},pendingElements:{get:function(){return this._pendingElements},set:function(){throw new a(a.READ_ONLY,"Cannot set the property pendingElements.")}},changeCount:{get:function(){return this._core.changeCount},set:function(e){this._core.changeCount=e}},readOnly:{get:function(){return this._core._readOnly},set:function(e){this._core._readOnly=e}}}),l.prototype.parse=function(e){if("string"!=typeof e)throw new a(a.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new a(a.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},l.prototype.getElementWithId=function(e){return this._createElement(this._core.getChildWithId(e))},l.prototype.getElementWithAbsolutePath=function(e){return this._createElement(this._core.getChildWithAbsolutePath(e))},l.prototype.addElement=function(e,t,n,o,i,r){if("string"!=typeof e)throw new a(a.INVALID_PARAMS,"Element must have a name of type string");if("string"!=typeof t)throw new a(a.INVALID_PARAMS,"Element must have a type of type string");if("string"!=typeof n)throw new a(a.INVALID_PARAMS,"Element must have a path of type string");var s=this._core.addChild(e,o,i,r);try{s.path=n}catch(e){throw this._core.removeChild(s),e}return s._data.type=t,this._createElement(s)},l.prototype.updateElement=function(e){var t=this.getChildWithId(e.rootNode.id);if(!t)throw new a(a.INVALID_PARAMS,"Element does not exist in branch.");var n=this._core.replaceChild(e.rootNode,t.path);return this._deleteElement(e),n},l.prototype.abandonElement=function(e){this._deleteElement(e)},l.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},l.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},l.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},l.prototype.addChild=function(e,t,n,o){return this._core.addChild(e,t,n,o)},l.prototype.removeChild=function(e){return this._core.removeChild(e)},l.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},l.prototype.copyChild=function(e,t,n,o,i,r){return this._core.copyChild(e,t,n,o,i,r)},l.prototype.replaceChild=function(e,t,n,o){return this._core.replaceChild(e,t,n,o)},l.prototype.allComponents=function(){return this._core.allComponents()},l.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},l.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},l.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},l.prototype.addComponent=function(e,t,n,o,i,r,a,s,c,l){return this._core.addComponent(e,t,n,o,i,r,a,s,c,l)},l.prototype.addComponentWithUploadResults=function(e,t,n,o,i){return this._core.addComponentWithUploadResults(e,t,n,o,i)},l.prototype.updateComponent=function(e,t,n,o){return this._core.updateComponent(e,t,n,o)},l.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},l.prototype.removeComponent=function(e){return this._core.removeComponent(e)},l.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},l.prototype.copyComponent=function(e,t,n,o,i){return this._core.copyComponent(e,t,n,o,i)},l.prototype.replaceComponent=function(e,t,n,o){return this._core.replaceComponent(e,t,n,o)},l.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},l.prototype.copy=function(){var e=new l(JSON.parse(JSON.stringify(this._data)));return e._localStorage=this._localStorage,e},l.prototype._createElement=function(e){var t;if(e){var n=JSON.parse(JSON.stringify(e._data));n["manifest-format-version"]=this._data["manifest-format-version"],delete n.path,(t=new r(n,this,this._core._readOnly))&&this._localStorage&&(t._localStorage=this._localStorage,t._updateLocalDataFromBranch(this),this._localStorage.registerInMemoryBranchOrElement(t))}return t&&this._pendingElements.push(t),t},l.prototype._deleteElement=function(e){var t=this._pendingElements.indexOf(e);if(t<0)throw new a(a.INVALID_PARAMS,"Unknown element.");this._pendingElements.splice(t,1),this._localStorage&&this._localStorage.unregisterInMemoryBranchOrElement(e)},l.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new a(a.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new a(a.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new a(a.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},l.prototype._verify=function(e){return"string"!=typeof e.id?new a(a.INVALID_DATA,"Manifest is missing an id of type string"):"string"!=typeof e.name?new a(a.INVALID_DATA,"Manifest is missing a name of type string"):"string"!=typeof e.type?new a(a.INVALID_DATA,"Manifest is missing a type of type string"):"number"!=typeof e["manifest-format-version"]?new a(a.INVALID_DATA,"Manifest is missing a manifest-format-version of type number"):null},l.prototype._setData=function(e,t){this.originalManifestFormatVersion=e["manifest-format-version"],function(e){var t=e["manifest-format-version"];if(t<c){if(t<4)throw new a(a.INVALID_DATA,"Encountered manifest format version "+e["manifest-format-version"]+". Format version conversion not yet implemented for that version.");t<5&&function e(t){var n,o,i=t.components;if(i)for(o=i.length,n=0;n<o;n++)delete i[n].localStorageAssetId;var r=t.children;if(r)for(o=r.length,n=0;n<o;n++)e(r[n])}(e),t<6&&function e(t,n){n&&t.path&&delete t.path;var i,r=t.components;if("object"===o(r))for(i=0;i<r.length;i++){var a=r[i];"number"==typeof a.version&&(a.version=a.version.toString())}var s=t.children;if("object"===o(s))for(i=0;i<s.length;i++)e(s[i])}(e,!0)}}(e),e.local&&(e.local.version=2);var n=this._verify(e);if(null===n)return e["manifest-format-version"]=c,this._core=new i(e,this,t),this._data=e,this;throw n},l.prototype._reset=function(e,t){if(this._readOnly)throw new a(a.READ_ONLY,"This object is read-only.");this._data.local&&(delete this._data.local.manifestEtag,delete this._data.local.compositeHref),e||(this._data.id=s.generateUuid()),this._data.state="modified",this._core._recursiveReset(this._data,t),this._core._setDirty()},l.prototype._resetBinding=function(e){this._reset(!0,e)},l.prototype._resetIdentity=function(e){this._reset(!1,e)},l.prototype._local=function(){return this._core._local()},l.prototype._setDirty=function(e){this._core._setDirty(e)},l.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},l.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=l},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=n(0),r=n(8),a={},s="undefined"!==("undefined"==typeof LOCALE_ROOT?"undefined":o(LOCALE_ROOT));function c(){this.setLocale()}i.hasFileSystem()&&s||(a={cs_CZ:n(47),da_DK:n(48),de_DE:n(49),en_US:n(50),es_ES:n(51),es_MX:n(52),fi_FI:n(53),fr_CA:n(54),fr_FR:n(55),fr_MA:n(56),hu_HU:n(57),it_IT:n(58),ja_JP:n(59),ko_KR:n(60),nb_NO:n(61),nl_NL:n(62),pl_PL:n(63),pt_BR:n(64),ru_RU:n(65),sv_SE:n(66),tr_TR:n(67),uk_UA:n(68),zh_CN:n(69),zh_TW:n(70)}),c.prototype._getLocaleData=function(e){if(!a[e]&&i.hasFileSystem()&&s)try{a[e]=i.fs.readFileSync(LOCALE_ROOT+e+"/messages.properties","utf8")}catch(e){}return a[e]},c.prototype._normaliseLocale=function(e){if(e){var t=(e=e.replace("-","_")).split("_");return t[0]=t[0]&&t[0].toLowerCase(),t[1]=t[1]&&t[1].toUpperCase(),t.join("_")}},c.prototype.setLocale=function(e){(e=this._normaliseLocale(e))&&this._getLocaleData(e)||(e="en_US"),this._locale=e,this._strings=r.parseLocalisationFile(this._getLocaleData(this._locale))},c.prototype.getLocale=function(){return this._locale},c.prototype.translate=function(e,t){var n=this._strings[e];return n&&t&&(n=r.constructStringFromTemplate(n,t)),n||e};var l={photoshop:"LIBS_TOOLKIT_NAME_PHOTOSHOP"};c.prototype.getToolkitName=function(e){return this.translate(l[e]||"LIBS_TOOLKIT_NAME_DEFAULT")},Object.freeze(c),Object.seal(c.prototype),e.exports=new c},function(e,t,n){var o=n(1),i=n(2),r=n(4),a={getBackoffTicks:function(e){var t=o.BACKOFF_INTERVALS;return t[Math.max(0,Math.min(e,t.length-1))]-1},getRetryAfterHeader:function(e){if(e){var t=e["retry-after"]||e["Retry-After"];if(t)try{var n=parseInt(t,10);if(n)return Math.max(0,n);var i=Date.parse(t);if(i){var r=(new Date).valueOf();return Math.max(0,i-r)/1e3+Math.floor(Math.random()*o.RETRY_RANDOM_SECONDS)}}catch(e){}}return 0},getLocationHeader:function(e){if(e){var t=e.location||e.Location;if(t)return t}},getContentTypeHeader:function(e){if(e){var t=e["content-type"]||e["Content-Type"];if(t){var n=t.indexOf(";");return n>0&&(t=t.substring(0,n)),t}}},getContentLengthHeader:function(e){if(e){var t=e["content-length"]||e["Content-Length"];return Number(t)||void 0}},isUnrecoverableClientError:function(e,t){return!!e&&e>=400&&e<500&&(401!==e||!!t)&&407!==e&&408!==e},isRedirect:function(e){return 301===e||302===e||303===e||307===e}},s=function(e,t){return t.some((function(t){if(e===t)return!0;var n=e.indexOf("."+t);return-1!==n&&n===e.length-t.length-1}))};a.isAdobeDomain=function(e){return!!e&&s(e,o.ADOBE_AUTHENTICATED_DOMAINS)},a.validateURL=function(e,t){if(!e)return new i(i.URL_VALIDATION_FAILED,"URL not specified");var n=r.parseURI(e);if("https"!==n.scheme)return new i(i.URL_VALIDATION_FAILED,"URL must be https://");if(!a.isAdobeDomain(n.authority)&&!s(n.authority,o.WHITELISTED_DOMAINS))return new i(i.URL_VALIDATION_FAILED,"URL domain not in whitelist");var c=t&&t._syncManager._storageHost,l=c&&o.DISALLOWED_DOMAINS[c];return s(n.authority,l||[])?new i(i.URL_VALIDATION_FAILED,"URL domain does not match IMS environment (stage-production mismatch)"):null},Object.seal(a),e.exports=a},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=n(3),r=n(4);function a(e,t){e?this._setData(e):this._data={},this._readOnly=t}var s={unmodified:"unmodified",modified:"modified",pendingDelete:"pendingDelete",committedDelete:"committedDelete"};a.STATES=s,a._UploadResults=function(e){this.compositeId=e,this.records={}},a._UploadRecord=function(e,t,n,o,i,r){this.id=e,this.etag=t,this.version=n,this.md5=o,this.length=i,this.type=r},Object.defineProperties(a.prototype,{id:{get:function(){return this._data.id},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(this._owner)throw new i(i.READ_ONLY,"Cannot change the id of a component that is part of a branch or element.");if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty()}},name:{get:function(){return this._data.name},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty()}},type:{get:function(){return this._data.type},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,"Expecting a non-empty string.");this._data.type=e,this._setDirty()}},path:{get:function(){return this._data.path},set:function(e){if(this._data.path!==e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!r.isValidPath(e))throw new i(i.INVALID_PARAMS,"Expecting a valid path.");this._owner?this._owner._core._setPathOfComponent(this,e):(this._data.path=e,this._parentPath=""),this._setDirty()}}},parentPath:{get:function(){return this._parentPath},set:function(){throw new i(i.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get:function(){return this._data.path&&this._owner?r.appendPathElements(this._parentPath,this._data.path):void 0},set:function(){throw new i(i.READ_ONLY,"absolutePath is read-only.")}},relationship:{get:function(){return this._data.rel},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty()}},state:{get:function(){return this._data.state},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,"Expecting a string.");if(!s.hasOwnProperty(e))throw new i(i.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDelete", or "committedDelete".');this._data.state=e,this._setDirty()}},etag:{get:function(){return this._data.etag},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.etag=e,this._setDirty()}},md5:{get:function(){return this._data.md5},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.md5=e,this._setDirty()}},version:{get:function(){return this._data.version},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(void 0!==e&&"string"!=typeof e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.version=e,this._setDirty()}},length:{get:function(){return this._data.length},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a number or undefined.");this._data.length=e,this._setDirty()}},width:{get:function(){return this._data.width},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a number or undefined.");this._data.width=e,this._setDirty()}},height:{get:function(){return this._data.height},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a number or undefined.");this._data.height=e,this._setDirty()}}});var c={name:!0,id:!0,state:!0,path:!0,rel:!0,type:!0,etag:!0,length:!0,version:!0,md5:!0,width:!0,height:!0};a.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),o=n.length;for(e=0;e<o;e++){var i=n[e];c[i]||t.push(i)}return t},a.prototype.getValue=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "key" must be a string');return this._data[e]},a.prototype.setValue=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "key" must be a string');this._data[e]=t,this._setDirty()},a.prototype.removeValue=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "key" must be a string');delete this._data[e],this._setDirty()},a.prototype.getLink=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0},a.prototype.setLink=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("object"!==o(e))throw new i(i.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new i(i.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty()},a.prototype.removeLink=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty())},a.prototype.isEqualTo=function(e,t){return r.objectsEqual(this._data,e._data,t)},a.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},a.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},a.prototype._verify=function(e){return"string"!=typeof e.id?new i(i.INVALID_DATA,"Component is missing an id of type string"):null},e.exports=a},function(e,t,n){var o=n(3),i=o.networkError,r=o.unexpectedResponse,a=n(4),s=a.merge,c=n(30),l=a.appendPathElements;function p(e,t){this._service=e,this._server=t,t&&(this._endPoint=a.endPointOf(t)),this.SYNC_ASYNC_DEFAULT_DELAY=5,this.ASYNC_DEFAULT_DELAY=1,this.DEFAULT_POLL_DELAY=10,this._maxRedirects=5,this._authenticationWhitelist=[]}p.FileContent=c.FileContent,p.StreamProvider=c.StreamProvider,Object.defineProperties(p.prototype,{maxRedirects:{get:function(){return this._maxRedirects},set:function(e){if("number"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a number.");this._maxRedirects=Math.floor(e)}},authenticationWhitelist:{get:function(){return this._authenticationWhitelist},set:function(e){if(!Array.isArray(e))throw new o(o.INVALID_PARAMS,"Expecting an array.");this._authenticationWhitelist=e}}}),p.prototype.isValidHref=function(e){var t=a.endPointOf(e);return!t||t===this._endPoint},p.prototype.isDomainOnWhitelist=function(e){var t=a.parseURI(e).authority;if(!t||0===t.length)return!0;var n,o=t.length,i=this._authenticationWhitelist.length;for(n=0;n<i;n++){var r=this._authenticationWhitelist[n],s=r.length;if((o>s?t.slice(-s):t)===r)return!0}return!1},p.prototype.getAsset=function(e,t,n,c){if(!(e=this._resolveUrl(e)))return c(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));var l,p={};"string"==typeof t?p["If-None-Match"]=t:s(p,t);var d,h=this,u=0;function _(e,t){if(e)return c(i("Error downloading an asset",e,t));var n=t.statusCode;if(200===n)c(void 0,t);else if(304===n)c(void 0,t);else if(301===n||302===n||303===n||307===n)if(!h._service.handlesRedirects&&h.maxRedirects)if(u<h.maxRedirects){var o=t.headers.location;o?d(o):c(r("Missing location header in redirect response",e,t))}else c(r("Too many redirects",e,t));else c(r("Unexpected response getting an asset",e,t));else c(r("Unexpected response getting an asset",e,t))}return(l=(d=function(t){var o={responseType:n};return t&&(u++,o.reuseRequestDesc=l,h.isDomainOnWhitelist(t)||(p.Authorization=null)),h._service.invoke("GET",t||e,p,void 0,o,_)})()).progress=a.noOp,l},p.prototype.getAssetAsType=function(e,t,n,o){return this.getAsset(e,n,t,(function(e,t){if(e)return o(e);if(200===t.statusCode){var n=t.response||t.responseText;o(void 0,n,t.headers.etag,t)}else 304===t.statusCode?o(void 0,null,t.headers.etag,t):o(r("Unexpected response getting asset",e,t))}))},p.prototype._resolveUrl=function(e){var t=a.endPointOf(e);if(t){if(t!==this._endPoint)return;return e}return l(this._server,e)},p.prototype._makeRelativeUrl=function(e){var t=a.endPointOf(e);if(t){if(t!==this._endPoint)return;var n=a.parseURI(e);(n.scheme||n.authority)&&(e=n.path,n.query&&(e+="?"+n.query),n.fragment&&(e+="#"+n.fragment))}return e},p.prototype._parseAsyncResponse=function(e){var t=e.responseText||e.response;if(!t)throw new o(o.INVALID_DATA,"No body data.");var n={},i=t.indexOf("\n");if(-1===i)throw new o(o.INVALID_DATA,"Could not find status line.");var r=t.slice(0,13===t.charCodeAt(i-1)?i-1:i).split(" ");if(n.statusCode=parseInt(r[1],10),!n.statusCode)throw new o(o.INVALID_DATA,"Could not find status code.");r.length>2&&(n.statusText=r[2]);var s=t.search(/\r?\n\r?\n/);-1===s&&(s=t.length);var c=t.slice(i+1,s);n.headers=a.parseHeaders(c);var l="\r"===t.charAt(s)?s+4:s+2;return n.response=t.slice(l),n},p.prototype._pollForAsyncResponse=function(e,t,n,o){var s=this,c=Date.now()+1e3*t,l={responseType:"text",reuseRequestDesc:n,noSoonerThen:c};a.log("asynchronous request - polling"),n=this._service.invoke("GET",e,void 0,void 0,l,(function(t,c){if(t)return o(i("Error polling for an asynchronous reponse",t,c));var l=c.statusCode;if(202===l){a.log("asynchronous request - not yet ready");var p=c.headers["retry-after"];p&&(p=parseInt(p,10)),s._pollForAsyncResponse(e,p||s.DEFAULT_POLL_DELAY,n,o)}else if(200===l){a.log("asynchronous request - success");try{c=s._parseAsyncResponse(c)}catch(e){return o(r("Error parsing response body.",e,c))}200===(l=c.statusCode)||201===l||204===l?o(void 0,c):o(r("Unexpected response polling for an asynchronous response",t,c))}else a.log("asynchronous request - error"),o(r("Unexpected response polling for an asynchronous response",t,c))}))},p.prototype._handle202Response=function(e,t,n,o){var i,a=e.responseText||e.response;try{i=JSON.parse(a)}catch(t){return o(r("Error parsing 202 response body.",t,e))}var s=i.href;if(!s)return o(r("202 response missing an href.",void 0,e));var c=e.headers["retry-after"];c=c?parseInt(c,10):n,this._pollForAsyncResponse(this._resolveUrl(s),c,t,o)},e.exports=p},function(e,t,n){var o=n(3),i=n(34),r=n(0),a=n(1),s=n(75),c=n(76),l=n(77),p=n(11),d=n(2),h=n(18),u=n(78),_=n(12),f=n(5),m=n(10),y=n(6),E=n(19),g=n(8),v=n(16),A=n(79),C=n(9),O=n(80);function L(e){this._userId=e.USER_ID,this._cloudId=e.CLOUD_ID,this._cloudInfo=e.CLOUD_INFO||{},this._syncManager=new s(this,e),this._libraries=[],this._syncState="syncing",this._syncProgressMap={},this._externalLinkDownloadProgressMap={},this._initialSyncInProgress=!1,this._syncErrors=[],this._listenerManager=new C(["change","deepchange","sync","operation","commitError"]),this._operations=[],O.connect(this),this._libraryIdMap={},this._operationIdMap={},this._removeOperationTimeout={},this._pendingDeletes=[],this._loaded=!1,this._syncing=!1,this._lastSyncTime=0,this._pendingSyncs=[],this._backoffTicks=0,this._numBackoffs=0,this._numRetries=0,this.isPublic||(this._bookmarkManager=new c(this),this._fontManager=new l(this))}L.prototype._dispose=function(){O.disconnect(this)},L.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._libraries.forEach((function(e){e._removeAllListeners()}))},L.prototype._notifyChange=function(e){this._listenerManager.notify("deepchange"),e&&this._listenerManager.notify("change")},L.prototype._loadLibrary=function(e,t){var n=this,o=this._getCompositeDir(e),a=function(o){r.log("Load error: ".concat(o)),f.deleteLibraryFromDisk(n,e,(function(){return t(null)}))},s=function(o){var r=new i(n,o,n.isPublic&&e);"pendingDelete"===o.current.compositeState?(n._pendingDeletes.push(r),t(null)):(n._libraries.push(r),n._libraryIdMap[r.id]=r,r._renditionCache.load().then(t))};r.dcx.newCompositeFromLocalStorage(o,(function(t,o){return t?a("DCX error loading composite for ".concat(e)):o&&o.current?m.validateLibrary(o)?n.isPublic||o.id===e?void(o.href&&o.current.isBound?o.loadBaseBranch((function(t,n){t||!n?a("missing base branch for ".concat(e," (even though bound to server)")):s(o)})):s(o)):a("library id ".concat(o.id," doesn't match folder on disk ").concat(e)):a("failed validation for ".concat(e)):a("composite/branch not loaded for ".concat(e))}))},L.prototype._load=function(e){var t=this;this._loaded?e(null):(this._loaded=!0,f.readLibraryDirectory(this,(function(n,o){if(!n&&o){var i=new _;o.forEach((function(e){m.validateLibraryId(e,t.isPublic)&&i.addOperation(t._loadLibrary,[e],t)})),i.addOperation((function(e){return t._externalLinkCache.load().then(e)})),t.isPublic||i.addOperation(t._bookmarkManager.load,[],t._bookmarkManager),i.run((function(){r.log("Loaded "+t._libraries.length+" libraries and "+t._pendingDeletes.length+" pending deletes"),e(null)}),(function(e){return t._reportCommitError(e)}))}else e(null)})))},L.prototype._removeFromPendingDeletes=function(e){var t=this._pendingDeletes.indexOf(e);-1!==t&&this._pendingDeletes.splice(t,1)},L.prototype._handlePendingDeletes=function(e){var t=this,n=new _;this._pendingDeletes.forEach((function(e){n.addOperation((function(n){e._deleteFromServer(!1,(function(i){if(i&&i.code===o.UPDATE_CONFLICT)return t._removeFromPendingDeletes(e),t._libraries.push(e),t._libraryIdMap[e.id]=e,e._markDeletedLocally(!1),t._updateSyncState(),t._notifyChange(!0),void n(null,!0);i?n(i):(t._removeFromPendingDeletes(e),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(t,e.id,(function(e){n(e,!0)})))}))}))})),n.run(e)},L.prototype._doesLibraryExist=function(e){if(this._libraryIdMap[e])return!0;var t;for(t=0;t<this._pendingDeletes.length;t++)if(this._pendingDeletes[t].id===e)return!0;return!1},L.prototype._syncNewLibrary=function(e,t,n,a){var s=this,c=t||this._syncManager.getCompositePath(e),l=r.hasFileSystem()&&this._getCompositeDir(e),p=r.dcx.newCompositeWithHref(c,l);s._libraryIdMap[e]="pending",s._updateSyncState(),s._syncManager.pullComposite(p,s,(function(t,r){if(t||!r)return delete s._libraryIdMap[e],s._updateSyncState(),t=t?t.code===o.NO_COMPOSITE||t.code===o.DELETED_COMPOSITE?null:y.getSyncError(t,e):new d(d.NETWORK_ERROR,"No pulled branch"),void a(t,!0);p.resolvePullWithBranch(r,(function(t){if(t||!s.isPublic&&p.id!==e)return delete s._libraryIdMap[e],s._updateSyncState(),t=t?y.getCommitError(t,e):new d(d.CORRUPTED_LIBRARY,"Library id does not match sync group id"),void a(t,!0);var o=new i(s,p,s.isPublic&&e);s._libraries.push(o),s._libraryIdMap[o.id]=o,s._updateSyncState(),o._setCollaboration(n),v.prefetchRenditions(o),s._notifyChange(!0),a(null,!0)}))}))},L.prototype._syncNewLibraries=function(e,t){var n=this,o=new _;if(this._loadingHint){var i=[];e.forEach((function(e){-1!==n._loadingHint.indexOf(e.name)&&i.push(e)})),e.forEach((function(e){-1===n._loadingHint.indexOf(e.name)&&i.push(e)})),e=i}e.forEach((function(e){var t=e.name;n._doesLibraryExist(e.name)||o.addOperation(n._syncNewLibrary,[t,void 0,e],n)})),o.run(t)},L.prototype._syncExistingLibraries=function(e,t,n){var o=this,i=new _;this._libraries.forEach((function(n){var r=e&&e[n.id];if(r&&(n._setCollaboration(r),n._deletedFromServer&&(n._deletedFromServer=!1,n._notifyChange())),t)(t[n.id]||r&&!r.isUnmodified)&&i.addOperation(n._sync,[!1],n);else{var a=!e||r&&r.isUnmodified;void 0===n.collaboration?i.addOperation(n._sync,[a],n):a?i.addOperation((function(e){o._syncManager.hasCompositeChangedOnServer(n._dcxComposite,(function(t){n._sync(!t,e)}))})):i.addOperation(n._sync,[!1],n)}})),i.run(n)},L.prototype._dosync=function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites((function(o,i,r){if(o)return o=y.getSyncError(o,void 0,{403:d.ACCESS_DENIED}),n._reportSyncError(o),void t(null,!1);var a=new _;a.addOperation(n._syncNewLibraries,[i],n),a.addOperation(n._syncExistingLibraries,[r,e],n),a.addOperation(n._handlePendingDeletes,[],n),e||a.addOperation(n._bookmarkManager.sync,[],n._bookmarkManager),a.run((function(e,n){t(null,n)}),(function(e){n._reportSyncError(e)}))}))},L.prototype._reportSyncError=function(e){e&&(r.log("Sync error: "+y.errorToString(e)),this._syncErrors.push(e))},L.prototype._clearSyncErrors=function(e){if(e){var t=[];this._syncErrors.forEach((function(n){n.libraryId!==e&&t.push(n)})),this._syncErrors=t}else this._syncErrors=[]},L.prototype._reportCommitError=function(e){this._lastCommitError=e,e&&(r.log("Commit error: "+y.errorToString(e)),this._listenerManager.notify("commitError",[e]))},L.prototype._updateRetryState=function(){if(!this._retryTimeoutId&&"syncing"!==this._syncState){if("error"===this._syncState){var e=this.getPrimarySyncError();if(e&&e.code===d.RETRYABLE_SERVER_ERROR){if(this._numRetries++,this._numRetries>a.ERROR_RETRY_INTERVALS.length)return this._retryTime="never",r.log("Retry Failed"),void(a.MAX_SYNC_INTERVAL=a.RETRY_FAIL_MAX_SYNC_INTERVAL);r.log("Retry "+this._numRetries);var t=e.underlyingError&&e.underlyingError.response&&e.underlyingError.response.headers,n=1e3*E.getRetryAfterHeader(t);n>0?(this._numRetries=a.ERROR_RETRY_INTERVALS.length,r.log("Got Retry-After header")):n=1e3*a.ERROR_RETRY_INTERVALS[this._numRetries-1],r.log("Retrying after "+n+"ms"),this._retryTime=(new Date).valueOf()+n;var o=this;return void(this._retryTimeoutId=setTimeout((function(){o._retryTimeoutId=void 0,o._retryTime=void 0,r.log("Starting retry"),o._syncWithParameters(!1)}),n))}if(e&&e.code===d.EXCEEDS_QUOTA)return a.MAX_SYNC_INTERVAL=a.RETRY_FAIL_MAX_SYNC_INTERVAL,this._numRetries=a.ERROR_RETRY_INTERVALS.length+1,void(this._retryTime="never")}this._numRetries=0,this._retryTime=void 0}},L.prototype._updateSyncState=function(){var e,t=this,n=this._initialSyncInProgress;Object.keys(this._libraryIdMap).forEach((function(e){var o=t._libraryIdMap[e],i="pending"===o||o._isSyncing();n=n||i})),n?e="syncing":(this._syncErrors.length>0?(e="error",t._syncManager.clearSyncGroupCache(),p.reportError(this.getPrimarySyncError())):e="ok",this._syncProgressMap={},this._syncProgress=void 0);var o=this._syncState;this._syncState=e,this._updateRetryState(),o===e&&"error"!==this._syncState||this._listenerManager.notify("sync"),t._ensureDefaultLibrary()},L.prototype._updateProgress=function(e,t,n){n?this._syncProgressMap[e]={bytesLoaded:t||0,bytesTotal:n,progress:this._syncProgressMap[e]&&this._syncProgressMap[e].progress}:this._syncProgressMap[e]?(0===this._syncProgressMap[e].bytesTotal&&(this._syncProgressMap[e].bytesTotal=1e4),this._syncProgressMap[e].bytesLoaded=this._syncProgressMap[e].bytesTotal):this._syncProgressMap[e]={bytesLoaded:0,bytesTotal:0};var o=!1,i=t||0,r=(n||0)>0?Math.max(0,Math.min(100,Math.round(i/n*100))):void 0;this._syncProgressMap[e].progress!==r&&(this._syncProgressMap[e].progress=r,o=!0);var a=0,s=0,c=0,l=0,p=this._syncProgressMap;Object.keys(p).forEach((function(e){a++,p[e].bytesTotal>0&&s++,c+=p[e].bytesLoaded,l+=p[e].bytesTotal}));var d=l>0?c*s/(l*a):0,h=Math.max(0,Math.min(100,Math.round(100*d)));(!this._syncProgress||this._syncProgress<h||100===this._syncProgress&&h<100)&&(this._syncProgress=h,o=!0),o&&this._listenerManager.notify("sync")},L.prototype._updateExternalLinkDownloadProgress=function(e,t,n,o){var i,r=e.element.library.id+"."+e.element.id+"."+e.id;n?(t=t||0,i=Math.max(0,Math.min(100,Math.round(t/n*100)))):o&&(i=-1),i!==this._externalLinkDownloadProgressMap[r]&&(void 0===i?delete this._externalLinkDownloadProgressMap[r]:this._externalLinkDownloadProgressMap[r]=i,this._listenerManager.notify("sync"))},L.prototype._getExternalLinkDownloadProgress=function(e){var t=e.element.library.id+"."+e.element.id+"."+e.id;return this._externalLinkDownloadProgressMap[t]},L.prototype._setInitialSyncState=function(e,t){this._initialSyncInProgress=e,this._loadingHint=t,this._updateSyncState()},L.prototype._resetPollBackoff=function(){this._backoffTicks=0,this._numBackoffs=0},L.prototype._getBaseDir=function(){var e=r.getPathSeparator();return f.getUserDir(this._userId)+e+this._cloudId},L.prototype._getLibraryDir=function(e,t){var n=r.getPathSeparator(),o=this._getBaseDir()+n+e;return t&&(o+=n+t),o},L.prototype._getCompositeDir=function(e){return this._getLibraryDir("dcx",e)},L.prototype._getTempDir=function(){var e=r.getPathSeparator();return this._getBaseDir()+e+".tmp"},L.prototype._getRenditionCacheDir=function(e){return this._getLibraryDir("renditions",e)},L.prototype._ensureDefaultLibrary=function(){var e="ok"===this.syncState&&!this.isInitialSyncInProgress&&a.SYNCING_ENABLED,t=0;if(this.libraries.forEach((function(e){e.isDeletedLocally||e.isDeletedFromServer||t++})),!this.isPublic&&e&&0===t){var n=h.translate("LIBS_DEFAULT_LIBRARY_NAME");r.log("Creating default library: "+n),this.createLibrary(n)}},L.prototype._doRemoveLibrary=function(e,t){var n=this,o=g.wrapCallback(t),i=this._libraries.indexOf(e);-1!==i&&(this._libraries.splice(i,1),delete this._libraryIdMap[e.id]),e._removeAllListeners(),a.SHARED_LOCAL_STORAGE?(e._dcxBranch.compositeState="pendingDelete",e._commit(!1,!0),e._markDeletedLocally(!0),o(null)):(n._pendingDeletes.push(e),a.SYNCING_ENABLED?e._deleteFromServer(!0,(function(t){e._markDeletedLocally(!0),t?o(null):(n._removeFromPendingDeletes(e),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(n,e.id,o))})):(e._dcxBranch.compositeState="pendingDelete",e._commit(!0,!0),e._markDeletedLocally(!0),o(null))),this._notifyChange(!0)},L.prototype._doExportLibrary=function(e,t,n,o){var i,s=this;if(a.SHARED_LOCAL_STORAGE){var c=r.uuid();return r.storageInterface.exportLibrary(e,t,c,n),this._addOperation(c,"export",{libraryId:e.id})}o=o||r.uuid(),e._setAutoGC("export_"+o,!1);var l=this._addOperation(o,"export",{libraryId:e.id},(function(){i&&i()}));return i=A.exportLibrary(e,t,(function(e){l._updateProgress(e)}),(function(t){l._updateProgress(100),s._removeOperation(l),e._setAutoGC("export_"+o,!0),n(t)})),l},L.prototype._doImportLibrary=function(e,t,n){var o,i=this;if(a.SHARED_LOCAL_STORAGE){var s=r.uuid();return r.storageInterface.importLibrary(this,e,s,t),this._addOperation(s,"import")}var c=this._addOperation(n||r.uuid(),"import",void 0,(function(){o&&o()}));return o=A.importLibrary(this,e,(function(e){c._updateProgress(e)}),(function(e,n){c._updateProgress(100),i._removeOperation(c),t(e,n)})),c},L.prototype._addOperation=function(e,t,n,o){var i=new u(this,e,t,n,o);return this._operations.push(i),this._operationIdMap[i.id]=i,this._notifyOperationChange(),i},L.prototype._removeOperation=function(e){var t=this._operations.indexOf(e);-1!==t&&(this._operations.splice(t,1),delete this._operationIdMap[e.id]),this._notifyOperationChange()},L.prototype._delayedRemoveOperation=function(e){var t=this;this._removeOperationTimeout[e.id]||(this._removeOperationTimeout[e.id]=setTimeout((function(){delete t._removeOperationTimeout[e.id],t._removeOperation(e)}),a.REMOVE_OPERATION_TIMEOUT))},L.prototype._updateOperation=function(e,t,n,o){this._operationIdMap[e]||this._addOperation(e,t,n),this._removeOperationTimeout[e]&&(clearTimeout(this._removeOperationTimeout[e]),delete this._removeOperationTimeout[e]),this._operationIdMap[e]._updateProgress(o)},L.prototype._notifyOperationChange=function(){this._listenerManager.notify("operation")},Object.defineProperties(L.prototype,{libraries:{get:function(){return this._libraries},set:function(){throw new d(d.READ_ONLY,"Cannot modify libraries list directly")}},commitError:{get:function(){return this._lastCommitError},set:function(){throw new d(d.READ_ONLY,"commitError is a read-only property")}},syncState:{get:function(){return this._syncState},set:function(){throw new d(d.READ_ONLY,"syncState is a read-only property")}},syncErrors:{get:function(){return this._syncErrors},set:function(){throw new d(d.READ_ONLY,"syncErrors is a read-only property")}},syncProgress:{get:function(){return this._syncProgress},set:function(){throw new d(d.READ_ONLY,"syncProgress is a read-only property")}},isInitialSyncInProgress:{get:function(){return this._initialSyncInProgress},set:function(){throw new d(d.READ_ONLY,"isInitialSyncInProgress is a read-only property")}},isPolling:{get:function(){return void 0!==this._pollTimerId},set:function(){throw new d(d.READ_ONLY,"isPolling is a read-only property")}},isLoggedIn:{get:function(){if(!a.SHARED_LOCAL_STORAGE)return this._syncManager.isLoggedIn()},set:function(){throw new d(d.READ_ONLY,"isLoggedIn is a read-only property")}},retryTime:{get:function(){return"never"!==this._retryTime?this._retryTime:void 0},set:function(){throw new d(d.READ_ONLY,"retryTime is a read-only property")}},userId:{get:function(){return this._userId},set:function(){throw new d(d.READ_ONLY,"userId is a read-only property")}},cloudId:{get:function(){return this._cloudId},set:function(){throw new d(d.READ_ONLY,"cloudId is a read-only property")}},cloudInfo:{get:function(){return this._cloudInfo},set:function(){throw new d(d.READ_ONLY,"cloudInfo is a read-only property")}},isPublic:{get:function(){return!1},set:function(){throw new d(d.READ_ONLY,"isPublic is a read-only property")}},bookmarks:{get:function(){return this._bookmarkManager.getBookmarks()},set:function(){throw new d(d.READ_ONLY,"bookmarks is a read-only property")}},fontManager:{get:function(){return this._fontManager},set:function(){throw new d(d.READ_ONLY,"fontManager is a read-only property")}},operations:{get:function(){return this._operations},set:function(){throw new d(d.READ_ONLY,"operations is a read-only property")}}}),L.prototype.addChangeListener=function(e){this._listenerManager.add("change",e)},L.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},L.prototype.addDeepChangeListener=function(e){this._listenerManager.add("deepchange",e)},L.prototype.removeDeepChangeListener=function(e){this._listenerManager.remove("deepchange",e)},L.prototype.createLibrary=function(e){var t=r.uuid(),n=a.COMPOSITE_TYPE,o=this._getCompositeDir(t),s=r.dcx.newEmptyComposite(e,n,o,t);s.current.rootNode.setValue(a.VERSION_KEY,a.VERSION),this._syncManager.prepareCompositeForPush(s);var c=new i(this,s);return c._updateCreatedTime(),this._libraries.push(c),this._libraryIdMap[c.id]=c,this._notifyChange(!0),c._commit(!1,!0),p.reportCreateLibrary(c),c},L.prototype.removeLibrary=function(e,t){this._doRemoveLibrary(e,t),p.reportDeleteLibrary(e)},L.prototype.removeDeletedLibraries=function(e,t){var n=this,o=g.wrapCallback(t);"function"==typeof e&&(o=e,e=void 0);var i=e&&e.exclude||[];function r(e,t){var o=n._libraries.indexOf(e);-1!==o&&(n._libraries.splice(o,1),delete n._libraryIdMap[e.id]),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(n,e.id,t),e._markDeletedLocally(!0)}var a=new _,s=!1;this._libraries.forEach((function(e){if(e.isDeletedFromServer){var t=!0;i.forEach((function(n){t=t&&e!==n})),t&&(s=!0,a.addOperation(r,[e]))}})),a.run((function(e){s&&n._notifyChange(!0),o(e)}))},L.prototype.exportLibrary=function(e,t,n){if(-1!==this._libraries.indexOf(e))if("string"==typeof t)if(0===t.length||t[t.length-1].match(/\\|\//))n(new d(d.INVALID_PARAMETER,"path must end in a filename"));else{if(t.substring(t.length-a.EXPORT_EXTENSION.length)!==a.EXPORT_EXTENSION&&(t+=a.EXPORT_EXTENSION),a.SHARED_LOCAL_STORAGE||r.hasFileSystem())return this._doExportLibrary(e,t,(function(t){p.reportExportLibrary(t,e),n(t)}));n(new d(d.REQUIRES_FILESYSTEM,"exportLibrary only supported when you have a filesystem"))}else n(new d(d.INVALID_PARAMETER,"path must be a string"));else n(new d(d.INVALID_PARAMETER,"library not in this collection"))},L.prototype.importLibrary=function(e,t){if("string"==typeof e){if(a.SHARED_LOCAL_STORAGE||r.hasFileSystem())return this._doImportLibrary(e,(function(e,n){p.reportImportLibrary(e,n),t(e,n)}));t(new d(d.REQUIRES_FILESYSTEM,"importLibrary only supported when you have a filesystem"))}else t(new d(d.INVALID_PARAMETER,"path must be a string"))},L.prototype.sync=function(e){this._syncWithParameters(!1,!1,void 0,e)},L.prototype.syncChanges=function(e,t){var n={};(e=e||[]).forEach((function(e){n[e]=!0})),this._syncWithParameters(!1,!1,n,t)},L.prototype.syncFull=function(e){this._syncManager.clearSyncGroupCache(),this._syncWithParameters(!1,!1,void 0,e)},L.prototype.syncBookmarks=function(e){this._bookmarkManager.sync((function(t){e&&e(t)}))},L.prototype._syncWithParameters=function(e,t,n,o){var i=this,s=function(){o&&o(null)};if(a.SHARED_LOCAL_STORAGE)return r.storageInterface.sync(this),void s();if(a.SYNCING_ENABLED)if(this._retryTimeoutId)s();else{if(e||this._resetPollBackoff(),this.isPolling){if(this._syncing)return void s()}else if(this._syncing)return void i._pendingSyncs.push(s);if((new Date).valueOf()<this._lastSyncTime+a.MAX_SYNC_INTERVAL)return t?void s():void setTimeout((function(){i._syncWithParameters(e,!0,n,s)}),a.MAX_SYNC_INTERVAL);r.log("Start Sync: "+this.cloudId+(e?" [polling]":"")),this._syncing=!0,this._lastSyncTime=(new Date).valueOf(),this._dosync(n,(function(e,t){if(i._syncing=!1,i._updateSyncState(),r.log("End Sync: "+i.cloudId),t&&(i._backoffTicks=0,i._numBackoffs=0),i._pendingSyncs.length>0){var n=i._pendingSyncs;i._pendingSyncs=[],i.sync((function(){n.forEach((function(e){e()}))}))}s()}))}else s()},L.prototype.addSyncListener=function(e){this._listenerManager.add("sync",e)},L.prototype.removeSyncListener=function(e){this._listenerManager.remove("sync",e)},L.prototype.getPrimarySyncError=function(){var e=this._syncErrors[0];return this._syncErrors.forEach((function(t){var n=y.getErrorPriority(t),o=y.getErrorPriority(e);n>o?e=t:n===o&&e.code===t.code&&e.libraryId!==t.libraryId&&(e=new d(e.code,"multiple errors (see libraryCollection.syncErrors)",void 0))})),e},L.prototype.getNewLibrarySyncProgress=function(){var e=this;if(this._newLibraryProgress)return this._newLibraryProgress;var t=[];return Object.keys(this._libraryIdMap).forEach((function(n){"pending"===e._libraryIdMap[n]&&t.push({id:n,progress:e._syncProgressMap[n]&&e._syncProgressMap[n].progress})})),t},L.prototype.addOperationChangeListener=function(e){this._listenerManager.add("operation",e)},L.prototype.removeOperationChangeListener=function(e){this._listenerManager.remove("operation",e)},L.prototype.addCommitErrorListener=function(e){this._listenerManager.add("commitError",e)},L.prototype.removeCommitErrorListener=function(e){this._listenerManager.remove("commitError",e)},L.prototype.startPolling=function(){if(a.SHARED_LOCAL_STORAGE)throw new d(d.NOT_SUPPORTED,"startPolling() not supported with shared local storage");if(!this.isPolling){var e=this,t=6e4*a.POLL_INTERVAL;this._pollTimerId=setInterval((function(){"never"!==e._retryTime&&(e._backoffTicks>0?e._backoffTicks--:(0===e._backoffTicks&&(e._numBackoffs++,e._backoffTicks=E.getBackoffTicks(e._numBackoffs)),e._syncWithParameters(!0)))}),t)}},L.prototype.stopPolling=function(){if(a.SHARED_LOCAL_STORAGE)throw new d(d.NOT_SUPPORTED,"stopPolling() not supported with shared local storage");this.isPolling&&(clearInterval(this._pollTimerId),delete this._pollTimerId),this._retryTimeoutId&&(clearTimeout(this._retryTimeoutId),delete this._retryTimeoutId)},L.prototype.createBookmark=function(e,t,n){this._bookmarkManager.createBookmark(e,t,n)},L.prototype.removeBookmark=function(e,t){this._bookmarkManager.removeBookmark(e,t)},L.prototype.findBookmark=function(e){var t;return this.bookmarks&&this.bookmarks.some((function(n){if(n.url===e._dcxComposite.href)return t=n,!0})),t},L.prototype.getDefaultLibrary=function(){var e;return this.libraries.forEach((function(t){"incoming"!==t.collaboration&&(!e||(e.created||0)>(t.created||0))&&(e=t)})),e},L.prototype.getLibraryById=function(e){var t=this._libraryIdMap[e];if(t instanceof i)return t},L.prototype.getToolkitLibrary=function(e){var t=this._libraries.filter((function(t){return t.toolkitId===e}));if(t.length)return t.sort((function(e,t){return e.created-t.created})),t[0];var n=this.createLibrary(h.getToolkitName(e));return n.setValue(a.TOOLKIT_NAMESPACE,a.TOOLKIT_ID_KEY,e),n},L.prototype.updateAccessToken=function(e){if(a.SHARED_LOCAL_STORAGE)throw new d(d.NOT_SUPPORTED,"updateAccessToken() not supported with shared local storage");this._syncManager.updateAccessToken(e),r.log("defined")},L.prototype.getTempDir=function(e){if(r.hasFileSystem()){var t=this._getTempDir();f.ensurePathExists(t,(function(n){e(n,t)}))}else e(new d(d.REQUIRES_FILESYSTEM,"getTempDir only supported when you have a filesystem"))},L.prototype.copyFileToTempDir=function(e,t){this.getTempDir((function(n,o){if(n)t(n);else{var i=f.getFileExtension(e),a=o+r.getPathSeparator()+r.uuid()+(i?"."+i:"");f.copyFile(e,a,(function(e){e?f.deleteFile(a,(function(){return t(e)})):t(null,a)}))}}))},Object.freeze(L),Object.seal(L.prototype),e.exports=L},function(e,t,n){var o=n(0),i=n(5),r=n(6),a=function(e){return r.getCommitError(e)};e.exports={stat:function(e){var t=o.fs;return new Promise((function(n,o){return t.stat(e,(function(e,t){return e?o(a(e)):n(t)}))}))},statSync:function(e){try{return o.fs.statSync(e)}catch(e){}},unlink:function(e){var t=o.fs;return new Promise((function(n,o){return t.unlink(e,(function(e){return e?o(a(e)):n()}))}))},readdir:function(e){var t=o.fs;return new Promise((function(n,o){return t.readdir(e,(function(e,t){return e?o(a(e)):n(t)}))}))},rename:function(e,t){return new Promise((function(n,o){return i.rename(e,t,(function(e){return e?o(a(e)):n()}))}))},copy:function(e,t){return new Promise((function(n,o){return i.copyFile(e,t,(function(e){return e?o(a(e)):n()}))}))},ensureDir:function(e){return new Promise((function(t,n){return i.ensurePathExists(e,(function(e){return e?n(a(e)):t()}))}))},remove:function(e){var t=this;return this.stat(e).then((function(n){return n&&n.isDirectory()?new Promise((function(t,n){return i.recursiveDeleteDirectory(e,(function(e){return e?n(a(e)):t()}))})):t.unlink(e)}))}}},function(e,t,n){var o=n(0);e.exports={join:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.join(o.getPathSeparator())},relative:function(e,t){for(var n=o.getPathSeparator(),i=e.replace(/\\/g,n).split(n),r=t.replace(/\\/g,n).split(n);i[0]===r[0];)i.shift(),r.shift();return new Array(i.length).fill("..").concat(r).join(n)}}},function(e,t,n){var o=n(0),i=n(1),r=function(){return o.storageInterface.getServiceInfo()},a=function(){var e=r();return e&&e.apiVersion||0},s={supportsClearRenditionCache:function(){return a()>=7},supportsTestExternalLink:function(){return a()>=10},updateElementActionMap:function(e){if(r()){if(a()<9){var t=e.types;e.types=i.ELEMENT_ACTION_PRODUCT_MAP.types,e.types["application/vnd.adobe.element.image+dcx"]=t}i.ELEMENT_ACTION_PRODUCT_MAP=e}},formatElementActionMapForClient:function(e){return e<9?{types:i.ELEMENT_ACTION_PRODUCT_MAP.types["application/vnd.adobe.element.image+dcx"],products:i.ELEMENT_ACTION_PRODUCT_MAP.products,installedApps:i.ELEMENT_ACTION_PRODUCT_MAP.installedApps}:i.ELEMENT_ACTION_PRODUCT_MAP}};Object.seal(s),e.exports=s},function(e,t,n){var o=n(13),i=n(30),r=n(31),a=n(45),s=n(32),c=n(4),l=n(3),p=n(7),d=n(33);function h(e,t){e&&p._setFS(e),this._compositeOptions=c.merge({},t),t&&t.logCallback&&c._setLogCallback(t.logCallback)}h.COLLABORATION={PRIVATE:o.COLLABORATION.PRIVATE,SHARED_BY_USER:o.COLLABORATION.SHARED_BY_USER,SHARED_WITH_USER:o.COLLABORATION.SHARED_WITH_USER},h.AdobeDCXError=l,h.FileContent=i.FileContent,h.StreamProvider=i.StreamProvider,h.prototype.newEmptyComposite=function(e,t,n,i){var r=new o(e,t,null,i,null,this._compositeOptions);return n&&(r.path=n),r},h.prototype.newCompositeFromLocalStorage=function(e,t){try{if("string"!=typeof e)throw new l(l.INVALID_PARAMS,"");var n=new o(null,null,e,null,null,this._compositeOptions);n.loadCurrentFromLocalStorage((function(e){t(e,e?void 0:n)})),n.deleteTempFiles()}catch(e){t(e)}},h.prototype.newCompositeWithHref=function(e,t,n,i,r){var a=new o(n,r,null,i,e,this._compositeOptions);return t&&(a.path=t),a},h.prototype.newCompositeAsCopyOf=function(e,t,n,i,r,a){return o.newCompositeAsCopyOf(e,t,n,i,r,a,this._compositeOptions)},h.prototype.createHTTPService=function(e){return new i(e)},h.prototype.createStorageSession=function(e,t){return new r(e,t)},h.prototype.createCommunitySession=function(e,t){return new a(e,t)},h.prototype.compositeXfer=s,h.prototype.snapshot=d,e.exports=h},function(e,t,n){var o=n(3),i=n(39),r=n(20),a=n(7),s=n(4);function c(e,t,n){this._readOnly=n,this._owner=t,this._setData(e),this._localStorage=void 0}function l(e,t,n,i,r,a,c,l){var p=t._owner._core,d=e._owner._core,h=n&&e.id===t.id,u=d._getSourceHrefOfComponent(e),_=p.getComponentWithId(t.id),f=i&&(!_||!_.etag)&&"unmodified"===e.state,m=!h&&!u,y=m;if(r&&!_&&(u||m)&&e.id===t.id&&(t._data.id=s.generateUuid(),t.state="modified",t.etag=void 0,t.version=void 0,t.md5=void 0,t.length=void 0),a&&a._copyComponentMapping(e.id,l,t.id,c)&&(y=!1,h||(t.state="modified")),m){if(f){if(u=d._getHrefOfComponent(e),p._setSourceHrefOfComponent(u,t,c),!u&&y)throw new o(o.INVALID_STATE,"Failed to determine the source href of a component that does not have a local file.")}else if(y)throw new o(o.INVALID_STATE,"Could not use server-to-server copy for component "+e.id)}else p._setSourceHrefOfComponent(u,t,c);u&&(t.state="modified")}Object.defineProperties(c.prototype,{rootNode:{get:function(){return this.getChildWithAbsolutePath(i.ROOT_PATH)},set:function(){throw new o(o.READ_ONLY,'Property "rootNode" is read-only.')}},hasLocalStorage:{get:function(){return this._localStorage},set:function(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},isDirty:{get:function(){return this._isDirty},set:function(){throw new o(o.READ_ONLY,"Cannot set the property isDirty.")}},changeCount:{get:function(){return this._data.local&&this._data.local.change||0},set:function(){throw new o(o.READ_ONLY,"Cannot set the property changeCount.")}}}),c.prototype.getChildWithId=function(e){return this._allNodes[e]},c.prototype.getChildWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof i?t:void 0},c.prototype.getChildrenOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown node");var t,n=[],i=e._data.children;if(Array.isArray(i))for(t=0;t<i.length;t++){var r=i[t],a=this._allNodes[r.id];if(!a)throw new o(o.INVALID_DATA,"Node not in cache");n[n.length]=a}return n},c.prototype.addChild=function(e,t,n,r){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(t=t||s.generateUuid(),this._allNodes[t])throw new o(o.DUPLICATE_VALUE,"Node already exists in branch.");if(n&&("number"!=typeof n||n%1!=0))throw new o(o.INVALID_PARAMS,'Param "index" must be an integer.');var a=r?this._allNodes[r.id]:this.rootNode;if(!a)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var c=new i;c.id=t,e&&(c.name=e),c._parentPath=a.absolutePath||a._parentPath;var l=a._data.children;return l?(n>=0&&n<=l.length||(n=l.length),n===l.length?l[n]=c._data:l.splice(n,0,c._data)):a._data.children=[c._data],this._allNodes[c.id]=c,c._owner=this._owner,this._setDirty(),c},c.prototype.removeChild=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new o(o.INVALID_PARAMS,"Cannot remove the root node.");var t=e.id;if(!t)throw new o(o.INVALID_PARAMS,'Param "node" must have an id.');var n=this._nodeDataOfParentOfNode(e);if(!n)throw new o(o.INVALID_PARAMS,"Node not found in this branch.");return n.parentNodeData.children.splice(n.index,1),0===n.parentNodeData.children.length&&delete n.parentNodeData.children,e=this._allNodes[t],this._removeNodeFromCachesRecursively(e._data),this._setDirty(),e},c.prototype.moveChild=function(e,t,n){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new o(o.INVALID_PARAMS,"Cannot move the root node.");if(t&&("number"!=typeof t||t%1!=0))throw new o(o.INVALID_PARAMS,'Param "index" must be an integer.');var i=e.id;if(!i)throw new o(o.INVALID_PARAMS,'Param "node" must have an id.');var r=this._nodeDataOfParentOfNode(e);if(e=this._allNodes[i],!r)throw new o(o.INVALID_PARAMS,"Node not found in this branch.");var a=n?this._allNodes[n.id]:this.rootNode;if(!a)throw new o(o.INVALID_PARAMS,"Unknown parent node.");if(this._nodeIdIsDescendantOf(a.id,e._data))throw new o(o.INVALID_PARAMS,"Must not create a cycle.");var s=r.parentNodeData.children.splice(r.index,1)[0];try{var c=a._data.children;c?(t>=0&&t<=c.length||(t=c.length),t===c.length?c[t]=s:c.splice(t,0,s)):a._data.children=[s]}catch(e){throw r.parentNodeData.children.splice(r.index,0,s),e}return 0===r.parentNodeData.children.length&&delete r.parentNodeData.children,this._setDirty(),this._allNodes[i]},c.prototype.copyChild=function(e,t,n,o,i,r){return this._copyChild(e,t,n,o,i,!1,r)},c.prototype.replaceChild=function(e,t,n,o){return this._copyChild(e,void 0,void 0,t,n||e.id,!0,o)},c.prototype.allComponents=function(){var e,t=[];for(e in this._allComponents)this._allComponents.hasOwnProperty(e)&&t.push(this._allComponents[e]);return t},c.prototype.getComponentWithId=function(e){return this._allComponents[e]},c.prototype.getComponentWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof r?t:void 0},c.prototype.getComponentsOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown node");var t,n=[],i=e._data.components;if(Array.isArray(i))for(t=0;t<i.length;t++){var r=i[t],a=this._allComponents[r.id];if(!a)throw new o(o.INVALID_DATA,"Component not in cache");n[n.length]=a}return n},c.prototype.addComponent=function(e,t,n,i,a,c,l,p,d,h){var u=this._localStorage;if(!u)throw new o(o.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadNewComponent() followed by addComponentWithUploadResults()");if("function"!=typeof h&&a)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(d&&"string"!=typeof d)throw new o(o.INVALID_PARAMS,'Param "id" must be of type string.');if(!a&&!l)throw new o(o.INVALID_PARAMS,"Must provide either source or sourceHref.");try{if(l){var _=this._getBranchOf(this).compositeHref;if(_){var f=s.endPointOf(_),m=s.endPointOf(l);if(f&&m&&f!==m)throw new o(o.WRONG_ENDPOINT,"Given source href has an invalid endpoint: "+m)}}var y=this._local();d=d||s.generateUuid();var E=new r;E.id=d,E.name=e,E.type=t,E.relationship=n,E.path=i,E.state="modified";var g=this,v=function(e){if(!e)try{if(d&&g._allComponents[d])throw new o(o.DUPLICATE_VALUE,'The "id" of a component must be unique.');var t=p?g._allNodes[p.id]:g.rootNode;if(!t)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var n=g._normalizedAbsolutePathForItem(E,t);if(g._absolutePaths[n])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+n);if(!s.isValidAbsolutePath(n))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+n);E._parentPath=t.absolutePath||t._parentPath;var i=t._data.components;i?i.push(E._data):t._data.components=[E._data],E._owner=g._owner,l&&g._setSourceHrefOfComponent(l,E),g._allComponents[E.id]=E,g._absolutePaths[n]=E,g._setDirty()}catch(t){u.removeComponentAsset(E,y),l&&g._setSourceHrefOfComponent(void 0,E),E=void 0,e=t}if(h)return h(e,E);if(e)throw e;return E};if(!a)return v();u.ingestComponentAsset(E,a,c,y,v)}catch(e){if(h)return h(e);throw e}},c.prototype.addComponentWithUploadResults=function(e,t,n,i,a){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(a.compositeId!==this._owner.compositeId)throw new o(o.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var s=Object.keys(a.records);if(1!==s.length)throw new o(o.INVALID_PARAMS,"Param uploadResults must contain records of exactly one component upload.");if(this._localStorage)throw new o(o.INVALID_PARAMS,"This method is for in-browser use only. Use addComponent() instead.");var c=a.records[s[0]],l=c.id;if(this._allComponents[l])throw new o(o.DUPLICATE_VALUE,"Duplicate component id: "+l);var p=i?this._allNodes[i.id]:this.rootNode;if(!p)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var d=new r;d.id=l,d.name=e,d.type=c.type,d.relationship=t,d.path=n,d.state="unmodified",d.etag=c.etag,d.length=c.length,d.version=c.version,d.md5=c.md5;var h=this._normalizedAbsolutePathForItem(d,p);if(this._absolutePaths[h])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+h);d._parentPath=p.absolutePath||p._parentPath;var u=p._data.components;return u?u.push(d._data):p._data.components=[d._data],d._owner=this._owner,this._allComponents[l]=d,this._absolutePaths[h]=d,this._setDirty(),d},c.prototype.updateComponent=function(e,t,n,i){var r=this._localStorage;if(!r)throw new o(o.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadComponent() to upload a new component asset and then call updateComponentWithUploadResults()");if("function"!=typeof i)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new o(o.INVALID_PARAMS,"Unknown component.");try{var a=this;r.ingestComponentAsset(e,t,n,this._local(),(function(t){if(!t)try{"modified"!==e.state?e.state="modified":a._setDirty(),a._setSourceHrefOfComponent(void 0,e)}catch(n){t=n,e=void 0}i(t,e)}))}catch(e){i(e)}},c.prototype.updateComponentWithUploadResults=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new o(o.INVALID_PARAMS,"Unknown component.");if(this._localStorage)throw new o(o.INVALID_PARAMS,"This method is for in-browser use only. Use updateComponent() instead.");if(t.compositeId!==this._owner.compositeId)throw new o(o.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var n=t.records[e.id];if(!n)throw new o(o.INVALID_PARAMS,"Param uploadResults does not contain an upload record for the given component.");return e.etag=n.etag,e.version=n.version,e.md5=n.md5,e.length=n.length,e},c.prototype.removeComponent=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var t=e.id;if(!t)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var n=this._nodeDataOfParentOfComponent(e);if(!n)throw new o(o.INVALID_PARAMS,"Component not found in this branch.");return n.parentNodeData.components.splice(n.index,1),0===n.parentNodeData.components.length&&delete n.parentNodeData.components,e=this._allComponents[t],delete this._allComponents[t],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._localStorage&&(this._localStorage.removeComponentAsset(e,this._local()),this._setSourceHrefOfComponent(void 0,e)),e._owner=void 0,e._parentPath="",this._setDirty(),e},c.prototype.moveComponent=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var n=e.id;if(!n)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var i=this._nodeDataOfParentOfComponent(e);if(!i)throw new o(o.INVALID_PARAMS,"Component not found in this branch.");var r=t?this._allNodes[t.id]:this.rootNode;if(!r)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var a=this._normalizedAbsolutePathForItem(e,r);if(this._absolutePaths[a])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+a);var s=i.parentNodeData.components.splice(i.index,1)[0],c=r._data.components;return c?c.push(s):r._data.components=[s],0===i.parentNodeData.components.length&&delete i.parentNodeData.components,e=this._allComponents[n],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],e._parentPath=r.absolutePath||r._parentPath,this._absolutePaths[a]=e,this._setDirty(),e},c.prototype.copyComponent=function(e,t,n,o,i){return this._copyComponent(e,t,n,o,!1,i)},c.prototype.replaceComponent=function(e,t,n,o){return this._copyComponent(e,void 0,t,n||e.id,!0,o)},c.prototype.assetOfComponent=function(e,t){try{if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');if(!e.id)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var n=this._localStorage.componentAssetPath(e,this._local());if(!t)return n;a.exists(n,(function(e){t(void 0,e?n:null)}))}catch(e){if(!t)throw e;t(e)}},c.prototype._getHrefOfComponent=function(e){var t,n=this._getBranchOf(e).compositeHref;return n&&void 0!==e.version&&(t=s.appendPathElements(n,e.id),t+=";version="+e.version),t},c.prototype._setSourceHrefOfComponent=function(e,t,n){var o=t.id,i=this._componentSourceHrefLookup(!0,n);e?i[o]=e:i[o]&&delete i[o]},c.prototype._getSourceHrefOfComponent=function(e,t){var n=e.id,o=this._componentSourceHrefLookup(!1,t);if(o)return o[n]},c.prototype._copySourceHrefsFrom=function(e){var t=e._componentSourceHrefLookup(!1),n=this.allComponents(),o=n.length;if(o&&t){var i,r=this._componentSourceHrefLookup(!0);for(i=0;i<o;i++){var a=n[i].id;r[a]=t[a]}}},c.prototype._getBranchOf=function(e){return e._owner?this._getBranchOf(e._owner):e},c.prototype._isSameComposite=function(e){var t=this._getBranchOf(this),n=this._getBranchOf(e);return t._data.id===n._data.id&&t.compositeHref===n.compositeHref&&this._localStorage===e._localStorage},c.prototype._stringify=function(e,t){if(e){var n=this._data.local,o=null;try{delete this._data.local,o=JSON.stringify(this._data,void 0,t?2:void 0)}catch(e){throw e}finally{n&&(this._data.local=n)}return o}return JSON.stringify(this._data,void 0,t?2:void 0)},c.prototype._setData=function(e){var t=new i(e,this._readOnly,!0);t._owner=this._owner,t._parentPath="";var n={},a={},c={};a[t.id]=t,c[i.ROOT_PATH]=t;var l=this;return function e(t,n,a,c,p){var d,h,u,_=t.components;if(Array.isArray(_))for(d=0;d<_.length;d++){var f=_[d],m=new r(f,l._readOnly);if(n[m.id])throw new o(o.INVALID_DATA,"Duplicate component id: "+m.id);if(m._owner=l._owner,m._parentPath=p,c[u=l._normalizedAbsolutePathForItem(m)])throw new o(o.INVALID_DATA,"Duplicate absolute path: "+u);if(!s.isValidAbsolutePath(u))throw new o(o.INVALID_DATA,"Invalid absolute component path: "+u);n[m.id]=m,c[u]=m}var y=t.children;if(Array.isArray(y))for(d=0;d<y.length;d++){var E=y[d],g=new i(E,l._readOnly);if(a[g.id])throw new o(o.INVALID_DATA,"Duplicate node id: "+g.id);if(h=g.path,g._owner=l._owner,g._parentPath=p,h){if(c[u=l._normalizedAbsolutePathForItem(g)])throw new o(o.INVALID_DATA,"Duplicate absolute path: "+u);if(!s.isValidAbsolutePath(u))throw new o(o.INVALID_DATA,"Invalid node absolute path: "+u);c[u]=g}a[g.id]=g,e(E,n,a,c,g.path?s.appendPathElements(p,g.path):p)}}(e,n,a,c,i.ROOT_PATH),this._data=e,this._allComponents=n,this._allNodes=a,this._absolutePaths=c,this._isDirty=!1,this},c.prototype._removeNodeFromCachesRecursively=function(e){var t,n=e.components;if(Array.isArray(n))for(t=0;t<n.length;t++){var o=n[t].id,i=this._allComponents[o];delete this._allComponents[o],delete this._absolutePaths[this._normalizedAbsolutePathForItem(i)],i._owner=void 0,this._localStorage&&(this._localStorage.removeComponentAsset(i,this._local()),this._setSourceHrefOfComponent(void 0,i))}var r=e.children;if(Array.isArray(r))for(t=0;t<r.length;t++)this._removeNodeFromCachesRecursively(r[t]);var a=e.id,s=this._allNodes[a];delete this._allNodes[a],s.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(s)],s._owner=void 0},c.prototype._local=function(){return this._data.local||(this._data.local={version:2}),this._data.local},c.prototype._componentSourceHrefLookup=function(e,t){if(e&&this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(t||(t=e?this._local():this._data.local)){var n=t["componentS2SCopy#srcHref"];return!n&&e&&(n=t["componentS2SCopy#srcHref"]={}),n}},c.prototype._recursiveReset=function(e,t){var n,o=e.components;if(o)for(n=o.length-1;n>=0;n--){var i=o[n];"committedDelete"===i.state?(delete o[n],delete this._allComponents[i.id],delete i._owner,this._localStorage&&this._localStorage.removeComponentAsset(i,this._local()),this._setSourceHrefOfComponent(void 0,i,this._local())):(delete i.etag,delete i.version,delete i.length,delete i.md5,i.state="modified",t&&t(i))}var r=e.children;if(r)for(n=0;n<r.length;n++)this._recursiveReset(r[n],t)},c.prototype._nodeIdIsDescendantOf=function(e,t){var n,o=t.children;if(o)for(n=0;n<o.length;n++){var i=o[n];if(i.id===e||this._nodeIdIsDescendantOf(e,i))return!0}return!1},c.prototype._recursivelyGetAllComponentsOfChild=function(e,t){t=t||[];var n,o,i=e._data||e,r=i.components;if(r)for(o=r.length,n=0;n<o;n++)t[t.length]=this._allComponents[r[n].id];var a=i.children;if(a)for(o=a.length,n=0;n<o;n++)t=this._recursivelyGetAllComponentsOfChild(a[n],t);return t},c.prototype._nodeDataOfParentOfNode=function(e,t){t=t||this._data;var n,o=e._data.id,i=t.children;if(i)for(n=0;n<i.length;n++){var r=i[n];if(r.id===o)return{parentNodeData:t,index:n};var a=this._nodeDataOfParentOfNode(e,r);if(a)return a}return null},c.prototype._nodeDataOfParentOfComponent=function(e,t){t=t||this._data;var n,o=e._data.id,i=t.components;if(i)for(n=0;n<i.length;n++)if(i[n].id===o)return{parentNodeData:t,index:n};var r=t.children;if(r)for(n=0;n<r.length;n++){var a=r[n],s=this._nodeDataOfParentOfComponent(e,a);if(s)return s}return null},c.prototype._determineAbsolutePathChangesRecursively=function(e,t,n){var o,i=e.components;if(i)for(o=0;o<i.length;o++){var r=i[o],a=this._allComponents[r.id];n.push({item:a,parentPath:t,absPath:s.appendPathElements(t,r.path)})}var c=e.children;if(c)for(o=0;o<c.length;o++){var l=c[o],p=this._allNodes[l.id],d=l.path,h=d?s.appendPathElements(t,d):t;n.push({item:p,parentPath:t,absPath:d?h:void 0}),this._determineAbsolutePathChangesRecursively(l,h,n)}},c.prototype._setPathOfNode=function(e,t){var n=t?s.appendPathElements(e.parentPath,t):e.parentPath,i=[{item:e,absPath:t?n:void 0}];this._determineAbsolutePathChangesRecursively(e._data,n,i);var r,a,c=s.flatCopy(this._absolutePaths);for(r=0;r<i.length;r++){var l=i[r].item;l._data.path&&delete c[this._normalizedAbsolutePathForItem(l)]}for(r=0;r<i.length;r++)if((a=i[r]).absPath){var p=a.absPath.toLowerCase();if(c[p])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+p);if(!s.isValidAbsolutePath(p))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+p);c[p]=a.item}for(r=0;r<i.length;r++)(a=i[r]).parentPath&&(a.item._parentPath=a.parentPath);e._data.path=t,this._absolutePaths=c},c.prototype._setPathOfComponent=function(e,t){if(!this._allComponents[e.id])throw new o(o.INVALID_PARAMS,"Unknown component.");var n=s.appendPathElements(e.parentPath,t).toLowerCase();if(this._absolutePaths[n])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path for component: "+n);if(!s.isValidAbsolutePath(n))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+n);delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._absolutePaths[n]=e,e._data.path=t},c.prototype._setDirty=function(e){if(!e){if("pending"===this._local().archivalState||"archived"===this._local().archivalState)throw new o(o.INVALID_STATE,"Cannot modify an archived composite.");"pendingDelete"!==this._data.state&&"committedDelete"!==this._data.state||console.error("Modifying deleted composite")}this._isDirty=!0,this._local().change=this.changeCount+1,e||"unmodified"!==this._data.state&&this._data.state||(this._data.state="modified")},c.prototype._normalizedAbsolutePathForItem=function(e,t){return(t?s.appendPathElements(t.absolutePath||t._parentPath,e.path):e.absolutePath).toLowerCase()},c.prototype._hasSameEndpoint=function(e){var t=this._getBranchOf(this).compositeHref,n=this._getBranchOf(e).compositeHref;if(t&&n){var o=s.endPointOf(t),i=s.endPointOf(n);if(o&&i&&o!==i)return!1}return!0},c.prototype._copyComponent=function(e,t,n,i,r,a){if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');if(a&&"function"!=typeof a)throw new o(o.INVALID_PARAMS,"Param callback must be a function.");var s=this,c=e._owner._core,p=this._isSameComposite(c),d=p||this._hasSameEndpoint(e),h=c._local(),u=this._localStorage,_=c._localStorage,f=u&&_;if(f&&!a&&!p)throw new o(o.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!f&&!d)throw new o(o.NO_LOCAL_STORAGE,"Cannot copy between two different endpoints without local storage.");var m=function(e,t,n){l(e,t,p,d,!i,f?u:void 0,n,h)},y=f?_.componentAssetPath(e,h):void 0;if(!a)return this._copyComponentModel(e,t,r,n,i,m);if(p||!y)try{a(void 0,this._copyComponentModel(e,t,r,n,i,m))}catch(e){a(e)}else{var E={};u.ingestComponentAsset(e,y,!0,E,(function(o){if(o)a(o);else try{h=E,a(void 0,s._copyComponentModel(e,t,r,n,i,m))}catch(e){a(e)}}))}},c.prototype._copyComponentModel=function(e,t,n,i,a,c){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var l=e._owner,p=new r(JSON.parse(JSON.stringify(e._data)));i?(p.path=i,p.id=a||s.generateUuid()):a&&(p.id=a),p._owner=this._owner,e.id===p.id&&this._isSameComposite(l._core)||(p.state="modified",p.etag=void 0,p.version=void 0,p.md5=void 0,p.length=void 0);var d,h,u=this._allComponents[p.id];if(u&&!n)throw new o(o.DUPLICATE_VALUE,"Component already exists.");if(n&&!u)throw new o(o.INVALID_PARAMS,"Could not find existing component.");if(n){var _=this._nodeDataOfParentOfComponent(u);if(!_)throw new o(o.INVALID_PARAMS,"Parent node of existing component not found in this branch.");var f=_.parentNodeData.id;if(!(h=this._allNodes[f]))throw new o(o.INVALID_STATE,"Unknown parent node.");d=_.index}else if(!(h=t?this._allNodes[t.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown parent node.");p._parentPath=h.absolutePath||h._parentPath;var m=this._normalizedAbsolutePathForItem(p),y=this._absolutePaths[m];if(y&&y!==u)throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+m);if(!s.isValidAbsolutePath(m))throw new o(o.INVALID_PARAMS,"Component path must be a valid path for a component.");var E=this._local();c&&c(e,p,E=s.deepCopy(E));var g=h._data.components;return n?g[d]=p._data:g?g.push(p._data):h._data.components=[p._data],this._data.local=E,this._allComponents[p.id]=p,this._absolutePaths[m]=p,this._setDirty(),p},c.prototype._copyChild=function(e,t,n,i,r,a,s){if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');var c=this,p=e._owner._core,d=this._isSameComposite(p),h=d||this._hasSameEndpoint(e),u=p._local(),_=this._localStorage,f=p._localStorage,m=_&&f,y=p._recursivelyGetAllComponentsOfChild(e);if(y.length>0){if(m&&!s&&!d)throw new o(o.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!m&&!h)throw new o(o.NO_LOCAL_STORAGE,"Cannot copy components between two different endpoints without local storage.")}var E=function(e,t,n){l(e,t,d,h,!0,m?_:void 0,n,u)};if(!s)return this._copyChildModel(e,t,n,a,i,r,E);var g=function(){s(void 0,c._copyChildModel(e,t,n,a,i,r,E))};if(0===y.length||d||!m)try{g()}catch(e){s(e)}else{var v,A,C={},O=y.length,L=0,S=function(e){if(e&&!A&&(A=e),0==--L)if(A)s(A);else try{u=C,g()}catch(e){s(e)}};for(v=0;v<O;v++){var I=y[v],R=f.componentAssetPath(I,u);R&&(L++,_.ingestComponentAsset(I,R,!0,C,S))}if(0===L)try{g()}catch(e){s(e)}}},c.prototype._copyChildModel=function(e,t,n,a,c,l,p){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");var d=e._owner,h=new i(JSON.parse(JSON.stringify(e._data)));c?(h.path=c,h.id=l||s.generateUuid()):l&&(h.id=l),h._owner=this._owner,e.isRoot&&(delete h._data.local,delete h._data["manifest-format-version"]);var u,_=this._allNodes[h.id];if(_&&!a)throw new o(o.DUPLICATE_VALUE,"Child node already exists.");if(a&&!_)throw new o(o.INVALID_PARAMS,"Could not find existing node to replace.");if(a){var f=this._nodeDataOfParentOfNode(_);if(!f)throw new o(o.INVALID_PARAMS,"Parent of existing node not found in this branch.");var m=f.parentNodeData.id;if(!(u=this._allNodes[m]))throw new o(o.INVALID_STATE,"Unknown parent node.");n=f.index}else if(!(u=t?this._allNodes[t.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown parent node.");if(h._parentPath=u.absolutePath||u._parentPath,h.path){var y=this._normalizedAbsolutePathForItem(h),E=this._absolutePaths[y];if(E&&E!==_)throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+y);if(!s.isValidAbsolutePath(y))throw new o(o.INVALID_PARAMS,"Node path must be a valid path for a node.")}var g=s.flatCopy(this._allNodes),v=s.flatCopy(this._allComponents),A=s.flatCopy(this._absolutePaths),C=s.deepCopy(this._local());if(_&&function e(t,n,o,i,r,a){var s,c;delete o[t.id],t.path&&delete r[n._normalizedAbsolutePathForItem(t)];var l=t._data.children;if(l)for(c=l.length,s=0;s<c;s++)e(o[l[s].id],n,o,i,r,a);var p=t._data.components;if(p)for(c=p.length,s=0;s<c;s++){var d=i[p[s].id];delete i[d.id],delete r[n._normalizedAbsolutePathForItem(d)],n._localStorage&&(n._localStorage.removeComponentAsset(d,a),n._setSourceHrefOfComponent(void 0,d,a))}}(_,this,g,v,A,C),function e(t,n,a,c,l,d,h,u){if(c[t.id])throw new o(o.DUPLICATE_VALUE,"Duplicate node id: "+t.id);var _;if(c[t.id]=t,t.path){if(d[_=n._core._normalizedAbsolutePathForItem(t)])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+_);d[_]=t}var f,m,y=t._data.children;if(y)for(m=y.length,f=0;f<m;f++){var E=new i(y[f]);c[E.id]&&(E.id=s.generateUuid()),E._owner=n,E._parentPath=t.absolutePath||t._parentPath,e(E,n,a,c,l,d,h,u)}var g=t._data.components;if(g)for(m=g.length,f=0;f<m;f++){var v=new r(g[f]),A=v.id;if(l[A]&&(v.id=s.generateUuid(),v.state="modified",v.etag=void 0,v.version=void 0,v.md5=void 0,v.length=void 0),v._owner=n,v._parentPath=t.absolutePath||t._parentPath,p&&p(a.getComponentWithId(A),v,h),l[v.id])throw new o(o.DUPLICATE_VALUE,"Duplicate component id: "+v.id);if(l[v.id]=v,d[_=n._core._normalizedAbsolutePathForItem(v)])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+_);d[_]=v}}(h,this._owner,d,g,v,A,C,d._local()),a)u._data.children[n]=h._data;else{var O=u._data.children;O?(n>=0&&n<=O.length||(n=O.length),n===O.length?O[n]=h._data:O.splice(n,0,h._data)):u._data.children=[h._data]}return this._allNodes=g,this._allComponents=v,this._absolutePaths=A,this._data.local=C,this._setDirty(),h},c.prototype._verifyIntegrity=function(e,t,n){var r,a=this,c=[],l=!1,p=function(e){return c.push(new o(o.INVALID_STATE,e)),t&&(l||(t("Branch for composite "+a.rootNode.id+" has the following errors:"),l=!0),t("   "+e)),!1},d=function(e,t){return!!e||p(t)},h=[],u=function(e){(h.indexOf(e)<0||p("Item "+e.id+" encountered more than once"))&&h.push(e)},_=s.flatCopy(this._allComponents),f=s.flatCopy(this._allNodes),m=s.flatCopy(this._absolutePaths),y=Object.keys(m),E=y.length;for(r=0;r<E;r++){var g=y[r];d("/"===g.charAt(0),"Absolute path "+g+" does not start with a slash.")}var v=m[i.ROOT_PATH];d(v,"Cannot find root node via path")&&(d(v.id===this._data.id,"Root node has correct id"),d(v.path===i.ROOT_PATH,"Root node has correct path"),d(""===v._parentPath,"Root node has correct parent path"),d(v._owner===this._owner,"Root node has correct owner"),d(v._data===this._data,"Root node has correct data"),d(f[v.id]===v,"Cannot find root node via id")&&delete f[v.id],delete m[i.ROOT_PATH]),function e(t,n){var o,i,r=t.children;if(r)for(o=0;o<r.length;o++){var c=r[o],l=f[c.id];(l||p("Node "+c.id+" is not in cache."))&&(u(l),d(l._data===c,"Node "+l.id+" _data property incorrect."),delete f[l.id],l.path&&l._owner&&(i=a._normalizedAbsolutePathForItem(l),(m[i]||p("Absolute path of node "+l.id+" ("+i+") is not in cache."))&&delete m[i]),d(l._parentPath===n,"Parent path of node "+l.id+" should be "+n+" but is "+l._parentPath),d(l._owner===a._owner,"Node "+l.id+" _owner property is not correct.")),e(c,c.path?s.appendPathElements(n,c.path):n)}var h=t.components;if(h)for(o=0;o<h.length;o++){var y=h[o],E=_[y.id];(E||p("Component "+y.id+" is not in cache."))&&(u(E),d(E._data===y,"Component "+E.id+" _data property incorrect."),delete _[E.id],E._owner&&(i=a._normalizedAbsolutePathForItem(E),(m[i]||p("Absolute path "+i+" is not in cache."))&&delete m[i]),d(E._parentPath===n,"Parent path of component "+E.id+" should be "+n+" but is "+E._parentPath),d(E._owner===a._owner,"Component "+E.id+" _owner property is not correct."))}}(this._data,i.ROOT_PATH);var A=Object.keys(_);for(r=0;r<A.length;r++)p("Component "+A[r]+" is in cache but could not be found.");for(A=Object.keys(f),r=0;r<A.length;r++)p("Node "+A[r]+" is in cache but could not be found.");for(A=Object.keys(m),r=0;r<A.length;r++)p("Absolute path "+A[r]+" is in cache but could not be found.");if(this._localStorage){var C=this._localStorage.componentIds(this._local());for(r=0;r<C.length;r++)d(this._allComponents[C[r]],"Component "+C[r]+" is in local storage mapping but could not be found in the manifest.");if(e)for(C=Object.keys(this._allComponents),r=0;r<C.length;r++){var O=C[r],L=this._allComponents[O],S=this._localStorage.componentAssetPath(L,this._local());d(S,"Component "+O+" does not have an entry in local storage mapping.")&&n&&d(n.existsSync(S),"Asset "+S+" does not exist.")}var I=this._componentSourceHrefLookup();if(I)for(E=(C=Object.keys(I)).length,r=0;r<E;r++){var R=this._allComponents[C[r]];R?d("modified"===R.state,"Component "+C[r]+" is in local source href mapping but has a state of "+R.state):d(!1,"Component "+C[r]+" is in local source href mapping but could not be found in the manifest.")}}return c.length?c:null},e.exports=c},function(e,t,n){var o=n(40),i=n(42);e.exports=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var s=0;s<16;++s)t[r+s]=a[s];return t||i(a)}},function(e,t,n){var o=n(3),i=n(7),r=3;function a(e,t,n){n?this._setData(n,e.href):this._data={"push-journal-format-version":r,"composite-href":e.href,"uploaded-components":{}},this._filePath=t,this._waitingCallbacks=[],this._commitInProgress=!1,this._needAnotherCommit=!1}a.readJournal=function(e,t,n,o){i.readFile(e,"utf8",(function(i,r){var s;if(i&&i.code&&n&&(i=void 0),!i)try{r=JSON.parse(r),s=new a(t,e,r)}catch(o){n?s=new a(t,e):i=o}o(i,i?void 0:s)}))},Object.defineProperties(a.prototype,{compositeHref:{get:function(){return this._data["composite-href"]},set:function(){throw new o(o.READ_ONLY,"This property is read-only.")}},manifestEtag:{get:function(){return this._data.etag},set:function(e){e?this._data.etag=e:delete this._data.etag}},currentBranchEtag:{get:function(){return this._data["current-branch-etag"]},set:function(e){e?this._data["current-branch-etag"]=e:delete this._data["current-branch-etag"]}},changeCount:{get:function(){return this._data.change},set:function(e){e?this._data.change=e:delete this._data.change}},compositeHasBeenCreated:{get:function(){return!!this._data["composite-created"]},set:function(e){e?this._data["composite-created"]=!0:delete this._data["composite-created"]}},compositeHasBeenDeleted:{get:function(){return!!this._data["composite-deleted"]},set:function(e){e?this._data["composite-deleted"]=!0:delete this._data["composite-deleted"]}},compositeHasBeenArchived:{get:function(){return!!this._data["composite-archived"]},set:function(e){e?this._data["composite-archived"]=!0:delete this._data["composite-archived"]}},isEmpty:{get:function(){return 0===Object.keys(this._data["uploaded-components"]).length&&!this.compositeHasBeenDeleted&&!this.manifestEtag},set:function(){throw new o(o.READ_ONLY,"This property is read-only.")}},isComplete:{get:function(){return!!(this._data.etag&&this._data.change||this._data["composite-deleted"]||this._data["composite-archived"])},set:function(){throw new o(o.READ_ONLY,"This property is read-only.")}}}),a.prototype.recordUploadedComponent=function(e,t,n,o,i,r,a){var s={etag:t,length:i,version:n,md5:o};r&&(s["storage-name"]=r),a&&(s["source-href"]=a),s.timestamp=(new Date).toISOString(),this._data["uploaded-components"][e]=s},a.prototype.idsOfAllUploadedComponents=function(){return Object.keys(this._data["uploaded-components"])},a.prototype.getRecordForUploadedComponent=function(e){var t=this._data["uploaded-components"][e];if(t&&!this.isComplete){var n=t.timestamp;if(!n)return this.removeRecordForUploadedComponent(e);if(n=new Date(n),isNaN(n.getTime()))return this.removeRecordForUploadedComponent(e);if(Date.now()-n.getTime()>=6048e5)return this.removeRecordForUploadedComponent(e)}return t},a.prototype.removeRecordForUploadedComponent=function(e){delete this._data["uploaded-components"][e]},a.prototype.applyToBranch=function(e,t){if(!this.isComplete)throw new o(o.INVALID_STATE,"Journal is not complete.");var n=e.isDirty;if(this.compositeHasBeenDeleted)e._data.state="committedDelete",e.manifestEtag=this.manifestEtag;else{this.compositeHasBeenArchived&&(e.compositeArchivalState="archived");var i,r="unmodified"!==e.compositeState&&this.changeCount!==e.changeCount,a=this.idsOfAllUploadedComponents(),s=a.length;for(i=0;i<s;i++){var c=a[i],l=e.getComponentWithId(c);if(l){var p=this.getRecordForUploadedComponent(l.id);l._data.etag=p.etag,l._data.length=p.length,l._data.version=p.version,l._data.md5=p.md5,p["source-href"]?e._core._getSourceHrefOfComponent(l)===p["source-href"]&&(l._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,l)):e.hasLocalStorage&&e._localStorage.componentAssetName(l,e._local())===p["storage-name"]?(l._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,l)):e.hasLocalStorage||(l._data.state="unmodified")}}e.manifestEtag=this.manifestEtag,r||(e._data.state="unmodified")}t&&(e._isDirty=n)},a.prototype.commitChanges=function(e){if(this._filePath){var t=this;t._commitInProgress?(this._needAnotherCommit=!0,e&&this._waitingCallbacks.push(e)):function e(n){t._needAnotherCommit=!1,t._commitInProgress=!0,t._waitingCallbacks=[],i.writeFileAtomically(t._filePath,JSON.stringify(t._data),"utf8",(function(o){var i,r=n.length;for(i=0;i<r;i++)try{n[i](o)}catch(e){}t._needAnotherCommit?e(t._waitingCallbacks):t._commitInProgress=!1}))}(e?[e]:[])}else e&&e()},a.prototype._setData=function(e,t){if(e["push-journal-format-version"]<=2){var n=e["uploaded-components"];if(n){var o,i=Object.keys(n),a=i.length;for(o=0;o<a;o++){var s=n[i[o]];"number"==typeof s.version&&(s.version=String(s.version))}}e["push-journal-format-version"]=r}var c=this._verify(e,t);if(null===c)return this._data=e,this;throw c},a.prototype._verify=function(e,t){return e["push-journal-format-version"]!==r?new o(o.INVALID_DATA,"Wrong push journal format version."):e["composite-href"]!==t?new o(o.INVALID_DATA,"Composite and journal hrefs mismatch."):e["uploaded-components"]?null:new o(o.INVALID_DATA,"Missing component list.")},e.exports=a},function(e,n,o){var i,r,a=o(4),s=o(3),c=o(7);i=window.XMLHttpRequest;var l=a.merge;function p(e){this.filename=e}function d(){}function h(e){this._requestQueue=[],this._requestsOutstanding=[],this._rejectedAuths=[],this._authCallback=e,this._isActive=!0,this._waitingForAuthentication=!1,this._currentAuthId=a.generateUuid(),this._https=r,this._XMLHttpRequest=i,this._handlesRedirects=void 0!==i,this._maxOutstanding=5}Object.defineProperties(h.prototype,{isActive:{get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e||(this._authValue=void 0,this._checkQueue()))}},crossOriginCredentials:{get:function(){return this._withCredentials},set:function(e){this._withCredentials=e}},maxOutstanding:{get:function(){return this._maxOutstanding},set:function(e){this._maxOutstanding=e,this._checkQueue()}},handlesRedirects:{get:function(){return this._handlesRedirects}}}),h.prototype._forceXhr=function(e,t){this._https=void 0,this._XMLHttpRequest=e||i,this._handlesRedirects=!t},h.FileContent=p,h.StreamProvider=d,h.prototype.setAdditionalHeaders=function(e){this._additionalHeaders=e||{}},h.prototype.setAdditionalNodeOptions=function(e){this._additionalNodeOptions=e},h.prototype.setApiKey=function(e){this._apiKey=e},h.prototype.setTimeout=function(e){this._timeout=e},h.prototype.setAuthToken=function(e){e?(this._authValue="Bearer "+e,this.resume()):(this._authValue=void 0,this._currentAuthId=a.generateUuid())},h.prototype.resume=function(){this._currentAuthId=a.generateUuid(),this._waitingForAuthentication=!1,this._checkQueue()},h.prototype.setRequestHooks=function(e,t){this._beforeHook=e,this._afterHook=t},h.prototype.invoke=function(e,n,o,i,r,d){var h=(r=r||{}).responseType;if(h instanceof p){if(!c.canUseFileSystem)throw new s(s.INVALID_PARAMS,"No filesystem access")}else if("buffer"===h){if("function"!=typeof t)throw new s(s.INVALID_PARAMS,"No Buffer class")}else if("blob"===h){if("function"!=typeof Blob)throw new s(s.INVALID_PARAMS,"No Blob class")}else if(h&&"text"!==h&&"json"!==h&&"arraybuffer"!==h)throw new s(s.INVALID_PARAMS,"Unsupported response type");o=l({},o,this._additionalHeaders),this._apiKey&&(o["x-api-key"]=this._apiKey);var u={method:e,href:n,headers:o,callback:d,body:i,options:r},_=r.reuseRequestDesc;if(_){if(this._requestQueue.indexOf(_)>=0||this._requestsOutstanding.indexOf(_)>=0)throw new s(s.INVALID_PARAMS,"Request descriptor still in use.");u=a.merge(_,u)}return this._doRequest(u),u},h.prototype._doRequest=function(e){var n,o,i,r=this,h=0,u=[],_=e.body,f=e.options.responseType;function m(t,n){t&&a.log("["+e.id+"] error: "+t),o&&o.end();var i=r._requestsOutstanding.indexOf(e);i>=0&&r._requestsOutstanding.splice(i,1);var c=e.callback;c&&(e.callback=void 0,t&&(t.clientRequest=e.clientRequest,t.xhr=e.xhr),t&&t.code!==s.SERVICE_IS_INACTIVE&&!r._isActive?t=new s(s.SERVICE_IS_INACTIVE,"Service is now inactive",t):e.timedOut&&(t=new s(s.TIMED_OUT,"timed out request",t)),c(t,n)),r._isActive&&r._checkQueue()}if(!this._isActive)return m(new s(s.SERVICE_IS_INACTIVE,"Network request in inactive state"));function y(t){t.pipe(i),t.on("error",(function(t){return r.abort(e),m(new s(s.TERMINATED_INPUTSTREAM,"Input stream terminated abnormally",t))}))}if(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||e.options.noSoonerThen)this._requestQueue.push(e),this._waitingForAuthentication||this._checkQueue();else{var E=e.headers;if(null===E.Authorization)delete E.Authorization;else{if(!this._allowAuthTokenToBeSentInsecurely_DONT_USE_THIS_IN_PRODUCTION&&0!==e.href.indexOf("https:"))return m(new s(s.INVALID_PARAMS,"Must not send auth token over unsecured connection"));this._authValue&&(E.Authorization=this._authValue)}if(this._currentAuthId&&(e.authId=this._currentAuthId),this._beforeHook&&this._beforeHook(e),e.id=a.generateUuid(),e.startTime=(new Date).valueOf(),E["X-Request-Id"]=e.id,this._https){this._requestsOutstanding.push(e);var g=(void 0).parse(e.href),v=l({},this._additionalNodeOptions,g);v.method=e.method||"GET",v.headers=E,a.log("["+e.id+"] "+v.method+" "+e.href),i=this._https.request(v,(function(n){var i=!1,l=!1,d=!1;function h(){if(!l)return l=!0,o=void 0,m(void 0,n)}var _=r._requestsOutstanding.indexOf(e);if(_<0)r._checkQueue();else{e.response=n;var y=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+n.statusCode+" ("+y+"ms)"),401===n.statusCode&&r._authCallback)r._requestsOutstanding.splice(_,1),r._requestQueue.unshift(e),r._authFail(e),a.consumeStream(n);else{var E=e.progress;200===n.statusCode||201===n.statusCode||202===n.statusCode?(n.on("data",(function(e){e.length&&E&&E(e.length),!o&&e&&u.push(e)})),r._https&&f instanceof p&&(o=c.createWriteStream(f.filename),n.pipe(o),i=!0)):a.consumeStream(n),n.once("end",(function(){d=!0;var o=r._requestsOutstanding.indexOf(e);if(!(o<0||(r._requestsOutstanding.splice(o,1),r._checkQueue(),i||l)))return l=!0,n.response=t.concat(u),"arraybuffer"===f?n.response=new ArrayBuffer(n.response):"text"===f&&(n.response=n.response.toString()),m(void 0,n)})),n.once("close",(function(){if(!d&&!l)return l=!0,m(new s(s.NETWORK_ERROR,"incomplete response"))})),i&&(o.once("finish",h),o.once("close",h))}}})),e.clientRequest=i,i.once("error",m),r._timeout&&i.setTimeout(r._timeout,(function(){e.timedOut=!0,i.abort()})),e.bytesSent=0,e.bytesReported=0,i.once("end",(function(){if(e.progress){var t=e.bytesSent-e.bytesReported;t>0&&(e.progress(t),e.bytesReported+=t)}}));var A=i.write;if(i.write=function(t){var n=t&&t.length;return n&&(e.bytesSent+=n),A.call(i,t,(function(){e.progress&&t&&(e.progress(n),e.bytesReported+=n)}))},_ instanceof p)y(c.createReadStream(_.filename));else if(_ instanceof d)_.getStream?y(_.getStream()):_.getStreamAsync&&_.getStreamAsync((function(t,n){if(t)return r.abort(e),m(new s(s.TERMINATED_INPUTSTREAM,"Error creating input stream",t));y(n)}));else if(_ instanceof t)i.write(_),i.end();else if(_ instanceof ArrayBuffer)i.write(new t(new Int8Array(_))),i.end();else if("string"==typeof _)i.write(new t(_,"utf8")),i.end();else{if(_)return m(new s(s.INVALID_PARAMS,"Invalid data type"));i.end()}this._afterHook&&this._afterHook(e,i)}else{if(_ instanceof p)return c.canUseFileSystem?void c.readFile(_.filename,{},(function(t,n){if(t)return m(t);e.body=n,r._doRequest(e)})):m(new s(s.INVALID_PARAMS,"Can't use FileContent without filesystem support"));var C;for(C in"function"==typeof t&&_ instanceof t&&(e.body=_=new Int8Array(_)),this._requestsOutstanding.push(e),a.log("["+e.id+"] "+e.method+" "+e.href),(n=new this._XMLHttpRequest).open(e.method,e.href,!0),this._withCredentials&&(n.withCredentials=!0),f&&(n.responseType=f instanceof p?"buffer":f),n.onreadystatechange=function(){var t=e.progress;if(t&&n.response){var o=n.response.length;t(o-h),h=o}if(4===n.readyState){if(0===n.status)return m(new s(s.UNEXPECTED,"XHR failure"));var i=r._requestsOutstanding.indexOf(e);if(i<0)r._checkQueue();else{var l=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+n.status+" ("+l+"ms)"),r._requestsOutstanding.splice(i,1),401!==n.status||!r._authCallback){if(e.xhr=n,e.response=n,n.statusCode=n.status,n.headers=a.parseHeaders(n.getAllResponseHeaders()),f instanceof p){var d=n.response.response;return void c.writeFileAtomically(f.filename,d,void 0,(function(e){return e?m(new s(s.UNEXPECTED,"Can't create file",e,n)):m(void 0,n)}))}return t&&_&&t(_.length||_.size),m(void 0,n)}r._requestQueue.unshift(e),r._authFail(e),r._checkQueue()}}},E)E.hasOwnProperty(C)&&n.setRequestHeader(C,E[C]);e.xhr=n,r._timeout&&(n.timeout=r._timeout,n.ontimeout=function(){e.timedOut=!0,n.abort()}),_?n.send(_):n.send(),this._afterHook&&this._afterHook(e,n)}}},h.prototype._authFail=function(e){if(this._authCallback){var t=e.authId;if(-1!==this._rejectedAuths.indexOf(t))return;this._authValue=null,this._waitingForAuthentication=!0,this._rejectedAuths.unshift(t)>this._maxOutstanding&&(this._rejectedAuths.length=this._maxOutstanding),this._authCallback(this)}},h.prototype._checkQueue=function(){if(!this._isActive){var e=this._requestsOutstanding;this._requestsOutstanding=[],e.forEach((function(e){e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort();var t=e.callback;t&&(e.callback=void 0,t(new s(s.SERVICE_IS_INACTIVE,"Network request in inactive state")))}));var t=this._requestQueue;return this._requestQueue=[],t.forEach((function(e){var t=new s(s.SERVICE_IS_INACTIVE,"Network request in inactive state"),n=e.callback;n&&(e.callback=void 0,n(t))})),void(this._checkQueueTimerId&&(clearTimeout(this._checkQueueTimerId),this._checkQueueTimerId=void 0,this._checkQueueTimerWhen=void 0))}for(var n,o=Date.now(),i=o+3e5,r=0;!(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||r>=this._requestQueue.length);){var a=this._requestQueue[r];(n=a.options.noSoonerThen||o)&&n>i&&(n=a.options.noSoonerThen=i),n<=o?(this._requestQueue.splice(r,1),a.options.noSoonerThen=void 0,this._doRequest(a)):r++}if(!this._waitingForAuthentication&&this._requestsOutstanding.length<this._maxOutstanding&&this._requestQueue.length>0){var c,l,p=this._requestQueue.length;for(l=0;l<p;l++)(n=this._requestQueue[l].options.noSoonerThen)&&n>i&&(n=this._requestQueue[l].options.noSoonerThen=i),n&&(c=c&&c<n?c:n);if(c&&(!this._checkQueueTimerWhen||this._checkQueueTimerWhen>c)){this._checkQueueTimerId&&clearTimeout(this._checkQueueTimerId),this._checkQueueTimerWhen=c;var d=this;this._checkQueueTimerId=setTimeout((function(){d._checkQueueTimerWhen=void 0,d._checkQueueTimerId=void 0,d._checkQueue()}),c-o)}}},h.prototype.abort=function(e){var t=this._requestQueue.indexOf(e);t>=0?this._requestQueue.splice(t,1):(t=this._requestsOutstanding.indexOf(e))>=0&&(this._requestsOutstanding.splice(t,1),e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort(),this._checkQueue())},h.prototype.abortAllWithToken=function(e){if(e){var t;for(t=0;t<this._requestQueue.length;++t)this._requestQueue[t].token===e&&(this._requestQueue.splice(t,1),--t);for(t=0;t<this._requestsOutstanding.length;++t)if(this._requestsOutstanding[t].token===e){var n=this._requestsOutstanding[t];this._requestsOutstanding.splice(t,1),--t,n.xhr&&n.xhr.abort(),n.clientRequest&&n.clientRequest.abort()}this._checkQueue()}},e.exports=h},function(e,t,n){var o=n(21),i=n(3),r=i.networkError,a=i.unexpectedResponse,s=n(13),c=n(4),l=n(7),p=c.appendPathElements,d="If-Match";function h(e,t){if(o.call(this,e,t),!this._endPoint)throw new i(i.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}h.prototype=Object.create(o.prototype),h.prototype.name="AdobeStorageSession",h.FileContent=o.FileContent,h.StreamProvider=o.StreamProvider,h.prototype.getCollection=function(e,t,n){if(!(e=this._resolveUrl(e)))return n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e));var o;e+="?order=asc&orderby=name";var s={};t&&(s["If-None-Match"]=t);var c=this;return this._service.invoke("GET",e,s,void 0,{responseType:"text"},(function t(l,p){if(l)return n(r("Error retrieving a collection",l,p));if(200===p.statusCode){var d,h=p.responseText||p.response;try{d=JSON.parse(h)}catch(e){return(l=new i(i.INVALID_DATA,"Invalid JSON returned by server",e)).response=p,n(l)}o?o.children=o.children.concat(d.children):o=d;var u=p.headers["x-children-next-start"];if(u){var _=e+"&start="+u;c._service.invoke("GET",_,s,void 0,{responseType:"text"},t)}else n(void 0,o,p.headers.etag,p.headers)}else 304===p.statusCode?n(void 0,null,p.headers.etag,p.headers):n(a("Unexpected status code while getting a collection",void 0,p))}))},h.prototype.pagedGetCollection=function(e,t,n,o,s,c,l,p){if(!(e=this._resolveUrl(e)))return p(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e));e+=function(e,t,n,o){var i=[],r="";return t&&i.push("order="+t),e&&i.push("orderBy="+e),n&&i.push("start="+n),o&&i.push("limit="+o),i.length>0&&(r="?"+i.join("&")),r}(n,o,s,c);var d={};return t&&(d["If-None-Match"]=t),this._service.invoke("GET",e,d,void 0,{responseType:"text"},(function(e,t){if(e)return p(r("Error retrieving a collection",e,t));if(200===t.statusCode){var n,o=t.responseText||t.response;try{n=JSON.parse(o)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,p(e)}l?l.children=l.children.concat(n.children):l=n,p(void 0,l,t.headers.etag,t.headers)}else 304===t.statusCode?p(void 0,null,t.headers.etag,t.headers):p(a("Unexpected status code while getting a collection",void 0,t))}))},h.prototype.getComponent=function(e,t,n){var o=this.getComponentHref(e,e.version);return this.getAsset(o,void 0,t,n)},h.prototype.getRenditionOfComponent=function(e,t,n,o,i){var r=this.getComponentRenditionHref(e,e.version,n);return this.getAsset(r,{accept:t},o,i)},h.prototype.getSyncGroups=function(e,t){var n=p(this._server,"assets");return this.getCollection(n,e,t)},h.prototype.getSyncGroup=function(e,t,n){var o=p(this._server,"assets",e);return this.getCollection(o,t,n)},h.prototype.getCompositeManifest=function(e,t,n){var o=e.href;return o&&(o=this._resolveUrl(o)),o?(o=p(o,"manifest"),this.getAssetAsType(o,"text",t,n)):n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o))},h.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,(function(e,n){if(e)return t(e);t(e,n)}))},h.prototype._checkForComponentAlreadyUploaded=function(e,t,n){var o=this;if(!(l.canUseFileSystem&&e&&t&&t.filename))return n();l.getMD5Hash(t.filename,(function(t,i){if(t)return n();o.headRequest(e,(function(e,t){if(e)return n();var o=t&&t.statusCode,r=t&&t.headers["content-md5"];200!==o||r!==i?n():n(t,r)}))}))},h.prototype.remixComposite=function(e,t,n,o,i,r){var a={compositeId:o};i&&(a.creatorTool=i);var s={href:e};return t&&(s.authorization=t),this._invokeOperation("remix",s,{href:n},a,r)},h.prototype.createCompositeDirectory=function(e,t,n){var o=this,s=this._resolveUrl(e.href);if(!s)return n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+s));function l(e,t,n){var a={"Content-Type":"application/vnd.adobe.directory+json","X-Update":"content"};t&&(a[d]="*"),o._service.invoke("PUT",s,a,void 0,void 0,(function(e,t){return e?n(r("Error Creating composite directory",e,t)):409===t.statusCode?((e=new i(i.ALREADY_EXISTS,e)).response=t,n(e)):void n(void 0,t)}))}l(0,t,(function(e,i){if(e)return n(e);var p=i.statusCode;if(200===p||201===p)n(void 0,i);else if(404===p){var d=c.parentDirectory(s);o._service.invoke("PUT",d,{},void 0,void 0,(function(e,o){if(e)return n(r("Error creating composite directory",e,o));var i=o.statusCode;200===i||201===i||409===i?l(0,t,(function(e,t){if(e)return n(e);var o=t.statusCode;200===o||201===o?n(void 0,t):n(r("Error creating composite directory",e,t))})):n(a("Unexpected response creating composite directory",e,o))}))}else n(a("Unexpected response creating composite directory",e,i))}))},h.prototype.deleteCompositeDirectory=function(e,t){var n=this,o=this._resolveUrl(e.href);if(!o)return t(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o));o+="?recursive=true&invocation_mode=sync,async";var s=this._service.invoke("DELETE",o,{"If-Match":"*"},void 0,void 0,(function(e,o){if(e)return t(r("Error deleting composite directory",e,o));var i=o.statusCode;return 200===i||204===i||404===i?t(void 0,o):202===i?n._handle202Response(o,s,n.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response deleting composite directory",e,o))}))},h.prototype.archiveCompositeDirectory=function(e,t){var n=this,o=this._makeRelativeUrl(e.href);if(!o)return t(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e.href));var s={"Content-Type":"application/vnd.adobe.directory+json",Link:"<"+o+">;rel=self"},c=this._resolveUrl("/archive/"+e.id)+"?invocation_mode=sync,async",l=this._service.invoke("PUT",c,s,void 0,void 0,(function(e,o){if(e)return t(r("Error archiving composite directory",e,o));var i=o.statusCode;return 200===i||204===i||404===i?t(void 0,o):202===i?n._handle202Response(o,l,n.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response archiving composite directory",e,o))}))},h.prototype.leaveSharedComposite=function(e,t){if(e.collaborationType!==s.COLLABORATION.SHARED_WITH_USER)throw new i(i.INVALID_STATE,"Composite's collaboration type must be sharedWithUser.");return this.deleteCompositeDirectory(e,t)},h.prototype.uploadComponent=function(e,t,n,o,r,a){if(!e._owner||!e._owner.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return this.uploadAssetForComponentId(e.id,e.type,e._owner.compositeHref,t,n,o,r,a)},h.prototype.uploadAssetForComponentId=function(e,t,n,o,s,c,l,p){var h=this,u=this._constructComponentHref(n,e),_=u;s&&(_+="?intermediates=false");var f={};t&&(f["Content-Type"]=t);var m=function(e,t){e?delete f[d]:f[d]="*";var n=h._service.invoke("PUT",_,f,l,void 0,(function(e,n){if(e)return t(r("Error uploading component",e,n));var o=n.statusCode;if(200===o||201===o||204===o){var s;try{s=JSON.parse(n.responseText||n.response)}catch(o){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",o)).response=n,t(e,n,s)}t(void 0,n,s)}else 507===o?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=n,t(e)):((e=a("Unexpected response uploading component",e)).response=n,t(e))}));return n.token=c,n};return m(o,(function(e,t,n){if(e){if(!(t=e.response))return p(e);var i=t.statusCode;o||404!==i?!o||409!==i&&412!==i?p(e):h._checkForComponentAlreadyUploaded(u,l,(function(e,t){e?p(null,e,{md5:t}):m(!1,p)})):m(!0,p)}else p(void 0,t,n)}))},h.prototype.copyAssetToComponentId=function(e,t,n,o,s,c,l,p){var h=this._makeRelativeUrl(l);if(!h)return p(new i(i.WRONG_ENDPOINT,"Cannot copy asset: "+l));var u=this,_=this._constructComponentHref(n,e);_+="?invocation_mode=sync,async",s&&(_+="&intermediates=false");var f={};function m(e,t,n){e?delete f[d]:f[d]="*";var o=u._service.invoke("PUT",_,f,void 0,{responseType:"text"},(function(e,i){if(e)return n(r("Error uploading component",e,i));var s=i.statusCode;200===s||201===s||204===s?n(void 0,i,t):202===s?u._handle202Response(i,o,u.SYNC_ASYNC_DEFAULT_DELAY,(function(e,o){n(e,o,t)})):n(a("Unexpected response copying a component asset",e,i),i,t)}));return o.token=c,o}return t&&(f["Content-Type"]=t),f.Link="<"+h+">;rel=source",m(o,!0,(function e(t,n,r){var a;if(t){if(!(n=t.response))return p(t);var s=n.statusCode;r||404!==s&&409!==s&&412!==s?507===s?((t=new i(i.EXCEEDS_QUOTA,"Exceeds quota",t)).response=n,p(t)):p(t):m(!o,!0,e)}else{try{a=JSON.parse(n.responseText||n.response)}catch(e){return(t=new i(i.INVALID_DATA,"Invalid JSON returned by server",e)).response=n,p(t)}p(void 0,n,a)}}))},h.prototype.updateManifest=function(e,t,n,o){var s=this.getBranchManifestHref(e),c={"Content-Type":"application/vnd.adobe.dcx-manifest+json"},l=e.manifestEtag;return n?c["If-Match"]="*":l&&(c["If-Match"]=l),this._service.invoke("PUT",s,c,t,void 0,(function(e,t){if(e)return o(r("Error updating manifest",e,t));var s=t.statusCode;!t.headers.etag||200!==s&&201!==s&&204!==s?412===s||l&&!n&&409===s?((e=new i(i.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(a("Unexpected response updating manifest",e,t)):o(void 0,t)}))},h.prototype.getHrefForComposite=function(e,t){if(!e.type)throw new i(i.INVALID_STATE,"Composite needs a type");if(!e.id)throw new i(i.INVALID_STATE,"Composite needs an id");return e.href?e.href:this._resolveUrl(p("assets",t,e.id))},h.prototype.getHrefForCompositeWithId=function(e,t){return this._resolveUrl(p("assets",t,e))},h.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return p(t,"manifest")},h.prototype.getBranchManifestHref=function(e){var t=this._resolveUrl(e.compositeHref);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return p(t,"manifest")},h.prototype.getComponentHref=function(e,t){var n,o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return o._core&&(n=o._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(o.compositeHref,e.id,t)},h.prototype.getComponentRenditionHref=function(e,t,n){var o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(o._core&&o._core._getSourceHrefOfComponent(e))throw new i(i.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(o.compositeHref,e,t,n)},h.prototype._constructComponentHref=function(e,t,n){var o=p(this._resolveUrl(e),t);return o&&void 0!==n&&(o+=";version="+n),o},h.prototype._invokeOperation=function(e,t,n,o,s){var l=this,p=this._resolveUrl("/ops");p+="?invocation_mode=sync,async";var d={op:e,id:c.generateUuid(),target:n,source:t};o&&(d.value=o),c.log("[invoke operation]: "+JSON.stringify(d,void 0,2));var h=function(e,t){var n;if(e)return(t=e.response)?void(507===t.statusCode?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,s(e)):s(e)):s(e);try{n=JSON.parse(t.responseText||t.response)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,s(e)}if(n.error)return(e=new i(i.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,s(e);s(void 0,t,n)},u=l._service.invoke("POST",p,{"Content-Type":"application/vnd.adobe.asset-operation+json"},JSON.stringify(d),{responseType:"text"},(function(t,n){if(t)return h(r("Error invoking operation "+e,t,n));var o=n.statusCode;200===o||201===o||204===o?h(void 0,n):202===o?l._handle202Response(n,u,l.SYNC_ASYNC_DEFAULT_DELAY,(function(e,t){h(e,t)})):h(a("Unexpected response for operation "+e,t,n),n)}));return u},h.prototype._constructComponentRenditionHref=function(e,t,n,o){var i=p(this._constructComponentHref(e,t.id),":rendition");return i+=";size="+(o||"full"),void 0!==n&&(i+=";version="+n),i},e.exports=h},function(e,t,n){var o,i,r=n(13),a=n(20),s=n(17),c=n(3),l=n(29),p=n(21),d=n(4),h=n(7),u=p.FileContent,_=a.STATES;function f(e,t,n){return c.wrapError(c.UNEXPECTED_RESPONSE,e,t,n)}function m(e,t,n){this._session=e,this._callback=t,this._cleanup=n,this._componentsPending=0,this.bytesTransfered=0,this.bytesTotal=0,this.onProgress=d.noOp;var o=this;this._reportProgress=function(e){if(e>0){o.bytesTransfered+=e;var t=o.onProgress;t&&t(o.bytesTransfered,o.bytesTotal)}}}m.prototype._callCallback=function(e,t){var n=this._callback;n&&(this._callback=void 0,n(e,t))},m.prototype._xferComplete=function(e,t){var n=this._cleanup;n?(this._cleanup=void 0,n(e,t)):this._callCallback(e,t)},m.prototype.abort=function(e){this._aborted||(this._aborted=!0,this._session._service.abortAllWithToken(this)),e||(this._callback=void 0,e=new Error("Aborted")),this._xferComplete(e)};var y={pullComposite:function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"all",n)},pullMinimumComposite:function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"min",n)},pullCompositeManifestOnly:function(e,t,n){return this._pullComposite(e,t,"none",n)},downloadComponents:function(e,t,n,o){var i=function e(t){return t._owner?e(t._owner):t}(t),r=new m(n,o);return r._referenceBranch=i,y._pullComponents(r,i,e||t.allComponents()),r},pushComposite:function(e,t,n,o){var i,r=e._localStorage;(i=new m(n,o,(function(t,n){if(i._owner&&e.hasLocalStorage&&r.unregisterInMemoryBranchOrElement(i._owner),!e.hasLocalStorage){var o=i._journal;e._pushJournal=o.isEmpty?void 0:o}i._callCallback(t,n)})))._composite=e,i._overwriteExisting=t;var a=!e.isBound;if(i._compositeIsNew=a,e.hasLocalStorage)e._loadBranch(r.currentManifestPath(),!1,(function(t,n){if(t)return i._xferComplete(t);i._owner=n,e._localStorage.registerInMemoryBranchOrElement(n),l.readJournal(r.pushJournalPath(),e,!0,(function(t,n){if(t)return i._xferComplete(t);i._journal=n,y._pushComposite(e,i)}))}));else{if(!e.href)return i._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));i._owner=e.current.copy(),i._journal=e._pushJournal||new l(e),y._pushComposite(e,i)}return i},remixComposite:function(e,t,n,o,i,r,a){var s=d.parseURI(n).path;if(!s||!o||s.split("/").pop()!==o)throw new c(c.INVALID_PARAMS,"Invalid combination of params targetHref ("+n+") and compositeId ("+o+")");var l=new m(r,a);return r.remixComposite(e,t,n,o,i,(function(e){l._xferComplete(e,e?void 0:n)})).token=l,l},uploadNewComponent:function(e,t,n,i,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return o(i||d.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},uploadComponent:function(e,t,n,i,a){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.updateComponent() to update a component asset");return o(e.id,e.type,!1,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,t,n.id,n.href,i,a)},copyAssetForNewComponent:function(e,t,n,o,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return i(o||d.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},getURLForComponent:function(e,t){if(e._owner._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only.");return t.getComponentHref(e,e.version)},_pullComposite:function(e,t,n,o){if("string"!=typeof e.href)throw new c(c.INVALID_STATE,"Composite must have an href");var i,r=function(o,r){if(o)return i._xferComplete(o);var a;r?(a=r.manifestEtag,i._referenceBranch=r):e.current&&(a=e.current.manifestEtag,i._referenceBranch=e.current);var l=t.getCompositeManifest(e,a,(function(t,o,a){if(t)return t.response&&404===t.response.statusCode?i._xferComplete(new c(c.NO_COMPOSITE,"Composite missing or deleted",t.underlyingError||t)):i._xferComplete(t);if(null===o&&!r)return i._xferComplete(void 0,null);var l;if(null!==o)try{if((l=(new s).parse(o))._localStorage=e._localStorage,l.compositeHref=e.href,l._collaborationType=e.collaborationType,l._clientDataString=e.clientDataString,l.manifestEtag=a,l.compositeState===_.committedDelete||l.compositeState===_.pendingDelete)return void i._session.deleteCompositeDirectory(e,(function(e){return e?i._xferComplete(new c(c.DELETED_COMPOSITE,"Error deleting composite directory",e)):i._xferComplete(new c(c.DELETED_COMPOSITE,"Composite is deleted"))}));i._referenceBranch&&l.hasLocalStorage&&l._updateLocalDataFromBranch(i._referenceBranch)}catch(e){return i._xferComplete(new c(c.INVALID_JSON,"Corrupted manifest",e))}else l=r;var p,d,h=l.allComponents();for(p=0;p<h.length;++p)(d=h[p]).state===_.pendingDelete||d.state===_.committedDelete?l.removeComponent(d):d.state=_.unmodified;h=void 0,"all"===n?h=l.allComponents():"min"===n&&(d=l.getComponentWithAbsolutePath("/META-INF/metadata.xml"))&&(h=[d]),h?y._pullComponents(i,l,h):i._xferComplete(void 0,l)}));l&&(l.token=i,l.progress=i._reportProgress)};return(i=new m(t,o,(function(t,n){if(t){var o=t.pulledBranch;o?(o.compositeState=_.unmodified,o.hasLocalStorage?h.writeFileAtomically(e._localStorage.pulledManifestPath(),t.pulledBranch.localData,"utf8",(function(){i._callCallback(t)})):i._callCallback(t)):i._callCallback(t)}else{if(null===n)return i._callCallback(void 0,null);if(n.compositeState=_.unmodified,n.readOnly=!0,n.hasLocalStorage){var r=e._localStorage.pulledManifestPath();h.writeFileAtomically(r,n.localData,"utf8",(function(e){if(e)return i._callCallback(e);n.manifestPath=r,n._isDirty=!1,i._callCallback(void 0,n)}))}else e._options.xhrBaseBranchSupport&&(e._pulledBranchData=n.localData),i._callCallback(void 0,n)}})))._composite=e,e.hasLocalStorage?e.loadPulledBranch(r):r(),i},_pullComponents:function(e,t,n){if(!t.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage.");var o,i=e._session;function r(o,i){if(e._componentsPending-=1,o&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:i,error:o})),0===e._componentsPending&&!e._aborted){var r=e.failedComponents;if(r){o=new c(c.COMPONENT_DOWNLOAD_ERROR,"Failed to download all components");var a,s=r.length;for(a=0;a<s;a++){var l=r[a].error;if(l.code===c.OUT_OF_SPACE){o=new c(l.code,l.message);break}}o.pulledBranch=t,o.failedComponents=r}t.readOnly&&t.manifestPath&&(!r||n.length>r.length)?h.writeFileAtomically(t.manifestPath,t.localData,"utf8",(function(n){o=o||n,e._xferComplete(o,o?void 0:t)})):e._xferComplete(o,o?void 0:t)}}function a(t){if(!e._aborted){e.bytesTotal+=t.length||0;var n=t._owner._localStorage.tempPathForComponent(t),o=d.parentDirectory(n);h.ensureDirectoryExists(o,(function(o){if(o)return e.abort(o);var a=y._pullComponent(t,n,i,r);a.progress=e._reportProgress,a.token=e}))}}function s(e){t.assetOfComponent(e,(function(t,n){"string"!=typeof n?a(e):r(void 0,e)}))}for(e._componentsPending=n.length,o=0;o<n.length;++o){var l,p=n[o];if(e._referenceBranch){var u=e._referenceBranch.getComponentWithId(p.id);u&&(l=u.etag)}p.etag!==l?a(p):s(p)}0===e._componentsPending&&e._xferComplete(void 0,t)},_pullComponent:function(e,t,n,o){var i=e._owner;if(!e._owner.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return n.getComponent(e,new u(t),(function(n,r){if(n)o(n,e);else if(200===r.statusCode){var a=Number(r.headers["content-length"]);e.length&&!isNaN(a)&&a!==e.length?o(new c(c.UNEXPECTED_RESPONSE,"Incorrect content length",n,r)):i._localStorage.ingestComponentAsset(e,t,!1,i._local(),(function(t){o(t,e,r.headers.etag)}))}else 304===r.statusCode?o(void 0,e,r.headers.etag):o(f("Unexpected response getting a component",n,r),e)}))},_pushComposite:function(e,t){if(!e.href)return t._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));var n=t._owner,o=t._journal,i=t._compositeIsNew,a=t._overwriteExisting,s=t._session,l=n.changeCount,p=n.remoteData.length+50;if(t.bytesTotal=p,n.compositeState===_.committedDelete)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push a deleted composite"));if("archived"===n.compositeArchivalState)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push an archived composite"));var d="pending"===n.compositeArchivalState;if(d&&e.collaborationType===r.COLLABORATION.SHARED_WITH_USER)return t._xferComplete(new c(c.INVALID_STATE,"Attempt to archive composite that is shared with this user."));if(!i&&!d&&n.compositeState===_.unmodified)return t._xferComplete();if(n.compositeState===_.pendingDelete)return i&&!a?t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to delete unbound composite")):e.collaborationType===r.COLLABORATION.SHARED_WITH_USER?t._xferComplete(new c(c.INVALID_STATE,"Attempt to delete composite that is shared with this user.")):y._deleteComposite(t,a,(function(e,n){t._xferComplete(e,n)}));function u(n,o){d?s.archiveCompositeDirectory(e,(function(i){if(i)return o(i);n.compositeArchivalState="archived",t._journal.compositeHasBeenArchived=!0,t._journal.commitChanges((function(t){if(t)return o(t);e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),n.localData,"utf8",(function(e){if(e)return o(e);o(void 0,n)})):o(void 0,n)}))})):o(void 0,n)}function m(n){if(i)return t._xferComplete(n);var o=s.getCompositeManifestHref(e);s.headRequest(o,(function(e,o){return e?t._xferComplete(e):404===o.statusCode?(n=new c(c.NO_COMPOSITE,"Composite does not exist; may have been deleted"),t._xferComplete(n)):t._xferComplete(n)}))}!function(e,t,n,o,i){function r(e){e||(t.compositeHasBeenCreated=!0);var n,o=t._compositeCreationCallbacks,i=o.length;for(n=0;n<i;n++)try{o[n](e)}catch(e){}t._compositeCreationCallbacks=void 0}e.isBound||t.compositeHasBeenCreated?i():t._compositeCreationCallbacks?t._compositeCreationCallbacks.push(i):(t._compositeCreationCallbacks=[i],o.createCompositeDirectory(e,n,(function(t,i){if(t){if(t.code!==c.ALREADY_EXISTS)return r(f("Unexpected response creating a composite directory",t,i));if(n)r();else{var a=o.getCompositeManifestHref(e);o.headRequest(a,(function(e,t){return e?r(e):404!==t.statusCode?r(e=new c(c.ALREADY_EXISTS,"Composite already exists and overwriteExisting not specified")):void r()}))}}else r()})))}(e,o,a,s,(function(i){if(i)return t._xferComplete(i);y._pushComponents(t,n,(function(){var r=t.failedComponents;if(r){i=new c(c.COMPONENT_UPLOAD_ERROR,"One or more components failed to upload.");var d,f=r.length;for(d=0;d<f;d++){var y=r[d].error;if(y.code===c.EXCEEDS_QUOTA){i=new c(y.code,y.message);break}}return i.failedComponents=r,m(i)}if(n.compositeState===_.modified){n.compositeState=_.unmodified,o.manifestEtag&&o.currentBranchEtag===n.manifestEtag&&(n.manifestEtag=o.manifestEtag);var E=n.remoteData;t.bytesTotal+=E.length,t.bytesTotal-=p;var g=s.updateManifest(n,E,a,(function(i,r){if(i)return m(i);var a=r.headers.etag;o.manifestEtag=a,o.currentBranchEtag=n.manifestEtag,o.changeCount=l,o.commitChanges((function(i){if(i)return t._xferComplete(i);o.applyToBranch(n),n.compositeState=_.unmodified,e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),n.localData,"utf8",(function(e){if(e)return t._xferComplete(e);n._isDirty=!1,u(n,(function(e,n){t._xferComplete(e,n)}))})):(e._options.xhrBaseBranchSupport&&(e._pushedBranchData=n.localData),u(n,(function(e,n){t._xferComplete(e,n)})))}))}));g&&(g.progress=t._reportProgress,g.token=t)}else u(n,(function(e,n){t._xferComplete(e,n)}))}))}))},_deleteComposite:function(e,t,n){var o=e._composite,i=e._owner,r=e._session;i.compositeState=_.committedDelete;var a=i.remoteData;e.bytesTotal=a.length,e._journal.manifestEtag&&e._journal.currentBranchEtag===i.manifestEtag&&(i.manifestEtag=e._journal.manifestEtag),r.updateManifest(i,a,t,(function(t){if(t)return n(t);r.deleteCompositeDirectory(o,(function(t){if(t)return n(t);e._journal.compositeHasBeenDeleted=!0,e._journal.commitChanges((function(e){if(e)return n(e);o.hasLocalStorage?h.writeFileAtomically(o._localStorage.pushedManifestPath(),i.localData,"utf8",(function(e){if(e)return n(e);n(void 0,i)})):n(void 0,i)}))}))}))},_pushComponents:function(e,t,n){var o,i=t.allComponents(),a=e._composite,s=a._localStorage,l={},p=e._journal;function f(t,o,i){o?l[t.id]=o:delete l[t.id],i&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:t,error:i})),0===Object.keys(l).length&&p.commitChanges(n)}function m(t,n,o){f(t,"uploading"),h.info(n,(function(i,s){if(i)return i=new c(c.INVALID_STATE,"Component asset missing",i),void f(t,null,i);var l=s.size,h=d.filePathComponents(n).fileName,m=p.getRecordForUploadedComponent(t.id);if(m&&m.length===l&&m["storage-name"]===h)return t.etag=m.etag,t.version=m.version,t.md5=m.md5,t.length=m.length,t.state=_.unmodified,void f(t,null);e.bytesTotal+=l;var y=e._session.uploadComponent(t,o,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,new u(n),(function(e,n,o){if(!e){var i=n.headers.etag,r=n.headers["x-latest-version"],a=o.md5;i||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),r||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),a||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),e||(t.etag=i,t.version=r,t.md5=a,t.length=l,t.state=_.unmodified,p.recordUploadedComponent(t.id,i,r,a,l,h),p.commitChanges())}f(t,null,e)}));y&&(y.progress=e._reportProgress,y.token=e)}))}function y(n,o,i){var l=p.getRecordForUploadedComponent(n.id);if(l&&l["source-href"]===o)return n.etag=l.etag,n.version=l.version,n.md5=l.md5,n.length=l.length,void(n.state=_.unmodified);f(n,"copying");var d=e._session.copyAssetToComponentId(n.id,n.type,e._composite.href,i,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,o,(function(e,r,a){if(e){if(s){var l=s.componentAssetPath(n,t._local());if("string"==typeof l)return m(n,l,i)}}else{var d=r.headers.etag,h=r.headers["x-latest-version"],u=a.md5,y=a.size;d||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),h||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),u||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),y||(e=new c(c.UNEXPECTED_RESPONSE,"No length")),e||(n.etag=d,n.version=h,n.md5=u,n.length=y,n.state=_.unmodified,p.recordUploadedComponent(n.id,d,h,u,y,void 0,o),p.commitChanges())}f(n,null,e)}));d&&(d.progress=e._reportProgress,d.token=e)}for(o=0;o<i.length;++o){var E=i[o],g=E.state,v=!E.etag;if(g||(g=_.unmodified),v||g===_.modified){var A=t._core._getSourceHrefOfComponent(E);if(t.hasLocalStorage||A){var C=v||e._compositeIsNew;if(A)y(E,A,C);else{var O=s.componentAssetPath(E,t._local());"string"==typeof O&&m(E,O,C)}}else{var L=new c(c.INVALID_STATE,"Component should not be modified or new without local storage");e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:E,error:L})}}else g===_.unmodified?p.removeRecordForUploadedComponent(E.id):g!==_.committedDelete&&g!==_.pendingDelete||t.removeComponent(E)}0===Object.keys(l).length&&n()}};o=function(e,t,n,o,i,r,s,l,p){if("function"!=typeof p)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var d=i.length||i.byteLength||i.size,h=new m(l,p);h.bytesTotal=d;var u=l.uploadAssetForComponentId(e,t,s,n,o,h,i,(function(n,o,i){var s;if(!n)try{s=new a._UploadResults(r),d=d||u.bytesSent,s.records[e]=function(e,t,n,o,i){if("number"!=typeof t)throw new c(c.UNEXPECTED_RESPONSE,"No length");var r=o.headers.etag,s=o.headers["x-latest-version"],l=i.md5;if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!l)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,r,s,l,t,n)}(e,d,t,o,i)}catch(e){n=e,s=void 0}h._xferComplete(n,s)}));return u&&(u.progress=h._reportProgress,u.token=h),h},i=function(e,t,n,o,i,r,s,l,p){if("function"!=typeof p)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var d=new m(l,p),h=l.copyAssetToComponentId(e,t,s,n,o,d,i,(function(n,o,i){if(!d._aborted){var s;if(!n)try{(s=new a._UploadResults(r)).records[e]=function(e,t,n,o){var i=o.headers.etag,r=o.headers["x-latest-version"],s=t.md5,l=t.size;if("number"!=typeof l)throw new c(c.UNEXPECTED_RESPONSE,"No length");if(!i)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,i,r,s,l,n)}(e,i,t,o)}catch(e){n=e,s=void 0}p(n,s)}}));return h&&(h.progress=d._reportProgress,h.token=d),d},e.exports=y},function(e,n,o){var i=o(13),r=o(17),a=o(3),s=o(4),c=o(7),l={isSnapshot:function(e,n){var o,i=!1,r=function(e,t){i||(i=!0,o&&o.isOpen&&o.close(),n(e,t))};(void 0).open(e,{lazyEntries:!0},(function(e,n){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?r(e):r(new a(a.INVALID_DATA,"Error while opening snapshot: "+e)):((o=n).on("entry",(function(e){"mimetype"===e.fileName?o.openReadStream(e,(function(e,n){if(e)r(e);else{var o=[];n.on("data",(function(e){o.push(e)})),n.on("error",(function(e){r(e)})),n.on("end",(function(){var e=t.concat(o).toString();e&&h(e,"dcxucf")?r(null,!0):r(null,!1)}))}})):r(null,!1)})).on("error",(function(e){r(e)})),o.readEntry())}))},importSnapshot:function(e,t,n,o,r,a){return this.importSnapshotToDirectory(e,t,n,o,r,(function(e,t){if(e)a(e);else try{var n=new i(null,null,t,null,null,null);n.loadCurrentFromLocalStorage((function(e){a(e,e?void 0:n)})),n.deleteTempFiles()}catch(e){a(e)}}))},importSnapshotToDirectory:function(e,n,o,i,l,p){var d,u,f,m,y=!1,E=0,g=0,v=0,A=!1,C=function(e,t){if(!A){if(A=!0,d&&d.isOpen&&d.close(),e)return t&&c.deleteDirectory(t),void p(e);p(e,t)}},O={},L={};return c.ensureDirectoryExists(n,(function(p){p?C(p):(void 0).open(e,{lazyEntries:!0},(function(e,p){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?C(e):C(new a(a.INVALID_DATA,"Error while opening snapshot: "+e)):((d=p).on("entry",(function(e){if(E++,g=0,v=0,_(e,i))if(1===E)"mimetype"===e.fileName?d.openReadStream(e,(function(e,n){if(e)C(e);else{var o=[];n.on("data",(function(e){o.push(e)})),n.on("error",(function(e){C(e)})),n.on("end",(function(){var e=t.concat(o).toString();e&&h(e,"dcxucf")||C(new a(a.INVALID_DATA,"Bad mimetype")),d.readEntry()}))}})):C(new a(a.INVALID_DATA,"Missing mimetype file"));else if(2===E)"manifest"===e.fileName?d.openReadStream(e,(function(e,n){if(e)C(e);else{var o=[];n.on("data",(function(e){o.push(e)})),n.on("error",(function(e){C(e)})),n.on("end",(function(){var e=t.concat(o).toString();if(e){if(u=JSON.parse(e),(f=new r(u))._resetIdentity(),i){var n=f.getComponentWithAbsolutePath("/META-INF/metadata.xml");n&&f.removeComponent(n)}m=u.id,d.readEntry()}else C(new a(a.INVALID_DATA,"Unable to parse manifest on import"))}))}})):C(new a(a.INVALID_DATA,"Missing manifest file"));else if(m){g=e.uncompressedSize;var o=n+"/"+m+"/components";c.ensureDirectoryExists(o,(function(t){t?C(t):d.openReadStream(e,(function(t,n){if(t)C(t);else{var i=s.generateUuid(),r=e.fileName.split("/"),a=r[r.length-1].split(".");a&&(i=i+"."+a[a.length-1]),O["/"+e.fileName]=i,n.on("end",(function(){d.readEntry()})),n.on("data",(function(e){v+=e.length,function(){if(!y){var e=(E-1)/d.entryCount;g&&(e+=v/(g*d.entryCount)),l(Math.round(100*e))}}()})).on("error",(function(e){C(e)})).pipe(c.createWriteStream(o+"/"+i))}}))}))}else C(new a(a.INVALID_DATA,"Missing manifest id"));else d.readEntry()})).on("error",(function(e){C(e)})).on("close",(function(){A||(y?C(new a(a.UNEXPECTED,"Import cancelled")):(Object.keys(O).forEach((function(e){var t=f.getComponentWithAbsolutePath(e);t&&(L[t.id]=O[e])})),u.local||(u.local={}),u.local["copyOnWrite#storageIds"]=L,o&&(u.local.compositeHref=o.endsWith("/")?o+u.id:o+"/"+u.id),m?c.ensureDirectoryExists(n+"/"+m,(function(e){e?C(e):c.writeFile(n+"/"+m+"/manifest",JSON.stringify(u,void 0,2),(function(e){e?C(e):C(null,n+"/"+m)}))})):C(new a(a.INVALID_DATA,"Missing manifest id"))))})),d.readEntry())}))})),function(){y||(y=!0,d&&d.close())}},exportSnapshot:function(e,n,o,i,r){var l,d,u=!1,_=function(e){if(!u){if(u=!0,e)return void c.deleteFile(d,(function(){return r(e)}));c.move(d,n,!1,(function(e){return r(e||null)}))}};try{d=n.replace(/([^\\/]+)$/,"."+s.generateUuid()+"_$1"),l=c.createWriteStream(d)}catch(e){return void _(e)}var f,m=new(void 0).ZipFile;if(e.type&&h(e.type,"dcx")){f=e.type+"ucf",m.addBuffer(new t(f),"mimetype",{compress:!1});var E=p(e.current,o),g=JSON.stringify(E.manifest,void 0,2),v=E.lengths.total+g.length;m.addBuffer(new t(g),"manifest",{compress:!0});var A=E.componentMap,C=!1,O=0;return E.components.map((function(t){return{id:t.id,path:A&&A[t.id]||t.path,type:t.type,absolutePath:e.current.getComponentWithId(t.id).absolutePath.substring(1)}})).sort((function(e,t){return e.absolutePath<t.absolutePath?-1:e.absolutePath>t.absolutePath?1:0})).forEach((function(t){var n=e.path+"/components/"+t.path;y(t.type)?m.addFile(n,t.absolutePath,{compress:!0}):m.addFile(n,t.absolutePath,{compress:!1})})),m.end(),m.on("error",(function(){_(new a(a.INVALID_DATA,"Missing component file locally."))})),m.outputStream.on("error",(function(e){_(C?new a(a.UNEXPECTED,"Export cancelled"):e)})).on("data",(function(e){O+=e.length,C||i(Math.min(100,Math.round(100*O/v)))})).pipe(l).on("close",(function(){_(C?new a(a.UNEXPECTED,"Export cancelled"):null)})).on("error",(function(e){_(e)})),function(){C||(C=!0,m.outputStream.end())}}_(new a(a.INVALID_PARAMS,"Invalid composite type"))}},p=function(e,t){var n=JSON.parse(e.localData);t&&t(n);var o=d(n,n.local["copyOnWrite#storageIds"]||{});return delete n.local,delete n.manifestEtag,n.state="unmodified",{manifest:n,lengths:o.lengths,componentMap:o.componentMap,components:o.components}},d=function e(t,n,o,i,r){return r=r||[],o=o||{},i=i||{total:0},t.components&&t.components.forEach((function(e){o[e.id]=n[e.id];var t=e.length||1e5;i[e.id]=t,i.total+=t,e.state="unmodified",delete e.version,delete e.md5,delete e.etag,r.push(e)})),t.children&&t.children.forEach((function(t){e(t,n,o,i,r)})),{lengths:i,componentMap:o,components:r}},h=function(e,t){var n=e.split("/");if(2===n.length){var o=n[1];if(o.length<t.length+2)return!1;if(o.substring(o.length-t.length)!==t)return!1;var i=o.length-(t.length+1);return"+"===o.charAt(i)}return!1},u=/^[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}\.[^/\\]+$/i,_=function(e,t){if("mimetype"===e.fileName||"manifest"===e.fileName)return!0;var n=e.fileName.split("/");if(n){var o=n[n.length-1];return!t&&"metadata.xml"===o||o.match(u)}return!1},f=["text/"],m=["+json","+xml"],y=function(e){return f.forEach((function(t){if(e.startsWith(t))return!0})),m.forEach((function(t){if(e.endsWith(t))return!0})),!1};e.exports=l},function(e,t,n){var o=n(3),i=n(46),r=n(71),a=n(1),s=n(11),c=n(2),l=n(0),p=n(18),d=n(12),h=n(14),u=n(16),_=n(10),f=n(6),m=n(5),y=n(8),E=n(15),g=n(9),v=n(74);function A(e,t,n){this._collection=e,this._dcxComposite=t,this._dcxBranch=t.current,this._listenerManager=new g(["change"]),n?(this._publicId=n,this._writable=!1):this._writable=!0,this._filterCache={},this._renditionCache=new v(this),this._autoGCMode={},this._transactionCount=0,this._commitInProgress=!1,this._pendingCommit=!1,this._onCommitCallbacks=[],this._dcxLock=new h,this._networkLock=new h,this._syncState=void 0,this._deletedLocally=!1,this._deletedFromServer=!1,this._waitForSyncToFinishCallbacks=[],this._errors=[],this._pushFailedDueToQuota=!1,this._numUpdateConflicts=0,this._numActiveCopyNodeOperations=0,this._pendingCopyNodeOperations=[],this._dcxBranch.getChildrenOf().forEach((function(e){e.name===a.ELEMENTS_NAME&&(this._dcxElementsNode=e),e.name===a.REMOVED_ELEMENTS_NAME&&(this._dcxRemovedElementsNode=e),e.name===a.GROUPS_NAME&&(this._dcxGroupsNode=e)}),this),this._dcxElementsNode||(this._dcxElementsNode=this._dcxBranch.addChild(a.ELEMENTS_NAME)),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._elements=[],this._removedElements=[],this._groups=[],this._dcxBranch.getChildrenOf(this._dcxElementsNode).forEach((function(e){var t=new r(this,e);this._addElementToFilter(t),this._elements.push(t)}),this),this._dcxRemovedElementsNode&&(this._dcxBranch.getChildrenOf(this._dcxRemovedElementsNode).forEach((function(e){var t=new r(this,e);this._removedElements.push(t)}),this),this._sortRemovedElements()),this._dcxGroupsNode&&this._dcxBranch.getChildrenOf(this._dcxGroupsNode).forEach((function(e){var t=new i(this,e);this._groups.push(t)}),this),l.hasFileSystem()||(this._dcxBaseBranch=this._dcxBranch.copy())}A.prototype._getRemovedElementsNode=function(){return this._dcxRemovedElementsNode||(this._dcxRemovedElementsNode=this._dcxBranch.addChild(a.REMOVED_ELEMENTS_NAME)),this._dcxRemovedElementsNode},A.prototype._getGroupsNode=function(){return this._dcxGroupsNode||(this._dcxGroupsNode=this._dcxBranch.addChild(a.GROUPS_NAME)),this._dcxGroupsNode},A.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._elements.forEach((function(t){t._markDeletedLocally(e)})),this._groups.forEach((function(t){t._markDeletedLocally(e)})),e&&this._listenerManager.removeAll()},A.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._elements.forEach((function(e){e._removeAllListeners()}))},A.prototype._toJSON=function(){return{id:this.id,name:this.name,elements:this._elements.map((function(e){return e._toJSON()})),renditionCache:this._renditionCache.serializeCache(),groups:this._groups.map((function(e){return e._toJSON()}))}},A.prototype._getRenditionCache=function(){var e={},t=function(t){e[t.id]=JSON.parse(JSON.stringify(t._renditionCache))};return this._elements.forEach(t),this._removedElements.forEach(t),e},A.prototype._doCommit=function(e){var t=this,n=this;function o(t){var o=n._onCommitCallbacks;n._onCommitCallbacks=[],o.forEach((function(e){e.waitForSuccess&&!t?n._onCommitCallbacks.push(e):n._waitForCommit(e.callback)})),function(){if(e&&!a.SHARED_LOCAL_STORAGE){if(n._deletedLocally)return;n._collection._clearSyncErrors(),n._push(),n._collection._resetPollBackoff()}}()}l.hasFileSystem()?this._commitInProgress?this._pendingCommit=!0:(this._commitInProgress=!0,l.storageInterface.commitManifest(this,(function(i,r){!function(e,t){e&&(e=f.getCommitError(e,n.id,"Failed to write composite to disk")),n._collection._reportCommitError(e)}(i),t._commitInProgress=!1,t._pendingCommit?(t._pendingCommit=!1,0===t._transactionCount&&t._doCommit(e)):o(r)}))):o()},A.prototype._waitForCommit=function(e,t){this._commitInProgress||this._transactionCount>0?this._onCommitCallbacks.push({callback:e,waitForSuccess:t}):this._renditionCache._waitForCommit(e)},A.prototype._notifyChange=function(){this._listenerManager.notify("change"),this._collection._notifyChange()},A.prototype._commit=function(e,t){0===this._transactionCount&&(t||(this._updateModifiedTime(),this._notifyChange()),this._doCommit(!e))},A.prototype._wrapOperation=function(e,t){var n;this._beginOperation();try{n=e.call(t)}catch(e){throw this._transactionCount--,e}return this._endOperation(),n},A.prototype._beginOperation=function(){this._transactionCount++},A.prototype._endOperation=function(){this._transactionCount--,this._commit()},A.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxBranch.rootNode.setValue(a.MODIFIED_KEY,e)},A.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxBranch.rootNode.setValue(a.CREATED_KEY,e),this._dcxBranch.rootNode.setValue(a.MODIFIED_KEY,e)},A.prototype._getMissingLocalComponents=function(){var e=[];return this._elements.forEach((function(t){e=e.concat(t._getMissingLocalComponents())})),e},A.prototype._gcLocalData=function(e){var t=this,n=[],o={},i=[];if(this._removedElements.forEach((function(e){e._shouldGCLocalData()&&(n.push(e),e._forEachRepresentation((function(e){var t=e._dcxComponent,n=e._getCurrentComponentPath();t&&n&&t.etag&&"modified"!==t.state?(o[n]=o[n]||[],o[n].push(t.id)):n&&i.push(n)})))})),0!==n.length){i.forEach((function(e){delete o[e]})),this._elements.forEach((function(e){e._forEachRepresentation((function(e){var t=e._getCurrentComponentPath();t&&delete o[t]}))}));var r=[];Object.keys(o).forEach((function(e){r.push.apply(r,o[e])})),n.forEach((function(e){return t._renditionCache.clearCache(e)})),l.log("Removing local files for components: [ "+r.join(", ")+" ]"),this._dcxComposite.removeLocalFilesForComponentsWithIDs(r,e)}else e(null)},A.prototype._checkRenditionType=function(e,t){if(!e||-1===a.VALID_LIBRARY_RENDITION_TYPES.indexOf(e)){if(t)return t(new c(c.INVALID_PARAMETER,"composite rendition type not supported: "+e)),!1;throw new c(c.INVALID_PARAMETER,"composite rendition type not supported: "+e)}return!0},A.prototype._setRenditionFromPath=function(e,t,n,o){if(!_.checkDeletedState(this,o)){var i=this._dcxCompositeRenditionMap[e],r=this,s=t&&l.getFileNameFromPath(t),c=m.getFileExtension(s),p=l.uuid()+"."+c;m.checkFileSize(t,(function(c){c?o(c):l.storageInterface.notifyStartWrite(r,[],(function(){r._dcxBranch.addComponent(s,n,"rendition",p,t,!0,void 0,r._dcxBranch.rootNode,void 0,(function(t,n){t?o(t):_.checkDeletedState(r,o)||(n.setValue(a.MODIFIED_KEY,(new Date).valueOf()),n.setValue(a.RENDITION_TYPE_KEY,e),i&&r._dcxBranch.removeComponent(i),r._dcxCompositeRenditionMap=_.getCompositeRenditionMap(r._dcxBranch),r._commit(),o(null))}))}))}))}},A.prototype._setRendition=function(e,t,n,o,i){var r,a=l.fs,s=this;function c(t){t?i(f.getCommitError(t,s.id,"error writing library rendition")):_.checkDeletedState(s,i)||s._setRenditionFromPath(e,r,o,i)}var p=this.collection._getTempDir();m.ensurePathExists(p,(function(e){if(e)i(f.getCommitError(e,s.id,"error creating temp directory"));else if(!_.checkDeletedState(s,i)){var d=E.getExtensions(o)[0],h=l.uuid()+"."+d;r=p+l.getPathSeparator()+h,"buffer"===n?a.writeFile(r,t,c):a.writeFile(r,t,n,c)}}))},A.prototype._setRenditionInBrowser=function(e,t,n,o){var i=this,r=this._dcxCompositeRenditionMap[e],s=this._collection._syncManager,c=l.uuid();s.uploadNewComponentForLibrary(t,c,n,"rendition",this,(function(t,n){t?o(t):_.checkDeletedState(i,o)||(n.setValue(a.MODIFIED_KEY,(new Date).valueOf()),n.setValue(a.RENDITION_TYPE_KEY,e),r&&i._dcxBranch.removeComponent(r),i._dcxCompositeRenditionMap=_.getCompositeRenditionMap(i._dcxBranch),i._commit(),o(null))}))},A.prototype._getFilterKey=function(e){return e&&-1!==a.ELEMENT_TYPE_FILTERS.indexOf(e)?e:"*"},A.prototype._removeElementFromFilter=function(e){var t=this._getFilterKey(e.type);if(this._filterCache[t]){var n=this._filterCache[t].indexOf(e);-1!==n&&this._filterCache[t].splice(n,1)}},A.prototype._addElementToFilter=function(e){var t=this._getFilterKey(e.type);this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t].push(e)},A.prototype._doCreateGroup=function(e,t,n){var o=this._getGroupsNode(),r=this._dcxBranch.addChild(e,void 0,void 0,o);r.type=a.GROUP_TYPE,r.setValue(a.CLASSIFIER_KEY,n),r.setValue(a.ORDER_KEY,t);var s=new i(this,r);return s._updateCreatedTime(),this._groups.push(s),s},A.prototype._doRemoveGroup=function(e,t){var n=this._groups.indexOf(e);this._groups.splice(n,1),this.elements.slice().forEach((function(n){void 0!==n.getOrderInGroup(e)&&(n._doSetOrderInGroup(e,void 0,!0),t&&t(n))})),this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},A.prototype._getNumberOfElementsInGroup=function(e){if(e){var t=0;return this.elements.forEach((function(n){void 0!==n.getOrderInGroup(e)&&t++})),t}},A.prototype._doCopyGroup=function(e,t,n,o,i){var r=e.library!==t&&t._groups.every((function(t){return t.id!==e.id}))?e.id:l.uuid();this._doCopyDCXGroup(e,t,n,o,r,i)},A.prototype._doCopyDCXGroup=function(e,t,n,o,r,a){var c=this;t._beginOperation(),o&&c._beginOperation();var p=function(e){t._endOperation(),o&&c.endOperation(),a(e)};l.storageInterface.notifyStartWrite(t,[this],(function(){var l=t._getGroupsNode();t._dcxBranch.copyChild(e._dcxNode,l,void 0,r,r,(function(r,l){if(!_.checkDeletedState(c,a))if(r)p(r);else{var h=new i(t,l);t._groups.push(h);var u=function(){_.checkDeletedState(c,a)||(t._endOperation(),o&&(c._doRemoveGroup(e),c.endOperation()),a(null,h))};if(n){var f=c.elements.filter((function(t){return void 0!==t.getOrderInGroup(e)})),m=new d;f.forEach((function(e){m.addOperation(c._doCopyElement,[e,t,o],c)})),m.run((function(t,n,o){if(t)p(t);else try{f.forEach((function(t,n){var i=t.getOrderInGroup(e),r=o[n];r._doSetOrderInGroup(h,i,!0),s.reportCopyElement(r,t)})),u()}catch(e){p(e)}}))}else u()}}))}))},A.prototype._doCreateElement=function(e,t){var n=this._dcxBranch.addChild(e,void 0,void 0,this._dcxElementsNode);n.path=n.id,n.type=t;var o=new r(this,n);return o._updateCreatedTime(),this._elements.push(o),this._addElementToFilter(o),o},A.prototype._doRemoveElement=function(e,t){var n=this._elements.indexOf(e);-1!==n&&this._elements.splice(n,1),-1!==(n=this._removedElements.indexOf(e))&&this._removedElements.splice(n,1),this._removeElementFromFilter(e),t&&this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},A.prototype._ensureRemovedElementsSpace=function(){for(;this.removedElements.length>=a.MAX_REMOVED_ELEMENTS;)this._doRemoveElement(this.removedElements[0],!0)},A.prototype._sortRemovedElements=function(){this._removedElements.sort((function(e,t){return e.removed-t.removed}))},A.prototype._doMarkElementRemoved=function(e,t){var n=this._elements.indexOf(e);-1!==n&&(this._ensureRemovedElementsSpace(),this._elements.splice(n,1),this._removeElementFromFilter(e),this._removedElements.push(e),this._sortRemovedElements(),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._getRemovedElementsNode()),e._updateTimestampOnRemove()))},A.prototype._doRestoreElement=function(e,t){var n=this._removedElements.indexOf(e);-1!==n&&(this._removedElements.splice(n,1),this._elements.push(e),this._addElementToFilter(e),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._dcxElementsNode),e._updateTimestampOnRestore(),e._stripObsoleteGroupsData()))},A.prototype._doCopyDCXNode=function(e,t,n,o,i){var r=this;if(this._numActiveCopyNodeOperations<a.MAX_DCX_CONCURRENT_COPIES)return this._numActiveCopyNodeOperations++,void e.copyChild(t,n,void 0,o,o,(function(e,t){r._numActiveCopyNodeOperations--,i(e,t),r._pendingCopyNodeOperations.length>0&&r._pendingCopyNodeOperations.shift()()}));this._pendingCopyNodeOperations.push((function(){r._doCopyDCXNode(e,t,n,o,i)}))},A.prototype._doCopyDCXElement=function(e,t,n,o,i){var a=this;t._beginOperation(),l.storageInterface.notifyStartWrite(t,[this],(function(){a._doCopyDCXNode(t._dcxBranch,e._dcxNode,t._dcxElementsNode,o,(function(o,s){if(!_.checkDeletedState(a,i)){if(o)return t._endOperation(),void i(o);var c=new r(t,s);t._addElementToFilter(c),t._elements.push(c),c._stripObsoleteGroupsData();var p=function(){_.checkDeletedState(a,i)||(t._endOperation(),n&&a._wrapOperation((function(){a._doRemoveElement(e,!0)})),i(null,c))};l.hasFileSystem()?a._renditionCache.copyCache(e,c).then(p,p):p()}}))}))},A.prototype._doCopyElement=function(e,t,n,o){if(t._elements.length>=a.MAX_ELEMENTS)o(new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id));else{var i=e.id;t._elements.every((function(e){return e.id!==i}))&&t._removedElements.every((function(e){return e.id!==i}))||(i=l.uuid()),this._doCopyDCXElement(e,t,n,i,o)}},A.prototype.jasmineToString=function(){return this.toString()},A.prototype._setSyncState=function(e){this._syncState!==e&&(this._syncState=e,this._collection._updateSyncState(),this._checkSyncFinishedAndNotify())},A.prototype._isSyncing=function(){return void 0!==this._syncState},A.prototype._checkSyncFinishedAndNotify=function(){if(!this._isSyncing()){var e=this._waitForSyncToFinishCallbacks;this._waitForSyncToFinishCallbacks=[],e.forEach((function(e){e()}))}},A.prototype._waitForSyncToFinish=function(e){this._waitForSyncToFinishCallbacks.push(e),this._checkSyncFinishedAndNotify()},A.prototype._getClientData=function(){var e={};if(this._dcxComposite.clientDataString)try{e=JSON.parse(this._dcxComposite.clientDataString)}catch(e){}return e},A.prototype._getClientDataValue=function(e){return this._getClientData()[e]},A.prototype._setClientDataValue=function(e,t){var n=this._getClientData();n[e]=t,this._dcxComposite.clientDataString=JSON.stringify(n)},A.prototype._setCollaboration=function(e){var t=e&&e.collaboration&&e.collaboration.toLowerCase(),n=e&&e.collaboration_role&&e.collaboration_role.toLowerCase(),o=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);if(this.collaboration!==t||o!==n){var i=_.collaborationStateToDCX(t);this._dcxComposite.collaborationType=i,this._setClientDataValue(a.DATA_COLLABORATION_ROLE,n),this._commit(!0,!0),this._notifyChange(),this._revertLocalChangesIfNecessary()}},A.prototype._isDeletedError=function(e){var t=e&&(e.code===o.NO_COMPOSITE||e.code===o.DELETED_COMPOSITE),n=e&&e.code===o.UNEXPECTED_RESPONSE&&e.response&&401===e.response.statusCode;return t||this.collection.isPublic&&n},A.prototype._isAlreadyExistsError=function(e){var t=e&&e.code===o.ALREADY_EXISTS,n=e&&e.code===o.UNEXPECTED_RESPONSE&&e.response&&409===e.response.statusCode;return t||n},A.prototype._isReadOnlyError=function(e){if("incoming"!==this.collaboration)return!1;var t=!1;return!e||e.code!==o.COMPONENT_UPLOAD_ERROR&&e.code!==o.UNEXPECTED_RESPONSE||(e.code===o.UNEXPECTED_RESPONSE&&e.response&&403===e.response.statusCode&&(t=!0),e.code===o.COMPONENT_UPLOAD_ERROR&&Array.isArray(e.failedComponents)&&e.failedComponents.length>0&&(t=!0,e.failedComponents.forEach((function(e){e.error&&e.error.code===o.UNEXPECTED_RESPONSE&&e.error.response&&403===e.error.response.statusCode||(t=!1)})))),t},A.prototype._mergeAndSwitchToBranch=function(e,t,n){var o=this,c=void 0!==t,p=e.localData;function h(t,h){if(!_.checkDeletedState(o,n))if(t)n(f.getCommitError(t,o.id));else{l.log("Starting merge "+(c?"(local)":"(remote)"));var m={},y=function(e){return m[e]=(m[e]||0)+1};h.name!==o.name&&(e.name=o.name);var E=e.rootNode.getValue(a.MODIFIED_KEY),g=Math.max(E||0,o.modified||0);h!==o._dcxBranch&&g&&E!==g&&e.rootNode.setValue(a.MODIFIED_KEY,g);var v=function(e){var t={};return _.getCustomDCXData(e.rootNode).forEach((function(e){t[e.namespace+"#"+e.key]=e.value})),t},A={},C=v(o._dcxBranch),O=v(h),L=v(e);Object.keys(C).forEach((function(e){A[e]=!0,JSON.stringify(C[e])!==JSON.stringify(O[e])&&(L[e]=C[e])})),Object.keys(L).forEach((function(e){A[e]||O[e]&&!C[e]&&delete L[e]}));var S,I,R,D=_.getCompositeRenditionMap(e),b=_.getCompositeRenditionMap(h);Object.keys(o._dcxCompositeRenditionMap).forEach((function(t){var n=o._dcxCompositeRenditionMap[t],i=b[t],r=D[t];i&&n.id===i.id||(r?(n.getValue(a.MODIFIED_KEY)||0)>(r.getValue(a.MODIFIED_KEY)||0)&&(e.removeComponent(r),e.copyComponent(n,e.rootNode)):e.copyComponent(n,e.rootNode))})),Object.keys(b).forEach((function(t){var n=o._dcxCompositeRenditionMap[t],i=b[t],r=D[t];!n&&r&&r.id===i.id&&e.removeComponent(r)})),e.getChildrenOf().forEach((function(e){e.name===a.ELEMENTS_NAME&&(S=e),e.name===a.REMOVED_ELEMENTS_NAME&&(I=e),e.name===a.GROUPS_NAME&&(R=e)})),S||(S=e.addChild(a.ELEMENTS_NAME));var T=function(){I||(I=e.addChild(a.REMOVED_ELEMENTS_NAME))},N=[],w={},P=[],x=function(e,t,n,o){var i=t.getValue(a.ORDER_KEY),r=n&&n.getValue(a.ORDER_KEY),s=o&&o.getValue(a.ORDER_KEY);if(s!==i)e._dcxNode.setValue(a.ORDER_KEY,i);else if(r!==s)return e.order!==r&&e._dcxNode.setValue(a.ORDER_KEY,r),!0;return!1};o._groups.forEach((function(t){var n=t.id,o=t._dcxNode,i=t.modified,r=e.getChildWithId(n),s=r&&r.getValue(a.MODIFIED_KEY),c=h&&h.getChildWithId(n),p=c&&c.getValue(a.MODIFIED_KEY);if(!p&&!s||p&&!s&&i!==p){y("g1: group created locally");var d=e.copyChild(o,(R||(R=e.addChild(a.GROUPS_NAME)),R),void 0,void 0,void 0);t._setDCXNode(d)}else p&&!s&&i===p?(y("g2: group deleted on server"),P.push(t)):p===i&&p===s?(y("g3: no changes to group modified time"),t._setDCXNode(r),x(t,o,r,c)&&N.push(t)):p===i&&p!==s?(y("g4: updated group on server"),t._setDCXNode(r),N.push(t),x(t,o,r,c)):p!==i&&p===s?(y("g5: updated group locally"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),x(t,o,r,c)&&N.push(t)):p!==i&&p!==s?(y("g6: updated group locally and on server (conflict)"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),x(t,o,r,c)&&N.push(t)):l.log("ERROR: unexpected group merge case: base="+p+", current="+i+", pulled="+s);w[n]=!0})),P.forEach((function(e){return o._doRemoveGroup(e)}));var k=[],M=[],F=[],V=[],U=new d,B=function(t){var n=t.id,i=t._dcxNode,p=t.modified,d=t.removed,u=e.getChildWithId(n),_=u&&u.getValue(a.MODIFIED_KEY),f=u&&u.getValue(a.REMOVED_KEY),m=h&&h.getChildWithId(n),E=m&&m.getValue(a.MODIFIED_KEY),g=m&&m.getValue(a.REMOVED_KEY);o._dcxBranch=e;var v=function(){return d?(T(),I):S},A=function(){return!d&&t.removed?(F.push(t),!0):!(!d||t.removed||(V.push(t),0))},C=function(){var e=!1,n=i.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},o=u&&u.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},r=m&&m.getValue(a.DESCRIPTION_DATA_KEY)||{time:0};if(n.time!==r.time){var s=i.getValue(a.DESCRIPTION_KEY);t._dcxNode.setValue(a.DESCRIPTION_KEY,s),t._dcxNode.setValue(a.DESCRIPTION_DATA_KEY,n)}else o.time!==r.time&&(e=!0);var c=i.getValue(a.GROUPS_KEY)||{},l=u&&u.getValue(a.GROUPS_KEY)||{},p=m&&m.getValue(a.GROUPS_KEY)||{},d={};return Object.keys(c).forEach((function(t){var n=c[t],o=l[t],i=p[t];i&&n.order===i.order?o||(e=!0):d[t]=n})),Object.keys(l).forEach((function(t){var n=c[t],o=l[t],i=p[t];i&&!n||d[t]||(d[t]=o,i&&o.order===i.order||(e=!0))})),(Object.keys(d).length>0||Object.keys(l).length>0)&&JSON.stringify(l)!==JSON.stringify(d)&&t._dcxNode.setValue(a.GROUPS_KEY,d),e};if(!E&&!_||E&&!_&&p!==E){y("e1: created element locally");var O=e.copyChild(i,v(),void 0,void 0,void 0);t._setDCXNode(O,!0)}else if(E&&!_&&p===E)y("e2: deleted element on server"),M.push(t);else if(E===p&&E===_){y("e3: no changes to element modified time"),t._setDCXNode(u,!0),g!==d&&(g===f?d&&!f?(y("e3a: removed element locally"),T(),t._dcxNode=e.moveChild(t._dcxNode,void 0,I),t._updateTimestampOnRemove(d)):f&&!d&&(y("e3b: restored element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,S),t._updateTimestampOnRestore()):d||(y("e3c: remove/restore element conflict - local restore wins"),t._dcxNode=e.moveChild(t._dcxNode,void 0,S),t._updateTimestampOnRestore()));var L=A(),R=C();(L||R)&&N.push(t),t._ensureRemovedDataValid(c&&!a.SHARED_LOCAL_STORAGE)}else if(E===p&&E!==_)y("e4: updated element on server"),t._setDCXNode(u,c),N.push(t),A(),C(),t._ensureModifiedDataValid(c&&!a.SHARED_LOCAL_STORAGE);else if(E!==p&&E===_){y("e5: updated element locally");var D=e.replaceChild(i,void 0,void 0);t._setDCXNode(D,!0),(d&&!f||f&&!d)&&(t._dcxNode=e.moveChild(t._dcxNode,void 0,v())),C()&&N.push(t)}else if(E!==p&&E!==_){y("e6: updated element locally and on server (conflict)"),t._setDCXNode(u),N.push(t),A(),t._ensureModifiedDataValid(c&&!a.SHARED_LOCAL_STORAGE);var b=l.uuid(),P=e.copyChild(i,v(),void 0,b,b),x=new r(o,P);k.push(x),w[x.id]=!0,l.hasFileSystem()&&U.addOperation((function(e){return o._renditionCache.copyCache(t,x).then(e,e)})),s.reportCollisionElement(t)}else l.log("ERROR: unexpected element merge case: base="+E+", current="+p+", pulled="+_);o._dcxBranch=o._dcxComposite.current,w[n]=!0};o._elements.forEach(B),o._removedElements.forEach(B);var Y=function(e){e.removed?o._removedElements.push(e):(o._addElementToFilter(e),o._elements.push(e))};k.forEach(Y),o._sortRemovedElements(),M.forEach((function(e){o._doRemoveElement(e,!1)})),F.forEach((function(e){o._doMarkElementRemoved(e,!1)})),V.forEach((function(e){o._doRestoreElement(e,!1)})),o._dcxBranch=e,o._dcxElementsNode=S,o._dcxRemovedElementsNode=I,o._dcxGroupsNode=R,o._dcxCompositeRenditionMap=_.getCompositeRenditionMap(e);var H=function(t,n){if(!w[t.id]){var s=t.getValue(a.MODIFIED_KEY),l=h&&h.getChildWithId(t.id),p=l&&l.getValue(a.MODIFIED_KEY);if(p&&s&&p===s)y(n?"g7: deleted group locally":"e7: deleted element locally"),e.removeChild(t);else if(y(n?"g8: created group on server":"e8: created element on server"),n){var d=new i(o,t);o._groups.push(d)}else{var u=new r(o,t);Y(u),u._ensureCreatedDataValid(c&&!a.SHARED_LOCAL_STORAGE)}}},j=o._dcxBranch.getChildrenOf(o._dcxElementsNode),G=o._dcxRemovedElementsNode?o._dcxBranch.getChildrenOf(o._dcxRemovedElementsNode):[],W=o._dcxGroupsNode?o._dcxBranch.getChildrenOf(o._dcxGroupsNode):[];j.forEach((function(e){H(e)})),G.forEach((function(e){H(e)})),W.forEach((function(e){H(e,!0)})),Object.keys(m).sort().forEach((function(e){var t=m[e];l.log("Merge Case ".concat(e," (").concat(t,")"))})),o._transactionCount++,U.run((function(){_.checkDeletedState(o,n)||(o._transactionCount--,l.storageInterface.resolvePullWithBranch(o,e,p,c,(function(t){_.checkDeletedState(o,n)||(t?n(f.getCommitError(t,o.id)):(l.hasFileSystem()||(o._dcxBaseBranch=e.copy()),a.SHARED_LOCAL_STORAGE||c||u.prefetchRenditions(o),n(null),N.forEach((function(e){e._listenerManager.notify("change")})),o._notifyChange()))})))}))}}this._waitForCommit((function(){_.checkDeletedState(o,n)||(t?h(null,t):"unmodified"===o._dcxBranch.compositeState?h(null,o._dcxBranch):o._loadBaseBranch(h))}))},A.prototype._pull=function(e){var t=this;if(this._dcxComposite.href&&this._dcxBranch.isBound)if(this._deletedFromServer)e(null,!1);else{var n=function(n,o){_.checkDeletedState(t,e)||(n&&t._collection._reportSyncError(n),t._setSyncState(),t._networkLock.release(),e(n,o))};this._networkLock.obtain((function(o){o?e(null):_.checkDeletedState(t,e)||(this._setSyncState("downloading"),this._collection._syncManager.pullComposite(this._dcxComposite,this._collection,(function(o,i){_.checkDeletedState(t,e)||(t._isDeletedError(o)?l.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&"incoming"!==t.collaboration?(t._doRebindToServer(!1,e),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),n(null,!0)):o?n(f.getSyncError(o,t.id)):i?t._mergeAndSwitchToBranch(i,void 0,(function(o){_.checkDeletedState(t,e)||n(o,!0)})):n(null,!1))})))}),this)}else e(null,!1)},A.prototype._pushWithParameters=function(e,t){var n=this,i=function(e,n){t&&t(null,n)};if(a.SYNCING_ENABLED)if(this._collection._retryTimeoutId)i(0,!1);else if(this._dcxBranch.isBound&&"modified"!==this._dcxBranch.compositeState)i(0,!1);else if(this._deletedFromServer)i(0,!1);else if(this.isWritable)if(this._pushPending)i(0,!1);else{var r=function(e,o){_.checkDeletedState(n,i)||(n._pushFailedDueToQuota=!1,e&&(n._collection._reportSyncError(e),e.code===c.EXCEEDS_QUOTA&&(n._pushFailedDueToQuota=!0)),n._setSyncState(),n._collection._syncManager.pullMissingComponents(n,(function(){_.checkDeletedState(n,t)||(n._networkLock.release(),u.prefetchRenditions(n),i(0,o))})))};this._pushPending=!0,this._networkLock.obtain((function(t){t?i(0,!1):this._waitForCommit((function(){var t;_.checkDeletedState(n,i)||(n._pushPending=!1,l.hasFileSystem()||(t=n._dcxBranch.copy()),n._setSyncState("uploading"),n._collection._syncManager.pushComposite(n._dcxComposite,n._collection,e,(function(e){if(!_.checkDeletedState(n,i))if(n._isDeletedError(e))l.hasFileSystem()&&"modified"===n._dcxBranch.compositeState&&"incoming"!==n.collaboration?(n._doRebindToServer(!1,i),n._networkLock.release()):(n._deletedFromServer=!0,n._notifyChange(),r(null,!0));else{if(n._isAlreadyExistsError(e))return n._dcxComposite.name=p.translate("LIBS_RECOVERED_LIBRARY",{name:n._dcxComposite.name}),n._doRebindToServer(!0,i),void n._networkLock.release();if(n._isReadOnlyError(e))return l.log("Push failed due to read only. Reverting: "+n.id),n._setClientDataValue(a.DATA_COLLABORATION_ROLE,"viewer"),void n._revertLocalChangesIfNecessary((function(e){r(e,!1)}));if(e&&e.code===c.TRANSFER_ABORTED)r(null,!0);else{if(e&&e.code===o.UPDATE_CONFLICT){if(l.log("Push failed due to conflict: "+n.id),n._numUpdateConflicts++,n._numUpdateConflicts<=a.MAX_UPDATE_CONFLICTS)return n._sync(!1,i),void n._networkLock.release();s.reportUnexpectedState(n,"updateConflict"),l.log("Reached maximum number of update-conflict retries: "+n.id)}n._numUpdateConflicts=0,e&&e.code===o.COMPONENT_UPLOAD_ERROR&&(l.log("Push failed due to component upload failure: "+n.id),_.removeMissingLocalComponents(n,e.failedComponents)),e?r(f.getSyncError(e,n.id)):l.storageInterface.acceptPush(n,(function(e){_.checkDeletedState(n,i)||(e?r(f.getCommitError(e,n.id),!0):(l.hasFileSystem()||(n._dcxBaseBranch=t),r(null,!0)))}))}}})))}))}),this)}else i(0,!1);else i(0,!1)},A.prototype._loadBaseBranch=function(e){var t=this;l.hasFileSystem()?t._dcxComposite.loadBaseBranch((function(n,o){t._waitForCommit((function(){e(n,o)}))})):e(null,t._dcxBaseBranch)},A.prototype._revertLocalChangesIfNecessary=function(e){var t=this,n=y.wrapCallback(e);this.isWritable||"modified"!==this._dcxBranch.compositeState?n(null):this._loadBaseBranch((function(e,o){t._transactionCount++,_.recoverReadOnlyEdits(t,o,(function(e){e&&l.log("Error recovering library changes: "+e),t._transactionCount--;var i=o.copy(),r=t.collaboration,s=t._getClientDataValue(a.DATA_COLLABORATION_ROLE);t._mergeAndSwitchToBranch(i,t._dcxBranch,(function(e){if(e)l.log("Error Reverting: "+t.id),n(e);else{var o=_.collaborationStateToDCX(r);t._dcxComposite.collaborationType=o,t._setClientDataValue(a.DATA_COLLABORATION_ROLE,s),t._commit(!0,!0),t._waitForCommit((function(){t._notifyChange(),n(null)}))}}))}))}))},A.prototype._push=function(e){this._pushWithParameters(!1,e)},A.prototype._abortPushOrPull=function(){this._networkLock.abortPendingOperations(new c(c.TRANSFER_ABORTED)),this._collection._syncManager.abortPushOrPull(this.id)},A.prototype._deleteFromServer=function(e,t){var n=this;if(this._deletingFromServerInProgress||this._abortPushOrPull(),this._dcxComposite.href)if(this._deletedFromServer)t(null);else{this._deletingFromServerInProgress=!0;var i=function(e){n._deletingFromServerInProgress=!1,n._setSyncState(),n._networkLock.release(),t(e)};this._networkLock.obtain((function(r){r?t(null):this._deletedFromDisk?i(null):(this._setSyncState("uploading"),this._dcxBranch.compositeState="pendingDelete",this._commit(!0,!0),this._waitForCommit((function(){n._deletedFromDisk?i(null):n._collection._syncManager.pushDeletedComposite(n._dcxComposite,n._collection,n.collaboration,e,(function(t){t?n._isDeletedError(t)?(n._deletedFromServer=!0,t=null):(e||t.code!==o.UPDATE_CONFLICT)&&(t=f.getSyncError(t,n.id),n._collection._reportSyncError(t)):n._deletedFromServer=!0,i(t)}))})))}),this)}else t(null)},A.prototype._doRebindToServer=function(e,t){var n=this;this._deletedFromServer=!1;var o=e||"incoming"===this.collaboration?"resetIdentity":"resetBinding",i=this.id;this._dcxComposite[o]((function(e){_.checkDeletedState(n,t)||(e?t(e):(n._transactionCount++,n.id!==i&&(n._collection._libraryIdMap[n.id]=n,delete n._collection._libraryIdMap[i]),m.moveLibrary(n,i,(function(e){_.checkDeletedState(n,t)||(n._transactionCount--,e?t(e):(n._collection._syncManager.prepareCompositeForPush(n._dcxComposite),n._setCollaboration(),n._commit(!1,!0),n._pushWithParameters(!0,t)))}))))}))},A.prototype._sync=function(e,t){var n=this;function o(e,o){t&&n._waitForSyncToFinish((function(){t(e,o)}))}function i(e,t){_.checkDeletedState(n,o)||(e?o(e,t):n._push((function(e,i){_.checkDeletedState(n,o)||o(e,t||i)})))}!a.SHARED_LOCAL_STORAGE&&a.SYNCING_ENABLED?this._collection._retryTimeoutId?o(null,!1):(this._collection._clearSyncErrors(this.id),e?i(null,!1):this._pull(i)):o(null,!1)},A.prototype._getCompositeDir=function(){return this._collection._getCompositeDir(this.id)},A.prototype._getRenditionCacheDir=function(){return this._collection._getRenditionCacheDir(this.id)},A.prototype._setAutoGC=function(e,t){!1===t?this._autoGCMode[e]=!1:delete this._autoGCMode[e],this._dcxComposite.autoRemoveUnusedLocalFiles=0===Object.keys(this._autoGCMode)},Object.defineProperties(A.prototype,{id:{get:function(){return this._publicId||this._dcxComposite.id},set:function(){throw new c(c.READ_ONLY,"Cannot change the id of an existing library",this.id)}},collection:{get:function(){return this._collection},set:function(){throw new c(c.READ_ONLY,"collection is a read-only property",this.id)}},isWritable:{get:function(){var e=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);return this._writable&&"viewer"!==e},set:function(){throw new c(c.READ_ONLY,"isWritable is a read-only property",this.id)}},name:{get:function(){return this._dcxComposite.name||""},set:function(e){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);this._dcxComposite.name=e,this._commit()}},modified:{get:function(){return this._dcxBranch.rootNode.getValue(a.MODIFIED_KEY)},set:function(){throw new c(c.READ_ONLY,"Cannot change the modified timestamp of a library directly",this.id)}},created:{get:function(){return this._dcxBranch.rootNode.getValue(a.CREATED_KEY)},set:function(){throw new c(c.READ_ONLY,"Cannot change the created timestamp of a library directly",this.id)}},elements:{get:function(){return this._elements},set:function(){throw new c(c.READ_ONLY,"Cannot modify elements list directly",this.id)}},removedElements:{get:function(){return this._removedElements},set:function(){throw new c(c.READ_ONLY,"Cannot modify removed elements list directly",this.id)}},isDeletedFromServer:{get:function(){return this._deletedFromServer},set:function(){throw new c(c.READ_ONLY,"isDeletedFromServer is a read-only property",this.id)}},isDeletedLocally:{get:function(){return this._deletedLocally},set:function(){throw new c(c.READ_ONLY,"isDeletedLocally is a read-only property",this.id)}},isQuotaExceeded:{get:function(){return this._pushFailedDueToQuota},set:function(){throw new c(c.READ_ONLY,"isQuotaExceeded is a read-only property",this.id)}},toolkitId:{get:function(){return this.getValue(a.TOOLKIT_NAMESPACE,a.TOOLKIT_ID_KEY)},set:function(){throw new c(c.READ_ONLY,"toolkitId is a read-only property",this.id)}},collaboration:{get:function(){var e=this._dcxComposite.collaborationType;return _.collaborationStateFromDCX(e)},set:function(){throw new c(c.READ_ONLY,"collaboration is a read-only property",this.id)}},syncState:{get:function(){return this._syncState},set:function(){throw new c(c.READ_ONLY,"syncState is a read-only property")}},syncProgress:{get:function(){var e=this._collection._syncProgressMap[this.id];return e&&e.progress},set:function(){throw new c(c.READ_ONLY,"syncProgress is a read-only property")}}}),A.prototype.toString=function(){return JSON.stringify(this._toJSON())},A.prototype.addChangeListener=function(e){_.checkDeletedState(this),this._listenerManager.add("change",e)},A.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},A.prototype.getGroups=function(e){return e=e||a.DEFAULT_GROUP_CLASSIFIER,this._groups.filter((function(t){return e instanceof RegExp?e.test(t.classifierName):e===t.classifierName}))},A.prototype.getGroupById=function(e){return this._groups.find((function(t){return t.id===e}))},A.prototype.createGroup=function(e,t,n){if(n=n||a.DEFAULT_GROUP_CLASSIFIER,_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);var o=this._doCreateGroup(e,t,n);return this._commit(),s.reportCreateGroup(o),o},A.prototype.removeGroup=function(e,t){var n=this;if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No group specified",this.id);if(-1===this._groups.indexOf(e))throw new c(c.INVALID_PARAMETER,"group not in this library",this.id);var o=0;this._doRemoveGroup(e,(function(e){t?(n.removeElement(e),o++):e._listenerManager.notify("change")})),this._commit(),s.reportDeleteGroup(e,t,o)},A.prototype.moveGroup=function(e,t,n,o){if(!_.checkDeletedState(this,o))if(this.isWritable)if(e)if(-1!==this._groups.indexOf(e))if(t)if(this!==t){var i;if(t.isWritable)return n&&(i=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,n,!0,(function(t,r){t?o(t):(s.reportMoveGroup(r,e,n,i),o(null,r))}));o(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else o(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else o(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else o(new c(c.INVALID_PARAMETER,"Group not in this library",this.id));else o(new c(c.INVALID_PARAMETER,"No group specified",this.id));else o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},A.prototype.copyGroup=function(e,t,n,o){if(!_.checkDeletedState(this,o))if(e)if(-1!==this._groups.indexOf(e))if(t){var i;if(t.isWritable)return n&&(i=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,n,!1,(function(t,r){t?o(t):(s.reportCopyGroup(r,e,n,i),o(null,r))}));o(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else o(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else o(new c(c.INVALID_PARAMETER,"Group not in this library",this.id));else o(new c(c.INVALID_PARAMETER,"No group specified",this.id))},A.prototype.createElement=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(this._elements.length>=a.MAX_ELEMENTS)throw new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation((function(){var n=this._doCreateElement(e,t);return s.reportCreateElement(n),n.beginOperation(),n}),this)},A.prototype.removeElement=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._elements.indexOf(e)){if(-1===this._removedElements.indexOf(e))throw new c(c.INVALID_PARAMETER,"Element not in this library",this.id);if(!t)throw new c(c.INVALID_PARAMETER,"Element already removed",this.id)}return this._wrapOperation((function(){for(;e._transactionCount>0;)e.endOperation();t?this._doRemoveElement(e,!0):this._doMarkElementRemoved(e,!0),s.reportDeleteElement(e,t)}),this)},A.prototype.restoreElement=function(e){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._removedElements.indexOf(e)){if(-1===this._elements.indexOf(e))throw new c(c.INVALID_PARAMETER,"Element not in this library",this.id);throw new c(c.INVALID_PARAMETER,"Element already restored",this.id)}if(this._elements.length>=a.MAX_ELEMENTS)throw new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation((function(){this._doRestoreElement(e,!0),s.reportRestoreElement(e)}),this)},A.prototype.copyElement=function(e,t,n){if(!_.checkDeletedState(this,n))if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t){if(t.isWritable)return this._doCopyElement(e,t,!1,(function(t,o){t?n(t):(s.reportCopyElement(o,e),n(null,o))}));n(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else n(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No element specified",this.id))},A.prototype.moveElement=function(e,t,n){if(!_.checkDeletedState(this,n))if(this.isWritable)if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t)if(this!==t){if(t.isWritable)return this._doCopyElement(e,t,!0,(function(t,o){t?n(t):(s.reportMoveElement(o,e),n(null,o))}));n(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else n(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else n(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No element specified",this.id));else n(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},A.prototype.getValues=function(){return _.getCustomDCXData(this._dcxBranch.rootNode)},A.prototype.setValue=function(e,t,n){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);var o,i=_.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new c(c.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.id)}this._dcxBranch.rootNode.setValue(i,o),this._commit()},A.prototype.getValue=function(e,t){if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);var n=_.getDCXKey(e,t);return this._dcxBranch.rootNode.getValue(n)},A.prototype.removeValue=function(e,t){if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);var n=_.getDCXKey(e,t);this._dcxBranch.rootNode.removeValue(n)},A.prototype.getRenditionPath=function(e,t){if(l.hasFileSystem()){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this._dcxCompositeRenditionMap[e];if(!n)return t(null);var o=this._dcxBranch.assetOfComponent(n);if(o)return t(null,o);var i=this;this._networkLock.obtain((function(e){e?t(e):_.checkDeletedState(i,t)?i._networkLock.release():(i._setSyncState("downloading"),i._collection._syncManager.downloadComponent(i._dcxBranch,n,(function(e){i._networkLock.release(),i._setSyncState(),e?t(f.getSyncError(e,i.id)):_.checkDeletedState(i,t)||(i._commit(!0,!0),t(null,i._dcxBranch.assetOfComponent(n)))})))}))}}else t(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id))},A.prototype.getRenditionURL=function(e){_.checkDeletedState(this),this._checkRenditionType(e);var t=this._dcxCompositeRenditionMap[e];if(t)return this._collection._syncManager.getSharedCloudContentURL(t)},A.prototype.getAuthenticatedRenditionURL=function(e,t){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this.getRenditionURL(e);if(!n)return t(null);this._collection._syncManager.appendAccessTokenToURL(n,t)}},A.prototype.setRendition=function(e,t,n,o,i){if(!_.checkDeletedState(this,i)&&this._checkRenditionType(e,i))if(t)if(this.isWritable)if(l.hasFileSystem()){if(!_.checkEncoding(n,["utf8","ascii","base64","buffer"],i))return;this._setRendition(e,t,n,o,i)}else{if(void 0!==n)return void i(new c(c.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setRenditionInBrowser(e,t,o,i)}else i(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id));else i(new c(c.INVALID_PARAMETER,"content must exist",this.id))},A.prototype.setRenditionFromPath=function(e,t,n,o){_.checkDeletedState(this,o)||this._checkRenditionType(e,o)&&("string"==typeof t?l.hasFileSystem()?this.isWritable?this._setRenditionFromPath(e,t,n,o):o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id)):o(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id)):o(new c(c.INVALID_PARAMETER,"path must be a string",this.id)))},A.prototype.removeRendition=function(e){if(_.checkDeletedState(this),this._checkRenditionType(e),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);var t=this._dcxCompositeRenditionMap[e];if(t)return this._wrapOperation((function(){this._dcxBranch.removeComponent(t),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._commit()}),this)},A.prototype.beginOperation=function(){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);this._beginOperation()},A.prototype.endOperation=function(){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);this._endOperation()},A.prototype.getFilteredElements=function(e){if(!e)throw new c(c.INVALID_PARAMETER,"must specify element type to filter",this.id);if("*"!==e&&-1===a.ELEMENT_TYPE_FILTERS.indexOf(e))throw new c(c.INVALID_PARAMETER,"must specify '*', or an element type in config.ELEMENT_TYPE_FILTERS",this.id);var t=this._getFilterKey(e);return this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t]},A.prototype.sync=function(e){_.checkDeletedState(this,e)||this._sync(!1,e)},A.prototype.rebindToServer=function(e){l.hasFileSystem()?_.checkDeletedState(this,e)||(this.isWritable?this._deletedFromServer?this._doRebindToServer(!1,e):e(null):e(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))):e(new c(c.REQUIRES_FILESYSTEM,"rebindToServer requires a filesystem",this.id))},A.prototype.getElementById=function(e,t){var n;return this.elements.forEach((function(t){t.id===e&&(n=t)})),n||t||this.removedElements.forEach((function(t){t.id===e&&(n=t)})),n},Object.freeze(A),Object.seal(A.prototype),e.exports=A},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var r=n(23),a=n(24),s=n(0),c=n(1),l=n(14),p=n(5),d=n(6),h=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._rootDir=t,this._cache={},this._pendingCacheItems={},this._lock=new l}return function(e,t,n){t&&i(e.prototype,t)}(e,[{key:"load",value:function(){var e=this;return this._loadingPromise||(this._loadingPromise=this._doTransaction((function(){return e._load()}),!1)),this._loadingPromise}},{key:"save",value:function(){var e=this;return this._doTransaction((function(){return e._save()}))}},{key:"_doTransaction",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=function(){return t._lock.release()},i=new Promise((function(e){return t._lock.obtain(e)})).then(e);return n&&(i=i.then((function(e){return t._save().then((function(){return e}))}))),i.then(o,o),i}},{key:"_load",value:function(){var e=this;return!s.hasFileSystem()||c.SHARED_LOCAL_STORAGE?Promise.resolve():p.readJSONData(a.join(this._rootDir,c.RENDITION_CACHE_FILE)).catch((function(){})).then((function(t){e._cache=t||{}}))}},{key:"_save",value:function(){var e=this;return!s.hasFileSystem()||c.SHARED_LOCAL_STORAGE?Promise.resolve():p.writeJSONData(this._rootDir,c.RENDITION_CACHE_FILE,this._cache).then((function(){return e._gcUnreferencedFiles()}))}},{key:"_waitForCommit",value:function(e){if(!this._lock.isLocked())return e();this._doTransaction(e,!1)}},{key:"_getCache",value:function(e){for(var t=this._cache,n=0;t&&n<e.length;n++)t=t[e[n]];return t}},{key:"_isErrorCode",value:function(e){return e&&d.isErrorCode(e)}},{key:"_isPath",value:function(e){return e&&e!==c.RENDITION_CACHE_PLACEHOLDER&&!this._isErrorCode(e)}},{key:"_getFilePath",value:function(e,t){if(e){if(t&&!this._isPath(e))return e;var n=a.join(this._rootDir,e);return c.SHARED_LOCAL_STORAGE||r.statSync(n)?n:void 0}}},{key:"_setCacheEntry",value:function(e,t){for(var n=this._cache,o=0;o<e.length-1;o++){var i=e[o];n=n[i]=n[i]||{}}var r=e[e.length-1];return void 0===t?delete n[r]:n[r]=t,t}},{key:"_setCache",value:function(e,t,n){var o=this,i=p.getFileExtension(t)||"png",c="".concat(s.uuid(),".").concat(i);return r.ensureDir(this._rootDir).then((function(){return o._pendingCacheItems[c]=!0,r[n?"rename":"copy"](t,a.join(o._rootDir,c))})).then((function(){return delete o._pendingCacheItems[c],o._setCacheEntry(e,c),a.join(o._rootDir,c)})).catch((function(e){return delete o._pendingCacheItems[c],Promise.reject(d.getCommitError(e,void 0,"unable to save cache to disk"))}))}},{key:"_iterate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._cache,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];Object.keys(n).forEach((function(r){"object"===o(n[r])?t._iterate(e,n[r],i.concat(r)):e(i,n[r])}))}},{key:"_gcUnreferencedFiles",value:function(){var e=this,t={};return this._iterate((function(n,o){t[o]=!0,delete e._pendingCacheItems[o]})),r.readdir(this._rootDir).then((function(n){var o=[];return n.forEach((function(n){var i=p.normaliseTempFileName(n);n===c.RENDITION_CACHE_FILE||t[n]||e._pendingCacheItems[i]||o.push(r.remove(a.join(e._rootDir,n)))})),Promise.all(o)}))}}]),e}();e.exports=h},function(e,t,n){var o=n(2);function i(e,t){this._id=e,this._url=t}Object.defineProperties(i.prototype,{id:{get:function(){return this._id},set:function(){throw new o(o.READ_ONLY,"Cannot change the id of an existing bookmark")}},url:{get:function(){return this._url},set:function(){throw new o(o.READ_ONLY,"Cannot change the url of an existing bookmark")}}}),Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o=n(22),i=n(2),r=n(1),a=n(0),s=n(12),c=n(5);function l(e){e.IS_PUBLIC=!0,e.USER_ID=e.USER_ID||r.PUBLIC_USER_ID,this._newLibrariesLoading={},o.call(this,e)}Object.keys(o.prototype).forEach((function(e){0===e.indexOf("_")&&(l.prototype[e]=o.prototype[e])})),l.prototype._dosync=function(e,t){var n=this;this._clearSyncErrors();var o=new s;this._libraries.forEach((function(e){o.addOperation((function(t){n._syncManager.hasCompositeChangedOnServer(e._dcxComposite,(function(n){e._sync(!n,t)}))}))})),o.run((function(e,n){t(null,n)}),(function(e){n._reportSyncError(e)}))},Object.defineProperties(l.prototype,{libraries:{get:function(){return this._libraries},set:function(){throw new i(i.READ_ONLY,"Cannot modify libraries list directly")}},commitError:{get:function(){return this._lastCommitError},set:function(){throw new i(i.READ_ONLY,"commitError is a read-only property")}},syncState:{get:function(){return this._syncState},set:function(){throw new i(i.READ_ONLY,"syncState is a read-only property")}},syncErrors:{get:function(){return this._syncErrors},set:function(){throw new i(i.READ_ONLY,"syncErrors is a read-only property")}},syncProgress:{get:function(){return this._syncProgress},set:function(){throw new i(i.READ_ONLY,"syncProgress is a read-only property")}},isPolling:{get:function(){return void 0!==this._pollTimerId},set:function(){throw new i(i.READ_ONLY,"isPolling is a read-only property")}},retryTime:{get:function(){return"never"!==this._retryTime?this._retryTime:void 0},set:function(){throw new i(i.READ_ONLY,"retryTime is a read-only property")}},userId:{get:function(){return this._userId},set:function(){throw new i(i.READ_ONLY,"userId is a read-only property")}},cloudId:{get:function(){return this._cloudId},set:function(){throw new i(i.READ_ONLY,"cloudId is a read-only property")}},cloudInfo:{get:function(){return this._cloudInfo},set:function(){throw new i(i.READ_ONLY,"cloudInfo is a read-only property")}},isPublic:{get:function(){return!0},set:function(){throw new i(i.READ_ONLY,"isPublic is a read-only property")}},operations:{get:function(){return this._operations},set:function(){throw new i(i.READ_ONLY,"operations is a read-only property")}}}),l.prototype.addChangeListener=function(e){o.prototype.addChangeListener.call(this,e)},l.prototype.removeChangeListener=function(e){o.prototype.removeChangeListener.call(this,e)},l.prototype.addDeepChangeListener=function(e){o.prototype.addDeepChangeListener.call(this,e)},l.prototype.removeDeepChangeListener=function(e){o.prototype.removeDeepChangeListener.call(this,e)},l.prototype.canLoadLibrary=function(e){var t=new RegExp(this._syncManager.getSyncGroupPath()+"/(.+)");return!!e.match(t)},l.prototype.loadLibrary=function(e,t,n){var o=this,s=this.getLibraryById(e);if(s)n(null,s);else if(!t||this.canLoadLibrary(t)){var c=this._newLibrariesLoading[e];c?c.push(n):(this._newLibrariesLoading[e]=[n],r.SHARED_LOCAL_STORAGE?a.storageInterface.loadPublicLibrary(this,e,t,l):this._syncNewLibrary(e,t,void 0,(function(t){t?l(t):((s=o.getLibraryById(e))&&(s._loadedExternally=!0),l(null,s))})))}else n(new i(i.INVALID_PARAMETER,"Invalid library url"));function l(t,n){var i=o._newLibrariesLoading[e];delete o._newLibrariesLoading[e],i.forEach((function(e){e(t,n)}))}},l.prototype.unloadLibrary=function(e,t){var n=this._libraries.indexOf(e);-1!==n?(this._libraries.splice(n,1),delete this._libraryIdMap[e.id],e._markDeletedLocally(!0),r.SHARED_LOCAL_STORAGE?a.storageInterface.unloadPublicLibrary(e,t):(e._deletedFromDisk=!0,c.deleteLibraryFromDisk(this,e.id,t)),this._listenerManager.notify("change")):t(null)},l.prototype.removeDeletedLibraries=function(e,t){o.prototype.removeDeletedLibraries.call(this,e,t)},l.prototype.exportLibrary=function(e,t,n){return o.prototype.exportLibrary.call(this,e,t,n)},l.prototype.sync=function(e){o.prototype.sync.call(this,e)},l.prototype.addSyncListener=function(e){o.prototype.addSyncListener.call(this,e)},l.prototype.removeSyncListener=function(e){o.prototype.removeSyncListener.call(this,e)},l.prototype.getPrimarySyncError=function(){return o.prototype.getPrimarySyncError.call(this)},l.prototype.getNewLibrarySyncProgress=function(){return o.prototype.getNewLibrarySyncProgress.call(this)},l.prototype.addOperationChangeListener=function(e){this._listenerManager.add("operation",e)},l.prototype.removeOperationChangeListener=function(e){this._listenerManager.remove("operation",e)},l.prototype.addCommitErrorListener=function(e){o.prototype.addCommitErrorListener.call(this,e)},l.prototype.removeCommitErrorListener=function(e){o.prototype.removeCommitErrorListener.call(this,e)},l.prototype.startPolling=function(){o.prototype.startPolling.call(this)},l.prototype.stopPolling=function(){o.prototype.stopPolling.call(this)},l.prototype.getLibraryById=function(e){return o.prototype.getLibraryById.call(this,e)},l.prototype.getTempDir=function(e){o.prototype.getTempDir.call(this,e)},Object.freeze(l),Object.seal(l.prototype),e.exports=l},function(e,t,n){var o=n(0),i=n(1),r=n(22),a=n(37),s=n(81),c=n(2),l=n(18),p=n(82),d=n(86),h=n(87),u=n(5),_=n(10),f=new s,m={};function y(e,t,n){var o=e+"/"+t,i=void 0!==m[o];return m[o]=m[o]||[],m[o].push(n),i}function E(e,t){var n;n=e===i.PUBLIC_USER_ID?f.getPublicLibraryCollection(t):f.getLibraryCollection(e,t);var o=e+"/"+t,r=m[o];r&&(delete m[o],r.forEach((function(e){e(null,n)})))}var g={configure:function(e,t){if(o.hasFileSystem()||void 0!==t.SHARED_LOCAL_STORAGE||(t.SHARED_LOCAL_STORAGE=!1),o.hasFileSystem()&&!t.ROOT_DIR&&!1===t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"Missing ROOT_DIR option");if(o.hasFileSystem()&&t.ROOT_DIR&&!1!==t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"ROOT_DIR option doesn't apply when using shared local storage");if(!o.hasFileSystem()&&t.ROOT_DIR)throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");if(!1===t.SHARED_LOCAL_STORAGE&&!t.STORAGE_API_KEY)throw new c(c.INVALID_PARAMETER,"Missing STORAGE_API_KEY option");if(!1===t.SHARED_LOCAL_STORAGE&&!t.DEVICE_ID)throw new c(c.INVALID_PARAMETER,"Missing DEVICE_ID option");if(!1!==t.SHARED_LOCAL_STORAGE&&!o.hasCEPVulcan()&&!e.vulcanCall)throw new c(c.INVALID_PARAMETER,"Shared local storage requires either the CEP VulcanInterface/VulcanMessage as globals, or for you to pass in the vulcanCall dependency");if(!t.APP_DESCRIPTION)throw new c(c.INVALID_PARAMETER,'Missing APP_DESCRIPTION option - should be a string of the form <name>-<version>, e.g. "PHXS-16.0".');if(t.ROOT_DIR)for(;-1!==["/","\\"].indexOf(t.ROOT_DIR.substr(-1));)t.ROOT_DIR=t.ROOT_DIR.slice(0,-1);t.LOCALE&&(l.setLocale(t.LOCALE),delete t.LOCALE),Object.keys(t).forEach((function(e){i.setParameter(e,t[e])})),o.analytics=e.analytics,o.vulcanCall=e.vulcanCall,o._log=e.log,o._getDisplayName=e.getDisplayName,o._getNodeTunnelOptions=e.getNodeTunnelOptions,e.renditionGenerator&&o.setRenditionGenerator(e.renditionGenerator),o.storageInterface&&o.storageInterface.shutdown(),o.storageInterface=new p(f),o.log("Configure: "+(i.SHARED_LOCAL_STORAGE?"<shared local storage>":i.ROOT_DIR))},setOption:function(e,t){if(-1!==["ROOT_DIR","SHARED_LOCAL_STORAGE","ELEMENT_TYPE_FILTERS","STORAGE_API_KEY"].indexOf(e))throw new c(c.INVALID_PARAMETER,"Cannot reconfigure "+e);i.setParameter(e,t),o.storageInterface.updateConfiguration()},getOption:function(e){return i[e]},setLocalSetting:function(e,t){if("string"!=typeof e)throw new c(c.INVALID_PARAMETER,"Key must be a string");try{JSON.stringify(t)}catch(e){throw new c(c.INVALID_PARAMETER,"Value must be serializable to JSON")}i.LOCAL_SETTINGS[e]=t,o.storageInterface.updateConfiguration()},getLocalSetting:function(e){return i.LOCAL_SETTINGS[e]},getSNISettings:function(){return{TLS_DISCOVERY_PORT_RANGE:i.TLS_DISCOVERY_PORT_RANGE,TLS_DELAY_ON_DECLINE:2*i.TLS_DELAY_ON_DECLINE,TLS_DELAY_ON_READY:2*i.TLS_DELAY_ON_READY}},getLoadedCollections:function(){return f.getLoadedCollections().slice(0)},getLoadedCollectionById:function(e,t){return f.getLibraryCollection(e,t)},getLoadedPublicCollectionById:function(e){return f.getPublicLibraryCollection(e)},addLoadedCollectionsListener:function(e){f.addLoadedCollectionsListener(e)},removeLoadedCollectionsListener:function(e){f.removeLoadedCollectionsListener(e)},getRootDir:function(){if(!o.hasFileSystem())throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");return i.ROOT_DIR},getLocale:function(){return l.getLocale()},unloadLibraryCollection:function(e){if(i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"unloadLibraryCollection() not supported with shared local storage");e.stopPolling(),e._removeAllListeners(),f.removeLibraryCollection(e)},loadLibraryCollection:function(e,t){if("function"!=typeof e)if(i.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadLibraryCollection() not supported with shared local storage"));else if(!o.hasFileSystem()||i.SHARED_LOCAL_STORAGE||i.ROOT_DIR)if(e=e||{},!o.hasFileSystem()||e.USER_ID)if(e.CLOUD_ID=e.CLOUD_ID||i.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME)if(e.COLLABORATION_HOSTNAME)if(e.CC_IMAGE_HOSTNAME)if(e.CC_IMAGE_X_HOSTNAME)if(e.TYPEKIT_HOSTNAME){var n=f.getLibraryCollection(e.USER_ID,e.CLOUD_ID),a=y(e.USER_ID,e.CLOUD_ID,t);if(!n||a){if(!a)if(n=new r(e),o.hasFileSystem())u.doesRootDirExist(n,(function(e,t){n._load((function(){t||n._setInitialSyncState(!0),n.sync((function(){n._setInitialSyncState(!1)})),l()}))}));else if("all"===e.WAIT_FOR)n._setInitialSyncState(!0),n.sync((function(){n._setInitialSyncState(!1),l()}));else if(_.validateLibraryId(e.WAIT_FOR,!1)){n._setInitialSyncState(!0,[e.WAIT_FOR]),n.sync((function(){n._setInitialSyncState(!1)}));var s=function t(){"syncing"===n.syncState&&"pending"===n._libraryIdMap[e.WAIT_FOR]||(n.removeChangeListener(t),n.removeSyncListener(t),l())};n.addChangeListener(s),n.addSyncListener(s)}else n._setInitialSyncState(!0),n.sync((function(){n._setInitialSyncState(!1)})),l()}else E(e.USER_ID,e.CLOUD_ID)}else t(new c(c.INVALID_PARAMETER,"Missing TYPEKIT_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing CC_IMAGE_X_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing CC_IMAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing COLLABORATION_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing USER_ID option"));else t(new c(c.INVALID_PARAMETER,"ROOT_DIR not configured. Make sure you call CCLibraries.configure()"));else(t=e)(new c(c.INVALID_PARAMETER,"options argument not specified"));function l(){f.addLibraryCollection(n),i.AUTO_START_POLLING&&n.startPolling(),E(e.USER_ID,e.CLOUD_ID)}},loadPublicLibraryCollection:function(e,t){if("function"!=typeof e)if(i.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadPublicLibraryCollection() not supported with shared local storage"));else if(!o.hasFileSystem()||i.SHARED_LOCAL_STORAGE||i.ROOT_DIR)if((e=e||{}).CLOUD_ID=e.CLOUD_ID||i.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME){var n=f.getPublicLibraryCollection(e.CLOUD_ID),r=y(i.PUBLIC_USER_ID,e.CLOUD_ID,t);!n||r?r||(n=new a(e),o.hasFileSystem()?n._load((function(){n.sync(),s()})):s()):E(i.PUBLIC_USER_ID,e.CLOUD_ID)}else t(new c(c.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"ROOT_DIR not configured. Make sure you call CCLibraries.configure()"));else(t=e)(new c(c.INVALID_PARAMETER,"options argument not specified"));function s(){f.addLibraryCollection(n),i.AUTO_START_POLLING&&n.startPolling(),E(i.PUBLIC_USER_ID,e.CLOUD_ID)}},isConnected:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"isConnected() is only applicable if using shared local storage");return o.storageInterface&&o.storageInterface.isConnected()},reconnect:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"reconnect() is only applicable if using shared local storage");o.storageInterface&&o.storageInterface.reconnect()},disconnect:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"disconnect() is only applicable if using shared local storage");o.storageInterface&&o.storageInterface.isConnected()&&o.storageInterface.shutdown()},getServiceInfo:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"getServiceInfo() is only applicable if using shared local storage");return o.storageInterface&&o.storageInterface.getServiceInfo()},isSyncingEnabled:function(){if(i.SHARED_LOCAL_STORAGE){var e=g.getServiceInfo();return!(!e||!e.syncingEnabled)}return i.SYNCING_ENABLED},enableSyncing:function(){i.SHARED_LOCAL_STORAGE?o.storageInterface.setSyncEnabled(!0):(i.SYNCING_ENABLED=!0,g.getLoadedCollections().forEach((function(e){e.sync()})))},disableSyncing:function(){i.SHARED_LOCAL_STORAGE?o.storageInterface.setSyncEnabled(!1):i.SYNCING_ENABLED=!1},getLibraryById:function(e){var t;return g.getLoadedCollections().some((function(n){return t=n.getLibraryById(e)})),t},resolveElementReference:function(e){e=e||"";var t,n=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),o=e.match(n);if(o){var i=o[1],r=o[2],a=o[3];g.getLoadedCollections().every((function(e){if(i===e._syncManager.getElementRefDomainPath()){var n=e.getLibraryById(r);return n&&(t=n.getElementById(a)),!1}return!0}))}return t},getAccessToken:function(e,t,n,r,a){i.SHARED_LOCAL_STORAGE?0!==f.getLoadedCollections().length?o.storageInterface.getAccessToken(e,t,n,r,a):a(new c(c.LOGGED_OUT,"User must be logged in to request an access token")):a(new c(c.NOT_SUPPORTED,"getAccessToken() is only supported with shared local storage"))}};g.errors=c,g.utils=d,g.analyticsUtils=h,Object.seal(g),e.exports=g},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=n(3),r=n(4);function a(e,t,n){e?this._setData(e):this._data={},this._readOnly=t,this._isRoot=n}a.ROOT_PATH="/",Object.defineProperties(a.prototype,{id:{get:function(){return this._data.id},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(this._owner)throw new i(i.READ_ONLY,"Cannot change the id of a node that is part of a branch or element.");if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty()}},name:{get:function(){return this._data.name},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty()}},type:{get:function(){return this._data.type},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.type=e,this._setDirty()}},relationship:{get:function(){return this._data.rel},set:function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty()}},path:{get:function(){return this._isRoot?"/":this._data.path},set:function(e){if(e!==this.path){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(this._isRoot)throw new i(i.READ_ONLY,"Cannot change the path of the root node.");if(e&&!r.isValidPath(e))throw new i(i.INVALID_PARAMS,"Expecting a valid path or undefined.");this._owner?this._owner._setPathOfNode(this,e||void 0):(this._data.path=e||void 0,this._parentPath=""),this._setDirty()}}},parentPath:{get:function(){return this._parentPath},set:function(){throw new i(i.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get:function(){var e=this.path;return this._isRoot?e:e&&this._owner?r.appendPathElements(this._parentPath,e):void 0},set:function(){throw new i(i.READ_ONLY,"absolutePath is read-only.")}},isRoot:{get:function(){return this._isRoot},set:function(){throw new i(i.READ_ONLY,"isRoot is read-only.")}}}),a.prototype.getLink=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0},a.prototype.setLink=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("object"!==o(e))throw new i(i.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new i(i.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty()},a.prototype.removeLink=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty())};var s={components:!0,children:!0,"manifest-format-version":!0,id:!0,name:!0,type:!0,state:!0,local:!0},c={components:!0,children:!0,rel:!0,path:!0,id:!0,name:!0,type:!0};a.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),o=n.length;for(e=0;e<o;e++){var i=n[e];(this._isRoot?s[i]:c[i])||t.push(i)}return t},a.prototype.getValue=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new i(i.INVALID_PARAMS,"Illegal key");return this._data[e]},a.prototype.setValue=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new i(i.INVALID_PARAMS,"Illegal key");this._data[e]=t,this._setDirty()},a.prototype.removeValue=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new i(i.INVALID_PARAMS,"Illegal key");delete this._data[e],this._setDirty()},a.prototype.copy=function(){var e=null,t=this._data.children,n=this._data.components;try{t&&delete this._data.children,n&&delete this._data.components,e=new a(JSON.parse(JSON.stringify(this._data)))}finally{t&&(this._data.children=t),n&&(this._data.components=n)}return e},a.prototype.isEqualTo=function(e,t,n){return this._isEqual(this._data,e._data,r.merge({children:!0,components:!0},t),n)},a.prototype._isEqual=function(e,t,n,o){var i,a,s,c,l,p,d;if(!r.objectsEqual(e,t,n))return!1;if(a=e.components,s=t.components,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(i=0;i<c;i++){for(l=a[i],p=null,d=0;d<c;d++)if(l.id===s[d].id){p=s[d];break}if(!p)return!1;if(!r.objectsEqual(l,p,o))return!1}if(a=e.children,s=t.children,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(i=0;i<c;i++)if(!this._isEqual(a[i],s[i],n,o))return!1;return!0},a.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},a.prototype._verify=function(e){return"string"!=typeof e.id?new i(i.INVALID_DATA,"Node is missing an id of type string"):null},a.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},e.exports=a},function(e,t,n){(function(t){var n,o=void 0!==t&&(t.crypto||t.msCrypto);if(o&&o.getRandomValues){var i=new Uint8Array(16);n=function(){return o.getRandomValues(i),i}}if(!n){var r=new Array(16);n=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}e.exports=n}).call(this,n(41))},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o;o=function(){return this}();try{o=o||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":n(window))&&(o=window)}e.exports=o},function(e,t){for(var n=[],o=0;o<256;++o)n[o]=(o+256).toString(16).substr(1);e.exports=function(e,t){var o=t||0,i=n;return i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]}},function(e,t,n){var o=n(27),i=n(3),r=n(4);function a(e,t,n){this._owner=t,e?e=this._setData(e,n):(e={id:r.generateUuid()},this._core=new o(e,this,n),this._data=e)}Object.defineProperties(a.prototype,{rootNode:{get:function(){return this._core.rootNode},set:function(e){this._core.rootNode=e}},name:{get:function(){return this._core.rootNode.name},set:function(e){var t=this._core;if(t._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get:function(){return this._core.rootNode.type},set:function(e){var t=this._core;if(t._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get:function(){return this._owner.compositeHref},set:function(){throw new i(i.READ_ONLY,'Property "compositeHref" is read-only.')}},_localStorage:{get:function(){return this._core._localStorage},set:function(e){this._core._localStorage=e}},hasLocalStorage:{get:function(){return this._core.hasLocalStorage},set:function(e){this._core.hasLocalStorage=e}},_isDirty:{get:function(){return this._core._isDirty},set:function(e){this._core._isDirty=e}},isDirty:{get:function(){return this._isDirty},set:function(e){this._core.isDirty=e}},changeCount:{get:function(){return this._core.changeCount},set:function(e){this._core.changeCount=e}}}),a.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},a.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},a.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},a.prototype.addChild=function(e,t,n,o){return this._core.addChild(e,t,n,o)},a.prototype.removeChild=function(e){return this._core.removeChild(e)},a.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},a.prototype.copyChild=function(e,t,n,o,i,r){return this._core.copyChild(e,t,n,o,i,r)},a.prototype.allComponents=function(){return this._core.allComponents()},a.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},a.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},a.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},a.prototype.addComponent=function(e,t,n,o,i,r,a,s,c,l){return this._core.addComponent(e,t,n,o,i,r,a,s,c,l)},a.prototype.addComponentWithUploadResults=function(e,t,n,o,i){return this._core.addComponentWithUploadResults(e,t,n,o,i)},a.prototype.updateComponent=function(e,t,n,o){return this._core.updateComponent(e,t,n,o)},a.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},a.prototype.removeComponent=function(e){return this._core.removeComponent(e)},a.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},a.prototype.copyComponent=function(e,t,n,o,i){return this._core.copyComponent(e,t,n,o,i)},a.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},a.prototype.parse=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new i(i.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},a.prototype.copy=function(){return new a(JSON.parse(JSON.stringify(this._data)),this._owner)},a.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new i(i.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},a.prototype._verify=function(e){return"string"!=typeof e.id?new i(i.INVALID_DATA,"Element is missing an id of type string"):"string"!=typeof e.name?new i(i.INVALID_DATA,"Element is missing a name of type string"):"string"!=typeof e.type?new i(i.INVALID_DATA,"Element is missing a type of type string"):null},a.prototype._setData=function(e,t){var n=this._verify(e);if(null===n)return this._core=new o(e,this,t),this._data=e,this;throw n},a.prototype._local=function(){return this._core._local()},a.prototype._setDirty=function(e){this._core._setDirty(e)},a.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},a.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=a},function(e,t,n){var o=n(3),i=n(4),r=n(7);function a(e,t){if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e,this._preserveFileExtensions=t,this._inMemoryBranchesAndElements=[],this._inflightComponents=[]}Object.defineProperties(a.prototype,{compositePath:{get:function(){return this._compositePath},set:function(e){if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e}}}),a.prototype.currentManifestPath=function(){return this._compositePath+"/manifest"},a.prototype.currentBaseManifestPath=function(){return this._compositePath+"/manifest.base"},a.prototype.pulledManifestPath=function(){return this._compositePath+"/pull.manifest"},a.prototype.pushedManifestPath=function(){return this._compositePath+"/push.manifest"},a.prototype.resolvePulledBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",(function(e){e?(e.code!==o.OUT_OF_SPACE&&(e=new o(o.INVALID_STATE,"Could not write current manifest.",e)),t(e)):r.move(n.pulledManifestPath(),n.currentBaseManifestPath(),!1,(function(e){e?t(new o(o.INVALID_STATE,"Could not move pull manifest.",e)):t()}))}))},a.prototype.acceptPushedBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",(function(e){e?(e.code!==o.OUT_OF_SPACE&&(e=new o(o.INVALID_STATE,"Could not write current manifest.",e)),t(new o(o.INVALID_STATE,"Could not write current manifest.",e))):r.move(n.pushedManifestPath(),n.currentBaseManifestPath(),!1,(function(e){e?t(new o(o.INVALID_STATE,"Could not move push manifest.",e)):n._deleteJournal(t)}))}))},a.prototype.discardPulledBranch=function(e){r.deleteFile(this.pulledManifestPath(),e)},a.prototype.discardPushedBranch=function(e){var t=this;r.deleteFile(this.pushedManifestPath(),(function(n){n?e(n):t._deleteJournal(e)}))},a.prototype.discardBaseBranch=function(e){r.deleteFile(this.currentBaseManifestPath(),e)},a.prototype.registerInMemoryBranchOrElement=function(e){if(this._inMemoryBranchesAndElements.indexOf(e)>=0)throw new o(o.INVALID_STATE,"Branch or element is already registered.");this._inMemoryBranchesAndElements.push(e)},a.prototype.unregisterInMemoryBranchOrElement=function(e){var t=this._inMemoryBranchesAndElements.indexOf(e);if(t<0)throw new o(o.INVALID_STATE,"Unknown branch or element.");this._inMemoryBranchesAndElements.splice(t,1)},a.prototype._deleteJournal=function(e){r.deleteFile(this.pushJournalPath(),e)};var s=/(\/)|(\.$)/;a.prototype.componentAssetName=function(e,t){var n=t["copyOnWrite#storageIds"],o=n?n[e.id]:null;return o&&s.test(o)&&(o=null),o},a.prototype.componentAssetPath=function(e,t){var n=this.componentAssetName(e,t);return n?this._componentPathFromName(n):null},a.prototype.ingestComponentAsset=function(e,t,n,i,a){var s=this,c=this._newFileNameForComponent(e),l=this._componentPathFromName(c);this._inflightComponents.push(c);var p=function(t){if(!t)try{s._setComponentName(e,i,c)}catch(e){t=e}var n=s._inflightComponents.indexOf(c);n<0&&!t&&(t=new o(o.INVALID_STATE,"Could not find inflight component.")),s._inflightComponents.splice(n,1),a(t)};n?r.copyFile(t,l,p):r.move(t,l,!0,p)},a.prototype.removeComponentAsset=function(e,t){var n=t["copyOnWrite#storageIds"];n&&delete n[e.id]},a.prototype.componentIds=function(e){var t=e["copyOnWrite#storageIds"];return t?Object.keys(t):[]},a.prototype.copyLocalStorageData=function(e,t,n,o){var i,r=n.allComponents(),a=r.length,s=t["copyOnWrite#storageIds"];if(s){var c=o["copyOnWrite#storageIds"];for(c||(c=o["copyOnWrite#storageIds"]={}),i=0;i<a;i++){var l=r[i],p=l.id,d=e.getComponentWithId(p);if(d&&d.etag===l.etag){var h=s[p];h&&(c[p]=h)}}}},a.prototype.removeUnusedLocalFiles=function(e,t){var n,i,a,s,c,l=this,p=function(e){l._deleteComponentAsset(e,(function(e){e&&!n&&(n=e),0==--c&&t(n)}))},d=function(){try{var e,n=s.length,o=[];for(e=0;e<n;e++){var r=s[e].name,d=s[e].info;!i[r]&&d.mtime.getTime()<a&&l._inflightComponents.indexOf(r)<0&&o.push(r)}if((c=n=o.length)>0)for(e=0;e<n;e++)p(o[e])}catch(e){return void t(e)}0===c&&t()};this._gatherComponentAssetNames([this.currentManifestPath(),this.currentBaseManifestPath(),this.pulledManifestPath(),this.pushedManifestPath()],e,(function(e,r,c,l){if(n)t(n);else{if(!e)try{if(r<1||!l)throw new o(o.INVALID_STATE,r<1?"No manifest found.":"Invalid time stamp");i=c,a=l}catch(t){e=t}e&&(n=e),s&&(n?t(n):d())}})),r.directoryListing(this._compositePath+"/components",(function(e,o){if(n)t(n);else{if(!e)try{s=o}catch(t){e=t}e&&(n=e),i&&(n?t(n):d())}}))},a.prototype.tempPathForComponent=function(){return this._compositePath+"/tmp/"+i.generateUuid()},a.prototype.deleteTempFiles=function(e){r.deleteDirectory(this._compositePath+"/tmp",e)},a.prototype.clientDataPath=function(){return this._compositePath+"/clientdata"},a.prototype.pushJournalPath=function(){return this._compositePath+"/push.journal"},a.prototype._copyComponentMapping=function(e,t,n,o){var i=t["copyOnWrite#storageIds"];if(i){var r=o["copyOnWrite#storageIds"];r||(r=o["copyOnWrite#storageIds"]={});var a=i[e];return a&&(r[n]=a),a}},a.prototype._componentPathFromName=function(e){return this._compositePath+"/components/"+e},a.prototype._newFileNameForComponent=function(e){var t=i.generateUuid();if(this._preserveFileExtensions){var n=e.path?i.filePathComponents(e.path).extension:null;n&&(t=t+"."+n)}return t},a.prototype._setComponentName=function(e,t,n){var o=t["copyOnWrite#storageIds"];o||(o=t["copyOnWrite#storageIds"]={}),o[e.id]=n},a.prototype._gatherComponentAssetNames=function(e,t,n){try{var o,a,s={},c=t||i.timeStamp(!0),l=e.length,p=l,d=0,h=function(e){if(e){e=e["copyOnWrite#storageIds"];var t,n=Object.keys(e);for(t=0;t<n.length;t++){var o=e[n[t]];s[o]=!0}}},u=function(e){r.exists(e,(function(t){t?(d++,r.info(e,(function(t,o){if(!t)try{var i=o.mtime.getTime();i<c&&(c=i),r.readFile(e,"utf8",(function(e,t){if(p--,!e)try{t=JSON.parse(t),h(t.local)}catch(t){e=t}e&&!a&&(a=e),0===p&&n(a,d,s,c)}))}catch(e){t=e}t&&(p--,a||(a=t),0===p&&n(a))}))):0==--p&&n(a,d,s,c)}))};for(o=0;o<l;o++)u(e[o]);for(l=this._inMemoryBranchesAndElements.length,o=0;o<l;o++)h(this._inMemoryBranchesAndElements[o]._local())}catch(e){n(e)}},a.prototype._deleteComponentAsset=function(e,t){r.deleteFile(this._componentPathFromName(e),t)},e.exports=a},function(e,t,n){var o=n(21),i=n(3),r=n(4),a=r.appendPathElements;function s(e,t){if(o.call(this,e,t),!this._endPoint)throw new i(i.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}s.prototype=Object.create(o.prototype),s.prototype.name="AdobeCommunitySession",s.FileContent=o.FileContent,s.StreamProvider=o.StreamProvider,s.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return a(t,"manifest")},s.prototype.getComponent=function(e,t,n){var o=this.getComponentHref(e,e.version);return this.getAsset(o,void 0,t,n)},s.prototype.getRenditionOfComponent=function(e,t,n,o,i,r){var a=this.getComponentRenditionHref(e,e.version,t,n,o);return this.getAsset(a,{accept:t},i,r)},s.prototype.getCompositeManifest=function(e,t,n){var o=e.href;return o&&(o=this._resolveUrl(o)),o?(o=a(o,"manifest"),this.getAssetAsType(o,"text",t,n)):n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o))},s.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,(function(e,n){if(e)return t(e);t(e,n)}))},s.prototype.getComponentHref=function(e,t){var n,o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return o._core&&(n=o._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(o.compositeHref,e,t)},s.prototype.getComponentRenditionHref=function(e,t,n,o,r){var a=e._owner;if(!a||!a.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(a._core&&a._core._getSourceHrefOfComponent(e))throw new i(i.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(a.compositeHref,e,t,n,o,r)},s.prototype._constructComponentHref=function(e,t,n){var o=t.absolutePath.slice(1),i=a(this._resolveUrl(e),o);return i&&void 0!==n&&(this._hrefUsesContentApis(e)?i+="/version/"+n:i+="?version="+n),i};var c=/^\/?content\/2\/[^/]+\/[^/]+/,l=/^\/?api\/v2\/[^/]+\/assets\/[^/]+/,p={"image/jpeg":"jpg","image/png":"png"};s.prototype._constructComponentRenditionHref=function(e,t,n,o,a,s){var d,h,u=t.absolutePath.slice(1),_=r.parseURI(e).path;if("/content/2/"===_.slice(0,"/content/2/".length)){var f=p[o];if(!f)throw new i(i.INVALID_PARAMS,"Unsupported rendition media type: "+o);if(!((d=c.exec(_))&&d.length>0))throw new i(i.INVALID_PARAMS,"Failed to parse composite href: "+e);h=this._resolveUrl(r.appendPathElements(d[0],"rendition",u,"version",n,"format",f,"dimension",a,"size",String(s)))}else{if(!((d=l.exec(_))&&d.length>0))throw new i(i.INVALID_PARAMS,"Failed to parse composite href: "+e);h=this._resolveUrl(r.appendPathElements(d[0],"rendition",a,String(s),u)+"?version="+n)}return h},s.prototype._hrefUsesContentApis=function(e){return"/content/2/"===r.parseURI(e).path.slice(0,"/content/2/".length)},e.exports=s},function(e,t,n){var o=n(1),i=n(2),r=n(11),a=n(10),s=n(9);function c(e,t){this._library=e,this._listenerManager=new s(["change"]),this._setDCXNode(t)}c.prototype._setDCXNode=function(e){this._dcxNode=e,this._deletedLocally=!1},c.prototype._getEventData=function(e){return this._dcxNode.getValue(o[e+"_DATA_KEY"])||{}},c.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.deviceId,delete t.userId,t},c.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&o.DEVICE_ID)return t===o.DEVICE_ID},c.prototype._markDeletedLocally=function(e){this._deletedLocally=e,e&&this._listenerManager.removeAll()},c.prototype._commit=function(){this._updateModifiedTime(),this._library._commit(),this._listenerManager.notify("change"),r.reportUpdateGroup(this)},c.prototype._commitMetadata=function(){this._library._commit(),this._listenerManager.notify("change")},c.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.CREATED_KEY,e),this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED")},c.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("MODIFIED")},c.prototype._toJSON=function(){return{id:this.id,classifierName:this.classifierName,name:this.name,order:this.order}},c.prototype.toString=function(){return JSON.stringify(this._toJSON())},c.prototype.jasmineToString=function(){return this.toString()},c.prototype._setEventData=function(e){if(o.DEVICE_ID){var t={userId:this.library.collection.userId,deviceId:o.DEVICE_ID};o.DEVICE_DESCRIPTION&&(t.device=o.DEVICE_DESCRIPTION),o.APP_DESCRIPTION&&(t.app=o.APP_DESCRIPTION),this._dcxNode.setValue(o[e+"_DATA_KEY"],t)}else this._clearEventData(e)},c.prototype._clearEventData=function(e){this._dcxNode.getValue(o[e+"_DATA_KEY"])&&this._dcxNode.removeValue(o[e+"_DATA_KEY"])},Object.defineProperties(c.prototype,{id:{get:function(){return this._dcxNode.id},set:function(){throw new i(i.READ_ONLY,"Cannot change the id of an existing group",this._library.id)}},library:{get:function(){return this._library},set:function(){throw new i(i.READ_ONLY,"library is a read-only property",this._library.id)}},name:{get:function(){return this._dcxNode.name},set:function(e){if(a.checkDeletedState(this),!this.isWritable)throw new i(i.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit()}},classifierName:{get:function(){return this._dcxNode.getValue(o.CLASSIFIER_KEY)},set:function(){throw new i(i.READ_ONLY,"classifierName is a read-only property",this._library.id)}},order:{get:function(){return this._dcxNode.getValue(o.ORDER_KEY)},set:function(e){if(!this.isWritable)throw new i(i.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e)throw new i(i.INVALID_PARAMETER,"order must be a string",this._library.id);this._dcxNode.setValue(o.ORDER_KEY,e),this._commitMetadata(),r.reportUpdateGroupMetadata(this,e)}},isWritable:{get:function(){return this._library.isWritable},set:function(){throw new i(i.READ_ONLY,"isWritable is a read-only property",this.id)}},created:{get:function(){return this._dcxNode.getValue(o.CREATED_KEY)},set:function(){throw new i(i.READ_ONLY,"Cannot change the created timestamp of a group directly",this._library.id)}},createdBy:{get:function(){return this._getEventData("CREATED").userId},set:function(){throw new i(i.READ_ONLY,"Cannot change the createdBy property of a group directly",this._library.id)}},createdContext:{get:function(){return this._getEventContext("CREATED")},set:function(){throw new i(i.READ_ONLY,"Cannot change the createdContext property of a group directly",this._library.id)}},wasCreatedLocally:{get:function(){return this._isLocalEvent("CREATED")},set:function(){throw new i(i.READ_ONLY,"Cannot change the wasCreatedLocally property of a group directly",this._library.id)}},modified:{get:function(){return this._dcxNode.getValue(o.MODIFIED_KEY)},set:function(){throw new i(i.READ_ONLY,"Cannot change the modified timestamp of a group directly",this._library.id)}},modifiedBy:{get:function(){return this._getEventData("MODIFIED").userId},set:function(){throw new i(i.READ_ONLY,"Cannot change the modifiedBy property of a group directly",this._library.id)}},modifiedContext:{get:function(){return this._getEventContext("MODIFIED")},set:function(){throw new i(i.READ_ONLY,"Cannot change the modifiedContext property of a group directly",this._library.id)}},wasModifiedLocally:{get:function(){return this._isLocalEvent("MODIFIED")},set:function(){throw new i(i.READ_ONLY,"Cannot change the wasModifiedLocally property of a group directly",this._library.id)}},isDeletedLocally:{get:function(){return this._deletedLocally},set:function(){throw new i(i.READ_ONLY,"isDeletedLocally is a read-only property",this._library.id)}}}),c.prototype.addChangeListener=function(e){a.checkDeletedState(this),this._listenerManager.add("change",e)},c.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},Object.freeze(c),Object.seal(c.prototype),e.exports=c},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Moje knihovna\nLIBS_RECOVERED_LIBRARY={{name}} (obnoveno)\nLIBS_TOOLKIT_NAME_DEFAULT=Vaše sada nástrojů\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Vaše knihovna aplikace Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Mit bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (Gendannet)\nLIBS_TOOLKIT_NAME_DEFAULT=Din værktøjspakke\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Dit Photoshop-bibliotek"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Meine Bibliothek\nLIBS_RECOVERED_LIBRARY={{name}} (Wiederhergestellt)\nLIBS_TOOLKIT_NAME_DEFAULT=Ihr Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ihre Photoshop-Bibliothek"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=My Library\nLIBS_RECOVERED_LIBRARY={{name}} (Recovered)\nLIBS_TOOLKIT_NAME_DEFAULT=Your Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Your Photoshop Library"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Mi biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Su kit de herramientas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Su biblioteca de Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Mi biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Su kit de herramientas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Su biblioteca de Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Oma kirjasto\nLIBS_RECOVERED_LIBRARY={{name}} (palautettu)\nLIBS_TOOLKIT_NAME_DEFAULT=Oma työkalusarja\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Oma Photoshop-kirjasto"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ma bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ma bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ma bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Saját könyvtár\nLIBS_RECOVERED_LIBRARY={{name}} (helyreállított)\nLIBS_TOOLKIT_NAME_DEFAULT=Az Ön eszköztára\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Az Ön Photoshop könyvtára"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Libreria personale\nLIBS_RECOVERED_LIBRARY={{name}} (recuperato)\nLIBS_TOOLKIT_NAME_DEFAULT=Il vostro toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=La vostra Libreria Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=マイライブラリ\nLIBS_RECOVERED_LIBRARY={{name}} (回復済み)\nLIBS_TOOLKIT_NAME_DEFAULT=自分の Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop ライブラリ"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=내 라이브러리\nLIBS_RECOVERED_LIBRARY={{name}}(복구됨)\nLIBS_TOOLKIT_NAME_DEFAULT=툴킷\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop Library"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Biblioteket mitt\nLIBS_RECOVERED_LIBRARY={{name}} (gjenopprettet)\nLIBS_TOOLKIT_NAME_DEFAULT=Ditt verktøysett\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ditt Photoshop-bibliotek"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Mijn bibliotheek\nLIBS_RECOVERED_LIBRARY={{name}} (hersteld)\nLIBS_TOOLKIT_NAME_DEFAULT=Uw toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Uw Photoshop-bibliotheek"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Moja biblioteka\nLIBS_RECOVERED_LIBRARY={{name}} (Odzyskane)\nLIBS_TOOLKIT_NAME_DEFAULT=Twój zestaw narzędzi\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Biblioteka programu Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Minha biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (Recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Seu kit de ferramentas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Sua biblioteca do Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Моя библиотека\nLIBS_RECOVERED_LIBRARY={{name}} (восстановлено)\nLIBS_TOOLKIT_NAME_DEFAULT=Инструменты\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Библиотека Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Mitt bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (återskapet)\nLIBS_TOOLKIT_NAME_DEFAULT=Ditt Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ditt Photoshop-bibliotek"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Kitaplığım\nLIBS_RECOVERED_LIBRARY={{ad}} ((Kurtarıldı))\nLIBS_TOOLKIT_NAME_DEFAULT=Araç Setiniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop Kitaplığınız"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Моя бібліотека\nLIBS_RECOVERED_LIBRARY={{name}} (відновлено)\nLIBS_TOOLKIT_NAME_DEFAULT=Мій інструментарій\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Моя бібліотека Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=我的库\nLIBS_RECOVERED_LIBRARY={{name}} （已恢复）\nLIBS_TOOLKIT_NAME_DEFAULT=您的工具箱\nLIBS_TOOLKIT_NAME_PHOTOSHOP=您的 Photoshop 库"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=我的資料庫\nLIBS_RECOVERED_LIBRARY={{name}} (已復原)\nLIBS_TOOLKIT_NAME_DEFAULT=您的工具組。\nLIBS_TOOLKIT_NAME_PHOTOSHOP=您的 Photoshop 資料庫"},function(e,t,n){var o=n(0),i=n(1),r=n(72),a=n(11),s=n(2),c=n(73),l=n(14),p=n(10),d=n(16),h=n(6),u=n(9);function _(e,t){this._library=e,this._renditionFetchLock=new l,this._listenerManager=new u(["change"]),this._transactionCount=0,this._setDCXNode(t,!0)}_.prototype._setDCXNode=function(e,t){var n=this,o={};this._representations&&this._representations.forEach((function(e){o[e.id]=e})),this._dcxNode=e,this._representations=[],this._deletedLocally=!1,this._library._dcxBranch.getChildrenOf(e).forEach((function(e){var t=o[e.id];t?(t._setDCXNode(e),delete o[e.id]):t=new r(n,e),n._representations.push(t)})),this._library._dcxBranch.getComponentsOf(e).forEach((function(e){var t=o[e.id];t?(t._setDCXComponent(e),delete o[e.id]):t=new r(n,void 0,e),n._representations.push(t)})),p.sortRepresentations(this._representations),t||this.library._renditionCache.clearCache(this),this._displayName=void 0},_.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._representations.forEach((function(t){t._markDeletedLocally(e)})),e&&this._listenerManager.removeAll()},_.prototype._removeAllListeners=function(){this._listenerManager.removeAll()},_.prototype._toJSON=function(){var e={id:this.id,name:this.name,type:this.type,description:this.description,representations:[]};return this._representations.forEach((function(t){e.representations.push(t._toJSON())})),e.representations.sort((function(e,t){return e.type>t.type?1:e.type<t.type?-1:0})),e},_.prototype._addRepresentation=function(e,t){void 0!==t?this._representations.splice(t,0,e):this._representations.push(e)},_.prototype._removeRepresentation=function(e){var t=this._representations.indexOf(e);-1!==t&&this._representations.splice(t,1)},_.prototype._validateRelationship=function(e){var t=this;if(-1===i.VALID_RELATIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unsupported relationship",this._library.id);this._representations.length>0&&"primary"===e&&this._representations.forEach((function(n){if(n!==e&&"primary"===n.relationship)throw new s(s.INVALID_PARAMETER,"Cannot have more than one primary representation",t._library.id)}))},_.prototype._doCreateRepresentation=function(e,t,n){var o=this._library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);if(o.type=e,o.setValue(i.RELATIONSHIP_KEY,t),void 0===n){var a=this.representations[this.representations.length-1],s=Math.max(this.representations.length,a?a._getOrder()+1:0);o.setValue(i.REPRESENTATION_ORDER_KEY,s)}else o.setValue(i.REPRESENTATION_ORDER_KEY,n),this._representations.forEach((function(e,t){if(t>=n){var o=e._getDCXElement(),r=o.getValue(i.REPRESENTATION_ORDER_KEY);void 0!==r&&o.setValue(i.REPRESENTATION_ORDER_KEY,r+1)}}));var c=new r(this,o);return this._addRepresentation(c,n),c},_.prototype._getEventData=function(e,t){var n=!t&&{},o=this._dcxNode.getValue(i[e+"_DATA_KEY"])||n;if("CREATED"!==e&&"DESCRIPTION"!==e){var r=this._dcxNode.getValue(i[e+"_KEY"]);r&&r===o.time||(o=n)}return o},_.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&i.DEVICE_ID)return t===i.DEVICE_ID},_.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.time,delete t.deviceId,delete t.userId,t},_.prototype._clearEventData=function(e){this._dcxNode.getValue(i[e+"_DATA_KEY"])&&this._dcxNode.removeValue(i[e+"_DATA_KEY"])},_.prototype._setEventData=function(e,t){if(i.DEVICE_ID){var n={userId:this.library.collection.userId,deviceId:i.DEVICE_ID};i.DEVICE_DESCRIPTION&&(n.device=i.DEVICE_DESCRIPTION),i.APP_DESCRIPTION&&(n.app=i.APP_DESCRIPTION),t&&(n.time=t),this._dcxNode.setValue(i[e+"_DATA_KEY"],n)}else this._clearEventData(e)},_.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(i.MODIFIED_KEY,e),this._setEventData("MODIFIED",e)},_.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(i.CREATED_KEY,e),this._dcxNode.setValue(i.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED",e)},_.prototype._updateTimestampOnRemove=function(e){var t=e||(new Date).valueOf();this._dcxNode.setValue(i.REMOVED_KEY,t),this._setEventData("REMOVED",t)},_.prototype._updateTimestampOnRestore=function(){this._dcxNode.removeValue(i.REMOVED_KEY),this._clearEventData("REMOVED")},_.prototype._ensureRemovedDataValid=function(e){this.removed&&!this._getEventData("REMOVED",!0)?e?this._setEventData("REMOVED",this.removed):this._clearEventData("REMOVED"):this.removed||this._clearEventData("REMOVED")},_.prototype._ensureModifiedDataValid=function(e){this._getEventData("MODIFIED",!0)||(e?this._setEventData("MODIFIED",this.modified):this._clearEventData("MODIFIED")),this._ensureRemovedDataValid(e)},_.prototype._ensureCreatedDataValid=function(e){e&&!this._getEventData("CREATED",!0)&&this._setEventData("CREATED"),this._ensureModifiedDataValid(e)},_.prototype._commit=function(e){this._displayName=void 0,this._updateModifiedTime(),this._forEachRepresentation((function(e){return e._clearCachedExternalLink(!0)})),this._listenerManager.notify("change"),this._library._commit(),a.reportUpdateElement(this,e)},_.prototype._commitMetadata=function(){this._listenerManager.notify("change"),this._library._commit()},_.prototype._wrapOperation=function(e,t){return this._library._wrapOperation((function(){var n=this._library._wrapOperation(e,t);return this._updateModifiedTime(),this._listenerManager.notify("change"),n}),this)},_.prototype._getMissingLocalComponents=function(){var e=[];return this._representations.forEach((function(t){e=e.concat(t._getMissingLocalComponents())})),e},_.prototype._forEachRepresentation=function(e){var t=this;(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.representations).forEach((function(n){e(n),t._forEachRepresentation(e,n.children)}))},_.prototype._shouldGCLocalData=function(){var e=(new Date).valueOf();return this.removed&&e-this.removed>=i.REMOVED_ELEMENTS_CACHE_TIMEOUT},_.prototype.jasmineToString=function(){return this.toString()},_.prototype._stripObsoleteGroupsData=function(e){var t=this._dcxNode.getValue(i.GROUPS_KEY);if(t){var n=(e=e||i.DEFAULT_GROUP_CLASSIFIER)+"#",o=!1;Object.keys(t).forEach((function(e){if(e.startsWith(n)){var i=e.substring(n.length);this.library.getGroupById(i)||(delete t[e],o=!0)}}),this),o&&this._dcxNode.setValue(i.GROUPS_KEY,t)}},Object.defineProperties(_.prototype,{id:{get:function(){return this._dcxNode.id},set:function(){throw new s(s.READ_ONLY,"Cannot change the id of an existing element",this._library.id)}},library:{get:function(){return this._library},set:function(){throw new s(s.READ_ONLY,"library is a read-only property",this._library.id)}},isWritable:{get:function(){return this._library.isWritable},set:function(){throw new s(s.READ_ONLY,"isWritable is a read-only property",this.id)}},name:{get:function(){return this._dcxNode.name||""},set:function(e){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit(!0)}},displayName:{get:function(){return void 0===this._displayName&&(this._displayName=o.getDisplayName(this)||""),this._displayName},set:function(){throw new s(s.READ_ONLY,"displayName is a read-only property",this._library.id)}},type:{get:function(){return this._dcxNode.type},set:function(){throw new s(s.READ_ONLY,"Cannot change the type of an existing element",this._library.id)}},tags:{get:function(){return this._dcxNode.getValue("tags")||[]},set:function(e){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e||e.constructor!==Array)throw new s(s.INVALID_PARAMETER,"tags must be an array",this._library.id);if(!e.every((function(e){return"string"==typeof e})))throw new s(s.INVALID_PARAMETER,"tags must be an array of strings",this._library.id);0===e.length?this._dcxNode.removeValue("tags"):this._dcxNode.setValue("tags",e),this._commit(!0)}},description:{get:function(){return this._dcxNode.getValue(i.DESCRIPTION_KEY)||""},set:function(e){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.setValue(i.DESCRIPTION_KEY,e);var t=(new Date).valueOf();this._setEventData("DESCRIPTION",t),this._commitMetadata(),a.reportSetDescription(this)}},descriptionModified:{get:function(){return this._getEventData("DESCRIPTION").time||0},set:function(){throw new s(s.READ_ONLY,"Cannot change the descriptionModified timestamp of an element directly",this._library.id)}},descriptionModifiedBy:{get:function(){return this._getEventData("DESCRIPTION").userId},set:function(){throw new s(s.READ_ONLY,"Cannot change the descriptionModifiedBy property of an element directly",this._library.id)}},descriptionModifiedContext:{get:function(){return this._getEventContext("DESCRIPTION")},set:function(){throw new s(s.READ_ONLY,"Cannot change the descriptionModifiedContext property of an element directly",this._library.id)}},wasDescriptionModifiedLocally:{get:function(){return this._isLocalEvent("DESCRIPTION")},set:function(){throw new s(s.READ_ONLY,"Cannot change the wasDescriptionModifiedLocally property of an element directly",this._library.id)}},modified:{get:function(){return this._dcxNode.getValue(i.MODIFIED_KEY)},set:function(){throw new s(s.READ_ONLY,"Cannot change the modified timestamp of an element directly",this._library.id)}},modifiedBy:{get:function(){return this._getEventData("MODIFIED").userId},set:function(){throw new s(s.READ_ONLY,"Cannot change the modifiedBy property of an element directly",this._library.id)}},modifiedContext:{get:function(){return this._getEventContext("MODIFIED")},set:function(){throw new s(s.READ_ONLY,"Cannot change the modifiedContext property of an element directly",this._library.id)}},wasModifiedLocally:{get:function(){return this._isLocalEvent("MODIFIED")},set:function(){throw new s(s.READ_ONLY,"Cannot change the wasModifiedLocally property of an element directly",this._library.id)}},created:{get:function(){return this._dcxNode.getValue(i.CREATED_KEY)},set:function(){throw new s(s.READ_ONLY,"Cannot change the created timestamp of an element directly",this._library.id)}},createdBy:{get:function(){return this._getEventData("CREATED").userId},set:function(){throw new s(s.READ_ONLY,"Cannot change the createdBy property of an element directly",this._library.id)}},createdContext:{get:function(){return this._getEventContext("CREATED")},set:function(){throw new s(s.READ_ONLY,"Cannot change the createdContext property of an element directly",this._library.id)}},wasCreatedLocally:{get:function(){return this._isLocalEvent("CREATED")},set:function(){throw new s(s.READ_ONLY,"Cannot change the wasCreatedLocally property of an element directly",this._library.id)}},removed:{get:function(){return this._dcxNode.getValue(i.REMOVED_KEY)},set:function(){throw new s(s.READ_ONLY,"Cannot change the removed timestamp of an element directly",this._library.id)}},removedBy:{get:function(){return this._getEventData("REMOVED").userId},set:function(){throw new s(s.READ_ONLY,"Cannot change the removedBy property of an element directly",this._library.id)}},removedContext:{get:function(){return this._getEventContext("REMOVED")},set:function(){throw new s(s.READ_ONLY,"Cannot change the removedContext property of an element directly",this._library.id)}},wasRemovedLocally:{get:function(){return this._isLocalEvent("REMOVED")},set:function(){throw new s(s.READ_ONLY,"Cannot change the wasRemovedLocally property of an element directly",this._library.id)}},representations:{get:function(){return this._representations},set:function(){throw new s(s.READ_ONLY,"Cannot modify representation list directly",this._library.id)}},isDeletedLocally:{get:function(){return this._deletedLocally},set:function(){throw new s(s.READ_ONLY,"isDeletedLocally is a read-only property",this._library.id)}},sourceRef:{get:function(){return this._dcxNode.getValue(i.SOURCE_REF_KEY)},set:function(e){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e||!e.startsWith("urn:"))throw new s(s.INVALID_PARAMETER,"sourceRef must be a string and a valid URN",this._library.id);this._dcxNode.setValue(i.SOURCE_REF_KEY,e),this._commit(!0)}}}),_.prototype.toString=function(){return JSON.stringify(this._toJSON())},_.prototype.addChangeListener=function(e){p.checkDeletedState(this),this._listenerManager.add("change",e)},_.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},_.prototype.beginOperation=function(){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount++,this._library._beginOperation()},_.prototype.endOperation=function(e){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount>0&&(this._transactionCount--,this._library._endOperation()),e&&this._library._waitForCommit(e,!0)},_.prototype.createRepresentation=function(e,t,n,o){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation((function(){if(e===i.LINK_REPRESENTATION_TYPE)throw new s(s.INVALID_PARAMETER,"Cannot create external link representation directly - use setContentFromURL instead",this._library.id);if(void 0!==n&&(n<0||n>this._representations.length))throw new s(s.INVALID_PARAMETER,"Invalid index",this._library.id);this._validateRelationship(t);var r=this._doCreateRepresentation(e,t,n);return o||this.library._renditionCache.clearCache(this,!0),r}),this)},_.prototype.removeRepresentation=function(e){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation((function(){this._removeRepresentation(e),e._dcxComponent?this._library._dcxBranch.removeComponent(e._dcxComponent):this._library._dcxBranch.removeChild(e._dcxNode),this.library._renditionCache.clearCache(this,!0),e._markDeletedLocally(!0)}),this)},_.prototype.removeAllRepresentations=function(){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation((function(){for(;this._representations[0];)this.removeRepresentation(this._representations[0])}),this)},_.prototype.getPrimaryRepresentation=function(){var e;return this._representations.forEach((function(t){e||"primary"!==t.relationship||(e=t)})),e},_.prototype.getValue=function(e,t){if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var n=p.getDCXKey(e,t);return this._dcxNode.getValue(n)},_.prototype.getValues=function(){return p.getCustomDCXData(this._dcxNode)},_.prototype.setValue=function(e,t,n){if(p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var o,r=p.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new s(s.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._library.id)}this._dcxNode.setValue(r,o),this._commit()},_.prototype.removeValue=function(e,t){if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this.id);var n=p.getDCXKey(e,t);this._dcxNode.removeValue(n)},_.prototype._getRenditionCandidate=function(e){var t,n,o,i,r,a,s,c=0;if("vector"===e&&this.supportsVectorThumbnail())return this.getPrimaryRepresentation();for(n=0;n<this._representations.length&&(o=this._representations[n],i=Math.max(o.width||0,o.height||0),r=o.isFullSize?Number.POSITIVE_INFINITY:i,a="primary"===o.relationship,s="rendition"===o.relationship,(!t||o.isPreferredThumbnail&&!t.isPreferredThumbnail||a&&"primary"!==t.relationship||s&&"primary"!==t.relationship&&"rendition"!==t.relationship||s&&"rendition"===t.relationship&&r>c)&&d.canComputeRendition(o)&&(t=o,c=r),!s||"image/png"!==o.type||!e||i!==e);n++);return t},_.prototype._setRenditionCache=function(e,t,n,i,r){var a=this;this.library._renditionCache.setCache(this,e,t,n).then((function(e){i&&o.storageInterface.notifyDownloadRendition(a),r(null,e)}),r)},_.prototype.getThumbnailURL=function(e,t){var n=this;p.checkDeletedState(this,t)||this._library._waitForCommit((function(){if(!p.checkDeletedState(n,t)){var o=n._getRenditionCandidate(e);o?n._library._collection._syncManager.getSharedCloudRenditionUrl(o,e,t):t(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}}))},_.prototype.getAuthenticatedThumbnailURL=function(e,t){this.getThumbnailURL(e,function(e,n){e?t(e):this._library._collection._syncManager.appendAccessTokenToURL(n,t)}.bind(this))},_.prototype.getThumbnailPath=function(e,t){var n=this;o.hasFileSystem()?p.checkDeletedState(this,t)||this._library._waitForCommit((function(){if(!p.checkDeletedState(n,t))if(i.SHARED_LOCAL_STORAGE)o.storageInterface.getRenditionPath(n,e,t);else{var r=function(e,o){n._renditionFetchLock.release(),t(e,o)};n._renditionFetchLock.obtain((function(){if(!p.checkDeletedState(n,r)){var t=this.library._renditionCache.getCache(this,e);if(t)r(null,t);else{var i=this._getRenditionCandidate(e);if(i){if("rendition"===i.relationship&&"image/png"===i.type&&e&&Math.max(i.width||0,i.height||0)===e)return void i.getContentPath(r);var a=this._library._collection._syncManager,c=this.modified,l=function(t,o){n.modified>c?r(new s(s.STALE_THUMBNAIL,"element changed before the rendition was received",n._library.id,t)):p.checkDeletedState(n,r)||(t?r(new s(s.THUMBNAIL_NOT_AVAILABLE,"error generating thumbnail",n._library.id,t)):n._setRenditionCache(e,o,!0,!0,r))};o.hasRenditionGenerator()&&e&&"vector"!==e?i.getContentPath((function(t,n){if(!t&&n){var r=i.element.library.collection._getTempDir()+o.getPathSeparator()+o.uuid()+".png";o.renditionGenerator(n,r,e,(function(t){t?a.getSharedCloudRendition(i,e,l):l(null,r)}))}else a.getSharedCloudRendition(i,e,l)})):a.getSharedCloudRendition(i,e,l)}else r(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}}}),n)}})):t(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},_.prototype.getCachedThumbnailPath=function(e){return this.library._renditionCache.getCache(this,e)},_.prototype.getThumbnailContent=function(e,t,n){var i=this,r=o.fs;o.hasFileSystem()?p.checkDeletedState(this,n)||p.checkEncoding(t,["utf8","ascii","base64","buffer"],n)&&this.getThumbnailPath(e,(function(e,o){if(!e&&o){if(!p.checkDeletedState(i,n)){var a=function(e,t){e&&(e=h.getCommitError(e,i._library.id,"error reading content from disk")),n(e,t)};"buffer"===t?r.readFile(o,a):r.readFile(o,t,a)}}else n(e)})):n(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},_.prototype.setThumbnailCache=function(e,t,n){"string"==typeof t?o.hasFileSystem()?p.checkDeletedState(this,n)||this._setRenditionCache(e,t,!1,!1,n):n(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id)):n(new s(s.INVALID_PARAMETER,"path must be a string",this._library.id))},_.prototype.supportsVectorThumbnail=function(){var e=this.getPrimaryRepresentation();return!!e&&i.VECTOR_RENDITION_ELEMENT_TYPES.indexOf(e.type)>-1},_.prototype._getActions=function(e){var t=this.getPrimaryRepresentation();if(!t)return[];var n=i.ELEMENT_ACTION_PRODUCT_MAP,o=[];((n.types[this.type]||{})[t.type]||[]).forEach(function(t){!n.products[t]||e&&e!==n.products[t].action||o.push(new c(this,n.products[t]))}.bind(this));var r=o.map((function(e,t){return{i:t,v:e}}));return r.sort((function(e,t){return e.v.isCompatibleVersionInstalled&&!t.v.isCompatibleVersionInstalled?-1:t.v.isCompatibleVersionInstalled&&!e.v.isCompatibleVersionInstalled?1:e.i-t.i})),r.map((function(e){return e.v}))},_.prototype.getActions=function(e){if(!i.SHARED_LOCAL_STORAGE)throw new s(s.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===i.ELEMENT_ACTIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",i.ELEMENT_ACTIONS.join(", "));return this._getActions(e)},_.prototype.getGroups=function(e){e=e||i.DEFAULT_GROUP_CLASSIFIER;var t=this._dcxNode.getValue(i.GROUPS_KEY);if(!t)return[];var n=Object.keys(t);return this.library.getGroups(e).filter((function(e){return void 0!==this.getOrderInGroup(e)}),this).sort((function(e,t){var o=n.indexOf(e.classifierName+"#"+e.id),i=n.indexOf(t.classifierName+"#"+t.id);return o===i?0:o<i?-1:1}))},_.prototype.getOrderInGroup=function(e){if(!e)throw new s(s.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library===this.library){var t=this._dcxNode.getValue(i.GROUPS_KEY)||{},n=e.classifierName+"#"+e.id;return t[n]&&t[n].order}},_.prototype._doSetOrderInGroup=function(e,t,n){var o=this._dcxNode.getValue(i.GROUPS_KEY)||{},r=e.classifierName+"#"+e.id;n&&Object.keys(o).forEach((function(t){t.startsWith(e.classifierName+"#")&&delete o[t]})),void 0===t&&o[r]&&delete o[r],void 0!==t&&(o[r]={order:t}),this._dcxNode.setValue(i.GROUPS_KEY,o)},_.prototype.setOrderInGroup=function(e,t,n){if(n=!1!==n,p.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e)throw new s(s.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library!==this.library)throw new s(s.INVALID_PARAMETER,"Cannot set element order in a group that is in a different library.",this._library.id);if("string"!=typeof t&&void 0!==t)throw new s(s.INVALID_PARAMETER,"order must be a string",this._library.id);this._doSetOrderInGroup(e,t,n),this._commitMetadata(),a.reportSetOrderInGroup(this,e,n)},_.prototype.getReference=function(){return"cloud-asset://"+this._library._collection._syncManager.getElementRefDomain()+this._library._collection._syncManager.getElementRefPath()+"/"+this._library.id+";node="+this.id},_.prototype.getRepresentationById=function(e){var t;return this.representations.forEach((function(n){n.id===e&&(t=n)})),t},Object.freeze(_),Object.seal(_.prototype),e.exports=_},function(e,t,n){var o=n(0),i=n(1),r=n(2),a=n(14),s=n(15),c=n(10),l=n(5),p=n(6),d=n(19),h=n(16);function u(e,t,n){e instanceof u?this._parent=e:this._element=e,t?this._setDCXNode(t):this._setDCXComponent(n),this._lock=new a,this._pendingDownloadCallbacks=[]}u.prototype._setDCXNode=function(e){var t={};this._children&&this._children.forEach((function(e){t[e.id]=e})),this._dcxNode=e,delete this._dcxComponent,this._deletedLocally=!1,this._children=[],this.element.library._dcxBranch.getChildrenOf(e).forEach((function(e){var n=t[e.id];n?(n._setDCXNode(e),delete t[e.id]):n=new u(this,e),this._children.push(n)}),this),this.element.library._dcxBranch.getComponentsOf(e).forEach((function(e){var n=t[e.id];n?(n._setDCXComponent(e),delete t[e.id]):n=new u(this,void 0,e),this._children.push(n)}),this)},u.prototype._setDCXComponent=function(e,t){this._dcxComponent=e,delete this._dcxNode,this._children=[],t||(this._deletedLocally=!1)},u.prototype._markDeletedLocally=function(e){this._deletedLocally=e},u.prototype._toJSON=function(){var e={id:this.id,type:this.type,relationship:this.relationship};return o.hasFileSystem()&&(e._componentPath=this._getComponentPath()),e},u.prototype._getOrder=function(){return this._getDCXElement().getValue(i.REPRESENTATION_ORDER_KEY)||0},u.prototype._setComponentInBrowser=function(e,t,n){var o=this;this.element._library._collection._syncManager.uploadNewComponentForRepresentation(e,t,this,(function(e,t){c.checkDeletedState(o,n)?n(e):e?n(e):(c.copyCustomDCXData(o._dcxNode,t),o.element._library._dcxBranch.removeChild(o._dcxNode),o._setDCXComponent(t,!0),o._commit(),n(null))}))},u.prototype._setComponentFromPath=function(e,t,n,r){var a=this,s=e&&o.getFileNameFromPath(e),p=l.getFileExtension(s),d=this.id+"."+p;l.checkFileSize(e,(function(p){p?r(p):l.getImageDimensions(e,(function(l){o.storageInterface.notifyStartWrite(a.element._library,[],(function(){var o=a.element._library._dcxBranch;o.addComponent(s,a.type,a.relationship,d,e,n,void 0,a.element._dcxNode,a.id,(function(e,n){c.checkDeletedState(a,r)||(e?r(e):(c.copyCustomDCXData(a._dcxNode,n),o.removeChild(a._dcxNode),a._setDCXComponent(n,!0),l&&(n.setValue("width",l.width),n.setValue("height",l.height)),t&&n.setValue(i.SHA_KEY,t),a._commit(),r(null)))}))}))}))}))},u.prototype._setComponent=function(e,t,n,i){var r,a=o.fs,d=this;function h(e){c.checkDeletedState(d,i)||(e?i(p.getCommitError(e,d.element._library.id,"error writing representation contents")):d._setComponentFromPath(r,void 0,!1,i))}var u=this.element.library.collection._getTempDir();l.ensurePathExists(u,(function(l){if(!c.checkDeletedState(d,i))if(l)i(p.getCommitError(l,d.element._library.id,"error creating temp directory"));else{if(!n){var _=s.getExtensions(d.type)[0];n=d.id+"."+_}r=u+o.getPathSeparator()+n,"buffer"===t?a.writeFile(r,e,h):a.writeFile(r,e,t,h)}}))},u.prototype._getCurrentComponentPath=function(){if(this._dcxComponent)return this.element._library._dcxBranch.assetOfComponent(this._dcxComponent)},u.prototype._getComponentPath=function(e,t){var n=this;if(!e)return this._getCurrentComponentPath();if(this.isExternalLink)return this.element.library.collection._externalLinkCache.getExternalLink(this).then((function(t){return e(null,t)}),e);if(this._dcxComponent){var o=this._getCurrentComponentPath();if(o||t)e(null,o);else{var i=this.element._library;i._networkLock.obtain((function(t){t?e(t):c.checkDeletedState(n,e)?i._networkLock.release():(i._setSyncState("downloading"),i._collection._syncManager.downloadRepresentation(n,(function(t){i._networkLock.release(),i._setSyncState(),c.checkDeletedState(n,e)||(t?e(p.getSyncError(t,n.element._library.id)):(i._commit(!0,!0),n._getComponentPath(e,!0)))})))}))}}else{var r=this._getContentFromData();if(r){var a=this.element.library._renditionCache.getCache(this.element,this.id);a?e(null,a):this._generateContentDataFile(r,e)}else e(null)}},u.prototype._getContentFromData=function(){if(o.hasFileSystem()){var e=i.REPRESENTATION_CONTENT_VALUES[this.type];if(e&&e.contentFromData)return this.getValue(e.namespace,e.key)}},u.prototype._setExternalLink=function(e,t){if(this._dcxNode.setValue(i.LINK_TYPE_KEY,this._dcxNode.type),this._dcxNode.type=i.LINK_REPRESENTATION_TYPE,this._dcxNode.setValue(i.LINK_URL_KEY,e),t){t=t.replace(/\\/g,"/");var n=i.DEFAULT_CONTENT_LOCATIONS.find((function(e){return t.startsWith(e)}));if(n){var o=t.substring(n.length);this._dcxNode.setValue(i.LINK_LOCAL_PATH_KEY,o)}return this.element.library.collection._externalLinkCache.ensureExternalLinkCache(e,t)}return Promise.resolve()},u.prototype._clearCachedExternalLink=function(e){var t=this.element.library.collection._externalLinkCache;t&&this.isExternalLink&&(!e||t.getCachedError(this))&&(i.SHARED_LOCAL_STORAGE?o.storageInterface.clearCachedExternalLink(this):h.shouldPrefetchExternalLink(this)?t.getExternalLink(this,!0).catch((function(){})):t.testExternalLink(this,!0).catch((function(){})))},u.prototype._getLinkLocalPaths=function(){var e=this._dcxNode&&this._dcxNode.getValue(i.LINK_LOCAL_PATH_KEY);return e?i.DEFAULT_CONTENT_LOCATIONS.map((function(t){return"".concat(t).concat(e)})):[]},u.prototype._setContentFromPath=function(e,t,n){var r=this,a=function(o){var a=o&&i.SHA_CACHE[o];if(a){r._dcxNode.setValue(i.SHA_KEY,o);var s=function(){r._commit(),n(null)};r._setExternalLink(a,e).then(s,s)}else r._setComponentFromPath(e,o,t,n)};o.storageInterface.computeSHA(e).then(a,(function(){return a()}))},u.prototype._generateContentDataFile=function(e,t){var n=this,i=this.element.library.collection._getTempDir(),r=s.getExtensions(this.type)[0];l.writeJSONData(i,this.id+"."+r,e).then((function(e){n.element.setThumbnailCache(n.id,e,(function(e,i){o.storageInterface.notifyDownloadRendition(n.element),t(e,i)}))}),(function(e){return t(p.getCommitError(e))}))},u.prototype._getDCXElement=function(){return this._dcxComponent||this._dcxNode},u.prototype._commit=function(){this.element._commit()},u.prototype._getMissingLocalComponents=function(){return o.hasFileSystem()&&this._dcxComponent&&!this._getCurrentComponentPath()?[this._dcxComponent]:[]},u.prototype.jasmineToString=function(){return this.toString()},Object.defineProperties(u.prototype,{id:{get:function(){return this._getDCXElement().id},set:function(){throw new r(r.READ_ONLY,"Cannot change the id of an existing representation",this.element._library.id)}},element:{get:function(){return this._parent?this._parent.element:this._element},set:function(){throw new r(r.READ_ONLY,"element is a read-only property",this.element._library.id)}},children:{get:function(){return this._children},set:function(){throw new r(r.READ_ONLY,"children is a read-only property",this.element._library.id)}},isWritable:{get:function(){return this.element.isWritable},set:function(){throw new r(r.READ_ONLY,"isWritable is a read-only property",this.element._library.id)}},type:{get:function(){var e=this._getDCXElement().type;return e===i.LINK_REPRESENTATION_TYPE&&(e=this._getDCXElement().getValue(i.LINK_TYPE_KEY)),e},set:function(){throw new r(r.READ_ONLY,"Cannot change the content type of an existing representation",this.element._library.id)}},relationship:{get:function(){return this._dcxComponent?this._dcxComponent.relationship:this._dcxNode.getValue(i.RELATIONSHIP_KEY)||this._dcxNode.getValue("relationship")},set:function(e){if(this._parent)throw new r(r.NOT_ALLOWED,"you cannot set relationship on child representations",this.element._library.id);this.element._validateRelationship(e,this),this._dcxComponent?this._dcxComponent.relationship=e:this._dcxNode.setValue(i.RELATIONSHIP_KEY,e)}},width:{get:function(){return this._dcxComponent?this._dcxComponent.getValue("width"):this._dcxNode.getValue(i.WIDTH_KEY)},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set width on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid width",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("width",e):this._dcxNode.setValue(i.WIDTH_KEY,e),this._commit()}},height:{get:function(){return this._dcxComponent?this._dcxComponent.getValue("height"):this._dcxNode.getValue(i.HEIGHT_KEY)},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set height on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid height",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("height",e):this._dcxNode.setValue(i.HEIGHT_KEY,e),this._commit()}},isFullSize:{get:function(){return this._getDCXElement().getValue(i.IS_FULL_SIZE_KEY)},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set isFullSize on a representation without contents",this.element._library.id);if("boolean"!=typeof e)throw new r(r.INVALID_PARAMETER,"Invalid isFullSize",this.element._library.id);this._getDCXElement().setValue(i.IS_FULL_SIZE_KEY,e),this._commit()}},isPreferredThumbnail:{get:function(){return this._getDCXElement().getValue(i.IS_PREFERRED_THUMBNAIL_KEY)||!1},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if("boolean"!=typeof e)throw new r(r.INVALID_PARAMETER,"Invalid isPreferredThumbnail",this.element._library.id);this._getDCXElement().setValue(i.IS_PREFERRED_THUMBNAIL_KEY,e),this._commit()}},contentLength:{get:function(){if(this.isExternalLink)return this._dcxNode.getValue(i.LENGTH_KEY);if(this._dcxComponent){if(void 0===this._dcxComponent.length&&o.hasFileSystem()){var e=this._getCurrentComponentPath();try{var t=o.fs.statSync(e);return t&&t.size}catch(e){}}return this._dcxComponent.length}},set:function(e){if(!this.isExternalLink)throw new r(r.READ_ONLY,"setContentLength can only be used for an externally-linked representation",this.element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid content length",this.element._library.id);this._dcxNode.setValue(i.LENGTH_KEY,e),this._commit()}},contentHash:{get:function(){return this._getDCXElement().getValue(i.SHA_KEY)},set:function(){throw new r(r.READ_ONLY,"contentHash is a read-only property",this.element.library.id)}},isDeletedLocally:{get:function(){return this._deletedLocally},set:function(){throw new r(r.READ_ONLY,"isDeletedLocally is a read-only property",this.element._library.id)}},isExternalLink:{get:function(){return void 0!==this._dcxNode&&this._dcxNode.type===i.LINK_REPRESENTATION_TYPE},set:function(){throw new r(r.READ_ONLY,"isExternalLink is a read-only property",this.element._library.id)}}}),u.prototype.isCompatibleType=function(e){if(this._dcxComponent){var t=l.getFileExtension(this._dcxComponent.path);if(-1===s.getExtensions(e).indexOf(t))return!1}return c.isCompatibleType(e,this.type)},u.prototype.toString=function(){return JSON.stringify(this._toJSON())},u.prototype.getValue=function(e,t){if(e===i.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var n=c.getDCXKey(e,t);return this._getDCXElement().getValue(n)},u.prototype.getValues=function(){return c.getCustomDCXData(this._getDCXElement())},u.prototype.setValue=function(e,t,n){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(e===i.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var o,a=c.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new r(r.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.element._library.id)}this._getDCXElement().setValue(a,o),this._commit()},u.prototype.setContent=function(e,t,n,i){if(!c.checkDeletedState(this,i))if(this.isWritable)if(this._dcxComponent||this.isExternalLink)i(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else if(o.hasFileSystem()){if(!c.checkEncoding(t,["utf8","ascii","base64","buffer"],i))return;this._setComponent(e,t,n,i)}else{if(void 0!==t)return void i(new r(r.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setComponentInBrowser(e,n,i)}else i(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))},u.prototype.setContentFromPath=function(e,t,n){"function"==typeof t&&(n=t,t=!1),o.hasFileSystem()?c.checkDeletedState(this,n)||(this.isWritable?this._dcxComponent||this.isExternalLink?n(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id)):this._setContentFromPath(e,!t,n):n(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))):n(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))},u.prototype.setContentFromURL=function(e,t,n,i){if(o.hasFileSystem()||e){if(!c.checkDeletedState(this,i))if(this.isWritable)if("boolean"==typeof e)if(this._dcxComponent||this.isExternalLink)i(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else{if(e)return this._setExternalLink(t),this._commit(),void i(null);var a=this,h=this.element.library.collection,u=h._getTempDir();o.storageInterface.getAssetFromURL(h,t,n,u,(function(e,t,n,o){if(e)i(p.getSyncError(e));else if(!c.checkDeletedState(a,i)){var r=d.getContentTypeHeader(o&&o.headers);if(r){var h=t+"."+s.getExtensions(r)[0];l.rename(t,h,(function(e){e?i(p.getCommitError(e)):a._setComponentFromPath(h,void 0,!1,i)}))}else a._setComponentFromPath(t,void 0,!1,i)}}))}else i(new r(r.INVALID_PARAMETER,"Invalid createLink parameter: must be Boolean",this.element._library.id));else i(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))}else i(new r(r.NOT_IMPLEMENTED,"not yet implemented setContentFromURL without a filesystem",this.element._library.id))},u.prototype.getContentPath=function(e){o.hasFileSystem()?c.checkDeletedState(this,e)||this._getComponentPath(e):e(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))},u.prototype.getCachedContentPath=function(){if(o.hasFileSystem())return this.isExternalLink?this.element.library.collection._externalLinkCache.getCachedPath(this):this._dcxComponent?this._getCurrentComponentPath()||void 0:this._getContentFromData()&&this.element.library._renditionCache.getCache(this.element,this.id)||void 0},u.prototype.getContent=function(e,t){var n=o.fs,i=this;if(!c.checkDeletedState(this,t))if(o.hasFileSystem()){if(!c.checkEncoding(e,["utf8","ascii","base64","buffer"],t))return;this._getComponentPath((function(o,r){if(!o&&r){if(!c.checkDeletedState(i,t)){var a=function(e,n){e&&(e=p.getCommitError(e,i.element._library.id,"error reading content from disk")),t(e,n)};"buffer"===e?n.readFile(r,a):n.readFile(r,e,a)}}else t(o)}))}else{if(!c.checkEncoding(e,["text","blob","arraybuffer"],t))return;if(!this._dcxComponent)return void t(null);this.element._library._collection._syncManager.getSharedCloudContent(this,e,t)}},u.prototype.getContentURL=function(){return this.isExternalLink?this._dcxNode.getValue(i.LINK_URL_KEY):this._dcxComponent?this.element._library._collection._syncManager.getSharedCloudContentURL(this._dcxComponent):void 0},u.prototype.getAuthenticatedContentURL=function(e){var t=this.getContentURL();this.element._library._collection._syncManager.appendAccessTokenToURL(t,e)},u.prototype.createChild=function(e){if(!this._dcxNode)throw new r(r.NOT_ALLOWED,"can't create child on a component representation",this.element.library.id);var t=this.element.library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);t.type=e,t.setValue(i.RELATIONSHIP_KEY,i.RELATIONSHIP_CHILD);var n=new u(this,t);return this._children.push(n),this._commit(),n},u.prototype.removeChild=function(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e._parent!==this)throw new r(r.INVALID_PARAMETER,"cannot remove a child that doesn't belong to this representation",this._library.id);e._dcxComponent?this.element.library._dcxBranch.removeComponent(e._dcxComponent):this.element.library._dcxBranch.removeChild(e._dcxNode);var t=this._children.indexOf(e);-1!==t&&this._children.splice(t,1),this._commit()},u.prototype.testExternalLink=function(e){this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.testExternalLink(this).then((function(){return e(null,!0)}),(function(){return e(null,!1)})):e(new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id))},u.prototype.clearCachedExternalLink=function(){if(!this.isExternalLink||!this.getContentURL())throw new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id);this._clearCachedExternalLink()},u.prototype.getCachedExternalLinkError=function(){return this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.getCachedError(this):new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id)},u.prototype.getExternalLinkDownloadProgress=function(){if(this.isExternalLink)return this.element.library.collection._getExternalLinkDownloadProgress(this)},Object.freeze(u),Object.seal(u.prototype),e.exports=u},function(e,t,n){var o=n(2),i=n(8),r=n(1),a=n(0),s=n(11);function c(e,t){this._element=e,this._id=t.action,this._appCode=t.appCode,this._appName=t.appName,this._minVersion=t.minVersion,this._installedVersions=r.ELEMENT_ACTION_PRODUCT_MAP.installedApps.filter((function(e){return e.code===t.appCode})).map((function(e){return e.version})).sort(i.compareVersions),this._invokable=this._installedVersions.length>0&&i.compareVersions(t.minVersion,this._installedVersions[0])>=0,Object.freeze(this._installedVersions)}Object.defineProperties(c.prototype,{id:{get:function(){return this._id},set:function(){throw new o(o.READ_ONLY,"Cannot change the id of an existing element action",this._id)}},element:{get:function(){return this._element},set:function(){throw new o(o.READ_ONLY,"element is a read-only property",this._element.id)}},appCode:{get:function(){return this._appCode},set:function(){throw new o(o.READ_ONLY,"Cannot change the app code of an element action",this._appCode)}},appName:{get:function(){return this._appName},set:function(){throw new o(o.READ_ONLY,"Cannot change the app name of an element action",this._appName)}},minAppVersion:{get:function(){return this._minVersion},set:function(){throw new o(o.READ_ONLY,"Cannot change the min version of an element action",this._minVersion)}},installedVersions:{get:function(){return this._installedVersions},set:function(){throw new o(o.READ_ONLY,"Cannot change the installed versions of an element action")}},isCompatibleVersionInstalled:{get:function(){return!!this._invokable},set:function(){throw new o(o.READ_ONLY,"Cannot change the compatibility of an element action")}}}),c.prototype.invoke=function(e){var t=i.wrapCallback(e);this.isCompatibleVersionInstalled?(s.reportElementActionInvoked(this),a.storageInterface.sendElementAction(this,(function(e,n){e?(e=-1!==["APP_NOT_INSTALLED","NO_COMPATIBLE_VERSION"].indexOf(e)?new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action:"+e):new o(o.APP_LAUNCH_FAILED,"Launching the app failed:"+e),s.reportElementActionFailed(this,e)):s.reportElementActionSuccessful(this,n),t(e,n)}))):t(new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action",this._appCode))},Object.freeze(c),Object.seal(c.prototype),e.exports=c},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e,t,n){return(r="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(o){var i=Object.getOwnPropertyDescriptor(o,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var c=n(23),l=n(24),p=n(1),d=n(25),h=n(35),u="renditions",_=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}(this,a(t).call(this,e._getRenditionCacheDir())))._library=e,n._pendingSetCache=[],n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,h),function(e,t,n){t&&i(e.prototype,t)}(t,[{key:"getCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full",n=this._getCache([u,e.id,t]);return this._getFilePath(n)}},{key:"setCache",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full",o=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return p.SHARED_LOCAL_STORAGE?this._requestSetCache(e.id,n,o):this._doTransaction((function(){return t._setCache([u,e.id,n],o,i)}))}},{key:"clearCache",value:function(e,t){var n=this,o=this._getCache([u,e.id]);return o?(t&&p.SHARED_LOCAL_STORAGE&&d.supportsClearRenditionCache()&&Object.keys(o).forEach((function(t){return n._requestSetCache(e.id,t,"CLEAR")})),this._clearCache(e)):Promise.resolve()}},{key:"copyCache",value:function(e,t){var n=this;return p.SHARED_LOCAL_STORAGE?(this._copyCache(e,t),Promise.resolve()):this._doTransaction((function(){return n._copyCache(e,t)}))}},{key:"serializeCache",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,o={},i=function(i){o[i.id]=e.serializeElementCache(i,t,n)};return this._library.elements.forEach(i),this._library.removedElements.forEach(i),o}},{key:"serializeElementCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,o=Object.assign({},this._cache.renditions&&this._cache.renditions[e.id]||{});return t&&this._convertToAbsolutePaths(o),this._addExternalLinksToElementCache(o,e,t,n),o}},{key:"replaceCache",value:function(e){this._cache=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},u,e)}},{key:"replaceElementCache",value:function(e,t){this._cache.renditions=this._cache.renditions||{},this._cache.renditions[e.id]=t}},{key:"checkAndInvalidateRenditions",value:function(e,t){var n,o=this,i=this._getCache([u,e.id]);return Object.keys(i).some((function(r){if(Number(r)){var a=l.join(o._rootDir,i[r]),s=l&&c.statSync(a);return s&&s.size>t?(o.clearCache(e),n="Invalidating rendition - ".concat(e.id," ").concat(e.name," dimension: ").concat(r," size: ").concat(s.size),!0):void 0}})),n}},{key:"doRequestSetCache",value:function(){var e=this;return this._requestingSetCache=this._pendingSetCache,this._pendingSetCache=[],{data:this._requestingSetCache.map((function(e){return{element:e.element,size:e.size,path:e.path}})),cancel:function(){e._pendingSetCache=e._requestingSetCache.concat(e._pendingSetCache),delete e._requestingSetCache},complete:function(t){return e._completeRequestSetCache(t)}}}},{key:"applyRequestSetCache",value:function(e){var t=this;return this._doTransaction((function(){return t._applyRequestSetCache(e)}))}},{key:"gc",value:function(){var e=this,t={},n=function(e){e._shouldGCLocalData()||(t[e.id]=!0)};this._library.elements.forEach(n),this._library.removedElements.forEach(n);var o=this._cache.renditions||{},i=!1;Object.keys(o).forEach((function(n){t[n]||(e._setCacheEntry([u,n]),i=!0)}));var r=i?this.save():Promise.resolve(),a=this._library.collection._externalLinkCache;return r.then((function(){return a&&a.gc()}))}},{key:"_load",value:function(){var e=this;return r(a(t.prototype),"_load",this).call(this).then((function(){e.serializeCache(!0,!1)}))}},{key:"_gcUnreferencedFiles",value:function(){return this._library._dcxComposite.autoRemoveUnusedLocalFiles?r(a(t.prototype),"_gcUnreferencedFiles",this).call(this):Promise.resolve()}},{key:"_copyCache",value:function(e,t){var n=this,o=t.library._renditionCache,i=this._getCache([u,e.id])||{},r=Object.keys(i).map((function(r){var a=n._getFilePath(i[r],!0);if(!a)return Promise.resolve();var s=e.getRepresentationById(r);if(s&&!t.getRepresentationById(r)){var c=e.representations.indexOf(s);c>=0&&c<t.representations.length&&(r=t.representations[c].id)}return n._isPath(a)?p.SHARED_LOCAL_STORAGE?o._requestSetCache(t.id,r,a):o._setCache([u,t.id,r],a):Promise.resolve(o._setCacheEntry([u,t.id,r],a))}));return Promise.all(r)}},{key:"_requestSetCache",value:function(e,t,n){var o=this;return new Promise((function(i,r){o._pendingSetCache=o._pendingSetCache.filter((function(n){return!(n.element===e&&n.size===t&&"CLEAR"===n.path)})),o._pendingSetCache.push({element:e,size:t,path:n,callback:function(e,t){return e?r(e):i(t)}})}))}},{key:"_applyRequestSetCache",value:function(e){var t=this,n=e.map((function(e){var n=e.element,o=e.size,i=e.path;return"CLEAR"===i?(t._setCacheEntry([u,n,o]),Promise.resolve()):t._setCache([u,n,o],i)}));return Promise.all(n)}},{key:"_completeRequestSetCache",value:function(e){var t=this,n={};return e.forEach((function(e,o){var i=t._requestingSetCache[o],r=t._library.getElementById(i.element);if(i&&r&&e&&0===e.indexOf(t._rootDir)){var a=e.substring(t._rootDir.length+1);t._setCacheEntry([u,i.element,i.size],a),n[r.id]=r}i&&i.callback(null,e)})),delete this._requestingSetCache,Object.keys(n).map((function(e){return n[e]}))}},{key:"_clearCache",value:function(e,t){var n=t?[u,e.id,t]:[u,e.id];return this._setCacheEntry(n),this.save()}},{key:"_convertToAbsolutePaths",value:function(e){var t=this;Object.keys(e).forEach((function(n){var o=e[n];e[n]=t._isPath(o)?l.join(t._rootDir,o):o}))}},{key:"_legacyGetCacheEntry",value:function(e){var t=this._getCache([u,e.element.id,e.id]);return this._getFilePath(t,!0)}},{key:"_legacyClearCacheEntry",value:function(e){var t=[u,e.element.id,e.id];this._getCache(t)&&(this._setCacheEntry(t),this.save())}},{key:"_addExternalLinksToElementCache",value:function(e,t){var n=this,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;e=e||{};var r=this._library.collection._externalLinkCache;t._forEachRepresentation((function(t){if(t.isExternalLink&&!e[t.id]){var a=r._getCacheEntry(t);a&&(e[t.id]=!o&&a.startsWith(r._rootDir)?l.relative(n._rootDir,a):a,r._notifyDownloadRendition(t,i))}}))}}]),t}();e.exports=_},function(e,t,n){var o=n(31),i=n(32),r=n(4),a=n(3),s=n(1),c=n(2),l=n(0),p=n(19),d=n(6),h=n(5),u=n(8),_=n(10),f=n(15);function m(e,t){this._collection=e,this._isPublic=t.IS_PUBLIC,this._storageHost=t.STORAGE_HOSTNAME,this._collaborationHost=t.COLLABORATION_HOSTNAME,this._imageHost=t.CC_IMAGE_HOSTNAME,this._imageXHost=t.CC_IMAGE_X_HOSTNAME,this._typekitHost=t.TYPEKIT_HOSTNAME,this._ccLibraryHost="https://".concat(t.CC_LIBRARY_SERVICE_HOSTNAME,"/api/v1"),this._storageAssetsPath=this._isPublic?t.STORAGE_ASSETS_PATH:s.STORAGE_ASSETS_PATH,this._apiKey=s.STORAGE_API_KEY,this._syncGroup=this._isPublic?t.SYNC_GROUP:s.LIBRARY_SYNC_GROUP,this._XHR=t.XHR,this._requiresCommunitySession=t.REQUIRES_COMMUNITY_SESSION,this._getAccessToken=t.getAccessToken,this._httpServices=[],this._storageService=this._createStorageSession(),this._renditionStorageService=this._createStorageSession(),this._temporaryStorageServices={},this._lastSyncGroupState={},this._hasSetAuthToken=!1,this._authToken=void 0,this._inProgressSyncMap={},s.SHARED_LOCAL_STORAGE||this._isPublic||this._updateAuthToken()}m.prototype._getCommonRequestHeaders=function(){var e={};return s.USER_AGENT_HEADER&&(e["User-Agent"]=s.USER_AGENT_HEADER),e},m.prototype._setAuthToken=function(e){this._hasSetAuthToken=!0,this._authToken=e,this._httpServices.forEach((function(t){e?(t.isActive=!0,t.setAuthToken(e)):t.isActive=!1}))},m.prototype._updateAuthToken=function(e){var t=this,n=u.wrapCallback(e);this._getAccessToken(this._authToken,(function(e,o){!e&&o?t._setAuthToken(o):(e&&e.code===c.ACCESS_DENIED&&(t._collection._reportSyncError(e),t._collection._updateSyncState()),t._setAuthToken()),n(null,o)}))},m.prototype._getAuthToken=function(e){this._hasSetAuthToken?e(null,this._authToken):this._updateAuthToken(e)},m.prototype._authHandler=function(){this._updateAuthToken()},m.prototype._createStorageSession=function(){var e;return this._isPublic?e=l.dcx.createHTTPService():(e=l.dcx.createHTTPService(this._authHandler.bind(this)),this._httpServices.push(e)),e.setApiKey(this._apiKey),e.setTimeout(s.NETWORK_TIMEOUT),e.setAdditionalNodeOptions(l.getNodeTunnelOptions(this.getStorageHost())),e.setAdditionalHeaders(this._getCommonRequestHeaders()),this._XHR&&e._forceXhr(this._XHR),this._requiresCommunitySession?l.dcx.createCommunitySession(e,this.getStorageHost()):l.dcx.createStorageSession(e,this.getStorageHost())},m.prototype._createTemporaryStorageSession=function(e,t){var n;return t&&this._getAccessToken?(this._authToken||this._updateAuthToken(),(n=l.dcx.createHTTPService(this._authHandler.bind(this))).setApiKey(this._apiKey),n.setAdditionalHeaders(this._getCommonRequestHeaders()),n.setAuthToken(this._authToken),this._httpServices.push(n)):n=l.dcx.createHTTPService(),n.setTimeout(s.NETWORK_TIMEOUT),n.setAdditionalNodeOptions(l.getNodeTunnelOptions(e)),this._XHR&&n._forceXhr(this._XHR),l.dcx.createStorageSession(n,e)},m.prototype._getTemporaryStorageSession=function(e){var t=r.parseURI(e),n=t.scheme+"://"+t.authority,o=p.isAdobeDomain(t.authority);return this._temporaryStorageServices[n]||(this._temporaryStorageServices[n]=this._createTemporaryStorageSession(n,o)),this._temporaryStorageServices[n]},m.prototype.getServerComposites=function(e){var t=this,n=this._lastSyncGroupState.etag;this._storageService.getCollection(this.getSyncGroupPath(),n,(function(n,o,i,r){if(n)n.response&&404===n.response.statusCode?e(null,[]):e(n);else{if(!o){var a=Math.max(s.DEFAULT_MAX_SYNC_INTERVAL,1e3*p.getRetryAfterHeader(r));return s.MAX_SYNC_INTERVAL=a,void e(null,[])}s.MAX_SYNC_INTERVAL=s.DEFAULT_MAX_SYNC_INTERVAL;var c=t._lastSyncGroupState.compositeEtags||{},l={},d=[],h={};(o.children||[]).forEach((function(e){e&&_.validateLibraryId(e.name,!1)&&(e.isUnmodified=e.etag&&c[e.name]===e.etag,d.push(e),h[e.name]=e,l[e.name]=e.etag)})),t._lastSyncGroupState={etag:i,compositeEtags:l},e(null,d,h)}}))},m.prototype.clearSyncGroupCache=function(){this._lastSyncGroupState={}},m.prototype.doHeadRequest=function(e,t){var n;try{n=this._storageService.getCompositeManifestHref(e)}catch(e){return void t(e)}this._storageService.headRequest(n,t)},m.prototype.hasCompositeChangedOnServer=function(e,t){this.doHeadRequest(e,(function(n,o){if(n)t(!0);else{var i=o&&o.headers&&o.headers.etag,r=e.current&&e.current.manifestEtag;t(i!==r)}}))},m.prototype.downloadComponent=function(e,t,n){i.downloadComponents([t],e,this._storageService,n)},m.prototype.downloadRepresentation=function(e,t){var n=e._dcxComponent,o=e.element.library._dcxBranch;this.downloadComponent(o,n,t)},m.prototype.abortPushOrPull=function(e){this._inProgressSyncMap[e]&&(this._inProgressSyncMap[e].abort(new c(c.TRANSFER_ABORTED,"abort push or pull operation")),delete this._inProgressSyncMap[e])},m.prototype._isManifestOnly=function(){return"manifestOnly"===s.SYNC_POLICY||!l.hasFileSystem()},m.prototype._pullCompositeComponents=function(e,t,n,o,r){if(this._isManifestOnly())r(null);else{var a=i.downloadComponents(e,t,this._storageService,r);this._inProgressSyncMap[o]=a,a.onProgress=function(e,t){0!==t&&n._updateProgress(o,e,t)}}},m.prototype._pullComposite=function(e,t,n,o){var r=this;this._inProgressSyncMap[n]=i.pullCompositeManifestOnly(e,this._storageService,(function(e,i){if(!e&&i){var a=i.getComponentsOf();i.getChildrenOf().forEach((function(e){e.name===s.ELEMENTS_NAME&&i.getChildrenOf(e).forEach((function(e){a=a.concat(i.getComponentsOf(e))}))})),r._pullCompositeComponents(a,i,t,n,(function(e){o(e,i)}))}else o(e,i)}))},m.prototype.pullComposite=function(e,t,n){var o=this,i=e.id;if(!i&&e.href){var r=e.href.split("/");i=r&&r[r.length-1]}l.log("Started pulling: "+i+(this._isManifestOnly()?" (manifest only)":""));var s=(new Date).valueOf();t._updateProgress(i),this._pullComposite(e,t,i,(function(r,p){var d=(new Date).valueOf()-s;l.log("Finished pulling: "+i+(r?" ["+r.code+"]":"")+" duration="+d),delete o._inProgressSyncMap[i],t._updateProgress(i),p&&(p=p.copy(),_.ensureBranchDataValid(p)),r&&r.code===a.COMPONENT_DOWNLOAD_ERROR?o.doHeadRequest(e,(function(e,t){if(!e&&t&&200===t.statusCode){var o=_.removeMissingComponents(r.pulledBranch.copy(),r.failedComponents);if(o)return void n(null,o)}n(r,p)})):r&&r.code===c.TRANSFER_ABORTED?n(null,void 0):n(r,p)}))},m.prototype.pullMissingComponents=function(e,t){var n=this,o=e.id,i=e.collection,r=e._getMissingLocalComponents();if(this._isManifestOnly()||0===r.length)t(null);else{e._setSyncState("downloading"),l.log("Started pulling missing components: "+o);var a=(new Date).valueOf();i._updateProgress(o),this._pullCompositeComponents(r,e._dcxBranch,i,o,(function(r){var s=(new Date).valueOf()-a;l.log("Finished pulling missing components: "+o+(r?" ["+r.code+"]":"")+" duration="+s),delete n._inProgressSyncMap[o],i._updateProgress(o),e._setSyncState(),r&&r.code===c.TRANSFER_ABORTED?t(null):t(r)}))}},m.prototype.pushComposite=function(e,t,n,o){var r=this,a=e.id;l.log("Started pushing: "+a);var s=(new Date).valueOf();t._updateProgress(a),this._inProgressSyncMap[a]=i.pushComposite(e,n,this._storageService,(function(e){var n=(new Date).valueOf()-s;l.log("Finished pushing: "+a+(e?" ["+e.code+"]":"")+" duration="+n),delete r._inProgressSyncMap[a],t._updateProgress(a),o(e)})),this._inProgressSyncMap[a].onProgress=function(e,n){0!==n&&t._updateProgress(a,e,n)}},m.prototype.pushDeletedComposite=function(e,t,n,o,i){var r=this;"incoming"===n?(l.log("Deleting incoming collaboration without pushing: "+e.id),this._storageService.deleteCompositeDirectory(e,i)):e.current&&!e.current.isBound?i(null):(l.log("Pushing deleted composite: "+e.id),this.pushComposite(e,t,o,(function(n){if(n){if(n.code===a.UNEXPECTED_RESPONSE&&n.response&&404===n.response.statusCode)return void r._storageService.deleteCompositeDirectory(e,i);if(n.code===a.UPDATE_CONFLICT){var o=n;return void r.pullComposite(e,t,(function(t){t&&t.code===a.NO_COMPOSITE?r._storageService.deleteCompositeDirectory(e,i):t&&t.code===a.DELETED_COMPOSITE?i(null):i(t||o)}))}}i(n)})))},m.prototype.getStorageHost=function(){return"https://"+this._storageHost},m.prototype.getSyncGroupPath=function(){var e=this.getStorageHost()+(this._storageAssetsPath||"");return this._syncGroup?r.appendPathElements(e,this._syncGroup):e},m.prototype.getCompositePath=function(e){return r.appendPathElements(this.getSyncGroupPath(),e)},m.prototype.getComponentPath=function(e,t){return r.appendPathElements(this.getSyncGroupPath(),e,t)},m.prototype.getElementRefDomain=function(){return this._requiresCommunitySession?s.CP_CLOUD_ID:this._storageHost},m.prototype.getElementRefPath=function(){return s.STORAGE_ASSETS_PATH+s.LIBRARY_SYNC_GROUP},m.prototype.getElementRefDomainPath=function(){return this.getElementRefDomain()+this.getElementRefPath()},m.prototype.getCollaborationHost=function(){return"https://"+this._collaborationHost},m.prototype._getSharedCloudRenditionUrl=function(e,t,n){if(e._dcxComponent)try{n(null,this._requiresCommunitySession?this._storageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,"image/png","width",t||"full"):this._storageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,t||"full"))}catch(e){n(e)}else n("representation must be a component to generate a rendition")},m.prototype._getTypekitFontData=function(e,t){var n="https://"+this._typekitHost+"/v1/variations?include=trial,full,marketplace,purchased&include_marketplace_data=true&purpose=sync";this._getTemporaryStorageSession(n)._service.invoke("POST",n,null,JSON.stringify(e),{responseType:"text"},(function(e,n){if(e||200!==n.statusCode)return t(e||"Typekit service call failed with: "+n.statusCode);try{t(null,JSON.parse(n.response))}catch(e){t(e)}}))},m.prototype._retry404IfNeeded=function(e,t,n,o,i){var r=1e3*p.getRetryAfterHeader(t);if(s.RENDITION_RETRY_INTERVAL=Math.max(s.DEFAULT_RENDITION_RETRY_INTERVAL,r),s.RENDITION_404_BACKOFF=Math.max(s.DEFAULT_RENDITION_404_BACKOFF,r),n<s.RENDITION_MAX_RETRIES)return n++,l.log("404 fetching rendition: retrying ("+n+")"),void setTimeout(o,s.RENDITION_RETRY_INTERVAL,n);l.log("404 fetching rendition: reached maximum retries"),l.log("Backing off rendition fetch of "+e.id+" for "+s.RENDITION_404_BACKOFF+"ms"),e._lastRendition404=(new Date).valueOf(),i()},m.prototype._getImageServiceSVGRendition=function(e,t,n){var o=this,i=e.element,r="https://"+this._imageHost+"/createagc",a=this._getTemporaryStorageSession(r),s={"Content-Type":"application/vnd.adobe.image-operation+json"},c={inputs:{application_file:{href:i.getReference()}},outputs:{agc:{disposition:"location"}}};if(e.isDeletedLocally||e.element.library.isDeletedFromServer)n("Error: representation deleted");else{var p=function(t){o._getImageServiceSVGRendition(e,t,n)};a._service.invoke("POST",r,s,JSON.stringify(c),{responseType:"text"},(function(d,u){if(d||200!==u.statusCode){var _=function(){return n(d||"Image service call failed with: "+u.statusCode)};return u&&404===u.statusCode?o._retry404IfNeeded(e,u&&u.headers,t,p,_):void _()}var f;try{f=JSON.parse(u.response)}catch(e){return n(e)}if(f&&f.outputs&&f.outputs.agc&&f.outputs.agc.location)return r="https://"+o._imageXHost+"/agctosvg",a=o._getTemporaryStorageSession(r),s={"Content-Type":"application/vnd.adobe.dwbedrockservice-operation+json"},c={inputs:{href:f.outputs.agc.location}},a._service.invoke("POST",r,s,JSON.stringify(c),{responseType:"text"},(function(e,t){if(e||200!==t.statusCode)return n(e||"Image-x service call failed with: "+t.statusCode);var o=t.response,r=i.library.collection._getTempDir(),a=r+l.getPathSeparator()+l.uuid()+".svg";h.ensurePathExists(r,(function(e){if(e)return n(e);l.fs.writeFile(a,o,(function(e){if(e)return n(e);n(null,a)}))}))}));n("Invalid image service response")}))}},m.prototype._getAssetAsType=function(e,t,n,i,r,a){var c=this;if(a=a||0,e.isDeletedLocally||e.element.library.isDeletedFromServer)r("Error: representation deleted");else{var p=function(o){c._getAssetAsType(e,t,n,i,r,o)};if(a>0&&"uploading"===e.element.library.syncState)setTimeout(p,s.RENDITION_RETRY_INTERVAL,a);else{var h=n+l.getPathSeparator()+l.uuid()+".png",u=new o.FileContent(h);this._renditionStorageService.getAssetAsType(t,u,i,(function(t){var n=t&&t.response&&t.response.headers,o=function(){r(t,h)};if(404===d.getErrorStatusCode(t))return c._retry404IfNeeded(e,n,a,p,o);o()}))}}},m.prototype.getSharedCloudRenditionUrl=function(e,t,n){this._getSharedCloudRenditionUrl(e,t,n)},m.prototype.getSharedCloudRendition=function(e,t,n){var o=this;if(e.element.library.isDeletedFromServer)return l.log("Error: Trying to fetch rendition from deleted library."),void n("Error: library deleted");(new Date).valueOf()-(e._lastRendition404||0)<s.RENDITION_404_BACKOFF?n("Error: got 404 on last rendition attempt - backing off"):"vector"===t&&e.element.supportsVectorThumbnail()?function t(){"uploading"!==e.element.library.syncState?o._getImageServiceSVGRendition(e,0,n):setTimeout(t,s.RENDITION_RETRY_INTERVAL)}():this._getSharedCloudRenditionUrl(e,t,(function(t,i){if(t)n(t);else{var r={Accept:"image/png"},a=e.element.library.collection._getTempDir();h.ensurePathExists(a,(function(t){t?n(t):o._getAssetAsType(e,i,a,r,n)}))}}))},m.prototype.getSharedCloudContentURL=function(e){return this._storageService.getComponentHref(e,e.version)},m.prototype.appendAccessTokenToURL=function(e,t){if(e){var n=this._apiKey;this._getAuthToken((function(o,i){t(null,e+="?api_key="+n+(i?"&user_token="+i:""))}))}else t(null,void 0)},m.prototype.getSharedCloudContent=function(e,t,n){var o=this._storageService.getComponentHref(e._dcxComponent,e._dcxComponent.version);this._storageService.getAssetAsType(o,t,{},(function(e,t){e?n(e):n(null,t)}))},m.prototype.getAssetFromURL=function(e,t,n,i,r,c){var d=this;l.log("getAssetFromURL: "+e);var u=this._getTemporaryStorageSession(e),_=n+l.getPathSeparator()+l.uuid(),f=new o.FileContent(_);c=c||0,t=t||{},h.ensurePathExists(n,(function(o){if(o)r(o);else{var h=u.getAssetAsType(e,f,t,(function(o,u,f,m){if(h&&delete h.progress,o&&o.code===a.UNEXPECTED_RESPONSE){var y=o.response&&o.response.statusCode;if(l.log("getAssetFromURL: Unexpected Response "+y+" from "+e),p.isRedirect(y)){var E=p.getLocationHeader(o.response.headers);if(E&&c<s.MAX_REDIRECT_FOLLOW)return l.log("getAssetFromURL: Redirecting to "+E),void d.getAssetFromURL(E,t,n,i,r,c+1);o.response.statusCode=404}}r(o,_,f,m)}));if(h&&i){var m,y=0;h.progress=function(e){y+=e,!m&&h.response&&h.response.headers&&(m=p.getContentLengthHeader(h.response.headers)),i(y,m||1)},i(0,1)}}}))},m.prototype.doHeadRequestOfURL=function(e,t,n){var o=this;n=n||0,this._getTemporaryStorageSession(e).headRequest(e,(function(i,r){var a=r?r.statusCode:i;if(l.log("doHeadRequestOfURL: "+e+" -> "+a),r&&p.isRedirect(r.statusCode)){var c=p.getLocationHeader(r.headers);if(c&&n<s.MAX_HEAD_REDIRECT_FOLLOW)return l.log("doHeadRequestOfURL: Redirecting to "+c),void o.doHeadRequestOfURL(c,t,n+1);n>0&&(r.statusCode=404)}t(i,r)}))},m.prototype.prepareCompositeForPush=function(e){e.href=this.getCompositePath(e.id)},m.prototype.updateAccessToken=function(e){this._setAuthToken(e)},m.prototype.isLoggedIn=function(){return this._isPublic||this._httpServices[0].isActive},m.prototype.uploadNewComponentForRepresentation=function(e,t,n,o){var r=n._element._library._dcxComposite;i.uploadNewComponent(e,n.type,r,n.id,this._storageService,(function(e,i){if(e)o(e);else{var a=t?t.lastIndexOf("."):-1,s=-1!==a&&t.substr(a+1).toLowerCase(),c=n.id+"."+s,l=r.current.addComponentWithUploadResults(t,n.relationship,c,n._element._dcxNode,i);o(null,l)}}))},m.prototype.uploadNewComponentForLibrary=function(e,t,n,o,r,a){var s=r._dcxComposite;i.uploadNewComponent(e,n,s,t,this._storageService,(function(e,i){if(e)a(e);else{var r=f.getExtensions(n)[0],c=t+"."+r,l=s.current.addComponentWithUploadResults(c,o,c,s,i);a(null,l)}}))},m.prototype.pushClientTokenInfo=function(e,t,n){this._getTemporaryStorageSession(this._ccLibraryHost)._service.invoke("POST","".concat(this._ccLibraryHost,"/client-tokens/").concat(e),{"Content-Type":"application/json"},JSON.stringify({token:JSON.stringify(t),ttl:300}),null,(function(e,t){if(e||201!==t.statusCode)return n(e||new Error("Failed to push client Token info to the server"));n(null,!0)}))},Object.freeze(m),Object.seal(m.prototype),e.exports=m},function(e,t,n){var o=n(36),i=n(0),r=n(1),a=n(14),s=n(5),c=n(6);function l(e){this._collection=e,this._bookmarks=[],this._bookmarksEtag=void 0,this._bookmarksBase=void 0,this._syncModified=!1,this._lock=new a,this._service=e._syncManager._createTemporaryStorageSession(e._syncManager.getCollaborationHost(),!0)._service,this._bookmarksURL=e._syncManager.getCollaborationHost()+r.BOOKMARKS_PATH}function p(e,t){var n;return e.some((function(e){if(e.id===t)return n=e,!0})),n}function d(e){var t=[];return e.forEach((function(e){t.push({id:e.id,url:e.url})})),t}function h(e){var t=[];return e&&e.forEach((function(e){t.push(new o(e.id,e.url))})),t}l.prototype._getBookmarksDir=function(){return this._collection._getBaseDir()},l.prototype._saveBookmarks=function(e){if(i.hasFileSystem()){var t={bookmarks:d(this._bookmarks),etag:this._bookmarksEtag};this._bookmarksBase&&(t.bookmarks_base=this._bookmarksBase),s.writeJSONData(this._getBookmarksDir(),r.BOOKMARKS_FILENAME,t).then((function(){return e(null)}),(function(t){return e(c.getCommitError(t,null,"bookmarks could not be saved"))}))}else e(null)},l.prototype._loadBookmarks=function(e){var t=this;if(i.hasFileSystem()){var n=this._getBookmarksDir()+i.getPathSeparator()+r.BOOKMARKS_FILENAME;s.readJSONData(n).then((function(n){n&&(t._bookmarks=h(n.bookmarks),t._bookmarksEtag=n.etag,t._bookmarksBase=n.bookmarks_base&&h(n.bookmarks_base)),e(null)}),(function(t){return e(c.getCommitError(t,null,"bookmarks could not be loaded"))}))}else e(null)},l.prototype._pullBookmarks=function(e){i.log("Pulling bookmarks");var t={},n=this;this._bookmarksEtag&&(t["If-None-Match"]=this._bookmarksEtag),this._service.invoke("GET",this._bookmarksURL,t,void 0,{responseType:"text"},(function(t,o){if(t)return e(t);if(200===o.statusCode)try{var i=JSON.parse(o.response);n._syncModified=!0,e(null,h(i.bookmarks),o.headers.etag)}catch(t){e("Cannot parse data: "+o.response)}else 304===o.statusCode||404===o.statusCode?e(null,void 0,o.headers.etag):e("Unexpected response getting bookmarks: "+o.statusCode)}))},l.prototype._mergeBookmarks=function(e,t){if(i.log("Merging bookmarks"),e){if(this._bookmarksBase){var n=this;e.forEach((function(t){var o=p(n._bookmarks,t.id),i=p(n._bookmarksBase,t.id);!o&&i&&e.splice(e.indexOf(t),1)})),this._bookmarks.forEach((function(t){var o=p(e,t.id),i=p(n._bookmarksBase,t.id);o||i||e.push(t)}))}this._bookmarks=e}this._bookmarksEtag=t},l.prototype._pushBookmarks=function(e){i.log("Pushing bookmarks");var t={"Content-Type":"application/json"};this._bookmarksEtag&&(t["If-Match"]=this._bookmarksEtag);var n=this,o=JSON.stringify({bookmarks:d(this._bookmarks)});this._service.invoke("PUT",this._bookmarksURL,t,o,void 0,(function(t,o){if(t)return e(t);var i=o.statusCode;!o.headers.etag||200!==i&&201!==i&&204!==i?409===i||412===i?n._pullBookmarks((function(t,o,i){if(t)return e(t);n._mergeBookmarks(o,i),n._pushBookmarks(e)})):e("Unexpected response updating bookmarks: "+i):e(null,o.headers.etag)}))},l.prototype._commit=function(e){i.log("Commiting bookmarks");var t=this;this._lock.obtain((function(){t._saveBookmarks((function(n){t._lock.release(),n?t._collection._reportCommitError(n):e&&t.sync((function(e){e&&t._collection._reportSyncError(e)}))}))}))},l.prototype._sync=function(e){var t=this;this._bookmarksBase?t._pushBookmarks((function(n,o){if(n)return e(n);t._bookmarksEtag=o,t._bookmarksBase=void 0,t._commit(),e(null)})):t._pullBookmarks((function(n,o,i){if(n)return e(n);o&&(t._bookmarks=o,t._bookmarksEtag=i,t._bookmarksBase=void 0,t._commit()),e(null)}))},l.prototype._createBase=function(){this._bookmarksBase||(this._bookmarksBase=this._bookmarks.slice())},l.prototype.load=function(e){i.log("Loading bookmarks");var t=this;this._lock.obtain((function(){t._loadBookmarks((function(n){t._lock.release(),e(n)}))}))},l.prototype.sync=function(e){i.log("Syncing bookmarks");var t=this;this._lock.obtain((function(){t._syncModified=!1,t._sync((function(n){if(t._lock.release(),n)return n=c.getSyncError(n,null),e(n);e(null),t._syncModified&&t._collection._notifyChange(!0)}))}))},l.prototype.createBookmark=function(e,t,n){if(r.SHARED_LOCAL_STORAGE)i.storageInterface.createBookmark(this._collection,e,t,n);else{i.log("Creating bookmark: "+e+" url: "+t);var a=this;this._lock.obtain((function(){var i=p(a._bookmarks,e),s=!1;i||(a._createBase(),i=new o(e,t),a._bookmarks.push(i),s=!0),a._lock.release(),n(null,i,s),s&&(a._commit(r.SYNCING_ENABLED),a._collection._notifyChange(!0))}))}},l.prototype.removeBookmark=function(e,t){if(r.SHARED_LOCAL_STORAGE)i.storageInterface.removeBookmark(this._collection,e,t);else{i.log("Removing bookmark: "+e.id+" url: "+e.id);var n=this;this._lock.obtain((function(){(e=p(n._bookmarks,e.id))&&(n._createBase(),n._bookmarks.splice(n._bookmarks.indexOf(e),1)),n._lock.release(),t(null),e&&(n._commit(r.SYNCING_ENABLED),n._collection._notifyChange(!0))}))}},l.prototype.getBookmarks=function(){return this._bookmarks.slice()},Object.freeze(l),Object.seal(l.prototype),e.exports=l},function(e,t,n){var o=n(1),i=n(2),r=n(0),a=n(9);function s(e){this._collection=e,this._listenerManager=new a(["change"]),this._fontsCache={}}s.prototype._clearCache=function(){this._fontsCache={},this._listenerManager.notify("change")},s.prototype.addChangeListener=function(e){this._listenerManager.add("change",e)},s.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},s.prototype.getFontData=function(e,t){var n=this,a=this._fontsCache[e];a?t(null,a):o.SHARED_LOCAL_STORAGE?r.storageInterface.getFontData(this._collection,e,(function(o,i){i&&(n._fontsCache[e]=i),t(o,i)})):this._collection._syncManager._getTypekitFontData([e],(function(o,r){o?t(new i(i.NETWORK_ERROR,"Error occurred while getting font data",null,o)):(a=r&&r[0],n._fontsCache[e]=a,t(null,a))}))},s.prototype.isSystemFontAvailable=function(e,t,n){if(!o.SHARED_LOCAL_STORAGE)return n(new i(i.NOT_SUPPORTED,"isSystemFontAvailable() is only supported with shared local storage"));r.storageInterface.isFontAvailable(e,t,n)},Object.freeze(s),Object.seal(s.prototype),e.exports=s},function(e,t,n){var o=n(2),i=n(0),r=n(1),a=n(9);function s(e,t,n,o,i){this._listenerManager=new a(["progress"]),this._collection=e,this._id=t,this._type=n,this._data=o,this._cancelCallback=i,this._progress=0}s.prototype._updateProgress=function(e){this._progress!==e&&(this._progress=e,this._listenerManager.notify("progress",[this]),this._collection._notifyOperationChange())},Object.defineProperties(s.prototype,{id:{get:function(){return this._id},set:function(){throw new o(o.READ_ONLY,"Cannot modify id directly")}},type:{get:function(){return this._type},set:function(){throw new o(o.READ_ONLY,"Cannot modify type directly")}},data:{get:function(){return this._data},set:function(){throw new o(o.READ_ONLY,"Cannot modify data directly")}},progress:{get:function(){return this._progress},set:function(){throw new o(o.READ_ONLY,"Cannot modify progress directly")}}}),s.prototype.addProgressListener=function(e){this._listenerManager.add("progress",e)},s.prototype.removeProgressListener=function(e){this._listenerManager.remove("progress",e)},s.prototype.cancel=function(){r.SHARED_LOCAL_STORAGE?i.storageInterface.cancelOperation(this._collection,this._id):this._cancelCallback&&this._cancelCallback()},Object.freeze(s),Object.seal(s.prototype),e.exports=s},function(e,n,o){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=o(33),a=o(1),s=o(0),c=o(5),l=o(6),p=o(2),d={},h=/^[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}\.[^/\\]+$/i;d.importLibrary=function(e,t,n,o){var i,a,s=function(t,n){if(a&&(t=new p(p.OPERATION_CANCELLED,"import cancelled")),t)o(t);else{i=void 0;var r=n.libraryId,s=n.extractPath,d=e._getCompositeDir(r),h=function(e){c.recursiveDeleteDirectory(s),c.recursiveDeleteDirectory(d),o(e)};c.rename(s,d,(function(t){if(t)return h(l.getFileSystemError(t,"unable to move extracted zip after import"));e._loadLibrary(r,(function(t){if(t)return h(t);var n=e.getLibraryById(r);if(!n)return h(new p(p.INVALID_DATA,"could not load library after import"));e._notifyChange(!0),n._push(),o(null,n)}))}))}};return r.isSnapshot(t,(function(o,c){if(o||a)s(o&&l.getSnapshotError(o,void 0,"error opening library archive"));else{var p=e._getTempDir();if(c){var h=e._syncManager.getSyncGroupPath();i=r.importSnapshot(t,p,h,!1,n,(function(e,t){!e&&t?s(null,{libraryId:t.id,extractPath:t.path}):s(l.getSnapshotError(e,void 0,"cannot import the snapshot file"))}))}else i=d._importNonSnapshotLibrary(e,t,p,n,s)}})),function(){a||(a=!0,i&&i())}},d._importNonSnapshotLibrary=function(e,n,o,r,d){var u=s.getPathSeparator(),_=s.fs,f=s.yauzl;if(f){var m,y=s.uuid(),E=o+s.getPathSeparator()+y,g=e._syncManager.getCompositePath(y),v=!1,A=-1,C=0,O=0,L=!1,S=function(e){L||(L=!0,e&&c.recursiveDeleteDirectory(E),d(e,e?void 0:{libraryId:y,extractPath:E}))},I=E+u+"components";return c.ensurePathExists(I,(function(e){e?S(l.getFileSystemError(e,"unable to create temp dir")):f.open(n,{lazyEntries:!0},(function(e,n){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?S(l.getFileSystemError(e,"error opening library archive")):S(new p(p.INVALID_DATA,"error opening library archive: "+e)):((m=n).on("entry",(function(e){A++,C=0,O=0,function(e){return"data"===e.fileName||e.fileName.match(h)}(e)?"data"!==e.fileName?(C=e.uncompressedSize,m.openReadStream(e,(function(t,n){t?S(l.getFileSystemError(t,"error extracting zip file")):(n.on("end",(function(){m.readEntry()})),n.on("data",(function(e){O+=e.length,function(){if(!v){var e=A/m.entryCount;C&&(e+=O/(C*m.entryCount)),r(Math.round(100*e))}}()})).on("error",(function(e){S(l.getFileSystemError(e,"error extracting zip file"))})).pipe(_.createWriteStream(I+u+e.fileName)))}))):m.openReadStream(e,(function(e,n){if(e)S(l.getFileSystemError(e,"error reading zip file entry"));else{var o=[];n.on("data",(function(e){o.push(e)})),n.on("error",(function(e){S(l.getFileSystemError(e,"error extracting zip file"))})),n.on("end",(function(){var e=function(e,t,n){var o;try{o=JSON.parse(e)}catch(e){return null}if(!o||o.version!==a.EXPORT_VERSION)return null;var r=o.manifest,s=o.componentMap;return"object"!==i(s)||Object.keys(s).some((function(e){return"string"!=typeof s[e]}))?null:(r.id=t,r.local={version:2,change:1,compositeHref:n,"copyOnWrite#storageIds":o.componentMap},{json:o,manifest:r})}(t.concat(o).toString(),y,g);e&&e.manifest?_.writeFile(E+u+"manifest",JSON.stringify(e.manifest,void 0,2),(function(e){e?S(l.getFileSystemError(e,"unable to write manifest file")):m.readEntry()})):S(new p(p.INVALID_DATA,"unable to parse export data"))}))}})):m.readEntry()})).on("error",(function(e){S(l.getFileSystemError(e,"error extracting zip file"))})).on("close",(function(){v?S(new p(p.OPERATION_CANCELLED,"import cancelled")):S()})),m.readEntry())}))})),function(){v||(v=!0,m&&m.close())}}d(new p(p.NOT_SUPPORTED,"yauzl (unzip) module not present"))},d.exportLibrary=function(e,t,n,o){var i,s=r.exportSnapshot(e._dcxComposite,t,(function(e){return delete e["".concat(a.TOOLKIT_NAMESPACE,"#").concat(a.TOOLKIT_ID_KEY)],e.children=e.children.filter((function(e){return e.name!==a.REMOVED_ELEMENTS_NAME})),e}),n,(function(t){o(i?new p(p.OPERATION_CANCELLED,"export cancelled"):t&&l.getSnapshotError(t,e.id,"cannot export a snapshot file"))}));return function(){i||(i=!0,s())}},Object.seal(d),e.exports=d},function(e,t,n){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(23),p=n(24),d=n(0),h=n(2),u=n(1),_=n(15),f=n(5),m=n(6),y=n(25),E=n(19),g=n(35),v=function(e){return new Promise((function(t,n){d.storageInterface.downloadExternalLink(e,(function(e,o){return e?n(e):t(o)}))}))},A=function(e){return new Promise((function(t,n){d.storageInterface.testExternalLink(e,(function(e,o){return o?t():n()}))}))},C={},O=function(e){function t(e){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=p.join(f.getUserDir(e),"links");return(n=i(this,r(t).call(this,o)))._userId=e,n._collections=[],n._pendingDownloads={},n._pendingTests={},n._referencedLinks={},n._sentNotifications={},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,g),s(t,null,[{key:"connect",value:function(e){var n=e.userId,o=C[n]=C[n]||new t(n);return o._connect(e),o}},{key:"disconnect",value:function(e){var t=e.userId;C[t]&&C[t]._disconnect(e)}}]),s(t,[{key:"getCachedPath",value:function(e){var t=this._getCacheEntry(e);return this._isPath(t)?t:void 0}},{key:"getCachedError",value:function(e){var t=E.validateURL(e.getContentURL(),this._privateCollection);if(t)return t;var n=this._getCacheEntry(e);return this._isErrorCode(n)?new h(n,"Broken link, or access denied"):null}},{key:"getExternalLink",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.getContentURL(),i=E.validateURL(o,this._privateCollection);if(i)return Promise.reject(i);if(n)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry(["urls",o]);else{var r=this._getCacheEntry(e);if(this._isPath(r))return Promise.resolve(r);if(this._isErrorCode(r))return Promise.reject(new h(r,"Broken link, or access denied"))}if(u.SHARED_LOCAL_STORAGE)return v(e);if(!this._pendingDownloads[o]){var a=function(){t._notifyDownloadFinished(t._pendingDownloads[o]);var n=e.element;n.supportsVectorThumbnail()&&n.library._renditionCache._clearCache(n,"vector"),delete t._pendingDownloads[o]};this._pendingDownloads[o]={promise:this._doGetExternalLink(e),representations:[]},this._pendingDownloads[o].promise.then(a,a)}return this._pendingDownloads[o].representations.push(e),this._pendingDownloads[o].promise}},{key:"testExternalLink",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.getContentURL();if(E.validateURL(o,this._privateCollection))return Promise.reject();if(n)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry(["urls",o]);else{var i=this._getCacheEntry(e);if(i)return this._isErrorCode(i)?Promise.reject():Promise.resolve()}if(u.SHARED_LOCAL_STORAGE&&y.supportsTestExternalLink())return A(e);if(!this._pendingTests[o]){var r=this._getOnDownloadProgressCallback("_pendingTests",o),a=function(){t._notifyDownloadFinished(t._pendingTests[o]),r(),delete t._pendingTests[o]};this._pendingTests[o]={promise:this._doTest(o),representations:[]},r(0,1),this._pendingTests[o].promise.then(a,a)}return this._pendingTests[o].representations.push(e),this._pendingTests[o].promise}},{key:"ensureExternalLinkCache",value:function(e,t){var n=this,o=this._getCache(["urls",e]);return this._getFilePath(o)?Promise.resolve():this._doTransaction((function(){return n._setCache(["urls",e],t)}))}},{key:"gc",value:function(){var e=this,t={};this._collections.forEach((function(n){n.libraries.forEach((function(n){Object.assign(t,e._getReferences(n))}))}));var n=this._cache.urls||{},o=!1;return Object.keys(n).forEach((function(n){t[n]||(e._setCacheEntry(["urls",n]),o=!0)})),o?this.save():Promise.resolve()}},{key:"_connect",value:function(e){this._collections.push(e),e._externalLinkCache=this}},{key:"_disconnect",value:function(e){var t=this._collections.indexOf(e);-1!==t&&(this._collections.splice(t,1),delete e._externalLinkCache),0===this._collections.length&&delete C[this._userId]}},{key:"_getCacheEntry",value:function(e){var t=e.element.library._renditionCache._legacyGetCacheEntry(e);if(t)return t;var n=e.getContentURL(),o=this._getCache(["urls",n]);return this._getFilePath(o,!0)}},{key:"_doGetExternalLink",value:function(e){var t=this,n=e.getContentURL(),o=e._getLinkLocalPaths().find((function(e){return l.statSync(e)}));return o?this._doTransaction((function(){return t._setCache(["urls",n],o)})):this._doDownload(n,e.type)}},{key:"_doDownload",value:function(e,t){var n=this,o=this._getOnDownloadProgressCallback("_pendingDownloads",e),i=this._privateCollection._getTempDir();return function(e,t,n,o){return new Promise((function(i,r){var a=(new Date).valueOf();d.log("Downloading from external URL: "+t),e._syncManager.getAssetFromURL(t,{},n,o,(function(e,t,n,o){d.log("Finished downloading from external URL: "+((new Date).valueOf()-a)+"ms"),e?r(e):i({tempFilePath:t,etag:n,response:o})}))}))}(this._privateCollection,e,i,o).then((function(i){var r=i.tempFilePath,a=i.response,s=E.getContentTypeHeader(a&&a.headers)||t,c=r+"."+(_.getExtensions(s)[0]||"data"),p=l.rename(r,c).then((function(){return n._doTransaction((function(){return n._setCache(["urls",e],c,!0)}))}));return p.then(o,o),p})).catch((function(t){var i,r=t&&t.response&&t.response.statusCode;return E.isUnrecoverableClientError(r)?(n._setCacheEntry(["urls",e],h.RENDITION_NOT_AVAILABLE),i=n.save().then((function(){return Promise.reject(new h(h.RENDITION_NOT_AVAILABLE,"Broken link, or access denied"))}))):i=Promise.reject(m.getSyncError(t)),i.catch((function(){return o(void 0,void 0,t)})),i}))}},{key:"_doTest",value:function(e){var t=this;return function(e,t){return new Promise((function(n){var o=(new Date).valueOf();d.log("HEAD request of external URL: "+t),d.storageInterface.doHeadRequestOfURL(e,t,(function(e,t){d.log("Finished HEAD request of external URL: "+((new Date).valueOf()-o)+"ms"),n(t)}))}))}(this._privateCollection,e).then((function(n){var o,i=n&&n.statusCode;return E.isUnrecoverableClientError(i)?o=h.RENDITION_NOT_AVAILABLE:i&&i>=200&&i<400&&(o=u.RENDITION_CACHE_PLACEHOLDER),o?(t._setCacheEntry(["urls",e],o),t.save().then((function(){return t._isErrorCode(o)?Promise.reject():Promise.resolve()}))):Promise.resolve()}))}},{key:"_getOnDownloadProgressCallback",value:function(e,t){var n=this;return function(o,i,r){(n[e]&&n[e][t]&&n[e][t].representations).forEach((function(e){e.element.library.collection._updateExternalLinkDownloadProgress(e,o,i,r)}))}}},{key:"_notifyDownloadFinished",value:function(e){var t=this;e.representations.forEach((function(e){return t._notifyDownloadRendition(e,!0)}))}},{key:"_notifyDownloadRendition",value:function(e,t){var n="".concat(e.element.library.id,".").concat(e.element.id,".").concat(e.id);!0!==t&&this._sentNotifications[n]||(this._sentNotifications[n]=!0,!1!==t&&d.storageInterface.notifyDownloadRendition(e.element))}},{key:"_getReferences",value:function(e){var t=this;if(this._referencedLinks[e.id]=this._referencedLinks[e.id]||{},this._referencedLinks[e.id].modified!==e.modified){this._referencedLinks[e.id].modified=e.modified,this._referencedLinks[e.id].urlMap={};var n=function(n){n._shouldGCLocalData()||n._forEachRepresentation((function(n){var o=n.isExternalLink&&n.getContentURL();o&&(t._referencedLinks[e.id].urlMap[o]=!0)}))};e.elements.forEach(n),e.removedElements.forEach(n)}return this._referencedLinks[e.id].urlMap}},{key:"_privateCollection",get:function(){return this._collections.find((function(e){return!e.isPublic}))}}]),t}();e.exports=O},function(e,t,n){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var i=n(9),r=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._collections=[],this._listenerManager=new i(["change"])}return function(e,t,n){t&&o(e.prototype,t)}(e,[{key:"getLibraryCollection",value:function(e,t){return this._collections.find((function(n){return!n.isPublic&&n.userId===e&&n.cloudId===t}))}},{key:"getPublicLibraryCollection",value:function(e){return this._collections.find((function(t){return t.isPublic&&t.cloudId===e}))}},{key:"addLibraryCollection",value:function(e){this._collections.push(e),this._listenerManager.notify("change")}},{key:"removeLibraryCollection",value:function(e){e._dispose();var t=this._collections.indexOf(e);-1!==t&&(this._collections.splice(t,1),this._listenerManager.notify("change"))}},{key:"removeAllLibraryCollections",value:function(){this._collections.forEach((function(e){return e._dispose()})),this._collections=[],this._listenerManager.notify("change")}},{key:"getLoadedCollections",value:function(){return this._collections}},{key:"addLoadedCollectionsListener",value:function(e){this._listenerManager.add("change",e)}},{key:"removeLoadedCollectionsListener",value:function(e){this._listenerManager.remove("change",e)}}]),e}();e.exports=r},function(e,t,n){var o=n(13),i=n(17),r=n(22),a=n(37),s=n(34),c=n(36),l=n(2),p=n(1),d=n(0),h=n(83),u=n(84),_=n(85),f=n(12),m=n(10),y=n(8),E=n(25),g=n(5);function v(e){this._collectionManager=e,this._acceptPushedBranchListeners=[],this._downloadRenditionListeners=[],this._rootListeners=[],this._baseBranches={},this._portDiagnosis="UNKNOWN",this._logIndex=0,p.SHARED_LOCAL_STORAGE&&(this._connect(),this.fs=new _(this),d.hasFileSystem()||d.setFileSystem(this.fs))}var A=function(e){var t={};return t.isPublic=e.isPublic,t.userId=e.userId,t.cloudId=e.cloudId,t},C=function(e,t){var n=A(e.collection);return n[t||"id"]=e.id,n},O=function(e,t,n){var o=C(e.library,n);return o[t||"element"]=e.id,o},L=function(e){var t=O(e.element);return t.representation=e.id,t};v.prototype._getBase=function(e){var t=this._baseBranches[e];return t&&t.base},v.prototype._setBase=function(e,t){this._baseBranches[e]=this._baseBranches[e]||{},this._baseBranches[e].base=t},v.prototype._getLogIndex=function(){return this._logIndex++},v.prototype._getServicePort=function(e){var t=p.VULCAN_PREFIX+p.VULCAN_QUERY_REQUEST,n=p.VULCAN_PREFIX+p.VULCAN_QUERY_RESPONSE;function o(t){var n;try{n=JSON.parse(t)}catch(e){}n?e(null,n):e("NO_DATA")}if(d.vulcanCall)d.vulcanCall(t,"",n,o);else if(d.hasCEPVulcan()){var i,r=d.getVulcanInterface(),a=d.getVulcanMessage(),s=function t(a){r.removeMessageListener(n,t),clearTimeout(i),a?o(r.getPayload(a)):e("NO_VULCAN_MESSAGE")};r.addMessageListener(n,s),i=setTimeout(s,p.VULCAN_QUERY_TIMEOUT);var c=new a(t);c.setPayload(""),r.dispatchMessage(c)}},v.prototype._connectToPort=function(e,t){var n=this,o=t&&t.port,i=t&&t.token,r=t&&t.domain;if(this._portDiagnosis=t?t.portdiagnosis:"UNKNOWN",this._connectionPort=o,!this._channel&&o&&"SIMPLE_HOSTNAME_GOING_TO_PROXY"!==this._portDiagnosis){try{var a=new u(o,i,r);this._channel=new h(a)}catch(e){}this._channel&&(this._channel.addListener("environmentinfo",this._onEnvironmentInfo.bind(this)),this._channel.addListener("collectionadded",this._onCollectionAdded.bind(this)),this._channel.addListener("collectionremoved",this._onCollectionRemoved.bind(this)),this._channel.addListener("clearcollections",this._onClearCollections.bind(this)),this._channel.addListener("syncstate",this._onSyncState.bind(this)),this._channel.addListener("librarychange",this._onLibraryChange.bind(this)),this._channel.addListener("renditioncachechange",this._onRenditionCacheChange.bind(this)),this._channel.addListener("librarydeleted",this._onLibraryDeleted.bind(this)),this._channel.addListener("bookmarkschanged",this._onBookmarksChanged.bind(this)),this._channel.addListener("fontcachechanged",this._onFontCacheChanged.bind(this)),this._channel.addListener("operationschanged",this._onOperationsChanged.bind(this)),this._channel.onOpen((function(){n._isConnected=!0,n._sendConfiguration()})),this._channel.onClose(this._onDisconnect.bind(this)),this._channel.onError(this._onDisconnect.bind(this)))}},v.prototype._connect=function(){this._getServicePort(this._connectToPort.bind(this))},v.prototype.shutdown=function(){this._onDisconnect()},v.prototype._onDisconnect=function(){this._channel&&(this._channel.shutdown(),this._channel=void 0),this._isConnected=!1,this._collectionManager.removeAllLibraryCollections()},v.prototype._sendConfiguration=function(){this._channel.send("configure",{CLIENT_DESCRIPTION:p.CLIENT_DESCRIPTION,RENDITION_SIZES:p.RENDITION_SIZES,FULL_RENDITION_CONFIG:p.FULL_RENDITION_CONFIG,LOCAL_SETTINGS:p.LOCAL_SETTINGS})},v.prototype._onEnvironmentInfo=function(e){this._serviceInfo=e,e.whitelistedDomains&&(p.WHITELISTED_DOMAINS=e.whitelistedDomains),e.elementActionProductMap&&E.updateElementActionMap(e.elementActionProductMap),e.deviceId&&(p.DEVICE_ID=e.deviceId),e.deviceDescription&&(p.DEVICE_DESCRIPTION=e.deviceDescription),e.maxElements&&(p.MAX_ELEMENTS=e.maxElements),e.maxRemovedElements&&(p.MAX_REMOVED_ELEMENTS=e.maxRemovedElements),e.maxComponentSize&&(p.MAX_COMPONENT_SIZE=e.maxComponentSize),e.localSettings&&(p.LOCAL_SETTINGS=Object.assign(e.localSettings,p.LOCAL_SETTINGS)),e.shaCache&&(p.SHA_CACHE=e.shaCache),e.defaultContentLocations&&(p.DEFAULT_CONTENT_LOCATIONS=e.defaultContentLocations),e.analyticsEnabled&&(p.ANALYTICS_ENABLED=e.analyticsEnabled),this._collectionManager._collections.forEach((function(e){e._listenerManager.notify("sync")}))},v.prototype._onCollectionAdded=function(e){var t=this;p.ROOT_DIR=e.rootDir;var n,o=new f,i={USER_ID:e.userId,CLOUD_ID:e.cloudId,CLOUD_INFO:e.cloudInfo,STORAGE_HOSTNAME:e.storageHost,COLLABORATION_HOSTNAME:e.collaborationHost,CC_IMAGE_HOSTNAME:e.imageHost,CC_IMAGE_X_HOSTNAME:e.imageXHost,TYPEKIT_HOSTNAME:e.typekitHost,REQUIRES_COMMUNITY_SESSION:e.requiresCommunitySession};n=e.isPublic?new a(i):new r(i),e.libraries.forEach((function(e){o.addOperation(t.loadExistingLibrary,[n,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache],t)})),o.run((function(){t._collectionManager.addLibraryCollection(n)}))},v.prototype._getLibraryCollection=function(e){return e.isPublic?this._collectionManager.getPublicLibraryCollection(e.cloudId):this._collectionManager.getLibraryCollection(e.userId,e.cloudId)},v.prototype._onCollectionRemoved=function(e){var t=this._getLibraryCollection(e);t&&this._collectionManager.removeLibraryCollection(t)},v.prototype._onClearCollections=function(){this._collectionManager.removeAllLibraryCollections()},v.prototype._onSyncState=function(e){var t=this._getLibraryCollection(e);t&&(t._syncState=e.state,t._syncProgress=e.progress,t._syncProgressMap=e.progressMap,t._externalLinkDownloadProgressMap=e.externalLinkDownloadProgressMap||{},t._newLibraryProgress=e.newLibraryProgress,t._initialSyncInProgress=e.initialSyncInProgress,t._syncErrors=[],e.errors.forEach((function(e){t._syncErrors.push(new l(e.code,e.message,e.libraryId))})),e.libraryStates.forEach((function(e){var n=t.getLibraryById(e.id);n&&(n._syncState=e.state)})),t._listenerManager.notify("sync"))},v.prototype._onLibraryChange=function(e){var t=this._getLibraryCollection(e);if(t){var n=t.getLibraryById(e.id);n?(d.log("onLibraryChange: "+n.id),n._deletedFromServer!==e.deletedFromServer&&(n._deletedFromServer=e.deletedFromServer,n._notifyChange()),e.renditionCache=e.renditionCache||{},n._renditionCache.replaceCache(e.renditionCache),this.updateExistingLibrary(t,n,e.manifest,void 0,this._getBase(n.id),(function(){n._renditionCache.replaceCache(e.renditionCache)}))):this.loadExistingLibrary(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache)}},v.prototype._onRenditionCacheChange=function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id),o=n&&n.getElementById(e.elementId);o&&e.renditionCache&&(n._renditionCache.replaceElementCache(o,e.renditionCache),o._listenerManager.notify("change"))},v.prototype._onOperationsChanged=function(e){var t=this._getLibraryCollection(e),n={};e.operations.forEach((function(e){t._updateOperation(e.id,e.type,e.data,e.progress),n[e.id]=!0})),Object.keys(t._operationIdMap).forEach((function(e){n[e]||t._delayedRemoveOperation(t._operationIdMap[e])}))},v.prototype._onLibraryDeleted=function(e){var t=this._getLibraryCollection(e);t&&this._deleteLibrary(t,e.id)},v.prototype._onBookmarksChanged=function(e){var t=this._getLibraryCollection(e);if(t&&e.bookmarks){var n=[];e.bookmarks.forEach((function(e){n.push(new c(e._id,e._url))})),t._bookmarkManager._bookmarks=n}},v.prototype._onFontCacheChanged=function(e){var t=this._getLibraryCollection(e);t&&t.fontManager&&t.fontManager._clearCache()},v.prototype.isConnected=function(){return this._isConnected},v.prototype.reconnect=function(){this._channel||this._connect()},v.prototype.getServiceInfo=function(){return this._serviceInfo?{updateRequired:this._serviceInfo.updateRequired,version:this._serviceInfo.codeVersion,buildNumber:this._serviceInfo.buildNumber,apiVersion:this._serviceInfo.version,environment:this._serviceInfo.environment,syncingEnabled:this._serviceInfo.syncingEnabled,portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}:{portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}},v.prototype.updateConfiguration=function(){p.SHARED_LOCAL_STORAGE&&this._channel&&this._isConnected&&this._sendConfiguration()},v.prototype.sync=function(e){this._channel.send("sync",A(e))},v.prototype.setSyncEnabled=function(e){this._channel.send("configuresync",{enable:e})},v.prototype.commitManifest=function(e,t){var n=this;if(p.SHARED_LOCAL_STORAGE){var o=e._dcxBranch.localData,i=e._renditionCache.doRequestSetCache(),r=C(e);r.current=o,r.base=this._getBase(e.id),r.renditions=i.data,d.log("Start commit"),this._channel.call("commit",r,(function(a){d.log("Finish commit: "+(a.success?"success":"fail")),a.success?(d.log("Update base after commit"),n._setBase(e.id,o),a.renditions&&i.complete(a.renditions).forEach((function(e){return e._listenerManager.notify("change")}))):(i.cancel(),e._waitForCommit((function(){n.notifyStartWrite(e,[],(function(){e._deletedFromServer=a.deletedFromServer,n.updateExistingLibrary(e.collection,e,a.manifest,void 0,r.base,(function(){e._commit(!0,!0)}))}))}))),t(null,a.success)}))}else e._dcxLock.obtain((function(){e._gcLocalData((function(){e._dcxComposite.commitChanges((function(n){e._dcxLock.release(),e._renditionCache.gc(),t(n,!0)}))}))}))},v.prototype.resolvePullWithBranch=function(e,t,n,o,i){d.log("resolvePullWithBranch"),p.SHARED_LOCAL_STORAGE?(e._dcxComposite._current=t,this._setBase(e.id,n),d.log("Finished resolvePullWithBranch: shared local storage"),i()):o?e._dcxLock.obtain((function(){e._dcxComposite._current=t,e._dcxLock.release(),d.log("Finished resolvePullWithBranch: local merge"),i()})):e._dcxLock.obtain((function(){e._dcxComposite.resolvePullWithBranch(t,(function(t,n){e._dcxLock.release(),e._commit(!0,!0),e._waitForCommit((function(){d.log("Finished resolvePullWithBranch: remote merge"),i(t,n)}))}))}))},v.prototype.acceptPush=function(e,t){var n=this;d.log("acceptPush"),e._dcxLock.obtain((function(){e._dcxComposite.acceptPush((function(o){e._dcxLock.release(),d.log("Finished acceptPush"),n._acceptPushedBranchListeners.forEach((function(t){t(e)})),t(o)}))}))},v.prototype.onAcceptPushedBranch=function(e){this._acceptPushedBranchListeners.push(e)},v.prototype.removeOnAcceptPushedBranchListeners=function(){this._acceptPushedBranchListeners=[]},v.prototype._deleteLibrary=function(e,t){d.log("deleteLibrary");var n=e.getLibraryById(t);if(n){var o=e._libraries.indexOf(n);-1!==o&&(e._libraries.splice(o,1),delete e._libraryIdMap[n.id]),n._markDeletedLocally(!0),e._notifyChange(!0)}},v.prototype._loadBranch=function(e,t,n){var o;try{(o=new i(void 0,n).parse(t))._localStorage=e._localStorage}catch(e){}return o},v.prototype._addLibrary=function(e,t,n,i,r){n=n||e._getCompositeDir(t);var a=new o(null,null,n,null,null,{preserveFileExtensions:!0}),c=this._loadBranch(a,i,!1);if(c)if("pendingDelete"!==c.compositeState){a._current=c,this._setBase(t,i);var p=new s(e,a,e.isPublic&&t);e._libraries.push(p),e._libraryIdMap[p.id]=p,e._notifyChange(!0),r(null,p)}else r(null);else r(new l(l.CORRUPTED_LIBRARY,"Library corrupted in local storage",t))},v.prototype.createNewLibrary=function(e,t,n,o){var i=y.wrapCallback(o);d.log("createNewLibrary"),this._addLibrary(e,t,void 0,n,(function(e,t){!e&&t?(t._commit(!1,!0),t._waitForCommit(i)):i(e)}))},v.prototype.loadExistingLibrary=function(e,t,n,o,i,r,a){var s=y.wrapCallback(a);d.log("loadExistingLibrary"),this._addLibrary(e,t,void 0,o,(function(e,t){!e&&t?(t._deletedFromServer=i,r&&t._renditionCache.replaceCache(r),s(null,t)):s(e)}))},v.prototype.updateExistingLibrary=function(e,t,n,o,i,r){var a=this,s=y.wrapCallback(r),c="updateExistingLibrary["+this._getLogIndex()+"]: ";if(m.areManifestsEqual(t._dcxBranch.localData,n))return d.log(c+"already up-to-date"),void s();var h=this._loadBranch(t._dcxComposite,n,!1);if(d.log(c+"changes to update (state = "+(h&&h.compositeState)+")"),h){var u=m.ensureBranchDataValid(h);d.log(c+"fixed branch data: "+u),"pendingDelete"===h.compositeState?(e._doRemoveLibrary(t),s()):t._waitForCommit((function(){if(o){if(!m.areManifestsEqual(t._dcxBranch.localData,o))return d.log(c+"Commit aborting: something changed and it's no longer a fast-forward"),void s(!0)}else o=a._getBase(t.id);if(i&&o!==i)return d.log(c+"Commit aborting: base manifest changed before we got chance to update!"),void s(!0);var e=a._loadBranch(t._dcxComposite,o,!0)||h;d.log(c+"base "+e.changeCount+" -> updated "+h.changeCount),t._mergeAndSwitchToBranch(h,e,(function(){d.log(c+"finished merge"),p.SHARED_LOCAL_STORAGE?s(null):(t._commit(!1,!0),t._waitForCommit(s))}))}))}else s(new l(l.CORRUPTED_LIBRARY,"Invalid manifest",t.id))},v.prototype.getRenditionPath=function(e,t,n,o){o=o||0;var i=this,r=y.wrapCallback(n),a=e.library._renditionCache.getCache(e,t||"full");if(a)r(null,a);else{var s=O(e);s.size=t,d.log("Get rendition path from CCLibrary process"),this._channel.call("getrenditionpath",s,(function(a){if(!a&&o<p.LOCAL_RENDITION_MAX_RETRIES)return d.log("getrenditionpath: rendition not found"),void setTimeout((function(){i.getRenditionPath(e,t,n,o+1)}),p.LOCAL_RENDITION_RETRY_INTERVAL);r(null,a)}))}},v.prototype.notifyDownloadRendition=function(e){this._downloadRenditionListeners.forEach((function(t){t(e)})),e._listenerManager.notify("change")},v.prototype.onDownloadRendition=function(e){this._downloadRenditionListeners.push(e)},v.prototype.removeOnDownloadRenditionListeners=function(){this._downloadRenditionCacheListeners=[]},v.prototype.notifyStartWrite=function(e,t,n){var o=y.wrapCallback(n);if(p.SHARED_LOCAL_STORAGE){var i=C(e);i.dependencies=[],t.forEach((function(e){i.dependencies.push(C(e))})),this._channel.call("startcomponentwrite",i,(function(){o(null)}))}else o(null)},v.prototype.loadPublicLibrary=function(e,t,n,o){var i=y.wrapCallback(o),r=A(e);r.id=t,r.url=n,this._channel.call("loadpubliclibrary",r,(function(){i(null)}))},v.prototype.unloadPublicLibrary=function(e,t){var n=y.wrapCallback(t),o=C(e);this._channel.call("unloadpubliclibrary",o,(function(){n(null)}))},v.prototype.getAssetFromURL=function(e,t,n,o,i){if(p.SHARED_LOCAL_STORAGE){var r=A(e);r.url=t,r.headers=n,r.tempDir=o,this._channel.call("downloadfile",r,(function(e){i(e.err,e.tempFilePath,e.etag,{headers:e.responseHeaders})}))}else e._syncManager.getAssetFromURL(t,n,o,void 0,i)},v.prototype.doHeadRequestOfURL=function(e,t,n){p.SHARED_LOCAL_STORAGE?n(null):e._syncManager.doHeadRequestOfURL(t,n)},v.prototype.downloadExternalLink=function(e,t){d.log("Download external link from CCLibrary process"),this._channel.call("downloadexternallink",L(e),(function(e){t(e.err,e.path)}))},v.prototype.testExternalLink=function(e,t){d.log("Test external link via CCLibrary process"),this._channel.call("testexternallink",L(e),(function(e){t(e.err,e.success)}))},v.prototype.clearCachedExternalLink=function(e){d.log("Clear cached external link via CCLibrary process"),this._channel.send("clearcachedexternallink",L(e))},v.prototype.createBookmark=function(e,t,n,o){var i=y.wrapCallback(o),r=A(e);r.id=t,r.url=n,this._channel.call("createBookmark",r,(function(e){var t=e&&e.err,n=e&&e.bookmark;n&&(n=new c(n._id,n._url)),i(t,n)}))},v.prototype.removeBookmark=function(e,t,n){var o=y.wrapCallback(n),i=A(e);i.id=t.id,this._channel.call("removeBookmark",i,(function(e){o(e)}))},v.prototype.sendElementAction=function(e,t){var n=y.wrapCallback(t),o=O(e.element,"elementId","libraryId");o.appCode=e.appCode,o.minVersion=e.minAppVersion,o.action=e.id,this._channel.call("performElementAction",o,(function(e){n(e.err,e.data)}))},v.prototype.getImageDimensions=function(e,t){this._channel.call("getImageDimensions",e,(function(e){t(e.data)}))},v.prototype.importLibrary=function(e,t,n,o){var i=y.wrapCallback(o),r=A(e);r.path=t,r.operationId=n,this._channel.call("importlibrary",r,(function(t){i(t.err,e.getLibraryById(t.libraryId))}))},v.prototype.exportLibrary=function(e,t,n,o){var i=y.wrapCallback(o),r=C(e);r.path=t,r.operationId=n,this._channel.call("exportlibrary",r,(function(e){i(e.err)}))},v.prototype.cancelOperation=function(e,t){var n=A(e);n.operationId=t,this._channel.send("canceloperation",n)},v.prototype.getFontData=function(e,t,n){var o=y.wrapCallback(n),i=A(e);i.fontId=t,this._channel.call("getfontdata",i,(function(e){o(e.err,e.data)}))},v.prototype.isFontAvailable=function(e,t,n){var o=y.wrapCallback(n),i={fontName:e,matchFamily:t};this._channel.call("isfontavailable",i,(function(e){var t=e.err,n=e.data;return o(t,n)}))},v.prototype.getAccessToken=function(e,t,n,o,i){var r=y.wrapCallback(i),a={userId:e,clientId:t,clientSecret:n,scopes:o};this._channel.call("getaccesstoken",a,(function(e){var t=e.err,n=e.data;return r(t,n)}))},v.prototype.computeSHA=function(e){var t=this;return p.SHARED_LOCAL_STORAGE?new Promise((function(n,o){t._channel.call("computesha",{path:e},(function(e){var t=e.err,i=e.data;return t?o(t):n(i)}))})):g.computeSHA(e)},Object.freeze(v),Object.seal(v.prototype),e.exports=v},function(e,t,n){var o=n(0),i=n(9);function r(e){this._socket=e,this._listenerManager=new i,this._socketListenerManager=new i,this._pendingWriteState={},this._pendingWriteDependencyMap={},this._init()}function a(e){return e+"_req"}function s(e){return e+"_res"}function c(e,t,n){return e+"#"+t+"#"+n}r.prototype._init=function(){var e=this;this._addSocketListener("message",(function(t){var n=JSON.parse(t);e._logReceive(n.type),e._listenerManager.notify(n.type,[n.data])}))},r.prototype._addSocketListener=function(e,t){this._socketListenerManager.add(e,t),this._socket.addListener(e,t)},r.prototype._removeSocketListeners=function(){var e=this;this._socketListenerManager.forEach((function(t,n){e._socket.removeListener(t,n)})),this._socketListenerManager.removeAll()},r.prototype._logSend=function(e){this._logCallback&&this._logCallback("SEND "+e)},r.prototype._logReceive=function(e){this._logCallback&&this._logCallback("RECEIVE "+e)},r.prototype._logError=function(e){this._logCallback&&this._logCallback("ERROR "+e)},r.prototype.setPendingWriteState=function(e,t,n){var o=c(e,t,n);this._pendingWriteState[o]=!0},r.prototype.setPendingWriteDependency=function(e,t,n,o,i,r){var a=c(e,t,n),s=c(o,i,r);a!==s&&(this._pendingWriteDependencyMap[a]=this._pendingWriteDependencyMap[a]||{},this._pendingWriteDependencyMap[a][s]={userId:o,cloudId:i,id:r})},r.prototype.clearPendingWriteState=function(e,t,n){var o=c(e,t,n),i=[];return Object.keys(this._pendingWriteDependencyMap[o]||{}).forEach((function(e){i.push(this._pendingWriteDependencyMap[o][e])}),this),delete this._pendingWriteState[o],delete this._pendingWriteDependencyMap[o],i},r.prototype.getPendingWriteState=function(e,t,n,o){var i=c(e,t,n),r=!1;return!o&&this._pendingWriteState[i]&&(r=this._pendingWriteState[i]),Object.keys(this._pendingWriteDependencyMap).forEach((function(e){this._pendingWriteDependencyMap[e][i]&&(r=this._pendingWriteState[e]||r)}),this),r},r.prototype.setLogCallback=function(e){this._logCallback=e},r.prototype.addListener=function(e,t){this._listenerManager.add(e,t)},r.prototype.removeListener=function(e,t){this._listenerManager.remove(e,t)},r.prototype.send=function(e,t){try{this._logSend(e),this._socket.send(JSON.stringify({type:e,data:t}))}catch(e){this._logError(e),this._socketListenerManager.notify("error",[e])}},r.prototype.addCallListener=function(e,t){var n=this;this.addListener(a(e),(function(o){var i=o.id;t(o.data,(function(t){n.send(s(e),{id:i,data:t})}))}))},r.prototype.removeCallListener=function(e,t){this.removeListener(a(e),t)},r.prototype.call=function(e,t,n){var i=this,r=o.uuid();this.addListener(s(e),(function t(o){o.id===r&&(i.removeListener(s(e),t),n(o.data))})),this.send(a(e),{id:r,data:t})},r.prototype.onOpen=function(e){this._addSocketListener("open",e)},r.prototype.onClose=function(e){this._addSocketListener("close",e)},r.prototype.onError=function(e){this._addSocketListener("error",e)},r.prototype.shutdown=function(){var e=this;this._addSocketListener("close",(function(){e._removeSocketListeners(),e._listenerManager.removeAll()})),this._socket.close()},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(1),i=n(9);function r(e,t,n){var r=n?"wss://".concat(n,":").concat(e):"ws://127.0.0.1:".concat(e);r+="/?version=".concat(o.SHARED_LOCAL_STORAGE_VERSION),t&&(r+="&token=".concat(t)),this._socket=new WebSocket(r),this._socket.onopen=this._onSocketOpen.bind(this),this._socket.onclose=this._onSocketClose.bind(this),this._socket.onmessage=this._onSocketMessage.bind(this),this._socket.onerror=this._onSocketError.bind(this),this._listenerManager=new i(["open","close","message","error"])}r.prototype._onSocketOpen=function(){this._listenerManager.notify("open")},r.prototype._onSocketClose=function(){this._listenerManager.notify("close")},r.prototype._onSocketMessage=function(e){this._listenerManager.notify("message",[e.data])},r.prototype._onSocketError=function(e){this._listenerManager.notify("error",[e])},r.prototype.send=function(e){this._socket.send(e)},r.prototype.addListener=function(e,t){this._listenerManager.add(e,t)},r.prototype.removeListener=function(e,t){this._listenerManager.remove(e,t)},r.prototype.close=function(){this._socket.close(),this._socket.onopen=void 0,this._socket.onclose=void 0,this._socket.onmessage=void 0,this._socket.onerror=void 0,this._listenerManager.removeAll()},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(2),i=n(8),r={rename:!0,renameSync:!1,ftruncate:!1,ftruncateSync:!1,truncate:!1,truncateSync:!1,chown:!1,chownSync:!1,fchown:!1,fchownSync:!1,lchown:!1,lchownSync:!1,chmod:!1,chmodSync:!1,fchmod:!1,fchmodSync:!1,lchmod:!1,lchmodSync:!1,stat:!0,lstat:!1,fstat:!1,statSync:!1,lstatSync:!1,fstatSync:!1,link:!1,linkSync:!1,symlink:!1,symlinkSync:!1,readlink:!1,readlinkSync:!1,realpath:!1,realpathSync:!1,unlink:!0,unlinkSync:!1,rmdir:!0,rmdirSync:!1,mkdir:!0,mkdirSync:!1,readdir:!0,readdirSync:!1,close:!1,closeSync:!1,open:!1,openSync:!1,utimes:!0,utimesSync:!1,futimes:!1,futimesSync:!1,fsync:!1,fsyncSync:!1,write:!1,writeSync:!1,read:!1,readSync:!1,readFile:!0,readFileSync:!1,writeFile:!0,writeFileSync:!1,appendFile:!1,appendFileSync:!1,watchFile:!1,unwatchFile:!1,watch:!1,exists:!0,existsSync:!1,createReadStream:!1,createWriteStream:!1};function a(e){this._storageInterface=e}a.prototype._fsCall=function(e,t,n){var o=i.wrapCallback(n),r={method:e,args:t};this._storageInterface._channel.call("fscall",r,(function(e){o.apply(null,e)}))},a.prototype._pipeCall=function(e,t,n,o){var r=i.wrapCallback(o),a={readStream:{path:e,options:t},writeStream:n};this._storageInterface._channel.call("fspipe",a,r)},Object.keys(r).forEach((function(e){a.prototype[e]=r[e]?function(){var t,n=Array.prototype.slice.call(arguments);"function"==typeof n[n.length-1]&&(t=n.pop()),this._fsCall(e,n,t)}:function(){var t=new o(o.NOT_IMPLEMENTED,e+" is not implemented in shared local storage"),n=arguments[arguments.length-1];if("function"!=typeof n)throw t;n(t)}})),a.prototype.createReadStream=function(e){var t=this,n={on:function(e,t){n[e]=t},pipe:function(o,i){t._pipeCall(e,i,o,(function(e){n[e.event]&&n[e.event].apply(null,e.args)}))}};return n},a.prototype.createWriteStream=function(e,t){return{path:e,options:t}},Object.freeze(a),Object.seal(a.prototype),e.exports=a},function(e,t,n){var o=n(0),i=n(15),r=n(16),a=n(5),s={mimeTypeToExtensions:function(e){return i.getExtensions(e)},extensionToMimeTypes:function(e){return i.getMimeTypes(e)},canGenerateRenditionFromMimeType:function(e){return r.canComputeRenditionFromMimeType(e)},generateUuid:function(){return o.uuid()},copyFile:function(e,t,n,i){if(n)return a.copyFile(e,t,i);var r=o.getFileNameFromPath(t);a.getAvailablePath(t.substring(0,t.indexOf(r)),r,(function(t,n){t?i(t):a.copyFile(e,n,i)}))},getFileSize:function(e,t){a.statFile(e,(function(e,n){t(e,n&&n.size)}))}};Object.seal(s),e.exports=s},function(e,t,n){var o=n(11),i={reportUseElement:function(e,t,n){o.reportUseElement(e,t,n)},reportCheckoutElement:function(e,t,n){o.reportCheckoutElement(e,t,n)},reportCreateLink:function(e,t){o.reportCreateLink(e,t)},reportShareElementLink:function(e){o.reportShareElementLink(e)},reportShareLibraryLink:function(e){o.reportShareLibraryLink(e)}};Object.seal(i),e.exports=i}])}).call(this,n("HDXh").Buffer)}}]);