{
  "version": 3,
  "sources": ["/cdn/shop/t/34/assets/product-form.js?guard=20260718"],
  "sourcesContent": ["if (!customElements.get('product-form')) {\n  customElements.define(\n    'product-form',\n    class ProductForm extends HTMLElement {\n      constructor() {\n        super();\n\n        this.form = this.querySelector('form');\n        this.variantIdInput.disabled = false;\n        this.form.addEventListener('submit', this.onSubmitHandler.bind(this));\n        this.cart = document.querySelector('cart-notification') || document.querySelector('cart-drawer');\n        this.submitButton = this.querySelector('[type=\"submit\"]');\n        this.submitButtonText = this.submitButton.querySelector('span');\n\n        if (document.querySelector('cart-drawer')) this.submitButton.setAttribute('aria-haspopup', 'dialog');\n\n        this.hideErrors = this.dataset.hideErrors === 'true';\n        this.sellingPlanGuardEnabled = false;\n        this.sellingPlanBlocked = false;\n        this.sellingPlanGuardTimeouts = [];\n        this.sellingPlanGuardAppliedDisabled = false;\n        this.sellingPlanReadyText = this.submitButtonText?.textContent?.trim() || '';\n\n        this.applySellingPlanFromUrl();\n        this.initSellingPlanGuard();\n      }\n\n      disconnectedCallback() {\n        this.sellingPlanObserver?.disconnect();\n        this.clearSellingPlanGuardTimeouts();\n      }\n\n      onSubmitHandler(evt) {\n        evt.preventDefault();\n        if (this.sellingPlanGuardEnabled && !this.syncSellingPlanGuard()) {\n          this.handleErrorMessage('Please wait a moment while the subscription plan updates.');\n          this.queueSellingPlanGuardSync(120);\n          this.queueSellingPlanGuardSync(350);\n          this.queueSellingPlanGuardSync(800);\n          return;\n        }\n        if (this.submitButton.getAttribute('aria-disabled') === 'true') return;\n\n        this.handleErrorMessage();\n\n        this.submitButton.setAttribute('aria-disabled', true);\n        this.submitButton.classList.add('loading');\n        this.querySelector('.loading__spinner').classList.remove('hidden');\n\n        const config = fetchConfig('javascript');\n        config.headers['X-Requested-With'] = 'XMLHttpRequest';\n        delete config.headers['Content-Type'];\n\n        const formData = new FormData(this.form);\n        if (this.cart) {\n          formData.append(\n            'sections',\n            this.cart.getSectionsToRender().map((section) => section.id)\n          );\n          formData.append('sections_url', window.location.pathname);\n          this.cart.setActiveElement(document.activeElement);\n        }\n        config.body = formData;\n\n        fetch(`${routes.cart_add_url}`, config)\n          .then((response) => response.json())\n          .then((response) => {\n            if (response.status) {\n              publish(PUB_SUB_EVENTS.cartError, {\n                source: 'product-form',\n                productVariantId: formData.get('id'),\n                errors: response.errors || response.description,\n                message: response.message,\n              });\n              this.handleErrorMessage(response.description);\n\n              const soldOutMessage = this.submitButton.querySelector('.sold-out-message');\n              if (!soldOutMessage) return;\n              this.submitButton.setAttribute('aria-disabled', true);\n              this.submitButtonText.classList.add('hidden');\n              soldOutMessage.classList.remove('hidden');\n              this.error = true;\n              return;\n            } else if (!this.cart) {\n              window.location = window.routes.cart_url;\n              return;\n            }\n\n            const startMarker = CartPerformance.createStartingMarker('add:wait-for-subscribers');\n            if (!this.error)\n              publish(PUB_SUB_EVENTS.cartUpdate, {\n                source: 'product-form',\n                productVariantId: formData.get('id'),\n                cartData: response,\n              }).then(() => {\n                CartPerformance.measureFromMarker('add:wait-for-subscribers', startMarker);\n              });\n            this.error = false;\n            const quickAddModal = this.closest('quick-add-modal');\n            if (quickAddModal) {\n              document.body.addEventListener(\n                'modalClosed',\n                () => {\n                  setTimeout(() => {\n                    CartPerformance.measure(\"add:paint-updated-sections\", () => {\n                      this.cart.renderContents(response);\n                    });\n                  });\n                },\n                { once: true }\n              );\n              quickAddModal.hide(true);\n            } else {\n              CartPerformance.measure(\"add:paint-updated-sections\", () => {\n                this.cart.renderContents(response);\n              });\n            }\n          })\n          .catch((e) => {\n            console.error(e);\n          })\n          .finally(() => {\n            this.submitButton.classList.remove('loading');\n            if (this.cart && this.cart.classList.contains('is-empty')) this.cart.classList.remove('is-empty');\n            if (!this.error) this.submitButton.removeAttribute('aria-disabled');\n            this.querySelector('.loading__spinner').classList.add('hidden');\n\n            CartPerformance.measureFromEvent(\"add:user-action\", evt);\n          });\n      }\n\n      handleErrorMessage(errorMessage = false) {\n        if (this.hideErrors) return;\n\n        this.errorMessageWrapper =\n          this.errorMessageWrapper || this.querySelector('.product-form__error-message-wrapper');\n        if (!this.errorMessageWrapper) return;\n        this.errorMessage = this.errorMessage || this.errorMessageWrapper.querySelector('.product-form__error-message');\n\n        this.errorMessageWrapper.toggleAttribute('hidden', !errorMessage);\n\n        if (errorMessage) {\n          this.errorMessage.textContent = errorMessage;\n        }\n      }\n\n      toggleSubmitButton(disable = true, text) {\n        if (!disable && this.sellingPlanGuardEnabled && !this.hasSellingPlan()) {\n          this.syncSellingPlanGuard();\n          return;\n        }\n\n        if (disable) {\n          this.submitButton.setAttribute('disabled', 'disabled');\n          if (text) this.submitButtonText.textContent = text;\n        } else {\n          this.submitButton.removeAttribute('disabled');\n          this.submitButtonText.textContent = window.variantStrings.addToCart;\n        }\n      }\n\n      get variantIdInput() {\n        return this.form.querySelector('[name=id]');\n      }\n\n      applySellingPlanFromUrl() {\n        const sellingPlanId = new URLSearchParams(window.location.search).get('selling_plan')?.trim();\n        const allowedSellingPlanIds = (this.dataset.sellingPlanIds || '')\n          .split(',')\n          .map((id) => id.trim())\n          .filter(Boolean);\n\n        if (\n          !sellingPlanId ||\n          !allowedSellingPlanIds.includes(sellingPlanId) ||\n          this.form.querySelector('[name=\"selling_plan\"]')\n        ) {\n          return;\n        }\n\n        const input = document.createElement('input');\n        input.type = 'hidden';\n        input.name = 'selling_plan';\n        input.value = sellingPlanId;\n        input.className = 'product-form__selling-plan-url';\n        this.form.appendChild(input);\n      }\n\n      initSellingPlanGuard() {\n        const productInfo = this.closest('product-info');\n        const isMonthlyProduct =\n          productInfo?.dataset?.url === '/products/fujiri-monthly-box' ||\n          window.location.pathname === '/products/fujiri-monthly-box';\n\n        if (!isMonthlyProduct) return;\n\n        this.sellingPlanGuardEnabled = true;\n        this.sellingPlanObserver = new MutationObserver(() => this.syncSellingPlanGuard());\n        this.sellingPlanObserver.observe(this.form, {\n          childList: true,\n          subtree: true,\n          attributes: true,\n          attributeFilter: ['value', 'checked', 'selected', 'disabled'],\n        });\n\n        this.form.addEventListener('change', (event) => {\n          if (!event.target.closest('.sealsubs-container') && event.target.name !== 'selling_plan') return;\n\n          this.syncSellingPlanGuard();\n          this.queueSellingPlanGuardSync(100);\n          this.queueSellingPlanGuardSync(300);\n          this.queueSellingPlanGuardSync(700);\n        });\n\n        this.syncSellingPlanGuard();\n        this.queueSellingPlanGuardSync(100);\n        this.queueSellingPlanGuardSync(300);\n        this.queueSellingPlanGuardSync(700);\n        this.queueSellingPlanGuardSync(1500);\n      }\n\n      hasSellingPlan() {\n        return Boolean(this.form.querySelector('[name=\"selling_plan\"]')?.value?.trim());\n      }\n\n      queueSellingPlanGuardSync(delay) {\n        const timeoutId = window.setTimeout(() => this.syncSellingPlanGuard(), delay);\n        this.sellingPlanGuardTimeouts.push(timeoutId);\n      }\n\n      clearSellingPlanGuardTimeouts() {\n        this.sellingPlanGuardTimeouts.forEach((timeoutId) => window.clearTimeout(timeoutId));\n        this.sellingPlanGuardTimeouts = [];\n      }\n\n      syncSellingPlanGuard() {\n        if (!this.sellingPlanGuardEnabled) return true;\n\n        const urlSellingPlanInput = this.form.querySelector('.product-form__selling-plan-url');\n        const appSellingPlanInput = Array.from(this.form.querySelectorAll('[name=\"selling_plan\"]')).find(\n          (input) => input !== urlSellingPlanInput && input.value?.trim()\n        );\n\n        if (urlSellingPlanInput && appSellingPlanInput) {\n          urlSellingPlanInput.remove();\n        }\n\n        if (!this.hasSellingPlan()) {\n          this.sellingPlanBlocked = true;\n          if (!this.submitButton.hasAttribute('disabled')) {\n            this.sellingPlanGuardAppliedDisabled = true;\n            this.submitButton.setAttribute('disabled', 'disabled');\n          }\n          if (this.submitButton.getAttribute('aria-disabled') !== 'true') {\n            this.submitButton.setAttribute('aria-disabled', 'true');\n          }\n          if (this.submitButtonText?.textContent?.trim() !== 'Updating plan...') {\n            this.submitButtonText.textContent = 'Updating plan...';\n          }\n          return false;\n        }\n\n        const wasBlocked = this.sellingPlanBlocked;\n        this.sellingPlanBlocked = false;\n\n        if (this.sellingPlanGuardAppliedDisabled) {\n          this.submitButton.removeAttribute('disabled');\n          this.submitButton.removeAttribute('aria-disabled');\n          this.sellingPlanGuardAppliedDisabled = false;\n        }\n\n        if (this.submitButtonText?.textContent?.trim() === 'Updating plan...') {\n          this.submitButtonText.textContent = this.sellingPlanReadyText || window.variantStrings.addToCart;\n        }\n\n        if (wasBlocked) this.handleErrorMessage();\n        return true;\n      }\n    }\n  );\n}\n"],
  "mappings": "AAAK,eAAe,IAAI,cAAc,GACpC,eAAe,OACb,eACA,cAA0B,WAAY,CACpC,aAAc,CACZ,MAAM,EAEN,KAAK,KAAO,KAAK,cAAc,MAAM,EACrC,KAAK,eAAe,SAAW,GAC/B,KAAK,KAAK,iBAAiB,SAAU,KAAK,gBAAgB,KAAK,IAAI,CAAC,EACpE,KAAK,KAAO,SAAS,cAAc,mBAAmB,GAAK,SAAS,cAAc,aAAa,EAC/F,KAAK,aAAe,KAAK,cAAc,iBAAiB,EACxD,KAAK,iBAAmB,KAAK,aAAa,cAAc,MAAM,EAE1D,SAAS,cAAc,aAAa,GAAG,KAAK,aAAa,aAAa,gBAAiB,QAAQ,EAEnG,KAAK,WAAa,KAAK,QAAQ,aAAe,OAC9C,KAAK,wBAA0B,GAC/B,KAAK,mBAAqB,GAC1B,KAAK,yBAA2B,CAAC,EACjC,KAAK,gCAAkC,GACvC,KAAK,qBAAuB,KAAK,kBAAkB,aAAa,KAAK,GAAK,GAE1E,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,CAC5B,CAEA,sBAAuB,CACrB,KAAK,qBAAqB,WAAW,EACrC,KAAK,8BAA8B,CACrC,CAEA,gBAAgB,IAAK,CAEnB,GADA,IAAI,eAAe,EACf,KAAK,yBAA2B,CAAC,KAAK,qBAAqB,EAAG,CAChE,KAAK,mBAAmB,2DAA2D,EACnF,KAAK,0BAA0B,GAAG,EAClC,KAAK,0BAA0B,GAAG,EAClC,KAAK,0BAA0B,GAAG,EAClC,MACF,CACA,GAAI,KAAK,aAAa,a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