"use strict";(function(){"use strict";global.Promise=require("bluebird");var e=require("co");var r=require("./jsUtil");var t=require("node-xlsx");var n=require("fs");var i=r.getPkgInfo().spec.info.maccHost;exports.build=function(s,a,c,u){return e(regeneratorRuntime.mark(function o(){var e,u,l,d,f,v,p,b,h,g,m,x,k,q,y,S;return regeneratorRuntime.wrap(function w(o){while(1){switch(o.prev=o.next){case 0:e=t.parse(s);u=e[0].data;l=[];d=u[0];f=[];for(v=0;v<d.length;v++){f.push(d[v])};l.push(f);u.shift();p=0;b=true;h=false;g=undefined;o.prev=13;m=u[Symbol.iterator]();case 15:if(b=(x=m.next()).done){o.next=32;break}k=x.value;o.next=19;return r.commonPost2(i,"/service/api/device_qrcode/list",{device:[{deviceType:k[0].toString(),deviceSn:k[2].toString(),mac:""}]},{},12e3);case 19:q=o.sent;console.log("qrcode result:",q);if(!(q.code==0&&Array.isArray(q.list)&&q.list.length>0)){o.next=28;break}p++;if(typeof c==="function"){c(p)}y=q.list[0];l.push([y.deviceType,y.deviceClass!=undefined?y.deviceClass:"",y.deviceSn,y.qrcode]);o.next=29;break;case 28:return o.abrupt("return",Promise.reject(q.msg));case 29:b=true;o.next=15;break;case 32:o.next=38;break;case 34:o.prev=34;o.t0=o["catch"](13);h=true;g=o.t0;case 38:o.prev=38;o.prev=39;if(!b&&m.return){m.return()}case 41:o.prev=41;if(!h){o.next=44;break}throw g;case 44:return o.finish(41);case 45:return o.finish(38);case 46:S=t.build([{name:"qrcode",data:l}]);n.writeFileSync(a,S);return o.abrupt("return",l.length-1);case 49:case"end":return o.stop()}}},o,this,[[13,34,38,46],[39,,41,45]])})).catch(function(e){console.error("e:",e.toString());return Promise.reject(e)}).asCallback(u)}})();