import{ao as e,ba as M,au as E,av as O,bS as _,bT as D,gF as i,az as u,dK as G,a_ as W,aX as R,ay as w,bI as U,fK as B,fI as q,f7 as j,aZ as k,v as I,gG as K,gH as z,gI as $,gJ as Y,gK as J,gL as Q,gM as X,gN as Z,gO as ee,gP as ae,bN as se,L as te,p as ie,aj as ne,fh as oe,gQ as re,gB as de,f as h,e as v,eg as ce,c as le,a2 as F,gR as pe,c3 as C,cu as y}from"./app-k0jcl5PQ.js";import{u as ue,a as me}from"./BbvXec0K.chunk.js";import{F as S,W as b,b as H}from"./D62ACZel.chunk.js";import{P as A}from"./DbAvN-pg.chunk.js";import{u as ge}from"./DDxzgH2W.chunk.js";import{a as he}from"./BAuuQuuB.chunk.js";import{u as ve}from"./4IZETxJX.chunk.js";import{V as Le}from"./DqZSd8JQ.chunk.js";import{C as fe}from"./BHJbqrq4.chunk.js";import"./CnmbO5oy.chunk.js";import"./DdN4NAtQ.chunk.js";import"./CBiwFpxE.chunk.js";import"./BBUCoOir.chunk.js";import"./BrY2bcAL.chunk.js";import"./BhYYYlpK.chunk.js";import"./FGhEvk_q.chunk.js";import"./WCBjpMHJ.chunk.js";import"./DoFMWlew.chunk.js";import"./CMnqIsoM.chunk.js";import"./CIN5bTKK.chunk.js";const xe="_leftNavIcon_1rltt_1",Ce={leftNavIcon:xe},ye={[i.StudentFeed]:"bg-purple",[i.Discover]:"bg-blue",[i.MoviesAndTv]:"bg-indigo",[i.Playlists]:"bg-green",[i.MyVideos]:"bg-orange",[i.MyShares]:"bg-ultramarine",[i.Library]:"bg-teal"};function Se(s){return e.jsx("li",{className:"col-6 mb-3",children:e.jsxs(M,{appLink:s.appLink,className:`border rounded-3 d-flex align-items-center
          justify-content-center flex-column text-decoration-none h-100 py-3 px-1 text-center`,children:[e.jsx("div",{className:`${Ce.leftNavIcon} ${s.iconClassName} mx-auto mb-3`,children:e.jsx(E,{imageUrl:_.createUrl(s.imageUrl,{size:D.Small}),svg:s.svg,svgSize:O.Large})}),e.jsx("div",{className:"h6",children:s.name})]})})}function be(s){return e.jsx("ul",{className:"list-unstyled row row-cols-md-5",children:s.items.filter(a=>a.type==="applink").map((a,n)=>e.jsx(Se,{id:a.id,appLink:a.appLink,name:a.name,iconClassName:ye[a.id]??"bg-gray-500",svg:a.svg,imageUrl:a.imageUrl},`${a.id}-${n}`))})}function He(){var c,l,t;const s=u(Le.userVideoHistory()),a=he(((l=(c=s.data)==null?void 0:c.data)==null?void 0:l.map(o=>o.videoId))??[],G.watchHistoryVideos),n=ue({source:(t=s.data)==null?void 0:t.data,target:a.itemsArr,sourceKey:"videoId"});return ve(n),{data:n,hasCompleted:!a.isFetching}}function Ae(s){return e.jsx(M,{appLink:s.appLink,children:e.jsx(W,{svg:fe})})}function Ie(){var p;const s=K(),{hasPermissions:a,hasLocalPermissions:n}=R(),c=w(null),{activePresentation:l}=U(),{dashboard:t}=B({targetType:q.MoviesAndTv,queryParams:{}}),o=u(a(k.ViewLibraries)&&j.domainLibraries(["customLibrary","sharedLibrary"]));u(!!((p=o.data)!=null&&p.length)&&j.librariesWithOwnerLogos(o.data.map(f=>f.id)));const L=I.getCurrentAppLink();return s.setOptions({navState:z.Hidden,currentAppLink:L,hasPermissions:a,hasLocalPermissions:n,settings:c}).addHandler(i.StudentFeed,$).addHandler(i.Discover,Y,{activePresentation:l}).addHandler(i.MoviesAndTv,J,{hasMoviesAndTvDashboardData:!!t.data,activePresentation:l}).addHandler(i.Playlists,Q).addHandler(i.MyVideos,X).addHandler(i.MyShares,Z),a(k.StudentExperience)||s.addHandler(i.Library,ee,{libraries:o.data??[],showOnHidden:!0}),s.getItems()}const Pe="default.popupPlugin",g=te.encloseNamespace(Pe),T={application:v.MY_SHARES,action:h.MyShares.LIST},Ve={application:v.DEFAULT,action:h.Default.POPUP_PLUGIN};function Je(){const{focusSearchBar:s}=ae(),{hasNewSearch:a,hasShareFlowV2:n,isLoadingSettings:c}=w(null),l=Ie();se({title:g("title")});const{activePresentation:t}=U(),{hasPermissions:o,isLoaded:L}=R(),{commonVideoProps:p,hasCommonVideoPropsCompleted:f}=ge({locationContext:ie.VideoThumbnail}),m=u(ne.currentUser()),x=u(t&&oe.audiencesByPresentationId(t.id)),P=He(),V=u(m.data&&re.getFavourites(m.data.id)),N=me({shouldFetch:n});return de(F.SHELL,pe.ROUTE,r=>{!I.getHref(r)||I.isEqual(r,Ve,{args:!1,params:!1})||(ce.enableNav(),!(c||a)&&le.Radio.channel(F.SHELL).once("routing:end",s))},[a,c]),L&&f?e.jsxs("div",{className:"px-4",children:[e.jsx(be,{items:l}),P.hasCompleted?e.jsx("div",{className:"mb-3",children:e.jsx(S,{name:g("recentlyWatched"),collection:P.data||[],contents:b.Videos,childComponent:A,extraChildComponentProps:{presentationAudiences:x.data,showVideoGuidance:y.showVideoGuidance(o),onClickRemoveItem:null,commonVideoProps:p},getChildAppLink:r=>{var d;return C.getAppLink(r,{includeContext:(d=m.data)==null?void 0:d.isAuthenticated},t==null?void 0:t.vanitySlug)},appLink:{application:v.WATCH_HISTORY,action:h.WatchHistory.HOME},prefetched:!0})}):e.jsx("div",{className:"mb-3",children:e.jsx(H,{})}),n&&e.jsx(e.Fragment,{children:N.hasFirstPageCompleted?e.jsx(S,{headingBadgeComponent:e.jsx(Ae,{appLink:T}),name:g("recentlyShared"),collection:N.items,contents:b.Videos,childComponent:A,extraChildComponentProps:{presentationAudiences:x.data,showVideoGuidance:y.showVideoGuidance(o),onClickRemoveItem:null,commonVideoProps:p},getChildAppLink:r=>{var d;return C.getAppLink(r,{includeContext:(d=m.data)==null?void 0:d.isAuthenticated},t==null?void 0:t.vanitySlug)},appLink:T,prefetched:!0}):e.jsx(H,{})}),V.hasCompleted?e.jsx(S,{name:g("favourites"),collection:V.data.data||[],contents:b.Videos,childComponent:A,extraChildComponentProps:{presentationAudiences:x.data,showVideoGuidance:y.showVideoGuidance(o),onClickRemoveItem:null,commonVideoProps:p},getChildAppLink:r=>{var d;return C.getAppLink(r,{includeContext:(d=m.data)==null?void 0:d.isAuthenticated},t==null?void 0:t.vanitySlug)},appLink:{application:v.DEFAULT,action:h.MyFavourites.MY_FAVOURITES},prefetched:!0}):e.jsx(H,{})]}):e.jsx(e.Fragment,{})}export{Je as PopupPluginView};
//# sourceMappingURL=BnmM73Vv.chunk.js.map
