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