{"version":3,"sources":["webpack:///resources/js/src/app/components/item/QuantityInput.vue","webpack:///./resources/js/src/app/components/item/QuantityInput.vue?b65e","webpack:///./resources/js/src/app/components/item/QuantityInput.vue","webpack:///./resources/js/src/app/components/item/QuantityInput.vue?2b01","webpack:///./resources/js/src/app/components/item/QuantityInput.vue?de93"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;AACA;AACA;AACA;AAEA;AACA,wBADA;AAGA;AACA;AACA,kBADA;AAEA;AAFA,KADA;AAKA;AACA,kBADA;AAEA,qBAFA;AAGA;AAHA,KALA;AAUA;AACA,kBADA;AAEA,qBAFA;AAGA;AAHA,KAVA;AAeA;AACA,kBADA;AAEA;AAFA,KAfA;AAmBA;AACA,kBADA;AAEA,qBAFA;AAGA;AAHA,KAnBA;AAwBA;AACA,mBADA;AAEA;AAFA,KAxBA;AA4BA;AACA,kBADA;AAEA;AAFA,KA5BA;AAgCA;AAhCA,GAHA;AAsCA,MAtCA,kBAuCA;AACA;AACA,2BADA;AAEA,uBAFA;AAGA,uBAHA;AAIA,iCAJA;AAKA,qBALA;AAMA;AANA;AAQA,GAhDA;AAkDA,SAlDA,qBAmDA;AAAA;;AACA;AACA;AAEA;AACA;AAEA;AAEA,yGACA;AACA;AACA,KAHA,EAGA,sFAHA;;AAKA,qGACA;AACA;AACA;AACA,GArEA;AAuEA;AAEA,2BAFA,qCAGA;AAAA;;AACA,sGACA;AACA;AACA;;AAEA,wFACA;AACA;AAAA;AAAA;AAEA;AACA;;AAEA;AACA,KAjBA;AAmBA,aAnBA,uBAoBA;AACA;AACA,KAtBA;AAwBA,aAxBA,uBAyBA;AACA;AACA,KA3BA;AA6BA,eA7BA,yBA8BA;AACA,6BACA,uCADA,EAEA;AACA;AADA,OAFA;AAMA,KArCA;AAuCA,eAvCA,yBAwCA;AACA,6BACA,uCADA,EAEA;AACA;AADA,OAFA;AAMA,KA/CA;AAiDA,gBAjDA,0BAkDA;AACA;AACA,KApDA;AAsDA,sBAtDA,gCAuDA;AACA,iDACA;AACA;AACA;;AAEA;AACA;AA9DA,KAgEA;AACA;AAAA;AAAA;AADA,IAhEA,CAvEA;AA4IA,SACA;AACA,eADA,uBACA,QADA,EAEA;AACA,sFACA;AACA;AACA;AACA,KAPA;AASA,iBACA;AACA,aADA,mBACA,QADA,EACA,QADA,EAEA;AACA,gGACA;AACA;AACA;AACA,OAPA;AAQA;AARA,KAVA;AAqBA,OArBA,eAqBA,QArBA,EAsBA;AACA;AACA;AACA,KAzBA;AA2BA,OA3BA,eA2BA,QA3BA,EA4BA;AACA;AACA;AACA,KA/BA;AAiCA,SAjCA,iBAiCA,QAjCA,EAiCA,QAjCA,EAkCA;AACA,iCACA;AACA;AACA;AACA,KAvCA;AAyCA,YAzCA,oBAyCA,WAzCA,EA0CA;AACA;AACA;AA5CA,GA7IA;AA4LA,WACA;AACA,iBADA,2BAEA;AACA;;AAEA,iJACA;AACA;AACA;AACA,KATA;AAWA,iBAXA,2BAYA;AACA;;AAEA,iJACA;AACA;AACA;AACA,KAnBA;AAqBA,YArBA,oBAqBA,KArBA,EAsBA;AACA;AACA,qCACA;AACA;AACA;;AAEA;;AACA,wBACA;AACA;AACA,OAXA,CAaA;;;AACA,+GAdA,CAgBA;;AACA;;AACA,gEACA;AACA;AACA,OAHA,MAKA;AACA;AACA;;AAEA,kDACA;AACA,0CACA;AACA;AACA,SAHA,MAKA;AACA;AACA;;AACA;AACA,OAtCA,CAwCA;;;AACA;;AAEA,oCACA;AACA;AACA;AACA,OAJA,MAKA,8GACA;AACA;AACA;AACA,KA1EA;AA4EA,2BA5EA,qCA6EA;AACA,iLACA;AACA;AACA;AACA,OAJA,MAKA,wCACA;AACA;AACA;AACA;;AAEA,+FACA;AACA;AACA;;AAEA,yEACA;AACA;AACA;AACA;AACA,SALA,MAOA;AACA;AACA;AACA,OAfA,MAiBA;AACA;AACA;;AAEA;AACA;AA/GA;AA7LA,G;;;;;;;;;;;;AC5CA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA,oBAAoB,sCAAsC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,iBAAiB,0BAA0B;AAC3C;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,eAAe,sDAAsD;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,oBAAoB;AACpB,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,oBAAoB;AACpB,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACzGA;AAAA;AAAA;AAAA;AAA4F;AAC3B;AACL;;;AAG5D;AACsG;AACtG,gBAAgB,2GAAU;AAC1B,EAAE,mFAAM;AACR,EAAE,wFAAM;AACR,EAAE,iGAAe;AACjB;AACA;AACA;AACA;;AAEA;;AAEA;AACA,IAAI,KAAU,EAAE,YAiBf;AACD;AACe,gF;;;;;;;;;;;;ACtCf;AAAA;AAAA,wCAAqM,CAAgB,iPAAG,EAAC,C;;;;;;;;;;;;ACAzN;AAAA;AAAA;AAAA;AAAA;AAAA","file":"chunks/ceres-0.js","sourcesContent":["<template>\n    <div class=\"qty-box d-flex h-100\">\n        <input class=\"qty-input text-center\"\n               type=\"text\"\n               :value=\"displayValue\"\n               @change=\"setValue($event.target.value)\"\n               :disabled=\"waiting\"\n               ref=\"quantityInputField\"\n               :aria-label=\"$translate('Ceres::Template.itemQuantityInput')\">\n\n        <div class=\"qty-btn-container d-flex flex-column\">\n            <button class=\"btn qty-btn flex-fill d-flex justify-content-center p-0\"\n                 @click=\"increaseValue()\"\n                 :class=\"{ 'disabled': isMaximum || waiting, 'btn-appearance': useAppearance }\"\n                 v-tooltip=\"isMaximum && compMax !== 0\"\n                 data-toggle=\"tooltip\"\n                 data-placement=\"top\"\n                 data-testing=\"quantity-btn-increase\"\n                 :title=\"maximumHint\"\n                 :aria-label=\"$translate('Ceres::Template.itemQuantityInputIncrease')\">\n                <i class=\"fa fa-plus default-float\" aria-hidden=\"true\"></i>\n            </button>\n\n            <button class=\"btn qty-btn flex-fill d-flex justify-content-center p-0\"\n                 @click=\"decreaseValue()\"\n                 :class=\"{ 'disabled': isMinimum || waiting, 'btn-appearance': useAppearance }\"\n                 v-tooltip=\"isMinimum && compMax !== 0\"\n                 data-toggle=\"tooltip\"\n                 data-placement=\"bottom\"\n                 data-testing=\"quantity-btn-decrease\"\n                 :title=\"minimumHint\"\n                 :aria-label=\"$translate('Ceres::Template.itemQuantityInputDecrease')\">\n                <i class=\"fa fa-minus default-float\" aria-hidden=\"true\"></i>\n            </button>\n        </div>\n    </div>\n</template>\n\n<script>\nimport { floatLength, formatFloat, limit } from \"../../helper/number\";\nimport { defaultValue, isDefined, isNullOrUndefined } from \"../../helper/utils\";\nimport { debounce } from \"../../helper/debounce\";\nimport { mapState } from \"vuex\";\n\nexport default {\n    name: \"quantity-input\",\n\n    props: {\n        value: {\n            type: Number,\n            required: true\n        },\n        timeout: {\n            type: Number,\n            required: false,\n            default: 500\n        },\n        min: {\n            type: Number,\n            required: false,\n            default: 0\n        },\n        max: {\n            type: Number,\n            required: false\n        },\n        interval: {\n            type: Number,\n            required: false,\n            default: 1\n        },\n        waiting: {\n            type: Boolean,\n            required: false\n        },\n        variationId: {\n            type: Number,\n            required: false\n        },\n        useAppearance: Boolean\n    },\n\n    data()\n    {\n        return {\n            compValue:      this.value,\n            compMin:        this.min,\n            compMax:        this.max,\n            compInterval:   this.interval,\n            compDecimals:   0,\n            onValueChanged: null\n        };\n    },\n\n    created()\n    {\n        this.compInterval = defaultValue(this.compInterval, 1);\n        this.compInterval = this.compInterval === 0 ? 1 : this.compInterval;\n\n        const minDecimals = floatLength(this.min);\n        const intervalDecimals = floatLength(this.compInterval);\n\n        this.compDecimals = Math.max(minDecimals, intervalDecimals);\n\n        this.onValueChanged = debounce(() =>\n        {\n            this.$emit(\"quantity-change\", this.compValue);\n        }, defaultValue(this.timeout, 500));\n\n        if (!isNullOrUndefined(this.variationId))\n        {\n            this.fetchQuantityFromBasket();\n        }\n    },\n\n    computed:\n    {\n        variationBasketQuantity()\n        {\n            if (isNullOrUndefined(this.variationId))\n            {\n                return 0;\n            }\n\n            if(this.itemSetVariationId <= 0 || this.variationId === this.itemSetVariationId)\n            {\n                const basketObject = this.$store.state.basket.items.find(variations => variations.variationId === this.variationId);\n\n                return basketObject ? basketObject.quantity : 0;\n            }\n\n            return 0;\n        },\n\n        isMinimum()\n        {\n            return isDefined(this.compMin) && (this.compValue - this.compInterval) < this.compMin;\n        },\n\n        isMaximum()\n        {\n            return isDefined(this.compMax) && (this.compValue + this.compInterval) > this.compMax;\n        },\n\n        minimumHint()\n        {\n            return this.$translate(\n                \"Ceres::Template.singleItemQuantityMin\",\n                {\n                    min: this.$options.filters.numberFormat(this.compMin)\n                }\n            );\n        },\n\n        maximumHint()\n        {\n            return this.$translate(\n                \"Ceres::Template.singleItemQuantityMax\",\n                {\n                    max: this.$options.filters.numberFormat(this.max)\n                }\n            );\n        },\n\n        displayValue()\n        {\n            return this.$options.filters.numberFormat(this.compValue);\n        },\n\n        itemSetVariationId()\n        {\n            if (this.$store.state.items.itemSetId > 0)\n            {\n                return this.$store.getters[`${this.$store.state.items.itemSetId}/currentItemVariation`].variation.id;\n            }\n\n            return 0;\n        },\n\n        ...mapState({\n            basketItems: state => state.basket.items\n        })\n    },\n\n    watch:\n    {\n        variationId(newValue)\n        {\n            if (isDefined(newValue))\n            {\n                this.fetchQuantityFromBasket();\n            }\n        },\n\n        basketItems:\n        {\n            handler(newValue, oldValue)\n            {\n                if (isDefined(this.variationId))\n                {\n                    this.fetchQuantityFromBasket();\n                }\n            },\n            deep: true\n        },\n\n        min(newValue)\n        {\n            this.compMin = newValue;\n            this.fetchQuantityFromBasket();\n        },\n\n        max(newValue)\n        {\n            this.compMax = newValue;\n            this.fetchQuantityFromBasket();\n        },\n\n        value(newValue, oldValue)\n        {\n            if (newValue !== oldValue)\n            {\n                this.setValue(newValue);\n            }\n        },\n\n        interval(newInterval)\n        {\n            this.compInterval = defaultValue(newInterval, 1)\n        }\n    },\n\n    methods:\n    {\n        increaseValue()\n        {\n            const newValue = formatFloat(this.compValue + this.compInterval, this.compDecimals);\n\n            if ((isNullOrUndefined(this.compMax) || newValue <= this.compMax) && !this.waiting)\n            {\n                this.setValue(newValue);\n            }\n        },\n\n        decreaseValue()\n        {\n            const newValue = formatFloat(this.compValue - this.compInterval, this.compDecimals);\n\n            if ((isNullOrUndefined(this.compMin) || newValue >= this.compMin) && !this.waiting)\n            {\n                this.setValue(newValue);\n            }\n        },\n\n        setValue(value)\n        {\n            // consider the configured decimal seperator (if the input is typed in the input field)\n            if (typeof value === \"string\")\n            {\n                value = value.replace(App.decimalSeparator || \",\", \".\");\n            }\n\n            value = parseFloat(value);\n            if (isNaN(value))\n            {\n                value = defaultValue(this.compMin, 1);\n            }\n\n            // limit new value to min/ max value\n            value = limit(value, this.compMin, this.compMax);\n\n            // make sure, new value is an even multiple of interval\n            let diff;\n            if (this.variationBasketQuantity === 0 && this.min !== 0)\n            {\n                diff = formatFloat((value - this.min) % this.compInterval, this.compDecimals, true);\n            }\n            else\n            {\n                diff = formatFloat(value % this.compInterval, this.compDecimals, true);\n            }\n\n            if (diff > 0 && diff !== this.compInterval)\n            {\n                if (diff < this.compInterval / 2)\n                {\n                    value -= diff;\n                }\n                else\n                {\n                    value += this.compInterval - diff;\n                }\n                value = limit(value, this.compMin, this.compMax);\n            }\n\n            // cut fraction\n            value = formatFloat(value, this.compDecimals);\n\n            if (value !== this.compValue)\n            {\n                this.compValue = value;\n                this.onValueChanged();\n            }\n            else if (!isNullOrUndefined(this.$refs.quantityInputField))\n            {\n                this.$refs.quantityInputField.value = this.displayValue;\n            }\n        },\n\n        fetchQuantityFromBasket()\n        {\n            if (!isNullOrUndefined(this.min) && this.variationBasketQuantity >= this.min && this.variationBasketQuantity !== 0)\n            {\n                // set the minimum value to the interval, if the item is already in the basket\n                this.compMin = this.compInterval;\n            }\n            else if (this.variationBasketQuantity === 0)\n            {\n                // reset the minimum, when item is not in the basket\n                this.compMin = this.min;\n            }\n\n            if (!isNullOrUndefined(this.max))\n            {\n                // decrease maximum quantity by quantity of variations already in basket\n                this.compMax = this.max - this.variationBasketQuantity;\n\n                if (this.variationBasketQuantity + this.compInterval > this.max)\n                {\n                    this.compMin = 0;\n                    this.compMax = 0;\n                    this.$emit(\"out-of-stock\", true);\n                }\n                else\n                {\n                    this.$emit(\"out-of-stock\", false);\n                }\n            }\n            else\n            {\n                this.$emit(\"out-of-stock\", false);\n            }\n\n            this.setValue(this.compMin);\n        }\n    }\n}\n</script>\n","var render = function() {\n  var _vm = this\n  var _h = _vm.$createElement\n  var _c = _vm._self._c || _h\n  return _c(\"div\", { staticClass: \"qty-box d-flex h-100\" }, [\n    _c(\"input\", {\n      ref: \"quantityInputField\",\n      staticClass: \"qty-input text-center\",\n      attrs: {\n        type: \"text\",\n        disabled: _vm.waiting,\n        \"aria-label\": _vm.$translate(\"Ceres::Template.itemQuantityInput\")\n      },\n      domProps: { value: _vm.displayValue },\n      on: {\n        change: function($event) {\n          return _vm.setValue($event.target.value)\n        }\n      }\n    }),\n    _vm._v(\" \"),\n    _c(\"div\", { staticClass: \"qty-btn-container d-flex flex-column\" }, [\n      _c(\n        \"button\",\n        {\n          directives: [\n            {\n              name: \"tooltip\",\n              rawName: \"v-tooltip\",\n              value: _vm.isMaximum && _vm.compMax !== 0,\n              expression: \"isMaximum && compMax !== 0\"\n            }\n          ],\n          staticClass:\n            \"btn qty-btn flex-fill d-flex justify-content-center p-0\",\n          class: {\n            disabled: _vm.isMaximum || _vm.waiting,\n            \"btn-appearance\": _vm.useAppearance\n          },\n          attrs: {\n            \"data-toggle\": \"tooltip\",\n            \"data-placement\": \"top\",\n            \"data-testing\": \"quantity-btn-increase\",\n            title: _vm.maximumHint,\n            \"aria-label\": _vm.$translate(\n              \"Ceres::Template.itemQuantityInputIncrease\"\n            )\n          },\n          on: {\n            click: function($event) {\n              return _vm.increaseValue()\n            }\n          }\n        },\n        [\n          _c(\"i\", {\n            staticClass: \"fa fa-plus default-float\",\n            attrs: { \"aria-hidden\": \"true\" }\n          })\n        ]\n      ),\n      _vm._v(\" \"),\n      _c(\n        \"button\",\n        {\n          directives: [\n            {\n              name: \"tooltip\",\n              rawName: \"v-tooltip\",\n              value: _vm.isMinimum && _vm.compMax !== 0,\n              expression: \"isMinimum && compMax !== 0\"\n            }\n          ],\n          staticClass:\n            \"btn qty-btn flex-fill d-flex justify-content-center p-0\",\n          class: {\n            disabled: _vm.isMinimum || _vm.waiting,\n            \"btn-appearance\": _vm.useAppearance\n          },\n          attrs: {\n            \"data-toggle\": \"tooltip\",\n            \"data-placement\": \"bottom\",\n            \"data-testing\": \"quantity-btn-decrease\",\n            title: _vm.minimumHint,\n            \"aria-label\": _vm.$translate(\n              \"Ceres::Template.itemQuantityInputDecrease\"\n            )\n          },\n          on: {\n            click: function($event) {\n              return _vm.decreaseValue()\n            }\n          }\n        },\n        [\n          _c(\"i\", {\n            staticClass: \"fa fa-minus default-float\",\n            attrs: { \"aria-hidden\": \"true\" }\n          })\n        ]\n      )\n    ])\n  ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\nexport { render, staticRenderFns }","import { render, staticRenderFns } from \"./QuantityInput.vue?vue&type=template&id=62163595&\"\nimport script from \"./QuantityInput.vue?vue&type=script&lang=js&\"\nexport * from \"./QuantityInput.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  null,\n  null\n  \n)\n\n/* hot reload */\nif (module.hot) {\n  var api = require(\"/home/runner/work/plugin-ceres/plugin-ceres/node_modules/vue-hot-reload-api/dist/index.js\")\n  api.install(require('vue'))\n  if (api.compatible) {\n    module.hot.accept()\n    if (!api.isRecorded('62163595')) {\n      api.createRecord('62163595', component.options)\n    } else {\n      api.reload('62163595', component.options)\n    }\n    module.hot.accept(\"./QuantityInput.vue?vue&type=template&id=62163595&\", function () {\n      api.rerender('62163595', {\n        render: render,\n        staticRenderFns: staticRenderFns\n      })\n    })\n  }\n}\ncomponent.options.__file = \"resources/js/src/app/components/item/QuantityInput.vue\"\nexport default component.exports","import mod from \"-!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./QuantityInput.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./QuantityInput.vue?vue&type=script&lang=js&\"","export * from \"-!../../../../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./QuantityInput.vue?vue&type=template&id=62163595&\""],"sourceRoot":""}