{"version":3,"sources":["jsdelivr-header.js","/npm/signalk-autopilot-garmin@0.1.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACSA,MAAM,QAAU,CACd,OAAQ,QAAQ,qBAIlB,OAAO,QAAU,SAAU,GACzB,IACI,EADA,EAAS,CAAC,EAoEd,OAhEA,EAAO,MAAQ,SAAU,GACvB,MAAM,EAAO,EAAM,KAEnB,GADA,EAAI,MAAM,kCAAkC,QACvC,QAAQ,GAIb,IACE,MAAM,EAAa,QAAQ,GAC3B,GAA0B,mBAAf,EACT,MAAM,IAAI,MAAM,oBAAoB,kCAGtC,KADA,EAAY,EAAW,KACsB,mBAApB,EAAU,MACjC,MAAM,IAAI,MAAM,oBAAoB,oCAGtC,EAAI,MAAM,+BAA+B,MACzC,EAAU,MAAM,GAChB,EAAI,mBAAmB,eAAgB,2BAA4B,EAAU,UAC7E,EAAI,mBAAmB,eAAgB,2CAA4C,EAAU,iBAO/F,CAAE,MAAO,GACP,EAAI,MAAM,wCAAwC,OAAU,EAAM,UACpE,MAzBE,EAAI,MAAM,mBAAmB,wBA0BjC,EAEA,EAAO,KAAO,WACR,GACF,EAAU,MAEd,EAEA,EAAO,GAAK,mBACZ,EAAO,KAAO,2BACd,EAAO,YAAc,kDAErB,EAAO,OAAS,WACd,IAAI,EAAS,CACX,MAAO,oBACP,KAAM,SACN,WAAY,CACV,KAAM,CACJ,KAAM,SACN,MAAO,iBACP,KAAM,CACJ,UAEF,UAAW,CACT,kBAEF,QAAS,YAKf,OADA,EAAO,WAAa,IAAK,GAAW,gBAAiB,EAAO,YACrD,CACT,EAEO,CACT","file":"/npm/signalk-autopilot-garmin@0.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/signalk-autopilot-garmin@0.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * Copyright 2024 Jörgen Karlsson <jorgen@karlsson.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst modules = {\n  garmin: require('./garmin_reactor')\n};\n\n\nmodule.exports = function (app) {\n  var plugin = {};\n  var autopilot;\n\n\n  plugin.start = function (props) {\n    const type = props.type;\n    app.debug(`Initializing autopilot of type ${type}...`);\n    if (!modules[type]) {\n      app.error(`Autopilot type '${type}' is not recognized.`);\n      return;\n    }\n    try {\n      const initModule = modules[type];\n      if (typeof initModule !== 'function') {\n        throw new Error(`Module for type '${type}' does not export a function.`);\n      }\n      autopilot = initModule(app);\n      if (!autopilot || typeof autopilot.start !== 'function') {\n        throw new Error(`Module for type '${type}' did not initialize correctly.`);\n      }\n\n      app.debug(`Starting autopilot of type '${type}'`);\n      autopilot.start(props);\n      app.registerPutHandler('vessels.self', \"steering.autopilot.state\", autopilot.putState);\n      app.registerPutHandler('vessels.self', \"steering.autopilot.actions.adjustHeading\", autopilot.putAdjustHeading);\n      /*  TODO in future the following put handlers could be added:  \n      targetHeadingPath = \"steering.autopilot.target.headingMagnetic\";\n      targetWindPath = \"steering.autopilot.target.windAngleApparent\";\n      tack = \"steering.autopilot.actions.tack\";\n      advance = \"steering.autopilot.actions.advanceWaypoint\";\n      */\n    } catch (error) {\n      app.error(`Failed to initialize autopilot type '${type}': ${error.message}`);\n    }\n  };\n\n  plugin.stop = function () {\n    if (autopilot) {\n      autopilot.stop();\n    }\n  };\n\n  plugin.id = \"autopilot-garmin\";\n  plugin.name = \"Autopilot Garmin Control\";\n  plugin.description = \"Plugin that controls a Garmin Reactor autopilot\";\n\n  plugin.schema = function () {\n    let config = {\n      title: \"Autopilot Control\",\n      type: \"object\",\n      properties: {\n        type: {\n          type: 'string',\n          title: 'Autopilot Type',\n          enum: [\n            'garmin'\n          ],\n          enumNames: [\n            'Garmin Reactor'\n          ],\n          default: 'garmin'\n        }\n      }\n    };\n    config.properties = { ...autopilot?.properties(), ...config.properties };\n    return config;\n  };\n\n  return plugin;\n};\n\n"]}