//>>built
define("dojox/wire/Wire",["dojo","dijit","dojox","dojo/require!dojox/wire/_base"],function(d,m,h){d.provide("dojox.wire.Wire");d.require("dojox.wire._base");d.declare("dojox.wire.Wire",null,{_wireClass:"dojox.wire.Wire",constructor:function(b){d.mixin(this,b);if(this.converter)if(d.isString(this.converter)){b=d.getObject(this.converter);if(d.isFunction(b))try{var a=new b;a&&!d.isFunction(a.convert)?this.converter={convert:b}:this.converter=a}catch(c){}else d.isObject(b)&&d.isFunction(b.convert)&&
(this.converter=b);d.isString(this.converter)&&(this.converter=(a=h.wire._getClass(this.converter))?new a:void 0)}else d.isFunction(this.converter)&&(this.converter={convert:this.converter})},getValue:function(b){var a=void 0,a=h.wire.isWire(this.object)?this.object.getValue(b):this.object||b;if(this.property){b=this.property.split(".");for(var c in b){if(!a)return a;a=this._getPropertyValue(a,b[c])}}c=void 0;if(c=this._getValue?this._getValue(a):a)this.type&&("string"==this.type?c=c.toString():"number"==
this.type?c=parseInt(c,10):"boolean"==this.type?c="false"!=c:"array"==this.type&&(d.isArray(c)||(c=[c]))),this.converter&&this.converter.convert&&(c=this.converter.convert(c,this));return c},setValue:function(b,a){var c=void 0,c=h.wire.isWire(this.object)?this.object.getValue(a):this.object||a,e=void 0,f;if(this.property){if(!c)if(h.wire.isWire(this.object))c={},this.object.setValue(c,a);else throw Error(this._wireClass+".setValue(): invalid object");for(var e=this.property.split("."),d=e.length-
1,k=0;k<d;k++){var l=e[k];f=this._getPropertyValue(c,l);f||(f={},this._setPropertyValue(c,l,f));c=f}e=e[d]}if(this._setValue){if(e&&(f=this._getPropertyValue(c,e),f||(f={},this._setPropertyValue(c,e,f)),c=f),f=this._setValue(c,b),!c&&f)if(h.wire.isWire(this.object))this.object.setValue(f,a);else throw Error(this._wireClass+".setValue(): invalid object");}else if(e)this._setPropertyValue(c,e,b);else if(h.wire.isWire(this.object))this.object.setValue(b,a);else throw Error(this._wireClass+".setValue(): invalid property");
},_getPropertyValue:function(b,a){var c=void 0,e=a.indexOf("[");if(0<=e){var f=a.indexOf("]"),f=a.substring(e+1,f),g=null;0===e?g=b:(a=a.substring(0,e),(g=this._getPropertyValue(b,a))&&!d.isArray(g)&&(g=[g]));g&&(c=g[f])}else b.getPropertyValue?c=b.getPropertyValue(a):(c="get"+a.charAt(0).toUpperCase()+a.substring(1),c=this._useGet(b)?b.get(a):this._useAttr(b)?b.attr(a):b[c]?b[c]():b[a]);return c},_setPropertyValue:function(b,a,c){var e=a.indexOf("[");if(0<=e){var f=a.indexOf("]"),f=a.substring(e+
1,f),d=null;0===e?d=b:(a=a.substring(0,e),d=this._getPropertyValue(b,a),d||(d=[],this._setPropertyValue(b,a,d)));d[f]=c}else if(b.setPropertyValue)b.setPropertyValue(a,c);else if(e="set"+a.charAt(0).toUpperCase()+a.substring(1),this._useSet(b))b.set(a,c);else if(this._useAttr(b))b.attr(a,c);else if(b[e])b[e](c);else b[a]=c},_useGet:function(b){var a=!1;d.isFunction(b.get)&&(a=!0);return a},_useSet:function(b){var a=!1;d.isFunction(b.set)&&(a=!0);return a},_useAttr:function(b){var a=!1;d.isFunction(b.attr)&&
(a=!0);return a}})});