b.command.push(a)}else b.command.push(a)}),c&&c.status&&c.status.forEach(function(a){if(a&&"root"==a.type){var c;a:{if((c=a.value)&&b&&b.status)for(var d=0;d<b.status.length;d++)if(b.status[d]&&"root"==b.status[d].type&&b.status[d].value==c){c=b.status[d];break a}c=null}c?(c.children||(c.children=[]),c.children=c.children.concat(a.children)):b.status.push(a)}else b.status.push(a)}));return b}}}();
var h=JSON.parse(JSON.stringify(a)),k=null;switch(b.catagory){case "command":k=e(a,b);h.command=k;break;case "status":k=e(a,b);h.status=k;break;default:return null}return k&&0!=k.length?h:null},getCommandStatusMap:function(c){if(!c||!c.type)return null;var b=a[c.type];if(!b)return null;b=JSON.parse(JSON.stringify(b));var d=xnm.aio.yamaha.AVR.getZoneCount(c);if(1<d)for(var f=2;f<=d;f++){var g=JSON.parse(JSON.stringify(a.avr_zone_template));g.command[0].name="zone "+f;g.command[0].value="zone"+f;g.status[0].name=
"zone "+f;g.status[0].value="zone"+f;b.command=b.command.concat(g.command);b.status=b.status.concat(g.status)}c.model&&a[c.type+"_"+c.model]&&((c=a[c.type+"_"+c.model])&&(c=JSON.parse(JSON.stringify(c))),c&&c.command&&c.command.forEach(function(a){if(a&&"root"==a.type){var c;a:{if((c=a.value)&&b&&b.command)for(var d=0;d<b.command.length;d++)if(b.command[d]&&"root"==b.command[d].type&&b.command[d].value==c){c=b.command[d];break a}c=null}c?(c.children||(c.children=[]),c.children=c.children.concat(a.children)):
b.command.push(a)}else b.command.push(a)}),c&&c.status&&c.status.forEach(function(a){if(a&&"root"==a.type){var c;a:{if((c=a.value)&&b&&b.status)for(var d=0;d<b.status.length;d++)if(b.status[d]&&"root"==b.status[d].type&&b.status[d].value==c){c=b.status[d];break a}c=null}c?(c.children||(c.children=[]),c.children=c.children.concat(a.children)):b.status.push(a)}else b.status.push(a)}));return b}}}();