1import{d as D,j as s,P as te,Q as se,R as Re,S as oe,T as ne,U as _e,r as _,c as Ce,q as De,f as ae,u as Ne,l as U,e as re}from"./vendor.CrY80Nml.js";import{ai as Oe}from"./icons.C_MsxUgD.js";import{a0 as Ie,a_ as ce,a$ as b,hv as M,hw as ge,hx as Ae,aK as ke,t as xe,d8 as Me,b2 as v,hy as G,hz as le,C as fe,O as pe,I as Le,co as ie,n as Pe,H as je,u as we,hA as He,hB as Ye,K as ye,U as W,aZ as de,hC as be,hD as Ue,hE as ve,hF as Ge,P as We}from"./app.dzbmMYEY.js";const B={from:null,to:null};var l=(e=>(e.START="START",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.LOADING="LOADING",e.PROCESSING="PROCESSING",e))(l||{}),t=(e=>(e.TODAY="TODAY",e.WEEK="WEEK",e.CURRENT_MONTH="CURRENT_MONTH",e.LAST_MONTH="LAST_MONTH",e.ALL_TIME="ALL_TIME",e.SELECT_RANGE="SELECT_RANGE",e.SELECT_DAY="SELECT_DAY",e.SELECT_MONTH="SELECT_MONTH",e.YESTERDAY="YESTERDAY",e.CURRENT_WEEK="CURRENT_WEEK",e.PREV_WEEK="PREV_WEEK",e.CURRENT_MONTH_FROM_1="CURRENT_MONTH_FROM_1",e.PREV_MONTH="PREV_MONTH",e))(t||{}),k=(e=>(e.DAY="day",e.WEEK="week",e.MONTH="month",e))(k||{});const Be="ErrorStep-scss--module_image_MN1hl",Ke="ErrorStep-scss--module_footer_QXwua",$e="ErrorStep-scss--module_greyText_cWDUb",Fe="ErrorStep-scss--module_link_dQyTu",Ve="ErrorStep-scss--module_fadeIn_LKqCH",ze="ErrorStep-scss--module_fadeOut_6njKr",Qe="ErrorStep-scss--module_dropdownAnimationFadeIn_Hxf5s",Xe="ErrorStep-scss--module_flashing_i7u7L",qe="ErrorStep-scss--module_loading_zjBvi",Ze="ErrorStep-scss--module_rotating_Qlhj8",Je="ErrorStep-scss--module_growIn_zdAmu",et="ErrorStep-scss--module_closeLock_ry2PM",tt="ErrorStep-scss--module_shakeLock_yJj5P",st="ErrorStep-scss--module_flashToHighlight_V3t2u",ot="ErrorStep-scss--module_flash_OUTyx",H={image:Be,footer:Ke,greyText:$e,link:Fe,fadeIn:Ve,fadeOut:ze,dropdownAnimationFadeIn:Qe,flashing:Xe,loading:qe,rotating:Ze,growIn:Je,closeLock:et,shakeLock:tt,flashToHighlight:st,flash:ot},ue=D.getTranslation("@founder/common/containers.ExportStat.components.ErrorStep"),nt=e=>{const{onNavigateBack:n}=e;return s.jsxs("div",{children:[s.jsx("div",{className:H.image}),s.jsxs("div",{className:H.footer,children:[s.jsx("div",{children:ue.firstSentence}),s.jsx("div",{className:H.greyText,children:D.getReactText(ue.secondSentence,{Link:({text:r})=>s.jsx("span",{onClick:n,className:H.link,children:r})})})]})]})},at="LoadingStep-scss--module_footer_8lfYX",rt="LoadingStep-scss--module_darkText_nY5QL",ct="LoadingStep-scss--module_spinner_oPuj8",K={footer:at,darkText:rt,spinner:ct},me=D.getTranslation("@founder/common/containers.ExportStat.components.LoadingStep"),lt=e=>{const{isProcessing:n}=e;return s.jsxs("div",{children:[s.jsx("div",{className:K.spinner,children:s.jsx(Ie,{size:80})}),s.jsx("div",{className:K.footer,children:D.getReactText(n?me.processing:me.loading,{Black:({text:r})=>s.jsx("span",{className:K.darkText,children:r})})})]})};function Se(e,n,r){return r?ce(b(e),n?"dd/MMMM/yyyy":"dd/MMMM"):ce(b(e),"dd/MM/yy")}function w(e){const{from:n,hasYear:r,isMonthWord:i}=e,T=e.to||new Date;return n?n.toLocaleDateString()===T.toLocaleDateString()?Se(n,r,i):[n,T].map(u=>Se(u,r,i)).join(" - "):""}const E=D.getTranslation("@founder/common/containers.ExportStat.components.StartStep"),it=()=>[t.TODAY,t.WEEK,t.CURRENT_MONTH,t.LAST_MONTH,t.ALL_TIME,t.SELECT_RANGE],dt=()=>{const e=new Date;return{[t.TODAY]:{label:E.rangeItems.today,from:M(),to:null},[t.WEEK]:{label:E.rangeItems.week,from:M(7),to:null},[t.CURRENT_MONTH]:{label:E.rangeItems.currentMonth,from:M(e.getDate()-1),to:null},[t.LAST_MONTH]:{label:E.rangeItems.lastMonth,from:M(30),to:null},[t.ALL_TIME]:{label:E.rangeItems.allTime,from:null,to:null},[t.SELECT_RANGE]:{label:E.rangeItems.selectRange,from:null,to:null},[t.SELECT_DAY]:{label:E.rangeItems.selectDay,from:null,to:null},[t.SELECT_MONTH]:{label:E.rangeItems.selectMonth,from:null,to:null},[t.YESTERDAY]:{label:E.rangeItems.yesterday,from:M(1),to:ge(M(1))},[t.CURRENT_WEEK]:{label:E.rangeItems.currentWeek,from:te(e,{weekStartsOn:1}),to:e},[t.PREV_WEEK]:{label:E.rangeItems.prevWeek,from:te(se(e,1),{weekStartsOn:1}),to:Re(se(e,1),{weekStartsOn:1})},[t.CURRENT_MONTH_FROM_1]:{label:E.rangeItems.currentMonth,from:oe(e),to:e},[t.PREV_MONTH]:{label:E.rangeItems.prevMonth,from:oe(ne(e,1)),to:_e
1(ne(e,1))}}},ut=e=>{const{onExport:n,periods:r}=e,[i,T]=_.useState(0),[u,c]=_.useState(!1),[I,h]=_.useState(!1),[g,x]=_.useState(!1),[S,C]=_.useState(B),[N,L]=_.useState(B),[f,A]=_.useState(B),p=dt(),m=r.map(o=>({...p[o],name:o}));return{periodItems:m,currentRangeIndex:i,customRange:S,hasMonthPicker:g,hasDayPicker:I,hasRangePicker:u,handleRangeIndexChange:o=>{const a=Number(o);T(a),c(m[a].name===t.SELECT_RANGE),h(m[a].name===t.SELECT_DAY),x(m[a].name===t.SELECT_MONTH)},handleCustomRangeChange:o=>{C({from:o[0],to:o[1]})},handleDayPickerChange:o=>{L({from:Ae(o),to:ge(o)})},handleMonthPickerChange:o=>{const a=Math.min(Number(_e(o)),Number(new Date));A({from:o,to:new Date(a)})},handleExportClick:()=>{var a;const o=(a=m[i])==null?void 0:a.name;if(g)n(f);else if(u)n(S);else if(I)n(N);else{const{from:P,to:R}=m[i];n({from:P,to:R},o)}},getPeriodText:o=>{const a=m[o];return a.name===t.SELECT_RANGE?w({from:S.from,to:S.to,hasYear:!0,isMonthWord:!0}):a.name===t.SELECT_MONTH?w({from:f.from,to:f.to,hasYear:!0,isMonthWord:!0}):a.name===t.SELECT_DAY?w({from:N.from,to:N.to,hasYear:!0,isMonthWord:!0}):w({from:a.from,to:a.to,isMonthWord:!0})},isAcceptButtonDisabled:()=>g?!f.from:I?!N.from:u?!S.from:!1}};var V=(e=>(e.ROOT="ROOT",e.DATE_PICKER="DATE_PICKER",e))(V||{});const Te=ke("common/ExportStat/StartStep"),Y={root:Te(V.ROOT),datePicker:Te(V.DATE_PICKER)},mt="StartStep-scss--module_item_x-ggJ",St="StartStep-scss--module_radioButton_80eig",Tt="StartStep-scss--module_calendar_3oHPA",Et="StartStep-scss--module_footer_lKppg",ht="StartStep-scss--module_range_XBRKy",_t="StartStep-scss--module_rangeSelected_Y0ZyY",O={item:mt,radioButton:St,calendar:Tt,footer:Et,range:ht,rangeSelected:_t},Ee=D.getTranslation("@founder/common/containers.ExportStat.components.StartStep"),gt=e=>{const{onCancel:n,onExport:r,periods:i=it()}=e,{periodItems:T,currentRangeIndex:u,customRange:c,hasMonthPicker:I,hasDayPicker:h,hasRangePicker:g,handleRangeIndexChange:x,handleCustomRangeChange:S,handleDayPickerChange:C,handleMonthPickerChange:N,handleExportClick:L,getPeriodText:f,isAcceptButtonDisabled:A}=ut({onExport:r,periods:i});return s.jsxs("div",{...xe(Y.root),children:[T.map((p,m)=>s.jsxs("div",{className:O.item,children:[s.jsx(Me,{classNames:{root:O.radioButton},label:p.label,value:m.toString(),isChecked:m===u,onRadioButtonClick:x}),s.jsx("div",{className:Ce(O.range,{[O.rangeSelected]:m===u}),children:f(m)})]},m)),g&&s.jsx(v,{className:O.calendar,minDate:G,maxDate:new Date,onChange:S,hasFooter:!1,defaultValue:[c.from,c.to],testIdPrefix:Y.datePicker}),h&&s.jsx(v,{testIdPrefix:Y.datePicker,className:O.datePicker,minDate:G,maxDate:new Date,isRangeDisabled:!0,maxDetail:le.MONTH,defaultValue:c.from,onChange:C}),I&&s.jsx(v,{testIdPrefix:Y.datePicker,className:O.datePicker,minDate:G,maxDate:new Date,isRangeDisabled:!0,maxDetail:le.YEAR,defaultValue:[c.from,c.to],onChange:N}),s.jsxs("div",{className:O.footer,children:[s.jsx(fe,{onClick:L,isDisabled:A(),children:Ee.export}),s.jsx(pe,{onClick:n,children:Ee.cancel})]})]})},ft="SuccessStep-scss--module_image_pLi2Y",pt="SuccessStep-scss--module_text_IWoTU",Rt="SuccessStep-scss--module_icon_zvl4K",Ct="SuccessStep-scss--module_footer_RAmCF",Dt="SuccessStep-scss--module_buttonContent_hshUM",Nt="SuccessStep-scss--module_fadeIn_nNlFk",Ot="SuccessStep-scss--module_fadeOut_QSkjA",It="SuccessStep-scss--module_dropdownAnimationFadeIn_PobX4",At="SuccessStep-scss--module_flashing_zEQ4i",kt="SuccessStep-scss--module_loading_Zg64d",xt="SuccessStep-scss--module_rotating_8zSDb",Mt="SuccessStep-scss--module_growIn_FwI7C",Lt="SuccessStep-scss--module_closeLock_R9CUN",Pt="SuccessStep-scss--module_shakeLock_5xAhi",jt="SuccessStep-scss--module_flashToHighlight_Y5dFn",wt="SuccessStep-scss--module_flash_Am2aE",j={image:ft,text:pt,icon:Rt,footer:Ct,buttonContent:Dt,fadeIn:Nt,fadeOut:Ot,dropdownAnimationFadeIn:It,flashing:At,loading:kt,rotating:xt,growIn:Mt,closeLock:Lt,shakeLock:Pt,flashToHighlight:jt,flash:wt},$=D.getTranslation("@founder/common/containers.ExportStat.components.SuccessStep"),Ht=e=>{const{onNavigateBack:n,onDownload:r}=e;return s.jsxs("div",{children:[s.jsx("div",{className:j.image}),s.jsx("div",{className:j.text,children:s.jsx("div",{children:$.text})}),s.jsxs("div",{className:j.footer,children:[s.jsx(fe,{onClick:r,children:s.jsxs("div",{className:j.buttonContent,children:[s.jsx(Le,{glyph:Oe,className:j.icon}),$.download]})}),s.jsx(pe,{onClick:n,children:$.newReport})]})]})},Yt=e=>{const{periods:n,onClose:r,onAcceptRange:i,onNavigateBack:T,onDownload:u,currentStep:c}=e;return s.jsxs("div",{children:[c===l.START&&s.jsx(gt,{onCancel:r,onExport:i,periods:n}),(c===l.LOADING||c===l.PROCESSING)&&s.jsx(lt,{isProcessing:c===l.PROCESSING}),c===l.ERROR&&s.jsx(nt,{onNavigateBack:T}),c===l.SUCCESS&&s.jsx(Ht,{onNavigateBack:T,onDownload:u})]})};var y=(e=>(e.COMPLETED="completed",e.FAILED="failed",e.PROCESSING="processing",e))(y||{});const yt={[ie.BLOG_VISITS_UTM]:{periods:[t.TODAY,t.YESTERDAY,t.CURRENT_WEEK,t.PREV_WEEK,t.CURRENT_MONTH,t.PREV_MONTH,t.SELECT_DAY,t.SELECT_MONTH],sendPeriod:!0},[ie.BLOG_VISITS_REFERS]:{periods:[t.TODAY,t.YESTERDAY,t.CURRENT_WEEK,t.PREV_WEEK,t.CURRENT_MONTH,t.PREV_MONTH,t.SELECT_DAY,t.SELECT_MONTH],sendPeriod:!0}},F=D.getTranslation("@founder/common/containers.ExportStat.hooks"),he=86400,bt=()=>{const{blogUrl:e}=Pe(),{search:n,pathname:r}=je(),{dataType:i,lastReport:T}=De.parse(n),u=we(),c=ae(He),{isFetched:I}=ae(Ye),h=c==null?void 0:c[i],[g,x]=_.useState(null),[S,C]=_.useState(l.START),[N,L]=_.useState(""),f=Ne(),A=ye(W.BLOG_STATISTICS_CATEGORY_EXPORT,r),p=yt[i];_.useEffect(()=>{h||q()},[]),_.useEffect(()=>{if(h&&I){const d=S===l.LOADING||S===l.PROCESSING;if(h.status===y.PROCESSING&&C(l.PROCESSING),g&&h.status===y.FAILED&&C(l.ERROR),h.status===y.COMPLETED&&(d||T)){if(!g){const{startDate:o,endDate:a}=h;x({from:o?new Date(de(o)):null,to:a?new Date(de(a)):null})}C(l.SUCCESS),L(h.url)}}},[h]);const m=()=>{const d=A==null?void 0:A.params.category;u(d?re.getParametrizedUrl(W.BLOG_STATISTICS_CATEGORY,{blogUrl:e,category:d}):re.getParametrizedUrl(W.BLOG_STATISTICS,{blogUrl:e}))},z=(d,o)=>{x(d),C(l.LOADING),Z(d,o)},Q=()=>{C(l.START)},X=async()=>{const{data:d}=await f(U.thunkToAction(Ue.action)(N));ve({data:d,filename:`stat-${i.toString()}.csv`})},q=()=>
1{f(U.thunkToAction(be.action)({blogUrl:e,dataType:i}))},Z=(d,o)=>{const a=b(d.to?d.to:Date.now()),P=d.from?b(d.from):null;let R;if(p!=null&&p.sendPeriod){const ee=a-P;d.from&&d.to==null&&o?(o===t.CURRENT_WEEK&&(R=k.WEEK),o===t.TODAY&&(R=k.DAY),(o===t.CURRENT_MONTH||o===t.CURRENT_MONTH_FROM_1)&&(R=k.MONTH)):ee<he?R=k.DAY:ee<he*7?R=k.WEEK:R=k.MONTH}f(U.thunkToAction(Ge.action)({blogUrl:e,dataType:i,...P?{from:P}:{},...R?{period:R}:{to:a}}))},J=()=>{switch(S){case l.START:case l.PROCESSING:return F.steps[S];case l.LOADING:case l.ERROR:case l.SUCCESS:const d=w({from:g.from,to:g.to,hasYear:!0});return D.getParametrizedText(F.steps[S],{range:d||F.forAllTime})}return""};return{currentStep:S,periods:p==null?void 0:p.periods,handleAcceptRange:z,handleClose:m,handleNavigateBack:Q,handleDownload:X,getTitle:J}},Ut="ExportStat-scss--module_popupBlock_PuNVB",vt={popupBlock:Ut},Kt=()=>{const{currentStep:e,periods:n,handleAcceptRange:r,handleClose:i,handleNavigateBack:T,handleDownload:u,getTitle:c}=bt();return s.jsx(We,{classNames:{block:vt.popupBlock},title:c(),onClose:i,children:s.jsx(Yt,{periods:n,currentStep:e,onClose:i,onAcceptRange:r,onNavigateBack:T,onDownload:u})})};export{Kt as ExportStat};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.