//>>built
define("dojox/robot/recorder",["dojo","dijit","dojox"],function(d,z,A){d.provide("dojox.robot.recorder");d.experimental("dojox.robot.recorder");(function(){var h=[],w=0,k=null,m=null,g=function(a,b){if(!(null==k||"doh.robot.keyPress"==a&&b[0]==d.keys.ENTER&&eval("("+b[2]+")").ctrl&&eval("("+b[2]+")").alt)){var c=Math.max(Math.min(Math.round((new Date).getTime()-m.getTime()),1E4),1);"doh.robot.mouseMove"==a?b[2]=c:b[1]=c;h.push({name:a,args:b});m=new Date}},x=function(){var a=h;"doh.robot.keyPress"!=
a[0].name||a[0].args[0]!=d.keys.ENTER&&77!=a[0].args[0]||a.splice(0,1);for(var b=a.length-1;b>=a.length-2&&0<=b;b--)("doh.robot.keyPress"==a[b].name&&a[b].args[0]==d.keys.ALT||a[b].args[0]==d.keys.CTRL)&&a.splice(b,1);for(b=0;b<a.length;b++){var c,e;if(a[b+1]&&"doh.robot.mouseMove"==a[b].name&&a[b+1].name==a[b].name&&500>a[b+1].args[2]){c=a[b+1];for(e=0;c&&c.name==a[b].name&&500>c.args[2];)a.splice(b+1,1),e+=c.args[2],a[b].args[0]=c.args[0],a[b].args[1]=c.args[1],c=a[b+1];a[b].args[3]=e}else if(a[b+
1]&&"doh.robot.mouseWheel"==a[b].name&&a[b+1].name==a[b].name&&500>a[b+1].args[1]){c=a[b+1];for(e=0;c&&c.name==a[b].name&&500>c.args[1];)a.splice(b+1,1),e+=c.args[1],a[b].args[0]+=c.args[0],c=a[b+1];a[b].args[2]=e}else if(a[b+2]&&"doh.robot.mouseMoveAt"==a[b].name&&"doh.robot.scrollIntoView"==a[b+2].name)c=a.splice(b+2,1)[0],a.splice(b,0,c);else if(a[b+1]&&"doh.robot.mousePress"==a[b].name&&"doh.robot.mouseRelease"==a[b+1].name&&a[b].args[0]==a[b+1].args[0])a[b].name="doh.robot.mouseClick",a.splice(b+
1,1),a[b+1]&&"doh.robot.mouseClick"==a[b+1].name&&a[b].args[0]==a[b+1].args[0]&&a.splice(b+1,1);else if(a[b+1]&&a[b-1]&&"doh.robot.mouseMoveAt"==a[b-1].name&&"doh.robot.mousePress"==a[b].name&&"doh.robot.mouseMove"==a[b+1].name)a.splice(b+1,0,{name:"doh.robot.mouseMoveAt",args:[a[b-1].args[0],1,100,a[b-1].args[3]+1,a[b-1].args[4]]});else if(a[b+1]&&("doh.robot.keyPress"==a[b].name&&"string"==typeof a[b].args[0]||"doh.robot.typeKeys"==a[b].name)&&"doh.robot.keyPress"==a[b+1].name&&"string"==typeof a[b+
1].args[0]&&1E3>=a[b+1].args[1]&&!eval("("+a[b].args[2]+")").ctrl&&!eval("("+a[b].args[2]+")").alt&&!eval("("+a[b+1].args[2]+")").ctrl&&!eval("("+a[b+1].args[2]+")").alt){a[b].name="doh.robot.typeKeys";a[b].args.splice(3,1);c=a[b+1];for(e=0;c&&"doh.robot.keyPress"==c.name&&"string"==typeof c.args[0]&&1E3>=c.args[1]&&!eval("("+c.args[2]+")").ctrl&&!eval("("+c.args[2]+")").alt;)a.splice(b+1,1),a[b].args[0]+=c.args[0],e+=c.args[1],c=a[b+1];a[b].args[2]=e;a[b].args[0]="'"+a[b].args[0]+"'"}else if("doh.robot.keyPress"==
a[b].name)if("string"==typeof a[b].args[0])a[b].args[0]="'"+a[b].args[0]+"'";else if(0==a[b].args[0])a.splice(b,1);else for(var f in d.keys)if(d.keys[f]==a[b].args[0]){a[b].args[0]="dojo.keys."+f;break}}},y=function(){var a=Math.round((new Date).getTime()-k.getTime());k=null;x();var b=h;console.log("Stop called. Commands: "+b.length);if(b.length){var c;c="doh.register('dojox.robot.AutoGeneratedTestGroup',{\n"+("     name: 'autotest"+w++ +"',\n");c=c+("     timeout: "+(a+2E3)+",\n")+"     runTest: function(){\n          var d \x3d new doh.Deferred();\n";
for(a=0;a<b.length;a++){c+="          "+b[a].name+"(";for(var e=0;e<b[a].args.length;e++)c+=b[a].args[e],e!=b[a].args.length-1&&(c+=", ");c+=");\n"}c+="          doh.robot.sequence(function(){\n";c+="               if(/*Your condition here*/){\n";c+="                    d.callback(true);\n";c+="               }else{\n";c+="                    d.errback(new Error('We got a failure'));\n";c+="               }\n";c+="          }, 1000);\n";c+="          return d;\n";c+="     }\n";c+="});\n";var f=document.createElement("div");
f.id="dojox.robot.recorder";f.style.backgroundColor="white";f.style.position="absolute";b=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;a=window.pageXOffset||(window.dojo?d._fixIeBiDiScrollLeft(document.documentElement.scrollLeft):void 0)||document.body.scrollLeft||0;f.style.left=a+"px";f.style.top=b+"px";b=document.createElement("h1");b.innerHTML="Your code:";f.appendChild(b);b=document.createElement("pre");void 0!==b.innerText?b.innerText=c:b.textContent=c;f.appendChild(b);
c=document.createElement("button");c.innerHTML="Close";var g=d.connect(c,"onmouseup",function(a){d.stopEvent(a);document.body.removeChild(f);d.disconnect(g)});f.appendChild(c);document.body.appendChild(f);h=[]}},l=function(a){if("string"==typeof a)return"'"+a+"'";if(a.id)return"'"+a.id+"'";var b=document.getElementsByTagName(a.nodeName),c;for(c=0;c<b.length&&b[c]!=a;c++);return"function(){ return document.getElementsByTagName('"+a.nodeName+"')["+c+"]; }"},n=function(a){return"{left:"+(0==a)+", middle:"+
(1==a)+", right:"+(2==a)+"}"};d.connect(document,"onkeydown",function(a){(a.keyCode==d.keys.ENTER||77==a.keyCode)&&a.ctrlKey&&a.altKey&&(d.stopEvent(a),k?y():(alert("Started recording."),h=[],k=new Date,m=new Date))});var e={type:""},p=function(a){if(a&&(e.type!=a.type||e.button!=a.button)){e={type:a.type,button:a.button};var b=l(a.target),c=d.coords(a.target);g("doh.robot.mouseMoveAt",[b,0,100,a.clientX-c.x,a.clientY-c.y]);g("doh.robot.mousePress",[n(a.button-(d.isIE?1:0)),0])}},q=function(a){!a||
e.type==a.type&&e.button==a.button||(e={type:a.type,button:a.button},l(a.target),d.coords(a.target),g("doh.robot.mouseClick",[n(a.button-(d.isIE?1:0)),0]))},r=function(a){!a||e.type==a.type&&e.button==a.button||(e={type:a.type,button:a.button},l(a.target),d.coords(a.target),g("doh.robot.mouseRelease",[n(a.button-(d.isIE?1:0)),0]))},t=function(a){!a||e.type==a.type&&e.pageX==a.pageX&&e.pageY==a.pageY||(e={type:a.type,detail:a.detail?a.detail:-a.wheelDelta/120},g("doh.robot.mouseWheel",[e.detail]))},
u=function(a){!a||e.type==a.type&&e.charCode==a.charCode&&e.keyCode==a.keyCode||(e={type:a.type,charCode:a.charCode,keyCode:a.keyCode},g("doh.robot.keyPress",[a.charOrCode==d.keys.SPACE?" ":a.charOrCode,0,"{'shift':"+a.shiftKey+", 'ctrl':"+a.ctrlKey+", 'alt':"+a.altKey+"}"]))},v=function(a){!a||e.type==a.type&&e.charCode==a.charCode&&e.keyCode==a.keyCode||(e={type:a.type,charCode:a.charCode,keyCode:a.keyCode})};d.connect(document,"onmousedown",p);d.connect(document,"onmouseup",r);d.connect(document,
"onclick",q);d.connect(document,"onkeypress",u);d.connect(document,"onkeyup",v);d.connect(document,"onmousemove",function(a){!a||e.type==a.type&&e.pageX==a.pageX&&e.pageY==a.pageY||(e={type:a.type,pageX:a.pageX,pageY:a.pageY},g("doh.robot.mouseMove",[a.pageX,a.pageY,0,100,!0]))});d.connect(document,d.isMozilla?"DOMMouseScroll":"onmousewheel",t);d.addOnLoad(function(){d.window&&d.connect(d.window,"scrollIntoView",function(a){g("doh.robot.scrollIntoView",[l(a)])})});d.connect(d,"connect",function(a,
b,c){!a||c&&c._mine||(c=null,"onmousedown"==b.toLowerCase()?c=d.hitch(this,p):b.toLowerCase()==(d.isMozilla?"dommousescroll":"onmousewheel")?c=d.hitch(this,t):"onclick"==b.toLowerCase()?c=d.hitch(this,q):"onmouseup"==b.toLowerCase()?c=d.hitch(this,r):"onkeypress"==b.toLowerCase()?c=d.hitch(this,u):"onkeyup"==b.toLowerCase()&&(c=d.hitch(this,v)),null!=c&&(c._mine=!0,d.connect(a,b,c)))})})()});