{"version":3,"file":"index.B8cNd8-d.js","sources":["../../../../../../../node_modules/@babylon/ui-kit-forms/esm/components/inputs/checkbox/constants/index.mjs","../../../../../../../node_modules/@babylon/ui-kit-forms/esm/components/inputs/checkbox/index.mjs"],"sourcesContent":["const IMAGE_RESIZE = {\n width: 20,\n height: 20\n};\n\nexport { IMAGE_RESIZE };\n//# sourceMappingURL=index.mjs.map\n","import { jsxs, Fragment, jsx } from 'react/jsx-runtime';\nimport ErrorTooltip from '../../others/error-tooltip/index.mjs';\nimport { useInput } from '../../../hooks/useInput/index.mjs';\nimport { forwardRef, useRef, useId, useState, useEffect, useCallback } from 'react';\nimport { IMAGE_RESIZE } from './constants/index.mjs';\nimport { CheckboxWrapper, CheckboxInput, CheckboxLabel, LabelWrapper, StyledImage, CheckboxLabelCount } from './styled.mjs';\n\nconst Checkbox = /*#__PURE__*/ forwardRef(({ label, id = null, value, checked: initialChecked = false, disabled = false, count, className, error, hasError, onChange, onBlur, image, ...rest }, ref)=>{\n const wrapperRef = useRef(null);\n const uniqueId = useId();\n const [checked, setChecked] = useState(initialChecked);\n useEffect(()=>{\n setChecked(initialChecked);\n }, [\n initialChecked\n ]);\n const handleChange = useCallback((e)=>{\n setChecked(e.target.checked);\n if (onChange) onChange(e.target.checked);\n }, [\n onChange\n ]);\n return /*#__PURE__*/ jsxs(Fragment, {\n children: [\n /*#__PURE__*/ jsxs(CheckboxWrapper, {\n ref: wrapperRef,\n className: className,\n children: [\n /*#__PURE__*/ jsx(CheckboxInput, {\n ref: ref,\n type: \"checkbox\",\n id: id ?? uniqueId,\n value: value,\n checked: checked,\n disabled: disabled,\n \"data-testid\": \"Checkbox\",\n onChange: handleChange,\n onBlur: onBlur,\n ...rest\n }),\n /*#__PURE__*/ jsxs(CheckboxLabel, {\n checked: checked,\n $hasError: hasError,\n htmlFor: id ?? uniqueId,\n children: [\n /*#__PURE__*/ jsxs(LabelWrapper, {\n children: [\n image && /*#__PURE__*/ jsx(StyledImage, {\n src: image,\n resize: IMAGE_RESIZE,\n isLazy: true\n }),\n label\n ]\n }),\n count && /*#__PURE__*/ jsx(CheckboxLabelCount, {\n children: count\n })\n ]\n })\n ]\n }),\n /*#__PURE__*/ jsx(ErrorTooltip, {\n referenceElement: wrapperRef.current,\n error: error,\n isVisible: !!hasError\n })\n ]\n });\n});\nCheckbox.displayName = 'Checkbox';\nconst FormCheckbox = (props)=>{\n const { isHiddenRequired: _isHiddenRequired, ...rest } = props;\n const { field: { value: checked, ...restField }, error, hasError, label } = useInput({\n type: 'checkbox',\n ...props\n });\n return /*#__PURE__*/ jsx(Checkbox, {\n ...rest,\n ...restField,\n checked: checked,\n error: error,\n hasError: hasError,\n label: label\n });\n};\n\nexport { FormCheckbox, Checkbox as default };\n//# sourceMappingURL=index.mjs.map\n"],"names":["IMAGE_RESIZE","Checkbox","forwardRef","label","id","value","initialChecked","disabled","count","className","error","hasError","onChange","onBlur","image","rest","ref","wrapperRef","useRef","uniqueId","useId","checked","setChecked","useState","useEffect","handleChange","useCallback","e","jsxs","Fragment","CheckboxWrapper","jsx","CheckboxInput","CheckboxLabel","LabelWrapper","StyledImage","CheckboxLabelCount","ErrorTooltip","FormCheckbox","props","_isHiddenRequired","restField","useInput"],"mappings":"+GAAA,MAAMA,EAAe,CACjB,MAAO,GACP,OAAQ,EACZ,ECIMC,EAAyBC,EAAAA,WAAW,CAAC,CAAE,MAAAC,EAAO,GAAAC,EAAK,KAAM,MAAAC,EAAO,QAASC,EAAiB,GAAO,SAAAC,EAAW,GAAO,MAAAC,EAAO,UAAAC,EAAW,MAAAC,EAAO,SAAAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,MAAAC,EAAO,GAAGC,CAAM,EAAEC,IAAM,CAClM,MAAMC,EAAaC,SAAO,IAAI,EACxBC,EAAWC,EAAAA,QACX,CAACC,EAASC,CAAU,EAAIC,EAAQ,SAACjB,CAAc,EACrDkB,EAAAA,UAAU,IAAI,CACVF,EAAWhB,CAAc,CACjC,EAAO,CACCA,CACR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