PageSourceSearch

https://mirlo.space/assets/Index-gpnP1EN-.js

js mirlo.space collected 2026-10-02 03:33:47 UTC 70,024 bytes, 2 lines download raw bytes

1import{R as x,j as e,u as te,t as Ye,v as Z,m as P,r as H,x as Je,L as Re,q as K,n as $e}from"./vendor-DxTwiIr9.js";import{m as Q,t as ue,an as Xe,a6 as Y,dL as we,d as U,E as ae,U as F,dM as Ge,B as W,a1 as X,o as z,au as le,bN as es,ae as ss,u as ne,dN as ke,L as ts,bj as he,a3 as B,b8 as oe,ba as re,dO as Ee,aQ as as,bB as is,bY as rs,dy as ns,dP as Ue,j as se,l as Ne,ao as Pe,bi as ce,P as ze,p as de,dQ as ls,aq as os,y as xe,bQ as cs,dR as ds,dS as ms,dT as us,dw as hs,bo as xs,dx as ps,e as Oe,be as gs,Z as Ae,Q as bs,dh as fs,dU as Be,cq as Ve,cG as De,C as js,dV as ys,G as vs,dW as me,bv as ws,bz as ks,av as Ns,dX as Ps,_ as As,dY as Cs,dj as Fe,dZ as Ts,d1 as Ds,d_ as Fs,d$ as Is,O as Ss,cF as Ms,ad as Ie,dt as Ls,cE as Rs}from"./index-B0cS9kiR.js";import{u as $s,D as Es}from"./useFormPersist-DsD9ou1W.js";import{u as S,T as ee}from"./i18n-BmyL0TSe.js";import{B as Us}from"./BackToArtistLink-LADIKoBe.js";import{M as zs}from"./ManageSectionWrapper-w_EmI7Iz.js";import{A as He}from"./AutoComplete-D3-GSoOI.js";import"./charts-DHrntohF.js";import{u as We}from"./useManagedArtistQuery-D_wfvJLc.js";import{M as Os,h as je}from"./ManageTags-BtH9WDTk.js";import{o as qe}from"./IncludesDigitalDownload-Cmo6sBha.js";import{S as Bs}from"./SavingInput-CIURLg-G.js";import{B as Vs}from"./index-SAGPuLKI.js";import{c as Hs}from"./cloneDeep-DC0Hyq8x.js";import{T as Ws}from"./Table-CPhe8cNj.js";import{T as qs}from"./TrackAuthors-0R1mTaCW.js";import{T as Ks}from"./TrackRowPlayControl-By8-y_LK.js";import{C as Qs,F as ye}from"./FormCheckbox-DEeNjV9F.js";import{F as ve}from"./FormError-qMv_Y8At.js";import{L as _s}from"./LicenseForm-CIbJ5z7x.js";import{u as Se}from"./useMatchMedia-DY_8qOF4.js";import{U as Zs}from"./UploadArtistImage-D5ljScO-.js";import{f as Ys}from"./ReleaseDate-DSXTDLaW.js";import{T as Js}from"./Toggle-C5ptGH6W.js";import{P as Xs}from"./PaymentSlider-BUNd4SYE.js";import"./markdown-CNkDHZ-E.js";import"./editor-Cm2fdcmq.js";import"./player-Dfxbckx2.js";import"./safeLocalStorage-TrJO6DW3.js";import"./uniq-BGSYOx8e.js";import"./browser-CpzCjPgI.js";import"./UploadImage-CakldA4r.js";const Ke=x.createContext(new Set),Gs=({fields:s,children:r})=>{const t=x.useMemo(()=>new Set(s),[s]);return e.jsx(Ke.Provider,{value:t,children:r})},G=({htmlFor:s,field:r,children:t})=>e.jsxs("label",{htmlFor:s,children:[t,e.jsx(et,{name:r})]}),et=({name:s})=>{const{t:r}=S("translation",{keyPrefix:"common"});return x.useContext(Ke).has(s)?e.jsx("span",{role:"img","aria-label":r("restoredFromDraft"),title:r("restoredFromDraft"),className:"inline-block w-1 h-1 ml-0.5 mt-1 rounded-full bg-(--mi-info-background-color) align-top"}):null},st=({trackGroup:s,reload:r,onSaveSuccess:t})=>{var N,T,D;const{t:i}=S("translation",{keyPrefix:"manageAlbum"}),a=Q(),o=ue(),[m,l]=x.useState(!1),{artistId:n,trackGroupId:p}=te(),{data:d}=Xe(),c=Y(),b=(N=c==null?void 0:c.formState.isDirty)!=null?N:!1,f=d==null?void 0:d.userId,u=we(),y=x.useCallback(async()=>{var L;const C=c.getValues();await u.mutateAsync({formData:C,trackGroupId:s.id,artistId:Number(n),fundraiserId:(L=s.fundraiser)==null?void 0:L.id}),c.reset(C)},[c,u,s.id,(T=s.fundraiser)==null?void 0:T.id,n]),v=x.useCallback(async()=>{var R,h,j,I;if(l(!0),s.publishedAt&&new Date(s.publishedAt)>new Date&&!window.confirm((R=i("publishNowInsteadOf",{futureDate:s.publishedAt.split("T")[0]}))!=null?R:"")){l(!1);return}const C=s.tracks.length===0,L=s.tracks.find(E=>{var O;return((O=E.audio)==null?void 0:O.uploadState)!=="SUCCESS"});if((L||C)&&!window.confirm((h=i(L?"areYouSurePublish":"noTracks"))!=null?h:"")){l(!1);return}const k=s.tracks.filter(E=>!E.title||E.title.trim()==="");if(k.length>0&&!window.confirm((j=i("tracksMissingTitle",{count:k.length}))!=null?j:"")){l(!1);return}try{f&&p&&(b&&(await y(),t==null||t()),await U.put("manage/trackGroups/".concat(p,"/publish"),{}),a(i(s.publishedAt?"madePrivate":"publishedSuccess"),{type:"success"}))}catch(E){console.error(E),a((I=E.message)!=null?I:i("somethingWentWrong"),{type:"warning"})}finally{await r(),l(!1)}},[s.tracks,s.publishedAt,i,f,p,b,y,t,a,r]),w=x.useCallback(async()=>{try{await y(),t==null||t(),a(i("releaseUpdated"),{type:"success"})}catch(C){o(C)}},[y,t,a,o,i]);if(!s||!d)return null;if(ae(s))return e.jsx("div",{className:"flex flex-wrap gap-3",children:e.jsx(F,{type:"button",isLoading:u.isPending,onClick:w,disabled:u.isPending||!b,className:"!bg-(--mi-green-500) !border-(--mi-green-700) !text-(--mi-green-100) [&_svg]:!fill-(--mi-green-100) enabled:hover:!bg-(--mi-green-700) enabled:hover:!border-(--mi-green-700) disabled:grayscale disabled:!opacity-50",children:i("updateRelease")})});const A=((D=s.tracks)==null?void 0:D.length)===0&&!s.fundraisingGoal;return e.jsx("div",{className:"flex flex-wrap gap-3",children:e.jsx(F,{type:"button",isLoading:m,onClick:v,disabled:m||A,title:A?i("publishDisabledNoTracks"):void 0,className:"!bg-(--mi-green-500) !border-(--mi-green-700) !text-(--mi-green-100) [&_svg]:!fill-(--mi-green-100) enabled:hover:!bg-(--mi-green-700) enabled:hover:!border-(--mi-green-700) disabled:grayscale disabled:!opacity-50",children:i("publishSimple")})})},tt=({existingObject:s,onSaveSuccess:r})=>{const{t}=S("translation",{keyPrefix:"manageAlbum"}),{isDirty:i}=Ge(),{getValues:a,reset:o}=Y(),{artistId:m}
1=te(),l=Q(),n=ue(),p=we();if(ae(s))return null;const d=async()=>{var b,f;const c=a();try{const u=await p.mutateAsync({formData:c,trackGroupId:s.id,artistId:Number(m),fundraiserId:(b=s.fundraiser)==null?void 0:b.id});o({...c,urlSlug:(f=u[0].result.urlSlug)!=null?f:c.urlSlug}),r==null||r(),l(t("draftSaved"),{type:"success"})}catch(u){n(u)}};return e.jsx(F,{type:"button",onClick:d,isLoading:p.isPending,disabled:p.isPending||!i,variant:"outlined",children:t("saveAlbumDraft")})},at=({existingObject:s,reload:r})=>{const{t,i18n:i}=S("translation",{keyPrefix:"manageAlbum"}),{artistId:a,trackGroupId:o}=te(),m=ue(),[l,n]=x.useState(null),[p,d]=x.useState(""),[c,b]=x.useState(!1),f=new Date().toISOString().split("T")[0];if(ae(s))return null;const u=s.publishedAt&&new Date(s.publishedAt)>new Date?s.publishedAt:null,y=()=>{d(""),n("schedule")},v=async()=>{if(!(!p||!o||!a)){b(!0);try{await U.put("manage/trackGroups/".concat(o),{publishedAt:new Date("".concat(p,"T00:00:00")).toISOString(),artistId:Number(a)}),await r(),n(null)}catch(g){m(g)}finally{b(!1)}}},w=async()=>{if(!(!o||!a)){b(!0);try{await U.put("manage/trackGroups/".concat(o),{publishedAt:null,artistId:Number(a)}),await r(),n(null)}catch(g){m(g)}finally{b(!1)}}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[u?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("scheduledPublicationLabel",{date:Ys({date:u,options:{year:"numeric",month:"short",day:"numeric"},i18n:i})})}),e.jsx(W,{type:"button",variant:"link",onClick:()=>n("cancel"),className:"!text-inherit",children:t("scheduledPublicationCancelButton")})]}):e.jsx(W,{type:"button",variant:"link",onClick:y,className:"!text-inherit opacity-60 hover:opacity-100",children:t("schedulePublicationLink")}),e.jsx(X,{open:l==="schedule",onClose:()=>n(null),title:t("schedulePublicationModalTitle"),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{id:"hint-schedule-publication-date",children:t("schedulePublicationModalBody")}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{htmlFor:"input-schedule-publication-date",children:t("schedulePublicationDateLabel")}),e.jsx(z,{id:"input-schedule-publication-date",type:"date",min:f,value:p,onChange:g=>d(g.target.value),"aria-describedby":"hint-schedule-publication-date"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{type:"button",onClick:v,disabled:!p||c,isLoading:c,children:t("schedulePublicationConfirm")}),e.jsx(W,{type:"button",variant:"outlined",onClick:()=>n(null),disabled:c,children:t("schedulePublicationCancel")})]})]})}),e.jsx(X,{open:l==="cancel",onClose:()=>n(null),title:t("cancelSchedulePublicationModalTitle"),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{children:t("cancelSchedulePublicationModalBody")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{type:"button",onClick:w,disabled:c,isLoading:c,children:t("cancelSchedulePublicationConfirm")}),e.jsx(W,{type:"button",variant:"outlined",onClick:()=>n(null),disabled:c,children:t("cancelSchedulePublicationKeep")})]})]})})]})},Me=({existingObject:s,reload:r,onSaveSuccess:t,className:i})=>{var o;const{t:a}=S("translation",{keyPrefix:"manageAlbum"});return e.jsxs("div",{className:Ye("flex flex-wrap items-start gap-2 bg-(--mi-background-color) py-4",i),children:[e.jsx(tt,{existingObject:s,onSaveSuccess:t}),!ae(s)&&(((o=s.tracks)==null?void 0:o.length)>0||!!s.fundraiser)&&s.artist&&e.jsx(le,{to:ss(s.artist,s),startIcon:e.jsx(es,{}),variant:"dashed",children:a("previewRelease")}),e.jsxs("div",{className:"ml-auto flex flex-col items-end gap-1",children:[e.jsx(st,{trackGroup:s,reload:r,onSaveSuccess:t}),e.jsx(at,{existingObject:s,reload:r})]})]})},it=({trackGroupId:s,fundraiser:r})=>{var R;const t=Q(),{t:i}=S("translation",{keyPrefix:"manageAlbum"}),{register:a}=Y(),{user:o}=ne(),[m,l]=x.useState(!1),[n,p]=x.useState(!1),{data:d,refetch:c}=Z(ke(s)),b=!!(r!=null&&r.isAllOrNothing),f=(R=r==null?void 0:r.goalAmount)!=null?R:0,{data:{totalAmount:u,totalPledges:y}={results:[],total:0,totalAmount:0,totalSupporters:0,totalPledges:0}}=Z(ts(s)),v=(y!=null?y:0)>0,w=(r==null?void 0:r.status)==="SUCCESSFUL",g=!w&&(!b||u>0&&f<=u),A=async()=>{try{if(l(!0),!r)return;await U.post("manage/fundraisers/".concat(r.id,"/chargePledges"),{message:"Fundraiser successfully funded!"}),t(i("chargePledgesSuccess"),{type:"success"}),c()}catch(h){console.error(h)}finally{l(!1)}},N=async()=>{try{l(!0),p(!0),await U.post("manage/trackGroups/".concat(s,"/fundraiser"),{}),c()}catch(h){console.error(h)}finally{l(!1)}},T=async()=>{try{if(l(!0),p(!1),!r||v&&!confirm(i("removingFundraiserWithPledgesWarning",{count:y!=null?y:0})))return;await U.delete("manage/trackGroups/".concat(s,"/fundraiser")),t(i("fundraiserRemoved"),{type:"success"}),c()}catch(h){console.error(h),t(i("removalFailed"),{type:"warning"})}finally{l(!1)}},D=x.useRef(null),{ref:C,...L}=a("goalAmount",{min:0}),k=h=>{C(h),D.current=h};return x.useEffect(()=>{var h;n&&((h=D.current)==null||h.focus())},[n,D.current]),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center w-full",children:[e.jsx("h2",{children:i("fundraisingGoal")}),w&&e.jsx("p",{className:"text-sm text-(--mi-success-text-color) font-semibold",children:i("fundraiserComplete")}
1),e.jsxs("div",{className:"flex gap-2",children:[r.isAllOrNothing&&e.jsx(le,{to:"/manage/fundraiser/".concat(r.id,"/pledges"),className:"flex items-center gap-1",children:i("viewPledges")}),g&&e.jsx(F,{type:"button",onClick:A,isLoading:m,children:i(b?"chargePledges":"markFundraiserDone")}),r&&e.jsx(F,{type:"button",onClick:T,isLoading:m,startIcon:e.jsx(he,{}),children:i(v?"cancelFundraiser":"removeFundraiser")})]})]}),e.jsxs("div",{className:P({name:"4rrsf8",styles:"width:100%;display:grid;grid-template-columns:repeat(2, 1fr);gap:0.5rem"}),children:[e.jsxs(B,{children:[e.jsx("label",{htmlFor:"input-fundraiser-name",children:i("fundraiserName")}),e.jsx(z,{id:"input-fundraiser-name","aria-describedby":"description-fundraiser-name",...a("fundraiserName")}),e.jsx("span",{className:"text-sm",id:"description-fundraiser-name",children:i("fundraiserNameDescription")})]}),e.jsxs(B,{children:[e.jsx("label",{htmlFor:"input-goal-amount",children:i("goal")}),e.jsxs("div",{className:"flex items-center gap-2",children:[(o==null?void 0:o.currency)&&e.jsx("span",{className:"ml-1",children:oe(o.currency)}),e.jsx(z,{"aria-describedby":"description-goal-amount",id:"input-goal-amount",type:"number",step:"0.01",min:0,...L,ref:k})]}),e.jsx("span",{className:"text-sm",id:"description-goal-amount",children:i("fundraisingGoalDescription")})]})]}),e.jsxs(B,{children:[e.jsx("label",{htmlFor:"input-fundraiser-description",children:i("fundraiserDescription")}),e.jsx(re,{id:"input-fundraiser-description",rows:3,"aria-describedby":"description-fundraiser-description",...a("fundraiserDescription")}),e.jsx("span",{className:"text-sm",id:"description-fundraiser-description",children:i("fundraiserDescriptionDescription")})]}),e.jsxs(B,{direction:"row",children:[e.jsx("div",{children:e.jsx(z,{"aria-describedby":"description-all-or-nothing",id:"isAllOrNothing",type:"checkbox",disabled:v,...a("isAllOrNothing")})}),e.jsxs("div",{className:"flex flex-col pl-2",children:[e.jsx("label",{htmlFor:"isAllOrNothing",children:i("isAllOrNothing")}),e.jsxs("small",{id:"description-all-or-nothing",children:[i("isAllOrNothingDescription"),v&&e.jsxs(e.Fragment,{children:[" ",i("isAllOrNothingLockedWithPledges")]})]})]})]})]}):e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("h2",{children:i("addFundraiser")}),e.jsx("small",{id:"description-add-fundraiser",children:i("addFundraiserDescription")}),e.jsx(F,{wrap:!0,type:"button",onClick:N,isLoading:m,"aria-describedby":"description-add-fundraiser",className:"mt-4",children:i("addFundraiserToThisRelease")})]})},rt=({existingObject:s,reload:r,hasReleaseDate:t})=>{var Ce,Te;const{t:i}=S("translation",{keyPrefix:"manageAlbum"}),{artistId:a,trackGroupId:o}=te(),{watch:m,setValue:l}=Y(),n=ue(),p=m("releaseDate"),{mutateAsync:d}
1=Ee(),[c,b]=x.useState(s.isPreorder),[f,u]=x.useState(s.scheduleEndOnReleaseDate),[y,v]=x.useState(s.makeTracksPreviewableOnRelease);x.useEffect(()=>{b(s.isPreorder),u(s.scheduleEndOnReleaseDate),v(s.makeTracksPreviewableOnRelease)},[s.isPreorder,s.scheduleEndOnReleaseDate,s.makeTracksPreviewableOnRelease]);const w=ae(s),[g,A]=x.useState(!1),[N,T]=x.useState(!1),[D,C]=x.useState(!1),[L,k]=x.useState(!1),[R,h]=x.useState(!1),j=!!p&&new Date(p)<new Date(new Date().toDateString()),I=t&&!j,E=(Te=(Ce=s.releaseDate)==null?void 0:Ce.split("T")[0])!=null?Te:"",O=x.useRef(I);x.useEffect(()=>{f&&O.current&&!I&&k(!0),O.current=I},[I,f]);const $=async()=>{k(!1);try{await U.put("manage/trackGroups/".concat(o),{scheduleEndOnReleaseDate:!1,makeTracksPreviewableOnRelease:!1,artistId:Number(a)}),r()}catch(M){n(M)}},V=()=>{k(!1),l("releaseDate",E)},ie=async M=>{try{await U.put("manage/trackGroups/".concat(o),{...M,artistId:Number(a)}),r()}catch(ge){n(ge),r()}},J=async M=>{b(M),M||(u(!1),v(!1));try{await U.put("manage/trackGroups/".concat(o),{isPreorder:M,...!M&&{scheduleEndOnReleaseDate:!1,makeTracksPreviewableOnRelease:!1},artistId:Number(a)}),await d({trackGroupId:Number(o),isPreview:!M}),r()}catch(ge){b(!M),n(ge)}},pe=async()=>{try{await U.post("manage/trackGroups/".concat(o,"/endPreorder"),{makeTracksPreviewable:R}),A(!1),h(!1),r()}catch(M){n(M)}},_e=async M=>{if(M&&!t){T(!0);return}if(M&&j){C(!0);return}u(M),M||v(!1),await ie({scheduleEndOnReleaseDate:M,...!M&&{makeTracksPreviewableOnRelease:!1}})},Ze=async M=>{v(M),await ie({makeTracksPreviewableOnRelease:M})};return e.jsxs(q,{children:[e.jsx("h2",{children:i("preOrder")}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Js,{label:i("setupAsPreorder"),toggled:c,onClick:J}),c&&e.jsxs(e.Fragment,{children:[e.jsx("small",{children:e.jsx(ee,{i18nKey:"manageAlbum.preorderTrackInfo",components:{strong:e.jsx("strong",{})}})}),e.jsxs("div",{className:"ml-4 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start gap-2 p-1",children:[e.jsx(z,{id:"input-schedule-preorder-release","aria-describedby":"hint-schedule-preorder-release",type:"checkbox",checked:f,onChange:M=>_e(M.target.checked),className:"mt-0.5 w-8 shrink-0"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"input-schedule-preorder-release",children:i("schedulePreorderReleaseDate")}),e.jsx("small",{id:"hint-schedule-preorder-release",className:"block mt-1",children:e.jsx(ee,{i18nKey:"manageAlbum.schedulePreorderNotPublicationHint",components:{strong:e.jsx("strong",{})}})})]})]}),f&&e.jsxs("div",{className:"flex items-start gap-2 p-1",children:[e.jsx(z,{id:"input-make-tracks-previewable-on-release",type:"checkbox",checked:y,onChange:M=>Ze(M.target.checked),className:"mt-0.5 w-8 shrink-0"}),e.jsx("label",{htmlFor:"input-make-tracks-previewable-on-release",children:i("setTracksAsFreeListen")})]}),f&&t&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-start gap-3",children:[e.jsxs("div",{className:"w-fit rounded border border-black/10 bg-(--mi-tint-color) p-3 opacity-80",children:[e.jsx("label",{htmlFor:"input-preorder-release-date",className:"text-sm text-(--mi-neutral-500)",children:i("currentReleaseDate")}),e.jsx(z,{id:"input-preorder-release-date",type:"date",value:p,disabled:!0,"aria-describedby":"hint-preorder-release-date",className:"mt-1 opacity-60"}),e.jsx("small",{id:"hint-preorder-release-date",className:"sr-only",children:i("releaseDateScheduledHint")})]}),e.jsx("small",{className:"flex-1 mt-1",children:i("releaseDatePreorderHint")})]})]}),e.jsx(W,{wrap:!0,type:"button",className:"self-start",onClick:()=>A(!0),children:i("endPreorderCampaign")}),e.jsx("small",{className:"ml-1 block",children:i("releasePreorderHint")})]})]}),e.jsx(X,{open:g,onClose:()=>A(!1),title:i("endPreorderCampaign"),children:w?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{children:i("endPreorderConfirmation")}),e.jsxs(Qs,{htmlFor:"input-make-tracks-previewable",children:[e.jsx(z,{id:"input-make-tracks-previewable",type:"checkbox",checked:R,onChange:M=>h(M.target.checked)}),i("makeTracksPreviewableOnRelease")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{type:"button",onClick:pe,children:i("confirmEndPreorder")}),e.jsx(W,{type:"button",onClick:()=>A(!1),children:i("cancel")})]})]}):e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{children:i("endPreorderNotPublished")}),e.jsx(W,{type:"button",onClick:()=>A(!1),children:i("cancel")})]})}),e.jsx(X,{open:N,onClose:()=>T(!1),title:i("schedulePreorderReleaseDate"),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{children:i("noReleaseDateSet")}),e.jsx(W,{type:"button",onClick:()=>T(!1),children:i("cancel")})]})}),e.jsx(X,{open:D,onClose:()=>C(!1),title:i("schedulePreorderReleaseDate"),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{children:i("releaseDateInPast")}),e.jsx(W,{type:"button",onClick:()=>C(!1),children:i("cancel")})]})}),e.jsx(X,{open:L,onClose:V,title:i("schedulePreorderReleaseDate"),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{children:i("removeScheduleOnDate
1ChangeWarning")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{type:"button",onClick:$,children:i("continue")}),e.jsx(W,{type:"button",onClick:V,children:i("cancel")})]})]})})]})},nt=({reload:s,tracks:r})=>{const{t}=S("translation",{keyPrefix:"manageAlbum"}),i=Q(),[a,o]=H.useState(),m=async l=>{try{await Promise.all(r.map(n=>U.put("manage/tracks/".concat(n.id),{minPrice:a&&l?a*100:void 0,allowIndividualSale:l}))),await U.put("manage/trackGroups/".concat(r[0].trackGroupId),{defaultTrackAllowIndividualSale:l,defaultTrackMinPrice:a&&l?a*100:void 0}),l||o(void 0),i(t("updatedAllTracks"),{type:"success"}),s()}catch(n){console.error("Error updating tracks:",n)}};return e.jsxs("div",{className:P({name:"naywx9",styles:"display:flex;flex-wrap:wrap;gap:1rem;align-items:flex-end;padding:1rem 0;input{margin-bottom:0!important;}>div{margin-bottom:0!important;}"}),children:[e.jsxs(B,{children:[e.jsx("label",{htmlFor:"minPriceOnTracks",children:t("minPriceOnTracks")}),e.jsx(z,{id:"minPriceOnTracks",type:"number",value:a,step:"0.01",min:0,className:P({name:"1pzk433",styles:"width:100px"}),onChange:l=>{const n=Number(l.target.value);o(Number.isFinite(n)&&n>=0?n:0)}})]}),e.jsx(F,{wrap:!0,type:"button",onClick:()=>m(!0),children:t("setPriceOfAllTracks")}),e.jsx(F,{wrap:!0,type:"button",variant:"dashed",onClick:()=>m(!1),children:t("dontAllowIndividualSale")})]})},lt=({existingObject:s,reload:r})=>{var C,L,k,R;const{t}=S("translation",{keyPrefix:"manageAlbum"}),{trackGroupId:i}=te(),{data:a}=We(),{control:o,formState:{dirtyFields:m,errors:l,touchedFields:n},register:p,watch:d,setValue:c,getValues:b}=Y(),{field:f}=as({control:o,name:"isGettable",defaultValue:!1}),{user:u}=ne(),y={"free-or-donate":x.useRef(null),paid:x.useRef(null),"no-payments":x.useRef(null)},v=(C=f.value)!=null?C:!1,w=Number(d("minPrice")||0),g=Number(d("suggestedPrice")||w);x.useEffect(()=>{const h=m.minPrice||n.minPrice,j=m.suggestedPrice;h&&w>g&&!j&&(c("minPrice",w.toString(),{shouldTouch:!0}),c("suggestedPrice",w.toString(),{shouldDirty:!1}))},[m,w,g,n.minPrice]);const A=v?w>0?"paid":"free-or-donate":"no-payments",N=x.useCallback(h=>{var V;const j=Number(b("minPrice")||0),I=Number(b("suggestedPrice")||j);let E=!0,O=j,$=I;h==="no-payments"&&(E=!1),h==="free-or-donate"&&(E=!0,O=0),h==="paid"&&(E=!0,O<=0&&(O=I>0?I:1)),c("isGettable",E,{shouldDirty:!0}),c("minPrice",O.toString(),{shouldDirty:!0}),c("suggestedPrice",$.toString(),{shouldDirty:!0}),(V=y[h].current)==null||V.focus()},[b,f,y,c]),T=(L=a==null?void 0:a.subscriptionTiers.filter(h=>{var j;return(j=h.releases)==null?void 0:j.some(I=>I.trackGroupId===Number(i))}))!=null?L:[],D=(k=a==null?void 0:a.subscriptionTiers.filter(h=>h.autoPurchaseAlbums))!=null?k:[];return a?e.jsxs(q,{children:[e.jsx("h2",{id:"label-pricing",children:t("priceAndSuch")}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(B,{children:e.jsx("div",{"aria-labelledby":"label-pricing",className:P({name:"1jzjzef",styles:"display:flex;& input:focus-visible+label>button{outline:5px auto Highlight;outline:5px auto -webkit-focus-ring-color;}& label:first-of-type>button{border-start-end-radius:0;border-end-end-radius:0;}& label~label>button{border-radius:0;}& label:last-of-type>button{border-start-end-radius:var(--mi-border-radius);border-end-end-radius:var(--mi-border-radius);}"}),role:"group",children:[{key:"free-or-donate",label:t("pricingFreeOrDonate",{currency:u!=null&&u.currency?oe(u==null?void 0:u.currency):""})},{key:"paid",label:t("pricingPaid")},{key:"no-payments",label:t("pricingNoPayments")}].map(h=>{const j=A===h.key,I="pricing-".concat(h.key);return e.jsxs(x.Fragment,{children:[e.jsx("input",{checked:j,className:"sr-only",id:I,name:"pricing",onChange:()=>N(h.key),ref:y[h.key],type:"radio"}),e.jsx("label",{htmlFor:I,children:e.jsx(F,{onClick:()=>N(h.key),tabIndex:-1,type:"button",variant:j?"default":"outlined",children:h.label})})]},h.key)})})}),e.jsxs("div",{hidden:!v,children:[e.jsxs(B,{className:"grow",children:[e.jsx("label",{htmlFor:"input-minimum-price",children:t("minimumPrice")}),e.jsx("small",{id:"description-minimum-price",className:"max-w-[72ch]",children:t("minimumPriceDescription")}),e.jsxs("div",{className:P({name:"s5xdrg",styles:"display:flex;align-items:center"}),children:[(u==null?void 0:u.currency)&&e.jsx("div",{className:P({name:"gx3s2p",styles:"width:2rem;height:89%;display:flex;align-items:center;justify-content:center;margin-bottom:0.25rem"}),id:"unit-minimum-price",children:oe(u==null?void 0:u.currency)}),e.jsx(z,{"aria-describedby":"unit-minimum-price description-minimum-price hint-minimum-price-access hint-minimum-price-currency",id:"input-minimum-price",type:"number",step:"0.01",min:0,...p("minPrice",{min:0})})]}),e.jsx("small",{id:"hint-minimum-price-access",className:"max-w-[72ch]",children:a.maxFreePlays?t("pricingHelpWithLimit",{count:a.maxFreePlays}):t("pricingHelp")}),l.minPrice&&e.jsx(ve,{children:t("priceZeroOrMore")}),e.jsx("small",{id:"hint-minimum-price-currency",className:"max-w-[72ch]",children:t("currencyIsSetOnManageArtist")})]}),e.jsxs(B,{className:"grow",children:[e.jsx("label",{htmlFor:"input-suggested-price",children:t("suggestedPrice")}),e.jsx("small",{id:"hint-suggested-price",className:"max-w-[72ch]",children:t("suggestedPriceDescription")}),e.jsx("small",{id:"hint-suggested-price-clarifier",className:"max-w-[72ch]",children:t("suggestedPriceDescriptionClarifier")}),e.jsxs("div",{className:P({name:"s5xdrg",styles:"display:flex;align-items:center"}),children:[(u==null?void 0:u.currency)&&e.jsx("div",{className:P({name:"gx3s2p",styles:"width:2rem;height:89%;display:flex;align-items:center;justify-content:center;margin-bottom:0.25rem"}),id:"unit-suggested-price",children:oe(u==null?void 0:u.currency)}),e.jsx(z,{"aria-describedby":"unit-suggested-price hint-suggested-price hint-suggested-price-clarifier",id:"input-suggested-price",type:"number",step:"0.01",min:w,...p("suggestedPrice",{min:w})})]})]}),e.jsxs(B,{className:"max-w-150",children:[e.jsx(Xs,{label:t("platformPercent")}),l.platformPercent&&e.jsx(ve,{children:t("platformPercent")})]})]}),s&&((R=s==null?void 0:s.tracks)==null?void 0:R.length)>0&&A!=="no-payments"&&e.jsx(nt,{tracks:s.tracks,reload:r})]}),e.jsxs("div",{className:"w-full flex flex-col gap-2 border-1 border-(--mi-tint-x-color) px-4 py-3",children:[!v&&e.jsx("p",{children:t("albumNotAvailableForPurchase")}),T.length>0&&e.jsx("p",{children:t("albumGrantedBySubscriptionTier",{tiers:T.map(h=>h.name).join(", ")})}),D.length>0&&e.jsx("p",{children:t("albumGrantedToSubscriptionTiersWhenPublished",{tiers:D.map(h=>h.name).join(", ")})}),T.length===0&&D.length===0&&e.jsx("p",{children:e.jsx(ee,{i18nKey:"manageOnSubscription",t,components:{subscriptionLink:e.jsx(is,{to:rs(a.id)})}})})]})]}):null},ot=({existingObject:s})=>{var l;const{t:r}=S("translation",{keyPrefix:"manageAlbum"}),{watch:t,setValue:i}=Y(),a=ae(s),o=(l=t("isPublic"))!=null?l:s.isPublic,m=n=>{i("isPublic",n,{shouldDirty:!0})};return e.jsxs("fieldset",{className:"flex flex-col gap-2 mt-4",children:[e.jsx("legend",{className:"font-semibold mb-2",children:r(a?"visibilityPublished":"visibility")}),e.jsxs("label",{htmlFor:"input-visibility-public",className:"flex items-start gap-2 cursor-pointer",children:[e.jsx(z,{id:"input-visibility-public",type:"radio",name:"visibility",checked:o,onChange:()=>m(!0),"aria-describedby":"hint-visibility-public",className:"mt-1 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:r("visibilityPublicLabel")}),e.jsx("small",{id:"hint-visibility-public",className:"block mt-1",children:r(a?s.isPublic||s.hasNotifiedFollowers?"visibilityPublicHintPublished":"visibilityPublicHintPublishedNotYetNotified":"visibilityPublicHint")})]})]}),e.jsxs("label",{htmlFor:"input-visibility-private",className:"flex items-start gap-2 cursor-pointer",children:[e.jsx(z,{id:"input-visibility-private",type:"radio",name:"visibility",checked:!o,onChange:()=>m(!1),"aria-describedby":"hint-visibility-private",className:"mt-1 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:r("visibilityPrivateLabel")}),e.jsx("small",{id:"hint-visibility-private",className:"block mt-1",children:r(a?"visibilityPrivateHintPublished":"visibilityPrivateHint")})]})]})]})},be=250,ct=({existingObject:s,reload:r,onSaveSuccess:t})=>{var g;const{register:i,watch:a}=Y(),{t:o}=S("translation",{keyPrefix:"manageAlbum"}),m=ns(),{imageQueue:l}=Ue(),n=l.some(A=>A.resourceKey==="trackGroup-".concat(s.id)&&A.status!=="completed"&&A.status!=="failed"),p=a("urlSlug"),d=p==null?void 0:p.startsWith("mi-temp-slug"),b=!!a("releaseDate"),u=((g=a("coverImageAlt"))!=null?g:"").length,y=Se("(min-width: ".concat(se.large,"px)")),v=Se("(min-width: ".concat(se.small,"px)")),w=y?3:v?4:5;return e.jsxs(e.Fragment,{children:[e.jsx(Me,{existingObject:s,reload:r,onSaveSuccess:t,className:"sticky z-[1001] mb-4 border-b border-(--mi-tint-x-color) transition-[top] duration-300 ".concat(m==="down"?"top-0":"top-(--header-cover-sticky-height)")}),e.jsx(ot,{existingObject:s}),e.jsx(rt,{existingObject:s,reload:r,hasReleaseDate:b}),e.jsxs(q,{children:[e.jsx("h2",{children:o("keyDetails")}),e.jsxs("div",{className:"md:grid md:grid-cols-2 gap-4",children:[e.jsxs(B,{children:[e.jsx(G,{htmlFor:"input-title",field:"title",children:o("title")}),e.jsx(z,{id:"input-title",...i("title")}),d&&e.jsx("small",{children:o("urlSlugHint")})]}),!d&&e.jsxs(B,{children:[e.jsx(G,{htmlFor:"input-slug",field:"urlSlug",children:o("urlSlug")}),e.jsx(z,{id:"input-slug",...i("urlSlug")}),ae(s)&&e.jsxs("small",{children:[e.jsxs("span",{children:[o("fullUrlIs",{currentUrlSlug:"".concat(window.location.origin,"/").concat(s.artist.urlSlug,"/release/").concat(p)}),"."," "]}),e.jsx("span",{className:"bg-(--mi-background-color) text-(--mi-warning-color)",children:o("urlSlugWarning")})]})]})]}),e.jsxs("div",{className:P("@media screen and (min-width: ",se.medium,"px){display:flex;gap:1rem;>div{width:33%;}}",""),children:[e.jsxs(B,{children:[e.jsx(G,{htmlFor:"input-release-date",field:"releaseDate",children:o("releaseDate")}),e.jsx(z,{"aria-describedby":"hint-release-date",id:"input-release-date",type:"date",...i("releaseDate")}),e.jsx("small",{id:"hint-release-date",children:s.scheduleEndOnReleaseDate?e.jsx(ee,{i18nKey:"manageAlbum.releaseDateScheduledHint",components:{strong:e.jsx("strong",{})}}):o("releaseDateInfoText")})]}),e.jsx(Os,{tags:s.tags})]})]}),e.jsxs(q,{children:[e.jsx("h2",{children:o("artwork")}),e.jsxs(B,{style:{flexDirection:"column",marginRight:"1rem",display:"flex",alignItems:"flex-start"},children:[e.jsx(Zs,{imageTypeDescription:o("anAlbumCover"),existing:s,imageType:"cover",height:"400",width:"400",maxDimensions:"1500x1500",maxSize:"15mb",isLoading:n}),e.jsxs("div",{className:"flex flex-col gap-2 max-w-[72ch]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(G,{htmlFor:"input-cover-image-alt",field:"coverImageAlt",children:o("coverImageAlt")}),e.jsx("span",{id:"counter-cover-image-alt","aria-live":"polite",className:"text-sm tabular-nums",children:o("coverImageAltCharacterCount",{count:u,max:be})})]}),e.jsx(re,{id:"input-cover-image-alt",rows:w,maxLength:be,"aria-describedby":"hint-cover-image-alt counter-cover-image-alt",...i("coverImageAlt",{maxLength:be})}),e.jsx("small",{id:"hint-cover-image-alt",children:o("coverImageAltHint")})]}),e.jsxs("div",{className:"flex flex-col gap-2 max-w-[72ch] mt-4 w-full",children:[e.jsx(G,{htmlFor:"input-cover-credit",field:"coverCredit",children:o("coverCredit")}),e.jsx(z,{id:"input-cover-credit","aria-describedby":"hint-cover-credit",...i("coverCredit")}),e.jsx("small",{id:"hint-cover-credit",children:o("coverCreditHint")})]})]})]}),e.jsx(lt,{reload:r,existingObject:s}),e.jsxs(q,{children:[e.jsx("h2",{children:o("aboutTheAlbum")}),e.jsxs(B,{children:[e.jsx(G,{htmlFor:"input-about",field:"about",children:o("about")}),e.jsx(re,{id:"input-about",rows:5,...i("about")})]}),e.jsxs(B,{children:[e.jsx(G,{htmlFor:"input-credits",field:"credits",children:o("credits")}),e.jsx(re,{id:"input-credits",rows:5,...i("credits")})]}),e.jsx("div",{className:P("@media screen and (min-width: ",se.medium,"px){display:flex;gap:1rem;>div{width:33%;}}",""),children:e.jsxs(B,{children:[e.jsx(G,{htmlFor:"input-catalog-number",field:"catalogNumber",children:o("catalogNumber")}),e.jsx(z,{id:"input-catalog-number",...i("catalogNumber")})]})})]}),e.jsx(q,{children:e.jsx(it,{trackGroupId:s.id,fundraiser:s.fundraiser})}),e.jsx(Me,{existingObject:s,reload:r,onSaveSuccess:t,className:"mt-2 border-t border-(--mi-tint-x-color)"})]})},fe=s=>{var t,i,a,o,m,l,n,p,d,c,b,f,u,y,v;const r=(t=s==null?void 0:s.isGettable)!=null?t:!1;return{...s,releaseDate:(a=(i=s==null?void 0:s.releaseDate)==null?void 0:i.split("T")[0])!=null?a:"",catalogNumber:(o=s==null?void 0:s.catalogNumber)!=null?o:"",coverImageAlt:(m=s==null?void 0:s.coverImageAlt)!=null?m:"",coverCredit:(l=s==null?void 0:s.coverCredit)!=null?l:"",publishedAt:(n=s==null?void 0:s.publishedAt)==null?void 0:n.split("T")[0],platformPercent:"".concat((p=s==null?void 0:s.platformPercent)!=null?p:
17),isGettable:r,minPrice:"".concat((s==null?void 0:s.minPrice)!==void 0?s.minPrice/100:""),suggestedPrice:(s==null?void 0:s.suggestedPrice)!==void 0?"".concat(s.suggestedPrice/100):"",goalAmount:"".concat((d=s==null?void 0:s.fundraiser)!=null&&d.goalAmount?s.fundraiser.goalAmount/100:""),isAllOrNothing:(b=(c=s==null?void 0:s.fundraiser)==null?void 0:c.isAllOrNothing)!=null?b:!1,fundraiserName:(u=(f=s==null?void 0:s.fundraiser)==null?void 0:f.name)!=null?u:"",fundraiserDescription:(v=(y=s==null?void 0:s.fundraiser)==null?void 0:y.description)!=null?v:""}},dt=({trackGroup:s,reload:r})=>{const{t}=S("translation",{keyPrefix:"manageAlbum"}),i=Ne({defaultValues:fe(s)}),{reset:a}=i;x.useEffect(()=>{a(fe(s),{keepDirtyValues:!0,keepDirty:!0})},[s]);const o=s!=null&&s.id?"albumDraft-".concat(s.id):null,{hasRestoredDraft:m,restoredFields:l,clearDraft:n,discardDraft:p,dismissBanner:d}=$s(o,i),c=x.useMemo(()=>({title:t("title"),urlSlug:t("urlSlug"),releaseDate:t("releaseDate"),catalogNumber:t("catalogNumber"),coverImageAlt:t("coverImageAlt"),coverCredit:t("coverCredit"),about:t("about"),credits:t("credits"),minPrice:t("minimumPrice"),suggestedPrice:t("suggestedPrice")}),[t]),b=l.map(f=>c[f]).filter(Boolean);return e.jsx("div",{children:e.jsx(Pe,{...i,children:e.jsxs(Gs,{fields:l,children:[m&&e.jsx(Es,{onDiscard:()=>p(fe(s)),onKeep:d,fieldLabels:b}),e.jsx(ct,{existingObject:s,reload:r,onSaveSuccess:n})]})})})},mt=()=>{var p,d;const{trackGroupId:s}=te(),{data:r,refetch:t}=Z(ke(Number(s)||0)),{user:i}=ne(),{data:a}=We(),{t:o}=S("translation",{keyPrefix:"manageAlbum"}),m=x.useCallback(async c=>{var u;const b=c.trim().toLowerCase();return((u=a==null?void 0:a.artistLabels)!=null?u:[]).filter(y=>{var v,w,g,A,N,T;return y.isArtistApproved&&y.isLabelApproved&&(((w=(v=y.labelUser)==null?void 0:v.name)==null?void 0:w.toLowerCase().includes(b))||((A=(g=y.labelUser)==null?void 0:g.email)==null?void 0:A.toLowerCase().includes(b))||((T=(N=y.labelUser)==null?void 0:N.artists)==null?void 0:T.some(D=>D.name.toLowerCase().includes(b))))}).map(y=>({id:y.labelUserId,name:y.labelUser.name,isLabel:!0}))},[]),l=x.useCallback(async c=>{try{je(c)&&await U.put("manage/trackGroups/".concat(s),{paymentToUserId:c.id,artistId:a==null?void 0:a.id}),t()}catch(b){console.error("Error setting label for payment:",b)}},[]),n=i&&((p=a==null?void 0:a.artistLabels)==null?void 0:p.some(c=>c.labelUserId===i.id));return!a||((d=a.artistLabels)!=null?d:[]).length===0?null:e.jsx("div",{children:e.jsxs(B,{children:[e.jsx("label",{children:o("nameOfAccountToReceivePayment")}),e.jsx("small",{className:P({name:"16nhzd2",styles:"display:block;margin-bottom:0.5rem"}),children:e.jsx(ee,{t:o,i18nKey:n?"labelReceivePaymentDescription":"receivePaymentDescription",components:{artistPage:e.jsx(le,{variant:"link",to:ce(a.id)}),labelPage:e.jsx(le,{variant:"link",to:"/account/label"})}})}),(r==null?void 0:r.paymentToUser)&&e.jsxs(ze,{variant:"tint",children:[r.paymentToUser.name," ",e.jsx(F,{variant:"dashed",startIcon:e.jsx(de,{}),onClick:()=>{l({id:null,name:""})}})]}
1),!(r!=null&&r.paymentToUser)&&e.jsx(He,{getOptions:m,id:"input-payment-receiver",onSelect:l})]})})},ut=({queryKey:[s,{}],signal:r})=>{const t=new URLSearchParams;return os("v1/licenses?".concat(t),{signal:r})};function Qe(){return Je({queryKey:["fetchLicenses",{},ls],queryFn:ut})}const ht=({tracks:s,reload:r})=>{const{t}=S("translation",{keyPrefix:"manageAlbum"}),i=Q(),[a,o]=H.useState(""),[m,l]=H.useState(!1),{data:n}=Z(Qe()),p=async()=>{if(a){l(!0);try{await Promise.all(s.map(d=>U.put("manage/tracks/".concat(d.id),{licenseId:Number(a)}))),i(t("updatedAllTracks"),{type:"success"}),r()}catch(d){console.error("Error updating tracks:",d),i(t("errorUpdatingTracks"),{type:"warning"})}finally{l(!1)}}};return e.jsxs("div",{className:"flex flex-wrap gap-4 items-end py-2 [&>div]:mb-0!",children:[e.jsxs(B,{children:[e.jsx("label",{htmlFor:"licenseOnAllTracks",children:t("licenseOnAllTracks")}),e.jsxs(xe,{id:"licenseOnAllTracks",value:a,onChange:d=>o(d.target.value),children:[e.jsx("option",{value:"",children:t("selectALicense")}),n==null?void 0:n.results.map(d=>e.jsx("option",{value:d.id,children:d.short},d.id))]})]}),e.jsx(F,{wrap:!0,type:"button",disabled:!a||m,isLoading:m,onClick:p,children:t("setLicenseOfAllTracks")})]})},xt=K("div",{target:"e16orvr50"})({name:"1drok7z",styles:"display:flex;gap:1rem;align-items:center;padding:1rem 0;flex-direction:row"}),pt=({trackGroup:s,reload:r})=>{var l,n;const{t}=S("translation",{keyPrefix:"manageAlbum"}),i=Ne({defaultValues:s}),a=Q(),{mutate:o}=Ee(),m=p=>{o({trackGroupId:s.id,isPreview:p},{onSuccess:()=>{a(t("updatedAllTracks"),{type:"success"}),r()},onError:d=>{console.error("Error updating tracks:",d)}})};return e.jsxs("div",{children:[e.jsx(Pe,{...i,children:e.jsxs(xt,{children:[e.jsx(Bs,{id:"input-allow-mirlo-promo",type:"checkbox",formKey:"defaultAllowMirloPromo",url:"manage/trackGroups/".concat(s.id),timer:0,width:"auto"}),e.jsx("label",{htmlFor:"input-allow-mirlo-promo",children:e.jsx(ee,{t,i18nKey:"allowMirloPromo",components:{hype:e.jsx(Re,{className:qe,to:"/team/posts/236/",target:"_blank"})}})})]})}),((l=s.tracks)!=null?l:[]).length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-4 py-2",children:[e.jsx(F,{wrap:!0,onClick:()=>m(!0),children:t("setAllTracksAsPreview")}),e.jsx(F,{wrap:!0,variant:"dashed",onClick:()=>m(!1),children:t("setAllTracksAsMustOwn")})]}),e.jsx(ht,{tracks:(n=s.tracks)!=null?n:[],reload:r})]})]})},gt=({trackGroup:s,artist:r})=>{var b;const{t}=S("translation",{keyPrefix:"manageAlbum"}),i=Q(),a=$e(),[o,m]=x.useState(!1),[l,n]=x.useState(""),{data:p}=Z(cs()),d=((b=p==null?void 0:p.results)!=null?b:[]).filter(f=>f.id!==r.id),c=x.useCallback(async()=>{var v,w;const f=Number(l);if(!f)return;const u=d.find(g=>g.id===f);if(window.confirm((w=t("confirmMoveRelease",{artistName:(v=u==null?void 0:u.name)!=null?v:""}))!=null?w:""))try{m(!0),await U.put("manage/trackGroups/".concat(s.id),{moveToArtistId:f}),i(t("releaseMoved"),{type:"success"}),a("".concat(ce(f),"/releases"))}catch(g){console.error(g),i(t("releaseMoveFailed"),{type:"warning"})}finally{m(!1)}},[l,d,s.id,a,i,t]);return d.length===0?null:e.jsxs(B,{children:[e.jsx("label",{htmlFor:"select-move-release",children:t("moveReleaseToArtist")}),e.jsx("small",{className:"block mb-2",children:t("moveReleaseToArtistHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsxs(xe,{id:"select-move-release",className:"w-auto!",value:l,onChange:f=>n(f.target.value),children:[e.jsx("option",{value:"",children:t("chooseAnArtist")}),d.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]}),e.jsx(F,{type:"button",variant:"outlined",disabled:!l,isLoading:o,onClick:c,children:t("moveRelease")})]})]})},bt=({trackGroupId:s})=>{var A;const{t:r}=S("translation",{keyPrefix:"manageAlbum"}),{t}=S("translation",{keyPrefix:"commandSearch"}),i=Q(),[a,o]=x.useState(!1),[m,l]=x.useState(""),{data:{results:n}={},refetch:p}=Z(ds(s)),d=ms(),c=us(),[b]=hs(m,300),f=b.trim(),u=a&&f.length>=2,y=Z({...xs({q:f,take:10}),enabled:u});x.useEffect(()=>{a||l("")},[a]);const v=x.useCallback(N=>{d.mutate({trackGroupId:s,recommendedTrackGroupId:N},{onSuccess:()=>{p(),i(r("recommendationAdded"),{type:"success"})},onError:()=>{i(r("recommendationError"),{type:"warning"})}})},[d,s,p,i,r]),w=N=>{c.mutate({trackGroupId:s,recommendedTrackGroupId:N},{onSuccess:()=>{p(),i(r("recommendationRemoved"),{type:"success"})},onError:()=>{i(r("recommendationError"),{type:"warning"})}})},g=x.useMemo(()=>{var T,D;if(!u)return[];const N=((D=(T=y.data)==null?void 0:T.results)!=null?D:[]).filter(C=>C.id!==s&&!(n!=null&&n.some(L=>L.id===C.id))).map(C=>
1{var L,k;return{key:"trackGroup-".concat(C.id),node:"".concat((k=(L=C.artist)==null?void 0:L.name)!=null?k:""," · ").concat(C.title),onSelect:()=>v(C.id)}});return N.length>0?[{category:t("categoryReleases"),items:N}]:[]},[u,y.data,n,s,v,t]);return e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:r("recommendedAlbums")}),((A=n==null?void 0:n.length)!=null?A:0)>0&&e.jsx("div",{className:"mb-8",children:e.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-4 mt-4",children:n==null?void 0:n.map(N=>{var T,D;return e.jsxs("li",{className:"relative border border-gray-300 rounded p-2 flex flex-col gap-2",children:[((D=(T=N.cover)==null?void 0:T.sizes)==null?void 0:D[300])&&e.jsx("img",{src:N.cover.sizes[300],alt:N.coverImageAlt,className:"w-full h-auto rounded"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold m-0",children:N.title}),e.jsx("p",{className:"text-xs text-gray-600 m-0",children:N.artist.name})]}),e.jsx(F,{type:"button",onClick:()=>w(N.id),isLoading:c.isPending,startIcon:e.jsx(he,{}),className:"mt-auto",children:r("remove")})]},N.id)})})}),e.jsx("div",{children:e.jsx(F,{wrap:!0,type:"button",onClick:()=>o(!0),isLoading:d.isPending,children:r("addRecommendedAlbum")})}),e.jsx(ps,{open:a,onClose:()=>o(!1),title:r("addRecommendedAlbum"),placeholder:r("searchPlaceholder"),query:m,onQueryChange:l,sections:g,isLoading:y.isFetching})]})},ft=()=>{const{dispatch:s}=Oe(),r=x.useCallback(i=>{s({type:"setDraggingTrackId",draggingTrackId:+i.currentTarget.id})},[s]),t=x.useCallback(()=>{s({type:"setDraggingTrackId",draggingTrackId:void 0})},[s]);return{onDragStart:r,onDragEnd:t}},jt=({statusKey:s,disabled:r})=>{const{register:t}=Y(),{t:i}=S("translation",{keyPrefix:"manageAlbum"});return e.jsxs(xe,{defaultValue:"paid",...t(s),disabled:r,children:[e.jsx("option",{value:"preview",children:i("preview")}),e.jsx("option",{value:"must-own",children:i("mustOwn")})]})},yt=({uploadingState:s})=>e.jsxs(e.Fragment,{children:[s==="completed"&&e.jsx("div",{className:P({name:"v98kxt",styles:"color:green"}),children:e.jsx(gs,{})}),(s==="waiting"||s==="active")&&e.jsx(Ae,{})]}),vt=()=>{const[s,r]=x.useState(!1),{t}=S("translation",{keyPrefix:"manageAlbum"}),i=Y(),{data:a,refetch:o}=Z(Qe()),m=x.useCallback(()=>{o(),r(!1)},[o]);return e.jsxs(e.Fragment,{children:[e.jsx(X,{open:s,onClose:()=>r(!1),title:t("addALicense"),children:e.jsx(_s,{callback:m})}),e.jsxs(B,{children:[e.jsxs(xe,{...i.register("licenseId"),children:[e.jsx("option",{value:"",children:t("selectALicense")}),a==null?void 0:a.results.map(l=>e.jsx("option",{value:l.id,children:l.short}))]}),e.jsx("div",{className:P({name:"zjik7",styles:"display:flex"}),children:e.jsxs("small",{className:P({name:"ye2gio",styles:"display:flex;align-items:center;flex-direction:row"}),children:[t("dontSeeTheLicenseYouWant"),e.jsx(F,{variant:"dashed",onClick:()=>r(!0),type:"button",size:"compact",className:P({name:"1y2mh23",styles:"margin-left:0.25rem"}),children:t("addIt")})]})})]})]})},wt=({artistIndex:s,disabled:r,onRemove:t})=>{var f;const{t:i}=S("translation",{keyPrefix:"manageAlbum"}),{register:a,control:o,setValue:m,watch:l}=Y(),n=x.useCallback(async u=>(await U.getMany("artists",{name:u})).results.map(v=>({id:v.id,name:v.name})),[]),p=x.useCallback(async u=>{if(je(u)&&typeof u.id=="number"){const y=await U.get("artists/".concat(u.id));m("trackArtists.".concat(s,".artistName"),y.result.name,{shouldDirty:!0}),m("trackArtists.".concat(s,".artistId"),u.id,{shouldDirty:!0})}else je(u)&&typeof u.id=="string"&&m("trackArtists.".concat(s,".artistName"),u.id,{shouldDirty:!0})},[s,m]),d=x.useCallback(()=>{m("trackArtists.".concat(s,".artistId"),void 0),m("trackArtists.".concat(s,".artistName"),void 0)},[s,m]),c=l("trackArtists.".concat(s,".artistId")),b=l("trackArtists.".concat(s,".artistName"));return e.jsxs("div",{className:P({name:"5cvntg",styles:"display:flex;align-items:center;border:1px solid var(--mi-tint-x-color);padding:1rem;justify-content:space-between;div{margin-right:1rem;}:not(:first-of-type){margin-top:1rem;}"}),children:[e.jsxs("div",{children:[!c&&!b&&e.jsx(He,{getOptions:n,id:"input-track-artist",showBackgroun
1d:!0,allowNew:!0,placeholder:i("searchArtists"),onSelect:p}),(c||b)&&e.jsxs("div",{className:P({name:"oluxa2",styles:"margin:0.25rem 0 0.5rem"}),children:[i(c?"artistOnMirlo":"artist"),":"," ",e.jsxs(ze,{variant:"tint",children:[b," ",e.jsx(F,{size:"compact",startIcon:e.jsx(de,{}),variant:"dashed",title:"Clear",onClick:d})]})]}),e.jsx(z,{...a("trackArtists.".concat(s,".role")),placeholder:(f=i("role"))!=null?f:"",disabled:r}),e.jsx(ye,{keyName:"trackArtists.".concat(s,".isCoAuthor"),description:i("coAuthorCheck"),disabled:r})]}),e.jsx(F,{onClick:()=>{t(s)},type:"button",variant:"dashed",size:"compact",disabled:r,className:"shrink-0",children:i("removeArtist")})]})},kt=({track:s})=>{const{t:r}=S("translation",{keyPrefix:"manageAlbum"}),[t,i]=H.useState(!1),a=()=>{i(!t)};return e.jsxs("div",{children:[e.jsx(F,{onClick:a,variant:"outlined",size:"compact",children:r(t?"hideRawId3Data":"showRawId3Data")}),t&&e.jsx("div",{children:e.jsx("code",{children:JSON.stringify(s.metadata,null,2)})})]})},_=K("tr",{target:"e1ipqhfo0"})({name:"1ojc6wg",styles:"border-left:1rem solid var(--mi-text-color);border-bottom:1px solid var(--mi-text-color);td{padding:1rem 0;}td:first-child{padding-left:3rem;}"}),Nt=({track:s,onCancelEditing:r,reload:t})=>{var I,E,O;const[i,a]=x.useState(!1),[o,m]=x.useState(!1),{t:l}=S("translation",{keyPrefix:"manageAlbum"}),{uploadJobs:n,setUploadJobs:p}=bs({reload:r}),d=Ne({defaultValues:{...s,status:s.isPreview?"preview":"must-own",minPrice:"".concat((s==null?void 0:s.minPrice)!==void 0?s.minPrice/100:"0")}}),{user:c}=ne(),b=c==null?void 0:c.id,f=Q(),u=s.id,{control:y,register:v,reset:w,watch:g}=d,A=g("allowIndividualSale"),N=g("isrc"),T=!!N&&!/^[A-Z]{2}[A-Z0-9]{3}[0-9]{7}$/.test(N.replace(/-/g,"")),{fields:D,append:C,remove:L}=fs({control:y,name:"trackArtists"}),k=x.useCallback(()=>{w({title:s.title,trackArtists:s.trackArtists,status:s.isPreview?"preview":"must-own",licenseId:s.licenseId,isrc:s.isrc,allowMirloPromo:s.allowMirloPromo,lyrics:s.lyrics,description:s.description,minPrice:"".concat((s==null?void 0:s.minPrice)!==void 0?s.minPrice/100:"0"),allowIndividualSale:s.allowIndividualSale}),r()},[w,s,r]),R=x.useCallback(async $=>{try{a(!0);const V={title:$.title,trackArtists:$.trackArtists,isrc:$.isrc,lyrics:$.lyrics,description:$.description,allowMirloPromo:$.allowMirloPromo,isPreview:$.status==="preview",allowIndividualSale:$.allowIndividualSale,minPrice:$.minPrice?Number($.minPrice)*100:void 0,licenseId:$.licenseId?Number($.licenseId):null};if(await U.put("manage/tracks/".concat(u),V),$.trackFile&&$.trackFile.length>0){const J=(await U.uploadFile("manage/tracks/".concat(u,"/audio"),[$.trackFile[0]])).result.jobId;p([{jobId:J,jobStatus:"waiting"}])}else k();f(l("updatedTrack"),{type:"success"})}catch(V){console.error(V)}finally{a(!1),t()}},[k,t,p,f,l,u,b]),h=(I=n==null?void 0:n[0])==null?void 0:I.jobStatus;let j=!!(h||n.length>0);return e.jsxs(Pe,{...d,children:[e.jsxs("tr",{className:P("td{padding-bottom:1.5rem!important;}",j||i?"\n            opacity: .4;\n            pointer-events: none;\n            ":"",";",""),children:[e.jsxs("td",{children:[i&&e.jsx(Ae,{}),!h&&!i&&e.jsx(Be,{trackId:u,isDisabled:j,reload:t}),!i&&e.jsx(yt,{uploadingState:h})]}),e.jsxs("td",{className:P({name:"121z217",styles:"width:40%"}),children:[e.jsx(z,{...v("title"),id:"".concat(s.id,"-title"),disabled:i||j,"aria-describedby":"".concat(s.id,"-title-info")}),e.jsx("p",{id:"".concat(s.id,"-title-info"),children:l("originalFilename",{keyPrefix:"manageTrackTable",filename:(E=s.audio)==null?void 0:E.originalFilename})})]}),e.jsx("td",{children:e.jsx(jt,{statusKey:"status"})}),e.jsx("td",{align:"right",children:((O=s.audio)==null?void 0:O.duration)&&Ve(+s.audio.duration)}),e.jsxs("td",{align:"right",className:P({name:"jjhl8v",styles:"button{display:inline-block;margin-left:0.25rem;}"}),children:[e.jsx(F,{size:"compact",onClick:k,type:"button",title:"Close",variant:"dashed",startIcon:e.jsx(de,{}),disabled:i||j}),e.jsx(F,{size:"compact",variant:"dashed",startIcon:e.jsx(De,{}),disabled:i||j,onClick:d.handleSubmit(R),type:"button",className:P(d.formState.isDirty?"background-color: var(--mi-button-color) !important;\n                   color: var(--mi-button-text-color) !important;\n                   border-color: var(--mi-button-color) !important;\n\n                   animation: shake 0.5s;\n\n                   svg {\n                     fill: var(--mi-button-text-color) !important;\n                   }":"",";","")})]})]}),e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:e.jsx("label",{htmlFor:"listedArtists",children:l("listedArtists",{keyPrefix:"manageTrackTable"})})}),e.jsx("td",{colSpan:99,children:e.jsxs("div",{className:P({name:"1fttcpj",styles:"display:flex;flex-direction:column"}),children:[e.jsx("div",{children:D.map(($,V)=>e.jsx(wt,{artistIndex:V,disabled:j,onRemove:L},$.id))}),e.jsx("div",{className:P({name:"5ae91h",styles:"margin-top:1rem;display:flex;justify-content:space-between;width:100%;align-items:center"}),children:e.jsx(F,{onClick:()=>{C({artistName:"",order:D.length})},type:"button",size:"compact",disabled:j,startIcon:e.jsx(js,{}),variant:"dashed",children:l("addNewArtist")})})]})})]}),e.jsx(_,{children:e.jsx("td",{colSpan:101,children:e.jsx(ye,{keyName:"allowIndividualSale",description:l("allowSaleDescription")})})}),A&&e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:e.jsx("label",{htmlFor:"minPrice",children:l("minPrice")})}),e.jsx("td",{colSpan:99,children:e.jsx(z,{id:"minPrice",type:"number",min:0,step:"0.01",...v("minPrice",{min:0})})})]}),e.jsx(_,{children:e.jsx("td",{colSpan:101,children:e.jsx(ye,{idPrefix:"".concat(s.id,"-"),keyName:"allowMirloPromo",description:e.jsx("p",{children:e.jsx(ee,{t:l,i18nKey:"allowMirloPromo",components:{hype:e.jsx(Re,{className:qe,to:"/team/posts/236/",target:"_blank"})}})})})})}),e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:e.jsx("label",{htmlFor:"isrc",children:l("isrcCode")})}),e.jsxs("td",{colSpan:99,children:[e.jsx(z,{id:"isrc",...v("isrc"),disabled:i||j}),T&&e.jsx(ve,{children:l("isrcInvalid")})]})]}),e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:e.jsx("label",{htmlFor:"lyrics",children:l("lyrics")})}),e.jsx("td",{colSpan:99,children:e.jsx(re,{id:"lyrics",...v("lyrics"),className:P({name:"1d3w5wq",styles:"width:100%"}),rows:8})})]}),e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:e.jsx("label",{htmlFor:"description",children:l("description")})}),e.jsx("td",{colSpan:99,children:e.jsx(re,{id:"description",...v("description"),className:P({name:"1d3w5wq",styles:"width:100%"}),rows:8})})]}),e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:e.jsxs("div",{className:P({name:"s5xdrg",styles:"display:flex;align-items:center"}),children:[l("license"),e.jsx(W,{onClick:()=>m(!0),startIcon:e.jsx(ys,{})}),e.jsx(X,{onClose:()=>m(!1),open:o,children:e.jsx(ee,{t:l,i18nKey:"whatMeanLicense",components:{a:e.jsx("a",{})}})})]})}),e.jsx("td",{colSpan:99,children:e.jsx(vt,{})})]}),e.jsxs(_,{children:[e.jsx("td",{colSpan:2,children:l("id3Data")}),e.jsx("td",{colSpan:99,children:e.jsx(kt,{track:s})})]}),e.jsx(_,{children:e.jsxs("td",{colSpan:99,className:P({name:"1wj15vq",styles:"padding-bottom:2rem!important;white-space:nowrap;button{margin-right:0.5rem;float:right;}"}),children:[e.jsx(F,{size:"compact",startIcon:e.jsx(De,{}),disabled:i||j,onClick:d.handleSubmit(R),type:"button",className:P(d.formState.isDirty?"background-color: var(--mi-button-color) !important;\n                   color: var(--mi-button-text-color) !important;\n                   border-color: var(--mi-button-color) !important;":"",";",""),children:l("saveTrack")}),e.jsx(F,{size:"compact",onClick:k,type:"button",title:"Close",variant:"dashed",startIcon:e.jsx(de,{}),disabled:i||j,children:l("cancelChanges")}
1)]})})]})},Pt=K("tr",{target:"e1izbnj80"})({name:"kgwz3p",styles:"&:hover{background-color:var(--mi-tint-color);@media (prefers-color-scheme: dark){background-color:var(--mi-tint-color);}}"}),At=({track:s,addTracksToQueue:r,reload:t,handleDrop:i})=>{var D,C,L,k,R,h;const{t:a}=S("translation",{keyPrefix:"manageTrackTable"}),[o,m]=x.useState((D=s.audio)==null?void 0:D.uploadState),l=Q(),[n,p]=x.useState(!1),{user:d}=ne(),{onDragStart:c,onDragEnd:b}=ft(),f=d==null?void 0:d.id;x.useEffect(()=>{let j=null;return o==="STARTED"&&(j=setInterval(async()=>{var O;const E=(O=(await U.get("manage/tracks/".concat(s.id))).result.audio)==null?void 0:O.uploadState;m(E),E==="SUCCESS"&&j&&clearInterval(j)},4e3)),()=>j?clearInterval(j):void 0},[s.id,o,f]);const u=x.useCallback(async()=>{var j;try{window.confirm((j=a("areYouSureDelete"))!=null?j:"")&&(await U.delete("manage/tracks/".concat(s.id)),await(t==null?void 0:t()),l(a("deleteTrackSuccess"),{type:"success"}))}catch(I){console.error(I)}},[s.id,f,t,l]),y=x.useCallback(()=>{try{return U.getFileDownloadUrl("manage/tracks/".concat(s.id,"/downloadOriginal"))}catch(j){console.error(j)}},[s.id,f,t,l]),v=s.audio?new Date(s.audio.createdAt).getTime():0,w=new Date().getTime()-72e5,g=v<w,A=s.audio&&o==="STARTED"&&!g,N=o==="ERROR",T=x.useCallback(()=>{p(!1),t()},[t]);return n?e.jsx(Nt,{track:s,onCancelEditing:T,reload:t}):e.jsxs(Pt,{id:"".concat(s.id),onDragOver:j=>j.preventDefault(),draggable:!0,onDragStart:c,onDrop:i,onDragEnd:b,className:"group ".concat(P(N?"background-color: red;":""," &:hover{cursor:grab;}",s.audio?"":"background-color: red;",";","")),children:[e.jsxs("td",{className:P({name:"3xe8e8",styles:"width:50px;text-align:center"}),children:[s.audio&&e.jsx(Ks,{trackId:s.id,canPlayTrack:!0,trackNumber:s.order,onTrackPlayCallback:r,isDisabled:A}),!s.audio&&e.jsxs(vs,{hoverText:"Track audio is missing",children:[e.jsx(me,{}),e.jsx(Be,{trackId:s.id,reload:t})]})]}),e.jsx("td",{className:P('width:40%;overflow:hidden;whitespace:nowrap;text-overflow:ellipsis;&:before{content:"',a("titleColumn"),': ";}',""),children:e.jsx("div",{className:P({name:"s5xdrg",styles:"display:flex;align-items:center"}),children:e.jsxs("div",{children:[s.title||e.jsxs("div",{className:P({name:"1gcbvj2",styles:"filter:hue-rotate(90deg)"}),children:[e.jsx(me,{})," ",a("missingTitle")]}),e.jsx(qs,{track:s}),e.jsx("p",{children:e.jsxs("small",{className:P({name:"1espw9v",styles:"gap:0.4rem;display:flex"}),children:[o==="SUCCESS"&&a("doneUploadingTrack"),o==="STARTED"&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{size:"small"}),a("stillProcessing")]}),o==="ERROR"&&a("thereWasAnError")]})})]})})}),e.jsx("td",{className:P('&:before{content:"',a("status"),': ";}',""),children:a(s.isPreview?"statusPreview":"statusMustOwn")}),e.jsx("td",{className:"alignRight "+P('&:before{content:"',a("durationColumn"),': ";}',""),children:((C=s.audio)==null?void 0:C.duration)&&Ve((L=s.audio)==null?void 0:L.duration)}),e.jsxs("td",{align:"right",className:P({name:"1xdoy1c",styles:"width:150px;display:flex;flex-direction:row;justify-content:flex-end;button,a{}"}),children:[e.jsx(ws,{size:"compact",startIcon:e.jsx(ks,{}),variant:"dashed",href:y(),title:(k=a("downloadOriginal"))!=null?k:"",style:{marginRight:".25rem"}}),e.jsx(F,{size:"compact",startIcon:e.jsx(Ns,{}),variant:"dashed",onClick:()=>p(!0),title:(R=a("edit"))!=null?R:"",style:{marginRight:".25rem"}}),e.jsx(F,{variant:"dashed",startIcon:e.jsx(he,{}),size:"compact",onClick:u,title:(h=a("delete"))!=null?h:""})]})]},s.id)},Ct=K(Ws,{target:"e174emfx0"})("margin-bottom:1.5rem;margin-top:1rem;&.mi-table tbody tr:nth-child(odd){background-color:transparent;}&.mi-table tbody tr:not(:last-child){border-bottom:1px solid var(--mi-tint-color);}&.mi-table th:not(:last-child),&.mi-table td:not(:last-child){border-right:none;}&.mi-table th:nth-child(4),&.mi-table td:nth-child(4),&.mi-table th:nth-child(5){text-align:center;}@media screen and (max-width: ",se.medium,"px){display:block;& thead,tbody,td,tr,th{display:block;}thead{position:absolute;top:-9999px;left:-9999px;}tr{margin-bottom:1rem;border:1px solid #ccc;}td{border:none;border-bottom:1px solid #eee;position:relative;width:100%;display:flex;align-items:center;}td:before{display:inline-block;color:grey;padding-right:10px;}td.alignRight{text-align:left!important;}}@media screen and (min-width: ",se.medium,"px){td{padding:0.5rem 0.5rem;}td:before{display:none;}}"),Tt=({tracks:s,trackGroupId:r,editable:t,reload:i})=>{const[a,o]=x.useState(!1),{state:{draggingTrackId:m},dispatch:l}=Oe(),{user:n}=ne(),p=n==null?void 0:n.id,[d,c]=x.useState([]),{t:b}=S("translation",{keyPrefix:"manageTrackTable"}),f=x.useCallback(async w=>{if(w.preventDefault(),t&&m){const g=+w.currentTarget.id,A=Ps(d,g,m);r&&(c(A),await U.put("manage/trackGroups/".concat(r,"/trackOrder"),{trackIds:A.map(N=>N.id)}),i==null||i())}},[t,m,d,r,i,p]),u=x.useCallback(async w=>{const g=Hs(w);c(g),o(!1)},[p]);x.useEffect(()=>{o(!0),u(s)},[s,u]);const y=x.useCallback(w=>{const g=s.map(N=>N.id),A=g.indexOf(w);l({type:"startPlayingIds",playerQueueIds:g,startingIndex:A>=0?A:0})},[l,s]),v=x.useCallback(async()=>{r&&i&&await i()},[i,r]);return a?e.jsx(As,{}):e.jsxs(Ct,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:b("titleColumn")}),e.jsx("th",{children:b("status")}),e.jsx("th",{children:b("durationColumn")}),e.jsx("th",{className:"alignRight",style:{minWidth:"8rem"},children:b("manageColumn")})]})}),e.jsxs("tbody",{children:[d==null?void 0:d.map(w=>e.jsx(At,{track:w,addTracksToQueue:y,reload:v,handleDrop:f},w.id)),d.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:999,style:{textAlign:"center"},children:b("emptyTracklist")})})]})]})},Dt=({trackGroupId:s,artistId:r,reload:t,isOpen:i,preScanResult:a,existingTracksCount:o,selectedCoverIndex:m,onSelectedCoverChange:l,invalidFilesAction:n,onInvalidFilesActionChange:p,onClose:d})=>{var T,D,C,L,k,R;const{t:c}=S("translation",{keyPrefix:"zipImport"}),{enqueue:b,enqueueImage:f}=Ue(),u=we(),y=((T=a==null?void 0:a.invalidFiles.length)!=null?T:0)>0,v=((D=a==null?void 0:a.audioFiles.length)!=null?D:0)>0&&(!y||n==="skip"),w=H.useMemo(()=>{var h;return[...(h=a==null?void 0:a.audioFiles)!=null?h:[]].sort((j,I)=>{var $,V;const E=($=j.trackNumber)!=null?$:1/0,O=(V=I.trackNumber)!=null?V:1/0;return E-O})},[a==null?void 0:a.audioFiles]),g=(C=a==null?void 0:a.albumMeta)!=null?C:{},A=g.title||g.albumArtist||g.year||g.date||g.label||g.releaseDate||g.description||((k=(L=g.genres)==null?void 0:L.length)!=null?k:0)>0,N=x.useCallback(async(h,j)=>{var O,$,V,ie;if(!h)return;const I=h.albumMeta;try{await u.mutateAsync({trackGroupId:s,formData:{title:(O=I.title)!=null?O:"",releaseDate:($=I.releaseDate)!=null?$:void 0,about:(V=I.description)!=null?V:void 0},artistId:r})}catch(J){console.error("Error saving album metadata",J)}const E=(ie=h.imageFiles[j])==null?void 0:ie.file;E&&f({name:c("albumCover"),endpoint:"manage/trackGroups/".concat(s,"/cover"),file:E,thumbnail:URL.createObjectURL(E),resourceKey:"trackGroup-".concat(s),onComplete:t}),h.audioFiles.length>0&&b({trackgroup:{id:s,artistId:r,tracks:[]},files:h.audioFiles.map(J=>J.file),reload:t});for(const J of h.downloadableContentFiles)try{await Cs(J.file,{trackGroupId:s})}catch(pe){console.error("Error uploading downloadable content",pe)}d(),t()},[s,r,b,f,t,d]);return e.jsxs(X,{open:i&&a!==null,onClose:d,title:c("previewTitle"),size:"small",focusTrapOptions:{delayInitialFocus:!0},children:[o>0&&e.jsxs("div",{className:"p-4 rounded-[var(--mi-border-radius)] mb-4 flex gap-3 bg-[rgba(255,193,7,0.1)] border-l-4 border-[#FFC107]",children:[e.jsx("div",{className:"text-xl flex-shrink-0 mt-1",children:"⚠️"}),e.jsx("div",{className:"text-sm leading-snug",children:c("existingTracksWarning",{count:o})})]}),a&&y&&e.jsxs("div",{className:"p-4 rounded-[var(--mi-border-radius)] mb-4 flex gap-3 bg-[rgba(244,67,54,0.1)] border-l-4 border-[#F44336]",children:[e.jsx("div",{className:"text-xl flex-shrink-0 mt-1",children:e.jsx(me,{})}),e.jsxs("div",{className:"text-sm leading-snug",children:[c("invalidFilesFound",{count:a.invalidFiles.length}),e.jsx("ul",{className:"mt-2 ml-6 p-0 text-xs",children:a.invalidFiles.map(h=>e.jsxs("li",{className:"text-[var(--mi-lighter-foreground-color)] mb-1",children:[h.name," — ",h.reason]},h.name))}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"invalidAction",value:"skip",checked:n==="skip",onChange:()=>p("skip")}),c("skipInvalidFiles")]}),e.jsxs("label",{className:"flex items-center gap-2 mt-2",children:[e.jsx("input",{type:"radio",name:"invalidAction",value:"cancel",checked:n==="cancel",onChange:()=>p("cancel")}),c("cancelImport")]})]})]})]}),A&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-base font-semibold mb-3 text-[var(--mi-text-color)] flex items-center gap-2",children:c("albumDetails")}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-y-1 gap-x-3 m-0 text-sm",children:[g.title&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-[var(--mi-lighter-foreground-color)] font-semibold whitespace-nowrap",children:c("albumTitle")}),e.jsx("dd",{className:"m-0 text-[var(--mi-text-color)]",children:g.title})]}),g.albumArtist&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-[var(--mi-lighter-foreground-color)] font-semibold whitespace-nowrap",children:c("albumArtist")}),e.jsx("dd",{className:"m-0 text-[var(--mi-text-color)]",children:g.albumArtist})]}),(g.date||g.year)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-[var(--mi-lighter-foreground-color)] font-semibold whitespace-nowrap",children:c("releaseDate")}),e.jsx("dd",{className:"m-0 text-[var(--mi-text-color)]",children:(R=g.releaseDate)!=null?R:String(g.releaseDate)})]}),g.description&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-[var(--mi-lighter-foreground-color)] font-semibold whitespace-nowrap",children:c("albumDescription")}),e.jsx("dd",{className:"m-0 text-[var(--mi-text-color)] whitespace-pre-wrap line-clamp-4",children:g.description})]})]})]}),a&&a.audioFiles.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-base font-semibold mb-3 text-[var(--mi-text-color)] flex items-center gap-2",children:[e.jsxs("span",{className:"text-[var(--mi-success-background-color)] flex items-center gap-1",children:[e.jsx(Fe,{})," ",a.audioFiles.length]}),c("tracksFound")]}),e.jsx("div",{className:"flex flex-col gap-2",children:w.map((h,j)=>e.jsxs("div",{className:"p-3 bg-[var(--mi-tint-color)] rounded-[var(--mi-border-radius)] text-sm",children:[e.jsxs("div",{children:[h.trackNumber&&e.jsxs("span",{className:"font-semibold text-[var(--mi-button-color)] mr-2",children:[h.trackNumber,"."]}),e.jsx("span",{className:"text-[var(--mi-text-color)]",children:h.title})]}),h.artists.length>0&&e.jsxs("span",{className:"text-xs text-[var(--mi-lighter-foreground-color)] block mt-1",children:[c("artists"),": ",h.artists.join(", ")
1]})]},"".concat(h.file.name,"-").concat(j)))})]}),a&&a.imageFiles.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-base font-semibold mb-3 text-[var(--mi-text-color)] flex items-center gap-2",children:c("selectCoverImage")}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-4 mb-4",children:a.imageFiles.map((h,j)=>e.jsxs("label",{className:"relative cursor-pointer rounded-[var(--mi-border-radius)] overflow-hidden border-[3px] transition-all duration-200 hover:border-[var(--mi-button-color)] ".concat(j===m?"border-[var(--mi-button-color)]":"border-transparent"),children:[e.jsx("input",{type:"radio",name:"coverImage",value:j,checked:j===m,onChange:()=>l(j),className:"absolute top-2 right-2 z-[2]"}),h.dataUrl&&e.jsx("img",{src:h.dataUrl,alt:h.name,className:"w-full h-[100px] object-cover block"})]},"".concat(h.name,"-").concat(j)))})]}),a&&a.downloadableContentFiles.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-base font-semibold mb-3 text-[var(--mi-text-color)] flex items-center gap-2",children:[e.jsxs("span",{className:"text-[var(--mi-success-background-color)] flex items-center gap-1",children:[e.jsx(Fe,{})," ",a.downloadableContentFiles.length]}),c("downloadableContentFound")]}),e.jsx("div",{className:"flex flex-col gap-2",children:a.downloadableContentFiles.map((h,j)=>e.jsx("div",{className:"p-3 bg-[var(--mi-tint-color)] rounded-[var(--mi-border-radius)] text-sm",children:e.jsx("span",{className:"text-[var(--mi-text-color)]",children:h.name})},"".concat(h.name,"-").concat(j)))})]}),a&&a.audioFiles.length===0&&e.jsxs("div",{className:"p-4 rounded-[var(--mi-border-radius)] mb-4 flex gap-3 bg-[rgba(244,67,54,0.1)] border-l-4 border-[#F44336]",children:[e.jsx("div",{className:"text-xl flex-shrink-0 mt-1",children:e.jsx(me,{})}),e.jsx("div",{className:"text-sm leading-snug",children:c("noAudioFilesFound")})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(F,{onClick:d,variant:"outlined",children:c("cancel")}),e.jsx(F,{onClick:()=>N(a,m),disabled:!v,children:c("confirmImport")})]})]})},Ft=K("div",{target:"e1txcvn25"})("position:relative;border:2px dashed var(--mi-text-color);border-radius:var(--mi-border-radius);padding:2rem;text-align:center;cursor:pointer;transition:all 0.2s ease;background-color:",s=>s.isDragging?"var(--mi-tint-color)":"transparent",";border-color:",s=>s.isDragging?"var(--mi-button-color)":"var(--mi-text-color)",";"),It=K("input",{target:"e1txcvn24"})({name:"kj4lyn",styles:"position:absolute;top:0;left:0;width:100%;height:100%;opacity:0;cursor:pointer"}),St=K("div",{target:"e1txcvn23"})({name:"y909ps",styles:"font-size:2rem;margin-bottom:1rem;color:var(--mi-text-color)"}),Mt=K("div",{target:"e1txcvn22"})({name:"1gok8e8",styles:"margin-bottom:0.5rem"}),Lt=K("div",{target:"e1txcvn21"})({name:"1hpkst6",styles:"font-weight:600;font-size:1.1rem;margin-bottom:0.25rem;color:var(--mi-text-color)"}),Le=K("div",{target:"e1txcvn20"})({name:"13ibcz0",styles:"font-size:0.9rem;color:var(--mi-lighter-foreground-color)"}),Rt=({existingTracksCount:s,trackGroupId:r,artistId:t,reload:i})=>{const{t:a}=S("translation",{keyPrefix:"zipImport"}),[o,m]=H.useState(!1),[l,n]=H.useState(!1),[p,d]=H.useState(null),[c,b]=H.useState(null),[f,u]=H.useState(!1),[y,v]=H.useState(0),[w,g]=H.useState(null),A=H.useCallback(k=>{k.preventDefault(),k.stopPropagation(),m(!0)},[]),N=H.useCallback(k=>{k.preventDefault(),k.stopPropagation(),m(!1)},[]),T=async k=>{if(!k.name.toLowerCase().endsWith(".zip")){d(a("notAZipFile"));return}d(null),n(!0);try{if(k.size/1048576>1e3){d(a("fileTooLarge",{size:"1000MB"}));return}const h=await Fs(k);if(h.errorMessage){d(h.errorMessage);return}const j=await Is(h.files);b(j),v(0),g(null),u(!0)}catch(R){d("".concat(a("error"),": ").concat(R instanceof Error?R.message:"Unknown error"))}finally{n(!1)}},D=H.useCallback(async k=>{var R;k.preventDefault(),k.stopPropagation(),m(!1),((R=k.dataTransfer.files)==null?void 0:R.length)>0&&await T(k.dataTransfer.files[0])},[]),C=H.useCallback(async k=>{k.target.files&&k.target.files.length>0&&await T(k.target.files[0])},[]),L=H.useCallback(()=>{u(!1),b(null),v(0),g(null)},[]);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("h2",{children:a("importFromZip")}),e.jsx("p",{children:a("importAlbumContent")}),e.jsxs(Ft,{isDragging:o,onDragOver:A,onDragLeave:N,onDrop:D,className:P(l?"opacity: 0.6; pointer-events: none;":"",";",""),children:[e.jsx(It,{type:"file",accept:".zip",onChange:C,disabled:l,"aria-label":"Import album from zip file"}),e.jsx(St,{children:l?e.jsx(Ts,{}):e.jsx(Ds,{})}),e.jsxs(Mt,{children:[e.jsx(Lt,{children:a("title")}),e.jsx(Le,{children:a("subtitle")})]}),l&&e.jsx(Le,{children:a("scanning")})]}),p&&e.jsx("div",{className:P({name:"7b6vg0",styles:"margin-top:1rem;padding:0.75rem 1rem;background-color:rgba(244, 67, 54, 0.1);border-left:4px solid #f44336;border-radius:var(--mi-border-radius);
1color:var(--mi-text-color);font-size:0.9rem"}),children:p}),e.jsx(Dt,{trackGroupId:r,artistId:t,reload:i,isOpen:f&&c!==null,preScanResult:c,existingTracksCount:s,selectedCoverIndex:y,onSelectedCoverChange:v,invalidFilesAction:w,onInvalidFilesActionChange:g,onClose:L}),e.jsx("p",{className:"text-sm opacity-75",children:a("zipUploadDescription")})]})},q=K("div",{target:"e1gv0wd00"})({name:"199bhmr",styles:"margin:2rem 0;padding-bottom:1rem;border-bottom:1px solid var(--mi-tint-x-color)"}),xa=()=>{var u,y,v;const{t:s}=S("translation",{keyPrefix:"manageAlbum"}),{t:r}=S("translation",{keyPrefix:"manageArtist"}),t=Q(),i=$e(),{artistId:a,trackGroupId:o}=te(),{data:m,isPending:l}=Z(Ss({artistSlug:a!=null?a:""})),{data:n,isPending:p,refetch:d}=Z(ke(Number(o))),{mutateAsync:c,isPending:b}=Ms(),f=x.useCallback(async()=>{var g;if(!(!n||!m||!window.confirm((g=r("deleteTrackGroupConfirm"))!=null?g:"")))try{await c({trackGroupId:n.id}),t(r("albumDeleted"),{type:"success"}),i(ce(m.id)+"/releases")}catch(A){console.error(A),t(r("somethingWentWrong"),{type:"warning"})}},[m,c,r,i,t,n]);if(!m&&l)return e.jsx(Ie,{});if(m){if(!n&&p)return e.jsx(Ie,{});if(!n)return null}else return null;return e.jsxs(zs,{className:P("padding-top:2rem!important;@media (max-width: ",se.small,"px){padding-top:1rem!important;}",""),children:[e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx(Us,{subPage:"releases"}),e.jsx("h1",{className:"mt-4",children:s(n?"editAlbum":"createAlbum")})]}),e.jsx(mt,{}),n.tracks.length===0&&n&&e.jsx(q,{children:e.jsx(Rt,{existingTracksCount:(y=(u=n==null?void 0:n.tracks)==null?void 0:u.length)!=null?y:0,trackGroupId:n.id,artistId:m.id,reload:d})}),e.jsx(dt,{trackGroup:n,artist:m,reload:()=>d()}),e.jsxs(q,{children:[e.jsx("h2",{children:s("uploadTracks")}),e.jsx(pt,{trackGroup:n,reload:d}),n&&((v=n==null?void 0:n.tracks)==null?void 0:v.length)>0&&e.jsx(Tt,{tracks:n.tracks,editable:!0,trackGroupId:n.id,owned:!0,reload:d}),n&&e.jsx(Vs,{trackgroup:n,reload:()=>d(),multiple:!0})]}),e.jsxs(q,{children:[e.jsx("h2",{children:s("downloadableContent")}),e.jsx(Ls,{reload:d,item:n,itemType:"release"})]}),e.jsx(q,{children:e.jsx(bt,{trackGroupId:n.id})}),e.jsx(le,{to:ce(m.id)+"/releases/tools",startIcon:e.jsx(Rs,{}),variant:"outlined",children:s("downloadCodes")}),e.jsx(q,{children:e.jsx(gt,{trackGroup:n,artist:m})}),e.jsx("hr",{className:"my-8 border-(--mi-tint-x-color)"}),e.jsx(F,{startIcon:e.jsx(he,{}),onClick:()=>{f()},isLoading:b,className:"!bg-(--mi-red-700) !border-(--mi-red-700) !text-(--mi-red-100) [&_svg]:!fill-(--mi-red-100) enabled:hover:!bg-(--mi-red-800) enabled:hover:!border-(--mi-red-800)",children:r("delete")})]})};export{q as FormSection,xa as default};
2//# sourceMappingURL=Index-gpnP1EN-.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.