{"version":3,"file":"cart-block-frontend.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACsE;AACC;AAClC;AACoB;AACvB;;AAElC;AACA;AACA;AACoC;AAE7B,MAAMU,KAAK,GAAIC,KAAK,IAAK;EAC/B;AACD;AACA;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,OACCC,oDAAA;IAAKC,SAAS,EAAC;EAAK,GAKnBD,oDAAA,CAACT,gEAAa;IACbW,KAAK,EAAET,mDAAE,CAAC,UAAU,EAAE,mBAAmB,CAAE;IAC3CU,KAAK,EAAE,GAAI;IACXN,OAAO,EAAEA,6CAAOA;EAAC,CACjB,CACG,CAAC;AAER,CAAC;;;;;;;;;;;;;;;;AC9JD;AACA;AACA;AACqC;AAE9B,MAAMA,OAAO,GAAG,CACtB;EACCK,KAAK,EAAET,mDAAE,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;EACvDU,KAAK,EAAE;AACR;AACA;AACD;AACA;AACA,GAHC,CAIA;;;;;;;;;;ACdD;;;;;;;;;;ACAA;;;;;;;;;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H,IAAI,CAACY,aAAc;AAC7C;AACA,kIAAkIZ,IAAI,CAACY,aAAc;AACrJ;AACA;AACA,sBAAsBP,KAAM;AAC5B;AACA;AACA,0DAA0DL,IAAI,CAACa,WAAY,KAAIxC,mDAAE,CAAC,aAAa,CAAE;AACjG,gBAAgB;IACR;IACA,IAAG2B,IAAI,CAACc,YAAY,EAAC;MACjB,IAAIT,KAAK,GAAI,EAAC;MACd,IAAIC,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;MAClBR,IAAI,CAACS,MAAM,CAACC,OAAO,CAACC,GAAG,IAAI;QACvBN,KAAK,IACJ;AACjB,+CAA+CM,GAAG,CAACI,QAAS;AAC5D,0FAA0FJ,GAAG,CAACK,GAAI;AAClG;AACA,oEAAoEL,GAAG,CAACM,IAAK;AAC7E,uBAAuB;MACX,CAAC,CAAC;MACF,IAAIC,QAAQ,GAAGlB,IAAI,CAACa,WAAW,GAAI,2CAA0Cb,IAAI,CAACa,WAAY,KAAIxC,mDAAE,CAAC,iBAAiB,CAAE,MAAK,GAAG,EAAE;MAElI8B,IAAI,IAAK,eAAcH,IAAI,CAACY,aAAc;AACtD,wHAAwHZ,IAAI,CAACY,aAAc;AAC3I,sBAAsBP,KAAM;AAC5B;AACA,kBAAkBa,QAAS;AAC3B,uBAAuB;IACf;EACJ;EAEA,OAAQ,GAAEf,IAAK,EAAC;AACpB,CAAC;AAEDX,uBAAuB,CAAEL,wCAAQ,EAAE;EAC/BgC,QAAQ,EAAEzB;AACd,CAAE,CAAC,C","sources":["webpack://online-design/./src/js/cart-block/block.js","webpack://online-design/./src/js/cart-block/options.js","webpack://online-design/external window \"React\"","webpack://online-design/external window \"lodash\"","webpack://online-design/external window [\"wc\",\"blocksCheckout\"]","webpack://online-design/external window [\"wc\",\"wcBlocksRegistry\"]","webpack://online-design/external window [\"wp\",\"components\"]","webpack://online-design/external window [\"wp\",\"data\"]","webpack://online-design/external window [\"wp\",\"element\"]","webpack://online-design/external window [\"wp\",\"i18n\"]","webpack://online-design/external window [\"wp\",\"plugins\"]","webpack://online-design/webpack/bootstrap","webpack://online-design/webpack/runtime/compat get default export","webpack://online-design/webpack/runtime/define property getters","webpack://online-design/webpack/runtime/hasOwnProperty shorthand","webpack://online-design/webpack/runtime/make namespace object","webpack://online-design/./src/js/cart-block/frontend.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { SelectControl, TextareaControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { debounce } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { options } from './options';\n\nexport const Block = (props) => {\n\t/**\n\t * setExtensionData will update the wc/store/checkout data store with the values supplied. It\n\t * can be used to pass data from the client to the server when submitting the checkout form.\n\t */\n\t// const { setExtensionData } = checkoutExtensionData;\n\t// /**\n\t// * Debounce the setExtensionData function to avoid multiple calls to the API when rapidly\n\t// * changing options.\n\t// */\n\t// // eslint-disable-next-line react-hooks/exhaustive-deps\n\t// const debouncedSetExtensionData = useCallback(\n\t// \tdebounce((namespace, key, value) => {\n\t// \t\tsetExtensionData(namespace, key, value);\n\t// \t}, 1000),\n\t// \t[setExtensionData]\n\t// );\n\t// console.log(checkoutExtensionData);\n\t// const validationErrorId = 'shipping-workshop-other-value';\n\n\t// const { setValidationErrors, clearValidationError } = useDispatch(\n\t// \t'wc/store/validation'\n\t// );\n\n\t// const validationError = useSelect((select) => {\n\t// \tconst store = select('wc/store/validation');\n\t// \t/**\n\t// \t * [frontend-step-07]\n\t// \t * πŸ“ Write some code to get the validation error from the `wc/store/validation` data store.\n\t// \t * Using the `getValidationError` selector on the `store` object, get the validation error.\n\t// \t *\n\t// \t * The `validationErrorId` variable can be used to get the validation error. Documentation\n\t// \t * on the validation data store can be found here:\n\t// \t * https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/third-party-developers/extensibility/data-store/validation.md\n\t// \t */\n\n\t// \t/**\n\t// \t * [frontend-step-07-extra-credit]\n\t// \t * πŸ’° Extra credit: In the `useEffect` that handles the \"other\" textarea, only call\n\t// \t * `clearValidationError` if the validation error is in the data store already.\n\t// \t */\n\t// });\n\t// const [\n\t// \tselectedAlternateShippingInstruction,\n\t// \tsetSelectedAlternateShippingInstruction,\n\t// ] = useState('try-again');\n\t// const [otherShippingValue, setOtherShippingValue] = useState('');\n\n\t// /* Handle changing the select's value */\n\t// useEffect(() => {\n\t// \t/**\n\t// \t * [frontend-step-02]\n\t// \t * πŸ“ Using `setExtensionData`, write some code in this useEffect that will run when the\n\t// \t * `selectedAlternateShippingInstruction` value changes.\n\t// \t *\n\t// \t * The API of this function is: setExtensionData( namespace, key, value )\n\t// \t *\n\t// \t * This code should use `setExtensionData` to update the `alternateShippingInstruction` key\n\t// \t * in the `shipping-workshop` namespace of the checkout data store.\n\t// \t */\n\t// \t/**\n\t// \t * [frontend-step-02-extra-credit-1]\n\t// \t * πŸ’° Extra credit: Ensure the `setExtensionData` function is not called multiple times. We\n\t// \t * can use the `debouncedSetExtensionData` function for this. The API is the same.\n\t// \t */\n\t// }, [setExtensionData, selectedAlternateShippingInstruction]);\n\n\t// /**\n\t// * [frontend-step-02-extra-credit-2]\n\t// * πŸ’° Extra credit: Use a `useState` to track whether the user has interacted with the \"other\"\n\t// * textbox. If they have, then the validation error should not be hidden when the user changes\n\t// * the select's value. If it is \"pristine\" then we should keep the error hidden.\n\t// */\n\n\t// /* Handle changing the \"other\" value */\n\t// useEffect(() => {\n\t// \t/**\n\t// \t * [frontend-step-03]\n\t// \t * πŸ“ Write some code in this useEffect that will run when the `otherShippingValue` value\n\t// \t * changes. This code should use `setExtensionData` to update the `otherShippingValue` key\n\t// \t * in the `shipping-workshop` namespace of the checkout data store.\n\t// \t */\n\t// \t/**\n\t// \t * [frontend-step-03-extra-credit]\n\t// \t * πŸ’° Extra credit: Ensure the `setExtensionData` function is not called multiple times. We\n\t// \t * can use the `debouncedSetExtensionData` function for this. The API is the same.\n\t// \t */\n\t// \t/**\n\t// \t * [frontend-step-04]\n\t// \t * πŸ“ Write some code that will use `setValidationErrors` to add an entry to the validation\n\t// \t * data store if `otherShippingValue` is empty.\n\t// \t *\n\t// \t * The API of this function is: `setValidationErrors( errors )`.\n\t// \t *\n\t// \t * `errors` is an object with the following shape:\n\t// \t * {\n\t// \t * [ validationErrorId ]: {\n\t// \t * \t\tmessage: string,\n\t// \t *\t \thidden: boolean,\n\t// \t * }\n\t// \t * }\n\t// \t *\n\t// \t * For now, the error should remain hidden until the user has interacted with the field.\n\t// \t *\n\t// \t * [frontend-step-04-extra-credit]\n\t// \t * πŸ’° Extra credit: If the `selectedAlternateShippingInstruction` is not `other` let's skip\n\t// \t * adding the validation error. Make sure to place this code before the\n\t// \t * `setValidationErrors` call, thus, the spoiler of [frontend-step-04] comes after the one\n\t// \t * of [frontend-step-04-extra-credit].\n\t// \t */\n\t// \t/**\n\t// \t * [frontend-step-05]\n\t// \t * πŸ“ Update the above code so that it will use `clearValidationError` to remove the\n\t// \t * validation error from the data store if `selectedAlternateShippingInstruction` is not\n\t// \t * `other`, or if the `otherShippingValue` is not empty.\n\t// \t *\n\t// \t * The API of `clearValidationError` is: `clearValidationError( validationErrorId )`\n\t// \t *\n\t// \t * πŸ’‘Don't forget to update the dependencies of the `useEffect` when you reference new\n\t// \t * functions/variables!\n\t// \t */\n\t// }, [\n\t// \t/**\n\t// \t * [frontend-step-06]\n\t// \t * πŸ’‘ Don't forget to update the dependencies of the `useEffect` when you reference new\n\t// \t * functions/variables!\n\t// \t */\n\t// \totherShippingValue,\n\t// \tsetExtensionData,\n\t// ]);\n\n\treturn (\n\t\t
\n\t\t\t{/**\n\t\t\t * [frontend-step-01]\n\t\t\t * πŸ“ Go to options.js and add some new options to display in the SelectControl below.\n\t\t\t */}\n\t\t\t\n\t\t
\n\t);\n};\n","/**\n * External dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const options = [\n\t{\n\t\tlabel: __('Try again another day', 'shipping-workshop'),\n\t\tvalue: 'try-again',\n\t},\n\t/**\n\t * [frontend-step-01]\n\t * πŸ“ Add more options using the same format as above. Ensure one option has the key \"other\".\n\t */\n];\n","module.exports = window[\"React\"];","module.exports = window[\"lodash\"];","module.exports = window[\"wc\"][\"blocksCheckout\"];","module.exports = window[\"wc\"][\"wcBlocksRegistry\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"plugins\"];","// 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};","/**\n * External dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\nimport { registerCheckoutBlock } from '@woocommerce/blocks-checkout';\nimport { getRegisteredBlockComponents } from '@woocommerce/blocks-registry';\nimport { __ } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport { Block } from './block';\nimport metadata from './block.json';\nconst { registerBlockComponent } = window.wc.wcBlocksRegistry;\nconst { registerCheckoutFilters } = window.wc.blocksCheckout;\n\nconst modifyItemName = ( defaultValue, extensions, args ) => {\n console.log(args);\n var item = args.cartItem.extensions.online_design;\n var html = defaultValue;\n if(typeof item != 'undefined'){\n if(item.nbd_item_key){\n var image = ``;\n var t = Date.now();\n item.images.forEach(img => {\n image += `\n `;\n }\n if(item.nbu_item_key){\n var image = ``;\n var t = Date.now();\n item.images.forEach(img => {\n image += \n `
\n \n \n \n

${img.name}

\n
`;\n });\n var edit_btn = item.edit_design ? `${__('Reupload design')}` : '';\n\n html += `
\n

Upload fileΓ—

\n ${image}\n
\n ${edit_btn}\n
`;\n }\n }\n \n return `${html}`;\n};\n\nregisterCheckoutFilters( metadata, {\n itemName: modifyItemName\n} );"],"names":["useEffect","useState","useCallback","SelectControl","TextareaControl","__","useSelect","useDispatch","debounce","options","Block","props","createElement","className","label","value","registerPlugin","registerCheckoutBlock","getRegisteredBlockComponents","metadata","registerBlockComponent","window","wc","wcBlocksRegistry","registerCheckoutFilters","blocksCheckout","modifyItemName","defaultValue","extensions","args","console","log","item","cartItem","online_design","html","nbd_item_key","image","t","Date","now","images","forEach","img","cart_item_key","edit_design","nbu_item_key","file_url","src","name","edit_btn","itemName"],"sourceRoot":""}