@inspectr/app 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -196,7 +196,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
196
196
  <line x1="6" x2="6.01" y1="6" y2="6" />
197
197
  <line x1="6" x2="6.01" y1="18" y2="18" />
198
198
  </svg>
199
- `,Pye={resource:Sye,tool:Oye,prompt:Cye,system:Aye},Tye=(e="")=>{const t=e.toLowerCase();return t.includes("resource")?"resource":t.includes("tool")?"tool":t.includes("prompt")?"prompt":t.includes("system")?"system":null},tD={slate:{root:"bg-slate-500/10 text-slate-700 ring-slate-500/20 dark:bg-slate-500/5 dark:text-slate-200 dark:ring-slate-500/60"},gray:{root:"bg-gray-500/10 text-gray-700 ring-gray-500/20 dark:bg-gray-500/5 dark:text-gray-200 dark:ring-gray-500/60"},zinc:{root:"bg-zinc-500/10 text-zinc-700 ring-zinc-500/20 dark:bg-zinc-500/5 dark:text-zinc-200 dark:ring-zinc-500/60"},neutral:{root:"bg-neutral-500/10 text-neutral-700 ring-neutral-500/20 dark:bg-neutral-500/5 dark:text-neutral-200 dark:ring-neutral-500/60"},stone:{root:"bg-stone-500/10 text-stone-700 ring-stone-500/20 dark:bg-stone-500/5 dark:text-stone-200 dark:ring-stone-500/60"},red:{root:"bg-red-500/10 text-red-700 ring-red-500/20 dark:bg-red-500/5 dark:text-red-200 dark:ring-red-500/60"},orange:{root:"bg-orange-500/10 text-orange-700 ring-orange-500/20 dark:bg-orange-500/5 dark:text-orange-200 dark:ring-orange-500/60"},amber:{root:"bg-amber-500/10 text-amber-700 ring-amber-500/20 dark:bg-amber-500/5 dark:text-amber-200 dark:ring-amber-500/60"},yellow:{root:"bg-yellow-500/10 text-yellow-700 ring-yellow-500/20 dark:bg-yellow-500/5 dark:text-yellow-200 dark:ring-yellow-500/60"},lime:{root:"bg-lime-500/10 text-lime-700 ring-lime-500/20 dark:bg-lime-500/5 dark:text-lime-200 dark:ring-lime-500/60"},green:{root:"bg-green-500/10 text-green-700 ring-green-500/20 dark:bg-green-500/5 dark:text-green-200 dark:ring-green-500/60"},emerald:{root:"bg-emerald-500/10 text-emerald-700 ring-emerald-500/20 dark:bg-emerald-500/5 dark:text-emerald-200 dark:ring-emerald-500/60"},teal:{root:"bg-teal-500/10 text-teal-700 ring-teal-500/20 dark:bg-teal-500/5 dark:text-teal-200 dark:ring-teal-500/60"},cyan:{root:"bg-cyan-500/10 text-cyan-700 ring-cyan-500/20 dark:bg-cyan-500/5 dark:text-cyan-200 dark:ring-cyan-500/60"},sky:{root:"bg-sky-500/10 text-sky-700 ring-sky-500/20 dark:bg-sky-500/5 dark:text-sky-200 dark:ring-sky-500/60"},blue:{root:"bg-blue-500/10 text-blue-700 ring-blue-500/20 dark:bg-blue-500/5 dark:text-blue-200 dark:ring-blue-500/60"},indigo:{root:"bg-indigo-500/10 text-indigo-700 ring-indigo-500/20 dark:bg-indigo-500/5 dark:text-indigo-200 dark:ring-indigo-500/60"},violet:{root:"bg-violet-500/10 text-violet-700 ring-violet-500/20 dark:bg-violet-500/5 dark:text-violet-200 dark:ring-violet-500/60"},purple:{root:"bg-purple-500/10 text-purple-700 ring-purple-500/20 dark:bg-purple-500/5 dark:text-purple-200 dark:ring-purple-500/60"},fuchsia:{root:"bg-fuchsia-500/10 text-fuchsia-700 ring-fuchsia-500/20 dark:bg-fuchsia-500/5 dark:text-fuchsia-200 dark:ring-fuchsia-500/60"},pink:{root:"bg-pink-500/10 text-pink-700 ring-pink-500/20 dark:bg-pink-500/5 dark:text-pink-200 dark:ring-pink-500/60"},rose:{root:"bg-rose-500/10 text-rose-700 ring-rose-500/20 dark:bg-rose-500/5 dark:text-rose-200 dark:ring-rose-500/60"}},MP={xs:"h-[22px] px-2 py-0.5 text-xs",sm:"h-6 px-2.5 py-0.5 text-sm"},Mye=e=>{if(!e)return"blue";const t=String(e).toLowerCase();return tD[t]?t:"blue"},Zl=({method:e,children:t,color:r,size:n="xs",showIcon:o=!0})=>{const a=r||ZL(e),i=Tye(e),s=o?Pye[i]:null,c=s?s.replace("<svg",'<svg class="h-full w-full block"'):null,u=Mye(a),d=tD[u].root,f=MP[n]||MP.xs;return l.jsx("span",{className:`w-max shrink-0 inline-flex items-center justify-center cursor-default rounded-tremor-small ring-1 ring-inset ${f} ${d}`,children:l.jsxs("span",{className:"inline-flex items-center gap-1 leading-none",children:[c?l.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center leading-none","aria-hidden":"true",dangerouslySetInnerHTML:{__html:c}}):null,l.jsx("span",{className:"leading-none",children:t})]})})},Om=(e,t,r="slate")=>e?l.jsx(Lt,{color:r,size:"xs",children:t}):null,rD=({tool:e})=>{var t,r,n,o,a,i,s,c;const{total:u,required:d}=jye(e.inputSchema),f=Object.entries(((t=e.inputSchema)==null?void 0:t.properties)||{}),h=new Set(((r=e.inputSchema)==null?void 0:r.required)||[]);return l.jsxs(Mt,{className:"space-y-2 rounded-tremor-small border border-tremor-border p-3 shadow-sm dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx(pt,{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e.title||((n=e.annotations)==null?void 0:n.title)||e.name}),e.description?l.jsx(pt,{className:"mt-0.5 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:e.description}):null]}),l.jsxs("div",{className:"flex flex-wrap gap-1 text-[11px]",children:[Om((o=e.annotations)==null?void 0:o.readOnlyHint,"Read-only","blue"),Om(((a=e.annotations)==null?void 0:a.destructiveHint)&&!((i=e.annotations)!=null&&i.readOnlyHint),"Destructive","rose"),Om((s=e.annotations)==null?void 0:s.idempotentHint,"Idempotent","emerald"),Om((c=e.annotations)==null?void 0:c.openWorldHint,"Open world","amber"),u?l.jsxs(Lt,{color:"slate",size:"xs",children:[u," params",d?` (${d} required)`:""]}):l.jsx(Lt,{color:"slate",size:"xs",children:"No params"})]})]}),f.length?l.jsx("div",{className:"space-y-1",children:f.map(([m,g])=>l.jsxs("div",{className:"flex items-start gap-2 rounded-tremor-small bg-tremor-background-subtle px-2 py-1 dark:bg-dark-tremor-background-subtle",children:[l.jsx("div",{className:"font-mono text-xs text-tremor-content-strong dark:text-dark-tremor-content-strong",children:m}),l.jsxs("div",{className:"flex-1 text-[11px] text-tremor-content dark:text-dark-tremor-content",children:[g!=null&&g.type?`${g.type}`:"any",g!=null&&g.description?` — ${g.description}`:""]}),h.has(m)?l.jsx(Lt,{color:"rose",size:"xs",children:"required"}):null]},m))}):null]})},_ye=e=>{if(!e)return null;const t=e.split(`
199
+ `,Pye={resource:Sye,tool:Oye,prompt:Cye,system:Aye},Tye=(e="")=>{const t=e.toLowerCase();return t.includes("resource")?"resource":t.includes("tool")?"tool":t.includes("prompt")?"prompt":t.includes("system")?"system":null},tD={slate:{root:"bg-slate-500/10 text-slate-700 ring-slate-500/20 dark:bg-slate-500/5 dark:text-slate-200 dark:ring-slate-500/60"},gray:{root:"bg-gray-500/10 text-gray-700 ring-gray-500/20 dark:bg-gray-500/5 dark:text-gray-200 dark:ring-gray-500/60"},zinc:{root:"bg-zinc-500/10 text-zinc-700 ring-zinc-500/20 dark:bg-zinc-500/5 dark:text-zinc-200 dark:ring-zinc-500/60"},neutral:{root:"bg-neutral-500/10 text-neutral-700 ring-neutral-500/20 dark:bg-neutral-500/5 dark:text-neutral-200 dark:ring-neutral-500/60"},stone:{root:"bg-stone-500/10 text-stone-700 ring-stone-500/20 dark:bg-stone-500/5 dark:text-stone-200 dark:ring-stone-500/60"},red:{root:"bg-red-500/10 text-red-700 ring-red-500/20 dark:bg-red-500/5 dark:text-red-200 dark:ring-red-500/60"},orange:{root:"bg-orange-500/10 text-orange-700 ring-orange-500/20 dark:bg-orange-500/5 dark:text-orange-200 dark:ring-orange-500/60"},amber:{root:"bg-amber-500/10 text-amber-700 ring-amber-500/20 dark:bg-amber-500/5 dark:text-amber-200 dark:ring-amber-500/60"},yellow:{root:"bg-yellow-500/10 text-yellow-700 ring-yellow-500/20 dark:bg-yellow-500/5 dark:text-yellow-200 dark:ring-yellow-500/60"},lime:{root:"bg-lime-500/10 text-lime-700 ring-lime-500/20 dark:bg-lime-500/5 dark:text-lime-200 dark:ring-lime-500/60"},green:{root:"bg-green-500/10 text-green-700 ring-green-500/20 dark:bg-green-500/5 dark:text-green-200 dark:ring-green-500/60"},emerald:{root:"bg-emerald-500/10 text-emerald-700 ring-emerald-500/20 dark:bg-emerald-500/5 dark:text-emerald-200 dark:ring-emerald-500/60"},teal:{root:"bg-teal-500/10 text-teal-700 ring-teal-500/20 dark:bg-teal-500/5 dark:text-teal-200 dark:ring-teal-500/60"},cyan:{root:"bg-cyan-500/10 text-cyan-700 ring-cyan-500/20 dark:bg-cyan-500/5 dark:text-cyan-200 dark:ring-cyan-500/60"},sky:{root:"bg-sky-500/10 text-sky-700 ring-sky-500/20 dark:bg-sky-500/5 dark:text-sky-200 dark:ring-sky-500/60"},blue:{root:"bg-blue-500/10 text-blue-700 ring-blue-500/20 dark:bg-blue-500/5 dark:text-blue-200 dark:ring-blue-500/60"},indigo:{root:"bg-indigo-500/10 text-indigo-700 ring-indigo-500/20 dark:bg-indigo-500/5 dark:text-indigo-200 dark:ring-indigo-500/60"},violet:{root:"bg-violet-500/10 text-violet-700 ring-violet-500/20 dark:bg-violet-500/5 dark:text-violet-200 dark:ring-violet-500/60"},purple:{root:"bg-purple-500/10 text-purple-700 ring-purple-500/20 dark:bg-purple-500/5 dark:text-purple-200 dark:ring-purple-500/60"},fuchsia:{root:"bg-fuchsia-500/10 text-fuchsia-700 ring-fuchsia-500/20 dark:bg-fuchsia-500/5 dark:text-fuchsia-200 dark:ring-fuchsia-500/60"},pink:{root:"bg-pink-500/10 text-pink-700 ring-pink-500/20 dark:bg-pink-500/5 dark:text-pink-200 dark:ring-pink-500/60"},rose:{root:"bg-rose-500/10 text-rose-700 ring-rose-500/20 dark:bg-rose-500/5 dark:text-rose-200 dark:ring-rose-500/60"}},MP={xs:"h-[22px] px-2 py-0.5 text-xs",sm:"h-6 px-2.5 py-0.5 text-sm"},Mye=e=>{if(!e)return"blue";const t=String(e).toLowerCase();return tD[t]?t:"blue"},Zl=({method:e,children:t,color:r,size:n="xs",showIcon:o=!0,copyText:a})=>{const i=r||ZL(e),s=Tye(e),c=o?Pye[s]:null,u=c?c.replace("<svg",'<svg class="h-full w-full block"'):null,d=Mye(i),f=tD[d].root,h=MP[n]||MP.xs,m=a??(typeof t=="string"||typeof t=="number"?String(t):typeof e=="string"?e:""),g=b=>{var v;b.stopPropagation(),m&&(v=navigator?.clipboard)!=null&&v.writeText&&navigator.clipboard.writeText(m).catch(()=>{})};return l.jsx("span",{className:`w-max shrink-0 inline-flex items-center justify-center cursor-pointer rounded-tremor-small ring-1 ring-inset ${h} ${f}`,onClick:g,children:l.jsxs("span",{className:"inline-flex items-center gap-1 leading-none",children:[u?l.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center leading-none","aria-hidden":"true",dangerouslySetInnerHTML:{__html:u}}):null,l.jsx("span",{className:"leading-none",children:t})]})})},Om=(e,t,r="slate")=>e?l.jsx(Lt,{color:r,size:"xs",children:t}):null,rD=({tool:e})=>{var t,r,n,o,a,i,s,c;const{total:u,required:d}=jye(e.inputSchema),f=Object.entries(((t=e.inputSchema)==null?void 0:t.properties)||{}),h=new Set(((r=e.inputSchema)==null?void 0:r.required)||[]);return l.jsxs(Mt,{className:"space-y-2 rounded-tremor-small border border-tremor-border p-3 shadow-sm dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx(pt,{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e.title||((n=e.annotations)==null?void 0:n.title)||e.name}),e.description?l.jsx(pt,{className:"mt-0.5 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:e.description}):null]}),l.jsxs("div",{className:"flex flex-wrap gap-1 text-[11px]",children:[Om((o=e.annotations)==null?void 0:o.readOnlyHint,"Read-only","blue"),Om(((a=e.annotations)==null?void 0:a.destructiveHint)&&!((i=e.annotations)!=null&&i.readOnlyHint),"Destructive","rose"),Om((s=e.annotations)==null?void 0:s.idempotentHint,"Idempotent","emerald"),Om((c=e.annotations)==null?void 0:c.openWorldHint,"Open world","amber"),u?l.jsxs(Lt,{color:"slate",size:"xs",children:[u," params",d?` (${d} required)`:""]}):l.jsx(Lt,{color:"slate",size:"xs",children:"No params"})]})]}),f.length?l.jsx("div",{className:"space-y-1",children:f.map(([m,g])=>l.jsxs("div",{className:"flex items-start gap-2 rounded-tremor-small bg-tremor-background-subtle px-2 py-1 dark:bg-dark-tremor-background-subtle",children:[l.jsx("div",{className:"font-mono text-xs text-tremor-content-strong dark:text-dark-tremor-content-strong",children:m}),l.jsxs("div",{className:"flex-1 text-[11px] text-tremor-content dark:text-dark-tremor-content",children:[g!=null&&g.type?`${g.type}`:"any",g!=null&&g.description?` — ${g.description}`:""]}),h.has(m)?l.jsx(Lt,{color:"rose",size:"xs",children:"required"}):null]},m))}):null]})},_ye=e=>{if(!e)return null;const t=e.split(`
200
200
  `),r=[];let n=[];const o=()=>{n.length&&(r.push(l.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm",children:n.map((a,i)=>l.jsx("li",{children:a},i))},`list-${r.length}`)),n=[])};return t.forEach(a=>{var i,s;const c=a.trim();if(!c){o();return}if(c.startsWith("#")){o();const u=Math.min(((s=(i=c.match(/^#+/))==null?void 0:i[0])==null?void 0:s.length)||1,6),d=c.replace(/^#+\s*/,"")||c;r.push(l.jsx("div",{className:`font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong ${u<=2?"text-base":"text-sm"}`,children:d},`h-${r.length}`));return}if(c.startsWith("- ")||c.startsWith("* ")){n.push(c.slice(2));return}o(),r.push(l.jsx("p",{className:"text-sm",children:c},`p-${r.length}`))}),o(),l.jsx("div",{className:"space-y-1 text-tremor-content dark:text-dark-tremor-content",children:r})},Iye=e=>{if(typeof window>"u"||typeof DOMParser>"u")return e||"";try{return new DOMParser().parseFromString(e||"","text/html").body.textContent||e||""}catch{return e||""}},nD=({resource:e,mimeType:t,editorOptions:r})=>typeof e?.text=="string"?l.jsxs(l.Fragment,{children:[(t||"").includes("markdown")?l.jsx("div",{className:"rounded-tremor-small border border-slate-200 bg-tremor-background-subtle p-3 text-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:_ye(e.text)||l.jsx("div",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Unable to render markdown preview."})}):null,(t||"").includes("html")?l.jsxs("div",{className:"rounded-tremor-small border border-slate-200 bg-tremor-background-subtle p-3 text-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsx(pt,{className:"text-xs font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:"HTML (text-only preview)"}),l.jsx("p",{className:"mt-1 text-sm text-tremor-content dark:text-dark-tremor-content",children:Iye(e.text)})]}):null,l.jsx(Qa,{value:e.text,language:Eye(t),theme:ti(),beforeMount:ei,options:r,height:"240px"})]}):l.jsx(za,{data:e}),Iu=({annotations:e})=>{if(!e||typeof e!="object")return null;const{audience:t,priority:r,lastModified:n}=e,o=[];return Array.isArray(t)&&t.length&&o.push(l.jsxs(Lt,{color:"slate",size:"xs",children:["audience: ",t.join(", ")]},"audience")),r!==void 0&&o.push(l.jsxs(Lt,{color:"slate",size:"xs",children:["priority: ",r]},"priority")),n&&o.push(l.jsxs(Lt,{color:"slate",size:"xs",children:["modified: ",n]},"lastModified")),o.length?l.jsx("div",{className:"flex flex-wrap gap-2",children:o}):null},_P=(e,t)=>t?`data:${e||"application/octet-stream"};base64,${t}`:"",Lye=({item:e,index:t})=>{const r=`Item ${t+1}`;switch(e?.type){case"text":return l.jsxs("div",{className:"space-y-1 rounded-tremor-small border border-slate-200 bg-white p-3 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:[r," · Text"]}),l.jsx(Iu,{annotations:e.annotations})]}),l.jsx("pre",{className:"whitespace-pre-wrap break-words text-xs text-slate-700 dark:text-dark-tremor-content",children:e.text||"[empty text]"})]});case"image":return l.jsxs("div",{className:"space-y-2 rounded-tremor-small border border-slate-200 bg-white p-3 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:[r," · Image"]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.mimeType?l.jsx(Lt,{color:"slate",size:"xs",children:e.mimeType}):null,l.jsx(Iu,{annotations:e.annotations})]})]}),e.data?l.jsx("img",{src:_P(e.mimeType,e.data),alt:e.description||"MCP image content",className:"max-h-64 w-auto rounded"}):l.jsx("div",{className:"text-sm text-slate-600 dark:text-dark-tremor-content",children:"No image data provided."})]});case"audio":return l.jsxs("div",{className:"space-y-1 rounded-tremor-small border border-slate-200 bg-white p-3 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:[r," · Audio"]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.mimeType?l.jsx(Lt,{color:"slate",size:"xs",children:e.mimeType}):null,l.jsx(Iu,{annotations:e.annotations})]})]}),e.data?l.jsxs("audio",{controls:!0,className:"w-full",children:[l.jsx("source",{src:_P(e.mimeType,e.data),type:e.mimeType||"audio/wav"}),"Your browser does not support the audio element."]}):l.jsx("div",{className:"text-sm text-slate-600 dark:text-dark-tremor-content",children:"No audio data provided."})]});case"resource_link":return l.jsxs("div",{className:"space-y-1 rounded-tremor-small border border-slate-200 bg-white p-3 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:[r," · Resource link"]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.mimeType?l.jsx(Lt,{color:"slate",size:"xs",children:e.mimeType}):null,l.jsx(Iu,{annotations:e.annotations})]})]}),l.jsxs("div",{className:"space-y-1 text-sm text-slate-800 dark:text-dark-tremor-content",children:[l.jsx("div",{className:"font-semibold",children:e.name||e.title||"Unnamed resource"}),l.jsx("div",{className:"break-all text-xs text-slate-600 dark:text-dark-tremor-content",children:e.uri||"No URI"}),e.description?l.jsx("div",{className:"text-sm text-slate-700 dark:text-dark-tremor-content",children:e.description}):null]})]});case"resource":{const n=e.resource||e;return l.jsxs("div",{className:"space-y-2 rounded-tremor-small border border-slate-200 bg-white p-3 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:[r," · Resource"]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.mimeType?l.jsx(Lt,{color:"slate",size:"xs",children:n.mimeType}):null,l.jsx(Iu,{annotations:n.annotations||e.annotations})]})]}),l.jsx(nD,{resource:n,mimeType:n.mimeType})]})}default:return l.jsx(za,{data:e,title:`${r} · ${e?.type||"Unknown type"}`,copyText:JSON.stringify(e,null,2)})}},oD=({items:e=[]})=>!Array.isArray(e)||!e.length?l.jsx("div",{className:"text-sm text-slate-500 dark:text-dark-tremor-content",children:"No content items returned."}):l.jsx("div",{className:"space-y-2",children:e.map((t,r)=>l.jsx(Lye,{item:t,index:r},r))}),Dye=({label:e,value:t})=>l.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium text-slate-800 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content-strong",children:[l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:e}),l.jsx("span",{className:"font-mono text-sm",children:t??"—"})]}),Rye=({tokens:e,title:t="MCP Tokens",defaultOpen:r=!0})=>{const[n,o]=p.useState(r),a=p.useMemo(()=>[{label:"Request",value:e?.request},{label:"Response",value:e?.response},{label:"Total",value:e?.total}].filter(i=>i.value!==void 0),[e]);return e?l.jsx(eo,{title:t,defaultOpen:r,onToggle:o,className:"rounded-lg border border-slate-200 bg-white shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",withBorderTop:!1,children:n?l.jsx("div",{className:"grid grid-cols-2 gap-3 p-2 sm:grid-cols-3",children:a.length>0?a.map(i=>l.jsx(Dye,{label:i.label,value:i.value},i.label)):l.jsx("div",{className:"text-sm text-slate-500 dark:text-dark-tremor-content",children:"No token counts"})}):null}):null},Fye=({open:e,className:t=""})=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:`h-4 w-4 text-tremor-content transition-transform dark:text-dark-tremor-content ${e?"rotate-180":"rotate-0"} ${t}`,"aria-hidden":"true",children:l.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.084l3.71-3.854a.75.75 0 0 1 1.08 1.04l-4.25 4.417a.75.75 0 0 1-1.08 0L5.21 8.27a.75.75 0 0 1 .02-1.06z",clipRule:"evenodd"})}),$ye=({operation:e})=>{var t,r,n,o,a,i,s,c,u,d,f,h,m,g,b;const v=((t=e?.meta)==null?void 0:t.mcp)||((n=(r=e?.raw)==null?void 0:r.meta)==null?void 0:n.mcp)||((a=(o=e?.meta)==null?void 0:o.trace)==null?void 0:a.mcp)||((c=(s=(i=e?.raw)==null?void 0:i.meta)==null?void 0:s.trace)==null?void 0:c.mcp);if(!(v&&typeof v=="object"&&Object.keys(v).filter(q=>v[q]!==void 0).length))return l.jsx("div",{className:"text-sm text-gray-500 dark:text-dark-tremor-content",children:"No MCP metadata"});const x=v.tokens,w=Number(e?.status)>=400;ZL(v?.method);const E=typeof((u=e?.request)==null?void 0:u.body)=="string"?e.request.body:(d=e?.request)!=null&&d.body?JSON.stringify(e.request.body):"",j=typeof((f=e?.response)==null?void 0:f.body)=="string"?e.response.body:(h=e?.response)!=null&&h.body?JSON.stringify(e.response.body):"",S=eD((m=e?.response)==null?void 0:m.event_frames),C=j||S||"",O=mh(E),T=mh(C),P=!!((g=O?.params)!=null&&g.arguments&&Object.keys(O.params.arguments).length),[M,D]=p.useState("structured"),R=v?.method||O?.method,F=p.useMemo(()=>QL(R,T),[R,T]),_=p.useMemo(()=>!!F.structuredContent,[F.structuredContent]),L=p.useMemo(()=>Array.isArray(F.content)&&F.content.length,[F.content]),[V,$]=p.useState({mcp:!0}),B=q=>{$(W=>({...W,[q]:!W[q]}))},z=p.useMemo(()=>{const q=[];return _&&q.push({key:"structured",label:"Structured content"}),L&&q.push({key:"content",label:"Content items"}),q.push({key:"raw",label:"Raw content"}),q},[_,L]);return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-2 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("h3",{className:"text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong",children:"MCP"}),l.jsx(Lt,{color:w?"rose":"emerald",size:"xs",children:w?"Error":"Success"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(v9,{mcp:v}),l.jsx("button",{type:"button",onClick:()=>B("mcp"),"aria-label":V.mcp?"Collapse MCP section":"Expand MCP section",children:l.jsx(Fye,{open:V.mcp})})]})]}),V.mcp?l.jsxs("div",{className:"mt-1 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[l.jsxs("div",{className:"rounded border border-slate-200 bg-white px-3 py-2 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsx("div",{className:"text-[11px] uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:v.category??"Name"}),l.jsx("div",{className:"mt-1 text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong break-all",children:l.jsx(Zl,{method:v.method??"",children:v.name??"—"})})]}),l.jsxs("div",{className:"rounded border border-slate-200 bg-white px-3 py-2 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsx("div",{className:"text-[11px] uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:"Method"}),l.jsx("div",{className:"mt-1 text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong break-all",children:l.jsx(Zl,{method:v.method??"",children:v.method??"—"})})]}),l.jsxs("div",{className:"rounded border border-slate-200 bg-white px-3 py-2 shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsx("div",{className:"text-[11px] uppercase tracking-wide text-slate-500 dark:text-dark-tremor-content",children:"Category"}),l.jsx("div",{className:"mt-1 text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong break-all",children:l.jsx(Zl,{color:"slate",children:v.category??"—"})})]})]}):null]}),x?l.jsx(Rye,{tokens:x}):null,O||T?l.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[P?l.jsx(Hm,{children:l.jsx(JL,{args:O.params.arguments})}):null,l.jsx(zm,{children:T?F.type==="toolsList"&&(b=F.tools)!=null&&b.length?l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("h4",{className:"text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong",children:["Tools (",F.tools.length,")"]})}),l.jsx("div",{className:"space-y-2",children:F.tools.map(q=>l.jsx(rD,{tool:q},q.name))})]}):F.type==="promptsList"&&F.prompts?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong",children:["Prompts (",F.prompts.length,")"]}),l.jsx("div",{className:"space-y-2",children:F.prompts.map(q=>{const W=q.arguments||[],J=W.filter(Y=>Y.required).length;return l.jsxs("div",{className:"space-y-1 rounded border border-slate-200 bg-white p-3 text-sm shadow-sm dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"font-semibold text-slate-800 dark:text-dark-tremor-content-strong",children:q.title||q.name}),q.description?l.jsx("div",{className:"text-xs text-slate-600 dark:text-dark-tremor-content",children:q.description}):null]}),l.jsxs(Lt,{color:"slate",size:"xs",children:[W.length," args",J?` (${J} required)`:""]})]}),W.length?l.jsx("div",{className:"space-y-1",children:W.map(Y=>l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx("span",{className:"font-mono text-slate-700 dark:text-dark-tremor-content-strong",children:Y.name}),l.jsx("span",{className:"flex-1 text-slate-700 dark:text-dark-tremor-content",children:Y.description||"No description"}),Y.required?l.jsx(Lt,{color:"rose",size:"xs",children:"required"}):null]},Y.name))}):null]},q.name)})})]}):F.type==="resourcesList"&&F.resources?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-semibold text-slate-800 dark:text-dark-tremor-content-strong",children:["Resources (",F.resources.length,")"]}),l.jsx("div",{className:"divide-y divide-slate-200 text-sm dark:divide-dark-tremor-border",children:F.resources.map(q=>l.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"font-semibold text-slate-800 dark:text-dark-tremor-content-strong",children:q.title||q.name||q.uri}),l.jsx("div",{className:"text-xs text-slate-600 dark:text-dark-tremor-content",children:q.uri}),q.description?l.jsx("div",{className:"text-xs text-slate-700 dark:text-dark-tremor-content",children:q.description}):null]}),q.mimeType?l.jsx(Lt,{color:"slate",size:"xs",children:q.mimeType}):null,q.size?l.jsx(Lt,{color:"slate",size:"xs",children:`${(q.size/1024).toFixed(1)} KB`}):null]},q.uri))})]}):F.type==="structured"||F.type==="content"||L?(()=>{var q;const W=((q=z.find(Y=>Y.key===M))==null?void 0:q.key)||z[0].key,J=z.findIndex(Y=>Y.key===W);return l.jsxs(Rc,{index:J,onIndexChange:Y=>{var ne;return D(((ne=z[Y])==null?void 0:ne.key)||"raw")},children:[l.jsx(Dc,{children:z.map(Y=>l.jsx(to,{children:Y.label},Y.key))}),l.jsx(Fc,{children:z.map(Y=>l.jsxs(ro,{children:[Y.key==="structured"?l.jsx(za,{data:F.structuredContent,title:"Structured content"}):null,Y.key==="content"?l.jsx(za,{data:F.content,title:"Content items",copyText:JSON.stringify(F.content,null,2),children:l.jsx(oD,{items:F.content})}):null,Y.key==="raw"?l.jsx(za,{data:F.raw,title:"Raw Output"}):null]},Y.key))})]})})():l.jsx(za,{data:F.raw}):l.jsx("div",{className:"text-sm text-slate-500 dark:text-dark-tremor-content",children:"No MCP output"})})]}):null]})},Bye=({endpoint:e,command:t,prompt:r="computer:~$",showCopyButton:n=!1,showCopyLabel:o=!1,copyLabelText:a="Copy",copiedText:i="Copied"})=>{const s=t||`curl -X GET ${e||"http://localhost:8080"}`;return l.jsx("div",{className:"w-full mt-6 max-w-xl mx-auto",children:l.jsxs("div",{className:`coding inverse-toggle px-5 pt-4 shadow-lg text-gray-100 text-sm font-mono subpixel-antialiased
201
201
  bg-gray-800 pb-6 pt-4 rounded-lg leading-normal overflow-hidden`,children:[l.jsxs("div",{className:"top mb-2 flex justify-between",children:[l.jsxs("div",{className:"flex",children:[l.jsx("div",{className:"h-3 w-3 bg-red-500 rounded-full"}),l.jsx("div",{className:"ml-2 h-3 w-3 bg-orange-300 rounded-full"}),l.jsx("div",{className:"ml-2 h-3 w-3 bg-green-500 rounded-full"})]}),n&&l.jsx(on,{textToCopy:s})]}),l.jsxs("div",{className:"mt-4 flex",children:[l.jsx("span",{className:"text-green-400",children:r}),l.jsxs("p",{className:"flex-1 typing items-start pl-2",children:[s,l.jsx("br",{})]})]})]})})},pw={opacity:1,visibility:"visible",transition:"opacity 0.3s ease-in-out, visibility 0.3s ease-in-out"},hw={opacity:0,visibility:"hidden",transition:"opacity 0.3s ease-in-out, visibility 0.3s ease-in-out"},Hye=({operation:e,currentTab:t,setCurrentTab:r})=>{var n,o,a,i,s,c;const[u,d]=Rr("ingressEndpoint",""),[f,h]=Rr("proxyEndpoint",""),[m]=Rr("expose","false"),g=m==="true",[b,v]=p.useState(!1),x=T=>T?Array.isArray(T)?T:Object.entries(T).map(([P,M])=>({name:P,value:M})):[],w=x((o=(n=e?.meta)==null?void 0:n.inspectr)==null?void 0:o.guard),E=x((i=(a=e?.meta)==null?void 0:a.inspectr)==null?void 0:i.directives),j=w.length>0||E.length>0,S=((s=e?.meta)==null?void 0:s.mcp)||null,C=!!(S&&typeof S=="object"&&Object.keys(S).some(T=>S[T]!==void 0)),O=Array.isArray((c=e?.meta)==null?void 0:c.tags)&&e.meta.tags.length>0?"calc(100vh - 270px - 64px - 48px)":"calc(100vh - 270px - 64px)";return p.useEffect(()=>{!j&&t==="meta"&&r("request")},[j,t,r]),p.useEffect(()=>{!C&&t==="mcp"&&r("request")},[C,t,r]),p.useEffect(()=>{const T=setTimeout(()=>{v(!0)},100);return()=>clearTimeout(T)},[]),e?l.jsxs("div",{className:"flex flex-col h-full min-h-0",style:b?pw:hw,children:[l.jsx(LW,{operation:e,setCurrentTab:r}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx("button",{className:`px-4 py-1 text-base rounded-t ${t==="request"?"bg-blue-600 dark:bg-blue-700 text-white":"bg-gray-200 dark:bg-dark-tremor-background-subtle text-gray-700 dark:text-dark-tremor-content"}`,onClick:()=>r("request"),children:"Request"}),l.jsx("button",{className:`px-4 py-1 text-base rounded-t ${t==="response"?"bg-blue-600 dark:bg-blue-700 text-white":"bg-gray-200 dark:bg-dark-tremor-background-subtle text-gray-700 dark:text-dark-tremor-content"}`,onClick:()=>r("response"),children:"Response"}),j&&l.jsx("button",{className:`px-4 py-1 text-base rounded-t ${t==="meta"?"bg-teal-600 dark:bg-teal-700 text-white":"bg-gray-200 dark:bg-dark-tremor-background-subtle text-gray-700 dark:text-dark-tremor-content"}`,onClick:()=>r("meta"),children:"Info"}),C&&l.jsx("button",{className:`px-4 py-1 text-base rounded-t ${t==="mcp"?"bg-sky-500 dark:bg-sky-800 text-white":"bg-gray-200 dark:bg-dark-tremor-background-subtle text-gray-700 dark:text-dark-tremor-content"}`,onClick:()=>r("mcp"),children:"MCP"})]}),l.jsx("div",{className:"p-4 bg-white dark:bg-dark-tremor-background border border-gray-300 dark:border-dark-tremor-border rounded-b shadow dark:shadow-dark-tremor-shadow flex-1 min-h-0 overflow-y-auto",style:{...b?pw:hw,maxHeight:O},children:t==="request"?l.jsx(qq,{operation:e}):t==="response"?l.jsx(Jq,{operation:e}):t==="meta"&&j?l.jsx(Zq,{operation:e}):t==="mcp"?l.jsx($ye,{operation:e}):null})]}):l.jsx("div",{className:"h-96 min-h-full mb-20 flex flex-1 flex-col justify-center rounded-tremor-default border border-tremor-border bg-tremor-background-muted px-6 py-10 dark:border-dark-tremor-border dark:bg-dark-tremor-background-muted",style:b?pw:hw,children:l.jsxs("div",{className:"mx-auto text-center",children:[l.jsx("h4",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong font-[Inter] font-sans",children:"Request Inspectr"}),l.jsx("p",{className:"mt-3 max-w-xl text-tremor-default leading-6 text-tremor-content dark:text-dark-tremor-content sm:text-base",children:"Select a request from the list to view its details"}),l.jsxs("p",{className:"max-w-xl text-tremor-default leading-6 text-tremor-content dark:text-dark-tremor-content sm:text-base",children:["or get started by making a request to"," ",g?u?`"${u}"`:"the ingress endpoint":f?`"${f}"`:"the proxy endpoint","."]}),l.jsx(Bye,{endpoint:g?u:f,showCopyButton:!0}),l.jsxs("div",{className:"mt-8 sm:flex sm:items-center sm:justify-center sm:gap-x-3",children:[l.jsx("a",{href:"https://inspectr.dev/docs",target:"_blank",className:"w-full whitespace-nowrap rounded-tremor-small bg-tremor-brand px-4 py-2 text-tremor-default font-medium text-tremor-brand-inverted shadow-tremor-input hover:bg-tremor-brand-emphasis dark:bg-dark-tremor-brand dark:text-dark-tremor-brand-inverted dark:shadow-dark-tremor-input dark:hover:bg-dark-tremor-brand-emphasis sm:w-fit",children:"View Documentation"}),l.jsxs("a",{href:"https://inspectr.dev",target:"_blank",className:"mt-2 inline-flex w-full items-center justify-center gap-1.5 whitespace-nowrap rounded-tremor-small border border-tremor-border bg-tremor-background px-3 py-2 text-tremor-default font-medium text-tremor-brand shadow-tremor-input hover:text-tremor-brand-emphasis dark:border-dark-tremor-border dark:bg-dark-tremor-background dark:text-dark-tremor-brand dark:shadow-dark-tremor-input hover:dark:text-dark-tremor-brand-emphasis sm:mt-0 sm:w-fit",children:["Visit Website",l.jsx(fR,{className:"size-5 shrink-0","aria-hidden":!0})]})]})]})})},zye="data:image/svg+xml,%3csvg%20class='inline-block'%20width='24'%20height='24'%20viewBox='0%200%201648%201648'%20xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3clinearGradient%20id='grad-r4R0»'%20x1='0%25'%20y1='0%25'%20x2='100%25'%20y2='0%25'%3e%3cstop%20offset='0%25'%20style='stop-color:%23ff8c00'%3e%3c/stop%3e%3cstop%20offset='100%25'%20style='stop-color:%23ffd700'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='m610%20216.654c-66.158%204.092-126.119%2035.849-164.917%2087.346-8.408%2011.16-13.344%2019.191-19.983%2032.513-12.431%2024.946-19.521%2050.434-22.11%2079.487-1.665%2018.687-.854%20826.238.841%20837.939%207.867%2054.284%2032.465%20101.134%2070.706%20134.667%2016.297%2014.291%2032.283%2024.657%2053.963%2034.991%2016.889%208.05%2034.568%2013.468%2060.5%2018.541%209.019%201.764%2052.201%201.795%2061.5.044%2026.487-4.989%2043.97-10.341%2061-18.675%2015.131-7.406%2021.53-11.135%2060.5-35.267%2020.813-12.887%2023.095-14.298%2029.5-18.24l13-8%2013-8c6.901-4.247%2012.593-7.767%2029.54-18.271%205.796-3.593%2012.771-7.863%2015.5-9.49%202.728-1.626%208.56-5.19%2012.96-7.921%204.4-2.73%2072.575-44.711%20151.5-93.29s150.925-92.918%20160-98.531c9.075-5.612%2024.15-14.936%2033.5-20.719s23.075-14.234%2030.5-18.78c85.169-52.142%20120.029-73.942%20130.014-81.304%2040.974-30.211%2068.344-69.764%2081.788-118.194%2013.864-49.94%208.549-104.847-14.809-153-16.836-34.708-41.252-62.432-74.993-85.154-4.125-2.778-17.625-11.26-30-18.849s-27-16.594-32.5-20.009c-5.5-3.416-109.45-67.427-231-142.246-306.386-188.593-335.221-206.352-350-215.553-30.562-19.028-59.301-29.911-90-34.083-11.697-1.59-30.408-2.514-39.5-1.952m-10.5%2077.269c-39.541%206.402-76.013%2029.73-97.661%2062.467-13.001%2019.66-19.718%2038.39-22.802%2063.584-1.472%2012.028-1.434%20802.191.04%20818.026%201.861%2019.998%206.142%2035.48%2014.415%2052.133%2017.942%2036.114%2053.025%2064.18%2091.508%2073.203%203.575.839%208.975%202.118%2012%202.844%208.221%201.973%2040.343%201.613%2049.971-.56%2032.301-7.289%2065.233-26.686%2094.817-55.849%2015.26-15.042%2022.884-24.803%2033.571-42.979%2013.939-23.706%2020.949-43.36%2027.745-77.792%201.004-5.086%201.428-50%201.949-206.5.465-139.686%201.001-201.809%201.777-206%20.611-3.3%201.608-9.15%202.217-13%201.672-10.583%204.039-21.117%207.191-32%208.179-28.247%2020.714-55.13%2037.188-79.751%2024.262-36.262%2053.189-63.572%2093.074-87.872%204.95-3.016%2012.825-7.435%2017.5-9.82s8.95-4.668%209.5-5.074c3.565-2.63%2034.688-13.266%2052.465-17.93%206.2-1.627%2011.49-3.174%2011.754-3.439%201.003-1.002-1.016-2.602-10.967-8.689-5.639-3.449-16.552-10.172-24.252-14.94-13.435-8.319-31.76-19.604-58.5-36.029-6.875-4.222-16.1-9.911-20.5-12.641-7.667-4.758-73.088-45.103-122.5-75.546-75.227-46.348-108.509-66.591-116.5-70.86-9.422-5.033-25.23-10.76-37.043-13.419-7.967-1.794-40.076-2.843-47.957-1.567m473.5%20305.564c-5.775.685-11.625%201.491-13%201.792-1.375.3-5.2%201.088-8.5%201.749-7.914%201.587-27.103%207.461-36.5%2011.174-38.797%2015.33-75.171%2044.925-98.829%2080.41-11.24%2016.86-21.329%2038.407-26.167%2055.888-2.443%208.825-3.85%2014.608-4.866%2020-.621%203.3-1.653%208.475-2.292%2011.5-.846%204.008-1.345%2059.624-1.837%20205-.618%20182.331-.824%20200.361-2.399%20209.5-1.629%209.459-4.196%2022.506-6.744%2034.279-.628%202.903-.881%205.54-.561%205.859.596.596%20455.986-279.084%20472.195-290.001%2017.547-11.819%2036.335-33.412%2046.291-53.203%203.956-7.863%209.527-23.924%2011.597-33.434%204.848-22.272%203.572-48.26-3.506-71.387-6.907-22.572-18.055-40.93-35.316-58.158-12.705-12.681-16.829-15.485-79.066-53.756-7.15-4.397-15.7-9.654-19-11.684-3.3-2.029-8.925-5.504-12.5-7.722-53.826-33.397-67.199-40.611-88.616-47.8-29.343-9.85-61.599-13.421-90.384-10.006m-1066.25%201048.256c3.988.189%2010.513.189%2014.5%200%203.988-.19.725-.346-7.25-.346s-11.238.156-7.25.346'%20fill='url(%23grad-r4R0»)'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e";function Wye({status:e,onReconnect:t}){const r={connected:"bg-green-500 text-white",reconnecting:"bg-yellow-500 text-black",disconnected:"bg-red-500 text-white"}[e],n={connected:"bg-green-800 animate-pulse",reconnecting:"bg-yellow-800 animate-pulse",disconnected:"bg-red-800"}[e],o=e.charAt(0).toUpperCase()+e.slice(1);return l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("span",{className:`px-2 py-1 rounded-full text-xs font-semibold flex items-center ${r}`,children:[l.jsx("span",{className:`w-2 h-2 rounded-full mr-1 ${n}`}),o]}),e==="disconnected"&&l.jsx("button",{onClick:t,className:"ml-2 text-sm font-medium text-blue-600 hover:underline",children:"Reconnect"})]})}const qye=()=>{const{apiEndpoint:e,setApiEndpoint:t,connectionStatus:r,channelCode:n,setChannelCode:o,channel:a,setChannel:i,client:s,userInitiatedRegistrationRef:c,handleRegister:u,attemptReRegistration:d,resetReRegistration:f}=yr(),[h,m]=p.useState(!1),[g,b]=p.useState(e),[v,x]=p.useState(n),[w,E]=p.useState(a);p.useEffect(()=>{h||(b(e),x(n),E(a))},[e,n,a,h]);const j=()=>{const C=g.replace(/\/+$/,"");t(C),s.configure({apiEndpoint:C}),c.current=!1,u(n,a,"",!0)},S=()=>{c.current=!0,o(v),i(w),u(v,w,"",!0)};return l.jsxs("div",{className:"fixed bottom-0 left-0 w-full",children:[l.jsxs("div",{className:"flex items-center justify-between bg-gray-200 dark:bg-dark-tremor-background-subtle px-4 py-2 w-full cursor-pointer select-none",onClick:()=>m(C=>!C),children:[l.jsx(Wye,{status:r,onReconnect:C=>{C.stopPropagation(),f(),d()}}),l.jsxs("a",{href:"https://github.com/inspectr-hq/inspectr",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[l.jsx("img",{src:zye,alt:"Inspectr Logo",className:"h-6"}),l.jsx("span",{className:"text-gray-700 dark:text-dark-tremor-content font-semibold text-sm",children:"Inspectr"})]})]}),l.jsx("div",{className:`bg-gray-100 dark:bg-dark-tremor-background border-t border-gray-300 dark:border-dark-tremor-border transition-all duration-300 overflow-hidden ${h?"max-h-96 opacity-100 py-4":"max-h-0 opacity-0 py-0"}`,children:l.jsxs("div",{className:"px-6",children:[l.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-dark-tremor-content-strong mb-4",children:"Configuration"}),l.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Inspectr API Endpoint"}),l.jsx("input",{type:"text",placeholder:"Enter API Endpoint...",value:g,onChange:C=>b(C.target.value),className:"w-full border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content border-gray-300 dark:border-dark-tremor-border rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"}),l.jsx("button",{onClick:j,className:"mt-2 bg-blue-600 hover:bg-blue-700 dark:bg-blue-700 dark:hover:bg-blue-800 text-white px-3 py-1.5 rounded-md text-sm",children:"Save"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Channel"}),l.jsx("input",{type:"text",placeholder:"Enter Channel...",value:w,onChange:C=>E(C.target.value),className:"w-full bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content border border-gray-300 dark:border-dark-tremor-border rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"}),l.jsx("button",{onClick:S,className:"mt-2 bg-green-600 hover:bg-green-700 dark:bg-green-700 dark:hover:bg-green-800 text-white px-3 py-1.5 rounded-md text-sm",children:"Register"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Access Code"}),l.jsx("input",{type:"text",placeholder:"Enter Access Code...",value:v,onChange:C=>x(C.target.value),className:"w-full border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content border-gray-300 dark:border-dark-tremor-border rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]})]})})]})};function cl(){const e=window.location.hash.slice(1),[t,r]=e.split("?"),[n,o,a]=t.split("/"),i=Object.fromEntries(new URLSearchParams(r||""));return{slug:n,operationId:o,subTab:a,params:i}}function Uye(e,t=e[0].slug){const r=()=>{const{slug:s,operationId:c,subTab:u,params:d}=cl();return e.some(f=>f.slug===s)?{slug:s,operationId:c,subTab:u,params:d}:{slug:t,operationId:null,subTab:null,params:{}}},[n,o]=p.useState(()=>typeof window>"u"?{slug:t,operationId:null,subTab:null,params:{}}:r());p.useEffect(()=>{const s=()=>o(r());return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]);const a=s=>{window.history.pushState(null,"",`#${s.slug}`),o({slug:s.slug,operationId:null,subTab:null,params:{}})},i=e.find(s=>s.slug===n.slug)||e[0];return{route:n,currentNav:i,handleTabClick:a}}function Vye(e,t="request"){const[r,n]=p.useState(null),[o,a]=p.useState(t);return p.useEffect(()=>{const i=()=>{const{slug:s,operationId:c,subTab:u}=cl();if(s==="inspectr"){if(c&&e.length){const d=e.find(f=>String(f.id)===c);d&&n(d)}u&&a(u)}};return i(),window.addEventListener("hashchange",i),()=>window.removeEventListener("hashchange",i)},[e]),{selectedOperation:r,currentTab:o,handleSelect:i=>{n(i),window.history.pushState(null,"",`#inspectr/${i.id}/${o}`)},handleTabChange:i=>{a(i);const s=r?`#inspectr/${r.id}`:"#inspectr";window.history.replaceState(null,"",`${s}/${i}`)},clearSelection:()=>{n(null),window.history.pushState(null,"","#inspectr")}}}function IP(e,t){if(e===null)return t;try{return JSON.parse(e)}catch{return e}}function LP(e){if(e==null)return null;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Kye(e,t,r={}){const{resetOnReload:n=!1}=r,o=p.useRef(),a=()=>{if(typeof window>"u")return t;const c=sessionStorage.getItem(e);return IP(c,t)},[i,s]=p.useState(a);return p.useEffect(()=>{o.current=i},[i]),p.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{sessionStorage.removeItem(e)};return window.addEventListener("beforeunload",c),()=>window.removeEventListener("beforeunload",c)},[e,n]),p.useEffect(()=>{if(typeof window>"u")return;const c=u=>{if(u.key&&u.key!==e)return;const d=sessionStorage.getItem(e),f=IP(d,t),h=LP(o.current);d!==h&&s(f)};return window.addEventListener("storage",c),window.addEventListener("session-storage",c),()=>{window.removeEventListener("storage",c),window.removeEventListener("session-storage",c)}},[e,t]),p.useEffect(()=>{if(typeof window>"u")return;const c=LP(i),u=sessionStorage.getItem(e);if(c===null){if(u===null)return;sessionStorage.removeItem(e)}else{if(u===c)return;sessionStorage.setItem(e,c)}window.dispatchEvent(new CustomEvent("session-storage",{detail:{key:e,value:i}}))},[e,i]),[i,s]}const Yye=e=>{if(e==null)return null;if(typeof e=="string")return e;if(e instanceof Date)return e.toISOString();if(typeof e=="number"){const r=new Date(e);if(!Number.isNaN(r.valueOf()))return r.toISOString()}const t=new Date(e);return Number.isNaN(t.valueOf())?String(e):t.toISOString()},Ls=e=>Yye(e),_2=(e,t)=>{if(!e)return!1;if(!t)return!0;const r=Date.parse(e),n=Date.parse(t);return!Number.isNaN(r)&&!Number.isNaN(n)?r>n:e>t},Gye="requestFilters",Xye=Object.freeze({}),Jye=Object.freeze({resetOnReload:!0}),aD=({route:e={slug:"inspectr"}})=>{const{toast:t,setToast:r,client:n}=yr(),{syncOperations:o,setLastEventId:a}=yr(),i=100,s=33,[c,u]=p.useState(1),[d,f]=p.useState(!1),[h,m]=Rr("leftPanelWidth",s),[,g]=Rr("inspectrLastSeenAt",null),b=parseFloat(h||s),v=p.useRef(!1),[x,w]=p.useState("time"),[E,j]=p.useState("desc"),[S,C]=Kye(Gye,Xye,Jye),{results:O=[],totalCount:T=0}=aa(()=>rn.queryEvents({filters:S,sort:{field:x,order:E},page:c,pageSize:i}),[S,x,E,c],{results:[],totalCount:0})||{},P=aa(()=>rn.getAllTagOptions(),[],[])||[],M=aa(async()=>{try{const Z=await rn.db.events.orderBy("time").last();return Z?.time||null}catch{return null}},[])||null,D=(e?.slug||null)==="inspectr";p.useEffect(()=>{if(!D)return;const Z=Ls(M);Z&&g(de=>{const te=Ls(de);return!te||_2(Z,te)?Z:te})},[D,M,g]);const R=T?Math.ceil(T/i):1,{selectedOperation:F,currentTab:_,handleSelect:L,handleTabChange:V,clearSelection:$}=Vye(O),B=()=>{f(!0),o(),setTimeout(()=>f(!1),2500)};p.useEffect(()=>{if(!O||F&&O.some(te=>te.id===F.id))return;const{slug:Z,operationId:de}=cl();if(Z==="inspectr"&&de){const te=O.find(oe=>String(oe.id)===de);te&&L(te);return}O.length>0?L(O[0]):$()},[O,F]);const z=async()=>{$();try{await rn.clearEvents(),await J(),a("")}catch(Z){console.error("Error clearing all operations:",Z)}},q=async()=>{try{const Z=await rn.queryEvents({filters:S,sort:{field:"time",order:"desc"},page:1,pageSize:Number.MAX_SAFE_INTEGER});await Promise.all(Z.map(async de=>{await rn.deleteEvent(de.id),await Y(de.operation_id)})),F&&Z.some(de=>de.id===F.id)&&$()}catch(Z){console.error("Error clearing filtered operations:",Z)}},W=async Z=>{const de=F&&(F.id||"")===Z,te=await rn.getEvent(Z);try{if(await rn.deleteEvent(Z),await Y(te.operation_id),de){$();const oe=await rn.queryEvents({sort:{field:x,order:E},filters:S,page:c,pageSize:i});oe&&oe.length>0&&L(oe[0])}}catch(oe){console.error("Error during operation removal:",oe)}},J=async()=>{try{await n.operations.deleteAll()}catch(Z){console.error("Error deleting all operations:",Z),r({message:"Error deleting all operations",subMessage:Z.message,type:"error"})}},Y=async Z=>{try{await n.operations.delete(Z)}catch(de){console.error(`Error deleting operation ${Z}:`,de),r({message:"Error deleting operation",subMessage:de.message,type:"error"})}};p.useEffect(()=>{const Z=te=>{if(!v.current)return;const oe=te.clientX/window.innerWidth*100;oe>10&&oe<90&&m(String(oe))},de=()=>{v.current=!1};return window.addEventListener("mousemove",Z),window.addEventListener("mouseup",de),()=>{window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",de)}},[m]);const ne=()=>{v.current=!0};return l.jsxs("div",{className:"flex flex-col h-screen bg-white dark:bg-dark-tremor-background",style:{maxHeight:"calc(100vh - 64px)"},children:[l.jsxs("div",{className:"flex flex-grow",children:[l.jsx("div",{className:"overflow-y-auto",style:{width:`${b}%`},children:l.jsx(bR,{operations:O||[],onSelect:L,onRemove:W,clearOperations:z,clearFilteredOperations:q,selectedOperation:F,currentPage:c,totalPages:R,totalCount:T||0,onPageChange:u,sortField:x,sortDirection:E,filters:S,setSortField:w,setSortDirection:j,setFilters:C,syncOperations:B,isSyncing:d,tagOptions:P})}),l.jsx("div",{className:"relative w-px bg-gray-300 dark:bg-dark-tremor-border cursor-col-resize",onMouseDown:ne,children:l.jsx("button",{type:"button",className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10 flex items-center justify-center px-0 py-2 rounded-md border border-gray-300 bg-white/80 backdrop-blur-sm shadow-sm cursor-col-resize dark:border-dark-tremor-border dark:bg-dark-tremor-background/80",title:"Drag to resize. Double-click to reset.","aria-label":"Resize panels",onMouseDown:Z=>{Z.preventDefault(),ne()},onDoubleClick:Z=>{Z.preventDefault(),m(s)},children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4 text-gray-600 dark:text-gray-400","aria-hidden":!0,children:l.jsx("path",{d:"M8.5 7C9.32843 7 10 6.32843 10 5.5C10 4.67157 9.32843 4 8.5 4C7.67157 4 7 4.67157 7 5.5C7 6.32843 7.67157 7 8.5 7ZM8.5 13.5C9.32843 13.5 10 12.8284 10 12C10 11.1716 9.32843 10.5 8.5 10.5C7.67157 10.5 7 11.1716 7 12C7 12.8284 7.67157 13.5 8.5 13.5ZM10 18.5C10 19.3284 9.32843 20 8.5 20C7.67157 20 7 19.3284 7 18.5C7 17.6716 7.67157 17 8.5 17C9.32843 17 10 17.6716 10 18.5ZM15.5 7C16.3284 7 17 6.32843 17 5.5C17 4.67157 16.3284 4 15.5 4C14.6716 4 14 4.67157 14 5.5C14 6.32843 14.6716 7 15.5 7ZM17 12C17 12.8284 16.3284 13.5 15.5 13.5C14.6716 13.5 14 12.8284 14 12C14 11.1716 14.6716 10.5 15.5 10.5C16.3284 10.5 17 11.1716 17 12ZM15.5 20C16.3284 20 17 19.3284 17 18.5C17 17.6716 16.3284 17 15.5 17C14.6716 17 14 17.6716 14 18.5C14 19.3284 14.6716 20 15.5 20Z"})})})}),l.jsx("div",{className:"p-4 h-full overflow-y-auto bg-white dark:bg-dark-tremor-background text-tremor-content-strong dark:text-dark-tremor-content-strong",style:{width:`${100-b}%`},children:l.jsx("div",{className:"flex flex-col h-full",children:l.jsx(Hye,{operation:F,currentTab:_,setCurrentTab:V})})})]}),l.jsx(qye,{})]})},DP="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%201648%201648'%20xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3clinearGradient%20id='grad-ops'%20x1='0%25'%20y1='0%25'%20x2='100%25'%20y2='0%25'%3e%3cstop%20offset='0%25'%20stop-color='%2353afba'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%2376fffb'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='m610%20216.654c-66.158%204.092-126.119%2035.849-164.917%2087.346-8.408%2011.16-13.344%2019.191-19.983%2032.513-12.431%2024.946-19.521%2050.434-22.11%2079.487-1.665%2018.687-.854%20826.238.841%20837.939%207.867%2054.284%2032.465%20101.134%2070.706%20134.667%2016.297%2014.291%2032.283%2024.657%2053.963%2034.991%2016.889%208.05%2034.568%2013.468%2060.5%2018.541%209.019%201.764%2052.201%201.795%2061.5.044%2026.487-4.989%2043.97-10.341%2061-18.675%2015.131-7.406%2021.53-11.135%2060.5-35.267%2020.813-12.887%2023.095-14.298%2029.5-18.24l13-8%2013-8c6.901-4.247%2012.593-7.767%2029.54-18.271%205.796-3.593%2012.771-7.863%2015.5-9.49%202.728-1.626%208.56-5.19%2012.96-7.921%204.4-2.73%2072.575-44.711%20151.5-93.29s150.925-92.918%20160-98.531c9.075-5.612%2024.15-14.936%2033.5-20.719s23.075-14.234%2030.5-18.78c85.169-52.142%20120.029-73.942%20130.014-81.304%2040.974-30.211%2068.344-69.764%2081.788-118.194%2013.864-49.94%208.549-104.847-14.809-153-16.836-34.708-41.252-62.432-74.993-85.154-4.125-2.778-17.625-11.26-30-18.849s-27-16.594-32.5-20.009c-5.5-3.416-109.45-67.427-231-142.246-306.386-188.593-335.221-206.352-350-215.553-30.562-19.028-59.301-29.911-90-34.083-11.697-1.59-30.408-2.514-39.5-1.952m-10.5%2077.269c-39.541%206.402-76.013%2029.73-97.661%2062.467-13.001%2019.66-19.718%2038.39-22.802%2063.584-1.472%2012.028-1.434%20802.191.04%20818.026%201.861%2019.998%206.142%2035.48%2014.415%2052.133%2017.942%2036.114%2053.025%2064.18%2091.508%2073.203%203.575.839%208.975%202.118%2012%202.844%208.221%201.973%2040.343%201.613%2049.971-.56%2032.301-7.289%2065.233-26.686%2094.817-55.849%2015.26-15.042%2022.884-24.803%2033.571-42.979%2013.939-23.706%2020.949-43.36%2027.745-77.792%201.004-5.086%201.428-50%201.949-206.5.465-139.686%201.001-201.809%201.777-206%20.611-3.3%201.608-9.15%202.217-13%201.672-10.583%204.039-21.117%207.191-32%208.179-28.247%2020.714-55.13%2037.188-79.751%2024.262-36.262%2053.189-63.572%2093.074-87.872%204.95-3.016%2012.825-7.435%2017.5-9.82s8.95-4.668%209.5-5.074c3.565-2.63%2034.688-13.266%2052.465-17.93%206.2-1.627%2011.49-3.174%2011.754-3.439%201.003-1.002-1.016-2.602-10.967-8.689-5.639-3.449-16.552-10.172-24.252-14.94-13.435-8.319-31.76-19.604-58.5-36.029-6.875-4.222-16.1-9.911-20.5-12.641-7.667-4.758-73.088-45.103-122.5-75.546-75.227-46.348-108.509-66.591-116.5-70.86-9.422-5.033-25.23-10.76-37.043-13.419-7.967-1.794-40.076-2.843-47.957-1.567m473.5%20305.564c-5.775.685-11.625%201.491-13%201.792-1.375.3-5.2%201.088-8.5%201.749-7.914%201.587-27.103%207.461-36.5%2011.174-38.797%2015.33-75.171%2044.925-98.829%2080.41-11.24%2016.86-21.329%2038.407-26.167%2055.888-2.443%208.825-3.85%2014.608-4.866%2020-.621%203.3-1.653%208.475-2.292%2011.5-.846%204.008-1.345%2059.624-1.837%20205-.618%20182.331-.824%20200.361-2.399%20209.5-1.629%209.459-4.196%2022.506-6.744%2034.279-.628%202.903-.881%205.54-.561%205.859.596.596%20455.986-279.084%20472.195-290.001%2017.547-11.819%2036.335-33.412%2046.291-53.203%203.956-7.863%209.527-23.924%2011.597-33.434%204.848-22.272%203.572-48.26-3.506-71.387-6.907-22.572-18.055-40.93-35.316-58.158-12.705-12.681-16.829-15.485-79.066-53.756-7.15-4.397-15.7-9.654-19-11.684-3.3-2.029-8.925-5.504-12.5-7.722-53.826-33.397-67.199-40.611-88.616-47.8-29.343-9.85-61.599-13.421-90.384-10.006m-1066.25%201048.256c3.988.189%2010.513.189%2014.5%200%203.988-.19.725-.346-7.25-.346s-11.238.156-7.25.346'%20fill='url(%23grad-ops)'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",Zye="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%201648%201648'%20xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3clinearGradient%20id='grad-connections'%20x1='0%25'%20y1='0%25'%20x2='100%25'%20y2='0%25'%3e%3cstop%20offset='0%25'%20stop-color='%23ff8c00'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%23ffd700'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='m610%20216.654c-66.158%204.092-126.119%2035.849-164.917%2087.346-8.408%2011.16-13.344%2019.191-19.983%2032.513-12.431%2024.946-19.521%2050.434-22.11%2079.487-1.665%2018.687-.854%20826.238.841%20837.939%207.867%2054.284%2032.465%20101.134%2070.706%20134.667%2016.297%2014.291%2032.283%2024.657%2053.963%2034.991%2016.889%208.05%2034.568%2013.468%2060.5%2018.541%209.019%201.764%2052.201%201.795%2061.5.044%2026.487-4.989%2043.97-10.341%2061-18.675%2015.131-7.406%2021.53-11.135%2060.5-35.267%2020.813-12.887%2023.095-14.298%2029.5-18.24l13-8%2013-8c6.901-4.247%2012.593-7.767%2029.54-18.271%205.796-3.593%2012.771-7.863%2015.5-9.49%202.728-1.626%208.56-5.19%2012.96-7.921%204.4-2.73%2072.575-44.711%20151.5-93.29s150.925-92.918%20160-98.531c9.075-5.612%2024.15-14.936%2033.5-20.719s23.075-14.234%2030.5-18.78c85.169-52.142%20120.029-73.942%20130.014-81.304%2040.974-30.211%2068.344-69.764%2081.788-118.194%2013.864-49.94%208.549-104.847-14.809-153-16.836-34.708-41.252-62.432-74.993-85.154-4.125-2.778-17.625-11.26-30-18.849s-27-16.594-32.5-20.009c-5.5-3.416-109.45-67.427-231-142.246-306.386-188.593-335.221-206.352-350-215.553-30.562-19.028-59.301-29.911-90-34.083-11.697-1.59-30.408-2.514-39.5-1.952m-10.5%2077.269c-39.541%206.402-76.013%2029.73-97.661%2062.467-13.001%2019.66-19.718%2038.39-22.802%2063.584-1.472%2012.028-1.434%20802.191.04%20818.026%201.861%2019.998%206.142%2035.48%2014.415%2052.133%2017.942%2036.114%2053.025%2064.18%2091.508%2073.203%203.575.839%208.975%202.118%2012%202.844%208.221%201.973%2040.343%201.613%2049.971-.56%2032.301-7.289%2065.233-26.686%2094.817-55.849%2015.26-15.042%2022.884-24.803%2033.571-42.979%2013.939-23.706%2020.949-43.36%2027.745-77.792%201.004-5.086%201.428-50%201.949-206.5.465-139.686%201.001-201.809%201.777-206%20.611-3.3%201.608-9.15%202.217-13%201.672-10.583%204.039-21.117%207.191-32%208.179-28.247%2020.714-55.13%2037.188-79.751%2024.262-36.262%2053.189-63.572%2093.074-87.872%204.95-3.016%2012.825-7.435%2017.5-9.82s8.95-4.668%209.5-5.074c3.565-2.63%2034.688-13.266%2052.465-17.93%206.2-1.627%2011.49-3.174%2011.754-3.439%201.003-1.002-1.016-2.602-10.967-8.689-5.639-3.449-16.552-10.172-24.252-14.94-13.435-8.319-31.76-19.604-58.5-36.029-6.875-4.222-16.1-9.911-20.5-12.641-7.667-4.758-73.088-45.103-122.5-75.546-75.227-46.348-108.509-66.591-116.5-70.86-9.422-5.033-25.23-10.76-37.043-13.419-7.967-1.794-40.076-2.843-47.957-1.567m473.5%20305.564c-5.775.685-11.625%201.491-13%201.792-1.375.3-5.2%201.088-8.5%201.749-7.914%201.587-27.103%207.461-36.5%2011.174-38.797%2015.33-75.171%2044.925-98.829%2080.41-11.24%2016.86-21.329%2038.407-26.167%2055.888-2.443%208.825-3.85%2014.608-4.866%2020-.621%203.3-1.653%208.475-2.292%2011.5-.846%204.008-1.345%2059.624-1.837%20205-.618%20182.331-.824%20200.361-2.399%20209.5-1.629%209.459-4.196%2022.506-6.744%2034.279-.628%202.903-.881%205.54-.561%205.859.596.596%20455.986-279.084%20472.195-290.001%2017.547-11.819%2036.335-33.412%2046.291-53.203%203.956-7.863%209.527-23.924%2011.597-33.434%204.848-22.272%203.572-48.26-3.506-71.387-6.907-22.572-18.055-40.93-35.316-58.158-12.705-12.681-16.829-15.485-79.066-53.756-7.15-4.397-15.7-9.654-19-11.684-3.3-2.029-8.925-5.504-12.5-7.722-53.826-33.397-67.199-40.611-88.616-47.8-29.343-9.85-61.599-13.421-90.384-10.006m-1066.25%201048.256c3.988.189%2010.513.189%2014.5%200%203.988-.19.725-.346-7.25-.346s-11.238.156-7.25.346'%20fill='url(%23grad-connections)'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",iD="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2024%2024'%20stroke-width='1.5'%20stroke='currentColor'%20class='size-6'%3e%3cpath%20stroke-linecap='round'%20stroke-linejoin='round'%20d='m3.75%2013.5%2010.5-11.25L12%2010.5h8.25L9.75%2021.75%2012%2013.5H3.75Z'%20/%3e%3c/svg%3e",Qye="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20d='M3.49994%2011.7501L11.6717%203.57855C12.7762%202.47398%2014.5672%202.47398%2015.6717%203.57855C16.7762%204.68312%2016.7762%206.47398%2015.6717%207.57855M15.6717%207.57855L9.49994%2013.7501M15.6717%207.57855C16.7762%206.47398%2018.5672%206.47398%2019.6717%207.57855C20.7762%208.68312%2020.7762%2010.474%2019.6717%2011.5785L12.7072%2018.543C12.3167%2018.9335%2012.3167%2019.5667%2012.7072%2019.9572L13.9999%2021.2499'%20stroke='%236b7280'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3e%3c/path%3e%3cpath%20d='M17.4999%209.74921L11.3282%2015.921C10.2237%2017.0255%208.43272%2017.0255%207.32823%2015.921C6.22373%2014.8164%206.22373%2013.0255%207.32823%2011.921L13.4999%205.74939'%20stroke='%236b7280'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3e%3c/path%3e%3c/svg%3e",exe="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%236b7280'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%3e%3cpath%20d='m15%2012-8.373%208.373a1%201%200%201%201-3-3L12%209'%3e%3c/path%3e%3cpath%20d='m18%2015%204-4'%3e%3c/path%3e%3cpath%20d='m21.5%2011.5-1.914-1.914A2%202%200%200%201%2019%208.172V7l-2.26-2.26a6%206%200%200%200-4.202-1.756L9%202.96l.92.82A6.18%206.18%200%200%201%2012%208.4V10l2%202h1.172a2%202%200%200%201%201.414.586L18.5%2014.5'%3e%3c/path%3e%3c/svg%3e",txe="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%236b7280'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%3e%3cpath%20d='M20%207h-3a2%202%200%200%201-2-2V2'%3e%3c/path%3e%3cpath%20d='M9%2018a2%202%200%200%201-2-2V4a2%202%200%200%201%202-2h7l4%204v10a2%202%200%200%201-2%202Z'%3e%3c/path%3e%3cpath%20d='M3%207.6v12.8A1.6%201.6%200%200%200%204.6%2022h9.8'%3e%3c/path%3e%3c/svg%3e",rxe="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%236b7280'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%3e%3cpath%20d='M21%2015a2%202%200%200%201-2%202H7l-4%204V5a2%202%200%200%201%202-2h14a2%202%200%200%201%202%202z'%3e%3c/path%3e%3c/svg%3e";function fa(e,t=!1,r=!0){const[n,o]=Rr(`feature_preview_${e}`,t?"true":void 0);return p.useEffect(()=>{r&&n==="false"&&o(void 0)},[r,n,o]),[n==="true",a=>{o(a?"true":r?void 0:"false")}]}function sD(e){const t=e&&e.reason||"",r=e&&e.status;switch(t){case"invalid_request":return'Invalid request. Submit as {"license_key": "..."}.';case"invalid_format":return"Invalid format. Did you paste JSON or a file? Paste only the license key string.";case"ingress_unreachable":return"Activation service unreachable. Check network/ingress connectivity and try again.";case"activation_error":return`Activation failed. ${e?.details||"Please try again or contact support."}`;case"invalid_key":return"Invalid license key. Is this the exact key? Check for typos or request a new key.";case"revoked":return"License revoked. Contact support to resolve or obtain a new license.";case"expired":return"License expired. Renew your license or enter a valid key.";case"storage_error":return"Failed to store the license locally. Ensure write permissions and retry.";case"internal_error":return"Server error during activation. Please try again shortly.";default:return r===401?"Unauthorized: Invalid license key.":r===403?"Forbidden: License revoked.":r===410?"Expired license. Please renew or use a new key.":e?.message||"Failed to update license"}}function nxe({open:e,onClose:t,onSubmit:r}){const[n,o]=p.useState(""),[a,i]=p.useState(""),[s,c]=p.useState(!1),u="license-file-input";if(p.useEffect(()=>{e&&(o(""),i(""),c(!1))},[e]),!e)return null;const d=async()=>{i("");const h=(n||"").trim();if(!h){i("Please paste a license key.");return}try{c(!0),await r(h),t()}catch(m){const g=sD(m);i(g),c(!1)}},f=async h=>{const m=h.target.files&&h.target.files[0];if(m)try{const g=await m.text();o(g.trim()),i("")}catch{i("Failed to read license file.")}finally{h.target.value=""}};return l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white dark:bg-gray-950 rounded-lg shadow-xl max-w-2xl w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-50",children:"Update License"}),l.jsx("button",{onClick:t,className:"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-gray-100","aria-label":"Close",disabled:s,children:"×"})]}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mb-3",children:"Paste your license key below or upload a key file."}),l.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[l.jsx("input",{id:u,type:"file",accept:".txt,.key,.license,application/octet-stream,text/plain,application/json",onChange:f,className:"hidden",disabled:s}),l.jsx("button",{type:"button",onClick:()=>{var h;return(h=document.getElementById(u))==null?void 0:h.click()},className:"px-3 py-1.5 text-sm rounded bg-gray-200 dark:bg-gray-800 text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-700",disabled:s,children:"Upload Key File"}),l.jsx("span",{className:"text-xs text-gray-500",children:"Accepted: .txt, .key, .license"})]}),l.jsx("textarea",{className:`w-full h-48 p-3 rounded border text-sm font-mono ${a?"border-red-500 focus:border-red-500 focus:ring-red-500":"border-gray-300 dark:border-gray-800 focus:border-blue-500 focus:ring-blue-500"}`,placeholder:"Paste your license key here",value:n,onChange:h=>{o(h.target.value),a&&i("")},disabled:s}),a&&l.jsx("p",{className:"mt-2 text-sm text-red-600",children:a}),l.jsxs("div",{className:"mt-4 flex justify-end gap-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-200 dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded hover:bg-gray-300 dark:hover:bg-gray-700",disabled:s,children:"Cancel"}),l.jsx("button",{onClick:d,className:`px-4 py-2 text-white rounded ${s?"bg-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"}`,disabled:s,children:s?"Updating…":"Update License"})]})]})]})}function oxe({open:e,onClose:t,license:r,onRefresh:n}){var o,a;const[i,s]=p.useState(""),[c,u]=p.useState(!1),[d,f]=p.useState("");if(p.useEffect(()=>{e&&(s(""),u(!1),f(""))},[e]),!e)return null;const h=((o=r?.license)==null?void 0:o.plan)||"unknown",m=r?.license||{},g=r?.features||{},b=((a=r?.usage)==null?void 0:a.features)||{},v=m?.expires_at||null,x=m?.starts_at||null,w=m?.updated_at||null,E=m?.grace_until||null,j=m?.in_grace===!0,S=m?.issuer||null,C=m?.subject||null,O=Object.entries(g||{}),T=q=>{if(!q)return null;const W=new Date(q);return isNaN(W)?q:W.toISOString().slice(0,19).replace("T"," ")},P=async()=>{f("");const q=(i||"").trim();if(!q){f("Please enter a license key.");return}try{u(!0),await n(q),s("")}catch(W){f(sD(W))}finally{u(!1)}},M=new Date,D=v?new Date(v):null,R=E?new Date(E):null,F=D?M>D:!1,_=F&&R?M>R:!1,L=j||F&&R&&M<=R,V=D?M<=D:!1;let $="Unknown",B="",z="bg-gray-400";return _?($="Expired",B=R?`(grace ended ${T(E)})`:"(grace ended)",z="bg-red-600"):L?($="In Grace",B=R?`(until ${T(E)})`:"",z="bg-yellow-500"):V&&($="Active",B=D?`(until ${T(v)})`:"",z="bg-green-600"),l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white dark:bg-gray-950 rounded-lg shadow-xl max-w-3xl w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-50",children:"License Overview"}),l.jsx("button",{onClick:t,className:"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-gray-100","aria-label":"Close",disabled:c,children:"×"})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Status"}),l.jsxs("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50 flex items-center",children:[l.jsx("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${z}`}),$,B&&l.jsx("span",{className:"ml-2 text-xs font-normal text-gray-500",children:B})]})]}),l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Plan"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:h})]}),l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Issued By"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:S||"—"})]}),l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"License Key"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:C||"—"})]}),l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Last Updated"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:T(w)||"—"})]}),l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Starts"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:T(x)||"—"})]}),l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Expires"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:T(v)||"—"})]}),E&&l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500",children:"Grace Until"}),l.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:T(E)})]})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50 mb-2",children:"Features"}),O.length===0&&l.jsx("p",{className:"text-sm text-gray-500",children:"No features available."}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:O.map(([q,W])=>{const J=q.toUpperCase(),Y=b?.[q]||{};return l.jsxs("div",{className:"rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-xs uppercase text-gray-500 mb-1",children:J}),l.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300 space-y-1",children:["effective_enabled"in W&&l.jsxs("p",{children:["Effective enabled: ",String(W.effective_enabled)]}),"effective_limit"in W&&l.jsxs("p",{children:["Effective limit: ",W.effective_limit??"—"]}),"licensed_enabled"in W&&l.jsxs("p",{children:["Licensed enabled: ",String(W.licensed_enabled)]}),"licensed_limit"in W&&l.jsxs("p",{children:["Licensed limit: ",W.licensed_limit??"—"]}),"default_limit"in W&&l.jsxs("p",{children:["Default limit: ",W.default_limit??"—"]}),"unlimited"in W&&l.jsxs("p",{children:["Unlimited: ",String(W.unlimited)]}),("used"in Y||"used"in W)&&l.jsxs("p",{children:["Used: ",Y.used??W.used??0]}),("remaining"in Y||"remaining"in W)&&l.jsxs("p",{children:["Remaining: ",Y.remaining??W.remaining??0]}),("window"in Y||"window"in W)&&l.jsxs("p",{children:["Window: ",Y.window??W.window??"—"]}),("period_start"in Y||"period_start"in W)&&l.jsxs("p",{children:["Period start: ",T(Y.period_start??W.period_start)]})]})]},q)})})]}),l.jsxs("div",{className:"mt-2 rounded border border-gray-200 dark:border-gray-800 p-3",children:[l.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Refresh License"}),l.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Enter a license key to update the license details."}),l.jsxs("div",{className:"mt-2 flex gap-2",children:[l.jsx("input",{type:"text",value:i,onChange:q=>s(q.target.value),placeholder:"INSPECTR-...",className:"flex-1 rounded border border-gray-300 dark:border-gray-800 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:c}),l.jsx("button",{type:"button",onClick:P,className:`px-4 py-2 text-white rounded ${c?"bg-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"}`,disabled:c,children:c?"Refreshing…":"Refresh License"})]}),d&&l.jsx("p",{className:"mt-2 text-sm text-red-600",children:d})]})]})]})}const axe=()=>{var e,t,r,n,o,a,i,s,c,u,d,f,h,m;const{client:g,setToast:b}=yr(),[v,x]=p.useState(null),[w,E]=p.useState(null),[j,S]=p.useState(!0),[C,O]=p.useState(!1),[T,P]=p.useState(""),[M,D]=p.useState(!1),[R,F]=p.useState(!1),[_,L]=p.useState(!1),[V,$]=p.useState(!1),B=y.useCallback(async(Ie=!1)=>{var lt;try{Ie?S(!0):O(!0);let Ge=null,Ve=null;(lt=g?.service)!=null&&lt.getLicense?[Ge,Ve]=await Promise.all([g.service.getMetrics(),g.service.getLicense().catch(()=>null)]):Ge=await g.service.getMetrics(),x(Ge),Ve&&E(Ve),P("")}catch(Ge){console.error("Error fetching metrics:",Ge),P(Ge.message||"Failed to load metrics")}finally{Ie?S(!1):O(!1)}},[g]);p.useEffect(()=>{B(!0)},[B]);const z=async Ie=>{await g.service.putLicense(Ie),b?.({message:"License updated",subMessage:"License applied successfully."}),await B(!1)},q=async Ie=>{await g.service.putLicense(Ie),b?.({message:"License refreshed",subMessage:"License updated successfully."}),await B(!1)},W=v?.operations||{},J=((t=(e=v?.generic)==null?void 0:e.totals)==null?void 0:t.sse)||{},Y=((n=(r=v?.generic)==null?void 0:r.totals)==null?void 0:n.mcp)||{},ne=((a=(o=v?.generic)==null?void 0:o.totals)==null?void 0:a.features)||{},Z=v?.features||{},de=v?.mcp||{},te=(()=>{var Ie;const lt=(Ie=w?.features)==null?void 0:Ie.mcp;if(lt)return lt.unlimited===!0?!0:typeof lt.effective_limit=="number"?!1:lt.effective_enabled===!0&&typeof lt.default_limit!="number"})(),oe=(()=>{var Ie;const lt=(Ie=w?.features)==null?void 0:Ie.mcp;return!lt||lt.unlimited===!0?null:typeof lt.effective_limit=="number"?lt.effective_limit:typeof lt.default_limit=="number"?lt.default_limit:null})(),G=(i=w?.features)==null?void 0:i.mcp,ce=(c=(s=w?.usage)==null?void 0:s.features)==null?void 0:c.mcp,ae=(()=>{const Ie=ce?.window||G?.window;return Ie?Ie.charAt(0).toUpperCase()+Ie.slice(1):null})(),U=(()=>{const Ie=ce?.period_start||G?.period_start;if(!Ie)return null;const lt=new Date(Ie);return isNaN(lt)?null:lt.toISOString().slice(0,10)})(),ie=(()=>{const Ie=ce?.period_end||G?.period_end;if(!Ie)return null;const lt=new Date(Ie);return isNaN(lt)?null:lt.toISOString().slice(0,10)})(),fe=typeof ce?.used=="number"?ce.used:typeof Y.requests=="number"?Y.requests:0,ye=oe?Math.min(100,fe/oe*100):0,Ce=(u=w?.features)==null?void 0:u.rules,Pe=(f=(d=w?.usage)==null?void 0:d.features)==null?void 0:f.rules,$e=(()=>{const Ie=Ce;return!Ie||Ie.unlimited===!0?null:typeof Ie.effective_limit=="number"?Ie.effective_limit:typeof Ie.default_limit=="number"?Ie.default_limit:null})();(()=>{const Ie=Pe?.window||Ce?.window;return Ie?Ie.charAt(0).toUpperCase()+Ie.slice(1):null})(),(()=>{const Ie=Pe?.period_start||Ce?.period_start;if(!Ie)return null;const lt=new Date(Ie);return isNaN(lt)?null:lt.toISOString().slice(0,10)})(),(()=>{const Ie=Pe?.period_end||Ce?.period_end;if(!Ie)return null;const lt=new Date(Ie);return isNaN(lt)?null:lt.toISOString().slice(0,10)})();const rt=((m=(h=v?.generic)==null?void 0:h.totals)==null?void 0:m.rules)||{},_e=v?.rules||{},nt=typeof rt.definitions=="number"?rt.definitions:typeof _e.definitions_total=="number"?_e.definitions_total:0,Qe=$e?Math.min(100,nt/$e*100):0,ot=(()=>{var Ie;const lt=(((Ie=w?.license)==null?void 0:Ie.plan)||"").toString().toLowerCase(),Ge=(de?.plan||"").toString().toLowerCase(),Ve=lt||Ge;return Ve==="pro"||Ve==="professional"||Ve==="paid"?"pro":["open_source","open-source","opensource","oss","open source"].includes(Ve)?"open_source":te?"pro":"open_source"})(),ft=ot==="pro"?"Pro":"Open Source",et=ot==="pro"?"bg-brand-primary text-gray-900 ":"bg-white dark:bg-gray-800/10 border border-brand-primary text-brand-primary",vt=(()=>{var Ie;const lt=(Ie=v?.meta)==null?void 0:Ie.installed_at;if(!lt)return null;const Ge=new Date(lt);return isNaN(Ge)?null:Ge.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})(),Ye=ot==="open_source"&&fe>0||typeof oe=="number"&&ye>=90,We=ot==="open_source"&&nt>0||typeof $e=="number"&&Qe>=90;return p.useEffect(()=>{v&&D(Ye)},[Ye,v]),p.useEffect(()=>{v&&F(We)},[We,v]),j?l.jsxs(Mt,{className:"p-6",children:[l.jsx(On,{children:"Usage Overview"}),l.jsx(pt,{className:"mt-2",children:"Loading usage…"})]}):T?l.jsxs(Mt,{className:"p-6",children:[l.jsx(On,{children:"Usage Overview"}),l.jsxs(pt,{className:"mt-2 text-red-600 dark:text-red-400",children:["Error loading metrics: ",T]})]}):l.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[l.jsx("header",{children:l.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[l.jsx("h3",{className:"text-tremor-title font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Usage Overview"}),l.jsx("div",{className:"mt-2 sm:mt-0",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Jl,{onClick:()=>$(!0),children:"License Details"}),l.jsx(Jl,{onClick:()=>L(!0),children:"Update License"}),l.jsx(Jl,{onClick:()=>B(!1),children:C?"Loading":"Refresh"})]})})]})}),l.jsxs("div",{className:"rounded-lg bg-gray-200 p-6 ring-1 ring-inset ring-gray-200 dark:bg-gray-400/10 dark:ring-gray-800",children:[l.jsxs("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:["This workspace is currently on"," ",l.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-xs font-medium ${et}`,children:ft})]}),l.jsxs("p",{className:"mt-1 max-w-2xl text-sm leading-6 text-gray-500",children:[ot==="pro"?"You're on Pro — enjoy premium features and priority support.":"Boost your analytics and unlock advanced features with our premium plans.",l.jsxs("a",{href:"https://inspectr.dev/pricing",target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1 text-indigo-600 dark:text-indigo-500",children:[ot==="pro"?"Explore features":"Compare plans",l.jsx("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor","aria-hidden":"true",className:"remixicon size-4 shrink-0",children:l.jsx("path",{d:"M16.0037 9.41421L7.39712 18.0208L5.98291 16.6066L14.5895 8H7.00373V6H18.0037V17H16.0037V9.41421Z"})})]})]})]}),vt&&l.jsxs(pt,{className:"-mt-2 text-sm text-gray-500",children:["Usage metrics since ",vt]}),l.jsx(nxe,{open:_,onClose:()=>L(!1),onSubmit:z}),l.jsx(oxe,{open:V,onClose:()=>$(!1),license:w,onRefresh:q}),l.jsxs(Mt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:DP,width:24,height:24,alt:"","aria-hidden":"true",className:"inline-block"}),l.jsx(On,{className:"!mb-0",children:"Operations"})]}),l.jsx(pt,{className:"mt-1 text-gray-500",children:"Metrics on requests, responses, and events handled by Inspectr."}),l.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx(pt,{children:"Total requests"}),l.jsx(Ga,{children:W.total_requests??(W.requests_local??0)+(W.requests_ingress??0)}),l.jsx("div",{className:"mt-3",children:l.jsx(Uu,{data:[{name:"proxy",value:W.requests_local??0,color:"cyan"},{name:"ingress",value:W.requests_ingress??0,color:"yellow"}]})})]}),l.jsxs("div",{children:[l.jsx(pt,{children:"Total responses"}),l.jsx(Ga,{children:W.total_responses??(W.responses_local??0)+(W.responses_ingress??0)}),l.jsx("div",{className:"mt-3",children:l.jsx(Uu,{data:[{name:"proxy",value:W.responses_local??0,color:"cyan"},{name:"ingress",value:W.responses_ingress??0,color:"yellow"}]})})]}),l.jsxs("div",{children:[l.jsx(pt,{children:"Event frames"}),l.jsx(Ga,{children:W.total_event_frames??(W.event_frames_local??0)+(W.event_frames_ingress??0)}),l.jsx("div",{className:"mt-3",children:l.jsx(Uu,{data:[{name:"proxy",value:W.event_frames_local??0,color:"cyan"},{name:"ingress",value:W.event_frames_ingress??0,color:"yellow"}]})})]})]})]}),l.jsxs(Mt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:DP,width:24,height:24,alt:"","aria-hidden":"true",className:"inline-block"}),l.jsx(On,{className:"!mb-0",children:"Features"})]}),l.jsx(pt,{className:"mt-1 text-gray-500",children:"Usage metrics for core Inspectr features."}),l.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Registrations"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:ne.registrations??Z.registration_requests??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Token refresh"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:ne.token_refresh??Z.token_refresh_requests??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Launches"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:ne.launches??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Ingress registrations"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:ne.ingress_registrations??0})]})]})]}),l.jsxs(Mt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:Zye,width:24,height:24,alt:"","aria-hidden":"true",className:"inline-block"}),l.jsx(On,{className:"!mb-0",children:"Inspectr Connections"})]}),l.jsx(pt,{className:"mt-1 text-gray-500",children:"Overview of metrics related to the Inspectr App SSE connections to Inspectr."}),l.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Active connections"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:J.active??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Reconnect attempts"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:J.reconnect_attempts??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total connections"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:J.total_connections??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total disconnections"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:J.total_disconnections??0})]})]})]}),l.jsxs(Mt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:iD,width:24,height:24,alt:"","aria-hidden":"true",className:"inline-block"}),l.jsx(On,{className:"!mb-0",children:"Rules"})]}),l.jsx(pt,{className:"mt-1 text-gray-500",children:"Overview of Rules definitions and actions usage."}),R&&We&&l.jsxs("div",{className:"mt-4 rounded-md bg-gray-50 p-6 ring-1 ring-inset ring-gray-200 dark:bg-gray-900 dark:ring-gray-800",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Want more rules?"}),l.jsx("p",{className:"mt-2 text-sm/6 text-gray-500 dark:text-gray-500",children:"Elevate your workspace and boost productivity with premium features. See our pro plans and upgrade today."}),l.jsxs("div",{className:"mt-6 flex items-center space-x-2",children:[l.jsx("a",{href:"https://inspectr.dev/pricing",target:"_blank",rel:"noreferrer noopener",className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border px-3 py-2 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-yellow-500 dark:outline-blue-500 border-transparent text-white dark:text-white bg-yellow-500 dark:bg-yellow-500 hover:bg-yellow-600 dark:hover:bg-yellow-600 disabled:bg-blue-300 disabled:text-white disabled:dark:bg-blue-800 disabled:dark:text-blue-400",children:"Discover Plans"}),l.jsx("button",{type:"button",className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border px-3 py-2 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 disabled:dark:text-gray-600",onClick:()=>F(!1),children:"Dismiss"})]})]}),$e!==null&&l.jsxs("div",{className:"mt-6",children:[l.jsx(pt,{className:"mb-2",children:"Definitions usage"}),l.jsx(M2,{value:Qe,color:"indigo"}),l.jsxs(pt,{className:"mt-2",children:[nt," of ",$e," rules defined"]})]}),l.jsxs("div",{className:"mt-6 grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Rules executed"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:rt.actions_executed??_e.actions_executed??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Actions triggered"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:rt.actions_triggered??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Historically operations processed"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:rt.apply_processed??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Historically operations updated"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:rt.apply_updated??0})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"text-tremor-title font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong mb-2",children:"Actions by type"}),l.jsx(Uu,{data:Object.entries(_e.actions_by_type||{}).map(([Ie,lt])=>({name:Ie,value:lt}))})]})]})]}),l.jsxs(Mt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:Qye,width:24,height:24,alt:"","aria-hidden":"true",className:"inline-block"}),l.jsx(On,{className:"!mb-0",children:"Inspectr MCP Server"})]}),l.jsx(pt,{className:"mt-1 text-gray-500",children:"Overview of Model Context Protocol (MCP) activity on the Inspectr MCP server, including usage across tools, resources, and prompts."}),M&&Ye&&l.jsxs("div",{className:"mt-4 rounded-md bg-gray-50 p-6 ring-1 ring-inset ring-gray-200 dark:bg-gray-900 dark:ring-gray-800",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Want to upgrade?"}),l.jsx("p",{className:"mt-2 text-sm/6 text-gray-500 dark:text-gray-500",children:"Elevate your workspace and boost productivity with premium features. See our pro plans and upgrade today."}),l.jsxs("div",{className:"mt-6 flex items-center space-x-2",children:[l.jsx("a",{href:"https://inspectr.dev/pricing",target:"_blank",rel:"noreferrer noopener",className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border px-3 py-2 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-yellow-500 dark:outline-yellow-500 border-transparent text-white dark:text-white bg-yellow-500 dark:bg-yellow-500 hover:bg-yellow-600 dark:hover:bg-yellow-600 disabled:bg-blue-300 disabled:text-white disabled:dark:bg-blue-800 disabled:dark:text-blue-400",children:"Explore Plans"}),l.jsx("button",{type:"button",className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border px-3 py-2 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 disabled:dark:text-gray-600",onClick:()=>D(!1),children:"Dismiss"})]})]}),oe&&l.jsxs("div",{className:"mt-6",children:[l.jsx(pt,{className:"mb-2",children:"Remaining usage"}),l.jsx(M2,{value:ye,color:"blue"}),l.jsxs(pt,{className:"mt-2",children:[fe," of ",oe," uses"]}),(ae||U||ie)&&l.jsxs(pt,{className:"mt-1 text-gray-500",children:[ae?`${ae} window`:"Usage window",U?` since ${U}`:"",ie?` — resets on ${ie}`:""]})]}),l.jsxs("div",{className:"mt-6 grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[l.jsx("h4",{className:"text-tremor-title font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Usage"}),l.jsxs("div",{children:[l.jsxs("p",{className:"flex items-center text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:[l.jsx("img",{src:exe,width:16,height:16,alt:"","aria-hidden":"true",className:"w-4 h-4 mr-2"}),"Total tools"]}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Y.tools??0})]}),l.jsxs("div",{children:[l.jsxs("p",{className:"flex items-center text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:[l.jsx("img",{src:txe,width:16,height:16,alt:"","aria-hidden":"true",className:"w-4 h-4 mr-2"}),"Total resources"]}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Y.resources??0})]}),l.jsxs("div",{children:[l.jsxs("p",{className:"flex items-center text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:[l.jsx("img",{src:rxe,width:16,height:16,alt:"","aria-hidden":"true",className:"w-4 h-4 mr-2"}),"Total prompts"]}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Y.prompts??0})]})]}),l.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[l.jsx("h4",{className:"text-tremor-title font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Traffic"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total requests"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Y.requests??0})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total responses"}),l.jsx("p",{className:"font-semibold text-tremor-metric text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Y.responses??0})]})]})]})]})]})};function ixe(...e){return e.filter(Boolean).join(" ")}function sxe({overall:e}){if(!e)return l.jsx("div",{children:"Loading KPI..."});const t=[{name:"Total Requests",stat:e.total_requests,change:"",changeType:"neutral"},{name:"Average Response Time",stat:`${e.average_response_time} ms`,change:"",changeType:"neutral"},{name:"Success Rate",stat:`${(e.success_rate*100).toFixed(1)}%`,change:"",changeType:"neutral"},{name:"Error Rate",stat:`${(e.error_rate*100).toFixed(1)}%`,change:"",changeType:"neutral"}],r=t.length;return l.jsx("dl",{className:`grid grid-cols-1 gap-${r} sm:grid-cols-2 lg:grid-cols-${r}`,children:t.map(n=>l.jsxs(Mt,{children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("dt",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:n.name}),n.change&&l.jsx("span",{className:ixe(n.changeType==="positive"?"bg-emerald-100 text-emerald-800 ring-emerald-600/10 dark:bg-emerald-400/10 dark:text-emerald-500 dark:ring-emerald-400/20":"bg-red-100 text-red-800 ring-red-600/10 dark:bg-red-400/10 dark:text-red-500 dark:ring-red-400/20","inline-flex items-center rounded-tremor-small px-2 py-1 text-tremor-label font-medium ring-1 ring-inset"),children:n.change})]}),l.jsx("dd",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:n.stat})]},n.name))})}function lxe(...e){return e.filter(Boolean).join(" ")}function cxe({title:e="Traffic Volume",data:t,valueFormatter:r}){const n=Array.isArray(t)?t:[],o=n.reduce((s,c)=>(s["2xx"]+=c["2xx"]||0,s["3xx"]+=c["3xx"]||0,s["4xx"]+=c["4xx"]||0,s["5xx"]+=c["5xx"]||0,s),{"2xx":0,"3xx":0,"4xx":0,"5xx":0}),a=r||(s=>Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(s)),i=[{name:"2xx",value:o["2xx"],color:"bg-blue-500"},{name:"3xx",value:o["3xx"],color:"bg-orange-500"},{name:"4xx",value:o["4xx"],color:"bg-cyan-500"},{name:"5xx",value:o["5xx"],color:"bg-red-500"}];return l.jsxs(Mt,{className:"mt-4 h-120 rounded-tremor-small p-2",children:[l.jsx("h3",{className:"font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e}),l.jsx("ul",{role:"list",className:"mt-6 grid gap-3 sm:grid-cols-4 md:grid-cols-4",children:i.map(s=>l.jsxs("li",{className:"rounded-tremor-small border border-tremor-border px-3 py-2 text-left dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center space-x-1.5",children:[l.jsx("span",{className:lxe(s.color,"size-2.5 rounded-sm"),"aria-hidden":"true"}),l.jsx("p",{className:"text-tremor-label text-tremor-content dark:text-dark-tremor-content",children:s.name})]}),l.jsx("p",{className:"mt-0.5 font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:a(s.value)})]},s.name))}),l.jsx(eh,{data:n,index:"date",categories:["2xx","3xx","4xx","5xx"],colors:["blue","orange","cyan","red"],showLegend:!1,valueFormatter:a,yAxisWidth:50,stack:!0,className:"mt-6 hidden h-80 w-full sm:block"}),l.jsx(eh,{data:n,index:"date",categories:["2xx","3xx","4xx","5xx"],colors:["blue","orange","cyan","red"],showLegend:!1,valueFormatter:a,showYAxis:!1,stack:!0,className:"mt-6 h-48 w-full sm:hidden"})]})}function uxe(e,t){return t==="ms"?`${Math.round(e)}`:new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}function gw({title:e="Response Times",data:t,metricKey:r=[],metricUnit:n="",highlightValue:o="",highlightLabel:a=""}){const i=Array.isArray(r)?r:[r],s=c=>uxe(c,n);return l.jsxs(Mt,{className:"mt-4 h-120 rounded-tremor-small p-2",children:[l.jsx("h3",{className:"font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e}),l.jsxs("div",{className:"p-6",children:[l.jsx("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:a}),l.jsxs("p",{className:"text-2xl font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[o,n?` ${n}`:""]}),l.jsx(Gd,{data:t,index:"date",categories:i,showGradient:!1,valueFormatter:s,className:"mt-8 hidden h-80 w-full sm:block"}),l.jsx(Gd,{data:t,index:"date",categories:i,showGradient:!1,valueFormatter:s,className:"mt-8 h-48 w-full sm:hidden"})]})]})}function dxe(...e){return e.filter(Boolean).join(" ")}function lD({className:e=""}){return l.jsx("div",{className:dxe("flex items-center justify-center w-full h-full border border-dashed rounded-tremor-default border-tremor-border dark:border-dark-tremor-border",e),children:l.jsx("p",{className:"text-tremor-content text-tremor-default dark:text-dark-tremor-content",children:"No data"})})}const fxe=e=>`${Intl.NumberFormat("us").format(e).toString()}`;function Ei({title:e,data:t,toggleable:r=!0}){const[n,o]=p.useState(!0),a=r?n:!0,i=t?t.map(c=>({name:c.p95_response_time!=null?`${c.path} (P95: ${c.p95_response_time} ms)`:c.path,value:c.count})):[],s=i.length>0;return l.jsxs(Mt,{className:"mt-4 rounded-tremor-small p-2",children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-tremor-border p-3 dark:border-dark-tremor-border",children:[l.jsx("p",{className:"font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e}),l.jsx("p",{className:"text-tremor-label font-medium uppercase text-tremor-content dark:text-dark-tremor-content",children:"Totals"})]}),l.jsx("div",{className:`overflow-hidden p-6 ${a?"":"max-h-[260px]"}`,children:s?l.jsx(Uu,{data:i,valueFormatter:fxe}):l.jsx(lD,{className:"min-h-[150px]"})}),r&&s&&l.jsx("div",{className:`flex justify-center ${n?"px-6 pb-6":"absolute inset-x-0 bottom-0 rounded-b-tremor-default bg-gradient-to-t from-tremor-background to-transparent py-7 dark:from-dark-tremor-background"}`,children:l.jsx("button",{className:"flex items-center justify-center rounded-tremor-small border border-tremor-border bg-tremor-background px-2.5 py-2 text-tremor-default font-medium text-tremor-content-strong shadow-tremor-input hover:bg-tremor-background-muted dark:border-dark-tremor-border dark:bg-dark-tremor-background dark:text-dark-tremor-content-strong dark:shadow-dark-tremor-input hover:dark:bg-dark-tremor-background-muted",onClick:()=>o(!n),children:n?"Show less":"Show more"})})]})}function mxe(...e){return e.filter(Boolean).join(" ")}function Cm({title:e="Donut Chart",description:t="",data:r,valueFormatter:n,colors:o}){const a=["bg-blue-500","bg-violet-500","bg-fuchsia-500","bg-emerald-500","bg-sky-500"],i=o||["blue","violet","fuchsia","emerald","sky"],s=n||(u=>`${u}`);let c=[];if(Array.isArray(r))c=r;else if(r&&typeof r=="object"){const u=Object.entries(r),d=u.reduce((f,[,h])=>f+h,0);c=u.map(([f,h],m)=>({name:f,amount:h,share:d>0?`${(h/d*100).toFixed(1)}%`:"0%",borderColor:a[m%a.length]}))}return l.jsxs(Mt,{className:"mt-4 h-120 rounded-tremor-small p-2",children:[l.jsx("h3",{className:"text-tremor-default font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e}),t&&l.jsx("p",{className:"mt-1 text-tremor-default leading-6 text-tremor-content dark:text-dark-tremor-content",children:t}),l.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-0 sm:grid-cols-2 sm:gap-8",children:[l.jsx(dI,{data:c,category:"amount",index:"name",valueFormatter:s,showTooltip:!0,className:"h-40 w-full",colors:i}),l.jsx("div",{className:"mt-6 flex items-center sm:mt-0",children:l.jsx("ul",{role:"list",className:"space-y-3",children:c.map(u=>l.jsxs("li",{className:"flex space-x-3",children:[l.jsx("span",{className:mxe(u.borderColor,"w-1 shrink-0 rounded")}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-tremor-default font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[s(u.amount)," ",l.jsxs("span",{className:"font-normal",children:["(",u.share,")"]})]}),l.jsx("p",{className:"mt-0.5 whitespace-nowrap text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:u.name})]})]},u.name))})})]})]})}const pxe=({open:e,onClose:t,onConfirm:r,title:n="Clear All",message:o="Are you sure you want to clear all? This action cannot be undone.",confirmButtonText:a="Clear All"})=>e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("div",{className:"flex-shrink-0 bg-red-100 rounded-full p-2",children:l.jsx("svg",{className:"size-6 text-red-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})})}),l.jsxs("div",{className:"ml-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:n}),l.jsx("p",{className:"mt-2 text-sm text-gray-500",children:o})]})]}),l.jsxs("div",{className:"mt-6 flex justify-end space-x-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-200 rounded hover:bg-gray-300 text-sm",children:"Cancel"}),l.jsx("button",{onClick:()=>{r(),t()},className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 text-sm",children:a})]})]})]}):null;function RP(e){return e==null||Number.isNaN(e)?"":`${Math.round(e)}`}function hxe({active:e,label:t,onClick:r}){return l.jsx("button",{type:"button",onClick:r,className:["px-2 py-1 text-xs rounded border",e?"bg-tremor-brand text-tremor-brand-inverted dark:bg-dark-tremor-brand dark:text-dark-tremor-brand-inverted border-transparent":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-600 hover:bg-gray-200 dark:hover:bg-gray-600"].join(" "),children:t})}function gxe({title:e="HTTP Request duration: p50, p90, p95, p99",data:t=[]}){const r=["p50","p90","p95","p99"],n=p.useMemo(()=>{if(!Array.isArray(t))return[];const f=new Set;for(const h of t)for(const m of r)h&&typeof h[m]=="number"&&f.add(m);return r.filter(h=>f.has(h))},[t]),[o,a]=p.useState(new Set(r));p.useEffect(()=>{a(f=>{const h=new Set([...f].filter(m=>n.includes(m)));return h.size===0?new Set(n):(n.forEach(m=>h.add(m)),h)})},[n]);const i=f=>{a(h=>{const m=new Set(h);return m.has(f)?m.delete(f):m.add(f),m})},s={p50:"blue",p90:"violet",p95:"cyan",p99:"rose"},c=p.useMemo(()=>n.filter(f=>o.has(f)),[n,o]),u=p.useMemo(()=>c.map(f=>s[f]),[c]),d=Array.isArray(t)&&t.length>0&&n.length>0;return l.jsxs(Mt,{className:"mt-4 rounded-tremor-small p-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e}),l.jsx("div",{className:"flex gap-2",children:r.map(f=>l.jsx(hxe,{label:f.toUpperCase(),active:o.has(f),onClick:()=>i(f)},f))})]}),l.jsxs("div",{className:"p-6",children:[d?c.length===0?l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"No percentile selected. Toggle one or more options above."}):l.jsxs(l.Fragment,{children:[l.jsx(Gd,{data:t,index:"date",categories:c,colors:u,showGradient:!1,valueFormatter:RP,className:"mt-4 hidden h-80 w-full sm:block"}),l.jsx(Gd,{data:t,index:"date",categories:c,colors:u,showGradient:!1,valueFormatter:RP,className:"mt-4 h-48 w-full sm:hidden"})]}):l.jsx(lD,{className:"h-40"}),d?l.jsx("p",{className:"mt-3 text-xs text-gray-500 dark:text-gray-400",children:"Values in milliseconds"}):null]})]})}function Lu(...e){return e.filter(Boolean).join(" ")}function Wm({tags:e=[],selectedTag:t,onSelect:r,disabled:n=!1,loading:o=!1,error:a,fullWidth:i=!1}){const[s,c]=p.useState(!1),u=p.useRef(null),d=p.useRef(null),f=!!t;p.useEffect(()=>{if(!s)return;const v=w=>{!d.current||!u.current||d.current.contains(w.target)||u.current.contains(w.target)||c(!1)},x=w=>{var E;w.key==="Escape"&&(c(!1),(E=u.current)==null||E.focus())};return document.addEventListener("mousedown",v),document.addEventListener("touchstart",v),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("touchstart",v),document.removeEventListener("keydown",x)}},[s]);const h=()=>{n||c(v=>!v)},m=()=>c(!1),g=v=>{n||(r?.(v),m())},b="tag-filter-dropdown-label";return l.jsxs("div",{className:Lu("relative inline-block text-left",i?"w-full":""),children:[l.jsxs("button",{type:"button",ref:u,onClick:h,onKeyDown:v=>{v.key==="ArrowDown"&&!s&&(v.preventDefault(),c(!0))},disabled:n,"aria-haspopup":"menu","aria-expanded":s,"aria-labelledby":b,className:Lu("inline-flex items-center gap-2 rounded-tremor-small border border-tremor-border bg-tremor-background px-3 py-2 text-sm font-medium text-tremor-content-strong shadow-tremor-input transition focus:z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-tremor-brand/60 min-h-[42px]",i?"w-full justify-start":"","hover:bg-tremor-background-subtle disabled:cursor-not-allowed disabled:opacity-70","dark:border-dark-tremor-border dark:bg-gray-950 dark:text-dark-tremor-content-strong dark:shadow-dark-tremor-input dark:hover:bg-gray-950/60"),children:[l.jsx("span",{id:b,className:"sr-only",children:"Filter statistics by tag"}),l.jsx(mR,{className:"h-4 w-4","aria-hidden":!0}),f?l.jsx(rl,{tag:t}):l.jsx("span",{className:"text-xs uppercase tracking-wide",children:"All tags"})]}),s?l.jsxs("div",{ref:d,role:"menu","aria-orientation":"vertical","aria-labelledby":b,className:Lu("absolute z-50 mt-2 w-64 rounded-md border border-tremor-border bg-tremor-background p-2 shadow-xl shadow-black/[2.5%] focus:outline-none dark:border-dark-tremor-border dark:bg-gray-950",i?"left-0 right-auto origin-top-left":"right-0 origin-top-right"),children:[l.jsx("div",{className:"px-2 pb-2 text-xs font-semibold uppercase tracking-wide text-tremor-content dark:text-dark-tremor-content",children:"Select a tag"}),l.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[l.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":!f,onClick:()=>g(null),className:Lu("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm transition","text-gray-500 hover:bg-tremor-background-subtle focus:outline-none focus-visible:bg-tremor-background-subtle dark:text-gray-400 dark:hover:bg-dark-tremor-background dark:focus-visible:bg-dark-tremor-background",f?"":"font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong"),children:[l.jsx("span",{className:"text-xs font-medium uppercase tracking-wide",children:"All tags"}),f?null:l.jsx(pS,{className:"ml-auto h-4 w-4 text-tremor-brand dark:text-dark-tremor-brand","aria-hidden":!0})]}),l.jsx("div",{className:"my-2 h-px bg-tremor-border dark:bg-dark-tremor-border"}),o?l.jsx("div",{className:"px-2 py-4 text-center text-xs text-gray-500 dark:text-gray-400",children:"Loading tags…"}):e.length===0?l.jsx("div",{className:"px-2 py-4 text-center text-xs text-gray-500 dark:text-gray-400",children:a||"No tags available"}):e.map(v=>{const x=t===v;return l.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":x,onClick:()=>g(v),className:Lu("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm transition","text-tremor-content-strong hover:bg-tremor-background-subtle focus:outline-none focus-visible:bg-tremor-background-subtle dark:text-dark-tremor-content-strong dark:hover:bg-dark-tremor-background dark:focus-visible:bg-dark-tremor-background",x?"font-semibold":""),children:[l.jsx(rl,{tag:v}),x?l.jsx(pS,{className:"ml-auto h-4 w-4 text-tremor-brand dark:text-dark-tremor-brand","aria-hidden":!0}):null]},v)})]})]}):null]})}const cD=(e,t=0,r=0,n=0,o=0)=>new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,r,n,o),rb=e=>!(e instanceof Date)||Number.isNaN(e.getTime())?new Date(0).toISOString():cD(e).toISOString(),nb=e=>!(e instanceof Date)||Number.isNaN(e.getTime())?new Date(0).toISOString():cD(e,23,59,59,999).toISOString(),Du=(e,t,r)=>{const n=rb(t),o=nb(r);return{label:e,start:n,end:o,tooltip:`${n} – ${o}`}},uD=(e=new Date)=>{const t=e instanceof Date?new Date(e):new Date,r=t;return new Date(r.getTime()-60*60*1e3),[Du("Today",t,t),Du("7D",new Date(t.getTime()-7*24*60*60*1e3),t),Du("30D",new Date(t.getTime()-30*24*60*60*1e3),t),Du("3M",new Date(t.getUTCFullYear(),t.getUTCMonth()-3,t.getUTCDate()),t),Du("6M",new Date(t.getUTCFullYear(),t.getUTCMonth()-6,t.getUTCDate()),t)]},dD=(e,t=new Date)=>e&&uD(t).find(r=>r.label===e)||null,FP=(...e)=>e.filter(Boolean).join(" ");function WN({selectedRange:e,onSelect:t,onCustomClick:r,referenceDate:n}){const o=p.useMemo(()=>uD(n),[n]);return l.jsxs("div",{className:"inline-flex items-center rounded shadow",children:[o.map((a,i)=>l.jsx("button",{onClick:()=>t?.(a),title:a.tooltip,type:"button",className:FP(i===0?"rounded-l":i===o.length-1?"-ml-px rounded-r":"-ml-px","border px-3 py-1 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-tremor-brand/60",e===a.label?"bg-tremor-brand text-tremor-brand-inverted dark:bg-dark-tremor-brand dark:text-dark-tremor-brand-inverted":"bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"),children:a.label},a.label)),l.jsx("button",{onClick:r,title:"Set custom date range",type:"button",className:FP("-ml-px rounded-r","border px-3 py-1 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-tremor-brand/60",e==="Custom"?"bg-tremor-brand text-tremor-brand-inverted dark:bg-dark-tremor-brand dark:text-dark-tremor-brand-inverted":"bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"),children:"Custom"})]})}function $P(e){return new Date(e).toLocaleString("en-GB",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function bxe(e){return new Date(e).toLocaleString("en-GB",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function bw(e){return Array.isArray(e)?e.map(t=>{const r={...t,date:bxe(t.date)};return t.median_response_time!=null&&(r.p50=t.median_response_time),t.p90_response_time!=null&&(r.p90=t.p90_response_time),t.p95_response_time!=null&&(r.p95=t.p95_response_time),t.p99_response_time!=null&&(r.p99=t.p99_response_time),r}):[]}function vxe({tag:e}){return e?l.jsx(rl,{tag:e}):l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"All operations"})}function fD(e,t,{includeTopMargin:r=!0,layout:n="overview"}={}){var o,a,i,s,c,u,d,f,h,m,g,b,v,x,w;const E=n==="compare",j="mt-6 grid grid-cols-1 gap-4";return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:r?"mt-6":"",children:l.jsx(sxe,{overall:e?.overall})}),l.jsxs("div",{className:E?j:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-2 lg:grid-cols-2",children:[l.jsx(cxe,{title:"Traffic Volume",data:t}),l.jsx(gw,{title:"Average Response Times",data:t,metricKey:["min_response_time","average_response_time","max_response_time"],metricUnit:"ms",highlightValue:(o=e?.overall)==null?void 0:o.average_response_time,highlightLabel:"Average Response Time"})]}),l.jsx("div",{className:"mt-6 grid grid-cols-1",children:l.jsx(gxe,{title:"HTTP Request duration: p50, p90, p95, p99",data:t})}),E?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:j,children:[l.jsx(gw,{title:"Success / Error Rate",data:t,metricKey:["success","errors"],metricUnit:"",highlightValue:(a=e?.overall)==null?void 0:a.average_errors,highlightLabel:"Average Errors"}),l.jsx(Ei,{title:"Top Endpoints",data:(i=e?.top_endpoints)==null?void 0:i.all,toggleable:!1})]}),l.jsxs("div",{className:j,children:[l.jsx(Cm,{title:"Method Ratio",description:"Distribution of HTTP methods",data:(s=e?.totals)==null?void 0:s.method}),l.jsx(Cm,{title:"Status Ratio",description:"Distribution of HTTP status codes",data:(c=e?.totals)==null?void 0:c.status}),l.jsx(Ei,{title:"Top Failed Endpoints",data:(u=e?.top_endpoints)==null?void 0:u.error,toggleable:!1})]}),l.jsxs("div",{className:j,children:[l.jsx(Ei,{title:"Top Fastest Endpoints (P95)",data:(d=e?.top_endpoints)==null?void 0:d.fastest,toggleable:!1}),l.jsx(Ei,{title:"Top Slowest Endpoints (P95)",data:(f=e?.top_endpoints)==null?void 0:f.slowest,toggleable:!1})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"mt-6 grid grid-cols-3 gap-4 items-stretch",children:[l.jsx("div",{className:"col-span-2",children:l.jsx(gw,{title:"Success / Error Rate",data:t,metricKey:["success","errors"],metricUnit:"",highlightValue:(h=e?.overall)==null?void 0:h.average_errors,highlightLabel:"Average Errors"})}),l.jsx("div",{className:"col-span-1",children:l.jsx(Ei,{title:"Top Endpoints",data:(m=e?.top_endpoints)==null?void 0:m.all,toggleable:!1})})]}),l.jsxs("div",{className:"mt-6 grid grid-cols-3 gap-4 md:grid-cols-3 lg:grid-cols-3",children:[l.jsx(Cm,{title:"Method Ratio",description:"Distribution of HTTP methods",data:(g=e?.totals)==null?void 0:g.method}),l.jsx(Cm,{title:"Status Ratio",description:"Distribution of HTTP status codes",data:(b=e?.totals)==null?void 0:b.status}),l.jsx(Ei,{title:"Top Failed Endpoints",data:(v=e?.top_endpoints)==null?void 0:v.error,toggleable:!1})]}),l.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-2 lg:grid-cols-2",children:[l.jsx(Ei,{title:"Top Fastest Endpoints (P95)",data:(x=e?.top_endpoints)==null?void 0:x.fastest,toggleable:!1}),l.jsx(Ei,{title:"Top Slowest Endpoints (P95)",data:(w=e?.top_endpoints)==null?void 0:w.slowest,toggleable:!1})]})]})]})}function BP({label:e,tag:t,stats:r,intervalData:n,loading:o}){const a=!!r;return l.jsxs("div",{className:"rounded-tremor-small border border-tremor-border bg-tremor-background p-4 shadow-sm dark:border-dark-tremor-border dark:bg-gray-950",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e}),l.jsx("div",{className:"mt-1",children:l.jsx(vxe,{tag:t})})]}),o?l.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Loading…"}):null]}),a?l.jsx("div",{className:"mt-4",children:fD(r,n,{includeTopMargin:!1,layout:"compare"})}):l.jsx("p",{className:"mt-4 text-sm text-gray-500 dark:text-gray-400",children:o?"Loading statistics…":"No data available for this selection."})]})}function yxe(){const{client:e}=yr();fa("feat_statistics_compare",!1,!0);const[t,r]=p.useState(null),[n,o]=p.useState(!1),[a,i]=p.useState(null),[s,c]=p.useState("hour"),[u,d]=p.useState([]),[f,h]=p.useState(!1),[m,g]=p.useState(""),[b,v]=p.useState(null),[x,w]=p.useState("overview"),[E,j]=p.useState(null),[S,C]=p.useState(void 0),[O,T]=p.useState(null),[P,M]=p.useState(null),[D,R]=p.useState(!1),[F,_]=p.useState(null),L=new Date,V=rb(L),$=nb(L),[B,z]=p.useState("Today"),[q,W]=p.useState(V),[J,Y]=p.useState($),[ne,Z]=p.useState(!1),[de,te]=p.useState(new Date(L.getTime()-7*24*60*60*1e3).toISOString().split("T")[0]),[oe,G]=p.useState("00:00"),[ce,ae]=p.useState(L.toISOString().split("T")[0]),[U,ie]=p.useState("23:59"),[fe,ye]=p.useState(!1),Ce=async Ge=>{var Ve,Vt,In,Ir,at,wn;const mr={from:q,to:J,interval:s,tag:Ge||void 0},[tr,Me,kn,Ar,fo,Yo,fn,hi]=await Promise.all([e.stats.getOverview(mr),e.stats.getBuckets(mr),e.stats.aggregateBy("method",{...mr,order:"-count",metrics:["count"]}),e.stats.aggregateBy("status",{...mr,order:"-count",metrics:["count"]}),e.stats.aggregateBy("path",{...mr,order:"-count",metrics:["count"],limit:10}),e.stats.aggregateBy("path",{...mr,statusClass:["4xx","5xx"],order:"-count",metrics:["count"],limit:10}),e.stats.aggregateBy("path",{...mr,order:"+p95_ms",metrics:["count","p95_ms"],limit:10}),e.stats.aggregateBy("path",{...mr,order:"-p95_ms",metrics:["count","p95_ms"],limit:10})]),gi=tr?.data??tr?.overall??tr??null,Ln=(Me?.data??[]).map(ut=>{const Zt=ut?.series??{},Pa=Number(Zt["2xx"]??0),Co=Number(Zt["3xx"]??0),Yn=Number(Zt["4xx"]??0),we=Number(Zt["5xx"]??0),Ue=(typeof ut.requests=="number"?ut.requests:ut.total_requests)??Pa+Co+Yn+we,yt=(typeof ut.success=="number"?ut.success:void 0)??Pa+Co,Bt=(typeof ut.errors=="number"?ut.errors:void 0)??Yn+we;return{date:ut.timestamp||ut.date,total_requests:Ue,success:yt,errors:Bt,"2xx":Pa,"4xx":Yn,"5xx":we,average_response_time:ut.avg_ms??ut.average_response_time,min_response_time:ut.min_ms??ut.min_response_time,max_response_time:ut.max_ms??ut.max_response_time,median_response_time:ut.p50_ms??ut.median_response_time,p90_response_time:ut.p90_ms??ut.p90_response_time,p95_response_time:ut.p95_ms??ut.p95_response_time,p99_response_time:ut.p99_ms??ut.p99_response_time}}),Vn={method:Object.fromEntries((((Ve=kn?.data)==null?void 0:Ve.rows)??[]).map(ut=>[ut.method,ut.count])),status:Object.fromEntries((((Vt=Ar?.data)==null?void 0:Vt.rows)??[]).map(ut=>[String(ut.status),ut.count]))},ln=ut=>(ut??[]).map(Zt=>({path:Zt.path,count:Zt.count,p95_response_time:Zt.p95_ms??Zt.p95_response_time})),Kn={all:ln((In=fo?.data)==null?void 0:In.rows),error:ln((Ir=Yo?.data)==null?void 0:Ir.rows),fastest:ln((at=fn?.data)==null?void 0:at.rows),slowest:ln((wn=hi?.data)==null?void 0:wn.rows)};return{overall:gi,by_interval:Ln,totals:Vn,top_endpoints:Kn}},Pe=async()=>{var Ge;if((Ge=e?.stats)!=null&&Ge.getOverview){o(!0),i(null);try{const Ve=await Ce(b);r(Ve)}catch(Ve){console.error(Ve),i(Ve?.message||"Failed to load statistics")}finally{o(!1)}}},$e=async()=>{var Ge;if((Ge=e?.stats)!=null&&Ge.getOverview&&S!==void 0){R(!0),_(null);try{const[Ve,Vt]=await Promise.all([Ce(E),Ce(S)]);T(Ve),M(Vt)}catch(Ve){console.error(Ve),_(Ve?.message||"Failed to load comparison data")}finally{R(!1)}}},rt=()=>x==="compare"?$e():Pe(),_e=async()=>{try{await e.stats.deleteOperations(),await Pe(),x==="compare"&&await $e()}catch(Ge){console.error("Error clearing all operation stats:",Ge)}};p.useEffect(()=>{Pe()},[e,s,q,J,b]),p.useEffect(()=>{x==="compare"&&$e()},[e,x,s,q,J,E,S]),p.useEffect(()=>{var Ge;if(!((Ge=e?.operations)!=null&&Ge.listTags))return;let Ve=!1;return(async()=>{try{h(!0),g("");const Vt=await e.operations.listTags();if(Ve)return;const In=Array.isArray(Vt?.tags)?[...Vt.tags]:[];In.sort((Ir,at)=>Ir.localeCompare(at)),d(In)}catch(Vt){if(Ve)return;console.error("Failed to load tags",Vt),d([]),g(Vt?.message||"Failed to load tags")}finally{Ve||h(!1)}})(),()=>{Ve=!0}},[e]),p.useEffect(()=>{b&&(u.includes(b)||v(null))},[u,b]),p.useEffect(()=>{E&&(u.includes(E)||j(null))},[u,E]),p.useEffect(()=>{if(S!=null&&!u.includes(S)){const Ge=u.find(Ve=>Ve!==E)??null;C(Ge)}},[u,E,S]),p.useEffect(()=>{if(S!==void 0)return;if(u.length===0){C(null);return}const Ge=u.find(Ve=>Ve!==E)??u[0];C(Ge??null)},[u,E,S]);const nt=p.useMemo(()=>bw(t?.by_interval),[t?.by_interval]),Qe=p.useMemo(()=>bw(O?.by_interval),[O?.by_interval]),ot=p.useMemo(()=>bw(P?.by_interval),[P?.by_interval]),ft=x==="compare"?1:0,et=x==="compare"?D:n,vt=S===void 0?null:S,Ye=Ge=>{w(Ge===1?"compare":"overview")},We=Ge=>{z(Ge.label),W(Ge.start),Y(Ge.end),Z(!1)},Ie=()=>{Z(!ne),ne||z("Custom")},lt=()=>{const Ge=new Date(`${de}T${oe}:00`),Ve=new Date(`${ce}T${U}:00`);W(Ge.toISOString()),Y(Ve.toISOString()),z("Custom"),Z(!1)};return l.jsxs(l.Fragment,{children:[l.jsx("header",{children:l.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[l.jsx("h3",{className:"text-tremor-title font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Inspectr Statistics"}),l.jsxs("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400 sm:mt-0",children:[l.jsx("span",{className:"font-medium",children:"Range:"})," ",$P(q)," -"," ",$P(J)]})]})}),l.jsxs(Rc,{index:ft,onIndexChange:Ye,children:[l.jsxs("div",{className:"relative mt-4",children:[l.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-start md:justify-between",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs(Dc,{className:"w-auto",children:[l.jsx(to,{children:"Overview"}),l.jsx(to,{children:"Compare"})]}),x==="overview"?l.jsx(Wm,{tags:u,selectedTag:b,onSelect:v,disabled:et,loading:f,error:m}):l.jsx("div",{className:"flex flex-wrap items-end gap-3",children:l.jsxs("div",{className:"flex flex-row gap-1 items-center",children:[l.jsx(Wm,{tags:u,selectedTag:E,onSelect:j,disabled:et,loading:f,error:m}),l.jsx(Wm,{tags:u,selectedTag:vt,onSelect:C,disabled:et,loading:f,error:m})]})})]}),l.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[l.jsx(WN,{selectedRange:B,onSelect:We,onCustomClick:Ie}),l.jsxs(HN,{className:"w-full sm:w-fit [&>button]:rounded-tremor-small",enableClear:!1,value:s,onValueChange:Ge=>c(Ge),children:[l.jsx(Bi,{value:"hour",children:"Hourly"}),l.jsx(Bi,{value:"day",children:"Daily"}),l.jsx(Bi,{value:"week",children:"Weekly"}),l.jsx(Bi,{value:"month",children:"Monthly"})]}),l.jsx(Jl,{onClick:rt,disabled:et,children:et?"Loading":"Refresh"}),l.jsxs("button",{type:"button",className:"rounded bg-red-500 px-2 py-2 text-xs text-white",onClick:()=>ye(!0),children:[l.jsx("span",{className:"sr-only",children:"Clear all operation stats"}),l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"h-4 w-4","aria-hidden":!0,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})]})]})]}),m&&!f?l.jsxs("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:["Tag filter unavailable: ",m]}):null,ne&&l.jsxs("div",{className:"absolute top-full right-0 z-10 mt-2 flex flex-wrap items-center gap-2 rounded bg-gray-50 p-3 shadow dark:bg-gray-800",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Start Date"}),l.jsx("input",{type:"date",value:de,onChange:Ge=>te(Ge.target.value),className:"rounded border px-2 py-1 focus:outline-none focus:ring-2 focus:ring-tremor-brand dark:border-gray-600 dark:bg-gray-700"})]}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Start Time"}),l.jsx("input",{type:"time",value:oe,onChange:Ge=>G(Ge.target.value),className:"rounded border px-2 py-1 focus:outline-none focus:ring-2 focus:ring-tremor-brand dark:border-gray-600 dark:bg-gray-700"})]}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:"End Date"}),l.jsx("input",{type:"date",value:ce,onChange:Ge=>ae(Ge.target.value),className:"rounded border px-2 py-1 focus:outline-none focus:ring-2 focus:ring-tremor-brand dark:border-gray-600 dark:bg-gray-700"})]}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("label",{className:"text-xs text-gray-500 dark:text-gray-400",children:"End Time"}),l.jsx("input",{type:"time",value:U,onChange:Ge=>ie(Ge.target.value),className:"rounded border px-2 py-1 focus:outline-none focus:ring-2 focus:ring-tremor-brand dark:border-gray-600 dark:bg-gray-700"})]}),l.jsx("div",{className:"flex items-end",children:l.jsx(Jl,{onClick:lt,className:"ml-2",children:"Apply"})})]})]}),l.jsxs(Fc,{children:[l.jsxs(ro,{children:[a?l.jsxs("p",{className:"mt-4 text-red-600 dark:text-red-400",children:["Error: ",a]}):null,l.jsx("main",{className:"mt-6",children:fD(t,nt)})]}),l.jsxs(ro,{children:[F?l.jsxs("p",{className:"mt-4 text-red-600 dark:text-red-400",children:["Comparison error: ",F]}):null,l.jsx("main",{className:"mt-6",children:l.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-2",children:[l.jsx(BP,{label:"Input A",tag:E,stats:O,intervalData:Qe,loading:D}),l.jsx(BP,{label:"Input B",tag:vt,stats:P,intervalData:ot,loading:D})]})})]})]})]}),l.jsx(pxe,{open:fe,onClose:()=>ye(!1),title:"Clear All Operation Stats?",message:"Are you sure you want to clear all operation stats? This action cannot be undone.",onConfirm:_e})]})}const xxe=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"}],wxe=e=>{if(!Array.isArray(e)||e.length===0)return[];const t=new Set;return e.map(r=>{if(!r||typeof r!="object")return null;const n=r.operator||r.value||r.op;if(!n||typeof n!="string")return null;const o=n.trim();if(!o||t.has(o))return null;t.add(o);const a=Array.isArray(r.aliases)?r.aliases.filter(i=>typeof i=="string"&&i.trim()):[];return{operator:o,label:r.label||r.name||o,description:r.description||"",aliases:a,valueRequired:!!(r.value_required??r.valueRequired??r.requiresValue),multiValue:!!(r.multi_value??r.multiValue)}}).filter(Boolean)},kxe=(e=[])=>e.map(t=>({value:t.operator,label:t.label||t.operator,description:t.description||"",valueRequired:t.valueRequired!==!1,multiValue:t.multiValue===!0})),jxe=(e=[])=>e.reduce((t,r)=>{const n=r.label||r.operator;return t[r.operator]=n,(r.aliases||[]).forEach(o=>{t[o]=n}),t},{}),Exe=(e=[])=>e.reduce((t,r)=>(t[r.operator]=r,(r.aliases||[]).forEach(n=>{t[n]=r}),t),{}),mD=(e=[])=>{var t;return((t=e[0])==null?void 0:t.operator)||""},Nxe=[{value:"and",label:"All conditions match"},{value:"or",label:"Any condition matches"}],Sxe={and:"All conditions must match before actions run.",or:"Any condition may match before actions run."},HP={tag:"Apply static tags",tag_dynamic:"Apply dynamic tags"},I2=e=>typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="1":!!e,L2=e=>{if(e?.input==="single_select"&&Array.isArray(e?.choices)&&e.choices.length){if(e.default!=null)return e.default;const t=e.choices[0];return t?.value??""}return typeof e?.type=="string"&&e.type.startsWith("array")?"":e?.type==="object"?{}:e?.type==="boolean"?I2(e.default??!0):e?.default!=null?e.default:""},qm=()=>Math.random().toString(36).slice(2,10),D2=(e=mD())=>({path:"",operator:e,value:"",valueType:"string"}),Vu=e=>({id:qm(),type:e?.type||"",params:(e?.params||[]).reduce((t,r)=>(t[r.name]=L2(r),t),{})}),Ku=e=>Array.isArray(e)?e:typeof e=="string"?e.split(",").map(t=>t.trim()).filter(Boolean):[],ph=e=>e?Array.isArray(e)?e.flatMap(ph):e.left&&e.op?[e]:e.args?e.args.flatMap(ph):[]:[],Oxe=e=>typeof e=="number"?"number":typeof e=="boolean"?"boolean":"string",Cxe=e=>e==null||e===""?"empty":Array.isArray(e)?e.join(", "):typeof e=="object"?JSON.stringify(e):typeof e=="string"?`"${e}"`:typeof e=="boolean"?e?"true":"false":String(e),Axe=e=>HP[e]?HP[e]:e.toString().replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase()),Pxe=(e={})=>{const t=Object.entries(e);return t.length===0?"No parameters configured":t.map(([r,n])=>Array.isArray(n)?`${r}: ${n.join(", ")}`:typeof n=="object"&&n!==null?`${r}: ${JSON.stringify(n)}`:typeof n=="boolean"?`${r}: ${n?"true":"false"}`:`${r}: ${n}`).join(" · ")},Txe=e=>{if(!e)return null;const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const r=Date.now()-t.getTime();if(r<0)return t.toLocaleString();const n=Math.round(r/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const o=Math.round(n/60);if(o<24)return`${o}h ago`;const a=Math.round(o/24);return a<30?`${a}d ago`:t.toLocaleDateString()},zP=(e,t,r)=>{if(!Array.isArray(e))return e;const n=e.length;if(n===0)return e;const o=(t%n+n)%n,a=(r%n+n)%n;if(o===a)return e;const i=[...e],[s]=i.splice(o,1);return i.splice(a,0,s),i},Mxe=({variant:e})=>e==="event"?l.jsx("span",{className:"relative flex aspect-square h-9 items-center justify-center rounded-lg bg-orange-600 dark:bg-orange-500","aria-hidden":"true",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-5 shrink-0 text-white","aria-hidden":"true",children:[l.jsx("path",{d:"M12 2v14"}),l.jsx("path",{d:"m19 9-7 7-7-7"}),l.jsx("circle",{cx:"12",cy:"21",r:"1"})]})}):e==="condition"?l.jsx("span",{className:"relative flex aspect-square h-9 items-center justify-center rounded-lg bg-sky-500 dark:bg-sky-500","aria-hidden":"true",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-5 shrink-0 text-white","aria-hidden":"true",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),l.jsx("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3"}),l.jsx("path",{d:"M9 11.2h5.7"})]})}):l.jsx("span",{className:"relative flex aspect-square h-9 items-center justify-center rounded-lg bg-emerald-500 dark:bg-emerald-500","aria-hidden":"true",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-5 shrink-0 text-white","aria-hidden":"true",children:[l.jsx("path",{d:"M22 12A10 10 0 1 1 12 2"}),l.jsx("path",{d:"M22 2 12 12"}),l.jsx("path",{d:"M16 2h6v6"})]})}),_xe=(e,t,r)=>{var n;const o=String(((n=e.expression)==null?void 0:n.op)||"and").toLowerCase(),a=Sxe[o],i=t[e.event]||{},s=i.name||e.event,c=[e.description,i.description,a].filter(Boolean),u=[{variant:"event",title:s,description:c.join(" · ")}];return ph(e.expression).forEach((d,f)=>{var h,m;const g=r?.[d.op]||d.op,b=Cxe(d.right),v=[];(h=d.left)!=null&&h.path&&v.push(d.left.path),(m=d.right)!=null&&m.path&&v.push(`Compare to ${d.right.path}`),u.push({variant:"condition",title:`Condition ${f+1}: ${g} ${b}`,description:v.join(" · ")})}),(e.actions||[]).forEach((d,f)=>{u.push({variant:"action",title:`Action ${f+1}: ${Axe(d.type)}`,description:Pxe(d.params)})}),u},Ixe=e=>{if(!e||typeof e!="object")return null;const{id:t,updated_at:r,created_at:n,...o}=e,a=`Copy of ${e.name||"Untitled rule"}`;return{...o,name:a,active:!1}},Lxe=({rules:e,events:t,loading:r,error:n,isRefreshing:o,openRuleId:a,onToggleRule:i,onRefresh:s,onEditRule:c,onDeleteRule:u,onCreateRule:d,onStartFromTemplate:f,onApplyHistory:h,actionsDisabled:m=!1,onDuplicateRule:g,onPauseRule:b,onExportRule:v,onImportRule:x,meta:w,licenseUsage:E=null,onPageChange:j,paginationAlwaysShow:S=!1,operatorLabelMap:C={}})=>{const O=p.useMemo(()=>t.reduce((_,L)=>(_[L.type]=L,_),{}),[t]),T=typeof w?.total=="number"?w.total:e.length,P=typeof E?.limit=="number"&&!Number.isNaN(E.limit)?E.limit:null,M=typeof E?.used=="number"&&!Number.isNaN(E.used)?E.used:null,D=Number.isFinite(M)?M:T,R=P!==null?`${D}/${P}`:`${D}`,F=P!==null&&Number.isFinite(D)&&D>=P;return l.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800",children:[l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:iD,width:24,height:24,alt:"","aria-hidden":"true",className:"inline-block"}),l.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Rules"}),l.jsx("span",{className:"inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs font-semibold text-gray-700 dark:bg-gray-800 dark:text-gray-200",children:R})]}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Overview of automation rules currently available on your workspace."})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("button",{type:"button",onClick:x,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-900",children:"Import rule"}),l.jsx("button",{type:"button",onClick:f,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-900",children:"Start from template"}),l.jsx("button",{type:"button",onClick:d,className:"inline-flex items-center rounded-md border border-transparent bg-blue-500 px-3 py-1.5 text-sm font-medium text-white shadow-sm transition hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-blue-600 dark:hover:bg-blue-500",children:"Add rule"}),l.jsx("button",{type:"button",onClick:()=>s&&s(),title:"Refresh rules",disabled:o||r,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-900",children:o?"Refreshing…":"Refresh"})]})]}),l.jsxs("div",{className:"px-4 py-4",children:[F?l.jsxs("div",{className:"my-2 flex items-center justify-between gap-3 rounded-md bg-gray-50 px-3 py-2 text-sm text-gray-700 ring-1 ring-inset ring-gray-200 dark:bg-gray-900 dark:text-gray-300 dark:ring-gray-800",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-400 dark:bg-gray-400",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"white",className:"size-6",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})})}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Rules limit reached"}),l.jsx("p",{className:"mt-1 text-xs text-gray-600 dark:text-gray-400",children:"You have used all available rules within your plan. View available plans to unlock more capacity."})]})]}),l.jsx("a",{href:"https://inspectr.dev/pricing",target:"_blank",rel:"noreferrer noopener",className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border px-3 py-2 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-transparent text-white dark:text-white bg-yellow-500 dark:bg-yellow-500 hover:bg-yellow-600 dark:hover:bg-blue-600 disabled:bg-blue-300 disabled:text-white disabled:dark:bg-blue-800 disabled:dark:text-blue-400",children:"Discover Plans"})]}):null,r?l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Loading rules…"}):n?l.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:n}):e.length===0?l.jsxs("div",{className:"mt-8 flex h-96 min-h-full flex-1 flex-col justify-center rounded-lg border border-gray-200 bg-gray-50 px-6 py-10 text-center dark:border-gray-700 dark:bg-gray-800",children:[l.jsx("h2",{className:"text-2xl font-semibold text-gray-900 dark:text-gray-50",children:"Get started with rules"}),l.jsx("p",{className:"mt-3 mx-auto max-w-xl text-sm text-gray-500 dark:text-gray-400 sm:text-base",children:"Automate how Inspectr responds to captured operations. Add your first rule or choose a template to jump-start your automation flow."}),l.jsxs("div",{className:"mt-8 flex flex-col items-center justify-center gap-3 sm:flex-row",children:[l.jsx("button",{type:"button",onClick:d,disabled:m||r,className:"inline-flex w-full items-center justify-center rounded-md border border-transparent bg-blue-500 px-3 py-2 text-sm font-medium text-white shadow-sm transition hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-blue-600 dark:hover:bg-blue-500 sm:w-auto",children:"Add rule"}),l.jsx("button",{type:"button",onClick:f,disabled:m||r,className:"inline-flex w-full items-center justify-center gap-1 rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-900 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-50 dark:hover:bg-gray-800/60 sm:w-auto",children:"Start from template"})]})]}):l.jsx("div",{className:"space-y-3",children:e.map(_=>{const L=a===_.id,V=_xe(_,O,C),$=Txe(_.updated_at||_.created_at);return l.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:[l.jsx("button",{type:"button",onClick:()=>i(L?null:_.id),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left text-sm font-medium text-gray-900 transition hover:bg-gray-50 dark:text-gray-100 dark:hover:bg-gray-900/40",children:l.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[l.jsxs("div",{className:"truncate",children:[l.jsx("p",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-50",children:_.name}),l.jsx("p",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",children:_.description||"No description provided"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium ${_.active?"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5","aria-hidden":"true",children:_.active?l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"m9 11 3 3L22 4"}),l.jsx("path",{d:"M21.801 10A10 10 0 1 1 17 3.335"})]}):l.jsx("circle",{cx:"12",cy:"12",r:"10"})}),_.active?"Live":"Inactive"]}),l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`size-5 shrink-0 transition-transform duration-150 text-gray-400 dark:text-gray-600 ${L?"rotate-180":""}`,"aria-hidden":"true",children:l.jsx("path",{d:"m6 9 6 6 6-6"})})]})]})}),L&&l.jsx("div",{className:"border-t border-gray-200 bg-gray-50 px-4 py-5 text-sm dark:border-gray-800 dark:bg-gray-900/40",children:l.jsxs("div",{className:"overflow-hidden pb-4 text-sm text-gray-700 dark:text-gray-200",children:[l.jsx("div",{className:"mx-auto flex w-full items-center justify-between gap-3 text-sm text-gray-500 dark:text-gray-500",children:l.jsx("div",{className:"h-[1px] w-full bg-gray-200 dark:bg-gray-800"})}),l.jsx("ul",{role:"list",className:"mt-6 space-y-6","aria-label":"Rule steps",children:V.map((B,z)=>{const q=z===V.length-1;return l.jsxs("li",{className:"relative flex gap-x-4",children:[!q&&l.jsx("div",{className:"-bottom-6 absolute left-0 top-0 flex w-9 justify-center",children:l.jsx("div",{className:"w-px bg-gray-200 dark:bg-gray-800"})}),l.jsx(Mxe,{variant:B.variant}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:[z+1,". ",B.title]}),B.description&&l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:B.description})]})]},`${_.id}-step-${z}`)})}),l.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3",children:[l.jsx("time",{className:"flex-none text-xs leading-5 text-gray-500 dark:text-gray-500",children:$?`Updated ${$}`:"Updated recently"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{type:"button",onClick:()=>h&&h(_),className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border border-blue-500 px-3 py-1.5 text-sm font-medium text-blue-600 shadow-sm transition hover:bg-blue-50 dark:border-blue-400 dark:text-blue-400 dark:hover:bg-blue-900/20",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4 -ml-0.5 mr-1.5","aria-hidden":"true",children:l.jsx("path",{d:"M19.3788 15.1057C20.9258 11.4421 19.5373 7.11431 16.0042 5.0745C13.4511 3.60046 10.4232 3.69365 8.03452 5.0556L7.04216 3.31879C10.028 1.61639 13.8128 1.4999 17.0042 3.34245C21.4949 5.93513 23.2139 11.4848 21.1217 16.112L22.4635 16.8867L18.2984 19.1008L18.1334 14.3867L19.3788 15.1057ZM4.62961 8.89968C3.08263 12.5633 4.47116 16.8911 8.00421 18.9309C10.5573 20.4049 13.5851 20.3118 15.9737 18.9499L16.9661 20.6867C13.9803 22.389 10.1956 22.5055 7.00421 20.663C2.51357 18.0703 0.794565 12.5206 2.88672 7.89342L1.54492 7.11873L5.70999 4.90463L5.87505 9.61873L4.62961 8.89968ZM13.4184 14.8311L10.59 12.0027L7.76157 14.8311L6.34736 13.4169L10.59 9.17428L13.4184 12.0027L16.2469 9.17428L17.6611 10.5885L13.4184 14.8311Z"})}),"Apply to history"]}),l.jsxs("button",{type:"button",onClick:()=>c(_),className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-900 shadow-sm transition hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-50 dark:hover:bg-gray-800/30",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-settings -ml-0.5 mr-1.5 size-4 shrink-0","aria-hidden":"true",children:[l.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),l.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Edit"]}),l.jsxs("button",{type:"button",onClick:()=>{const B=Ixe(_);B&&(g?g(B):d&&d(B))},className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-900 shadow-sm transition hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-50 dark:hover:bg-gray-800/30",title:"Duplicate rule","aria-label":"Duplicate rule",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4 -ml-0.5 mr-1.5",children:[l.jsx("path",{d:"M9 7a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-7a2 2 0 0 1-2-2V7z"}),l.jsx("path",{d:"M5 9a2 2 0 0 1 2-2h1v7a4 4 0 0 0 4 4h7v1a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V9z"})]}),"Duplicate"]}),l.jsxs("button",{type:"button",onClick:()=>v&&v(_),className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-900 shadow-sm transition hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-50 dark:hover:bg-gray-800/30",title:"Export rule","aria-label":"Export rule",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"-ml-0.5 mr-1.5 size-4",children:[l.jsx("path",{d:"M5 7v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7"}),l.jsx("path",{d:"M12 3v12"}),l.jsx("path",{d:"m8 11 4 4 4-4"})]}),"Export"]}),l.jsxs("button",{type:"button",onClick:()=>u(_),className:"inline-flex items-center gap-1 rounded-md border border-grey-300 px-2.5 py-1.5 text-xs font-medium text-red-700 transition hover:bg-red-50 dark:border-red-900/40 dark:text-red-300 dark:hover:bg-red-950",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"-ms-0.5",children:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),l.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),l.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),l.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]}),"Delete"]}),l.jsxs("button",{type:"button",onClick:()=>b&&b(_),disabled:m||r,className:"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-900 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-50 dark:hover:bg-gray-800/30",title:_.active?"Pause rule":"Activate rule",children:[_.active?l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-circle-pause -ml-0.5 mr-1.5 size-4 shrink-0","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("line",{x1:"10",x2:"10",y1:"15",y2:"9"}),l.jsx("line",{x1:"14",x2:"14",y1:"15",y2:"9"})]}):l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-circle-play -ml-0.5 mr-1.5 size-4 shrink-0","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polygon",{points:"10 8 16 12 10 16"})]}),_.active?"Pause":"Play"]})]})]})]})})]},_.id||_.name)})}),w&&l.jsx(x7,{meta:w,onPageChange:j,alwaysShow:S})]})]})};function Dxe({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){if(!t||t.hidden)return null;const a=t.label||t.name,i=o??!!t.readonly,s=t.help||(t.description?"":t.description);return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[a,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("input",{id:e,type:"checkbox",disabled:i,checked:!!r,onChange:c=>n(c.target.checked),className:"size-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-900"}),t.description&&l.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:t.description})]}),s&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s})]})}function Rxe({id:e,descriptor:t,value:r,onChange:n,provider:o,readOnly:a}){if(!t||t.hidden)return null;const i=t.label||t.name,s=a??!!t.readonly,c=t.help||t.description,u="block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",d=(t.choices||[]).filter(f=>!f.group||!o||f.group===o);return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[i,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("select",{id:e,disabled:s,value:typeof r=="string"?r:r??"",onChange:f=>n(f.target.value),className:u,children:d.map(f=>l.jsx("option",{value:f.value,title:f.description||"",children:f.label||f.value},f.value))}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function Fxe({id:e,descriptor:t,value:r,onChange:n,provider:o,readOnly:a}){if(!t||t.hidden)return null;const i=t.label||t.name,s=a??!!t.readonly,c=t.help||t.description,u="block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",d=r&&typeof r=="object"&&r!==null?r:{},f=(g,b)=>{const v={...d};b?g in v||(v[g]=""):delete v[g],n(v)},h=(g,b)=>{const v={...d};v[g]=b,n(v)},m=(t.choices||[]).filter(g=>!g.group||!o||g.group===o);return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[i,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:m.map(g=>{var b,v;const x=((b=g.meta)==null?void 0:b.key)||g.value,w=Object.prototype.hasOwnProperty.call(d,x),E=((v=g.meta)==null?void 0:v.type)||"string",j=(()=>{const S=d[x];if(E==="object"&&typeof S=="object"&&S!==null)try{return JSON.stringify(S)}catch{return String(S)}return S??""})();return l.jsxs("div",{className:"rounded-md border border-gray-200 p-2 dark:border-gray-800",children:[l.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[l.jsx("input",{type:"checkbox",disabled:s,checked:w,onChange:S=>f(x,S.target.checked),className:"mt-1 size-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-900"}),l.jsxs("span",{className:"flex-1",children:[l.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:g.label||g.value}),g.description&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:g.description})]})]}),w&&l.jsx("div",{className:"mt-2",children:E==="object"?l.jsx("textarea",{rows:3,disabled:s,value:j,onChange:S=>h(x,S.target.value),placeholder:g.label,className:u}):l.jsx("input",{type:E==="integer"||E==="number"?"number":"text",disabled:s,value:j,onChange:S=>h(x,S.target.value),placeholder:g.label,className:u})})]},g.value)})}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function $xe({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){if(!t||t.hidden)return null;const a=t.label||t.name,i=o??!!t.readonly,s=t.placeholder||"",c=t.help||t.description;return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[a,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("input",{id:e,type:"number",step:t.type==="integer"?1:"any",disabled:i,value:r??"",onChange:u=>n(u.target.value),placeholder:s,className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function Bxe({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){if(!t||t.hidden)return null;const a=t.label||t.name,i=o??!!t.readonly,s=t.placeholder||"",c=t.help||t.description;return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[a,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("input",{id:e,type:"text",disabled:i,value:Array.isArray(r)?r.join(", "):r??"",onChange:u=>n(u.target.value),placeholder:s,className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function Hxe({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){if(!t||t.hidden)return null;const a=t.label||t.name,i=o??!!t.readonly,s=t.placeholder||"",c=t.help||t.description,u="block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",d=typeof r=="string"?r:r?JSON.stringify(r,null,2):"";return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[a,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("textarea",{id:e,rows:4,disabled:i,value:d,onChange:f=>n(f.target.value),placeholder:s,className:u}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function zxe({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){if(!t||t.hidden)return null;const a=t.label||t.name,i=o??!!t.readonly,s=t.placeholder||"",c=t.help||t.description;return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[a,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("input",{id:e,type:"text",disabled:i,value:typeof r=="string"?r:r??"",onChange:u=>n(u.target.value),placeholder:s,className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function Wxe({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){if(!t||t.hidden)return null;const a=t.label||t.name,i=o??!!t.readonly,s=t.placeholder||"",c=t.help||t.description;return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[a,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx("input",{id:e,type:"password",disabled:i,value:typeof r=="string"?r:r??"",onChange:u=>n(u.target.value),placeholder:s,className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}class qxe{add(t,r,n){if(typeof arguments[0]!="string")for(let o in arguments[0])this.add(o,arguments[0][o],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(o){this[o]=this[o]||[],r&&this[o][n?"unshift":"push"](r)},this)}run(t,r){this[t]=this[t]||[],this[t].forEach(function(n){n.call(r&&r.context?r.context:r,r)})}}class Uxe{constructor(t){this.jsep=t,this.registered={}}register(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(o=>{if(typeof o!="object"||!o.name||!o.init)throw new Error("Invalid JSEP plugin format");this.registered[o.name]||(o.init(this.jsep),this.registered[o.name]=o)})}}class Ee{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Ee.version}static addUnaryOp(t){return Ee.max_unop_len=Math.max(t.length,Ee.max_unop_len),Ee.unary_ops[t]=1,Ee}static addBinaryOp(t,r,n){return Ee.max_binop_len=Math.max(t.length,Ee.max_binop_len),Ee.binary_ops[t]=r,n?Ee.right_associative.add(t):Ee.right_associative.delete(t),Ee}static addIdentifierChar(t){return Ee.additional_identifier_chars.add(t),Ee}static addLiteral(t,r){return Ee.literals[t]=r,Ee}static removeUnaryOp(t){return delete Ee.unary_ops[t],t.length===Ee.max_unop_len&&(Ee.max_unop_len=Ee.getMaxKeyLen(Ee.unary_ops)),Ee}static removeAllUnaryOps(){return Ee.unary_ops={},Ee.max_unop_len=0,Ee}static removeIdentifierChar(t){return Ee.additional_identifier_chars.delete(t),Ee}static removeBinaryOp(t){return delete Ee.binary_ops[t],t.length===Ee.max_binop_len&&(Ee.max_binop_len=Ee.getMaxKeyLen(Ee.binary_ops)),Ee.right_associative.delete(t),Ee}static removeAllBinaryOps(){return Ee.binary_ops={},Ee.max_binop_len=0,Ee}static removeLiteral(t){return delete Ee.literals[t],Ee}static removeAllLiterals(){return Ee.literals={},Ee}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new Ee(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(r=>r.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return Ee.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!Ee.binary_ops[String.fromCharCode(t)]||Ee.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return Ee.isIdentifierStart(t)||Ee.isDecimalDigit(t)}throwError(t){const r=new Error(t+" at character "+this.index);throw r.index=this.index,r.description=t,r}runHook(t,r){if(Ee.hooks[t]){const n={context:this,node:r};return Ee.hooks.run(t,n),n.node}return r}searchHook(t){if(Ee.hooks[t]){const r={context:this};return Ee.hooks[t].find(function(n){return n.call(r.context,r),r.node}),r.node}}gobbleSpaces(){let t=this.code;for(;t===Ee.SPACE_CODE||t===Ee.TAB_CODE||t===Ee.LF_CODE||t===Ee.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=t.length===1?t[0]:{type:Ee.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r=[],n,o;for(;this.index<this.expr.length;)if(n=this.code,n===Ee.SEMCOL_CODE||n===Ee.COMMA_CODE)this.index++;else if(o=this.gobbleExpression())r.push(o);else if(this.index<this.expr.length){if(n===t)break;this.throwError('Unexpected "'+this.char+'"')}return r}gobbleExpression(){const t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,Ee.max_binop_len),r=t.length;for(;r>0;){if(Ee.binary_ops.hasOwnProperty(t)&&(!Ee.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Ee.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,n,o,a,i,s,c,u;if(i=this.gobbleToken(),!i||(r=this.gobbleBinaryOp(),!r))return i;for(a={value:r,prec:Ee.binaryPrecedence(r),right_a:Ee.right_associative.has(r)},s=this.gobbleToken(),s||this.throwError("Expected expression after "+r),o=[i,a,s];r=this.gobbleBinaryOp();){if(n=Ee.binaryPrecedence(r),n===0){this.index-=r.length;break}a={value:r,prec:n,right_a:Ee.right_associative.has(r)},u=r;const d=f=>a.right_a&&f.right_a?n>f.prec:n<=f.prec;for(;o.length>2&&d(o[o.length-2]);)s=o.pop(),r=o.pop().value,i=o.pop(),t={type:Ee.BINARY_EXP,operator:r,left:i,right:s},o.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),o.push(a,t)}for(c=o.length-1,t=o[c];c>1;)t={type:Ee.BINARY_EXP,operator:o[c-1].value,left:o[c-2],right:t},c-=2;return t}gobbleToken(){let t,r,n,o;if(this.gobbleSpaces(),o=this.searchHook("gobble-token"),o)return this.runHook("after-token",o);if(t=this.code,Ee.isDecimalDigit(t)||t===Ee.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===Ee.SQUOTE_CODE||t===Ee.DQUOTE_CODE)o=this.gobbleStringLiteral();else if(t===Ee.OBRACK_CODE)o=this.gobbleArray();else{for(r=this.expr.substr(this.index,Ee.max_unop_len),n=r.length;n>0;){if(Ee.unary_ops.hasOwnProperty(r)&&(!Ee.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!Ee.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;const a=this.gobbleToken();return a||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Ee.UNARY_EXP,operator:r,argument:a,prefix:!0})}r=r.substr(0,--n)}Ee.isIdentifierStart(t)?(o=this.gobbleIdentifier(),Ee.literals.hasOwnProperty(o.name)?o={type:Ee.LITERAL,value:Ee.literals[o.name],raw:o.name}:o.name===Ee.this_str&&(o={type:Ee.THIS_EXP})):t===Ee.OPAREN_CODE&&(o=this.gobbleGroup())}return o?(o=this.gobbleTokenProperty(o),this.runHook("after-token",o)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===Ee.PERIOD_CODE||r===Ee.OBRACK_CODE||r===Ee.OPAREN_CODE||r===Ee.QUMARK_CODE;){let n;if(r===Ee.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Ee.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===Ee.OBRACK_CODE?(t={type:Ee.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},t.property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==Ee.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===Ee.OPAREN_CODE?t={type:Ee.CALL_EXP,arguments:this.gobbleArguments(Ee.CPAREN_CODE),callee:t}:(r===Ee.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:Ee.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t="",r,n;for(;Ee.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===Ee.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);Ee.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(r=this.char,r==="e"||r==="E"){for(t+=this.expr.charAt(this.index++),r=this.char,(r==="+"||r==="-")&&(t+=this.expr.charAt(this.index++));Ee.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);Ee.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return n=this.code,Ee.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(n===Ee.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===Ee.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Ee.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="";const r=this.index,n=this.expr.charAt(this.index++);let o=!1;for(;this.index<this.expr.length;){let a=this.expr.charAt(this.index++);if(a===n){o=!0;break}else if(a==="\\")switch(a=this.expr.charAt(this.index++),a){case"n":t+=`
202
202
  `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=a}else t+=a}return o||this.throwError('Unclosed quote after "'+t+'"'),{type:Ee.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(Ee.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Ee.isIdentifierPart(t));)this.index++;return{type:Ee.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){const r=[];let n=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===t){n=!0,this.index++,t===Ee.CPAREN_CODE&&o&&o>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(a===Ee.COMMA_CODE){if(this.index++,o++,o!==r.length){if(t===Ee.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Ee.CBRACK_CODE)for(let i=r.length;i<o;i++)r.push(null)}}else if(r.length!==o&&o!==0)this.throwError("Expected comma");else{const i=this.gobbleExpression();(!i||i.type===Ee.COMPOUND)&&this.throwError("Expected comma"),r.push(i)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Ee.CPAREN_CODE);if(this.code===Ee.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:Ee.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Ee.ARRAY_EXP,elements:this.gobbleArguments(Ee.CBRACK_CODE)}}}const Vxe=new qxe;Object.assign(Ee,{hooks:Vxe,plugins:new Uxe(Ee),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});Ee.max_unop_len=Ee.getMaxKeyLen(Ee.unary_ops);Ee.max_binop_len=Ee.getMaxKeyLen(Ee.binary_ops);const ai=e=>new Ee(e).parse(),Kxe=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(Ee).filter(e=>!Kxe.includes(e)&&ai[e]===void 0).forEach(e=>{ai[e]=Ee[e]});ai.Jsep=Ee;const Yxe="ConditionalExpression";var Gxe={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:Yxe,test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let a=r;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};ai.plugins.register(Gxe);const WP=47,Xxe=92;var Jxe={name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(this.code===WP){const r=++this.index;let n=!1;for(;this.index<this.expr.length;){if(this.code===WP&&!n){const o=this.expr.slice(r,this.index);let a="";for(;++this.index<this.expr.length;){const s=this.code;if(s>=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57)a+=this.char;else break}let i;try{i=new RegExp(o,a)}catch(s){this.throwError(s.message)}return t.node={type:e.LITERAL,value:i,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=this.code===Xxe?2:1}this.throwError("Unclosed Regex")}})}};const vw=43,Zxe=45,Tl={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[vw,Zxe],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];Tl.assignmentOperators.forEach(n=>e.addBinaryOp(n,Tl.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(n){const o=this.code;Tl.updateOperators.some(a=>a===o&&a===this.expr.charCodeAt(this.index+1))&&(this.index+=2,n.node={type:"UpdateExpression",operator:o===vw?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},(!n.node.argument||!t.includes(n.node.argument.type))&&this.throwError(`Unexpected ${n.node.operator}`))}),e.hooks.add("after-token",function(n){if(n.node){const o=this.code;Tl.updateOperators.some(a=>a===o&&a===this.expr.charCodeAt(this.index+1))&&(t.includes(n.node.type)||this.throwError(`Unexpected ${n.node.operator}`),this.index+=2,n.node={type:"UpdateExpression",operator:o===vw?"++":"--",argument:n.node,prefix:!1})}}),e.hooks.add("after-expression",function(n){n.node&&r(n.node)});function r(n){Tl.assignmentOperators.has(n.operator)?(n.type="AssignmentExpression",r(n.left),r(n.right)):n.operator||Object.values(n).forEach(o=>{o&&typeof o=="object"&&r(o)})}}};ai.plugins.register(Jxe,Tl);ai.addUnaryOp("typeof");ai.addLiteral("null",null);ai.addLiteral("undefined",void 0);const Qxe=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),ur={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return ur.evalBinaryExpression(e,t);case"Compound":return ur.evalCompound(e,t);case"ConditionalExpression":return ur.evalConditionalExpression(e,t);case"Identifier":return ur.evalIdentifier(e,t);case"Literal":return ur.evalLiteral(e,t);case"MemberExpression":return ur.evalMemberExpression(e,t);case"UnaryExpression":return ur.evalUnaryExpression(e,t);case"ArrayExpression":return ur.evalArrayExpression(e,t);case"CallExpression":return ur.evalCallExpression(e,t);case"AssignmentExpression":return ur.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression(e,t){return{"||":(r,n)=>r||n(),"&&":(r,n)=>r&&n(),"|":(r,n)=>r|n(),"^":(r,n)=>r^n(),"&":(r,n)=>r&n(),"==":(r,n)=>r==n(),"!=":(r,n)=>r!=n(),"===":(r,n)=>r===n(),"!==":(r,n)=>r!==n(),"<":(r,n)=>r<n(),">":(r,n)=>r>n(),"<=":(r,n)=>r<=n(),">=":(r,n)=>r>=n(),"<<":(r,n)=>r<<n(),">>":(r,n)=>r>>n(),">>>":(r,n)=>r>>>n(),"+":(r,n)=>r+n(),"-":(r,n)=>r-n(),"*":(r,n)=>r*n(),"/":(r,n)=>r/n(),"%":(r,n)=>r%n()}[e.operator](ur.evalAst(e.left,t),()=>ur.evalAst(e.right,t))},evalCompound(e,t){let r;for(let n=0;n<e.body.length;n++){e.body[n].type==="Identifier"&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&e.body[n+1].type==="AssignmentExpression"&&(n+=1);const o=e.body[n];r=ur.evalAst(o,t)}return r},evalConditionalExpression(e,t){return ur.evalAst(e.test,t)?ur.evalAst(e.consequent,t):ur.evalAst(e.alternate,t)},evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral(e){return e.value},evalMemberExpression(e,t){const r=String(e.computed?ur.evalAst(e.property):e.property.name),n=ur.evalAst(e.object,t);if(n==null)throw TypeError(`Cannot read properties of ${n} (reading '${r}')`);if(!Object.hasOwn(n,r)&&Qxe.has(r))throw TypeError(`Cannot read properties of ${n} (reading '${r}')`);const o=n[r];return typeof o=="function"?o.bind(n):o},evalUnaryExpression(e,t){return{"-":r=>-ur.evalAst(r,t),"!":r=>!ur.evalAst(r,t),"~":r=>~ur.evalAst(r,t),"+":r=>+ur.evalAst(r,t),typeof:r=>typeof ur.evalAst(r,t)}[e.operator](e.argument)},evalArrayExpression(e,t){return e.elements.map(r=>ur.evalAst(r,t))},evalCallExpression(e,t){const r=e.arguments.map(n=>ur.evalAst(n,t));return ur.evalAst(e.callee,t)(...r)},evalAssignmentExpression(e,t){if(e.left.type!=="Identifier")throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,n=ur.evalAst(e.right,t);return t[r]=n,t[r]}};class e0e{constructor(t){this.code=t,this.ast=ai(this.code)}runInNewContext(t){const r=Object.assign(Object.create(null),t);return ur.evalAst(this.ast,r)}}function Ni(e,t){return e=e.slice(),e.push(t),e}function R2(e,t){return t=t.slice(),t.unshift(e),t}class t0e extends Error{constructor(t){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=t,this.name="NewError"}}function Qt(e,t,r,n,o){if(!(this instanceof Qt))try{return new Qt(e,t,r,n,o)}catch(i){if(!i.avoidNew)throw i;return i.value}typeof e=="string"&&(o=n,n=r,r=t,t=e,e=null);const a=e&&typeof e=="object";if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=Object.hasOwn(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.eval=e.eval===void 0?"safe":e.eval,this.ignoreEvalErrors=typeof e.ignoreEvalErrors>"u"?!1:e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){const i={path:a?e.path:t};a?"json"in e&&(i.json=e.json):i.json=r;const s=this.evaluate(i);if(!s||typeof s!="object")throw new t0e(s);return s}}Qt.prototype.evaluate=function(e,t,r,n){let o=this.parent,a=this.parentProperty,{flatten:i,wrap:s}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&typeof e=="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),i=Object.hasOwn(e,"flatten")?e.flatten:i,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,s=Object.hasOwn(e,"wrap")?e.wrap:s,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=Object.hasOwn(e,"parent")?e.parent:o,a=Object.hasOwn(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=Qt.toPathString(e)),!e&&e!==""||!t)return;const c=Qt.toPathArray(e);c[0]==="$"&&c.length>1&&c.shift(),this._hasParentSelector=null;const u=this._trace(c,t,["$"],o,a,r).filter(function(d){return d&&!d.isParentSelector});return u.length?!s&&u.length===1&&!u[0].hasArrExpr?this._getPreferredOutput(u[0]):u.reduce((d,f)=>{const h=this._getPreferredOutput(f);return i&&Array.isArray(h)?d=d.concat(h):d.push(h),d},[]):s?[]:void 0};Qt.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const r=Array.isArray(e.path)?e.path:Qt.toPathArray(e.path);return e.pointer=Qt.toPointer(r),e.path=typeof e.path=="string"?e.path:Qt.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return Qt.toPathString(e[t]);case"pointer":return Qt.toPointer(e.path);default:throw new TypeError("Unknown result type")}};Qt.prototype._handleCallback=function(e,t,r){if(t){const n=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:Qt.toPathString(e.path),t(n,r,e)}};Qt.prototype._trace=function(e,t,r,n,o,a,i,s){let c;if(!e.length)return c={path:r,value:t,parent:n,parentProperty:o,hasArrExpr:i},this._handleCallback(c,a,"value"),c;const u=e[0],d=e.slice(1),f=[];function h(m){Array.isArray(m)?m.forEach(g=>{f.push(g)}):f.push(m)}if((typeof u!="string"||s)&&t&&Object.hasOwn(t,u))h(this._trace(d,t[u],Ni(r,u),t,u,a,i));else if(u==="*")this._walk(t,m=>{h(this._trace(d,t[m],Ni(r,m),t,m,a,!0,!0))});else if(u==="..")h(this._trace(d,t,r,n,o,a,i)),this._walk(t,m=>{typeof t[m]=="object"&&h(this._trace(e.slice(),t[m],Ni(r,m),t,m,a,!0))});else{if(u==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:d,isParentSelector:!0};if(u==="~")return c={path:Ni(r,u),value:o,parent:n,parentProperty:null},this._handleCallback(c,a,"property"),c;if(u==="$")h(this._trace(d,t,r,null,null,a,i));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(u))h(this._slice(u,d,t,r,n,o,a));else if(u.indexOf("?(")===0){if(this.currEval===!1)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const m=u.replace(/^\?\((.*?)\)$/u,"$1"),g=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);g?this._walk(t,b=>{const v=[g[2]],x=g[1]?t[b][g[1]]:t[b];this._trace(v,x,r,n,o,a,!0).length>0&&h(this._trace(d,t[b],Ni(r,b),t,b,a,!0))}):this._walk(t,b=>{this._eval(m,t[b],b,r,n,o)&&h(this._trace(d,t[b],Ni(r,b),t,b,a,!0))})}else if(u[0]==="("){if(this.currEval===!1)throw new Error("Eval [(expr)] prevented in JSONPath expression.");h(this._trace(R2(this._eval(u,t,r.at(-1),r.slice(0,-1),n,o),d),t,r,n,o,a,i))}else if(u[0]==="@"){let m=!1;const g=u.slice(1,-2);switch(g){case"scalar":(!t||!["object","function"].includes(typeof t))&&(m=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===g&&(m=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(m=!0);break;case"number":Number.isFinite(t)&&(m=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(m=!0);break;case"object":t&&typeof t===g&&(m=!0);break;case"array":Array.isArray(t)&&(m=!0);break;case"other":m=this.currOtherTypeCallback(t,r,n,o);break;case"null":t===null&&(m=!0);break;default:throw new TypeError("Unknown value type "+g)}if(m)return c={path:r,value:t,parent:n,parentProperty:o},this._handleCallback(c,a,"value"),c}else if(u[0]==="`"&&t&&Object.hasOwn(t,u.slice(1))){const m=u.slice(1);h(this._trace(d,t[m],Ni(r,m),t,m,a,i,!0))}else if(u.includes(",")){const m=u.split(",");for(const g of m)h(this._trace(R2(g,d),t,r,n,o,a,!0))}else!s&&t&&Object.hasOwn(t,u)&&h(this._trace(d,t[u],Ni(r,u),t,u,a,i,!0))}if(this._hasParentSelector)for(let m=0;m<f.length;m++){const g=f[m];if(g&&g.isParentSelector){const b=this._trace(g.expr,t,g.path,n,o,a,i);if(Array.isArray(b)){f[m]=b[0];const v=b.length;for(let x=1;x<v;x++)m++,f.splice(m,0,b[x])}else f[m]=b}}return f};Qt.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let n=0;n<r;n++)t(n)}else e&&typeof e=="object"&&Object.keys(e).forEach(r=>{t(r)})};Qt.prototype._slice=function(e,t,r,n,o,a,i){if(!Array.isArray(r))return;const s=r.length,c=e.split(":"),u=c[2]&&Number.parseInt(c[2])||1;let d=c[0]&&Number.parseInt(c[0])||0,f=c[1]&&Number.parseInt(c[1])||s;d=d<0?Math.max(0,d+s):Math.min(s,d),f=f<0?Math.max(0,f+s):Math.min(s,f);const h=[];for(let m=d;m<f;m+=u)this._trace(R2(m,t),r,n,o,a,i,!0).forEach(g=>{h.push(g)});return h};Qt.prototype._eval=function(e,t,r,n,o,a){this.currSandbox._$_parentProperty=a,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const i=e.includes("@path");i&&(this.currSandbox._$_path=Qt.toPathString(n.concat([r])));const s=this.currEval+"Script:"+e;if(!Qt.cache[s]){let c=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(i&&(c=c.replaceAll("@path","_$_path")),this.currEval==="safe"||this.currEval===!0||this.currEval===void 0)Qt.cache[s]=new this.safeVm.Script(c);else if(this.currEval==="native")Qt.cache[s]=new this.vm.Script(c);else if(typeof this.currEval=="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const u=this.currEval;Qt.cache[s]=new u(c)}else if(typeof this.currEval=="function")Qt.cache[s]={runInNewContext:u=>this.currEval(c,u)};else throw new TypeError(`Unknown "eval" property "${this.currEval}"`)}try{return Qt.cache[s].runInNewContext(this.currSandbox)}catch(c){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+c.message+": "+e)}};Qt.cache={};Qt.toPathString=function(e){const t=e,r=t.length;let n="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(t[o])||(n+=/^[0-9*]+$/u.test(t[o])?"["+t[o]+"]":"['"+t[o]+"']");return n};Qt.toPointer=function(e){const t=e,r=t.length;let n="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(t[o])||(n+="/"+t[o].toString().replaceAll("~","~0").replaceAll("/","~1"));return n};Qt.toPathArray=function(e){const{cache:t}=Qt;if(t[e])return t[e].concat();const r=[],n=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,function(o,a){return"[#"+(r.push(a)-1)+"]"}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,function(o,a){return"['"+a.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"}).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,function(o,a){return";"+a.split("").join(";")+";"}).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map(function(o){const a=o.match(/#(\d+)/u);return!a||!a[1]?o:r[a[1]]});return t[e]=n,t[e].concat()};Qt.prototype.safeVm={Script:e0e};const r0e=function(e,t,r){const n=e.length;for(let o=0;o<n;o++){const a=e[o];r(a)&&t.push(e.splice(o--,1)[0])}};class n0e{constructor(t){this.code=t}runInNewContext(t){let r=this.code;const n=Object.keys(t),o=[];r0e(n,o,c=>typeof t[c]=="function");const a=n.map(c=>t[c]);r=o.reduce((c,u)=>{let d=t[u].toString();return/function/u.test(d)||(d="function "+d),"var "+u+"="+d+";"+c},"")+r,!/(['"])use strict\1/u.test(r)&&!n.includes("arguments")&&(r="var arguments = undefined;"+r),r=r.replace(/;\s*$/u,"");const i=r.lastIndexOf(";"),s=i!==-1?r.slice(0,i+1)+" return "+r.slice(i+1):" return "+r;return new Function(...n,s)(...a)}}Qt.prototype.vm={Script:n0e};const qP={label:"Inspectr Operation",value:"$",description:"Root object containing the captured request, response, and metadata.",children:[{label:"Version",value:"$.version",description:"Inspectr payload version string."},{label:"Operation ID",value:"$.operation_id",description:"Unique identifier assigned to the captured operation."},{label:"Correlation ID",value:"$.correlation_id",description:"Correlation identifier propagated between services."},{label:"Request",value:"$.request",description:"Incoming HTTP request information.",children:[{label:"Method",value:"$.request.method"},{label:"URL",value:"$.request.url"},{label:"Path",value:"$.request.path"},{label:"Server",value:"$.request.server"},{label:"Client IP",value:"$.request.client_ip"},{label:"HTTP Version",value:"$.request.http_version"},{label:"Headers Size",value:"$.request.headers_size"},{label:"Headers",value:"$.request.headers",description:"Array of request headers as name/value pairs.",children:[{label:"Header Name",value:"$.request.headers[*].name"},{label:"Header Value",value:"$.request.headers[*].value"}]},{label:"Query Parameters",value:"$.request.query_params",description:"Array of query parameters as name/value pairs.",children:[{label:"Query Param Name",value:"$.request.query_params[*].name"},{label:"Query Param Value",value:"$.request.query_params[*].value"}]},{label:"Cookies",value:"$.request.cookies",description:"Array of request cookies.",children:[{label:"Cookie Name",value:"$.request.cookies[*].name"},{label:"Cookie Value",value:"$.request.cookies[*].value"}]},{label:"Body",value:"$.request.body"},{label:"Body Size",value:"$.request.body_size"},{label:"Timestamp",value:"$.request.timestamp"}]},{label:"Response",value:"$.response",description:"Outgoing HTTP response information.",children:[{label:"Status Code",value:"$.response.status"},{label:"Status Text",value:"$.response.status_text"},{label:"HTTP Version",value:"$.response.http_version"},{label:"Headers Size",value:"$.response.headers_size"},{label:"Headers",value:"$.response.headers",description:"Array of response headers as name/value pairs.",children:[{label:"Header Name",value:"$.response.headers[*].name"},{label:"Header Value",value:"$.response.headers[*].value"}]},{label:"Cookies",value:"$.response.cookies",description:"Array of response cookies.",children:[{label:"Cookie Name",value:"$.response.cookies[*].name"},{label:"Cookie Value",value:"$.response.cookies[*].value"}]},{label:"Body",value:"$.response.body"},{label:"Body Size",value:"$.response.body_size"},{label:"Timestamp",value:"$.response.timestamp"},{label:"Event Frames",value:"$.response.event_frames",description:"Server-sent events captured during the operation.",children:[{label:"Frame ID",value:"$.response.event_frames[*].id"},{label:"Frame Event",value:"$.response.event_frames[*].event"},{label:"Frame Data",value:"$.response.event_frames[*].data"},{label:"Frame Timestamp",value:"$.response.event_frames[*].timestamp"}]}]},{label:"Timing",value:"$.timing",description:"Timing metrics for the operation lifecycle.",children:[{label:"Request Timestamp",value:"$.timing.request"},{label:"Response Timestamp",value:"$.timing.response"},{label:"Duration (ms)",value:"$.timing.duration"}]},{label:"Meta",value:"$.meta",description:"Additional metadata captured alongside the operation.",children:[{label:"Proxy",value:"$.meta.proxy",children:[{label:"Instance",value:"$.meta.proxy.instance"},{label:"URL",value:"$.meta.proxy.url"}]},{label:"Ingress",value:"$.meta.ingress",children:[{label:"Headers",value:"$.meta.ingress.headers",description:"Map of ingress headers preserved by Inspectr.",children:[{label:"Header Value by Name",value:'$.meta.ingress.headers["Header-Name"]',description:"Replace Header-Name with the ingress header key."}]}]},{label:"Inspectr",value:"$.meta.inspectr",children:[{label:"Directives",value:"$.meta.inspectr.directives",description:"Map of Inspectr directive headers.",children:[{label:"Directive by Name",value:'$.meta.inspectr.directives["directive-name"]',description:"Replace directive-name with the directive key."}]},{label:"Guard",value:"$.meta.inspectr.guard",description:"Map of Inspectr Guard headers.",children:[{label:"Guard Header by Name",value:'$.meta.inspectr.guard["guard-name"]',description:"Replace guard-name with the guard header key."}]}]},{label:"Tags",value:"$.meta.tags",description:"Array of user-defined tags applied to the operation.",children:[{label:"Tag Value",value:"$.meta.tags[*]"}]}]}]};function o0e(e){const t=[],r=n=>{n&&(n.value&&t.push({value:n.value,label:n.label,description:n.description||""}),n.children&&n.children.length>0&&n.children.forEach(o=>r(o)))};return r(e),t}const UP=Object.freeze({results:[],totalCount:0});function a0e(e=10){const t=typeof e=="number"&&e>0?e:10,r=aa(()=>rn.queryEvents({sort:{field:"time",order:"desc"},page:1,pageSize:t}),[t],UP)||UP,n=Array.isArray(r.results)?r.results:[],o=typeof r.totalCount=="number"?r.totalCount:0;return{results:n,totalCount:o}}const VP=e=>{if(typeof e!="string")return e;const t=e.trim();if(t===""||!(t.startsWith("{")||t.startsWith("[")))return e;try{return JSON.parse(t)}catch{return e}},i0e=e=>{if(!e||typeof e!="object")return e;const t={...e};if(e.request&&typeof e.request=="object"&&(t.request={...e.request},"body"in e.request)){const r=VP(e.request.body);r!==e.request.body&&(t.request.body=r,t.request.__rawBody=e.request.body)}if(e.response&&typeof e.response=="object"&&(t.response={...e.response},"body"in e.response)){const r=VP(e.response.body);r!==e.response.body&&(t.response.body=r,t.response.__rawBody=e.response.body)}return t};function pD(e,t,r=0){return e?e.map(n=>{const o=`${n.value||n.label}-${r}`,a=n.children&&n.children.length>0,i=`${r*12}px`;return l.jsxs("div",{className:"space-y-1",style:{paddingLeft:i},children:[l.jsxs("button",{type:"button",onClick:()=>n.value&&t(n.value),className:`flex w-full flex-col items-start rounded-md px-2 py-1 text-left text-sm transition hover:bg-blue-50 hover:text-blue-600 focus:bg-blue-100 focus:text-blue-700 focus:outline-none dark:hover:bg-blue-500/10 dark:hover:text-blue-300 dark:focus:bg-blue-500/20 dark:focus:text-blue-200 ${n.value?"":"cursor-default text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"}`,disabled:!n.value,children:[l.jsx("span",{children:n.label}),n.description&&n.value&&l.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:n.description})]}),a&&pD(n.children,t,r+1)]},o)}):null}function hD({id:e,value:t,onChange:r,placeholder:n="$.request.path",inputClassName:o="",browseButtonLabel:a="Browse paths",className:i="",disabled:s=!1,enablePreview:c=!1}){const u=p.useId(),d=e||`json-path-input-${u}`,f=`${d}-options`,[h,m]=p.useState(!1),[g,b]=p.useState(""),[v,x]=p.useState(!1),[w,E]=p.useState(""),[j,S]=p.useState(null),[C,O]=p.useState(0),[T,P]=p.useState(""),[M,D]=p.useState(!1),R=typeof t=="string"?t.trim():"",{results:F}=a0e(8),_=p.useMemo(()=>o0e(qP),[]),L=p.useMemo(()=>{const z=g.trim().toLowerCase();return z?_.filter(q=>q.value.toLowerCase().includes(z)||q.label&&q.label.toLowerCase().includes(z)||q.description&&q.description.toLowerCase().includes(z)):_},[_,g]),V=z=>{z&&(r&&r(z),m(!1))};p.useEffect(()=>{var z;if(!c||!v||!F.length)return;const q=(z=F[0])==null?void 0:z.id;q&&E(W=>W||q)},[c,v,F]),p.useEffect(()=>{if(!c||!v)return;if(!R){S(null),O(0),P(""),D(!1);return}if(!w){S(null),O(0),P("Select an operation to preview"),D(!1);return}const z=F.find(q=>q.id===w);if(!z){S(null),O(0),P("Selected operation is no longer available"),D(!1);return}D(!0);try{const q=i0e(z),W=Qt({path:R,json:q}),J=Array.isArray(W)?W:[W],Y=J.length;O(Y),S(Y===0?null:Y===1?J[0]:J),P("")}catch(q){S(null),O(0),P(q?.message||"Failed to evaluate JSON path")}finally{D(!1)}},[c,v,R,w,F]),p.useEffect(()=>{c||x(!1)},[c]);const $=()=>{if(!R)return l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Enter a JSON path to preview the matching values."});if(!F.length)return l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No recent operations available. Capture traffic to preview JSON path results."});if(T)return l.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300",children:T});if(M)return l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Evaluating JSON path…"});if(C===0||j===null||typeof j>"u")return l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No results found for this JSON path in the selected operation."});const z=(()=>{if(typeof j=="string")return j;if(typeof j=="number"||typeof j=="boolean")return String(j);try{return JSON.stringify(j,null,2)}catch{return String(j)}})();return l.jsxs("div",{className:"space-y-2",children:[C>1&&l.jsxs("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:["Found ",C," matches."]}),l.jsx("pre",{className:"max-h-64 overflow-auto rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-800 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100",children:z})]})},B=F.map(z=>{var q,W,J,Y,ne;const Z=((q=z?.request)==null?void 0:q.method)||"GET",de=((W=z?.request)==null?void 0:W.path)||((J=z?.request)==null?void 0:J.url)||"Unknown path",te=(Y=z?.response)==null?void 0:Y.status,oe=(ne=z?.request)!=null&&ne.timestamp?new Date(z.request.timestamp).toLocaleString():"Unknown time",G=te?`${te}`:"N/A";return{id:z.id,label:`${Z} ${de} • ${G} • ${oe}`}});return l.jsxs("div",{className:`space-y-2 ${i}`,children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx("input",{id:d,list:f,value:t,onChange:z=>r&&r(z.target.value),placeholder:n,className:`block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30 ${o}`,onFocus:()=>!s&&b(""),autoComplete:"off",disabled:s}),l.jsx("datalist",{id:f,children:_.map(z=>l.jsx("option",{value:z.value,children:z.label},z.value))})]}),c&&l.jsx("button",{type:"button",onClick:()=>{s||x(z=>!z)},className:"inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800 dark:focus:border-blue-700 dark:focus:ring-blue-700/30 disabled:cursor-not-allowed disabled:opacity-60",disabled:s,children:v?"Hide preview":"Preview"}),l.jsx("button",{type:"button",onClick:()=>{s||(m(z=>!z),b(""))},className:"inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800 dark:focus:border-blue-700 dark:focus:ring-blue-700/30 disabled:cursor-not-allowed disabled:opacity-60",disabled:s,children:a})]}),h&&!s&&l.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-3 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[l.jsx("input",{type:"text",value:g,onChange:z=>b(z.target.value),placeholder:"Search JSON paths...",className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"}),l.jsx("button",{type:"button",onClick:()=>m(!1),className:"inline-flex items-center justify-center whitespace-nowrap rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-sm font-medium text-gray-600 transition hover:bg-gray-100 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:"Close"})]}),l.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto pr-1 text-gray-800 dark:text-gray-100",children:g.trim()?L.length>0?L.map(z=>l.jsxs("button",{type:"button",onClick:()=>V(z.value),className:"flex w-full flex-col items-start rounded-md px-2 py-1 text-left text-sm transition hover:bg-blue-50 hover:text-blue-600 focus:bg-blue-100 focus:text-blue-700 focus:outline-none dark:hover:bg-blue-500/10 dark:hover:text-blue-300 dark:focus:bg-blue-500/20 dark:focus:text-blue-200",children:[l.jsx("span",{children:z.value}),z.label&&l.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:z.label}),z.description&&l.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:z.description})]},z.value)):l.jsx("p",{className:"px-2 py-4 text-sm text-gray-500 dark:text-gray-400",children:"No matches found."}):pD([qP],V)})]}),c&&v&&!s&&l.jsxs("div",{className:"space-y-3 rounded-lg border border-gray-200 bg-white p-3 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("label",{htmlFor:`${d}-preview-operation`,className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Preview with operation"}),l.jsxs("select",{id:`${d}-preview-operation`,value:w,onChange:z=>E(z.target.value),className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:[l.jsx("option",{value:"",children:"Select an operation…"}),B.map(z=>l.jsx("option",{value:z.id,children:z.label},z.id))]})]}),l.jsx("div",{children:$()})]})]})}function s0e({id:e,descriptor:t,value:r,onChange:n,readOnly:o}){var a,i;if(!t||t.hidden)return null;const s=t.label||t.name,c=t.help||t.description,u=t.placeholder||"$.request.path",d=((a=t.meta)==null?void 0:a.browseLabel)||((i=t.meta)==null?void 0:i.browse_label)||"Browse paths",f=o??!!t.readonly,h=typeof r=="string"?r:r??"";return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("label",{htmlFor:e,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[s,t.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),l.jsx(hD,{id:e,value:h,onChange:n,placeholder:u,browseButtonLabel:d,disabled:f,enablePreview:!0}),c&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})}function yw({id:e,descriptor:t,value:r,onChange:n,provider:o,className:a="",readOnly:i}){if(!t||t.hidden)return null;const s=t.type==="boolean"||t.input==="boolean",c=typeof t.type=="string"&&t.type.startsWith("array"),u=t.input==="single_select"&&Array.isArray(t.choices),d=t.input==="multi_select"&&Array.isArray(t.choices),f=t.type==="integer"||t.type==="number"||t.input==="number",h=t.type==="object"||t.input==="object",m=t.input==="password",g=t.input==="json_path";let b=zxe;return s?b=Dxe:u?b=Rxe:d?b=Fxe:f?b=$xe:c?b=Bxe:h?b=Hxe:m?b=Wxe:g&&(b=s0e),l.jsx("div",{className:a,children:l.jsx(b,{id:e,descriptor:t,value:r,onChange:n,provider:o,readOnly:i})})}function l0e({value:e,options:t=[],onChange:r,disabled:n=!1,className:o=""}){const a=Array.isArray(t)?t:[],i=a.length>0,s=e??"",c=u=>{r?.(u.target.value)};return l.jsx("select",{value:i?s:"",onChange:c,disabled:n||!i,className:o||"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:i?a.map(u=>l.jsx("option",{value:u.value,children:u.label},u.value)):l.jsx("option",{value:"",disabled:!0,children:"No operators available"})})}const KP="block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",c0e="rounded-md border border-dashed border-gray-300 px-3 py-2 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400",u0e=e=>e===!0?"true":e===!1?"false":e===""||e===null||e===void 0?"true":String(e),d0e=(e,t)=>e?t==="number"?"e.g. 100, 200":"Enter comma-separated values":t==="number"?"e.g. 200":"e.g. /api/payments";function f0e({value:e,valueType:t="string",valueRequired:r=!0,multiValue:n=!1,onChange:o,className:a,hintClassName:i}){return r?t==="boolean"?l.jsxs("select",{value:u0e(e),onChange:s=>o?.(s.target.value),className:a||KP,children:[l.jsx("option",{value:"true",children:"true"}),l.jsx("option",{value:"false",children:"false"})]}):l.jsx("input",{type:"text",value:e??"",onChange:s=>o?.(s.target.value),placeholder:d0e(n,t),className:a||KP}):l.jsx("div",{className:i||c0e,children:"This operator does not require a comparison value."})}const YP=({onMoveUp:e,onMoveDown:t,disableUp:r,disableDown:n})=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{type:"button",onClick:e,disabled:r,"aria-label":"Move up",className:"inline-flex items-center justify-center rounded-md border border-gray-200 p-1 text-gray-500 transition hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:l.jsx("path",{d:"m18 15-6-6-6 6"})})}),l.jsx("button",{type:"button",onClick:t,disabled:n,"aria-label":"Move down",className:"inline-flex items-center justify-center rounded-md border border-gray-200 p-1 text-gray-500 transition hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:l.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),m0e=({form:e,events:t,selectedEventDescription:r,actionsCatalog:n,isEditing:o,saving:a,formErrors:i,onSubmit:s,onReset:c,onFieldChange:u,onConditionChange:d,onAddCondition:f,onRemoveCondition:h,onMoveCondition:m,onActionTypeChange:g,onActionParamChange:b,onAddAction:v,onRemoveAction:x,onMoveAction:w,operatorOptions:E,formId:j,hideFooter:S=!1})=>{const C=e.conditions.length>1,O=e.actions.length>1,T=Array.isArray(E)?E:[];return l.jsxs("form",{id:j,className:"space-y-6 rounded-lg border border-gray-200 bg-gray-50 p-4 shadow-sm dark:border-gray-800 dark:bg-[#090E1A]/60 sm:p-6",onSubmit:s,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"rule-name",className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:o?"Edit Rule":"Rule Name"}),l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:o?"Update the selected rule and save your changes.":"Define a descriptive name for your rule."})]}),o&&l.jsx("span",{className:"inline-flex items-center rounded-full bg-blue-500/10 px-3 py-1 text-xs font-medium text-blue-600 dark:text-blue-400",children:"Editing"})]}),l.jsx("input",{id:"rule-name",type:"text",value:e.name,onChange:P=>u("name",P.target.value),placeholder:"E.g. Min. Transaction Amount USD",className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-800 dark:bg-[#090E1A] dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"rule-description",className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Description"}),l.jsx("textarea",{id:"rule-description",rows:3,value:e.description,onChange:P=>u("description",P.target.value),placeholder:"Optional summary for this automation rule",className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-800 dark:bg-[#090E1A] dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"})]}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"rule-event",className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Event Trigger"}),l.jsxs("select",{id:"rule-event",value:e.event,onChange:P=>u("event",P.target.value),className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-800 dark:bg-[#090E1A] dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:[t.length===0&&l.jsx("option",{value:"",children:"No events available"}),t.map(P=>l.jsx("option",{value:P.type,children:P.label||P.name||P.type},P.type))]}),t.length>0&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:r||"Select the event to monitor."})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"rule-priority",className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Priority"}),l.jsx("input",{id:"rule-priority",type:"number",value:e.priority,onChange:P=>u("priority",P.target.value),className:"block w-full max-w-[7rem] rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-800 dark:bg-[#090E1A] dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30"})]}),l.jsxs("div",{className:"space-y-2 sm:justify-self-end",children:[l.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Activation"}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("input",{id:"rule-active",type:"checkbox",checked:e.active,onChange:P=>u("active",P.target.checked),className:"size-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900"}),l.jsx("label",{htmlFor:"rule-active",className:"text-sm text-gray-700 dark:text-gray-200",children:"Rule is active"})]})]})]}),l.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-[#090E1A]",children:[l.jsxs("div",{className:"border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Rule Flow"}),l.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Configure the event, matching conditions, and resulting actions."})]}),l.jsxs("div",{className:"space-y-6 px-4 py-5",children:[l.jsxs("div",{className:"rounded-lg border-l-4 border-orange-600 bg-orange-50/60 p-4 dark:border-orange-500 dark:bg-orange-500/10",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"flex aspect-square h-10 items-center justify-center rounded-lg bg-orange-600 dark:bg-orange-500","aria-hidden":"true",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-6 text-white",children:[l.jsx("path",{d:"M12 2v14"}),l.jsx("path",{d:"m19 9-7 7-7-7"}),l.jsx("circle",{cx:"12",cy:"21",r:"1"})]})}),l.jsxs("div",{className:"truncate",children:[l.jsx("h5",{className:"text-sm font-medium capitalize text-gray-900 dark:text-gray-50",children:"Event"}),l.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Select the operation event you want to monitor."})]})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx("label",{className:"text-xs font-medium text-gray-900 dark:text-gray-200",htmlFor:"builder-event",children:"Event"}),l.jsx("select",{id:"builder-event",value:e.event,onChange:P=>u("event",P.target.value),className:"mt-2 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-800 dark:bg-[#090E1A] dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:t.map(P=>l.jsx("option",{value:P.type,children:P.name||P.type},P.type))})]})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsx("h5",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Conditions"}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",htmlFor:"expression-type",children:"Condition Logic"}),l.jsx("select",{id:"expression-type",value:e.expressionType,onChange:P=>u("expressionType",P.target.value),className:"rounded-md border border-gray-300 bg-white px-3 py-2 text-xs text-gray-700 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:Nxe.map(P=>l.jsx("option",{value:P.value,children:P.label},P.value))})]})]}),e.conditions.map((P,M)=>{const D=T.find(_=>_.value===P.operator)||T[0],R=D?.valueRequired!==!1,F=D?.multiValue===!0;return l.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900",children:l.jsxs("div",{className:"flex items-start gap-4 px-4 py-4",children:[l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx("span",{className:"flex aspect-square h-10 items-center justify-center rounded-lg bg-sky-500","aria-hidden":"true",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-6 text-white",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),l.jsx("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3"}),l.jsx("path",{d:"M9 11.2h5.7"})]})}),l.jsx(YP,{onMoveUp:()=>m(M,M-1),onMoveDown:()=>m(M,M+1),disableUp:!C||M===0,disableDown:!C||M===e.conditions.length-1})]}),l.jsxs("div",{className:"flex-1 space-y-3",children:[l.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"JSON path"}),l.jsx(hD,{value:P.path,onChange:_=>d(M,"path",_),placeholder:"$.request.path",className:"!space-y-1",browseButtonLabel:"Browse",enablePreview:!0})]}),l.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Operator"}),l.jsx(l0e,{value:P.operator,options:T,onChange:_=>d(M,"operator",_),disabled:a||T.length===0})]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Value Type"}),l.jsx("select",{value:P.valueType,onChange:_=>d(M,"valueType",_.target.value),disabled:!R,className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:xxe.map(_=>l.jsx("option",{value:_.value,children:_.label},_.value))})]})]})]}),l.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Compare value"}),l.jsx(f0e,{value:P.value,valueType:P.valueType,valueRequired:R,multiValue:F,onChange:_=>d(M,"value",_)})]}),l.jsx("div",{className:"flex flex-wrap items-end justify-end gap-2",children:l.jsx("button",{type:"button",onClick:()=>h(M),className:"inline-flex items-center gap-2 rounded-md border border-transparent px-3 py-2 text-xs font-medium text-red-600 transition hover:border-red-200 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60 dark:text-red-400 dark:hover:border-red-800 dark:hover:bg-red-900/30",disabled:e.conditions.length===1,children:"Remove"})})]})]})]})},M)}),l.jsxs("button",{type:"button",onClick:f,className:"inline-flex items-center gap-2 rounded-md border border-dashed border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 transition hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-900",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4","aria-hidden":"true",children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Condition"]})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h5",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Actions"}),l.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-2 rounded-md border border-transparent bg-blue-500 px-3 py-2 text-xs font-medium text-white transition hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-500",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4","aria-hidden":"true",children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Action"]})]}),e.actions.map((P,M)=>{const D=n.find(L=>L.type===P.type),R=D||{params:[]},F=!D&&!!P.type,_=["overflow-hidden rounded-lg border bg-white shadow-sm dark:bg-gray-900",F?"border-amber-300 dark:border-amber-500/40":"border-gray-200 dark:border-gray-800"].join(" ");return l.jsx("div",{className:_,children:l.jsxs("div",{className:"flex items-start gap-4 px-4 py-4",children:[l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx("span",{className:"flex aspect-square h-10 items-center justify-center rounded-lg bg-emerald-500","aria-hidden":"true",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-6 text-white",children:[l.jsx("path",{d:"M22 12A10 10 0 1 1 12 2"}),l.jsx("path",{d:"M22 2 12 12"}),l.jsx("path",{d:"M16 2h6v6"})]})}),l.jsx(YP,{onMoveUp:()=>w(P.id,M-1),onMoveDown:()=>w(P.id,M+1),disableUp:!O||M===0,disableDown:!O||M===e.actions.length-1})]}),l.jsxs("div",{className:"flex-1 space-y-3",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-[180px] space-y-1",children:[l.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Action Type"}),l.jsxs("select",{value:P.type,onChange:L=>g(P.id,L.target.value),className:"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-50 dark:focus:border-blue-700 dark:focus:ring-blue-700/30",children:[n.length===0&&l.jsx("option",{value:"",children:"No actions available"}),F&&P.type&&l.jsx("option",{value:P.type,children:P.type}),n.map(L=>{const V=L.label||L.name,$=V&&V!==L.type?`${V} (${L.type})`:L.type;return l.jsx("option",{value:L.type,children:$},L.type)})]})]}),F&&l.jsx("div",{className:"flex items-center gap-2",children:l.jsx("span",{className:"inline-flex items-center rounded-full bg-amber-100 px-2.5 py-1 text-xs font-medium text-amber-800 dark:bg-amber-500/10 dark:text-amber-200",children:"Connector disabled"})}),l.jsx("div",{className:"flex items-center gap-2",children:l.jsx("button",{type:"button",onClick:()=>x(P.id),className:"inline-flex items-center gap-2 rounded-md border border-transparent px-3 py-2 text-xs font-medium text-red-600 transition hover:border-red-200 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60 dark:text-red-400 dark:hover:border-red-800 dark:hover:bg-red-900/30",disabled:e.actions.length===1,children:"Remove"})})]}),R?.description&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:R.description}),F&&l.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-500/30 dark:bg-amber-950/40 dark:text-amber-100",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mt-0.5 size-4 flex-shrink-0","aria-hidden":"true",children:[l.jsx("path",{d:"M10.29 3.86 1.82 18a1 1 0 0 0 .86 1.5h18.64a1 1 0 0 0 .86-1.5L13.71 3.86a1 1 0 0 0-1.72 0Z"}),l.jsx("path",{d:"M12 9v4"}),l.jsx("path",{d:"M12 17h.01"})]}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold",children:"Action unavailable"}),l.jsx("p",{className:"mt-1 text-amber-700 dark:text-amber-200/80",children:"This action is unavailable because its connector is disabled. The existing configuration is kept when you save, but the action will be skipped until the connector is enabled again."})]})]}),l.jsx("div",{className:"space-y-4",children:(R.params||[]).map(L=>{var V,$,B,z;if(L.hidden)return null;const q=`${P.id}-${L.name}`,W=(V=P.params)==null?void 0:V[L.name];L.type==="boolean"||L.input,typeof L.type=="string"&&L.type.startsWith("array"),L.input==="single_select"&&Array.isArray(L.choices),L.input==="multi_select"&&Array.isArray(L.choices),L.type==="integer"||L.type==="number"||L.input;const J=L.type==="object"||L.input==="object";L.input,L.readonly;const Y=l.jsxs("label",{htmlFor:q,className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[L.label||L.name,L.required&&l.jsx("span",{className:"ml-1 text-red-500",children:"*"})]});if(J&&Array.isArray(L.variants)&&L.variants.length){const ne=($=P.params)==null?void 0:$.provider,Z=L.variants.find(te=>te.value===ne),de=W&&typeof W=="object"?W:{};return l.jsxs("div",{className:"space-y-2",children:[Y,ne?Z?l.jsxs("div",{className:"space-y-3 rounded-md border border-gray-200 p-3 dark:border-gray-800",children:[Z.description&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:Z.description}),(Z.params||[]).map(te=>{var oe;if(te.hidden)return null;const G=`${q}-${te.name}`;te.type==="boolean"||te.input,te.type==="integer"||te.type==="number"||te.input,typeof te.type=="string"&&te.type.startsWith("array"),te.type==="object"||te.input,te.input==="single_select"&&Array.isArray(te.choices),te.input,te.readonly;const ce=de?.[te.name],ae=U=>{b(P.id,L.name,{...de,[te.name]:U})};return l.jsx(yw,{id:G,descriptor:te,provider:(oe=P.params)==null?void 0:oe.provider,value:ce,onChange:U=>ae(U)},te.name)})]}):l.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:['No options available for provider "',ne,'".']}):l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:"Select a provider to configure options."}),(L.description||L.help)&&l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:L.description||L.help})]},L.name)}return J?l.jsx(yw,{id:q,descriptor:L,provider:(B=P.params)==null?void 0:B.provider,value:W,onChange:ne=>b(P.id,L.name,ne)},L.name):l.jsx(yw,{id:q,descriptor:L,provider:(z=P.params)==null?void 0:z.provider,value:W,onChange:ne=>b(P.id,L.name,ne)},L.name)})})]})]})},P.id)}),l.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-2 rounded-md border border-dashed border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 transition hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-900",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4","aria-hidden":"true",children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Action"]})]})]})]}),i.length>0&&l.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/30 dark:text-red-300",children:l.jsx("ul",{className:"list-disc space-y-1 pl-4",children:i.map((P,M)=>l.jsx("li",{children:P},M))})}),!S&&l.jsxs("div",{className:"sticky bottom-0 z-10 -mx-4 -mb-4 flex items-center justify-end gap-3 border-t border-gray-200 bg-gray-50/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:backdrop-blur dark:border-gray-800 dark:bg-[#090E1A]/95 sm:-mx-6 sm:px-6",children:[l.jsx("button",{type:"button",onClick:c,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-900",children:o?"Cancel edit":"Reset"}),l.jsx("button",{type:"submit",disabled:a,className:"inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-300 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-blue-500 dark:hover:bg-blue-400",children:a?"Saving…":o?"Update Rule":"Save Rule"})]})]})};function p0e({open:e,title:t,description:r,onClose:n,children:o,footer:a=null,showFooter:i=!0,onReset:s,onSave:c,saving:u=!1,isEditing:d=!1,formId:f}){return e?l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 !mt-0",children:l.jsxs("div",{className:"flex max-h-[94vh] w-full max-w-[70%] flex-col overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800 sm:px-6",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:t}),r&&l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r})]}),l.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center rounded-md border border-gray-300 p-2 text-gray-500 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800","aria-label":"Close builder dialog",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[l.jsx("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),l.jsx("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-4 sm:px-6",children:o}),(a||i)&&l.jsx("div",{className:"border-t border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-800 dark:bg-gray-900 sm:px-6",children:a||l.jsxs("div",{className:"flex items-center justify-end gap-3",children:[s?l.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-900",children:d?"Cancel edit":"Reset"}):null,l.jsx("button",{type:f?"submit":"button",form:f,onClick:f?void 0:c,disabled:u,className:"inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-300 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-blue-500 dark:hover:bg-blue-400",children:u?"Saving…":d?"Update Rule":"Save Rule"})]})})]})}):null}function h0e({open:e,groupedTemplates:t,loading:r,error:n,onClose:o,onRetry:a,onSelect:i}){const[s,c]=y.useState(null),[u,d]=y.useState("");y.useEffect(()=>{var m;if(!e){c(null),d("");return}if(t.length===0){c(null);return}t.some(g=>g.id===s)||c(((m=t[0])==null?void 0:m.id)??null)},[e,t,s]);const f=y.useMemo(()=>t.find(m=>m.id===s)??null,[t,s]),h=y.useMemo(()=>{if(!f)return[];if(!u.trim())return f.items;const m=u.toLowerCase();return f.items.filter(g=>{var b,v;const x=((b=g.name)==null?void 0:b.toLowerCase())??"",w=((v=g.description)==null?void 0:v.toLowerCase())??"";return x.includes(m)||w.includes(m)})},[f,u]);return e?l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 !mt-0",children:l.jsxs("div",{className:"w-full max-w-5xl overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800 sm:px-6",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Start from a template"}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Choose a starter rule and customise it to fit your automation workflow."})]}),l.jsx("button",{type:"button",onClick:o,className:"inline-flex items-center rounded-md border border-gray-300 p-2 text-gray-500 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800","aria-label":"Close template dialog",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[l.jsx("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),l.jsx("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]}),l.jsx("div",{className:"max-h-[80vh] overflow-y-auto px-4 py-6 sm:px-6",children:r?l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Loading templates…"}):n?l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:n}),l.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800",children:"Try again"})]}):t.length===0?l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"No templates available right now."}):l.jsxs("div",{className:"grid gap-6 lg:grid-cols-[260px,1fr]",children:[l.jsxs("aside",{className:"space-y-4",children:[l.jsx("h4",{className:"text-sm font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Template groups"}),l.jsx("div",{className:"space-y-2",children:t.map(m=>{const g=m.id===s;return l.jsx("button",{type:"button",onClick:()=>{c(m.id),d("")},className:`w-full rounded-md border px-4 py-3 text-left transition ${g?"border-blue-500 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-900/30 dark:text-blue-100":"border-gray-200 bg-white text-gray-900 hover:border-blue-300 hover:bg-blue-50/60 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-100 dark:hover:border-blue-500/70 dark:hover:bg-blue-900/20"}`,children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold",children:m.label}),m.description&&l.jsx("p",{className:"mt-1 text-xs text-gray-600 dark:text-gray-400",children:m.description})]}),l.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:m.items.length})]})},m.id)})})]}),l.jsxs("section",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:f?.label??"Select a group"}),f?.description&&l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:f.description})]}),f&&l.jsxs("div",{className:"relative w-full sm:w-64",children:[l.jsx("label",{htmlFor:"template-search",className:"sr-only",children:"Search templates"}),l.jsx("input",{id:"template-search",type:"search",value:u,onChange:m=>d(m.target.value),placeholder:"Search templates",className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm outline-none transition focus:border-blue-500 focus:ring-2 focus:ring-blue-500/40 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100"}),l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 text-gray-400 dark:text-gray-500","aria-hidden":"true",children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("path",{d:"m21 21-3.6-3.6"})]})]})]}),f?h.length===0?l.jsx("div",{className:"rounded-md border border-dashed border-gray-300 p-6 text-center text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400",children:"No templates match your search in this group."}):l.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:h.map(m=>{var g;return l.jsxs("div",{className:"flex h-full flex-col justify-between rounded-lg border border-gray-200 bg-white p-4 shadow-sm transition hover:border-blue-400 hover:shadow-md dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("h5",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:m.name}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:m.description}),l.jsxs("div",{className:"mt-3 space-y-1 text-xs text-gray-500 dark:text-gray-500",children:[l.jsxs("p",{children:[l.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Event:"})," ",m.event]}),l.jsxs("p",{children:[l.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Actions:"})," ",((g=m.actions)==null?void 0:g.length)||0]})]})]}),l.jsx("button",{type:"button",onClick:()=>i(m),className:"mt-4 inline-flex items-center justify-center rounded-md border border-transparent bg-blue-500 px-3 py-2 text-sm font-medium text-white shadow-sm transition hover:bg-blue-600 dark:bg-blue-600 dark:hover:bg-blue-500",children:"Use template"})]},m.id)})}):l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Select a group to view its templates."})]})]})})]})}):null}function g0e({open:e,rule:t,onClose:r,onPreview:n,onApply:o,loading:a,applying:i,error:s,preview:c,previewType:u="preview",tagOptions:d=[]}){const f=()=>({since:"",until:"",methods:[],path:"",host:"",tagsAll:[],tagsAny:[],statuses:[]}),[h,m]=p.useState(f),[g,b]=p.useState(!1),v=p.useMemo(()=>{if(!Array.isArray(d))return[];const $=Array.from(new Set(d.filter(B=>typeof B=="string")));return $.sort((B,z)=>B.localeCompare(z)),$},[d]);p.useEffect(()=>{e&&(m(f()),b(!1))},[e,t?.id]);const x=$=>Array.isArray($)?$.map(B=>B.trim()).filter(Boolean):[],w=$=>{const{name:B,value:z}=$.target;m(q=>({...q,[B]:z}))},E=$=>{const B=x($).slice(0,1);m(z=>({...z,methods:B}))},j=$=>{m(B=>({...B,statuses:x($)}))},S=$=>{m(B=>({...B,tagsAll:x($)}))},C=$=>{m(B=>({...B,tagsAny:x($)}))},O=()=>{m(f()),b(!1)},T=p.useMemo(()=>{var $,B,z,q,W,J;const Y=[];return h.since&&Y.push("Since"),h.until&&Y.push("Until"),($=h.methods)!=null&&$.length&&Y.push("Method"),(B=h.statuses)!=null&&B.length&&Y.push("Status codes"),(z=h.path)!=null&&z.trim()&&Y.push("Path"),(q=h.host)!=null&&q.trim()&&Y.push("Host"),(W=h.tagsAll)!=null&&W.length&&Y.push("Tags (all)"),(J=h.tagsAny)!=null&&J.length&&Y.push("Tags (any)"),Y},[h]);p.useEffect(()=>{T.length>0&&b(!0)},[T.length]);const P=()=>{var $,B;const z=Z=>{if(!Z)return;const de=new Date(Z);return Number.isNaN(de.getTime())?void 0:de},q=(Array.isArray(h.statuses)?h.statuses:[]).map(Z=>Number(Z)).filter(Z=>Number.isFinite(Z)),W=x(h.methods).map(Z=>Z.toUpperCase()),J=x(h.tagsAll),Y=x(h.tagsAny),ne=W[0];return{since:z(h.since),until:z(h.until),method:ne,path:(($=h.path)==null?void 0:$.trim())||void 0,host:((B=h.host)==null?void 0:B.trim())||void 0,tagsAll:J.length?J:void 0,tagsAny:Y.length?Y:void 0,statuses:q.length?q:void 0}},M=p.useMemo(()=>{if(!c)return[];const $=c.matches||c.operations||c.items||c.sample||c.sampled||c.preview||[];return Array.isArray($)?$:[]},[c]),D=p.useMemo(()=>!c||typeof c!="object"?[]:[{key:"processed",label:"Processed",value:c.processed},{key:"matched",label:"Matched",value:c.matched},{key:"updated",label:"Updated",value:c.updated},{key:"duration_ms",label:"Duration (ms)",value:c.duration_ms}].filter($=>$.value!==void 0&&$.value!==null),[c]),R=u==="apply",F=p.useMemo(()=>c?typeof c?.matched=="number"?c.matched>0:M.length>0:!1,[c,M]),_=R?"Apply results":"Preview summary",L=R?"Affected operations":"Preview matches",V=($,B)=>{const z=$.method||$.req_method||$.http_method,q=$.path||$.req_path||$.url||$.request_path,W=$.status||$.res_status||$.http_status,J=$.time||$.ts||$.timestamp||$.at;return l.jsxs("li",{className:"rounded border border-gray-200 bg-white p-3 text-xs dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[z&&l.jsx("span",{className:"inline-flex items-center rounded bg-gray-100 px-2 py-0.5 font-medium text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:z}),q&&l.jsx("span",{className:"truncate text-gray-800 dark:text-gray-200",children:q}),W!=null&&l.jsx("span",{className:"ml-auto inline-flex items-center rounded bg-gray-100 px-2 py-0.5 font-medium text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:String(W)})]}),J&&l.jsx("div",{className:"mt-1 text-gray-500 dark:text-gray-400",children:String(J)}),!z&&!q&&!W&&l.jsx("pre",{className:"mt-2 overflow-auto text-[10px] leading-tight text-gray-600 dark:text-gray-400",children:JSON.stringify($,null,2)})]},B)};return e?l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 !mt-0",children:l.jsxs("div",{className:"w-full max-w-3xl overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800 sm:px-6",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:["Apply “",t?.name,"” to history"]}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Optionally set filters, review the results, then apply."})]}),l.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center rounded-md border border-gray-300 p-2 text-gray-500 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800","aria-label":"Close",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[l.jsx("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),l.jsx("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]}),l.jsxs("div",{className:"max-h-[80vh] overflow-auto p-4 sm:p-6",children:[l.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Filters (optional)"}),l.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:T.length===0?"No filters applied. Inspectr will search across all stored operations.":`Active filters: ${T.join(", ")}`})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&l.jsx("button",{type:"button",onClick:O,className:"rounded border border-gray-300 px-2 py-1 text-xs font-medium text-gray-600 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Clear filters"}),l.jsx("button",{type:"button",onClick:()=>b($=>!$),className:"rounded border border-transparent bg-gray-100 px-2 py-1 text-xs font-medium text-gray-700 transition hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:g?"Hide filters":"Show filters"})]})]}),g&&l.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",children:[l.jsxs("label",{className:"text-xs text-gray-700 dark:text-gray-300",children:["Since",l.jsx("input",{type:"datetime-local",name:"since",value:h.since,onChange:w,className:"mt-1 w-full rounded border border-gray-300 bg-white p-2 text-sm dark:border-gray-700 dark:bg-gray-900"})]}),l.jsxs("label",{className:"text-xs text-gray-700 dark:text-gray-300",children:["Until",l.jsx("input",{type:"datetime-local",name:"until",value:h.until,onChange:w,className:"mt-1 w-full rounded border border-gray-300 bg-white p-2 text-sm dark:border-gray-700 dark:bg-gray-900"})]}),l.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300",children:[l.jsx("span",{children:"Method"}),l.jsx("div",{className:"mt-1",children:l.jsx($s,{options:v7,selected:h.methods,onChange:E,placeholder:"Select method",colorFn:H2})})]}),l.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300",children:[l.jsx("span",{children:"Status codes"}),l.jsx("div",{className:"mt-1",children:l.jsx($s,{options:y7,selected:h.statuses,onChange:j,placeholder:"Add status code...",colorFn:tf})})]}),l.jsxs("label",{className:"text-xs text-gray-700 dark:text-gray-300",children:["Path contains",l.jsx("input",{type:"text",name:"path",placeholder:"/api/users",value:h.path,onChange:w,className:"mt-1 w-full rounded border border-gray-300 bg-white p-2 text-sm dark:border-gray-700 dark:bg-gray-900"})]}),l.jsxs("label",{className:"text-xs text-gray-700 dark:text-gray-300",children:["Host",l.jsx("input",{type:"text",name:"host",placeholder:"api.example.com",value:h.host,onChange:w,className:"mt-1 w-full rounded border border-gray-300 bg-white p-2 text-sm dark:border-gray-700 dark:bg-gray-900"})]}),l.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300",children:[l.jsx("span",{children:"Tags (all)"}),l.jsx("div",{className:"mt-1",children:l.jsx($s,{options:v,selected:h.tagsAll,onChange:S,placeholder:"Add tag..."})})]}),l.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300",children:[l.jsx("span",{children:"Tags (any)"}),l.jsx("div",{className:"mt-1",children:l.jsx($s,{options:v,selected:h.tagsAny,onChange:C,placeholder:"Add tag..."})})]})]})]}),R&&!i&&!s&&l.jsx("div",{className:"mt-3 rounded border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700 dark:border-green-900 dark:bg-green-950/40 dark:text-green-300",children:"Rule applied to historical operations. Review the results below."}),s&&l.jsx("p",{className:"mt-3 text-sm text-red-600 dark:text-red-400",children:s}),l.jsxs("div",{className:"mt-4 flex w-full items-center justify-end gap-3",children:[l.jsx("button",{type:"button",onClick:()=>n(P()),disabled:a,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-900 transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-700 dark:text-gray-50 dark:hover:bg-gray-800",children:a?"Previewing…":"Preview matches"}),l.jsx("button",{type:"button",onClick:()=>o(P()),disabled:i,className:"inline-flex items-center rounded-md border border-transparent bg-blue-500 px-3 py-2 text-sm font-medium text-white shadow-sm transition hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-blue-600 dark:hover:bg-blue-500",children:i?"Applying…":"Apply now"}),l.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800",children:"Cancel"})]}),D.length>0&&l.jsxs("div",{className:"mt-6 space-y-2",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:_}),l.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:D.map($=>l.jsxs("div",{className:"flex items-center justify-between rounded border border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-800 dark:bg-gray-900",children:[l.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:$.label}),l.jsx("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:$.value})]},$.key))})]}),M.length>0&&l.jsxs("div",{className:"mt-6",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:L}),l.jsx("ul",{className:"mt-2 space-y-2",children:M.map(V)})]}),!a&&c&&!F&&l.jsx("p",{className:"mt-4 text-sm text-gray-500 dark:text-gray-400",children:"No matching operations found for the selected filters."})]})]})}):null}function b0e({onTagsUpdate:e}){const{client:t,setToast:r}=yr(),[n,o]=p.useState([]),[a,i]=p.useState(!0),[s,c]=p.useState(""),[u,d]=p.useState(!1),[f,h]=p.useState(null),[m,g]=p.useState(!1),[b,v]=p.useState(""),x=!!(t!=null&&t.operations),w=O=>{o(O),e?.(O)},E=async()=>{if(x)try{d(!0),c("");const O=await t.operations.listTags(),T=Array.isArray(O?.tags)?O.tags:[];T.sort((P,M)=>P.localeCompare(M)),w(T)}catch(O){console.error("Failed to refresh tags",O),c(O?.message||"Failed to refresh tags")}finally{d(!1)}};p.useEffect(()=>{if(!x)return;let O=!1;return(async()=>{try{i(!0);const T=await t.operations.listTags();if(O)return;const P=Array.isArray(T?.tags)?T.tags:[];P.sort((M,D)=>M.localeCompare(D)),w(P)}catch(T){if(O)return;console.error("Failed to load tags",T),c(T?.message||"Failed to load tags")}finally{O||i(!1)}})(),()=>{O=!0}},[x,t]);const j=O=>{h(O),v("")},S=()=>{h(null),v("")},C=async()=>{if(!(!f||!(t!=null&&t.operations)))try{g(!0),v("");const O=await t.operations.bulkDeleteTag({tag:f,dryRun:!1});r?.({type:"success",message:`Tag "${f}" removed from matching operations`}),h(null),E()}catch(O){console.error("Bulk delete tag failed",O),v(O?.message||"Failed to delete tag"),r?.({type:"error",message:O?.message||"Failed to delete tag"})}finally{g(!1)}};return l.jsxs("section",{className:"rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Operation Tags"}),l.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"View and remove tags across operations."})]}),l.jsx("div",{className:"flex items-center gap-3",children:l.jsx("button",{type:"button",onClick:E,title:"Refresh tags",disabled:u||a,className:"inline-flex items-center rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-900",children:u?"Refreshing…":"Refresh"})})]}),l.jsxs("div",{className:"px-4 pt-2 pb-4",children:[s&&l.jsx("div",{className:"mb-3 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950 dark:text-red-300",children:s}),a?l.jsx("div",{className:"py-8 text-center text-sm text-gray-500 dark:text-gray-400",children:"Loading tags…"}):n.length===0?l.jsx("div",{className:"py-8 text-center text-sm text-gray-500 dark:text-gray-400",children:"No tags found."}):l.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:n.map(O=>l.jsxs("li",{className:"flex items-center justify-between gap-3 py-2",children:[l.jsx("div",{className:"inline-flex items-center gap-2",children:l.jsx(rl,{tag:O})}),l.jsxs("button",{type:"button",onClick:()=>j(O),className:"inline-flex items-center gap-1 rounded-md border border-red-200 px-2.5 py-1.5 text-xs font-medium text-red-700 transition hover:bg-red-50 dark:border-red-900/40 dark:text-red-300 dark:hover:bg-red-950",title:`Remove tag "${O}" from operations`,children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"-ms-0.5",children:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),l.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),l.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),l.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]}),"Remove"]})]},O))})]}),l.jsx(Bh,{open:!!f,isDeleting:m,error:b,onCancel:S,onConfirm:C,title:"Remove tag from operations?",description:f?l.jsxs(l.Fragment,{children:["This will remove the tag ",l.jsx("span",{className:"font-semibold",children:f})," from all matching operations. This action cannot be undone."]}):"",confirmLabel:"Delete Tag"})]})}function v0e({open:e,rule:t,onClose:r}){const{client:n,setToast:o}=yr(),[a,i]=p.useState(!1),[s,c]=p.useState(""),u=p.useMemo(()=>t?.name||"All rules",[t]);if(!e)return null;const d=async()=>{var f;if((f=n?.rules)!=null&&f.export){i(!0),c("");try{const{blob:h,filename:m}=await n.rules.export({id:t?.id}),g=URL.createObjectURL(h),b=document.createElement("a");b.href=g,b.download=m||"rules.yaml",document.body.appendChild(b),b.click(),b.remove(),URL.revokeObjectURL(g),o?.({type:"success",message:`Downloaded ${m||"rules.yaml"}`}),r?.()}catch(h){console.error("Export download failed",h),c(h?.message||"Failed to export rules")}finally{i(!1)}}};return l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 !mt-0",children:l.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800 sm:px-6",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Export rules"}),l.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Download YAML export",t!=null&&t.name?` for "${u}"`:"","."]}),t?.name&&l.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:["Rule: ",u]})]}),l.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center rounded-md border border-gray-300 p-2 text-gray-500 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800","aria-label":"Close export dialog",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[l.jsx("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),l.jsx("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]}),l.jsxs("div",{className:"space-y-4 px-4 py-4 sm:px-6",children:[s&&l.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300",children:s}),l.jsx("div",{className:"flex items-center justify-end",children:l.jsx("button",{type:"button",onClick:d,disabled:a,className:"inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-blue-700 disabled:opacity-60 focus:outline-none focus:ring-2 focus:ring-blue-300 dark:bg-blue-500 dark:hover:bg-blue-400",children:a?"Preparing…":"Download rules.yaml"})})]})]})})}function y0e({open:e,onCancel:t,onImport:r,onImported:n}){const{client:o,setToast:a}=yr(),[i,s]=p.useState(""),[c,u]=p.useState(null),[d,f]=p.useState(""),[h,m]=p.useState(!1),[g,b]=p.useState(!1);if(p.useEffect(()=>{e||(s(""),u(null),f(""),m(!1),b(!1))},[e]),!e)return null;const v=w=>{var E;const j=((E=w.target.files)==null?void 0:E[0])||null;u(j),f("")},x=async()=>{var w;if((w=o?.rules)!=null&&w.import){if(!c&&!i.trim()){f("Select a YAML file or paste YAML content.");return}m(!0),f("");try{let E=i;if(c)try{E=await new Response(c).text()}catch(C){console.error("Failed to read file",C),f("Could not read the selected file. Please reselect it or paste the YAML."),m(!1);return}const j=await o.rules.import(E,{overwrite:g}),S=j?.rule||(Array.isArray(j?.rules)?j.rules[0]:null);if(a?.({type:"success",message:"Import completed"}),n)try{await n()}catch{}S&&r&&r(S),t?.()}catch(E){console.error("Import failed",E),f(E?.message||"Failed to import rules")}finally{m(!1)}}};return l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 !mt-0",children:l.jsxs("div",{className:"w-full max-w-xl overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-800 dark:bg-gray-900",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-4 py-4 dark:border-gray-800 sm:px-6",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Import rules"}),l.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Upload a .yaml export or paste YAML content."})]}),l.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center rounded-md border border-gray-300 p-2 text-gray-500 transition hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800","aria-label":"Close import dialog",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[l.jsx("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),l.jsx("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]}),l.jsxs("div",{className:"space-y-4 px-4 py-4 sm:px-6",children:[d&&l.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300",children:d}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("label",{htmlFor:"rule-import-file",className:"shrink-0 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"YAML file"}),l.jsx("input",{id:"rule-import-file",type:"file",accept:".yaml,.yml,text/yaml,application/x-yaml,application/yaml",onChange:v,onClick:w=>{w.currentTarget.value=null},className:"block w-full text-sm text-gray-700 file:mr-3 file:rounded-md file:border file:border-gray-300 file:bg-white file:px-3 file:py-2 file:text-sm file:font-medium file:text-gray-700 hover:file:bg-gray-50 dark:text-gray-200 dark:file:border-gray-700 dark:file:bg-gray-900"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"rule-import-yaml",className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Or paste YAML"}),l.jsx("textarea",{id:"rule-import-yaml",value:i,onChange:w=>s(w.target.value),rows:12,placeholder:`# name: Example rule
package/dist/index.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en" data-astro-cid-sckkx6r4> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><link rel="icon" type="image/icon" href="/favicon.ico"><meta name="description" content="Inspectr – Simplifying API and Webhook debugging"><title>Inspectr</title><link rel="stylesheet" href="/_astro/index.CUH79thk.css"></head> <body class="text-sm" data-astro-cid-sckkx6r4> <style>astro-island,astro-slot,astro-static-slot{display:contents}</style><script>(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event("astro:only"));})();</script><script>(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>1/0*t},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,"Component");d(this,"hydrator");d(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},h=this.querySelectorAll("template[data-astro-template]");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let p;try{p=this.hasAttribute("props")?m(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute("props"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});d(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[h,{default:p}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),u=this.getAttribute("component-export")||"default";if(!u.includes("."))this.Component=h[u];else{this.Component=h;for(let f of u.split("."))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(`[astro-island] Error hydrating ${this.getAttribute("component-url")}`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",y)}})();</script><astro-island uid="DTaCv" component-url="/_astro/ui.CYofYkXz.js" component-export="Workspace" renderer-url="/_astro/client.BGkzOQ_w.js" props="{}" ssr client="only" opts="{&quot;name&quot;:&quot;Workspace&quot;,&quot;value&quot;:&quot;react&quot;}"></astro-island> </body></html>
1
+ <!DOCTYPE html><html lang="en" data-astro-cid-sckkx6r4> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><link rel="icon" type="image/icon" href="/favicon.ico"><meta name="description" content="Inspectr – Simplifying API and Webhook debugging"><title>Inspectr</title><link rel="stylesheet" href="/_astro/index.CUH79thk.css"></head> <body class="text-sm" data-astro-cid-sckkx6r4> <style>astro-island,astro-slot,astro-static-slot{display:contents}</style><script>(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event("astro:only"));})();</script><script>(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>1/0*t},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,"Component");d(this,"hydrator");d(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},h=this.querySelectorAll("template[data-astro-template]");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let p;try{p=this.hasAttribute("props")?m(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute("props"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});d(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[h,{default:p}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),u=this.getAttribute("component-export")||"default";if(!u.includes("."))this.Component=h[u];else{this.Component=h;for(let f of u.split("."))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(`[astro-island] Error hydrating ${this.getAttribute("component-url")}`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",y)}})();</script><astro-island uid="DTaCv" component-url="/_astro/ui.CpebLRsQ.js" component-export="Workspace" renderer-url="/_astro/client.BGkzOQ_w.js" props="{}" ssr client="only" opts="{&quot;name&quot;:&quot;Workspace&quot;,&quot;value&quot;:&quot;react&quot;}"></astro-island> </body></html>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@inspectr/app",
3
3
  "description": "Standalone Inspectr app for inspecting API requests & Webhook events.",
4
4
  "type": "module",
5
- "version": "1.5.0",
5
+ "version": "1.5.1",
6
6
  "author": "Tim Haselaars",
7
7
  "homepage": "https://inspectr.dev",
8
8
  "bugs": "https://github.com/inspectr-hq/inspectr-app/issues",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@astrojs/react": "^4.4.2",
50
- "@inspectr/ui": "^1.5.0",
50
+ "@inspectr/ui": "^1.5.1",
51
51
  "@tailwindcss/vite": "^4.1.3",
52
52
  "@types/react": "^18.3.20",
53
53
  "@types/react-dom": "^18.3.6",