"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[95],{9433:(e,t,a)=>{a.d(t,{CronPicker:()=>c});var n=a(5872),l=a.n(n),r=(a(67294),a(38179)),i=a(55867),o=a(51995),s=a(61247),d=a(11965);const u={everyText:(0,i.t)("every"),emptyMonths:(0,i.t)("every month"),emptyMonthDays:(0,i.t)("every day of the month"),emptyMonthDaysShort:(0,i.t)("day of the month"),emptyWeekDays:(0,i.t)("every day of the week"),emptyWeekDaysShort:(0,i.t)("day of the week"),emptyHours:(0,i.t)("every hour"),emptyMinutes:(0,i.t)("every minute"),emptyMinutesForHourPeriod:(0,i.t)("every"),yearOption:(0,i.t)("year"),monthOption:(0,i.t)("month"),weekOption:(0,i.t)("week"),dayOption:(0,i.t)("day"),hourOption:(0,i.t)("hour"),minuteOption:(0,i.t)("minute"),rebootOption:(0,i.t)("reboot"),prefixPeriod:(0,i.t)("Every"),prefixMonths:(0,i.t)("in"),prefixMonthDays:(0,i.t)("on"),prefixWeekDays:(0,i.t)("on"),prefixWeekDaysForMonthAndYearPeriod:(0,i.t)("and"),prefixHours:(0,i.t)("at"),prefixMinutes:(0,i.t)(":"),prefixMinutesForHourPeriod:(0,i.t)("at"),suffixMinutesForHourPeriod:(0,i.t)("minute(s)"),errorInvalidCron:(0,i.t)("Invalid cron expression"),clearButtonText:(0,i.t)("Clear"),weekDays:[(0,i.t)("Sunday"),(0,i.t)("Monday"),(0,i.t)("Tuesday"),(0,i.t)("Wednesday"),(0,i.t)("Thursday"),(0,i.t)("Friday"),(0,i.t)("Saturday")],months:[(0,i.t)("January"),(0,i.t)("February"),(0,i.t)("March"),(0,i.t)("April"),(0,i.t)("May"),(0,i.t)("June"),(0,i.t)("July"),(0,i.t)("August"),(0,i.t)("September"),(0,i.t)("October"),(0,i.t)("November"),(0,i.t)("December")],altWeekDays:[(0,i.t)("SUN"),(0,i.t)("MON"),(0,i.t)("TUE"),(0,i.t)("WED"),(0,i.t)("THU"),(0,i.t)("FRI"),(0,i.t)("SAT")],altMonths:[(0,i.t)("JAN"),(0,i.t)("FEB"),(0,i.t)("MAR"),(0,i.t)("APR"),(0,i.t)("MAY"),(0,i.t)("JUN"),(0,i.t)("JUL"),(0,i.t)("AUG"),(0,i.t)("SEP"),(0,i.t)("OCT"),(0,i.t)("NOV"),(0,i.t)("DEC")]},c=(0,o.iK)((e=>(0,d.tZ)(r.ZP,{getPopupContainer:e=>e.parentElement},(0,d.tZ)(s.default,l()({locale:u},e)))))`
  .react-js-cron-field {
    margin-bottom: 0px;
  }
  .react-js-cron-select:not(.react-js-cron-custom-select) > div:first-of-type,
  .react-js-cron-custom-select {
    border-radius: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
    background-color: ${e=>{let{theme:t}=e;return t.colors.grayscale.light4}} !important;
  }
  .react-js-cron-custom-select > div:first-of-type {
    border-radius: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
  }
  .react-js-cron-custom-select .ant-select-selection-placeholder {
    flex: auto;
  }
  .react-js-cron-custom-select .ant-select-selection-overflow-item {
    align-self: center;
  }
`},67852:(e,t,a)=>{a.d(t,{E5:()=>Z,G:()=>h,Ks:()=>f,Mv:()=>p,OD:()=>E,Su:()=>_,aQ:()=>N,gH:()=>y,gt:()=>v,kq:()=>b,nn:()=>c,oA:()=>d,oo:()=>m,xZ:()=>T,yk:()=>g,zV:()=>u});var n=a(51995),l=a(11965),r=a(74069),i=a(35932),o=a(87183),s=a(9433);const d=(0,n.iK)(r.Z)`
  .ant-modal-body {
    padding: 0;
  }
`,u=n.iK.div`
  padding: ${e=>{let{theme:t}=e;return`${3*t.gridUnit}px ${4*t.gridUnit}px ${2*t.gridUnit}px`}};
  label {
    font-size: ${e=>{let{theme:t}=e;return t.typography.sizes.s}}px;
    color: ${e=>{let{theme:t}=e;return t.colors.grayscale.light1}};
  }
`,c=n.iK.div`
  border-top: 1px solid ${e=>{let{theme:t}=e;return t.colors.grayscale.light2}};
  padding: ${e=>{let{theme:t}=e;return`${4*t.gridUnit}px ${4*t.gridUnit}px ${6*t.gridUnit}px`}};
  .ant-select {
    width: 100%;
  }
  .control-label {
    font-size: ${e=>{let{theme:t}=e;return t.typography.sizes.s}}px;
    color: ${e=>{let{theme:t}=e;return t.colors.grayscale.light1}};
  }
`,p=n.iK.span`
  span {
    margin-right: ${e=>{let{theme:t}=e;return 2*t.gridUnit}}px;
    vertical-align: middle;
  }
  .text {
    vertical-align: middle;
  }
`,m=n.iK.div`
  margin-bottom: ${e=>{let{theme:t}=e;return 7*t.gridUnit}}px;

  h4 {
    margin-bottom: ${e=>{let{theme:t}=e;return 3*t.gridUnit}}px;
  }
`,T=(0,n.iK)(s.CronPicker)`
  margin-bottom: ${e=>{let{theme:t}=e;return 3*t.gridUnit}}px;
  width: ${e=>{let{theme:t}=e;return 120*t.gridUnit}}px;
`,h=n.iK.p`
  color: ${e=>{let{theme:t}=e;return t.colors.error.base}};
`,v=l.iv`
  margin-bottom: 0;
`,E=(0,n.iK)(i.Z)`
  width: ${e=>{let{theme:t}=e;return 40*t.gridUnit}}px;
`,_=e=>l.iv`
  margin: ${3*e.gridUnit}px 0 ${2*e.gridUnit}px;
`,g=e=>l.iv`
  margin: ${3*e.gridUnit}px 0 ${2*e.gridUnit}px;
`,b=e=>l.iv`
  margin: ${3*e.gridUnit}px 0;
`,N=n.iK.div`
  margin: ${e=>{let{theme:t}=e;return 8*t.gridUnit}}px 0
    ${e=>{let{theme:t}=e;return 4*t.gridUnit}}px;
`,f=(0,n.iK)(o.Y)`
  display: block;
  line-height: ${e=>{let{theme:t}=e;return 8*t.gridUnit}}px;
`,Z=(0,n.iK)(o.Y.Group)`
  margin-left: ${e=>{let{theme:t}=e;return.5*t.gridUnit}}px;
`,y=e=>l.iv`
  border: ${e.colors.error.base} 1px solid;
  padding: ${4*e.gridUnit}px;
  margin: ${4*e.gridUnit}px;
  margin-top: 0;
  color: ${e.colors.error.dark2};
  .ant-alert-message {
    font-size: ${e.typography.sizes.m}px;
    font-weight: bold;
  }
  .ant-alert-description {
    font-size: ${e.typography.sizes.m}px;
    line-height: ${4*e.gridUnit}px;
    .ant-alert-icon {
      margin-right: ${2.5*e.gridUnit}px;
      font-size: ${e.typography.sizes.l}px;
      position: relative;
      top: ${e.gridUnit/4}px;
    }
  }
`},73192:(e,t,a)=>{a.d(t,{r:()=>o}),a(67294);var n=a(51995),l=a(40987),r=a(11965);const i=(0,n.iK)(l.Z)`
  .ant-switch-checked {
    background-color: ${e=>{let{theme:t}=e;return t.colors.primary.base}};
  }
`,o=e=>(0,r.tZ)(i,e)},98978:(e,t,a)=>{a.d(t,{Z:()=>N});var n=a(11965),l=a(67294),r=a(80008),i=a.n(r),o=a(55867),s=a(4715);const d="GMT Standard Time",u="400px",c={"-300-240":["Eastern Standard Time","Eastern Daylight Time"],"-360-300":["Central Standard Time","Central Daylight Time"],"-420-360":["Mountain Standard Time","Mountain Daylight Time"],"-420-420":["Mountain Standard Time - Phoenix","Mountain Standard Time - Phoenix"],"-480-420":["Pacific Standard Time","Pacific Daylight Time"],"-540-480":["Alaska Standard Time","Alaska Daylight Time"],"-600-600":["Hawaii Standard Time","Hawaii Daylight Time"],60120:["Central European Time","Central European Daylight Time"],"00":[d,d],"060":["GMT Standard Time - London","British Summer Time"]},p=i()(),m=i()([2021,1]),T=i()([2021,7]),h=e=>m.tz(e).utcOffset().toString()+T.tz(e).utcOffset().toString(),v=e=>{var t,a;const n=h(e);return(p.tz(e).isDST()?null==(t=c[n])?void 0:t[1]:null==(a=c[n])?void 0:a[0])||e},E=i().tz.countries().map((e=>i().tz.zonesForCountry(e,!0))).flat(),_=[];E.forEach((e=>{_.find((t=>h(t.name)===h(e.name)))||_.push(e)}));const g=_.map((e=>({label:`GMT ${i().tz(p,e.name).format("Z")} (${v(e.name)})`,value:e.name,offsets:h(e.name),timezoneName:e.name}))),b=(e,t)=>i().tz(p,e.timezoneName).utcOffset()-i().tz(p,t.timezoneName).utcOffset();function N(e){let{onTimezoneChange:t,timezone:a,minWidth:r=u}=e;const d=(0,l.useMemo)((()=>(e=>{var t;return(null==(t=g.find((t=>t.offsets===h(e))))?void 0:t.value)||"Africa/Abidjan"})(a||i().tz.guess())),[a]);return(0,l.useEffect)((()=>{a!==d&&t(d)}),[d,t,a]),(0,n.tZ)(s.Ph,{ariaLabel:(0,o.t)("Timezone selector"),css:(0,n.iv)({minWidth:r},"",""),onChange:e=>t(e),value:d,options:g,sortComparator:b})}g.sort(b)},20095:(e,t,a)=>{a.d(t,{j5:()=>j,KL:()=>Y,ZP:()=>J});var n=a(78580),l=a.n(n),r=a(67294),i=a(55867),o=a(51995),s=a(11965),d=a(93185),u=a(31069),c=a(15926),p=a.n(c),m=a(34858),T=a(70163),h=a(9875),v=a(73192),E=a(74069),_=a(98978),g=a(87183),b=a(85633),N=a(91877),f=a(14114),Z=a(4715),y=a(42878),x=a(18451),S=a(67852),O=a(9882),A=a(28216),R=a(9433);const C=e=>{let{value:t,onChange:a}=e;const n=(0,o.Fg)(),l=(0,r.useRef)(null),[d,u]=(0,r.useState)("picker"),c=(0,r.useCallback)((e=>u(e.target.value)),[]),p=(0,r.useCallback)((e=>{var t;a(e),null==(t=l.current)||t.setValue(e)}),[l,a]),m=(0,r.useCallback)((e=>{a(e.target.value)}),[a]),T=(0,r.useCallback)((()=>{var e;a((null==(e=l.current)?void 0:e.input.value)||"")}),[a]),[v,E]=(0,r.useState)();return(0,s.tZ)(r.Fragment,null,(0,s.tZ)(g.Y.Group,{onChange:c,value:d},(0,s.tZ)("div",{className:"inline-container add-margin"},(0,s.tZ)(g.Y,{value:"picker"}),(0,s.tZ)(R.CronPicker,{clearButton:!1,value:t,setValue:p,disabled:"picker"!==d,displayError:"picker"===d,onError:E})),(0,s.tZ)("div",{className:"inline-container add-margin"},(0,s.tZ)(g.Y,{value:"input"}),(0,s.tZ)("span",{className:"input-label"},(0,i.t)("CRON Schedule")),(0,s.tZ)(j,{className:"styled-input"},(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(h.II,{type:"text",name:"crontab",ref:l,style:v?{borderColor:n.colors.error.base}:{},placeholder:(0,i.t)("CRON expression"),disabled:"input"!==d,onBlur:m,onPressEnter:T}))))))},D=o.iK.div`
  margin-bottom: 10px;

  .input-container {
    textarea {
      height: auto;
    }
  }

  .inline-container {
    margin-bottom: 10px;

    .input-container {
      margin-left: 10px;
    }

    > div {
      margin: 0;
    }

    .delete-button {
      margin-left: 10px;
      padding-top: 3px;
    }
  }
`,I=e=>{let{setting:t=null,index:a,onUpdate:n,onRemove:l}=e;const{method:d,recipients:u,options:c}=t||{},[p,m]=(0,r.useState)(u||""),h=(0,o.Fg)();return t?(u&&p!==u&&m(u),(0,s.tZ)(D,null,(0,s.tZ)("div",{className:"inline-container"},(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(Z.Ph,{ariaLabel:(0,i.t)("Delivery method"),onChange:e=>{if(m(""),n){const l={...t,method:e,recipients:""};n(a,l)}},placeholder:(0,i.t)("Select Delivery Method"),options:(c||[]).map((e=>({label:e,value:e}))),value:d}))),void 0!==d&&l?(0,s.tZ)("span",{role:"button",tabIndex:0,className:"delete-button",onClick:()=>l(a)},(0,s.tZ)(T.Z.Trash,{iconColor:h.colors.grayscale.base})):null),void 0!==d?(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},(0,i.t)(d)),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)("textarea",{name:"recipients",value:p,onChange:e=>{const{target:l}=e;if(m(l.value),n){const e={...t,recipients:l.value};n(a,e)}}})),(0,s.tZ)("div",{className:"helper"},(0,i.t)('Recipients are separated by "," or ";"'))):null)):null},U=["pivot_table_v2","table","paired_ttest"],X=["Email"],$="PNG",L=[{label:(0,i.t)("< (Smaller than)"),value:"<"},{label:(0,i.t)("> (Larger than)"),value:">"},{label:(0,i.t)("<= (Smaller or equal)"),value:"<="},{label:(0,i.t)(">= (Larger or equal)"),value:">="},{label:(0,i.t)("== (Is equal)"),value:"=="},{label:(0,i.t)("!= (Is not equal)"),value:"!="},{label:(0,i.t)("Not null"),value:"not null"}],M=[{label:(0,i.t)("None"),value:0},{label:(0,i.t)("30 days"),value:30},{label:(0,i.t)("60 days"),value:60},{label:(0,i.t)("90 days"),value:90}],P=(0,o.iK)(E.Z)`
  max-width: 1200px;
  width: 100%;

  .ant-modal-body {
    overflow: initial;
  }
`,k=e=>s.iv`
  margin: auto ${2*e.gridUnit}px auto 0;
  color: ${e.colors.grayscale.base};
`,w=o.iK.div`
  display: flex;
  flex-direction: column;

  .control-label {
    margin-top: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
  }

  .header-section {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    width: 100%;
    padding: ${e=>{let{theme:t}=e;return 4*t.gridUnit}}px;
    border-bottom: 1px solid ${e=>{let{theme:t}=e;return t.colors.grayscale.light2}};
  }

  .column-section {
    display: flex;
    flex: 1 1 auto;

    .column {
      flex: 1 1 auto;
      min-width: calc(33.33% - ${e=>{let{theme:t}=e;return 8*t.gridUnit}}px);
      padding: ${e=>{let{theme:t}=e;return 4*t.gridUnit}}px;

      .async-select {
        margin: 10px 0 20px;
      }

      &.condition {
        border-right: 1px solid ${e=>{let{theme:t}=e;return t.colors.grayscale.light2}};
      }

      &.message {
        border-left: 1px solid ${e=>{let{theme:t}=e;return t.colors.grayscale.light2}};
      }
    }
  }

  .inline-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    &.wrap {
      flex-wrap: wrap;
    }

    > div {
      flex: 1 1 auto;
    }

    &.add-margin {
      margin-bottom: 5px;
    }

    .styled-input {
      margin: 0 0 0 10px;

      input {
        flex: 0 0 auto;
      }
    }
  }
`,H=o.iK.div`
  display: flex;
  align-items: center;
  margin: ${e=>{let{theme:t}=e;return 2*t.gridUnit}}px auto
    ${e=>{let{theme:t}=e;return 4*t.gridUnit}}px auto;

  h4 {
    margin: 0;
  }

  .required {
    margin-left: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
    color: ${e=>{let{theme:t}=e;return t.colors.error.base}};
  }
`,z=o.iK.div`
  display: flex;
  align-items: center;
  margin-top: 10px;

  .switch-label {
    margin-left: 10px;
  }
`,j=o.iK.div`
  flex: 1;
  margin-top: 0;

  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  input[type='number'] {
    -moz-appearance: textfield;
  }

  .helper {
    display: block;
    color: ${e=>{let{theme:t}=e;return t.colors.grayscale.base}};
    font-size: ${e=>{let{theme:t}=e;return t.typography.sizes.s}}px;
    padding: ${e=>{let{theme:t}=e;return t.gridUnit}}px 0;
    text-align: left;
  }

  .required {
    margin-left: ${e=>{let{theme:t}=e;return t.gridUnit/2}}px;
    color: ${e=>{let{theme:t}=e;return t.colors.error.base}};
  }

  .input-container {
    display: flex;
    align-items: center;

    > div {
      width: 100%;
    }

    label {
      display: flex;
      margin-right: ${e=>{let{theme:t}=e;return 2*t.gridUnit}}px;
    }

    i {
      margin: 0 ${e=>{let{theme:t}=e;return t.gridUnit}}px;
    }
  }

  input,
  textarea {
    flex: 1 1 auto;
  }

  input[disabled] {
    color: ${e=>{let{theme:t}=e;return t.colors.grayscale.base}};
  }

  textarea {
    height: 300px;
    resize: none;
  }

  input::placeholder,
  textarea::placeholder {
    color: ${e=>{let{theme:t}=e;return t.colors.grayscale.light1}};
  }

  textarea,
  input[type='text'],
  input[type='number'] {
    padding: ${e=>{let{theme:t}=e;return t.gridUnit}}px
      ${e=>{let{theme:t}=e;return 2*t.gridUnit}}px;
    border-style: none;
    border: 1px solid ${e=>{let{theme:t}=e;return t.colors.grayscale.light2}};
    border-radius: ${e=>{let{theme:t}=e;return t.gridUnit}}px;

    &[name='description'] {
      flex: 1 1 auto;
    }
  }

  .input-label {
    margin-left: 10px;
  }
`,G=(0,o.iK)(g.Y)`
  display: block;
  line-height: ${e=>{let{theme:t}=e;return 7*t.gridUnit}}px;
`,q=(0,o.iK)(g.Y.Group)`
  margin-left: ${e=>{let{theme:t}=e;return 5.5*t.gridUnit}}px;
`,K=(0,o.iK)(Z.r4)`
  margin-top: ${e=>{let{theme:t}=e;return 2*t.gridUnit}}px;
`,F=o.iK.div`
  color: ${e=>{let{theme:t}=e;return t.colors.primary.dark1}};
  cursor: pointer;

  i {
    margin-right: ${e=>{let{theme:t}=e;return 2*t.gridUnit}}px;
  }

  &.disabled {
    color: ${e=>{let{theme:t}=e;return t.colors.grayscale.light1}};
    cursor: default;
  }
`,V=o.iK.div`
  .inline-container .input-container {
    margin-left: 0;
  }
`,W=e=>s.iv`
  margin-right: ${3*e.gridUnit}px;
`,Y={ADD_NOTIFICATION_METHOD_TEXT:(0,i.t)("Add notification method"),ADD_DELIVERY_METHOD_TEXT:(0,i.t)("Add delivery method"),SAVE_TEXT:(0,i.t)("Save"),ADD_TEXT:(0,i.t)("Add"),EDIT_REPORT_TEXT:(0,i.t)("Edit Report"),EDIT_ALERT_TEXT:(0,i.t)("Edit Alert"),ADD_REPORT_TEXT:(0,i.t)("Add Report"),ADD_ALERT_TEXT:(0,i.t)("Add Alert"),REPORT_NAME_TEXT:(0,i.t)("Report name"),ALERT_NAME_TEXT:(0,i.t)("Alert name"),OWNERS_TEXT:(0,i.t)("Owners"),DESCRIPTION_TEXT:(0,i.t)("Description"),ACTIVE_TEXT:(0,i.t)("Active"),ALERT_CONDITION_TEXT:(0,i.t)("Alert condition"),DATABASE_TEXT:(0,i.t)("Database"),SQL_QUERY_TEXT:(0,i.t)("SQL Query"),TRIGGER_ALERT_IF_TEXT:(0,i.t)("Trigger Alert If..."),CONDITION_TEXT:(0,i.t)("Condition"),VALUE_TEXT:(0,i.t)("Value"),VALUE_TOOLTIP:(0,i.t)("Threshold value should be double precision number"),REPORT_SCHEDULE_TEXT:(0,i.t)("Report schedule"),ALERT_CONDITION_SCHEDULE_TEXT:(0,i.t)("Alert condition schedule"),TIMEZONE_TEXT:(0,i.t)("Timezone"),SCHEDULE_SETTINGS_TEXT:(0,i.t)("Schedule settings"),LOG_RETENTION_TEXT:(0,i.t)("Log retention"),WORKING_TIMEOUT_TEXT:(0,i.t)("Working timeout"),TIME_IN_SECONDS_TEXT:(0,i.t)("Time in seconds"),SECONDS_TEXT:(0,i.t)("seconds"),GRACE_PERIOD_TEXT:(0,i.t)("Grace period"),MESSAGE_CONTENT_TEXT:(0,i.t)("Message content"),DASHBOARD_TEXT:(0,i.t)("Dashboard"),CHART_TEXT:(0,i.t)("Chart"),SEND_AS_PNG_TEXT:(0,i.t)("Send as PNG"),SEND_AS_CSV_TEXT:(0,i.t)("Send as CSV"),SEND_AS_TEXT:(0,i.t)("Send as text"),IGNORE_CACHE_TEXT:(0,i.t)("Ignore cache when generating report"),CUSTOM_SCREENSHOT_WIDTH_TEXT:(0,i.t)("Screenshot width"),CUSTOM_SCREENSHOT_WIDTH_PLACEHOLDER_TEXT:(0,i.t)("Input custom width in pixels"),NOTIFICATION_METHOD_TEXT:(0,i.t)("Notification method")},B=e=>{let{status:t="active",onClick:a}=e;return"hidden"===t?null:(0,s.tZ)(F,{className:t,onClick:()=>{"disabled"!==t&&a()}},(0,s.tZ)("i",{className:"fa fa-plus"})," ","active"===t?Y.ADD_NOTIFICATION_METHOD_TEXT:Y.ADD_DELIVERY_METHOD_TEXT)},J=(0,f.ZP)((e=>{var t,a,n,o,c,E,f,R;let{addDangerToast:D,onAdd:F,onHide:J,show:Q,alert:ee=null,isReport:te=!1,addSuccessToast:ae}=e;const ne=(0,A.v9)((e=>e.user)),le=(0,x.c)(),re=(null==le?void 0:le.ALERT_REPORTS_NOTIFICATION_METHODS)||X,[ie,oe]=(0,r.useState)(!0),[se,de]=(0,r.useState)(),[ue,ce]=(0,r.useState)(!0),[pe,me]=(0,r.useState)("dashboard"),[Te,he]=(0,r.useState)($),[ve,Ee]=(0,r.useState)(!1),[_e,ge]=(0,r.useState)(!1);(0,r.useEffect)((()=>{ge("dashboard"===pe||"chart"===pe&&"PNG"===Te)}),[pe,Te]);const[be,Ne]=(0,r.useState)(!1),[fe,Ze]=(0,r.useState)([]),[ye,xe]=(0,r.useState)([]),[Se,Oe]=(0,r.useState)([]),[Ae,Re]=(0,r.useState)(""),Ce=null!==ee,De="chart"===pe&&((0,N.c)(d.T.ALERTS_ATTACH_REPORTS)||te),[Ie,Ue]=(0,r.useState)("active"),[Xe,$e]=(0,r.useState)([]),{ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT:Le,ALERT_REPORTS_DEFAULT_CRON_VALUE:Me,ALERT_REPORTS_DEFAULT_RETENTION:Pe}=(0,A.v9)((e=>{var t,a,n,l;const r=null==(t=e.common)?void 0:t.conf;return{ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT:null!=(a=null==r?void 0:r.ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT)?a:3600,ALERT_REPORTS_DEFAULT_CRON_VALUE:null!=(n=null==r?void 0:r.ALERT_REPORTS_DEFAULT_CRON_VALUE)?n:"0 * * * *",ALERT_REPORTS_DEFAULT_RETENTION:null!=(l=null==r?void 0:r.ALERT_REPORTS_DEFAULT_RETENTION)?l:90}})),ke={active:!0,creation_method:"alerts_reports",crontab:Me,log_retention:Pe,working_timeout:Le,name:"",owners:[],recipients:[],sql:"",validator_config_json:{},validator_type:"",force_screenshot:!1,grace_period:void 0},we=(e,t)=>{const a=Xe.slice();a[e]=t,$e(a),void 0!==t.method&&"hidden"!==Ie&&Ue("active")},He=e=>{const t=Xe.slice();t.splice(e,1),$e(t),Ue("active")},{state:{loading:ze,resource:je,error:Ge},fetchResource:qe,createResource:Ke,updateResource:Fe,clearError:Ve}=(0,m.LE)("report",(0,i.t)("report"),D),We=()=>{Ve(),ce(!0),J(),$e([]),de({...ke}),Ue("active")},Ye=(0,r.useMemo)((()=>function(e,t,a){void 0===e&&(e="");const n=p().encode({filter:e,page:t,page_size:a});return u.Z.get({endpoint:`/api/v1/report/related/created_by?q=${n}`}).then((e=>({data:e.json.result.map((e=>({value:e.value,label:e.text}))),totalCount:e.json.count})))}),[]),Be=(0,r.useCallback)((e=>{const t=e||(null==se?void 0:se.database);if(!t||t.label)return null;let a;return fe.forEach((e=>{e.value!==t.value&&e.value!==t.id||(a=e)})),a}),[null==se?void 0:se.database,fe]),Je=(e,t)=>{de((a=>({...a,[e]:t})))},Qe=(0,r.useMemo)((()=>function(e,t,a){void 0===e&&(e="");const n=p().encode({filter:e,page:t,page_size:a});return u.Z.get({endpoint:`/api/v1/report/related/database?q=${n}`}).then((e=>{const t=e.json.result.map((e=>({value:e.value,label:e.text})));return Ze(t),{data:t,totalCount:e.json.count}}))}),[]),et=(null==se?void 0:se.database)&&!se.database.label;(0,r.useEffect)((()=>{et&&Je("database",Be())}),[et,Be]);const tt=(0,r.useMemo)((()=>function(e,t,a){void 0===e&&(e="");const n=p().encode_uri({filter:e,page:t,page_size:a});return u.Z.get({endpoint:`/api/v1/report/related/dashboard?q=${n}`}).then((e=>{const t=e.json.result.map((e=>({value:e.value,label:e.text})));return xe(t),{data:t,totalCount:e.json.count}}))}),[]),at=e=>{const t=e||(null==se?void 0:se.dashboard);if(!t||t.label)return null;let a;return ye.forEach((e=>{e.value!==t.value&&e.value!==t.id||(a=e)})),a},nt=(0,r.useCallback)((e=>{const t=e||(null==se?void 0:se.chart);if(!t||t.label)return null;let a;return Se.forEach((e=>{e.value!==t.value&&e.value!==t.id||(a=e)})),a}),[Se,null==se?void 0:se.chart]),lt=(null==se?void 0:se.chart)&&!(null!=se&&se.chart.label);(0,r.useEffect)((()=>{lt&&Je("chart",nt())}),[nt,lt]);const rt=(0,r.useMemo)((()=>function(e,t,a){void 0===e&&(e="");const n=p().encode_uri({filter:e,page:t,page_size:a});return u.Z.get({endpoint:`/api/v1/report/related/chart?q=${n}`}).then((e=>{const t=e.json.result.map((e=>({value:e.value,label:e.text})));return Oe(t),{data:t,totalCount:e.json.count}}))}),[]),it=e=>{const{target:{type:t,value:a,name:n}}=e,l="number"===t?parseInt(a,10)||null:a;Je(n,l)},ot=e=>{const{target:t}=e,a=+t.value;Je(t.name,0===a?null:a?Math.max(a,1):a)};(0,r.useEffect)((()=>{if(Ce&&(null==se||!se.id||(null==ee?void 0:ee.id)!==se.id||ue&&Q)){if(null!==(null==ee?void 0:ee.id)&&!ze&&!Ge){const e=ee.id||0;qe(e)}}else!Ce&&(!se||se.id||ue&&Q)&&(de({...ke,owners:ne?[{value:ne.userId,label:`${ne.firstName} ${ne.lastName}`}]:[]}),$e([]),Ue("active"))}),[ee]),(0,r.useEffect)((()=>{if(je){const e=(je.recipients||[]).map((e=>{const t="string"==typeof e.recipient_config_json?JSON.parse(e.recipient_config_json):{};return{method:e.type,recipients:t.target||e.recipient_config_json,options:re}}));$e(e),Ue(e.length===re.length?"hidden":"active"),me(je.chart?"chart":"dashboard"),he(je.chart&&je.report_format||$);const t="string"==typeof je.validator_config_json?JSON.parse(je.validator_config_json):je.validator_config_json;Ne("not null"===je.validator_type),je.chart&&Re(je.chart.viz_type),Ee(je.force_screenshot),de({...je,chart:je.chart?nt(je.chart)||{value:je.chart.id,label:je.chart.slice_name}:void 0,dashboard:je.dashboard?at(je.dashboard)||{value:je.dashboard.id,label:je.dashboard.dashboard_title}:void 0,database:je.database?Be(je.database)||{value:je.database.id,label:je.database.database_name}:void 0,owners:((null==ee?void 0:ee.owners)||[]).map((e=>({value:e.value||e.id,label:e.label||`${e.first_name} ${e.last_name}`}))),validator_config_json:"not null"===je.validator_type?{op:"not null"}:t})}}),[je]);const st=se||{};return(0,r.useEffect)((()=>{var e,t,a,n,l,r;null!=se&&null!=(e=se.name)&&e.length&&null!=se&&null!=(t=se.owners)&&t.length&&null!=se&&null!=(a=se.crontab)&&a.length&&void 0!==(null==se?void 0:se.working_timeout)&&("dashboard"===pe&&null!=se&&se.dashboard||"chart"===pe&&null!=se&&se.chart)&&(()=>{if(!Xe.length)return!1;let e=!1;return Xe.forEach((t=>{var a;t.method&&null!=(a=t.recipients)&&a.length&&(e=!0)})),e})()&&(te||se.database&&null!=(n=se.sql)&&n.length&&(be||null!=(l=se.validator_config_json)&&l.op)&&(be||void 0!==(null==(r=se.validator_config_json)?void 0:r.threshold)))?oe(!1):oe(!0)}),[st.name,st.owners,st.database,st.sql,st.validator_config_json,st.crontab,st.working_timeout,st.dashboard,st.chart,pe,Xe,be]),ue&&Q&&ce(!1),(0,s.tZ)(P,{className:"no-content-padding",responsive:!0,disablePrimaryButton:ie,onHandledPrimaryAction:()=>{var e,t,a;const n=[];Xe.forEach((e=>{e.method&&e.recipients.length&&n.push({recipient_config_json:{target:e.recipients},type:e.method})}));const l="chart"===pe&&!te,r={...se,type:te?"Report":"Alert",force_screenshot:l||ve,validator_type:be?"not null":"operator",validator_config_json:be?{}:null==se?void 0:se.validator_config_json,chart:"chart"===pe?null==se||null==(e=se.chart)?void 0:e.value:null,dashboard:"dashboard"===pe?null==se||null==(t=se.dashboard)?void 0:t.value:null,database:null==se||null==(a=se.database)?void 0:a.value,owners:((null==se?void 0:se.owners)||[]).map((e=>e.value||e.id)),recipients:n,report_format:"dashboard"===pe?$:Te||$};if(r.recipients&&!r.recipients.length&&delete r.recipients,r.context_markdown="string",Ce){if(null!=se&&se.id){const e=se.id;delete r.id,delete r.created_by,delete r.last_eval_dttm,delete r.last_state,delete r.last_value,delete r.last_value_row_json,Fe(e,r).then((e=>{e&&(ae((0,i.t)("%s updated",r.type)),F&&F(),We())}))}}else se&&Ke(r).then((e=>{e&&(ae((0,i.t)("%s updated",r.type)),F&&F(e),We())}))},onHide:We,primaryButtonName:Ce?Y.SAVE_TEXT:Y.ADD_TEXT,show:Q,width:"100%",maxWidth:"1450px",title:(0,s.tZ)("h4",null,Ce?(0,s.tZ)(T.Z.EditAlt,{css:k}):(0,s.tZ)(T.Z.PlusLarge,{css:k}),Ce&&te?Y.EDIT_REPORT_TEXT:Ce?Y.EDIT_ALERT_TEXT:te?Y.ADD_REPORT_TEXT:Y.ADD_ALERT_TEXT)},(0,s.tZ)(w,null,(0,s.tZ)("div",{className:"header-section"},(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},te?Y.REPORT_NAME_TEXT:Y.ALERT_NAME_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)("input",{type:"text",name:"name",value:se?se.name:"",placeholder:te?Y.REPORT_NAME_TEXT:Y.ALERT_NAME_TEXT,onChange:it,css:W}))),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.OWNERS_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(Z.qb,{ariaLabel:Y.OWNERS_TEXT,allowClear:!0,name:"owners",mode:"multiple",value:(null==se?void 0:se.owners)||[],options:Ye,onChange:e=>{Je("owners",e||[])},css:W}))),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.DESCRIPTION_TEXT),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)("input",{type:"text",name:"description",value:se&&se.description||"",placeholder:Y.DESCRIPTION_TEXT,onChange:it,css:W}))),(0,s.tZ)(z,null,(0,s.tZ)(v.r,{onChange:e=>{Je("active",e)},checked:!se||se.active}),(0,s.tZ)("div",{className:"switch-label"},Y.ACTIVE_TEXT))),(0,s.tZ)("div",{className:"column-section"},!te&&(0,s.tZ)("div",{className:"column condition"},(0,s.tZ)(H,null,(0,s.tZ)("h4",null,Y.ALERT_CONDITION_TEXT)),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.DATABASE_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(Z.qb,{ariaLabel:Y.DATABASE_TEXT,name:"source",value:null!=se&&null!=(t=se.database)&&t.label&&null!=se&&null!=(a=se.database)&&a.value?{value:se.database.value,label:se.database.label}:void 0,options:Qe,onChange:e=>{Je("database",e||[])}}))),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.SQL_QUERY_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)(y.Z,{name:"sql",language:"sql",offerEditInModal:!1,minLines:15,maxLines:15,onChange:e=>{Je("sql",e||"")},readOnly:!1,initialValue:null==je?void 0:je.sql,key:null==se?void 0:se.id})),(0,s.tZ)("div",{className:"inline-container wrap"},(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label",css:W},Y.TRIGGER_ALERT_IF_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(Z.Ph,{ariaLabel:Y.CONDITION_TEXT,onChange:e=>{var t;Ne("not null"===e);const a={op:e,threshold:se?null==(t=se.validator_config_json)?void 0:t.threshold:void 0};Je("validator_config_json",a)},placeholder:"Condition",value:(null==se||null==(n=se.validator_config_json)?void 0:n.op)||void 0,options:L,css:W}))),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.VALUE_TEXT," ",(0,s.tZ)(O.V,{tooltip:Y.VALUE_TOOLTIP}),(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)("input",{type:"number",name:"threshold",disabled:be,value:void 0!==(null==se||null==(o=se.validator_config_json)?void 0:o.threshold)?se.validator_config_json.threshold:"",placeholder:Y.VALUE_TEXT,onChange:e=>{var t;const{target:a}=e,n={op:se?null==(t=se.validator_config_json)?void 0:t.op:void 0,threshold:a.value};Je("validator_config_json",n)}}))))),(0,s.tZ)("div",{className:"column schedule"},(0,s.tZ)(H,null,(0,s.tZ)("h4",null,te?Y.REPORT_SCHEDULE_TEXT:Y.ALERT_CONDITION_SCHEDULE_TEXT),(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)(C,{value:(null==se?void 0:se.crontab)||Me,onChange:e=>Je("crontab",e)}),(0,s.tZ)("div",{className:"control-label"},Y.TIMEZONE_TEXT),(0,s.tZ)("div",{className:"input-container",css:e=>(e=>s.iv`
  margin: ${3*e.gridUnit}px 0;
`)(e)},(0,s.tZ)(_.Z,{onTimezoneChange:e=>{Je("timezone",e)},timezone:null==se?void 0:se.timezone,minWidth:"100%"})),(0,s.tZ)(H,null,(0,s.tZ)("h4",null,Y.SCHEDULE_SETTINGS_TEXT)),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.LOG_RETENTION_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(Z.Ph,{ariaLabel:Y.LOG_RETENTION_TEXT,placeholder:Y.LOG_RETENTION_TEXT,onChange:e=>{Je("log_retention",e)},value:"number"==typeof(null==se?void 0:se.log_retention)?null==se?void 0:se.log_retention:Pe,options:M,sortComparator:(0,b.mj)("value")}))),(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.WORKING_TIMEOUT_TEXT,(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)("input",{type:"number",min:"1",name:"working_timeout",value:(null==se?void 0:se.working_timeout)||"",placeholder:Y.TIME_IN_SECONDS_TEXT,onChange:ot}),(0,s.tZ)("span",{className:"input-label"},Y.SECONDS_TEXT))),!te&&(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label"},Y.GRACE_PERIOD_TEXT),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)("input",{type:"number",min:"1",name:"grace_period",value:(null==se?void 0:se.grace_period)||"",placeholder:Y.TIME_IN_SECONDS_TEXT,onChange:ot}),(0,s.tZ)("span",{className:"input-label"},Y.SECONDS_TEXT)))),(0,s.tZ)("div",{className:"column message"},(0,s.tZ)(H,null,(0,s.tZ)("h4",null,Y.MESSAGE_CONTENT_TEXT),(0,s.tZ)("span",{className:"required"},"*")),(0,s.tZ)(g.Y.Group,{onChange:e=>{const{target:t}=e;Ee(!1),setTimeout((()=>me(t.value)),200)},value:pe},(0,s.tZ)(G,{value:"dashboard"},Y.DASHBOARD_TEXT),(0,s.tZ)(G,{value:"chart"},Y.CHART_TEXT)),"chart"===pe?(0,s.tZ)(Z.qb,{ariaLabel:Y.CHART_TEXT,name:"chart",value:null!=se&&null!=(c=se.chart)&&c.label&&null!=se&&null!=(E=se.chart)&&E.value?{value:se.chart.value,label:se.chart.label}:void 0,options:rt,onChange:e=>{(e=>{u.Z.get({endpoint:`/api/v1/chart/${e.value}`}).then((e=>Re(e.json.result.viz_type)))})(e),Je("chart",e||void 0),Je("dashboard",null)}}):(0,s.tZ)(Z.qb,{ariaLabel:Y.DASHBOARD_TEXT,name:"dashboard",value:null!=se&&null!=(f=se.dashboard)&&f.label&&null!=se&&null!=(R=se.dashboard)&&R.value?{value:se.dashboard.value,label:se.dashboard.label}:void 0,options:tt,onChange:e=>{Je("dashboard",e||void 0),Je("chart",null)}}),De&&(0,s.tZ)(r.Fragment,null,(0,s.tZ)("div",{className:"inline-container"},(0,s.tZ)(q,{onChange:e=>{const{target:t}=e;he(t.value)},value:Te},(0,s.tZ)(G,{value:"PNG"},Y.SEND_AS_PNG_TEXT),(0,s.tZ)(G,{value:"CSV"},Y.SEND_AS_CSV_TEXT),l()(U).call(U,Ae)&&(0,s.tZ)(G,{value:"TEXT"},Y.SEND_AS_TEXT)))),_e&&(0,s.tZ)(j,null,(0,s.tZ)("div",{className:"control-label",css:S.yk},Y.CUSTOM_SCREENSHOT_WIDTH_TEXT),(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(h.II,{type:"number",name:"custom_width",value:(null==se?void 0:se.custom_width)||"",placeholder:Y.CUSTOM_SCREENSHOT_WIDTH_PLACEHOLDER_TEXT,onChange:it}))),(te||"dashboard"===pe)&&(0,s.tZ)("div",{className:"inline-container"},(0,s.tZ)(K,{className:"checkbox",checked:ve,onChange:e=>{Ee(e.target.checked)}},Y.IGNORE_CACHE_TEXT)),(0,s.tZ)(H,null,(0,s.tZ)("h4",null,Y.NOTIFICATION_METHOD_TEXT),(0,s.tZ)("span",{className:"required"},"*")),Xe.map(((e,t)=>(0,s.tZ)(V,null,(0,s.tZ)(I,{setting:e,index:t,key:`NotificationMethod-${t}`,onUpdate:we,onRemove:He})))),(0,s.tZ)(B,{status:Ie,onClick:()=>{const e=Xe.slice();e.push({recipients:"",options:re}),$e(e),Ue(e.length===re.length?"hidden":"disabled")}})))))}))}}]);
//# sourceMappingURL=ab3e758f9d7e1184ce42.chunk.js.map