OwlCyberSecurity - MANAGER
Edit File: add-to-cart-form.js
(()=>{var e,t,o,n={9535:(e,t,o)=>{"use strict";o.r(t);var n=o(1609),r=o(2294);const i=window.wp.blocks,c=window.wp.data,s=window.wc.wcTypes;class a{constructor(){(0,r.A)(this,"blocks",new Map),(0,r.A)(this,"currentTemplateId",void 0),(0,r.A)(this,"initialized",!1),(0,r.A)(this,"attemptedRegisteredBlocks",new Set),this.initializeSubscriptions()}static getInstance(){return a.instance||(a.instance=new a),a.instance}parseTemplateId(e){const t=(0,s.isNumber)(e)?void 0:e;return null==t?void 0:t.split("//")[1]}initializeSubscriptions(){if(this.initialized)return;const e=(0,c.subscribe)((()=>{const t=(0,c.select)("core/edit-site"),o=(0,c.select)("core/edit-post");if(t||o)if(t){const o=t.getEditedPostId();e(),this.currentTemplateId="string"==typeof o?this.parseTemplateId(o):void 0,(0,c.subscribe)((()=>{const e=this.currentTemplateId;this.currentTemplateId=this.parseTemplateId(t.getEditedPostId()),e!==this.currentTemplateId&&this.handleTemplateChange(e)}),"core/edit-site"),this.initialized=!0}else o&&(e(),this.blocks.forEach((e=>{if(e.isAvailableOnPostEditor){const t=e.variationName||e.blockName;this.hasAttemptedRegistration(t)||this.registerBlock(e)}})),this.initialized=!0)}))}handleTemplateChange(e){var t;((null===(t=this.currentTemplateId)||void 0===t?void 0:t.includes("single-product"))||(null==e?void 0:e.includes("single-product")))&&this.blocks.forEach((e=>{this.unregisterBlock(e),this.registerBlock(e)}))}hasAttemptedRegistration(e){return this.attemptedRegisteredBlocks.has(e)}unregisterBlock(e){const{blockName:t,isVariationBlock:o,variationName:n}=e;try{o&&n?((0,i.unregisterBlockVariation)(t,n),this.attemptedRegisteredBlocks.delete(n)):((0,i.unregisterBlockType)(t),this.attemptedRegisteredBlocks.delete(t))}catch(e){console.debug(`Failed to unregister block ${t}:`,e)}}registerBlock(e){const{blockName:t,settings:o,isVariationBlock:n,variationName:r,isAvailableOnPostEditor:a}=e;try{const e=r||t;if(this.hasAttemptedRegistration(e))return;const d=(0,c.select)("core/edit-site");if(!d&&!a)return;if(n)(0,i.registerBlockVariation)(t,o);else{var l;const e=(0,s.isEmpty)(null==o?void 0:o.ancestor)?["woocommerce/single-product"]:null==o?void 0:o.ancestor,n=d&&(null===(l=this.currentTemplateId)||void 0===l?void 0:l.includes("single-product"));(0,i.registerBlockType)(t,{...o,ancestor:n?void 0:e})}this.attemptedRegisteredBlocks.add(e)}catch(e){console.error(`Failed to register block ${t}:`,e)}}registerBlockConfig(e){const t=e.variationName||e.blockName;this.blocks.set(t,e),this.registerBlock(e)}}(0,r.A)(a,"instance",void 0);var l=o(7104),d=o(498);const u=JSON.parse('{"name":"woocommerce/add-to-cart-form","version":"1.0.0","title":"Add to Cart with Options","description":"Display a button so the customer can add a product to their cart. Options will also be displayed depending on product type. e.g. quantity, variation.","category":"woocommerce-product-elements","attributes":{"quantitySelectorStyle":{"type":"string","enum":["input","stepper"],"default":"input"}},"keywords":["WooCommerce"],"usesContext":["postId"],"textdomain":"woocommerce","supports":{"interactivity":true},"apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),p=window.wp.blockEditor;var m=o(7723);o(6455);const b=({numberOfLines:e=1,tag:t="div",maxWidth:o="100%"})=>{const r=Array.from({length:e},((e,t)=>(0,n.createElement)("span",{className:"wc-block-components-skeleton-text-line","aria-hidden":"true",key:t})));return(0,n.createElement)(t,{className:"wc-block-components-skeleton",style:{maxWidth:o}},r)},w=window.wp.components,k=window.wc.wcSettings;o(5375);let g=function(e){return e.Input="input",e.Stepper="stepper",e}({});const f=e=>e===g.Input?(0,m.__)("Shoppers can enter a number of items to add to cart.","woocommerce"):e===g.Stepper?(0,m.__)("Shoppers can use buttons to change the number of items to add to cart.","woocommerce"):void 0,h=({quantitySelectorStyle:e,setAttributes:t,features:o})=>{const{isStepperLayoutFeatureEnabled:r}=o;return(0,n.createElement)(p.InspectorControls,null,r&&(0,n.createElement)(w.PanelBody,{title:(0,m.__)("Quantity Selector","woocommerce")},(0,n.createElement)(w.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,value:e,isBlock:!0,onChange:e=>{t({quantitySelectorStyle:e})},help:f(e)},(0,n.createElement)(w.__experimentalToggleGroupControlOption,{label:(0,m.__)("Input","woocommerce"),value:g.Input}),(0,n.createElement)(w.__experimentalToggleGroupControlOption,{label:(0,m.__)("Stepper","woocommerce"),value:g.Stepper}))))},v=(0,k.getSettingWithCoercion)("isBlockifiedAddToCart",!1,s.isBoolean),y=(0,k.getSetting)("isBlockTheme"),_=(()=>{const{experimentalBlocksEnabled:e}=(0,k.getSetting)("wcBlocksConfig",{experimentalBlocksEnabled:!1});return e})()&&v&&y;var E=o(6087),S=o(4922),B=o.n(S);B()("wc-admin:tracks:stats");const O=B()("wc-admin:tracks");var C=o(851);function x({children:e,className:t,actionLabel:o,onActionClick:r,...i}){return(0,n.createElement)(w.Notice,{...i,className:(0,C.$)("wc-block-editor-components-upgrade-downgrade-notice",t),actions:[{label:o,onClick:r,noDefaultClasses:!0,variant:"link"}]},(0,n.createElement)("div",{className:"wc-block-editor-components-upgrade-downgrade-notice__text"},e))}o(2615);const N=({blocks:e,findCondition:t})=>{for(const o of e){if(t(o))return o;if(o.innerBlocks){const e=N({blocks:o.innerBlocks,findCondition:t});if(e)return e}}},T=({blockClientId:e})=>{const t=(0,E.createInterpolateElement)((0,m.__)("Upgrade the Add to Cart with Options block to <strongText /> for more features!","woocommerce"),{strongText:(0,n.createElement)("strong",null,(0,m.__)("a new blockified experience","woocommerce"))}),o=(0,m.__)("Upgrade to the blockified Add to Cart with Options block","woocommerce");return(0,n.createElement)(x,{isDismissible:!1,actionLabel:o,onActionClick:async()=>{const t=await(async e=>{const t=(0,c.select)("core/block-editor").getBlocks(),o=N({blocks:t,findCondition:t=>t.name===u.name&&t.clientId===e});if(!o)return!1;const n=(0,i.createBlock)("woocommerce/add-to-cart-with-options",{isDescendentOfSingleProductBlock:o.attributes.isDescendentOfSingleProductBlock});return(0,c.dispatch)("core/block-editor").replaceBlock(o.clientId,n),!0})(e);t&&function(e,t){if(O("recordevent %s %o","wcadmin_"+e,t,{_tqk:window._tkq,shouldRecord:!!window._tkq&&!!window.wcTracks&&!!window.wcTracks.isEnabled}),!window.wcTracks||"function"!=typeof window.wcTracks.recordEvent)return!1;window.wcTracks.recordEvent(e,t)}("blocks_add_to_cart_with_options_migration",{transform_to:"blockified"})}},t)};o(6515),o(5193),(e=>{const t=e.name;if(!t)return void console.error("registerProductBlockType: Block name is required for registration");const o=(({name:e,...t})=>t)(e),{isVariationBlock:n,variationName:r,isAvailableOnPostEditor:i,...c}={...o,...{isAvailableOnPostEditor:!0}||{}},s={blockName:t,settings:{...c},isVariationBlock:null!=n&&n,variationName:null!=r?r:void 0,isAvailableOnPostEditor:null!=i&&i};a.getInstance().registerBlockConfig(s)})({...u,edit:e=>{const{setAttributes:t}=e,o=(0,k.getSettingWithCoercion)("isStepperLayoutFeatureEnabled",!1,s.isBoolean),r=e.attributes.quantitySelectorStyle!==g.Input&&o?"wc-block-add-to-cart-form--stepper":"wc-block-add-to-cart-form--input",i=(0,p.useBlockProps)({className:`wc-block-add-to-cart-form ${r}`}),a=(0,c.useSelect)((e=>(e=>{if(!(e=>null===e)(t=e)&&t instanceof Object&&t.constructor===Object){const t=e.getEditedPostType();return"wp_template"===t||"wp_template_part"===t}var t;return!1})(e("core/edit-site"))),[]);return(0,n.createElement)(n.Fragment,null,_&&(0,n.createElement)(p.InspectorControls,null,(0,n.createElement)(T,{blockClientId:null==e?void 0:e.clientId})),(0,n.createElement)(h,{quantitySelectorStyle:e.attributes.quantitySelectorStyle,setAttributes:t,features:{isStepperLayoutFeatureEnabled:o}}),(0,n.createElement)("div",{...i},(0,n.createElement)(w.Tooltip,{text:(0,m.__)("Customer will see product add-to-cart options in this space, dependent on the product type.","woocommerce"),position:"bottom right"},(0,n.createElement)("div",{className:"wc-block-editor-add-to-cart-form-container"},(0,n.createElement)(b,{numberOfLines:3}),(0,n.createElement)(w.Disabled,null,(e.attributes.quantitySelectorStyle===g.Input||!o)&&(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"quantity"},(0,n.createElement)("input",{style:a?{}:{backgroundColor:"#ffffff",lineHeight:"normal",minHeight:"unset",boxSizing:"unset",borderRadius:"unset"},type:"number",value:"1",className:"input-text qty text",readOnly:!0})),(0,n.createElement)("button",{className:"single_add_to_cart_button alt wp-element-button"},(0,m.__)("Add to cart","woocommerce"))),e.attributes.quantitySelectorStyle===g.Stepper&&o&&(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"quantity wc-block-components-quantity-selector"},(0,n.createElement)("button",{className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus"},"-"),(0,n.createElement)("input",{style:a?{}:{backgroundColor:"#ffffff",lineHeight:"normal",minHeight:"unset",boxSizing:"unset",borderRadius:"unset"},type:"number",value:"1",className:"input-text qty text",readOnly:!0}),(0,n.createElement)("button",{className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus"},"+")),(0,n.createElement)("button",{className:"single_add_to_cart_button alt wp-element-button"},(0,m.__)("Add to cart","woocommerce"))))))))},icon:{src:(0,n.createElement)(l.A,{icon:d.A,className:"wc-block-editor-components-block-icon"})},ancestor:["woocommerce/single-product"],save:()=>null})},5193:()=>{},6455:()=>{},5375:()=>{},6515:()=>{},2615:()=>{},1609:e=>{"use strict";e.exports=window.React},6087:e=>{"use strict";e.exports=window.wp.element},7723:e=>{"use strict";e.exports=window.wp.i18n},5573:e=>{"use strict";e.exports=window.wp.primitives}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var o=r[e]={exports:{}};return n[e].call(o.exports,o,o.exports,i),o.exports}i.m=n,e=[],i.O=(t,o,n,r)=>{if(!o){var c=1/0;for(d=0;d<e.length;d++){for(var[o,n,r]=e[d],s=!0,a=0;a<o.length;a++)(!1&r||c>=r)&&Object.keys(i.O).every((e=>i.O[e](o[a])))?o.splice(a--,1):(s=!1,r<c&&(c=r));if(s){e.splice(d--,1);var l=n();void 0!==l&&(t=l)}}return t}r=r||0;for(var d=e.length;d>0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[o,n,r]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var r=Object.create(null);i.r(r);var c={};t=t||[null,o({}),o([]),o(o)];for(var s=2&n&&e;"object"==typeof s&&!~t.indexOf(s);s=o(s))Object.getOwnPropertyNames(s).forEach((t=>c[t]=()=>e[t]));return c.default=()=>e,i.d(r,c),r},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=2100,(()=>{var e={2100:0};i.O.j=t=>0===e[t];var t=(t,o)=>{var n,r,[c,s,a]=o,l=0;if(c.some((t=>0!==e[t]))){for(n in s)i.o(s,n)&&(i.m[n]=s[n]);if(a)var d=a(i)}for(t&&t(o);l<c.length;l++)r=c[l],i.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return i.O(d)},o=self.webpackChunkwebpackWcBlocksMainJsonp=self.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var c=i.O(void 0,[94],(()=>i(9535)));c=i.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["add-to-cart-form"]=c})();