function e(e){switch(e){case`valid`:return`success`;case`limited`:return`warning`;case`invalid`:case`disabled`:return`danger`;default:return`neutral`}}function t(e){switch(e){case`valid`:return`Ready`;case`limited`:return`Limited`;case`invalid`:return`Invalid`;case`disabled`:return`Disabled`;default:return`Not connected`}}function n(e){let t=e.status_json?.http_status;if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim().length>0){let e=Number(t);return Number.isFinite(e)?e:null}return null}function r(e){let t=n(e);return e.secret_configured?e.status===`limited`?t===402?`OpenRouter reported insufficient credits. Add OpenRouter credits or switch this action to a free or available model before retrying.`:t===429?`OpenRouter rate-limited this key. Wait for the provider limit to reset or use another OpenRouter key.`:`OpenRouter limited this key. Review your OpenRouter account limits before retrying.`:e.status===`invalid`?e.auth_mode===`constant`?`OpenRouter rejected the server-backed key. Update the constant or environment variable, then validate it again before running direct actions.`:`OpenRouter rejected this key. Validate a current key before running direct actions.`:e.status===`disabled`?`This key is disabled locally and will not be used for direct actions.`:null:e.auth_mode===`constant`?`The server constant or environment variable could not be resolved. Define it on the WordPress host, then refresh Providers before using direct actions.`:`The secret is missing. Save and validate this key before using it.`}function i(e){return e.status===`limited`?`sf:text-warning-700`:e.status===`invalid`||e.status===`disabled`?`sf:text-danger-700`:`sf:text-slate-500`}function a(e){return e.provider===`openrouter`&&e.status===`valid`&&e.secret_configured}function o(e){let t=e.filter(e=>e.provider===`openrouter`);return t.find(e=>e.status===`limited`)??t.find(e=>e.status!==`valid`||!e.secret_configured)??t[0]??null}function s(e){return e.some(e=>e.provider===`openrouter`)?`OpenRouter key needs attention`:`No ready OpenRouter key`}function c(e){let t=o(e);if(!t)return`Validate and save a key, or connect a server-backed constant, before creating a Direct OpenRouter action.`;let n=r(t);return n?`${n} Then validate a ready OpenRouter key or server-backed constant before creating a Direct OpenRouter action.`:`Validate and save a key, or connect a server-backed constant, before creating a Direct OpenRouter action.`}function l(e){switch(e.auth_mode){case`manual_key`:return`Local vault`;case`constant`:return`Server secret`;case`sentient_proxy`:return`Managed service`;case`oauth_broker`:return`OAuth broker`;default:return e.auth_mode}}function u(e){if(e.auth_mode===`constant`){let t=e.constant_name?.trim();return t?`references ${t} on the server`:e.secret_configured?`resolved from the server`:`not found on the server`}return e.auth_mode===`sentient_proxy`?e.secret_configured?`service key available`:`service key missing`:e.secret_configured?`secret configured`:`secret missing`}function d(e){let t=e.find(e=>a(e))??null;if(t)return{status:`ready`,badgeStatus:`valid`,title:`OpenRouter ready`,message:`Direct actions can run through the saved OpenRouter key.`,credential:t};let n=o(e);if(!n)return{status:`missing`,badgeStatus:`missing`,title:`OpenRouter key missing`,message:`Connect and validate an OpenRouter key before Direct OpenRouter actions can run.`,credential:null};let i=r(n);return{status:`degraded`,badgeStatus:n.status,title:`OpenRouter key needs attention`,message:i?`${i} Direct OpenRouter actions stay blocked until a ready key is available.`:`Direct OpenRouter actions stay blocked until a ready OpenRouter key is available.`,credential:n}}export{l as a,i as c,d as i,t as l,c as n,u as o,s as r,r as s,a as t,e as u};