"undefined"==typeof EventTypes&&(EventTypes={});EventTypes.OpenUrl=0;EventTypes.Click=1;EventTypes.Change=2;EventTypes.Comment=3;EventTypes.Submit=4;EventTypes.CheckPageTitle=5;EventTypes.CheckPageLocation=6;EventTypes.CheckTextPresent=7;EventTypes.CheckValue=8;EventTypes.CheckValueContains=9;EventTypes.CheckText=10;EventTypes.CheckHref=11;EventTypes.CheckEnabled=12;EventTypes.CheckDisabled=13;EventTypes.CheckSelectValue=14;EventTypes.CheckSelectOptions=15;EventTypes.CheckImageSrc=16;
EventTypes.PageLoad=17;EventTypes.ScreenShot=18;EventTypes.ElementScreenShot=24;EventTypes.MoveCursorToElement=25;EventTypes.PrintElementText=26;EventTypes.SaveElementText=27;EventTypes.ExplicitWait=28;EventTypes.FetchElementText=29;EventTypes.SelectElementOption=30;EventTypes.CancelLastStep=31;EventTypes.NoteDownElement=32;EventTypes.InspectElement=33;EventTypes.Cancel=99;EventTypes.MouseDown=19;EventTypes.MouseUp=20;EventTypes.MouseDrag=21;EventTypes.MouseDrop=22;EventTypes.KeyPress=23;
function CasperRenderer(a){this.document=a;this.title="Automation Flow";this.items=null;this.history=[];this.last_events=[]}CasperRenderer.prototype.text=function(a){this.document.writeln(a)};CasperRenderer.prototype.stmt=function(a,b){void 0==b&&(b=0);a=Array(4*b).join(" ")+a;this.document.writeln(a)};CasperRenderer.prototype.pyrepr=function(a,b){b&&(a=a.replace(/(['"])/g,"\\$1"));return a};CasperRenderer.prototype.space=function(){this.document.write("\n")};
CasperRenderer.prototype.regexp_escape=function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s\/]/g,"\\$&")};CasperRenderer.prototype.cleanStringForXpath=function(a,b){a=a.match(/[^'"]+|['"]/g);a=a.map(function(a){return"'"===a?'"\'"':'"'===a?"'\"'":a});var f="";f=1<a.length?"concat("+a.join(",")+")":a[0];b&&(f=f.replace(/(["])/g,"\\$1"));return f};var d={};d[EventTypes.OpenUrl]="openUrl";d[EventTypes.Click]="click";d[EventTypes.Comment]="comment";d[EventTypes.Submit]="submit";
d[EventTypes.CheckPageTitle]="checkPageTitle";d[EventTypes.CheckPageLocation]="checkPageLocation";d[EventTypes.CheckTextPresent]="checkTextPresent";d[EventTypes.CheckValue]="checkValue";d[EventTypes.CheckText]="checkText";d[EventTypes.CheckHref]="checkHref";d[EventTypes.CheckEnabled]="checkEnabled";d[EventTypes.CheckDisabled]="checkDisabled";d[EventTypes.CheckSelectValue]="checkSelectValue";d[EventTypes.CheckSelectOptions]="checkSelectOptions";d[EventTypes.CheckImageSrc]="checkImageSrc";
d[EventTypes.PageLoad]="pageLoad";d[EventTypes.ScreenShot]="screenShot";d[EventTypes.ElementScreenShot]="elementScreenShot";d[EventTypes.NoteDownElement]="noteDownElement";d[EventTypes.InspectElement]="inspectElement";d[EventTypes.MoveCursorToElement]="moveCursorToElement";d[EventTypes.PrintElementText]="printElementText";d[EventTypes.SaveElementText]="saveElementText";d[EventTypes.FetchElementText]="fetchElementText";d[EventTypes.SelectElementOption]="selectElementOption";
d[EventTypes.ExplicitWait]="explicitWait";d[EventTypes.CancelLastStep]="cancelLastStep";d[EventTypes.Cancel]="cancel";d[EventTypes.MouseDrag]="mousedrag";d[EventTypes.KeyPress]="keypress";CasperRenderer.prototype.dispatch=d;var cc=EventTypes;
CasperRenderer.prototype.render=function(a){this.with_xy=a;a=EventTypes;this.document.open();this.document.write('<pre id="uiflowpanel">');this.document.write('<span style="font-size: 18px">');for(var b=null,f=!1,e=0;e<this.items.length;e++){var c=this.items[e];if(0==e)if(c.type!=a.OpenUrl)this.text("ERROR - steps did not start with opening an url");else{this.startUrl(c);continue}if(c.type==a.MouseDown)b=this.items[e];else if(c.type==a.MouseUp&&b)b.x==c.x&&b.y==c.y?f=!1:(c.before=b,this[this.dispatch[a.MouseDrag]](c),
b=null,f=!0);else if(c.type==a.Click&&f)f=!1;else if(!(0<e&&c.type==a.Click&&(5<=this.items[e-1].type&&16>=this.items[e-1].type||18==this.items[e-1].type||24<=this.items[e-1].type))&&this.dispatch[c.type])this[this.dispatch[c.type]](c)}this.document.write("</span>");this.document.write("</pre>");this.document.write('<input type="button" id="export" value="\u521b\u5efa\u6307\u4ee4\u6d41\u7a0b\u56fe">');this.document.close();var g=null;document.getElementById("export").addEventListener("click",function(){var a=
document.getElementById("uiflowpanel").innerText;page=localStorage.getItem("_debug_uiflow")?"http://test.juguandian.com/rpa4_local.html?uiflow=true":"https://public.juguandian.com/rpa4.html?uiflow=true";var b=window.open(page);g&&window.removeEventListener("message",g);g=function(c){c.source==b&&(console.log("export",a),b.postMessage({uiflow:a},"*"))};window.addEventListener("message",g)})};CasperRenderer.prototype.rewriteUrl=function(a){return a};
CasperRenderer.prototype.shortUrl=function(a){return a.substr(a.indexOf("/",10),999999999)};CasperRenderer.prototype.startUrl=function(a){a=this.pyrepr(this.rewriteUrl(a.url));this.stmt(a)};CasperRenderer.prototype.openUrl=function(a){a=this.pyrepr(this.rewriteUrl(a.url));var b=this.history;a==b[b.length-2]?(this.stmt("this.back();"),b.pop(),b.pop()):this.stmt(a)};CasperRenderer.prototype.pageLoad=function(a){a=this.pyrepr(this.rewriteUrl(a.url));this.history.push(a)};
CasperRenderer.prototype.normalizeWhitespace=function(a){return a.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ")};CasperRenderer.prototype.getControl=function(a){return a.info.selector};
CasperRenderer.prototype.getLinkXPath=function(a){if(a.info.id)var b='@id="'+this.pyrepr(a.info.id)+'"';else a.text?(b=-1==a.text.indexOf("[whitespace]")?'text()="'+this.cleanStringForXpath(a.text,!0)+'"':'contains(text(),"'+this.cleanStringForXpath(a.text.replace(/\[whitespace\]/g,""),!0)+'")',a.info.href&&(b+=' or contains("'+this.pyrepr(a.info.href)+'",@href)')):a.info.href&&(b='contains("'+this.pyrepr(a.info.href)+'",@href)');return b};
CasperRenderer.prototype.click=function(a){var b=a.info.tagName.toLowerCase();this.with_xy&&"a"!=b&&"input"!=b&&"button"!=b?this.stmt("this.mouse.click("+a.x+", "+a.y+");"):(a="a"==b?(b=this.getLinkXPath(a))?"//a["+b+"]":a.info.selector:"input"==b||"button"==b?this.getControl(a):a.info.selector,"#"==a.charAt(0)&&(a=a.substring(1)),this.stmt("click "+a))};
CasperRenderer.prototype.getFormSelector=function(a){a=a.info;return a.form?a.form.name?"form[name="+a.form.name+"] ":a.form.id?"form#"+a.form.id+" ":"form ":""};CasperRenderer.prototype.mousedrag=function(a){this.with_xy&&(this.stmt("this.mouse.down("+a.before.x+", "+a.before.y+");"),this.stmt("this.mouse.move("+a.x+", "+a.y+");"),this.stmt("this.mouse.up("+a.x+", "+a.y+");"))};
CasperRenderer.prototype.keypress=function(a){var b=a.text.replace(/\r\n/g,"[enter]").replace(/\r/g,"[enter]").replace(/\n/g,"[enter]");a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("type "+a+" as "+b)};CasperRenderer.prototype.submit=function(a){};CasperRenderer.prototype.screenShot=function(a){this.stmt("snap page")};CasperRenderer.prototype.elementScreenShot=function(a){a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("snap "+a)};
CasperRenderer.prototype.inspectElement=function(a){};CasperRenderer.prototype.noteDownElement=function(a){a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("// element is "+a)};CasperRenderer.prototype.moveCursorToElement=function(a){a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("hover "+a)};CasperRenderer.prototype.fetchElementText=function(a){a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("read "+a+" to variable")};
CasperRenderer.prototype.selectElementOption=function(a){var b=this.getControl(a);a=this.pyrepr(a.info.value);"#"==b.charAt(0)&&(b=b.substring(1));this.stmt("select "+b+" as "+a)};CasperRenderer.prototype.cancelLastStep=function(a){this.stmt("cancel the last step")};CasperRenderer.prototype.printElementText=function(a){a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("show "+a)};
CasperRenderer.prototype.saveElementText=function(a){a=this.getControl(a);"#"==a.charAt(0)&&(a=a.substring(1));this.stmt("save "+a)};CasperRenderer.prototype.explicitWait=function(a){this.stmt("wait")};CasperRenderer.prototype.cancel=function(a){};CasperRenderer.prototype.checkPageTitle=function(a){};CasperRenderer.prototype.checkPageLocation=function(a){};CasperRenderer.prototype.checkTextPresent=function(a){};CasperRenderer.prototype.checkValue=function(a){};CasperRenderer.prototype.checkText=function(a){};
CasperRenderer.prototype.checkHref=function(a){};CasperRenderer.prototype.checkEnabled=function(a){};CasperRenderer.prototype.checkDisabled=function(a){};CasperRenderer.prototype.checkSelectValue=function(a){};CasperRenderer.prototype.checkSelectOptions=function(a){};CasperRenderer.prototype.checkImageSrc=function(a){};CasperRenderer.prototype.waitAndTestSelector=function(a){};var dt=new CasperRenderer(document);
window.onload=function(){var a=!1;"?xy=true"==window.location.search&&(a=!0);chrome.runtime.sendMessage({action:"get_items"},function(b){dt.items=b.items;dt.render(a)})};
