import{z as j,ag as y,q as v,G as A,ai as C,I as E,J as N,ab as k,b as q,M as I,j as t,aw as P,T as u,N as _,av as l}from"./main-D6SjkSWq.js";import{C as F}from"./crupdate-artist-form-PX51uBTS.js";import{g as c}from"./artist-link-C48CzE2I.js";import{D as Q}from"./paginated-resources-C0CNliR6.js";import{u as w}from"./use-artist-permissions-4y2T1-d7.js";import{C as B}from"./crupdate-resource-layout-IY4TseVy.js";import{u as f}from"./use-required-params-CpncaBAU.js";import{u as g}from"./useSuspenseQuery-Xmh5uCOE.js";import{B as x,a as o}from"./breadcrumb-Pvuej4Ko.js";import"./music-Bh2SQVZ2.js";import"./album-image-CV6DMn1J.js";import"./Album-DPLpFLYW.js";import"./album-link-C4KAB_gW.js";import"./use-delete-album-DQQ5xCNs.js";import"./table-BI0jS7jz.js";import"./checkbox-BOwiW7Rf.js";import"./CheckBoxOutlineBlank-Bq47EBBJ.js";import"./skeleton-3NNrk_-o.js";import"./ArrowDownward-XP3ErQ5N.js";import"./useInteractOutside-B51FER0Z.js";import"./useEffectEvent-Bb2YhEEQ.js";import"./is-ctrl-or-shift-pressed-CY4knlcl.js";import"./use-pointer-events-gcsg7T42.js";import"./useGlobalListeners-DfpyJoKy.js";import"./use-sortable-table-data-BV4E9fRG.js";import"./sort-array-of-objects-CuHY7GpM.js";import"./formatted-date-BIydE9wI.js";import"./use-date-formatter-DZ85Tkvk.js";import"./DateFormatter-Dix9bfnP.js";import"./formatted-number-BBL0Q5Lv.js";import"./Add-DqbkGfuM.js";import"./Edit-Cysuqwzc.js";import"./confirmation-dialog-E4zsogCz.js";import"./dialog-footer-es-AfbvV.js";import"./external-ids-fields-CaZSeG7G.js";import"./profile-links-form-CCWaP3OB.js";import"./genre-B_3ZyEC1.js";import"./form-normalized-model-chip-field-D_4zoyut.js";import"./use-normalized-models-D9FqQyBj.js";import"./form-chip-field-CRtNtvyR.js";import"./input-CalT3wzl.js";import"./chip-list-CvrJkGlz.js";import"./chevron-down-BqXy_cI5.js";import"./image-selector-CCexW8Lt.js";import"./file-upload-provider-C966C2x1.js";import"./uploaded-file-Dt7HVOVK.js";import"./extension-from-filename-O0XMuZye.js";import"./pretty-bytes-bO14ePu9.js";import"./traditional-GTMgz7Xu.js";import"./use-active-upload-DElCZe_0.js";import"./open-upload-window-DxsWEG58.js";import"./AddAPhoto-BPK-B3uy.js";import"./file-input-config-DrcTpI3-.js";import"./switch-CvotT3pn.js";import"./tabs-BwrtVGjA.js";import"./tab-panels-DDLnWdlJ.js";import"./datatable-page-with-header-layout-BuTOEIJh.js";import"./dashboard-layout-context-C1ErlVWg.js";import"./ChevronRight-BN6UJOeQ.js";import"./MoreHoriz-Bms6kOtf.js";const D=i=>`artists/${i}`;function L(i){const{trans:s}=j(),e=y(),{pathname:m}=v();return A({mutationFn:a=>S(a),onSuccess:a=>{E(s(N("Artist updated"))),k.invalidateQueries({queryKey:Q("artists")}),m.includes("admin")?e("/admin/artists"):e(c(a.artist))},onError:a=>C(a,i)})}function S({id:i,...s}){return q.put(D(i),s).then(e=>e.data)}function z({showExternalFields:i=!0,breadcrumbs:s,navbar:e}){var d;const{artistId:m}=f(["artistId"]),a=g(l.artists.show(m).artist("editArtistPage")),r=a.data.artist,{canEdit:b}=w(r),p=I({defaultValues:{id:r.id,name:r.name,verified:r.verified,spotify_id:r.spotify_id,genres:r.genres,image_small:r.image_small,links:r.links,profile:r.profile,profile_images:r.profile_images,disabled:r.disabled}}),n=L(p);return b?t.jsx(B,{form:p,onSubmit:h=>{n.mutate(h)},navbar:e,title:s??t.jsxs(x,{size:"xl",children:[t.jsx(o,{to:"/admin/artists",children:t.jsx(u,{message:"Artists"})}),t.jsx(o,{children:r.name})]}),isLoading:n.isPending,disableSaveWhenNotDirty:!0,children:t.jsx(F,{albums:(d=a.data.albums)==null?void 0:d.data,showExternalFields:i})}):t.jsx(P,{to:"/",replace:!0})}function Jt(){const{artistId:i}=f(["artistId"]),s=g(l.artists.show(i).artist("editArtistPage"));return t.jsx("div",{className:"h-screen",children:t.jsx(z,{showExternalFields:!1,navbar:t.jsx(_,{className:"flex-shrink-0",color:"bg",darkModeColor:"bg"}),breadcrumbs:t.jsxs(x,{size:"xl",children:[t.jsx(o,{to:c(s.data.artist),children:s.data.artist.name}),t.jsx(o,{children:t.jsx(u,{message:"Edit"})})]})})})}export{Jt as BackstageUpdateArtistPage,z as Component};
