"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[9636],{96754:(e,t,n)=>{n.d(t,{rS:()=>y,sK:()=>x,HQ:()=>h,x6:()=>b});var o=n(57431),i=n(40040),l=n(44630),a=n(60072),c=n(56070),s=n(26325),r=n(14374),d=n(71111),u=n(31209),p=n(87934);const m=(0,n(51264).l)("/api/collection/move_items/",{statusCode:0});var v=function(e,t,n,o){return new(n||(n=Promise))((function(i,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function c(e){try{s(o.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((o=o.apply(e,t||[])).next())}))};const f={statusCode:0,loading:!1,hasMore:!0,collectionList:[],total:"0"},g=(0,r._)((0,d.atom)(f),{rehydrationKey:"desktop.userPage.userCollectionList"});g.debugLabel="collectionInfoListAtom";const{useAtomService:h,useServiceDispatchers:x,useServiceState:b,getStaticApi:y}=(0,u.i)(g,((e,t)=>({getCollectionInfoList(n){return v(this,void 0,void 0,(function*(){const{secUid:a,isReset:r=!1}=n;try{t(g,(e=>Object.assign(Object.assign({},e),{loading:!0})));const{user:n}=(0,o.x)(),d=Object.assign(Object.assign({},(0,l.bv)(e,g,{secUid:a})),{appId:i.xE,publicOnly:(null==n?void 0:n.secUid)!==a});r&&(d.cursor="0");const u=function(e){return v(this,void 0,void 0,(function*(){return c.h.get("/api/user/collection_list/",{query:e,baseUrlType:2,headers:{[s.nk]:c.h.csrfToken}})}))}(d);t(g,(e=>Object.assign(Object.assign({},e),{prevPromise:u})));const p=yield u;t(g,(e=>{var t,n;if(e.prevPromise!==u)return e;if(r)return Object.assign(Object.assign(Object.assign({},e),p),{loading:!1});const o=[...null!==(t=e.collectionList)&&void 0!==t?t:[]],i=new Set(o.map((e=>e.collectionId)));for(const e of null!==(n=p.collectionList)&&void 0!==n?n:[])i.has(e.collectionId)||(i.add(e.collectionId),o.push(e));return Object.assign(Object.assign(Object.assign({},e),p),{collectionList:o,loading:!1})}))}catch(e){t(g,(e=>Object.assign(Object.assign({},e),{loading:!1,statusCode:-1})))}}))},resetCollectionInfoList(){t(g,Object.assign({},f))},moveItems({itemIds:n,fromCollectionId:o,targetCollectionId:i,onMove:l}){var c,s,r,d,u,f,h;return v(this,void 0,void 0,(function*(){if(0===n.length)return;const v=e(g),x=null===(c=v.collectionList)||void 0===c?void 0:c.find((e=>e.collectionId===o)),b=null===(s=v.collectionList)||void 0===s?void 0:s.find((e=>e.collectionId===i)),y=null!==(r=null==x?void 0:x.total)&&void 0!==r?r:"0",C=(BigInt(y)-BigInt(n.length)).toString(),_=null!==(d=null==b?void 0:b.total)&&void 0!==d?d:"0",I=(BigInt(_)+BigInt(n.length)).toString(),j=null===(h=null===(f=null===(u=e(a.Pu)[n[0]])||void 0===u?void 0:u.video)||void 0===f?void 0:f.zoomCover)||void 0===h?void 0:h[240],k="0"===C||null==x?void 0:x.cover,w=!(null==b?void 0:b.cover)&&j?{urlList:[j]}:null==b?void 0:b.cover;let O;if(o)i?(this.modifyCollectionInfo(o,{total:C,cover:k}),this.modifyCollectionInfo(i,{total:I,cover:w}),O=t(m,{itemIDs:n.join(","),fromCollectionID:o,targetCollectionID:i})):(this.modifyCollectionInfo(o,{total:C,cover:k}),O=t(p.m,{collectionId:o,deleteIds:n.join(",")}));else{if(!i)return;this.modifyCollectionInfo(i,{total:I,cover:w}),O=t(p.m,{collectionId:i,commitIds:n.join(",")})}const{statusCode:$}=yield O;0!==$&&(o&&this.modifyCollectionInfo(o,{total:y,cover:null==x?void 0:x.cover}),i&&this.modifyCollectionInfo(i,{total:_,cover:null==b?void 0:b.cover})),null==l||l({statusCode:$,fromCollection:x,targetCollection:b})}))},prependCollectionInfo(n){var o;(null===(o=e(g).collectionList)||void 0===o?void 0:o.some((e=>e.collectionId===n.collectionId)))||t(g,(e=>{var t;return Object.assign(Object.assign({},e),{collectionList:[n,...null!==(t=e.collectionList)&&void 0!==t?t:[]]})}))},modifyCollectionInfo(n,o){const i=e(g);if(!i.collectionList)return;const l=i.collectionList.findIndex((e=>e.collectionId===n));if(l<0)return;const a=[...i.collectionList];a[l]=Object.assign(Object.assign({},a[l]),o),t(g,(e=>Object.assign(Object.assign({},e),{collectionList:a})))}})))},51264:(e,t,n)=>{n.d(t,{l:()=>r});var o=n(56070),i=n(26325),l=n(57431),a=n(89049),c=n(28086),s=function(e,t,n,o){return new(n||(n=Promise))((function(i,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function c(e){try{s(o.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((o=o.apply(e,t||[])).next())}))};function r(e,t){return(0,c.z)({initState:t,fetchAction:(n,c,r)=>s(this,void 0,void 0,(function*(){try{const{user:t,language:n}=(0,l.x)(),s=yield o.h.post(e,{query:Object.assign(Object.assign({},c),{aid:a.xE,region:null==t?void 0:t.region,language:n}),baseUrlType:2,headers:{[i.nk]:o.h.csrfToken}});return null==r||r(s),s}catch(e){const n=Object.assign(Object.assign({},t),{statusCode:-1});return null==r||r(n),n}}))})}},70911:(e,t,n)=>{n.d(t,{e:()=>o});const o=(0,n(51264).l)("/api/collection/create/",{collectionId:0,collectionIdString:"",statusCode:0})},87934:(e,t,n)=>{n.d(t,{m:()=>o});const o=(0,n(51264).l)("/api/collection/modify_items/",{statusCode:0})},72781:(e,t,n)=>{n.d(t,{o:()=>l,s:()=>i});var o=n(40099);function i(e){const t=(0,o.useCallback)(((t,n)=>{n&&(n.preventDefault(),n.stopPropagation()),t.disabled||(t.preventCloseOnClick||null==e||e(!1),t.action())}),[e]),n=(0,o.useCallback)(((e,n)=>{n.target instanceof HTMLInputElement||"Enter"!==n.code&&"Space"!==n.code||(n.preventDefault(),n.stopPropagation(),t(e,n))}),[t]);return{handleAction:t,handleKeyDown:n}}function l({controlledOpen:e,onControlledOpenChange:t}){const[n,i]=(0,o.useState)(!1),l=null!=e?e:n,a=(0,o.useCallback)((e=>{i(e),null==t||t(e)}),[t]);return[l,a]}},24716:(e,t,n)=>{n.d(t,{e:()=>G});var o=n(24643),i=n(40099),l=n(27535),a=n(67518),c=n(58542),s=n(57431),r=n(25616),d=n(32125),u=n(96754),p=n(93608),m=n(71111),v=n(31209);const f=(0,m.atom)({activeItemId:null});f.debugLabel="collectionPopoverAtom";const{useAtomService:g}=(0,v.i)(f,((e,t)=>({showForItem(e,n){t(f,(t=>Object.assign(Object.assign({},t),{activeItemId:e,activePlayModeForTea:n})))},dismiss(){t(f,(e=>Object.assign(Object.assign({},e),{activeItemId:null,activePlayModeForTea:null})))}})));function h({itemId:e,playModeForTea:t}){const[{activeItemId:n,activePlayModeForTea:o},l]=g((e=>e),d.bN),a=(0,i.useMemo)((()=>e===n&&t===o),[n,o,e,t]),c=(0,i.useCallback)(((n,o)=>{a!==n&&(n?(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:o?"scroll_to_next":"click"})))}),[l,a,e,t]);return(0,i.useMemo)((()=>[a,c]),[a,c])}var x=n(28086),b=n(70911),y=n(50299),C=n(58180);const _=(0,i.memo)((function({disabled:e,onCreate:t,playModeForTea:n}){const[,l]=(0,x.I)(b.e,{resetStateBeforeDispatch:!0}),[a,s]=(0,u.HQ)((e=>{var t;return BigInt(null!==(t=e.total)&&void 0!==t?t:0)>0})),[d,m]=(0,i.useState)(!1),[v,f]=(0,i.useState)(""),[g,h]=(0,i.useState)(!1),_=(0,r.s)(),I=(0,y.Z)(),j=(0,i.useCallback)((({statusCode:e,collectionIdString:o})=>{0===e&&o?(m(!1),p.f.sendEvent("collection_create_success",{video_selection:"did_not_select",play_mode:n}),s.prependCollectionInfo({collectionId:o,name:v,status:g?3:1,total:"0"}),null==t||t(o)):I({success:!1})}),[n,s,v,g,t,I]),k=(0,i.useCallback)((()=>{return e=this,t=void 0,i=function*(){p.f.sendEvent("name_collection",{make_public:g?1:0,enter_method:"popup_modal",play_mode:n}),yield l({collectionName:v.trim(),collectionStatus:g?3:1},j)},new((o=void 0)||(o=Promise))((function(n,l){function a(e){try{s(i.next(e))}catch(e){l(e)}}function c(e){try{s(i.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,c)}s((i=i.apply(e,t||[])).next())}));var e,t,o,i}),[v,g,l,j,n]),w=(0,i.useCallback)((()=>{f(""),h(!1),m(!0),p.f.sendEvent("create_collection",{enter_method:"popup_modal",has_collections:a?1:0,play_mode:n})}),[a,n]),O=(0,i.useCallback)((e=>{m(e),e||p.f.sendEvent("close_create_collection",{stage:"naming stage",play_mode:n})}),[n]);return(0,o.jsxs)("div",{children:[(0,o.jsx)(c.I05,{leadingIcon:(0,o.jsx)(c.l$J,{}),label:_("create_new_collection_btn"),size:"medium",variant:"secondary",onClick:w,"data-e2e":"collection-action-create","aria-label":_("create_new_collection_btn"),disabled:e,tabIndex:0}),(0,o.jsx)(C.k,{open:d,onOpenChange:O,name:v,onNameChange:f,isPublic:g,onIsPublicChange:h,onNext:k,nextText:_("save_collection_btn")})]})}));var I=n(2584),j=n(60072),k=n(58791),w=n(26290),O=n(72781),$=n(62186);const M=n(75431).AH` opacity: 0.4; cursor: not-allowed !important; `,P=(0,$.default)(c.KhS,{target:"e12guzic0"})((()=>({height:"var(--popover-item-height) !important","& > .TUXMenuItem-iconContainer":{fontSize:"22px"}})),(({disabled:e})=>e&&M),"label:PopoverActionItem;"),L=(0,$.default)(P,{target:"e12guzic1"})((()=>({cursor:"auto !important",pointerEvents:"none",backgroundColor:c.Tj4.UISheetFlat3})),"label:PopoverTitle;"),T=(0,$.default)(c.KhS,{target:"e12guzic2"})((()=>[M,{"&:hover":{backgroundColor:"unset !important"}}]),"label:EmptyItem;"),S=(0,i.memo)((function({title:e,overflow:t,initialVisibleItems:n,actionOptions:s,open:d,onOpenChange:u,e2eTag:p="action",placement:m,onShowMore:v,trigger:f,itemHeight:g=50,emptyContent:h,style:x,className:b}){const[y,C]=(0,i.useState)(!1),_=(0,i.useRef)(!1),I=(0,r.s)(),{zIndex:j}=(0,a.u)(),[k,$]=(0,O.o)({controlledOpen:d,onControlledOpenChange:u}),[M]=(0,l.Wx)({threshold:1,triggerOnce:!0,onChange:e=>e&&(null==v?void 0:v())}),S=(0,i.useMemo)((()=>(("scroll"===t?.5:1)+n)*g),[n,g,t]),E=(0,i.useMemo)((()=>{const t=S+(e?1:0)*g+8;return Object.assign({maxHeight:t,padding:4,overflowY:"auto",overflowX:"hidden",zIndex:j.overlay-50,"--popover-item-height":`${g}px`},x)}),[g,S,x,e,j.overlay]),U=(0,i.useMemo)((()=>"expand"===t?y?s.slice(n):s.slice(0,n):s),[s,n,t,y]),{handleAction:F,handleKeyDown:D}=(0,O.s)();return(0,i.useEffect)((()=>{_.current&&!k&&setTimeout((()=>{C(!1)}),300),_.current=k}),[k]),(0,o.jsxs)(c.nb1,{"data-e2e":`${p}-group`,trigger:f,open:k,onOpenChange:$,style:E,className:b,placement:m,children:[e&&!y&&(0,o.jsx)(L,{"data-e2e":`${p}-title`,tabIndex:-1,height:g,preventCloseOnClick:!0,children:e}),"expand"===t&&y&&(0,o.jsx)(P,{"data-e2e":`${p}-less`,leadingIcon:(0,o.jsx)(c.pdK,{autoMirror:!0}),onClick:()=>C(!1),preventCloseOnClick:!0,children:I("Back")}),U.map((e=>{const t=s.findIndex((t=>t.key===e.key))===n;return(0,o.jsx)("div",{ref:t?M:void 0,children:(0,o.jsx)(P,{"data-e2e":`${p}-${e.key}`,leadingIcon:e.icon,onClick:()=>F(e),onKeyDown:t=>D(e,t),preventCloseOnClick:e.preventCloseOnClick||e.disabled,disabled:e.disabled,children:e.title},e.key)},e.key)})),0===U.length&&h&&(0,o.jsx)(T,{"data-e2e":`${p}-empty`,preventCloseOnClick:!0,children:(0,o.jsx)(w.F.P2,{as:"div",weight:"normal",align:"center",children:h})}),"expand"===t&&!y&&(0,o.jsx)(P,{"data-e2e":`${p}-more`,leadingIcon:(0,o.jsx)(c.sLX,{}),onClick:()=>C(!0),preventCloseOnClick:!0,children:I("more")})]})}));var E=n(72898);const U=E.I.div((()=>({height:"42.667px",width:"32px",borderRadius:"6px"}))),F=E.I.div((({$loading:e})=>({display:"flex",gap:"12px",alignItems:"center",pointerEvents:e?"none":"auto","& > div:nth-of-type(2)":{flexGrow:1,display:"flex",flexDirection:"column"}}))),D=(0,E.I)(w.F.P1)((()=>({overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}))),N=(0,E.I)(w.F.P3)((()=>({display:"flex",gap:"2px",alignItems:"center"}))),z=(0,E.I)(S)` &::-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: ${c.Tj4.UISheetFlat3}; z-index: 2; button { width: 100%; pointer-events: auto; } & + div { margin-top: 52px; } } } `,A=E.I.button((()=>({color:c.Tj4.UITextInfoDisplay,"&:disabled, &[disabled]":{color:c.Tj4.UIShapeSecondaryMuted2,cursor:"not-allowed"}}))),B=(0,i.memo)((function({itemId:e,playModeForTea:t}){const n=(0,j.F3)((t=>{var n,o;return null!==(o=null===(n=t[e])||void 0===n?void 0:n.collected)&&void 0!==o&&o})),l=(0,r.s)(),[a,s]=h({itemId:e,playModeForTea:t}),d=(0,i.useCallback)((()=>{s(!0)}),[s]);return(0,o.jsx)(A,{type:"button",onClick:d,disabled:!n||a,"aria-label":l("favorites_collection_toast_manage"),children:(0,o.jsx)(w.F.P1,{weight:"medium",children:(0,o.jsxs)(c.rxD,{alignItems:"center",children:[(0,o.jsx)("span",{children:l("favorites_collection_toast_manage")}),(0,o.jsx)(c.sJ,{autoMirror:!0})]})})})}));var q=function(e,t,n,o){return new(n||(n=Promise))((function(i,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function c(e){try{s(o.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((o=o.apply(e,t||[])).next())}))};let H=!1;var K=n(24688),W=n(95868),V=n(93341);const R=(0,$.default)("img",{target:"egz0myv0"})((()=>({width:"100%",height:"100%",objectFit:"cover",borderRadius:"6px"})),"label:ImgCover;"),X=(0,$.default)("div",{target:"egz0myv1"})((()=>({display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:c.Tj4.UIShapeNeutral3,borderRadius:"6px",width:"100%",height:"100%"})),"label:DivEmptyCover;");function Z(){return(0,o.jsx)(X,{"data-e2e":"collection-empty-cover",children:(0,o.jsx)(c.xJb,{color:"UIText3",size:"22px"})})}const Q=(0,i.memo)((function({cover:e,name:t}){var n;const l=Boolean(null===(n=null==e?void 0:e.urlList)||void 0===n?void 0:n.length),a=(0,i.useMemo)((()=>{var t,n;return null!==(n=null===(t=null==e?void 0:e.urlList)||void 0===t?void 0:t[0])&&void 0!==n?n:""}),[e]);return l?(0,o.jsx)(R,{src:a,alt:t}):(0,o.jsx)(Z,{})})),J=(0,i.memo)((function({collection:e,isSelected:t,loading:n}){var i,l;const a=(0,r.s)(),s=null!==(i=e.total)&&void 0!==i?i:0,d=BigInt(s)===BigInt(1)?a("collectionsProfilePage_favoritesPage_collectionSection_videoLabelSingular"):a("collectionsProfilePage_favoritesPage_collectionSection_videoLabelPlural",{d_numOfVideos:s});return(0,o.jsxs)(F,{$loading:n,children:[(0,o.jsx)(U,{children:(0,o.jsx)(Q,{cover:e.cover,name:e.name})}),(0,o.jsxs)("div",{style:{overflow:"hidden"},children:[(0,o.jsx)(D,{weight:"medium",children:null!==(l=e.name)&&void 0!==l?l:""}),(0,o.jsxs)(N,{weight:"normal",color:"UITextPlaceholder",children:[1===e.status&&(0,o.jsx)(c.hN4,{}),d]})]}),t&&(n?(0,o.jsx)(c.XWZ,{size:"small",style:{width:"14px",height:"14px"}}):(0,o.jsx)(c.IuZ,{color:"UIShapePrimary"}))]})}));const G=(0,i.memo)((function(e){var t,{trigger:n,itemId:m,playModeForTea:v}=e,f=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);ie),d.bN),b=(0,i.useMemo)((()=>{var e,t;const n=null!==(t=null===(e=g.collectionList)||void 0===e?void 0:e.length)&&void 0!==t?t:0;return(0===n||n>=4)&&(g.loading||g.hasMore)}),[null===(t=g.collectionList)||void 0===t?void 0:t.length,g.hasMore,g.loading]),[C,w]=h({itemId:m,playModeForTea:v}),O=(0,r.s)(),{direction:$}=(0,a.u)(),{user:M}=(0,i.useMemo)(s.x,[]),{isLoading:P,handleClickFavorite:L}=function({itemId:e,playModeForTea:t,onOpenChange:n,popoverTriggerType:l,toastTheme:a,toastDuration:c}){const{user:d}=(0,i.useMemo)(s.x,[]),[p,m]=(0,j.l8)((t=>{var n;return null===(n=t[e])||void 0===n?void 0:n.collected})),[v,f]=(0,u.HQ)((e=>e.loading)),g=(0,r.s)(),h=(0,i.useMemo)((()=>"bottomToast"===l?"bottom":"top"),[l]),{showToast:x,dismissToast:b}=(0,y.Z)(h,{theme:a,durationMs:c}),[C,_]=(0,i.useState)(!1),w=(0,i.useMemo)((()=>g("fc_add_toast_added_to_fav")),[g]);return{isLoading:C,handleClickFavorite:(0,k.$)({actionWhenUserLoggedIn:(0,i.useCallback)((()=>{return i=this,a=void 0,s=function*(){if(p)return _(!1),n(!1),b(),void(yield m.postCollectVideo({itemId:e}));_(!0),"default"===l&&n(!0);const[i]=yield Promise.all([m.postCollectVideo({itemId:e}),(null==d?void 0:d.secUid)&&!v&&f.getCollectionInfoList({secUid:d.secUid,isReset:!0})]);0===(null==i?void 0:i.statusCode)?x("default"===l?{success:!0,message:w}:{success:!0,message:w,trailing:(0,o.jsx)(B,{itemId:e,playModeForTea:t})}):(x({success:!1}),n(!1)),_(!1)},new((c=void 0)||(c=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function o(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof c?i:new c((function(e){e(i)}))).then(n,o)}l((s=s.apply(i,a||[])).next())}));var i,a,c,s}),[w,p,v,m,e,f,n,t,l,x,null==d?void 0:d.secUid]),modalConfig:{query:{enter_method:"click_favorite",group_id:e}},sideEffect:()=>{I.O.handleGeneralClick("favorite",{group_id:e,play_mode:t})}})}}(Object.assign({itemId:m,playModeForTea:v,onOpenChange:w},f)),{isLoading:T,selectedCollection:S,handleSelectCollection:E}=function({itemId:e,playModeForTea:t,isFavoriteLoading:n}){const[o]=(0,j.l8)((t=>{var n;return null===(n=t[e])||void 0===n?void 0:n.collected})),l=(0,u.sK)(),a=(0,r.s)(),c=(0,y.Z)(),[s,d]=(0,i.useState)(!1),[m,v]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),h=(0,i.useCallback)(((n,o)=>q(this,void 0,void 0,(function*(){yield l.moveItems({itemIds:[e],fromCollectionId:n,targetCollectionId:o,onMove:({statusCode:e,fromCollection:i,targetCollection:l})=>{var s,r;if(0===e){o?(p.f.sendEvent("add_vids_to_collection",{play_mode:t,enter_method:"popup_modal"}),n&&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=o?a("desktopWeb_collectionsP2_collectionName",{collectionName:null!==(r=null==l?void 0:l.name)&&void 0!==r?r:""}):a("desktopWeb_collectionsP2_removedFrom",{collectionName:null!==(s=null==i?void 0:i.name)&&void 0!==s?s:""});c({success:!0,message:e})}else c({success:!1}),v(n);d(!1)}})}))),[e,l,t,c,a]),x=(0,i.useCallback)((e=>q(this,void 0,void 0,(function*(){if(s)return;const t=m===e?"":e;v(t),d(!0),n?g(!0):yield h(m,t)}))),[s,m,n,h]);return(0,i.useEffect)((()=>{f&&!n&&(g(!1),o?h("",m):d(!1))}),[h,n,o,f,m]),(0,i.useEffect)((()=>{o||v("")}),[o]),(0,i.useEffect)((()=>{v("")}),[e]),{isLoading:s,selectedCollection:m,handleSelectCollection:x}}({itemId:m,playModeForTea:v,isFavoriteLoading:P}),[U]=(0,l.Wx)({threshold:1,delay:100,onChange:e=>e&&(null==M?void 0:M.secUid)&&!g.loading&&x.getCollectionInfoList({secUid:M.secUid})}),F=(0,i.useMemo)((()=>"browser_mode"===v?"ltr"===$?"left-start":"right-start":"ltr"===$?"right-end":"left-end"),[v,$]),D=(0,i.useCallback)((e=>{return t=this,n=void 0,i=function*(){e||w(!1)},new((o=void 0)||(o=Promise))((function(e,l){function a(e){try{s(i.next(e))}catch(e){l(e)}}function c(e){try{s(i.throw(e))}catch(e){l(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(a,c)}s((i=i.apply(t,n||[])).next())}));var t,n,o,i}),[w]),N=(0,i.useMemo)((()=>{var e;return[...(null!==(e=g.collectionList)&&void 0!==e?e:[]).map((e=>{const t=e.collectionId;if(t)return{key:t,title:(0,o.jsx)(J,{collection:e,isSelected:S===t,loading:T}),action:()=>E(t),preventCloseOnClick:!0}})).filter((e=>void 0!==e)),...b?[{key:"loading",title:(0,o.jsx)("div",{ref:U,children:(0,o.jsx)(c.sgs,{style:{width:"100%"}})}),action:()=>{},preventCloseOnClick:!0}]:[]]}),[g.collectionList,b,U,S,T,E]),A=(0,i.useCallback)((e=>{"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),e.preventDefault(),w(!C))}),[C,w]),R=(0,i.cloneElement)(n,{onClick:L,onKeyDown:A});return function(){const{user:e}=(0,i.useMemo)(s.x,[]),[{loading:t,hasMore:n,collectionList:o,statusCode:l},a]=(0,u.HQ)((e=>e),d.bN);(0,i.useEffect)((()=>{H||(H=!0,!t&&n&&0===(null==o?void 0:o.length)&&0===l&&(null==e?void 0:e.secUid)&&a.getCollectionInfoList({secUid:e.secUid}))}),[])}(),function({isOpen:e,handleOpenChange:t}){const n=(0,V.VP)();(0,i.useEffect)((()=>{if(e){const e=(0,K.n)((e=>{const n=e.target;((0,W.Fj)(window.location.pathname)&&n===document||n instanceof HTMLDivElement&&(n.className.includes("DivColumnListContainer")||function(e){let t=e;for(;t;){if(t.className.includes("DivBrowserModeContainer"))return!0;t=t.parentElement}return!1}(n)))&&t(!1,!0)}),200);return document.addEventListener("scroll",e,!0),()=>{document.removeEventListener("scroll",e,!0)}}}),[e,t]),(0,i.useEffect)((()=>{e&&t(!1,!0)}),[n])}({isOpen:C,handleOpenChange:w}),(0,o.jsx)(z,{trigger:(0,o.jsx)("div",{children:R}),title:(0,o.jsx)(_,{disabled:T,onCreate:E,playModeForTea:v}),actionOptions:N,overflow:"scroll",initialVisibleItems:4,placement:F,open:C,onOpenChange:D,e2eTag:"collection",style:"browser_mode"===v?{zIndex:3001}:{},itemHeight:58.66,emptyContent:O("desktopWeb_collectionsP2_noCollectionsCreated"),className:"collection-popover"})}))},58180:(e,t,n)=>{n.d(t,{k:()=>C});var o=n(24643),i=n(40099),l=n(58542),a=n(25616),c=n(50299),s=n(26325),r=n(56070),d=n(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; `,m=d.default.div` display: flex; flex-direction: column; gap: 0px; `,v=d.default.div` margin-bottom: 8px; `,f=d.default.span` font-size: 16px; line-height: 20.8px; font-weight: 500; `,g=d.default.span` color: ${e=>e.hasError?l.Tj4.UITextDanger:l.Tj4.UIText3}; font-size: 14px; line-height: 18.2px; font-weight: 400; `,h=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; } } `,b=(0,d.default)(l.DBO)` margin-top: 8px; margin-bottom: 4px; & .TUXModalNavBar-title { font-weight: 700; } `;var y=function(e,t,n,o){return new(n||(n=Promise))((function(i,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function c(e){try{s(o.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((o=o.apply(e,t||[])).next())}))};const C=(0,i.memo)((function({open:e,onOpenChange:t,name:n,onNameChange:d,isPublic:C,onIsPublicChange:_,nextText:I,onNext:j,loading:k}){const w=(0,a.s)(),O=(0,c.Z)(),[$,M]=(0,i.useState)(!1),[P,L]=(0,i.useState)(!1),T=(0,i.useMemo)((()=>n.length>30),[n.length]),S=(0,i.useMemo)((()=>n.trim().length>0&&!T),[n,T]),E=k||P,U=(0,i.useMemo)((()=>T?w("collectionsProfilePage_favoritesPage_newModal_errorMessage"):$?w("yproject_playlist_name_toast",{name:n}):void 0),[w,n,T,$]),F=(0,i.useCallback)((()=>y(this,void 0,void 0,(function*(){let e;L(!0),d(n.trim());try{e=yield function(e){return t=this,n=void 0,i=function*(){return r.h.get("/api/playlist/name_check",{query:{name:e},baseUrlType:2,headers:{[s.nk]:r.h.csrfToken}})},new((o=void 0)||(o=Promise))((function(e,l){function a(e){try{s(i.next(e))}catch(e){l(e)}}function c(e){try{s(i.throw(e))}catch(e){l(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(a,c)}s((i=i.apply(t,n||[])).next())}));var t,n,o,i}(n.trim())}catch(t){e={statusCode:-1,isValid:!1}}const{statusCode:t,isValid:o}=e;0===t?(o?(M(!1),j()):M(!0),L(!1)):O({success:!1,message:w("Sorry, something wrong with the server, please try again.")})}))),[w,O,d,j,n]),D=(0,i.useCallback)((e=>y(this,void 0,void 0,(function*(){S&&"Enter"===e.key&&(yield F())}))),[S,F]);return(0,i.useEffect)((()=>{M(!1)}),[n]),(0,i.useEffect)((()=>{if(e)return document.addEventListener("keydown",D,!0),()=>{document.removeEventListener("keydown",D,!0)}}),[D,e]),(0,o.jsxs)(l.nOL,{open:e,onOpenChange:t,"data-e2e":"collection-create-modal",style:{zIndex:3001},children:[(0,o.jsx)(b,{title:w("collectionsProfilePage_favoritesPage_newModal_header")}),(0,o.jsxs)(u,{hasMakePublic:void 0!==C,children:[(0,o.jsxs)(m,{children:[(0,o.jsxs)("div",{children:[(0,o.jsxs)(v,{children:[(0,o.jsxs)(f,{children:[w("collection_name_header")," "]}),(0,o.jsxs)(g,{hasError:Boolean(T),children:["(",n.length,"/",30,")"]})]}),(0,o.jsx)(l.ZPA,{ref:t=>{e&&t&&t.focus()},hideLabel:!0,label:w("collection_name_header"),placeholder:w("collection_name_description"),value:n,onChange:d,disabled:E}),(0,o.jsx)(h,{children:U?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.Om6,{size:"13px"}),U]}):null})]}),void 0!==C&&_&&(0,o.jsxs)("div",{children:[(0,o.jsx)(x,{label:w("make_public_toggle"),labelPosition:"before",disabled:E,checked:C,onChange:_}),(0,o.jsx)(p,{children:w("make_public_toggle_description")})]})]}),(0,o.jsx)(l.I05,{disabled:!S,label:null!=I?I:w("Next"),variant:"primary",onClick:F,loading:E})]})]})}))},58791:(e,t,n)=>{n.d(t,{$:()=>a});var o=n(40099),i=n(49057),l=n(16680);function a({actionWhenUserLoggedIn:e,modalConfig:t={},sideEffect:n,alwaysOpenLoginModal:a}){const c=(0,i.W)((()=>["user"]),[]),s=(0,l.b1)();return(0,o.useCallback)(((...o)=>{if(null==n||n(...o),(null==c?void 0:c.user)&&!a){if(!t.isLinkPhoneOrEmail)return null==e?void 0:e(...o);s.openModal(t)}else s.openModal(t)}),[e,null==c?void 0:c.user,s,t,n,a])}},44935:(e,t,n)=>{n.d(t,{AP:()=>u,CE:()=>p,MI:()=>v,iB:()=>f,jS:()=>m});var o=n(41271),i=n(72688),l=n(17566),a=n(52333),c=n(32125),s=n(84908);const r="https://www.tiktok.com";function d(e){const t={"<":"<",">":">",'"':""","'":"'","&":"&","/":"/"};let n=`(${Object.keys(t).toString()})`;n=n.replace(/,/g,")|(");const o=new RegExp(n,"g");return e.replace(o,(e=>t[e]))}function u(e){var t,n,u;const p=(0,o.P)(a.k,{selector:t=>t[e],dependencies:[e]}),m=(0,s.nW)((e=>{var t;return e.users[null!==(t=null==p?void 0:p.author)&&void 0!==t?t:""]}),c.bN),{music:v,textExtra:f,desc:g}=null!=p?p:{},{uniqueId:h="",secUid:x}=null!=m?m:{},b=null!==(t=null==v?void 0:v.title)&&void 0!==t?t:"",y=null!==(n=null==v?void 0:v.id)&&void 0!==n?n:"",C=null!==(u=null==v?void 0:v.authorName)&&void 0!==u?u:"",_=(0,i.fJR)({uniqueId:h,secUid:x}),I=(0,i.pHc)({musicName:b,musicId:y}),j=(0,l._u)()(p),k=b.replace(`- ${C}`,"")+(C?` - ${C}`:""),w=`${r}${_.split("?")[0]}`,O=`${r}${I.split("?")[0]}`,$=`${r}${j.split("?")[0]}`,M=`${r}/embed.js`,P=`@${h}`,L=`♬ ${d(k)}`;return`\n
\n
\n ${P}\n ${function(e,t=[]){return t.length?[...t].sort(((e,t)=>e.start-t.start)).reduce(((t,n,o,l)=>{const{start:a,end:c,hashtagName:s,type:u}=n,p=0===o?0:l[o-1].end,m=a,v=e.substring(p,m);v&&(t+=d(v));const f=e.substring(a,c);return t+(1===u&&s?`${d(f)}`:d(f))}),""):`

${d(e)}

`}(null!=g?g:"",f)}\n ${L}\n
\n
\n