2 lines
55 KiB
JavaScript
2 lines
55 KiB
JavaScript
(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[2774],{68248:function(e,t,a){"use strict";a.d(t,{Z:function(){return n}});class n{static async getSalt(e){const t=new URL("/api/v1/login/salt",document.URL);return t.searchParams.append("email",e),(await fetch(t.toString()).then((e=>e.json().then((e=>e))))).salt}static async hashPasswordInWorker(e,t,n){const o=new Worker(new URL(a.p+a.u(3639),a.b));return new Promise((a=>{o.onmessage=e=>{a(e.data.clientHash)},o.postMessage({email:e,password:n,salt:t})}))}}},2735:function(e,t,a){"use strict";a.d(t,{Qj:function(){return P},zx:function(){return S}});var n=a(65443),o=a.n(n),l=a(94159),r=a(6285);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},s.apply(this,arguments)}const i=r.z.enum(["pill","roundrect","authn"]),c=r.z.enum(["cherry","strawberry","mango","not-black","red","green","accent","secondary","authn-primary","authn-other"]),m=(r.z.object({buttonStyle:i,color:c,className:r.z.string().optional()}),o()("bg-notWhite","hover:text-notWhite")),u=o()("font-atkinson","font-bold","rounded-full","border-2"),d=o()("body-2","rounded-lg"),p=o()("flex","h-12","items-center","justify-center","rounded-lg","px-6","text-lg"),h=o()("border-cherry","hover:bg-cherry","text-cherry","active:bg-cherry-600","active:border-cherry-600","disabled:text-cherry-300","disabled:border-cherry-300","focus:outline-cherry","focus:ring-cherry",m),g=o()("border-strawberry","hover:bg-strawberry","text-strawberry","active:bg-strawberry-600","active:border-strawberry-600","disabled:text-strawberry-300","disabled:border-strawberry-300","focus:outline-strawberry","focus:ring-strawberry",m),f=o()("border-red","hover:bg-red","text-red","active:bg-red-600","active:border-red-600","disabled:text-red-300","disabled:border-red-300","focus:outline-red",m),b=o()("border-green","hover:bg-green","text-green","active:bg-green-600","active:border-green-600","disabled:text-green-300","disabled:border-green-300","focus:outline-green",m),E=o()("border-mango","hover:bg-mango","text-mango","bg-notBlack","hover:text-notBlack"),y=o()("border-notBlack","hover:bg-notBlack","text-notBlack","focus:outline-notBlack","focus:ring-notBlack",m),w=o()("border-accent","text-accent","bg-foreground","hover:bg-accent","hover:text-text"),v=o()("bg-secondary","text-notWhite","dark:text-notBlack","hover:bg-secondary-600"),x=o()("bg-foreground","text-text","hover:bg-foreground-600","active:bg-foreground-700","disabled:bg-foreground-200"),N=o()("border-2","border-foreground","text-foreground","hover:bg-longan-200"),k=e=>o()("leading-none","align-middle","py-2","px-4","no-select",e.className,{[u]:"pill"===e.buttonStyle,[d]:"roundrect"===e.buttonStyle,[p]:"authn"===e.buttonStyle,[h]:"cherry"===e.color,[g]:"strawberry"===e.color,[E]:"mango"===e.color,[y]:"not-black"===e.color,[f]:"red"===e.color,[w]:"accent"===e.color,[b]:"green"===e.color,[v]:"secondary"===e.color,[x]:"authn-primary"===e.color,[N]:"authn-other"===e.color}),S=l.forwardRef((({buttonStyle:e,color:t,className:a,...n},o)=>{const r=k({buttonStyle:e,color:t,className:a,...n});return l.createElement("button",s({},n,{className:r,ref:o}),n.children)}));S.displayName="Button";const P=l.forwardRef((({buttonStyle:e,color:t,...a},n)=>{const o=k({buttonStyle:e,color:t,...a});return l.createElement("a",s({},a,{className:o,ref:n}),a.children)}));P.displayName="LinkButton"},20228:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});var n=a(94159),o=a(70496),l=a(65443),r=a.n(l);const s=({bigLabel:e,smallLabel:t,inputElement:a,infoBoxLevel:l,infoBoxContent:s,customDescription:i,disabled:c})=>{const m=t?"row-span-1":"row-span-2",u=i??null;return n.createElement("div",{className:"grid grid-cols-[1fr_min-content] grid-rows-[min-content] items-center gap-2.5 pt-2.5"},n.createElement(n.Fragment,null,n.createElement("label",{htmlFor:a.props.id,className:r()("col-start-1 row-start-1 font-bold",m,{"text-gray-300":c})},e),t?n.createElement("label",{htmlFor:a.props.id,className:r()("col-start-1 row-start-2 align-middle",{"text-gray-300":c})},t):null,n.createElement("div",{className:"col-start-2 row-span-2 row-start-1"},a),l?n.createElement(o.v,{level:l,className:"col-span-2 col-start-1"},s):u,n.createElement("hr",{className:"col-span-2 col-start-1 w-full border-gray-300"})))}},72228:function(e,t,a){"use strict";a.d(t,{F:function(){return m}});var n=a(97244),o=a(34377),l=a(65443),r=a.n(l),s=a(94159),i=a(99838);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},c.apply(this,arguments)}const m=({style:e="light",showValidity:t=!0,name:a,control:l,rules:m,trigger:u,...d})=>{const{field:p,fieldState:h}=(0,i.bc)({name:a,control:l,rules:m}),{name:g,onChange:f}=p,[b,E]=(0,s.useState)();(0,s.useEffect)((()=>{p.ref(b)}),[b,p]);const{inputStyleClasses:y,contentDivStyleClasses:w,validityIconStyleClasses:v}=(0,s.useMemo)((()=>{switch(e){case"light":return{inputStyleClasses:"border-gray-600 text-notBlack\n placeholder:text-gray-600\n focus:border-notBlack disabled:border-gray-300",contentDivStyleClasses:"to-notWhite",validityIconStyleClasses:"bg-notWhite"};case"dynamic":return{inputStyleClasses:"co-styled-input",contentDivStyleClasses:"co-styled-input-content",validityIconStyleClasses:"co-styled-input-validity-icon"};default:return{inputStyleClasses:"border-gray-400 text-notWhite \n placeholder:text-gray-400\n focus:border-notWhite read-only:bg-gray-700",contentDivStyleClasses:"to-notBlack",validityIconStyleClasses:"bg-notBlack"}}}),[e]);return(0,s.useEffect)((()=>{b&&b.value&&b.value!==d.defaultValue&&b.value!==p.value&&!h.isTouched&&(f(b.value),u(g,{shouldFocus:!0}))}),[b,p.value,g,h.isTouched,f,d.defaultValue,u]),s.createElement("div",{className:"relative"},s.createElement("input",c({className:r()("\n w-full min-w-[15rem] rounded-lg border-2 bg-transparent\n ",y)},d,p,{ref:E})),t&&!d.readOnly&&h.isTouched?s.createElement(s.Fragment,null,s.createElement("div",{className:r()("\n absolute bottom-0 right-9 top-0 my-auto h-6 w-3 \n bg-gradient-to-r from-transparent\n ",w)}),h.invalid?s.createElement(n.Z,{className:r()("\n absolute bottom-0 right-3 top-0 my-auto h-6 \n w-6 text-red\n ",v)}):s.createElement(o.Z,{className:r()("\n absolute bottom-0 right-3 top-0 my-auto h-6\n w-6 bg-notWhite text-green\n ",v)})):null)}},64672:function(e,t,a){"use strict";a.r(t),a.d(t,{UserSettingsMain:function(){return Be},default:function(){return We}});var n=a(38934),o=a(8227),l=a(12093),r=a(94159),s=a(90275),i=a(70496),c=a(48002),m=a(71860),u=a(86036),d=a.n(u),p=a(99838),h=a(51028),g=a(6553),f=a(72228);const b=()=>{const{t:e}=(0,h.$G)(),{email:t,emailVerified:a}=(0,o.Pc)(),{control:n,handleSubmit:s,trigger:i,formState:{errors:u,isSubmitting:b,isSubmitSuccessful:E}}=(0,p.cI)({defaultValues:{email:t??void 0}}),y=m.S.useContext(),w=m.S.login.changeEmail.useMutation({onSuccess:()=>y.login.emailChangeInProgress.invalidate()}),v=m.S.login.resendVerification.useMutation({}),x=(0,r.useCallback)((async t=>{try{const e=await d().post(l.ZP.public.apiV1.checkEmail().toString(),{email:t},{responseType:"json"});return!0===e.data.valid||e.data.reason}catch(t){return e("common:unknown-error").toString()}}),[e]),N=m.S.login.emailChangeInProgress.useQuery();return r.createElement("div",{className:c.hY},r.createElement("h4",{className:c.Kl},"change email"),N.data?r.createElement("p",null,"You're already changing your e-email address to"," ",N.data,". Click the verify link we sent there to finish it!"):null,r.createElement("form",{onSubmit:s((async({email:e})=>{await w.mutateAsync({newEmail:e})})),className:"flex flex-col gap-4"},r.createElement("div",{className:"flex flex-col"},r.createElement("label",null,r.createElement("p",{className:"font-bold"},"email"),r.createElement(f.F,{trigger:i,name:"email",control:n,rules:{required:e("client:register.email.required").toString(),validate:x},type:"email",autoComplete:"email",placeholder:"bradley@example.com"})),r.createElement("p",{className:"text-red"},u.email?u.email.message:null),a?null:r.createElement("p",{className:"mt-2 flex flex-row gap-2"},r.createElement("button",{className:"font-bold underline",onClick:()=>v.mutate(),disabled:v.isLoading},"resend verification"),v.isLoading?r.createElement("span",null,"sending..."):v.isSuccess?r.createElement("span",{className:"text-green"},"sent!"):v.isError?r.createElement("span",{className:"text-red"},r.createElement(r.Fragment,null,"error:"," ",v.failureReason)):null)),r.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},E?r.createElement("p",{className:"text-green"},"Email changed! Check for a new verification email!"):null,r.createElement(g.p,{type:"submit",disabled:b,className:"font-bold"},"change email"))))};var E=a(68248);const y=()=>{const e=(0,o.Pc)(),{t:t}=(0,h.$G)(),[a,n]=(0,r.useState)(""),{handleSubmit:s,control:i,getValues:m,formState:{errors:u,isSubmitting:b,isSubmitSuccessful:y},reset:w,trigger:v}=(0,p.cI)({mode:"onTouched"});return r.createElement("div",{id:"password-email",className:c.hY},r.createElement("h4",{className:c.Kl},"change password"),r.createElement("form",{onSubmit:s((async({oldPassword:t,newPassword:a})=>{if(n(""),!e.loggedIn)return;const o=await E.Z.getSalt(e.email),r=await E.Z.hashPasswordInWorker(e.email,o,t),s={type:"change",newClientHash:await E.Z.hashPasswordInWorker(e.email,o,a),oldClientHash:r};try{await d().post(l.ZP.public.apiV1.changePassword().toString(),s),w({confirmNewPassword:"",newPassword:"",oldPassword:""})}catch(e){n("Changing password failed.")}})),className:"flex flex-col gap-4"},r.createElement("div",null,r.createElement("label",{className:"flex flex-col"},r.createElement("p",{className:"font-bold"},"old password"),r.createElement(f.F,{trigger:v,name:"oldPassword",control:i,rules:{required:t("client:register.password.required").toString(),minLength:{value:8,message:t("client:register.password.min-length").toString()}},type:"password",autoComplete:"current-password",placeholder:"hunter2"})),r.createElement("p",{className:"text-red",role:"alert"},u.oldPassword?u.oldPassword.message:null)),r.createElement("div",null,r.createElement("label",{className:"flex flex-col"},r.createElement("p",{className:"font-bold"},"new password"),r.createElement(f.F,{trigger:v,name:"newPassword",control:i,rules:{required:t("client:register.password.required","Password is required!").toString(),minLength:{value:8,message:t("client:register.password.min-length","Password must be at least 8 characters!").toString()}},type:"password",autoComplete:"new-password",placeholder:"hunter3"})),r.createElement("p",{className:"text-red",role:"alert"},u.newPassword?u.newPassword.message:null)),r.createElement("div",null,r.createElement("label",{className:"flex flex-col"},r.createElement("p",{className:"font-bold"},"confirm new password"),r.createElement(f.F,{trigger:v,name:"confirmNewPassword",control:i,rules:{required:t("client:register.password.required","Password is required!").toString(),validate:e=>e===m().newPassword||t("client:register.password.confirm-password-mismatch","Passwords must match!").toString()},type:"password",autoComplete:"new-password",placeholder:"hunter3"})),r.createElement("p",{className:"text-red",role:"alert"},u.confirmNewPassword?u.confirmNewPassword.message:null)),r.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},y?r.createElement("p",{className:"text-green"},"Password changed!"):null,a?r.createElement("p",{className:"text-red",role:"alert"},a):null,r.createElement(g.p,{type:"submit",disabled:b,className:"font-bold"},"change password"))))};var w=a(990),v=a(65443),x=a.n(v),N=a(83797),k=a(20228);const S="rounded border-cherry border p-2",P=()=>{const e=m.S.useContext(),{data:t}=m.S.users.cwFilters.query.useQuery(void 0,{suspense:!0}),{mutate:a,error:n,isError:o,isLoading:l,isSuccess:s}=m.S.users.cwFilters.mutate.useMutation({onSuccess:async()=>{await e.users.cwFilters.query.invalidate()}}),[u,d]=(0,r.useState)(t?.silence??[]),[p,h]=(0,r.useState)(t?.autoexpand??[]),[f,b]=(0,r.useState)(t?.autoExpandAllCws??!1),[E,y]=(0,r.useState)(!1);return r.createElement("div",{id:"post-visibility","data-theme":"light",className:x()("co-themed-box",c.hY)},r.createElement("h4",{className:c.Kl},"filtered content warnings"),r.createElement(i.v,{level:"info",className:"prose max-w-full"},"Content warnings are matched ",r.createElement("em",null,"case insensitively"),'; hiding or showing "spiders" also applies to "Spiders" and "SPIDERS". However, partial matches don\'t work right now, so posts with a content warning for "big spiders" will still show up.'),r.createElement("p",{className:"prose"},"show me posts with these content warnings"," ",r.createElement("strong",{className:"font-bold text-cherry"},"without clicking through"),":"),r.createElement(N.r,{TokenIcon:w.Z,className:S,tokens:p,setTokens:h}),r.createElement(k.Z,{bigLabel:r.createElement(r.Fragment,null,"show ",r.createElement("span",{className:"font-bold text-cherry"},"ALL")," ","posts with content warnings"," ",r.createElement("span",{className:"font-bold text-cherry"},"without clicking through")),infoBoxLevel:"info",infoBoxContent:r.createElement("div",{className:"prose prose-sm"},r.createElement("p",null,"This will automatically expand ALL posts with content warnings. However, posts which contain content warnings you have asked to"," ",r.createElement("span",{className:"font-bold text-cherry"},"silence")," ","will still be fully hidden.")),inputElement:r.createElement("input",{type:"checkbox",checked:f,onChange:()=>b((e=>!e)),className:"h-6 w-6 rounded-lg border-2 border-foreground bg-notWhite text-foreground focus:ring-foreground"})}),r.createElement("p",{className:"prose"},r.createElement("strong",{className:"font-bold text-cherry"},"silence")," posts with these content warnings, hiding them completely:"),E?r.createElement("div",{className:S},r.createElement(N.r,{TokenIcon:w.Z,tokens:u,setTokens:d})):r.createElement("button",{className:x()(S,"cursor-pointer bg-strawberry-100 text-left"),onClick:()=>y(!0),type:"button"},"click to show list of silenced content warnings"),r.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},s?r.createElement("p",{className:"text-green"},"Settings saved!"):null,o?r.createElement("p",{className:"text-red"},n.message):null,r.createElement(g.p,{type:"submit",disabled:l,className:"font-bold",onClick:()=>a({silence:u,autoexpand:p,autoExpandAllCws:f})},"save settings")))};var T=a(62745),C=a(72100),I=a(15867),L=a(95024),A=a(44387);function F(){return F=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},F.apply(this,arguments)}const O=({user:e})=>{const[t,a]=(0,r.useState)(!1),[o,l]=(0,r.useState)(""),[s,u]=(0,r.useState)(""),d=(0,T.Q)(),h=(0,n._c)(),f=(0,L.useFlag)(I.T.Enum["chaos-day-2023"]),b=(0,L.useFlag)(I.T.Enum["attachment-composer-v2"]),{handleSubmit:E,formState:{errors:y},register:w}=(0,p.cI)({mode:"onTouched",defaultValues:{collapseAdultContent:e.collapseAdultContent,collapseLongThreads:d.collapseLongThreads,gifsStartPaused:d.gifsStartPaused,pauseProfileGifs:d.pauseProfileGifs,enableEmbeds:!d.disableEmbeds,externalLinksInNewTab:d.externalLinksInNewTab,enableNotificationCount:d.enableNotificationCount,suggestedFollowsDismissed:d.suggestedFollowsDismissed,enableMobileQuickShare:d.enableMobileQuickShare,beatsTimestamps:!!h&&d.beatsTimestamps,disableModalPostComposer:d.disableModalPostComposer,homeView:d.homeView,defaultShow18PlusPostsInSearches:d.defaultShow18PlusPostsInSearches,defaultPostBoxTheme:d.defaultPostBoxTheme,previewFeatures_lexicalPostEditor:d.previewFeatures_lexicalPostEditor,chaosDay2023_showNumbers:d.chaosDay2023_showNumbers}}),v=m.S.login.userSettings.useMutation(),x=b;return r.createElement("div",{className:"cohost-shadow-light dark:cohost-shadow-dark relative mx-auto flex max-h-min w-full flex-col gap-4 rounded-lg bg-notWhite px-7 py-8 text-notBlack"},r.createElement("form",{onSubmit:E((async({collapseAdultContent:e,collapseLongThreads:t,gifsStartPaused:n,pauseProfileGifs:o,enableEmbeds:r,externalLinksInNewTab:s,enableNotificationCount:i,suggestedFollowsDismissed:c,enableMobileQuickShare:m,beatsTimestamps:p,disableModalPostComposer:h,homeView:g,defaultShow18PlusPostsInSearches:f,defaultPostBoxTheme:b,previewFeatures_lexicalPostEditor:E,chaosDay2023_showNumbers:y})=>{a(!0),l(""),u("");try{await v.mutateAsync({explicitlyCollapseAdultContent:e,collapseLongThreads:t,gifsStartPaused:n,pauseProfileGifs:o,disableEmbeds:!r,externalLinksInNewTab:s,enableNotificationCount:i,suggestedFollowsDismissed:c,enableMobileQuickShare:m,beatsTimestamps:p,disableModalPostComposer:h,homeView:g,defaultShow18PlusPostsInSearches:f,defaultPostBoxTheme:b,previewFeatures_lexicalPostEditor:E,autoExpandAllCws:d.autoExpandAllCws,chaosDay2023_showNumbers:y})}catch(e){l("Changing settings failed."),a(!1)}u("Settings changed!"),a(!1)})),className:"flex flex-col gap-4"},r.createElement("h4",{className:c.Kl},"display settings"),r.createElement("div",{className:"flex flex-col"},r.createElement("h5",{className:c.nk},"what posts you see"),r.createElement(k.Z,{bigLabel:'hide 18+ posts until you click "show post"?',inputElement:r.createElement("input",F({id:"collapseAdultContent",type:"checkbox",className:"rounded-checkbox"},w("collapseAdultContent")))}),r.createElement(k.Z,{bigLabel:"include 18+ posts in tag searches and bookmarked tag feed by default?",inputElement:r.createElement("input",F({id:"defaultShow18PlusPostsInSearches",type:"checkbox",className:"rounded-checkbox"},w("defaultShow18PlusPostsInSearches")))}),r.createElement(k.Z,{bigLabel:"hide middle of long threads by default?",inputElement:r.createElement("input",F({id:"collapseLongThreads",type:"checkbox",className:"rounded-checkbox"},w("collapseLongThreads")))}),r.createElement("p",{className:"text-red"},y.collapseAdultContent?y.collapseAdultContent.message:null),r.createElement("div",{id:"post-display",className:"invisible relative top-0 h-0 w-0"}),r.createElement("h5",{className:c.nk},"how content inside posts looks"),r.createElement(k.Z,{bigLabel:"pause animated GIFs until you click them?",inputElement:r.createElement("input",F({id:"gifsStartPaused",type:"checkbox",className:"rounded-checkbox"},w("gifsStartPaused"))),infoBoxLevel:"warning",infoBoxContent:r.createElement(r.Fragment,null,"This feature still has some limitations that we're working on fixing. It currently only works on images attached at the top of a post, and only on GIFs; other animated image types can't be paused yet.")}),r.createElement(k.Z,{bigLabel:"open external links in a new tab?",inputElement:r.createElement("input",F({id:"externalLinksInNewTab",type:"checkbox",className:"rounded-checkbox"},w("externalLinksInNewTab")))}),r.createElement(k.Z,{bigLabel:"display previews of links?",inputElement:r.createElement("input",F({id:"enableEmbeds",type:"checkbox",className:"rounded-checkbox"},w("enableEmbeds"))),infoBoxLevel:"info",infoBoxContent:r.createElement(r.Fragment,null,"We use a service provider, iframely (",r.createElement("a",{href:"https://iframely.com/privacy",className:"underline"},"privacy policy"),"), to generate these. If you don't want to load content from iframely, uncheck this box. Some previews require you to load content from other sites in addition to iframely; we'll prompt you before new sites do this, and you can turn them off later through"," ",r.createElement("a",{href:`https://iframely.com/consents?site=${encodeURIComponent(new URL(C.O.HOME_URL).hostname)}`,className:"underline"},"iframely's site"),".")}),r.createElement(k.Z,{bigLabel:"default theme of posts and notifications:",inputElement:r.createElement("select",w("defaultPostBoxTheme"),r.createElement("option",{value:"light"},"always light"),r.createElement("option",{value:"dark"},"always dark"),r.createElement("option",{value:"prefers-color-scheme"},"follows device theme")),infoBoxLevel:"info",infoBoxContent:r.createElement(r.Fragment,null,"Other parts of the site follow your device's default color scheme. If a post doesn't look right in your default theme, you can switch to the other one from the \"meatball\" (",r.createElement(A.Z,{className:"inline-block h-4 w-4"}),") menu.")}),r.createElement("div",{id:"ui-display",className:"invisible relative top-0 h-0 w-0"}),r.createElement("h6",{className:c.nk},"how other parts of the site look"),r.createElement(k.Z,{bigLabel:"pause animated GIFs in avatars and header images?",inputElement:r.createElement("input",F({id:"pauseProfileGifs",type:"checkbox",className:"rounded-checkbox"},w("pauseProfileGifs")))}),r.createElement(k.Z,{bigLabel:"show new notification count in the sidebar?",inputElement:r.createElement("input",F({id:"enableNotificationCount",type:"checkbox",className:"rounded-checkbox"},w("enableNotificationCount")))}),r.createElement(k.Z,{bigLabel:"go to a new page when sharing or writing a post?",inputElement:r.createElement("input",F({id:"disableModalPostComposer",type:"checkbox",className:"rounded-checkbox"},w("disableModalPostComposer")))}),r.createElement(k.Z,{bigLabel:"which view do you want to be your home page?",inputElement:r.createElement("select",w("homeView"),r.createElement("option",{value:"dashboard"},"dashboard view"),r.createElement("option",{value:"following"},"following view"))}),f?r.createElement(k.Z,{bigLabel:"display Numbers™️ on posts?",inputElement:r.createElement("input",F({type:"checkbox",className:"rounded-checkbox"},w("chaosDay2023_showNumbers")))}):null,x?r.createElement(r.Fragment,null,r.createElement("h5",{className:c.nk},"preview features"),r.createElement(i.v,{level:"info"},r.createElement("div",{className:"prose prose-sm"},r.createElement("p",null,"These settings control features that are new to the site and which we intend to permanently enable soon, but that we want to give you the ability to disable in the event you run into problems. If you do run into problems, please e-mail us at"," ",r.createElement("a",{href:"mailto:support@cohost.org"},"support@cohost.org")," ","so we can fix them permanently for everyone."))),b?r.createElement(k.Z,{bigLabel:"enable new post editor?",inputElement:r.createElement("input",F({type:"checkbox",className:"rounded-checkbox"},w("previewFeatures_lexicalPostEditor"))),infoBoxLevel:"info",infoBoxContent:r.createElement("div",{className:"prose prose-sm"},r.createElement("p",null,"This new editor allows you to place images and audio in the middle of a post without having to set up your own hosting."))}):null):null,r.createElement("h5",{className:c.nk},"cohost plus settings"),r.createElement(i.v,{level:"info"},r.createElement("div",{className:"prose prose-sm"},r.createElement("p",null,"These settings enable features that are only available for cohost ",r.createElement("i",null,"Plus!")," subscribers."),h?null:r.createElement("p",null,"You can sign up for cohost ",r.createElement("i",null,"Plus!")," by scrolling down slightly."))),r.createElement(k.Z,{bigLabel:"enable .beat internet timestamps?",inputElement:r.createElement("input",F({type:"checkbox",className:"rounded-checkbox"},w("beatsTimestamps",{disabled:!h}))),infoBoxLevel:"info",infoBoxContent:r.createElement("div",{className:"prose prose-sm"},r.createElement("p",null,"changes all timestamps on cohost to use"," ",r.createElement("a",{href:"https://en.wikipedia.org/wiki/Swatch_Internet_Time"},".beat internet time"),"."))})),r.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},s?r.createElement("p",{className:"text-green"},s):null,o?r.createElement("p",{className:"text-red"},o):null,r.createElement(g.p,{type:"submit",disabled:t,className:"font-bold"},"save settings"))))};var R=a(74487);const _=()=>{const e=(0,R.F)(),{t:t}=(0,h.$G)();let a;const n=m.S.invites.getActiveInvites.useQuery(void 0,{suspense:!0});if(n.data?.totalRemainingUses){const t=t=>a=>{a.preventDefault();const n=l.ZP.public.invites.activate({inviteId:t}).toString();navigator.clipboard.writeText(n).catch((t=>{e&&e.error("invites form doesn't have clipboard permission!")}))};a=r.createElement("div",{id:"invites-activation",className:"prose"},r.createElement(h.cC,{i18nKey:"client:invites.youve-got-em",values:{nInvitesAvailable:n.data.totalRemainingUses},count:n.data.totalRemainingUses},r.createElement("p",null,"you can invite <0>{{nInvitesAvailable}}</0> people to cohost right now."),r.createElement("p",null,"if you'd like to invite someone to cohost, you can click any of the links below and we'll copy it to your clipboard. (you can also right click and copy the link directly if you prefer)"),r.createElement("p",null,"thanks for spreading the word!")),r.createElement("table",{className:"overflow-x-scroll"},r.createElement("thead",null,r.createElement("th",null,"invite ID"),r.createElement("th",null,"remaining uses")),r.createElement("tbody",null,n.data.invites.map((e=>r.createElement("tr",{key:e.inviteId},r.createElement("td",null,r.createElement("a",{onClick:t(e.inviteId),href:l.ZP.public.invites.activate({inviteId:e.inviteId}).toString()},e.inviteId)),r.createElement("td",null,e.userActivationsRemaining)))))))}else a=r.createElement("div",{className:"prose"},r.createElement("p",null,t("client:invites.no-invites-yet",{defaultValue:"you don't have any invites available right now. we'll \n send more out as we're able to hire additional help to \n develop and moderate cohost, and we'll let you know when \n we do!"})));return r.createElement("div",{className:c.hY},r.createElement("h4",{className:c.Kl},"invite people to cohost"),a)};function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},D.apply(this,arguments)}const j=({modMode:e})=>{const[t,a]=(0,r.useState)(!1),[n,o]=(0,r.useState)(""),[s,i]=(0,r.useState)(""),{handleSubmit:m,register:u}=(0,p.cI)({mode:"onTouched",defaultValues:{modMode:e}});return r.createElement("div",{id:"staff-only",className:c.hY},r.createElement("h4",{className:c.Kl},"moderator settings"),r.createElement("a",{href:l.ZP.public.moderation.home().toString(),className:"underline"},"Moderation directory"),r.createElement("form",{onSubmit:m((async({modMode:e})=>{a(!0),o(""),i("");try{await d().post(l.ZP.public.apiV1.moderation.changeSettings().toString(),{modMode:e}),i("Settings changed!"),a(!1)}catch(e){o("Changing settings failed."),a(!1)}})),className:"flex flex-col gap-4"},r.createElement("div",{className:"flex flex-col"},r.createElement("div",{className:"flex flex-row items-center gap-2"},r.createElement("label",{htmlFor:"modMode",className:"font-bold"},"enable moderator mode (ignore visibility checks)?"),r.createElement("input",D({type:"checkbox"},u("modMode"))))),r.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},s?r.createElement("p",{className:"text-green"},s):null,n?r.createElement("p",{className:"text-red"},n):null,r.createElement(g.p,{type:"submit",disabled:t,className:"font-bold"},"save settings"))))},B=()=>{const{activated:e,emailVerified:t}=(0,o.Pc)(),a=m.S.users.getPositionInQueue.useQuery(void 0,{enabled:!e,suspense:!0});return e?null:r.createElement("div",{id:"invites-activation",className:c.hY},r.createElement("h5",{className:"h5"},"check your place in line"),t?null:r.createElement(i.v,{level:"warning"},r.createElement("div",{className:"prose prose-sm"},r.createElement("p",null,r.createElement("strong",null,"Your email address has not been verified!")," ","You cohost account will not be activated until you've verified your email address."),r.createElement("p",null,'Search your spam folder for emails from "no-reply@no-reply.cohost.org" if you\'re having trouble finding it, you can resend it from the top of this page.'))),r.createElement("div",{className:"prose"},r.createElement("p",null,"You're not activated yet! There are currently"," ",a.data?.toLocaleString("en-US")," people in front of you."),r.createElement("p",null,"We're activating new batches of users almost every day, so you'll get to the front soon enough!"),r.createElement("p",null,"For more information, check out"," ",r.createElement("a",{href:"https://help.antisoftware.club/en/support/solutions/articles/62000224749-how-do-i-get-an-invite-to-cohost-and-activate-my-account-"},"our support page on the topic"),".")))};var W=a(6285);const Z=W.z.enum(["cohost_plus_monthly"]);W.z.object({priceLookupKey:Z});var M=a(16086),K=a.p+"c9cba9a97beb26e73cb4.png";const Y=()=>r.createElement("div",{className:"cohost-shadow-light dark:cohost-shadow-dark relative mx-auto\n flex max-h-min w-full flex-col items-center gap-4 rounded-lg\n bg-longan-200 text-center text-cherry"},r.createElement("div",{id:"cohost-plus",className:"absolute -top-20 block h-0 w-0"}),r.createElement("img",{src:l.ZP.public.static.staticAsset({path:K}).toString(),className:"rounded-t-lg",alt:"Flyer for cohost plus"}),r.createElement("div",{className:"sr-only"},r.createElement("p",null,"Cohost Plus is our subscription service that helps support our development and gets you access to some extra features. Currently, your upload limit is increased to 10 megabytes, with more features coming soon. Only $4.99 per month or $49.99 per year.")),r.createElement(r.Suspense,{fallback:r.createElement("div",null,"loading subscriptions details...")},r.createElement(U,null))),U=()=>{const{data:e}=m.S.subscriptions.userSubscriptions.useQuery(void 0,{suspense:!0,select:e=>e.filter((e=>"active"===e.status))});return r.createElement("div",{className:"flex flex-col items-center gap-4 p-3"},e&&e.length>0?r.createElement(r.Fragment,null,r.createElement("p",null,"Your cohost Plus! subscription will expire on"," ",r.createElement(M.k,{dateISO:e[0].expirationDate,className:"font-bold"}),"."),e.length>1?r.createElement("div",{className:"prose rounded-lg border-2 border-red-700 bg-red-200 p-3 prose-p:my-1"},r.createElement("p",null,r.createElement("strong",null,"Heads up!")," It looks like you've got more than one active subscription! This shouldn't be possible, but it looks like we goofed up and made it happen anyway."),r.createElement("p",null,"Please contact us right away at"," ",r.createElement("a",{href:"mailto:support@cohost.org",className:"font-bold"},"support@cohost.org")," ","so we can figure out what's happening and fix it.")):null,r.createElement("form",{action:l.ZP.public.subscriptions.createPortalSession().toString(),method:"post"},r.createElement(g.p,{type:"submit"},"manage your subscription"))):r.createElement(r.Fragment,null,r.createElement("div",{className:"prose"},r.createElement("p",null,"You don't currently have a ",r.createElement("i",null,"cohost Plus!")," ","subscription! If you just subscribed and you're still seeing this, wait a bit; this can be slow to update. If it's been more than a couple hours and you're still seeing this, please e-mail us at"," ",r.createElement("a",{href:"mailto:support@cohost.org",className:"font-bold"},"support@cohost.org"),".")),r.createElement("form",{action:l.ZP.public.subscriptions.createCheckoutSession().toString(),method:"post"},r.createElement("input",{type:"hidden",value:Z.Enum.cohost_plus_monthly,name:"priceLookupKey"}),r.createElement(g.p,{type:"submit"},r.createElement("span",null,"subscribe to ",r.createElement("i",null,"cohost Plus!"))))))};var q=a(87239);const V="rounded border-cherry border p-2",z=()=>{const e=m.S.useContext(),{data:t}=m.S.users.tagFilters.query.useQuery(void 0,{suspense:!0}),{mutate:a,error:n,isError:o,isLoading:l,isSuccess:s}=m.S.users.tagFilters.mutate.useMutation({onSuccess:async()=>{await e.users.tagFilters.query.invalidate()}}),[u,d]=(0,r.useState)(t?.collapse??[]),[p,h]=(0,r.useState)(t?.silence??[]),[f,b]=(0,r.useState)(!1);return r.createElement("div",{id:"post-visibility","data-theme":"light",className:x()("co-themed-box",c.hY)},r.createElement("h4",{className:c.Kl},"filtered tags"),r.createElement(i.v,{level:"info",className:"prose max-w-full"},"Tags are matched ",r.createElement("em",null,"case insensitively"),'—hiding or showing "#fandom" also applies to "#Fandom" and "#FANDOM". However, partial matches don\'t work right now, so "#javascript fandom" will still show up.'),r.createElement("p",{className:"prose"},r.createElement("strong",{className:"font-bold text-cherry"},"muffle")," posts with these tags, requiring me to click through to view them:"),r.createElement("div",{className:V},r.createElement(N.r,{TokenIcon:q.Z,tokens:u,setTokens:d,getSuggestions:!0})),r.createElement("p",{className:"prose"},r.createElement("strong",{className:"font-bold text-cherry"},"silence")," posts with these tags, hiding them completely:"),f?r.createElement("div",{className:V},r.createElement(N.r,{TokenIcon:q.Z,tokens:p,setTokens:h,getSuggestions:!0})):r.createElement("button",{className:x()(V,"cursor-pointer bg-strawberry-100 text-left"),onClick:()=>b(!0),type:"button"},"click to show list of silenced tags"),r.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},s?r.createElement("p",{className:"text-green"},"Settings saved!"):null,o?r.createElement("p",{className:"text-red"},n.message):null,r.createElement(g.p,{type:"submit",disabled:l,className:"font-bold",onClick:()=>a({collapse:u,silence:p})},"save settings")))};var G=a(36592),Q=a(77689),H=a(8416),$=a(72362),J=a(105),X=a(48856),ee=a(7449);const te=(0,ee.I)(),ae=(0,$.C)({initial:"initializing",strict:!0,context:{enabled:void 0,email:void 0,baseSecret:void 0,baseSecretDataUrl:void 0,recoverySecret:void 0,token:void 0,retriesRemaining:void 0,resolvingTRPCError:void 0},states:{initializing:{id:"initializing",invoke:{src:"get2FAState",onDone:[{target:"enabled",cond:"is2FAEnabled"},{target:"disabled"}]}},disabled:{initial:"idle",states:{idle:{id:"disabledIdle",on:{SETUP_START:{target:"setup"}}},setup:{initial:"promptingBaseSecret",states:{promptingBaseSecret:{invoke:{src:"generateBaseSecret",onDone:{actions:(0,J.f0)(((e,t)=>{const a=t.data;return{baseSecret:a.baseSecret,baseSecretDataUrl:a.dataUrl}}))},onError:{target:"#setupError"}},on:{ACKNOWLEDGE:{target:"confirmingToken"},CANCEL:{target:"#disabledIdle"}}},confirmingToken:{initial:"awaitingInput",states:{awaitingInput:{on:{SETUP_ENTER_TOKEN:{target:"sending",actions:(0,J.f0)(((e,t)=>({token:t.token})))},CANCEL:{target:"#disabledIdle"}}},sending:{invoke:{src:"sendSetup",onDone:{actions:(0,X.Le)(((e,t)=>[(0,X.OU)(t.data)]))},onError:{actions:(0,X.Le)(((e,t)=>[(0,X.OU)(t.data)]))}},on:{SETUP_DONE:{target:"#setupDone",actions:(0,J.f0)(((e,t)=>({recoverySecret:t.recoverySecret})))},SETUP_RETRY_TOKEN:{target:"awaitingInput",actions:(0,J.f0)((e=>({retriesRemaining:(e.retriesRemaining??3)-1})))},SETUP_FATAL_ERROR:{target:"#setupError"}}}},exit:[(0,J.f0)((()=>({retriesRemaining:void 0})))]}},exit:[(0,J.f0)((()=>({baseSecret:void 0,baseSecretDataUrl:void 0,recoverySecret:void 0,token:void 0})))]},setupDone:{id:"setupDone",on:{ACKNOWLEDGE:{target:"#initializing"}}},setupError:{id:"setupError",on:{ACKNOWLEDGE:{target:"#initializing"}}}}},enabled:{initial:"idle",states:{idle:{id:"enabledIdle",on:{RESET_START:{target:"reset"}}},reset:{initial:"confirmingToken",states:{confirmingToken:{initial:"awaitingInput",states:{awaitingInput:{on:{RESET_ENTER_TOKEN:{target:"sending",actions:(0,J.f0)(((e,t)=>({token:t.token})))},CANCEL:{target:"#enabledIdle"}}},sending:{invoke:{src:"sendReset",onDone:{actions:(0,X.Le)(((e,t)=>[(0,X.OU)(t.data)]))},onError:{actions:(0,X.Le)(((e,t)=>[(0,X.OU)(t.data)]))}},on:{RESET_DONE:{target:"#initializing"},RESET_RETRY_TOKEN:{target:"awaitingInput",actions:(0,J.f0)((e=>({retriesRemaining:(e.retriesRemaining??3)-1})))},RESET_FATAL_ERROR:{target:"#resetError"}}}},exit:[(0,J.f0)((()=>({retriesRemaining:void 0})))]}},exit:[(0,J.f0)((()=>({token:void 0})))]},resetError:{id:"resetError",on:{ACKNOWLEDGE:{target:"#initializing"}}}}}}},{services:{get2FAState:async e=>{const t=await te.login.is2FAEnabled.query();e.enabled=t},generateBaseSecret:async e=>{const t=(0,ee.I)(),a=(await t.login.generate2FABaseSecret.mutate(void 0)).baseSecret,n=Q.authenticator.keyuri(e.email,"cohost.org",a);return new Promise(((e,t)=>H.toDataURL(n,((n,o)=>{n?t(n):e({dataUrl:o,baseSecret:a})}))))},sendSetup:async(e,t)=>{const a=(0,ee.I)();if(!e.baseSecret||!e.token)throw"assertion failure: 2FA setup process isn't done";try{return{type:"SETUP_DONE",recoverySecret:(await a.login.setup2FA.mutate({token:e.token})).recoverySecret}}catch(e){return e instanceof G.ss&&"incorrect-totp"===e?.data?.errorCode?{type:"SETUP_RETRY_TOKEN"}:{type:"SETUP_FATAL_ERROR",error:e}}},sendReset:async(e,t)=>{console.warn("in sendReset");const a=(0,ee.I)();if(!e.token)throw"assertion failure: 2FA setup process isn't done";try{return await a.login.reset2FA.mutate({token:e.token}),{type:"RESET_DONE"}}catch(e){if(e instanceof G.ss){const t=e;if("incorrect-totp"===t?.data?.errorCode)return{type:"RESET_RETRY_TOKEN",retriesRemaining:t.data.retriesRemaining}}return{type:"RESET_FATAL_ERROR",error:e}}}},guards:{is2FAEnabled:e=>!!e.enabled}}),ne=(0,r.createContext)({});var oe=a(45072),le=a(9488),re=a(2735),se=a(76709);function ie(){return ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},ie.apply(this,arguments)}const ce="w-fit rounded-lg border-2 border-cherry py-1 px-3",me=e=>e.context.baseSecret,ue=e=>e.context.baseSecretDataUrl,de=e=>e.context.retriesRemaining,pe=e=>e.context.recoverySecret,he=e=>{const t=(0,r.useContext)(ne);return r.createElement("div",{id:"two-factor-auth",className:c.hY},r.createElement("h4",{className:c.Kl},"two-factor authentication"),r.createElement(i.v,{level:"warning",className:"prose max-w-full"},"Your account has two-factor authentication disabled. You can help us keep your account secure by turning it on! Click the button below to start."),r.createElement("div",{className:c.dO},r.createElement(re.zx,{buttonStyle:"authn",color:"authn-primary",onClick:e=>{e.preventDefault(),t.send({type:"SETUP_START"})},className:"font-bold"},"enable 2FA (recommended)")))},ge=()=>{const e=(0,r.useContext)(ne),t=(0,oe.v)(e,me),a=(0,oe.v)(e,ue);return r.createElement("div",{className:c.hY},r.createElement("h4",{className:c.Kl},"two-factor authentication setup"),r.createElement(i.v,{level:"info",className:"prose max-w-full"},"If you don't already have one, you'll need to download a two-factor authenticator app. We recommend"," ",r.createElement("a",{href:"https://authy.com/"},"Authy"),"!"),r.createElement("div",{className:"flex flex-col items-center gap-3"},r.createElement("div",{className:"text-center font-bold"},"Open your authenticator app and scan this QR code:"),r.createElement("img",{className:ce,width:"250",height:"250",src:a,alt:"QR code"}),r.createElement("div",{className:"text-center font-bold"},"If your authenticator app doesn't support QR, enter the secret code below:"),r.createElement("div",{className:ce},t)),r.createElement(i.v,{level:"info",className:"prose max-w-full"},"Once cohost is registered in your app, you should see a six-digit code and a countdown."),r.createElement("div",{className:"flex w-full flex-row items-center font-bold text-notWhite"},r.createElement(re.zx,{buttonStyle:"authn",color:"authn-other",onClick:t=>{t.preventDefault(),e.send({type:"CANCEL"})},type:"reset",className:"font-bold"},"cancel setup"),r.createElement("div",{className:"flex-1"}," "),r.createElement(re.zx,{buttonStyle:"authn",color:"authn-primary",onClick:t=>{t.preventDefault(),e.send({type:"ACKNOWLEDGE"})},className:"font-bold",type:"submit"},"continue")))},fe=({mode:e})=>{const t=(0,r.useContext)(ne),a=(0,oe.v)(t,de),{handleSubmit:n,register:o}=(0,p.cI)({mode:"onTouched"});return r.createElement("div",{className:c.hY},r.createElement("h4",{className:c.Kl},"two-factor authentication setup"),r.createElement("form",{onSubmit:n((a=>{const n="setup"===e?"SETUP_ENTER_TOKEN":"RESET_ENTER_TOKEN";t.send({type:n,token:a.token})})),className:"flex flex-col items-center gap-3"},"setup"===e?r.createElement("div",{className:"text-center font-bold"},"Enter the 6-digit code found in your authenticator app below."):r.createElement("div",{className:"text-center font-bold"},"Enter the 6-digit code found in your authenticator app below. If you don't have access to your authenticator, you can also enter your recovery code."),r.createElement("div",null,r.createElement("label",{htmlFor:"token",className:"font-bold"},"your 6-digit code:"),r.createElement("input",ie({className:"block rounded-lg border-2 border-gray-600\n bg-transparent text-notBlack focus:border-notBlack",type:"text",autoComplete:"one-time-code"},o("token",{required:!0}))),a?r.createElement("div",{className:"text-sm text-gray-600"},"incorrect code. retries left: ",a,"."):null),r.createElement("div",{className:"flex w-full flex-row items-center font-bold text-notWhite"},r.createElement(re.zx,{buttonStyle:"authn",color:"authn-other",onClick:e=>{e.preventDefault(),t.send({type:"CANCEL"})},className:"font-bold",type:"reset"},"cancel"),r.createElement("div",{className:"flex-1"}," "),r.createElement(re.zx,{buttonStyle:"authn",color:"authn-primary",type:"submit",className:"font-bold"},"continue"))))},be=({setupJustFinished:e})=>{const t=(0,r.useContext)(ne),a=(0,oe.v)(t,pe);return r.createElement("div",{className:c.hY},r.createElement("h4",{className:c.Kl},e?"two-factor authentication setup":"two-factor authentication"),r.createElement(i.v,{level:"done"},r.createElement("p",{className:"font-bold text-green-800"},"Two-factor authentication is enabled!"),"Thanks for helping us keep your account secure."),e?r.createElement("div",{className:"flex flex-col items-center gap-3"},r.createElement("div",{className:"text-center font-bold"},"If you lose access to your authenticator for any reason—e.g. your phone gets factory reset or you lose it—you can use the code below to recover your account."),r.createElement("div",{className:ce},a),r.createElement("div",{className:"text-center font-bold"},"You can enter it in place of the 6-digit code when logging in to disable 2FA. We won't show you this code again, so save it in a secure place now."),r.createElement(re.zx,{buttonStyle:"authn",color:"authn-primary",onClick:e=>{e.preventDefault(),t.send({type:"ACKNOWLEDGE"})},className:"font-bold text-notWhite"},"finish")):r.createElement("div",{className:c.dO},r.createElement(re.zx,{buttonStyle:"authn",color:"authn-other",onClick:e=>{e.preventDefault(),t.send({type:"RESET_START"})},className:"font-bold"},"disable 2FA (not recommended)")))},Ee=()=>{const e=(0,r.useContext)(ne);return r.createElement("div",{className:c.hY},"There was an unexpected error setting up two-factor authentication for you, and your settings are unchanged. Try setting it up again later, or get in touch with us at support@cohost.org if the issue persists.",r.createElement("button",{onClick:t=>{t.preventDefault(),e.send({type:"ACKNOWLEDGE"})}},"OK"))},ye=()=>{const e=(0,r.useContext)(ne);return r.createElement("div",{className:c.hY},"There was an error disabling two-factor authentication on your account. It may or may not be disabled, so try reloading to check before you delete data from your authenticator.",r.createElement("button",{onClick:t=>{t.preventDefault(),e.send({type:"ACKNOWLEDGE"})}},"reload"))},we=()=>{const[e,,t]=(0,le.e)(ae,{devTools:!1});let a;switch(!0){case e.matches("disabled.idle"):a=r.createElement(he,{resetJustFinished:!1});break;case e.matches("disabled.setup.promptingBaseSecret"):a=r.createElement(ge,null);break;case e.matches("disabled.setup.confirmingToken"):a=r.createElement(fe,{mode:"setup"});break;case e.matches("disabled.setupDone"):a=r.createElement(be,{setupJustFinished:!0});break;case e.matches("disabled.setupError"):a=r.createElement(Ee,null);break;case e.matches("enabled.idle"):a=r.createElement(be,{setupJustFinished:!1});break;case e.matches("enabled.reset.confirmingToken"):a=r.createElement(fe,{mode:"reset"});break;case e.matches("enabled.resetDone"):a=r.createElement(he,{resetJustFinished:!0});break;case e.matches("enabled.resetError"):a=r.createElement(ye,null);break;default:a=r.createElement(r.Fragment,null,"loading...")}return r.createElement(se.S,null,r.createElement(ne.Provider,{value:t},a))};var ve=a(20616),xe=a(97287),Ne=a(58121),ke=a(13828),Se=a(4402),Pe=a(51540),Te=a(61888),Ce=a.n(Te);const Ie=({project:e})=>r.createElement(xe.R.Option,{key:e.projectId,value:e,className:"flex h-10 cursor-pointer flex-row items-center gap-3 px-2 py-1 hover:bg-foreground-100 hover:text-foreground-800 lg:first-of-type:rounded-t-lg lg:last-of-type:rounded-b-lg"},r.createElement(Pe.t,{project:e,noLink:!0,className:"h-8 w-8"}),r.createElement("span",null,"@",e.handle)),Le=e=>{const{t:t}=(0,h.$G)(),{projects:a}=(0,Se.m)(),n=Ce().find(a,(t=>t.projectId===e.selectedProjectId));return n?r.createElement(xe.R,{value:n,by:"projectId",onChange:t=>{e.onChange(t.projectId)}},r.createElement("div",{className:"relative"},r.createElement(xe.R.Button,{className:"group flex flex-row items-center gap-1"},r.createElement("div",{className:"flex flex-row items-center gap-3 rounded-l-lg px-2 py-1 group-hover:bg-foreground-600 group-hover:text-notWhite ui-open:bg-foreground-700 ui-open:text-notWhite"},r.createElement(Pe.t,{project:n,noLink:!0,className:"h-8 w-8"}),r.createElement("span",null,"@",n?.handle)),r.createElement("div",{className:"block rounded-r-lg p-2 text-notBlack group-hover:bg-foreground-600 group-hover:text-notWhite ui-open:bg-foreground-700 ui-open:text-notWhite"},r.createElement(ke.Z,{className:"h-6 w-6 transition-transform ui-open:rotate-180"}))),r.createElement(Ne.u,{as:r.Fragment,leave:"lg:transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0"},r.createElement(xe.R.Options,{className:"lg:cohost-shadow-light dark:lg:cohost-shadow-dark\n fixed bottom-0 right-0 top-16 z-10 max-w-xs divide-y divide-foreground-500\n !overflow-y-auto truncate bg-foreground text-notWhite !outline-none\n lg:absolute lg:bottom-auto lg:right-auto lg:top-auto lg:mt-6\n lg:max-h-[calc(100vh_-_100px)] lg:divide-none lg:rounded-lg lg:bg-notWhite lg:text-notBlack"},a.map((e=>r.createElement(Ie,{project:e,key:e.projectId}))))))):null};var Ae=a(78954);const Fe=()=>{const e=(0,Se.m)(),t=Ce().filter(e.projects,(e=>!!e.isSelfProject))[0],{control:a,handleSubmit:n}=(0,p.cI)({defaultValues:{projectId:t.projectId}}),o=m.S.users.changeSelfProject.useMutation();return r.createElement("div",{id:"main-page",className:c.hY},r.createElement("h4",{className:c.Kl},"change main page"),r.createElement("form",{onSubmit:n((async({projectId:e})=>{await o.mutateAsync({projectId:e})})),className:"flex flex-col gap-4"},r.createElement("p",{className:"prose"},'One of your pages on cohost is your "main page"; this is the page you see when you log in. Your main page can\'t be deleted, but is otherwise the same as the other pages you edit. Your main page is currently'," ",r.createElement("strong",null,"@",t.handle),"."),r.createElement(k.Z,{bigLabel:"change your main page to:",inputElement:r.createElement(p.Qr,{control:a,name:"projectId",render:({field:{onChange:e,value:t}})=>r.createElement(Le,{onChange:e,selectedProjectId:t})})}),r.createElement(Ae.A,{submitMutation:o,submitButtonLabel:"change main page"})))};var Oe=a(84879);function Re(){return Re=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Re.apply(this,arguments)}const _e=()=>{const e=(0,o.Pc)(),{register:t,handleSubmit:a,formState:{errors:n},trigger:l,control:s,watch:i}=(0,p.cI)({defaultValues:{confirmEmail:"",password:"",otp:""}}),u=m.S.users.scheduleDelete.useMutation(),d=i("confirmEmail");return r.createElement("div",{className:c.hY},r.createElement("form",{className:"flex flex-col gap-4",onSubmit:a((async t=>{if(!e.email)throw new Error("e-mail is null?");const a=e.email,n=await(0,ee.I)().login.getSalt.query({email:a}),o=await E.Z.hashPasswordInWorker(a,n.salt,t.password);await u.mutateAsync({confirmEmail:t.confirmEmail,clientHash:o,twoFactorToken:t.otp})}))},r.createElement("h4",{className:c.Kl},"delete account"),r.createElement("p",{className:"prose"},"If you'd like to delete this account, fill out the information below. We'll schedule its data to be permanently deleted in 3 days – to give you a chance to change your mind – but with no further action required from you. If you need to delete it sooner than that, please e-mail us at"," ",r.createElement("a",{href:"mailto:support@cohost.org"},"support@cohost.org")," ","and we can help you."),r.createElement(k.Z,{bigLabel:"confirm e-mail address",inputElement:r.createElement("div",{className:"flex flex-row items-center gap-2"},r.createElement(f.F,{trigger:l,name:"confirmEmail",control:s,type:"email",showValidity:!0}))}),r.createElement(k.Z,{bigLabel:"confirm your password",disabled:""===d,inputElement:r.createElement(f.F,{trigger:l,name:"password",control:s,type:"password",showValidity:!1,disabled:""===d})}),e.twoFactorActive?r.createElement(k.Z,{bigLabel:"confirm your 2fa code",disabled:""===d,inputElement:r.createElement(f.F,{trigger:l,name:"otp",control:s,type:"text",showValidity:!1,disabled:""===d})}):null,r.createElement(Ae.A,{submitMutation:u,submitButtonLabel:"schedule deletion"})))},De=()=>{const{register:e,handleSubmit:t}=(0,p.cI)({}),a=(0,o.Pc)(),n=m.S.users.cancelScheduledDelete.useMutation();return a.loggedIn?r.createElement("div",{className:c.hY},r.createElement("form",{onSubmit:t((async e=>{e.confirm&&await n.mutateAsync()})),className:"flex flex-col gap-4"},r.createElement("h4",{className:c.Kl},"cancel scheduled deletion"),r.createElement("p",{className:"prose"},"Your account is currently scheduled for deletion. At"," ",r.createElement("strong",null,a.deleteAfter.toLocaleString(Oe.ou.DATETIME_MED_WITH_WEEKDAY)),", the waiting period will expire and at our next scheduled maintenance less than 24 hours later, its data will be permanently deleted. If you've changed your mind, or didn't intend to request the account's deletion, you can cancel the deletion here."),r.createElement(k.Z,{bigLabel:"Please check this checkbox to confirm.",inputElement:r.createElement("input",Re({type:"checkbox"},e("confirm",{required:"You must check the checkbox to confirm."}),{className:"rounded-checkbox"}))}),r.createElement(Ae.A,{submitMutation:n,submitButtonLabel:"cancel deletion"}))):null},je=()=>(0,o.Pc)().deleteAfter?r.createElement(De,null):r.createElement(_e,null),Be=({user:e,hasModPermission:t,modMode:a})=>{const{activated:m}=(0,o.Pc)(),u=(0,n.dg)(),d=u?u.handle:"(unknown)";return r.createElement(r.Fragment,null,r.createElement(s.ql,{title:"settings"}),r.createElement("div",{className:"container mx-auto mt-16 grid w-full grid-cols-1 gap-16 lg:grid-cols-4"},r.createElement(ve.w3,null),r.createElement("div",{className:"cohost-shadow-light dark:cohost-shadow-dark prose invisible sticky top-32 order-3 mx-auto flex h-min w-full flex-col gap-4 rounded-lg bg-notWhite p-3 text-notBlack lg:visible"},r.createElement("strong",null,"what do you want to do?"),r.createElement("ul",null,r.createElement("li",null,r.createElement("a",{href:"#cohost-plus"},"manage my cohost plus subscription")),r.createElement("li",null,r.createElement("a",{href:"#password-email"},"change my password or e-mail address")),r.createElement("li",null,r.createElement("a",{href:"#main-page"},"change my main page")),r.createElement("li",null,r.createElement("a",{href:"#post-visibility"},"change what posts I see")),r.createElement("li",null,r.createElement("a",{href:"#post-display"},"change how content inside posts looks")),r.createElement("li",null,r.createElement("a",{href:"#ui-display"},"change how other parts of the site look")),r.createElement("li",null,r.createElement("a",{href:"#invites-activation"},"check activation queue/invites")),t?r.createElement("li",null,r.createElement("a",{href:"#staff-only"},"change staff-only settings")):null)),r.createElement("div",{className:"col-span-1 flex w-full flex-col gap-6 lg:col-span-2"},r.createElement(i.v,{level:"info",textSize:"base",className:"not-prose text-notBlack"},"you can change settings which apply to all your pages here. some settings are specific to one page; you can also ",r.createElement("a",{href:l.ZP.public.project.settings().toString(),className:"underline"},"edit @",d,"'s per-page settings"),"."),r.createElement(y,null),r.createElement(we,null),r.createElement(b,null),r.createElement(Fe,null),r.createElement(P,null),r.createElement(z,null),r.createElement("div",{className:c.hY},r.createElement("h4",{className:c.Kl},"silenced posts"),r.createElement("div",{className:"prose"},r.createElement("p",null,r.createElement("a",{href:l.ZP.public.silencedPosts({}).toString()},"manage your silenced posts")))),r.createElement(O,{user:e}),r.createElement(Y,null),m?r.createElement(_,null):r.createElement(B,null),r.createElement(je,null),t?r.createElement(j,{modMode:a}):null)))};Be.displayName="settings-main/page";var We=Be},78954:function(e,t,a){"use strict";a.d(t,{A:function(){return l}});var n=a(94159),o=a(6553);const l=e=>n.createElement("div",{className:"flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite"},e.submitMutation.isSuccess?n.createElement("p",{className:"text-green"},"saved!"):null,e.submitMutation.isError?n.createElement("p",{className:"text-red"},e.submitMutation.error.message):null,n.createElement(o.p,{type:"submit",disabled:e.submitMutation.isLoading,className:"font-bold"},e.submitButtonLabel))},48002:function(e,t,a){"use strict";a.d(t,{Kl:function(){return o},dO:function(){return l},hY:function(){return n},nk:function(){return r}});const n="cohost-shadow-light dark:cohost-shadow-dark mx-auto flex max-h-min w-full flex-col gap-4 rounded-lg bg-notWhite text-notBlack px-7 py-8",o="font-atkinson font-bold text-4xl",l="flex w-full flex-row items-center justify-end gap-4 font-bold text-notWhite",r="font-atkinson font-bold text-2xl pt-8"},16086:function(e,t,a){"use strict";a.d(t,{k:function(){return s}});var n=a(40438),o=a(84879),l=a(94159),r=a(62745);const s=({dateISO:e,link:t,className:a="block flex-none text-sm text-gray-500 dark:text-gray-300"})=>{const s=(0,r.Q)(),[i,c]=(0,l.useState)(o.ou.fromISO(e).toUTC()),m=s.beatsTimestamps?`${(u=i).setZone("UTC+1").toLocaleString(o.ou.DATE_MED)} ${(0,n.mI)(u,!0)}`:i.toLocaleString(o.ou.DATE_MED_WITH_WEEKDAY);var u;return(0,l.useEffect)((()=>{c((e=>e.toLocal()))}),[]),l.createElement("time",{dateTime:i.toISO(),className:a},t?l.createElement("a",{href:t.toString(),className:"hover:underline"},m):m)}},90040:function(){},66107:function(){},32465:function(){},51326:function(){},1088:function(){}}]);
|
||
//# sourceMappingURL=client-preact-components-pages-user-settings.41d3820dcc9ac54eddfa.js.map
|