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,OAAO,CAAC;MACjBN,SAAS,CAACI,SAAS,GAAGG,QAAQ,CAACJ,KAAK,CAAC,GAAG,CAAC;IAC9C;IAKAnB,2DAAQ,CAAE;MACLwB,IAAI,EAAE,8BAA8B;MACpCC,MAAM,EAAE,MAAM;MACdC,IAAI,EAAE;QAAEjB,MAAM,EAAEA;MAAO;IAC3B,CAAE,CAAC,CAACkB,IAAI,CAAIC,GAAG,IAAM;MACjB;IAAA,CACF,CAAC;EAET,CAAC,CAAC;AACP,CAAC,CAAC,C","sources":["webpack://gold-eyes-core/external window [\"wp\",\"apiFetch\"]","webpack://gold-eyes-core/webpack/bootstrap","webpack://gold-eyes-core/webpack/runtime/compat get default export","webpack://gold-eyes-core/webpack/runtime/define property getters","webpack://gold-eyes-core/webpack/runtime/hasOwnProperty shorthand","webpack://gold-eyes-core/webpack/runtime/make namespace object","webpack://gold-eyes-core/./src/postlikes/view.js"],"sourcesContent":["module.exports = window[\"wp\"][\"apiFetch\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","//Call api fetch\nimport apiFetch from '@wordpress/api-fetch';\n\n\n\n//Send the info to the REST API\nArray.from(document.querySelectorAll('.goldeyes-post-likes__button')).forEach(elem => {\n elem.addEventListener('click', function(el){\n const postId = elem.getAttribute('data-link');\n const list = elem.classList;\n const liked = elem.classList.contains('liked');\n const unliked = elem.classList.contains('unliked');\n const countElem = elem.parentElement.querySelector('.goldeyes-post-likes_count');\n const count = countElem.innerHTML;\n\n if(liked){\n list.remove('liked');\n list.add('unliked');\n countElem.innerHTML = parseInt(count) - 1;\n } else{\n list.remove('unliked');\n list.add('liked');\n countElem.innerHTML = parseInt(count) + 1;\n }\n\n \n \n\n apiFetch( {\n path: '/post_tracking/v1/post_likes',\n method: 'POST',\n data: { postId: postId },\n } ).then( ( res ) => {\n //console.log( res );\n } );\n\n })\n});"],"names":["apiFetch","Array","from","document","querySelectorAll","forEach","elem","addEventListener","el","postId","getAttribute","list","classList","liked","contains","unliked","countElem","parentElement","querySelector","count","innerHTML","remove","add","parseInt","path","method","data","then","res"],"sourceRoot":""}