1import{at as Z,y as J,r as l,bb as Q,o as Y,ab as ee,j as E,h as te,P as re,q as ne,bc as oe,bd as v,be as ie,b as ae,B as K,c as ue,D as le}from"./index.RuhrnD1v.js";import{W as ce}from"./WidgetLabel.CgwydhVR.js";import{W as se}from"./WidgetLabelHelpIconInline.p-GgbwF5.js";import{u as fe}from"./useBasicWidgetState.CI9LlGGe.js";import"./styled-components.CXqQ-NdV.js";import"./FormClearHelper.DFo50Lfo.js";var pe={secondary:"secondary"},N={default:"default"},de={default:"default"},B=Object.freeze({radio:"radio",checkbox:"checkbox"}),V=Z("div",function(e){var t=e.$shape,r=e.$length,n=e.$theme,o=r===1?void 0:t!==N.default?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}});V.displayName="StyledRoot";V.displayName="StyledRoot";function D(e){"@babel/helpers - typeof";return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D(e)}function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},G.apply(this,arguments)}function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ye(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?F(Object(r),!0).forEach(function(n){W(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function me(e,t){return ve(e)||ge(e,t)||he(e,t)||be()}function be(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function he(e,t){if(e){if(typeof e=="string")return q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return q(e,t)}}function q(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ge(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,i=!1,a,c;try{for(r=r.call(e);!(o=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));o=!0);}catch(f){i=!0,c=f}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw c}}return n}}function ve(e){if(Array.isArray(e))return e}function Se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Oe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _e(e,t,r){return t&&Oe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&z(e,t)}function z(e,t){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},z(e,t)}function Pe(e){var t=Le();return function(){var n=C(e),o;if(t){var i=C(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return Ee(this,o)}}function Ee(e,t){if(t&&(D(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return H(e)}function H(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Le(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}
2function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},C(e)}function W(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Re(e,t){return!Array.isArray(e)&&typeof e!="number"?!1:Array.isArray(e)?e.includes(t):e===t}var X=(function(e){we(r,e);var t=Pe(r);function r(){var n;Se(this,r);for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=t.call.apply(t,[this].concat(i)),W(H(n),"childRefs",{}),n}return _e(r,[{key:"render",value:function(){var o=this,i=this.props,a=i.overrides,c=a===void 0?{}:a,f=i.mode,S=f===void 0?B.checkbox:f,d=i.children,p=i.selected,b=i.disabled,y=i.onClick,O=i.kind,_=i.shape,w=i.size,h=J(c.Root,V),k=me(h,2),I=k[0],j=k[1],L=this.props["aria-label"]||this.props.ariaLabel,s=S===B.radio,P=l.Children.count(d);return l.createElement(Q.Consumer,null,function(A){return l.createElement(I,G({"aria-label":L||A.buttongroup.ariaLabel,"data-baseweb":"button-group",role:s?"radiogroup":"group",$shape:_,$length:d.length},j),l.Children.map(d,function(m,R){if(!l.isValidElement(m))return null;var T=m.props.isSelected?m.props.isSelected:Re(p,R);return s&&(o.childRefs[R]=l.createRef()),l.cloneElement(m,{disabled:b||m.props.disabled,isSelected:T,ref:s?o.childRefs[R]:void 0,tabIndex:!s||T||s&&(!p||p===-1)&&R===0?0:-1,onKeyDown:function(u){if(s){var g=Number(p)?Number(p):0;if(u.key==="ArrowUp"||u.key==="ArrowLeft"){u.preventDefault&&u.preventDefault();var $=g-1<0?P-1:g-1;y&&y(u,$),o.childRefs[$].current&&o.childRefs[$].current.focus()}if(u.key==="ArrowDown"||u.key==="ArrowRight"){u.preventDefault&&u.preventDefault();var M=g+1>P-1?0:g+1;y&&y(u,M),o.childRefs[M].current&&o.childRefs[M].current.focus()}}},kind:O,onClick:function(u){b||(m.props.onClick&&m.props.onClick(u),y&&y(u,R))},shape:_,size:w,overrides:ye({BaseButton:{style:function(u){var g=u.$theme;return d.length===1?{}:_!==N.default?{marginLeft:g.sizing.scale100,marginRight:g.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":T,role:s?"radio":"checkbox"}}},m.props.overrides)})}))})}}]),r})(l.Component);W(X,"defaultProps",{disabled:!1,onClick:function(){},shape:N.default,size:de.default,kind:pe.secondary});function x(e){const t=e.contentIcon,r=e.content??"";return t?`${t} ${r}`.trim():r}function ke(e,t){for(let r=e.length-1;r>=0;r--)if(x(e[r])===t)return r;return-1}function Be(e,t){const r=[];for(const n of t){const o=ke(e,n);o>=0&&r.push(o)}return r}function Ce(e,t){return t.includes(e)?t.filter(r=>r!==e):[...t,e]}function Ie(e,t,r){return e===v.ClickMode.MULTI_SELECT?Ce(t,r):r.includes(t)?[]:[t]}function je(e){switch(e){case v.ClickMode.SINGLE_SELECT:return B.radio;case v.ClickMode.MULTI_SELECT:return B.checkbox;default:return}}function Ae(e){return e.length===0?-1:e[0]}function Te(e,t){return e.getStringArrayValue(t)}function $e(e){return(e.default??[]).map(r=>{const n=e.options[r];return n?x(n):""}).filter(r=>r!=="")}function Me(e){return e.rawValues??[]}function De(e,t,r,n){t.setStringArrayValue(e,r.value,{fromUi:r.fromUi},n)}function Ge(e,t,r){const n=r===v.Style.PILLS?K.PILLS:K.SEGMENTED_CONTROL;return{element:E(le,{icon:t,label:e,iconSize:"base",useSmallerFont:!0}),kind:n,size:ue.MEDIUM}}function ze(e,t){return e&&(t=`${t}Active`),t}function Ne(e,t,r){const n={flexWrap:"wrap",maxWidth:r?"100%":"fit-content",margin:"0 0"},o=r?"100%":"auto";switch(e){case v.Style.PILLS:return{...n,columnGap:t.twoXS,rowGap:t.twoXS,width:o};case v.Style.SEGMENTED_CONTROL:return{...n,columnGap:t.none,rowGap:t.twoXS,width:o};default:return n}}function Ve(e,t,r,n,o){const i=r.includes(t);return l.forwardRef(function(c,f){const{element:S,kind:d,size:p}=Ge(e.content??"",e.contentIcon??void 0,n),b=ze(i,d);return E(ae,{...c,size:p,kind:b,containerWidth:o,children:S})})}function We(e){const{disabled:t,element:r,fragmentId:n,widgetMgr:o,widthConfig:i}=e,{clickMode:a,options:c,style:f,label:S,labelVisibility:d,help:p}=r,b=Y(),y=r.queryParamKey?{paramKey:r.queryParamKey,valueType:"string_array_value",clearable:!0,urlFormat:"repeated"}
2:void 0,[O,_]=fe({getStateFromWidgetMgr:Te,getDefaultStateFromProto:$e,getCurrStateFromProto:Me,updateWidgetMgrState:De,element:r,widgetMgr:o,fragmentId:n,formClearBehavior:"resetValueOnly",queryParamBinding:y}),w=l.useMemo(()=>Be(c,O),[c,O]),h=ee(i),k=l.useCallback((L,s)=>{const P=x(c[s]),A=Ie(a,P,O);_({value:A,fromUi:!0})},[a,c,O,_]),I=je(a),j=l.useMemo(()=>c.map((L,s)=>{const P=Ve(L,s,w,f,h);return E(P,{},`${L.content}-${s}`)}),[c,f,w,h]);return te(ie,{className:"stButtonGroup","data-testid":"stButtonGroup",containerWidth:h,children:[E(ce,{label:S,disabled:t,labelVisibility:ne(d?.value??oe.LabelVisibilityOptions.COLLAPSED),children:p&&E(se,{content:p,placement:re.TOP,label:S})}),E(X,{disabled:t,mode:I,onClick:k,selected:a===v.ClickMode.MULTI_SELECT?w:Ae(w),overrides:{Root:{style:l.useCallback(()=>Ne(f,b.spacing,h),[f,b.spacing,h])}},children:j})]})}const Xe=l.memo(We);export{Xe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.