'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),o=require("react"),l=require("./RectangleList.js"),s=require("../../../../../common/helper.js");const i=({name:i,variantKey:n,...a})=>{let{setSelectedOption:r}=t.useSelectedOption(),u=t.useProduct(),d=o.useMemo(()=>{if(!a.presetConfiguration)return;let{presets:e,optionType:t}=a.presetConfiguration;return e?.[t||"rectangle_list"]},[a.presetConfiguration]),p=d?.itemSpacing,c=d?.numberPerRow||5,m=o.useMemo(()=>({minWidth:`${100/c}%`,paddingLeft:s.postPurchaseSpacing[p||"none"],paddingTop:s.postPurchaseSpacing[p||"none"],width:`${100/c}%`}),[p,c]),g=o.useMemo(()=>l.default,[]),b=t.useVariantOutStock(i??"",a.value?.label??"",{position:a.optionPosition,optionNumber:a.optionNumber}),O=o.useMemo(()=>"Disable"===a.soldOutStyle&&a.soldOutMark,[a.soldOutStyle,a.soldOutMark]),h=o.useMemo(()=>"Line"===a.soldOutStyle&&a.soldOutMark,[a.soldOutStyle,a.soldOutMark]);return e.jsxs("label",{className:t.cls({"gp-pointer-events-none":O&&!b,"gp-flex gp-items-center":!0}),style:{...m},htmlFor:`${a.uid}-${n}`,children:[e.jsx("input",{checked:a.checked,name:`${u?.id}-options-${i?.toString().replaceAll('"','\\"')}`,id:`${a.uid}-${n}`,value:a.value?.label,type:"radio",className:"gp-sr-only",onChange:()=>{if(b||!O){r(i,a.value?.label,u?.id);let e=new CustomEvent("change-selected-option",{bubbles:!0,cancelable:!0,composed:!0,detail:{optionId:i,optionValue:a.value?.label,productId:u?.id}});window.dispatchEvent(e)}}}),e.jsx("span",{className:"gp-sr-only",children:a.value?.label}),e.jsx(g,{...a,preset:d,isVariantOutStock:O&&!b&&0!==a.optionPosition,soldOutMark:O,soldOutMarkLine:h,available:b})]})};i.defaultProps={},exports.default=i;
