(()=>{var t,e,o,r={8526:(t,e,o)=>{"use strict";const r=window.wp.blocks;var i=o(4530),n=o(1331);const s=JSON.parse('{"name":"woocommerce/add-to-cart-with-options-variation-selector-attribute-options","title":"Variation Selector: Attribute Options (Beta)","description":"Display the attribute options associated with a variable product.","category":"woocommerce-product-elements","keywords":["WooCommerce"],"ancestor":["woocommerce/add-to-cart-with-options-variation-selector-attribute"],"attributes":{"optionStyle":{"type":"string","enum":["pills","dropdown"]}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json","supports":{"inserter":false,"interactivity":true},"usesContext":["woocommerce/attributeId","woocommerce/attributeName","woocommerce/attributeTerms"],"style":"file:../woocommerce/add-to-cart-with-options-variation-selector-attribute-options-style.css"}');var l=o(7723);const a=window.wp.blockEditor,c=window.wp.components,d=window.wc.wcBlocksSharedContext;var u=o(4921),p=o(6087),w=o(790);function b({id:t,options:e}){return(0,w.jsx)("ul",{id:t,className:"wc-block-add-to-cart-with-options-variation-selector-attribute-options__pills",children:e.map(((t,e)=>(0,w.jsx)("li",{className:(0,u.A)("wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill",{"wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill--selected":0===e,"wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill--disabled":t.disabled}),children:t.label},t.value)))})}o(8180),(0,r.registerBlockType)(s,{edit:function(t){const{attributes:e,setAttributes:o}=t,{className:r,optionStyle:i}=e,n=(0,a.useBlockProps)({className:r});((t,e)=>{const o=(0,p.useRef)(null);(0,p.useEffect)((()=>{let r=document.querySelector(".editor-styles-wrapper");if(!r){const t=document.querySelector(".edit-site-visual-editor__editor-canvas");if(!(t&&t instanceof HTMLIFrameElement))return;const e=t.contentDocument||t.contentWindow?.document;if(!e)return;r=e.querySelector(".editor-styles-wrapper")}if(!r)return;const i=window.getComputedStyle(r),n=i?.backgroundColor,s=i?.color;if(!n||!s)return;const l=`${t}-editor-theme-colors`;let a=r.querySelector(`#${l}`);a||(a=document.createElement("style"),a.id=l,r.appendChild(a)),o.current=a;const c=e({editorBackgroundColor:n,editorColor:s});a.textContent=c;const d=new MutationObserver((()=>{const t=window.getComputedStyle(r),i=t?.backgroundColor,l=t?.color;if(i!==n||l!==s){const t=e({editorBackgroundColor:i,editorColor:l});o.current&&(o.current.textContent=t)}}));return d.observe(r,{attributes:!0,attributeFilter:["class"]}),()=>{d.disconnect(),o.current&&o.current.parentNode&&o.current.parentNode.removeChild(o.current)}}),[e,t])})("add-to-cart-with-options-variation-selector-attribute-options",(({editorBackgroundColor:t,editorColor:e})=>`\n\t\t\t:where(.wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill--selected) {\n\t\t\t\t--pill-color: ${t};\n\t\t\t\t--pill-background-color: ${e};\n\t\t\t}\n\t\t`));const{data:s}=(0,d.useCustomDataContext)("attribute");if(!s)return null;const u=s.terms.map(((t,e)=>({value:t.slug,label:t.name,disabled:e>1&&e===s.terms.length-1})));return(0,w.jsxs)("div",{...n,children:[(0,w.jsx)(a.InspectorControls,{children:(0,w.jsx)(c.PanelBody,{title:(0,l.__)("Style","woocommerce"),children:(0,w.jsxs)(c.__experimentalToggleGroupControl,{label:(0,l.__)("Style","woocommerce"),value:null!=i?i:"pills",onChange:t=>{"pills"!==t&&"dropdown"!==t||o({optionStyle:t})},isBlock:!0,hideLabelFromVision:!0,size:"__unstable-large",children:[(0,w.jsx)(c.__experimentalToggleGroupControlOption,{value:"pills",label:(0,l.__)("Pills","woocommerce")}),(0,w.jsx)(c.__experimentalToggleGroupControlOption,{value:"dropdown",label:(0,l.__)("Dropdown","woocommerce")})]})})}),(0,w.jsx)(c.Disabled,{children:"dropdown"===i?(0,w.jsx)("select",{id:s.taxonomy,className:"wc-block-add-to-cart-with-options-variation-selector-attribute-options__dropdown",children:u.map((t=>(0,w.jsx)("option",{value:t.value,children:t.label},t.value)))}):(0,w.jsx)(b,{id:s.taxonomy,options:u})})]})},attributes:s.attributes,icon:{src:(0,w.jsx)(i.A,{icon:n.A})},save:()=>null})},8180:()=>{},1609:t=>{"use strict";t.exports=window.React},790:t=>{"use strict";t.exports=window.ReactJSXRuntime},6087:t=>{"use strict";t.exports=window.wp.element},7723:t=>{"use strict";t.exports=window.wp.i18n},5573:t=>{"use strict";t.exports=window.wp.primitives}},i={};function n(t){var e=i[t];if(void 0!==e)return e.exports;var o=i[t]={exports:{}};return r[t](o,o.exports,n),o.exports}n.m=r,t=[],n.O=(e,o,r,i)=>{if(!o){var s=1/0;for(d=0;d=i)&&Object.keys(n.O).every((t=>n.O[t](o[a])))?o.splice(a--,1):(l=!1,i0&&t[d-1][2]>i;d--)t[d]=t[d-1];t[d]=[o,r,i]},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},o=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,n.t=function(t,r){if(1&r&&(t=this(t)),8&r)return t;if("object"==typeof t&&t){if(4&r&&t.__esModule)return t;if(16&r&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var s={};e=e||[null,o({}),o([]),o(o)];for(var l=2&r&&t;"object"==typeof l&&!~e.indexOf(l);l=o(l))Object.getOwnPropertyNames(l).forEach((e=>s[e]=()=>t[e]));return s.default=()=>t,n.d(i,s),i},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.j=277,(()=>{var t={277:0};n.O.j=e=>0===t[e];var e=(e,o)=>{var r,i,[s,l,a]=o,c=0;if(s.some((e=>0!==t[e]))){for(r in l)n.o(l,r)&&(n.m[r]=l[r]);if(a)var d=a(n)}for(e&&e(o);cn(8526)));s=n.O(s),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["add-to-cart-with-options-variation-selector-attribute-options"]=s})();