/*
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","../Collection","../collectionUtils","../HandleOwner","../has","../Logger","../maybe","../accessorSupport/decorators/property","../arrayUtils","../accessorSupport/ensureType","../accessorSupport/decorators/subclass"],(function(e,t,o,n,r,s,i,l,c,a,u,p,_){"use strict";function f(e,t){return{type:e,cast:r.castForReferenceSetter,set(o){const n=r.referenceSetter(o,this._get(t),e);n.owner=this,this._set(t,n)}}}l.getLogger("esri.core.support.OwningCollection"),e.OwningCollection=function(e){function o(t){var o;return(o=e.call(this,t)||this).handles.add([o.on("before-add",(e=>{c.isNone(e.item)&&e.preventDefault()})),o.on("after-add",(e=>o._own(e.item))),o.on("after-remove",(e=>o._release(e.item)))]),o}t._inheritsLoose(o,e);var r=o.prototype;return r._ownAll=function(){for(const e of this.items)this._own(e)},r._releaseAll=function(){for(const e of this.items)this._release(e)},r._createNewInstance=function(e){return this.itemType?new(n.ofType(this.itemType.Type))(e):new n(e)},t._createClass(o,[{key:"owner",get:function(){return this._get("owner")},set:function(e){e!==this._get("owner")&&(this._releaseAll(),this._set("owner",e),this._ownAll())}}]),o}(s.HandleOwnerMixin(n)),o.__decorate([a.property()],e.OwningCollection.prototype,"owner",null),e.OwningCollection=o.__decorate([_.subclass("esri.core.support.OwningCollection")],e.OwningCollection),e.owningCollectionProperty=f,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
