"use strict";(self.webpackChunk_byted_secsdk_captcha=self.webpackChunk_byted_secsdk_captcha||[]).push([[488],{8601:function(e,a,t){var l=t(5108),c=t(1578),n=t(8549),o=t(5174),i=t(1414);a.A=function(e){const{aid:a,app_name:t,ch:r,iid:s,did:d,os_type:p,h5_sdk_version:u,h5_sdk_use_type:h,sdk_version:m,platform:g,os_name:f,webdriver:v,imagexDomain:_,defaultType:E}=(0,c.d4)((e=>({aid:e.captchaOptionSettingModel.aid,app_name:e.captchaOptionSettingModel.app_name,ch:e.captchaOptionSettingModel.ch,iid:e.captchaOptionSettingModel.iid,did:e.captchaOptionSettingModel.did,os_type:e.captchaOptionSettingModel.os_type,h5_sdk_version:i.MF,h5_sdk_use_type:i.bn,sdk_version:e.captchaOptionSettingModel.sdk_version,platform:e.captchaOptionSettingModel.platform,os_name:e.captchaOptionSettingModel.os_name,webdriver:String(window.navigator.webdriver),imagexDomain:e.captchaOptionSettingModel.imagexDomain,defaultType:e.captcha.type})),c.bN);return(0,l.useMemo)((()=>({aid:a,lang:n.Ay.language,app_name:t,ch:r,iid:s,did:d,os_type:p,h5_sdk_version:u,h5_sdk_use_type:h,sdk_version:m,verify_data:void 0,challenge_code:(0,o.Ye)(e||E),platform:g,os_name:f,webdriver:v,type:e||E,mode:e||E,challenge_mode:e||E,imagexDomain:_})),[a,t,r,s,d,p,u,h,m,g,f,v,_,e,E])}},5488:function(e,a,t){t.r(a),t.d(a,{GenericCaptchaPage:function(){return q},default:function(){return Y}});var l=t(5108),c=t(1578),n=t(1793),o=t(1192),i=t(8549);var r=function(e){const[a,t]=(0,l.useState)(""),[r,s]=(0,l.useState)(""),[d,p]=(0,l.useState)(!1),u=(0,c.d4)((e=>e.captchaOptionSettingModel.feedbackSubmitCb)),h=(0,c.d4)((e=>e.captcha.type)),m=(0,l.useMemo)((()=>{let e=[];switch(h){case"voice":e=[{label:i.Ay.t("captchaOpti_rapBottomSheet_audioCaptchaOption1"),value:"captchaOpti_rapBottomSheet_audioCaptchaOption1"},{label:i.Ay.t("captchaOpti_rapBottomSheet_audioCaptchaOption2"),value:"captchaOpti_rapBottomSheet_audioCaptchaOption2"},{label:i.Ay.t("captchaOpti_rapBottomSheet_audioCaptchaOption3"),value:"captchaOpti_rapBottomSheet_audioCaptchaOption3"},{label:i.Ay.t("captchaOpti_rapBottomSheet_audioCaptchaOption4"),value:"captchaOpti_rapBottomSheet_audioCaptchaOption4"}];break;case"arkose":case"hcaptcha":case"geetest":case"hashcash":case"slide":case"whirl":case"icon":case"3d":e=[{label:i.Ay.t("captchaOpti_rapBottomSheet_imageCaptchaOption1"),value:"captchaOpti_rapBottomSheet_imageCaptchaOption1"},{label:i.Ay.t("captchaOpti_rapBottomSheet_imageCaptchaOption2"),value:"captchaOpti_rapBottomSheet_imageCaptchaOption2"},{label:i.Ay.t("captchaOpti_rapBottomSheet_imageCaptchaOption3"),value:"captchaOpti_rapBottomSheet_imageCaptchaOption3"},{label:i.Ay.t("captchaOpti_rapBottomSheet_imageCaptchaOption4"),value:"captchaOpti_rapBottomSheet_imageCaptchaOption4"}];break;default:e=[]}return e.push({label:i.Ay.t("captchaOpti_rapBottomSheet_captchaOption5"),value:"captchaOpti_rapBottomSheet_captchaOption5"}),e}),[h]);(0,l.useEffect)((()=>{"captchaOpti_rapBottomSheet_captchaOption5"===r?(t(""),p(!0)):(t(r),p(!1))}),[r]);const g=(0,l.useCallback)((e=>{s(e)}),[s]),f=(0,l.useCallback)((e=>{t(e)}),[t]),v=(0,l.useCallback)((()=>{e.onSubmit(),o.A.trackEvent({key:"USER_FEEDBACK_SUBMIT",stage:JSON.stringify(window.captchaFailEvents),is_success:1,custom:a,mode:h}),u&&u()}),[e,a,h,u]);return l.createElement(l.Fragment,null,l.createElement(n.DBO,{title:i.Ay.t("captchaOpti_rapBottomSheet_header"),style:{paddingLeft:"0px",paddingRight:"0px"}}),l.createElement("div",{className:"cap-flex cap-flex-col cap-max-h-[256px] cap-overflow-y-auto"},l.createElement(n.qMW,{label:"",value:r,onChange:g,options:m}),d&&l.createElement(n.U5X,{label:"",className:"cap-mx-4",value:a,onChange:f,placeholder:i.Ay.t("captchaOpti_rapBottomSheet_captchaOption5_inputBody"),maxLength:100,style:{width:"-webkit-fill-available"}}),l.createElement(n.I05,{id:"captcha_feedback_submit",label:i.Ay.t("captchaOpti_rapBottomSheet_btn"),variant:"primary",onClick:v,className:"cap-mt-2"})))},s=t(8395);const d=e=>{const a=(0,n.Abx)(),{iconSize:t}=(0,s.Ay)(),o=(0,c.d4)((e=>e.feedbackModel.isOpen)),d=(0,c.d4)((e=>e.captchaOptionSettingModel.isNarrowScreen||e.captchaOptionSettingModel.theme.keepSmallWidth?"296px":"400px")),p=(0,c.wA)(),u=(0,l.useCallback)((()=>{p.feedbackModel.toggleModal({},null),a.dismiss(0)}),[p.feedbackModel,a]),h=(0,l.useCallback)((e=>{p.feedbackModel.update({isOpen:e},null),a.dismiss(0)}),[p,a]),m=(0,l.useCallback)((()=>{p.feedbackModel.update({isOpen:!1},null),a.show({})}),[p,a]),g=(0,l.useMemo)((()=>{var a;return l.createElement(n.I05,{id:"captcha_feedback_button",leadingIcon:l.createElement(n.qwh,{size:t}),label:"",size:"xsmall",shape:"borderless",variant:"secondary",onClick:u,className:`cap-flex cap-items-center ${null!==(a=e.className)&&void 0!==a?a:""}`})}),[u,t,e.className]),f=(0,l.useMemo)((()=>g),[g]),v=(0,n.HIr)(),_=(0,c.d4)((e=>{var a;return(null===(a=e.captchaOptionSettingModel.theme)||void 0===a?void 0:a.lightBgColor)||null})),E=(0,c.d4)((e=>{var a;return(null===(a=e.captchaOptionSettingModel.theme)||void 0===a?void 0:a.darkBgColor)||null}));return l.createElement(l.Fragment,null,f,l.createElement(n.nOL,{open:o,width:"small",onOpenChange:h,className:"captcha-verify-container cap-px-8 cap-pb-8 sm:cap-pb-16 captcha-feedback-modal",style:{width:d,zIndex:8e3,backgroundColor:"dark"==v?E:_}},l.createElement(r,{onSubmit:m})),l.createElement(n.otH,{position:"top",state:a,render:()=>l.createElement("div",{className:"captcha-verify-container"},l.createElement(n.Mzi,{content:i.Ay.t("feedback_success"),leading:l.createElement(n.R$6,null)}))}))};var p=t(5330),u=t(8601);const h=e=>{const{iconSize:a}=(0,s.Ay)(),t=(0,c.d4)((e=>e.loggerModel.refresh_frequency)),i=(0,c.d4)((e=>e.captcha.loading)),r=(0,c.d4)((e=>e.voiceModel.isAudioLoading)),d=(0,u.A)(),h=(0,c.d4)((e=>e.captcha.type)),m=(0,c.wA)(),g=(0,l.useCallback)((()=>{o.A.trackEvent({key:"USER_ACTION_CLICKREFRESH",stage:"PRE",is_success:1,duration:t+1,mode:h}),m.loggerModel.refreshIncrease(null,null),m.captcha.refresh({query:(0,p.vA)(d)})}),[t,h,m.loggerModel,m.captcha,d]);return l.createElement(n.I05,{id:"captcha_refresh_button",leadingIcon:l.createElement(n.rXK,{size:a}),className:`cap-flex cap-items-center ${e.className||""}`,disabled:i||r,label:"",size:"xsmall",shape:"borderless",variant:"secondary",onClick:g})},m=e=>{var a;const{iconSize:t}=(0,s.Ay)(),o=(0,c.d4)((e=>e.captcha.loading)),r=(0,c.d4)((e=>e.captcha.type)),d=(0,c.d4)((e=>e.captcha.mostRecentImageMode)),h=(0,u.A)("voice"!==r?"voice":d),m=(0,c.wA)(),g="voice"==r?l.createElement(n.Mbu,{size:t}):l.createElement(n.RJi,{size:t}),f="voice"==r?i.Ay.t("captchaOpti_audioCaptchaModal_btn2"):i.Ay.t("captchaOpti_imageCaptchaModal_btn");return l.createElement(n.I05,{id:"captcha_switch_button",leadingIcon:g,className:`cap-flex ${null!==(a=e.className)&&void 0!==a?a:""}`,label:f,size:"xsmall",shape:"borderless",variant:"secondary",disabled:o,onClick:()=>{m.captcha.refresh({query:(0,p.vA)(h)})},style:{lineHeight:"unset",height:"unset",fontWeight:"normal"}})};function g(e){var a;const t=(0,c.d4)((e=>!!i.Ay.language.startsWith("en")&&("slide"==e.captcha.type||"whirl"==e.captcha.type||"3d"==e.captcha.type||"icon"==e.captcha.type||"voice"==e.captcha.type)));return l.createElement("div",{className:`cap-flex cap-flex-row cap-justify-between ${null!==(a=e.className)&&void 0!==a?a:""}`},t?l.createElement(m,null):l.createElement("div",null),l.createElement("div",{className:"cap-flex cap-flex-row"},l.createElement(h,{className:"cap-mx-4"}),l.createElement(d,{className:"cap-mx-4"})))}var f=function(e){const[a,t]=(0,l.useState)(0),{iconSize:o,textSize:r}=(0,s.Ay)(),d=(0,c.d4)((e=>e.captcha.loading)),p=(0,c.d4)((e=>e.captchaOptionSettingModel.hideCloseBtn)),u=(0,c.d4)((e=>e.iconAndThreeDModel.question)),h=(0,c.d4)((e=>e.captcha.verify_status)),m=(0,c.d4)((e=>{switch(e.captcha.type){case"voice":return i.F2.t("title");case"whirl":return i.F2.t("text_title_whirl");case"slide":return i.F2.t("captchaOpti_imageCaptchaModal_sliderBody");case"3d":return i.F2.t("H5_VerifyTips_11");case"icon":return u;case"none":case"hashcash":return i.F2.t("loading_verify");case"hcaptcha":case"arkose":case"geetest":return i.F2.t("captchaOpti_hCaptchaModal1_header");default:return i.F2.t("captchaOpti_captchaModal_header")}})),g=(0,c.wA)();return(0,l.useEffect)((()=>{t(Date.now())}),[]),l.createElement("div",{className:`cap-flex cap-flex-row-reverse sm:cap-flex-col cap-justify-between sm:cap-justify-start ${e.className||""}`},l.createElement("div",{className:`cap-flex cap-flex-row-reverse cap-items-center ${p?"cap-invisible":""} }`},l.createElement(n.I05,{id:"captcha_close_button",disabled:p,leadingIcon:l.createElement(n.gn,{size:o}),label:"",size:"xsmall",shape:"borderless",variant:"secondary",onClick:()=>{g.captcha.close(a)},role:"button","aria-label":i.F2.t("aria_label_close_btn"),"aria-live":"polite"})),l.createElement(n.Fm,{size:r,color:"UIText1",className:"cap-flex cap-items-center "+(d&&"going"!=h?"cap-invisible":"")},m))};var v=e=>{let{children:a,bounds:t,position:c,onStart:n,onDrag:o,onStop:i,disabled:r,className:s,style:d}=e;const[p,u]=(0,l.useState)(0),[h,m]=(0,l.useState)(0),g=(0,l.useRef)(new Image);(0,l.useEffect)((()=>{g.current.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";const e=e=>{m(e.clientX)};return window.addEventListener("mousemove",e),window.addEventListener("dragover",e),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("dragover",e)}}),[]);const f=(0,l.useCallback)((e=>{if(r)return void e.preventDefault();const a=e.type.startsWith("touch")?e.touches[0].clientX:e.clientX;u(a),null===n||void 0===n||n(),e.type.startsWith("drag")&&e.dataTransfer.setDragImage(g.current,0,0)}),[n,r]),v=(0,l.useCallback)((e=>{if(r)return;const a=e.type.startsWith("touch")?e.changedTouches[0].clientX:e.clientX,l=0!==a?a:h,c=Math.min(t.right,Math.max(t.left,l-p));null===o||void 0===o||o({x:c,y:0})}),[t,p,o,r,h]),_=(0,l.useCallback)((()=>{null===i||void 0===i||i()}),[i]);return l.createElement("div",{draggable:!0,onDragStart:f,onDrag:v,onDragEnd:_,onTouchStart:f,onTouchMove:v,onTouchEnd:_,className:`cap-flex cap-absolute ${null!==s&&void 0!==s?s:""}`,style:{cursor:r?"not-allowed":"grab",transform:`translateX(${c.x}px)`,...d}},a)},_=t(1414);var E=function(e){var a,t,i,r,s;const d=(0,c.wA)(),h=(0,l.useRef)(null),m=(0,l.useRef)(null),g=(0,n.jig)();(0,l.useEffect)((()=>{if(h.current&&m.current){const e=h.current.offsetWidth,a=m.current.offsetWidth;d.whirlModel.update({sliderRightBound:e-a},null)}}),[d.whirlModel,null===(a=h.current)||void 0===a?void 0:a.offsetWidth,null===(t=m.current)||void 0===t?void 0:t.offsetWidth]);const f=(0,c.d4)((e=>e.whirlModel.sliderRightBound)),E=(0,c.d4)((e=>e.whirlModel.isQuestionImageLoading)),y=(0,c.d4)((e=>e.whirlModel.isAnswerImageLoading)),b=(0,c.d4)((e=>e.whirlModel.questionImageLoadingErrorMessage)),w=(0,c.d4)((e=>e.whirlModel.answerImageLoadingErrorMessage)),A=(0,c.d4)((e=>{const a=e.whirlModel.dragTrack;if(a.length>0){return a[a.length-1].x}return 0})),M=(0,c.d4)((e=>e.captcha.type)),S=(0,c.d4)((e=>e.captcha.challenge_id)),k=(0,u.A)(),x=(0,c.d4)((e=>e.captchaOptionSettingModel.autoClose)),O=(0,c.d4)((e=>e.whirlModel.dragTrack)),T=(0,c.d4)((e=>e.whirlModel.dragStartTimeStamp)),C=(0,l.useCallback)((()=>{var e;const a=(null===(e=h.current)||void 0===e?void 0:e.offsetWidth)||0;o.A.trackEvent({key:"SYSTEM_VERIFY_ATTEMPT",is_success:1,stage:"PRE",custom:JSON.stringify(O),duration:Date.now()-T,mode:M}),d.captcha.submit({query:(0,p.vA)(k),data:{modified_img_width:a,id:S,mode:M,reply:O.map((e=>({...e,x:Math.round(e.x*a)}))),models:{},log_params:{},reply2:[],models2:{},drag_width:a},autoClose:x})}),[O,T,M,d.captcha,k,S,x]);return l.createElement("div",{className:`cap-flex ${null!==(i=e.className)&&void 0!==i?i:""}`},l.createElement("div",{ref:h,className:`cap-flex ${"rtl"===g?"cap-justify-end":""} cap-w-full cap-h-40 cap-rounded-full cap-bg-UISheetGrouped3`},l.createElement(v,{bounds:{left:0,right:f-("slide"==M?50:0)},position:{x:A*((null===(r=h.current)||void 0===r?void 0:r.offsetWidth)-("whirl"==M?null===(s=m.current)||void 0===s?void 0:s.offsetWidth:0)||0),y:0},onStart:()=>{d.whirlModel.update({dragStartTimeStamp:Date.now()},null),o.A.trackEvent({key:"USER_DRAG_SLIDER_START",is_success:1,stage:"AFTER",mode:M}),_.Fr&&console.log("bytedance://disable_swipe")},onDrag:e=>{d.whirlModel.appendDragTrack({x:e.x/f,y:e.y},null)},onStop:C,disabled:E||y||null!=b||null!=w},l.createElement(n.I05,{id:"captcha_slide_button",leadingIcon:l.createElement(n.pTX,null),variant:"secondary",label:"",disabled:!0,className:"secsdk-captcha-drag-icon sm:cap-w-auto cap-ml-0 cap-shadow-md",style:{opacity:E||y||null!=b||null!=w?.4:1,cursor:E||y||null!=b||null!=w?"unset":"grab",borderRadius:"32px",width:"64px",minWidth:"24px"},ref:m}))))},y=t(2426),b=t(8599),w=t(5169),A=t.n(w),M=t(5174);const S=(0,l.forwardRef)(((e,a)=>{let{id:t,initialSrc:n,fallbackSrc:i,onClickEmptyArea:r,onLoad:s,onError:d,alt:p="Captcha",className:u,style:h}=e;const[m,g]=(0,l.useState)(""),f=(0,c.d4)((e=>e.captcha.type));(0,l.useEffect)((()=>{if(void 0==n)return;let e=!1;A().get(n,{responseType:"blob",validateStatus:()=>!0}).catch((a=>{var t,l;const{template:c,format:r}=(0,M.wc)(n);return o.A.trackEvent({key:"SYSTEM_IMAGE_ONLOAD",is_success:0,mode:f,questionImageFormat:r,questionImageTemplate:c,code:null!==(t=null===a||void 0===a?void 0:a.code)&&void 0!==t?t:"err.code is empty",message:null!==(l=null===a||void 0===a?void 0:a.message)&&void 0!==l?l:"err.message is empty",error:JSON.stringify(a)}),e=!0,A().get(i,{responseType:"blob",validateStatus:()=>!0})})).then((a=>{const{template:t,format:l}=(0,M.wc)(e?i:n);o.A.trackEvent({key:"SYSTEM_IMAGE_ONLOAD",is_success:1,mode:f,questionImageFormat:l,questionImageTemplate:t});const c=URL.createObjectURL(a);g(c)})).catch((e=>{var a,t;const{template:l,format:c}=(0,M.wc)(i);o.A.trackEvent({key:"SYSTEM_IMAGE_ONLOAD",is_success:0,mode:f,questionImageFormat:c,questionImageTemplate:l,code:null!==(a=null===e||void 0===e?void 0:e.code)&&void 0!==a?a:"err.code is empty",message:null!==(t=null===e||void 0===e?void 0:e.message)&&void 0!==t?t:"err.message is empty",error:JSON.stringify(e)})}))}),[i,n,f]);const v=(0,l.useCallback)((()=>{null===d||void 0===d||d()}),[d]);if(""!=m)return l.createElement("img",{id:t,ref:a,src:m,alt:p,style:h,className:u,draggable:!1,onClick:r,onLoad:()=>{null===s||void 0===s||s()},onError:v})}));S.displayName="CaptchaImage";var k=function(e){var a,t;const[n,r]=(0,l.useState)(0),{isNarrowScreen:d}=(0,s.Ay)(),h=(0,c.d4)((e=>e.captcha.type)),m=(0,c.d4)((e=>e.whirlModel.sliderRightBound)),g=(0,c.d4)((e=>e.captcha.challenge_id)),f=(0,c.d4)((e=>e.whirlModel.questionImageURL)),E=(0,c.d4)((e=>e.whirlModel.answerImageURL)),w=(0,c.d4)((e=>{const a=e.whirlModel.questionImageURL,t=e.whirlModel.questionBackupImageURLArray;return t.length>0?t[0]:a})),A=(0,c.d4)((e=>{const a=e.whirlModel.answerImageURL,t=e.whirlModel.answerBackupImageURLArray;return t.length>0?t[0]:a})),k=(0,c.d4)((e=>e.whirlModel.isQuestionImageLoading)),x=(0,c.d4)((e=>e.whirlModel.isAnswerImageLoading)),O=(0,c.d4)((e=>e.whirlModel.questionImageLoadingErrorMessage)),T=(0,c.d4)((e=>e.whirlModel.answerImageLoadingErrorMessage)),C=(0,c.d4)((e=>e.whirlModel.answerVerticalPosition)),R=(0,c.d4)((e=>e.captchaSessionModelV2.sessionLoadingStartTime)),N=(0,c.d4)((e=>e.whirlModel.dragStartTimeStamp)),L=(0,l.useRef)(null),I=(0,l.useRef)(null),D=(0,c.d4)((e=>{const a=e.whirlModel.dragTrack;if(a.length>0){return a[a.length-1].x}return 0})),B=(0,u.A)(),F=(0,c.d4)((e=>e.whirlModel.dragTrack)),W=(0,c.wA)();(0,l.useEffect)((()=>{r(Date.now())}),[]);const U=(0,l.useCallback)((()=>{W.whirlModel.update({questionImageLoadingErrorMessage:i.Ay.t("QuestionJsonErr"),isQuestionImageLoading:!1},null)}),[W]),z=(0,l.useCallback)((()=>{W.whirlModel.update({answerImageLoadingErrorMessage:i.Ay.t("QuestionJsonErr"),isAnswerImageLoading:!1},null)}),[W]),H=(0,l.useCallback)((()=>{var e,a;L.current&&(o.A.trackEvent({key:"SYSTEM_VERIFY_ATTEMPT",is_success:1,stage:"PRE",mode:h,custom:JSON.stringify(F),duration:Date.now()-N}),W.captcha.submit({query:(0,p.vA)(B),data:{modified_img_width:null===(e=L.current)||void 0===e?void 0:e.offsetWidth,id:g,mode:h,reply:F.map((e=>{var a;return{...e,x:Math.round(e.x*((null===(a=L.current)||void 0===a?void 0:a.offsetWidth)||1))}})),models:{},log_params:{},reply2:[],models2:{},drag_width:null===(a=L.current)||void 0===a?void 0:a.offsetWidth}}))}),[g,W.captcha,N,F,h,B]),q=(0,l.useCallback)((()=>{W.whirlModel.update({isAnswerImageLoading:!1},null)}),[W]),Y=(0,l.useCallback)((e=>{const{template:a,format:t}=(0,M.wc)(f),{template:l,format:c}=(0,M.wc)(E);o.A.trackEvent({key:"SYSTEM_RENDER_ONSHOWN",stage:"AFTER",mode:h,is_success:e?1:0,duration:Date.now()-n,overall_duration:Date.now()-R,questionImageFormat:t,answerImageFormat:c,questionImageTemplate:a,answerImageTemplate:l})}),[E,h,n,f,R]),$=(0,l.useCallback)((()=>{W.whirlModel.update({isQuestionImageLoading:!1},null),Y(!0)}),[W,Y]),P=(0,l.useMemo)((()=>null!=O||null!=T?l.createElement(y.A,{message:i.Ay.t("QuestionJsonErr")+" [501]"}):k||x?l.createElement(b.A,null):null),[O,T,k,x]),J=-180*D,X=180*D,K=(0,l.useCallback)((e=>{W.whirlModel.appendDragTrack({x:e.x/m,y:e.y,contentWidth:m},null)}),[W.whirlModel,m]),[G,Q]=(0,l.useState)(0);(0,l.useEffect)((()=>{Q(110*(d?180:217)/344)}),[d,Q]);const j=(0,l.useMemo)((()=>k||x||null!=T||null!=O?"none":"block"),[T,x,k,O]);return"whirl"===h?l.createElement("div",{className:`cap-flex cap-flex-col cap-justify-center cap-items-center ${null!==(a=e.className)&&void 0!==a?a:""}`},P,l.createElement(S,{className:"cap-h-[170px] sm:cap-h-[210px]",style:{clipPath:"circle(50%)",display:k||x||null!=O||null!=T?"none":"flex",transform:`rotate(${J}deg)`},initialSrc:f,fallbackSrc:w,onError:U,onLoad:$}),l.createElement(S,{className:"cap-absolute cap-h-[105px] sm:cap-h-[128px]",style:{clipPath:"circle(50%)",transform:`rotate(${X}deg)`,display:k||x||null!=O||null!=T?"none":"flex"},initialSrc:E,fallbackSrc:A,onError:z,onLoad:q})):l.createElement("div",{className:"cap-flex cap-flex-col cap-relative"},P,l.createElement(S,{id:"captcha-verify-image",initialSrc:f,fallbackSrc:w,onLoad:$,onError:U,ref:L,className:"cap-rounded-lg cap-w-full cap-h-auto",style:{display:j},alt:i.Ay.t("captcha_whirl_title")}),l.createElement(v,{bounds:{left:0,right:m-("slide"==h?50:0)},key:E,onStart:()=>{o.A.trackEvent({key:"USER_DRAG_IMAGE_START",is_success:1,stage:"AFTER",mode:h}),W.whirlModel.update({dragStartTimeStamp:Date.now()},null),_.Fr&&console.log("bytedance://disable_swipe")},onDrag:K,onStop:H,disabled:k||x||null!=O||null!=T,position:{x:D*((null===(t=L.current)||void 0===t?void 0:t.offsetWidth)||0),y:0},style:{top:C*(d?1.025:1.29),left:0}},l.createElement(S,{ref:I,initialSrc:E,fallbackSrc:A,onError:z,onLoad:q,style:{width:`${G}px`,height:`${G}px`,display:j}})))};var x=function(){return l.createElement(l.Fragment,null,l.createElement(k,null),l.createElement(E,{className:"cap-w-full cap-mt-6 cap-mb-4"}))},O=t(7210);var T=new class{constructor(){this.count=0,this.data={t:[]},this.handleTouch=e=>{const a=[];for(let t=0;t{this.reset(),document.addEventListener("touchstart",this.handleTouch),document.addEventListener("touchmove",this.handleTouch)},this.unmount=()=>{document.removeEventListener("touchstart",this.handleTouch),document.removeEventListener("touchmove",this.handleTouch)},this.collectTouch=e=>{Array.prototype.push.apply(this.data.t,e)},this.getData=()=>this.data,this.reset=()=>{this.data={t:[]}}}},C=t(8757);var R=function(){const[e,a]=(0,l.useState)(0),{isNarrowScreen:t}=(0,s.Ay)(),r=(0,c.d4)((e=>e.captcha.initTime)),d=(0,c.d4)((e=>e.captcha.challenge_id)),h=(0,c.d4)((e=>e.captcha.type)),m=(0,u.A)(),g=(0,c.d4)((e=>e.iconAndThreeDModel.imageURL)),f=(0,c.d4)((e=>{const a=e.iconAndThreeDModel.imageURL,t=e.iconAndThreeDModel.backupImageUrlArray;return t.length>0?t[0]:a})),v=(0,c.d4)((e=>0===e.iconAndThreeDModel.selected_pos.length||e.captcha.loading||e.iconAndThreeDModel.isImageLoading||null!=e.iconAndThreeDModel.imageLoadingErrorMessage||"pass"===e.captcha.verify_status)),_=(0,c.d4)((e=>e.iconAndThreeDModel.isImageLoading)),E=(0,c.d4)((e=>e.iconAndThreeDModel.imageLoadingErrorMessage)),w=(0,c.d4)((e=>e.iconAndThreeDModel.selected_pos)),A=(0,c.d4)((e=>e.captchaSessionModelV2.sessionLoadingStartTime)),k=(0,c.wA)(),x=(0,l.useRef)(null);(0,l.useEffect)((()=>{a(Date.now())}),[]);const O=(0,l.useCallback)((()=>{var a;o.A.trackEvent({key:"SYSTEM_VERIFY_ATTEMPT",is_success:1,duration:Date.now()-e,stage:"PRE",mode:h}),k.captcha.submit({query:(0,p.vA)(m),data:{modified_img_width:null===(a=x.current)||void 0===a?void 0:a.offsetWidth,id:d,mode:h,reply:w.map((e=>{var a,t;return{x:e.x*(null===(a=x.current)||void 0===a?void 0:a.offsetWidth),y:e.y*(null===(t=x.current)||void 0===t?void 0:t.offsetHeight),time:e.time-r}})),models:{},log_params:{},reply2:[],models2:{}}})}),[e,h,k.captcha,m,d,w,r]),T=(0,l.useCallback)((e=>{var a,t;const l=x.current;let c={x:0,y:0,time:Date.now()};if(l){var n,i;const a=l.getBoundingClientRect();c={x:(e.clientX-a.left)/(null===(n=x.current)||void 0===n?void 0:n.offsetWidth),y:(e.clientY-a.top)/(null===(i=x.current)||void 0===i?void 0:i.offsetHeight),time:Date.now()}}else{var r,s;o.A.trackEvent({key:"USER_CLICK_EMPTYAREA",is_success:0,stage:"AFTER",custom:JSON.stringify(c),x:null===(r=c)||void 0===r?void 0:r.x,y:null===(s=c)||void 0===s?void 0:s.y,mode:h})}o.A.trackEvent({key:"USER_CLICK_EMPTYAREA",is_success:1,stage:"AFTER",custom:JSON.stringify(c),x:null===(a=c)||void 0===a?void 0:a.x,y:null===(t=c)||void 0===t?void 0:t.y,mode:h}),k.iconAndThreeDModel.appendPos(c,null)}),[k.iconAndThreeDModel,h]),C=(0,l.useCallback)((e=>{k.iconAndThreeDModel.removePos(e,null)}),[k]),R=(0,l.useCallback)((a=>{k.iconAndThreeDModel.update({isImageLoading:!1,imageLoadingErrorMessage:a?null:i.Ay.t("QuestionJsonErr")},null);const{template:t,format:l}=(0,M.wc)(g);o.A.trackEvent({key:"SYSTEM_RENDER_ONSHOWN",stage:"AFTER",is_success:a?1:0,overall_duration:Date.now()-A,duration:Date.now()-e,mode:h,questionImageFormat:l,questionImageTemplate:t})}),[k.iconAndThreeDModel,g,A,e,h]),N=(0,l.useCallback)((()=>{R(!0)}),[R]),L=(0,l.useCallback)((()=>{R(!1)}),[R]),I=(0,l.useMemo)((()=>null!=E?l.createElement(y.A,{message:i.Ay.t("QuestionJsonErr")+" [501]"}):_?l.createElement(b.A,null):null),[E,_]),D=(0,l.useMemo)((()=>w.map(((e,a)=>l.createElement("div",{key:a+1,className:"cap-flex cap-absolute cap-cursor-pointer",style:{top:e.y*(t?180:217),left:e.x*(t?288:348)},onClick:()=>C(a)},l.createElement(n.Vbv,{badgeCount:a+1},l.createElement("div",null)))))),[w,C,t]);return l.createElement("div",{className:"cap-flex cap-flex-col cap-relative",style:{minHeight:"inherit"}},I,l.createElement(S,{ref:x,initialSrc:g,fallbackSrc:f,onClickEmptyArea:T,onLoad:N,onError:L,alt:i.Ay.t("captchaOpti_hCaptchaModal1_header"),className:"cap-rounded-lg cap-cursor-pointer cap-w-full cap-h-auto",style:{display:_||null!=E?"none":"flex"}}),D,l.createElement(n.I05,{variant:"primary",label:i.Ay.t("H5_VerifyTips_9"),disabled:v,className:"cap-my-8 cap-w-full",onClick:O}))};let N=function(e){return e.SMALL="24",e.LARGE="32",e}({});var L=function(){const{isNarrowScreen:e}=(0,s.Ay)();return l.createElement("div",{className:"cap-flex cap-flex-col cap-items-center cap-justify-center cap-h-[128px] sm:cap-h-[196px]"},l.createElement(n.iRZ,{size:e?N.SMALL:N.LARGE}))},I=t(6057);var D=()=>{const e=(0,c.wA)();return(0,l.useEffect)((()=>{const a=setInterval((()=>{const a=document.querySelector(".captcha-feedback-modal");if(a){const{width:t,height:l}=a.getBoundingClientRect();e.feedbackModel.update({boxWidth:Math.round(t),boxHeight:Math.round(l),isOpen:!0},null)}else e.feedbackModel.update({boxWidth:null,boxHeight:null,isOpen:!1},null)}),500);return()=>clearInterval(a)}),[e.feedbackModel]),null};const B=(0,l.lazy)((()=>t.e(848).then(t.bind(t,7848)).catch((e=>(o.A.trackEvent({key:"SYSTEM_CHUNK_LOAD_ERROR",error:e.message,is_success:0,params_for_special:JSON.stringify(e.stack)}),{default:()=>l.createElement("div",null,"Failed to load voice captcha")}))))),F=(0,l.lazy)((()=>t.e(472).then(t.bind(t,6472)).catch((e=>(o.A.trackEvent({key:"SYSTEM_CHUNK_LOAD_ERROR",error:e.message,is_success:0,params_for_special:JSON.stringify(e.stack)}),{default:()=>l.createElement("div",null,"Failed to load none captcha")}))))),W=(0,l.lazy)((()=>Promise.all([t.e(324),t.e(92)]).then(t.bind(t,1092)).catch((e=>(o.A.trackEvent({key:"SYSTEM_CHUNK_LOAD_ERROR",error:e.message,is_success:0,params_for_special:JSON.stringify(e.stack)}),{default:()=>l.createElement("div",null,"Failed to load hCaptcha")}))))),U=(0,l.lazy)((()=>t.e(583).then(t.bind(t,8583)).catch((e=>(o.A.trackEvent({key:"SYSTEM_CHUNK_LOAD_ERROR",error:e.message,is_success:0,params_for_special:JSON.stringify(e.stack)}),{default:()=>l.createElement("div",null,"Failed to load arkose")}))))),z=(0,l.lazy)((()=>Promise.all([t.e(324),t.e(553)]).then(t.bind(t,1553)).catch((e=>(o.A.trackEvent({key:"SYSTEM_CHUNK_LOAD_ERROR",error:e.message,is_success:0,params_for_special:JSON.stringify(e.stack)}),{default:()=>l.createElement("div",null,"Failed to load hashcash captcha")}))))),H=(0,l.lazy)((()=>t.e(47).then(t.bind(t,9047)).catch((e=>(o.A.trackEvent({key:"SYSTEM_CHUNK_LOAD_ERROR",error:e.message,is_success:0,params_for_special:JSON.stringify(e.stack)}),{default:()=>l.createElement("div",null,"Failed to load geetest")})))));function q(){var e,a;const t=(0,l.useMemo)((()=>Date.now()),[]),{isNarrowScreen:r}=(0,s.Ay)(),d=(0,u.A)(),h=(0,c.d4)((e=>e.captcha.isOpen)),m=(0,c.d4)((e=>e.captchaOptionSettingModel.sideSlide)),v=(0,c.d4)((e=>e.captchaOptionSettingModel.useCaptureStyle)),E=(0,c.d4)((e=>e.captcha.challenge_id)),w=(0,c.d4)((e=>e.captcha.challenge_code)),A=(0,c.d4)((e=>e.captcha.loading)),M=(0,c.d4)((e=>e.captcha.errorMessage)),S=(0,c.d4)((e=>e.captchaOptionSettingModel.showMode)),k=(0,c.d4)((e=>e.captcha.type)),N=(0,c.d4)((e=>e.captcha.verify_status)),q=(0,c.wA)(),Y=(0,c.d4)((e=>{var a;return(null===(a=e.captchaOptionSettingModel.theme)||void 0===a?void 0:a.keepSmallWidth)||!1})),$=(0,c.d4)((e=>e.geeTestModel.boxWidth)),P=(0,c.d4)((e=>e.geeTestModel.boxHeight)),J=(0,c.d4)((e=>e.hCaptchaModel.boxWidth)),X=(0,c.d4)((e=>e.hCaptchaModel.boxHeight)),K=(0,c.d4)((e=>e.feedbackModel.boxWidth)),G=(0,c.d4)((e=>e.feedbackModel.boxHeight)),Q=(0,c.d4)((e=>e.feedbackModel.isOpen)),[j,V]=(0,l.useMemo)((()=>{switch(k){case"geetest":return["",`cap-w-[284px] cap-h-[${Math.max(P,320)}px]`];case"hcaptcha":return J&&X?["",`cap-w-[${Math.max(328,J)}px] cap-h-[470px]`]:["","cap-h-[82px]"];case"arkose":return["","cap-h-[580px]"];default:return Y?["cap-w-[312px]","cap-min-h-[180px]"]:["sm:cap-w-[380px]","cap-min-h-[180px]"]}}),[Y,k,P,J,X]),Z=(0,l.useMemo)((()=>{let e={width:r?"312px":"380px"};switch(k){case"geetest":e={width:"284px",height:_.ib?"392px":"auto"};break;case"hcaptcha":e={width:J?`${Math.max(328,J)}px`:"328px"};break;case"arkose":e={width:"fit-content",minWidth:"300px"}}if(Q&&K&&G){var a;const t=parseInt((null===(a=e.width)||void 0===a?void 0:a.toString())||"0",10),l=Math.max(t,K);return{...e,minWidth:`${l}px`,minHeight:`${G}px`}}return e}),[r,k,Q,K,G,J]),ee=(0,l.useRef)();(0,l.useEffect)((()=>{const e=()=>{q.captchaOptionSettingModel.update({isNarrowScreen:window.innerWidth<640},null)};return window.addEventListener("resize",e),e(),()=>{window.removeEventListener("resize",e)}}),[q.captchaOptionSettingModel]);const ae=(0,l.useCallback)(((e,a)=>{o.A.trackEvent({key:"SYSTEM_WINDOW_BEFOREUNLOAD",loading:e,verify_status:a,stage:"AFTER",duration:Date.now()-t,is_success:1,mode:k})}),[t,k]);(0,l.useEffect)((()=>{q.captcha.refresh({query:(0,p.vA)(d)}),o.A.trackEvent({key:"SYSTEM_RENDER_GENERIC",stage:"AFTER",duration:Date.now()-t,is_success:1,mode:k})}),[]),(0,l.useEffect)((()=>(window.addEventListener("beforeunload",ae.bind(A,N)),"disabled"===m&&_.ib&&console.log("bytedance://disable_swipe"),_.ib&&((0,O.K1)("goToClose").then((e=>{const a=e&&e.style||"mask_click_close";(0,O.F)({challenge_id:E,challenge_mode:k,challenge_code:w,verifyResultType:C.z[a],closeType:a,duration:Date.now()-t})})),(0,O.K1)("verifyReport").then((e=>{e&&e.data instanceof Array&&o.A.batchSendEvents(e.data.concat(window.captchaFailEvents))}))),_.Fr&&T.mount(),p.XP.init(v),p.XP.disabled(),()=>{_.Fr&&T.unmount(),p.XP.allow(),window.removeEventListener("beforeunload",(()=>ae(A,N)))})),[w,E,ae,A,k,t,m,v,N]);const te=(0,l.useMemo)((()=>({hcaptcha:W,arkose:U,voice:B,hashcash:z,none:F,whirl:x,slide:x,icon:R,"3d":R,geetest:H})),[]),le=(0,c.d4)((e=>e.iconAndThreeDModel.isImageLoading)),ce=(0,c.d4)((e=>e.whirlModel.isQuestionImageLoading)),ne=(0,c.d4)((e=>e.whirlModel.isAnswerImageLoading)),oe=(0,c.d4)((e=>e.voiceModel.isBackgroundImageLoading)),ie=(0,c.d4)((e=>e.arkoseModel.isScriptLoading)),re=(0,c.d4)((e=>e.geeTestModel.scriptLoading)),se=(0,c.d4)((e=>e.geeTestModel.scriptLoading)),de=(0,c.d4)((e=>{var a;return(null===(a=e.captchaOptionSettingModel.theme)||void 0===a?void 0:a.lightBgColor)||null})),pe=(0,c.d4)((e=>{var a;return(null===(a=e.captchaOptionSettingModel.theme)||void 0===a?void 0:a.darkBgColor)||null})),ue=(0,n.HIr)();(0,l.useEffect)((()=>{if(ee.current&&_.ib){var e,a;const t=null===(e=ee.current)||void 0===e?void 0:e.offsetWidth,l=null===(a=ee.current)||void 0===a?void 0:a.offsetHeight;(0,O.Uh)({h:Math.max(G,l,"geetest"==k&&Math.max(P,392),"hcaptcha"==k?X:0),w:Math.max(K,t,"geetest"==k?$:0,"hcaptcha"==k?J:0)})}}),[null===(e=ee.current)||void 0===e?void 0:e.offsetHeight,null===(a=ee.current)||void 0===a?void 0:a.offsetWidth,le,ce,ne,oe,ie,re,se,Q,K,G,P,$,J,X,k]);const he=(0,l.useMemo)((()=>e=>{var a,t;o.A.trackEvent({key:"SYSTEM_ERROR_ERRORBOUNDRY",stage:"MAIN_CONTENT",is_success:0,code:null!==(a=null===e||void 0===e?void 0:e.code)&&void 0!==a?a:"err.code is empty",message:null!==(t=null===e||void 0===e?void 0:e.message)&&void 0!==t?t:"err.message is empty",error:JSON.stringify(e),mode:k})}),[k]),me=(0,l.useMemo)((()=>{let e=l.createElement("div",null);if(A)e=l.createElement(b.A,null);else if("pass"===N)e=l.createElement(L,null);else if(null!=M)e=l.createElement(y.A,{message:"fail"===N?i.Ay.t("verify_fail"):M+" [500]"});else{const a=te[k];e=a?l.createElement(I.tH,{fallback:l.createElement(y.A,null),onError:he},l.createElement(l.Suspense,{fallback:l.createElement(b.A,null)},l.createElement(a,null))):null}const a="arkose"===k?"cap-px-0":"cap-px-12 sm:cap-px-16";return l.createElement("div",{id:"captcha-verify-container-main-page",ref:ee,"aria-modal":!0,role:"main",className:`cap-flex cap-py-4 ${a} sm:cap-py-12 cap-flex-col cap-justify-between cap-h-full ${j}`},l.createElement(D,null),l.createElement(f,{className:"cap-w-full cap-mb-8"}),l.createElement("div",{className:`cap-flex cap-flex-col cap-w-full cap-justify-center ${V}`},e),l.createElement(g,{className:"cap-w-full"}))}),[A,N,M,j,V,te,k,he]);if(!h){const e=document.getElementById(window.captchaOptions.ele);return e&&(e.style.display="none"),document.body.classList.remove("captcha-disable-scroll"),_.Fr&&T.unmount(),p.XP.allow(),null}return"mask"===S?l.createElement(n.nOL,{open:h,onOpenChange:()=>{},className:"captcha-verify-container",style:{...Z,maxWidth:"unset",zIndex:8e3,backgroundColor:"dark"==ue?pe:de}},me):l.createElement(n.yWh,{className:"captcha-verify-container",style:{...Z,paddingLeft:"0px",paddingRight:"0px",backgroundColor:"dark"==ue?pe:de}},me)}var Y=q}}]);