/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../chunks/_rollupPluginBabelHelpers","./materialKey/MaterialKey"],(function(e,n){"use strict";function t(e,n,t,...o){n<e.length?e.splice(n,t,...o):e.push(...o)}let o=function(){function o(){this.symbolLevels=[]}var u=o.prototype;return u.replay=function(e,t,o){for(const i of this.symbolLevels)for(const r of i.zLevels){const i=r.geometryDPInfo.unified;if(i)for(const r of i){const{geometryType:i,materialKey:l,indexFrom:s,indexCount:u}=r,m=n.MaterialKeyBase.load(l).symbologyType,y=e.painter.getBrush(i,m),d={geometryType:i,materialKey:l,indexFrom:s,indexCount:u,target:t.getGeometry(i)};y.prepareState(e,t),y.drawGeometry(e,t,d,o)}}},u.clear=function(){this.symbolLevels.length=0},u.addToList=function(e,n){if(Array.isArray(e))for(const t of e)this._addToList(t,n);else this._addToList(e,n)},u.removeFromList=function(e){Array.isArray(e)||(e=[e]);let n=null;for(const t of e)n=this._removeFromList(t);return n},u.clone=function(){const e=new o;for(const n of this.symbolLevels)e.symbolLevels.push(n.clone());return e},u.splitAfter=function(e){const n=this._getDisplayList(e.symbolLevel,e.zOrder),t=n.length,o=e.indexFrom+e.indexCount;for(let r=0;r<t;++r){const t=n[r];if(t.geometryType===e.geometryType&&o>t.indexFrom&&o<=t.indexFrom+t.indexCount){if(o<t.indexFrom+t.indexCount){const e=new i;e.geometryType=t.geometryType,e.materialKey=t.materialKey,e.indexFrom=o,e.indexCount=t.indexFrom+t.indexCount-o,n.splice(r+1,0,e),t.indexCount=o-t.indexFrom}return r}}},u._addToList=function(e,n){const o=e.symbolLevel,r=e.zOrder,l=this._getDisplayList(o,r),s=null!=n?n:l.length-1,u=s>=0&&s<l.length?l[s]:null;if(null!==u&&u.materialKey===e.materialKey&&u.indexFrom+u.indexCount===e.indexFrom&&u.geometryType===e.geometryType)u.indexCount+=e.indexCount;else{const n=new i;n.indexFrom=e.indexFrom,n.indexCount=e.indexCount,n.materialKey=e.materialKey,n.geometryType=e.geometryType,t(l,s+1,0,n)}},u._removeFromList=function(e){const n=e.symbolLevel,o=e.zOrder,r=this._getDisplayList(n,o),l=r.length;let s;for(let t=0;t<l;++t){const n=r[t];if(e.indexFrom+e.indexCount>n.indexFrom&&e.indexFrom<n.indexFrom+n.indexCount&&n.geometryType===e.geometryType){s=t;break}}if(void 0!==s){const n=r[s];if(e.indexFrom===n.indexFrom)return n.indexCount-=e.indexCount,n.indexFrom+=e.indexCount,0===n.indexCount&&t(r,s,1),s-1;if(e.indexFrom+e.indexCount===n.indexFrom+n.indexCount)return n.indexCount-=e.indexCount,0===n.indexCount?(t(r,s,1),s-1):s;{const o=n.indexFrom,l=e.indexFrom-n.indexFrom,u=e.indexCount,m=n.indexFrom+n.indexCount-(e.indexFrom+e.indexCount);n.indexCount=l;const y=new i;return y.geometryType=n.geometryType,y.materialKey=n.materialKey,y.indexFrom=o+l+u,y.indexCount=m,t(r,s+1,0,y),s}}return null},u._getDisplayList=function(e,n){let t;const o=this.symbolLevels.length;for(let r=0;r<o;r++)if(this.symbolLevels[r].symbolLevel===e){t=this.symbolLevels[r];break}let i;t||(t=new s,t.symbolLevel=e,this.symbolLevels.push(t));const u=t.zLevels.length;for(let r=0;r<u;r++)if(t.zLevels[r].zLevel===n){i=t.zLevels[r];break}return i||(i=new l,i.geometryDPInfo=new r,i.zLevel=n,t.zLevels.push(i)),i.geometryDPInfo.unified||(i.geometryDPInfo.unified=[]),i.geometryDPInfo.unified},u.getDPInfoType=function(){return"unified"},e._createClass(o,[{key:"empty",get:function(){return!this.symbolLevels||0===this.symbolLevels.length}}]),o}(),i=function(){function e(){this.materialKey=null,this.indexFrom=0,this.indexCount=0}return e.prototype.clone=function(){const n=new e;return n.geometryType=this.geometryType,n.materialKey=this.materialKey,n.indexFrom=this.indexFrom,n.indexCount=this.indexCount,n},e}(),r=function(){function e(){this.fill=null,this.line=null,this.marker=null,this.text=null,this.label=null,this.unified=null}return e.prototype.clone=function(){const n=new e;return n.fill=this.fill&&this.fill.map((e=>e.clone())),n.line=this.line&&this.line.map((e=>e.clone())),n.marker=this.marker&&this.marker.map((e=>e.clone())),n.text=this.text&&this.text.map((e=>e.clone())),n.label=this.label&&this.label.map((e=>e.clone())),n.unified=this.unified&&this.unified.map((e=>e.clone())),n},e}(),l=function(){function e(){this.geometryDPInfo=new r}return e.prototype.clone=function(){const n=new e;return n.zLevel=this.zLevel,n.geometryDPInfo=this.geometryDPInfo.clone(),n},e}(),s=function(){function e(){this.zLevels=[]}return e.prototype.clone=function(){const n=new e;n.symbolLevel=this.symbolLevel;for(const e of this.zLevels)n.zLevels.push(e.clone());return n},e}();return o}));
