//>>built
define("dojox/mvc/ModelRefController",["dojo/_base/array","dojo/_base/declare","dojo/_base/lang","dojo/Stateful","./_Controller"],function(q,v,r,w,x){return v("dojox.mvc.ModelRefController",x,{ownProps:null,_refModelProp:"model",_refInModelProp:"model",model:null,postscript:function(a,b){this._relTargetProp=(a||{})._refModelProp||this._refModelProp;this.inherited(arguments)},get:function(a){if(!this.hasControllerProperty(a)){var b=this[this._refModelProp];return b?b.get?b.get(a):b[a]:void 0}return this.inherited(arguments)},
_set:function(a,b){if(!this.hasControllerProperty(a)){var f=this[this._refModelProp];f&&(f.set?f.set(a,b):f[a]=b);return this}return this.inherited(arguments)},watch:function(a,b){function f(c){h&&h.unwatch();c&&r.isFunction(c.set)&&r.isFunction(c.watch)&&(h=c.watch.apply(c,(a?[a]:[]).concat([function(d,e,g){b.call(k,d,e,g)}])))}function y(c,d){var e={};a?e[a]=1:q.forEach([c,d],function(l){var t=l&&l.get("properties");if(t)q.forEach(t,function(u){k.hasControllerProperty(u)||(e[u]=1)});else for(var n in l)l.hasOwnProperty(n)&&
!k.hasControllerProperty(n)&&(e[n]=1)});for(var g in e)b.call(k,g,c?c.get?c.get(g):c[g]:void 0,d?d.get?d.get(g):d[g]:void 0)}if(this.hasControllerProperty(a))return this.inherited(arguments);b||(b=a,a=null);var m=null,h=null,k=this;m=w.prototype.watch.call(this,this._refModelProp,function(c,d,e){d!==e&&(y(d,e),f(e))});f(this.get(this._refModelProp));var p={};p.unwatch=p.remove=function(){h&&(h.unwatch(),h=null);m&&(m.unwatch(),m=null)};return p},hasControllerProperty:function(a){return"_watchCallbacks"==
a||a==this._refModelProp||a==this._refInModelProp||a in(this.ownProps||{})||a in this.constructor.prototype||/^dojoAttach(Point|Event)$/i.test(a)}})});