/*
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","../../../chunks/tslib.es6","../../../core/Collection","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../Widget","../css","./LegendItem","../../support/widgetUtils","../../support/jsxFactory"],(function(e,t,i,o,s,r,n,d,c,a,p,l,_,u,h){"use strict";e.Legend=function(e){function i(t,i){var s;return(s=e.call(this,t,i)||this)._items=new o,s._expandedLine=null,s}t._inheritsLoose(i,e);var r=i.prototype;return r.initialize=function(){this.own([s.watch((()=>this.profiles),(e=>{this._destroyItems(),this._items.addMany(e.map((e=>this._createItemForLine(e))))}),s.initial),s.watch((()=>this.effectiveUnits),(e=>{this._items.forEach((t=>{t.effectiveUnits=e}))}),s.initial)])},r.destroy=function(){this._destroyItems()},r.render=function(){return h.tsx("div",{class:l.LEGEND_CSS.base},this._items.toArray().map((e=>e.render())))},r._onExpandedToggle=function(e){this._expandedLine=e===this._expandedLine?null:e,this._items.forEach((e=>e.expanded=e.line===this._expandedLine))},r._createItemForLine=function(e){return new _.LegendItem({line:e,effectiveUnits:this.effectiveUnits,expanded:e===this._expandedLine,checkboxVisible:this.profiles.length>1,onExpandedToggle:()=>this._onExpandedToggle(e)})},r._destroyItems=function(){this._items.drain((e=>e.destroy()))},i}(p),i.__decorate([r.property()],e.Legend.prototype,"profiles",void 0),i.__decorate([r.property()],e.Legend.prototype,"effectiveUnits",void 0),i.__decorate([r.property()],e.Legend.prototype,"_items",void 0),i.__decorate([r.property()],e.Legend.prototype,"_expandedLine",void 0),e.Legend=i.__decorate([a.subclass("esri.widgets.ElevationProfile.Legend")],e.Legend),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
