PageSourceSearch

https://app.parler.com/assets/EditProfilePage-DH_gQyaa.js

js parler.com collected 2026-09-24 08:27:40 UTC 8,478 bytes, 1 lines download raw bytes

1import{V as ce,de as ue,z as be,c0 as me,df as Y,j as e}from"./vendor-data-eBPZki-Z.js";import{f as pe,r as n}from"./vendor-react-BgtJhS2O.js";import{u as k,af as O,aD as z,by as G,ag as ge,ah as xe,aY as fe,m as ve,bz as L}from"./index-DTQGL8n8.js";import{u as he}from"./useTrackScreen-BLOOZkQ_.js";import{e2 as ke,e3 as ye,J as M,e4 as je}from"./vendor-zod-Bei2Z9MS.js";import{u as W}from"./useImageCropTarget-D4vTG1Mx.js";import{C as q}from"./CameraIcon-MwhCrT8M.js";const Ce=ce();ue();be();const Ne=[5e3,15e3,3e4],we=3*6e4,Ue=2e4;function V(c){return c?c.split(/[?#]/)[0]:""}async function Ae(c,o){const m=Date.now();let f=!1;const h=async()=>{if(k.getState().user?.id!==o)return"done";try{const r=await Ce.get("/user"),l=je(r.data?.data??r.data);if(k.getState().user?.id!==o)return"done";const s=l.avatarUrl;s&&M(s)&&(f=!0);const v=!!s&&!M(s),t=V(s)!==V(c),a=f||Date.now()-m>Ue;if(v&&(t||a)){const p=t?s:`${s}${s.includes("?")?"&":"?"}v=${m}`,g=k.getState().user;return g&&k.getState().setUser({...g,avatarUrl:p}),(l.id||l.username)&&Y(G,l.id??"",p,l.username),"done"}}catch{}return"pending"};for(const r of Ne)if(await new Promise(l=>setTimeout(l,r)),await h()==="done")return;await new Promise(r=>{const l=()=>{document.removeEventListener("visibilitychange",s),clearTimeout(v),r()},s=async()=>{document.visibilityState==="visible"&&await h()==="done"&&l()};document.addEventListener("visibilitychange",s);const v=setTimeout(l,Math.max(0,we-(Date.now()-m)))})}const X="image/jpeg,image/png,image/webp,image/gif",T=50,D=160;function Fe(){he("EditProfile");const c=pe(),o=k(d=>d.user),m=k(d=>d.setUser),[f,h]=n.useState(o?.displayName??""),[r,l]=n.useState(o?.bio??""),[s,v]=n.useState(o?.website??""),t=W(),a=W(),[p,g]=n.useState(null),F=n.useRef(null),_=n.useRef(null),u=O(),b=O(),N=me({currentUserId:o?.id,currentUsername:o?.username}),J=z(t.file),H=z(a.file),w=N.isPending||u.isUploading||b.isUploading,y=f.trim(),U=y.length>T,A=r.length>D,j=n.useMemo(()=>ke(s),[s]),S=j.length>0&&!ye(j),[K,Q]=n.useState(!1),B=K&&y.length===0,Z=B||U,E=y.length>0&&!U&&!A&&!S&&!w,ee=n.useCallback(()=>F.current?.click(),[]),te=n.useCallback(()=>_.current?.click(),[]),ae=n.useCallback(d=>{Q(!0),h(d)},[]),re=n.useCallback(d=>{g(null),t.onPick(d.target.files?.[0]??null),u.reset(),d.target.value=""},[t,u]),se=n.useCallback(d=>{g(null),a.onPick(d.target.files?.[0]??null),b.reset(),d.target.value=""},[a,b]),ne=n.useCallback(async d=>{if(d.preventDefault(),!!E){g(null);try{let i,C;t.file&&(i=await u.upload(t.file)),a.file&&(C=await b.upload(a.file));const le=j.length>0?j:null,P={name:y,bio:r.trim(),website:le};i!==void 0&&(P.avatar=i),C!==void 0&&(P.background=C),await N.mutateAsync(P);const ie=M(i),x=k.getState().user,de=x?.avatarUrl??null;x&&m({...x,displayName:y,bio:r.trim(),website:j||void 0,...i?{avatarUrl:i}:{},...C?{bannerUrl:C}:{}}),i&&x&&(x.id||x.username)&&Y(G,x.id??"",i,x.username),ie&&Ae(de,x?.id??null),c("/profile",{replace:!0})}catch(i){if(i instanceof ge){g("Upload cancelled.");return}if(i instanceof xe){g(i.message);return}g(i?.response?.data?.message??i?.message??"Failed to save profile.")}}},[E,t,a,u,b,y,r,j,N,m,c]),oe=n.useCallback(()=>{u.isUploading&&u.cancel(),b.isUploading&&b.cancel(),c(-1)},[u,b,c]),R=J??o?.avatarUrl??null,$=H??o?.bannerUrl??null;return e.jsxs("div",{className:"max-w-[600px]",children:[e.jsxs("header",{className:"sticky top-0 z-10 bg-bg/90 dark:bg-bg-dark/90 backdrop-blur border-b border-border-light dark:border-border-dark px-4 py-3 flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:oe,className:"p-1.5 -ml-1.5 rounded-full text-text dark:text-text-dark hover:bg-bg-elevated dark:hover:bg-bg-elevated-dark transition-colors","aria-label":"Cancel",children:e.jsx(fe,{})}),e.jsx("h1",{className:"font-semibold",children:"Edit profile"}),e.jsx("button",{type:"submit",form:"edit-profile-form",disabled:!E,className:"bg-brand hover:bg-brand/90 text-text-on-brand font-medium py-1.5 px-4 rounded-full text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:w?"Saving…":"Save"})]}),e.jsxs("form",{id:"edit-profile-form",onSubmit:ne,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"relative aspect-[3/1] bg-gradient-to-br from-brand to-brand/40",children:[$&&e.jsx("img",{src:$,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:te,"aria-label":"Change banner",className:"absolute inset-0 flex items-center justify-center bg-scrim/40 hover:bg-scrim/60 text-text-on-brand transition-colors",children:e.jsx(q,{})}),a.originalFile&&e.jsx("button",{type:"button",onClick:a.reopen,className:"absolute bottom-2 right-2 px-3 py-1 text-xs font-semibold rounded-full bg-bg/90 dark:bg-bg-dark/90 text-text dark:text-text-dark hover:bg-bg dark:hover:bg-bg-dark transition-colors",children:"Crop"})]}),e.jsx("div",{className:"relative z-10 px-4 -mt-12 mb-3",children:e.jsxs("div",{className:"relative inline-block",children:[R?e.jsx("img",{src:R,alt:"",className:"w-24 h-24 rounded-full border-4 border-bg dark:border-bg-dark object-cover bg-bg-elevated dark:bg-bg-elevated-dark"}):e.jsx("div",{className:"w-24 h-24 rounded-full border-4 border-bg dark:border-bg-dark bg-bg-elevated dark:bg-bg-elevated-dark"}),e.jsx("button",{type:"button",onClick:ee,"aria-label":"Change avatar",className:"absolute inset-0 flex items-center justify-center rounded-full bg-scrim/40 hover:bg-scrim/60 text-text-on-brand transition-colors",children:e.jsx(q,{})}),t.originalFile&&e.jsx("button",{type:"button",onClick:t.reopen,"aria-label":"Re-crop avatar",className:"absolute -bottom-1 -right-1 px-2 py-0.5 text-[10px] font-semibold rounded-full bg-bg dark:bg-bg-dark text-text dark:text-text-dark border border-border-light dark:border-border-dark hover:bg-bg-elevated dark:hover:bg-bg-elevated-dark transition-colors",children:"Crop"})]})}),e.jsx("input",{ref:F,type:"file",accept:X,onChange:re,className:"hidden"}),e.jsx("input",{ref:_,type:"file",accept:X,onChange:se,className:"hidden"})]}),e.jsxs("div",{className:"px-4 space-y-4",children:[e.jsx(I,{label:"Display name",value:f,onChange:ae,maxLength:T,invalid:Z,required:!0,errorText:B?"Dis
1play name is required.":U?`Display name must be ${T} characters or less.`:void 0}),e.jsx(I,{label:"Bio",value:r,onChange:l,maxLength:D,invalid:A,multiline:!0,errorText:A?`Bio must be ${D} characters or less.`:void 0}),e.jsx(I,{label:"Website",value:s,onChange:v,placeholder:"https://example.com",invalid:S,errorText:S?"Enter a valid https website (e.g. example.com or https://example.com). http:// is not allowed.":void 0}),p&&e.jsx("p",{className:"text-error text-sm",children:p}),w&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary dark:text-text-secondary-dark",children:[e.jsx(ve,{size:"sm"}),e.jsx("span",{children:u.isUploading?`Uploading avatar… ${u.progress}%`:b.isUploading?`Uploading banner… ${b.progress}%`:"Saving…"})]})]})]}),e.jsx(L,{open:t.isOpen,onOpenChange:t.setOpen,onCancel:t.cancel,file:t.dialogFile,aspect:1,lockAspect:!0,title:"Crop avatar",onApply:t.onApply}),e.jsx(L,{open:a.isOpen,onOpenChange:a.setOpen,onCancel:a.cancel,file:a.dialogFile,aspect:3,lockAspect:!0,title:"Crop banner",onApply:a.onApply})]})}function I({label:c,value:o,onChange:m,placeholder:f,maxLength:h,invalid:r,required:l,multiline:s,errorText:v}){const t=h!=null?h-o.length:null,a=`w-full bg-transparent border rounded-lg px-3 py-2 text-text dark:text-text-dark text-sm focus:outline-none focus:ring-2 focus:ring-brand placeholder:text-text-secondary dark:placeholder:text-text-secondary-dark ${r?"border-error focus:ring-error":"border-border-light dark:border-border-dark"}`;return e.jsxs("label",{className:"block",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[e.jsxs("span",{className:"text-sm font-medium text-text dark:text-text-dark",children:[c,l&&e.jsx("span",{className:"text-error ml-0.5",children:"*"})]}),t!=null&&e.jsx("span",{className:`text-xs ${r?"text-error":"text-text-secondary dark:text-text-secondary-dark"}`,"aria-live":"polite",children:t})]}),s?e.jsx("textarea",{value:o,onChange:p=>m(p.target.value),placeholder:f,rows:3,"aria-invalid":r||void 0,className:a}):e.jsx("input",{value:o,onChange:p=>m(p.target.value),placeholder:f,"aria-invalid":r||void 0,className:a}),v&&e.jsx("p",{className:"mt-1 text-xs text-error",role:"alert",children:v})]})}export{Fe as default};

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.