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