import{ao as e,e3 as y,ck as P,aT as m,aq as p,L as r,e6 as f,aJ as i,aC as C,e8 as E,aP as u,aR as b,c8 as j,cy as I,b_ as F,a_ as _,av as N,bl as k}from"./app-k0jcl5PQ.js";import{T as v}from"./D1M9dqnr.chunk.js";import{T}from"./CnSDR2E3.chunk.js";import{P as L}from"./CGIhFPIn.chunk.js";import{F as A}from"./DzRq1F5-.chunk.js";import{b as B,a as H}from"./DV1GpLCe.chunk.js";import{F as w,u as D}from"./C3DvQ1wU.chunk.js";const x="playlists.newPlaylistForm",g=r.encloseNamespace(x);function R(){const s=D(),{errors:t,touched:o}=y(),n=B.getCustomFormControlClassName(t,o,"name");return e.jsxs(P,{children:[e.jsx(m.Label,{htmlFor:"name",children:e.jsx(p,{namespace:x,phrase:"label"})}),e.jsxs("div",{className:"input-group",children:[e.jsx(H,{type:"text",name:"name",id:"name",placeholder:g("placeholder"),autoFocus:!0,value:s.values.name,className:n,"aria-errormessage":"nameError"}),e.jsx(A,{isNew:!0,submitText:g("submit"),variant:"outline-dark",className:"border border-secondary rounded-end-1"}),e.jsx(f,{name:"name",children:a=>e.jsx(m.Control.Feedback,{id:"nameError",role:"status",type:"invalid",children:a})})]})]})}function M(s){return e.jsx(w,{initialValues:{name:""},validationSchema:L,onSubmit:s.onSubmit,children:e.jsx(R,{})})}const V="_suggestionContainer_191bz_1",O="_colourBox_191bz_4",c={suggestionContainer:V,colourBox:O},l="playlists.selectPlaylist",U=36,$=40,d=3,h=8;function z(s){let t=d;return s>d&&(t=s),s>h&&(t=h),U+t*$+"px"}function Y(s){const t=j.isFunction(s.isVideoInPlaylist)&&s.isVideoInPlaylist(s.playlist),[o,n]=i.useState(t);i.useEffect(()=>{o!==t&&n(t)},[t,o]);const a=t?c.mask:"cursor-pointer",S=I(s.playlist.name,F);return e.jsxs("button",{role:"checkbox","aria-checked":o,className:`${a} d-flex align-items-center`,children:[e.jsx("div",{className:`${c.colourBox} ${S} d-inline-block rounded flex-shrink-0`,children:o&&e.jsx(_,{svg:k,size:N.Large,title:r.getPhrase(l,"checkTooltip"),tooltipSpanHack:!0})}),e.jsx("p",{className:"ms-2 mb-0 text-break",children:s.playlist.name})]})}function K(s){const[t,o]=i.useState(!1),n=C.sortBy(s.playlists,"name");return e.jsxs(e.Fragment,{children:[!!s.playlists.length&&e.jsx(E,{label:r.getPhrase(l,"placeholder"),onSuggestionSelected:s.onSelectPlaylist,shouldUpdateQueryOnSelection:!1,suggestionsHeading:r.getPhrase(l,"suggestionsHeading"),local:n,initialLocalSuggestions:n,activationLength:1,placeholder:r.getPhrase(l,"placeholder"),theme:{suggestionsContainer:`mt-2 ${c.suggestionContainer}`,suggestionsContainerOpen:""},renderSectionTitle:a=>e.jsx("h3",{className:"font-size-normal fw-semibold my-1",children:a.title}),searchIconPlacement:"left",alwaysRenderSuggestions:!0,suggestionLimit:!1,getEmptyStateComponent:a=>e.jsx(v,{query:a,imageUrl:u.EmptyStates.TYPEAHEAD_RESULTS}),getErrorStateComponent:a=>e.jsx(T,{onClickTryAgain:a,imageUrl:u.TYPEAHEAD_ERROR}),getSuggestionComponent:a=>e.jsx(Y,{playlist:a,isVideoInPlaylist:s.isVideoInPlaylist}),autoFocusInput:!0,customScrollbarProps:{style:{height:z(n.length)}}}),e.jsx("div",{className:"border-top pt-3 px-3 mx-n3",children:t?e.jsx(M,{onSubmit:a=>s.createPlaylist(a.name)}):e.jsx(b,{variant:"link",className:"text-info p-0",onClick:()=>o(!0),children:e.jsx(p,{namespace:l,phrase:"createPlaylist"})})})]})}export{K as S};
//# sourceMappingURL=BejFPyFL.chunk.js.map
