1import{d as ye,D as Pe,C as _e,i as c,N as ge,V as Ve,j as y,w as n,u as e,y as ae,k as J,o as m,b as o,e as f,t as r,a as i,f as K,h as w,c as oe,r as we,F as xe,Q as de,_ as Te}from"./index-BTfmF8a3.js";import{c as W}from"./controlplane-DFF1VMWO.js";import{_ as Ce}from"./OpsPageHeader.vue_vue_type_script_setup_true_lang-DW-qjkXV.js";import{_ as Se}from"./ContractUnavailableState.vue_vue_type_script_setup_true_lang-CZOfsLF1.js";import{E as Ie}from"./EmptyState-LO4O_TI3.js";import{_ as ke}from"./JsonCodeBlock.vue_vue_type_script_setup_true_lang-Djek9f22.js";import{B as X}from"./Banner-CnVgLIFf.js";import{B as x}from"./Button-B7ZZeukS.js";import{C as D}from"./Card-IAtOhM5n.js";import{F as p}from"./FormField-D2wY_E2k.js";import{I as Y}from"./Inline-CApLTHRL.js";import{I as P}from"./Input-zz65MxO_.js";import{S as te}from"./Select-DmqYRBqp.js";import{S as T}from"./Stack-r9DzI8ME.js";import{T as Ue}from"./Table-BayWg8jy.js";import{T as re}from"./Textarea-7KGo202r.js";import{c as Ne}from"./contractAvailability-g_NpxF5M.js";import{b as ne}from"./format-D5vcAEQz.js";import"./contractStatus-kr5T6SnS.js";const Be={class:"health-policies-grid"},Me={class:"health-policies-grid"},Re={class:"helper-text"},$e={class:"helper-text"},De={class:"health-policies-grid"},Fe={class:"muted"},Ee={class:"definition-grid"},He={class:"health-policies-grid"},Le={class:"muted"},Ae=ye({__name:"HealthPoliciesView",setup(qe){const{t:l}=Pe(),F=_e(),E=c(F.tenantContextId?String(F.tenantContextId):""),Z=c(""),ee=c(""),_=c(null),u=c(null),H=c(""),C=c(""),v=c(""),g=c(null),L=c(!1),A=c(!1),S=c("passive"),I=c("3"),k=c("2"),U=c("30"),V=c(""),N=c(""),q=c("passive"),O=c("3"),j=c("2"),z=c("30"),B=c(""),Q=c(!1),b=c(""),se=J(()=>[{label:l("admin.healthPolicies.filters.allProbeModes"),value:""},{label:"passive",value:"passive"},{label:"active",value:"active"},{label:"hybrid",value:"hybrid"}]),ue=[{label:"passive",value:"passive"},{label:"active",value:"active"},{label:"hybrid",value:"hybrid"}],ce=[{label:"passive",value:"passive"},{label:"active",value:"active"}];function M(h){const t=h.trim();if(!t)return;if(!/^[1-9]\d*$/.test(t))return null;const a=Number(t);return Number.isSafeInteger(a)?a:null}function ie(h){const t=h.trim();if(!t)return;if(!/^(0|[1-9]\d*)$/.test(t))return null;const a=Number(t);return Number.isSafeInteger(a)?a:null}const R=J(()=>M(E.value)??null),he=J(()=>u.value!==null&&V.value.trim()!==""),pe=J(()=>R.value!==null&&N.value.trim()!==""&&B.value.trim()!=="");ge(()=>F.tenantContextId,h=>{E.value=h?String(h):""});function ve(){F.setTenantContext(R.value)}async function $(h=!1){var t;L.value=!0,H.value="",C.value="",v.value="",g.value=null;try{if(_.value=await W.listHealthPolicies({policyCode:Z.value||void 0,probeMode:ee.value||void 0,tenantId:R.value??void 0}),h){const a=(t=_.value.items[0])==null?void 0:t.id;a?await le(a):u.value=null}else _.value.items.some(d=>{var s;return d.id===((s=u.value)==null?void 0:s.id)})||(u.value=null)}catch(a){_.value=null,u.value=null;const d=Ne(a,l("admin.healthPolicies.contractUnavailableTitle"),l("admin.healthPolicies.errors.loadPolicies"));d.kind==="unavailable"?g.value={message:d.message,status:d.status,title:d.title}:d.kind==="error"&&(H.value=d.message)}finally{L.value=!1}}async function le(h){C.value="",v.value="";try{u.value=await W.getHealthPolicyDetail(h),S.value=u.value.probe_mode,I.value=String(u.value.failure_threshold),k.value=String(u.value.recovery_threshold),U.value=String(u.value.cooldown_seconds),V.value=""}catch(t){u.value=null,C.value=ae(t,l("admin.healthPolicies.errors.loadDetail"))}}async function me(){if(!u.value){v.value=l("admin.healthPolicies.errors.selectPolicy");return}const h=V.value.trim();if(!h){v.value=l("admin.healthPolicies.errors.updateReasonRequired");return}const t=M(I.value);if(t==null){v.value=l("admin.healthPolicies.errors.failureThresholdPositive");return}const a=M(k.value);if(a==null){v.value=l("admin.healthPolicies.errors.recoveryThresholdPositive");return}const d=ie(U.value);if(d==null){v.value=l("admin.healthPolicies.errors.cooldownNonNegative");return}A.value=!0,v.value="";try{u.value=await W.updateHealthPolicyProfile({cooldown_seconds:d,failure_threshold:t,policy_id:u.value.id,probe_mode:S.value,reason:h,recovery_threshold:a}),S.value=u.value.probe_mode,I.value=String(u.value.failure_threshold),k.value=String(u.value.recovery_threshold),U.value=String(u.value.cooldown_seconds),V.value="",de.success(l("admin.healthPolicies.toast.profileUpdated",{code:u.value.policy_code})),await $(!1)}catch(s){v.value=ae(s,l("admin.healthPolicies.errors.updateProfile"))}finally{A.value=!1}}async function fe(){if(!R.value){b.value=l("admin.healthPolicies.errors.applyTenantContext");return}const h=B.value.trim();if(!h){b.value=l("admin.healthPolicies.errors.createReasonRequired");return}const t=N.value.trim();if(!t){b.value=l("admin.healthPolicies.errors.policyCodeRequired");return}const a=M(O.value);if(a==null){b.value=l("admin.healthPolicies.errors.failureThresholdPositive");return}const d=M(j.value);if(d==null){b.value=l("admin.healthPolicies.errors.recoveryThresholdPositive");return}const s=ie(z.value);if(s==null){b.value=l("admin.healthPolicies.errors.cooldownNonNegative");return}Q.value=!0,b.value="";try{const G=await W.createHealthPolicy({cooldown_seconds:s,failure_threshold:a,policy_code:t,probe_mode:q.value,reason:h,recovery_threshold:d,tenant_id:R.value});de.success(l("admin.healthPolicies.toast.created",{code:G.policy_code})),N.value="",q.value="passive",O.value="3",j.value="2",z.value="30",B.value="",await $(!1),await le(G.id)}catch(G){b.value=ae(G,l("admin.healthPolicies.errors.createPolicy"))}finally{Q.value=!1}}const be=$(!0);return Ve(()=>be),(h,t)=>(m(),y(e(T),{gap:"lg"},{default:n(()=>[o(Ce,{eyebrow:e(l)("admin.healthPolicies.eyebrow"),title:e(l)("admin.healthPolicies.title"),description:e(l)("admin.healthPolicies.description")},{default:n(()=>[o(e(x),{variant:"ghost",loading:L.value,onClick:t[0]||(t[0]=a=>void $(!1))},{default:n(()=>[f(r(L.value?e(l)("admin.healthPolicies.refreshingButton"):e(l)("admin.healthPolicies.refreshButton")),1
1)]),_:1},8,["loading"])]),_:1},8,["eyebrow","title","description"]),o(e(D),{title:e(l)("admin.healthPolicies.tenantContext.cardTitle"),padding:"md"},{default:n(()=>[i("form",{"data-spec":"health-policies-tenant-context-form",onSubmit:K(ve,["prevent"])},[i("div",Be,[o(e(p),{label:e(l)("admin.healthPolicies.tenantContext.tenantId")},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:E.value,"onUpdate:modelValue":t[1]||(t[1]=s=>E.value=s),"data-spec":"health-policies-tenant-id-input",inputmode:"numeric",placeholder:e(l)("admin.healthPolicies.tenantContext.globalPlaceholder"),type:"text","aria-describedby":d},null,8,["id","modelValue","placeholder","aria-describedby"])]),_:1},8,["label"]),o(e(Y),{gap:"sm",align:"end"},{default:n(()=>[o(e(x),{type:"submit"},{default:n(()=>[f(r(e(l)("admin.healthPolicies.tenantContext.apply")),1)]),_:1})]),_:1})])],32)]),_:1},8,["title"]),o(e(D),{title:e(l)("admin.healthPolicies.filters.cardTitle"),description:e(l)("admin.healthPolicies.filters.cardDescription"),padding:"md"},{default:n(()=>[i("form",{"data-spec":"health-policies-filter-form",onSubmit:t[4]||(t[4]=K(a=>void $(!1),["prevent"]))},[i("div",Me,[o(e(p),{label:"policy_code"},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:Z.value,"onUpdate:modelValue":t[2]||(t[2]=s=>Z.value=s),"data-spec":"health-policies-policy-code-filter-input",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1}),o(e(p),{label:"probe_mode"},{default:n(({fieldId:a,describedBy:d})=>[o(e(te),{id:a,modelValue:ee.value,"onUpdate:modelValue":t[3]||(t[3]=s=>ee.value=s),"data-spec":"health-policies-probe-mode-filter-select",options:se.value,"aria-describedby":d},null,8,["id","modelValue","options","aria-describedby"])]),_:1}),o(e(Y),{gap:"sm",align:"end"},{default:n(()=>[o(e(x),{type:"submit"},{default:n(()=>[f(r(e(l)("admin.healthPolicies.filters.apply")),1)]),_:1})]),_:1})])],32)]),_:1},8,["title","description"]),g.value?(m(),y(Se,{key:0,message:g.value.message,status:g.value.status,title:g.value.title},null,8,["message","status","title"])):w("",!0),H.value?(m(),y(e(X),{key:1,variant:"error"},{default:n(()=>[f(r(H.value),1)]),_:1})):w("",!0),o(e(D),{title:e(l)("admin.healthPolicies.inventory.cardTitle"),description:e(l)("admin.healthPolicies.inventory.cardDescription"),padding:"none"},{default:n(()=>[!_.value||_.value.items.length===0?(m(),y(Ie,{key:0,title:e(l)("admin.healthPolicies.inventory.emptyTitle"),description:e(l)("admin.healthPolicies.inventory.emptyDescription")},null,8,["title","description"])):(m(),y(e(Ue),{key:1},{default:n(()=>[i("thead",null,[i("tr",null,[i("th",null,r(e(l)("admin.healthPolicies.inventory.table.policy")),1),i("th",null,r(e(l)("admin.healthPolicies.inventory.table.tenant")),1),i("th",null,r(e(l)("admin.healthPolicies.inventory.table.probeMode")),1),i("th",null,r(e(l)("admin.healthPolicies.inventory.table.failureRecovery")),1),i("th",null,r(e(l)("admin.healthPolicies.inventory.table.cooldown")),1),i("th",null,r(e(l)("admin.healthPolicies.inventory.table.updated")),1),i("th",null,r(e(l)("admin.healthPolicies.inventory.table.action")),1)])]),i("tbody",null,[(m(!0),oe(xe,null,we(_.value.items,a=>(m(),oe("tr",{key:a.id},[i("td",null,[i("strong",null,r(a.policy_code),1),i("p",Re,r(e(l)("admin.healthPolicies.inventory.idLabel",{id:a.id})),1)]),i("td",null,[f(r(a.tenant_slug)+" ",1),i("p",$e,r(e(l)("admin.healthPolicies.inventory.tenantIdLabel",{id:a.tenant_id})),1)]),i("td",null,r(a.probe_mode),1),i("td",null,r(a.failure_threshold)+" / "+r(a.recovery_threshold),1),i("td",null,r(a.cooldown_seconds),1),i("td",null,r(e(ne)(a.updated_at)),1),i("td",null,[o(e(x),{variant:"ghost",size:"sm","data-spec":`health-policy-inspect-${a.id}`,onClick:d=>void le(a.id)},{default:n(()=>[f(r(e(l)("admin.healthPolicies.inventory.inspectButton")),1)]),_:1},8,["data-spec","onClick"])])]))),128))])]),_:1}))]),_:1},8,["title","description"]),o(e(D),{title:e(l)("admin.healthPolicies.create.cardTitle"),description:e(l)("admin.healthPolicies.create.cardDescription"),padding:"md"},{default:n(()=>[o(e(T),{gap:"md"},{default:n(()=>[b.value?(m(),y(e(X),{key:0,variant:"error"},{default:n(()=>[f(r(b.value),1)]),_:1})):w("",!0),i("form",{"data-spec":"health-policy-create-form",onSubmit:t[11]||(t[11]=K(a=>void fe(),["prevent"]))},[o(e(T),{gap:"md"},{default:n(()=>[i("div",De,[o(e(p),{label:"policy_code"},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:N.value,"onUpdate:modelValue":t[5]||(t[5]=s=>N.value=s),"data-spec":"health-policy-create-code-input",placeholder:e(l)("admin.healthPolicies.create.policyCodePlaceholder"),type:"text","aria-describedby":d},null,8,["id","modelValue","placeholder","aria-describedby"])]),_:1}),o(e(p),{label:"probe_mode"},{default:n(({fieldId:a,describedBy:d})=>[o(e(te),{id:a,modelValue:q.value,"onUpdate:modelValue":t[6]||(t[6]=s=>q.value=s),"data-spec":"health-policy-create-probe-mode-select",options:ce,"aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1}),o(e(p),{label:"failure_threshold"},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:O.value,"onUpdate:modelValue":t[7]||(t[7]=s=>O.value=s),"data-spec":"health-policy-create-failure-threshold-input",inputmode:"numeric",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1}),o(e(p),{label:"recovery_threshold"},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:j.value,"onUpdate:modelValue":t[8]||(t[8]=s=>j.value=s),"data-spec":"health-policy-create-recovery-threshold-input",inputmode:"numeric",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1}),o(e(p),{label:"cooldown_seconds"},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:z.value,"onUpdate:modelValue":t[9]||(t[9]=s=>z.value=s),"data-spec":"health-policy-create-cooldown-input",inputmode:"numeric",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1}),o(e(p),{label:e(l)("admin.healthPolicies.create.operatorReason")},{default:n(({fieldId:a,describedBy:d})=>[o(e(re),{id:a,modelValue:B.value,"onUpdate:modelValue":t[10]||(t[10]=s=>B.value=s),"data-spec":"health-policy-create-reason-textarea",placeholder:e(l)("admin.healthPolicies.create.reasonPlaceholder"),"aria-describedby":d},null,8,["id","modelValue","placeholder","aria-describedby"])]),_:1},8,["label"])]),i("p",Fe,r(e(l)("admin.healthPolicies.create.backendNote")),1),o(e(Y),{gap:"sm"},{default:n(()=>[o(e(x),{type:"submit",loading:Q.value,disabled:!pe.value},{default:n(()=>[f(r(Q.value?e(l)("admin.healthPolicies.create.creatingButton"):e(l)("admin.healthPolicies.create.createButton")),1
1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})],32)]),_:1})]),_:1},8,["title","description"]),C.value?(m(),y(e(X),{key:2,variant:"error"},{default:n(()=>[f(r(C.value),1)]),_:1})):w("",!0),v.value?(m(),y(e(X),{key:3,variant:"error"},{default:n(()=>[f(r(v.value),1)]),_:1})):w("",!0),u.value?(m(),y(e(D),{key:4,title:e(l)("admin.healthPolicies.detail.cardTitle"),description:e(l)("admin.healthPolicies.detail.cardDescription"),padding:"md"},{default:n(()=>[o(e(T),{gap:"md"},{default:n(()=>[i("dl",Ee,[i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.id")),1),i("dd",null,[i("code",null,r(u.value.id),1)])]),i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.policyCode")),1),i("dd",null,r(u.value.policy_code),1)]),i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.tenant")),1),i("dd",null,r(u.value.tenant_slug)+" ("+r(u.value.tenant_id)+")",1)]),i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.probeMode")),1),i("dd",null,r(u.value.probe_mode),1)]),i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.failureRecovery")),1),i("dd",null,r(u.value.failure_threshold)+" / "+r(u.value.recovery_threshold),1)]),i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.cooldown")),1),i("dd",null,r(u.value.cooldown_seconds)+"s",1)]),i("div",null,[i("dt",null,r(e(l)("admin.healthPolicies.detail.fields.updated")),1),i("dd",null,r(e(ne)(u.value.updated_at)),1)])]),o(e(T),{gap:"xs"},{default:n(()=>[i("h3",null,r(e(l)("admin.healthPolicies.detail.definitionTitle")),1),o(ke,{value:u.value.definition_json},null,8,["value"])]),_:1}),i("form",{"data-spec":"health-policy-profile-form",onSubmit:t[17]||(t[17]=K(a=>void me(),["prevent"]))},[o(e(T),{gap:"md"},{default:n(()=>[i("div",He,[o(e(p),{label:e(l)("admin.healthPolicies.profile.probeMode")},{default:n(({fieldId:a,describedBy:d})=>[o(e(te),{id:a,modelValue:S.value,"onUpdate:modelValue":t[12]||(t[12]=s=>S.value=s),"data-spec":"health-policy-profile-probe-mode-select",options:ue,"aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1},8,["label"]),o(e(p),{label:e(l)("admin.healthPolicies.profile.failureThreshold")},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:I.value,"onUpdate:modelValue":t[13]||(t[13]=s=>I.value=s),"data-spec":"health-policy-profile-failure-threshold-input",inputmode:"numeric",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1},8,["label"]),o(e(p),{label:e(l)("admin.healthPolicies.profile.recoveryThreshold")},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:k.value,"onUpdate:modelValue":t[14]||(t[14]=s=>k.value=s),"data-spec":"health-policy-profile-recovery-threshold-input",inputmode:"numeric",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1},8,["label"]),o(e(p),{label:e(l)("admin.healthPolicies.profile.cooldown")},{default:n(({fieldId:a,describedBy:d})=>[o(e(P),{id:a,modelValue:U.value,"onUpdate:modelValue":t[15]||(t[15]=s=>U.value=s),"data-spec":"health-policy-profile-cooldown-input",inputmode:"numeric",type:"text","aria-describedby":d},null,8,["id","modelValue","aria-describedby"])]),_:1},8,["label"]),o(e(p),{label:e(l)("admin.healthPolicies.profile.operatorReason")},{default:n(({fieldId:a,describedBy:d})=>[o(e(re),{id:a,modelValue:V.value,"onUpdate:modelValue":t[16]||(t[16]=s=>V.value=s),"data-spec":"health-policy-profile-reason-textarea",placeholder:e(l)("admin.healthPolicies.profile.reasonPlaceholder"),"aria-describedby":d},null,8,["id","modelValue","placeholder","aria-describedby"])]),_:1},8,["label"])]),i("p",Le,r(e(l)("admin.healthPolicies.profile.backendNote")),1),o(e(Y),{gap:"sm"},{default:n(()=>[o(e(x),{type:"submit",loading:A.value,disabled:!he.value},{default:n(()=>[f(r(A.value?e(l)("admin.healthPolicies.profile.updatingButton"):e(l)("admin.healthPolicies.profile.updateButton")),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})],32)]),_:1})]),_:1},8,["title","description"])):w("",!0)]),_:1}))}}),nl=Te(Ae,[["__scopeId","data-v-87340b05"]]);export{nl as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.