(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,88673,e=>{"use strict";var t,n=e.i(94246),l=e.i(37819),a=((t={}).link="link",t.button="button",t.popup="popup",t.popdown="popdown",t.filterCatalog="filter_catalog",t.utm="utm",t.banner="banner",t.input_field="input_field",t.field="field",t);e.s(["DataLayerActionType",()=>a,"handelDataLayerPush",0,({eventCategory:e,eventAction:t,eventActionText:a="",eventLabel:i,eventValue:r,url:s})=>{let o=r;"boolean"==typeof r&&(o=r?"on":"off");let u=!0;"filter_catalog"!==t?u=/[а-я]/i.test(a.toLowerCase()):"string"==typeof i&&(u=/[а-я]/i.test(i.toLowerCase()));let d="filter_catalog"!==t?{event:"data-event",eventCategory:e,eventAction:({link:"click_link_",button:"click_button_",popup:"show_pop_up_",popdown:"close_pop_up_",utm:"save_utm",banner:"click_banner_",input_field:"input_field_",field:"click_field_"})[t]+(0,l.translit)(a),eventLabel:i,eventValue:o,url:s}:{event:"data-event",eventAction:e,eventCategory:t,eventLabel:"string"!=typeof i||u?i:(0,l.translit)(i),eventValue:o,url:s};(0,n.dataLayerPush)(d)}])},21590,e=>{"use strict";e.s(["getDebounceFunction",0,(e=300)=>{let t=null;return n=>{t&&clearInterval(t),t=setTimeout(n,e)}}])},18492,e=>{e.v({inputs:"DebitCardsOffers-module-scss-module__MmotTG__inputs",shine:"DebitCardsOffers-module-scss-module__MmotTG__shine"})},20212,e=>{"use strict";var t=e.i(43476),n=e.i(71645);e.i(34348);var l=e.i(47611),a=e.i(16727),i=e.i(91390);e.i(89485);var r=e.i(23179),s=e.i(14044),o=e.i(7670),u=e.i(30083),d=e.i(54061),c=e.i(2404);let p=(0,d.g)("input-autocomplete"),m={input:p,pending:`${p}__pending`,pendingIcon:`${p}__pending-icon`,empty:`${p}__empty`,emptyText:`${p}__empty-text`,emptyDescription:`${p}__empty-description`,options:`${p}__options`,optionIcon:`${p}__option-icon`,button:`${p}__button`,states:{selected:`${p}--selected`}},f=({items:e,itemSize:l,renderItem:a,overscan:i=2,outerRef:r,itemsContainerClassname:s})=>{let[o,u]=(0,n.useState)({start:0,end:0}),d=(0,n.useCallback)(()=>{if(!r.current)return;let t=r.current.clientHeight,n=r.current.scrollTop;u({start:Math.max(0,Math.floor(n/l)-i),end:Math.min(e.length,Math.ceil((n+t)/l)+i)})},[l,e.length,r,i]);(0,n.useLayoutEffect)(()=>{d()},[d]),(0,n.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>d();e.addEventListener("scroll",t);let n=new ResizeObserver(()=>d());return n.observe(e),()=>{e.removeEventListener("scroll",t),n.disconnect()}},[d,r]);let c=e.length*l+16,p=e.slice(o.start,o.end),m={position:"absolute",top:0,height:p.length*l,transform:`translateY(${o.start*l}px)`,width:"100%",margin:0};return(0,t.jsx)("div",{style:{position:"relative",height:c,width:"auto",margin:"-8px"},children:(0,t.jsx)("ul",{className:s,style:m,role:"listbox",children:p.map((e,t)=>a(e,o.start+t))},"options")})};function _({inputValue:e,mappedOptions:l,pending:i=!1,optionsEmptyText:s="Нет результатов",optionsEmptyDescription:d,contentInnerRef:p,withVirtualize:g=!1,handleOptionClick:b}){let v=(0,n.useId)();if(i)return(0,t.jsx)("div",{className:m.pending,children:(0,t.jsx)(c.P,{className:m.pendingIcon,children:(0,t.jsx)(a.S,{})})});if((null==e?void 0:e.length)&&!l.length)return(0,t.jsxs)("div",{className:m.empty,children:[(0,t.jsx)("div",{className:m.emptyText,children:s}),d&&(0,t.jsx)("div",{className:m.emptyDescription,children:d})]});let h=e=>(0,t.jsx)(r.g,{role:"option","aria-selected":e.selected,as:"li",disabled:e.disabled,label:e.label,caption:e.caption,focused:e.active,onClick:()=>b(e),append:(0,t.jsx)(c.P,{className:(0,o.default)(m.optionIcon,{[m.states.selected]:e.selected}),style:{fontSize:24},children:(0,t.jsx)(u.S,{})})},JSON.stringify(e.value));return g?(0,t.jsx)(f,{outerRef:p,items:l,itemSize:40,renderItem:h,itemsContainerClassname:m.options}):(0,t.jsx)("ul",{className:m.options,id:v,role:"listbox",children:l.map(h)},"options")}let g=(0,n.forwardRef)(({value:e,selectedValue:l,label:o,options:d=[],state:c,icon:p,rightLabel:f,slotLeft:g,desktopMaxHeight:b,pending:v=!1,buttonLabel:h="Выбрать",optionValue:y="value",optionLabel:x="label",optionCaption:C="caption",optionDisabled:j="disabled",variant:S="primary",size:k="m",disabled:I=!1,caption:w,hasCaption:$=!1,keepFocus:L=!1,optionsEmptyText:N="Нет результатов",optionsEmptyDescription:T,withVirtualize:D,onChange:M,onSelect:R,onFocus:A,onBlur:O,onKeydown:E,dataQa:P,dataId:B,className:z,style:U,...F},V)=>{let[H,K]=(0,n.useState)(!1),[G,Q]=(0,n.useState)(""),W=(0,n.useRef)(null),q=(0,n.useRef)(null),J=(0,n.useRef)(null),X=(0,n.useRef)(null),Y=(0,r.k)("m");(0,n.useImperativeHandle)(V,()=>q.current);let Z=(0,n.useMemo)(()=>Y?H&&(d.length>0||!!G||v):H,[G,Y,H,d.length,v]),ee=(0,n.useMemo)(()=>d.map((e,t)=>{let n=(0,u.g)(e,y,e),a=(0,u.g)(l,y,l);return{index:t,value:n,label:(0,u.g)(e,x,e),caption:(0,u.g)(e,C),disabled:(0,u.g)(e,j),selected:a===n,original:e}}),[C,j,x,y,d,l]),et=(0,n.useMemo)(()=>ee.find(({selected:e})=>e),[ee]);(0,n.useEffect)(()=>{e||l?e&&Q(e):Q("")},[e]),(0,n.useEffect)(()=>{l&&Q((0,u.g)(l,x,l))},[]),(0,n.useEffect)(()=>{H||(et?en(et.label):el())},[H]);let en=e=>{Q(e),null==M||M(e)},el=e=>{null==R||R(e)},ea=()=>{K(!1)},ei=e=>{null==O||O(e)};return(0,t.jsx)("div",{ref:V,className:m.input,"data-id":B,"data-qa":P,children:(0,t.jsxs)(r.D,{opened:Z,onToggle:K,width:"inherit",placement:"bottom",mobileFullHeight:!0,desktopMaxHeight:b,footer:Y||!l?void 0:(0,t.jsx)(a.a,{label:h,disabled:!l,className:m.button,onClick:()=>{ea()}}),heading:Y?void 0:(0,t.jsx)(i.I,{inputRef:J,className:z,style:U,value:G,label:o,rightLabel:f,slotLeft:g,icon:p,state:c,caption:w,hasCaption:$,onChange:en,onBlur:ei,...F}),dataQa:(0,s.g)(`${P}-dropdown`,!!P),children:[(0,t.jsx)(r.h,{asChild:!0,children:(0,t.jsx)(i.I,{value:G,label:o,rightLabel:f,slotLeft:g,icon:p,size:k,variant:S,state:c,disabled:I,caption:w,hasCaption:$,...{onClick:void 0,onChange:en,onFocus:e=>{K(!0),Y||(e.preventDefault(),setTimeout(()=>{var e;null==(e=J.current)||e.focus()},100)),null==A||A(e)},onBlur:ei,onKeyDown:e=>{"Tab"===e.key&&ea(),null==E||E(e)}},ref:W,inputRef:q,...F,dataQa:(0,s.g)(`${P}-dropdown-input`,!!P)})}),(0,t.jsx)(r.a,{contentInnerRef:X,children:(0,t.jsx)(_,{inputValue:G,mappedOptions:ee,pending:v,optionsEmptyText:N,optionsEmptyDescription:T,handleOptionClick:e=>{var t;if(en(e.label),el(e.original),Y){if(L){null==(t=q.current)||t.focus();return}ea()}},contentInnerRef:X,withVirtualize:D})})]})})});g.displayName="InputAutocomplete";var b=e.i(62798),v=e.i(89867),h=e.i(67638),y=e.i(82372),x=e.i(231);let C={id:0,name:"Вся Россия"},j=[{id:1095,main:1,name:"Москва",name_p:"Москве",name_r:"Москвы",parentId:77,url:"moskva"},{id:1096,main:1,name:"Санкт-Петербург",name_p:"Санкт-Петербурге",name_r:"Санкт-Петербурга",parentId:78,url:"sankt-peterburg"},{id:720,main:1,name:"Новосибирск",name_p:"Новосибирске",name_r:"Новосибирска",parentId:54,url:"novosibirsk"},{id:894,main:1,name:"Екатеринбург",name_p:"Екатеринбурге",name_r:"Екатеринбурга",parentId:66,url:"ekaterinburg"},{id:691,main:1,name:"Нижний Новгород",name_p:"Нижнем Новгороде",name_r:"Нижнего Новгорода",parentId:52,url:"nizhniy_novgorod"}];e.i(32847);var S=e.i(66035),k=e.i(21590),I=e.i(88673),w=e.i(18492);let $=()=>{let e,a,i=(0,h.getEnvValue)().NEXT_PUBLIC_BASE_URL,[r,s]=(0,n.useState)(null),{regions:u}=(0,v.useCitySelectContext)(),{regionOptions:d,handleRegionChange:c,selectedRegion:p,selectedTown:m}=(e=>{let[t,l]=(0,n.useState)(null),[a,i]=(0,n.useState)(null),r=x.appLocalStorage.getItem("user_town"),s=x.appLocalStorage.getItem("user_region"),o=x.appLocalStorage.getItem("auto_region"),u=x.appLocalStorage.getItem("auto_town"),d=(0,n.useMemo)(()=>{let e=((r||s)??(u||o)??C).id,t=((r||s)??(u||o)??C).name;return{value:t+e,label:t}},[]),[c,p]=(0,n.useState)(d),m=(0,n.useMemo)(()=>e.map(e=>({...e,towns:e.towns.map(t=>({...t,parentId:e.id}))})),[e]),f=(0,n.useMemo)(()=>{let e=m.map(({towns:e})=>e).reduce((e,t)=>[...e,...t],[]).filter(e=>!j.find(t=>t.name===e.name));return[...j,...e]},[m]);return{regionValue:c,regionOptions:(0,n.useMemo)(()=>[C,...f,...m].map(e=>({value:e.name+e.id,label:e.name,url:e.id})),[m,f]),handleRegionChange:(0,n.useCallback)(e=>{if(!e)return;p(e[0]);let t=null,n=null;C.name!==e[0].label&&(n=(t=f.find(t=>t.name===e[0].label)??null)?m.find(e=>e.id===Number(t?.parentId))??null:m.find(t=>t.name===e[0].label)??null),l(n),i(t)},[m,f]),selectedRegion:t,selectedTown:a}})(u),[f,_]=(0,n.useState)(""),$=(0,n.useRef)(null),L=(0,n.useMemo)(()=>(0,k.getDebounceFunction)(750),[]),N=m??p?.towns.find(({main:e})=>e)??null,T=(e=new URLSearchParams,p&&e.set("regionId",String(p.region_id)),N&&e.set("townId",String(N.id)),e.toString());(0,n.useEffect)(()=>{T!==$.current&&(L(()=>{(0,y.callApi)({url:`/api/debit-cards/count?${T}`,options:{isAppApi:!0}}).then(e=>{s(e.data?.totalCards||null)})}),$.current=T)},[T,L]);let D=`${i}${((e,t)=>{if(!e)return"/debetovye_karty";let n=`/debetovye_karty/reg_${e.url}`;return t&&t.url!==e.url?`${n}/${t.url}`:n})(p,N)}`,M=`${r||0} ${(0,b.pluralize)(r||0,"предложение","предложения","предложений")}`;return(0,t.jsxs)(S.OffersWrapper,{className:(0,o.default)(w.default.debitCardsOffersWrapper,"disableContentBlocksStyles"),title:"Дебетовые карты",children:[(0,t.jsx)("div",{className:w.default.inputs,children:(0,t.jsx)(g,{variant:"secondary",label:"Мое местоположение",value:f,options:d.filter(e=>e.label.includes(f)),onChange:_,onSelect:e=>e?c([e]):null})}),(0,t.jsx)(l.Button,{as:"a",className:w.default.button,label:`Смотреть ${M}`,variant:"primary",size:"s",href:D,onClick:(a=I.DataLayerActionType.button,()=>{(0,I.handelDataLayerPush)({eventCategory:"main_top_offers_block",eventAction:a,eventActionText:"смотреть",eventLabel:"debit_cards_calculator_top_offers",eventValue:void 0})})})]})};e.s(["DebitCardsOffers",0,$],2932),e.s([],23833),e.i(23833),e.i(2932),e.s(["DebitCardsOffers",0,$],20212)},44446,e=>{e.n(e.i(20212))}]);