"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),helper=require("../../../../common/helper.js"),helpers=require("../common/helpers.js"),styles=require("../common/styles.js"),Dropdown=require("./variants/Dropdown.js"),VariantItem=require("./variants/VariantItem.js"),Text=require("../../../../../text/components/Text.js"),classes=require("../common/classes.js");const ProductOption=({option:e,indexOption:s,productVariantSettings:t,styles:r,setting:a,builderProps:i,optionLength:n})=>{let{showAsSwatches:o}=a??{},{align:l}=r??{},{uid:p}=i??{},m=core.useVariants(),{getVariantConfiguration:u,getSwatchDropdownAutoWidth:c,hasPreSelected:d,variantId:y,selectedOptions:j,isChangeVariant:x}=t,g=u(e.name),h=g?g.optionType:e.optionType,S=(d||y)&&e.name?j?.[e.name]:void 0,v=g?.hide;if(v)return null;let b=g.presets[h],q=b?.labelToggle,w=b?.itemSpacing,f=helper.postPurchaseSpacing[w||"none"],C=system.createStyle({...styles.getVariantItemWrapperStyles(h,f)}),V=system.createClass({...classes.getProductOptionClasses()}),D=system.createClass({...classes.getVariantItemWrapperClasses()}),P=system.createClass({...classes.getDropdownVariantWrapperClasses(r)}),R=system.createStyle({...styles.getDisplayLabelStyles(l)});return jsxRuntime.jsxs("div",{className:V,children:[q&&"dropdown"!==h&&jsxRuntime.jsx(Text.default,{style:R,styles:styles.getDisplayLabelSettingStyles(),setting:helpers.getDisplayLabelSetting({option:e,hasPreSelected:d,isChangeVariant:x,selectedOptions:j})}),jsxRuntime.jsxs("div",{className:D,style:C,children:[o&&core.OptionSpecialStyle.includes(`${h}`)&&e.values.map(t=>{let i=(!!d||!!x||!!y)&&!!e.name&&j?.[e.name]===t.label;return jsxRuntime.jsx(VariantItem.default,{variantKey:`${e.id}-${t.id}`,showAsSwatches:o,uid:p,name:e.name,value:t,optionNumber:n,optionPosition:s,...r,...a,presetConfiguration:u(e.name),checked:i,optionType:h||"dropdown"},t.id)}),jsxRuntime.jsx("div",{className:P,children:("dropdown"===h||o&&!core.OptionSpecialStyle.includes(`${h}`))&&"radio_buttons"!==h&&jsxRuntime.jsx(Dropdown.default,{...r,...a,variants:m,preset:b,option:e,initValue:S,label:e.name,presetConfiguration:u(e.name),swatchAutoWidth:c(),optionPosition:s,optionNumber:n})})]})]},e.id)};exports.default=ProductOption;
