import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","size","form","disabled","view","status","leftSide","rightSide","children","style","focused","leftSlotsRefs","rightSlotsRefs","alignSlots"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{forwardRef}from"react";import{useFlag}from"../../../hooks/useFlag";import{forkRef}from"../../../hooks/useForkRef";import{useRefs}from"../../../hooks/useRefs";import{getElementWidth,useResizeObserved}from"../../../hooks/useResizeObserved";import{cnFieldControlLayout}from"./cnFieldControlLayout";import{formGuard,getBgColor,getBorderColor,getBorderRadius,getBorderStyle,getPadding,getSlots,getSlotsWidthStyles}from"./helpers";var renderContentSlot=function(a,b,c,d){return React.createElement("div",{key:b,ref:forkRef([null===c||void 0===c?void 0:c[b],null===d||void 0===d?void 0:d[b]]),className:cnFieldControlLayout("Slot")},a)};export var FieldControlLayout=forwardRef(function(a,b){var c,d=a.className,e=a.size,f=void 0===e?"m":e,g=a.form,h=void 0===g?"default":g,i=a.disabled,j=void 0!==i&&i,k=a.view,l=void 0===k?"default":k,m=a.status,n=a.leftSide,o=a.rightSide,p=a.children,q=a.style,r=a.focused,s=a.leftSlotsRefs,t=a.rightSlotsRefs,u=a.alignSlots,v=void 0===u?"top":u,w=_objectWithoutProperties(a,_excluded),x=getSlots(n),y=getSlots(o),z=useRefs(x.length),A=useRefs(1),B=useRefs(y.length),C=useResizeObserved(z,getElementWidth),D=useResizeObserved(B,getElementWidth),E=useResizeObserved(A,getElementWidth)[0],F=formGuard(h),G=useFlag(),H=_slicedToArray(G,2),I=H[0],J=H[1];return React.createElement("div",Object.assign({},w,{ref:b,className:cnFieldControlLayout({form:F,disabled:j,view:l,alignSlots:v,status:m},[d]),style:_objectSpread(_objectSpread(_objectSpread({},q),{},(c={},_defineProperty(c,"--field-control-layout-border-color",getBorderColor(r,I,m,j)),_defineProperty(c,"--field-control-layout-height","var(--control-height-".concat(f,")")),_defineProperty(c,"--field-control-layout-space","calc(var(--control-space-".concat(f,") * 0.5)")),_defineProperty(c,"--field-control-layout-text-size","var(--control-text-size-".concat(f,")")),_defineProperty(c,"--field-control-layout-text-line-height","var(--line-height-text-".concat(f,")")),_defineProperty(c,"--field-control-layout-border-radius",getBorderRadius(F,l)),_defineProperty(c,"--field-control-layout-border-style",getBorderStyle(F,l)),_defineProperty(c,"--field-control-layout-padding",getPadding(F,l)),_defineProperty(c,"--field-control-layout-bg-color",getBgColor(l,j)),_defineProperty(c,"--field-control-layout-border-width","default"===l?"var(--control-border-width)":"0px"),_defineProperty(c,"--field-control-layout-container-width","".concat(E,"px")),c),getSlotsWidthStyles(C,"left")),getSlotsWidthStyles(D,"right")),onMouseEnter:J.on,onMouseLeave:J.off}),React.createElement("div",{ref:A[0],className:cnFieldControlLayout("Container")},!!x.length&&x.map(function(a,b){return renderContentSlot(a,b,z,s)}),React.createElement("div",{className:cnFieldControlLayout("Children")},p),!!y.length&&y.map(function(a,b){return renderContentSlot(a,b,B,t)})))});
//# sourceMappingURL=FieldControlLayout.js.map