//>>built
define("dojox/gfx/_gfxBidiSupport","./_base dojo/_base/lang dojo/_base/sniff dojo/dom dojo/_base/html dojo/_base/array ./utils ./shape ./path dojox/string/BidiEngine".split(" "),function(b,k,n,r,p,t,h,g,w,u){function q(a,d){var e=m(d);e&&b.utils.forEach(a,function(c){if(c instanceof b.Surface||c instanceof b.Group)c.textDir=e;c instanceof b.Text&&c.setShape({textDir:e});c instanceof b.TextPath&&c.setText({textDir:e})},a);return a}function m(a){var d=["ltr","rtl","auto"];return a&&(a=a.toLowerCase(),
0>t.indexOf(d,a))?null:a}k.getObject("dojox.gfx._gfxBidiSupport",!0);switch(b.renderer){case "vml":b.isVml=!0;break;case "svg":b.isSvg=!0;b.svg.useSvgWeb&&(b.isSvgWeb=!0);break;case "silverlight":b.isSilverlight=!0;break;case "canvas":case "canvasWithEvents":b.isCanvas=!0}var f=new u;k.extend(b.shape.Surface,{textDir:"",setTextDir:function(a){q(this,a)},getTextDir:function(){return this.textDir}});k.extend(b.Group,{textDir:"",setTextDir:function(a){q(this,a)},getTextDir:function(){return this.textDir}});
k.extend(b.Text,{textDir:"",formatText:function(a,d){if(d&&a&&1<a.length){var e="ltr",c=d;if("auto"==c){if(b.isVml)return a;c=f.checkContextual(a)}if(b.isVml)return e=f.checkContextual(a),c!=e?"rtl"==c?f.hasBidiChar(a)?"\u200f\u200f"+a:f.bidiTransform(a,"IRNNN","ILNNN"):"\u200e"+a:a;if(b.isSvgWeb)return"rtl"==c?f.bidiTransform(a,"IRNNN","ILNNN"):a;if(b.isSilverlight)return"rtl"==c?f.bidiTransform(a,"IRNNN","VLYNN"):f.bidiTransform(a,"ILNNN","VLYNN");if(b.isCanvas)return"rtl"==c?"\u202b"+a+"\u202c":
"\u202a"+a+"\u202c";if(b.isSvg)return 4>n("ff")?"rtl"==c?f.bidiTransform(a,"IRYNN","VLNNN"):f.bidiTransform(a,"ILYNN","VLNNN"):"\u200e"+("rtl"==c?"\u202b":"\u202a")+a+"\u202c"}return a},bidiPreprocess:function(a){return a}});k.extend(b.TextPath,{textDir:"",formatText:function(a,d){if(d&&a&&1<a.length){var e="ltr",c=d;if("auto"==c){if(b.isVml)return a;c=f.checkContextual(a)}if(b.isVml)return e=f.checkContextual(a),c!=e?"rtl"==c?f.hasBidiChar(a)?"\u200f\u200f"+a:f.bidiTransform(a,"IRNNN","ILNNN"):"\u200e"+
a:a;if(b.isSvgWeb)return"rtl"==c?f.bidiTransform(a,"IRNNN","ILNNN"):a;b.isSvg&&(a=n("opera")||4<=n("ff")?"\u200e"+("rtl"==c?"\u202b":"\u202a")+a+"\u202c":"rtl"==c?f.bidiTransform(a,"IRYNN","VLNNN"):f.bidiTransform(a,"ILYNN","VLNNN"))}return a},bidiPreprocess:function(a){a&&"string"==typeof a&&(this.origText=a,a=this.formatText(a,this.textDir));return a}});h=function(a,d,e,c){var v=a.prototype[d];a.prototype[d]=function(){var l;e&&(l=e.apply(this,arguments));l=v.call(this,l);c&&(l=c.call(this,l,arguments));
return l}};g=function(a){a&&(a.textDir&&(a.textDir=m(a.textDir)),a.text&&a.text instanceof Array&&(a.text=a.text.join(",")));!a||void 0==a.text&&!a.textDir||this.textDir==a.textDir&&a.text==this.origText||(this.origText=void 0!=a.text?a.text:this.origText,a.textDir&&(this.textDir=a.textDir),a.text=this.formatText(this.origText,this.textDir));return this.bidiPreprocess(a)};h(b.Text,"setShape",g,null);h(b.TextPath,"setText",g,null);g=function(a){(a=k.clone(a))&&this.origText&&(a.text=this.origText);
return a};h(b.Text,"getShape",null,g);h(b.TextPath,"getText",null,g);g=function(a,d){var e;d&&d[0]&&(e=m(d[0]));a.setTextDir(e?e:this.textDir);return a};h(b.Surface,"createGroup",null,g);h(b.Group,"createGroup",null,g);g=function(a){if(a){var d=a.textDir?m(a.textDir):this.textDir;d&&(a.textDir=d)}return a};h(b.Surface,"createText",g,null);h(b.Surface,"createTextPath",g,null);h(b.Group,"createText",g,null);h(b.Group,"createTextPath",g,null);b.createSurface=function(a,d,e,c){d=b[b.renderer].createSurface(a,
d,e);c=m(c);if(b.isSvgWeb)return d.textDir=c?c:p.style(r.byId(a),"direction"),d;if(b.isVml||b.isSvg||b.isCanvas)d.textDir=c?c:p.style(d.rawNode,"direction");b.isSilverlight&&(d.textDir=c?c:p.style(d._nodes[1],"direction"));return d};return b});