import{At as e,B as t,C as n,Et as r,H as i,J as a,Lt as o,Rt as s,T as c,Tt as l,U as u,Ut as d,V as f,W as p,Wt as m,Y as h,bt as g,ft as _,j as v,jt as y,kt as b,pt as x,q as S,r as C,tt as w,v as T,vt as E,xt as D,yt as O}from"../chunks/De2yIhEs.js";import"../chunks/D5dhgX4z.js";import"../chunks/UJE8BsR4.js";import"../chunks/Cj9ecUMW.js";import"../chunks/BFbU5qhn.js";import"../chunks/tmK-_Zu8.js";import"../chunks/CXy0rHsr.js";import{B as k,J as A,L as j,R as ee,U as M,V as N,Y as te,ft as P,n as F,v as ne,y as re,z as I}from"../chunks/DVD-VP-F.js";import{t as L}from"../chunks/Du4GCB9i.js";import"../chunks/C5XftTGY.js";import{r as ie}from"../chunks/DLl5XHy4.js";import{n as ae}from"../chunks/BrMTXoyD.js";import{a as oe,c as se,l as R,n as ce,o as le,r as ue,s as de,t as fe,u as pe}from"../chunks/Dh2PkwVA.js";var me=p(`<div class="sf:grid sf:gap-3 sf:lg:grid-cols-3"><div class="sf:rounded sf:border sf:border-primary-200 sf:bg-primary-50 sf:p-4"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <!></div> <h3 class="sf:mt-3 sf:text-base sf:font-semibold sf:text-slate-900">Sentient Forms Managed Service</h3> <p class="sf:mt-2 sf:text-sm sf:text-slate-600">Use a Sentient Forms subscription when you want model access, spend controls, metering,
					and service setup handled for this WordPress site.</p> <p class="sf:mt-3 sf:text-xs sf:font-medium sf:text-slate-700">Managed runs are pass-through: Sentient Forms does not store LLM prompts, form fields, or
					outputs beyond the billing/support metadata described in the disclosure.</p></div> <div class="sf:rounded sf:border sf:border-slate-200 sf:bg-white sf:p-4"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <!></div> <h3 class="sf:mt-3 sf:text-base sf:font-semibold sf:text-slate-900">Try actions with free models</h3> <p class="sf:mt-2 sf:text-sm sf:text-slate-600">Use OpenRouter routes marked free. This is the lowest-friction way to confirm a workflow,
					but model availability, privacy posture, and retention policy are controlled by OpenRouter
					and the upstream model provider.</p></div> <div class="sf:rounded sf:border sf:border-slate-200 sf:bg-white sf:p-4"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <!></div> <h3 class="sf:mt-3 sf:text-base sf:font-semibold sf:text-slate-900">Bring your own OpenRouter key</h3> <p class="sf:mt-2 sf:text-sm sf:text-slate-600">Keep Sentient Forms out of the request path for direct model calls. You manage the
					OpenRouter account, key limits, provider terms, and paid model charges.</p></div></div>`),he=p(`<div class="sf:flex sf:flex-col sf:gap-4 sf:lg:flex-row sf:lg:items-center sf:lg:justify-between"><div class="sf:space-y-2"><div class="sf:flex sf:flex-wrap sf:gap-2"><!> <!> <!> <!></div> <h3 class="sf:text-xl sf:font-semibold sf:text-slate-900">Sentient Forms Managed Service</h3> <p class="sf:max-w-2xl sf:text-sm sf:text-slate-600">Sentient Forms receives rendered prompts and required form fields only for managed service
					runs. Direct OpenRouter runs stay outside Sentient Forms billing.</p></div> <div class="sf:flex sf:gap-6"><div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Saved service credentials</p> <p class="sf:text-2xl sf:font-semibold sf:text-slate-900" data-testid="providers-managed-count"> </p></div> <div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Ready service credentials</p> <p class="sf:text-2xl sf:font-semibold sf:text-slate-900" data-testid="providers-managed-ready-count"> </p></div> <div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Consent state</p> <p class="sf:text-sm sf:font-semibold sf:text-slate-900"> </p></div></div></div>`),ge=p(`<p class="sf:text-sm sf:text-danger-700" role="alert"> </p>`),_e=p(`<div class="sf:flex sf:flex-col sf:items-start sf:justify-between sf:gap-3 sf:sm:flex-row sf:sm:items-start"><div class="sf:min-w-0 sf:space-y-1"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <!></div> <p class="sf:font-medium sf:text-slate-900">Enforce ZDR for managed service</p> <p class="sf:max-w-2xl sf:text-sm sf:leading-6 sf:text-slate-600">Requires Sentient Forms Managed Service to use routes that OpenRouter marks for Zero Data
					Retention and to deny provider data collection. If the selected model is no longer
					eligible, Sentient Forms uses a comparable ZDR-safe model when available or fails safely.</p> <!></div> <label class="sf:flex sf:items-center sf:gap-3"><span class="sf:text-sm sf:font-semibold"> </span> <input type="checkbox" class="sf:h-5 sf:w-5 sf:rounded sf:text-primary-600 sf:focus-visible:outline-none sf:focus-visible:ring-2 sf:focus-visible:ring-primary-500 sf:focus-visible:ring-offset-1 sf:focus-visible:ring-offset-white" aria-label="Enforce ZDR for managed service"/></label></div>`),ve=p(`<p class="sf:font-semibold">Privacy depends on the route you choose</p> <p class="sf:mt-1">OpenRouter can mark models as available on Zero Data Retention (ZDR) routes, and
					Sentient Forms shows those tags to help you choose. ZDR <span class="sf:font-semibold sf:italic sf:underline">enforcement</span> for direct OpenRouter users can only be configured in OpenRouter.</p>`,1),ye=p(`<div class="sf:space-y-4"><div class="sf:flex sf:flex-col sf:gap-4 sf:lg:flex-row sf:lg:items-center sf:lg:justify-between"><div class="sf:space-y-2"><div class="sf:flex sf:flex-wrap sf:gap-2"><!> <!> <!></div> <h3 class="sf:text-xl sf:font-semibold sf:text-slate-900"> </h3> <p class="sf:max-w-2xl sf:text-sm sf:text-slate-600">OpenRouter receives the prompts and form fields needed for direct model calls. Sentient
						Forms does not receive those direct-call payloads. Use the local vault for the fastest
						setup, or use a server constant or environment variable when you want the key to stay
						out of the plugin database.</p></div> <div class="sf:flex sf:gap-6"><div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Saved keys</p> <p class="sf:text-2xl sf:font-semibold sf:text-slate-900" data-testid="providers-openrouter-count"> </p></div> <div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Ready keys</p> <p class="sf:text-2xl sf:font-semibold sf:text-slate-900" data-testid="providers-openrouter-ready-count"> </p></div></div></div> <!></div>`),be=p(`<p class="sf:text-sm sf:text-danger-700" role="alert" data-testid="providers-model-catalog-error"> </p>`),xe=p(`<label class="sf:flex sf:items-start sf:gap-3 sf:text-sm sf:text-slate-700"><input class="sf:mt-1 sf:h-4 sf:w-4 sf:rounded sf:border-slate-300" type="checkbox"/> <span>I understand refreshing the catalog contacts OpenRouter for model metadata, pricing,
							and capability flags. No form data or prompts are sent. I accept the <a class="sf:font-medium sf:text-slate-900 sf:underline" href="https://openrouter.ai/terms" target="_blank" rel="noreferrer noopener">OpenRouter terms</a> and <a class="sf:font-medium sf:text-slate-900 sf:underline" href="https://openrouter.ai/privacy" target="_blank" rel="noreferrer noopener">privacy policy</a>.</span></label>`),Se=p(`<div class="sf:mt-4"><!></div>`),Ce=p(`<div class="sf:mt-4"><!></div>`),we=p(`<div class="sf:rounded sf:border sf:border-slate-200 sf:bg-white sf:p-3" data-testid="providers-openrouter-free-model"><div class="sf:flex sf:items-start sf:justify-between sf:gap-2"><p class="sf:text-sm sf:font-medium sf:text-slate-900"> </p> <!></div> <p class="sf:mt-1 sf:break-all sf:text-xs sf:text-slate-500"> </p> <p class="sf:mt-2 sf:text-xs sf:text-slate-600"> </p></div>`),Te=p(`<div class="sf:mt-4 sf:grid sf:gap-3 sf:md:grid-cols-2 sf:xl:grid-cols-3"></div>`),Ee=p(`<div class="sf:flex sf:flex-col sf:gap-4 sf:lg:flex-row sf:lg:items-start sf:lg:justify-between"><div class="sf:space-y-2"><div class="sf:flex sf:flex-wrap sf:gap-2"><!> <!></div> <p class="sf:max-w-2xl sf:text-sm sf:text-slate-600">Refresh pulls model names, pricing, capabilities, and free-model flags from OpenRouter. No
					form data or prompts are sent.</p> <!> <!></div> <div class="sf:flex sf:flex-wrap sf:items-center sf:gap-6"><div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Cached models</p> <p class="sf:text-2xl sf:font-semibold sf:text-slate-900" data-testid="providers-openrouter-model-count"> </p></div> <div><p class="sf:text-xs sf:font-medium sf:text-slate-500">Free models</p> <p class="sf:text-2xl sf:font-semibold sf:text-slate-900" data-testid="providers-openrouter-free-model-count"> </p></div> <!></div></div> <!>`,1),De=p(`<div class="sf:mt-4 sf:rounded sf:border sf:border-success-200 sf:bg-success-50 sf:p-4" data-testid="providers-openrouter-validation-result"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <span class="sf:text-sm sf:text-success-800"> </span></div> <p class="sf:mt-2 sf:text-sm sf:text-success-800"> </p></div>`),Oe=p(`<form class="sf:space-y-4"><!> <!> <label class="sf:flex sf:items-start sf:gap-3 sf:text-sm sf:text-slate-700"><input class="sf:mt-1 sf:h-4 sf:w-4 sf:rounded sf:border-slate-300" type="checkbox"/> <span>Save the validated key in the local provider vault.</span></label> <label class="sf:flex sf:items-start sf:gap-3 sf:text-sm sf:text-slate-700"><input class="sf:mt-1 sf:h-4 sf:w-4 sf:rounded sf:border-slate-300" type="checkbox" required/> <span>I understand OpenRouter receives request data for direct model calls and I accept the <a class="sf:font-medium sf:text-slate-900 sf:underline" href="https://openrouter.ai/terms" target="_blank" rel="noreferrer noopener">OpenRouter terms</a> and <a class="sf:font-medium sf:text-slate-900 sf:underline" href="https://openrouter.ai/privacy" target="_blank" rel="noreferrer noopener">privacy policy</a>.</span></label> <!></form> <!>`,1),ke=p(`<p class="sf:font-semibold">No OpenRouter key is stored in the plugin database</p> <p class="sf:mt-1">Define a constant or environment variable on this WordPress host first, then validate
							it here. Sentient Forms only stores the reference name and status metadata.</p>`,1),Ae=p(`<p class="sf:text-sm sf:text-danger-700" role="alert" data-testid="providers-openrouter-constant-error"> </p>`),je=p(`<div class="sf:rounded sf:border sf:border-success-200 sf:bg-success-50 sf:p-4" data-testid="providers-openrouter-constant-result"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <span class="sf:text-sm sf:text-success-800"> </span></div> <p class="sf:mt-2 sf:text-sm sf:text-success-800">Server secret <code class="sf:rounded sf:bg-slate-200 sf:px-1.5 sf:py-0.5 sf:font-mono sf:text-[13px] sf:text-slate-800"> </code> </p></div>`),Me=p(`<div class="sf:space-y-4"><!> <form class="sf:space-y-4"><!> <!> <p class="sf:text-xs sf:text-slate-500">Example: <code class="sf:rounded sf:bg-slate-200 sf:px-1.5 sf:py-0.5 sf:font-mono sf:text-[13px] sf:text-slate-800">SENTIENT_FORMS_OPENROUTER_KEY</code>. Names must start with <code class="sf:rounded sf:bg-slate-200 sf:px-1.5 sf:py-0.5 sf:font-mono sf:text-[13px] sf:text-slate-800">SENTIENT_FORMS_OPENROUTER_</code>. Do not use WordPress auth keys, salts, database credentials, or other unrelated
							server secrets.</p> <label class="sf:flex sf:items-start sf:gap-3 sf:text-sm sf:text-slate-700"><input class="sf:mt-1 sf:h-4 sf:w-4 sf:rounded sf:border-slate-300" type="checkbox" required/> <span>I understand OpenRouter receives request data for direct model calls and I accept
								the <a class="sf:font-medium sf:text-slate-900 sf:underline" href="https://openrouter.ai/terms" target="_blank" rel="noreferrer noopener">OpenRouter terms</a> and <a class="sf:font-medium sf:text-slate-900 sf:underline" href="https://openrouter.ai/privacy" target="_blank" rel="noreferrer noopener">privacy policy</a>.</span></label> <!></form> <!> <!></div>`),Ne=p(`<p class="sf:mt-1 sf:text-xs sf:text-slate-500">Reference <code class="sf:rounded sf:bg-slate-200 sf:px-1.5 sf:py-0.5 sf:font-mono sf:text-[13px] sf:text-slate-800"> </code></p>`),Pe=p(`<p data-testid="providers-openrouter-credential-status-detail"> </p>`),Fe=p(`<div class="sf:mt-3 sf:rounded sf:border sf:border-danger-500 sf:bg-danger-50 sf:p-3" data-testid="providers-openrouter-delete-confirmation"><p class="sf:text-sm sf:font-medium sf:text-danger-600">Delete this saved OpenRouter key?</p> <p class="sf:mt-1 sf:text-xs sf:text-slate-700">Actions using this key need another provider key before they can run.</p> <div class="sf:mt-3 sf:flex sf:flex-wrap sf:gap-2"><!> <!></div></div>`),Ie=p(`<div class="sf:border-l sf:border-slate-300 sf:pl-3" data-testid="providers-openrouter-credential"><div class="sf:flex sf:flex-wrap sf:items-center sf:justify-between sf:gap-2"><p class="sf:font-medium sf:text-slate-900"> </p> <div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <!> <!></div></div> <p class="sf:mt-1 sf:text-sm sf:text-slate-600"> </p> <!> <p class="sf:mt-1 sf:text-xs sf:text-slate-500"> </p> <!> <!></div>`),Le=p(`<div class="sf:space-y-3"></div>`),Re=p(`<p class="sf:mt-2 sf:text-xs sf:text-slate-600"> </p>`),ze=p(`<div class="sf:mt-4"><!></div>`),Be=p(`<form class="sf:space-y-4"><!> <label class="sf:flex sf:items-start sf:gap-3 sf:text-sm sf:text-slate-700"><input class="sf:mt-1 sf:h-4 sf:w-4 sf:rounded sf:border-slate-300" type="checkbox" required/> <span>I understand Sentient Forms receives the rendered prompt and required form fields
									for managed service runs, meters usage, and bills through my Sentient Forms plan.</span></label> <!></form>`),Ve=p(`<div class="sf:space-y-4"><div data-testid="providers-managed-consent-state"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <!></div> <h3 class="sf:mt-3 sf:text-base sf:font-semibold sf:text-slate-900"><!></h3> <p class="sf:mt-2 sf:text-sm sf:text-slate-700"><!></p> <!> <!></div> <!></div>`),He=p(`<p class="sf:mt-4 sf:text-sm sf:text-danger-700" role="alert" data-testid="providers-managed-setup-error"> </p>`),Ue=p(`<p class="sf:mt-4 sf:text-sm sf:text-danger-700" role="alert" data-testid="providers-managed-revoke-error"> </p>`),We=p(`<div class="sf:mt-4 sf:rounded sf:border sf:border-success-200 sf:bg-success-50 sf:p-4" data-testid="providers-managed-setup-result"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <span class="sf:text-sm sf:text-success-800"> </span></div> <p class="sf:mt-2 sf:text-sm sf:text-success-800"> </p></div>`),Ge=p(`<div class="sf:mt-4 sf:rounded sf:border sf:border-amber-200 sf:bg-amber-50 sf:p-4" data-testid="providers-managed-revoke-result"><div class="sf:flex sf:flex-wrap sf:items-center sf:gap-2"><!> <span class="sf:text-sm sf:text-amber-800"> </span></div> <p class="sf:mt-2 sf:text-sm sf:text-amber-800">The local managed-service credential is disabled. Stripe billing was not changed.</p></div>`),Ke=p(`<!> <!> <!> <!> <!>`,1),qe=p(`<p data-testid="providers-managed-credential-status-detail"> </p>`),Je=p(`<div class="sf:border-l sf:border-slate-300 sf:pl-3" data-testid="providers-managed-credential"><div class="sf:flex sf:flex-wrap sf:items-center sf:justify-between sf:gap-2"><p class="sf:font-medium sf:text-slate-900"> </p> <div class="sf:flex sf:flex-wrap sf:gap-2"><!> <!></div></div> <p class="sf:mt-1 sf:text-sm sf:text-slate-600"> </p> <p class="sf:mt-1 sf:text-xs sf:text-slate-500"> </p> <!></div>`),Ye=p(`<div class="sf:space-y-3"></div>`),Xe=p(`<div class="sf:flex sf:flex-col sf:items-start sf:justify-between sf:gap-4 sf:lg:flex-row sf:lg:items-center"><div class="sf:space-y-2"><div class="sf:flex sf:flex-wrap sf:gap-2"><!> <!> <!></div> <p class="sf:max-w-2xl sf:text-sm sf:text-slate-600">Choose a form in Actions, then use Direct OpenRouter or the Sentient Forms managed
						service to create an action and mapping from the same screen where you manage hooks, run
						mode, and mapping health.</p></div> <!></div>`),Ze=p(`<!> <!> <!> <!> <!> <!> <div class="sf:grid sf:gap-4 sf:xl:grid-cols-[1fr_0.9fr]"><div class="sf:space-y-4"><!> <!></div> <!></div> <div class="sf:grid sf:gap-4 sf:xl:grid-cols-[1fr_0.9fr]"><!> <!></div> <!>`,1);function z(a,p){s(p,!0);let z=te(),Qe=ne,$e=re,et=r(!0),tt=r(D([])),B=r(null),nt=r(null),V=r(null),rt=r(null),H=r(null),U=r(null),W=r(null),G=r(null),it=r(null),at=r(null),ot=r(null),st=r(``),ct=r(`OpenRouter key`),lt=r(`OpenRouter server secret`),ut=r(`SENTIENT_FORMS_OPENROUTER_KEY`),dt=r(`Sentient Forms Managed Service`),ft=r(!0),K=r(!1),q=r(!1),J=r(!1),Y=r(!1),pt=r(null),mt=r(null),ht=r(!1),gt=r(!1),_t=r(!0),vt=r(!1),X=r(!1),yt=r(!1),bt=r(!1),xt=0,St=b(()=>w(tt).filter(e=>e.provider===`openrouter`)),Ct=b(()=>w(St).filter(e=>fe(e))),wt=b(()=>w(tt).filter(e=>e.provider===`sentient_managed`)),Tt=b(()=>w(wt).filter(e=>e.auth_mode===`sentient_proxy`&&e.status===`valid`&&e.secret_configured&&zt(e).state===`accepted`)),Et=b(()=>w(St)[0]??null),Dt=b(()=>w(Tt)[0]??w(wt)[0]??null),Z=b(()=>zt(w(Dt))),Ot=b(()=>w(Ct).length),kt=b(()=>[...w(Ct),...w(Tt)]),Q=b(()=>[`active`,`trial`,`valid`].includes(L.status)&&L.proxyKeyPresent&&!!L.licenseId&&!!L.siteId),At=b(()=>w(yt)||!w(bt)||!w(Q)),jt=b(()=>w(Q)?`Connect a provider before building actions`:ue(w(St))),Mt=b(()=>w(Q)?`Enable the Sentient Forms Managed Service here or validate an OpenRouter key or server secret for direct local execution.`:ce(w(St))),Nt=b(()=>(w(H)?.models??[]).filter(e=>e.free).slice(0,6)),Pt=b(()=>w(K)&&!w(vt)),Ft=b(()=>w(K)&&w(st).trim().length>0&&!w(J)),It=b(()=>w(K)&&w(ut).trim().length>0&&!w(Y)),Lt=b(()=>w(Q)&&w(q)&&!w(ht)&&w(Z).state!==`accepted`);x(()=>{w(Z).state===`accepted`?l(q,!0):w(Z).state===`revoked`&&l(q,!1)});function Rt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function zt(e){let t=Rt(e?.status_json)?e.status_json:null,n=Rt(t?.managed_consent)?t.managed_consent:null,r=typeof n?.state==`string`?n.state:`missing`;return{state:r===`accepted`||r===`revoked`||r===`missing`?r:`missing`,consentId:typeof n?.consent_id==`number`?n.consent_id:null,disclosureVersion:typeof n?.disclosure_version==`string`?n.disclosure_version:null,acceptedAt:typeof n?.accepted_at==`string`?n.accepted_at:null,revokedAt:typeof n?.revoked_at==`string`?n.revoked_at:null}}function Bt(e){return e===`accepted`?`success`:e===`revoked`?`warning`:`neutral`}function Vt(e){return e===`accepted`?`Consent accepted`:e===`revoked`?`Consent revoked`:`Consent missing`}function Ht(e){return e.state===`accepted`?e.acceptedAt:e.state===`revoked`?e.revokedAt:null}function $(e){if(e instanceof A){let t=e.payload;if(t&&typeof t==`object`&&`message`in t){let e=t.message;if(typeof e==`string`&&e.trim().length>0)return e}}return e instanceof Error?e.message:`Provider request failed.`}async function Ut(){l(et,!0),l(U,null);try{l(tt,await z.getLocalProviderCredentials({showNotifications:!1}),!0)}catch(e){l(U,$(e),!0)}finally{l(et,!1)}}async function Wt(){l(_t,!0),l(at,null);try{l(H,await z.getOpenRouterModels({limit:100},{showNotifications:!1}),!0)}catch(e){l(at,$(e),!0)}finally{l(_t,!1)}}function Gt(e){l(X,!!e.managed_zdr_required,!0)}async function Kt(){let e=++xt;l(ot,null);try{let t=await z.getSettings({showNotifications:!1});if(e!==xt)return;Gt(t),l(bt,!0)}catch(t){if(e!==xt)return;l(ot,$(t),!0)}}async function qt(e){if(!w(Q)){l(X,!1),P.warning(`Active Sentient Forms Managed Service is required to enforce ZDR.`);return}xt+=1;let t=w(X);l(X,e,!0),l(yt,!0),l(ot,null);try{Gt(await z.updateSettings({managed_zdr_required:e},{showNotifications:!1})),l(bt,!0),P.success(e?`Managed ZDR enforcement enabled`:`Managed ZDR enforcement disabled`)}catch(e){l(X,t,!0),l(ot,$(e),!0),P.error(`Unable to update managed ZDR enforcement`)}finally{l(yt,!1)}}async function Jt(){if(l(at,null),!w(K)){l(at,`Accept the OpenRouter external-service disclosure before refreshing model metadata.`);return}l(vt,!0);try{l(H,await z.refreshOpenRouterModels({disclosure_version:Qe,accepted_external_service_terms:w(K),output_modalities:`text`},{showNotifications:!1}),!0)}catch(e){l(at,$(e),!0)}finally{l(vt,!1)}}async function Yt(e){if(e.preventDefault(),l(U,null),l(W,null),l(B,null),l(nt,null),w(st).trim().length===0){l(U,`Enter an OpenRouter API key before validating.`);return}if(!w(K)){l(U,`Accept the OpenRouter external-service disclosure before validating this key.`);return}l(J,!0);try{l(B,await z.validateOpenRouterKey({api_key:w(st).trim(),label:w(ct).trim()||void 0,save:w(ft),disclosure_version:Qe,accepted_external_service_terms:w(K)},{showNotifications:!1}),!0),w(ft)&&(l(st,``),await Ut()),l(nt,`manual_key`)}catch(e){l(U,$(e),!0)}finally{l(J,!1)}}async function Xt(e){if(e.preventDefault(),l(U,null),l(W,null),l(B,null),l(nt,null),w(ut).trim().length===0){l(W,`Enter the constant or environment variable name before validating.`);return}if(!w(K)){l(W,`Accept the OpenRouter external-service disclosure before validating this server secret.`);return}l(Y,!0);try{l(B,await z.saveOpenRouterConstant({constant_name:w(ut).trim(),label:w(lt).trim()||void 0,disclosure_version:Qe,accepted_external_service_terms:w(K)},{showNotifications:!1}),!0),await Ut(),l(nt,`constant`)}catch(e){l(W,$(e),!0)}finally{l(Y,!1)}}function Zt(e){l(mt,e.id,!0)}function Qt(){l(mt,null)}async function $t(e){l(U,null),l(pt,e.id,!0);try{await z.deleteLocalProviderCredential(e.id,{showNotifications:!1}),l(tt,w(tt).filter(t=>t.id!==e.id),!0),l(mt,null),P.success(`${e.label} deleted`)}catch(e){let t=$(e);l(U,t,!0),P.error(t)}finally{l(pt,null)}}async function en(e){if(e.preventDefault(),l(G,null),l(V,null),l(it,null),l(rt,null),!w(Q)){l(G,`Activate a Sentient Forms Managed Service account before enabling managed service.`);return}if(!w(q)){l(G,`Accept the Sentient Forms Managed Service disclosure before enabling managed service.`);return}l(ht,!0);try{l(V,await z.setupSentientManagedProvider({label:w(dt).trim()||void 0,disclosure_version:$e,accepted_external_service_terms:w(q)},{showNotifications:!1}),!0),await Ut()}catch(e){l(G,$(e),!0)}finally{l(ht,!1)}}async function tn(){l(G,null),l(V,null),l(it,null),l(rt,null),l(gt,!0);try{l(rt,await z.revokeSentientManagedProvider({disclosure_version:$e,confirm_managed_service_revocation:!0},{showNotifications:!1}),!0),l(q,!1),await Ut(),P.success(`Managed-service consent revoked. Stripe subscription unchanged.`)}catch(e){l(it,$(e),!0)}finally{l(gt,!1)}}C(()=>{Ut(),Wt(),Kt()}),k(a,{heading:`Providers`,description:`Choose how Sentient Forms actions reach models. Managed service is the recommended setup for most WebMasters; free OpenRouter routes and BYOK remain available for testing and self-managed provider billing.`,actions:e=>{M(e,{variant:`secondary`,onclick:Ut,get disabled(){return w(et)},children:(e,t)=>{d();var n=S();_(()=>f(n,w(et)?`Refreshing...`:`Refresh`)),i(e,n)},$$slots:{default:!0}})},children:(r,a)=>{var o=Ze(),s=O(o),p=e=>{F(e,{variant:`error`,title:`Provider setup needs attention`,get message(){return w(U)},actionLabel:`Retry`,onAction:Ut,testId:`providers-error-state`})};t(s,e=>{w(U)&&e(p)});var x=g(s,2);N(x,{title:`Pick the operating model`,"data-testid":`providers-operating-model-card`,children:(e,t)=>{var n=me(),r=E(n),a=E(r),o=E(a);{let e=b(()=>w(Q)?`success`:`warning`);I(o,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(()=>f(n,w(Q)?`Ready to enable`:`License needed`)),i(e,n)},$$slots:{default:!0}})}I(g(o,2),{variant:`info`,children:(e,t)=>{d(),i(e,S(`Recommended`))},$$slots:{default:!0}}),m(a),d(6),m(r);var s=g(r,2),c=E(s),l=E(c);I(l,{variant:`success`,children:(e,t)=>{d(),i(e,S(`Free path`))},$$slots:{default:!0}}),I(g(l,2),{variant:`neutral`,children:(e,t)=>{d(),i(e,S(`OpenRouter`))},$$slots:{default:!0}}),m(c),d(4),m(s);var u=g(s,2),p=E(u),h=E(p);I(h,{variant:`info`,children:(e,t)=>{d(),i(e,S(`BYOK`))},$$slots:{default:!0}}),I(g(h,2),{variant:`neutral`,children:(e,t)=>{d(),i(e,S(`Direct billing`))},$$slots:{default:!0}}),m(p),d(4),m(u),m(n),i(e,n)},$$slots:{default:!0}});var C=g(x,2);N(C,{class:`sf:border-slate-300 sf:bg-slate-50`,"data-testid":`providers-managed-summary`,children:(e,t)=>{var n=he(),r=E(n),a=E(r),o=E(a);{let e=b(()=>pe(w(Dt)?.status??`missing`));I(o,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>R(w(Dt)?.status??`missing`)]),i(e,n)},$$slots:{default:!0}})}var s=g(o,2);{let e=b(()=>w(Q)?`success`:`warning`);I(s,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(()=>f(n,w(Q)?`Managed account ready`:`Managed account inactive`)),i(e,n)},$$slots:{default:!0}})}var c=g(s,2);{let e=b(()=>Bt(w(Z).state));I(c,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>Vt(w(Z).state)]),i(e,n)},$$slots:{default:!0}})}I(g(c,2),{variant:`info`,children:(e,t)=>{d(),i(e,S(`Sentient Forms billed`))},$$slots:{default:!0}}),m(a),d(4),m(r);var l=g(r,2),u=E(l),p=g(E(u),2),h=E(p,!0);m(p),m(u);var v=g(u,2),y=g(E(v),2),x=E(y,!0);m(y),m(v);var C=g(v,2),T=g(E(C),2),D=E(T,!0);m(T),m(C),m(l),m(n),_(e=>{f(h,w(wt).length),f(x,w(Tt).length),f(D,e)},[()=>Vt(w(Z).state)]),i(e,n)},$$slots:{default:!0}});var D=g(C,2);N(D,{class:`sf:border-slate-300 sf:bg-white`,"data-testid":`providers-managed-zdr`,children:(e,r)=>{var a=_e(),o=E(a),s=E(o),l=E(s);{let e=b(()=>w(Q)?`success`:`warning`);I(l,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(()=>f(n,w(Q)?`Managed service active`:`Managed service required`)),i(e,n)},$$slots:{default:!0}})}var u=g(l,2),p=e=>{I(e,{variant:`success`,children:(e,t)=>{d(),i(e,S(`ZDR enforced`))},$$slots:{default:!0}})};t(u,e=>{w(X)&&e(p)}),m(s);var h=g(s,6),v=e=>{var t=ge(),n=E(t,!0);m(t),_(()=>f(n,w(ot))),i(e,t)};t(h,e=>{w(ot)&&e(v)}),m(o);var y=g(o,2),x=E(y),C=E(x,!0);m(x);var T=g(x,2);n(T),T.__change=e=>qt(e.currentTarget.checked),m(y),m(a),_(()=>{f(C,w(X)?`On`:`Off`),c(T,w(X)),T.disabled=w(At)}),i(e,a)},$$slots:{default:!0}});var k=g(D,2);N(k,{class:`sf:border-slate-300 sf:bg-slate-50`,"data-testid":`providers-openrouter-summary`,children:(e,t)=>{var n=ye(),r=E(n),a=E(r),o=E(a),s=E(o);{let e=b(()=>pe(w(Et)?.status??`missing`));I(s,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>R(w(Et)?.status??`missing`)]),i(e,n)},$$slots:{default:!0}})}var c=g(s,2);I(c,{variant:`info`,children:(e,t)=>{d(),i(e,S(`Local credential storage`))},$$slots:{default:!0}}),I(g(c,2),{variant:`neutral`,children:(e,t)=>{d(),i(e,S(`Server secret supported`))},$$slots:{default:!0}}),m(o);var l=g(o,2),u=E(l,!0);m(l),d(2),m(a);var p=g(a,2),h=E(p),v=g(E(h),2),y=E(v,!0);m(v),m(h);var x=g(h,2),C=g(E(x),2),T=E(C,!0);m(C),m(x),m(p),m(r),ee(g(r,2),{variant:`warning`,children:(e,t)=>{var n=ve();d(2),i(e,n)},$$slots:{default:!0}}),m(n),_(()=>{f(u,w(Et)?.label??`OpenRouter direct`),f(y,w(St).length),f(T,w(Ot))}),i(e,n)},$$slots:{default:!0}});var A=g(k,2);N(A,{title:`OpenRouter model catalog`,"data-testid":`providers-openrouter-model-catalog`,children:(r,a)=>{var o=Ee(),s=O(o),c=E(s),p=E(c),h=E(p);{let e=b(()=>w(H)&&w(H).total_cached>0?`success`:`neutral`);I(h,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(()=>f(n,w(H)&&w(H).total_cached>0?`Cached locally`:`No local cache`)),i(e,n)},$$slots:{default:!0}})}var v=g(h,2),x=e=>{I(e,{variant:`warning`,children:(e,t)=>{d();var n=S();_(()=>f(n,`${w(H).stale_count??``} stale`)),i(e,n)},$$slots:{default:!0}})};t(v,e=>{w(H)&&w(H).stale_count>0&&e(x)}),m(p);var C=g(p,4),D=e=>{var t=be(),n=E(t,!0);m(t),_(()=>f(n,w(at))),i(e,t)};t(C,e=>{w(at)&&e(D)});var k=g(C,2);{let e=b(()=>w(K)?`success`:`info`);ee(k,{get variant(){return w(e)},"data-testid":`providers-model-catalog-disclosure`,children:(e,t)=>{var r=xe(),a=E(r);n(a),d(2),m(r),T(a,()=>w(K),e=>l(K,e)),i(e,r)},$$slots:{default:!0}})}m(c);var A=g(c,2),j=E(A),N=g(E(j),2),te=E(N,!0);m(N),m(j);var P=g(j,2),ne=g(E(P),2),re=E(ne,!0);m(ne),m(P);var L=g(P,2);{let e=b(()=>!w(Pt));M(L,{variant:`secondary`,get loading(){return w(vt)},get disabled(){return w(e)},onclick:Jt,"data-testid":`providers-refresh-model-catalog`,children:(e,t)=>{d();var n=S();_(()=>f(n,w(vt)?`Refreshing...`:`Refresh catalog`)),i(e,n)},$$slots:{default:!0}})}m(A),m(s);var ie=g(s,2),oe=e=>{var t=Se();F(E(t),{variant:`loading`,title:`Loading model cache`,dense:!0}),m(t),i(e,t)},se=n=>{var r=u(),a=O(r),o=e=>{var t=Ce(),n=E(t);{let e=b(()=>w(K)?`Refresh catalog`:null),t=b(()=>w(K)?Jt:null);F(n,{variant:`empty`,title:`No model cache yet`,message:`Accept the OpenRouter disclosure in this catalog panel, then refresh before choosing a specific cached model.`,get actionLabel(){return w(e)},get onAction(){return w(t)},dense:!0})}m(t),i(e,t)},s=n=>{var r=u(),a=O(r),o=t=>{var n=Te();e(n,21,()=>w(Nt),y,(e,t)=>{var n=we(),r=E(n),a=E(r),o=E(a,!0);m(a);var s=g(a,2);{let e=b(()=>w(t).stale?`warning`:`success`);I(s,{get variant(){return w(e)},children:(e,n)=>{d();var r=S();_(()=>f(r,w(t).stale?`Stale`:`Free`)),i(e,r)},$$slots:{default:!0}})}m(r);var c=g(r,2),l=E(c,!0);m(c);var u=g(c,2),p=E(u);m(u),m(n),_(e=>{f(o,w(t).name),f(l,w(t).id),f(p,`Context ${w(t).context_length??`unknown`??``} tokens · refreshed ${e??``}`)},[()=>ae(w(t).fetched_at,`never`)]),i(e,n)}),m(n),i(t,n)};t(a,e=>{w(Nt).length>0&&e(o)},!0),i(n,r)};t(a,e=>{!w(H)||w(H).total_cached===0?e(o):e(s,!1)},!0),i(n,r)};t(ie,e=>{w(_t)?e(oe):e(se,!1)}),_(()=>{f(te,w(_t)?`...`:w(H)?.total_cached??0),f(re,w(_t)?`...`:w(H)?.free_count??0)}),i(r,o)},$$slots:{default:!0}});var te=g(A,2),P=E(te),ne=E(P);N(ne,{title:`Validate OpenRouter key`,"data-testid":`providers-openrouter-form-card`,children:(e,r)=>{var a=Oe(),o=O(a),s=E(o);j(s,{id:`openrouter-label`,label:`Label`,placeholder:`OpenRouter key`,get disabled(){return w(J)},get value(){return w(ct)},set value(e){l(ct,e,!0)}});var c=g(s,2);j(c,{id:`openrouter-api-key`,label:`API key`,type:`password`,placeholder:`sk-or-...`,autocomplete:`off`,get disabled(){return w(J)},required:!0,get value(){return w(st)},set value(e){l(st,e,!0)}});var u=g(c,2),p=E(u);n(p),d(2),m(u);var v=g(u,2),y=E(v);n(y),d(2),m(v);var x=g(v,2);{let e=b(()=>!w(Ft));M(x,{type:`submit`,get loading(){return w(J)},get disabled(){return w(e)},children:(e,t)=>{d();var n=S();_(()=>f(n,w(J)?`Validating...`:`Validate key`)),i(e,n)},$$slots:{default:!0}})}m(o);var C=g(o,2),D=e=>{var t=De(),n=E(t),r=E(n);{let e=b(()=>pe(w(B).status));I(r,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>R(w(B).status)]),i(e,n)},$$slots:{default:!0}})}var a=g(r,2),o=E(a);m(a),m(n);var s=g(n,2),c=E(s,!0);m(s),m(t),_(()=>{f(o,`Consent #${w(B).consent_id??``} recorded.`),f(c,w(B).credential_id?`Saved credential #${w(B).credential_id}.`:`Validated without saving the key.`)}),i(e,t)};t(C,e=>{w(B)&&w(nt)===`manual_key`&&e(D)}),_(()=>{p.disabled=w(J),y.disabled=w(J)}),h(`submit`,o,Yt),T(p,()=>w(ft),e=>l(ft,e)),T(y,()=>w(K),e=>l(K,e)),i(e,a)},$$slots:{default:!0}}),N(g(ne,2),{title:`Use server constant or environment variable`,subtitle:`Recommended for high-sensitivity sites.`,"data-testid":`providers-openrouter-constant-card`,children:(e,r)=>{var a=Me(),o=E(a);ee(o,{variant:`info`,children:(e,t)=>{var n=ke();d(2),i(e,n)},$$slots:{default:!0}});var s=g(o,2),c=E(s);j(c,{id:`openrouter-constant-label`,label:`Label`,placeholder:`OpenRouter server secret`,get disabled(){return w(Y)},get value(){return w(lt)},set value(e){l(lt,e,!0)}});var u=g(c,2);j(u,{id:`openrouter-constant-name`,label:`Constant or environment variable`,placeholder:`SENTIENT_FORMS_OPENROUTER_KEY`,get disabled(){return w(Y)},required:!0,get value(){return w(ut)},set value(e){l(ut,e,!0)}});var p=g(u,4),v=E(p);n(v),d(2),m(p);var y=g(p,2);{let e=b(()=>!w(It));M(y,{type:`submit`,variant:`secondary`,get loading(){return w(Y)},get disabled(){return w(e)},"data-testid":`providers-openrouter-constant-submit`,children:(e,t)=>{d();var n=S();_(()=>f(n,w(Y)?`Validating...`:`Validate server secret`)),i(e,n)},$$slots:{default:!0}})}m(s);var x=g(s,2),C=e=>{var t=Ae(),n=E(t,!0);m(t),_(()=>f(n,w(W))),i(e,t)};t(x,e=>{w(W)&&e(C)});var D=g(x,2),O=e=>{var t=je(),n=E(t),r=E(n);{let e=b(()=>pe(w(B).status));I(r,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>R(w(B).status)]),i(e,n)},$$slots:{default:!0}})}var a=g(r,2),o=E(a);m(a),m(n);var s=g(n,2),c=g(E(s)),l=E(c,!0);m(c);var u=g(c);m(s),m(t),_(()=>{f(o,`Consent #${w(B).consent_id??``} recorded.`),f(l,w(B).constant_name??w(ut)),f(u,` is now ready as credential #${w(B).credential_id??``}.`)}),i(e,t)};t(D,e=>{w(B)&&w(nt)===`constant`&&e(O)}),m(a),_(()=>v.disabled=w(Y)),h(`submit`,s,Xt),T(v,()=>w(K),e=>l(K,e)),i(e,a)},$$slots:{default:!0}}),m(P),N(g(P,2),{title:`Saved OpenRouter keys`,"data-testid":`providers-openrouter-list-card`,children:(n,r)=>{var a=u(),o=O(a),s=e=>{F(e,{variant:`loading`,title:`Loading provider keys`,dense:!0})},c=n=>{var r=u(),a=O(r),o=e=>{F(e,{variant:`empty`,title:`No OpenRouter key saved`,message:`Validate a key or server secret to unlock the direct free path.`,dense:!0})},s=n=>{var r=Le();e(r,21,()=>w(St),y,(e,n)=>{let r=b(()=>de(w(n)));var a=Ie(),o=E(a),s=E(o),c=E(s,!0);m(s);var l=g(s,2),u=E(l);{let e=b(()=>pe(w(n).status));I(u,{get variant(){return w(e)},children:(e,t)=>{d();var r=S();_(e=>f(r,e),[()=>R(w(n).status)]),i(e,r)},$$slots:{default:!0}})}var p=g(u,2),h=e=>{I(e,{variant:`neutral`,children:(e,t)=>{d(),i(e,S(`Server secret`))},$$slots:{default:!0}})};t(p,e=>{w(n).auth_mode===`constant`&&e(h)});var y=g(p,2);{let e=b(()=>w(pt)===w(n).id),t=b(()=>`providers-openrouter-delete-${w(n).id}`);M(y,{size:`sm`,variant:`danger`,get disabled(){return w(e)},onclick:()=>Zt(w(n)),get"data-testid"(){return w(t)},children:(e,t)=>{d(),i(e,S(`Delete`))},$$slots:{default:!0}})}m(l),m(o);var x=g(o,2),C=E(x);m(x);var T=g(x,2),D=e=>{var t=Ne(),r=g(E(t)),a=E(r,!0);m(r),m(t),_(()=>f(a,w(n).constant_name)),i(e,t)};t(T,e=>{w(n).auth_mode===`constant`&&w(n).constant_name&&e(D)});var O=g(T,2),k=E(O);m(O);var A=g(O,2),j=e=>{var t=Pe(),a=E(t,!0);m(t),_(e=>{v(t,1,e),f(a,w(r))},[()=>`sf:mt-2 sf:text-xs ${se(w(n))}`]),i(e,t)};t(A,e=>{w(r)&&e(j)});var ee=g(A,2),N=e=>{var t=Fe(),r=g(E(t),4),a=E(r);{let e=b(()=>w(pt)===w(n).id),t=b(()=>`providers-openrouter-delete-confirm-${w(n).id}`);M(a,{size:`sm`,variant:`danger`,get loading(){return w(e)},onclick:()=>$t(w(n)),get"data-testid"(){return w(t)},children:(e,t)=>{d();var r=S();_(()=>f(r,w(pt)===w(n).id?`Deleting...`:`Delete key`)),i(e,r)},$$slots:{default:!0}})}var o=g(a,2);{let e=b(()=>w(pt)===w(n).id),t=b(()=>`providers-openrouter-delete-cancel-${w(n).id}`);M(o,{size:`sm`,variant:`secondary`,get disabled(){return w(e)},onclick:Qt,get"data-testid"(){return w(t)},children:(e,t)=>{d(),i(e,S(`Cancel`))},$$slots:{default:!0}})}m(r),m(t),i(e,t)};t(ee,e=>{w(mt)===w(n).id&&e(N)}),m(a),_((e,t,r)=>{f(c,w(n).label),f(C,`${e??``} · ${t??``}`),f(k,`Last validated ${r??``}`)},[()=>oe(w(n)),()=>le(w(n)),()=>ae(w(n).last_validated_at,`never`)]),i(e,a)}),m(r),i(n,r)};t(a,e=>{w(St).length===0?e(o):e(s,!1)},!0),i(n,r)};t(o,e=>{w(et)?e(s):e(c,!1)}),i(n,a)},$$slots:{default:!0}}),m(te);var re=g(te,2),L=E(re);{let e=b(()=>w(Z).state===`accepted`?`Manage Sentient Forms Managed Service`:`Enable Sentient Forms Managed Service`);N(L,{get title(){return w(e)},"data-testid":`providers-managed-setup-card`,children:(e,r)=>{var a=Ke(),o=O(a),s=e=>{F(e,{variant:`empty`,title:`Activate managed service first`,message:`Sentient Forms Managed Service needs an active subscription for this WordPress site. Direct OpenRouter remains available without Sentient Forms billing.`,actionLabel:`Open Managed Service`,onAction:()=>ie(`/licensing`),dense:!0,testId:`providers-managed-account-required`})},c=e=>{var r=Ve(),a=E(r),o=E(a),s=E(o);{let e=b(()=>Bt(w(Z).state));I(s,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>Vt(w(Z).state)]),i(e,n)},$$slots:{default:!0}})}var c=g(s,2),p=e=>{I(e,{variant:`neutral`,children:(e,t)=>{d();var n=S();_(()=>f(n,`Consent #${w(Z).consentId??``}`)),i(e,n)},$$slots:{default:!0}})};t(c,e=>{w(Z).consentId&&e(p)}),m(o);var y=g(o,2),x=E(y),C=e=>{i(e,S(`Sentient Forms Managed Service is allowed for this site`))},D=e=>{var n=u(),r=O(n),a=e=>{i(e,S(`Sentient Forms Managed Service is disabled locally`))},o=e=>{i(e,S(`Consent is required before Sentient Forms Managed Service can run`))};t(r,e=>{w(Z).state===`revoked`?e(a):e(o,!1)},!0),i(e,n)};t(x,e=>{w(Z).state===`accepted`?e(C):e(D,!1)}),m(y);var k=g(y,2),A=E(k),ee=e=>{i(e,S(`This WordPress site may send rendered prompts and required form fields through the
								Sentient Forms Managed Service. You can revoke this local consent without canceling
								or changing the Stripe subscription.`))},N=e=>{var n=u(),r=O(n),a=e=>{i(e,S(`New managed-service requests are blocked from this plugin until consent is enabled
								again. Revocation does not cancel or change the Stripe subscription.`))},o=e=>{i(e,S(`Enable managed service only when this site should use Sentient Forms billing and
								the central proxy for model runs.`))};t(r,e=>{w(Z).state===`revoked`?e(a):e(o,!1)},!0),i(e,n)};t(A,e=>{w(Z).state===`accepted`?e(ee):e(N,!1)}),m(k);var te=g(k,2),P=e=>{var t=Re(),n=E(t);m(t),_(e=>f(n,`Last changed ${e??``}.`),[()=>ae(Ht(w(Z)),`unknown`)]),i(e,t)};t(te,e=>{Ht(w(Z))&&e(P)});var F=g(te,2),ne=e=>{var t=ze();M(E(t),{variant:`danger`,get loading(){return w(gt)},get disabled(){return w(gt)},onclick:tn,"data-testid":`providers-managed-revoke-submit`,children:(e,t)=>{d();var n=S();_(()=>f(n,w(gt)?`Revoking...`:`Revoke managed-service consent`)),i(e,n)},$$slots:{default:!0}}),m(t),i(e,t)};t(F,e=>{w(Z).state===`accepted`&&e(ne)}),m(a);var re=g(a,2),L=e=>{var r=Be(),a=E(r);j(a,{id:`sentient-managed-label`,label:`Label`,placeholder:`Sentient Forms Managed Service`,get disabled(){return w(ht)},get value(){return w(dt)},set value(e){l(dt,e,!0)}});var o=g(a,2),s=E(o);n(s),d(2),m(o);var c=g(o,2);{let e=b(()=>!w(Lt));M(c,{type:`submit`,get loading(){return w(ht)},get disabled(){return w(e)},"data-testid":`providers-managed-setup-submit`,children:(e,n)=>{var r=u(),a=O(r),o=e=>{i(e,S(`Enabling...`))},s=e=>{var n=u(),r=O(n),a=e=>{i(e,S(`Re-enable managed service`))},o=e=>{i(e,S(`Enable managed service`))};t(r,e=>{w(Z).state===`revoked`?e(a):e(o,!1)},!0),i(e,n)};t(a,e=>{w(ht)?e(o):e(s,!1)}),i(e,r)},$$slots:{default:!0}})}m(r),_(()=>s.disabled=w(ht)),h(`submit`,r,en),T(s,()=>w(q),e=>l(q,e)),i(e,r)};t(re,e=>{w(Z).state!==`accepted`&&e(L)}),m(r),_(()=>v(a,1,`sf:rounded sf:border sf:p-4 ${w(Z).state===`accepted`?`sf:border-success-200 sf:bg-success-50`:w(Z).state===`revoked`?`sf:border-amber-200 sf:bg-amber-50`:`sf:border-slate-200 sf:bg-slate-50`}`)),i(e,r)};t(o,e=>{w(Q)?e(c,!1):e(s)});var p=g(o,2),y=e=>{var t=He(),n=E(t,!0);m(t),_(()=>f(n,w(G))),i(e,t)};t(p,e=>{w(G)&&e(y)});var x=g(p,2),C=e=>{var t=Ue(),n=E(t,!0);m(t),_(()=>f(n,w(it))),i(e,t)};t(x,e=>{w(it)&&e(C)});var D=g(x,2),k=e=>{var t=We(),n=E(t),r=E(n);{let e=b(()=>pe(w(V).status));I(r,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>R(w(V).status)]),i(e,n)},$$slots:{default:!0}})}var a=g(r,2),o=E(a);m(a),m(n);var s=g(n,2),c=E(s);m(s),m(t),_(()=>{f(o,`Consent #${w(V).consent_id??``} recorded.`),f(c,`Managed credential #${w(V).credential_id??``} is ready.`)}),i(e,t)};t(D,e=>{w(V)&&e(k)});var A=g(D,2),ee=e=>{var t=Ge(),n=E(t),r=E(n);I(r,{variant:`warning`,children:(e,t)=>{d(),i(e,S(`Consent revoked`))},$$slots:{default:!0}});var a=g(r,2),o=E(a);m(a),m(n),d(2),m(t),_(()=>f(o,`Consent #${w(rt).consent_id??``} recorded.`)),i(e,t)};t(A,e=>{w(rt)&&e(ee)}),i(e,a)},$$slots:{default:!0}})}N(g(L,2),{title:`Sentient Forms Managed Service credentials`,"data-testid":`providers-managed-list-card`,children:(n,r)=>{var a=u(),o=O(a),s=e=>{F(e,{variant:`loading`,title:`Loading managed service credentials`,dense:!0})},c=n=>{var r=u(),a=O(r),o=e=>{F(e,{variant:`empty`,title:`No managed service credential`,message:`Activate managed service, accept the disclosure, then enable the site credential.`,dense:!0})},s=n=>{var r=Ye();e(r,21,()=>w(wt),y,(e,n)=>{let r=b(()=>de(w(n))),a=b(()=>zt(w(n)));var o=Je(),s=E(o),c=E(s),l=E(c,!0);m(c);var u=g(c,2),p=E(u);{let e=b(()=>pe(w(n).status));I(p,{get variant(){return w(e)},children:(e,t)=>{d();var r=S();_(e=>f(r,e),[()=>R(w(n).status)]),i(e,r)},$$slots:{default:!0}})}var h=g(p,2);{let e=b(()=>Bt(w(a).state));I(h,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(e=>f(n,e),[()=>Vt(w(a).state)]),i(e,n)},$$slots:{default:!0}})}m(u),m(s);var y=g(s,2),x=E(y);m(y);var C=g(y,2),T=E(C);m(C);var D=g(C,2),O=e=>{var t=qe(),a=E(t,!0);m(t),_(e=>{v(t,1,e),f(a,w(r))},[()=>`sf:mt-2 sf:text-xs ${se(w(n))}`]),i(e,t)};t(D,e=>{w(r)&&e(O)}),m(o),_((e,t,r)=>{f(l,w(n).label),f(x,`${e??``} · ${t??``}`),f(T,`Last checked ${r??``}`)},[()=>oe(w(n)),()=>le(w(n)),()=>ae(w(n).last_validated_at,`never`)]),i(e,o)}),m(r),i(n,r)};t(a,e=>{w(wt).length===0?e(o):e(s,!1)},!0),i(n,r)};t(o,e=>{w(et)?e(s):e(c,!1)}),i(n,a)},$$slots:{default:!0}}),m(re),N(g(re,2),{title:`Action builder`,subtitle:`Create form-specific provider actions from the Actions screen.`,"data-testid":`providers-actions-builder-redirect-card`,children:(e,n)=>{var r=u(),a=O(r),o=e=>{F(e,{variant:`empty`,get title(){return w(jt)},get message(){return w(Mt)},dense:!0,testId:`providers-actions-builder-no-credential`})},s=e=>{var t=Xe(),n=E(t),r=E(n),a=E(r);I(a,{variant:`success`,children:(e,t)=>{d();var n=S();_(()=>f(n,`${w(Ct).length??``} ready key${w(Ct).length===1?``:`s`}`)),i(e,n)},$$slots:{default:!0}});var o=g(a,2);{let e=b(()=>w(Tt).length>0?`success`:`neutral`);I(o,{get variant(){return w(e)},children:(e,t)=>{d();var n=S();_(()=>f(n,`${w(Tt).length??``} managed ${w(Tt).length===1?`service credential`:`service credentials`}`)),i(e,n)},$$slots:{default:!0}})}I(g(o,2),{variant:`info`,children:(e,t)=>{d(),i(e,S(`Actions owns setup`))},$$slots:{default:!0}}),m(r),d(2),m(n),M(g(n,2),{onclick:()=>ie(`/actions`),"data-testid":`providers-open-actions`,children:(e,t)=>{d(),i(e,S(`Open Actions`))},$$slots:{default:!0}}),m(t),i(e,t)};t(a,e=>{w(kt).length===0?e(o):e(s,!1)}),i(e,r)},$$slots:{default:!0}}),i(r,o)},$$slots:{actions:!0,default:!0}}),o()}a([`change`]);export{z as component};