"use strict";const a=require("react/jsx-runtime"),_=require("react"),I=require("./heading-DLCdW6gx.js"),$=require("./index-BbtRr5Q6.js"),O=require("./bind-DeUYJ6m9.js"),C=require("./paragraph-BsI53OR0.js"),v=require("./skeleton-BU0KtWIM.js"),y={"purpur-radio-card-group":"_purpur-radio-card-group_19msf_1","purpur-radio-card-group--vertical":"_purpur-radio-card-group--vertical_19msf_5","purpur-radio-card-group--horizontal":"_purpur-radio-card-group--horizontal_19msf_9","purpur-radio-card-group--radio-left":"_purpur-radio-card-group--radio-left_19msf_18","purpur-radio-card-group__item":"_purpur-radio-card-group__item_19msf_18","purpur-radio-card-group__item-bottom-container":"_purpur-radio-card-group__item-bottom-container_19msf_21","purpur-radio-card-group__item-top-container":"_purpur-radio-card-group__item-top-container_19msf_24","purpur-radio-card-group__container":"_purpur-radio-card-group__container_19msf_35","purpur-radio-card-group__item-container":"_purpur-radio-card-group__item-container_19msf_42","purpur-radio-card-group__item-radio":"_purpur-radio-card-group__item-radio_19msf_77","purpur-radio-card-group__item-content":"_purpur-radio-card-group__item-content_19msf_108","purpur-radio-card-group__item-title":"_purpur-radio-card-group__item-title_19msf_121","purpur-radio-card-group__item-indicator":"_purpur-radio-card-group__item-indicator_19msf_141","purpur-radio-card-group__item-image-container":"_purpur-radio-card-group__item-image-container_19msf_151","purpur-radio-card-group__item-image":"_purpur-radio-card-group__item-image_19msf_151","purpur-radio-card-group__item-image--loaded":"_purpur-radio-card-group__item-image--loaded_19msf_164","purpur-radio-card-group__item-image-placeholder":"_purpur-radio-card-group__item-image-placeholder_19msf_167","purpur-radio-card-group__item-image-placeholder--loaded":"_purpur-radio-card-group__item-image-placeholder--loaded_19msf_172","purpur-radio-card-group__item-children":"_purpur-radio-card-group__item-children_19msf_175"},i=O.c.bind(y),h="purpur-radio-card-group__item-image",A=r=>!!r?.src&&!!r.altText,q=({src:r,altText:p,noPlaceholder:m,loading:e="lazy",["data-testid"]:o})=>{const[s,c]=_.useState(!1),l=()=>c(!0),u=i(h,{[`${h}--loaded`]:s}),g=i(`${h}-placeholder`,{[`${h}-placeholder--loaded`]:s});return a.jsxs(a.Fragment,{children:[a.jsx("img",{"data-testid":o,className:u,src:r,alt:p,loading:e,onLoad:l}),!m&&a.jsx(v.Skeleton,{className:g})]})},t="purpur-radio-card-group__item",R=(r,{disabled:p})=>typeof r=="function"?r({disabled:p}):r,N=_.forwardRef(({title:r,...p},m)=>{const{["data-testid"]:e,body:o,children:s,disabled:c,id:l,image:u,value:g}=p,d={...p};return a.jsxs("div",{className:i(`${t}-container`),ref:m,children:[a.jsxs($.Item2,{className:i(t),"data-testid":e,disabled:c,id:l,value:g,children:[u&&a.jsx("span",{className:i(`${t}-image-container`),children:A(u)?a.jsx(q,{...u,"data-testid":e&&`${e}-image`}):R(u,d)}),a.jsxs("span",{className:i(`${t}-content`),children:[a.jsxs("span",{className:i(`${t}-top-container`),children:[typeof r=="string"?a.jsx(C.Paragraph,{className:i(`${t}-title`),"data-testid":e&&`${e}-title`,variant:"paragraph-100",disabled:c,children:r}):R(r,d),a.jsx("span",{className:i(`${t}-radio`),children:a.jsx($.Indicator,{className:i(`${t}-indicator`)})})]}),o&&a.jsx("span",{className:i(`${t}-bottom-container`),children:typeof o=="string"?a.jsx(C.Paragraph,{"data-testid":e&&`${e}-body`,variant:"paragraph-100",disabled:c,children:o}):R(o,d)})]})]}),s]})});N.displayName="RadioCardItem";const D=r=>_.isValidElement(r)&&r?.type===N,P=["horizontal","vertical"],E=["right","left"],f="purpur-radio-card-group",j=_.forwardRef(({"data-testid":r,"aria-labelledby":p,children:m,className:e,items:o,heading:s,headingTag:c="h2",loop:l=!0,orientation:u="vertical",radioPosition:g="right",...d},b)=>{const x=_.Children.toArray(m).filter(D);return a.jsxs("div",{className:i(e,`${f}__container`),ref:b,children:[s&&a.jsxs(I.Heading,{"data-testid":r?`${r}-heading`:void 0,id:`${d.id}-heading`,tag:c,variant:"subsection-100",children:[d.required&&a.jsx("span",{"aria-hidden":!0,children:"* "}),s]}),(!!o?.length||x.length)&&a.jsxs($.Root2,{...d,"aria-labelledby":p||(s?`${d.id}-heading`:void 0),className:i(f,`${f}--${u}`,`${f}--radio-${g}`),"data-testid":r,loop:l,children:[o?.map(n=>a.jsx(N,{...n,disabled:n.disabled||d.disabled,"data-testid":r?`${r}-item`:void 0},n.id)),_.Children.map(x,n=>_.cloneElement(n,{disabled:n.props.disabled||d.disabled}))]})]})});j.displayName="RadioCardGroup";exports.RADIO_CARD_GROUP_ORIENTATION=P;exports.RADIO_POSITION=E;exports.RadioCardGroup=j;exports.RadioCardItem=N;
//# sourceMappingURL=radio-card-group-BT5pV3tA.js.map
