import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{Ar as t,Dvt as n,G$ as r,H$ as i,I$ as a,L$ as o,Mft as s,Mvt as c,N_t as l,O_t as u,Or as d,P_t as f,R$ as p,Rft as m,V$ as h,Vft as g,_ut as _,a3 as v,gut as y,hut as b,jft as x,r3 as S,vut as C,z$ as w}from"./app-initial-BHB6SClA.js";import{r as T,t as E}from"./avatar-mascot-button-lIOXDH5S.js";import{i as D,t as O}from"./custom-avatars-query-mkYIdPJ1.js";import{i as k,n as A,r as j,t as M}from"./pet-install-state-wUu7G9Ym.js";function N(e){let n=(0,P.c)(37),{session:r,onClose:s,onInstall:c}=e,{setSelectedAvatarId:l}=t(),u=r.status!==`installing`,d=r.status===`ready`||r.status===`installError`,f;n[0]!==u||n[1]!==s?(f=e=>{!e&&u&&s()},n[0]=u,n[1]=s,n[2]=f):f=n[2];let m=!u,h;n[3]!==d||n[4]!==c?(h=e=>{e.preventDefault(),d&&c()},n[3]=d,n[4]=c,n[5]=h):h=n[5];let v;n[6]!==r.name||n[7]!==r.status?(v=r.status===`installed`?(0,F.jsx)(g,{id:`pets.install.installedTitle`,defaultMessage:`Installed {petName}`,description:`Title shown after a pet installs successfully`,values:{petName:r.name}}):(0,F.jsx)(g,{id:`pets.install.title`,defaultMessage:`Install {petName}?`,description:`Title for the pet install modal`,values:{petName:r.name}}),n[6]=r.name,n[7]=r.status,n[8]=v):v=n[8];let y;n[9]!==r.description||n[10]!==v?(y=(0,F.jsx)(w,{children:(0,F.jsx)(p,{title:v,subtitle:r.description})}),n[9]=r.description,n[10]=v,n[11]=y):y=n[11];let x;n[12]!==r.name||n[13]!==r.preview||n[14]!==r.status?(x=(0,F.jsx)(w,{children:(0,F.jsx)(`div`,{className:`flex min-h-32 items-center justify-center`,children:r.status===`loading`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-token-text-secondary`,children:[(0,F.jsx)(_,{className:`icon-xs`}),(0,F.jsx)(g,{id:`pets.install.loading`,defaultMessage:`Loading {petName}`,description:`Loading state shown while a pet preview is prepared`,values:{petName:r.name}})]}):r.status===`previewError`?(0,F.jsx)(`div`,{className:`px-5 text-center text-sm text-token-text-secondary`,children:(0,F.jsx)(g,{id:`pets.install.error`,defaultMessage:`Unable to load {petName}`,description:`Error state shown when a pet cannot be prepared`,values:{petName:r.name}})}):(0,F.jsx)(E,{assetRef:`codex`,spriteVersionNumber:r.preview.spriteVersionNumber,spritesheetUrl:r.preview.spritesheetDataUrl})})}),n[12]=r.name,n[13]=r.preview,n[14]=r.status,n[15]=x):x=n[15];let S;n[16]!==r.name||n[17]!==r.status?(S=r.status===`installError`?(0,F.jsx)(w,{children:(0,F.jsx)(`div`,{className:`text-sm text-token-text-secondary`,children:(0,F.jsx)(g,{id:`pets.install.installError`,defaultMessage:`Unable to install {petName}`,description:`Error state shown when a pet preview is valid but installation fails`,values:{petName:r.name}})})}):null,n[16]=r.name,n[17]=r.status,n[18]=S):S=n[18];let C;n[19]!==u||n[20]!==d||n[21]!==s||n[22]!==r.installedAvatarId||n[23]!==r.status||n[24]!==l?(C=(0,F.jsx)(w,{children:r.status===`installed`?(0,F.jsxs)(o,{children:[(0,F.jsx)(b,{color:`outline`,type:`button`,onClick:s,children:(0,F.jsx)(g,{id:`pets.install.close`,defaultMessage:`Close`,description:`Button label to close a completed pet install modal`})}),(0,F.jsx)(b,{type:`button`,onClick:()=>{l(r.installedAvatarId),s()},children:(0,F.jsx)(g,{id:`pets.install.usePet`,defaultMessage:`Use this pet`,description:`Button label to select an installed pet`})})]}):(0,F.jsxs)(o,{children:[(0,F.jsx)(b,{color:`outline`,disabled:!u,type:`button`,onClick:s,children:(0,F.jsx)(g,{id:`pets.install.cancel`,defaultMessage:`Cancel`,description:`Button label to cancel a pet install`})}),(0,F.jsx)(b,{disabled:!d,loading:r.status===`installing`,type:`submit`,children:r.status===`installError`?(0,F.jsx)(g,{id:`pets.install.tryAgain`,defaultMessage:`Try again`,description:`Button label to retry a failed pet install`}):(0,F.jsx)(g,{id:`pets.install.install`,defaultMessage:`Install`,description:`Button label to install a pet`})})]})}),n[19]=u,n[20]=d,n[21]=s,n[22]=r.installedAvatarId,n[23]=r.status,n[24]=l,n[25]=C):C=n[25];let T;n[26]!==h||n[27]!==y||n[28]!==x||n[29]!==S||n[30]!==C?(T=(0,F.jsxs)(a,{as:`form`,onSubmit:h,children:[y,x,S,C]}),n[26]=h,n[27]=y,n[28]=x,n[29]=S,n[30]=C,n[31]=T):T=n[31];let D;return n[32]!==u||n[33]!==f||n[34]!==m||n[35]!==T?(D=(0,F.jsx)(i,{open:!0,onOpenChange:f,shouldIgnoreClickOutside:m,showDialogClose:u,size:`compact`,children:T}),n[32]=u,n[33]=f,n[34]=m,n[35]=T,n[36]=D):D=n[36],D}var P,F,I=e((()=>{P=c(),m(),T(),d(),y(),r(),h(),C(),F=n()}));function L(e){let t=(0,R.c)(10),{onClose:n}=e,r=l(x),i=f(k),a=v();if(i==null)return null;let o;t[0]!==n||t[1]!==r?(o=()=>{M(r),n()},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==a||t[4]!==r?(s=()=>j(r,()=>a(O)),t[3]=a,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==i||t[7]!==o||t[8]!==s?(c=(0,z.jsx)(N,{session:i,onClose:o,onInstall:s}),t[6]=i,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var R,z;e((()=>{R=c(),u(),D(),S(),s(),I(),A(),z=n()}))();export{L as PetInstallModalHost};
//# sourceMappingURL=pet-install-modal-host-XfAp8QDs.js.map