"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[4525],{96754:(e,t,o)=>{o.d(t,{rS:()=>y,sK:()=>x,HQ:()=>g,x6:()=>C});var n=o(57431),i=o(40040),l=o(44630),a=o(60072),s=o(39228),c=o(26325),r=o(14374),d=o(71111),u=o(31209),p=o(87934);const v=(0,o(51264).l)("/api/collection/move_items/",{statusCode:0});var h=function(e,t,o,n){return new(o||(o=Promise))((function(i,l){function a(e){try{c(n.next(e))}catch(e){l(e)}}function s(e){try{c(n.throw(e))}catch(e){l(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))};const m={statusCode:0,loading:!1,hasMore:!0,collectionList:[],total:"0"},f=(0,r._)((0,d.atom)(m),{rehydrationKey:"desktop.userPage.userCollectionList"});f.debugLabel="collectionInfoListAtom";const{useAtomService:g,useServiceDispatchers:x,useServiceState:C,getStaticApi:y}=(0,u.i)(f,((e,t)=>({getCollectionInfoList(o){return h(this,void 0,void 0,(function*(){const{secUid:a,isReset:r=!1}=o;try{t(f,(e=>Object.assign(Object.assign({},e),{loading:!0})));const{user:o}=(0,n.x)(),d=Object.assign(Object.assign({},(0,l.bv)(e,f,{secUid:a})),{appId:i.xE,publicOnly:(null==o?void 0:o.secUid)!==a});r&&(d.cursor="0");const u=yield function(e){return h(this,void 0,void 0,(function*(){return s.hd.get("/api/user/collection_list/",{query:e,baseUrlType:2,headers:{[c.nk]:s.hd.csrfToken}})}))}(d);t(f,(e=>{var t,o;if(r)return Object.assign(Object.assign(Object.assign({},e),u),{loading:!1});const n=[...null!==(t=e.collectionList)&&void 0!==t?t:[]],i=new Set(n.map((e=>e.collectionId)));for(const e of null!==(o=u.collectionList)&&void 0!==o?o:[])i.has(e.collectionId)||(i.add(e.collectionId),n.push(e));return Object.assign(Object.assign(Object.assign({},e),u),{collectionList:n,loading:!1})}))}catch(e){t(f,(e=>Object.assign(Object.assign({},e),{loading:!1,statusCode:-1})))}}))},resetCollectionInfoList(){t(f,Object.assign({},m))},moveItems({itemIds:o,fromCollectionId:n,targetCollectionId:i,onMove:l}){var s,c,r,d,u,m,g;return h(this,void 0,void 0,(function*(){if(0===o.length)return;const h=e(f),x=null===(s=h.collectionList)||void 0===s?void 0:s.find((e=>e.collectionId===n)),C=null===(c=h.collectionList)||void 0===c?void 0:c.find((e=>e.collectionId===i)),y=null!==(r=null==x?void 0:x.total)&&void 0!==r?r:"0",b=(BigInt(y)-BigInt(o.length)).toString(),_=null!==(d=null==C?void 0:C.total)&&void 0!==d?d:"0",I=(BigInt(_)+BigInt(o.length)).toString(),j=null===(g=null===(m=null===(u=e(a.Pu)[o[0]])||void 0===u?void 0:u.video)||void 0===m?void 0:m.zoomCover)||void 0===g?void 0:g[240],w="0"===b||null==x?void 0:x.cover,k=!(null==C?void 0:C.cover)&&j?{urlList:[j]}:null==C?void 0:C.cover;let T;if(n)i?(this.modifyCollectionInfo(n,{total:b,cover:w}),this.modifyCollectionInfo(i,{total:I,cover:k}),T=t(v,{itemIDs:o.join(","),fromCollectionID:n,targetCollectionID:i})):(this.modifyCollectionInfo(n,{total:b,cover:w}),T=t(p.m,{collectionId:n,deleteIds:o.join(",")}));else{if(!i)return;this.modifyCollectionInfo(i,{total:I,cover:k}),T=t(p.m,{collectionId:i,commitIds:o.join(",")})}const{statusCode:O}=yield T;0!==O&&(n&&this.modifyCollectionInfo(n,{total:y,cover:null==x?void 0:x.cover}),i&&this.modifyCollectionInfo(i,{total:_,cover:null==C?void 0:C.cover})),null==l||l({statusCode:O,fromCollection:x,targetCollection:C})}))},prependCollectionInfo(o){var n;(null===(n=e(f).collectionList)||void 0===n?void 0:n.some((e=>e.collectionId===o.collectionId)))||t(f,(e=>{var t;return Object.assign(Object.assign({},e),{collectionList:[o,...null!==(t=e.collectionList)&&void 0!==t?t:[]]})}))},modifyCollectionInfo(o,n){const i=e(f);if(!i.collectionList)return;const l=i.collectionList.findIndex((e=>e.collectionId===o));if(l<0)return;const a=[...i.collectionList];a[l]=Object.assign(Object.assign({},a[l]),n),t(f,(e=>Object.assign(Object.assign({},e),{collectionList:a})))}})))},51264:(e,t,o)=>{o.d(t,{l:()=>r});var n=o(39228),i=o(26325),l=o(57431),a=o(89049),s=o(28086),c=function(e,t,o,n){return new(o||(o=Promise))((function(i,l){function a(e){try{c(n.next(e))}catch(e){l(e)}}function s(e){try{c(n.throw(e))}catch(e){l(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))};function r(e,t){return(0,s.z)({initState:t,fetchAction:(o,s,r)=>c(this,void 0,void 0,(function*(){try{const{user:t,language:o}=(0,l.x)(),c=yield n.hd.post(e,{query:Object.assign(Object.assign({},s),{aid:a.xE,region:null==t?void 0:t.region,language:o}),baseUrlType:2,headers:{[i.nk]:n.hd.csrfToken}});return null==r||r(c),c}catch(e){const o=Object.assign(Object.assign({},t),{statusCode:-1});return null==r||r(o),o}}))})}},70911:(e,t,o)=>{o.d(t,{e:()=>n});const n=(0,o(51264).l)("/api/collection/create/",{collectionId:0,collectionIdString:"",statusCode:0})},87934:(e,t,o)=>{o.d(t,{m:()=>n});const n=(0,o(51264).l)("/api/collection/modify_items/",{statusCode:0})},72781:(e,t,o)=>{o.d(t,{o:()=>l,s:()=>i});var n=o(40099);function i(e){const t=(0,n.useCallback)(((t,o)=>{o&&(o.preventDefault(),o.stopPropagation()),t.disabled||(t.preventCloseOnClick||null==e||e(!1),t.action())}),[e]),o=(0,n.useCallback)(((e,o)=>{o.target instanceof HTMLInputElement||"Enter"!==o.code&&"Space"!==o.code||(o.preventDefault(),o.stopPropagation(),t(e,o))}),[t]);return{handleAction:t,handleKeyDown:o}}function l({controlledOpen:e,onControlledOpenChange:t}){const[o,i]=(0,n.useState)(!1),l=null!=e?e:o,a=(0,n.useCallback)((e=>{i(e),null==t||t(e)}),[t]);return[l,a]}},41428:(e,t,o)=>{function n(e){if(!e.state||!e.states||!e.states[e.state])return e;const t=e.states[e.state];return Object.assign(Object.assign({},e),t)}o.d(t,{Z:()=>n})},34525:(e,t,o)=>{o.d(t,{e:()=>J});var n=o(24643),i=o(40099),l=o(27535),a=o(67518),s=o(58542),c=o(57431),r=o(25616),d=o(32125),u=o(96754),p=o(93608),v=o(28086),h=o(70911),m=o(50299),f=o(58180);const g=(0,i.memo)((function({disabled:e,onCreate:t,playModeForTea:o}){const[,l]=(0,v.I)(h.e,{resetStateBeforeDispatch:!0}),[a,c]=(0,u.HQ)((e=>{var t;return BigInt(null!==(t=e.total)&&void 0!==t?t:0)>0})),[d,g]=(0,i.useState)(!1),[x,C]=(0,i.useState)(""),[y,b]=(0,i.useState)(!1),_=(0,r.s)(),I=(0,m.Z)(),j=(0,i.useCallback)((({statusCode:e,collectionIdString:n})=>{0===e&&n?(g(!1),p.f.sendEvent("collection_create_success",{video_selection:"did_not_select",play_mode:o}),c.prependCollectionInfo({collectionId:n,name:x,status:y?3:1,total:"0"}),null==t||t(n)):I({success:!1})}),[o,c,x,y,t,I]),w=(0,i.useCallback)((()=>{return e=this,t=void 0,i=function*(){p.f.sendEvent("name_collection",{make_public:y?1:0,enter_method:"popup_modal",play_mode:o}),yield l({collectionName:x.trim(),collectionStatus:y?3:1},j)},new((n=void 0)||(n=Promise))((function(o,l){function a(e){try{c(i.next(e))}catch(e){l(e)}}function s(e){try{c(i.throw(e))}catch(e){l(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}));var e,t,n,i}),[x,y,l,j,o]),k=(0,i.useCallback)((()=>{C(""),b(!1),g(!0),p.f.sendEvent("create_collection",{enter_method:"popup_modal",has_collections:a?1:0,play_mode:o})}),[a,o]),T=(0,i.useCallback)((e=>{g(e),e||p.f.sendEvent("close_create_collection",{stage:"naming stage",play_mode:o})}),[o]);return(0,n.jsxs)("div",{children:[(0,n.jsx)(s.I05,{leadingIcon:(0,n.jsx)(s.l$J,{}),label:_("create_new_collection_btn"),size:"medium",variant:"secondary",onClick:k,"data-e2e":"collection-action-create","aria-label":_("create_new_collection_btn"),disabled:e,tabIndex:0}),(0,n.jsx)(f.k,{open:d,onOpenChange:T,name:x,onNameChange:C,isPublic:y,onIsPublicChange:b,onNext:w,nextText:_("save_collection_btn")})]})}));var x=o(2584),C=o(60072),y=o(58791),b=o(26290),_=o(62186),I=o(72781),j=o(41428);const w=o(75431).AH` opacity: 0.4; cursor: not-allowed !important; `,k=(0,_.default)(s.KhS)` height: var(--popover-item-height) !important; & > .TUXMenuItem-iconContainer { font-size: 22px; } ${e=>e.disabled&&w} `,T=(0,_.default)(k)` cursor: auto !important; pointer-events: none; background-color: ${s.Tj4.UISheetFlat3}; `,O=(0,_.default)(s.KhS)` &:hover { background-color: unset !important; } ${w} `,M=(0,i.memo)((function({title:e,overflow:t,initialVisibleItems:o,actionOptions:c,open:d,onOpenChange:u,e2eTag:p="action",placement:v,onShowMore:h,trigger:m,itemHeight:f=50,emptyContent:g,style:x,className:C}){const[y,_]=(0,i.useState)(!1),w=(0,i.useRef)(!1),M=(0,r.s)(),{zIndex:L}=(0,a.u)(),[P,S]=(0,I.o)({controlledOpen:d,onControlledOpenChange:u}),[U]=(0,l.Wx)({threshold:1,triggerOnce:!0,onChange:e=>e&&(null==h?void 0:h())}),E=(0,i.useMemo)((()=>(("scroll"===t?.5:1)+o)*f),[o,f,t]),F=(0,i.useMemo)((()=>{const t=E+(e?1:0)*f+8;return Object.assign({maxHeight:t,padding:4,overflowY:"auto",overflowX:"hidden",zIndex:L.overlay-50,"--popover-item-height":`${f}px`},x)}),[f,E,x,e,L.overlay]),D=(0,i.useMemo)((()=>"expand"===t?y?c.slice(o):c.slice(0,o):c),[c,o,t,y]),{handleAction:$,handleKeyDown:N}=(0,I.s)();return(0,i.useEffect)((()=>{w.current&&!P&&setTimeout((()=>{_(!1)}),300),w.current=P}),[P]),(0,n.jsxs)(s.nb1,{"data-e2e":`${p}-group`,trigger:m,open:P,onOpenChange:S,style:F,className:C,placement:v,children:[e&&!y&&(0,n.jsx)(T,{"data-e2e":`${p}-title`,tabIndex:-1,height:f,preventCloseOnClick:!0,children:e}),"expand"===t&&y&&(0,n.jsx)(k,{"data-e2e":`${p}-less`,leadingIcon:(0,n.jsx)(s.pdK,{autoMirror:!0}),onClick:()=>_(!1),preventCloseOnClick:!0,children:M("Back")}),D.map((e=>{const t=(0,j.Z)(e),i=c.findIndex((e=>e.key===t.key))===o,l=(0,n.jsx)("div",{ref:i?U:void 0,children:(0,n.jsx)(k,{"data-e2e":`${p}-${t.key}`,leadingIcon:t.icon,onClick:()=>$(t),onKeyDown:e=>N(t,e),preventCloseOnClick:t.preventCloseOnClick||t.disabled,disabled:t.disabled,children:t.title},t.key)},t.key);return t.tooltip?(0,n.jsx)(s.N0Y,{content:t.tooltip,variant:"secondary",children:l},t.key):l})),0===D.length&&g&&(0,n.jsx)(O,{"data-e2e":`${p}-empty`,preventCloseOnClick:!0,children:(0,n.jsx)(b.F.P2,{as:"div",weight:"normal",align:"center",children:g})}),"expand"===t&&!y&&(0,n.jsx)(k,{"data-e2e":`${p}-more`,leadingIcon:(0,n.jsx)(s.sLX,{}),onClick:()=>_(!0),preventCloseOnClick:!0,children:M("more")})]})})),L={shouldForwardProp:e=>"theme"!==e&&!e.startsWith("$")},P=_.default.div` height: 42.667px; width: 32px; border-radius: 6px; `,S=(0,_.default)("div",L)` display: flex; gap: 12px; align-items: center; pointer-events: ${e=>e.$loading?"none":"auto"}; & > div:nth-of-type(2) { flex: 1; display: flex; flex-direction: column; } `,U=(0,_.default)(b.F.P1)` overflow: hidden; white-space: nowrap; text-overflow: ellipsis; `,E=(0,_.default)(b.F.P3)` display: flex; gap: 2px; align-items: center; `,F=(0,_.default)(M)` &::-webkit-scrollbar { width: 6px; } .TUXMenuItem { padding: 8px 12px; width: 240px; &[data-e2e='collection-title'] { position: fixed; height: auto !important; width: calc(100% - 16px); top: 0; left: 0; padding: 8px 0 2px; margin-block: 0; margin-inline: 8px; border-radius: 8px 8px 0 0; background-color: ${s.Tj4.UISheetFlat3}; z-index: 2; button { width: 100%; pointer-events: auto; } & + div { margin-top: 52px; } } } `,D=_.default.button` color: ${s.Tj4.UITextInfoDisplay}; &:disabled, &[disabled] { color: ${s.Tj4.UIShapeSecondaryMuted2}; cursor: not-allowed; } `;var $=o(71111),N=o(31209);const B=(0,$.atom)({activeItemId:null});B.debugLabel="collectionPopoverAtom";const{useAtomService:z}=(0,N.i)(B,((e,t)=>({showForItem(e,o){t(B,(t=>Object.assign(Object.assign({},t),{activeItemId:e,activePlayModeForTea:o})))},dismiss(){t(B,(e=>Object.assign(Object.assign({},e),{activeItemId:null,activePlayModeForTea:null})))}})));function A({itemId:e,playModeForTea:t}){const[{activeItemId:o,activePlayModeForTea:n},l]=z((e=>e),d.bN),a=(0,i.useMemo)((()=>e===o&&t===n),[o,n,e,t]),s=(0,i.useCallback)(((o,n)=>{a!==o&&(o?(l.showForItem(e,t),p.f.sendEvent("collection_popup_show",{play_mode:t})):(l.dismiss(),p.f.sendEvent("collection_popup_exit",{play_mode:t,enter_method:n?"scroll_to_next":"click"})))}),[l,a,e,t]);return(0,i.useMemo)((()=>[a,s]),[a,s])}const X=(0,i.memo)((function({itemId:e,playModeForTea:t}){const o=(0,C.F3)((t=>{var o,n;return null!==(n=null===(o=t[e])||void 0===o?void 0:o.collected)&&void 0!==n&&n})),l=(0,r.s)(),[a,c]=A({itemId:e,playModeForTea:t}),d=(0,i.useCallback)((()=>{c(!0)}),[c]);return(0,n.jsx)(D,{type:"button",onClick:d,disabled:!o||a,"aria-label":l("favorites_collection_toast_manage"),children:(0,n.jsx)(b.F.P1,{weight:"medium",children:(0,n.jsxs)(s.rxD,{alignItems:"center",children:[(0,n.jsx)("span",{children:l("favorites_collection_toast_manage")}),(0,n.jsx)(s.sJ,{autoMirror:!0})]})})})}));var H=function(e,t,o,n){return new(o||(o=Promise))((function(i,l){function a(e){try{c(n.next(e))}catch(e){l(e)}}function s(e){try{c(n.throw(e))}catch(e){l(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},K=o(24688),Z=o(78662),V=o(21367);const W=_.default.img` width: 100%; height: 100%; object-fit: cover; border-radius: 6px; `,q=_.default.div` display: flex; align-items: center; justify-content: center; background: ${s.Tj4.UIShapeNeutral3}; border-radius: 6px; width: 100%; height: 100%; `;function Q(){return(0,n.jsx)(q,{"data-e2e":"collection-empty-cover",children:(0,n.jsx)(s.xJb,{color:"UIText3",size:"22px"})})}const R=(0,i.memo)((function({cover:e,name:t}){var o;const l=Boolean(null===(o=null==e?void 0:e.urlList)||void 0===o?void 0:o.length),a=(0,i.useMemo)((()=>{var t,o;return null!==(o=null===(t=null==e?void 0:e.urlList)||void 0===t?void 0:t[0])&&void 0!==o?o:""}),[e]);return l?(0,n.jsx)(W,{src:a,alt:t}):(0,n.jsx)(Q,{})})),G=(0,i.memo)((function({collection:e,isSelected:t,loading:o}){var i,l;const a=(0,r.s)(),c=null!==(i=e.total)&&void 0!==i?i:0,d=BigInt(c)===BigInt(1)?a("collectionsProfilePage_favoritesPage_collectionSection_videoLabelSingular"):a("collectionsProfilePage_favoritesPage_collectionSection_videoLabelPlural",{d_numOfVideos:c});return(0,n.jsxs)(S,{$loading:o,children:[(0,n.jsx)(P,{children:(0,n.jsx)(R,{cover:e.cover,name:e.name})}),(0,n.jsxs)("div",{style:{overflow:"hidden"},children:[(0,n.jsx)(U,{weight:"medium",children:null!==(l=e.name)&&void 0!==l?l:""}),(0,n.jsxs)(E,{weight:"normal",color:"UITextPlaceholder",children:[1===e.status&&(0,n.jsx)(s.hN4,{}),d]})]}),t&&(o?(0,n.jsx)(s.XWZ,{size:"small",style:{width:"14px",height:"14px"}}):(0,n.jsx)(s.IuZ,{color:"UIShapePrimary"}))]})}));const J=(0,i.memo)((function({trigger:e,itemId:t,playModeForTea:o,popoverTriggerType:v="default"}){var h;const[f,b]=(0,u.HQ)((e=>e),d.bN),_=(0,i.useMemo)((()=>{var e,t;const o=null!==(t=null===(e=f.collectionList)||void 0===e?void 0:e.length)&&void 0!==t?t:0;return(0===o||o>=4)&&(f.loading||f.hasMore)}),[null===(h=f.collectionList)||void 0===h?void 0:h.length,f.hasMore,f.loading]),[I,j]=A({itemId:t,playModeForTea:o}),w=(0,r.s)(),{direction:k}=(0,a.u)(),{user:T}=(0,i.useMemo)(c.x,[]),{isLoading:O,handleClickFavorite:M}=function({itemId:e,playModeForTea:t,onOpenChange:o,popoverTriggerType:l}){const{user:a}=(0,i.useMemo)(c.x,[]),[s,d]=(0,C.l8)((t=>{var o;return null===(o=t[e])||void 0===o?void 0:o.collected})),[p,v]=(0,u.HQ)((e=>e.loading)),h=(0,r.s)(),f=(0,i.useMemo)((()=>"bottomToast"===l?"bottom":"top"),[l]),g=(0,m.Z)(f),[b,_]=(0,i.useState)(!1),I=(0,i.useMemo)((()=>h("fc_add_toast_added_to_fav")),[h]);return{isLoading:b,handleClickFavorite:(0,y.$)({actionWhenUserLoggedIn:(0,i.useCallback)((()=>{return i=this,c=void 0,u=function*(){if(s)return _(!1),o(!1),void(yield d.postCollectVideo({itemId:e}));_(!0),"default"===l&&o(!0);const[i]=yield Promise.all([d.postCollectVideo({itemId:e}),(null==a?void 0:a.secUid)&&!p&&v.getCollectionInfoList({secUid:a.secUid,isReset:!0})]);0===(null==i?void 0:i.statusCode)?g("default"===l?{success:!0,message:I}:{success:!0,message:I,trailing:(0,n.jsx)(X,{itemId:e,playModeForTea:t})}):(g({success:!1}),o(!1)),_(!1)},new((r=void 0)||(r=Promise))((function(e,t){function o(e){try{l(u.next(e))}catch(e){t(e)}}function n(e){try{l(u.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r((function(e){e(i)}))).then(o,n)}l((u=u.apply(i,c||[])).next())}));var i,c,r,u}),[I,s,p,d,e,v,o,t,l,g,null==a?void 0:a.secUid]),modalConfig:{query:{enter_method:"click_favorite",group_id:e}},sideEffect:()=>{x.O.handleGeneralClick("favorite",{group_id:e,play_mode:t})}})}}({itemId:t,playModeForTea:o,onOpenChange:j,popoverTriggerType:v}),{isLoading:L,selectedCollection:P,handleSelectCollection:S}=function({itemId:e,playModeForTea:t,isFavoriteLoading:o}){const[n]=(0,C.l8)((t=>{var o;return null===(o=t[e])||void 0===o?void 0:o.collected})),l=(0,u.sK)(),a=(0,r.s)(),s=(0,m.Z)(),[c,d]=(0,i.useState)(!1),[v,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),x=(0,i.useCallback)(((o,n)=>H(this,void 0,void 0,(function*(){yield l.moveItems({itemIds:[e],fromCollectionId:o,targetCollectionId:n,onMove:({statusCode:e,fromCollection:i,targetCollection:l})=>{var c,r;if(0===e){n?(p.f.sendEvent("add_vids_to_collection",{play_mode:t,enter_method:"popup_modal"}),o&&p.f.sendEvent("remove_vids_from_collection",{play_mode:t,enter_method:"click_other_collection"})):p.f.sendEvent("remove_vids_from_collection",{play_mode:t,enter_method:"click_same_collection"});const e=n?a("desktopWeb_collectionsP2_collectionName",{collectionName:null!==(r=null==l?void 0:l.name)&&void 0!==r?r:""}):a("desktopWeb_collectionsP2_removedFrom",{collectionName:null!==(c=null==i?void 0:i.name)&&void 0!==c?c:""});s({success:!0,message:e})}else s({success:!1}),h(o);d(!1)}})}))),[e,l,t,s,a]),y=(0,i.useCallback)((e=>H(this,void 0,void 0,(function*(){if(c)return;const t=v===e?"":e;h(t),d(!0),o?g(!0):yield x(v,t)}))),[c,v,o,x]);return(0,i.useEffect)((()=>{f&&!o&&(g(!1),n?x("",v):d(!1))}),[x,o,n,f,v]),(0,i.useEffect)((()=>{n||h("")}),[n]),(0,i.useEffect)((()=>{h("")}),[e]),{isLoading:c,selectedCollection:v,handleSelectCollection:y}}({itemId:t,playModeForTea:o,isFavoriteLoading:O}),[U]=(0,l.Wx)({threshold:1,delay:100,onChange:e=>e&&(null==T?void 0:T.secUid)&&!f.loading&&b.getCollectionInfoList({secUid:T.secUid})}),E=(0,i.useMemo)((()=>"browser_mode"===o?"ltr"===k?"left-start":"right-start":"ltr"===k?"right-end":"left-end"),[o,k]),D=(0,i.useCallback)((e=>{return t=this,o=void 0,i=function*(){e||j(!1)},new((n=void 0)||(n=Promise))((function(e,l){function a(e){try{c(i.next(e))}catch(e){l(e)}}function s(e){try{c(i.throw(e))}catch(e){l(e)}}function c(t){var o;t.done?e(t.value):(o=t.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}c((i=i.apply(t,o||[])).next())}));var t,o,n,i}),[j]),$=(0,i.useMemo)((()=>{var e;return[...(null!==(e=f.collectionList)&&void 0!==e?e:[]).map((e=>{const t=e.collectionId;if(t)return{key:t,title:(0,n.jsx)(G,{collection:e,isSelected:P===t,loading:L}),action:()=>S(t),preventCloseOnClick:!0}})).filter((e=>void 0!==e)),..._?[{key:"loading",title:(0,n.jsx)("div",{ref:U,children:(0,n.jsx)(s.sgs,{style:{width:"100%"}})}),action:()=>{},preventCloseOnClick:!0}]:[]]}),[f.collectionList,_,U,P,L,S]),N=(0,i.useCallback)((e=>{"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),e.preventDefault(),j(!I))}),[I,j]),B=(0,i.cloneElement)(e,{onClick:M,onKeyDown:N});return function(){const{user:e}=(0,i.useMemo)(c.x,[]),[{loading:t,hasMore:o,collectionList:n,statusCode:l},a]=(0,u.HQ)((e=>e),d.bN);(0,i.useEffect)((()=>{!t&&o&&0===(null==n?void 0:n.length)&&0===l&&(null==e?void 0:e.secUid)&&a.getCollectionInfoList({secUid:e.secUid})}),[])}(),function({isOpen:e,handleOpenChange:t}){const o=(0,V.VP)();(0,i.useEffect)((()=>{if(e){const e=(0,K.n)((e=>{const o=e.target;((0,Z.Fj)(window.location.pathname)&&o===document||o instanceof HTMLDivElement&&(o.className.includes("DivColumnListContainer")||function(e){let t=e;for(;t;){if(t.className.includes("DivBrowserModeContainer"))return!0;t=t.parentElement}return!1}(o)))&&t(!1,!0)}),200);return document.addEventListener("scroll",e,!0),()=>{document.removeEventListener("scroll",e,!0)}}}),[e,t]),(0,i.useEffect)((()=>{e&&t(!1,!0)}),[o])}({isOpen:I,handleOpenChange:j}),(0,n.jsx)(F,{trigger:(0,n.jsx)("div",{children:B}),title:(0,n.jsx)(g,{disabled:L,onCreate:S,playModeForTea:o}),actionOptions:$,overflow:"scroll",initialVisibleItems:4,placement:E,open:I,onOpenChange:D,e2eTag:"collection",style:"browser_mode"===o?{zIndex:3001}:{},itemHeight:58.66,emptyContent:w("desktopWeb_collectionsP2_noCollectionsCreated"),className:"collection-popover"})}))},58180:(e,t,o)=>{o.d(t,{k:()=>b});var n=o(24643),i=o(40099),l=o(58542),a=o(25616),s=o(50299),c=o(26325),r=o(39228),d=o(62186);const u=d.default.div` padding: 0 24px 24px 24px; display: flex; flex-direction: column; gap: ${e=>e.hasMakePublic?"20px":"4px"}; `,p=d.default.div` color: ${l.Tj4.UIText3}; font-size: 12px; line-height: 15.6px; margin-top: 4px; font-weight: 400; `,v=d.default.div` display: flex; flex-direction: column; gap: 0px; `,h=d.default.div` margin-bottom: 8px; `,m=d.default.span` font-size: 16px; line-height: 20.8px; font-weight: 500; `,f=d.default.span` color: ${e=>e.hasError?l.Tj4.UITextDanger:l.Tj4.UIText3}; font-size: 14px; line-height: 18.2px; font-weight: 400; `,g=d.default.div` display: flex; align-items: center; font-size: 13px; line-height: 19.5px; font-weight: 500; word-wrap: break-word; color: ${l.Tj4.UITextDanger}; min-height: 19.5px; margin-top: 4px; & > svg { margin-right: 4px; } `,x=(0,d.default)(l.OVK)` align-items: center !important; & > .TUXSwitch-labelContainer { padding-top: 0 !important; & > .TUXSwitch-label { font-weight: 500 !important; font-size: 16px !important; } } `,C=(0,d.default)(l.DBO)` margin-top: 8px; margin-bottom: 4px; & .TUXModalNavBar-title { font-weight: 700; } `;var y=function(e,t,o,n){return new(o||(o=Promise))((function(i,l){function a(e){try{c(n.next(e))}catch(e){l(e)}}function s(e){try{c(n.throw(e))}catch(e){l(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))};const b=(0,i.memo)((function({open:e,onOpenChange:t,name:o,onNameChange:d,isPublic:b,onIsPublicChange:_,nextText:I,onNext:j,loading:w}){const k=(0,a.s)(),T=(0,s.Z)(),[O,M]=(0,i.useState)(!1),[L,P]=(0,i.useState)(!1),S=(0,i.useMemo)((()=>o.length>30),[o.length]),U=(0,i.useMemo)((()=>o.trim().length>0&&!S),[o,S]),E=w||L,F=(0,i.useMemo)((()=>S?k("collectionsProfilePage_favoritesPage_newModal_errorMessage"):O?k("yproject_playlist_name_toast",{name:o}):void 0),[k,o,S,O]),D=(0,i.useCallback)((()=>y(this,void 0,void 0,(function*(){let e;P(!0),d(o.trim());try{e=yield function(e){return t=this,o=void 0,i=function*(){return r.hd.get("/api/playlist/name_check",{query:{name:e},baseUrlType:2,headers:{[c.nk]:r.hd.csrfToken}})},new((n=void 0)||(n=Promise))((function(e,l){function a(e){try{c(i.next(e))}catch(e){l(e)}}function s(e){try{c(i.throw(e))}catch(e){l(e)}}function c(t){var o;t.done?e(t.value):(o=t.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}c((i=i.apply(t,o||[])).next())}));var t,o,n,i}(o.trim())}catch(t){e={statusCode:-1,isValid:!1}}const{statusCode:t,isValid:n}=e;0===t?(n?(M(!1),j()):M(!0),P(!1)):T({success:!1,message:k("Sorry, something wrong with the server, please try again.")})}))),[k,T,d,j,o]),$=(0,i.useCallback)((e=>y(this,void 0,void 0,(function*(){U&&"Enter"===e.key&&(yield D())}))),[U,D]);return(0,i.useEffect)((()=>{M(!1)}),[o]),(0,i.useEffect)((()=>{if(e)return document.addEventListener("keydown",$,!0),()=>{document.removeEventListener("keydown",$,!0)}}),[$,e]),(0,n.jsxs)(l.nOL,{open:e,onOpenChange:t,"data-e2e":"collection-create-modal",style:{zIndex:3001},children:[(0,n.jsx)(C,{title:k("collectionsProfilePage_favoritesPage_newModal_header")}),(0,n.jsxs)(u,{hasMakePublic:void 0!==b,children:[(0,n.jsxs)(v,{children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)(h,{children:[(0,n.jsxs)(m,{children:[k("collection_name_header")," "]}),(0,n.jsxs)(f,{hasError:Boolean(S),children:["(",o.length,"/",30,")"]})]}),(0,n.jsx)(l.ZPA,{ref:t=>{e&&t&&t.focus()},hideLabel:!0,label:k("collection_name_header"),placeholder:k("collection_name_description"),value:o,onChange:d,disabled:E}),(0,n.jsx)(g,{children:F?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.Om6,{size:"13px"}),F]}):null})]}),void 0!==b&&_&&(0,n.jsxs)("div",{children:[(0,n.jsx)(x,{label:k("make_public_toggle"),labelPosition:"before",disabled:E,checked:b,onChange:_}),(0,n.jsx)(p,{children:k("make_public_toggle_description")})]})]}),(0,n.jsx)(l.I05,{disabled:!U,label:null!=I?I:k("Next"),variant:"primary",onClick:D,loading:E})]})]})}))},50299:(e,t,o)=>{o.d(t,{Z:()=>v});var n=o(24643),i=o(40099),l=o(67518),a=o(78448),s=o(59131),c=o(58542),r=o(25616),d=o(45618),u=o(26290);const p=o(62186).default.div` &.dark > .TUXBottomToast, &.dark > .TUXTopToast, & > .TUXBottomToast[data-tux-color-scheme='dark'], & > .TUXTopToast[data-tux-color-scheme='dark'] { background-color: rgba(56, 56, 56, 0.95) !important; } `;function v(e="top",t=3e3){const o=(0,r.s)(),{showToast:v,toastList:h}=(0,d.n)(e),{isDark:m}=(0,l.u)();return(0,i.useCallback)((({success:l,message:r,trailing:d})=>{const f=l||r?r:o("Sorry, something wrong with the server, please try again."),g=(0,i.isValidElement)(f)?f:(0,n.jsx)(u.F.P1,{weight:"medium",children:f}),x=l?(0,n.jsx)(a.R,{color:"UIText1"}):(0,n.jsx)(s.O,{color:"UIText1"}),C="top"===e?{"data-tux-color-scheme":"dark"}:void 0;return h.forEach((e=>e.dismiss())),v((0,n.jsx)(p,{className:m?"dark":"",children:d?(0,n.jsx)(c.qaZ,Object.assign({leading:x,content:g,trailing:d},C)):(0,n.jsx)(c.Mzi,Object.assign({leading:x,content:g},C))}),{durationMs:t,hasToastComponent:!1})}),[t,m,e,v,o,h])}},58791:(e,t,o)=>{o.d(t,{$:()=>a});var n=o(40099),i=o(49057),l=o(16680);function a({actionWhenUserLoggedIn:e,modalConfig:t={},sideEffect:o,alwaysOpenLoginModal:a}){const s=(0,i.W)((()=>["user"]),[]),c=(0,l.b1)();return(0,n.useCallback)(((...n)=>{if(null==o||o(...n),(null==s?void 0:s.user)&&!a){if(!t.isLinkPhoneOrEmail)return null==e?void 0:e(...n);c.openModal(t)}else c.openModal(t)}),[e,null==s?void 0:s.user,c,t,o,a])}},45618:(e,t,o)=>{o.d(t,{n:()=>l});var n=o(40099),i=o(58542);const l=e=>{const t=(0,n.useContext)(i.eU);if(!t)throw Error("ToastContext is undefined when calling useGlobalTUXToast. Make sure to wrap your app with TUXProvider.");const o=`GLOBAL-${e.toUpperCase()}`,l=t.getToasts(o);return{id:o,showToast:(e,{durationMs:n,hasToastComponent:i=!0}={hasToastComponent:!0})=>t.addToast(o,{content:e,hasToastComponent:i},n),showToastSingleMode:(e,{durationMs:n,hasToastComponent:i=!0}={hasToastComponent:!0})=>t.addToastSingleMode(o,{content:e,hasToastComponent:i},n),dismissToast:e=>t.removeToast(e),toastList:l}}}}]);