{"version":3,"file":"index-BBh0uvl3.js","sources":["../../../app/assets/javascripts/app/page_visit_count_tracker_per_page_type/index.ts"],"sourcesContent":["\nimport {\n isLocalStorageEnabled,\n\n getDataFromLocalStorage,\n\n setDataToLocalStorage,\n\n removeDataFromLocalStorage,\n} from \"app/local_storages/native_api_adapter\"\n\nconst PAGE_TYPE_PLACEHOLDER = \"%page_type%\"\nconst COMMON_KEY = `app/page_visit_count_tracker_per_page_type/${PAGE_TYPE_PLACEHOLDER}/.value`\n\nclass TrackerPerPageType {\n private page_type_identifier: string\n\n constructor(page_type_identifier: string) {\n this.page_type_identifier = page_type_identifier\n }\n\n public getValue() {\n if (!isLocalStorageEnabled()) { return 0 }\n\n // String\n const value_from_cookie = getDataFromLocalStorage(this.getKey()).data\n if (typeof value_from_cookie !== \"string\") { return 0 }\n\n const parsed_integer = parseInt(value_from_cookie, 10)\n if (isNaN(parsed_integer)) { return 0 }\n\n return parsed_integer\n }\n\n public incrementValue() {\n const new_value = this.getValue() + 1\n return setDataToLocalStorage(this.getKey(), new_value.toString())\n }\n\n public resetValue() {\n return removeDataFromLocalStorage(this.getKey())\n }\n\n private getKey() {\n // https://stackoverflow.com/a/17606289/838346\n return COMMON_KEY.split(PAGE_TYPE_PLACEHOLDER).join(this.page_type_identifier)\n }\n}\n\nexport default TrackerPerPageType\n"],"names":["PAGE_TYPE_PLACEHOLDER","COMMON_KEY","TrackerPerPageType","page_type_identifier","isLocalStorageEnabled","value_from_cookie","getDataFromLocalStorage","parsed_integer","new_value","setDataToLocalStorage","removeDataFromLocalStorage"],"mappings":"wDAWA,MAAMA,EAAwB,cACxBC,EAAa,8CAA8C,OAAAD,EAAqB,WAEtF,MAAME,CAAmB,CAGvB,YAAYC,EAA8B,CACxC,KAAK,qBAAuBA,CAAA,CAGvB,UAAW,CACZ,GAAA,CAACC,IAAkC,MAAA,GAGvC,MAAMC,EAAoBC,EAAwB,KAAK,OAAA,CAAQ,EAAE,KAC7D,GAAA,OAAOD,GAAsB,SAAmB,MAAA,GAE9C,MAAAE,EAAiB,SAASF,EAAmB,EAAE,EACjD,OAAA,MAAME,CAAc,EAAY,EAE7BA,CAAA,CAGF,gBAAiB,CAChB,MAAAC,EAAY,KAAK,SAAA,EAAa,EACpC,OAAOC,EAAsB,KAAK,OAAU,EAAAD,EAAU,UAAU,CAAA,CAG3D,YAAa,CACX,OAAAE,EAA2B,KAAK,QAAQ,CAAA,CAGzC,QAAS,CAEf,OAAOT,EAAW,MAAMD,CAAqB,EAAE,KAAK,KAAK,oBAAoB,CAAA,CAEjF"}