import{Q as u,l as Ye,X as Be,O as Le,w as P,o as k,j as t,e as C,I as ie,T as p,W as je,B as Y,Y as ae,Z as Ve,z as Te,c as Fe,$ as Xe,M as Ue,V as Ne,a0 as Qe,G as He,m as Oe,f as oe,h as te,r as qe,H as Ke,a1 as ye,d as Ge,a2 as Ze,t as Je,b as et,u as tt,v as st,a3 as it}from"./index-zM9vIFRQ.js";import{a as Ce,r as x}from"./vendor-animations-CsoOZIH8.js";import{B as at}from"./BaseLayout-MetYKNt_.js";import{F as nt}from"./FormErrors-ZGNRI_YF.js";import{P as rt,i as ue,D as ot,R as lt}from"./inMemoryDonator-vni4T3Jw.js";import{V as pe}from"./types-DrtkSZ7f.js";import{D as ct}from"./DonationPage-D8s3UKXA.js";import{B as dt}from"./BrandingBackdrop-BgHUOUMf.js";import{P as ht}from"./DonationFooter-Cn40dmCz.js";import{D as mt,P as ut}from"./DonationAmountInput-k-FtTRO1.js";import{D as pt}from"./DropdownInput-IMJ5WSof.js";import{T as $}from"./TextInput-CBGy_Nu6.js";import{U as ft}from"./UploadImageInput-BIYnhNKL.js";import{S as le}from"./SocialInput-CVR_aC6v.js";import{C as gt}from"./CheckboxInput-DiEbafki.js";import{Q as we}from"./quiz.constants-D50Xyuic.js";import{A as xt}from"./AIAssistant-OhhfSr0S.js";import{g as fe}from"./getNumberFormat-D9eLFqYV.js";import{S as _t,r as bt,P as vt}from"./SafeCodeInput-DOiUnyOr.js";import{u as At}from"./useQuery-Bs8VVqq9.js";import{W as Dt}from"./WallsService-RnSSQqGm.js";import{w as jt}from"./withOnFirstError-hAsdbznp.js";import"./useJivoExternalScript-yyZ--K1Q.js";import"./DonationVoice-DrDo2_CY.js";import"./getVotesFormat-CTrf3mHq.js";import"./getSocialFormat-CDK45c1l.js";import"./inputmask-Cr-e3LsO.js";import"./pluralize-BqhPSiJS.js";import"./validators-D8nzrbNm.js";import"./TextInput-BdBCNDVO.js";import"./copyToClipboard-DRZ9ijAN.js";class yt{constructor(e){this._pageId="",this.amountRef=Ce.createRef(),this._name="",this._amount="",this._activity=u.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._isMassQuiz=!1,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?Be(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>=u.Vote}get isAction(){return this.activity===u.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 isWallAvailable(){return!this.isSuperDonate}get isValidDetails(){const e=this._message.trim();switch(this._activity){case u.Action:case u.Message:const s=this._isSafeEnable?!!this._safeEmail.trim()&&this._safeCode.every(l=>!!l):!0,r=this._isWonderEnable?!!this._safeEmail.trim()&&this._wonderWord.every(l=>!!l):!0,o=this._isWallEnableForm?!!this._wallData:!0;return s&&r&&o;case u.Quiz:return this.isMassQuiz;case u.EmotionsControl:return!0;case u.Vote:return!!e&&!!this._firstVariant.trim()&&!!this._secondVariant.trim();case u.ViewerRate:return!!e&&!!this._firstVariant.trim()&&!!this._secondVariant.trim()&&!!this._image;case u.StreamerRate:return!!e&&!!this._image;case u.Advertising:return!!e&&!!this._about.trim()&&!!this._image;case u.QuestionAnswer:return!!e&&!!this._image;case u.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 Le}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}get isMassQuiz(){return this._isMassQuiz}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=u.Action,this._actionId=e.id,this._amount=e.price}resetActivity(){this._activity=u.Message,this._actionId=""}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}setIsMassQuiz(e){this._isMassQuiz=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>pe?{isTTSEnable:!0,voiceId:this.voiceId}:{isTTSEnable:!1},o=this.isSafeAvailable&&this.isSafeEnable?{isSafeEnabled:!0,safeEmail:this.safeEmail,safeCode:this.safeCode.join("")}:{isSafeEnabled:!1},l=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,...o,...l,...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===u.Action&&(a.typeId=u.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===u.StreamerRate&&(a.isPermissionToShow=this._isPermissionToShow),this._activity===u.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 ce="donation-activities",wt=i=>{const e=!!i.page.actions.length||!!i.page.activities.length,s=a=>{const c=i.form.activity===a.typeId;i.form.resetDetails(),c?i.form.resetActivity():i.form.setActivity(a)},r=a=>{const c=i.form.actionId===a.id;i.form.resetDetails(),c?i.form.resetActivity():i.form.setAction(a)},o=()=>t.jsx(t.Fragment,{children:i.page.activities.map(a=>t.jsxs("div",{className:`${ce}__item`,"aria-selected":a.typeId===i.form.activity,role:"radio",onClick:()=>s(a),children:[t.jsx(ie,{type:"superDonate"}),t.jsx(p,{size:"s",color:"primary",tag:"span",children:i.page.getActivityNameById(a.typeId)}),t.jsx(p,{size:"s",color:"primary",tag:"span",children:je(Number(a.price).valueOf())})]},a.typeId))}),l=()=>t.jsx(t.Fragment,{children:i.page.actions.map(a=>t.jsxs("div",{className:`${ce}__item`,"aria-selected":a.id===i.form.actionId,role:"radio",onClick:()=>r(a),children:[t.jsx(p,{size:"s",color:"primary",tag:"span",children:a.name}),t.jsx(p,{size:"s",color:"primary",tag:"span",children:je(Number(a.price).valueOf())})]},a.id))});return e?t.jsxs("div",{className:ce,children:[t.jsx(C,{value:i.t("sendDonation:form:activities"),size:"xs"}),l(),o()]}):null},St=P()(k(wt)),U="on-air-block",Et=i=>{const{page:e,form:s,t:r}=i;if(!(!!e.firstVariant&&!!e.secondVariant))return null;const l=e.secondVariant?`${e.firstVariant} или ${e.secondVariant}`:e.firstVariant;return t.jsxs("div",{className:U,children:[t.jsxs("div",{className:`${U}__badge`,children:[t.jsx("span",{className:`${U}__dot`}),r("sendDonation:onAirBlock:label")]}),t.jsxs("div",{className:`${U}__content`,children:[t.jsx(C,{value:r("sendDonation:onAirBlock:title"),size:"xs"}),t.jsx(p,{size:"s",color:"primary",className:`${U}__variants`,children:l})]}),t.jsx("div",{className:`${U}__action`,children:t.jsx(Y,{text:r("sendDonation:onAirBlock:button"),href:`/d/2/${s.pageId}`,size:"s",theme:"secondary"})})]})},It=P()(k(Et)),Mt=i=>{const[e,s]=x.useState(pe),r=x.useMemo(()=>{const c=i.voices.map(h=>({alias:h.id,icon:h.icon,title:`${h.name} ${h.priceValue>0?`(+${h.priceValue} ${i.t("general:rub:short")})`:""}`}));return c.push({alias:pe,icon:"male",title:i.t("general:withoutVoice")}),c},[i.voices]),o=i.voices.find(c=>c.id===i.currentVoice),l=c=>{i.onChange(c),s(c.alias)},a=()=>i.isAutoplay&&o&&o.id===e?t.jsx("audio",{src:o.example,autoPlay:!0}):null;return t.jsxs(Ce.Fragment,{children:[a(),t.jsx(pt,{title:i.title,allVariants:r,currentVariant:i.currentVoice,onChange:l,isDisabled:i.isDisabled,iconColor:"brand"})]})},Vt=P()(Mt),N="activity-details",Se=20;class Tt 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 o=this.props.form.amountValue<Number(this.props.page.ai.minAmount).valueOf(),l=fe(Number(this.props.page.ai.price),{minimumFractionDigits:0,maximumFractionDigits:2}),a=fe(Number(this.props.page.aiMinAmount),{minimumFractionDigits:0,maximumFractionDigits:2});return t.jsxs("div",{className:`${N}__ai-assistant`,children:[t.jsx(ae,{isChecked:this.props.form.isAIEnabled,isDisabled:o,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(xt,{avatar:this.props.page.ai.image,size:48}),t.jsx(p,{size:"m",color:"primary",bold:"700",children:`${e("sendDonation:aiCharacter")} — ${this.props.page.ai.name} (+ ${l} ${e("general:rub:short")})`})]}):null]})}return null}renderTTS(){const{t:e}=this.props;return this.props.page.isTTSEnable&&this.props.form.isTTSAvailable?t.jsx(Vt,{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 u.Quiz:return this.props.form.isMassQuiz?this.renderMassQuizDetails():this.renderQuizDetails();case u.EmotionsControl:return this.renderEmotionsControlDetails();case u.Vote:return this.renderVoteDetails();case u.StreamerRate:return this.renderStreamerRate();case u.ViewerRate:return this.renderViewerRate();case u.Advertising:return this.renderAdvertising();case u.StreamerHaveTo:return this.renderStreamerHaveTo();case u.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"),300),this.renderVideoLink()]})}renderQuizDetails(){const{t:e}=this.props;return t.jsxs("div",{className:`${N}__content`,children:[t.jsx(p,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:quiz:text")}),t.jsx(Ve,{title:e("sendDonation:details:quiz:selectCategory"),children:t.jsx("div",{className:`${N}__quiz-categories`,children:this.props.page.quizCategories.map(s=>s&&we[s]?t.jsx(Y,{size:"s",theme:"secondary",text:we[s],onClick:()=>this.props.onQuizCategoryClick(s),isDisabled:!this.props.form.name.trim()},s):null)})})]})}renderMassQuizDetails(){const{t:e}=this.props;return t.jsx("div",{className:`${N}__content`,children:t.jsx(p,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:massQuiz:text")})})}renderEmotionsControlDetails(){const{t:e}=this.props;return t.jsxs("div",{className:`${N}__content`,children:[t.jsx(p,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:emotionsControl:text1")}),t.jsx(p,{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",""],Se)]})}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(gt,{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"),""],Se)]})}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(p,{size:"m",color:"primary",bold:"700",isMarginDisabled:!0,children:e("sendDonation:details:streamerHaveTo:title")}),t.jsx(p,{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,o){return t.jsx($,{type:"text",value:this.props.form.message,title:e,placeholder:s,isMultiline:!0,maxLength:r,hintText:o,onChange:this.setMessage})}renderVideoLink(){const{t:e}=this.props;return t.jsx($,{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($,{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(ft,{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:o}=this.props,l=s.length===3;return t.jsxs("div",{className:`${N}__variants`,children:[t.jsx($,{title:e,placeholder:s[0],value:this.props.form.firstVariant,onChange:this.setFirstVariant,maxLength:r}),t.jsx($,{placeholder:s[1],value:this.props.form.secondVariant,onChange:this.setSecondVariant,maxLength:r}),this.props.form.isAddedVariant?t.jsx($,{placeholder:"",value:this.props.form.thirdVariant,onChange:this.setThirdVariant,maxLength:r}):l?t.jsx(Y,{size:"m",theme:"link",text:o("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(le,{inputVersion:2,type:"telegram",setValue:this.setTelegram,value:this.props.form.telegram,title:e}),t.jsx(le,{inputVersion:2,type:"vk",setValue:this.setVk,value:this.props.form.vk}),t.jsx(le,{inputVersion:2,type:"youtube",setValue:this.setYoutube,value:this.props.form.youtube})]})}}const Nt=P()(k(Tt)),se="safe-details",Ct=i=>{var h;const{t:e}=Te();if(!i.page.isSafeEnable||!i.form.isSafeAvailable)return null;const s=Math.max(i.page.safeMinAmount,i.form.minAmount),r=i.form.amountValue<s,o=((h=i.page.safe)==null?void 0:h.codeLength)||0,l=`${e("sendDonation:safeBlock:activate")} (${e("general:from")} ${s} ${e("general:rub:short")})`,a=()=>t.jsxs("div",{className:`${se}__header`,children:[t.jsxs("div",{className:`${se}__info`,children:[t.jsx(C,{size:"xs",children:e("sendDonation:safeBlock:title")}),t.jsx(p,{size:"s",color:"primary",children:e("sendDonation:safeBlock:text")})]}),t.jsx(ae,{isChecked:i.form.isSafeEnable,isDisabled:r,onChange:v=>{i.form.initSafeCode(o),i.form.setSafeEnable(v)},text:l})]}),c=()=>i.form.isSafeEnable?t.jsxs("div",{className:`${se}__content`,children:[t.jsx(_t,{size:"s",codeLength:o,code:i.form.safeCode,setCode:(v,A)=>i.form.setSafeCode(v,A),title:e("sendDonation:safeBlock:code"),hintText:e("sendDonation:safeBlock:hint")}),t.jsx($,{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:se,children:[a(),c(),t.jsx(ie,{type:"safe"})]})},kt=k(Ct),Ee="wonder-code-input",Wt=i=>{const e=i.wordLength,s=(o,l)=>(i.setWord(o,l.toUpperCase()),!0),r=()=>t.jsx("div",{className:`${Ee}__word`,children:bt(0,e).map((o,l)=>t.jsx(Xe,{children:()=>{var a;return t.jsx(vt,{customPrefix:"wonderWordPinField_",index:l,placeholder:"*",value:(a=i.word)==null?void 0:a[l],setValue:c=>s(l,c),borderColor:"secondary",type:"letter",autoFocus:l===0,size:"s",ariaRequired:!0})}},l))});return t.jsx(Ve,{className:Fe(Ee),title:i.title,hintText:i.hintText,withHintIcon:!0,children:r()})},G="wonder-details",$t=i=>{var v;const{t:e}=Te();if(!i.page.isWonderEnable||!i.form.isWonderAvailable)return null;const s=Math.max(i.page.wonderMinAmount,i.form.minAmount),r=i.form.amountValue<s,o=((v=i.page.wonder)==null?void 0:v.wordLength)||0,l=`${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(C,{size:"xs",children:e("sendDonation:wonderBlock:title")}),t.jsx(p,{size:"s",color:"primary",children:e("sendDonation:wonderBlock:text")})]}),t.jsx(ae,{isChecked:i.form.isWonderEnable,isDisabled:r,onChange:A=>{i.form.initWonderWord(o),i.form.setWonderEnable(A)},text:l})]}),c=()=>{var A;return i.form.isWonderEnable?t.jsxs("div",{className:`${G}__content`,children:[t.jsx(Wt,{wordLength:o,word:i.form.wonderWord,setWord:(W,F)=>i.form.setWonderWord(W,F),title:e("sendDonation:wonderBlock:word"),hintText:e("sendDonation:wonderBlock:hint")}),t.jsxs(p,{size:"m",color:"brand",bold:"700",children:[e("sendDonation:wonderBlock:clueWord")," ",((A=i.page.wonder)==null?void 0:A.hint)??""]}),t.jsx($,{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:W=>i.form.setSafeEmail(W)})]}):null},h=t.jsxs("div",{className:`${G}__wonder-label`,children:[t.jsx("div",{children:t.jsx(C,{size:"l",color:"white",children:"C"})}),t.jsx("div",{}),t.jsx("div",{})]});return t.jsxs("div",{className:G,children:[a(),c(),h]})},Pt=k($t),Rt=({isOpen:i,onClose:e,form:s,page:r})=>{const o=x.useRef(null),l=x.useRef(null),[a,c]=x.useState(1),[h,v]=x.useState({x:0,y:0}),[A,W]=x.useState("select"),[F,ge]=x.useState(!1),[Z,H]=x.useState("none"),[D,ke]=x.useState(null),[m,J]=x.useState(null),{data:X}=At({queryKey:["wall",r.login],queryFn:()=>Dt.getWallByNickname(r.login||"").then(n=>{const d=n.data;return d.wall?d:d.data}),enabled:i&&!!r.login}),_=X==null?void 0:X.wall,xe=(X==null?void 0:X.items)||[],_e=n=>{if(!l.current)return{x:0,y:0};const d=l.current.getBoundingClientRect(),b=Math.floor((n.clientX-d.left)/a),f=Math.floor((n.clientY-d.top)/a);return{x:b,y:f}},be=(n,d,b,f)=>{const g=Math.min(n,b),y=Math.min(d,f),M=Math.max(n,b),j=Math.max(d,f);return{x:g,y,w:M-g+1,h:j-y+1}},O=n=>xe.some(d=>n.x<d.x+d.width&&n.x+n.w>d.x&&n.y<d.y+d.height&&n.y+n.h>d.y),We=n=>{var b;if(n.currentTarget.setPointerCapture(n.pointerId),ge(!0),n.button===1){n.preventDefault(),H("pan");return}const d=n.target;if((b=d.classList)!=null&&b.contains("selection-handle")&&m){const f=d.classList.contains("top-left"),g=Math.min(m.startX,m.currentX),y=Math.min(m.startY,m.currentY),M=Math.max(m.startX,m.currentX),j=Math.max(m.startY,m.currentY);J({startX:f?M:g,startY:f?j:y,currentX:f?g:M,currentY:f?y:j}),H("resize"),W("select");return}if(A==="select"){const{x:f,y:g}=_e(n);if(d.closest(".wall-selector-modal__selection-box")&&m){H("move"),ke({mouseX:f,mouseY:g,startX:m.startX,startY:m.startY,currentX:m.currentX,currentY:m.currentY});return}if(O({x:f,y:g,w:1,h:1}))return;const y=(_==null?void 0:_.width)||3840,M=(_==null?void 0:_.height)||2160,j=Math.max(0,Math.min(f,y-1)),V=Math.max(0,Math.min(g,M-1));J({startX:j,startY:V,currentX:j,currentY:V}),H("create")}},$e=n=>{if(F){if(A==="pan"||Z==="pan"){v(d=>({x:d.x+n.movementX,y:d.y+n.movementY}));return}if(A==="select"&&m){const{x:d,y:b}=_e(n),f=(_==null?void 0:_.width)||3840,g=(_==null?void 0:_.height)||2160;if(Z==="move"&&D){const j=d-D.mouseX,V=b-D.mouseY,w=Math.abs(D.currentX-D.startX)+1,R=Math.abs(D.currentY-D.startY)+1,T=Math.min(D.startX,D.currentX),z=Math.min(D.startY,D.currentY);let E=0,B=Math.sign(j);for(let q=0;q<Math.abs(j);q++){let K=E+B,L=T+K;if(L<0||L+w>f||O({x:L,y:z,w,h:R}))break;E=K}let S=0,ze=Math.sign(V);for(let q=0;q<Math.abs(V);q++){let K=S+ze,L=z+K;if(L<0||L+R>g||O({x:T+E,y:L,w,h:R}))break;S=K}const Ae=D.startX<=D.currentX,De=D.startY<=D.currentY;J({startX:Ae?T+E:T+E+w-1,startY:De?z+S:z+S+R-1,currentX:Ae?T+E+w-1:T+E,currentY:De?z+S+R-1:z+S});return}const y=Math.max(0,Math.min(d,f-1)),M=Math.max(0,Math.min(b,g-1));if(Z==="create"||Z==="resize"){const j=m.startX,V=m.startY;let w=m.currentX,R=Math.sign(y-m.currentX);for(let E=0;E<Math.abs(y-m.currentX);E++){let B=w+R,S=be(j,V,B,m.currentY);if(S.w*S.h>2e5||O(S))break;w=B}let T=m.currentY,z=Math.sign(M-m.currentY);for(let E=0;E<Math.abs(M-m.currentY);E++){let B=T+z,S=be(j,V,w,B);if(S.w*S.h>2e5||O(S))break;T=B}J({...m,currentX:w,currentY:T});return}}}},ne=n=>{ge(!1),H("none"),n.currentTarget.releasePointerCapture(n.pointerId)},re=(n,d,b)=>{if(n===a)return;let f=d,g=b;if(f===void 0||g===void 0)if(o.current){const w=o.current.getBoundingClientRect();f=w.width/2,g=w.height/2}else f=0,g=0;const y=(f-h.x)/a,M=(g-h.y)/a,j=f-y*n,V=g-M*n;c(n),v({x:j,y:V})},Pe=n=>{if(n.preventDefault(),!o.current)return;const d=o.current.getBoundingClientRect(),b=n.clientX-d.left,f=n.clientY-d.top,g=Math.max(.1,Math.min(a-n.deltaY*.002,10));re(g,b,f)},I=(()=>{if(!m)return null;const n=Math.min(m.startX,m.currentX),d=Math.min(m.startY,m.currentY),b=Math.max(m.startX,m.currentX),f=Math.max(m.startY,m.currentY),g=b-n+1,y=f-d+1;return{x:n,y:d,w:g,h:y}})(),ve=I?I.w*I.h:0;let ee=ve;ee<Number(r.minAmountWall)&&(ee=Number(r.minAmountWall));const Re=()=>{if(!I){alert("Сначала выделите участок на стене!");return}s.setIsWallEnableForm(!0),s.setWallData(I),s.setAmount(String(ee)),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(C,{value:r.username||r.login||"",size:"m"})]}),t.jsx("div",{className:"wall-selector-modal__header-right",children:t.jsx(p,{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:()=>re(Math.min(a+.5,10)),children:"+"}),t.jsx("button",{className:"tool-btn",title:"Уменьшить",onClick:()=>re(Math.max(a-.5,.1)),children:"-"}),t.jsx("button",{className:`tool-btn ${A==="pan"?"active":""}`,title:"Перемещение холста",onClick:()=>W("pan"),children:"🖐"}),t.jsx("button",{className:`tool-btn ${A==="select"?"active":""}`,title:"Выделение/Перемещение области",onClick:()=>W("select"),children:"🔲"})]}),t.jsx("div",{className:"wall-selector-modal__workspace",onWheel:Pe,children:t.jsxs("div",{className:"wall-selector-modal__viewport",ref:o,onPointerDown:We,onPointerMove:$e,onPointerUp:ne,onPointerLeave:ne,onPointerCancel:ne,onDragStart:n=>n.preventDefault(),onMouseDown:n=>{n.button===1&&n.preventDefault()},children:[t.jsxs("div",{className:"wall-selector-modal__canvas-wrapper",ref:l,style:{width:(_==null?void 0:_.width)||3840,height:(_==null?void 0:_.height)||2160,transform:`translate(${Math.round(h.x)}px, ${Math.round(h.y)}px) scale(${a})`,transformOrigin:"0 0"},children:[t.jsx("div",{className:"wall-selector-modal__canvas-bg"}),xe.map(n=>{const d=!!n.imageUrl,b=d?`/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:d?"transparent":"rgba(255, 255, 255, 0.1)",border:d?"none":"1px dashed rgba(255, 255, 255, 0.3)"},children:d&&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:A==="pan"?F?"grabbing":"grab":"crosshair"}})]}),I&&t.jsxs("div",{className:"wall-selector-modal__selection-box",style:{left:Math.round(I.x*a+h.x),top:Math.round(I.y*a+h.y),width:Math.round(I.w*a),height:Math.round(I.h*a),boxSizing:"border-box",zIndex:10,borderWidth:"2px",cursor:A==="select"?"move":void 0,pointerEvents:A==="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:["✓ Вы выбрали ",ve.toLocaleString("ru-RU")," пикселей, ваш донат – ",ee.toLocaleString("ru-RU")," рублей"]}),t.jsxs("div",{className:"wall-selector-modal__actions",children:[t.jsx(Y,{theme:"accent",size:"m",text:"Продолжить",onClick:Re}),t.jsx(Y,{theme:"secondary",size:"m",text:"Отмена",onClick:e})]})]})]})},zt=k(({page:i,form:e})=>{const[s,r]=x.useState(!1);if(!i.isWallEnabled)return null;if(!e.isWallAvailable)return e.isWallEnableForm&&e.setIsWallEnableForm(!1),null;const o=Math.max(Number(i.minAmountWall)||0,e.minAmount),l=e.amountValue<o;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(C,{value:"Стена",size:"s"}),t.jsx(p,{size:"m",color:"secondary",className:"wall-details__desc",children:"Оставь навсегда свой след на стене у стримера!"}),t.jsx("div",{className:"wall-details__switch",children:t.jsx(ae,{isChecked:e.isWallEnableForm,isDisabled:l,onChange:a=>{if(e.setIsWallEnableForm(a),a&&e.wallData){let h=e.wallData.w*e.wallData.h;h<Number(i.minAmountWall)&&(h=Number(i.minAmountWall)),Number(e.amount)!==h&&e.setAmount(String(h))}},text:`Написать на стене (от ${o} руб.)`})})]}),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 h=Math.min(200/e.wallData.w,120/e.wallData.h),v=e.wallData.w*h,A=e.wallData.h*h,W=e.wallData.w*e.wallData.h,F=Math.max(W,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:`${A}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(Y,{theme:e.wallData?"secondary":"accent",size:"m",isFullWidth:!0,text:e.wallData?"Изменить область для рисования":"Выбрать область и размер",onClick:a=>{a==null||a.preventDefault(),r(!0)}})}),t.jsx(Rt,{isOpen:s,onClose:()=>r(!1),form:e,page:i})]})}),Yt="payment-donation-content";class Bt 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=ue.get();e.name&&this.props.form.setName(e.name)}render(){return this.props.page.isLoading?t.jsx(ot,{}):t.jsxs(x.Fragment,{children:[t.jsx(It,{page:this.props.page,form:this.props.form}),t.jsx(St,{page:this.props.page,form:this.props.form}),this.renderDonation(),t.jsx(Nt,{page:this.props.page,form:this.props.form,store:this.props.store,onQuizCategoryClick:this.props.onQuizCategoryClick}),this.props.form.isWallAvailable&&t.jsx(zt,{page:this.props.page,form:this.props.form}),this.props.form.isSafeAvailable&&t.jsx(kt,{page:this.props.page,form:this.props.form}),this.props.form.isWonderAvailable&&t.jsx(Pt,{page:this.props.page,form:this.props.form})]})}renderDonation(){const{t:e}=this.props;return t.jsxs("div",{className:Yt,children:[t.jsx($,{name:"name",iconPosition:"left",title:e("sendDonation:form:name:title"),placeholder:e("sendDonation:form:name:placeholder"),maxLength:Ne,value:this.props.form.name,onChange:this.setDonatorName}),t.jsx(mt,{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")} ${fe(this.props.form.minAmount,{minimumFractionDigits:0,maximumFractionDigits:2})}`})]})}}const Lt=P()(k(Bt)),de="activity-on-air",Ft=i=>{const e=()=>t.jsxs("div",{className:`${de}__online`,children:[t.jsx(ie,{type:"onlineType"}),t.jsx("span",{children:i.t("general:status:online")})]});return i.page.donationOnAir?t.jsxs("div",{className:de,children:[e(),t.jsxs("div",{className:`${de}__info`,children:[t.jsx(C,{value:i.page.getActivityNameById(i.page.donationOnAir.typeId),size:"xs"}),t.jsx(p,{size:"s",color:"primary",isMarginDisabled:!0,children:i.page.donationOnAir.message})]}),t.jsx(Y,{size:"s",theme:"secondary",text:i.t("general:participate"),href:i.page.donationOnAir.url,isReactLink:!1})]}):null},Xt=P()(k(Ft)),Q="uncompleted-activities-block",Ut=i=>{const[e,s]=x.useState([]),[r,o]=x.useState(!0);if(x.useEffect(()=>{o(!0),Qe.getUncompletedActivities(i.pageId).then(a=>{var c;(c=a.data)!=null&&c.data&&s(a.data.data)}).catch(()=>{}).finally(()=>{o(!1)})},[i.pageId]),r||e.length===0)return null;const l=a=>{const c=i.page.getActivityNameById(a.typeId)||a.name||i.t("sendDonation:uncompleted:unknownActivity");let h="";return a.typeId===17?a.urlToken?h=`/quiz/${a.urlToken}`:h=`/mass-quiz/${a.id}/play`:a.typeId===24?a.urlToken?h=`/mass-quiz/${a.urlToken}`:h=`/mass-quiz/${a.id}/play`:a.typeId===23?h=`/wall-editor/${a.id}`:a.typeId===18&&(h=`/pult/${a.id}`),t.jsxs("div",{className:`${Q}__item`,children:[t.jsxs("div",{className:`${Q}__info`,children:[t.jsxs("div",{className:`${Q}__badge`,children:[t.jsx(ie,{type:"outlineInfo"}),t.jsx("span",{children:i.t("sendDonation:uncompleted:badge")})]}),t.jsx(C,{value:c,size:"xs"}),t.jsx(p,{size:"s",color:"primary",isMarginDisabled:!0,children:i.t("sendDonation:uncompleted:pendingText")})]}),t.jsx(Y,{size:"s",theme:"accent",text:i.t("general:continue"),href:h,isReactLink:!1})]},a.id)};return t.jsxs("div",{className:Q,children:[t.jsx(C,{value:i.t("sendDonation:uncompleted:title"),size:"s",className:`${Q}__title`}),t.jsx("div",{className:`${Q}__list`,children:e.map(l)})]})},Qt=P()(k(Ut)),Ie="streamer-rules-pop-up",Ht=i=>{const e=i.rules?t.jsxs(p,{size:"m",color:"primary",isMarginDisabled:!0,children:[t.jsxs(p,{size:"m",color:"primary",tag:"span",bold:"700",children:[i.t("sendDonation:streamerRulesPopUp:title"),": "]}),i.rules]}):null;return t.jsx(He,{isVisible:i.isVisible,onClose:i.onClose,className:Ie,children:t.jsxs("div",{className:`${Ie}__content`,children:[t.jsx(p,{size:"m",isMarginDisabled:!0,color:"primary",children:i.t("sendDonation:streamerRulesPopUp:description1")}),t.jsx(p,{size:"m",isMarginDisabled:!0,color:"primary",children:i.t("sendDonation:streamerRulesPopUp:description2")}),e]})})},Ot=P()(Ht),he="send-donation-form",Me="tg",me="sid",qt="sum",Kt="amount",Gt="nick",Zt="name",Jt="username",es="message",ts="msg",ss="text";class is extends x.Component{constructor(e){super(e),this.form=new yt(this.props.pageId),this.page=new ct,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),ue.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(Me,"on"):s.delete(Me),this.props.setSearchParams(s)},Oe(this,{isBusy:oe,isRejected:oe,isStreamerRulesPopUpVisible:oe,setBusy:te.bound,setRejected:te.bound,openStreamerRulesPopUp:te.bound,closeStreamerRulesPopUp:te.bound}),this.fetchDonation(),this.createDonationAmountReaction()}get queryParams(){const e={},s=new URLSearchParams(window.location.search);return s.get(me)&&(e[me]=s.get(me)||""),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(){jt(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:`${he}__wrapper`,children:[t.jsxs(Ke,{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(dt,{branding:this.page.branding,isLoading:this.page.isLoading}),t.jsxs("div",{children:[t.jsxs("div",{className:he,children:[t.jsxs(ht,{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(Xt,{page:this.page}),t.jsx(Qt,{page:this.page,pageId:this.props.pageId})]}),t.jsx(Lt,{form:this.form,page:this.page,store:this.props.store,updateQueryParams:this.updateQueryParams,onQuizCategoryClick:this.onQuizCategory}),t.jsx(ut,{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(lt,{isVisible:this.isRejected,onClose:()=>this.setRejected(!1),page:this.page}),t.jsx(Ot,{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(p,{size:"s",color:"primary",children:t.jsx(ye,{i18nKey:"sendDonation:streamerRulesPopUp:text",components:{highlightText:t.jsx(Ge,{bold:"700",text:this.props.t("sendDonation:streamerRulesPopUp:highlightText"),onPress:this.openStreamerRulesPopUp})}})});return t.jsxs("div",{className:`${he}__info`,children:[t.jsx(p,{size:"s",color:"secondary-40",children:t.jsx(ye,{i18nKey:"sendDonation:from:info",components:{buttonText:t.jsx(t.Fragment,{children:e})}})}),t.jsx(p,{size:"s",color:"secondary-40",children:this.props.t("sendDonation:info")}),this.page.isSafeEnable&&t.jsx(p,{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),this.form.setIsMassQuiz(this.page.quizCategories.length===0),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(),this.setPrefillFieldsFromQueryParams()}).catch(e=>{Je(e)&&this.props.navigate("/404",{replace:!0})}).finally(()=>this.page.setLoading(!1))}setVoiceId(){const e=ue.get().voiceId;if(e){const s=Number(e).valueOf();if(this.page.voices.some(o=>o.id===s)){this.form.setVoiceId(s);return}}this.page.voices.length&&this.form.setVoiceId(this.page.voices[0].id)}setTgButtonIfAvailable(){}setDefaultDonationAmountIfHas(){const e=new URLSearchParams(window.location.search),s=e.get(qt)||e.get(Kt),r=Number(s);s&&!isNaN(r)&&r>0&&this.form.setAmount(s)}setPrefillFieldsFromQueryParams(){const e=new URLSearchParams(window.location.search),s=e.get(Gt)||e.get(Zt)||e.get(Jt);s&&s.trim()&&this.form.setName(s.trim().slice(0,Ne));const r=e.get(es)||e.get(ts)||e.get(ss);r&&r.trim()&&this.form.setMessage(r.slice(0,500))}}const as=P()(k(is)),Ps=()=>{const{store:i}=x.useContext(et),e=tt(),s=st(),[r,o]=it();return x.useEffect(()=>{let l=s.pageId||"";l.startsWith("@")&&(l=l.substring(1));const a=`https://ihaqdonate.com/d/${l}`;let c=document.querySelector("link[rel='canonical']"),h=!1,v=null;return c?v=c.getAttribute("href"):(c=document.createElement("link"),c.setAttribute("rel","canonical"),document.head.appendChild(c),h=!0),c.setAttribute("href",a),()=>{h&&c?document.head.removeChild(c):c&&v!==null?c.setAttribute("href",v):c&&c.removeAttribute("href")}},[s.pageId]),t.jsx(at,{children:t.jsx(as,{store:i,pageId:s.pageId||"",navigate:e,currentQueryParameters:r,setSearchParams:o})})};export{Ps as DonatePage};