!function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t){const o=new smarthome.App("1.0.0");let n=11080;o.onIdentify(async e=>{var t;console.debug("IDENTIFY request:",e);if("scrypted-gh"!==(null===(t=e.inputs[0].payload.device.mdnsScanData)||void 0===t?void 0:t.type))throw console.error("mdns type not 'scrypted-gh'"),Error("mdns type not 'scrypted-gh'");n=parseInt(e.inputs[0].payload.device.mdnsScanData.txt.port);const o={intent:smarthome.Intents.IDENTIFY,requestId:e.requestId,payload:{device:{id:"local-hub-id",isProxy:!0,isLocalOnly:!0}}};return console.debug("IDENTIFY response:",o),o}).onReachableDevices(e=>{console.debug("REACHABLE_DEVICES request:",e);const t=e.devices.map(e=>({verificationId:e.id})).filter(e=>"local-hub-id"!==e.verificationId),o={intent:smarthome.Intents.REACHABLE_DEVICES,requestId:e.requestId,payload:{devices:t}};return console.debug("REACHABLE_DEVICES response:",e),o}).onQuery(async e=>{var t,r,i,a,d,s;try{console.debug("QUERY request",e);const l=new smarthome.DataFlow.HttpRequestData;l.requestId=e.requestId,l.deviceId=e.inputs[0].payload.devices[0].id,l.method=smarthome.Constants.HttpOperation.POST,l.port=n,l.path="/endpoint/@scrypted/google-home/public",l.dataType="application/json",delete e.devices,l.data=JSON.stringify(e),l.additionalHeaders={Authorization:null===(s=null===(d=null===(a=null===(i=null===(r=null===(t=e.inputs)||void 0===t?void 0:t[0])||void 0===r?void 0:r.payload)||void 0===i?void 0:i.devices)||void 0===a?void 0:a[0])||void 0===d?void 0:d.customData)||void 0===s?void 0:s.localAuthorization};try{const e=await o.getDeviceManager().send(l);console.log("COMMAND result",e);const t=e.httpResponse.body,n=JSON.parse(t);return console.log("QUERY result",n),n}catch(e){throw console.error("QUERY error",e),e}}catch(e){throw console.error("QUERY failure",e),e}}).onExecute(async e=>{var t,r,i,a,d,s,l;try{console.debug("EXECUTE request",e);const c=new smarthome.DataFlow.HttpRequestData;c.requestId=e.requestId,c.deviceId=e.inputs[0].payload.commands[0].devices[0].id,c.method=smarthome.Constants.HttpOperation.POST,c.port=n,c.path="/endpoint/@scrypted/google-home/public",c.dataType="application/json",delete e.devices,c.data=JSON.stringify(e),c.additionalHeaders={Authorization:null===(l=null===(s=null===(d=null===(a=null===(i=null===(r=null===(t=e.inputs)||void 0===t?void 0:t[0])||void 0===r?void 0:r.payload)||void 0===i?void 0:i.commands)||void 0===a?void 0:a[0].devices)||void 0===d?void 0:d[0])||void 0===s?void 0:s.customData)||void 0===l?void 0:l.localAuthorization};try{const e=await o.getDeviceManager().send(c);console.log("COMMAND result",e);const t=e.httpResponse.body,n=JSON.parse(t);return console.log("EXECUTE result",n),n}catch(e){throw console.error("EXECUTE error",e),e}}catch(e){throw console.error("EXECUTE failure",e),e}}).listen().then(()=>{console.log("Ready")})}]);