import{h as s,C as S,k as e,l as C,_ as B,o as P,p as N,s as L,t as b,U as I,W as M,q as h,g as q,B as F,i as v,j as $,R as V}from"./entry_page.js";import{P as W,B as z,l as G,k as H,T as Q,E as Y,h as J,j as K,b as w,M as X,m as Z,u as ee,s as te,a as ne,d as oe,C as y,e as se,S as ae,f as re,g as _,i as ie}from"./usePlatform.CFP4tBzQ.js";import{L as le,E as ce}from"./ErrorBoundary.xJor3Ppq.js";import{P as T}from"./Search.BNBTqs0I.js";import{r as ue}from"./ArrowBroadUnderbarDown.wq6id2ca.js";import"./Search.CUubiSTp.js";const de=({tab:t})=>{const u=s.useContext(S),[o,d]=s.useState(!0),i=s.useRef(null),f=()=>new Promise(a=>{const p=t?.customTab?.src?u?.[t?.customTab?.src]:void 0;if(p?.type==="tab"){const l=p.component;a(l)}else t.customTab?.type==="external"&&B(()=>import(`${P()}/custom/${t.customTab.src}.js`),[],import.meta.url).then(l=>{const m=l.default;a(m)})});return s.useEffect(()=>{f().then(a=>{i.current&&(new a(t,i.current).render(),d(!1))})},[]),e.jsxs(e.Fragment,{children:[o&&C._("Loading..."),e.jsx("div",{ref:i,style:{visibility:o?"hidden":"visible"}})]})},pe=h.div`
    margin-left: 270px !important;
    width: 150px;
`;function D({serviceName:t}){const u=s.useRef(),[o,d]=s.useState(null),[i,f]=s.useState(!1),[a,p]=s.useState({});s.useEffect(()=>{const r=new AbortController;return N({endpointUrl:L(`settings/${encodeURIComponent(t)}`),handleError:!0,signal:r.signal,callbackOnError:c=>{r.signal.aborted||d(c)}}).catch(c=>{if(r.signal.aborted)return null;throw c}).then(c=>{c&&p(c.entry[0].content)}),()=>{r.abort()}},[t]);const l=r=>{u.current.handleSubmit(r)},m=r=>{f(r)};if(o)throw o;return Object.keys(a).length?e.jsxs(e.Fragment,{children:[e.jsx(S.Consumer,{children:r=>e.jsx(W.Consumer,{children:c=>e.jsx(z,{ref:u,page:b,stanzaName:t,serviceName:"settings",mode:G,currentServiceState:a,handleFormSubmit:m,pageContext:c,customComponentContext:r})})}),e.jsx(pe,{children:e.jsx(I,{className:"saveBtn",label:C._("Save"),onClick:l,loading:i})})]}):e.jsx(M,{size:"medium"})}D.propTypes={serviceName:T.string.isRequired};function A({selectedTab:t,updateIsPageOpen:u}){const[o,d]=s.useState({open:!1}),i=t.style===H;s.useEffect(()=>{i&&u(!!o.open)},[u,i,o]);const f=()=>{d({...o,open:!0,mode:w,formLabel:t.formTitle?`Add ${t.formTitle}`:`Add ${t.title}`})},a=()=>{d({...o,open:!1})},p=()=>e.jsx(K,{page:b,open:o.open,handleRequestClose:a,returnFocus:()=>{},serviceName:t.name,mode:w,formLabel:o.formLabel}),l=(j,E)=>{const g=t?.formTitle||t.title;d({...o,open:!0,stanzaName:j.name,formLabel:E===X?`Clone ${g}`:`Update ${g}`,mode:E})},m=()=>{d({...o,open:!1})},r=()=>e.jsx(Y,{open:o.open,handleRequestClose:m,serviceName:t.name,stanzaName:o.stanzaName,mode:o.mode,formLabel:o.formLabel,page:b}),c=()=>e.jsx("div",{style:i&&o.open?{display:"none"}:{display:"block"},children:e.jsx(J,{page:b,serviceName:t.name,handleRequestModalOpen:()=>f(),handleOpenPageStyleDialog:l})});return e.jsxs(Q,{value:null,children:[i&&o.open&&r(),c(),!i&&o.open&&p()]})}A.propTypes={selectedTab:T.object,updateIsPageOpen:T.func};const me=s.memo(A);var fe=ue();const ge=q(fe);function xe(t){return e.jsx(F,{target:"_blank",to:t.fileUrl,download:t.fileNameAfterDownload,"data-test":"downloadButton",icon:e.jsx(ge,{}),children:t.children})}const Ce=P().replace("js/build","openapi.json");function he(){return e.jsx(xe,{fileUrl:Ce,fileNameAfterDownload:"openapi.json",children:"OpenAPI.json"})}const je=h(Z.Typography)`
    font-size: 0.8em;
`,be=()=>{const t=v();if(t?.meta?.hideUCCVersion)return null;const u=t?.meta?._uccVersion??null;return e.jsxs(je,{as:"span",title:"Splunk Add-On UCC framework is a framework to generate UI-based Splunk add-ons. It includes UI, REST handlers, Modular inputs, OAuth and Alert action templates.","data-test":"ucc-credit",children:["Made with"," ",e.jsx(le,{to:"https://splunk.github.io/addonfactory-ucc-generator/",openInNewContext:!0,children:"UCC"})," ",u]})},ye=h.div`
    display: inline-flex;
    align-items: center;
    justify-content: end;
    flex-wrap: wrap;
    gap: 0.4rem;
`,Ee=h(y.Row)`
    padding: 5px 0px;

    .dropdown {
        text-align: right;
    }

    .input_button {
        text-align: right;
        margin-right: 0px;
    }
`,Te=h(_)`
    flex-wrap: wrap;
`;function Ae(){const t=v();$(t.pages.configuration,"Configuration page not found in global config");const{title:u,description:o,subDescription:d,tabs:i}=t.pages.configuration,f=ee(t,"configuration"),a=i.filter(n=>!te(n.hideForPlatform,f)),p=s.useMemo(()=>a.map(n=>n.name),[a]),l=s.useRef(!1),[m,r]=s.useState(a[0].name),[c,j]=s.useState(!1),g=ne()?.get("tab");s.useEffect(()=>{g&&p.includes(g)&&g!==m&&r(g)},[g,p,m]),s.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const O=s.useCallback((n,{selectedTabId:x})=>{l.current&&x&&(r(x),j(!1))},[]),R=n=>{l.current&&j(n)},k=n=>V.createElement(de,{tab:n}),U=n=>{let x;return n?.customTab?x=k(n):x=n?.table?e.jsx(me,{selectedTab:n,updateIsPageOpen:R},n.name):e.jsx(D,{serviceName:n.name},n.name),e.jsx("div",{style:n.name!==m?{display:"none"}:{display:"block"},id:`${n.name}Tab`,children:x},n.name)};return e.jsx(ce,{children:e.jsxs(oe,{platform:f,children:[e.jsxs("div",{style:c?{display:"none"}:{display:"block"},children:[e.jsx(y,{gutter:8,children:e.jsxs(Ee,{children:[e.jsxs(y.Column,{span:9,children:[e.jsx(se,{children:C._(u)}),e.jsx(ae,{children:C._(o||"")}),e.jsx(re,{text:d?.text||"",links:d?.links})]}),e.jsx(y.Column,{span:3,style:{textAlignLast:"right"},children:e.jsxs(ye,{children:[e.jsx(be,{}),e.jsx(he,{})]})})]})}),e.jsx(Te,{activeTabId:m,onChange:O,children:a.map(n=>e.jsx(_.Tab,{label:C._(n.title),tabId:n.name},n.name))})]}),a.map(n=>U(n)),e.jsx(ie,{position:"top-right"})]})})}export{Ae as default};
