"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9355,335],{29431:(ae,R,t)=>{t.r(R),t.d(R,{default:()=>ye,useMuteTimingNavData:()=>de});var e=t(85960),T=t(30694),p=t(49199),v=t(763),L=t(65892),d=t(66681),u=t(53285),K=t(47257),y=t(79468),C=t(51637),P=t(20519),f=t(24956),k=t(29165),U=t(95162),x=t(70335),G=t(84954),W=t(5970),H=t(98724),z=t(77294),O=t(56375);const I=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],J=["january","february","march","april","may","june","july","august","september","october","november","december"],B={times:[{start_time:"",end_time:""}],weekdays:"",days_of_month:"",months:"",years:"",location:""},Y=(a,r,i)=>a?a.split(",").map(o=>o.trim()).every(o=>o.split(":").every(r))||i:!0,V=a=>a?a.split(",").map(r=>r.trim()):void 0,oe=a=>{const r=a.time_intervals.map(({times:i,weekdays:o,days_of_month:g,months:E,years:D,location:s})=>{const n={times:i.filter(({start_time:c,end_time:l})=>!!c&&!!l),weekdays:V(o)?.map(c=>c.toLowerCase()),days_of_month:V(g),months:V(E),years:V(D),location:s||void 0};return(0,O.omitBy)(n,O.isUndefined)});return{name:a.name,time_intervals:r}};var Z=t(84237),te=t(13086),Q=t(97666),se=t(81368),m=t(84933),h=t(75064),A=t(77542);const $="Times must be between 00:00 and 24:00 UTC",X=({intervalIndex:a})=>{const r=(0,K.wW)(j),{register:i,formState:o,getValues:g}=(0,u.Gc)(),{fields:E,append:D,remove:s}=(0,u.Dq)({name:`time_intervals.${a}.times`}),n=o.errors.time_intervals?.[a],c=n?.times?.some?.(l=>l?.start_time||l?.end_time)??!1;return e.createElement("div",null,e.createElement(P.g,{className:r.field,label:"Time range",description:"The time inclusive of the start and exclusive of the end time (in UTC if no location has been selected, otherwise local time)",invalid:c},e.createElement(e.Fragment,null,E.map((l,M)=>{const b=n?.times?.[M],re=`time_intervals.${a}.times.${M}.start_time`,w=`time_intervals.${a}.times.${M}.end_time`,F=()=>{const N=g(re),_=g(w);return[N,_]};return e.createElement("div",{className:r.timeRange,key:l.id},e.createElement(se.Z,null,e.createElement(m._,{label:"Start time",invalid:!!b?.start_time,error:b?.start_time?.message},e.createElement(f.I,{...i(re,{validate:N=>{if(!(0,A.ot)(N))return $;const[q,ee]=F();if(!(0,A.kO)(q,ee))return"Start time must be before end time"}}),className:r.timeRangeInput,maxLength:5,suffix:e.createElement(Q.J,{name:"clock-nine"}),defaultValue:l.start_time,placeholder:"HH:mm","data-testid":"mute-timing-starts-at"})),e.createElement(m._,{label:"End time",invalid:!!b?.end_time,error:b?.end_time?.message},e.createElement(f.I,{...i(`time_intervals.${a}.times.${M}.end_time`,{validate:N=>{if(!(0,A.ot)(N))return $;const[q,ee]=F();if(!(0,A.kO)(q,ee))return"End time must be after start time"}}),className:r.timeRangeInput,maxLength:5,suffix:e.createElement(Q.J,{name:"clock-nine"}),defaultValue:l.end_time,placeholder:"HH:mm","data-testid":"mute-timing-ends-at"})),e.createElement(h.h,{className:r.deleteTimeRange,title:"Remove",name:"trash-alt",onClick:N=>{N.preventDefault(),s(M)},tooltip:"Remove time range"})))}))),e.createElement(k.zx,{className:r.addTimeRange,variant:"secondary",type:"button",icon:"plus",onClick:()=>D({start_time:"",end_time:""})},"Add another time range"))},j=a=>({field:(0,d.css)`
    margin-bottom: 0;
  `,timeRange:(0,d.css)`
    margin-bottom: ${a.spacing(1)};
  `,timeRangeInput:(0,d.css)`
    width: 90px;
  `,deleteTimeRange:(0,d.css)`
    margin: ${a.spacing(1)} 0 0 ${a.spacing(.5)};
  `,addTimeRange:(0,d.css)`
    margin-bottom: ${a.spacing(2)};
  `});var S=t(27436);const ce=["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Araguaina","America/Argentina/Buenos_Aires","America/Argentina/Catamarca","America/Argentina/Cordoba","America/Argentina/Jujuy","America/Argentina/La_Rioja","America/Argentina/Mendoza","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Aruba","America/Asuncion","America/Atikokan","America/Bahia","America/Bahia_Banderas","America/Barbados","America/Belem","America/Belize","America/Blanc-Sablon","America/Boa_Vista","America/Bogota","America/Boise","America/Cambridge_Bay","America/Campo_Grande","America/Cancun","America/Caracas","America/Cayenne","America/Cayman","America/Chicago","America/Chihuahua","America/Ciudad_Juarez","America/Costa_Rica","America/Creston","America/Cuiaba","America/Curacao","America/Danmarkshavn","America/Dawson","America/Dawson_Creek","America/Denver","America/Detroit","America/Dominica","America/Edmonton","America/Eirunepe","America/El_Salvador","America/Fort_Nelson","America/Fortaleza","America/Glace_Bay","America/Godthab","America/Goose_Bay","America/Grand_Turk","America/Grenada","America/Guadeloupe","America/Guatemala","America/Guayaquil","America/Guyana","America/Halifax","America/Havana","America/Hermosillo","America/Indiana/Indianapolis","America/Indiana/Knox","America/Indiana/Marengo","America/Indiana/Petersburg","America/Indiana/Tell_City","America/Indiana/Vevay","America/Indiana/Vincennes","America/Indiana/Winamac","America/Inuvik","America/Iqaluit","America/Jamaica","America/Juneau","America/Kentucky/Louisville","America/Kentucky/Monticello","America/Kralendijk","America/La_Paz","America/Lima","America/Los_Angeles","America/Lower_Princes","America/Maceio","America/Managua","America/Manaus","America/Marigot","America/Martinique","America/Matamoros","America/Mazatlan","America/Menominee","America/Merida","America/Metlakatla","America/Mexico_City","America/Miquelon","America/Moncton","America/Monterrey","America/Montevideo","America/Montreal","America/Montserrat","America/Nassau","America/New_York","America/Nipigon","America/Nome","America/Noronha","America/North_Dakota/Beulah","America/North_Dakota/Center","America/North_Dakota/New_Salem","America/Nuuk","America/Ojinaga","America/Panama","America/Pangnirtung","America/Paramaribo","America/Phoenix","America/Port-au-Prince","America/Port_of_Spain","America/Porto_Velho","America/Puerto_Rico","America/Punta_Arenas","America/Rainy_River","America/Rankin_Inlet","America/Recife","America/Regina","America/Resolute","America/Rio_Branco","America/Santa_Isabel","America/Santarem","America/Santiago","America/Santo_Domingo","America/Sao_Paulo","America/Scoresbysund","America/Shiprock","America/Sitka","America/St_Barthelemy","America/St_Johns","America/St_Kitts","America/St_Lucia","America/St_Thomas","America/St_Vincent","America/Swift_Current","America/Tegucigalpa","America/Thule","America/Thunder_Bay","America/Tijuana","America/Toronto","America/Tortola","America/Vancouver","America/Whitehorse","America/Winnipeg","America/Yakutat","America/Yellowknife","Antarctica/Casey","Antarctica/Davis","Antarctica/DumontDUrville","Antarctica/Macquarie","Antarctica/Mawson","Antarctica/McMurdo","Antarctica/Palmer","Antarctica/Rothera","Antarctica/South_Pole","Antarctica/Syowa","Antarctica/Troll","Antarctica/Vostok","Arctic/Longyearbyen","Asia/Aden","Asia/Almaty","Asia/Amman","Asia/Anadyr","Asia/Aqtau","Asia/Aqtobe","Asia/Ashgabat","Asia/Atyrau","Asia/Baghdad","Asia/Bahrain","Asia/Baku","Asia/Bangkok","Asia/Barnaul","Asia/Beirut","Asia/Bishkek","Asia/Brunei","Asia/Calcutta","Asia/Chita","Asia/Choibalsan","Asia/Chongqing","Asia/Colombo","Asia/Damascus","Asia/Dhaka","Asia/Dili","Asia/Dubai","Asia/Dushanbe","Asia/Famagusta","Asia/Gaza","Asia/Harbin","Asia/Hebron","Asia/Ho_Chi_Minh","Asia/Hong_Kong","Asia/Hovd","Asia/Irkutsk","Asia/Jakarta","Asia/Jayapura","Asia/Jerusalem","Asia/Kabul","Asia/Kamchatka","Asia/Karachi","Asia/Kashgar","Asia/Kathmandu","Asia/Katmandu","Asia/Khandyga","Asia/Krasnoyarsk","Asia/Kuala_Lumpur","Asia/Kuching","Asia/Kuwait","Asia/Macau","Asia/Magadan","Asia/Makassar","Asia/Manila","Asia/Muscat","Asia/Nicosia","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Oral","Asia/Phnom_Penh","Asia/Pontianak","Asia/Pyongyang","Asia/Qatar","Asia/Qostanay","Asia/Qyzylorda","Asia/Rangoon","Asia/Riyadh","Asia/Sakhalin","Asia/Samarkand","Asia/Seoul","Asia/Shanghai","Asia/Singapore","Asia/Srednekolymsk","Asia/Taipei","Asia/Tashkent","Asia/Tbilisi","Asia/Tehran","Asia/Thimphu","Asia/Tokyo","Asia/Tomsk","Asia/Ulaanbaatar","Asia/Urumqi","Asia/Ust-Nera","Asia/Vientiane","Asia/Vladivostok","Asia/Yakutsk","Asia/Yangon","Asia/Yekaterinburg","Asia/Yerevan","Atlantic/Azores","Atlantic/Bermuda","Atlantic/Canary","Atlantic/Cape_Verde","Atlantic/Faroe","Atlantic/Madeira","Atlantic/Reykjavik","Atlantic/South_Georgia","Atlantic/St_Helena","Atlantic/Stanley","Australia/Adelaide","Australia/Brisbane","Australia/Broken_Hill","Australia/Currie","Australia/Darwin","Australia/Eucla","Australia/Hobart","Australia/Lindeman","Australia/Lord_Howe","Australia/Melbourne","Australia/Perth","Australia/Sydney","Europe/Amsterdam","Europe/Andorra","Europe/Astrakhan","Europe/Athens","Europe/Belgrade","Europe/Berlin","Europe/Bratislava","Europe/Brussels","Europe/Bucharest","Europe/Budapest","Europe/Busingen","Europe/Chisinau","Europe/Copenhagen","Europe/Dublin","Europe/Gibraltar","Europe/Guernsey","Europe/Helsinki","Europe/Isle_of_Man","Europe/Istanbul","Europe/Jersey","Europe/Kaliningrad","Europe/Kiev","Europe/Kirov","Europe/Kyiv","Europe/Lisbon","Europe/Ljubljana","Europe/London","Europe/Luxembourg","Europe/Madrid","Europe/Malta","Europe/Mariehamn","Europe/Minsk","Europe/Monaco","Europe/Moscow","Europe/Oslo","Europe/Paris","Europe/Podgorica","Europe/Prague","Europe/Riga","Europe/Rome","Europe/Samara","Europe/San_Marino","Europe/Sarajevo","Europe/Saratov","Europe/Simferopol","Europe/Skopje","Europe/Sofia","Europe/Stockholm","Europe/Tallinn","Europe/Tirane","Europe/Ulyanovsk","Europe/Uzhgorod","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Vilnius","Europe/Volgograd","Europe/Warsaw","Europe/Zagreb","Europe/Zaporozhye","Europe/Zurich","GMT","Indian/Antananarivo","Indian/Chagos","Indian/Christmas","Indian/Cocos","Indian/Comoro","Indian/Kerguelen","Indian/Mahe","Indian/Maldives","Indian/Mauritius","Indian/Mayotte","Indian/Reunion","Local","Pacific/Apia","Pacific/Auckland","Pacific/Bougainville","Pacific/Chatham","Pacific/Chuuk","Pacific/Easter","Pacific/Efate","Pacific/Enderbury","Pacific/Fakaofo","Pacific/Fiji","Pacific/Funafuti","Pacific/Galapagos","Pacific/Gambier","Pacific/Guadalcanal","Pacific/Guam","Pacific/Honolulu","Pacific/Johnston","Pacific/Kanton","Pacific/Kiritimati","Pacific/Kosrae","Pacific/Kwajalein","Pacific/Majuro","Pacific/Marquesas","Pacific/Midway","Pacific/Nauru","Pacific/Niue","Pacific/Norfolk","Pacific/Noumea","Pacific/Pago_Pago","Pacific/Palau","Pacific/Pitcairn","Pacific/Pohnpei","Pacific/Ponape","Pacific/Port_Moresby","Pacific/Rarotonga","Pacific/Saipan","Pacific/Tahiti","Pacific/Tarawa","Pacific/Tongatapu","Pacific/Truk","Pacific/Wake","Pacific/Wallis","UTC"],le=a=>{const r=ce.map(i=>({label:i,value:i}));return e.createElement(S.Ph,{...a,options:r})},me=()=>{const a=(0,K.wW)(ue),{formState:r,register:i,setValue:o}=(0,u.Gc)(),{fields:g,append:E,remove:D}=(0,u.Dq)({name:"time_intervals"});return e.createElement(C.C,{label:"Time intervals"},e.createElement(e.Fragment,null,e.createElement("p",null,"A time interval is a definition for a moment in time. All fields are lists, and at least one list element must be satisfied to match the field. If a field is left blank, any moment of time will match the field. For an instant of time to match a complete time interval, all fields must match. A mute timing can contain multiple time intervals."),e.createElement(te.K,{direction:"column",gap:2},g.map((s,n)=>{const c=r.errors;return i(`time_intervals.${n}.location`),e.createElement("div",{key:s.id,className:a.timeIntervalSection},e.createElement(X,{intervalIndex:n}),e.createElement(P.g,{label:"Location",invalid:!!c.time_intervals?.[n]?.location,error:c.time_intervals?.[n]?.location?.message},e.createElement(le,{prefix:e.createElement(Q.J,{name:"map-marker"}),width:50,onChange:l=>{o(`time_intervals.${n}.location`,l.value)},defaultValue:{label:s.location,value:s.location},"data-testid":"mute-timing-location"})),e.createElement(P.g,{label:"Days of the week"},e.createElement(ge,{onChange:l=>{o(`time_intervals.${n}.weekdays`,l)},defaultValue:s.weekdays})),e.createElement(P.g,{label:"Days of the month",description:"The days of the month, 1-31, of a month. Negative values can be used to represent days which begin at the end of the month",invalid:!!c.time_intervals?.[n]?.days_of_month,error:c.time_intervals?.[n]?.days_of_month?.message},e.createElement(f.I,{...i(`time_intervals.${n}.days_of_month`,{validate:l=>Y(l,M=>{const b=parseInt(M,10);return b>-31&&b<0||b>0&&b<32},"Invalid day")}),width:50,defaultValue:s.days_of_month,placeholder:"Example: 1, 14:16, -1","data-testid":"mute-timing-days"})),e.createElement(P.g,{label:"Months",description:"The months of the year in either numerical or the full calendar month",invalid:!!c.time_intervals?.[n]?.months,error:c.time_intervals?.[n]?.months?.message},e.createElement(f.I,{...i(`time_intervals.${n}.months`,{validate:l=>Y(l,M=>J.includes(M)||parseInt(M,10)<13&&parseInt(M,10)>0,"Invalid month")}),width:50,placeholder:"Example: 1:3, may:august, december",defaultValue:s.months,"data-testid":"mute-timing-months"})),e.createElement(P.g,{label:"Years",invalid:!!c.time_intervals?.[n]?.years,error:c.time_intervals?.[n]?.years?.message??""},e.createElement(f.I,{...i(`time_intervals.${n}.years`,{validate:l=>Y(l,M=>/^\d{4}$/.test(M),"Invalid year")}),width:50,placeholder:"Example: 2021:2022, 2030",defaultValue:s.years,"data-testid":"mute-timing-years"})),e.createElement(k.zx,{type:"button",variant:"destructive",fill:"outline",icon:"trash-alt",onClick:()=>D(n)},"Remove time interval"))})),e.createElement(k.zx,{type:"button",variant:"secondary",className:a.removeTimeIntervalButton,onClick:()=>{E(B)},icon:"plus"},"Add another time interval")))},ie=a=>{const r=a.split(",").map(i=>i.trim()).flatMap(i=>i.includes(":")?ne(i):i).map(i=>i.toLowerCase()).filter(i=>I.includes(i));return(0,O.uniq)(r)};function ne(a){const[r="",i=""]=a.split(":"),o=I.indexOf(r),g=I.indexOf(i);return I.slice(o,g+1)}const ge=({defaultValue:a="",onChange:r})=>{const i=(0,K.wW)(ue),o=ie(a),[g,E]=(0,e.useState)(o),D=s=>{g.includes(s)?E(n=>(0,O.without)(n,s)):E(n=>(0,O.concat)(n,s))};return(0,e.useEffect)(()=>{r(g.join(", "))},[g,r]),e.createElement("div",{"data-testid":"mute-timing-weekdays"},e.createElement(te.K,{gap:1},I.map(s=>{const n=(0,d.cx)(i.dayOfTheWeek,g.includes(s)&&"selected"),c=s.slice(0,3);return e.createElement("button",{type:"button",key:s,className:n,onClick:()=>D(s)},(0,O.upperFirst)(c))})))},ue=a=>({input:(0,d.css)`
    width: 400px;
  `,timeIntervalSection:(0,d.css)`
    background-color: ${a.colors.background.secondary};
    padding: ${a.spacing(2)};
  `,removeTimeIntervalButton:(0,d.css)`
    margin-top: ${a.spacing(2)};
  `,dayOfTheWeek:(0,d.css)`
    cursor: pointer;
    user-select: none;
    padding: ${a.spacing(1)} ${a.spacing(3)};

    border: solid 1px ${a.colors.border.medium};
    background: none;
    border-radius: ${a.shape.radius.default};

    color: ${a.colors.text.secondary};

    &.selected {
      font-weight: ${a.typography.fontWeightBold};
      color: ${a.colors.primary.text};
      border-color: ${a.colors.primary.border};
      background: ${a.colors.primary.transparent};
    }
  `}),fe=a=>{const r={name:"",time_intervals:[B]};if(!a)return r;const i=a.time_intervals.map(o=>({times:o.times??B.times,weekdays:o.weekdays?.join(", ")??B.weekdays,days_of_month:o.days_of_month?.join(", ")??B.days_of_month,months:o.months?.join(", ")??B.months,years:o.years?.join(", ")??B.years,location:o.location??B.location}));return{name:a.name,time_intervals:i}},he=({muteTiming:a,showError:r,loading:i,provenance:o})=>{const g=(0,U.useDispatch)(),{selectedAlertmanager:E}=(0,G.ZA)(),D=(0,K.wW)(Ee),[s,n]=(0,e.useState)(!1),{currentData:c}=(0,x.W)(E),l=c?.alertmanager_config,M=fe(a),b=(0,u.cI)({defaultValues:M}),re=w=>{if(!c)return;const F=oe(w),N=a?l?.mute_time_intervals?.filter(({name:ee})=>ee!==a.name):l?.mute_time_intervals,_={...c,alertmanager_config:{...l,route:a&&F.name!==a.name?(0,H.FM)(F.name,a.name,l?.route??{}):l?.route,mute_time_intervals:[...N||[],F]}},q=g((0,W.mM)({newConfig:_,oldConfig:c,alertManagerSourceName:E,successMessage:"Mute timing saved",redirectPath:"/alerting/routes/",redirectSearch:"tab=mute_timings"}));n(!0),q.unwrap().finally(()=>{n(!1)})};return e.createElement(e.Fragment,null,o&&e.createElement(Z.Xq,{resource:Z.Uv.MuteTiming}),i&&e.createElement(y.u,{text:"Loading mute timing"}),r&&e.createElement(p.b,{title:"No matching mute timing found"}),c&&!i&&!r&&e.createElement(u.RV,{...b},e.createElement("form",{onSubmit:b.handleSubmit(re),"data-testid":"mute-timing-form"},e.createElement(C.C,{label:"Create mute timing",disabled:!!o||s},e.createElement(P.g,{required:!0,label:"Name",description:"A unique name for the mute timing",invalid:!!b.formState.errors?.name,error:b.formState.errors.name?.message},e.createElement(f.I,{...b.register("name",{required:!0,validate:w=>{if(!a)return l?.mute_time_intervals?.find(({name:N})=>w===N)?`Mute timing already exists for "${w}"`:!0}}),className:D.input,"data-testid":"mute-timing-name"})),e.createElement(me,null),e.createElement(k.zx,{type:"submit",className:D.submitButton,disabled:s},"Save mute timing"),e.createElement(k.Qj,{type:"button",variant:"secondary",fill:"outline",href:(0,z.eQ)("/alerting/routes/",E,{tab:"mute_timings"}),disabled:s},"Cancel")))))},Ee=a=>({input:(0,d.css)`
    width: 400px;
  `,submitButton:(0,d.css)`
    margin-right: ${a.spacing(1)};
  `}),Ae=he,pe=()=>{const[a]=(0,v.K)(),{selectedAlertmanager:r}=(0,G.ZA)(),{currentData:i,isLoading:o,error:g}=(0,x.W)(r,{refetchOnFocus:!0,refetchOnReconnect:!0}),E=i?.alertmanager_config,D=(0,e.useCallback)(s=>{const n=E?.mute_time_intervals?.find(({name:c})=>c===s);if(n){const c=E?.muteTimeProvenances?.[n.name];return{...n,provenance:c}}return n},[E]);return e.createElement(e.Fragment,null,g&&!o&&!i&&e.createElement(p.b,{severity:"error",title:`Error loading Alertmanager config for ${r}`},g.message||"Unknown error."),i&&!g&&e.createElement(T.rs,null,e.createElement(T.AW,{exact:!0,path:"/alerting/routes/mute-timing/new"},e.createElement(Ae,{loading:o})),e.createElement(T.AW,{exact:!0,path:"/alerting/routes/mute-timing/edit"},()=>{if(a.muteName){const s=D(String(a.muteName)),n=s?.provenance;return e.createElement(Ae,{loading:o,muteTiming:s,showError:!s&&!o,provenance:n})}return e.createElement(T.l_,{to:"/alerting/routes"})})))},ve=()=>{const a=de();return e.createElement(L.O,{navId:"am-routes",pageNav:a,accessType:"notification"},e.createElement(pe,null))};function de(){const{isExact:a,path:r}=(0,T.$B)(),[i,o]=(0,e.useState)();return(0,e.useEffect)(()=>{r==="/alerting/routes/mute-timing/new"?o({id:"alert-policy-new",text:"Add mute timing"}):r==="/alerting/routes/mute-timing/edit"&&o({id:"alert-policy-edit",text:"Edit mute timing"})},[r,a]),i}const ye=ve},65892:(ae,R,t)=>{t.d(R,{J:()=>Z,O:()=>te});var e=t(85960),T=t(8134),p=t(20989),v=t(90857),L=t(79055),d=t(66681),u=t(6753),K=t(47257),y=t(74042),C=t(14607),P=t(29165),f=t(49199);const k=({localStoreKey:m,startClosed:h=!1,severity:A="error",collapseText:$,collapseTooltip:X,collapseJustify:j="flex-end",alertTitle:S,children:ce})=>{const le=(0,K.l4)(),me=U(le,A),[ie,ne]=(0,u.Z)(m,h);return e.createElement(e.Fragment,null,ie&&e.createElement(y.Lh,{justify:j},e.createElement(C.u,{content:X,placement:"bottom"},e.createElement(P.zx,{fill:"text",variant:"secondary",icon:(0,f.j)(A),className:me.warningButton,onClick:()=>ne(!1)},$))),!ie&&e.createElement(f.b,{severity:A,title:S,onRemove:()=>ne(!0)},ce))},U=(m,h)=>{const A=m.colors[h];return{warningButton:(0,d.css)({color:A.text,"&:hover":{background:A.transparent}})}},x="grafana.unifiedalerting.upgrade.previewNotice",G=()=>v.config.unifiedAlertingEnabled||!v.config.featureToggles.alertingPreviewUpgrade?null:e.createElement(k,{localStoreKey:x,alertTitle:"This is a preview of the upgraded Grafana Alerting",collapseText:"Grafana Alerting Preview",collapseTooltip:"Show preview warning",severity:"warning"},e.createElement("p",null,"No rules are being evaluated and legacy alerting is still running.",e.createElement("br",null),"Please contact your administrator to upgrade permanently."),e.createElement(L.h,{external:!0,href:"https://grafana.com/docs/grafana/latest/alerting/set-up/migrating-alerts/"},"Read about upgrading"));var W=t(84954),H=t(84933),z=t(27436),O=t(76679);function I(m){return m.name===O.GC?"Grafana":m.name.slice(0,37)}const J=({disabled:m=!1})=>{const h=(0,K.wW)(B),{selectedAlertmanager:A,availableAlertManagers:$,setSelectedAlertmanager:X}=(0,W.ZA)(),j=(0,e.useMemo)(()=>$.map(S=>({label:I(S),value:S.name,imgUrl:S.imgUrl,meta:S.meta})),[$]);return e.createElement(H._,{className:h.field,label:m?"Alertmanager":"Choose Alertmanager",disabled:m||j.length===1,"data-testid":"alertmanager-picker"},e.createElement(z.Ph,{"aria-label":m?"Alertmanager":"Choose Alertmanager",width:29,className:"ds-picker select-container",backspaceRemovesValue:!1,onChange:S=>{S?.value&&X(S.value)},options:j,maxMenuHeight:500,noOptionsMessage:"No datasources found",value:A,getOptionLabel:S=>S.label}))},B=m=>({field:(0,d.css)`
    margin: 0;
  `}),Y=()=>e.createElement(f.b,{title:"No Alertmanager found",severity:"warning"},"We could not find any external Alertmanagers and you may not have access to the built-in Grafana Alertmanager."),V=()=>e.createElement(f.b,{title:"Selected Alertmanager not found.",severity:"warning"},"The selected Alertmanager no longer exists or you may not have permission to access it. You can select a different Alertmanager from the dropdown."),oe=({availableAlertManagers:m})=>{const h=m.length>0;return e.createElement("div",null,h?e.createElement(V,null):e.createElement(Y,null))},Z=({children:m,isLoading:h,...A})=>e.createElement(p.T,{...A},e.createElement(p.T.Contents,{isLoading:h},e.createElement("div",null,e.createElement(G,null),m))),te=({children:m,accessType:h,...A})=>{const $=Q();return e.createElement(W.h5,{accessType:h},e.createElement(Z,{...A,actions:e.createElement(J,{disabled:$})},e.createElement(se,null,m)))};function Q(){const m=(0,T.Z)();return["/edit","/new"].some(A=>m?.pathname?.includes(A))}const se=({children:m})=>{const{availableAlertManagers:h,selectedAlertmanager:A}=(0,W.ZA)();return A?e.createElement(e.Fragment,null,m):e.createElement(oe,{availableAlertManagers:h})}},84237:(ae,R,t)=>{t.d(R,{C0:()=>d,Uv:()=>v,Xq:()=>L});var e=t(85960),T=t(49199),p=t(67192),v=(u=>(u.ContactPoint="contact point",u.Template="template",u.MuteTiming="mute timing",u.AlertRule="alert rule",u.RootNotificationPolicy="root notification policy",u))(v||{});const L=({resource:u})=>e.createElement(T.b,{title:`This ${u} cannot be edited through the UI`,severity:"info"},"This ",u," has been provisioned, that means it was created by config. Please contact your server admin to update this ",u,"."),d=()=>e.createElement(p.C,{text:"Provisioned",color:"purple"})},77542:(ae,R,t)=>{t.d(R,{Nx:()=>K,kO:()=>u,ot:()=>d});var e=t(55104),T=t.n(e),p=t(85960),v=t(98724);const L=/^((([01][0-9])|(2[0-3])):[0-5][0-9])$|(^24:00$)/,d=y=>y?L.test(y):!0,u=(y,C)=>{if(!y&&!C)return!0;if(!y&&C||y&&!C)return!1;const P="HH:mm",f=T()().startOf("day").add(y,P),k=T()().startOf("day").add(C,P);return!!(y&&C&&f.isBefore(k)||y&&C&&k.isAfter(f))};function K(y){return y.time_intervals.map((P,f)=>{const{times:k,weekdays:U,days_of_month:x,months:G,years:W,location:H}=P,z=(0,v.u6)(k,H),O=(0,v.v7)(U),I=(0,v.J8)(x),J=(0,v.m8)(G),B=(0,v.qw)(W);return p.createElement(p.Fragment,{key:JSON.stringify(P)+f},`${z} ${O}`,p.createElement("br",null),[I,J,B].join(" | "),p.createElement("br",null))})}},70335:(ae,R,t)=>{t.d(R,{W:()=>T});var e=t(81828);function T(p,v){const L=e.alertmanagerApi.endpoints.getAlertmanagerConfiguration.useQuery(p??"",{...v,skip:!p});return{...L,error:L.error}}}}]);

//# sourceMappingURL=MuteTimings.f908bc85fc70db261005.js.map