/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../layers/graphics/dehydratedFeatures","../../../../layers/graphics/dehydratedFeatureComparison"],(function(e,t,s,i){"use strict";let n=function(){function e(e,t){this.highestResolutionVersion=null,this.versions=[],this.ref(e,t)}var s=e.prototype;return s.ref=function(e,t){const s=this.feature;o.oldVersion=s,this.feature&&Object.defineProperty(e,"uid",{value:this.feature.uid,configurable:!0});for(const r of this.versions)if(r.resolution===t){r.refCount++;const t=this.highestResolutionVersion===r&&!i.equals(e,r.feature);return(t||this.highestResolutionVersion!==r)&&(r.feature=e),o.newVersion=t?e:s,o}const n={feature:e,resolution:t,refCount:1};return this.versions.push(n),!this.highestResolutionVersion||t<this.highestResolutionVersion.resolution?(o.newVersion=e,this.highestResolutionVersion=n):o.newVersion=s,o},s.unref=function(e){for(let t=0;t<this.versions.length;t++){const s=this.versions[t];if(s.resolution===e)return s.refCount--,o.oldVersion=this.feature,0===s.refCount&&(this.versions[t]=this.versions[this.versions.length-1],this.versions.length--,this.highestResolutionVersion===s&&(this._recalculateHighestResolutionVersion(),o.oldVersion=s.feature)),o.newVersion=this.feature,o}return null},s._recalculateHighestResolutionVersion=function(){if(0===this.versions.length)return void(this.highestResolutionVersion=null);let e=this.versions[0];for(let t=1;t<this.versions.length;t++){const s=this.versions[t];s.resolution<e.resolution&&(e=s)}this.highestResolutionVersion=e},t._createClass(e,[{key:"isReferenced",get:function(){return 0!==this.versions.length}},{key:"isSingle",get:function(){return 1===this.versions.length&&1===this.versions[0].refCount}},{key:"feature",get:function(){return this.highestResolutionVersion?this.highestResolutionVersion.feature:null}}]),e}(),r=function(){function e(e){this._feature=e,this.refCount=1}var s=e.prototype;return s.ref=function(e){return++this.refCount,o.oldVersion=this._feature,this.feature&&Object.defineProperty(e,"uid",{value:this.feature.uid,configurable:!0}),i.equals(this._feature,e)||(this._feature=e),o.newVersion=this._feature,o},s.unref=function(){return o.oldVersion=this._feature,this.refCount>0&&(this.refCount--,!this.isReferenced)?(o.newVersion=null,o):(o.newVersion=this._feature,o)},t._createClass(e,[{key:"isReferenced",get:function(){return 0!==this.refCount}},{key:"isSingle",get:function(){return 1===this.refCount}},{key:"feature",get:function(){return this._feature}}]),e}();const o={oldVersion:null,newVersion:null};e.MultiFeatureReference=n,e.SingleFeatureReference=r,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
