"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[707],{54391:(X,V,n)=>{n.d(V,{R:()=>u});var s=n(74848),e=n(32196),l=n(96540),T=n(40845),N=n(14578),c=n(10354),g=n(72093);const u=({name:i,onChange:W,verifyLayerNameUniqueness:r,overrideStyles:z})=>{const a=(0,T.of)(L),[_,m]=(0,l.useState)(!1),[I,E]=(0,l.useState)(null),S=d=>{m(!0)},D=d=>{if(m(!1),I){E(null);return}i!==d&&W(d)},P=d=>{const A=d.currentTarget.value.trim();if(A.length===0){E("An empty layer name is not allowed");return}if(r&&!r(A)&&A!==i){E("Layer name already exists");return}I&&E(null)},p=d=>{D(d.currentTarget.value.trim())},M=d=>{d.key==="Enter"&&D(d.currentTarget.value)},Q=d=>{d.target.select()};return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:a.wrapper,children:[!_&&(0,s.jsxs)("button",{className:a.layerNameWrapper,title:"Edit layer name",onClick:S,"data-testid":"layer-name-div",children:[(0,s.jsx)("span",{className:z?"":a.layerName,children:i}),(0,s.jsx)(N.I,{name:"pen",className:a.layerEditIcon,size:"sm"})]}),_&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.p,{type:"text",defaultValue:i,onBlur:p,autoFocus:!0,onKeyDown:M,onFocus:Q,invalid:I!==null,onChange:P,className:a.layerNameInput,"data-testid":"layer-name-input"}),I&&(0,s.jsx)(g.P,{horizontal:!0,children:I})]})]})})},L=i=>({wrapper:(0,e.css)({label:"Wrapper",display:"flex",alignItems:"center",marginLeft:i.spacing(.5)}),layerNameWrapper:(0,e.css)({display:"flex",cursor:"pointer",border:"1px solid transparent",borderRadius:i.shape.radius.default,alignItems:"center",padding:`0 0 0 ${i.spacing(.5)}`,margin:0,background:"transparent","&:hover":{background:i.colors.action.hover,border:`1px dashed ${i.colors.border.strong}`},"&:focus":{border:`2px solid ${i.colors.primary.border}`},"&:hover, &:focus":{".query-name-edit-icon":{visibility:"visible"}}}),layerName:(0,e.css)({fontWeight:i.typography.fontWeightMedium,color:i.colors.primary.text,cursor:"pointer",overflow:"hidden",marginLeft:i.spacing(.5)}),layerEditIcon:(0,e.cx)((0,e.css)({marginLeft:i.spacing(2),visibility:"hidden"}),"query-name-edit-icon"),layerNameInput:(0,e.css)({maxWidth:"300px",margin:"-4px 0"})})},21934:(X,V,n)=>{n.d(V,{N:()=>L});var s=n(74848),e=n(32196),l=n(96540),T=n(40845),N=n(90182),c=n(83598),g=n(64278);const u={label:"Fixed color",value:"_____fixed_____"},L=W=>{const{value:r,context:z,onChange:a,item:_}=W,m="dark-green",I=(0,T.of)(i),E=r?.field,S=r&&!E&&r?.fixed,D=(0,g.sE)(z.data),P=(0,g.m3)(D,E,u,void 0,_.settings?.baseNameMode),p=(0,l.useCallback)(d=>{if(!d){a(void 0);return}const A=d.value;if(A&&A!==u.value)a({...r,field:A});else{const Y=r?.fixed??m;a({...r,field:void 0,fixed:Y})}},[a,r]),M=(0,l.useCallback)(d=>{a({field:void 0,fixed:d??m})},[a]),Q=S?u:P.find(d=>d.value===E);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:I.container,children:[(0,s.jsx)(N.l6,{value:Q,options:P,onChange:p,noOptionsMessage:"No fields found",isClearable:_.settings?.isClearable,placeholder:_.settings?.placeholder}),S&&(0,s.jsx)("div",{className:I.picker,children:(0,s.jsx)(c.sk,{color:r?.fixed,onChange:M,enableNamedColors:!0})})]})})},i=W=>({container:(0,e.css)`
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
  `,picker:(0,e.css)`
    padding-left: 8px;
  `})},86640:(X,V,n)=>{n.d(V,{h:()=>z});var s=n(74848),e=n(96540),l=n(52622),T=n(39268),N=n(14186),c=n(94354),g=n(55852),u=n(76218),L=n(29286);const i=[{label:"Fixed",value:l.RU.Fixed,description:"Fixed value"},{label:"Field",value:l.RU.Field,description:"Display field value"}],W={settings:{}},r={settings:{}},z=({value:a,context:_,onChange:m})=>{const E=(0,e.useCallback)(M=>{m({...a,mode:M})},[m,a]),S=(0,e.useCallback)(M=>{m({...a,field:M})},[m,a]),D=(0,e.useCallback)((M="")=>{m({...a,fixed:M})},[m,a]),P=()=>{D("")},p=a?.mode??l.RU.Fixed;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(T.C,{children:(0,s.jsx)(N.I,{label:"Source",labelWidth:9,grow:!0,children:(0,s.jsx)(c.z,{value:p,options:i,onChange:E,fullWidth:!0})})}),p!==l.RU.Fixed&&(0,s.jsx)(T.C,{children:(0,s.jsx)(N.I,{label:"Field",labelWidth:9,grow:!0,children:(0,s.jsx)(u.O,{context:_,value:a.field??"",onChange:S,item:W})})}),p===l.RU.Fixed&&(0,s.jsx)(T.C,{children:(0,s.jsx)(N.I,{label:"Value",labelWidth:9,grow:!0,children:(0,s.jsx)(L.g,{context:_,value:a?.fixed,onChange:D,item:r,suffix:a?.fixed&&(0,s.jsx)(g.$n,{icon:"times",variant:"secondary",fill:"text",size:"sm",onClick:P})})})},a?.fixed),p===l.RU.Template&&(0,s.jsx)(T.C,{children:(0,s.jsx)(N.I,{label:"Template",labelWidth:9,grow:!0,children:(0,s.jsx)(L.g,{context:_,value:a?.fixed,onChange:D,item:r})})})]})}},78437:(X,V,n)=>{n.d(V,{NO:()=>s.N,mj:()=>m,AW:()=>q,gm:()=>d,hj:()=>ne.h});var s=n(21934),e=n(74848),l=n(96540);const T=({value:o,onChange:t})=>{const[j,f]=useState(o?[{value:o,label:o}]:[]),[h,O]=useState(),R=window.__grafana_public_path__+"img/icons/unicons/",b=v=>{t(v),O(v)};return useEffect(()=>{getBackendSrv().get(`${R}/index.json`).then(v=>{f(v.files.map(B=>({value:B,label:B})))})},[R]),jsx(Select,{options:j,value:h,onChange:v=>{b(v.value)}})},N=null;var c=n(52622),g=n(39268),u=n(14186),L=n(94354),i=n(76218),W=n(63577),r=n(80744),z=n(25148);const a=[{label:"Fixed",value:c.q_.Fixed,description:"Fixed value"},{label:"Field",value:c.q_.Field,description:"Use a string field result"}],_={settings:{}},m=o=>{const{value:t,context:j,onChange:f,item:h}=o,O=9,R=(0,l.useCallback)(F=>{f({...t,mode:F})},[f,t]),b=(0,l.useCallback)((F="")=>{f({...t,field:F})},[f,t]),v=(0,l.useCallback)(F=>{f({...t,fixed:F??""})},[f,t]),B=F=>{F.stopPropagation(),f({mode:c.q_.Fixed,fixed:"",field:""})},K=t?.mode??c.q_.Fixed,U=h.settings?.showSourceRadio??!0,C=h.settings?.resourceType??r.zu.Icon,G=h.settings?.folderName??W.ResourceFolderName.Icon,H=h.settings?.maxFiles;let $="";return C===r.zu.Icon&&(t?.fixed?$=(0,W.getPublicOrAbsoluteUrl)(t.fixed):h.settings?.placeholderValue&&($=(0,W.getPublicOrAbsoluteUrl)(h.settings.placeholderValue))),(0,e.jsxs)(e.Fragment,{children:[U&&(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Source",labelWidth:O,grow:!0,children:(0,e.jsx)(L.z,{value:K,options:a,onChange:R,fullWidth:!0})})}),K!==c.q_.Fixed&&(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Field",labelWidth:O,grow:!0,children:(0,e.jsx)(i.O,{context:j,value:t.field??"",onChange:b,item:_})})}),K===c.q_.Fixed&&(0,e.jsx)(z.n,{onChange:v,onClear:B,value:t?.fixed,src:$,placeholder:h.settings?.placeholderText??"Select a value",name:I(t?.fixed)??"",mediaType:C,folderName:G,size:r.Iy.NORMAL,maxFiles:H}),K===c.q_.Mapping&&(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Mappings",labelWidth:O,grow:!0,children:(0,e.jsx)("div",{children:"TODO mappings editor!"})})})]})};function I(o){if(!o)return;const t=o.lastIndexOf("/");return t>0?o.substring(t+1):o}var E=n(32196),S=n(40845),D=n(90182),P=n(64278),p=n(60188),M=n(18379);const Q={label:"Fixed value",value:"_____fixed_____"},d=o=>{const{value:t,context:j,onChange:f,item:h}=o,{settings:O}=h,R=(0,S.of)(A),b=t?.field,v=!b,B=(0,P.sE)(j.data),K=(0,P.m3)(B,b,Q,O?.filteredFieldType),U=(0,l.useMemo)(()=>(0,M.Nn)(O),[O]),C=(0,l.useCallback)(x=>{f((0,M.Ru)(x,U))},[f,U]),G=(0,l.useCallback)(x=>{const k=x.value;k&&k!==Q.value?C({...t,field:k}):C({...t,field:void 0})},[C,t]),H=(0,l.useCallback)(x=>{x!==void 0&&C({...t,min:x})},[C,t]),$=(0,l.useCallback)(x=>{x!==void 0&&C({...t,max:x})},[C,t]),F=(0,l.useCallback)(x=>{x!==void 0&&C({...t,fixed:x})},[C,t]),y=t??{},J=v?Q:K.find(x=>x.value===b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{children:(0,e.jsx)(D.l6,{value:J,options:K,onChange:G,noOptionsMessage:"No fields found"})}),(0,e.jsxs)("div",{className:R.range,children:[v&&(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Value",labelWidth:8,grow:!0,children:(0,e.jsx)(p.Q,{value:y.fixed,...U,onChange:F})})}),!v&&!U.hideRange&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Min",labelWidth:8,grow:!0,children:(0,e.jsx)(p.Q,{value:y.min,...U,onChange:H})})}),(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Max",labelWidth:8,grow:!0,children:(0,e.jsx)(p.Q,{value:y.max,...U,onChange:$})})})]})]})]})},A=o=>({range:(0,E.css)`
    padding-top: 8px;
  `});var Y=n(11261);const Z={label:"Fixed value",value:"_____fixed_____"},w=[{label:"Mod",value:c.WQ.Mod,description:"Use field values, mod from max"},{label:"Clamped",value:c.WQ.Clamped,description:"Use field values, clamped to max and min"}],q=({value:o,context:t,onChange:j,item:f})=>{const{settings:h}=f,O=0,R=o?.field,b=!R,v=(0,P.sE)(t.data),B=(0,P.m3)(v,R,Z,Y.PU.number),K=(0,S.of)(ee),U=(0,l.useCallback)(y=>{const J=y.value;if(J&&J!==Z.value)j({...o,field:J});else{const x=o.fixed??O;j({...o,field:void 0,fixed:x})}},[j,o]),C=(0,l.useCallback)(y=>{j({...o,mode:y})},[j,o]),G=(0,l.useCallback)(y=>{j({...o,field:void 0,fixed:y??O})},[j,o]),H=o??{},$=o?.mode??c.WQ.Mod,F=b?Z:B.find(y=>y.value===R);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Limit",labelWidth:8,grow:!0,children:(0,e.jsx)(L.z,{value:$,options:w,onChange:C,fullWidth:!0})})}),(0,e.jsx)(D.l6,{value:F,options:B,onChange:U,noOptionsMessage:"No fields found"})]}),(0,e.jsx)("div",{className:K.range,children:b&&(0,e.jsx)(g.C,{children:(0,e.jsx)(u.I,{label:"Value",labelWidth:8,grow:!0,children:(0,e.jsx)(p.Q,{value:H?.fixed??O,onChange:G,max:h?.max,min:h?.min})})})})]})},ee=o=>({range:(0,E.css)`
    padding-top: 8px;
  `});var ne=n(86640)}}]);

//# sourceMappingURL=707.b02de56435c1c89199e3.js.map