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,CAAY,EAAY,GACtB,MAAM,0BAA0B,KAAc,yBAAoC,aAAa,SAAS,wEACxG,KAAK,KAAO,iBACd,EAYF,SAAS,0BACP,OAAO,YAAY,yBACrB,CAoBA,SAAS,uBAAuB,EAAO,GACrC,IAAK,YAAY,uBACf,MAAM,IAAI,oBAAoB,mBAAmB,KAAM,mBAAmB,WAE5E,MAAM,EAAO,EAAM,UAEnB,OADA,YAAY,uBAAuB,GAC5B,iBAAiB,YAAY,mBAAmB,UAAW,EACpE,CASA,SAAS,wBACP,iBAAiB,mBAAmB,mBAAmB,WACvD,YAAY,uBACd,CACA,IAAI,SAAW,QAAQ,QAAU","file":"/npm/@dongminyu/react-native-step-counter@0.2.4/lib/commonjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@dongminyu/react-native-step-counter@0.2.4/lib/commonjs/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","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nObject.defineProperty(exports, \"NAME\", {\n  enumerable: true,\n  get: function () {\n    return _NativeStepCounter.NAME;\n  }\n});\nObject.defineProperty(exports, \"VERSION\", {\n  enumerable: true,\n  get: function () {\n    return _NativeStepCounter.VERSION;\n  }\n});\nexports.isSensorWorking = exports.default = void 0;\nexports.isStepCountingSupported = isStepCountingSupported;\nexports.parseStepData = parseStepData;\nexports.startStepCounterUpdate = startStepCounterUpdate;\nexports.stopStepCounterUpdate = stopStepCounterUpdate;\nvar _reactNative = require(\"react-native\");\nvar _NativeStepCounter = require(\"./NativeStepCounter\");\n/* A way to check if the module is linked. */\nconst LINKING_ERROR = \"The package '@dongminyu/react-native-step-counter' doesn't seem to be linked. Make sure: \\n\\n\" + _reactNative.Platform.select({\n  ios: '- You have run `pod install` in the `ios` directory and then clean, rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.\\n',\n  android: '- You have the Android development environment set up: `https://reactnative.dev/docs/environment-setup.`',\n  default: ''\n}) + '- Use the \"npx react-native clean\" command to clean up the module\\'s cache and select the ' + '\"watchman\", \"yarn\", \"metro\", \"android\", \"npm\" options with comma-separated. ' + 'Re-Install packages and re-build the app again .' + '- You rebuilt the app after installing the package\\n' + '- You are not using Expo Go\\n' + 'If none of these fix the issue, please open an issue on the Github repository: ' + 'https://github.com/AndrewDongminYoo/react-native-step-counter`';\n/**\n * We keep TurboModuleManager alive until the JS VM is deleted.\n * It is perfectly valid to only use/create TurboModules from JS.\n * In such a case, we shouldn't de-alloc TurboModuleManager if there\n * aren't any strong references to it in ObjC. Hence, we give\n * __turboModuleProxy a strong reference to TurboModuleManager.\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/TurboModule/TurboModuleRegistry.js\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp\n */\n// @ts-ignore\nconst isTurboModuleEnabled = global.__turboModuleProxy != null;\n\n/**\n * The `StepCounterModule` constant is used to import the native module `NativeStepCounter` if\n * TurboModules are enabled. If TurboModules are not enabled, it falls back to using the\n * `NativeModules.StepCounter` module. This allows the code to work with both TurboModules and\n * non-TurboModules environments.\n * https://github.com/AndrewDongminYoo/react-native-step-counter/issues/29#issue-1857677086\n */\nconst StepCounterModule = isTurboModuleEnabled ? require('./NativeStepCounter').default : _reactNative.NativeModules.StepCounter;\n\n/**\n * A module that allows you to get the step count data.\n * `CMStepCounter` is deprecated in iOS 8.0. Used `CMPedometer` instead.\n * floorsAscended - The number of floors ascended during the time period. iOS Only.\n * floorsDescended - The number of floors descended during the time period. iOS Only.\n * counterType - The type of counter used to count the steps.\n * @throws {Error} LINKING_ERROR - Throws Error If global variable turboModuleProxy is undefined.\n * @example\n * import { StepCounter } from '@dongminyu/react-native-step-counter';\n */\nconst StepCounter = StepCounterModule ? StepCounterModule : new Proxy({}, {\n  get() {\n    throw new Error(LINKING_ERROR);\n  }\n});\nconst StepEventEmitter = new _reactNative.NativeEventEmitter(StepCounter);\nconst isSensorWorking = exports.isSensorWorking = StepEventEmitter.listenerCount(_NativeStepCounter.eventName) > 0;\n\n/**\n * Transform the step count data into a more readable format.\n * You can use it or directly use the `StepCountData` type.\n * @param {StepCountData} data - Step Counter Sensor Event Data.\n * @returns {ParsedStepCountData} - String Parsed Count Data.\n */\nfunction parseStepData(data) {\n  const {\n    steps,\n    startDate,\n    endDate,\n    distance\n  } = data;\n  const dailyGoal = 10000;\n  const stepsString = steps + ' steps';\n  const kCal = (steps * 0.045).toFixed(2) + 'kCal';\n  const endDateTime = new Date(endDate).toLocaleTimeString('en-gb');\n  const startDateTime = new Date(startDate).toLocaleTimeString('en-gb');\n  const roundedDistance = distance.toFixed(1) + 'm';\n  const stepGoalStatus = steps >= dailyGoal ? 'Goal Reached' : `${steps}/${dailyGoal} steps`;\n  return {\n    dailyGoal: stepGoalStatus,\n    steps,\n    stepsString,\n    calories: kCal,\n    startDate: startDateTime,\n    endDate: endDateTime,\n    distance: roundedDistance\n  };\n}\n\n/**\n * If you're using a method or property that's not available on the current platform, throw this error.\n * @param {string} moduleName The name of the module.\n * @param {string} propertyName The name of the property.\n * @returns {Error} The error.\n * @example\n *  if (!StepCounter.startStepCounterUpdate) {\n *     throw new UnavailabilityError(NativeModuleName, eventName);\n *  }\n */\nclass UnavailabilityError extends Error {\n  constructor(moduleName, propertyName) {\n    super(`The method or property ${moduleName}.${propertyName} is not available on ${_reactNative.Platform.OS}, ` + \"are you sure you've linked all the native dependencies properly?\");\n    this.code = 'ERR_UNAVAILABLE';\n  }\n}\n\n/**\n * Returns whether the stepCounter is enabled on the device.\n * iOS 8.0+ only. Android is available since KitKat (4.4 / API 19).\n * @see https://developer.android.com/about/versions/android-4.4.html\n * @see https://developer.apple.com/documentation/coremotion/cmpedometer/1613963-isstepcountingavailable\n * @returns {Promise<Record<string, boolean>>} A promise that resolves with an object containing the stepCounter availability.\n * supported - Whether the stepCounter is supported on device.\n * granted - Whether user granted the permission.\n */\nfunction isStepCountingSupported() {\n  return StepCounter.isStepCountingSupported();\n}\n\n/**\n * Start to subscribe stepCounter updates.\n * Only the past seven days worth of data is stored and available for you to retrieve.\n * Specifying a start date that is more than seven days in the past returns only the available data.\n * ### iOS\n * `CMStepCounter.startStepCountingUpdates` is deprecated since iOS 8.0. so used `CMPedometer.startUpdates` instead.\n * @see https://developer.apple.com/documentation/coremotion/cmpedometer/1613950-startupdates\n * @see https://developer.apple.com/documentation/coremotion/cmstepcounter/1616151-startstepcountingupdates\n * @param {Date} start A date indicating the start of the range over which to measure steps.\n * @param {StepCountUpdateCallback} callBack - This callback function makes it easy for app developers to receive sensor events.\n * @returns {Subscription} - Returns a Subscription that enables you to call.\n * When you would like to unsubscribe the listener, just use a method of subscriptions's `remove()`.\n * @example\n * const startDate = new Date();\n * startStepCounterUpdate(startDate).then((response) => {\n *    const data = parseStepCountData(response);\n * })\n */\nfunction startStepCounterUpdate(start, callBack) {\n  if (!StepCounter.startStepCounterUpdate) {\n    throw new UnavailabilityError(_NativeStepCounter.NAME, _NativeStepCounter.eventName);\n  }\n  const from = start.getTime();\n  StepCounter.startStepCounterUpdate(from);\n  return StepEventEmitter.addListener(_NativeStepCounter.eventName, callBack);\n}\n\n/**\n * Stop the step counter updates.\n * ### iOS\n * `CMStepCounter.stopStepCountingUpdates` is deprecated since iOS 8.0. so used `CMPedometer.stopUpdates` instead.\n * @see https://developer.apple.com/documentation/coremotion/cmpedometer/1613973-stopupdates\n * @see https://developer.apple.com/documentation/coremotion/cmstepcounter/1616157-stopstepcountingupdates\n */\nfunction stopStepCounterUpdate() {\n  StepEventEmitter.removeAllListeners(_NativeStepCounter.eventName);\n  StepCounter.stopStepCounterUpdate();\n}\nvar _default = exports.default = StepCounter;\n"]}