"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:()=>T,xZ:()=>m,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;
  }
`,T=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;
  }
`,m=(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()(),T=i()([2021,1]),m=i()([2021,7]),h=e=>T.tz(e).utcOffset().toString()+m.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:()=>z,KL:()=>W,ZP:()=>B});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),T=a(34858),m=a(70163),h=a(9875),v=a(73192),E=a(74069),_=a(98978),g=a(87183),b=a(85633),N=a(14114),f=a(4715),Z=a(42878),y=a(18451),x=a(67852),S=a(9882),O=a(28216),A=a(9433);const R=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]),T=(0,r.useCallback)((e=>{a(e.target.value)}),[a]),m=(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)(A.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)(z,{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:T,onPressEnter:m}))))))},C=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;
    }
  }
`,D=e=>{let{setting:t=null,index:a,onUpdate:n,onRemove:l}=e;const{method:d,recipients:u,options:c}=t||{},[p,T]=(0,r.useState)(u||""),h=(0,o.Fg)();return t?(u&&p!==u&&T(u),(0,s.tZ)(C,null,(0,s.tZ)("div",{className:"inline-container"},(0,s.tZ)(z,null,(0,s.tZ)("div",{className:"input-container"},(0,s.tZ)(f.Ph,{ariaLabel:(0,i.t)("Delivery method"),onChange:e=>{if(T(""),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)(m.Z.Trash,{iconColor:h.colors.grayscale.base})):null),void 0!==d?(0,s.tZ)(z,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(T(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},I=["pivot_table_v2","table","paired_ttest"],U=["Email"],X="PNG",$=[{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"}],L=[{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}],M=(0,o.iK)(E.Z)`
  max-width: 1200px;
  width: 100%;

  .ant-modal-body {
    overflow: initial;
  }
`,P=e=>s.iv`
  margin: auto ${2*e.gridUnit}px auto 0;
  color: ${e.colors.grayscale.base};
`,k=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;
      }
    }
  }
`,w=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}};
  }
`,H=o.iK.div`
  display: flex;
  align-items: center;
  margin-top: 10px;

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