import{j as e}from"./jsx-runtime-CnH95YSl.js";import{f as V,w as et,u as O,s as k,e as c}from"./index-BJMTVygn.js";import{O as nt}from"./OdysseyStorybookThemeDecorator-BuDiOG2V.js";import{f as M}from"./fieldComponentPropsMetaData-BqbNLw6V.js";import{a as it,O as at,b as rt,c as st,d as lt,e as z,p as pt}from"./pickerComponentPropsMetadata-D10GkMIO.js";import{u as ct,h as S}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{r as u}from"./index-NdkWRN8K.js";import{j as mt}from"./Typography-Cz6D417Y.js";import{M as v}from"./Settings-2rTKyez8.js";import{M as dt}from"./Folder-e-po0U54.js";import{M as I}from"./Video-DWT3WylB.js";import"./index-BJTM6NaI.js";import"./OdysseyProvider-qIn9QVYS.js";import"./useAutocomplete-BRetTkpF.js";import"./index.esm-CBOWgn41.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-CJ6Ie9dp.js";import"./Field-DH3L8v09.js";import"./Box-1mvP3NLW.js";import"./Box-BcMTQ_R2.js";import"./createBox-Dxawkfow.js";import"./List-CmjR1pNu.js";import"./ListItem-C0ExFtXb.js";import"./utils-iop7lDec.js";import"./useFormControl-BMISTZuX.js";import"./FormLabel-CiGre9wK.js";import"./useIsFocusVisible-DH0qxT5e.js";import"./isHostComponent-DVu5iVWx.js";import"./ButtonBase-BNqa2TMD.js";import"./TransitionGroupContext-DAL84N7p.js";import"./ScreenReaderText-CebALBsG.js";import"./visuallyHidden-Dan1xhjv.js";import"./FormHelperText-CsNAE1E3.js";import"./FieldHint-B3Jif_Up.js";import"./useUniqueId-Bsgqe1tm.js";import"./createUniqueId-ByTaVY63.js";import"./inputUtils-Dbi8XkA6.js";import"./InputBase-DeB4_faH.js";import"./ownerWindow-HkKU3E4x.js";import"./ownerDocument-DW-IO8s5.js";import"./debounce-Be36O1Ab.js";import"./Autocomplete-CxtGbb8j.js";import"./ArrowDropDown-DdemyKZU.js";import"./createSvgIcon-ClUWwDzL.js";import"./Close-OXBt1nIe.js";import"./Paper-D-_O-EjU.js";import"./Popper-BARIxJrI.js";import"./popper-BVOCD5jc.js";import"./_commonjsHelpers-gnU0ypJ3.js";import"./Portal-C6D59xAE.js";import"./index-B5xazMy1.js";import"./index-DieBXP3Z.js";import"./getReactElementRef-DsIevm5t.js";import"./resolveComponentProps-DXQ8X87i.js";import"./useControlled-NQulfz4l.js";import"./Chip-CXnMieIl.js";import"./IconButton-5qShmnSr.js";import"./ListSubheader-CQJAAOsd.js";import"./Typography-ClQ35Rr-.js";/*!
 * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const E=S("div",{shouldForwardProp:o=>o!=="odysseyDesignTokens"&&o!=="adornmentSize"&&o!=="isTagContainer"})(({adornmentSize:o="small",isTagContainer:n=!1,odysseyDesignTokens:t,position:i="left"})=>({position:"relative",bottom:"1px",alignSelf:"flex-start",width:t.Spacing5,height:t.Spacing5,overflow:"hidden",...i==="left"&&{marginInlineEnd:t.Spacing3},...i==="right"&&{marginInlineStart:t.Spacing3},svg:{width:"100%",height:"auto"},img:{position:"absolute",top:"50%",left:"50%",width:"100%",transform:"translate(-50%, -50%)"},...o==="large"&&!n&&{bottom:0,width:t.Spacing8,height:t.Spacing8},...n&&{bottom:0,alignSelf:"center",width:t.Spacing4,height:"auto",maxHeight:t.Spacing4,marginInlineEnd:t.Spacing2,svg:{display:"flex",width:"100%",height:"auto"}}})),xt=S("div",{shouldForwardProp:o=>o!=="odysseyDesignTokens"})(()=>({display:"flex",justifyContent:"space-between",width:"100%"})),ut=S("div",{shouldForwardProp:o=>o!=="odysseyDesignTokens"})(()=>({display:"flex"})),gt=({adornment:o,adornmentSize:n,odysseyDesignTokens:t})=>typeof o=="string"?e.jsx(E,{adornmentSize:n,odysseyDesignTokens:t,children:e.jsx("img",{alt:"",role:"presentation",src:o})}):e.jsx(E,{adornmentSize:n,odysseyDesignTokens:t,children:o}),Ct=({content:o,size:n,odysseyDesignTokens:t,onClick:i})=>{const r=u.useCallback(a=>{a.stopPropagation(),i()},[i]);return e.jsx(E,{adornmentSize:n,odysseyDesignTokens:t,onClick:r,children:o})},ht=({adornmentSize:o,muiProps:n,odysseyDesignTokens:t,option:i})=>{const{adornment:r,description:a,label:x,metaData:g,extra:l,onClick:p,isInteractive:s=!0}=i,C=u.useCallback(h=>{if(!s){h.preventDefault();return}h.stopPropagation(),p==null||p()},[p,s]),y=u.useMemo(()=>({...n,onClick:s?C:void 0,"aria-disabled":s?void 0:"true",role:"option"}),[n,s,C]);return e.jsx(at,{hasAdornment:!0,muiProps:y,children:e.jsxs(xt,{odysseyDesignTokens:t,children:[e.jsxs(ut,{odysseyDesignTokens:t,children:[e.jsx(gt,{adornment:r,adornmentSize:o,odysseyDesignTokens:t}),e.jsxs("div",{children:[e.jsxs(rt,{odysseyDesignTokens:t,children:[e.jsx(mt,{component:"p",children:x}),e.jsx(st,{description:a,odysseyDesignTokens:t})]}),g&&e.jsx(lt,{metaData:g,odysseyDesignTokens:t})]})]}),l&&e.jsx(Ct,{content:l.content,odysseyDesignTokens:t,onClick:l.onClick,size:l.size||o})]})})},kt=({adornmentSize:o="small",ariaDescribedBy:n,defaultValue:t,errorMessage:i,errorMessageList:r,getIsOptionEqualToValue:a,groupOptionsBy:x,id:g,inputValue:l,isCustomValueAllowed:p,isDisabled:s,isFullWidth:C=!1,isLoading:y,isOptional:h=!1,isReadOnly:F,isVirtualized:R=!1,hint:U,HintLinkComponent:_,label:q,name:N,onBlur:G,onChange:J,onInputChange:K,onFocus:Q,options:X,value:Y,testId:Z,translate:$})=>{const j=ct(),tt=u.useCallback((ot,B)=>e.jsx(ht,{adornmentSize:o,muiProps:ot,odysseyDesignTokens:j,option:B},B.value),[o,j]);return e.jsx(it,{ariaDescribedBy:n,defaultValue:t,errorMessage:i,errorMessageList:r,getIsOptionEqualToValue:a,groupOptionsBy:x,hint:U,HintLinkComponent:_,id:g,inputValue:l,isCustomValueAllowed:p,isDisabled:s,isFullWidth:C,isLoading:y,isOptional:h,isReadOnly:F,isVirtualized:R,label:q,name:N,onBlur:G,onChange:J,onFocus:Q,onInputChange:K,options:X,renderOption:tt,testId:Z,translate:$,value:Y})},W=u.memo(kt);W.displayName="MemoizedSearchDropdown";const m=V(),d=V(),w=[{value:"an",label:"An Option label",adornment:e.jsx(dt,{}),extra:{content:e.jsx(v,{"data-testid":"option1-extra"}),onClick:d},onClick:m},{value:"another",label:"Another Option label",description:"Some optional descriptive text",adornment:e.jsx(v,{}),extra:{content:e.jsx(I,{}),onClick:d},onClick:m},{value:"unselectable",label:"Unselectable Option",description:"Some optional descriptive text",isInteractive:!1,adornment:e.jsx(v,{"data-testid":"unselectable-extra"}),extra:{content:e.jsx(I,{}),onClick:d},onClick:m}],So={component:W,decorators:[nt],tags:["autodocs"],argTypes:{...pt,adornmentSize:{control:"radio",options:z,description:"Choose the size for the leading adornment. 'small' or 'large'",table:{type:{summary:z.join(" | ")}}},hint:M.hint,HintLinkComponent:M.HintLinkComponent},args:{label:"Picker with option adornment label",hint:"Optional hint text for picker",options:w}},b={args:{options:w},play:async({canvasElement:o,step:n})=>{const i=et(o).getByRole("combobox"),r=()=>{m.mockClear(),d.mockClear()};await n("Click on option triggers option onClick",async()=>{r(),await O.click(i);const a=k.getByText("An Option label");await O.click(a),c(m).toBeCalled(),c(d).not.toBeCalled()}),await n("Click on option extra triggers option.extra onClick",async()=>{r();const a=k.getByTestId("option1-extra");await O.click(a),c(m).not.toBeCalled(),c(d).toBeCalled()}),await n("Click on unselectable option not trigger onClick",()=>{r();const a=k.getByText("Unselectable Option");c(a).toHaveStyle("pointer-events: none");const x=k.getByTestId("unselectable-extra");c(x).toHaveStyle("pointer-events: none")})}},f={args:{adornmentSize:"large",options:w}};var A,T,D;b.parameters={...b.parameters,docs:{...(A=b.parameters)==null?void 0:A.docs,source:{originalSource:`{
  args: {
    options: optionsWithExtra
  },
  play: async ({
    canvasElement,
    step
  }) => {
    const canvas = within(canvasElement);
    const comboBoxElement = canvas.getByRole<HTMLInputElement>("combobox");
    const clearMocks = () => {
      optionOnClick.mockClear();
      optionExtraOnClick.mockClear();
    };
    await step("Click on option triggers option onClick", async () => {
      clearMocks();
      await userEvent.click(comboBoxElement);
      const option = screen.getByText("An Option label");
      await userEvent.click(option);
      expect(optionOnClick).toBeCalled();
      expect(optionExtraOnClick).not.toBeCalled();
    });
    await step("Click on option extra triggers option.extra onClick", async () => {
      clearMocks();
      const optionExtra = screen.getByTestId("option1-extra");
      await userEvent.click(optionExtra);
      expect(optionOnClick).not.toBeCalled();
      expect(optionExtraOnClick).toBeCalled();
    });
    await step("Click on unselectable option not trigger onClick", () => {
      clearMocks();
      const unselectableOption = screen.getByText("Unselectable Option");
      expect(unselectableOption).toHaveStyle("pointer-events: none");
      const optionExtra = screen.getByTestId("unselectable-extra");
      expect(optionExtra).toHaveStyle("pointer-events: none");
    });
  }
}`,...(D=(T=b.parameters)==null?void 0:T.docs)==null?void 0:D.source}}};var P,H,L;f.parameters={...f.parameters,docs:{...(P=f.parameters)==null?void 0:P.docs,source:{originalSource:`{
  args: {
    adornmentSize: "large",
    options: optionsWithExtra
  }
}`,...(L=(H=f.parameters)==null?void 0:H.docs)==null?void 0:L.source}}};const wo=["SmallAdornmentWithExtra","LargeAdornmentWithExtra"];export{f as LargeAdornmentWithExtra,b as SmallAdornmentWithExtra,wo as __namedExportsOrder,So as default};
