import{Q as g,l as Ye,X as Le,O as Xe,w as z,o as Y,j as t,e as R,I as ge,T as u,W as we,Y as se,Z as Ce,B,z as Ne,c as Be,$ as Fe,M as Ue,V as He,G as Me,a0 as Oe,m as Qe,f as ne,h as ee,r as qe,H as Ge,a1 as ye,d as Ke,a2 as Ze,t as Je,b as et,u as tt,v as st,a3 as it}from"./index-CmAiVN5e.js";import{a as fe,r as x}from"./vendor-animations-CsoOZIH8.js";import{B as at}from"./BaseLayout-BRoSNw-D.js";import{F as nt}from"./FormErrors-BZl-rKjZ.js";import{P as rt,i as me}from"./inMemoryDonator-E61LAVRP.js";import{V as ue}from"./types-wqI8I_vQ.js";import{D as ot}from"./DonationPage-CJ2-r8Nc.js";import{B as lt}from"./BrandingBackdrop-F-eQl6Oa.js";import{D as ct,P as dt,a as ht}from"./DonationAmountInput-DkFMRVaf.js";import{D as mt}from"./DropdownInput-BXbsCoN-.js";import{T as k}from"./TextInput-wB5aOs8O.js";import{U as ut}from"./UploadImageInput-csl6S7Ki.js";import{S as re}from"./SocialInput-DnglycEE.js";import{C as pt}from"./CheckboxInput-D8AUT0rU.js";import{Q as Se}from"./quiz.constants-CEchFP8r.js";import{A as gt}from"./AIAssistant-DcaMrhdT.js";import{g as pe}from"./getNumberFormat-D9eLFqYV.js";import{S as ft,r as xt,P as _t}from"./SafeCodeInput-DlViI1Qb.js";import{u as bt}from"./useQuery-ver6bBcI.js";import{W as vt}from"./WallsService-BUXK93Tu.js";import{w as Dt}from"./withOnFirstError-hAsdbznp.js";import"./useJivoExternalScript-yyZ--K1Q.js";import"./DonationVoice-fPbifzja.js";import"./getSocialFormat-CDK45c1l.js";import"./DonationFooter-Cr75uiIU.js";import"./inputmask-Cr-e3LsO.js";import"./pluralize-BqhPSiJS.js";import"./validators-3vU18RTh.js";import"./TextInput-Do8kQcsL.js";import"./copyToClipboard-C3humaIY.js";class At{constructor(e){this._pageId="",this.amountRef=fe.createRef(),this._name="",this._amount="",this._activity=g.Message,this._actionId="",this._message="",this._image="",this._videoLink="",this._firstVariant="",this._secondVariant="",this._thirdVariant="",this._isAddedVariant=!1,this._about="",this._telegram="",this._youtube="",this._twitch="",this._vk="",this._isPermissionToShow=!1,this._isTTSEnable=!1,this._voiceId=0,this._isTgEnable=!1,this._isAIEnabled=!1,this._isSafeEnable=!1,this._safeCode=[],this._safeEmail="",this._isWonderEnable=!1,this._wonderWord=[],this._isWallEnableForm=!1,this._wallData=null,this._paymentId=rt.Russia,this._minAmountDonation="",this._minAmountDonationMultiplier=1,this.errors=new nt,this.setPaymentId=s=>{this._paymentId=s},Ye(this),this._pageId=e}get isDisabled(){return!this.isValid}get pageId(){return this._pageId}get name(){return this._name}get amount(){return this._amount}get amountValue(){return Number(this._amount).valueOf()}get paymentId(){return this._paymentId}get activity(){return this._activity}get actionId(){return this._actionId}get isTTSEnable(){return this._isTTSEnable}get voiceId(){return this._voiceId}get isTgEnable(){return this._isTgEnable}get message(){return this._message}get videoLink(){return this._videoLink}get firstVariant(){return this._firstVariant}get secondVariant(){return this._secondVariant}get thirdVariant(){return this._thirdVariant}get isAddedVariant(){return this._isAddedVariant}get image(){return this._image?Le(this._image,300):""}get about(){return this._about}get youtube(){return this._youtube}get telegram(){return this._telegram}get vk(){return this._vk}get isPermissionToShow(){return this._isPermissionToShow}get isSuperDonate(){return this.activity>=g.Vote}get isAction(){return this.activity===g.Action}get isValid(){return!!this.paymentId&&!!this.name.trim()&&!!this.amountValue&&this.isValidDetails}get isTTSAvailable(){return!this.isSuperDonate}get isAIAvailable(){return!this.isSuperDonate}get isSafeAvailable(){return!this.isSuperDonate}get isWonderAvailable(){return!this.isSuperDonate}get isValidDetails(){const e=this._message.trim();switch(this._activity){case g.Action:case g.Message:const s=this._isSafeEnable?!!this._safeEmail.trim()&&this._safeCode.every(c=>!!c):!0,r=this._isWonderEnable?!!this._safeEmail.trim()&&this._wonderWord.every(c=>!!c):!0,l=this._isWallEnableForm?!!this._wallData:!0;return s&&r&&l;case g.Quiz:return!1;case g.EmotionsControl:return!0;case g.Vote:return!!e&&!!this._firstVariant.trim()&&!!this._secondVariant.trim();case g.ViewerRate:return!!e&&!!this._firstVariant.trim()&&!!this._secondVariant.trim()&&!!this._image;case g.StreamerRate:return!!e&&!!this._image;case g.Advertising:return!!e&&!!this._about.trim()&&!!this._image;case g.QuestionAnswer:return!!e&&!!this._image;case g.StreamerHaveTo:return!!this._firstVariant.trim()&&!!this._secondVariant.trim();default:return!1}}get minAmount(){return this.isSuperDonate||this.isAction?this.amountValue:Number(this._minAmountDonation)*this._minAmountDonationMultiplier}get maxAmount(){return Xe}get isAIEnabled(){return this._isAIEnabled}get isSafeEnable(){return this._isSafeEnable}get isWonderEnable(){return this._isWonderEnable}get safeCode(){return this._safeCode}get safeEmail(){return this._safeEmail}get wonderWord(){return this._wonderWord}get isWallEnableForm(){return this._isWallEnableForm}get wallData(){return this._wallData}setMinAmountDonationMultiplier(e){this._minAmountDonationMultiplier=e}setName(e){this._name=e}setAmount(e){this._amount=e}setActivity(e){this._activity=e.typeId,this._actionId="",this._amount=e.price||"0"}setAction(e){this._activity=g.Action,this._actionId=e.id,this._amount=e.price}setMessage(e){this._message=e}setVideoLink(e){this._videoLink=e}setMinAmountDonation(e){this._minAmountDonation=e}setFirstVariant(e){this._firstVariant=e}setSecondVariant(e){this._secondVariant=e}setThirdVariant(e){this._thirdVariant=e}setAddedVariant(e){this._isAddedVariant=e}setPermissionToShow(e){this._isPermissionToShow=e}setAbout(e){this._about=e}setTelegram(e){this._telegram=e}setVk(e){this._vk=e}setYoutube(e){this._youtube=e}setImage(e){this._image=e}setTTSEnable(e){this._isTTSEnable=e}setVoiceId(e){this._voiceId=e}setTgEnable(e){this._isTgEnable=e}setAIEnabled(e){this._isAIEnabled=e}setSafeEnable(e){this._isSafeEnable=e}setWonderEnable(e){this._isWonderEnable=e}initSafeCode(e){this._safeCode=Array.from({length:e},()=>"")}setSafeCode(e,s){e<this._safeCode.length&&(this._safeCode[e]=s)}setSafeEmail(e){this._safeEmail=e}initWonderWord(e){this._wonderWord=Array.from({length:e},()=>"")}setWonderWord(e,s){e<this._wonderWord.length&&(this._wonderWord[e]=s)}setIsWallEnableForm(e){this._isWallEnableForm=e}setWallData(e){this._wallData=e}resetDetails(){this.clear()}syncErrors(){this.errors.setError("message",""),this.errors.setError("about",""),this.errors.setError("image",""),this.errors.setError("firstVariant",""),this.errors.setError("secondVariant",""),this.errors.setError("name",""),this.errors.setError("amount","")}clear(){this._actionId="",this._message="",this._about="",this._firstVariant="",this._secondVariant="",this._thirdVariant="",this._image="",this._videoLink="",this._isAddedVariant=!1,this._isPermissionToShow=!1,this._isAIEnabled=!1,this._isTTSEnable=!1,this._isSafeEnable=!1,this._isWonderEnable=!1,this._safeCode=[],this._safeEmail="",this.syncErrors()}export(e,s){const r=this.isTTSAvailable&&this.isTTSEnable&&this.voiceId>ue?{isTTSEnable:!0,voiceId:this.voiceId}:{isTTSEnable:!1},l=this.isSafeAvailable&&this.isSafeEnable?{isSafeEnabled:!0,safeEmail:this.safeEmail,safeCode:this.safeCode.join("")}:{isSafeEnabled:!1},c=this.isWonderAvailable&&this.isWonderEnable?{isWonderEnabled:!0,safeEmail:this.safeEmail,wonderWord:this.wonderWord.join("")}:{isWonderEnabled:!1};this._isWallEnableForm&&this._wallData&&this._wallData;const a={donatorName:this._name,amount:this._amount,paymentId:this._paymentId,currency:"rub",pageId:this._pageId,anotherData:{},isAIEnabled:this._isAIEnabled,...r,...l,...c,...e};return this._isWallEnableForm&&this._wallData&&(a.anotherData.wall={...this._wallData}),s!=null&&s.quizCategoryId&&(a.quizCategoryId=s==null?void 0:s.quizCategoryId),a.typeId=this._activity,this._activity===g.Action&&(a.typeId=g.Message,a.actionId=this._actionId),a.message=this._message,this._image&&(a.image=this._image),this._firstVariant&&this._secondVariant&&(a.voting={firstVariant:this._firstVariant,secondVariant:this._secondVariant},this._thirdVariant.trim()&&(a.voting.thirdVariant=this._thirdVariant)),this._activity===g.StreamerRate&&(a.isPermissionToShow=this._isPermissionToShow),this._activity===g.Advertising&&(a.anotherData.ad={about:this._about,socials:{}},this._telegram&&(a.anotherData.ad.socials.telegram=this._telegram),this._vk&&(a.anotherData.ad.socials.vk=this._vk),this._youtube&&(a.anotherData.ad.socials.youtube=this._youtube)),this._videoLink&&(a.videoLink=this._videoLink),a}}const oe="donation-activities",jt=i=>{const e=!!i.page.actions.length||!!i.page.activities.length,s=a=>{i.form.resetDetails(),i.form.setActivity(a)},r=a=>{i.form.resetDetails(),i.form.setAction(a)},l=()=>t.jsx(t.Fragment,{children:i.page.activities.map(a=>t.jsxs("div",{className:`${oe}__item`,"aria-selected":a.typeId===i.form.activity,role:"radio",onClick:()=>s(a),children:[t.jsx(ge,{type:"superDonate"}),t.jsx(u,{size:"s",color:"primary",tag:"span",children:i.page.getActivityNameById(a.typeId)}),t.jsx(u,{size:"s",color:"primary",tag:"span",children:we(Number(a.price).valueOf())})]},a.typeId))}),c=()=>t.jsx(t.Fragment,{children:i.page.actions.map(a=>t.jsxs("div",{className:`${oe}__item`,"aria-selected":a.id===i.form.actionId,role:"radio",onClick:()=>r(a),children:[t.jsx(u,{size:"s",color:"primary",tag:"span",children:a.name}),t.jsx(u,{size:"s",color:"primary",tag:"span",children:we(Number(a.price).valueOf())})]},a.id))});return e?t.jsxs("div",{className:oe,children:[t.jsx(R,{value:i.t("sendDonation:form:activities"),size:"xs"}),c(),l()]}):null},wt=z()(Y(jt)),yt=i=>{const[e,s]=x.useState(ue),r=x.useMemo(()=>{const h=i.voices.map(m=>({alias:m.id,icon:m.icon,title:`${m.name} ${m.priceValue>0?`(+${m.priceValue} ${i.t("general:rub:short")})`:""}`}));return h.push({alias:ue,icon:"male",title:i.t("general:withoutVoice")}),h},[i.voices]),l=i.voices.find(h=>h.id===i.currentVoice),c=h=>{i.onChange(h),s(h.alias)},a=()=>i.isAutoplay&&l&&l.id===e?t.jsx("audio",{src:l.example,autoPlay:!0}):null;return t.jsxs(fe.Fragment,{children:[a(),t.jsx(mt,{title:i.title,allVariants:r,currentVariant:i.currentVoice,onChange:c,isDisabled:i.isDisabled,iconColor:"brand"})]})},St=z()(yt),N="activity-details",Ee=20;class Et extends x.Component{constructor(e){super(e),this.setMessage=s=>this.props.form.setMessage(s),this.setVideoLink=s=>this.props.form.setVideoLink(s),this.setAbout=s=>this.props.form.setAbout(s),this.setPermissionToShow=s=>this.props.form.setPermissionToShow(s.target.checked),this.setImage=s=>{if(s){this.handleUploadImage(s);return}this.props.form.setImage("")},this.onChangeAIEnable=s=>this.props.form.setAIEnabled(s),this.onChangeVoiceId=s=>this.props.form.setVoiceId(s.alias),this.setFirstVariant=s=>{this.props.form.setFirstVariant(s)},this.setSecondVariant=s=>{this.props.form.setSecondVariant(s)},this.setThirdVariant=s=>this.props.form.setThirdVariant(s),this.setTelegram=s=>this.props.form.setTelegram(s),this.setVk=s=>this.props.form.setVk(s),this.setYoutube=s=>this.props.form.setYoutube(s)}handleUploadImage(e){return this.props.store.uploadDonationImage(this.props.form.pageId,e).then(s=>this.props.form.setImage(s))}render(){return t.jsxs("div",{className:N,children:[this.renderContent(),this.renderTTS(),this.renderAI()]})}renderAI(){var r;const{t:e}=this.props;if(((r=this.props.page.ai)==null?void 0:r.isEnabled)&&this.props.form.isAIAvailable){const l=this.props.form.amountValue<Number(this.props.page.ai.minAmount).valueOf(),c=pe(Number(this.props.page.ai.price),{minimumFractionDigits:0,maximumFractionDigits:2}),a=pe(Number(this.props.page.aiMinAmount),{minimumFractionDigits:0,maximumFractionDigits:2});return t.jsxs("div",{className:`${N}__ai-assistant`,children:[t.jsx(se,{isChecked:this.props.form.isAIEnabled,isDisabled:l,onChange:this.onChangeAIEnable,text:`${e("sendDonation:aiAssistant")} (${e("general:from")} ${a} ${e("general:rub:short")})`}),this.props.form.isAIEnabled?t.jsxs("div",{className:`${N}__ai-character`,children:[t.jsx(gt,{avatar:this.props.page.ai.image,size:48}),t.jsx(u,{size:"m",color:"primary",bold:"700",children:`${e("sendDonation:aiCharacter")} — ${this.props.page.ai.name} (+ ${c} ${e("general:rub:short")})`})]}):null]})}return null}renderTTS(){const{t:e}=this.props;return this.props.page.isTTSEnable&&this.props.form.isTTSAvailable?t.jsx(St,{isAutoplay:!0,title:e("sendDonation:voiceTitle"),voices:this.props.page.voices,currentVoice:this.props.form.voiceId,onChange:this.onChangeVoiceId,isDisabled:!this.props.form.isTTSEnable}):null}renderContent(){switch(this.props.form.activity){case g.Quiz:return this.renderQuizDetails();case g.EmotionsControl:return this.renderEmotionsControlDetails();case g.Vote:return this.renderVoteDetails();case g.StreamerRate:return this.renderStreamerRate();case g.ViewerRate:return this.renderViewerRate();case g.Advertising:return this.renderAdvertising();case g.StreamerHaveTo:return this.renderStreamerHaveTo();case g.QuestionAnswer:return this.renderQuestionAnswer();default:return this.renderMessageDetails()}}renderMessageDetails(){const{t:e}=this.props;return t.jsxs(t.Fragment,{children:[this.renderMessage(e("sendDonation:details:message:title"),e("sendDonation:details:message:placeholder"),249),this.renderVideoLink()]})}renderQuizDetails(){const{t:e}=this.props;return t.jsxs("div",{className:`${N}__content`,children:[t.jsx(u,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:quiz:text")}),t.jsx(Ce,{title:e("sendDonation:details:quiz:selectCategory"),children:t.jsx("div",{className:`${N}__quiz-categories`,children:this.props.page.quizCategories.map(s=>s&&Se[s]?t.jsx(B,{size:"s",theme:"secondary",text:Se[s],onClick:()=>this.props.onQuizCategoryClick(s),isDisabled:!this.props.form.name.trim()},s):null)})})]})}renderEmotionsControlDetails(){const{t:e}=this.props;return t.jsxs("div",{className:`${N}__content`,children:[t.jsx(u,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:emotionsControl:text1")}),t.jsx(u,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:emotionsControl:text2")})]})}renderVoteDetails(){const{t:e}=this.props;return t.jsxs(t.Fragment,{children:[this.renderMessage(e("sendDonation:details:question:title"),e("sendDonation:details:question:placeholder"),50),this.renderVariants(e("sendDonation:details:options"),["Twitch","Youtube",""],Ee)]})}renderStreamerRate(){const{t:e}=this.props;return t.jsxs(t.Fragment,{children:[this.renderMessage(e("sendDonation:details:rate:title"),e("sendDonation:details:rate:placeholder"),50),this.renderImage(e("sendDonation:details:image:rate"),e("sendDonation:details:image:rateHint")),t.jsx(pt,{allVariants:[{id:"permissionToShow",title:e("sendDonation:details:streamerRate:permissionToShow")}],currentVariants:this.props.form.isPermissionToShow?["permissionToShow"]:[],onChangeVariant:this.setPermissionToShow})]})}renderViewerRate(){const{t:e}=this.props;return t.jsxs(t.Fragment,{children:[this.renderMessage(e("sendDonation:details:rate:title"),e("sendDonation:details:rate:placeholder"),50),this.renderImage(e("sendDonation:details:image:rate"),e("sendDonation:details:image:rateHint")),this.renderVariants(e("sendDonation:details:streamerRate:options"),[e("sendDonation:details:streamerRate:option1"),e("sendDonation:details:streamerRate:option2"),""],Ee)]})}renderAdvertising(){const{t:e}=this.props;return t.jsxs(t.Fragment,{children:[this.renderMessage(e("sendDonation:details:advertising:message:title"),e("sendDonation:details:advertising:message:placeholder"),50),this.renderAbout(),this.renderImage(e("sendDonation:details:image:photo"),e("sendDonation:details:image:photoHint")),this.renderSocials(e("sendDonation:details:advertising:socials:title"))]})}renderStreamerHaveTo(){const{t:e}=this.props;return t.jsxs("div",{className:`${N}__variants`,children:[t.jsx(u,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:streamerHaveTo:title")}),t.jsx(u,{size:"s",color:"primary",isMarginDisabled:!0,children:e("sendDonation:details:streamerHaveTo:text")}),this.renderVariants("",[e("sendDonation:details:streamerRate:option1"),e("sendDonation:details:streamerRate:option2")],38)]})}renderQuestionAnswer(){const{t:e}=this.props;return t.jsxs("div",{className:N,children:[this.renderMessage(e("sendDonation:details:question:title"),e("sendDonation:details:questionAnswer:placeholder"),50,e("sendDonation:details:questionAnswer:hint")),this.renderImage(e("sendDonation:details:image:question"),e("sendDonation:details:image:questionHint"))]})}renderMessage(e,s,r,l){return t.jsx(k,{type:"text",value:this.props.form.message,title:e,placeholder:s,isMultiline:!0,maxLength:r,hintText:l,onChange:this.setMessage})}renderVideoLink(){const{t:e}=this.props;return t.jsx(k,{title:e("sendDonation:videoLink"),placeholder:"https://www.youtube.com/",iconPosition:"right",icon:"link",type:"text",value:this.props.form.videoLink,onChange:this.setVideoLink})}renderAbout(){const{t:e}=this.props;return t.jsx(k,{type:"text",value:this.props.form.about,isMultiline:!0,title:e("sendDonation:details:advertising:about:title"),placeholder:e("sendDonation:details:advertising:about:placeholder"),maxLength:165,onChange:this.setAbout})}renderImage(e,s){return t.jsx(ut,{image:this.props.form.image,title:e,onChange:this.setImage,onDelete:this.setImage,errorText:this.props.form.errors.getErrorBy("image"),hintText:s})}renderVariants(e,s,r){const{t:l}=this.props,c=s.length===3;return t.jsxs("div",{className:`${N}__variants`,children:[t.jsx(k,{title:e,placeholder:s[0],value:this.props.form.firstVariant,onChange:this.setFirstVariant,maxLength:r}),t.jsx(k,{placeholder:s[1],value:this.props.form.secondVariant,onChange:this.setSecondVariant,maxLength:r}),this.props.form.isAddedVariant?t.jsx(k,{placeholder:"",value:this.props.form.thirdVariant,onChange:this.setThirdVariant,maxLength:r}):c?t.jsx(B,{size:"m",theme:"link",text:l("sendDonation:details:more"),icon:"add",iconPosition:"left",onClick:()=>this.props.form.setAddedVariant(!0)}):null]})}renderSocials(e){return t.jsxs("div",{className:`${N}__variants`,children:[t.jsx(re,{inputVersion:2,type:"telegram",setValue:this.setTelegram,value:this.props.form.telegram,title:e}),t.jsx(re,{inputVersion:2,type:"vk",setValue:this.setVk,value:this.props.form.vk}),t.jsx(re,{inputVersion:2,type:"youtube",setValue:this.setYoutube,value:this.props.form.youtube})]})}}const It=z()(Y(Et)),te="safe-details",Vt=i=>{var m;const{t:e}=Ne();if(!i.page.isSafeEnable||!i.form.isSafeAvailable)return null;const s=Math.max(i.page.safeMinAmount,i.form.minAmount),r=i.form.amountValue<s,l=((m=i.page.safe)==null?void 0:m.codeLength)||0,c=`${e("sendDonation:safeBlock:activate")} (${e("general:from")} ${s} ${e("general:rub:short")})`,a=()=>t.jsxs("div",{className:`${te}__header`,children:[t.jsxs("div",{className:`${te}__info`,children:[t.jsx(R,{size:"xs",children:e("sendDonation:safeBlock:title")}),t.jsx(u,{size:"s",color:"primary",children:e("sendDonation:safeBlock:text")})]}),t.jsx(se,{isChecked:i.form.isSafeEnable,isDisabled:r,onChange:v=>{i.form.initSafeCode(l),i.form.setSafeEnable(v)},text:c})]}),h=()=>i.form.isSafeEnable?t.jsxs("div",{className:`${te}__content`,children:[t.jsx(ft,{size:"s",codeLength:l,code:i.form.safeCode,setCode:(v,D)=>i.form.setSafeCode(v,D),title:e("sendDonation:safeBlock:code"),hintText:e("sendDonation:safeBlock:hint")}),t.jsx(k,{icon:"mail",iconPosition:"right",type:"email",name:"email",title:e("sendDonation:safeBlock:email:title"),placeholder:e("sendDonation:safeBlock:email:placeholder"),value:i.form.safeEmail,onChange:v=>i.form.setSafeEmail(v)})]}):null;return t.jsxs("div",{className:te,children:[a(),h(),t.jsx(ge,{type:"safe"})]})},Tt=Y(Vt),Ie="wonder-code-input",Ct=i=>{const e=i.wordLength,s=(l,c)=>(i.setWord(l,c.toUpperCase()),!0),r=()=>t.jsx("div",{className:`${Ie}__word`,children:xt(0,e).map((l,c)=>t.jsx(Fe,{children:()=>{var a;return t.jsx(_t,{customPrefix:"wonderWordPinField_",index:c,placeholder:"*",value:(a=i.word)==null?void 0:a[c],setValue:h=>s(c,h),borderColor:"secondary",type:"letter",autoFocus:c===0,size:"s",ariaRequired:!0})}},c))});return t.jsx(Ce,{className:Be(Ie),title:i.title,hintText:i.hintText,withHintIcon:!0,children:r()})},G="wonder-details",Nt=i=>{var v;const{t:e}=Ne();if(!i.page.isWonderEnable||!i.form.isWonderAvailable)return null;const s=Math.max(i.page.wonderMinAmount,i.form.minAmount),r=i.form.amountValue<s,l=((v=i.page.wonder)==null?void 0:v.wordLength)||0,c=`${e("sendDonation:wonderBlock:activate")} (${e("general:from")} ${s} ${e("general:rub:short")})`,a=()=>t.jsxs("div",{className:`${G}__header`,children:[t.jsxs("div",{className:`${G}__info`,children:[t.jsx(R,{size:"xs",children:e("sendDonation:wonderBlock:title")}),t.jsx(u,{size:"s",color:"primary",children:e("sendDonation:wonderBlock:text")})]}),t.jsx(se,{isChecked:i.form.isWonderEnable,isDisabled:r,onChange:D=>{i.form.initWonderWord(l),i.form.setWonderEnable(D)},text:c})]}),h=()=>{var D;return i.form.isWonderEnable?t.jsxs("div",{className:`${G}__content`,children:[t.jsx(Ct,{wordLength:l,word:i.form.wonderWord,setWord:(M,F)=>i.form.setWonderWord(M,F),title:e("sendDonation:wonderBlock:word"),hintText:e("sendDonation:wonderBlock:hint")}),t.jsxs(u,{size:"m",color:"brand",bold:"700",children:[e("sendDonation:wonderBlock:clueWord")," ",((D=i.page.wonder)==null?void 0:D.hint)??""]}),t.jsx(k,{icon:"mail",iconPosition:"right",type:"email",name:"email",title:e("sendDonation:wonderBlock:email:title"),placeholder:e("sendDonation:wonderBlock:email:placeholder"),value:i.form.safeEmail,onChange:M=>i.form.setSafeEmail(M)})]}):null},m=t.jsxs("div",{className:`${G}__wonder-label`,children:[t.jsx("div",{children:t.jsx(R,{size:"l",color:"white",children:"C"})}),t.jsx("div",{}),t.jsx("div",{})]});return t.jsxs("div",{className:G,children:[a(),h(),m]})},Mt=Y(Nt),kt=({isOpen:i,onClose:e,form:s,page:r})=>{const l=x.useRef(null),c=x.useRef(null),[a,h]=x.useState(1),[m,v]=x.useState({x:0,y:0}),[D,M]=x.useState("select"),[F,xe]=x.useState(!1),[K,H]=x.useState("none"),[A,ke]=x.useState(null),[d,Z]=x.useState(null),{data:U}=bt({queryKey:["wall",r.login],queryFn:()=>vt.getWallByNickname(r.login||"").then(n=>{const o=n.data;return o.wall?o:o.data}),enabled:i&&!!r.login}),_=U==null?void 0:U.wall,_e=(U==null?void 0:U.items)||[],be=n=>{if(!c.current)return{x:0,y:0};const o=c.current.getBoundingClientRect(),b=Math.floor((n.clientX-o.left)/a),p=Math.floor((n.clientY-o.top)/a);return{x:b,y:p}},ve=(n,o,b,p)=>{const f=Math.min(n,b),w=Math.min(o,p),V=Math.max(n,b),j=Math.max(o,p);return{x:f,y:w,w:V-f+1,h:j-w+1}},O=n=>_e.some(o=>n.x<o.x+o.width&&n.x+n.w>o.x&&n.y<o.y+o.height&&n.y+n.h>o.y),We=n=>{var b;if(n.currentTarget.setPointerCapture(n.pointerId),xe(!0),n.button===1){n.preventDefault(),H("pan");return}const o=n.target;if((b=o.classList)!=null&&b.contains("selection-handle")&&d){const p=o.classList.contains("top-left"),f=Math.min(d.startX,d.currentX),w=Math.min(d.startY,d.currentY),V=Math.max(d.startX,d.currentX),j=Math.max(d.startY,d.currentY);Z({startX:p?V:f,startY:p?j:w,currentX:p?f:V,currentY:p?w:j}),H("resize"),M("select");return}if(D==="select"){const{x:p,y:f}=be(n);if(o.closest(".wall-selector-modal__selection-box")&&d){H("move"),ke({mouseX:p,mouseY:f,startX:d.startX,startY:d.startY,currentX:d.currentX,currentY:d.currentY});return}if(O({x:p,y:f,w:1,h:1}))return;const w=(_==null?void 0:_.width)||3840,V=(_==null?void 0:_.height)||2160,j=Math.max(0,Math.min(p,w-1)),T=Math.max(0,Math.min(f,V-1));Z({startX:j,startY:T,currentX:j,currentY:T}),H("create")}},Pe=n=>{if(F){if(D==="pan"||K==="pan"){v(o=>({x:o.x+n.movementX,y:o.y+n.movementY}));return}if(D==="select"&&d){const{x:o,y:b}=be(n),p=(_==null?void 0:_.width)||3840,f=(_==null?void 0:_.height)||2160;if(K==="move"&&A){const j=o-A.mouseX,T=b-A.mouseY,y=Math.abs(A.currentX-A.startX)+1,W=Math.abs(A.currentY-A.startY)+1,C=Math.min(A.startX,A.currentX),P=Math.min(A.startY,A.currentY);let E=0,L=Math.sign(j);for(let Q=0;Q<Math.abs(j);Q++){let q=E+L,X=C+q;if(X<0||X+y>p||O({x:X,y:P,w:y,h:W}))break;E=q}let S=0,ze=Math.sign(T);for(let Q=0;Q<Math.abs(T);Q++){let q=S+ze,X=P+q;if(X<0||X+W>f||O({x:C+E,y:X,w:y,h:W}))break;S=q}const Ae=A.startX<=A.currentX,je=A.startY<=A.currentY;Z({startX:Ae?C+E:C+E+y-1,startY:je?P+S:P+S+W-1,currentX:Ae?C+E+y-1:C+E,currentY:je?P+S+W-1:P+S});return}const w=Math.max(0,Math.min(o,p-1)),V=Math.max(0,Math.min(b,f-1));if(K==="create"||K==="resize"){const j=d.startX,T=d.startY;let y=d.currentX,W=Math.sign(w-d.currentX);for(let E=0;E<Math.abs(w-d.currentX);E++){let L=y+W,S=ve(j,T,L,d.currentY);if(S.w*S.h>2e5||O(S))break;y=L}let C=d.currentY,P=Math.sign(V-d.currentY);for(let E=0;E<Math.abs(V-d.currentY);E++){let L=C+P,S=ve(j,T,y,L);if(S.w*S.h>2e5||O(S))break;C=L}Z({...d,currentX:y,currentY:C});return}}}},ie=n=>{xe(!1),H("none"),n.currentTarget.releasePointerCapture(n.pointerId)},ae=(n,o,b)=>{if(n===a)return;let p=o,f=b;if(p===void 0||f===void 0)if(l.current){const y=l.current.getBoundingClientRect();p=y.width/2,f=y.height/2}else p=0,f=0;const w=(p-m.x)/a,V=(f-m.y)/a,j=p-w*n,T=f-V*n;h(n),v({x:j,y:T})},$e=n=>{if(n.preventDefault(),!l.current)return;const o=l.current.getBoundingClientRect(),b=n.clientX-o.left,p=n.clientY-o.top,f=Math.max(.1,Math.min(a-n.deltaY*.002,10));ae(f,b,p)},I=(()=>{if(!d)return null;const n=Math.min(d.startX,d.currentX),o=Math.min(d.startY,d.currentY),b=Math.max(d.startX,d.currentX),p=Math.max(d.startY,d.currentY),f=b-n+1,w=p-o+1;return{x:n,y:o,w:f,h:w}})(),De=I?I.w*I.h:0;let J=De;J<Number(r.minAmountWall)&&(J=Number(r.minAmountWall));const Re=()=>{if(!I){alert("Сначала выделите учаÑток на Ñтене!");return}s.setIsWallEnableForm(!0),s.setWallData(I),s.setAmount(String(J)),e()};return t.jsxs(Ue,{open:i,onClose:e,center:!0,classNames:{modal:"wall-selector-modal",overlay:"wall-selector-overlay",modalContainer:"wall-selector-container"},showCloseIcon:!1,children:[t.jsxs("div",{className:"wall-selector-modal__header",children:[t.jsxs("div",{className:"wall-selector-modal__header-left",children:[r.avatar&&t.jsx("img",{src:r.avatar,alt:"avatar",className:"wall-selector-modal__avatar"}),t.jsx(R,{value:r.username||r.login||"",size:"m"})]}),t.jsx("div",{className:"wall-selector-modal__header-right",children:t.jsx(u,{size:"m",color:"secondary",children:"Выделите учаÑток «Стены» под Ñвой риÑунок"})})]}),t.jsxs("div",{className:"wall-selector-modal__layout",children:[t.jsxs("div",{className:"wall-selector-modal__toolbar",children:[t.jsx("button",{className:"tool-btn",title:"Увеличить",onClick:()=>ae(Math.min(a+.5,10)),children:"+"}),t.jsx("button",{className:"tool-btn",title:"Уменьшить",onClick:()=>ae(Math.max(a-.5,.1)),children:"-"}),t.jsx("button",{className:`tool-btn ${D==="pan"?"active":""}`,title:"Перемещение холÑта",onClick:()=>M("pan"),children:"ðŸ–"}),t.jsx("button",{className:`tool-btn ${D==="select"?"active":""}`,title:"Выделение/Перемещение облаÑти",onClick:()=>M("select"),children:"🔲"})]}),t.jsx("div",{className:"wall-selector-modal__workspace",onWheel:$e,children:t.jsxs("div",{className:"wall-selector-modal__viewport",ref:l,onPointerDown:We,onPointerMove:Pe,onPointerUp:ie,onPointerLeave:ie,onPointerCancel:ie,onDragStart:n=>n.preventDefault(),onMouseDown:n=>{n.button===1&&n.preventDefault()},children:[t.jsxs("div",{className:"wall-selector-modal__canvas-wrapper",ref:c,style:{width:(_==null?void 0:_.width)||3840,height:(_==null?void 0:_.height)||2160,transform:`translate(${Math.round(m.x)}px, ${Math.round(m.y)}px) scale(${a})`,transformOrigin:"0 0"},children:[t.jsx("div",{className:"wall-selector-modal__canvas-bg"}),_e.map(n=>{const o=!!n.imageUrl,b=o?`/images/donations/${n.imageUrl}`:void 0;return t.jsx("div",{style:{position:"absolute",left:`${n.x}px`,top:`${n.y}px`,width:`${n.width}px`,height:`${n.height}px`,boxSizing:"border-box",pointerEvents:"none",zIndex:1,backgroundColor:o?"transparent":"rgba(255, 255, 255, 0.1)",border:o?"none":"1px dashed rgba(255, 255, 255, 0.3)"},children:o&&t.jsx("img",{src:b,className:"wall-selector-modal__item-img",alt:"wall item",draggable:!1})},n.id)}),t.jsx("div",{className:"wall-selector-modal__interaction-layer",style:{cursor:D==="pan"?F?"grabbing":"grab":"crosshair"}})]}),I&&t.jsxs("div",{className:"wall-selector-modal__selection-box",style:{left:Math.round(I.x*a+m.x),top:Math.round(I.y*a+m.y),width:Math.round(I.w*a),height:Math.round(I.h*a),boxSizing:"border-box",zIndex:10,borderWidth:"2px",cursor:D==="select"?"move":void 0,pointerEvents:D==="select"?"auto":"none"},children:[t.jsx("div",{className:"selection-handle top-left",style:{top:0,left:0,width:"10px",height:"10px",transform:"translate(-50%, -50%)"}}),t.jsx("div",{className:"selection-handle bottom-right",style:{bottom:0,right:0,width:"10px",height:"10px",transform:"translate(50%, 50%)"}}),t.jsxs("div",{className:"selection-label",style:{top:"100%",right:"-10px",marginTop:"8px"},children:[I.w," x ",I.h,"px"]})]})]})})]}),t.jsxs("div",{className:"wall-selector-modal__footer",children:[t.jsxs("div",{className:"wall-selector-modal__cost-info",children:["✓ Ð’Ñ‹ выбрали ",De.toLocaleString("ru-RU")," пикÑелей, ваш донат – ",J.toLocaleString("ru-RU")," рублей"]}),t.jsxs("div",{className:"wall-selector-modal__actions",children:[t.jsx(B,{theme:"accent",size:"m",text:"Продолжить",onClick:Re}),t.jsx(B,{theme:"secondary",size:"m",text:"Отмена",onClick:e})]})]})]})},Wt=Y(({page:i,form:e})=>{const[s,r]=x.useState(!1);if(!i.isWallEnabled)return null;const l=Math.max(Number(i.minAmountWall)||0,e.minAmount),c=e.amountValue<l;return t.jsxs("div",{className:"wall-details",children:[t.jsxs("div",{className:"wall-details__top",children:[t.jsxs("div",{className:"wall-details__info",children:[t.jsx(R,{value:"Стена",size:"s"}),t.jsx(u,{size:"m",color:"secondary",className:"wall-details__desc",children:"ОÑтавь навÑегда Ñвой Ñлед на Ñтене у Ñтримера!"}),t.jsx("div",{className:"wall-details__switch",children:t.jsx(se,{isChecked:e.isWallEnableForm,isDisabled:c,onChange:a=>{if(e.setIsWallEnableForm(a),a&&e.wallData){let m=e.wallData.w*e.wallData.h;m<Number(i.minAmountWall)&&(m=Number(i.minAmountWall)),Number(e.amount)!==m&&e.setAmount(String(m))}},text:`ÐапиÑать на Ñтене (от ${l} руб.)`})})]}),t.jsx("div",{className:"wall-details__image-wrapper",children:t.jsx("img",{src:"/design/arts/widgets/wall-preview.webp",alt:"Стена",className:"wall-details__image"})})]}),e.isWallEnableForm&&e.wallData&&(()=>{const m=Math.min(200/e.wallData.w,120/e.wallData.h),v=e.wallData.w*m,D=e.wallData.h*m,M=e.wallData.w*e.wallData.h,F=Math.max(M,Number(i.minAmountWall)||0);return t.jsx("div",{className:"wall-details__preview-box",children:t.jsx("div",{className:"wall-details__preview-box-inner",style:{width:`${v}px`,height:`${D}px`},children:t.jsxs("div",{className:"wall-details__preview-box-label",children:[t.jsxs("div",{className:"wall-details__preview-box-dimensions",children:[e.wallData.w," x ",e.wallData.h,"px"]}),t.jsxs("div",{className:"wall-details__preview-box-price",children:[F.toLocaleString("ru-RU")," ₽"]})]})})})})(),e.isWallEnableForm&&t.jsx("div",{className:"wall-details__action",children:t.jsx(B,{theme:e.wallData?"secondary":"accent",size:"m",isFullWidth:!0,text:e.wallData?"Изменить облаÑть Ð´Ð»Ñ Ñ€Ð¸ÑованиÑ":"Выбрать облаÑть и размер",onClick:a=>{a==null||a.preventDefault(),r(!0)}})}),t.jsx(kt,{isOpen:s,onClose:()=>r(!1),form:e,page:i})]})}),$="donation-form-skeleton",Pt=()=>{const i=()=>t.jsxs("div",{className:`${$}__group`,children:[t.jsx("div",{className:`${$}__input`}),t.jsx("div",{className:`${$}__hint`})]}),e=()=>t.jsxs("div",{className:`${$}__group`,children:[t.jsx("div",{className:`${$}__textarea`}),t.jsx("div",{className:`${$}__hint`})]});return t.jsxs(fe.Fragment,{children:[t.jsxs("div",{className:$,children:[i(),i()]}),t.jsx("div",{className:$,children:e()})]})},$t="payment-donation-content";class Rt extends x.Component{constructor(e){super(e),this.form=this.props.form,this.page=this.props.page,this.setDonatorName=s=>{this.form.setName(s)},this.setAmount=s=>{this.form.setAmount(s),this.props.form.errors.setError("amount","")},this.initDonator()}initDonator(){const e=me.get();e.name&&this.props.form.setName(e.name)}render(){return this.props.page.isLoading?t.jsx(Pt,{}):t.jsxs(x.Fragment,{children:[t.jsx(wt,{page:this.props.page,form:this.props.form}),this.renderDonation(),t.jsx(It,{page:this.props.page,form:this.props.form,store:this.props.store,onQuizCategoryClick:this.props.onQuizCategoryClick}),t.jsx(Wt,{page:this.props.page,form:this.props.form}),t.jsx(Tt,{page:this.props.page,form:this.props.form}),t.jsx(Mt,{page:this.props.page,form:this.props.form})]})}renderDonation(){const{t:e}=this.props;return t.jsxs("div",{className:$t,children:[t.jsx(k,{name:"name",iconPosition:"left",title:e("sendDonation:form:name:title"),placeholder:e("sendDonation:form:name:placeholder"),maxLength:He,value:this.props.form.name,onChange:this.setDonatorName}),t.jsx(ct,{inputRef:this.props.form.amountRef,value:this.props.form.amount,name:"amount",setValue:this.setAmount,title:e("sendDonation:form:amount:title"),placeholder:e("sendDonation:form:amount:placeholder"),isDisabled:this.props.form.isAction||this.props.form.isSuperDonate||this.props.form.isWallEnableForm,errorText:this.props.form.errors.getErrorBy("amount"),hintText:`${e("sendDonation:form:amount:hint")} ${pe(this.props.form.minAmount,{minimumFractionDigits:0,maximumFractionDigits:2})}`})]})}}const zt=z()(Y(Rt)),le="activity-on-air",Yt=i=>{const e=()=>t.jsxs("div",{className:`${le}__online`,children:[t.jsx(ge,{type:"onlineType"}),t.jsx("span",{children:i.t("general:status:online")})]});return i.page.donationOnAir?t.jsxs("div",{className:le,children:[e(),t.jsxs("div",{className:`${le}__info`,children:[t.jsx(R,{value:i.page.getActivityNameById(i.page.donationOnAir.typeId),size:"xs"}),t.jsx(u,{size:"s",color:"primary",isMarginDisabled:!0,children:i.page.donationOnAir.message})]}),t.jsx(B,{size:"s",theme:"secondary",text:i.t("general:participate"),href:i.page.donationOnAir.url,isReactLink:!1})]}):null},Lt=z()(Y(Yt)),ce="reject-donation-pop-up",Xt=i=>{const e=x.useMemo(()=>{const s=[];return i.page.isAddedPhone||s.push(i.t("sendDonation:rejectDonationPopUp:phoneItem")),i.page.isAddedCreditCard||s.push(i.t("sendDonation:rejectDonationPopUp:bankCardItem")),s},[i.page.isEmailConfirmation,i.page.isAddedCreditCard,i.page.isAddedPhone]);return t.jsx(Me,{isVisible:i.isVisible,onClose:i.onClose,className:ce,children:t.jsxs(Oe,{children:[t.jsx(R,{size:"xl",children:i.t("sendDonation:rejectDonationPopUp:title")}),t.jsx(u,{size:"m",color:"primary",children:i.t("sendDonation:rejectDonationPopUp:text1")}),t.jsxs("div",{className:`${ce}__details`,children:[t.jsxs(u,{size:"m",color:"primary",children:[i.t("sendDonation:rejectDonationPopUp:listTitle"),":"]}),e.map(s=>t.jsx("div",{className:`${ce}__item`,children:t.jsx(u,{size:"m",color:"primary",children:s})},s))]}),t.jsx(u,{size:"m",color:"primary",children:i.t("sendDonation:rejectDonationPopUp:text2")}),t.jsx(B,{size:"m",theme:"accent",text:i.t("general:close"),onClick:i.onClose})]})})},Bt=z()(Xt),Ve="streamer-rules-pop-up",Ft=i=>{const e=i.rules?t.jsxs(u,{size:"m",color:"primary",isMarginDisabled:!0,children:[t.jsxs(u,{size:"m",color:"primary",tag:"span",bold:"700",children:[i.t("sendDonation:streamerRulesPopUp:title"),": "]}),i.rules]}):null;return t.jsx(Me,{isVisible:i.isVisible,onClose:i.onClose,className:Ve,children:t.jsxs("div",{className:`${Ve}__content`,children:[t.jsx(u,{size:"m",isMarginDisabled:!0,color:"primary",children:i.t("sendDonation:streamerRulesPopUp:description1")}),t.jsx(u,{size:"m",isMarginDisabled:!0,color:"primary",children:i.t("sendDonation:streamerRulesPopUp:description2")}),e]})})},Ut=z()(Ft),de="send-donation-form",Te="tg",he="sid",Ht="sum";class Ot extends x.Component{constructor(e){super(e),this.form=new At(this.props.pageId),this.page=new ot,this.isBusy=!1,this.isRejected=!1,this.isStreamerRulesPopUpVisible=!1,this.disposer=null,this.onDonate=s=>{if(this.form.errors.clear(),this.validateForm(),!this.page.isAvailable){this.setRejected(!0);return}if(this.form.errors.hasErrors){this.focusFirstErrorIfHas();return}this.setBusy(!0),me.set({name:this.form.name,voiceId:this.form.voiceId}),this.props.store.createDonation(this.form.export(this.queryParams,{quizCategoryId:s})).then(({paymentUrl:r})=>this.navigateToPay(r)).finally(()=>this.setBusy(!1))},this.onQuizCategory=s=>this.onDonate(s),this.updateQueryParams=()=>{const s=new URLSearchParams(window.location.search);this.form.isTgEnable?s.set(Te,"on"):s.delete(Te),this.props.setSearchParams(s)},Qe(this,{isBusy:ne,isRejected:ne,isStreamerRulesPopUpVisible:ne,setBusy:ee.bound,setRejected:ee.bound,openStreamerRulesPopUp:ee.bound,closeStreamerRulesPopUp:ee.bound}),this.fetchDonation(),this.createDonationAmountReaction()}get queryParams(){const e={},s=new URLSearchParams(window.location.search);return s.get(he)&&(e[he]=s.get(he)||""),e}componentWillUnmount(){this.disposer&&(this.disposer(),this.disposer=null)}setBusy(e){this.isBusy=e}setRejected(e){this.isRejected=e}openStreamerRulesPopUp(){this.isStreamerRulesPopUpVisible=!0}closeStreamerRulesPopUp(){this.isStreamerRulesPopUpVisible=!1}navigateToPay(e){window.location.href=e}validateForm(){if(!(this.form.isAction||this.form.isSuperDonate)){if(this.form.amountValue<this.form.minAmount){this.form.errors.setError("amount",this.props.t("validation:minAmount",{amount:this.form.minAmount}));return}if(this.form.amountValue>this.form.maxAmount){this.form.errors.setError("amount",this.props.t("validation:maxAmount",{amount:this.form.maxAmount}));return}}}focusFirstErrorIfHas(){Dt(this.form.errors,[[this.form.amountRef.current,"amount"]])(e=>{e==null||e.scrollIntoView({block:"center"}),e==null||e.focus({preventScroll:!0})})}createDonationAmountReaction(){this.disposer=qe(()=>this.form.amount,()=>{this.checkTTSAvailability(),this.checkAIAvailability(),this.checkSafeAvailability(),this.checkWonderAvailability(),this.checkWallAvailability()},{fireImmediately:!0})}checkTTSAvailability(){if(this.page.isTTSEnable){const e=this.form.amountValue>=this.page.ttsMinAmount;e?this.form.setTTSEnable(!0):!e&&this.form.isTTSEnable&&this.form.setTTSEnable(!1)}}checkAIAvailability(){this.page.isAIEnable&&!(this.form.amountValue>=this.page.aiMinAmount)&&this.form.isAIEnabled&&this.form.setAIEnabled(!1)}checkSafeAvailability(){this.page.isSafeEnable&&!(this.form.amountValue>=Math.max(this.page.safeMinAmount,this.form.minAmount))&&this.form.isSafeEnable&&this.form.setSafeEnable(!1)}checkWonderAvailability(){this.page.isWonderEnable&&!(this.form.amountValue>=Math.max(this.page.wonderMinAmount,this.form.minAmount))&&this.form.isWonderEnable&&this.form.setWonderEnable(!1)}checkWallAvailability(){this.page.isWallEnabled&&!(this.form.amountValue>=Math.max(Number(this.page.minAmountWall)||0,this.form.minAmount))&&this.form.isWallEnableForm&&this.form.setIsWallEnableForm(!1)}render(){const e=this.page.username?`Донат Ð´Ð»Ñ ${this.page.username} | iHAQDonate`:"Отправить донат | iHAQDonate",s=this.page.username?`Поддержите Ñтримера ${this.page.username} на iHAQDonate`:"Отправить донат любимому Ñтримеру на iHAQDonate";return t.jsxs("div",{className:`${de}__wrapper`,children:[t.jsxs(Ge,{children:[t.jsx("title",{children:e}),t.jsx("meta",{name:"description",content:s}),t.jsx("meta",{property:"og:title",content:e}),t.jsx("meta",{property:"og:description",content:s}),this.page.avatar&&t.jsx("meta",{property:"og:image",content:this.page.avatar})]}),t.jsx(lt,{branding:this.page.branding,isLoading:this.page.isLoading}),t.jsxs("div",{children:[t.jsxs("div",{className:de,children:[t.jsx(dt,{isLoading:this.page.isLoading,isPro:this.page.isPro,login:this.page.login,username:this.page.username,avatar:this.page.avatar,telegram:this.page.telegram,youtube:this.page.youtube,twitch:this.page.twitch,vk:this.page.vk,children:t.jsx(Lt,{page:this.page})}),t.jsx(zt,{form:this.form,page:this.page,store:this.props.store,updateQueryParams:this.updateQueryParams,onQuizCategoryClick:this.onQuizCategory}),t.jsx(ht,{buttonText:this.page.buttonText,isLoading:this.page.isLoading,isDisabled:this.form.isDisabled||this.isBusy,streamerRules:this.page.rules,onClick:this.onDonate})]}),this.renderInfo()]}),t.jsx(Bt,{isVisible:this.isRejected,onClose:()=>this.setRejected(!1),page:this.page}),t.jsx(Ut,{isVisible:this.isStreamerRulesPopUpVisible,rules:this.page.rules,onClose:this.closeStreamerRulesPopUp})]})}renderInfo(){if(this.page.isLoading)return null;const e=this.page.buttonText||this.props.t("sendDonation:from:supportButtonText"),s=t.jsx(u,{size:"s",color:"primary",children:t.jsx(ye,{i18nKey:"sendDonation:streamerRulesPopUp:text",components:{highlightText:t.jsx(Ke,{bold:"700",text:this.props.t("sendDonation:streamerRulesPopUp:highlightText"),onPress:this.openStreamerRulesPopUp})}})});return t.jsxs("div",{className:`${de}__info`,children:[t.jsx(u,{size:"s",color:"secondary-40",children:t.jsx(ye,{i18nKey:"sendDonation:from:info",components:{buttonText:t.jsx(t.Fragment,{children:e})}})}),t.jsx(u,{size:"s",color:"secondary-40",children:this.props.t("sendDonation:info")}),this.page.isSafeEnable&&t.jsx(u,{size:"s",color:"secondary-40",children:this.props.t("sendDonation:safeInfo")}),t.jsx(Ze,{text:s,icon:"outlineInfo",iconPosition:"left"})]})}fetchDonation(){this.page.setLoading(!0),this.props.store.getDonationPage(this.props.pageId).then(e=>{this.page.setFromApi(e.data),e.data.viewer.login&&this.form.setName(e.data.viewer.login),e.data.donationSettings.minAmountDonation&&this.form.setMinAmountDonation(e.data.donationSettings.minAmountDonation),e.data.donationSettings.minAmountDonationMultiplier&&this.form.setMinAmountDonationMultiplier(e.data.donationSettings.minAmountDonationMultiplier),e.data.sounds&&this.form.setTTSEnable(e.data.sounds.isTTSEnable),this.form.setAmount(String(this.form.minAmount)),this.setVoiceId(),this.setTgButtonIfAvailable(),this.setDefaultDonationAmountIfHas()}).catch(e=>{Je(e)&&this.props.navigate("/404",{replace:!0})}).finally(()=>this.page.setLoading(!1))}setVoiceId(){const e=me.get().voiceId;if(e){const s=Number(e).valueOf();if(this.page.voices.some(l=>l.id===s)){this.form.setVoiceId(s);return}}this.page.voices.length&&this.form.setVoiceId(this.page.voices[0].id)}setTgButtonIfAvailable(){}setDefaultDonationAmountIfHas(){const s=new URLSearchParams(window.location.search).get(Ht),r=Number(s);s&&!isNaN(r)&&r>0&&this.form.setAmount(s)}}const Qt=z()(Y(Ot)),Ss=()=>{const{store:i}=x.useContext(et),e=tt(),s=st(),[r,l]=it();return x.useEffect(()=>{let c=s.pageId||"";c.startsWith("@")&&(c=c.substring(1));const a=`https://ihaqdonate.com/d/${c}`;let h=document.querySelector("link[rel='canonical']"),m=!1,v=null;return h?v=h.getAttribute("href"):(h=document.createElement("link"),h.setAttribute("rel","canonical"),document.head.appendChild(h),m=!0),h.setAttribute("href",a),()=>{m&&h?document.head.removeChild(h):h&&v!==null?h.setAttribute("href",v):h&&h.removeAttribute("href")}},[s.pageId]),t.jsx(at,{children:t.jsx(Qt,{store:i,pageId:s.pageId||"",navigate:e,currentQueryParameters:r,setSearchParams:l})})};export{Ss as DonatePage};