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AgB,EAAK,gBAEvE,EAAsB,EAAkB,QAAO,GACnD,EAAgB,MAAK,GAAW,EAAU,YAAc,EAAQ,cAGlE,GAAmC,IAA/B,EAAoB,OAEtB,YADA,QAAQ,IAAI,0DAId,MAAM,EAAc,EAAoB,KAAI,IAC1C,MAAM,EAAU,EAAgB,MAAK,GAAK,EAAE,YAAc,EAAM,YAC1D,EAAW,KAAK,IAAI,EAAM,SAAW,EAAQ,UAC7C,EAAgB,EAAW,GACjC,MAAO,CACL,UAAW,EAAM,UACjB,SAAU,EACV,cAAe,EAChB,IAGH,QAAQ,IAAI,iCAAiC,EAAK,uBAAuB,EAAK,kBAC9E,EAAY,SAAQ,IAClB,QAAQ,IAAI,mBAAmB,EAAK,aACpC,QAAQ,IAAI,mBAAmB,EAAK,cAAc,QAAQ,cAC1D,QAAQ,IAAI,GAAG,GAEnB,CAAE,MAAO,GACP,QAAQ,MAAM,kDAAmD,EACnE,KAGH,QAAQ,CACP,QAAS,oBACT,SAAU,6DACV,QAAS,CACP,SAAU,CACR,SAAU,WACV,cAAc,EACd,KAAM,UAER,UAAW,CACT,SAAU,YACV,cAAc,EACd,KAAM,UAER,MAAO,CACL,SAAU,yCACV,KAAM,SACN,QAAS,IAGb,QAAS,MAAO,IACd,IACE,MAAM,QAAwB,OAAO,mBAAmB,EAAK,SAAU,EAAK,UAAW,EAAK,OAC5F,QAAQ,IAAI,qBAAsB,EACpC,CAAE,MAAO,GACP,QAAQ,MAAM,oCAAqC,EACrD,KAGH,cAAc,EAAG,qCACjB,OACA,MAAM,IAAK,QACX,SACA","file":"/npm/lta-api-project@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/lta-api-project@1.0.0/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","const yargs = require('yargs');\r\nconst ltaApi = require('./lta-api');\r\n\r\nyargs\r\n  .command({\r\n    command: 'bus-arrival',\r\n    describe: 'Get bus arrival information',\r\n    builder: {\r\n      busStopCode: {\r\n        describe: 'Bus Stop Code',\r\n        demandOption: true,\r\n        type: 'string',\r\n      },\r\n      serviceNo: {\r\n        describe: 'Service Number',\r\n        demandOption: true,\r\n        type: 'string',\r\n      },\r\n    },\r\n    handler: async (argv) => {\r\n      try {\r\n        const busArrival = await ltaApi.getBusArrival(argv.busStopCode, argv.serviceNo);\r\n        const nextBus = busArrival.Services[0].NextBus;\r\n        const nextBus2 = busArrival.Services[0].NextBus2;\r\n\r\n        console.log(`Bus Service No: ${argv.serviceNo}`);\r\n        console.log(`Bus Stop Code: ${argv.busStopCode}`);\r\n\r\n        if (nextBus.EstimatedArrival) {\r\n          const arrivalTime = new Date(nextBus.EstimatedArrival);\r\n          console.log(`Next Bus Arrival: ${arrivalTime.toLocaleString()}`);\r\n        } else {\r\n          console.log('Next Bus Arrival: Not available');\r\n        }\r\n\r\n        if (nextBus2.EstimatedArrival) {\r\n          const arrivalTime2 = new Date(nextBus2.EstimatedArrival);\r\n          console.log(`Next Bus 2 Arrival: ${arrivalTime2.toLocaleString()}`);\r\n        } else {\r\n          console.log('Next Bus 2 Arrival: Not available');\r\n        }\r\n      } catch (error) {\r\n        console.error('Error fetching bus arrival:', error);\r\n      }\r\n    },\r\n  })\r\n  .command({\r\n    command: 'parking-availability',\r\n    describe: 'Get parking availability information',\r\n    handler: async () => {\r\n      try {\r\n        const parkingAvailability = await ltaApi.getParkingAvailability();\r\n        console.log('Parking Availability:', parkingAvailability);\r\n      } catch (error) {\r\n        console.error('Error fetching parking availability:', error);\r\n      }\r\n    },\r\n  })\r\n  .command({\r\n    command: 'bus-travel-time',\r\n    describe: 'Estimate travel time between two bus stops',\r\n    builder: {\r\n      fromBusStopCode: {\r\n        describe: 'From Bus Stop Code',\r\n        demandOption: true,\r\n        type: 'string',\r\n      },\r\n      toBusStopCode: {\r\n        describe: 'To Bus Stop Code',\r\n        demandOption: true,\r\n        type: 'string',\r\n      },\r\n    },\r\n    handler: async (argv) => {\r\n      try {\r\n        const busRoutes = await ltaApi.getBusRoutes();\r\n        const fromBusStopRoutes = busRoutes.filter(route => route.BusStopCode === argv.fromBusStopCode);\r\n        const toBusStopRoutes = busRoutes.filter(route => route.BusStopCode === argv.toBusStopCode);\r\n\r\n        const commonServiceRoutes = fromBusStopRoutes.filter(fromRoute => \r\n          toBusStopRoutes.some(toRoute => fromRoute.ServiceNo === toRoute.ServiceNo)\r\n        );\r\n\r\n        if (commonServiceRoutes.length === 0) {\r\n          console.log('No direct bus service found between the two bus stops.');\r\n          return;\r\n        }\r\n\r\n        const travelTimes = commonServiceRoutes.map(route => {\r\n          const toRoute = toBusStopRoutes.find(r => r.ServiceNo === route.ServiceNo);\r\n          const distance = Math.abs(route.Distance - toRoute.Distance);\r\n          const estimatedTime = distance / 0.5; // Assuming average bus speed of 0.5 km/min\r\n          return {\r\n            serviceNo: route.ServiceNo,\r\n            distance: distance,\r\n            estimatedTime: estimatedTime,\r\n          };\r\n        });\r\n\r\n        console.log(`Travel time between bus stops ${argv.fromBusStopCode} and ${argv.toBusStopCode}:`);\r\n        travelTimes.forEach(time => {\r\n          console.log(`Bus Service No: ${time.serviceNo}`);\r\n          console.log(`Estimated Time: ${time.estimatedTime.toFixed(2)} minutes`);\r\n          console.log('');\r\n        });\r\n      } catch (error) {\r\n        console.error('Error estimating travel time between bus stops:', error);\r\n      }\r\n    },\r\n  })\r\n  .command({\r\n    command: 'nearest-bus-stops',\r\n    describe: 'Find the nearest bus stops based on latitude and longitude',\r\n    builder: {\r\n      latitude: {\r\n        describe: 'Latitude',\r\n        demandOption: true,\r\n        type: 'number',\r\n      },\r\n      longitude: {\r\n        describe: 'Longitude',\r\n        demandOption: true,\r\n        type: 'number',\r\n      },\r\n      limit: {\r\n        describe: 'Number of nearest bus stops to display',\r\n        type: 'number',\r\n        default: 5,\r\n      },\r\n    },\r\n    handler: async (argv) => {\r\n      try {\r\n        const nearestBusStops = await ltaApi.getNearestBusStops(argv.latitude, argv.longitude, argv.limit);\r\n        console.log('Nearest Bus Stops:', nearestBusStops);\r\n      } catch (error) {\r\n        console.error('Error fetching nearest bus stops:', error);\r\n      }\r\n    },\r\n  })\r\n  .demandCommand(1, 'You must provide a valid command.')\r\n  .help()\r\n  .alias('h', 'help')\r\n  .strict()\r\n  .parse();\r\n"]}