import{u as N,j as e,F as W,C as We,T as ue,S as D,a as ie,b as pe,r as d,c as b,d as y,A as Be,B as v,I as C,L as O,D as ze,R as Ve,O as Ge,e as q,f as Oe,g as G,h as E,i as he,k as X,l as fe,M as B,G as xe,m as ge,n as me,o as ye,p as Y,q as qe,s as Ue,t as Ke,v as Ze,w as Xe,x as Ye}from"./vendor-BgD923YP.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();const z=[{id:6,name:"Поиск"},{id:5,name:"Карточки"}],Je=[{id:0,name:"Все"},{id:1,name:"Активные"},{id:2,name:"Остановлены"},{id:3,name:"Неактивные"},{id:4,name:"Без биддера"}],ve=[{id:7,name:"Завершена"},{id:9,name:"Активна"},{id:11,name:"Приостановлена"}],Qe=[{id:0,name:"Все"},...ve],et=t=>{const s=ve.find(n=>n.id===t);return s?s.name:""},tt=[{title:"Кампания",dataIndex:"id",key:"id"},{title:"Параметры",key:"name",render:(t,s)=>{var n,i;return s.name||((n=s.bidder)==null?void 0:n.query)||((i=s.bidder)==null?void 0:i.name)}},{title:"Статус",key:"status",render:(t,s)=>et(s.status)},{title:"Текущая ставка",key:"bet",align:"right",render:(t,s)=>{var n;return(n=s.bidder)==null?void 0:n.bet}},{title:"Позиция",key:"place",align:"right",render:(t,s)=>{var n;return(n=s.bidder)==null?void 0:n.place}},{title:"Биддер",key:"active",render:(t,s)=>{var n;return e.jsx(We,{checked:((n=s.bidder)==null?void 0:n.active)||!1})}},{title:"Макс ставка",key:"maxbet",align:"right",render:(t,s)=>{var n;return(n=s.bidder)==null?void 0:n.maxbet}},{title:"Макс позиция",key:"top_place",align:"right",render:(t,s)=>{var n;return(n=s.bidder)==null?void 0:n.top_place}},{title:"Мин позиция",key:"low_place",align:"right",render:(t,s)=>{var n;return(n=s.bidder)==null?void 0:n.low_place}}];function st({rows:t}){const s=N();return e.jsx(W,{columns:tt,dataSource:t||[],rowKey:(n,i)=>i,size:"small",pagination:!1,scroll:{x:900},onRow:n=>({onClick:()=>{const i=n.bidder?`/campaigns/${n.bidder.id}/bidder`:`/campaigns/${n.id}`;s(i)},style:{cursor:"pointer"}})})}function nt({options:t,value:s,onChange:n}){function i(a){return t.findIndex(l=>l.id===a)}const r=t.map((a,l)=>({key:String(l),label:a.name}));return e.jsxs("div",{children:[e.jsx("h4",{children:"Типы кампаний"}),e.jsx(ue,{tabPosition:"left",activeKey:String(i(s)),onChange:a=>{n&&n(t[parseInt(a)].id)},items:r})]})}const V="/api",U=`${V}/v2`,J=`${U}/campaign`;function it({options:t,value:s,onChange:n}){const i=t.map((r,a)=>({key:String(a),label:r.name}));return e.jsxs("div",{children:[e.jsx("h4",{children:"Магазины"}),e.jsx(ue,{tabPosition:"left",activeKey:String(s),onChange:r=>{n&&n(parseInt(r))},items:i})]})}function T({count:t=4}){return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[...Array(t)].map((s,n)=>e.jsx(D.Input,{active:!0,block:!0,style:{height:32,width:"100%"}},n))})}function rt({status:t,bidder:s,onChange:n}){return e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8},children:[e.jsx(ie,{style:{flex:1},size:"small",value:t||0,onChange:i=>n&&n("status",i),options:Qe.map(i=>({value:i.id,label:i.name})),placeholder:"Статус"}),e.jsx(ie,{style:{flex:1},size:"small",value:s||0,onChange:i=>n&&n("bidder",i),options:Je.map(i=>({value:i.id,label:i.name})),placeholder:"Биддер"})]})}const at=`${U}/supplier/`,lt=(t,s,n)=>{const i=new URLSearchParams({...n,advert_type:t,supplier_id:s});return`${J}/?${i.toString()}`};function ot(){const[t,s]=pe(),[n,i]=d.useState(!0),[r,a]=d.useState([]),[l,o]=d.useState([]),[u,c]=d.useState(void 0),h=parseInt(t.get("type")||6),p=parseInt(t.get("supplier")||0),f=parseInt(t.get("status")||0),x=parseInt(t.get("bidder")||0),g=(m,j)=>{const k=new URLSearchParams(t);k.set(m,j),s(k)};return d.useEffect(()=>(r.length===0&&(i(!0),b.get(at).then(m=>{a(m.data)}).finally(()=>i(!1))),()=>{}),[]),d.useEffect(()=>{var m;if(r.length>0){const j=lt(h,(m=r[p])==null?void 0:m.id,{status:f,bidder:x});i(!0),b.get(j).then(k=>{o(k.data)}).finally(()=>i(!1))}},[r,t]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(y.Title,{level:4,style:{margin:0},children:"Кампании"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"240px 1fr"},children:[e.jsxs("div",{style:{marginRight:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(nt,{options:z,value:h,onChange:m=>g("type",m)}),e.jsx(it,{options:r,value:p,onChange:m=>g("supplier",m)})]}),e.jsxs("div",{style:{flexGrow:1},children:[e.jsx(rt,{status:f,bidder:x,onChange:(m,j)=>g(m,j)}),n?e.jsx(T,{count:5}):e.jsx(st,{rows:l})]})]})]})}function je(){const t=document.cookie.match(/csrftoken=([^ ;]+)/);if(t)return t[1]}function be(t,s){return b.get(`${V}/${t}`,s)}function P(t,s,n){const i={"X-CSRFToken":je()},r={withCredentials:!0,...n,headers:i};return b.post(`${V}/${t}`,s,r)}function ct(t,s){const n={"X-CSRFToken":je()},i={withCredentials:!0,...s,headers:n};return b.delete(`${V}/${t}`,i)}function w(t,s){return be(`v2/${t}/`,s)}function Ce(t,s,n){return P(`v2/${t}/`,s,n)}function dt(t,s){return ct(`v2/${t}/`,s)}function Q(t){var n;const s=(n=t.response)==null?void 0:n.data;return s!=null&&s.detail?s.detail:s!=null&&s.error?s.error:t.message}const ut="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20style='margin:%20auto;%20background:%20none;%20display:%20block;%20shape-rendering:%20auto;'%20width='200px'%20height='200px'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='xMidYMid'%3e%3cg%20transform='translate(80,50)'%3e%3cg%20transform='rotate(0)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='1'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.875s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.875s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(71.21320343559643,71.21320343559643)'%3e%3cg%20transform='rotate(45)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.875'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.75s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.75s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(50,80)'%3e%3cg%20transform='rotate(90)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.75'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.625s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.625s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(28.786796564403577,71.21320343559643)'%3e%3cg%20transform='rotate(135)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.625'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.5s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.5s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(20,50.00000000000001)'%3e%3cg%20transform='rotate(180)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.5'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.375s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.375s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(28.78679656440357,28.786796564403577)'%3e%3cg%20transform='rotate(225)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.375'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.25s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.25s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(49.99999999999999,20)'%3e%3cg%20transform='rotate(270)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.25'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.125s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.125s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(71.21320343559643,28.78679656440357)'%3e%3cg%20transform='rotate(315)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.125'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='0s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='0s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3c!--%20[ldio]%20generated%20by%20https://loading.io/%20--%3e%3c/svg%3e";function ee(){const[t,s]=d.useState(0);return d.useEffect(()=>(s(1),()=>{s(0)}),[]),e.jsx("div",{className:"spinner-wrapper",children:e.jsx("img",{src:ut,className:"spinner-img",style:{opacity:t}})})}const pt=[],ht=(t,s)=>{switch(s.type){case"ADD":return[s.payload,...t];case"REMOVE":return t.filter(n=>n.id!==s.payload);default:return t}},_e=d.createContext(pt),R=()=>d.useContext(_e);function ft({children:t}){const[s,n]=d.useReducer(ht,[]),i=(u,c)=>{const h=Math.round(Math.random()*1e9);n({type:"ADD",payload:{id:h,severity:"info",text:u,...c}}),setTimeout(()=>{r(h)},5e3)},r=u=>{n({type:"REMOVE",payload:u})},a=(u,c={})=>{i(u,{...c,severity:"error"})},o={showMessage:i,showError:a,showRequestError:u=>{a(Q(u))}};return e.jsxs(_e.Provider,{value:o,children:[t,e.jsx("div",{style:{position:"fixed",left:0,bottom:0,zIndex:2e3,display:"flex",flexDirection:"column",gap:4,padding:4},children:s.map(u=>e.jsx(Be,{type:u.severity==="error"?"error":"info",message:u.text,closable:!0,onClose:()=>r(u.id),showIcon:!0},u.id))})]})}const Z={},Se=d.createContext(Z);function xt({children:t}){const[s,n]=d.useState(Z),i=()=>{w("user/profile").then(l=>{n({...l.data})})},r=()=>{n({...Z,auth:!1})};d.useEffect(()=>{i()},[]);const a={profile:s,getProfile:i,clearProfile:r};return e.jsx(Se.Provider,{value:a,children:t})}const F=()=>d.useContext(Se),I=({children:t,...s})=>{const{variant:n,color:i,sx:r,size:a,type:l,disabled:o,onClick:u,component:c,href:h,target:p,...f}=s;let x="default",g=!1;n==="contained"?x="primary":n==="outlined"&&(x="default"),i==="error"&&(g=!0);const m={fontSize:"16px",lineHeight:"26px",fontWeight:500,padding:"8px 20px",height:"auto",...r||{}};return c==="a"||h?e.jsx("a",{href:h,target:p,style:{textDecoration:"none"},children:e.jsx(v,{type:x,danger:g,disabled:o,onClick:u,style:m,htmlType:l,children:t})}):e.jsx(v,{type:x,danger:g,disabled:o,onClick:u,style:m,htmlType:l,children:t})},we=()=>{const t=N(),{getProfile:s}=F(),{showRequestError:n}=R(),[i,r]=d.useState(!1),[a,l]=d.useState(""),[o,u]=d.useState(""),c=h=>{h.preventDefault(),r(!0),P("user/login",{login:a,password:o}).then(p=>{s(),t("/?auth=success")}).catch(p=>{console.log(p),n(p)}).finally(()=>r(!1))};return e.jsxs("div",{style:{maxWidth:444,margin:"0 auto"},children:[e.jsx("h1",{children:"Авторизация"}),e.jsx("form",{onSubmit:c,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(C,{id:"login",placeholder:"Введите логин",size:"large",required:!0,type:"tel",autoComplete:"on",value:a,onChange:h=>l(h.target.value)}),e.jsx(C.Password,{id:"password",placeholder:"Введите пароль",size:"large",required:!0,autoComplete:"on",value:o,onChange:h=>u(h.target.value)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(I,{variant:"contained",type:"submit",disabled:i,color:"primary",children:"Войти"}),e.jsx(I,{variant:"outlined",component:"a",href:"https://t.me/mkeeper_direct_bot",target:"_blank",color:"secondary",children:"Получить логин и пароль"})]})]})})]})},gt="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='64'%20fill='url(%23paint0_linear_0_1)'/%3e%3cpath%20d='M21.8564%2045.3936H27.9404V50.5889C29.3988%2048.7887%2030.7204%2047.4785%2031.9053%2046.6582C33.9333%2045.2682%2036.2347%2044.5732%2038.8096%2044.5732C41.7262%2044.5732%2044.0732%2045.291%2045.8506%2046.7266C46.8532%2047.5469%2047.7646%2048.7546%2048.585%2050.3496C49.9521%2048.39%2051.5586%2046.943%2053.4043%2046.0088C55.25%2045.0518%2057.3236%2044.5732%2059.625%2044.5732C64.5469%2044.5732%2067.8965%2046.3506%2069.6738%2049.9053C70.6309%2051.8193%2071.1094%2054.3942%2071.1094%2057.6299V82H64.7178V56.5703C64.7178%2054.1322%2064.1025%2052.4574%2062.8721%2051.5459C61.6644%2050.6344%2060.1833%2050.1787%2058.4287%2050.1787C56.0133%2050.1787%2053.9284%2050.9876%2052.1738%2052.6055C50.4421%2054.2233%2049.5762%2056.9235%2049.5762%2060.7061V82H43.3213V58.1084C43.3213%2055.6247%2043.0251%2053.8132%2042.4326%2052.6738C41.4984%2050.9648%2039.7552%2050.1104%2037.2031%2050.1104C34.8789%2050.1104%2032.7598%2051.0104%2030.8457%2052.8105C28.9544%2054.6107%2028.0088%2057.8691%2028.0088%2062.5859V82H21.8564V45.3936ZM80.0303%2031.79H85.9434V60.9453L101.734%2045.3936H109.596L95.582%2059.0996L110.382%2082H102.521L91.1045%2063.543L85.9434%2068.2598V82H80.0303V31.79Z'%20fill='black'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_0_1'%20x1='64'%20y1='32'%20x2='64'%20y2='82'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23F27420'/%3e%3cstop%20offset='1'%20stop-color='%23F9AB0D'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e";function mt(){const t=N(),{clearProfile:s,profile:n}=F(),i=()=>{P("user/logout").then(()=>{s(),t("/")}).catch(a=>{})};if(!n.auth)return e.jsx(O,{to:"/auth/login",style:{color:"inherit",textDecoration:"none"},children:e.jsx(v,{type:"text",children:"Войти"})});const r=[{key:"profile",label:e.jsx(O,{to:"/profile",style:{color:"inherit",textDecoration:"none"},children:"Управление"})},{key:"logout",label:"Выйти",onClick:i}];return e.jsx(ze,{menu:{items:r},trigger:["click"],children:e.jsx(v,{type:"text",icon:e.jsx(Ve,{}),style:{fontSize:"20px"}})})}function yt({auth:t}){const{profile:s}=F();return e.jsxs("header",{style:{position:"fixed",top:0,left:0,right:0,zIndex:1001,background:"#fff",boxShadow:"0 2px 8px rgba(0,0,0,0.06)",height:"64px",display:"flex",alignItems:"center",padding:"0 24px",justifyContent:"space-between"},children:[e.jsxs(O,{to:"/",style:{display:"flex",alignItems:"center",fontWeight:700,textDecoration:"none",fontSize:"18px",color:"#F9AB0D"},children:[e.jsx("span",{style:{marginRight:"8px",height:"32px"},children:e.jsx("img",{src:gt,style:{width:"32px",height:"32px",borderRadius:"16px"}})})," mkeeper"]}),e.jsx(mt,{})]})}function vt(){return e.jsx("div",{children:e.jsx(yt,{})})}function jt(){const{profile:t}=F();return e.jsxs("div",{style:{display:"flex"},children:[e.jsx(vt,{}),e.jsxs("main",{style:{flexGrow:1,padding:"12px"},children:[e.jsx("div",{style:{height:"64px"}}),t.auth===void 0?e.jsx(ee,{}):e.jsx(Ge,{})]})]})}const ke=({label:t,headers:s,rows:n})=>e.jsxs("div",{children:[t&&e.jsx(y.Title,{level:4,style:{padding:"16px"},children:t}),e.jsx(W,{columns:s,dataSource:n||[],rowKey:(i,r)=>r,size:"small",pagination:!1,scroll:{x:900},locale:{emptyText:"Empty..."}})]}),bt=()=>{let{subjectId:t}=q();const[s,n]=d.useState(!0),[i,r]=d.useState([]),a="Запросы по категории",l=[{title:"ПОИСКОВЫЙ ЗАПРОС",key:"text",dataIndex:"text"},{title:"ПРИОРИТЕТ",key:"priority",dataIndex:"priority",align:"right"},{title:"ПОКАЗОВ В МЕСЯЦ",key:"requestCount",dataIndex:"requestCount",align:"right"}];return d.useEffect(()=>{n(!0),w("wbstat/priority-subjects",{params:{id:t}}).then(u=>{var c;r(((c=u.data)==null?void 0:c.results)||[])}).finally(()=>n(!1))},[]),s?e.jsx(Oe,{}):e.jsx("div",{children:e.jsx(ke,{label:a,headers:l,rows:i})})},Ct=()=>e.jsxs("div",{style:{background:"#fff",borderRadius:4,padding:16,marginBottom:8,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:[e.jsxs(G.Group,{style:{marginBottom:8},children:[e.jsx(G,{value:"isByWord",children:"По словам"}),e.jsx(G,{value:"isBySearch",children:"История запросов"}),e.jsx(G,{value:"isByCategory",children:"По категории"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(C,{placeholder:"Поисковый запрос",size:"small",style:{flex:1}}),e.jsx(v,{type:"primary",style:{padding:"0 25px",fontSize:12,fontWeight:700},children:"Подобрать"})]})]}),_t=()=>{const t=[{title:"СТАТИСТИКА ПО СЛОВАМ",align:"left"},{title:"ПОКАЗОВ В МЕСЯЦ",align:"left"}];return e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(Ct,{}),e.jsx(ke,{headers:t})]})};function St({options:t,onChange:s,value:n}){return e.jsx(E,{dataSource:t||[],renderItem:(i,r)=>{var a;return e.jsx(E.Item,{onClick:()=>{s(i)},style:{cursor:"pointer",background:(i==null?void 0:i.id)===(n==null?void 0:n.id)?"#FFFBF3":"transparent",padding:"8px 16px"},children:e.jsx(E.Item.Meta,{title:i.name,description:(a=i.category)==null?void 0:a.name})},r)}})}function _(t){return t.toLocaleString()}const wt=[{title:"Фраза",dataIndex:"text",key:"text"},{title:"Приоритет",dataIndex:"priority",key:"priority"},{title:"Запросов за неделю",key:"weekRequestCount",render:(t,s)=>_(s.weekRequestCount)},{title:"Запросов за месяц",key:"monthRequestCount",render:(t,s)=>_(s.monthRequestCount)},{title:"Запросов за 3 месяца",key:"quarterRequestCount",render:(t,s)=>_(s.quarterRequestCount)}];function Te({rows:t}){return t!=null&&t.length?e.jsx(W,{columns:wt,dataSource:t||[],rowKey:(s,n)=>n,size:"small",pagination:!1,scroll:{x:900}}):null}function kt(){const[t,s]=d.useState(!1),[n,i]=d.useState([]),[r,a]=d.useState(""),[l,o]=d.useState([]),[u,c]=d.useState([]),[h,p]=d.useState(void 0),[f,x]=he("",300);d.useEffect(()=>{h&&(s(!0),w(`wbstat/subjects/phrases/${h.id}`).then(j=>{var k,$;o(((k=j.data)==null?void 0:k.results)||[]),c((($=j.data)==null?void 0:$.count)||0)}).finally(()=>s(!1)))},[h]),d.useEffect(()=>{if(r.length<3){i([]);return}w("wbstat/subjects/search",{params:{query:r}}).then(k=>{var $;i((($=k.data)==null?void 0:$.results)||[])}).finally(()=>s(!1))},[f]);const g=j=>{a(j),x(j)},m=()=>{window.location.href=`/api/wbstat/subjects/phrases/${h.id}/xlsx/${h.name}.xlsx`};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(y.Title,{level:4,style:{margin:0},children:"Фразы по категориям"}),e.jsx("div",{children:e.jsx(C,{onChange:j=>{g(j.target.value)},value:r,placeholder:"Введите текст для поиска категории",size:"large"})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"240px 1fr",gap:"20px"},children:[e.jsx("div",{children:e.jsx(St,{options:n,onChange:p,value:h})}),e.jsxs("div",{style:{flexGrow:1},children:[t?e.jsx(T,{count:1}):e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:!!(l!=null&&l.length)&&e.jsxs(v,{onClick:m,icon:e.jsx(X,{}),children:["Скачать ",u," фраз в xlsx"]})}),t?e.jsx(T,{count:5}):e.jsx(Te,{rows:l})]})]})]})}function Tt(){const{subjectId:t}=q(),[s,n]=d.useState(!1),[i,r]=d.useState([]),[a,l]=d.useState(0),[o,u]=d.useState(void 0);d.useEffect(()=>{w("wbstat/subjects/search",{params:{id:t}}).then(p=>{var f,x,g;u(((x=(f=p.data)==null?void 0:f.results)==null?void 0:x.length)>0?(g=p.data)==null?void 0:g.results[0]:void 0)}).finally(()=>n(!1))},[]),d.useEffect(()=>{o&&(n(!0),w(`wbstat/subjects/phrases/${t}`).then(h=>{var p,f;r(((p=h.data)==null?void 0:p.results)||[]),l(((f=h.data)==null?void 0:f.count)||0)}).finally(()=>n(!1)))},[o]);const c=()=>{window.location.href=`/api/wbstat/subjects/phrases/${t}/xlsx/${o.name}.xlsx`};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs(y.Title,{level:4,style:{margin:0},children:["Приоритетные фразы по категории ",o==null?void 0:o.name]}),e.jsxs("div",{style:{flexGrow:1},children:[s?e.jsx(T,{count:1}):e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsxs(v,{onClick:c,icon:e.jsx(X,{}),children:["Скачать ",a," фраз в xlsx"]})}),s?e.jsx(T,{count:5}):e.jsx(Te,{rows:i})]})]})}const Ft=t=>`/campaigns/${t}`,Dt=t=>`/campaigns/${t}/bidder`;function It({instance:t,campaignId:s}){var n,i,r;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",columnGap:8,alignItems:"center",justifyContent:"space-between"},children:["Актуальная ставка: 0",e.jsx("a",{href:Ft(s),children:e.jsx(v,{type:"link",children:"Изменить параметры"})})]}),e.jsx(y.Title,{level:5,style:{margin:0},children:"Параметры биддера"}),e.jsx(C,{id:"max-cpm",placeholder:"Максимальная ставка",value:((n=t.bidder)==null?void 0:n.maxbet)??"",size:"small"}),e.jsx(C,{id:"top-place",placeholder:"Верхняя позиция",value:((i=t.bidder)==null?void 0:i.top_place)??"",size:"small"}),e.jsx(C,{id:"low-place",placeholder:"Нижняя позиция",value:((r=t.bidder)==null?void 0:r.low_place)??"",size:"small"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(v,{type:"primary",children:"Сохранить изменения"}),e.jsx(v,{children:"Запустить биддер"})]})]})}const Rt=[{title:"Позиция",dataIndex:"place",key:"place"},{title:"Бренд",key:"brand",render:(t,s)=>`${s.brand} (${s.advert_id})`},{title:"Ставка",dataIndex:"cpm",key:"cpm",align:"right"}];function Fe({data:t,place:s,campaignId:n}){const i=t==null?void 0:t.filter(r=>!s&&r.place<=20||r.place<4||r.place>t.length-3||0<=s-r.place&&s-r.place<10||0<=r.place-s&&r.place-s<5);return e.jsx(W,{columns:Rt,dataSource:i||[],rowKey:"place",size:"small",pagination:!1,rowClassName:r=>r.advert_id===n?"ant-table-row-bold":""})}function Lt({instance:t}){const s=t.updated_at?new Date(t.updated_at):void 0,n=[{label:"Статус",value:t.active?"Активна":"Не активна"},{label:"Актуальная ставка",value:t.bet},{label:"Ожидаемое место",value:t.place},{label:"Обновлено",value:s==null?void 0:s.toLocaleString()}];return e.jsxs("div",{children:[e.jsx(y.Title,{level:5,style:{margin:0},children:"Состояние"}),e.jsx(E,{dataSource:n,renderItem:i=>e.jsx(E.Item,{children:e.jsx(E.Item.Meta,{title:i.value,description:i.label})})})]})}const Et=(t,s)=>(z.find(n=>n.id===t),`${J}/${s}`),Ht=t=>`${U}/auction/${t}/`;function Pt(){var c,h;const{campaignId:t}=q(),[s,n]=d.useState(!0),[i,r]=d.useState([]),[a,l]=d.useState([]),[o,u]=d.useState(void 0);return d.useEffect(()=>{n(!0),b.get(Et(6,t)).then(p=>{r(p.data)}).finally(()=>n(!1)),b.get(Ht(t)).then(p=>{var f,x;(x=(f=p.data)==null?void 0:f.data)==null||x.forEach((g,m)=>{g.place=m+1}),l(p.data)})},[t]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(fe,{items:[{title:e.jsx("a",{href:"/campaigns",children:"Мои кампании"})},{title:t}]}),e.jsxs(y.Title,{level:5,style:{margin:0},children:[(c=z.find(p=>p.id===i.advert_type))==null?void 0:c.name,": ",i.name]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"20px"},children:[e.jsx(It,{instance:i,campaignId:t}),e.jsx("div",{children:e.jsx(Lt,{instance:i.bidder||{}})}),e.jsx("div",{children:e.jsx(Fe,{...a,campaignId:t,place:(h=i.bidder)==null?void 0:h.place})})]})]})}function $t({supplierId:t}){const[s,n]=d.useState(!1),i=()=>{n(!0)},r=()=>{n(!1)},a=()=>"Ключ API";return e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:i,type:"link",children:"Добавить"}),e.jsxs(B,{open:s,onCancel:r,title:`Добавить ${a()} API`,onOk:r,okText:"Сохранить",cancelText:"Отмена",children:[e.jsx("p",{children:"Добавьте ключ API в кабинете поставщика и вставьте его сюда"}),e.jsx(C,{autoFocus:!0,id:"api_key",placeholder:a()})]})]})}function Mt({item:t}){return e.jsxs("div",{style:{border:"solid thin #ccc",borderRadius:"8px",padding:4},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y.Title,{level:5,style:{margin:0},children:t.name}),e.jsx(v,{type:"text",children:"Удалить"})]}),e.jsxs("div",{children:["Ключ API: ",t!=null&&t.api_key?"Есть":e.jsx($t,{supplierId:t.id,keyType:"uni"})]})]})}function At(){const[t,s]=d.useState(!1),n=()=>{s(!0)},i=()=>{s(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:n,type:"primary",children:"Добавить поставщика"}),e.jsxs(B,{open:t,onCancel:i,title:"Добавить поставщика",onOk:i,okText:"Сохранить",cancelText:"Отмена",children:[e.jsx("p",{children:"Добавьте ключ API в кабинете поставщика и вставьте его сюда"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(C,{autoFocus:!0,id:"name",placeholder:"Наименование"}),e.jsx(C,{id:"api_key",placeholder:"Ключ API"})]})]})]})}const te=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{width:"24",height:"24",rx:"12",fill:"#F7F8FA"}),e.jsx("path",{d:"M7 6.99988L17 16.9999",stroke:"#6E7788","stroke-width":"1.3","stroke-linecap":"square","stroke-linejoin":"round"}),e.jsx("path",{d:"M17 6.99988L7 16.9999",stroke:"#6E7788","stroke-width":"1.3","stroke-linecap":"square","stroke-linejoin":"round"})]}),Nt="_headerContainer_1o3pk_1",Wt="_customHeaderLabel_1o3pk_19",re={headerContainer:Nt,customHeaderLabel:Wt},H={blue:{500:"#0002F3"},primary:{500:"#F9AB0D"},redPale:{400:"#FD7967"},greyF:{700:"#6E7788"},dark:{500:"#383540"}},Bt={token:{colorPrimary:"#F9AB0D",colorError:"#FF3F3F",colorText:"#383540",colorTextSecondary:"#6E7788",colorTextDisabled:"#C3C3C3",colorBgLayout:"#F7F8FA",borderRadius:6}},zt=({size:t=16,color:s,direction:n="right"})=>{const i={up:"0deg",right:"90deg",down:"180deg"},r=s||H.dark[500];return e.jsx("svg",{style:{transform:`rotate(${i[n]})`},xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M8.61193 13.5L7.39003 13.5L7.40317 5.84127L7.16667 6.06614L4.36813 8.89683L3.50098 8.05026L7.99441 3.5L12.501 8.03704L11.6338 8.89682L8.59879 5.82804L8.61193 13.5Z",fill:r})})},se=t=>{const[s,n]=d.useState(!1),[i,r]=d.useState(!1),a=()=>{const o=t.column.getSort();n(o==="asc"),r(o==="desc")},l=o=>{const u=s?"desc":"asc";t.setSort(u,o.shiftKey)};return d.useEffect(()=>{t.column.addEventListener("sortChanged",a),a()},[]),e.jsxs("div",{className:re.headerContainer,onClick:l,onTouchEnd:l,style:t.enableSorting?{cursor:"pointer"}:{},children:[e.jsx("span",{className:re.customHeaderLabel,style:{fontSize:"16px",lineHeight:1.4,color:H.greyF[700]},children:t.displayName}),t.enableSorting?e.jsx("span",{style:{minWidth:"16px",maxWidth:"16px",minHeight:"16px",maxHeight:"16px"},children:e.jsx(zt,{direction:i?"down":"up",color:s||i?H.blue[500]:H.greyF[700]})}):""]})},Vt="_textCell_j8spt_1",ae={textCell:Vt},A=({value:t,textAlignment:s="left",link:n,afterIcon:i})=>e.jsxs("div",{className:ae.textCell,style:{textAlign:s},children:[e.jsx("span",{className:ae.text,style:{fontSize:"16px",lineHeight:1.4,color:"#383540"},children:n?e.jsx("a",{href:n,target:"_blank",children:t}):t}),i||""]}),Gt="_numberCell_1xqpf_1",Ot="_number_1xqpf_1",qt="_tag_1xqpf_17",L={numberCell:Gt,number:Ot,tag:qt},M=({value:t,digits:s,cellStyle:n,textAlignment:i="end",tag:r=!1,icon:a=!1,prefix:l=!1,suffix:o=!1})=>{const u=c=>isNaN(c)||!isFinite(c)?"--":s!==void 0?c.toLocaleString("ru-RU",{minimumFractionDigits:s,maximumFractionDigits:s}):c.toLocaleString("ru-RU");return e.jsxs("div",{className:L.numberCell,style:{...n,justifyContent:i},children:[r&&e.jsx("div",{className:L.tag,children:r}),a&&e.jsx("div",{className:L.icon,children:a}),e.jsxs("span",{className:L.number,style:{fontSize:"16px",lineHeight:1.4,color:"#383540"},children:[l&&t&&e.jsx("div",{className:L.prefix,children:l}),u(Number(t)),o&&t&&e.jsx("div",{className:L.suffix,children:o})]})]})},De=30,Ut=44,Kt=30,Ie=40;xe.setLicenseKey("key");ge.registerModules([me]);const Zt=[{headerName:"Тариф",field:"name",cellRenderer:t=>e.jsx(A,{value:t.value})},{headerName:"Цена",field:"price",cellRenderer:t=>e.jsx(M,{value:t.value}),width:70},{headerName:"Устройств",field:"devices",cellRenderer:t=>e.jsx(M,{value:t.value}),width:100},{headerName:"Биддеров",field:"limit",cellRenderer:t=>e.jsx(M,{value:t.value}),width:100}];function le({children:t}){const[s,n]=ye.useState(!1),[i,r]=d.useState([]),[a,l]=d.useState(!0),{showRequestError:o}=R(),u=()=>{l(!0),w("user/tariff").then(f=>{f.data&&r(f.data)}).catch(f=>{o(f)}).finally(()=>l(!1))},c=f=>{P("billing/get_payment_link",{tariff:f}).then(x=>{x.data.url?(window.open(x.data.url,"_blank").focus(),p()):o("Ошибка при создании платежа")}).catch(x=>{o(`Ошибка при создании платежа: ${Q(x)}`)})},h=()=>{n(!0),u()},p=()=>{n(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(I,{variant:"contained",onClick:h,color:"primary",children:t}),e.jsx(B,{open:!!s,onCancel:p,title:"Выберите тариф",footer:null,closeIcon:e.jsx(te,{}),width:500,children:e.jsx("div",{style:{width:"100%"},children:e.jsx(Y,{domLayout:"autoHeight",rowHeight:Ie,headerHeight:De,rowData:i,columnDefs:Zt,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!1,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:se},onRowDataUpdated:f=>{f.api.sizeColumnsToFit()},onRowClicked:f=>{console.log("props",f),c(f.data.id)}})})})]})}function Re(){var h;const[t,s]=d.useState(!1),[n,i]=d.useState(void 0),{showRequestError:r,showError:a}=R();d.useEffect(()=>{s(!0),w("user/license").then(p=>{i(p.data)}).catch(p=>r(p)).finally(()=>s(!1))},[]);const l=()=>{P("billing/get_payment_link",{}).then(p=>{p.data.url?window.open(p.data.url,"_blank").focus():a("Ошибка при создании платежа")}).catch(p=>{r(`Ошибка при создании платежа: ${Q(p)}`)})};if(t)return e.jsx(T,{count:3});let o=!1;if(!(n!=null&&n.length))o=!0;else{const p=n[0];new Date(p.action_date).getFullYear()<2020&&(o=!0)}if(o)return e.jsxs("div",{style:{display:"flex",columnGap:12,alignItems:"center"},children:[e.jsx(y.Text,{children:"Отстутствует лицензия"}),e.jsx(le,{children:"Активировать подписку"})]});const u=n[0],c=new Date(u.action_date);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs(y.Text,{style:{lineHeight:1.4},children:["Номер лицензии: ",u.key]}),e.jsxs(y.Text,{style:{lineHeight:1.4},children:["Тариф ",(h=u.tariff)==null?void 0:h.name]}),u.is_active?e.jsxs(y.Text,{style:{lineHeight:1.4},children:["Подписка активна до ",c.toLocaleDateString()]}):e.jsxs(y.Text,{style:{lineHeight:1.4},children:["Подписка закончилась ",c.toLocaleDateString()]})]}),e.jsx("div",{style:{marginTop:8,display:"flex",gap:8},children:u.tariff===void 0?e.jsx(le,{children:"Выбрать тариф"}):e.jsx(e.Fragment,{children:e.jsx(I,{variant:"contained",onClick:l,children:"Продлить подписку"})})})]})}const Xt="user/suppliers";function Yt(){const[t,s]=d.useState(!0),[n,i]=d.useState([]);return d.useEffect(()=>{s(!0),w(Xt).then(r=>{i(r.data)}).finally(()=>s(!1))},[]),t?e.jsx("div",{children:"Загрузка..."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",columnGap:12,alignItems:"center"},children:[e.jsx(At,{}),e.jsx(Re,{}),e.jsx(O,{to:"/devices",children:e.jsx(v,{children:"Расширение Chrome"})})]}),n.map((r,a)=>e.jsx(Mt,{item:r},a))]})}const Jt=`${V}/cabinet/supplier_full/`;function Qt(){const[t,s]=d.useState([]),[n,i]=d.useState(!0);return d.useEffect(()=>{t.length===0&&(i(!0),b.get(Jt).then(r=>{s(r.data)}).finally(()=>i(!1)))},[]),e.jsxs("div",{children:[e.jsx("h1",{children:"Поставщики и ключи API"}),e.jsx(Yt,{suppliers:t})]})}function es({instance:t,campaignId:s}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(C,{id:"name",placeholder:"Наименование кампании",value:t.name??"",size:"small"}),e.jsx(C,{id:"cpm",placeholder:"Ставка",value:t.bet??"",size:"small",type:"number"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:8},children:[e.jsx(v,{type:"primary",children:"Сохранить изменения"}),e.jsx("a",{href:Dt(s),children:e.jsx(v,{type:"link",children:"Запустить биддер"})})]})]})}const ts=(t,s)=>(z.find(n=>n.id===t),`${J}/${s}`),ss=t=>`${U}/auction/${t}/`;function ns(){var c;const{campaignId:t}=q(),[s,n]=d.useState(!0),[i,r]=d.useState([]),[a,l]=d.useState([]),[o,u]=d.useState(void 0);return d.useEffect(()=>{n(!0),b.get(ts(6,t)).then(h=>{r(h.data)}).finally(()=>n(!1)),b.get(ss(t)).then(h=>{var p,f;(f=(p=h.data)==null?void 0:p.data)==null||f.forEach((x,g)=>{x.place=g+1}),l(h.data)})},[t]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(fe,{items:[{title:e.jsx("a",{href:"/campaigns",children:"Мои кампании"})},{title:t}]}),e.jsxs(y.Title,{level:5,style:{margin:0},children:["Изменение: ",(c=z.find(h=>h.id===i.advert_type))==null?void 0:c.name,": ",i.name]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"20px"},children:[s?e.jsx("div",{style:{width:"100%"},children:e.jsx(T,{})}):e.jsx(es,{instance:i,campaignId:t}),e.jsx("div",{}),e.jsx(Fe,{...a,campaignId:t})]})]})}const is="&appType=1&curr=rub&dest=-1257786®ions=80,38,83,4,64,33,68,70,30,40,86,75,69,22,1,31,66,110,48,71,114&spp=0",rs=async t=>{let{data:s}=await b.get(`https://catalog-ads.wildberries.ru/api/v5/search?keyword=${t}`);if(!s.adverts)return null;const n=[];s.adverts.forEach(o=>n.push(o.id));let i=localStorage.getItem("geoData")||is;const{data:r}=await b.get(`https://prod.mkeeper.ru/api/wp/clist/?${i}&nm=${n.join(";")}`);if(!r)return null;const a=r.data.products.map(o=>(o.deliveryHours=o.time1+o.time2,o.nmId=o.id,o));return{advData:s,advGoods:a}};async function as(t){const{data:s}=await b.get("https://static-basket-01.wb.ru/vol0/data/subject-base.json");let n=[];const i=(r,a)=>{r.forEach(l=>{if(l.id==a){const o={id:l.id,subj_name:l.name};n.push(o)}else l.childs&&i(l.childs,a)})};return t.forEach(r=>i(s,r)),n}const ls=function(t,s,n){const{advData:i}=t;i.pages.sort((a,l)=>a.page-l.page);const r={};return n=cs(n,i),i.pages.forEach(a=>{let l=n.splice(0,a.positions.length);l.forEach((o,u)=>{const c=i.adverts.find(h=>h.id===o.nmId);os(o,c,a.positions[u],a.page)}),a.page===1&&(l=s.concat(l)),l.sort((o,u)=>o.advStatFields.position-u.advStatFields.position),r[a.page]=l}),r},os=function(t,s,n,i=1){var r,a,l,o;t.advStatFields={advertId:s.advertId,position:n,cpm:(r=(a=t.advStatFields)===null||a===void 0?void 0:a.cpm)!==null&&r!==void 0?r:s.cpm,subjectId:t.subjectId,brandId:t.brandCod,kindId:t.kindId,page:i,mk_cpmweight:(l=(o=t.advStatFields)===null||o===void 0?void 0:o.mk_cpmweight)!==null&&l!==void 0?l:0,mk_deliveryweight:(l=(o=t.advStatFields)===null||o===void 0?void 0:o.mk_deliveryweight)!==null&&l!==void 0?l:0,totalWeight:(l=(o=t.advStatFields)===null||o===void 0?void 0:o.totalWeight)!==null&&l!==void 0?l:0,cpmRatio:t.advStatFields.cpmRatio,deliveryRatio:t.advStatFields.deliveryRatio}},cs=function(t,s){var n,i;if((n=s.adverts)===null||n===void 0||!n.length||t==null||!t.length)return[];const r=s.adverts.reduce((l,o)=>l.set(o.id,o),new Map);if((i=s.prioritySubjects)!==null&&i!==void 0&&i.length)return ds(t,s,r);const a=Le(t,s.adverts.length);return Ee(a,s,r)},Le=function(t,s){return{advertsCount:s??0,products:t??[]}},ds=function(t,s,n){const i=t.reduce((l,o)=>l.set(o.nmId,o),new Map),r=s.adverts.reduce((l,o)=>{var u;const c=o.subject,h=i.get(o.id),p=(u=l.get(c))!==null&&u!==void 0?u:Le();return p.advertsCount++,h&&p.products.push(h),l.set(c,p)},new Map),a=[];for(let l=0;lu.advStatFields.totalWeight==c.advStatFields.totalWeight&&c.advStatFields.cpm!=u.advStatFields.cpm?c.advStatFields.cpm-u.advStatFields.cpm:c.advStatFields.totalWeight-u.advStatFields.totalWeight),i},us=function(t,s,n){const{cpms:i,deliveries:r}=t.reduce((u,c)=>{if(!c)return;const h=s.get(c.nmId);return u.deliveries.add(c.deliveryHours),u.cpms.add(h.cpm),u},{cpms:new Set,deliveries:new Set}),a=1/n.advertsCount;function l(u){let c=1;return u.reduce((h,p)=>h.has(p)?h:(h.size>0&&(c-=a),h.set(p,c)),new Map)}function o(u,c){const h=Array.from(u);return h.sort(c),h}return{weightMapCpm:l(o(i,(u,c)=>c-u)),weightMapDelivery:l(o(r,(u,c)=>u-c))}},ps=function(t){var s,n;let i=.6666666666666666,r=1/3;if(t!=null&&(s=t.sortWeights)!==null&&s!==void 0&&s.cpm&&t!=null&&(n=t.sortWeights)!==null&&n!==void 0&&n.delivery){const a=t.sortWeights.cpm+t.sortWeights.delivery;a&&(i=t.sortWeights.cpm/a,r=t.sortWeights.delivery/a)}return{cpmRatio:i,deliveryRatio:r}};function hs(t,s){const n=new Map;t.advData.adverts.forEach(c=>{n.has(c.id)||n.set(c.id,c)});const i=ls(t,[],t.advGoods),r=[];let a=0,l=0,o=0;Object.entries(i).forEach((c,h)=>{c[1].forEach(p=>{const f=++a;let x;s&&(x=s.find(m=>m.id===p.advStatFields.subjectId)),l||(l=p.advStatFields.cpmRatio),o||(o=p.advStatFields.deliveryRatio);const g={brand:p.brand,deliveryHours:p.deliveryHours,id:p.cod1S||p.id,n:f,page:p.advStatFields.page,pl:a,position:p.advStatFields.position,subj_name:x?x.subj_name:"",cpm:p.advStatFields.cpm,cpmWeight:p.advStatFields.mk_cpmweight.toFixed(3),deliveryWeight:p.advStatFields.mk_deliveryweight.toFixed(3),totalWeight:p.advStatFields.totalWeight.toFixed(3),subject:"",name:p.name};r.push(g)})});const u={cpm:"",delivery:"",cpmPercentages:null,deliveryPercentages:null};return t.advData.sortWeights&&(u.cpm=`${t.advData.sortWeights.cpm}/${t.advData.sortWeights.cpm+t.advData.sortWeights.delivery}`,u.delivery=`${t.advData.sortWeights.delivery}/${t.advData.sortWeights.cpm+t.advData.sortWeights.delivery}`),u.cpmPercentages=l*100,u.deliveryPercentages=o*100,{data:r,ratio:u}}async function fs(t){const s=await rs(t);if(s===null)return new Promise((r,a)=>r([]));const n=await as(s.advData.prioritySubjects),i=hs(s,n);return new Promise((r,a)=>r(i.data))}var He=(t=>(t[t.Small=360]="Small",t[t.Mobile=414]="Mobile",t[t.Tablet=768]="Tablet",t[t.Medium=1280]="Medium",t[t.Laptop=1366]="Laptop",t[t.Large=1920]="Large",t))(He||{});const Pe=d.createContext({resolution:1920}),oe=()=>document.body.clientWidth<=360?360:document.body.clientWidth<=414?414:document.body.clientWidth<=768?768:document.body.clientWidth<=1280?1280:document.body.clientWidth<=1366?1366:1920;function xs({children:t}){const[s,n]=d.useState(document.body.clientWidth);return d.useEffect(()=>{window.addEventListener("resize",()=>n(oe())),n(oe())},[]),e.jsx(Pe.Provider,{value:{resolution:s},children:t})}function $e(t,s=246,n=328){return`//basket-${gs(Math.floor(t/1e5))}.wb.ru/vol${Math.floor(t/1e5)}/part${Math.floor(t/1e3)}/${t}/images/c${s}x${n}/1.jpg`}function gs(t){return t>=0&&t<=143?"01":t>=144&&t<=287?"02":t>=288&&t<=431?"03":t>=432&&t<=719?"04":t>=720&&t<=1007?"05":t>=1008&&t<=1061?"06":t>=1062&&t<=1115?"07":t>=1116&&t<=1169?"08":t>=1170&&t<=1313?"09":t>=1314&&t<=1601?"10":t>=1602&&t<=1655?"11":"12"}function ms({rows:t,skeleton:s}){return s?e.jsx("div",{children:[...Array(5)].map((n,i)=>e.jsxs("div",{style:{border:"1px solid #d5d5d5",padding:"8px",borderRadius:"10px",marginTop:i>0?"15px":0},children:[e.jsx(D.Input,{active:!0,block:!0,style:{height:15,width:"100%"}}),e.jsxs("div",{style:{display:"flex",marginTop:"4px",width:"100%"},children:[e.jsx(D.Image,{active:!0,style:{height:80,width:60,marginRight:"4px"}}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(D.Input,{active:!0,block:!0,style:{height:15,width:"100%"}}),e.jsx(D.Input,{active:!0,block:!0,style:{height:15,width:"100%",marginTop:"4px"}}),e.jsx(D.Input,{active:!0,block:!0,style:{height:15,width:"100%",marginTop:"4px"}})]})]})]},i))}):t.length?e.jsx("div",{children:t.map(n=>e.jsxs("div",{style:{border:"1px solid #d5d5d5",padding:"8px",borderRadius:"10px",marginTop:"15px"},children:[e.jsxs("div",{style:{display:"flex"},children:[e.jsx("span",{style:{marginRight:"5px",fontSize:"12px"},children:n.n}),e.jsx("span",{style:{fontSize:"12px"},children:n.name})]}),e.jsxs("div",{style:{display:"flex",width:"100%",marginTop:"4px"},children:[e.jsx("a",{href:`https://www.wildberries.ru/catalog/${n.id}/detail.aspx`,target:"_blank",style:{height:"80px",marginRight:"5px"},children:e.jsx("img",{height:"80px",src:`${$e(n.id)}`,style:{borderRadius:"5px"}})}),e.jsxs("div",{style:{marginRight:"16px",flexGrow:1},children:[e.jsxs("div",{style:{fontSize:"12px"},children:["Артикул: ",n.id]}),e.jsxs("div",{style:{fontSize:"12px"},children:["Бренд: ",n.brand]}),e.jsxs("div",{style:{fontSize:"12px"},children:["Категория: ",n.subj_name]})]}),e.jsxs("div",{style:{minWidth:"90px"},children:[e.jsxs("div",{style:{fontSize:"12px"},children:["Ставка: ",n.cpm," ₽"]}),e.jsxs("div",{style:{fontSize:"12px"},children:["Доставка: ",n.deliveryHours," ч."]})]})]})]},n.id))}):e.jsx("div",{style:{width:"100%",textAlign:"center"},children:"Пусто..."})}const ys=[{title:"№",dataIndex:"n",key:"n",align:"center",render:t=>_(t)},{title:"",key:"img",align:"center",render:(t,s)=>e.jsx("a",{href:`https://www.wildberries.ru/catalog/${s.id}/detail.aspx`,target:"_blank",children:e.jsx("img",{height:"22px",src:`${$e(s.id)}`})})},{title:"Артикул",key:"id",align:"center",render:(t,s)=>e.jsx("a",{href:`https://www.wildberries.ru/catalog/${s.id}/detail.aspx`,target:"_blank",children:s.id})},{title:"Бренд",dataIndex:"brand",key:"brand",align:"center"},{title:"Категория",dataIndex:"subj_name",key:"subj_name",align:"center"},{title:"Ставка",key:"cpm",align:"center",render:(t,s)=>`${_(s.cpm)} ₽`},{title:"Вес ставки",key:"cpmWeight",align:"center",render:(t,s)=>_(s.cpmWeight)},{title:"Доставка",key:"deliveryHours",align:"center",render:(t,s)=>`${_(s.deliveryHours)} ч.`},{title:"Вес доставки",key:"deliveryWeight",align:"center",render:(t,s)=>_(s.deliveryWeight)},{title:"Общий вес",key:"totalWeight",align:"center",render:(t,s)=>_(s.totalWeight)},{title:"Место",key:"pl",align:"center",render:(t,s)=>_(s.pl)},{title:"Страница",key:"page",align:"center",render:(t,s)=>_(s.page)},{title:"Позиция",key:"position",align:"center",render:(t,s)=>_(s.position)}];function vs({rows:t,skeleton:s}){return s?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[...Array(8)].map((n,i)=>e.jsx(D.Input,{active:!0,block:!0,style:{height:32,width:"100%"}},i))}):e.jsx(W,{columns:ys,dataSource:t||[],rowKey:"id",size:"small",pagination:!1,locale:{emptyText:"Пусто..."}})}function js({rows:t,skeleton:s}){const{resolution:n}=d.useContext(Pe);return e.jsx(e.Fragment,{children:n<=He.Mobile?e.jsx(ms,{skeleton:s,rows:t}):e.jsx(vs,{skeleton:s,rows:t})})}const bs=async t=>{const{data:s}=await b.get(`https://search.wb.ru/suggests/api/v3/hint?query=${t}&gender=common&locale=ru&lang=ru`);let n=[];return s.forEach(i=>{i.type==="suggest"&&n.push({label:i.name})}),new Promise((i,r)=>i(n))};function Cs(){const[t,s]=d.useState(""),[n,i]=d.useState(!1),[r,a]=he("",300),[l,o]=d.useState([]),[u,c]=d.useState([]),h=f=>{s(f),f&&(a(f),i(!0))};d.useEffect(()=>{if(!t){o([]),c([]),i(!1);return}fs(t).then(f=>{o(f),i(!1)}),bs(t).then(f=>{Array.isArray(f)&&c(f)})},[r]);const p=u.map(f=>({value:f.label,label:f.label}));return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(y.Title,{level:4,style:{margin:0},children:"Аукцион поиска"}),e.jsx("div",{children:e.jsx(qe,{style:{width:"100%"},options:p,value:t,onSelect:f=>h(f),onSearch:f=>h(f),children:e.jsx(C.Search,{placeholder:"Введите текст для поиска",size:"large"})})}),e.jsx("div",{children:e.jsx(js,{rows:l,skeleton:n})})]})}function _s({onConfirm:t,title:s,button:n,children:i}){const[r,a]=d.useState(!1),l=()=>{a(!0)},o=()=>{a(!1)},u=()=>{t&&t(),a(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:l,className:"hoverable-icon",children:n}),e.jsxs(B,{open:r,onCancel:o,title:s,footer:null,closeIcon:e.jsx(te,{}),width:455,styles:{body:{padding:"16px 16px 0"}},children:[i&&e.jsx("div",{style:{marginBottom:16},children:i}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(I,{onClick:u,variant:"outlined",color:"error",sx:{width:"100%"},children:"Подтвердить"}),e.jsx(I,{onClick:o,variant:"outlined",color:"secondary",sx:{width:"100%"},children:"Отмена"})]})]})]})}const Ss=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[e.jsxs("g",{clipPath:"url(#clip0_7578_23038)",children:[e.jsx("mask",{id:"mask0_7578_23038",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"24",height:"24",children:e.jsx("rect",{width:"24",height:"24",fill:"#D9D9D9"})}),e.jsx("g",{mask:"url(#mask0_7578_23038)",children:e.jsx("path",{d:"M7 21C6.45 21 5.97917 20.8042 5.5875 20.4125C5.19583 20.0208 5 19.55 5 19V6H4V4H9V3H15V4H20V6H19V19C19 19.55 18.8042 20.0208 18.4125 20.4125C18.0208 20.8042 17.55 21 17 21H7ZM9 17H11V8H9V17ZM13 17H15V8H13V17Z",fill:H.redPale[400]})})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_7578_23038",children:e.jsx("rect",{width:"24",height:"24",fill:"white"})})})]}),Me=({message:t})=>e.jsx("div",{style:{padding:"20px",color:"#666666",fontSize:"16px",pointerEvents:"all",lineHeight:"1.5",display:"block"},children:e.jsx("span",{children:t||"Нет данных"})}),ce="user/device";function ws(){const[t,s]=d.useState(!0),[n,i]=d.useState([]),{showRequestError:r}=R(),a=()=>{s(!0),w(ce).then(c=>{i(c.data)}).catch(c=>{r(c)}).finally(()=>s(!1))};d.useEffect(()=>{a()},[]);const l=c=>{dt(`${ce}/${c}`).then(h=>{a()})},o=c=>`${c.license}${c.dev_num>0?`-${c.dev_num}`:""}`;if(t)return e.jsx(T,{count:2});const u=[{headerName:"Ключ активации",field:"license",valueFormatter:c=>o(c.value),cellRenderer:c=>e.jsx(A,{value:c.value})},{headerName:"Дата активации",field:"activation_date",cellRenderer:c=>e.jsx(A,{value:c.value,afterIcon:e.jsx("div",{style:{height:"24px",marginLeft:"auto"},children:e.jsx(_s,{button:e.jsx(Ss,{}),title:"Деактивировать устройство?",onConfirm:()=>l(c.data.dev_num)})})})}];return e.jsx(e.Fragment,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:e.jsx("div",{style:{width:"100%"},children:e.jsx(Y,{domLayout:"autoHeight",rowHeight:Kt,headerHeight:De,rowData:n,columnDefs:u,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!1,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:se},onRowDataUpdated:c=>{c.api.sizeColumnsToFit()},noRowsOverlayComponent:Me})})})})}const ks=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12.0026 4.00065V9.33398C12.0026 10.8067 10.8087 12.0007 9.33594 12.0007H4.0026C2.52984 12.0007 1.33594 10.8067 1.33594 9.33398V4.00065C1.33594 2.52789 2.52984 1.33398 4.0026 1.33398H9.33594C10.8087 1.33398 12.0026 2.52789 12.0026 4.00065ZM2.33594 4.00065V9.33398C2.33594 9.77601 2.51153 10.1999 2.82409 10.5125C3.13665 10.8251 3.56058 11.0007 4.0026 11.0007H9.33594C10.2564 11.0007 11.0026 10.2545 11.0026 9.33398V4.00065C11.0026 3.08018 10.2564 2.33398 9.33594 2.33398H4.0026C3.08213 2.33398 2.33594 3.08018 2.33594 4.00065Z",fill:"#007BFB"}),e.jsx("path",{d:"M14.0026 5.50065C13.728 5.50424 13.5062 5.72601 13.5026 6.00065V11.334C13.4989 12.5291 12.531 13.497 11.3359 13.5007H6.0026C5.72646 13.5007 5.5026 13.7245 5.5026 14.0007C5.5026 14.2768 5.72646 14.5007 6.0026 14.5007H11.3359C13.0848 14.5007 14.5026 13.0829 14.5026 11.334V6.00065C14.499 5.72601 14.2772 5.50424 14.0026 5.50065Z",fill:"#007BFB"}),e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12.0026 4.00065V9.33398C12.0026 10.8067 10.8087 12.0007 9.33594 12.0007H4.0026C2.52984 12.0007 1.33594 10.8067 1.33594 9.33398V4.00065C1.33594 2.52789 2.52984 1.33398 4.0026 1.33398H9.33594C10.8087 1.33398 12.0026 2.52789 12.0026 4.00065ZM2.33594 4.00065V9.33398C2.33594 9.77601 2.51153 10.1999 2.82409 10.5125C3.13665 10.8251 3.56058 11.0007 4.0026 11.0007H9.33594C10.2564 11.0007 11.0026 10.2545 11.0026 9.33398V4.00065C11.0026 3.08018 10.2564 2.33398 9.33594 2.33398H4.0026C3.08213 2.33398 2.33594 3.08018 2.33594 4.00065Z",stroke:"#007BFB","stroke-width":"0.2"}),e.jsx("path",{d:"M14.0026 5.50065C13.728 5.50424 13.5062 5.72601 13.5026 6.00065V11.334C13.4989 12.5291 12.531 13.497 11.3359 13.5007H6.0026C5.72646 13.5007 5.5026 13.7245 5.5026 14.0007C5.5026 14.2768 5.72646 14.5007 6.0026 14.5007H11.3359C13.0848 14.5007 14.5026 13.0829 14.5026 11.334V6.00065C14.499 5.72601 14.2772 5.50424 14.0026 5.50065Z",stroke:"#007BFB","stroke-width":"0.2"})]});function Ts(){const[t,s]=d.useState(""),{showRequestError:n}=R(),i=()=>{Ce("user/device/new").then(a=>{var l;(l=a.data)!=null&&l.key&&s(a.data.key)}).catch(a=>{n(a)})},r=()=>{s("")};return e.jsxs(e.Fragment,{children:[e.jsx(I,{variant:"outlined",onClick:i,color:"secondary",children:"Активировать новое устройство"}),e.jsx(B,{open:!!t,onCancel:r,title:"Активация нового устройства",footer:null,closeIcon:e.jsx(te,{}),children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(y.Text,{type:"secondary",style:{fontSize:"16px",lineHeight:1.4,fontWeight:400},children:"Ключ активации:"}),e.jsxs(y.Text,{strong:!0,style:{fontSize:"16px",lineHeight:1.4,display:"flex",alignItems:"center",gap:4},children:[t,e.jsx("div",{style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>navigator.clipboard.writeText(t),children:e.jsx(ks,{})})]})]})})]})}function Ae(){const{profile:t}=F();return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsx(y.Title,{level:5,style:{margin:0},children:"Устройства"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx("div",{style:{display:"flex",gap:16},children:e.jsx(Ts,{})}),e.jsx(ws,{})]})]})}function Ne({hidden:t}){const s=N(),{profile:n}=F(),{showRequestError:i,showError:r}=R(),[a,l]=d.useState("");return d.useEffect(()=>{n.auth?Ce("user/device/new").then(o=>{var u;(u=o.data)!=null&&u.key?l(o.data.key):(r("Нет свободных активаций. Отвяжите одно устройство или повысьте тариф"),s("/"))}).catch(o=>{}):s("/auth/login")},[]),e.jsxs("div",{children:[!t&&e.jsx(ee,{}),e.jsx("input",{type:"hidden",id:"new-device-key",value:a})]})}function de(){const{profile:t}=F(),[s,n]=pe(),i=s.get("auth")==="success";return t.auth===void 0?e.jsx(ee,{}):t.auth===!1?e.jsx(we,{}):e.jsxs("div",{style:{maxWidth:900,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:32},children:[e.jsx(y.Title,{level:4,style:{margin:0},children:"Панель управления"}),e.jsx(Re,{}),e.jsx(Ae,{})]}),i&&e.jsx(Ne,{hidden:!0})]})}const Fs=()=>{const{clearProfile:t}=F(),s=N(),n=()=>{P("user/logout").then(()=>{t(),s("/")}).catch(i=>{})};return d.useEffect(()=>{n()},[n]),e.jsx("div",{className:"auth-page",children:"Выход..."})},Ds="_container_10jp5_1",Is="_input_10jp5_10",K={container:Ds,input:Is},Rs=500,ne=d.forwardRef((t,s)=>{const[n,i]=d.useState(""),[r,a]=d.useState(""),l=d.useRef(null);d.useImperativeHandle(s,()=>({onParentModelChanged(p){p||(i(""),a(""))}}));const o=(p,f)=>{const x=p?Number(p):null,g=f?Number(f):null;x!=null&&g!=null?t.onModelChange({type:"inRange",filter:x,filterTo:g}):x!=null?t.onModelChange({type:"greaterThanOrEqual",filter:x}):g!=null?t.onModelChange({type:"lessThanOrEqual",filter:g}):t.onModelChange(null)},u=(p,f)=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{o(p,f)},Rs)},c=p=>{const f=p.target.value;i(f),u(f,r)},h=p=>{const f=p.target.value;a(f),u(n,f)};return e.jsxs("div",{className:K.container,children:[e.jsx("input",{className:K.input,type:"number",placeholder:"От",value:n,onChange:c}),e.jsx("input",{className:K.input,type:"number",placeholder:"До",value:r,onChange:h})]})});ne.displayName="RangeFloatingFilter";xe.setLicenseKey("key");ge.registerModules([me]);const Ls=64,Es={category_name:{text:"category"},subject_name:{text:"subject_name"},revenue:{min:"revenue_min",max:"revenue_max"},cards_count:{min:"cards_count_min",max:"cards_count_max"},cards_with_orders_count:{min:"cards_with_orders_count_min",max:"cards_with_orders_count_max"},suppliers:{min:"suppliers_min",max:"suppliers_max"},suppliers_with_sells:{min:"suppliers_with_sells_min",max:"suppliers_with_sells_max"},redemption_pc:{min:"redemption_pc_min",max:"redemption_pc_max"},avg_check:{min:"avg_check_min",max:"avg_check_max"},weekly_turnover_days:{min:"weekly_turnover_days_min",max:"weekly_turnover_days_max"},monopolization_pc:{min:"monopolization_pc_min",max:"monopolization_pc_max"},remaining_count:{min:"remaining_count_min",max:"remaining_count_max"},avg_rating:{min:"avg_rating_min",max:"avg_rating_max"}};function Hs(t){const s={};for(const[n,i]of Object.entries(t)){const r=Es[n];r&&("text"in r?i.filter&&(s[r.text]=i.filter):i.type==="inRange"?(i.filter!=null&&(s[r.min]=String(i.filter)),i.filterTo!=null&&(s[r.max]=String(i.filterTo))):i.type==="greaterThanOrEqual"?i.filter!=null&&(s[r.min]=String(i.filter)):i.type==="lessThanOrEqual"&&i.filter!=null&&(s[r.max]=String(i.filter)))}return s}const S=(t,s,n={})=>({headerName:t,field:s,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:ne,minWidth:130,cellRenderer:i=>e.jsx(M,{value:i.value,...n})}),Ps=[{headerName:"Категория",field:"category_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:200,cellRenderer:t=>e.jsx(A,{value:t.value})},{headerName:"Предмет",field:"subject_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:150,cellRenderer:t=>e.jsx(A,{value:t.value,link:`/external-analytics/niche-analysis?subject_id=${t.data.subject}`})},S("Выручка","revenue",{suffix:" ₽"}),S("Карточек товаров","cards_count"),{...S("Карточек с заказами","cards_with_orders_count"),minWidth:140},{...S("Продавцы","suppliers"),minWidth:110},{...S("Продавцы с заказами","suppliers_with_sells"),minWidth:140},{...S("% выкупа","redemption_pc",{suffix:"%"}),minWidth:110},{...S("Средний чек","avg_check",{suffix:" ₽"}),minWidth:120},S("Оборачиваемость","weekly_turnover_days"),S("Монополизация","monopolization_pc"),{...S("Среднее кол-во остатков","remaining_count"),minWidth:160},{headerName:"Средний рейтинг",field:"avg_rating",filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:ne,minWidth:130,cellRenderer:t=>e.jsx(M,{value:t.value,digits:1,icon:e.jsx(Ue,{style:{color:H.primary[500],fontSize:14}})})}];function $s({rowData:t,loading:s,onFilterChanged:n}){const i=d.useCallback(r=>{if(!n)return;const a=r.api.getFilterModel(),l=Hs(a);n(l)},[n]);return e.jsx("div",{style:{width:"100%"},children:e.jsx(Y,{domLayout:"autoHeight",rowHeight:Ie,headerHeight:Ut,floatingFiltersHeight:Ls,rowData:t,columnDefs:Ps,loading:s,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!0,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:se,headerComponentParams:{enableSorting:!0}},onGridReady:r=>{r.api.sizeColumnsToFit()},onGridSizeChanged:r=>{r.api.sizeColumnsToFit()},onFilterChanged:i,noRowsOverlayComponent:Me})})}const{Title:Ms}=y,As="wbstat/external_analytics";function Ns(){const[t,s]=d.useState([]),[n,i]=d.useState(!0),[r,a]=d.useState({}),{showRequestError:l}=R(),o=d.useCallback(c=>{i(!0),be(`${As}/`,{params:c}).then(h=>{s(h.data.results)}).catch(h=>{l(h)}).finally(()=>{i(!1)})},[l]);d.useEffect(()=>{o(r)},[r]);const u=d.useCallback(c=>{a(c)},[]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(Ms,{level:3,style:{margin:0},children:"Анализ ниш"}),e.jsx(v,{icon:e.jsx(X,{}),style:{alignSelf:"flex-start"},children:"Скачать"}),e.jsx($s,{rowData:t,loading:n,onFilterChanged:u})]})}const Ws=Ke([{element:e.jsx(jt,{}),path:"/",children:[{path:"/",index:!0,element:e.jsx(de,{})},{path:"/auth/login",element:e.jsx(we,{})},{path:"/auth/logout",element:e.jsx(Fs,{})},{path:"/auth/ext-auth",element:e.jsx(Ne,{})},{path:"/profile",element:e.jsx(de,{})},{path:"/devices",element:e.jsx(Ae,{})},{path:"/campaigns/:campaignId/bidder",element:e.jsx(Pt,{})},{path:"/campaigns/:campaignId",element:e.jsx(ns,{})},{path:"/campaigns",element:e.jsx(ot,{})},{path:"/subjects/:subjectId",element:e.jsx(Tt,{})},{path:"/subjects",element:e.jsx(kt,{})},{path:"/priority-subjects/:subjectId",element:e.jsx(bt,{})},{path:"/priority-subjects",element:e.jsx(_t,{})},{path:"/suppliers",element:e.jsx(Qt,{})},{path:"/search-auction",element:e.jsx(Cs,{})},{path:"/external-analytics/niche-analysis",element:e.jsx(Ns,{})}]}]);function Bs(){return e.jsx(Ze,{router:Ws})}function zs(){return e.jsx(e.Fragment,{children:e.jsx(Bs,{})})}Xe.createRoot(document.getElementById("root")).render(e.jsx(ye.StrictMode,{children:e.jsx(Ye,{theme:Bt,children:e.jsx(xs,{children:e.jsx(ft,{children:e.jsx(xt,{children:e.jsx(zs,{})})})})})}));