var CreateAmtRemoteIder=function(){var l={};function f(){urlvars&&urlvars.idertrace&&console.log(...arguments)}l.protocol=3,l.bytesToAmt=0,l.bytesFromAmt=0,l.rx_timeout=3e4,l.tx_timeout=0,l.heartbeat=2e4,l.version=1,l.acc="",l.inSequence=0,l.outSequence=0,l.iderinfo=null,l.enabled=!1,l.iderStart=0,l.floppy=null,l.cdrom=null,l.floppyReady=!1,l.cdromReady=!1,l.pingTimer=null;var u=String.fromCharCode(0,38,49,128,0,0,0,0,5,30,16,169,8,32,2,0,3,195,0,0,0,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,2,208,0,0),h=String.fromCharCode(0,92,36,128,0,0,0,0,1,10,0,1,0,0,0,0,2,0,0,0,3,22,0,160,0,0,0,0,0,18,2,0,0,0,0,0,0,0,160,0,0,0,5,30,16,169,8,32,2,0,3,195,0,0,0,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,2,208,0,0,8,10,0,0,0,0,0,0,0,0,0,0,11,6,0,0,0,17,36,49),p=String.fromCharCode(0,38,36,128,0,0,0,0,5,30,4,176,2,18,2,0,0,80,0,0,0,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,2,208,0,0),R=String.fromCharCode(0,92,36,128,0,0,0,0,1,10,0,1,0,0,0,0,2,0,0,0,3,22,0,160,0,0,0,0,0,18,2,0,0,0,0,0,0,0,160,0,0,0,5,30,4,176,2,18,2,0,0,80,0,0,0,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,2,208,0,0,8,10,0,0,0,0,0,0,0,0,0,0,11,6,0,0,0,17,36,49),E=String.fromCharCode(0,18,1,128,0,0,0,0,26,10,0,0,0,0,0,0,0,0,0,0),I=String.fromCharCode(0,18,1,128,0,0,0,0,29,10,0,0,0,0,0,0,0,0,0,0),g=String.fromCharCode(0,32,1,128,0,0,0,0,42,24,0,0,0,0,32,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0),b=String.fromCharCode(0,40,1,128,0,0,0,0,1,6,0,255,0,0,0,0,42,24,0,0,0,0,2,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0),A=(String.fromCharCode(0,0,0,40,0,0,0,8),String.fromCharCode(0,0,3,4,0,8,1,0)),T=String.fromCharCode(0,1,3,4,0,0,0,2),D=String.fromCharCode(0,2,3,4,0,0,0,0),y=String.fromCharCode(0,3,3,4,41,0,0,2),_=String.fromCharCode(0,16,1,8,0,0,8,0,0,1,0,0),k=String.fromCharCode(0,30,3,0),v=String.fromCharCode(1,0,3,0),O=String.fromCharCode(1,5,3,0),X=String.fromCharCode(0,18,36,128,0,0,0,0,1,10,0,1,0,0,0,0,2,0,0,0),w=String.fromCharCode(0,18,49,128,0,0,0,0,1,10,0,1,0,0,0,0,2,0,0,0),F=String.fromCharCode(0,14,1,128,0,0,0,0,1,6,0,255,0,0,0,0);function H(e,r,n,a){var o=null,t=0;160==e&&(o=l.floppy,null!=l.floppy&&(t=l.floppy.size>>9)),176==e&&(o=l.cdrom,null!=l.cdrom&&(t=l.cdrom.size>>11)),n<0||tl.iderinfo.readbfr&&(n=l.iderinfo.readbfr);c-=n;S+=n;var o=new FileReader;o.onload=function(){l.SendDataToHost(d,0==c,this.result,1&r),0>8,0,a?180:181,0,2,0,255&o,o>>8,e,88,133,0,3,0,0,0,e,80,0,0,0,0,0,0)+n,r,a):l.SendCommand(84,String.fromCharCode(0,255&n.length,n.length>>8,0,a?180:181,0,2,0,255&o,o>>8,e,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0)+n,r,a)},l.SendGetDataFromHost=function(e,r){l.SendCommand(82,String.fromCharCode(0,255&r,r>>8,0,181,0,0,0,255&r,r>>8,e,88,0,0,0,0,0,0,0,0,0,0,0),!1)},l.SendDisableEnableFeatures=function(e,r){null==r&&(r=""),l.SendCommand(72,String.fromCharCode(e)+r)};var d,S,c,C=!(l.ProcessDataEx=function(){if(l.acc.length<8)return 0;switch(l.acc.charCodeAt(0)){case 65:if(l.acc.length<30)return 0;var e=l.acc.charCodeAt(29);return l.acc.length<30+e?0:(l.iderinfo={},l.iderinfo.major=l.acc.charCodeAt(8),l.iderinfo.minor=l.acc.charCodeAt(9),l.iderinfo.fwmajor=l.acc.charCodeAt(10),l.iderinfo.fwminor=l.acc.charCodeAt(11),l.iderinfo.readbfr=ReadShortX(l.acc,16),l.iderinfo.writebfr=ReadShortX(l.acc,18),l.iderinfo.proto=l.acc.charCodeAt(21),l.iderinfo.iana=ReadIntX(l.acc,25),f(l.iderinfo),0!=l.iderinfo.proto&&(f("Unknown proto",l.iderinfo.proto),l.Stop()),8192>9)-1:S);break;case 176:if(null==l.floppy||0==l.floppy.size)return l.SendCommandEndResponse(0,2,e,58,0);f("DEV_CDDVD",S=null!=l.cdrom?(l.cdrom.size>>11)-1:S);break;default:return f("SCSI Internal error 4",e)}f("SCSI: READ_CAPACITY2",e,a),l.SendDataToHost(a,!0,IntToStr(S)+String.fromCharCode(0,0,176==e?8:2,0),1&n);break;case 40:C=ReadInt(r,2),S=ReadShort(r,7),f("SCSI: READ_10",e,C,S),H(e,C,S,n);break;case 42:case 46:C=ReadInt(r,2),S=ReadShort(r,7),f("SCSI: WRITE_10",e,C,S),l.SendGetDataFromHost(e,512*S);break;case 67:var d=ReadShort(r,7),c=2&r.charCodeAt(1),C=7&r.charCodeAt(2);switch(0==C&&(C=r.charCodeAt(9)>>6),f("SCSI: READ_TOC, dev="+e+", buflen="+d+", msf="+c+", format="+C),e){case 160:return l.SendCommandEndResponse(1,5,e,32,0);case 176:break;default:return f("SCSI Internal error 9",e)}1==C?l.SendDataToHost(e,!0,String.fromCharCode(0,10,1,1,0,20,1,0,0,0,0,0),1&n):0==C&&(c?l.SendDataToHost(e,!0,String.fromCharCode(0,18,1,1,0,20,1,0,0,0,2,0,0,20,170,0,0,0,52,19),1&n):l.SendDataToHost(e,!0,String.fromCharCode(0,18,1,1,0,20,1,0,0,0,0,0,0,20,170,0,0,0,0,0),1&n));break;case 70:var c=2!=r.charCodeAt(1),i=ReadShort(r,2),d=ReadShort(r,7);if(f("SCSI: GET_CONFIGURATION",e,c,i,d),0==d)return l.SendDataToHost(e,!0,IntToStr(60)+IntToStr(8),1&n);var s=IntToStr(8);return 0==i&&(s+=A),(1==i||c&&i<1)&&(s+=T),(2==i||c&&i<2)&&(s+=D),(3==i||c&&i<3)&&(s+=y),(16==i||c&&i<16)&&(s+=_),(30==i||c&&i<30)&&(s+=k),(256==i||c&&i<256)&&(s+=v),(261==i||c&&i<261)&&(s+=O),(s=IntToStr(s.length)+s).length>d&&(s=s.substring(0,d)),l.SendDataToHost(e,!0,s,1&n);case 74:if(f("SCSI: GET_EVENT_STATUS_NOTIFICATION",e,r.charCodeAt(1),r.charCodeAt(4),r.charCodeAt(9)),1!=r.charCodeAt(1)&&16!=r.charCodeAt(4)){f("SCSI ERROR"),l.SendCommandEndResponse(1,5,e,38,1);break}i=0;(160==e&&null!=l.floppy||176==e&&null!=l.cdrom)&&(i=2),l.SendDataToHost(e,!0,String.fromCharCode(0,i,128,0),1&n);break;case 76:l.SendCommand(81,IntToStrX(0)+IntToStrX(0)+IntToStrX(0)+String.fromCharCode(135,80,3,0,0,0,176,81,5,32,0),!0);break;case 81:return f("SCSI READ_DISC_INFO",e),l.SendCommandEndResponse(0,5,e,32,0);case 85:return f("SCSI ERROR: MODE_SELECT_10",e),l.SendCommandEndResponse(1,5,e,32,0);case 90:f("SCSI: MODE_SENSE_10",e,63&r.charCodeAt(2));d=ReadShort(r,7),s=null;if(0==d)return l.SendDataToHost(e,!0,IntToStr(60)+IntToStr(8),1&n);var m=0;switch(160==e?null!=l.floppy&&(m=l.floppy.size>>9):null!=l.cdrom&&(m=l.cdrom.size>>11),63&r.charCodeAt(2)){case 1:s=160==e?m<=2880?X:w:F;break;case 5:160==e&&(s=m<=2880?p:u);break;case 63:s=160==e?m<=2880?R:h:b;break;case 26:176==e&&(s=E);break;case 29:176==e&&(s=I);break;case 42:176==e&&(s=g)}null==s?l.SendCommandEndResponse(0,5,e,32,0):l.SendDataToHost(e,!0,s,1&n);break;default:return f("IDER: Unknown SCSI command",r.charCodeAt(0)),l.SendCommandEndResponse(0,5,e,32,0)}}(o,r,n,t),28;case 83:if(l.acc.length<14)return 0;e=ReadShortX(l.acc,9);return l.acc.length<14+e?0:(f("SCSI_WRITE, len = "+(14+e)),l.SendCommand(81,String.fromCharCode(0,0,0,0,0,0,0,0,0,0,0,0,135,112,3,0,0,0,160,81,7,39,0),!0),14+e);default:f("Unknown IDER command",l.acc[0]),l.Stop()}return 0}),i=null;return l}