@mcpjam/inspector 1.0.6 → 1.0.7
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"
|
|
1
|
+
(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"1089486b0ebec2785f22b85e112340804d2f12b0"}}catch{}})();try{(function(){var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="c0fa5fd7-3c6a-4f3c-ad8e-c08092eb55b1",t._sentryDebugIdIdentifier="sentry-dbid-c0fa5fd7-3c6a-4f3c-ad8e-c08092eb55b1")})()}catch{}function XK(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Vf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fS={exports:{}},cp={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -1770,9 +1770,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
1770
1770
|
|
|
1771
1771
|
<\/script>
|
|
1772
1772
|
</body>
|
|
1773
|
-
</html>`,Mq=1,FD=2,Oq=3,UD=4,Pq=5,BD=Symbol.for("quilt.threads.serialize"),Xde=Symbol.for("quilt.threads.transferable");class Qde extends AbortController{constructor(...e){super();const n=e.find(r=>r.aborted);if(n)this.abort(n.reason);else{const r=i=>this.abort(i.target.reason),s={signal:this.signal};for(const i of e)i.addEventListener("abort",r,s)}}}class qD extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let Jde="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function Iq(t=21){let e="",n=crypto.getRandomValues(new Uint8Array(t));for(let r=0;r<t;r++)e+=Jde[63&n[r]];return e}var Up,Dd,Bp,Qy,NT,Dq;class Zde{constructor(){Zi(this,NT),Zi(this,Up,new Map),Zi(this,Dd,new Map),Zi(this,Bp,new Map),Zi(this,Qy,new WeakMap)}get(e){return Pn(this,Dd).get(e)}release(e){const n=Pn(this,Dd).get(e);return n&&(Pn(this,Dd).delete(e),Pn(this,Up).delete(n)),!!n}serialize(e){let n=Pn(this,Up).get(e);return n==null&&(n=Iq(),Pn(this,Up).set(e,n),Pn(this,Dd).set(n,e)),n}deserialize(e,n){var r,s;let i=(r=Pn(this,Bp).get(e))==null?void 0:r.deref();return i||(i=(...a)=>{if(!Pn(this,Bp).has(e))throw new Error("You attempted to call a function that was already revoked.");return n.call((l,u,d)=>{n.messages.send([Oq,l,e,u],d)},a)},(s=Yr(this,NT,Dq).call(this,n))==null||s.register(i,e),Pn(this,Bp).set(e,new WeakRef(i)),i)}}Up=new WeakMap,Dd=new WeakMap,Bp=new WeakMap,Qy=new WeakMap,NT=new WeakSet,Dq=function(t){let e=Pn(this,Qy).get(t);if(!(typeof FinalizationRegistry>"u"))return e||(e=new FinalizationRegistry(n=>{t.messages.send([Pq,n])}),Pn(this,Qy).set(t,e)),e};function efe(t){return t!=null&&(Symbol.asyncIterator in t||Symbol.iterator in t)&&typeof t.next=="function"}function VD(t){if(t==null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e==null||e===Object.prototype}const aE="_@f",HD="_@i";var Jp,Zp,bi,Jy,Tl;class tfe{constructor(e){Zi(this,bi),Zi(this,Jp),Zi(this,Zp),TT(this,Jp,e?.serialize),TT(this,Zp,e?.deserialize)}serialize(e,n,r){return Yr(this,bi,Jy).call(this,e,n,r)}deserialize(e,n){return Yr(this,bi,Tl).call(this,e,n)}}Jp=new WeakMap,Zp=new WeakMap,bi=new WeakSet,Jy=function(t,e,n,r=new Map,s=!1){if(t==null)return t;if(r.has(t))return r.get(t);if(r.set(t,void 0),typeof t=="object"){if(Pn(this,Jp)&&!s){const l=Pn(this,Jp).call(this,t,u=>Yr(this,bi,Jy).call(this,u,e,n,r,!0),e,n);if(l!==void 0)return r.set(t,l),l}if(t[Xde])return n?.push(t),r.set(t,t),t;const i=l=>Yr(this,bi,Jy).call(this,l,e,n,r);if(typeof t[BD]=="function"){const l=t[BD]({serialize:i});return r.set(t,l),l}if(Array.isArray(t)){const l=t.map(u=>i(u));return r.set(t,l),l}if(t instanceof Map){const l=[...t.entries()].map(([d,p])=>[i(d),i(p)]),u=new Map(l);return r.set(t,u),u}if(t instanceof Set){const l=[...t].map(d=>i(d)),u=new Set(l);return r.set(t,u),u}const a=efe(t);if(VD(t)||a){const l={};for(const u of Object.keys(t))l[u]=i(t[u]);return a&&(l.next??(l.next=i(t.next.bind(t))),l.return??(l.return=i(t.return.bind(t))),l.throw??(l.throw=i(t.throw.bind(t))),l[HD]=!0),r.set(t,l),l}}if(typeof t=="function"){const i=e.functions.serialize(t,e,n),a={[aE]:i};return r.set(t,a),a}return r.set(t,t),t},Tl=function(t,e,n=!1){if(t==null)return t;if(typeof t=="object"){if(Pn(this,Zp)&&!n){const s=Pn(this,Zp).call(this,t,i=>Yr(this,bi,Tl).call(this,i,e,!0),e);if(s!==void 0)return s}if(t==null)return t;if(Array.isArray(t))return t.map(s=>Yr(this,bi,Tl).call(this,s,e));if(t instanceof Map)return new Map([...t].map(([s,i])=>[Yr(this,bi,Tl).call(this,s,e),Yr(this,bi,Tl).call(this,i,e)]));if(t instanceof Set)return new Set([...t].map(s=>Yr(this,bi,Tl).call(this,s,e)));if(aE in t)return e.functions.deserialize(t[aE],e);if(!VD(t))return t;const r={};for(const s of Object.keys(t))s===HD?r[Symbol.asyncIterator]=()=>r:r[s]=Yr(this,bi,Tl).call(this,t[s],e);return r}return t};var Ld,Gc,Cl,RT,Lq,jT,$q;class nfe{constructor(e,{imports:n,exports:r,functions:s=new Zde,serialization:i=new tfe,signal:a}={}){Zi(this,Cl),Zi(this,Ld),Zi(this,Gc,new Map);var l,u,d,p;this.messages=e,TT(this,Ld,a?new Qde(a):new AbortController),this.exports=r??{},this.imports=rfe(Yr(this,Cl,Lq).bind(this),n),this.functions=s,this.serialization=i,(u=(l=this.functions).start)==null||u.call(l,this),(p=(d=this.serialization).start)==null||p.call(d,this),this.signal.addEventListener("abort",()=>{for(const h of Pn(this,Gc).keys())Yr(this,Cl,jT).call(this,h,void 0,new qD);Pn(this,Gc).clear()},{once:!0}),e.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case Mq:{const[,v,b,x]=g,E=this.exports[b]??(()=>{throw new Error(`No '${b}' method is exported from this thread`)});await Yr(this,Cl,RT).call(this,E,x,(S,k,T)=>{this.messages.send([FD,v,S,k],T)});break}case Oq:{const[,v,b,x]=g,E=this.functions.get(b,this)??sfe;await Yr(this,Cl,RT).call(this,E,x,(S,k,T)=>{this.messages.send([UD,v,S,k],T)});break}case FD:case UD:{Yr(this,Cl,jT).call(this,...g.slice(1));break}case Pq:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Pn(this,Ld).signal}get closed(){return Pn(this,Ld).signal.aborted}close(){Pn(this,Ld).abort()}call(e,n){if(this.closed)return Promise.reject(new qD);const r=[],s=this.serialization.serialize(n,this,r),i=Iq(),a=Yr(this,Cl,$q).call(this,i);return e(i,s,r),a}}Ld=new WeakMap,Gc=new WeakMap,Cl=new WeakSet,RT=async function(t,e,n){try{const r=this.functions.call?await this.functions.call(t,e,this):await t(...this.serialization.deserialize(e,this)),s=[],i=this.serialization.serialize(r,this,s);n(i,void 0,s)}catch(r){n(void 0,this.serialization.serialize(r,this))}},Lq=function(t){return(...e)=>{try{if(typeof t!="string"&&typeof t!="number")throw new Error(`Can’t call a symbol method on a thread: ${t.toString()}`);return this.call((n,r,s)=>{this.messages.send([Mq,n,t,r],s)},e)}catch(n){return Promise.reject(n)}}},jT=function(...t){const e=t[0],n=Pn(this,Gc).get(e);n&&(n(...t),Pn(this,Gc).delete(e))},$q=function(t){const e=new Promise((n,r)=>{Pn(this,Gc).set(t,(s,i,a)=>{a==null?n(this.serialization.deserialize(i,this)):r(this.serialization.deserialize(a,this))})});return Object.defineProperty(e,Symbol.asyncIterator,{async*value(){const n=await e;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),e};function rfe(t,e){let n;if(e==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");const r=new Map;n=new Proxy({},{get(s,i){if(r.has(i))return r.get(i);const a=t(i);return r.set(i,a),a}})}else{n={};for(const r of e)Object.defineProperty(n,r,{value:t(r),writable:!1,configurable:!0,enumerable:!0})}return n}function sfe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const ife="quilt.threads.ping",GD="quilt.threads.pong";function afe(t,{targetOrigin:e="*"}={}){let n=!1;const r=function(i,a){t.postMessage(i,e,a)},s=new Promise(i=>{const a=new AbortController;globalThis.window.addEventListener("message",l=>{l.source===t&&l.data===GD&&(n=!0,a.abort(),i())},{signal:a.signal}),a.signal.addEventListener("abort",()=>i(),{once:!0}),r(ife)});return{send(i,a){return n?r(i,a):s.then(()=>{if(n)return r(i,a)})},listen(i,{signal:a}){self.addEventListener("message",l=>{l.source===t&&l.data!==GD&&i(l.data)},{signal:a})}}}class ofe extends nfe{constructor(e,{targetOrigin:n="*",...r}={}){super(afe(e.contentWindow,{targetOrigin:n}),r),this.iframe=e}}const zq=Ee.forwardRef(({content:t,children:e,...n},r)=>f.jsx("span",{ref:r,...n,children:t||e}));zq.displayName="UIText";const Fq=Ee.forwardRef(({label:t,onPress:e,onClick:n,children:r,...s},i)=>f.jsx("button",{ref:i,onClick:a=>{e&&e(),n&&n(a)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...s,children:t||r}));Fq.displayName="UIButton";const Uq=Ee.forwardRef(({direction:t="vertical",spacing:e="8",align:n="stretch",justify:r="flex-start",children:s,...i},a)=>f.jsx("div",{ref:a,style:{display:"flex",flexDirection:t==="horizontal"?"row":"column",gap:`${e}px`,alignItems:n,justifyContent:r},...i,children:s}));Uq.displayName="UIStack";const Bq=Ee.forwardRef(({src:t,alt:e,width:n,height:r,children:s,...i},a)=>f.jsx("img",{ref:a,src:t,alt:e,width:n,height:r,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...i}));Bq.displayName="UIImage";const qq={name:"basic",elements:[{tagName:"ui-text",component:zq,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:Fq,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:Uq,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:Bq,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},lfe=({receiver:t})=>{const e=w.useRef(null);return w.useEffect(()=>{if(e.current)return t.connect(e.current),()=>{t.disconnect()}},[t]),f.jsx("div",{ref:e,"data-testid":"standard-dom-renderer-container"})},cfe=({resource:t,library:e,remoteElements:n=[],onUIAction:r})=>{const s=w.useRef(null),i=w.useRef(null),[a,l]=w.useState(null),u=w.useMemo(()=>(t.mimeType||"").includes("framework=react")?"react":"webcomponents",[t.mimeType]),d=`${e?.name}-${u}`,{receiver:p,components:h}=w.useMemo(()=>{switch(u){case"react":{const v=new Fde,b=e||qq,x=new Map;return b&&b.elements.forEach(E=>{const S=Gde(E.component);x.set(E.tagName,S)}),{receiver:v,components:x}}case"webcomponents":default:return{receiver:new Ude,components:null}}},[t,e,n]);w.useEffect(()=>{function v(b){var x;if(s.current&&b.source===s.current.contentWindow){const E=b.data;if(!E)return;(x=r?.(E))==null||x.catch(S=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",S)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[r]),w.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[d]);const g=()=>{const v=s.current;if(!v||i.current)return;const b=new ofe(v);i.current=b;const{code:x,error:E}=jde(t);if(E){l(E);return}if(x&&p!=null&&p.connection){const S={code:x,remoteElements:n,useReactRenderer:u==="react",componentLibrary:e?.name};b.imports.render(S,p.connection).catch(k=>console.error("Error calling remote render:",k))}};return a?f.jsx("p",{className:"text-red-500",children:a}):f.jsxs(f.Fragment,{children:[f.jsx("iframe",{ref:s,srcDoc:Kde,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?f.jsx(Yde,{receiver:p,components:h}):f.jsx(lfe,{receiver:p})]})};function ufe(t){var e;if(t.contentType)return t.contentType;if(t.mimeType==="text/html")return"rawHtml";if(t.mimeType==="text/uri-list")return"externalUrl";if((e=t.mimeType)!=null&&e.startsWith("application/vnd.mcp-ui.remote-dom"))return"remoteDom"}const DN=t=>{const{resource:e,onUIAction:n,supportedContentTypes:r,htmlProps:s,remoteDomProps:i}=t,a=ufe(e);if(r&&a&&!r.includes(a))return f.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",a,"."]});switch(a){case"rawHtml":{const{proxy:l,...u}=s||{};return f.jsx(CT,{resource:e,onUIAction:n,...u})}case"externalUrl":return f.jsx(CT,{resource:e,onUIAction:n,...s});case"remoteDom":return f.jsx(cfe,{resource:e,onUIAction:n,library:i?.library||qq,...i});default:return f.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};DN.displayName="UIResourceRenderer";function Vq({componentUrl:t,toolCall:e,toolResult:n,onCallTool:r,onSendFollowup:s,className:i,serverId:a,toolMeta:l}){const u=w.useRef(null),[d,p]=w.useState(!1),[h,g]=w.useState(null),[v,b]=w.useState(null),x=`openai-widget-state:${e.name}:${e.id}`;return w.useEffect(()=>{if(t.startsWith("ui://")&&a){let E=null;if(n?.result){const k=n.result;if(k.structuredContent)E=k.structuredContent;else if(Array.isArray(k)&&k[0]){const T=k[0];T.output?.value?.structuredContent?E=T.output.value.structuredContent:T.structuredContent?E=T.structuredContent:T.output?.value&&(E=T.output.value)}E||(E=k)}(async()=>{try{await fetch("/api/mcp/resources/widget/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:a,uri:t,toolInput:e.parameters,toolOutput:E,toolId:e.id})});const k=`/api/mcp/resources/widget/${e.id}`;b(k)}catch(k){console.error("Error storing widget data:",k),g(k instanceof Error?k.message:"Failed to prepare widget")}})()}else(t.startsWith("http://")||t.startsWith("https://"))&&b(t)},[t,a,e.parameters,e.id,n?.result]),w.useEffect(()=>{if(!v)return;const E=async T=>{if(!(!u.current||T.source!==u.current.contentWindow))switch(T.data.type){case"openai:setWidgetState":try{localStorage.setItem(x,JSON.stringify(T.data.state))}catch(R){throw R}break;case"openai:callTool":if(r)try{const R=await r(T.data.toolName,T.data.params||{});u.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:T.data.requestId,result:R},"*")}catch(R){u.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:T.data.requestId,error:R instanceof Error?R.message:"Unknown error"},"*")}break;case"openai:sendFollowup":s&&s(T.data.message);break}};window.addEventListener("message",E);const S=()=>{p(!0),g(null)},k=T=>{g("Failed to load component")};return u.current?.addEventListener("load",S),u.current?.addEventListener("error",k),()=>{window.removeEventListener("message",E),u.current?.removeEventListener("load",S),u.current?.removeEventListener("error",k)}},[v,x,r,s]),f.jsxs("div",{className:i,children:[h&&f.jsx("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4 mb-2",children:f.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:["Failed to load component: ",h]})}),!d&&v&&f.jsx("div",{className:"bg-blue-50/30 dark:bg-blue-950/20 border border-blue-200/50 dark:border-blue-800/50 rounded-lg p-4 mb-2",children:f.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:"Loading component..."})}),v?f.jsx("iframe",{ref:u,src:v,className:"w-full border rounded-md bg-white dark:bg-gray-900",style:{minHeight:"400px",height:"600px",maxHeight:"80vh",border:"1px solid rgba(128, 128, 128, 0.3)"},sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",title:`OpenAI Component: ${e.name}`,allow:"web-share"}):f.jsx("div",{className:"bg-yellow-50/30 dark:bg-yellow-950/20 border border-yellow-200/50 dark:border-yellow-800/50 rounded-lg p-4",children:f.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-400",children:"Preparing component URL..."})})]})}function dfe(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(p){try{d(r.next(p))}catch(h){a(h)}}function u(p){try{d(r.throw(p))}catch(h){a(h)}}function d(p){p.done?i(p.value):s(p.value).then(l,u)}d((r=r.apply(t,[])).next())})}var ffe=function(){var t=document.getSelection();if(!t.rangeCount)return function(){};for(var e=document.activeElement,n=[],r=0;r<t.rangeCount;r++)n.push(t.getRangeAt(r));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return t.removeAllRanges(),function(){t.type==="Caret"&&t.removeAllRanges(),t.rangeCount||n.forEach(function(s){t.addRange(s)}),e&&e.focus()}},hfe=ffe,WD={"text/plain":"Text","text/html":"Url",default:"Text"},pfe="Copy to clipboard: #{key}, Enter";function mfe(t){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return t.replace(/#{\s*key\s*}/g,e)}function gfe(t,e){var n,r,s,i,a,l,u=!1;e||(e={}),n=e.debug||!1;try{s=hfe(),i=document.createRange(),a=document.getSelection(),l=document.createElement("span"),l.textContent=t,l.ariaHidden="true",l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",function(p){if(p.stopPropagation(),e.format)if(p.preventDefault(),typeof p.clipboardData>"u"){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var h=WD[e.format]||WD.default;window.clipboardData.setData(h,t)}else p.clipboardData.clearData(),p.clipboardData.setData(e.format,t);e.onCopy&&(p.preventDefault(),e.onCopy(p.clipboardData))}),document.body.appendChild(l),i.selectNodeContents(l),a.addRange(i);var d=document.execCommand("copy");if(!d)throw new Error("copy command was unsuccessful");u=!0}catch(p){n&&console.error("unable to copy using execCommand: ",p),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",t),e.onCopy&&e.onCopy(window.clipboardData),u=!0}catch(h){n&&console.error("unable to copy using clipboardData: ",h),n&&console.error("falling back to prompt"),r=mfe("message"in e?e.message:pfe),window.prompt(r,t)}}finally{a&&(typeof a.removeRange=="function"?a.removeRange(i):a.removeAllRanges()),l&&document.body.removeChild(l),s()}return u}var vfe=gfe;function ac(t){return Object.prototype.toString.call(t)==="[object Object]"}function em(t){return Array.isArray(t)?t.length:ac(t)?Object.keys(t).length:0}function yfe(t,e){if(typeof t=="string")return t;try{return JSON.stringify(t,(n,r)=>{switch(typeof r){case"bigint":return String(r)+"n";case"number":case"boolean":case"object":case"string":return r;default:return String(r)}},e)}catch(n){return`${n.name}: ${n.message}`||"JSON.stringify failed"}}function bfe(t){return dfe(this,void 0,void 0,function*(){try{yield navigator.clipboard.writeText(t)}catch{vfe(t)}})}function YD(t,e,n,r,s,i){if(i&&i.collapsed!==void 0)return!!i.collapsed;if(typeof r=="boolean")return r;if(typeof r=="number"&&e>r)return!0;const a=em(t);if(typeof r=="function"){const l=LN(r,[{node:t,depth:e,indexOrName:n,size:a}]);if(typeof l=="boolean")return l}return!!(Array.isArray(t)&&a>s||ac(t)&&a>s)}function KD(t,e,n,r,s,i){if(i&&i.collapsed!==void 0)return!!i.collapsed;if(typeof r=="boolean")return r;if(typeof r=="number"&&e>r)return!0;const a=Math.ceil(t.length/100);if(typeof r=="function"){const l=LN(r,[{node:t,depth:e,indexOrName:n,size:a}]);if(typeof l=="boolean")return l}return!!(Array.isArray(t)&&a>s||ac(t)&&a>s)}function df(t,e,n){return typeof t=="boolean"?t:!!(typeof t=="number"&&e>t||t==="collapsed"&&n||t==="expanded"&&!n)}function LN(t,e){try{return t(...e)}catch(n){reportError(n)}}function Hq(t){if(t===!0||ac(t)&&t.add===!0)return!0}function XD(t){if(t===!0||ac(t)&&t.edit===!0)return!0}function $N(t){if(t===!0||ac(t)&&t.delete===!0)return!0}function xfe(t){return typeof t=="function"}function Gq(t){return!t||t.add===void 0||!!t.add}function QD(t){return!t||t.edit===void 0||!!t.edit}function zN(t){return!t||t.delete===void 0||!!t.delete}function P0(t){return!t||t.enableClipboard===void 0||!!t.enableClipboard}function _fe(t){return!t||t.matchesURL===void 0||!!t.matchesURL}function wfe(t,e){return t==="string"?e.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):e}var JD;function MT(){return MT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},MT.apply(this,arguments)}var FN=function(e){return w.createElement("svg",MT({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),JD||(JD=w.createElement("path",{fill:"currentColor",d:"M12.473 5.806a.666.666 0 0 0-.946 0L8.473 8.86a.667.667 0 0 1-.946 0L4.473 5.806a.667.667 0 1 0-.946.94l3.06 3.06a2 2 0 0 0 2.826 0l3.06-3.06a.667.667 0 0 0 0-.94Z"})))},ZD;function OT(){return OT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},OT.apply(this,arguments)}var Sfe=function(e){return w.createElement("svg",OT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),ZD||(ZD=w.createElement("path",{fill:"currentColor",d:"M17.542 2.5h-4.75a3.963 3.963 0 0 0-3.959 3.958v4.75a3.963 3.963 0 0 0 3.959 3.959h4.75a3.963 3.963 0 0 0 3.958-3.959v-4.75A3.963 3.963 0 0 0 17.542 2.5Zm2.375 8.708a2.378 2.378 0 0 1-2.375 2.375h-4.75a2.378 2.378 0 0 1-2.375-2.375v-4.75a2.378 2.378 0 0 1 2.375-2.375h4.75a2.378 2.378 0 0 1 2.375 2.375v4.75Zm-4.75 6.334a3.963 3.963 0 0 1-3.959 3.958h-4.75A3.963 3.963 0 0 1 2.5 17.542v-4.75a3.963 3.963 0 0 1 3.958-3.959.791.791 0 1 1 0 1.584 2.378 2.378 0 0 0-2.375 2.375v4.75a2.378 2.378 0 0 0 2.375 2.375h4.75a2.378 2.378 0 0 0 2.375-2.375.792.792 0 1 1 1.584 0Z"})))},eL,tL;function PT(){return PT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},PT.apply(this,arguments)}var Efe=function(e){return w.createElement("svg",PT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),eL||(eL=w.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.755 3.755 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.755 3.755 0 0 0 17.25 3Zm2.25 14.25a2.25 2.25 0 0 1-2.25 2.25H6.75a2.25 2.25 0 0 1-2.25-2.25V6.75A2.25 2.25 0 0 1 6.75 4.5h10.5a2.25 2.25 0 0 1 2.25 2.25v10.5Z"})),tL||(tL=w.createElement("path",{fill:"#14C786",d:"M10.312 14.45 7.83 11.906a.625.625 0 0 0-.896 0 .659.659 0 0 0 0 .918l2.481 2.546a1.264 1.264 0 0 0 .896.381 1.237 1.237 0 0 0 .895-.38l5.858-6.011a.658.658 0 0 0 0-.919.625.625 0 0 0-.896 0l-5.857 6.01Z"})))};function I0({node:t,nodeMeta:e}){const{customizeCopy:n,CopyComponent:r,CopiedComponent:s}=w.useContext(oc),[i,a]=w.useState(!1),l=u=>{u.stopPropagation();const d=n(t,e);typeof d=="string"&&d&&bfe(d),a(!0),setTimeout(()=>a(!1),3e3)};return i?typeof s=="function"?f.jsx(s,{className:"json-view--copy",style:{display:"inline-block"}}):f.jsx(Efe,{className:"json-view--copy",style:{display:"inline-block"}}):typeof r=="function"?f.jsx(r,{onClick:l,className:"json-view--copy"}):f.jsx(Sfe,{onClick:l,className:"json-view--copy"})}function IT({indexOrName:t,value:e,depth:n,deleteHandle:r,editHandle:s,parent:i,parentPath:a}){const{displayArrayIndex:l}=w.useContext(oc),u=Array.isArray(i);return f.jsxs("div",Object.assign({className:"json-view--pair"},{children:[!u||u&&l?f.jsxs(f.Fragment,{children:[f.jsx("span",Object.assign({className:typeof t=="number"?"json-view--index":"json-view--property"},{children:t})),":"," "]}):f.jsx(f.Fragment,{}),f.jsx(Yq,{node:e,depth:n+1,deleteHandle:(d,p)=>r(d,p),editHandle:(d,p,h,g)=>s(d,p,h,g),parent:i,indexOrName:t,parentPath:a})]}))}var nL,rL;function DT(){return DT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},DT.apply(this,arguments)}var UN=function(e){return w.createElement("svg",DT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),nL||(nL=w.createElement("path",{fill:"currentColor",d:"M18.75 6h-2.325a3.757 3.757 0 0 0-3.675-3h-1.5a3.757 3.757 0 0 0-3.675 3H5.25a.75.75 0 0 0 0 1.5H6v9.75A3.754 3.754 0 0 0 9.75 21h4.5A3.754 3.754 0 0 0 18 17.25V7.5h.75a.75.75 0 1 0 0-1.5Zm-7.5-1.5h1.5A2.255 2.255 0 0 1 14.872 6H9.128a2.255 2.255 0 0 1 2.122-1.5Zm5.25 12.75a2.25 2.25 0 0 1-2.25 2.25h-4.5a2.25 2.25 0 0 1-2.25-2.25V7.5h9v9.75Z"})),rL||(rL=w.createElement("path",{fill:"#DA0000",d:"M10.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75ZM13.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75Z"})))},sL,iL;function LT(){return LT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},LT.apply(this,arguments)}var Wq=function(e){return w.createElement("svg",LT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),sL||(sL=w.createElement("path",{fill:"currentColor",d:"M21 6.75v10.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3h10.5A3.754 3.754 0 0 1 21 6.75Zm-1.5 0c0-1.24-1.01-2.25-2.25-2.25H6.75C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25V6.75Z"})),iL||(iL=w.createElement("path",{fill:"#14C786",d:"M15 12.75a.75.75 0 1 0 0-1.5h-2.25V9a.75.75 0 1 0-1.5 0v2.25H9a.75.75 0 1 0 0 1.5h2.25V15a.75.75 0 1 0 1.5 0v-2.25H15Z"})))},aL,oL;function $T(){return $T=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$T.apply(this,arguments)}var BN=function(e){return w.createElement("svg",$T({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),aL||(aL=w.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})),oL||(oL=w.createElement("path",{fill:"#14C786",d:"m10.85 13.96-1.986-2.036a.5.5 0 0 0-.716 0 .527.527 0 0 0 0 .735l1.985 2.036a1.01 1.01 0 0 0 .717.305.99.99 0 0 0 .716-.305l4.686-4.808a.526.526 0 0 0 0-.735.5.5 0 0 0-.716 0l-4.687 4.809Z"})))},lL,cL;function zT(){return zT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},zT.apply(this,arguments)}var qN=function(e){return w.createElement("svg",zT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),lL||(lL=w.createElement("path",{fill:"#DA0000",d:"M15 9a.75.75 0 0 0-1.06 0L12 10.94 10.06 9A.75.75 0 0 0 9 10.06L10.94 12 9 13.94A.75.75 0 0 0 10.06 15L12 13.06 13.94 15A.75.75 0 0 0 15 13.94L13.06 12 15 10.06A.75.75 0 0 0 15 9Z"})),cL||(cL=w.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})))};function kfe({originNode:t,node:e,depth:n,index:r,deleteHandle:s,customOptions:i,startIndex:a,parent:l,parentPath:u}){const{enableClipboard:d,src:p,onEdit:h,onChange:g,forceUpdate:v,displaySize:b,CustomOperation:x}=w.useContext(oc),E=[...u,String(r)],[S,k]=w.useState(!0),T=w.useCallback((A,N,M)=>{t[A]=N,h&&h({newValue:N,oldValue:M,depth:n,src:p,indexOrName:A,parentType:"array",parentPath:u}),g&&g({type:"edit",depth:n,src:p,indexOrName:A,parentType:"array",parentPath:u}),v()},[e,h,g,v]),R=A=>{t.splice(A,1),s&&s(A,u),v()},j=f.jsxs(f.Fragment,{children:[!S&&f.jsxs("span",Object.assign({onClick:()=>k(!0),className:"jv-size-chevron"},{children:[df(b,n,S)&&f.jsxs("span",Object.assign({className:"jv-size"},{children:[em(e)," Items"]})),f.jsx(FN,{className:"jv-chevron"})]})),!S&&d&&P0(i)&&f.jsx(I0,{node:e,nodeMeta:{depth:n,indexOrName:r,parent:l,parentPath:u,currentPath:E}}),typeof x=="function"?f.jsx(x,{node:e}):null]});return f.jsxs("div",{children:[f.jsx("span",{children:"["}),j,S?f.jsxs("button",Object.assign({onClick:()=>k(!1),className:"jv-button"},{children:[a," ... ",a+e.length-1]})):f.jsx("div",Object.assign({className:"jv-indent"},{children:e.map((A,N)=>f.jsx(IT,{indexOrName:N+a,value:A,depth:n,parent:e,deleteHandle:R,editHandle:T,parentPath:u},String(r)+String(N)))})),f.jsx("span",{children:"]"})]})}function Tfe({node:t,depth:e,deleteHandle:n,indexOrName:r,customOptions:s,parent:i,parentPath:a}){const l=typeof r<"u"?[...a,String(r)]:a,u=[];for(let X=0;X<t.length;X+=100)u.push(t.slice(X,X+100));const{collapsed:d,enableClipboard:p,collapseObjectsAfterLength:h,editable:g,onDelete:v,src:b,onAdd:x,CustomOperation:E,onChange:S,forceUpdate:k,displaySize:T}=w.useContext(oc),[R,j]=w.useState(KD(t,e,r,d,h,s));w.useEffect(()=>{j(KD(t,e,r,d,h,s))},[d,h]);const[A,N]=w.useState(!1),M=()=>{N(!1),n&&n(r,a),v&&v({value:t,depth:e,src:b,indexOrName:r,parentType:"array",parentPath:a}),S&&S({type:"delete",depth:e,src:b,indexOrName:r,parentType:"array",parentPath:a})},[I,O]=w.useState(!1),L=()=>{const X=t;X.push(null),x&&x({indexOrName:X.length-1,depth:e,src:b,parentType:"array",parentPath:a}),S&&S({type:"add",indexOrName:X.length-1,depth:e,src:b,parentType:"array",parentPath:a}),k()},z=A||I,G=()=>{N(!1),O(!1)},W=f.jsxs(f.Fragment,{children:[!R&&!z&&f.jsxs("span",Object.assign({onClick:()=>j(!0),className:"jv-size-chevron"},{children:[df(T,e,R)&&f.jsxs("span",Object.assign({className:"jv-size"},{children:[t.length," Items"]})),f.jsx(FN,{className:"jv-chevron"})]})),z&&f.jsx(BN,{className:"json-view--edit",style:{display:"inline-block"},onClick:I?L:M}),z&&f.jsx(qN,{className:"json-view--edit",style:{display:"inline-block"},onClick:G}),!R&&!z&&p&&P0(s)&&f.jsx(I0,{node:t,nodeMeta:{depth:e,indexOrName:r,parent:i,parentPath:a,currentPath:l}}),!R&&!z&&Hq(g)&&Gq(s)&&f.jsx(Wq,{className:"json-view--edit",onClick:()=>{L()}}),!R&&!z&&$N(g)&&zN(s)&&n&&f.jsx(UN,{className:"json-view--edit",onClick:()=>N(!0)}),typeof E=="function"?f.jsx(E,{node:t}):null]});return f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"["}),W,R?f.jsx("button",Object.assign({onClick:()=>j(!1),className:"jv-button"},{children:"..."})):f.jsx("div",Object.assign({className:"jv-indent"},{children:u.map((X,F)=>f.jsx(kfe,{originNode:t,node:X,depth:e,index:F,startIndex:F*100,deleteHandle:n,customOptions:s,parentPath:a},String(r)+String(F)))})),f.jsx("span",{children:"]"}),R&&df(T,e,R)&&f.jsxs("span",Object.assign({onClick:()=>j(!1),className:"jv-size"},{children:[t.length," Items"]}))]})}function Cfe({node:t,depth:e,indexOrName:n,deleteHandle:r,customOptions:s,parent:i,parentPath:a}){const{collapsed:l,onCollapse:u,enableClipboard:d,ignoreLargeArray:p,collapseObjectsAfterLength:h,editable:g,onDelete:v,src:b,onAdd:x,onEdit:E,onChange:S,forceUpdate:k,displaySize:T,CustomOperation:R}=w.useContext(oc),j=typeof n<"u"?[...a,String(n)]:a;if(!p&&Array.isArray(t)&&t.length>100)return f.jsx(Tfe,{node:t,depth:e,indexOrName:n,deleteHandle:r,customOptions:s,parentPath:j});const A=ac(t),[N,M]=w.useState(YD(t,e,n,l,h,s)),I=D=>{u?.({isCollapsing:!D,node:t,depth:e,indexOrName:n}),M(D)};w.useEffect(()=>{I(YD(t,e,n,l,h,s))},[l,h]);const O=w.useCallback((D,Z,he)=>{Array.isArray(t)?t[+D]=Z:t&&(t[D]=Z),E&&E({newValue:Z,oldValue:he,depth:e,src:b,indexOrName:D,parentType:A?"object":"array",parentPath:j}),S&&S({type:"edit",depth:e,src:b,indexOrName:D,parentType:A?"object":"array",parentPath:j}),k()},[t,E,S,k]),L=D=>{Array.isArray(t)?t.splice(+D,1):t&&delete t[D],k()},[z,G]=w.useState(!1),W=()=>{G(!1),r&&r(n,j),v&&v({value:t,depth:e,src:b,indexOrName:n,parentType:A?"object":"array",parentPath:j}),S&&S({type:"delete",depth:e,src:b,indexOrName:n,parentType:A?"object":"array",parentPath:j})},[X,F]=w.useState(!1),Y=w.useRef(null),H=()=>{var D;if(A){const Z=(D=Y.current)===null||D===void 0?void 0:D.value;Z&&(t[Z]=null,Y.current&&(Y.current.value=""),F(!1),x&&x({indexOrName:Z,depth:e,src:b,parentType:"object",parentPath:j}),S&&S({type:"add",indexOrName:Z,depth:e,src:b,parentType:"object",parentPath:j}))}else if(Array.isArray(t)){const Z=t;Z.push(null),x&&x({indexOrName:Z.length-1,depth:e,src:b,parentType:"array",parentPath:j}),S&&S({type:"add",indexOrName:Z.length-1,depth:e,src:b,parentType:"array",parentPath:j})}k()},te=D=>{D.key==="Enter"?(D.preventDefault(),H()):D.key==="Escape"&&re()},P=z||X,re=()=>{G(!1),F(!1)},ue=f.jsxs(f.Fragment,{children:[!N&&!P&&f.jsxs("span",Object.assign({onClick:()=>I(!0),className:"jv-size-chevron"},{children:[df(T,e,N)&&f.jsxs("span",Object.assign({className:"jv-size"},{children:[em(t)," Items"]})),f.jsx(FN,{className:"jv-chevron"})]})),X&&A&&f.jsx("input",{className:"json-view--input",placeholder:"property",ref:Y,onKeyDown:te}),P&&f.jsx(BN,{className:"json-view--edit",style:{display:"inline-block"},onClick:X?H:W}),P&&f.jsx(qN,{className:"json-view--edit",style:{display:"inline-block"},onClick:re}),!N&&!P&&d&&P0(s)&&f.jsx(I0,{node:t,nodeMeta:{depth:e,indexOrName:n,parent:i,parentPath:a,currentPath:j}}),!N&&!P&&Hq(g)&&Gq(s)&&f.jsx(Wq,{className:"json-view--edit",onClick:()=>{A?(F(!0),setTimeout(()=>{var D;return(D=Y.current)===null||D===void 0?void 0:D.focus()})):H()}}),!N&&!P&&$N(g)&&zN(s)&&r&&f.jsx(UN,{className:"json-view--edit",onClick:()=>G(!0)}),typeof R=="function"?f.jsx(R,{node:t}):null]});return Array.isArray(t)?f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"["}),ue,N?f.jsx("button",Object.assign({onClick:()=>I(!1),className:"jv-button"},{children:"..."})):f.jsx("div",Object.assign({className:"jv-indent"},{children:t.map((D,Z)=>f.jsx(IT,{indexOrName:Z,value:D,depth:e,parent:t,deleteHandle:L,editHandle:O,parentPath:j},String(n)+String(Z)))})),f.jsx("span",{children:"]"}),N&&df(T,e,N)&&f.jsxs("span",Object.assign({onClick:()=>I(!1),className:"jv-size"},{children:[em(t)," Items"]}))]}):A?f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"{"}),ue,N?f.jsx("button",Object.assign({onClick:()=>I(!1),className:"jv-button"},{children:"..."})):f.jsx("div",Object.assign({className:"jv-indent"},{children:Object.entries(t).map(([D,Z])=>f.jsx(IT,{indexOrName:D,value:Z,depth:e,parent:t,deleteHandle:L,editHandle:O,parentPath:j},String(n)+String(D)))})),f.jsx("span",{children:"}"}),N&&df(T,e,N)&&f.jsxs("span",Object.assign({onClick:()=>I(!1),className:"jv-size"},{children:[em(t)," Items"]}))]}):f.jsx("span",{children:String(t)})}const Afe=Ee.forwardRef(({str:t,className:e,ctrlClick:n},r)=>{let{collapseStringMode:s,collapseStringsAfterLength:i,customizeCollapseStringUI:a}=w.useContext(oc);const[l,u]=w.useState(!0),d=w.useRef(null);i=i>0?i:0;const p=t.replace(/\s+/g," "),h=typeof a=="function"?a(p,l):typeof a=="string"?a:"...",g=v=>{var b;if((v.ctrlKey||v.metaKey)&&n)n(v);else{const x=window.getSelection();if(x&&x.anchorOffset!==x.focusOffset&&((b=x.anchorNode)===null||b===void 0?void 0:b.parentElement)===d.current)return;u(!l)}};if(t.length<=i)return f.jsxs("span",Object.assign({ref:d,className:e,onClick:n},{children:['"',t,'"']}));if(s==="address")return t.length<=10?f.jsxs("span",Object.assign({ref:d,className:e,onClick:n},{children:['"',t,'"']})):f.jsxs("span",Object.assign({ref:d,onClick:g,className:e+" cursor-pointer"},{children:['"',l?[p.slice(0,6),h,p.slice(-4)]:t,'"']}));if(s==="directly")return f.jsxs("span",Object.assign({ref:d,onClick:g,className:e+" cursor-pointer"},{children:['"',l?[p.slice(0,i),h]:t,'"']}));if(s==="word"){let v=i,b=i+1,x=p,E=1;for(;;){if(/\W/.test(t[v])){x=t.slice(0,v);break}if(/\W/.test(t[b])){x=t.slice(0,b);break}if(E===6){x=t.slice(0,i);break}E++,v--,b++}return f.jsxs("span",Object.assign({ref:d,onClick:g,className:e+" cursor-pointer"},{children:['"',l?[x,h]:t,'"']}))}return f.jsxs("span",Object.assign({ref:d,className:e},{children:['"',t,'"']}))});var uL;function FT(){return FT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},FT.apply(this,arguments)}var Nfe=function(e){return w.createElement("svg",FT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),uL||(uL=w.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.754 3.754 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.754 3.754 0 0 0 17.25 3Zm2.25 14.25c0 1.24-1.01 2.25-2.25 2.25H6.75c-1.24 0-2.25-1.01-2.25-2.25V6.75c0-1.24 1.01-2.25 2.25-2.25h10.5c1.24 0 2.25 1.01 2.25 2.25v10.5Zm-6.09-9.466-5.031 5.03a2.981 2.981 0 0 0-.879 2.121v1.19c0 .415.336.75.75.75h1.19c.8 0 1.554-.312 2.12-.879l5.03-5.03a2.252 2.252 0 0 0 0-3.182c-.85-.85-2.331-.85-3.18 0Zm-2.91 7.151c-.28.28-.666.44-1.06.44H9v-.44c0-.4.156-.777.44-1.06l3.187-3.188 1.06 1.061-3.187 3.188Zm5.03-5.03-.782.783-1.06-1.061.782-.782a.766.766 0 0 1 1.06 0 .75.75 0 0 1 0 1.06Z"})))},dL,fL;function UT(){return UT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},UT.apply(this,arguments)}var Rfe=function(e){return w.createElement("svg",UT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),dL||(dL=w.createElement("path",{fill:"currentColor",d:"M6.75 3h5.5v1.5h-5.5C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25v-5.5H21v5.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3Z"})),fL||(fL=w.createElement("path",{fill:"currentColor",d:"M20.013 3h-3.946a.987.987 0 0 0 0 1.973h1.564l-6.342 6.342a1.004 1.004 0 0 0 0 1.396 1.004 1.004 0 0 0 1.396 0l6.342-6.342v1.564a.987.987 0 0 0 1.973 0V3.987A.987.987 0 0 0 20.013 3Z"})))};function Yq({node:t,depth:e,deleteHandle:n,indexOrName:r,parent:s,editHandle:i,parentPath:a}){const{collapseStringsAfterLength:l,enableClipboard:u,editable:d,src:p,onDelete:h,onChange:g,customizeNode:v,matchesURL:b,urlRegExp:x,EditComponent:E,DoneComponent:S,CancelComponent:k,CustomOperation:T}=w.useContext(oc);let R;if(typeof v=="function"&&(R=LN(v,[{node:t,depth:e,indexOrName:r}])),R){if(w.isValidElement(R))return R;if(xfe(R)){const j=R;return f.jsx(j,{node:t,depth:e,indexOrName:r})}}if(Array.isArray(t)||ac(t))return f.jsx(Cfe,{parent:s,node:t,depth:e,indexOrName:r,deleteHandle:n,parentPath:a,customOptions:typeof R=="object"?R:void 0});{const j=typeof t,A=typeof r<"u"?[...a,String(r)]:a,[N,M]=w.useState(!1),[I,O]=w.useState(!1),L=w.useRef(null),z=()=>{M(!0),setTimeout(()=>{var D,Z;(D=window.getSelection())===null||D===void 0||D.selectAllChildren(L.current),(Z=L.current)===null||Z===void 0||Z.focus()})},G=w.useCallback(()=>{let D=L.current.innerText;try{const Z=JSON.parse(D);i&&i(r,Z,t,a)}catch{const he=wfe(j,D);i&&i(r,he,t,a)}M(!1)},[i,r,t,a,j]),W=()=>{M(!1),O(!1)},X=()=>{O(!1),n&&n(r,a),h&&h({value:t,depth:e,src:p,indexOrName:r,parentType:Array.isArray(s)?"array":"object",parentPath:a}),g&&g({depth:e,src:p,indexOrName:r,parentType:Array.isArray(s)?"array":"object",type:"delete",parentPath:a})},F=w.useCallback(D=>{D.key==="Enter"?(D.preventDefault(),G()):D.key==="Escape"&&W()},[G]),Y=N||I,H=!Y&&XD(d)&&QD(R)&&i?D=>{(D.ctrlKey||D.metaKey)&&z()}:void 0,te=f.jsxs(f.Fragment,{children:[Y&&(typeof S=="function"?f.jsx(S,{className:"json-view--edit",style:{display:"inline-block"},onClick:I?X:G}):f.jsx(BN,{className:"json-view--edit",style:{display:"inline-block"},onClick:I?X:G})),Y&&(typeof k=="function"?f.jsx(k,{className:"json-view--edit",style:{display:"inline-block"},onClick:W}):f.jsx(qN,{className:"json-view--edit",style:{display:"inline-block"},onClick:W})),!Y&&u&&P0(R)&&f.jsx(I0,{node:t,nodeMeta:{depth:e,indexOrName:r,parent:s,parentPath:a,currentPath:A}}),!Y&&b&&j==="string"&&x.test(t)&&_fe(R)&&f.jsx("a",Object.assign({href:t,target:"_blank",className:"json-view--link"},{children:f.jsx(Rfe,{})})),!Y&&XD(d)&&QD(R)&&i&&(typeof E=="function"?f.jsx(E,{className:"json-view--edit",onClick:z}):f.jsx(Nfe,{className:"json-view--edit",onClick:z})),!Y&&$N(d)&&zN(R)&&n&&f.jsx(UN,{className:"json-view--edit",onClick:()=>O(!0)}),typeof T=="function"?f.jsx(T,{node:t}):null]});let P="json-view--string";switch(j){case"number":case"bigint":P="json-view--number";break;case"boolean":P="json-view--boolean";break;case"object":P="json-view--null";break}typeof R?.className=="string"&&(P+=" "+R.className),I&&(P+=" json-view--deleting");let re=String(t);j==="bigint"&&(re+="n");const ue=w.useMemo(()=>f.jsx("span",{contentEditable:!0,className:P,dangerouslySetInnerHTML:{__html:j==="string"?`"${re}"`:re},ref:L,onKeyDown:F}),[re,j,F]);return j==="string"?f.jsxs(f.Fragment,{children:[N?ue:t.length>l?f.jsx(Afe,{str:t,ref:L,className:P,ctrlClick:H}):f.jsxs("span",Object.assign({className:P,onClick:H},{children:['"',re,'"']})),te]}):f.jsxs(f.Fragment,{children:[N?ue:f.jsx("span",Object.assign({className:P,onClick:H},{children:re})),te]})}}const Kq=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,oc=w.createContext({src:void 0,collapseStringsAfterLength:99,collapseStringMode:"directly",customizeCollapseStringUI:void 0,collapseObjectsAfterLength:20,collapsed:!1,onCollapse:void 0,enableClipboard:!0,editable:!1,onEdit:void 0,onDelete:void 0,onAdd:void 0,onChange:void 0,forceUpdate:()=>{},customizeNode:void 0,customizeCopy:()=>{},displaySize:void 0,displayArrayIndex:!0,matchesURL:!1,urlRegExp:Kq,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function zl({src:t,collapseStringsAfterLength:e=99,collapseStringMode:n="directly",customizeCollapseStringUI:r,collapseObjectsAfterLength:s=99,collapsed:i,onCollapse:a,enableClipboard:l=!0,editable:u=!1,onEdit:d,onDelete:p,onAdd:h,onChange:g,dark:v=!1,theme:b="default",customizeNode:x,customizeCopy:E=W=>yfe(W),displaySize:S,displayArrayIndex:k=!0,style:T,className:R,matchesURL:j=!1,urlRegExp:A=Kq,ignoreLargeArray:N=!1,CopyComponent:M,CopiedComponent:I,EditComponent:O,CancelComponent:L,DoneComponent:z,CustomOperation:G}){const[W,X]=w.useState(0),F=w.useCallback(()=>X(te=>++te),[]),[Y,H]=w.useState(t);return w.useEffect(()=>H(t),[t]),f.jsx(oc.Provider,Object.assign({value:{src:Y,collapseStringsAfterLength:e,collapseStringMode:n,customizeCollapseStringUI:r,collapseObjectsAfterLength:s,collapsed:i,onCollapse:a,enableClipboard:l,editable:u,onEdit:d,onDelete:p,onAdd:h,onChange:g,forceUpdate:F,customizeNode:x,customizeCopy:E,displaySize:S,displayArrayIndex:k,matchesURL:j,urlRegExp:A,ignoreLargeArray:N,CopyComponent:M,CopiedComponent:I,EditComponent:O,CancelComponent:L,DoneComponent:z,CustomOperation:G}},{children:f.jsx("code",Object.assign({className:"json-view"+(v?" dark":"")+(b&&b!=="default"?" json-view_"+b:"")+(R?" "+R:""),style:T},{children:f.jsx(Yq,{node:Y,depth:1,editHandle:(te,P,re,ue)=>{H(P),d&&d({newValue:P,oldValue:re,depth:1,src:Y,indexOrName:te,parentType:null,parentPath:ue}),g&&g({type:"edit",depth:1,src:Y,indexOrName:te,parentType:null,parentPath:ue})},deleteHandle:(te,P)=>{H(void 0),p&&p({value:Y,depth:1,src:Y,indexOrName:te,parentType:null,parentPath:P}),g&&g({depth:1,src:Y,indexOrName:te,parentType:null,type:"delete",parentPath:P})},parentPath:[]})}))}))}function jfe(t){if(!t)return null;const e=t,n=e?.resource;if(n&&typeof n=="object"&&typeof n.uri=="string"&&n.uri.startsWith("ui://"))return n;const r=e?.content;if(Array.isArray(r)){for(const s of r)if(s&&s.type==="resource"&&s.resource&&typeof s.resource.uri=="string"&&s.resource.uri.startsWith("ui://"))return s.resource}return null}function Mfe({error:t,showStructured:e,onToggleStructured:n,structuredResult:r,result:s,validationErrors:i,unstructuredValidationResult:a,onExecuteFromUI:l,onHandleIntent:u,onSendFollowup:d,serverId:p,toolCallId:h,toolName:g,toolParameters:v,toolCallTimestamp:b,toolMeta:x}){const E=s,S=x?.["openai/outputTemplate"],k=S&&typeof S=="string",T=jfe(s);return f.jsxs("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Response"}),e&&i!==void 0&&(i===null?f.jsxs(vr,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[f.jsx(sf,{className:"h-3 w-3 mr-1.5"}),"Valid"]}):f.jsxs(vr,{variant:"destructive",children:[f.jsx(af,{className:"h-3 w-3 mr-1.5"}),"Invalid"]}))]}),E&&(r||k)&&f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ie,{size:"sm",variant:e?"outline":"default",onClick:()=>n(!1),children:k?"Component":"Raw Output"}),f.jsx(Ie,{size:"sm",variant:e?"default":"outline",onClick:()=>n(!0),children:k?"Raw JSON":"Structured Output"})]})]}),f.jsx("div",{className:"flex-1 overflow-hidden",children:t?f.jsx("div",{className:"p-4",children:f.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:t})}):e&&i?f.jsxs("div",{className:"p-4",children:[f.jsx("h3",{className:"text-sm font-semibold text-destructive mb-2",children:"Validation Errors"}),f.jsxs("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded-md",children:[f.jsx(zl,{src:i,theme:"atom",dark:!0,enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}}),Array.isArray(i)&&i.length>0&&f.jsx("span",{className:"text-sm font-semibold text-destructive mb-2",children:`${i[0].instancePath?.slice(1)??""} ${i[0].message??""}`})]})]}):e&&E&&k?f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-4",children:f.jsx(zl,{src:E,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):e&&r&&i===null?f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-4",children:f.jsx(zl,{src:r,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):E?!e&&k&&S?f.jsx(Vq,{componentUrl:S,toolCall:{id:h||"tool-result",name:g||"tool",parameters:v||{},timestamp:b||new Date,status:"completed"},toolResult:{id:`${h||"tool-result"}-result`,toolCallId:h||"tool-result",result:E,timestamp:new Date},onCallTool:async(R,j)=>(await l(R,j),{}),onSendFollowup:d,serverId:p,toolMeta:x}):!e&&T?f.jsx(DN,{resource:T,htmlProps:{autoResizeIframe:!0,style:{width:"100%",minHeight:"500px",height:"auto",overflow:"visible"}},onUIAction:async R=>(R.type==="tool"&&R.payload?.toolName?await l(R.payload.toolName,R.payload.params||{}):R.type==="intent"&&R.payload?.intent?await u(R.payload.intent,R.payload.params||{}):R.type==="link"&&R.payload?.url&&window.open(R.payload.url,"_blank","noopener,noreferrer"),{status:"handled"})}):f.jsxs("div",{className:"p-4",children:[a==="valid"&&f.jsxs(vr,{variant:"default",className:"bg-green-600 hover:bg-green-700 mb-4",children:[f.jsx(sf,{className:"h-3 w-3 mr-1.5"}),"Success: Content matches the output schema."]}),a==="schema_mismatch"&&f.jsxs(vr,{variant:"destructive",className:"mb-4",children:[f.jsx(af,{className:"h-3 w-3 mr-1.5"}),"Error: Content does not match the output schema."]}),a==="invalid_json"&&f.jsxs(vr,{variant:"destructive",className:"bg-amber-600 hover:bg-amber-700 mb-4",children:[f.jsx(af,{className:"h-3 w-3 mr-1.5"}),"Warning: Output schema provided by the tool is invalid."]}),f.jsx(zl,{src:E,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))",width:"calc(100vw - var(--sidebar-width) - 16px - 16px)"}})]}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Execute a tool to see results here"})})})]})}const Xq=w.forwardRef(({value:t,onValueChange:e,placeholder:n="Search…",className:r,clearable:s=!0,iconClassName:i,...a},l)=>f.jsxs("div",{className:"relative",children:[f.jsx(vB,{className:Me("absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground",i)}),f.jsx(Un,{ref:l,value:t,onChange:u=>e(u.target.value),placeholder:n,type:"search",role:"searchbox","aria-label":n,autoComplete:"off",spellCheck:!1,className:Me("pl-7 h-8 bg-background border-border hover:border-border/80 text-xs md:text-xs leading-4 text-foreground placeholder:text-muted-foreground/70",r),...a}),s&&t&&f.jsx("button",{type:"button",onClick:()=>e(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Clear search",children:f.jsx(Nu,{className:"h-3 w-3"})})]}));Xq.displayName="SearchInput";function Ofe({tool:t,name:e,isSelected:n,onClick:r}){return f.jsx("div",{className:`cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ${n?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"}`,onClick:r,children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e})}),t.description&&f.jsx("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:t.description})]}),f.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})})}function Pfe({request:t,isHighlighted:e,onLoad:n,onRename:r,onDuplicate:s,onDelete:i}){return f.jsx("div",{className:`group p-2 rounded mx-2 cursor-pointer transition-all duration-200 ${e?"bg-primary/20 border border-primary/30 shadow-sm":"hover:bg-muted/40"}`,onClick:()=>n(t),children:f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{className:"min-w-0 pr-2",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("code",{className:"font-mono text-[10px] bg-muted px-1.5 py-0.5 rounded border border-border",children:t.toolName})}),f.jsxs("div",{children:[f.jsx("div",{className:"text-xs font-medium truncate",children:t.title}),t.description&&f.jsx("div",{className:"text-[10px] text-muted-foreground truncate",children:t.description})]})]}),f.jsxs("div",{className:"flex gap-1",children:[f.jsx(Ie,{onClick:a=>{a.stopPropagation(),r(t)},size:"sm",variant:"ghost",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:f.jsx(Jse,{className:"w-3 h-3"})}),f.jsx(Ie,{onClick:a=>{a.stopPropagation(),s(t)},size:"sm",variant:"ghost",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:f.jsx(Po,{className:"w-3 h-3"})}),f.jsx(Ie,{onClick:a=>{a.stopPropagation(),i(t.id)},size:"sm",variant:"ghost",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:f.jsx(wie,{className:"w-3 h-3"})})]})]})})}function Ife({activeTab:t,onChangeTab:e,tools:n,toolNames:r,filteredToolNames:s,selectedToolName:i,fetchingTools:a,searchQuery:l,onSearchQueryChange:u,onRefresh:d,onSelectTool:p,savedRequests:h,highlightedRequestId:g,onLoadRequest:v,onRenameRequest:b,onDuplicateRequest:x,onDeleteRequest:E}){return f.jsx(ni,{defaultSize:35,minSize:20,maxSize:55,children:f.jsxs("div",{className:"h-full border-r border-border bg-background",children:[f.jsx("div",{className:"border-b border-border",children:f.jsxs("div",{className:"flex",children:[f.jsx("button",{onClick:()=>e("tools"),className:`px-4 py-3 text-xs font-medium border-b-2 transition-colors ${t==="tools"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Tools"}),f.jsxs("button",{onClick:()=>e("saved"),className:`px-4 py-3 text-xs font-medium border-b-2 transition-colors ${t==="saved"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:["Saved Requests",h.length>0&&f.jsx("span",{className:"ml-2 bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs font-mono",children:h.length})]})]})}),f.jsxs("div",{className:"px-4 py-4 border-b border-border bg-background space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(kk,{className:"h-3 w-3 text-muted-foreground"}),f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Tools"}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono",children:t==="tools"?r.length:h.length})]}),f.jsx(Ie,{onClick:d,variant:"ghost",size:"sm",disabled:a,children:t==="tools"&&f.jsx(ir,{className:`h-3 w-3 ${a?"animate-spin":""} cursor-pointer`})})]}),f.jsx(Xq,{value:l,onValueChange:u,placeholder:"Search tools by name or description"})]}),t==="tools"?f.jsx("div",{className:"h-[calc(100%-49px)] flex flex-col",children:f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-2",children:a?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(ir,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading tools..."}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available tools from server"})]}):s.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:n&&r.length===0?"No tools were found. Try refreshing. Make sure you selected the correct server and the server is running.":"No tools match your search."})}):f.jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(S=>f.jsx(Ofe,{tool:n[S],name:S,isSelected:i===S,onClick:()=>p(S)},S))})})})})}):f.jsx("div",{className:"h-full",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-3 space-y-1",children:h.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:"No saved requests yet."})}):h.map(S=>f.jsx(Pfe,{request:S,isHighlighted:g===S.id,onLoad:v,onRename:b,onDuplicate:x,onDelete:E},S.id))})})})]})})}function Dfe({open:t,defaultTitle:e="",defaultDescription:n="",onCancel:r,onSave:s}){const[i,a]=w.useState(e),[l,u]=w.useState(n);return w.useEffect(()=>{t&&(a(e||""),u(n||""))},[t,e,n]),f.jsx(aa,{open:t,children:f.jsxs(oa,{className:"sm:max-w-md",onEscapeKeyDown:r,onPointerDownOutside:r,children:[f.jsxs(la,{children:[f.jsx(ca,{children:"Save request"}),f.jsx(Jf,{children:"Give this request a memorable name and optional description."})]}),f.jsxs("div",{className:"space-y-3 py-2",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-xs font-medium",children:"Name"}),f.jsx(Un,{value:i,onChange:d=>a(d.target.value),placeholder:"My saved request",className:"text-sm"})]}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-xs font-medium",children:"Description"}),f.jsx(Ho,{value:l,onChange:d=>u(d.target.value),placeholder:"Optional description",className:"text-sm h-20"})]})]}),f.jsxs(v0,{children:[f.jsx(Ie,{variant:"ghost",onClick:r,size:"sm",children:"Cancel"}),f.jsx(Ie,{onClick:()=>{const d=(i||"").trim();d&&s({title:d,description:l?.trim()||void 0})},size:"sm",children:"Save"})]})]})})}function Lfe(t,e){switch(t){case"enum":return e?.[0]||"";case"string":return"";case"number":case"integer":return"";case"boolean":return!1;case"array":return[];case"object":return{};default:return""}}function $fe(t){if(!t||!t.properties)return[];const e=[],n=t.required||[];return Object.entries(t.properties).forEach(([r,s])=>{const i=s.enum?"enum":s.type||"string";e.push({name:r,type:i,description:s.description,required:n.includes(r),value:Lfe(i,s.enum),enum:s.enum,minimum:s.minimum,maximum:s.maximum,pattern:s.pattern})}),e}function zfe(t,e){return t.map(n=>{if(Object.prototype.hasOwnProperty.call(e,n.name)){const r=e[n.name];return n.type==="array"||n.type==="object"?{...n,value:JSON.stringify(r,null,2)}:{...n,value:r}}return n})}function Ffe(t,e){const n={};return t.forEach(r=>{if(!(r.required||r.value!==""&&r.value!==null&&r.value!==void 0))return;let i=r.value;try{r.type==="number"||r.type==="integer"?(i=Number(r.value),isNaN(i)&&e?.("Invalid number value for field",{fieldName:r.name,value:r.value})):r.type==="boolean"?i=!!r.value:(r.type==="array"||r.type==="object")&&(i=JSON.parse(r.value)),n[r.name]=i}catch(a){e?.("Failed to process field value",{fieldName:r.name,type:r.type,value:r.value,error:a}),n[r.name]=r.value}}),n}const Ufe="mcp-inspector.saved-requests";function VN(t){return`${Ufe}:${t}`}function Ll(t){try{const e=localStorage.getItem(VN(t));if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function HN(t,e){const n=new Date().toISOString(),r=Ll(t);let s;if(e.id){s={id:e.id,title:e.title,description:e.description,toolName:e.toolName,parameters:e.parameters,isFavorite:e.isFavorite,serverKey:t,createdAt:r.find(a=>a.id===e.id)?.createdAt||n,updatedAt:n};const i=r.findIndex(a=>a.id===s.id);i>=0?r[i]=s:r.push(s)}else s={id:crypto.randomUUID(),title:e.title,description:e.description,toolName:e.toolName,parameters:e.parameters,isFavorite:e.isFavorite,serverKey:t,createdAt:n,updatedAt:n},r.unshift(s);return localStorage.setItem(VN(t),JSON.stringify(r)),s}function Bfe(t,e){const n=Ll(t).filter(r=>r.id!==e);localStorage.setItem(VN(t),JSON.stringify(n))}function Qq(t,e){return Ll(t).find(n=>n.id===e)}function qfe(t,e){const n=Qq(t,e);if(n)return HN(t,{title:`${n.title} (copy)`,description:n.description,toolName:n.toolName,parameters:n.parameters,isFavorite:n.isFavorite})}function Vfe(t,e,n){const r=Qq(t,e);if(r)return HN(t,{id:e,title:n.title??r.title,description:n.description??r.description,toolName:r.toolName,parameters:r.parameters,isFavorite:n.isFavorite??r.isFavorite})}var oE,hL;function Hfe(){if(hL)return oE;hL=1;function t(e,r){var r=r||{};this._capacity=r.capacity,this._head=0,this._tail=0,Array.isArray(e)?this._fromArray(e):(this._capacityMask=3,this._list=new Array(4))}return t.prototype.peekAt=function(n){var r=n;if(r===(r|0)){var s=this.size();if(!(r>=s||r<-s))return r<0&&(r+=s),r=this._head+r&this._capacityMask,this._list[r]}},t.prototype.get=function(n){return this.peekAt(n)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.unshift=function(n){if(arguments.length===0)return this.size();var r=this._list.length;return this._head=this._head-1+r&this._capacityMask,this._list[this._head]=n,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.shift=function(){var n=this._head;if(n!==this._tail){var r=this._list[n];return this._list[n]=void 0,this._head=n+1&this._capacityMask,n<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),r}},t.prototype.push=function(n){if(arguments.length===0)return this.size();var r=this._tail;return this._list[r]=n,this._tail=r+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.pop=function(){var n=this._tail;if(n!==this._head){var r=this._list.length;this._tail=n-1+r&this._capacityMask;var s=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&n>1e4&&n<=r>>>2&&this._shrinkArray(),s}},t.prototype.removeOne=function(n){var r=n;if(r===(r|0)&&this._head!==this._tail){var s=this.size(),i=this._list.length;if(!(r>=s||r<-s)){r<0&&(r+=s),r=this._head+r&this._capacityMask;var a=this._list[r],l;if(n<s/2){for(l=n;l>0;l--)this._list[r]=this._list[r=r-1+i&this._capacityMask];this._list[r]=void 0,this._head=this._head+1+i&this._capacityMask}else{for(l=s-1-n;l>0;l--)this._list[r]=this._list[r=r+1+i&this._capacityMask];this._list[r]=void 0,this._tail=this._tail-1+i&this._capacityMask}return a}}},t.prototype.remove=function(n,r){var s=n,i,a=r;if(s===(s|0)&&this._head!==this._tail){var l=this.size(),u=this._list.length;if(!(s>=l||s<-l||r<1)){if(s<0&&(s+=l),r===1||!r)return i=new Array(1),i[0]=this.removeOne(s),i;if(s===0&&s+r>=l)return i=this.toArray(),this.clear(),i;s+r>l&&(r=l-s);var d;for(i=new Array(r),d=0;d<r;d++)i[d]=this._list[this._head+s+d&this._capacityMask];if(s=this._head+s&this._capacityMask,n+r===l){for(this._tail=this._tail-r+u&this._capacityMask,d=r;d>0;d--)this._list[s=s+1+u&this._capacityMask]=void 0;return i}if(n===0){for(this._head=this._head+r+u&this._capacityMask,d=r-1;d>0;d--)this._list[s=s+1+u&this._capacityMask]=void 0;return i}if(s<l/2){for(this._head=this._head+n+r+u&this._capacityMask,d=n;d>0;d--)this.unshift(this._list[s=s-1+u&this._capacityMask]);for(s=this._head-1+u&this._capacityMask;a>0;)this._list[s=s-1+u&this._capacityMask]=void 0,a--;n<0&&(this._tail=s)}else{for(this._tail=s,s=s+r+u&this._capacityMask,d=l-(r+n);d>0;d--)this.push(this._list[s++]);for(s=this._tail;a>0;)this._list[s=s+1+u&this._capacityMask]=void 0,a--}return this._head<2&&this._tail>1e4&&this._tail<=u>>>2&&this._shrinkArray(),i}}},t.prototype.splice=function(n,r){var s=n;if(s===(s|0)){var i=this.size();if(s<0&&(s+=i),!(s>i))if(arguments.length>2){var a,l,u,d=arguments.length,p=this._list.length,h=2;if(!i||s<i/2){for(l=new Array(s),a=0;a<s;a++)l[a]=this._list[this._head+a&this._capacityMask];for(r===0?(u=[],s>0&&(this._head=this._head+s+p&this._capacityMask)):(u=this.remove(s,r),this._head=this._head+s+p&this._capacityMask);d>h;)this.unshift(arguments[--d]);for(a=s;a>0;a--)this.unshift(l[a-1])}else{l=new Array(i-(s+r));var g=l.length;for(a=0;a<g;a++)l[a]=this._list[this._head+s+r+a&this._capacityMask];for(r===0?(u=[],s!=i&&(this._tail=this._head+s+p&this._capacityMask)):(u=this.remove(s,r),this._tail=this._tail-g+p&this._capacityMask);h<d;)this.push(arguments[h++]);for(a=0;a<g;a++)this.push(l[a])}return u}else return this.remove(s,r)}},t.prototype.clear=function(){this._list=new Array(this._list.length),this._head=0,this._tail=0},t.prototype.isEmpty=function(){return this._head===this._tail},t.prototype.toArray=function(){return this._copyArray(!1)},t.prototype._fromArray=function(n){var r=n.length,s=this._nextPowerOf2(r);this._list=new Array(s),this._capacityMask=s-1,this._tail=r;for(var i=0;i<r;i++)this._list[i]=n[i]},t.prototype._copyArray=function(n,r){var s=this._list,i=s.length,a=this.length;if(r=r|a,r==a&&this._head<this._tail)return this._list.slice(this._head,this._tail);var l=new Array(r),u=0,d;if(n||this._head>this._tail){for(d=this._head;d<i;d++)l[u++]=s[d];for(d=0;d<this._tail;d++)l[u++]=s[d]}else for(d=this._head;d<this._tail;d++)l[u++]=s[d];return l},t.prototype._growArray=function(){if(this._head!=0){var n=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=n}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1},t.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1},t.prototype._nextPowerOf2=function(n){var r=Math.log(n)/Math.log(2),s=1<<r+1;return Math.max(s,4)},oE=t,oE}var Gfe=Hfe();const Wfe=Vf(Gfe),pL={error:0,warn:1,info:2,debug:3,trace:4},Yfe={error:"#ef4444",warn:"#f59e0b",info:"#3b82f6",debug:"#8b5cf6",trace:"#6b7280"};class Kfe{config={level:"info",enableConsole:!0,maxBufferSize:1e3};buffer=new Wfe([],{capacity:this.config.maxBufferSize});listeners=new Set;setConfig(e){this.config={...this.config,...e},this.notifyListeners()}getConfig(){return{...this.config}}addEntry(e){this.buffer.unshift(e),this.notifyListeners()}getEntries(){return this.buffer.toArray()}clearBuffer(){this.buffer.clear(),this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}shouldLog(e){return pL[e]<=pL[this.config.level]}}const Yi=new Kfe;typeof window<"u"&&Yi.setConfig({level:"info",enableConsole:!0});function GN(t="Unknown"){const e=w.useCallback(r=>(s,i,a)=>{if(!Yi.shouldLog(r))return;const u={timestamp:new Date().toISOString(),level:r,context:t,message:s,data:i,error:a};Yi.addEntry(u),Yi.getConfig().enableConsole&&Xfe(u)},[t]);return w.useMemo(()=>({error:e("error"),warn:e("warn"),info:e("info"),debug:e("debug"),trace:e("trace"),context:t}),[e,t])}function Xfe(t){const{timestamp:e,level:n,context:r,message:s,data:i,error:a}=t,l=new Date(e).toLocaleTimeString(),u=Yfe[n],d=`color: ${u}; font-weight: bold;`,p=`color: ${u};`,h=[`%c[${l}] %c${n.toUpperCase()} %c[${r}] %c${s}`,"color: #6b7280;",d,"color: #6b7280;",p];i!==void 0&&h.push(`
|
|
1773
|
+
</html>`,Mq=1,FD=2,Oq=3,UD=4,Pq=5,BD=Symbol.for("quilt.threads.serialize"),Xde=Symbol.for("quilt.threads.transferable");class Qde extends AbortController{constructor(...e){super();const n=e.find(r=>r.aborted);if(n)this.abort(n.reason);else{const r=i=>this.abort(i.target.reason),s={signal:this.signal};for(const i of e)i.addEventListener("abort",r,s)}}}class qD extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let Jde="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function Iq(t=21){let e="",n=crypto.getRandomValues(new Uint8Array(t));for(let r=0;r<t;r++)e+=Jde[63&n[r]];return e}var Up,Dd,Bp,Qy,NT,Dq;class Zde{constructor(){Zi(this,NT),Zi(this,Up,new Map),Zi(this,Dd,new Map),Zi(this,Bp,new Map),Zi(this,Qy,new WeakMap)}get(e){return Pn(this,Dd).get(e)}release(e){const n=Pn(this,Dd).get(e);return n&&(Pn(this,Dd).delete(e),Pn(this,Up).delete(n)),!!n}serialize(e){let n=Pn(this,Up).get(e);return n==null&&(n=Iq(),Pn(this,Up).set(e,n),Pn(this,Dd).set(n,e)),n}deserialize(e,n){var r,s;let i=(r=Pn(this,Bp).get(e))==null?void 0:r.deref();return i||(i=(...a)=>{if(!Pn(this,Bp).has(e))throw new Error("You attempted to call a function that was already revoked.");return n.call((l,u,d)=>{n.messages.send([Oq,l,e,u],d)},a)},(s=Yr(this,NT,Dq).call(this,n))==null||s.register(i,e),Pn(this,Bp).set(e,new WeakRef(i)),i)}}Up=new WeakMap,Dd=new WeakMap,Bp=new WeakMap,Qy=new WeakMap,NT=new WeakSet,Dq=function(t){let e=Pn(this,Qy).get(t);if(!(typeof FinalizationRegistry>"u"))return e||(e=new FinalizationRegistry(n=>{t.messages.send([Pq,n])}),Pn(this,Qy).set(t,e)),e};function efe(t){return t!=null&&(Symbol.asyncIterator in t||Symbol.iterator in t)&&typeof t.next=="function"}function VD(t){if(t==null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e==null||e===Object.prototype}const aE="_@f",HD="_@i";var Jp,Zp,bi,Jy,Tl;class tfe{constructor(e){Zi(this,bi),Zi(this,Jp),Zi(this,Zp),TT(this,Jp,e?.serialize),TT(this,Zp,e?.deserialize)}serialize(e,n,r){return Yr(this,bi,Jy).call(this,e,n,r)}deserialize(e,n){return Yr(this,bi,Tl).call(this,e,n)}}Jp=new WeakMap,Zp=new WeakMap,bi=new WeakSet,Jy=function(t,e,n,r=new Map,s=!1){if(t==null)return t;if(r.has(t))return r.get(t);if(r.set(t,void 0),typeof t=="object"){if(Pn(this,Jp)&&!s){const l=Pn(this,Jp).call(this,t,u=>Yr(this,bi,Jy).call(this,u,e,n,r,!0),e,n);if(l!==void 0)return r.set(t,l),l}if(t[Xde])return n?.push(t),r.set(t,t),t;const i=l=>Yr(this,bi,Jy).call(this,l,e,n,r);if(typeof t[BD]=="function"){const l=t[BD]({serialize:i});return r.set(t,l),l}if(Array.isArray(t)){const l=t.map(u=>i(u));return r.set(t,l),l}if(t instanceof Map){const l=[...t.entries()].map(([d,p])=>[i(d),i(p)]),u=new Map(l);return r.set(t,u),u}if(t instanceof Set){const l=[...t].map(d=>i(d)),u=new Set(l);return r.set(t,u),u}const a=efe(t);if(VD(t)||a){const l={};for(const u of Object.keys(t))l[u]=i(t[u]);return a&&(l.next??(l.next=i(t.next.bind(t))),l.return??(l.return=i(t.return.bind(t))),l.throw??(l.throw=i(t.throw.bind(t))),l[HD]=!0),r.set(t,l),l}}if(typeof t=="function"){const i=e.functions.serialize(t,e,n),a={[aE]:i};return r.set(t,a),a}return r.set(t,t),t},Tl=function(t,e,n=!1){if(t==null)return t;if(typeof t=="object"){if(Pn(this,Zp)&&!n){const s=Pn(this,Zp).call(this,t,i=>Yr(this,bi,Tl).call(this,i,e,!0),e);if(s!==void 0)return s}if(t==null)return t;if(Array.isArray(t))return t.map(s=>Yr(this,bi,Tl).call(this,s,e));if(t instanceof Map)return new Map([...t].map(([s,i])=>[Yr(this,bi,Tl).call(this,s,e),Yr(this,bi,Tl).call(this,i,e)]));if(t instanceof Set)return new Set([...t].map(s=>Yr(this,bi,Tl).call(this,s,e)));if(aE in t)return e.functions.deserialize(t[aE],e);if(!VD(t))return t;const r={};for(const s of Object.keys(t))s===HD?r[Symbol.asyncIterator]=()=>r:r[s]=Yr(this,bi,Tl).call(this,t[s],e);return r}return t};var Ld,Gc,Cl,RT,Lq,jT,$q;class nfe{constructor(e,{imports:n,exports:r,functions:s=new Zde,serialization:i=new tfe,signal:a}={}){Zi(this,Cl),Zi(this,Ld),Zi(this,Gc,new Map);var l,u,d,p;this.messages=e,TT(this,Ld,a?new Qde(a):new AbortController),this.exports=r??{},this.imports=rfe(Yr(this,Cl,Lq).bind(this),n),this.functions=s,this.serialization=i,(u=(l=this.functions).start)==null||u.call(l,this),(p=(d=this.serialization).start)==null||p.call(d,this),this.signal.addEventListener("abort",()=>{for(const h of Pn(this,Gc).keys())Yr(this,Cl,jT).call(this,h,void 0,new qD);Pn(this,Gc).clear()},{once:!0}),e.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case Mq:{const[,v,b,x]=g,E=this.exports[b]??(()=>{throw new Error(`No '${b}' method is exported from this thread`)});await Yr(this,Cl,RT).call(this,E,x,(S,k,T)=>{this.messages.send([FD,v,S,k],T)});break}case Oq:{const[,v,b,x]=g,E=this.functions.get(b,this)??sfe;await Yr(this,Cl,RT).call(this,E,x,(S,k,T)=>{this.messages.send([UD,v,S,k],T)});break}case FD:case UD:{Yr(this,Cl,jT).call(this,...g.slice(1));break}case Pq:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Pn(this,Ld).signal}get closed(){return Pn(this,Ld).signal.aborted}close(){Pn(this,Ld).abort()}call(e,n){if(this.closed)return Promise.reject(new qD);const r=[],s=this.serialization.serialize(n,this,r),i=Iq(),a=Yr(this,Cl,$q).call(this,i);return e(i,s,r),a}}Ld=new WeakMap,Gc=new WeakMap,Cl=new WeakSet,RT=async function(t,e,n){try{const r=this.functions.call?await this.functions.call(t,e,this):await t(...this.serialization.deserialize(e,this)),s=[],i=this.serialization.serialize(r,this,s);n(i,void 0,s)}catch(r){n(void 0,this.serialization.serialize(r,this))}},Lq=function(t){return(...e)=>{try{if(typeof t!="string"&&typeof t!="number")throw new Error(`Can’t call a symbol method on a thread: ${t.toString()}`);return this.call((n,r,s)=>{this.messages.send([Mq,n,t,r],s)},e)}catch(n){return Promise.reject(n)}}},jT=function(...t){const e=t[0],n=Pn(this,Gc).get(e);n&&(n(...t),Pn(this,Gc).delete(e))},$q=function(t){const e=new Promise((n,r)=>{Pn(this,Gc).set(t,(s,i,a)=>{a==null?n(this.serialization.deserialize(i,this)):r(this.serialization.deserialize(a,this))})});return Object.defineProperty(e,Symbol.asyncIterator,{async*value(){const n=await e;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),e};function rfe(t,e){let n;if(e==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");const r=new Map;n=new Proxy({},{get(s,i){if(r.has(i))return r.get(i);const a=t(i);return r.set(i,a),a}})}else{n={};for(const r of e)Object.defineProperty(n,r,{value:t(r),writable:!1,configurable:!0,enumerable:!0})}return n}function sfe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const ife="quilt.threads.ping",GD="quilt.threads.pong";function afe(t,{targetOrigin:e="*"}={}){let n=!1;const r=function(i,a){t.postMessage(i,e,a)},s=new Promise(i=>{const a=new AbortController;globalThis.window.addEventListener("message",l=>{l.source===t&&l.data===GD&&(n=!0,a.abort(),i())},{signal:a.signal}),a.signal.addEventListener("abort",()=>i(),{once:!0}),r(ife)});return{send(i,a){return n?r(i,a):s.then(()=>{if(n)return r(i,a)})},listen(i,{signal:a}){self.addEventListener("message",l=>{l.source===t&&l.data!==GD&&i(l.data)},{signal:a})}}}class ofe extends nfe{constructor(e,{targetOrigin:n="*",...r}={}){super(afe(e.contentWindow,{targetOrigin:n}),r),this.iframe=e}}const zq=Ee.forwardRef(({content:t,children:e,...n},r)=>f.jsx("span",{ref:r,...n,children:t||e}));zq.displayName="UIText";const Fq=Ee.forwardRef(({label:t,onPress:e,onClick:n,children:r,...s},i)=>f.jsx("button",{ref:i,onClick:a=>{e&&e(),n&&n(a)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...s,children:t||r}));Fq.displayName="UIButton";const Uq=Ee.forwardRef(({direction:t="vertical",spacing:e="8",align:n="stretch",justify:r="flex-start",children:s,...i},a)=>f.jsx("div",{ref:a,style:{display:"flex",flexDirection:t==="horizontal"?"row":"column",gap:`${e}px`,alignItems:n,justifyContent:r},...i,children:s}));Uq.displayName="UIStack";const Bq=Ee.forwardRef(({src:t,alt:e,width:n,height:r,children:s,...i},a)=>f.jsx("img",{ref:a,src:t,alt:e,width:n,height:r,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...i}));Bq.displayName="UIImage";const qq={name:"basic",elements:[{tagName:"ui-text",component:zq,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:Fq,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:Uq,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:Bq,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},lfe=({receiver:t})=>{const e=w.useRef(null);return w.useEffect(()=>{if(e.current)return t.connect(e.current),()=>{t.disconnect()}},[t]),f.jsx("div",{ref:e,"data-testid":"standard-dom-renderer-container"})},cfe=({resource:t,library:e,remoteElements:n=[],onUIAction:r})=>{const s=w.useRef(null),i=w.useRef(null),[a,l]=w.useState(null),u=w.useMemo(()=>(t.mimeType||"").includes("framework=react")?"react":"webcomponents",[t.mimeType]),d=`${e?.name}-${u}`,{receiver:p,components:h}=w.useMemo(()=>{switch(u){case"react":{const v=new Fde,b=e||qq,x=new Map;return b&&b.elements.forEach(E=>{const S=Gde(E.component);x.set(E.tagName,S)}),{receiver:v,components:x}}case"webcomponents":default:return{receiver:new Ude,components:null}}},[t,e,n]);w.useEffect(()=>{function v(b){var x;if(s.current&&b.source===s.current.contentWindow){const E=b.data;if(!E)return;(x=r?.(E))==null||x.catch(S=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",S)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[r]),w.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[d]);const g=()=>{const v=s.current;if(!v||i.current)return;const b=new ofe(v);i.current=b;const{code:x,error:E}=jde(t);if(E){l(E);return}if(x&&p!=null&&p.connection){const S={code:x,remoteElements:n,useReactRenderer:u==="react",componentLibrary:e?.name};b.imports.render(S,p.connection).catch(k=>console.error("Error calling remote render:",k))}};return a?f.jsx("p",{className:"text-red-500",children:a}):f.jsxs(f.Fragment,{children:[f.jsx("iframe",{ref:s,srcDoc:Kde,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?f.jsx(Yde,{receiver:p,components:h}):f.jsx(lfe,{receiver:p})]})};function ufe(t){var e;if(t.contentType)return t.contentType;if(t.mimeType==="text/html")return"rawHtml";if(t.mimeType==="text/uri-list")return"externalUrl";if((e=t.mimeType)!=null&&e.startsWith("application/vnd.mcp-ui.remote-dom"))return"remoteDom"}const DN=t=>{const{resource:e,onUIAction:n,supportedContentTypes:r,htmlProps:s,remoteDomProps:i}=t,a=ufe(e);if(r&&a&&!r.includes(a))return f.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",a,"."]});switch(a){case"rawHtml":{const{proxy:l,...u}=s||{};return f.jsx(CT,{resource:e,onUIAction:n,...u})}case"externalUrl":return f.jsx(CT,{resource:e,onUIAction:n,...s});case"remoteDom":return f.jsx(cfe,{resource:e,onUIAction:n,library:i?.library||qq,...i});default:return f.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};DN.displayName="UIResourceRenderer";function Vq({componentUrl:t,toolCall:e,toolResult:n,onCallTool:r,onSendFollowup:s,className:i,serverId:a,toolMeta:l}){const u=w.useRef(null),[d,p]=w.useState(!1),[h,g]=w.useState(null),[v,b]=w.useState(null),x=`openai-widget-state:${e.name}:${e.id}`;return w.useEffect(()=>{if(t.startsWith("ui://")&&a){let E=null;if(n?.result){const k=n.result;if(k.structuredContent)E=k.structuredContent;else if(Array.isArray(k)&&k[0]){const T=k[0];T.output?.value?.structuredContent?E=T.output.value.structuredContent:T.structuredContent?E=T.structuredContent:T.output?.value&&(E=T.output.value)}E||(E=k)}(async()=>{try{await fetch("/api/mcp/resources/widget/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:a,uri:t,toolInput:e.parameters,toolOutput:E,toolId:e.id})});const k=`/api/mcp/resources/widget/${e.id}`;b(k)}catch(k){console.error("Error storing widget data:",k),g(k instanceof Error?k.message:"Failed to prepare widget")}})()}else(t.startsWith("http://")||t.startsWith("https://"))&&b(t)},[t,a,e.parameters,e.id,n?.result]),w.useEffect(()=>{if(!v)return;const E=async T=>{if(!(!u.current||T.source!==u.current.contentWindow))switch(T.data.type){case"openai:setWidgetState":try{localStorage.setItem(x,JSON.stringify(T.data.state))}catch(R){throw R}break;case"openai:callTool":if(r)try{const R=await r(T.data.toolName,T.data.params||{});u.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:T.data.requestId,result:R},"*")}catch(R){u.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:T.data.requestId,error:R instanceof Error?R.message:"Unknown error"},"*")}break;case"openai:sendFollowup":s&&s(T.data.message);break}};window.addEventListener("message",E);const S=()=>{p(!0),g(null)},k=T=>{g("Failed to load component")};return u.current?.addEventListener("load",S),u.current?.addEventListener("error",k),()=>{window.removeEventListener("message",E),u.current?.removeEventListener("load",S),u.current?.removeEventListener("error",k)}},[v,x,r,s]),f.jsxs("div",{className:i,children:[h&&f.jsx("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4 mb-2",children:f.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:["Failed to load component: ",h]})}),!d&&v&&f.jsx("div",{className:"bg-blue-50/30 dark:bg-blue-950/20 border border-blue-200/50 dark:border-blue-800/50 rounded-lg p-4 mb-2",children:f.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:"Loading component..."})}),v?f.jsx("iframe",{ref:u,src:v,className:"w-full border rounded-md bg-white dark:bg-gray-900",style:{minHeight:"400px",height:"600px",maxHeight:"80vh",border:"1px solid rgba(128, 128, 128, 0.3)"},sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",title:`OpenAI Component: ${e.name}`,allow:"web-share"}):f.jsx("div",{className:"bg-yellow-50/30 dark:bg-yellow-950/20 border border-yellow-200/50 dark:border-yellow-800/50 rounded-lg p-4",children:f.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-400",children:"Preparing component URL..."})})]})}function dfe(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(p){try{d(r.next(p))}catch(h){a(h)}}function u(p){try{d(r.throw(p))}catch(h){a(h)}}function d(p){p.done?i(p.value):s(p.value).then(l,u)}d((r=r.apply(t,[])).next())})}var ffe=function(){var t=document.getSelection();if(!t.rangeCount)return function(){};for(var e=document.activeElement,n=[],r=0;r<t.rangeCount;r++)n.push(t.getRangeAt(r));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return t.removeAllRanges(),function(){t.type==="Caret"&&t.removeAllRanges(),t.rangeCount||n.forEach(function(s){t.addRange(s)}),e&&e.focus()}},hfe=ffe,WD={"text/plain":"Text","text/html":"Url",default:"Text"},pfe="Copy to clipboard: #{key}, Enter";function mfe(t){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return t.replace(/#{\s*key\s*}/g,e)}function gfe(t,e){var n,r,s,i,a,l,u=!1;e||(e={}),n=e.debug||!1;try{s=hfe(),i=document.createRange(),a=document.getSelection(),l=document.createElement("span"),l.textContent=t,l.ariaHidden="true",l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",function(p){if(p.stopPropagation(),e.format)if(p.preventDefault(),typeof p.clipboardData>"u"){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var h=WD[e.format]||WD.default;window.clipboardData.setData(h,t)}else p.clipboardData.clearData(),p.clipboardData.setData(e.format,t);e.onCopy&&(p.preventDefault(),e.onCopy(p.clipboardData))}),document.body.appendChild(l),i.selectNodeContents(l),a.addRange(i);var d=document.execCommand("copy");if(!d)throw new Error("copy command was unsuccessful");u=!0}catch(p){n&&console.error("unable to copy using execCommand: ",p),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",t),e.onCopy&&e.onCopy(window.clipboardData),u=!0}catch(h){n&&console.error("unable to copy using clipboardData: ",h),n&&console.error("falling back to prompt"),r=mfe("message"in e?e.message:pfe),window.prompt(r,t)}}finally{a&&(typeof a.removeRange=="function"?a.removeRange(i):a.removeAllRanges()),l&&document.body.removeChild(l),s()}return u}var vfe=gfe;function ac(t){return Object.prototype.toString.call(t)==="[object Object]"}function em(t){return Array.isArray(t)?t.length:ac(t)?Object.keys(t).length:0}function yfe(t,e){if(typeof t=="string")return t;try{return JSON.stringify(t,(n,r)=>{switch(typeof r){case"bigint":return String(r)+"n";case"number":case"boolean":case"object":case"string":return r;default:return String(r)}},e)}catch(n){return`${n.name}: ${n.message}`||"JSON.stringify failed"}}function bfe(t){return dfe(this,void 0,void 0,function*(){try{yield navigator.clipboard.writeText(t)}catch{vfe(t)}})}function YD(t,e,n,r,s,i){if(i&&i.collapsed!==void 0)return!!i.collapsed;if(typeof r=="boolean")return r;if(typeof r=="number"&&e>r)return!0;const a=em(t);if(typeof r=="function"){const l=LN(r,[{node:t,depth:e,indexOrName:n,size:a}]);if(typeof l=="boolean")return l}return!!(Array.isArray(t)&&a>s||ac(t)&&a>s)}function KD(t,e,n,r,s,i){if(i&&i.collapsed!==void 0)return!!i.collapsed;if(typeof r=="boolean")return r;if(typeof r=="number"&&e>r)return!0;const a=Math.ceil(t.length/100);if(typeof r=="function"){const l=LN(r,[{node:t,depth:e,indexOrName:n,size:a}]);if(typeof l=="boolean")return l}return!!(Array.isArray(t)&&a>s||ac(t)&&a>s)}function df(t,e,n){return typeof t=="boolean"?t:!!(typeof t=="number"&&e>t||t==="collapsed"&&n||t==="expanded"&&!n)}function LN(t,e){try{return t(...e)}catch(n){reportError(n)}}function Hq(t){if(t===!0||ac(t)&&t.add===!0)return!0}function XD(t){if(t===!0||ac(t)&&t.edit===!0)return!0}function $N(t){if(t===!0||ac(t)&&t.delete===!0)return!0}function xfe(t){return typeof t=="function"}function Gq(t){return!t||t.add===void 0||!!t.add}function QD(t){return!t||t.edit===void 0||!!t.edit}function zN(t){return!t||t.delete===void 0||!!t.delete}function P0(t){return!t||t.enableClipboard===void 0||!!t.enableClipboard}function _fe(t){return!t||t.matchesURL===void 0||!!t.matchesURL}function wfe(t,e){return t==="string"?e.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):e}var JD;function MT(){return MT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},MT.apply(this,arguments)}var FN=function(e){return w.createElement("svg",MT({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),JD||(JD=w.createElement("path",{fill:"currentColor",d:"M12.473 5.806a.666.666 0 0 0-.946 0L8.473 8.86a.667.667 0 0 1-.946 0L4.473 5.806a.667.667 0 1 0-.946.94l3.06 3.06a2 2 0 0 0 2.826 0l3.06-3.06a.667.667 0 0 0 0-.94Z"})))},ZD;function OT(){return OT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},OT.apply(this,arguments)}var Sfe=function(e){return w.createElement("svg",OT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),ZD||(ZD=w.createElement("path",{fill:"currentColor",d:"M17.542 2.5h-4.75a3.963 3.963 0 0 0-3.959 3.958v4.75a3.963 3.963 0 0 0 3.959 3.959h4.75a3.963 3.963 0 0 0 3.958-3.959v-4.75A3.963 3.963 0 0 0 17.542 2.5Zm2.375 8.708a2.378 2.378 0 0 1-2.375 2.375h-4.75a2.378 2.378 0 0 1-2.375-2.375v-4.75a2.378 2.378 0 0 1 2.375-2.375h4.75a2.378 2.378 0 0 1 2.375 2.375v4.75Zm-4.75 6.334a3.963 3.963 0 0 1-3.959 3.958h-4.75A3.963 3.963 0 0 1 2.5 17.542v-4.75a3.963 3.963 0 0 1 3.958-3.959.791.791 0 1 1 0 1.584 2.378 2.378 0 0 0-2.375 2.375v4.75a2.378 2.378 0 0 0 2.375 2.375h4.75a2.378 2.378 0 0 0 2.375-2.375.792.792 0 1 1 1.584 0Z"})))},eL,tL;function PT(){return PT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},PT.apply(this,arguments)}var Efe=function(e){return w.createElement("svg",PT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),eL||(eL=w.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.755 3.755 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.755 3.755 0 0 0 17.25 3Zm2.25 14.25a2.25 2.25 0 0 1-2.25 2.25H6.75a2.25 2.25 0 0 1-2.25-2.25V6.75A2.25 2.25 0 0 1 6.75 4.5h10.5a2.25 2.25 0 0 1 2.25 2.25v10.5Z"})),tL||(tL=w.createElement("path",{fill:"#14C786",d:"M10.312 14.45 7.83 11.906a.625.625 0 0 0-.896 0 .659.659 0 0 0 0 .918l2.481 2.546a1.264 1.264 0 0 0 .896.381 1.237 1.237 0 0 0 .895-.38l5.858-6.011a.658.658 0 0 0 0-.919.625.625 0 0 0-.896 0l-5.857 6.01Z"})))};function I0({node:t,nodeMeta:e}){const{customizeCopy:n,CopyComponent:r,CopiedComponent:s}=w.useContext(oc),[i,a]=w.useState(!1),l=u=>{u.stopPropagation();const d=n(t,e);typeof d=="string"&&d&&bfe(d),a(!0),setTimeout(()=>a(!1),3e3)};return i?typeof s=="function"?f.jsx(s,{className:"json-view--copy",style:{display:"inline-block"}}):f.jsx(Efe,{className:"json-view--copy",style:{display:"inline-block"}}):typeof r=="function"?f.jsx(r,{onClick:l,className:"json-view--copy"}):f.jsx(Sfe,{onClick:l,className:"json-view--copy"})}function IT({indexOrName:t,value:e,depth:n,deleteHandle:r,editHandle:s,parent:i,parentPath:a}){const{displayArrayIndex:l}=w.useContext(oc),u=Array.isArray(i);return f.jsxs("div",Object.assign({className:"json-view--pair"},{children:[!u||u&&l?f.jsxs(f.Fragment,{children:[f.jsx("span",Object.assign({className:typeof t=="number"?"json-view--index":"json-view--property"},{children:t})),":"," "]}):f.jsx(f.Fragment,{}),f.jsx(Yq,{node:e,depth:n+1,deleteHandle:(d,p)=>r(d,p),editHandle:(d,p,h,g)=>s(d,p,h,g),parent:i,indexOrName:t,parentPath:a})]}))}var nL,rL;function DT(){return DT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},DT.apply(this,arguments)}var UN=function(e){return w.createElement("svg",DT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),nL||(nL=w.createElement("path",{fill:"currentColor",d:"M18.75 6h-2.325a3.757 3.757 0 0 0-3.675-3h-1.5a3.757 3.757 0 0 0-3.675 3H5.25a.75.75 0 0 0 0 1.5H6v9.75A3.754 3.754 0 0 0 9.75 21h4.5A3.754 3.754 0 0 0 18 17.25V7.5h.75a.75.75 0 1 0 0-1.5Zm-7.5-1.5h1.5A2.255 2.255 0 0 1 14.872 6H9.128a2.255 2.255 0 0 1 2.122-1.5Zm5.25 12.75a2.25 2.25 0 0 1-2.25 2.25h-4.5a2.25 2.25 0 0 1-2.25-2.25V7.5h9v9.75Z"})),rL||(rL=w.createElement("path",{fill:"#DA0000",d:"M10.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75ZM13.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75Z"})))},sL,iL;function LT(){return LT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},LT.apply(this,arguments)}var Wq=function(e){return w.createElement("svg",LT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),sL||(sL=w.createElement("path",{fill:"currentColor",d:"M21 6.75v10.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3h10.5A3.754 3.754 0 0 1 21 6.75Zm-1.5 0c0-1.24-1.01-2.25-2.25-2.25H6.75C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25V6.75Z"})),iL||(iL=w.createElement("path",{fill:"#14C786",d:"M15 12.75a.75.75 0 1 0 0-1.5h-2.25V9a.75.75 0 1 0-1.5 0v2.25H9a.75.75 0 1 0 0 1.5h2.25V15a.75.75 0 1 0 1.5 0v-2.25H15Z"})))},aL,oL;function $T(){return $T=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$T.apply(this,arguments)}var BN=function(e){return w.createElement("svg",$T({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),aL||(aL=w.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})),oL||(oL=w.createElement("path",{fill:"#14C786",d:"m10.85 13.96-1.986-2.036a.5.5 0 0 0-.716 0 .527.527 0 0 0 0 .735l1.985 2.036a1.01 1.01 0 0 0 .717.305.99.99 0 0 0 .716-.305l4.686-4.808a.526.526 0 0 0 0-.735.5.5 0 0 0-.716 0l-4.687 4.809Z"})))},lL,cL;function zT(){return zT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},zT.apply(this,arguments)}var qN=function(e){return w.createElement("svg",zT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),lL||(lL=w.createElement("path",{fill:"#DA0000",d:"M15 9a.75.75 0 0 0-1.06 0L12 10.94 10.06 9A.75.75 0 0 0 9 10.06L10.94 12 9 13.94A.75.75 0 0 0 10.06 15L12 13.06 13.94 15A.75.75 0 0 0 15 13.94L13.06 12 15 10.06A.75.75 0 0 0 15 9Z"})),cL||(cL=w.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})))};function kfe({originNode:t,node:e,depth:n,index:r,deleteHandle:s,customOptions:i,startIndex:a,parent:l,parentPath:u}){const{enableClipboard:d,src:p,onEdit:h,onChange:g,forceUpdate:v,displaySize:b,CustomOperation:x}=w.useContext(oc),E=[...u,String(r)],[S,k]=w.useState(!0),T=w.useCallback((A,N,M)=>{t[A]=N,h&&h({newValue:N,oldValue:M,depth:n,src:p,indexOrName:A,parentType:"array",parentPath:u}),g&&g({type:"edit",depth:n,src:p,indexOrName:A,parentType:"array",parentPath:u}),v()},[e,h,g,v]),R=A=>{t.splice(A,1),s&&s(A,u),v()},j=f.jsxs(f.Fragment,{children:[!S&&f.jsxs("span",Object.assign({onClick:()=>k(!0),className:"jv-size-chevron"},{children:[df(b,n,S)&&f.jsxs("span",Object.assign({className:"jv-size"},{children:[em(e)," Items"]})),f.jsx(FN,{className:"jv-chevron"})]})),!S&&d&&P0(i)&&f.jsx(I0,{node:e,nodeMeta:{depth:n,indexOrName:r,parent:l,parentPath:u,currentPath:E}}),typeof x=="function"?f.jsx(x,{node:e}):null]});return f.jsxs("div",{children:[f.jsx("span",{children:"["}),j,S?f.jsxs("button",Object.assign({onClick:()=>k(!1),className:"jv-button"},{children:[a," ... ",a+e.length-1]})):f.jsx("div",Object.assign({className:"jv-indent"},{children:e.map((A,N)=>f.jsx(IT,{indexOrName:N+a,value:A,depth:n,parent:e,deleteHandle:R,editHandle:T,parentPath:u},String(r)+String(N)))})),f.jsx("span",{children:"]"})]})}function Tfe({node:t,depth:e,deleteHandle:n,indexOrName:r,customOptions:s,parent:i,parentPath:a}){const l=typeof r<"u"?[...a,String(r)]:a,u=[];for(let X=0;X<t.length;X+=100)u.push(t.slice(X,X+100));const{collapsed:d,enableClipboard:p,collapseObjectsAfterLength:h,editable:g,onDelete:v,src:b,onAdd:x,CustomOperation:E,onChange:S,forceUpdate:k,displaySize:T}=w.useContext(oc),[R,j]=w.useState(KD(t,e,r,d,h,s));w.useEffect(()=>{j(KD(t,e,r,d,h,s))},[d,h]);const[A,N]=w.useState(!1),M=()=>{N(!1),n&&n(r,a),v&&v({value:t,depth:e,src:b,indexOrName:r,parentType:"array",parentPath:a}),S&&S({type:"delete",depth:e,src:b,indexOrName:r,parentType:"array",parentPath:a})},[I,O]=w.useState(!1),L=()=>{const X=t;X.push(null),x&&x({indexOrName:X.length-1,depth:e,src:b,parentType:"array",parentPath:a}),S&&S({type:"add",indexOrName:X.length-1,depth:e,src:b,parentType:"array",parentPath:a}),k()},z=A||I,G=()=>{N(!1),O(!1)},W=f.jsxs(f.Fragment,{children:[!R&&!z&&f.jsxs("span",Object.assign({onClick:()=>j(!0),className:"jv-size-chevron"},{children:[df(T,e,R)&&f.jsxs("span",Object.assign({className:"jv-size"},{children:[t.length," Items"]})),f.jsx(FN,{className:"jv-chevron"})]})),z&&f.jsx(BN,{className:"json-view--edit",style:{display:"inline-block"},onClick:I?L:M}),z&&f.jsx(qN,{className:"json-view--edit",style:{display:"inline-block"},onClick:G}),!R&&!z&&p&&P0(s)&&f.jsx(I0,{node:t,nodeMeta:{depth:e,indexOrName:r,parent:i,parentPath:a,currentPath:l}}),!R&&!z&&Hq(g)&&Gq(s)&&f.jsx(Wq,{className:"json-view--edit",onClick:()=>{L()}}),!R&&!z&&$N(g)&&zN(s)&&n&&f.jsx(UN,{className:"json-view--edit",onClick:()=>N(!0)}),typeof E=="function"?f.jsx(E,{node:t}):null]});return f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"["}),W,R?f.jsx("button",Object.assign({onClick:()=>j(!1),className:"jv-button"},{children:"..."})):f.jsx("div",Object.assign({className:"jv-indent"},{children:u.map((X,F)=>f.jsx(kfe,{originNode:t,node:X,depth:e,index:F,startIndex:F*100,deleteHandle:n,customOptions:s,parentPath:a},String(r)+String(F)))})),f.jsx("span",{children:"]"}),R&&df(T,e,R)&&f.jsxs("span",Object.assign({onClick:()=>j(!1),className:"jv-size"},{children:[t.length," Items"]}))]})}function Cfe({node:t,depth:e,indexOrName:n,deleteHandle:r,customOptions:s,parent:i,parentPath:a}){const{collapsed:l,onCollapse:u,enableClipboard:d,ignoreLargeArray:p,collapseObjectsAfterLength:h,editable:g,onDelete:v,src:b,onAdd:x,onEdit:E,onChange:S,forceUpdate:k,displaySize:T,CustomOperation:R}=w.useContext(oc),j=typeof n<"u"?[...a,String(n)]:a;if(!p&&Array.isArray(t)&&t.length>100)return f.jsx(Tfe,{node:t,depth:e,indexOrName:n,deleteHandle:r,customOptions:s,parentPath:j});const A=ac(t),[N,M]=w.useState(YD(t,e,n,l,h,s)),I=D=>{u?.({isCollapsing:!D,node:t,depth:e,indexOrName:n}),M(D)};w.useEffect(()=>{I(YD(t,e,n,l,h,s))},[l,h]);const O=w.useCallback((D,Z,he)=>{Array.isArray(t)?t[+D]=Z:t&&(t[D]=Z),E&&E({newValue:Z,oldValue:he,depth:e,src:b,indexOrName:D,parentType:A?"object":"array",parentPath:j}),S&&S({type:"edit",depth:e,src:b,indexOrName:D,parentType:A?"object":"array",parentPath:j}),k()},[t,E,S,k]),L=D=>{Array.isArray(t)?t.splice(+D,1):t&&delete t[D],k()},[z,G]=w.useState(!1),W=()=>{G(!1),r&&r(n,j),v&&v({value:t,depth:e,src:b,indexOrName:n,parentType:A?"object":"array",parentPath:j}),S&&S({type:"delete",depth:e,src:b,indexOrName:n,parentType:A?"object":"array",parentPath:j})},[X,F]=w.useState(!1),Y=w.useRef(null),H=()=>{var D;if(A){const Z=(D=Y.current)===null||D===void 0?void 0:D.value;Z&&(t[Z]=null,Y.current&&(Y.current.value=""),F(!1),x&&x({indexOrName:Z,depth:e,src:b,parentType:"object",parentPath:j}),S&&S({type:"add",indexOrName:Z,depth:e,src:b,parentType:"object",parentPath:j}))}else if(Array.isArray(t)){const Z=t;Z.push(null),x&&x({indexOrName:Z.length-1,depth:e,src:b,parentType:"array",parentPath:j}),S&&S({type:"add",indexOrName:Z.length-1,depth:e,src:b,parentType:"array",parentPath:j})}k()},te=D=>{D.key==="Enter"?(D.preventDefault(),H()):D.key==="Escape"&&re()},P=z||X,re=()=>{G(!1),F(!1)},ue=f.jsxs(f.Fragment,{children:[!N&&!P&&f.jsxs("span",Object.assign({onClick:()=>I(!0),className:"jv-size-chevron"},{children:[df(T,e,N)&&f.jsxs("span",Object.assign({className:"jv-size"},{children:[em(t)," Items"]})),f.jsx(FN,{className:"jv-chevron"})]})),X&&A&&f.jsx("input",{className:"json-view--input",placeholder:"property",ref:Y,onKeyDown:te}),P&&f.jsx(BN,{className:"json-view--edit",style:{display:"inline-block"},onClick:X?H:W}),P&&f.jsx(qN,{className:"json-view--edit",style:{display:"inline-block"},onClick:re}),!N&&!P&&d&&P0(s)&&f.jsx(I0,{node:t,nodeMeta:{depth:e,indexOrName:n,parent:i,parentPath:a,currentPath:j}}),!N&&!P&&Hq(g)&&Gq(s)&&f.jsx(Wq,{className:"json-view--edit",onClick:()=>{A?(F(!0),setTimeout(()=>{var D;return(D=Y.current)===null||D===void 0?void 0:D.focus()})):H()}}),!N&&!P&&$N(g)&&zN(s)&&r&&f.jsx(UN,{className:"json-view--edit",onClick:()=>G(!0)}),typeof R=="function"?f.jsx(R,{node:t}):null]});return Array.isArray(t)?f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"["}),ue,N?f.jsx("button",Object.assign({onClick:()=>I(!1),className:"jv-button"},{children:"..."})):f.jsx("div",Object.assign({className:"jv-indent"},{children:t.map((D,Z)=>f.jsx(IT,{indexOrName:Z,value:D,depth:e,parent:t,deleteHandle:L,editHandle:O,parentPath:j},String(n)+String(Z)))})),f.jsx("span",{children:"]"}),N&&df(T,e,N)&&f.jsxs("span",Object.assign({onClick:()=>I(!1),className:"jv-size"},{children:[em(t)," Items"]}))]}):A?f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"{"}),ue,N?f.jsx("button",Object.assign({onClick:()=>I(!1),className:"jv-button"},{children:"..."})):f.jsx("div",Object.assign({className:"jv-indent"},{children:Object.entries(t).map(([D,Z])=>f.jsx(IT,{indexOrName:D,value:Z,depth:e,parent:t,deleteHandle:L,editHandle:O,parentPath:j},String(n)+String(D)))})),f.jsx("span",{children:"}"}),N&&df(T,e,N)&&f.jsxs("span",Object.assign({onClick:()=>I(!1),className:"jv-size"},{children:[em(t)," Items"]}))]}):f.jsx("span",{children:String(t)})}const Afe=Ee.forwardRef(({str:t,className:e,ctrlClick:n},r)=>{let{collapseStringMode:s,collapseStringsAfterLength:i,customizeCollapseStringUI:a}=w.useContext(oc);const[l,u]=w.useState(!0),d=w.useRef(null);i=i>0?i:0;const p=t.replace(/\s+/g," "),h=typeof a=="function"?a(p,l):typeof a=="string"?a:"...",g=v=>{var b;if((v.ctrlKey||v.metaKey)&&n)n(v);else{const x=window.getSelection();if(x&&x.anchorOffset!==x.focusOffset&&((b=x.anchorNode)===null||b===void 0?void 0:b.parentElement)===d.current)return;u(!l)}};if(t.length<=i)return f.jsxs("span",Object.assign({ref:d,className:e,onClick:n},{children:['"',t,'"']}));if(s==="address")return t.length<=10?f.jsxs("span",Object.assign({ref:d,className:e,onClick:n},{children:['"',t,'"']})):f.jsxs("span",Object.assign({ref:d,onClick:g,className:e+" cursor-pointer"},{children:['"',l?[p.slice(0,6),h,p.slice(-4)]:t,'"']}));if(s==="directly")return f.jsxs("span",Object.assign({ref:d,onClick:g,className:e+" cursor-pointer"},{children:['"',l?[p.slice(0,i),h]:t,'"']}));if(s==="word"){let v=i,b=i+1,x=p,E=1;for(;;){if(/\W/.test(t[v])){x=t.slice(0,v);break}if(/\W/.test(t[b])){x=t.slice(0,b);break}if(E===6){x=t.slice(0,i);break}E++,v--,b++}return f.jsxs("span",Object.assign({ref:d,onClick:g,className:e+" cursor-pointer"},{children:['"',l?[x,h]:t,'"']}))}return f.jsxs("span",Object.assign({ref:d,className:e},{children:['"',t,'"']}))});var uL;function FT(){return FT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},FT.apply(this,arguments)}var Nfe=function(e){return w.createElement("svg",FT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),uL||(uL=w.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.754 3.754 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.754 3.754 0 0 0 17.25 3Zm2.25 14.25c0 1.24-1.01 2.25-2.25 2.25H6.75c-1.24 0-2.25-1.01-2.25-2.25V6.75c0-1.24 1.01-2.25 2.25-2.25h10.5c1.24 0 2.25 1.01 2.25 2.25v10.5Zm-6.09-9.466-5.031 5.03a2.981 2.981 0 0 0-.879 2.121v1.19c0 .415.336.75.75.75h1.19c.8 0 1.554-.312 2.12-.879l5.03-5.03a2.252 2.252 0 0 0 0-3.182c-.85-.85-2.331-.85-3.18 0Zm-2.91 7.151c-.28.28-.666.44-1.06.44H9v-.44c0-.4.156-.777.44-1.06l3.187-3.188 1.06 1.061-3.187 3.188Zm5.03-5.03-.782.783-1.06-1.061.782-.782a.766.766 0 0 1 1.06 0 .75.75 0 0 1 0 1.06Z"})))},dL,fL;function UT(){return UT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},UT.apply(this,arguments)}var Rfe=function(e){return w.createElement("svg",UT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),dL||(dL=w.createElement("path",{fill:"currentColor",d:"M6.75 3h5.5v1.5h-5.5C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25v-5.5H21v5.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3Z"})),fL||(fL=w.createElement("path",{fill:"currentColor",d:"M20.013 3h-3.946a.987.987 0 0 0 0 1.973h1.564l-6.342 6.342a1.004 1.004 0 0 0 0 1.396 1.004 1.004 0 0 0 1.396 0l6.342-6.342v1.564a.987.987 0 0 0 1.973 0V3.987A.987.987 0 0 0 20.013 3Z"})))};function Yq({node:t,depth:e,deleteHandle:n,indexOrName:r,parent:s,editHandle:i,parentPath:a}){const{collapseStringsAfterLength:l,enableClipboard:u,editable:d,src:p,onDelete:h,onChange:g,customizeNode:v,matchesURL:b,urlRegExp:x,EditComponent:E,DoneComponent:S,CancelComponent:k,CustomOperation:T}=w.useContext(oc);let R;if(typeof v=="function"&&(R=LN(v,[{node:t,depth:e,indexOrName:r}])),R){if(w.isValidElement(R))return R;if(xfe(R)){const j=R;return f.jsx(j,{node:t,depth:e,indexOrName:r})}}if(Array.isArray(t)||ac(t))return f.jsx(Cfe,{parent:s,node:t,depth:e,indexOrName:r,deleteHandle:n,parentPath:a,customOptions:typeof R=="object"?R:void 0});{const j=typeof t,A=typeof r<"u"?[...a,String(r)]:a,[N,M]=w.useState(!1),[I,O]=w.useState(!1),L=w.useRef(null),z=()=>{M(!0),setTimeout(()=>{var D,Z;(D=window.getSelection())===null||D===void 0||D.selectAllChildren(L.current),(Z=L.current)===null||Z===void 0||Z.focus()})},G=w.useCallback(()=>{let D=L.current.innerText;try{const Z=JSON.parse(D);i&&i(r,Z,t,a)}catch{const he=wfe(j,D);i&&i(r,he,t,a)}M(!1)},[i,r,t,a,j]),W=()=>{M(!1),O(!1)},X=()=>{O(!1),n&&n(r,a),h&&h({value:t,depth:e,src:p,indexOrName:r,parentType:Array.isArray(s)?"array":"object",parentPath:a}),g&&g({depth:e,src:p,indexOrName:r,parentType:Array.isArray(s)?"array":"object",type:"delete",parentPath:a})},F=w.useCallback(D=>{D.key==="Enter"?(D.preventDefault(),G()):D.key==="Escape"&&W()},[G]),Y=N||I,H=!Y&&XD(d)&&QD(R)&&i?D=>{(D.ctrlKey||D.metaKey)&&z()}:void 0,te=f.jsxs(f.Fragment,{children:[Y&&(typeof S=="function"?f.jsx(S,{className:"json-view--edit",style:{display:"inline-block"},onClick:I?X:G}):f.jsx(BN,{className:"json-view--edit",style:{display:"inline-block"},onClick:I?X:G})),Y&&(typeof k=="function"?f.jsx(k,{className:"json-view--edit",style:{display:"inline-block"},onClick:W}):f.jsx(qN,{className:"json-view--edit",style:{display:"inline-block"},onClick:W})),!Y&&u&&P0(R)&&f.jsx(I0,{node:t,nodeMeta:{depth:e,indexOrName:r,parent:s,parentPath:a,currentPath:A}}),!Y&&b&&j==="string"&&x.test(t)&&_fe(R)&&f.jsx("a",Object.assign({href:t,target:"_blank",className:"json-view--link"},{children:f.jsx(Rfe,{})})),!Y&&XD(d)&&QD(R)&&i&&(typeof E=="function"?f.jsx(E,{className:"json-view--edit",onClick:z}):f.jsx(Nfe,{className:"json-view--edit",onClick:z})),!Y&&$N(d)&&zN(R)&&n&&f.jsx(UN,{className:"json-view--edit",onClick:()=>O(!0)}),typeof T=="function"?f.jsx(T,{node:t}):null]});let P="json-view--string";switch(j){case"number":case"bigint":P="json-view--number";break;case"boolean":P="json-view--boolean";break;case"object":P="json-view--null";break}typeof R?.className=="string"&&(P+=" "+R.className),I&&(P+=" json-view--deleting");let re=String(t);j==="bigint"&&(re+="n");const ue=w.useMemo(()=>f.jsx("span",{contentEditable:!0,className:P,dangerouslySetInnerHTML:{__html:j==="string"?`"${re}"`:re},ref:L,onKeyDown:F}),[re,j,F]);return j==="string"?f.jsxs(f.Fragment,{children:[N?ue:t.length>l?f.jsx(Afe,{str:t,ref:L,className:P,ctrlClick:H}):f.jsxs("span",Object.assign({className:P,onClick:H},{children:['"',re,'"']})),te]}):f.jsxs(f.Fragment,{children:[N?ue:f.jsx("span",Object.assign({className:P,onClick:H},{children:re})),te]})}}const Kq=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,oc=w.createContext({src:void 0,collapseStringsAfterLength:99,collapseStringMode:"directly",customizeCollapseStringUI:void 0,collapseObjectsAfterLength:20,collapsed:!1,onCollapse:void 0,enableClipboard:!0,editable:!1,onEdit:void 0,onDelete:void 0,onAdd:void 0,onChange:void 0,forceUpdate:()=>{},customizeNode:void 0,customizeCopy:()=>{},displaySize:void 0,displayArrayIndex:!0,matchesURL:!1,urlRegExp:Kq,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function zl({src:t,collapseStringsAfterLength:e=99,collapseStringMode:n="directly",customizeCollapseStringUI:r,collapseObjectsAfterLength:s=99,collapsed:i,onCollapse:a,enableClipboard:l=!0,editable:u=!1,onEdit:d,onDelete:p,onAdd:h,onChange:g,dark:v=!1,theme:b="default",customizeNode:x,customizeCopy:E=W=>yfe(W),displaySize:S,displayArrayIndex:k=!0,style:T,className:R,matchesURL:j=!1,urlRegExp:A=Kq,ignoreLargeArray:N=!1,CopyComponent:M,CopiedComponent:I,EditComponent:O,CancelComponent:L,DoneComponent:z,CustomOperation:G}){const[W,X]=w.useState(0),F=w.useCallback(()=>X(te=>++te),[]),[Y,H]=w.useState(t);return w.useEffect(()=>H(t),[t]),f.jsx(oc.Provider,Object.assign({value:{src:Y,collapseStringsAfterLength:e,collapseStringMode:n,customizeCollapseStringUI:r,collapseObjectsAfterLength:s,collapsed:i,onCollapse:a,enableClipboard:l,editable:u,onEdit:d,onDelete:p,onAdd:h,onChange:g,forceUpdate:F,customizeNode:x,customizeCopy:E,displaySize:S,displayArrayIndex:k,matchesURL:j,urlRegExp:A,ignoreLargeArray:N,CopyComponent:M,CopiedComponent:I,EditComponent:O,CancelComponent:L,DoneComponent:z,CustomOperation:G}},{children:f.jsx("code",Object.assign({className:"json-view"+(v?" dark":"")+(b&&b!=="default"?" json-view_"+b:"")+(R?" "+R:""),style:T},{children:f.jsx(Yq,{node:Y,depth:1,editHandle:(te,P,re,ue)=>{H(P),d&&d({newValue:P,oldValue:re,depth:1,src:Y,indexOrName:te,parentType:null,parentPath:ue}),g&&g({type:"edit",depth:1,src:Y,indexOrName:te,parentType:null,parentPath:ue})},deleteHandle:(te,P)=>{H(void 0),p&&p({value:Y,depth:1,src:Y,indexOrName:te,parentType:null,parentPath:P}),g&&g({depth:1,src:Y,indexOrName:te,parentType:null,type:"delete",parentPath:P})},parentPath:[]})}))}))}function jfe(t){if(!t)return null;const e=t,n=e?.resource;if(n&&typeof n=="object"&&typeof n.uri=="string"&&n.uri.startsWith("ui://"))return n;const r=e?.content;if(Array.isArray(r)){for(const s of r)if(s&&s.type==="resource"&&s.resource&&typeof s.resource.uri=="string"&&s.resource.uri.startsWith("ui://"))return s.resource}return null}function Mfe({error:t,showStructured:e,onToggleStructured:n,structuredResult:r,result:s,validationErrors:i,unstructuredValidationResult:a,onExecuteFromUI:l,onHandleIntent:u,onSendFollowup:d,serverId:p,toolCallId:h,toolName:g,toolParameters:v,toolCallTimestamp:b,toolMeta:x}){const E=s,S=x?.["openai/outputTemplate"],k=S&&typeof S=="string",T=jfe(s);return f.jsxs("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Response"}),e&&i!==void 0&&(i===null?f.jsxs(vr,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[f.jsx(sf,{className:"h-3 w-3 mr-1.5"}),"Valid"]}):f.jsxs(vr,{variant:"destructive",children:[f.jsx(af,{className:"h-3 w-3 mr-1.5"}),"Invalid"]}))]}),E&&(r||k)&&f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ie,{size:"sm",variant:e?"outline":"default",onClick:()=>n(!1),children:k?"Component":"Raw Output"}),f.jsx(Ie,{size:"sm",variant:e?"default":"outline",onClick:()=>n(!0),children:k?"Raw JSON":"Structured Output"})]})]}),f.jsx("div",{className:"flex-1 overflow-hidden",children:t?f.jsx("div",{className:"p-4",children:f.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:t})}):e&&i?f.jsxs("div",{className:"p-4",children:[f.jsx("h3",{className:"text-sm font-semibold text-destructive mb-2",children:"Validation Errors"}),f.jsxs("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded-md",children:[f.jsx(zl,{src:i,theme:"atom",dark:!0,enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}}),Array.isArray(i)&&i.length>0&&f.jsx("span",{className:"text-sm font-semibold text-destructive mb-2",children:`${i[0].instancePath?.slice(1)??""} ${i[0].message??""}`})]})]}):e&&E&&k?f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-4",children:f.jsx(zl,{src:E,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):e&&r&&i===null?f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-4",children:f.jsx(zl,{src:r,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):E?!e&&k&&S?f.jsx(Vq,{componentUrl:S,toolCall:{id:h||"tool-result",name:g||"tool",parameters:v||{},timestamp:b||new Date,status:"completed"},toolResult:{id:`${h||"tool-result"}-result`,toolCallId:h||"tool-result",result:E,timestamp:new Date},onCallTool:async(R,j)=>{const A=await l(R,j);if("error"in A)return{isError:!0,error:A.error};if(A.status==="completed"){const N=A.result,M=N?.structuredContent||N;return{_meta:null,content:N?.content||[],structuredContent:M,isError:!1,result:JSON.stringify(M),meta:{}}}return{isError:!0,error:"Elicitation not supported in this context"}},onSendFollowup:d,serverId:p,toolMeta:x}):!e&&T?f.jsx(DN,{resource:T,htmlProps:{autoResizeIframe:!0,style:{width:"100%",minHeight:"500px",height:"auto",overflow:"visible"}},onUIAction:async R=>(R.type==="tool"&&R.payload?.toolName?await l(R.payload.toolName,R.payload.params||{}):R.type==="intent"&&R.payload?.intent?await u(R.payload.intent,R.payload.params||{}):R.type==="link"&&R.payload?.url&&window.open(R.payload.url,"_blank","noopener,noreferrer"),{status:"handled"})}):f.jsxs("div",{className:"p-4",children:[a==="valid"&&f.jsxs(vr,{variant:"default",className:"bg-green-600 hover:bg-green-700 mb-4",children:[f.jsx(sf,{className:"h-3 w-3 mr-1.5"}),"Success: Content matches the output schema."]}),a==="schema_mismatch"&&f.jsxs(vr,{variant:"destructive",className:"mb-4",children:[f.jsx(af,{className:"h-3 w-3 mr-1.5"}),"Error: Content does not match the output schema."]}),a==="invalid_json"&&f.jsxs(vr,{variant:"destructive",className:"bg-amber-600 hover:bg-amber-700 mb-4",children:[f.jsx(af,{className:"h-3 w-3 mr-1.5"}),"Warning: Output schema provided by the tool is invalid."]}),f.jsx(zl,{src:E,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))",width:"calc(100vw - var(--sidebar-width) - 16px - 16px)"}})]}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Execute a tool to see results here"})})})]})}const Xq=w.forwardRef(({value:t,onValueChange:e,placeholder:n="Search…",className:r,clearable:s=!0,iconClassName:i,...a},l)=>f.jsxs("div",{className:"relative",children:[f.jsx(vB,{className:Me("absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground",i)}),f.jsx(Un,{ref:l,value:t,onChange:u=>e(u.target.value),placeholder:n,type:"search",role:"searchbox","aria-label":n,autoComplete:"off",spellCheck:!1,className:Me("pl-7 h-8 bg-background border-border hover:border-border/80 text-xs md:text-xs leading-4 text-foreground placeholder:text-muted-foreground/70",r),...a}),s&&t&&f.jsx("button",{type:"button",onClick:()=>e(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Clear search",children:f.jsx(Nu,{className:"h-3 w-3"})})]}));Xq.displayName="SearchInput";function Ofe({tool:t,name:e,isSelected:n,onClick:r}){return f.jsx("div",{className:`cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ${n?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"}`,onClick:r,children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e})}),t.description&&f.jsx("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:t.description})]}),f.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})})}function Pfe({request:t,isHighlighted:e,onLoad:n,onRename:r,onDuplicate:s,onDelete:i}){return f.jsx("div",{className:`group p-2 rounded mx-2 cursor-pointer transition-all duration-200 ${e?"bg-primary/20 border border-primary/30 shadow-sm":"hover:bg-muted/40"}`,onClick:()=>n(t),children:f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{className:"min-w-0 pr-2",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("code",{className:"font-mono text-[10px] bg-muted px-1.5 py-0.5 rounded border border-border",children:t.toolName})}),f.jsxs("div",{children:[f.jsx("div",{className:"text-xs font-medium truncate",children:t.title}),t.description&&f.jsx("div",{className:"text-[10px] text-muted-foreground truncate",children:t.description})]})]}),f.jsxs("div",{className:"flex gap-1",children:[f.jsx(Ie,{onClick:a=>{a.stopPropagation(),r(t)},size:"sm",variant:"ghost",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:f.jsx(Jse,{className:"w-3 h-3"})}),f.jsx(Ie,{onClick:a=>{a.stopPropagation(),s(t)},size:"sm",variant:"ghost",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:f.jsx(Po,{className:"w-3 h-3"})}),f.jsx(Ie,{onClick:a=>{a.stopPropagation(),i(t.id)},size:"sm",variant:"ghost",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",children:f.jsx(wie,{className:"w-3 h-3"})})]})]})})}function Ife({activeTab:t,onChangeTab:e,tools:n,toolNames:r,filteredToolNames:s,selectedToolName:i,fetchingTools:a,searchQuery:l,onSearchQueryChange:u,onRefresh:d,onSelectTool:p,savedRequests:h,highlightedRequestId:g,onLoadRequest:v,onRenameRequest:b,onDuplicateRequest:x,onDeleteRequest:E}){return f.jsx(ni,{defaultSize:35,minSize:20,maxSize:55,children:f.jsxs("div",{className:"h-full border-r border-border bg-background",children:[f.jsx("div",{className:"border-b border-border",children:f.jsxs("div",{className:"flex",children:[f.jsx("button",{onClick:()=>e("tools"),className:`px-4 py-3 text-xs font-medium border-b-2 transition-colors ${t==="tools"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Tools"}),f.jsxs("button",{onClick:()=>e("saved"),className:`px-4 py-3 text-xs font-medium border-b-2 transition-colors ${t==="saved"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:["Saved Requests",h.length>0&&f.jsx("span",{className:"ml-2 bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs font-mono",children:h.length})]})]})}),f.jsxs("div",{className:"px-4 py-4 border-b border-border bg-background space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(kk,{className:"h-3 w-3 text-muted-foreground"}),f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Tools"}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono",children:t==="tools"?r.length:h.length})]}),f.jsx(Ie,{onClick:d,variant:"ghost",size:"sm",disabled:a,children:t==="tools"&&f.jsx(ir,{className:`h-3 w-3 ${a?"animate-spin":""} cursor-pointer`})})]}),f.jsx(Xq,{value:l,onValueChange:u,placeholder:"Search tools by name or description"})]}),t==="tools"?f.jsx("div",{className:"h-[calc(100%-49px)] flex flex-col",children:f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-2",children:a?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(ir,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading tools..."}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available tools from server"})]}):s.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:n&&r.length===0?"No tools were found. Try refreshing. Make sure you selected the correct server and the server is running.":"No tools match your search."})}):f.jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(S=>f.jsx(Ofe,{tool:n[S],name:S,isSelected:i===S,onClick:()=>p(S)},S))})})})})}):f.jsx("div",{className:"h-full",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-3 space-y-1",children:h.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:"No saved requests yet."})}):h.map(S=>f.jsx(Pfe,{request:S,isHighlighted:g===S.id,onLoad:v,onRename:b,onDuplicate:x,onDelete:E},S.id))})})})]})})}function Dfe({open:t,defaultTitle:e="",defaultDescription:n="",onCancel:r,onSave:s}){const[i,a]=w.useState(e),[l,u]=w.useState(n);return w.useEffect(()=>{t&&(a(e||""),u(n||""))},[t,e,n]),f.jsx(aa,{open:t,children:f.jsxs(oa,{className:"sm:max-w-md",onEscapeKeyDown:r,onPointerDownOutside:r,children:[f.jsxs(la,{children:[f.jsx(ca,{children:"Save request"}),f.jsx(Jf,{children:"Give this request a memorable name and optional description."})]}),f.jsxs("div",{className:"space-y-3 py-2",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-xs font-medium",children:"Name"}),f.jsx(Un,{value:i,onChange:d=>a(d.target.value),placeholder:"My saved request",className:"text-sm"})]}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("label",{className:"text-xs font-medium",children:"Description"}),f.jsx(Ho,{value:l,onChange:d=>u(d.target.value),placeholder:"Optional description",className:"text-sm h-20"})]})]}),f.jsxs(v0,{children:[f.jsx(Ie,{variant:"ghost",onClick:r,size:"sm",children:"Cancel"}),f.jsx(Ie,{onClick:()=>{const d=(i||"").trim();d&&s({title:d,description:l?.trim()||void 0})},size:"sm",children:"Save"})]})]})})}function Lfe(t,e){switch(t){case"enum":return e?.[0]||"";case"string":return"";case"number":case"integer":return"";case"boolean":return!1;case"array":return[];case"object":return{};default:return""}}function $fe(t){if(!t||!t.properties)return[];const e=[],n=t.required||[];return Object.entries(t.properties).forEach(([r,s])=>{const i=s.enum?"enum":s.type||"string";e.push({name:r,type:i,description:s.description,required:n.includes(r),value:Lfe(i,s.enum),enum:s.enum,minimum:s.minimum,maximum:s.maximum,pattern:s.pattern})}),e}function zfe(t,e){return t.map(n=>{if(Object.prototype.hasOwnProperty.call(e,n.name)){const r=e[n.name];return n.type==="array"||n.type==="object"?{...n,value:JSON.stringify(r,null,2)}:{...n,value:r}}return n})}function Ffe(t,e){const n={};return t.forEach(r=>{if(!(r.required||r.value!==""&&r.value!==null&&r.value!==void 0))return;let i=r.value;try{r.type==="number"||r.type==="integer"?(i=Number(r.value),isNaN(i)&&e?.("Invalid number value for field",{fieldName:r.name,value:r.value})):r.type==="boolean"?i=!!r.value:(r.type==="array"||r.type==="object")&&(i=JSON.parse(r.value)),n[r.name]=i}catch(a){e?.("Failed to process field value",{fieldName:r.name,type:r.type,value:r.value,error:a}),n[r.name]=r.value}}),n}const Ufe="mcp-inspector.saved-requests";function VN(t){return`${Ufe}:${t}`}function Ll(t){try{const e=localStorage.getItem(VN(t));if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function HN(t,e){const n=new Date().toISOString(),r=Ll(t);let s;if(e.id){s={id:e.id,title:e.title,description:e.description,toolName:e.toolName,parameters:e.parameters,isFavorite:e.isFavorite,serverKey:t,createdAt:r.find(a=>a.id===e.id)?.createdAt||n,updatedAt:n};const i=r.findIndex(a=>a.id===s.id);i>=0?r[i]=s:r.push(s)}else s={id:crypto.randomUUID(),title:e.title,description:e.description,toolName:e.toolName,parameters:e.parameters,isFavorite:e.isFavorite,serverKey:t,createdAt:n,updatedAt:n},r.unshift(s);return localStorage.setItem(VN(t),JSON.stringify(r)),s}function Bfe(t,e){const n=Ll(t).filter(r=>r.id!==e);localStorage.setItem(VN(t),JSON.stringify(n))}function Qq(t,e){return Ll(t).find(n=>n.id===e)}function qfe(t,e){const n=Qq(t,e);if(n)return HN(t,{title:`${n.title} (copy)`,description:n.description,toolName:n.toolName,parameters:n.parameters,isFavorite:n.isFavorite})}function Vfe(t,e,n){const r=Qq(t,e);if(r)return HN(t,{id:e,title:n.title??r.title,description:n.description??r.description,toolName:r.toolName,parameters:r.parameters,isFavorite:n.isFavorite??r.isFavorite})}var oE,hL;function Hfe(){if(hL)return oE;hL=1;function t(e,r){var r=r||{};this._capacity=r.capacity,this._head=0,this._tail=0,Array.isArray(e)?this._fromArray(e):(this._capacityMask=3,this._list=new Array(4))}return t.prototype.peekAt=function(n){var r=n;if(r===(r|0)){var s=this.size();if(!(r>=s||r<-s))return r<0&&(r+=s),r=this._head+r&this._capacityMask,this._list[r]}},t.prototype.get=function(n){return this.peekAt(n)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.unshift=function(n){if(arguments.length===0)return this.size();var r=this._list.length;return this._head=this._head-1+r&this._capacityMask,this._list[this._head]=n,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.shift=function(){var n=this._head;if(n!==this._tail){var r=this._list[n];return this._list[n]=void 0,this._head=n+1&this._capacityMask,n<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),r}},t.prototype.push=function(n){if(arguments.length===0)return this.size();var r=this._tail;return this._list[r]=n,this._tail=r+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.pop=function(){var n=this._tail;if(n!==this._head){var r=this._list.length;this._tail=n-1+r&this._capacityMask;var s=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&n>1e4&&n<=r>>>2&&this._shrinkArray(),s}},t.prototype.removeOne=function(n){var r=n;if(r===(r|0)&&this._head!==this._tail){var s=this.size(),i=this._list.length;if(!(r>=s||r<-s)){r<0&&(r+=s),r=this._head+r&this._capacityMask;var a=this._list[r],l;if(n<s/2){for(l=n;l>0;l--)this._list[r]=this._list[r=r-1+i&this._capacityMask];this._list[r]=void 0,this._head=this._head+1+i&this._capacityMask}else{for(l=s-1-n;l>0;l--)this._list[r]=this._list[r=r+1+i&this._capacityMask];this._list[r]=void 0,this._tail=this._tail-1+i&this._capacityMask}return a}}},t.prototype.remove=function(n,r){var s=n,i,a=r;if(s===(s|0)&&this._head!==this._tail){var l=this.size(),u=this._list.length;if(!(s>=l||s<-l||r<1)){if(s<0&&(s+=l),r===1||!r)return i=new Array(1),i[0]=this.removeOne(s),i;if(s===0&&s+r>=l)return i=this.toArray(),this.clear(),i;s+r>l&&(r=l-s);var d;for(i=new Array(r),d=0;d<r;d++)i[d]=this._list[this._head+s+d&this._capacityMask];if(s=this._head+s&this._capacityMask,n+r===l){for(this._tail=this._tail-r+u&this._capacityMask,d=r;d>0;d--)this._list[s=s+1+u&this._capacityMask]=void 0;return i}if(n===0){for(this._head=this._head+r+u&this._capacityMask,d=r-1;d>0;d--)this._list[s=s+1+u&this._capacityMask]=void 0;return i}if(s<l/2){for(this._head=this._head+n+r+u&this._capacityMask,d=n;d>0;d--)this.unshift(this._list[s=s-1+u&this._capacityMask]);for(s=this._head-1+u&this._capacityMask;a>0;)this._list[s=s-1+u&this._capacityMask]=void 0,a--;n<0&&(this._tail=s)}else{for(this._tail=s,s=s+r+u&this._capacityMask,d=l-(r+n);d>0;d--)this.push(this._list[s++]);for(s=this._tail;a>0;)this._list[s=s+1+u&this._capacityMask]=void 0,a--}return this._head<2&&this._tail>1e4&&this._tail<=u>>>2&&this._shrinkArray(),i}}},t.prototype.splice=function(n,r){var s=n;if(s===(s|0)){var i=this.size();if(s<0&&(s+=i),!(s>i))if(arguments.length>2){var a,l,u,d=arguments.length,p=this._list.length,h=2;if(!i||s<i/2){for(l=new Array(s),a=0;a<s;a++)l[a]=this._list[this._head+a&this._capacityMask];for(r===0?(u=[],s>0&&(this._head=this._head+s+p&this._capacityMask)):(u=this.remove(s,r),this._head=this._head+s+p&this._capacityMask);d>h;)this.unshift(arguments[--d]);for(a=s;a>0;a--)this.unshift(l[a-1])}else{l=new Array(i-(s+r));var g=l.length;for(a=0;a<g;a++)l[a]=this._list[this._head+s+r+a&this._capacityMask];for(r===0?(u=[],s!=i&&(this._tail=this._head+s+p&this._capacityMask)):(u=this.remove(s,r),this._tail=this._tail-g+p&this._capacityMask);h<d;)this.push(arguments[h++]);for(a=0;a<g;a++)this.push(l[a])}return u}else return this.remove(s,r)}},t.prototype.clear=function(){this._list=new Array(this._list.length),this._head=0,this._tail=0},t.prototype.isEmpty=function(){return this._head===this._tail},t.prototype.toArray=function(){return this._copyArray(!1)},t.prototype._fromArray=function(n){var r=n.length,s=this._nextPowerOf2(r);this._list=new Array(s),this._capacityMask=s-1,this._tail=r;for(var i=0;i<r;i++)this._list[i]=n[i]},t.prototype._copyArray=function(n,r){var s=this._list,i=s.length,a=this.length;if(r=r|a,r==a&&this._head<this._tail)return this._list.slice(this._head,this._tail);var l=new Array(r),u=0,d;if(n||this._head>this._tail){for(d=this._head;d<i;d++)l[u++]=s[d];for(d=0;d<this._tail;d++)l[u++]=s[d]}else for(d=this._head;d<this._tail;d++)l[u++]=s[d];return l},t.prototype._growArray=function(){if(this._head!=0){var n=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=n}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1},t.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1},t.prototype._nextPowerOf2=function(n){var r=Math.log(n)/Math.log(2),s=1<<r+1;return Math.max(s,4)},oE=t,oE}var Gfe=Hfe();const Wfe=Vf(Gfe),pL={error:0,warn:1,info:2,debug:3,trace:4},Yfe={error:"#ef4444",warn:"#f59e0b",info:"#3b82f6",debug:"#8b5cf6",trace:"#6b7280"};class Kfe{config={level:"info",enableConsole:!0,maxBufferSize:1e3};buffer=new Wfe([],{capacity:this.config.maxBufferSize});listeners=new Set;setConfig(e){this.config={...this.config,...e},this.notifyListeners()}getConfig(){return{...this.config}}addEntry(e){this.buffer.unshift(e),this.notifyListeners()}getEntries(){return this.buffer.toArray()}clearBuffer(){this.buffer.clear(),this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}shouldLog(e){return pL[e]<=pL[this.config.level]}}const Yi=new Kfe;typeof window<"u"&&Yi.setConfig({level:"info",enableConsole:!0});function GN(t="Unknown"){const e=w.useCallback(r=>(s,i,a)=>{if(!Yi.shouldLog(r))return;const u={timestamp:new Date().toISOString(),level:r,context:t,message:s,data:i,error:a};Yi.addEntry(u),Yi.getConfig().enableConsole&&Xfe(u)},[t]);return w.useMemo(()=>({error:e("error"),warn:e("warn"),info:e("info"),debug:e("debug"),trace:e("trace"),context:t}),[e,t])}function Xfe(t){const{timestamp:e,level:n,context:r,message:s,data:i,error:a}=t,l=new Date(e).toLocaleTimeString(),u=Yfe[n],d=`color: ${u}; font-weight: bold;`,p=`color: ${u};`,h=[`%c[${l}] %c${n.toUpperCase()} %c[${r}] %c${s}`,"color: #6b7280;",d,"color: #6b7280;",p];i!==void 0&&h.push(`
|
|
1774
1774
|
Data:`,i),a&&h.push(`
|
|
1775
|
-
Error:`,a),(n==="error"?console.error:n==="warn"?console.warn:n==="debug"?console.debug:console.log)(...h)}function Qfe(){const[,t]=w.useState({});return w.useEffect(()=>{const e=Yi.subscribe(()=>{t({})});return()=>{e()}},[]),{entries:Yi.getEntries(),config:Yi.getConfig(),setConfig:Yi.setConfig.bind(Yi),clearBuffer:Yi.clearBuffer.bind(Yi)}}var qp={exports:{}};/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */var Jfe=qp.exports,mL;function Zfe(){return mL||(mL=1,function(t,e){(function(n,r){r(e)})(Jfe,function(n){function r(){for(var ne=arguments.length,Q=Array(ne),se=0;se<ne;se++)Q[se]=arguments[se];if(Q.length>1){Q[0]=Q[0].slice(0,-1);for(var ye=Q.length-1,me=1;me<ye;++me)Q[me]=Q[me].slice(1,-1);return Q[ye]=Q[ye].slice(1),Q.join("")}else return Q[0]}function s(ne){return"(?:"+ne+")"}function i(ne){return ne===void 0?"undefined":ne===null?"null":Object.prototype.toString.call(ne).split(" ").pop().split("]").shift().toLowerCase()}function a(ne){return ne.toUpperCase()}function l(ne){return ne!=null?ne instanceof Array?ne:typeof ne.length!="number"||ne.split||ne.setInterval||ne.call?[ne]:Array.prototype.slice.call(ne):[]}function u(ne,Q){var se=ne;if(Q)for(var ye in Q)se[ye]=Q[ye];return se}function d(ne){var Q="[A-Za-z]",se="[0-9]",ye=r(se,"[A-Fa-f]"),me=s(s("%[EFef]"+ye+"%"+ye+ye+"%"+ye+ye)+"|"+s("%[89A-Fa-f]"+ye+"%"+ye+ye)+"|"+s("%"+ye+ye)),nt="[\\:\\/\\?\\#\\[\\]\\@]",tt="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",Mt=r(nt,tt),sn=ne?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",hn=ne?"[\\uE000-\\uF8FF]":"[]",at=r(Q,se,"[\\-\\.\\_\\~]",sn);s(Q+r(Q,se,"[\\+\\-\\.]")+"*"),s(s(me+"|"+r(at,tt,"[\\:]"))+"*");var ln=s(s("25[0-5]")+"|"+s("2[0-4]"+se)+"|"+s("1"+se+se)+"|"+s("0?[1-9]"+se)+"|0?0?"+se),jn=s(ln+"\\."+ln+"\\."+ln+"\\."+ln),lt=s(ye+"{1,4}"),an=s(s(lt+"\\:"+lt)+"|"+jn),Hn=s(s(lt+"\\:")+"{6}"+an),yn=s("\\:\\:"+s(lt+"\\:")+"{5}"+an),zi=s(s(lt)+"?\\:\\:"+s(lt+"\\:")+"{4}"+an),oi=s(s(s(lt+"\\:")+"{0,1}"+lt)+"?\\:\\:"+s(lt+"\\:")+"{3}"+an),as=s(s(s(lt+"\\:")+"{0,2}"+lt)+"?\\:\\:"+s(lt+"\\:")+"{2}"+an),Fi=s(s(s(lt+"\\:")+"{0,3}"+lt)+"?\\:\\:"+lt+"\\:"+an),zr=s(s(s(lt+"\\:")+"{0,4}"+lt)+"?\\:\\:"+an),Qr=s(s(s(lt+"\\:")+"{0,5}"+lt)+"?\\:\\:"+lt),zs=s(s(s(lt+"\\:")+"{0,6}"+lt)+"?\\:\\:"),bs=s([Hn,yn,zi,oi,as,Fi,zr,Qr,zs].join("|")),Fs=s(s(at+"|"+me)+"+");s("[vV]"+ye+"+\\."+r(at,tt,"[\\:]")+"+"),s(s(me+"|"+r(at,tt))+"*");var Qa=s(me+"|"+r(at,tt,"[\\:\\@]"));return s(s(me+"|"+r(at,tt,"[\\@]"))+"+"),s(s(Qa+"|"+r("[\\/\\?]",hn))+"*"),{NOT_SCHEME:new RegExp(r("[^]",Q,se,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(r("[^\\%\\:]",at,tt),"g"),NOT_HOST:new RegExp(r("[^\\%\\[\\]\\:]",at,tt),"g"),NOT_PATH:new RegExp(r("[^\\%\\/\\:\\@]",at,tt),"g"),NOT_PATH_NOSCHEME:new RegExp(r("[^\\%\\/\\@]",at,tt),"g"),NOT_QUERY:new RegExp(r("[^\\%]",at,tt,"[\\:\\@\\/\\?]",hn),"g"),NOT_FRAGMENT:new RegExp(r("[^\\%]",at,tt,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(r("[^]",at,tt),"g"),UNRESERVED:new RegExp(at,"g"),OTHER_CHARS:new RegExp(r("[^\\%]",at,Mt),"g"),PCT_ENCODED:new RegExp(me,"g"),IPV4ADDRESS:new RegExp("^("+jn+")$"),IPV6ADDRESS:new RegExp("^\\[?("+bs+")"+s(s("\\%25|\\%(?!"+ye+"{2})")+"("+Fs+")")+"?\\]?$")}}var p=d(!1),h=d(!0),g=function(){function ne(Q,se){var ye=[],me=!0,nt=!1,tt=void 0;try{for(var Mt=Q[Symbol.iterator](),sn;!(me=(sn=Mt.next()).done)&&(ye.push(sn.value),!(se&&ye.length===se));me=!0);}catch(hn){nt=!0,tt=hn}finally{try{!me&&Mt.return&&Mt.return()}finally{if(nt)throw tt}}return ye}return function(Q,se){if(Array.isArray(Q))return Q;if(Symbol.iterator in Object(Q))return ne(Q,se);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),v=function(ne){if(Array.isArray(ne)){for(var Q=0,se=Array(ne.length);Q<ne.length;Q++)se[Q]=ne[Q];return se}else return Array.from(ne)},b=2147483647,x=36,E=1,S=26,k=38,T=700,R=72,j=128,A="-",N=/^xn--/,M=/[^\0-\x7E]/,I=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=x-E,z=Math.floor,G=String.fromCharCode;function W(ne){throw new RangeError(O[ne])}function X(ne,Q){for(var se=[],ye=ne.length;ye--;)se[ye]=Q(ne[ye]);return se}function F(ne,Q){var se=ne.split("@"),ye="";se.length>1&&(ye=se[0]+"@",ne=se[1]),ne=ne.replace(I,".");var me=ne.split("."),nt=X(me,Q).join(".");return ye+nt}function Y(ne){for(var Q=[],se=0,ye=ne.length;se<ye;){var me=ne.charCodeAt(se++);if(me>=55296&&me<=56319&&se<ye){var nt=ne.charCodeAt(se++);(nt&64512)==56320?Q.push(((me&1023)<<10)+(nt&1023)+65536):(Q.push(me),se--)}else Q.push(me)}return Q}var H=function(Q){return String.fromCodePoint.apply(String,v(Q))},te=function(Q){return Q-48<10?Q-22:Q-65<26?Q-65:Q-97<26?Q-97:x},P=function(Q,se){return Q+22+75*(Q<26)-((se!=0)<<5)},re=function(Q,se,ye){var me=0;for(Q=ye?z(Q/T):Q>>1,Q+=z(Q/se);Q>L*S>>1;me+=x)Q=z(Q/L);return z(me+(L+1)*Q/(Q+k))},ue=function(Q){var se=[],ye=Q.length,me=0,nt=j,tt=R,Mt=Q.lastIndexOf(A);Mt<0&&(Mt=0);for(var sn=0;sn<Mt;++sn)Q.charCodeAt(sn)>=128&&W("not-basic"),se.push(Q.charCodeAt(sn));for(var hn=Mt>0?Mt+1:0;hn<ye;){for(var at=me,ln=1,jn=x;;jn+=x){hn>=ye&&W("invalid-input");var lt=te(Q.charCodeAt(hn++));(lt>=x||lt>z((b-me)/ln))&&W("overflow"),me+=lt*ln;var an=jn<=tt?E:jn>=tt+S?S:jn-tt;if(lt<an)break;var Hn=x-an;ln>z(b/Hn)&&W("overflow"),ln*=Hn}var yn=se.length+1;tt=re(me-at,yn,at==0),z(me/yn)>b-nt&&W("overflow"),nt+=z(me/yn),me%=yn,se.splice(me++,0,nt)}return String.fromCodePoint.apply(String,se)},D=function(Q){var se=[];Q=Y(Q);var ye=Q.length,me=j,nt=0,tt=R,Mt=!0,sn=!1,hn=void 0;try{for(var at=Q[Symbol.iterator](),ln;!(Mt=(ln=at.next()).done);Mt=!0){var jn=ln.value;jn<128&&se.push(G(jn))}}catch(ha){sn=!0,hn=ha}finally{try{!Mt&&at.return&&at.return()}finally{if(sn)throw hn}}var lt=se.length,an=lt;for(lt&&se.push(A);an<ye;){var Hn=b,yn=!0,zi=!1,oi=void 0;try{for(var as=Q[Symbol.iterator](),Fi;!(yn=(Fi=as.next()).done);yn=!0){var zr=Fi.value;zr>=me&&zr<Hn&&(Hn=zr)}}catch(ha){zi=!0,oi=ha}finally{try{!yn&&as.return&&as.return()}finally{if(zi)throw oi}}var Qr=an+1;Hn-me>z((b-nt)/Qr)&&W("overflow"),nt+=(Hn-me)*Qr,me=Hn;var zs=!0,bs=!1,Fs=void 0;try{for(var Qa=Q[Symbol.iterator](),Fg;!(zs=(Fg=Qa.next()).done);zs=!0){var mh=Fg.value;if(mh<me&&++nt>b&&W("overflow"),mh==me){for(var Fr=nt,mc=x;;mc+=x){var Lu=mc<=tt?E:mc>=tt+S?S:mc-tt;if(Fr<Lu)break;var gc=Fr-Lu,gh=x-Lu;se.push(G(P(Lu+gc%gh,0))),Fr=z(gc/gh)}se.push(G(P(Fr,0))),tt=re(nt,Qr,an==lt),nt=0,++an}}}catch(ha){bs=!0,Fs=ha}finally{try{!zs&&Qa.return&&Qa.return()}finally{if(bs)throw Fs}}++nt,++me}return se.join("")},Z=function(Q){return F(Q,function(se){return N.test(se)?ue(se.slice(4).toLowerCase()):se})},he=function(Q){return F(Q,function(se){return M.test(se)?"xn--"+D(se):se})},V={version:"2.1.0",ucs2:{decode:Y,encode:H},decode:ue,encode:D,toASCII:he,toUnicode:Z},U={};function K(ne){var Q=ne.charCodeAt(0),se=void 0;return Q<16?se="%0"+Q.toString(16).toUpperCase():Q<128?se="%"+Q.toString(16).toUpperCase():Q<2048?se="%"+(Q>>6|192).toString(16).toUpperCase()+"%"+(Q&63|128).toString(16).toUpperCase():se="%"+(Q>>12|224).toString(16).toUpperCase()+"%"+(Q>>6&63|128).toString(16).toUpperCase()+"%"+(Q&63|128).toString(16).toUpperCase(),se}function ae(ne){for(var Q="",se=0,ye=ne.length;se<ye;){var me=parseInt(ne.substr(se+1,2),16);if(me<128)Q+=String.fromCharCode(me),se+=3;else if(me>=194&&me<224){if(ye-se>=6){var nt=parseInt(ne.substr(se+4,2),16);Q+=String.fromCharCode((me&31)<<6|nt&63)}else Q+=ne.substr(se,6);se+=6}else if(me>=224){if(ye-se>=9){var tt=parseInt(ne.substr(se+4,2),16),Mt=parseInt(ne.substr(se+7,2),16);Q+=String.fromCharCode((me&15)<<12|(tt&63)<<6|Mt&63)}else Q+=ne.substr(se,9);se+=9}else Q+=ne.substr(se,3),se+=3}return Q}function B(ne,Q){function se(ye){var me=ae(ye);return me.match(Q.UNRESERVED)?me:ye}return ne.scheme&&(ne.scheme=String(ne.scheme).replace(Q.PCT_ENCODED,se).toLowerCase().replace(Q.NOT_SCHEME,"")),ne.userinfo!==void 0&&(ne.userinfo=String(ne.userinfo).replace(Q.PCT_ENCODED,se).replace(Q.NOT_USERINFO,K).replace(Q.PCT_ENCODED,a)),ne.host!==void 0&&(ne.host=String(ne.host).replace(Q.PCT_ENCODED,se).toLowerCase().replace(Q.NOT_HOST,K).replace(Q.PCT_ENCODED,a)),ne.path!==void 0&&(ne.path=String(ne.path).replace(Q.PCT_ENCODED,se).replace(ne.scheme?Q.NOT_PATH:Q.NOT_PATH_NOSCHEME,K).replace(Q.PCT_ENCODED,a)),ne.query!==void 0&&(ne.query=String(ne.query).replace(Q.PCT_ENCODED,se).replace(Q.NOT_QUERY,K).replace(Q.PCT_ENCODED,a)),ne.fragment!==void 0&&(ne.fragment=String(ne.fragment).replace(Q.PCT_ENCODED,se).replace(Q.NOT_FRAGMENT,K).replace(Q.PCT_ENCODED,a)),ne}function J(ne){return ne.replace(/^0*(.*)/,"$1")||"0"}function oe(ne,Q){var se=ne.match(Q.IPV4ADDRESS)||[],ye=g(se,2),me=ye[1];return me?me.split(".").map(J).join("."):ne}function fe(ne,Q){var se=ne.match(Q.IPV6ADDRESS)||[],ye=g(se,3),me=ye[1],nt=ye[2];if(me){for(var tt=me.toLowerCase().split("::").reverse(),Mt=g(tt,2),sn=Mt[0],hn=Mt[1],at=hn?hn.split(":").map(J):[],ln=sn.split(":").map(J),jn=Q.IPV4ADDRESS.test(ln[ln.length-1]),lt=jn?7:8,an=ln.length-lt,Hn=Array(lt),yn=0;yn<lt;++yn)Hn[yn]=at[yn]||ln[an+yn]||"";jn&&(Hn[lt-1]=oe(Hn[lt-1],Q));var zi=Hn.reduce(function(Qr,zs,bs){if(!zs||zs==="0"){var Fs=Qr[Qr.length-1];Fs&&Fs.index+Fs.length===bs?Fs.length++:Qr.push({index:bs,length:1})}return Qr},[]),oi=zi.sort(function(Qr,zs){return zs.length-Qr.length})[0],as=void 0;if(oi&&oi.length>1){var Fi=Hn.slice(0,oi.index),zr=Hn.slice(oi.index+oi.length);as=Fi.join(":")+"::"+zr.join(":")}else as=Hn.join(":");return nt&&(as+="%"+nt),as}else return ne}var be=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Ae="".match(/(){0}/)[1]===void 0;function Oe(ne){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se={},ye=Q.iri!==!1?h:p;Q.reference==="suffix"&&(ne=(Q.scheme?Q.scheme+":":"")+"//"+ne);var me=ne.match(be);if(me){Ae?(se.scheme=me[1],se.userinfo=me[3],se.host=me[4],se.port=parseInt(me[5],10),se.path=me[6]||"",se.query=me[7],se.fragment=me[8],isNaN(se.port)&&(se.port=me[5])):(se.scheme=me[1]||void 0,se.userinfo=ne.indexOf("@")!==-1?me[3]:void 0,se.host=ne.indexOf("//")!==-1?me[4]:void 0,se.port=parseInt(me[5],10),se.path=me[6]||"",se.query=ne.indexOf("?")!==-1?me[7]:void 0,se.fragment=ne.indexOf("#")!==-1?me[8]:void 0,isNaN(se.port)&&(se.port=ne.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?me[4]:void 0)),se.host&&(se.host=fe(oe(se.host,ye),ye)),se.scheme===void 0&&se.userinfo===void 0&&se.host===void 0&&se.port===void 0&&!se.path&&se.query===void 0?se.reference="same-document":se.scheme===void 0?se.reference="relative":se.fragment===void 0?se.reference="absolute":se.reference="uri",Q.reference&&Q.reference!=="suffix"&&Q.reference!==se.reference&&(se.error=se.error||"URI is not a "+Q.reference+" reference.");var nt=U[(Q.scheme||se.scheme||"").toLowerCase()];if(!Q.unicodeSupport&&(!nt||!nt.unicodeSupport)){if(se.host&&(Q.domainHost||nt&&nt.domainHost))try{se.host=V.toASCII(se.host.replace(ye.PCT_ENCODED,ae).toLowerCase())}catch(tt){se.error=se.error||"Host's domain name can not be converted to ASCII via punycode: "+tt}B(se,p)}else B(se,ye);nt&&nt.parse&&nt.parse(se,Q)}else se.error=se.error||"URI can not be parsed.";return se}function Ne(ne,Q){var se=Q.iri!==!1?h:p,ye=[];return ne.userinfo!==void 0&&(ye.push(ne.userinfo),ye.push("@")),ne.host!==void 0&&ye.push(fe(oe(String(ne.host),se),se).replace(se.IPV6ADDRESS,function(me,nt,tt){return"["+nt+(tt?"%25"+tt:"")+"]"})),(typeof ne.port=="number"||typeof ne.port=="string")&&(ye.push(":"),ye.push(String(ne.port))),ye.length?ye.join(""):void 0}var Qe=/^\.\.?\//,dt=/^\/\.(\/|$)/,Be=/^\/\.\.(\/|$)/,pt=/^\/?(?:.|\n)*?(?=\/|$)/;function De(ne){for(var Q=[];ne.length;)if(ne.match(Qe))ne=ne.replace(Qe,"");else if(ne.match(dt))ne=ne.replace(dt,"/");else if(ne.match(Be))ne=ne.replace(Be,"/"),Q.pop();else if(ne==="."||ne==="..")ne="";else{var se=ne.match(pt);if(se){var ye=se[0];ne=ne.slice(ye.length),Q.push(ye)}else throw new Error("Unexpected dot segment condition")}return Q.join("")}function et(ne){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=Q.iri?h:p,ye=[],me=U[(Q.scheme||ne.scheme||"").toLowerCase()];if(me&&me.serialize&&me.serialize(ne,Q),ne.host&&!se.IPV6ADDRESS.test(ne.host)){if(Q.domainHost||me&&me.domainHost)try{ne.host=Q.iri?V.toUnicode(ne.host):V.toASCII(ne.host.replace(se.PCT_ENCODED,ae).toLowerCase())}catch(Mt){ne.error=ne.error||"Host's domain name can not be converted to "+(Q.iri?"Unicode":"ASCII")+" via punycode: "+Mt}}B(ne,se),Q.reference!=="suffix"&&ne.scheme&&(ye.push(ne.scheme),ye.push(":"));var nt=Ne(ne,Q);if(nt!==void 0&&(Q.reference!=="suffix"&&ye.push("//"),ye.push(nt),ne.path&&ne.path.charAt(0)!=="/"&&ye.push("/")),ne.path!==void 0){var tt=ne.path;!Q.absolutePath&&(!me||!me.absolutePath)&&(tt=De(tt)),nt===void 0&&(tt=tt.replace(/^\/\//,"/%2F")),ye.push(tt)}return ne.query!==void 0&&(ye.push("?"),ye.push(ne.query)),ne.fragment!==void 0&&(ye.push("#"),ye.push(ne.fragment)),ye.join("")}function ot(ne,Q){var se=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ye=arguments[3],me={};return ye||(ne=Oe(et(ne,se),se),Q=Oe(et(Q,se),se)),se=se||{},!se.tolerant&&Q.scheme?(me.scheme=Q.scheme,me.userinfo=Q.userinfo,me.host=Q.host,me.port=Q.port,me.path=De(Q.path||""),me.query=Q.query):(Q.userinfo!==void 0||Q.host!==void 0||Q.port!==void 0?(me.userinfo=Q.userinfo,me.host=Q.host,me.port=Q.port,me.path=De(Q.path||""),me.query=Q.query):(Q.path?(Q.path.charAt(0)==="/"?me.path=De(Q.path):((ne.userinfo!==void 0||ne.host!==void 0||ne.port!==void 0)&&!ne.path?me.path="/"+Q.path:ne.path?me.path=ne.path.slice(0,ne.path.lastIndexOf("/")+1)+Q.path:me.path=Q.path,me.path=De(me.path)),me.query=Q.query):(me.path=ne.path,Q.query!==void 0?me.query=Q.query:me.query=ne.query),me.userinfo=ne.userinfo,me.host=ne.host,me.port=ne.port),me.scheme=ne.scheme),me.fragment=Q.fragment,me}function lr(ne,Q,se){var ye=u({scheme:"null"},se);return et(ot(Oe(ne,ye),Oe(Q,ye),ye,!0),ye)}function xe(ne,Q){return typeof ne=="string"?ne=et(Oe(ne,Q),Q):i(ne)==="object"&&(ne=Oe(et(ne,Q),Q)),ne}function Te(ne,Q,se){return typeof ne=="string"?ne=et(Oe(ne,se),se):i(ne)==="object"&&(ne=et(ne,se)),typeof Q=="string"?Q=et(Oe(Q,se),se):i(Q)==="object"&&(Q=et(Q,se)),ne===Q}function st(ne,Q){return ne&&ne.toString().replace(!Q||!Q.iri?p.ESCAPE:h.ESCAPE,K)}function qe(ne,Q){return ne&&ne.toString().replace(!Q||!Q.iri?p.PCT_ENCODED:h.PCT_ENCODED,ae)}var At={scheme:"http",domainHost:!0,parse:function(Q,se){return Q.host||(Q.error=Q.error||"HTTP URIs must have a host."),Q},serialize:function(Q,se){var ye=String(Q.scheme).toLowerCase()==="https";return(Q.port===(ye?443:80)||Q.port==="")&&(Q.port=void 0),Q.path||(Q.path="/"),Q}},Jn={scheme:"https",domainHost:At.domainHost,parse:At.parse,serialize:At.serialize};function Zn(ne){return typeof ne.secure=="boolean"?ne.secure:String(ne.scheme).toLowerCase()==="wss"}var Pe={scheme:"ws",domainHost:!0,parse:function(Q,se){var ye=Q;return ye.secure=Zn(ye),ye.resourceName=(ye.path||"/")+(ye.query?"?"+ye.query:""),ye.path=void 0,ye.query=void 0,ye},serialize:function(Q,se){if((Q.port===(Zn(Q)?443:80)||Q.port==="")&&(Q.port=void 0),typeof Q.secure=="boolean"&&(Q.scheme=Q.secure?"wss":"ws",Q.secure=void 0),Q.resourceName){var ye=Q.resourceName.split("?"),me=g(ye,2),nt=me[0],tt=me[1];Q.path=nt&&nt!=="/"?nt:void 0,Q.query=tt,Q.resourceName=void 0}return Q.fragment=void 0,Q}},bt={scheme:"wss",domainHost:Pe.domainHost,parse:Pe.parse,serialize:Pe.serialize},Xt={},vt="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",Qt="[0-9A-Fa-f]",cr=s(s("%[EFef]"+Qt+"%"+Qt+Qt+"%"+Qt+Qt)+"|"+s("%[89A-Fa-f]"+Qt+"%"+Qt+Qt)+"|"+s("%"+Qt+Qt)),br="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Yo="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",pc=r(Yo,'[\\"\\\\]'),fa="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Du=new RegExp(vt,"g"),ft=new RegExp(cr,"g"),Ln=new RegExp(r("[^]",br,"[\\.]",'[\\"]',pc),"g"),$n=new RegExp(r("[^]",vt,fa),"g"),xr=$n;function $i(ne){var Q=ae(ne);return Q.match(Du)?Q:ne}var Vn={scheme:"mailto",parse:function(Q,se){var ye=Q,me=ye.to=ye.path?ye.path.split(","):[];if(ye.path=void 0,ye.query){for(var nt=!1,tt={},Mt=ye.query.split("&"),sn=0,hn=Mt.length;sn<hn;++sn){var at=Mt[sn].split("=");switch(at[0]){case"to":for(var ln=at[1].split(","),jn=0,lt=ln.length;jn<lt;++jn)me.push(ln[jn]);break;case"subject":ye.subject=qe(at[1],se);break;case"body":ye.body=qe(at[1],se);break;default:nt=!0,tt[qe(at[0],se)]=qe(at[1],se);break}}nt&&(ye.headers=tt)}ye.query=void 0;for(var an=0,Hn=me.length;an<Hn;++an){var yn=me[an].split("@");if(yn[0]=qe(yn[0]),se.unicodeSupport)yn[1]=qe(yn[1],se).toLowerCase();else try{yn[1]=V.toASCII(qe(yn[1],se).toLowerCase())}catch(zi){ye.error=ye.error||"Email address's domain name can not be converted to ASCII via punycode: "+zi}me[an]=yn.join("@")}return ye},serialize:function(Q,se){var ye=Q,me=l(Q.to);if(me){for(var nt=0,tt=me.length;nt<tt;++nt){var Mt=String(me[nt]),sn=Mt.lastIndexOf("@"),hn=Mt.slice(0,sn).replace(ft,$i).replace(ft,a).replace(Ln,K),at=Mt.slice(sn+1);try{at=se.iri?V.toUnicode(at):V.toASCII(qe(at,se).toLowerCase())}catch(an){ye.error=ye.error||"Email address's domain name can not be converted to "+(se.iri?"Unicode":"ASCII")+" via punycode: "+an}me[nt]=hn+"@"+at}ye.path=me.join(",")}var ln=Q.headers=Q.headers||{};Q.subject&&(ln.subject=Q.subject),Q.body&&(ln.body=Q.body);var jn=[];for(var lt in ln)ln[lt]!==Xt[lt]&&jn.push(lt.replace(ft,$i).replace(ft,a).replace($n,K)+"="+ln[lt].replace(ft,$i).replace(ft,a).replace(xr,K));return jn.length&&(ye.query=jn.join("&")),ye}},zn=/^([^\:]+)\:(.*)/,Rn={scheme:"urn",parse:function(Q,se){var ye=Q.path&&Q.path.match(zn),me=Q;if(ye){var nt=se.scheme||me.scheme||"urn",tt=ye[1].toLowerCase(),Mt=ye[2],sn=nt+":"+(se.nid||tt),hn=U[sn];me.nid=tt,me.nss=Mt,me.path=void 0,hn&&(me=hn.parse(me,se))}else me.error=me.error||"URN can not be parsed.";return me},serialize:function(Q,se){var ye=se.scheme||Q.scheme||"urn",me=Q.nid,nt=ye+":"+(se.nid||me),tt=U[nt];tt&&(Q=tt.serialize(Q,se));var Mt=Q,sn=Q.nss;return Mt.path=(me||se.nid)+":"+sn,Mt}},fn=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,er={scheme:"urn:uuid",parse:function(Q,se){var ye=Q;return ye.uuid=ye.nss,ye.nss=void 0,!se.tolerant&&(!ye.uuid||!ye.uuid.match(fn))&&(ye.error=ye.error||"UUID is not valid."),ye},serialize:function(Q,se){var ye=Q;return ye.nss=(Q.uuid||"").toLowerCase(),ye}};U[At.scheme]=At,U[Jn.scheme]=Jn,U[Pe.scheme]=Pe,U[bt.scheme]=bt,U[Vn.scheme]=Vn,U[Rn.scheme]=Rn,U[er.scheme]=er,n.SCHEMES=U,n.pctEncChar=K,n.pctDecChars=ae,n.parse=Oe,n.removeDotSegments=De,n.serialize=et,n.resolveComponents=ot,n.resolve=lr,n.normalize=xe,n.equal=Te,n.escapeComponent=st,n.unescapeComponent=qe,Object.defineProperty(n,"__esModule",{value:!0})})}(qp,qp.exports)),qp.exports}var lE,gL;function WN(){return gL||(gL=1,lE=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var a=i[s];if(!t(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}),lE}var cE,vL;function ehe(){return vL||(vL=1,cE=function(e){for(var n=0,r=e.length,s=0,i;s<r;)n++,i=e.charCodeAt(s++),i>=55296&&i<=56319&&s<r&&(i=e.charCodeAt(s),(i&64512)==56320&&s++);return n}),cE}var uE,yL;function nh(){if(yL)return uE;yL=1,uE={copy:t,checkDataType:e,checkDataTypes:n,coerceToTypes:s,toHash:i,getProperty:u,escapeQuotes:d,equal:WN(),ucs2length:ehe(),varOccurences:p,varReplace:h,schemaHasRules:g,schemaHasRulesExcept:v,schemaUnknownRules:b,toQuotedString:x,getPathExpr:E,getPath:S,getData:R,unescapeFragment:A,unescapeJsonPointer:I,escapeFragment:N,escapeJsonPointer:M};function t(O,L){L=L||{};for(var z in O)L[z]=O[z];return L}function e(O,L,z,G){var W=G?" !== ":" === ",X=G?" || ":" && ",F=G?"!":"",Y=G?"":"!";switch(O){case"null":return L+W+"null";case"array":return F+"Array.isArray("+L+")";case"object":return"("+F+L+X+"typeof "+L+W+'"object"'+X+Y+"Array.isArray("+L+"))";case"integer":return"(typeof "+L+W+'"number"'+X+Y+"("+L+" % 1)"+X+L+W+L+(z?X+F+"isFinite("+L+")":"")+")";case"number":return"(typeof "+L+W+'"'+O+'"'+(z?X+F+"isFinite("+L+")":"")+")";default:return"typeof "+L+W+'"'+O+'"'}}function n(O,L,z){switch(O.length){case 1:return e(O[0],L,z,!0);default:var G="",W=i(O);W.array&&W.object&&(G=W.null?"(":"(!"+L+" || ",G+="typeof "+L+' !== "object")',delete W.null,delete W.array,delete W.object),W.number&&delete W.integer;for(var X in W)G+=(G?" && ":"")+e(X,L,z,!0);return G}}var r=i(["string","number","integer","boolean","null"]);function s(O,L){if(Array.isArray(L)){for(var z=[],G=0;G<L.length;G++){var W=L[G];(r[W]||O==="array"&&W==="array")&&(z[z.length]=W)}if(z.length)return z}else{if(r[L])return[L];if(O==="array"&&L==="array")return["array"]}}function i(O){for(var L={},z=0;z<O.length;z++)L[O[z]]=!0;return L}var a=/^[a-z$_][a-z$_0-9]*$/i,l=/'|\\/g;function u(O){return typeof O=="number"?"["+O+"]":a.test(O)?"."+O:"['"+d(O)+"']"}function d(O){return O.replace(l,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function p(O,L){L+="[^0-9]";var z=O.match(new RegExp(L,"g"));return z?z.length:0}function h(O,L,z){return L+="([^0-9])",z=z.replace(/\$/g,"$$$$"),O.replace(new RegExp(L,"g"),z+"$1")}function g(O,L){if(typeof O=="boolean")return!O;for(var z in O)if(L[z])return!0}function v(O,L,z){if(typeof O=="boolean")return!O&&z!="not";for(var G in O)if(G!=z&&L[G])return!0}function b(O,L){if(typeof O!="boolean"){for(var z in O)if(!L[z])return z}}function x(O){return"'"+d(O)+"'"}function E(O,L,z,G){var W=z?"'/' + "+L+(G?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):G?"'[' + "+L+" + ']'":"'[\\'' + "+L+" + '\\']'";return j(O,W)}function S(O,L,z){var G=x(z?"/"+M(L):u(L));return j(O,G)}var k=/^\/(?:[^~]|~0|~1)*$/,T=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function R(O,L,z){var G,W,X,F;if(O==="")return"rootData";if(O[0]=="/"){if(!k.test(O))throw new Error("Invalid JSON-pointer: "+O);W=O,X="rootData"}else{if(F=O.match(T),!F)throw new Error("Invalid JSON-pointer: "+O);if(G=+F[1],W=F[2],W=="#"){if(G>=L)throw new Error("Cannot access property/index "+G+" levels up, current level is "+L);return z[L-G]}if(G>L)throw new Error("Cannot access data "+G+" levels up, current level is "+L);if(X="data"+(L-G||""),!W)return X}for(var Y=X,H=W.split("/"),te=0;te<H.length;te++){var P=H[te];P&&(X+=u(I(P)),Y+=" && "+X)}return Y}function j(O,L){return O=='""'?L:(O+" + "+L).replace(/([^\\])' \+ '/g,"$1")}function A(O){return I(decodeURIComponent(O))}function N(O){return encodeURIComponent(M(O))}function M(O){return O.replace(/~/g,"~0").replace(/\//g,"~1")}function I(O){return O.replace(/~1/g,"/").replace(/~0/g,"~")}return uE}var dE,bL;function Jq(){if(bL)return dE;bL=1;var t=nh();dE=e;function e(n){t.copy(n,this)}return dE}var fE={exports:{}},xL;function the(){if(xL)return fE.exports;xL=1;var t=fE.exports=function(r,s,i){typeof s=="function"&&(i=s,s={}),i=s.cb||i;var a=typeof i=="function"?i:i.pre||function(){},l=i.post||function(){};e(s,a,l,r,"",r)};t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function e(r,s,i,a,l,u,d,p,h,g){if(a&&typeof a=="object"&&!Array.isArray(a)){s(a,l,u,d,p,h,g);for(var v in a){var b=a[v];if(Array.isArray(b)){if(v in t.arrayKeywords)for(var x=0;x<b.length;x++)e(r,s,i,b[x],l+"/"+v+"/"+x,u,l,v,a,x)}else if(v in t.propsKeywords){if(b&&typeof b=="object")for(var E in b)e(r,s,i,b[E],l+"/"+v+"/"+n(E),u,l,v,a,E)}else(v in t.keywords||r.allKeys&&!(v in t.skipKeywords))&&e(r,s,i,b,l+"/"+v,u,l,v,a)}i(a,l,u,d,p,h,g)}}function n(r){return r.replace(/~/g,"~0").replace(/\//g,"~1")}return fE.exports}var hE,_L;function YN(){if(_L)return hE;_L=1;var t=Zfe(),e=WN(),n=nh(),r=Jq(),s=the();hE=i,i.normalizeId=S,i.fullPath=b,i.url=k,i.ids=T,i.inlineRef=h,i.schema=a;function i(R,j,A){var N=this._refs[A];if(typeof N=="string")if(this._refs[N])N=this._refs[N];else return i.call(this,R,j,N);if(N=N||this._schemas[A],N instanceof r)return h(N.schema,this._opts.inlineRefs)?N.schema:N.validate||this._compile(N);var M=a.call(this,j,A),I,O,L;return M&&(I=M.schema,j=M.root,L=M.baseId),I instanceof r?O=I.validate||R.call(this,I.schema,j,void 0,L):I!==void 0&&(O=h(I,this._opts.inlineRefs)?I:R.call(this,I,j,void 0,L)),O}function a(R,j){var A=t.parse(j),N=x(A),M=b(this._getId(R.schema));if(Object.keys(R.schema).length===0||N!==M){var I=S(N),O=this._refs[I];if(typeof O=="string")return l.call(this,R,O,A);if(O instanceof r)O.validate||this._compile(O),R=O;else if(O=this._schemas[I],O instanceof r){if(O.validate||this._compile(O),I==S(j))return{schema:O,root:R,baseId:M};R=O}else return;if(!R.schema)return;M=b(this._getId(R.schema))}return d.call(this,A,M,R.schema,R)}function l(R,j,A){var N=a.call(this,R,j);if(N){var M=N.schema,I=N.baseId;R=N.root;var O=this._getId(M);return O&&(I=k(I,O)),d.call(this,A,I,M,R)}}var u=n.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function d(R,j,A,N){if(R.fragment=R.fragment||"",R.fragment.slice(0,1)=="/"){for(var M=R.fragment.split("/"),I=1;I<M.length;I++){var O=M[I];if(O){if(O=n.unescapeFragment(O),A=A[O],A===void 0)break;var L;if(!u[O]&&(L=this._getId(A),L&&(j=k(j,L)),A.$ref)){var z=k(j,A.$ref),G=a.call(this,N,z);G&&(A=G.schema,N=G.root,j=G.baseId)}}}if(A!==void 0&&A!==N.schema)return{schema:A,root:N,baseId:j}}}var p=n.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function h(R,j){if(j===!1)return!1;if(j===void 0||j===!0)return g(R);if(j)return v(R)<=j}function g(R){var j;if(Array.isArray(R)){for(var A=0;A<R.length;A++)if(j=R[A],typeof j=="object"&&!g(j))return!1}else for(var N in R)if(N=="$ref"||(j=R[N],typeof j=="object"&&!g(j)))return!1;return!0}function v(R){var j=0,A;if(Array.isArray(R)){for(var N=0;N<R.length;N++)if(A=R[N],typeof A=="object"&&(j+=v(A)),j==1/0)return 1/0}else for(var M in R){if(M=="$ref")return 1/0;if(p[M])j++;else if(A=R[M],typeof A=="object"&&(j+=v(A)+1),j==1/0)return 1/0}return j}function b(R,j){j!==!1&&(R=S(R));var A=t.parse(R);return x(A)}function x(R){return t.serialize(R).split("#")[0]+"#"}var E=/#\/?$/;function S(R){return R?R.replace(E,""):""}function k(R,j){return j=S(j),t.resolve(R,j)}function T(R){var j=S(this._getId(R)),A={"":j},N={"":b(j,!1)},M={},I=this;return s(R,{allKeys:!0},function(O,L,z,G,W,X,F){if(L!==""){var Y=I._getId(O),H=A[G],te=N[G]+"/"+W;if(F!==void 0&&(te+="/"+(typeof F=="number"?F:n.escapeFragment(F))),typeof Y=="string"){Y=H=S(H?t.resolve(H,Y):Y);var P=I._refs[Y];if(typeof P=="string"&&(P=I._refs[P]),P&&P.schema){if(!e(O,P.schema))throw new Error('id "'+Y+'" resolves to more than one schema')}else if(Y!=S(te))if(Y[0]=="#"){if(M[Y]&&!e(O,M[Y]))throw new Error('id "'+Y+'" resolves to more than one schema');M[Y]=O}else I._refs[Y]=te}A[L]=H,N[L]=te}}),M}return hE}var pE,wL;function KN(){if(wL)return pE;wL=1;var t=YN();pE={Validation:r(e),MissingRef:r(n)};function e(s){this.message="validation failed",this.errors=s,this.ajv=this.validation=!0}n.message=function(s,i){return"can't resolve reference "+i+" from id "+s};function n(s,i,a){this.message=a||n.message(s,i),this.missingRef=t.url(s,i),this.missingSchema=t.normalizeId(t.fullPath(this.missingRef))}function r(s){return s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s}return pE}var mE,SL;function Zq(){return SL||(SL=1,mE=function(t,e){e||(e={}),typeof e=="function"&&(e={cmp:e});var n=typeof e.cycles=="boolean"?e.cycles:!1,r=e.cmp&&function(i){return function(a){return function(l,u){var d={key:l,value:a[l]},p={key:u,value:a[u]};return i(d,p)}}}(e.cmp),s=[];return function i(a){if(a&&a.toJSON&&typeof a.toJSON=="function"&&(a=a.toJSON()),a!==void 0){if(typeof a=="number")return isFinite(a)?""+a:"null";if(typeof a!="object")return JSON.stringify(a);var l,u;if(Array.isArray(a)){for(u="[",l=0;l<a.length;l++)l&&(u+=","),u+=i(a[l])||"null";return u+"]"}if(a===null)return"null";if(s.indexOf(a)!==-1){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var d=s.push(a)-1,p=Object.keys(a).sort(r&&r(a));for(u="",l=0;l<p.length;l++){var h=p[l],g=i(a[h]);g&&(u&&(u+=","),u+=JSON.stringify(h)+":"+g)}return s.splice(d,1),"{"+u+"}"}}(t)}),mE}var gE,EL;function eV(){return EL||(EL=1,gE=function(e,n,r){var s="",i=e.schema.$async===!0,a=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),l=e.self._getId(e.schema);if(e.opts.strictKeywords){var u=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(u){var d="unknown keyword: "+u;if(e.opts.strictKeywords==="log")e.logger.warn(d);else throw new Error(d)}}if(e.isTop&&(s+=" var validate = ",i&&(e.async=!0,s+="async "),s+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",l&&(e.opts.sourceCode||e.opts.processCode)&&(s+=" "+("/*# sourceURL="+l+" */")+" ")),typeof e.schema=="boolean"||!(a||e.schema.$ref)){var n="false schema",p=e.level,h=e.dataLevel,g=e.schema[n],v=e.schemaPath+e.util.getProperty(n),b=e.errSchemaPath+"/"+n,j=!e.opts.allErrors,M,x="data"+(h||""),R="valid"+p;if(e.schema===!1){e.isTop?j=!0:s+=" var "+R+" = false; ";var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"false schema")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'boolean schema is false' "),e.opts.verbose&&(s+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?i?s+=" return data; ":s+=" validate.errors = null; return true; ":s+=" var "+R+" = true; ";return e.isTop&&(s+=" }; return validate; "),s}if(e.isTop){var k=e.isTop,p=e.level=0,h=e.dataLevel=0,x="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],e.schema.default!==void 0&&e.opts.useDefaults&&e.opts.strictDefaults){var T="default is ignored in the schema root";if(e.opts.strictDefaults==="log")e.logger.warn(T);else throw new Error(T)}s+=" var vErrors = null; ",s+=" var errors = 0; ",s+=" if (rootData === undefined) rootData = data; "}else{var p=e.level,h=e.dataLevel,x="data"+(h||"");if(l&&(e.baseId=e.resolve.url(e.baseId,l)),i&&!e.async)throw new Error("async schema in sync schema");s+=" var errs_"+p+" = errors;"}var R="valid"+p,j=!e.opts.allErrors,A="",N="",M,I=e.schema.type,O=Array.isArray(I);if(I&&e.opts.nullable&&e.schema.nullable===!0&&(O?I.indexOf("null")==-1&&(I=I.concat("null")):I!="null"&&(I=[I,"null"],O=!0)),O&&I.length==1&&(I=I[0],O=!1),e.schema.$ref&&a){if(e.opts.extendRefs=="fail")throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');e.opts.extendRefs!==!0&&(a=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(s+=" "+e.RULES.all.$comment.code(e,"$comment")),I){if(e.opts.coerceTypes)var L=e.util.coerceToTypes(e.opts.coerceTypes,I);var z=e.RULES.types[I];if(L||O||z===!0||z&&!dt(z)){var v=e.schemaPath+".type",b=e.errSchemaPath+"/type",v=e.schemaPath+".type",b=e.errSchemaPath+"/type",G=O?"checkDataTypes":"checkDataType";if(s+=" if ("+e.util[G](I,x,e.opts.strictNumbers,!0)+") { ",L){var W="dataType"+p,X="coerced"+p;s+=" var "+W+" = typeof "+x+"; var "+X+" = undefined; ",e.opts.coerceTypes=="array"&&(s+=" if ("+W+" == 'object' && Array.isArray("+x+") && "+x+".length == 1) { "+x+" = "+x+"[0]; "+W+" = typeof "+x+"; if ("+e.util.checkDataType(e.schema.type,x,e.opts.strictNumbers)+") "+X+" = "+x+"; } "),s+=" if ("+X+" !== undefined) ; ";var F=L;if(F)for(var Y,H=-1,te=F.length-1;H<te;)Y=F[H+=1],Y=="string"?s+=" else if ("+W+" == 'number' || "+W+" == 'boolean') "+X+" = '' + "+x+"; else if ("+x+" === null) "+X+" = ''; ":Y=="number"||Y=="integer"?(s+=" else if ("+W+" == 'boolean' || "+x+" === null || ("+W+" == 'string' && "+x+" && "+x+" == +"+x+" ",Y=="integer"&&(s+=" && !("+x+" % 1)"),s+=")) "+X+" = +"+x+"; "):Y=="boolean"?s+=" else if ("+x+" === 'false' || "+x+" === 0 || "+x+" === null) "+X+" = false; else if ("+x+" === 'true' || "+x+" === 1) "+X+" = true; ":Y=="null"?s+=" else if ("+x+" === '' || "+x+" === 0 || "+x+" === false) "+X+" = null; ":e.opts.coerceTypes=="array"&&Y=="array"&&(s+=" else if ("+W+" == 'string' || "+W+" == 'number' || "+W+" == 'boolean' || "+x+" == null) "+X+" = ["+x+"]; ");s+=" else { ";var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: { type: '",O?s+=""+I.join(","):s+=""+I,s+="' } ",e.opts.messages!==!1&&(s+=" , message: 'should be ",O?s+=""+I.join(","):s+=""+I,s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+v+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } if ("+X+" !== undefined) { ";var P=h?"data"+(h-1||""):"parentData",re=h?e.dataPathArr[h]:"parentDataProperty";s+=" "+x+" = "+X+"; ",h||(s+="if ("+P+" !== undefined)"),s+=" "+P+"["+re+"] = "+X+"; } "}else{var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: { type: '",O?s+=""+I.join(","):s+=""+I,s+="' } ",e.opts.messages!==!1&&(s+=" , message: 'should be ",O?s+=""+I.join(","):s+=""+I,s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+v+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}s+=" } "}}if(e.schema.$ref&&!a)s+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",j&&(s+=" } if (errors === ",k?s+="0":s+="errs_"+p,s+=") { ",N+="}");else{var ue=e.RULES;if(ue){for(var z,D=-1,Z=ue.length-1;D<Z;)if(z=ue[D+=1],dt(z)){if(z.type&&(s+=" if ("+e.util.checkDataType(z.type,x,e.opts.strictNumbers)+") { "),e.opts.useDefaults){if(z.type=="object"&&e.schema.properties){var g=e.schema.properties,he=Object.keys(g),V=he;if(V)for(var U,K=-1,ae=V.length-1;K<ae;){U=V[K+=1];var B=g[U];if(B.default!==void 0){var J=x+e.util.getProperty(U);if(e.compositeRule){if(e.opts.strictDefaults){var T="default is ignored for: "+J;if(e.opts.strictDefaults==="log")e.logger.warn(T);else throw new Error(T)}}else s+=" if ("+J+" === undefined ",e.opts.useDefaults=="empty"&&(s+=" || "+J+" === null || "+J+" === '' "),s+=" ) "+J+" = ",e.opts.useDefaults=="shared"?s+=" "+e.useDefault(B.default)+" ":s+=" "+JSON.stringify(B.default)+" ",s+="; "}}}else if(z.type=="array"&&Array.isArray(e.schema.items)){var oe=e.schema.items;if(oe){for(var B,H=-1,fe=oe.length-1;H<fe;)if(B=oe[H+=1],B.default!==void 0){var J=x+"["+H+"]";if(e.compositeRule){if(e.opts.strictDefaults){var T="default is ignored for: "+J;if(e.opts.strictDefaults==="log")e.logger.warn(T);else throw new Error(T)}}else s+=" if ("+J+" === undefined ",e.opts.useDefaults=="empty"&&(s+=" || "+J+" === null || "+J+" === '' "),s+=" ) "+J+" = ",e.opts.useDefaults=="shared"?s+=" "+e.useDefault(B.default)+" ":s+=" "+JSON.stringify(B.default)+" ",s+="; "}}}}var be=z.rules;if(be){for(var Ae,Oe=-1,Ne=be.length-1;Oe<Ne;)if(Ae=be[Oe+=1],Be(Ae)){var Qe=Ae.code(e,Ae.keyword,z.type);Qe&&(s+=" "+Qe+" ",j&&(A+="}"))}}if(j&&(s+=" "+A+" ",A=""),z.type&&(s+=" } ",I&&I===z.type&&!L)){s+=" else { ";var v=e.schemaPath+".type",b=e.errSchemaPath+"/type",E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: { type: '",O?s+=""+I.join(","):s+=""+I,s+="' } ",e.opts.messages!==!1&&(s+=" , message: 'should be ",O?s+=""+I.join(","):s+=""+I,s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+v+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } "}j&&(s+=" if (errors === ",k?s+="0":s+="errs_"+p,s+=") { ",N+="}")}}}j&&(s+=" "+N+" "),k?(i?(s+=" if (errors === 0) return data; ",s+=" else throw new ValidationError(vErrors); "):(s+=" validate.errors = vErrors; ",s+=" return errors === 0; "),s+=" }; return validate;"):s+=" var "+R+" = errors === errs_"+p+";";function dt(De){for(var et=De.rules,ot=0;ot<et.length;ot++)if(Be(et[ot]))return!0}function Be(De){return e.schema[De.keyword]!==void 0||De.implements&&pt(De)}function pt(De){for(var et=De.implements,ot=0;ot<et.length;ot++)if(e.schema[et[ot]]!==void 0)return!0}return s}),gE}var vE,kL;function nhe(){if(kL)return vE;kL=1;var t=YN(),e=nh(),n=KN(),r=Zq(),s=eV(),i=e.ucs2length,a=WN(),l=n.Validation;vE=u;function u(S,k,T,R){var j=this,A=this._opts,N=[void 0],M={},I=[],O={},L=[],z={},G=[];k=k||{schema:S,refVal:N,refs:M};var W=d.call(this,S,k,R),X=this._compilations[W.index];if(W.compiling)return X.callValidate=P;var F=this._formats,Y=this.RULES;try{var H=re(S,k,T,R);X.validate=H;var te=X.callValidate;return te&&(te.schema=H.schema,te.errors=null,te.refs=H.refs,te.refVal=H.refVal,te.root=H.root,te.$async=H.$async,A.sourceCode&&(te.source=H.source)),H}finally{p.call(this,S,k,R)}function P(){var B=X.validate,J=B.apply(this,arguments);return P.errors=B.errors,J}function re(B,J,oe,fe){var be=!J||J&&J.schema==B;if(J.schema!=k.schema)return u.call(j,B,J,oe,fe);var Ae=B.$async===!0,Oe=s({isTop:!0,schema:B,isRoot:be,baseId:fe,root:J,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:n.MissingRef,RULES:Y,validate:s,util:e,resolve:t,resolveRef:ue,usePattern:U,useDefault:K,useCustomRule:ae,opts:A,formats:F,logger:j.logger,self:j});Oe=E(N,b)+E(I,g)+E(L,v)+E(G,x)+Oe,A.processCode&&(Oe=A.processCode(Oe,B));var Ne;try{var Qe=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",Oe);Ne=Qe(j,Y,F,k,N,L,G,a,i,l),N[0]=Ne}catch(dt){throw j.logger.error("Error compiling schema, function code:",Oe),dt}return Ne.schema=B,Ne.errors=null,Ne.refs=M,Ne.refVal=N,Ne.root=be?Ne:J,Ae&&(Ne.$async=!0),A.sourceCode===!0&&(Ne.source={code:Oe,patterns:I,defaults:L}),Ne}function ue(B,J,oe){J=t.url(B,J);var fe=M[J],be,Ae;if(fe!==void 0)return be=N[fe],Ae="refVal["+fe+"]",V(be,Ae);if(!oe&&k.refs){var Oe=k.refs[J];if(Oe!==void 0)return be=k.refVal[Oe],Ae=D(J,be),V(be,Ae)}Ae=D(J);var Ne=t.call(j,re,k,J);if(Ne===void 0){var Qe=T&&T[J];Qe&&(Ne=t.inlineRef(Qe,A.inlineRefs)?Qe:u.call(j,Qe,k,T,B))}if(Ne===void 0)Z(J);else return he(J,Ne),V(Ne,Ae)}function D(B,J){var oe=N.length;return N[oe]=J,M[B]=oe,"refVal"+oe}function Z(B){delete M[B]}function he(B,J){var oe=M[B];N[oe]=J}function V(B,J){return typeof B=="object"||typeof B=="boolean"?{code:J,schema:B,inline:!0}:{code:J,$async:B&&!!B.$async}}function U(B){var J=O[B];return J===void 0&&(J=O[B]=I.length,I[J]=B),"pattern"+J}function K(B){switch(typeof B){case"boolean":case"number":return""+B;case"string":return e.toQuotedString(B);case"object":if(B===null)return"null";var J=r(B),oe=z[J];return oe===void 0&&(oe=z[J]=L.length,L[oe]=B),"default"+oe}}function ae(B,J,oe,fe){if(j._opts.validateSchema!==!1){var be=B.definition.dependencies;if(be&&!be.every(function(et){return Object.prototype.hasOwnProperty.call(oe,et)}))throw new Error("parent schema must have all required keywords: "+be.join(","));var Ae=B.definition.validateSchema;if(Ae){var Oe=Ae(J);if(!Oe){var Ne="keyword schema is invalid: "+j.errorsText(Ae.errors);if(j._opts.validateSchema=="log")j.logger.error(Ne);else throw new Error(Ne)}}}var Qe=B.definition.compile,dt=B.definition.inline,Be=B.definition.macro,pt;if(Qe)pt=Qe.call(j,J,oe,fe);else if(Be)pt=Be.call(j,J,oe,fe),A.validateSchema!==!1&&j.validateSchema(pt,!0);else if(dt)pt=dt.call(j,fe,B.keyword,J,oe);else if(pt=B.definition.validate,!pt)return;if(pt===void 0)throw new Error('custom keyword "'+B.keyword+'"failed to compile');var De=G.length;return G[De]=pt,{code:"customRule"+De,validate:pt}}}function d(S,k,T){var R=h.call(this,S,k,T);return R>=0?{index:R,compiling:!0}:(R=this._compilations.length,this._compilations[R]={schema:S,root:k,baseId:T},{index:R,compiling:!1})}function p(S,k,T){var R=h.call(this,S,k,T);R>=0&&this._compilations.splice(R,1)}function h(S,k,T){for(var R=0;R<this._compilations.length;R++){var j=this._compilations[R];if(j.schema==S&&j.root==k&&j.baseId==T)return R}return-1}function g(S,k){return"var pattern"+S+" = new RegExp("+e.toQuotedString(k[S])+");"}function v(S){return"var default"+S+" = defaults["+S+"];"}function b(S,k){return k[S]===void 0?"":"var refVal"+S+" = refVal["+S+"];"}function x(S){return"var customRule"+S+" = customRules["+S+"];"}function E(S,k){if(!S.length)return"";for(var T="",R=0;R<S.length;R++)T+=k(R,S);return T}return vE}var yE={exports:{}},TL;function rhe(){if(TL)return yE.exports;TL=1;var t=yE.exports=function(){this._cache={}};return t.prototype.put=function(n,r){this._cache[n]=r},t.prototype.get=function(n){return this._cache[n]},t.prototype.del=function(n){delete this._cache[n]},t.prototype.clear=function(){this._cache={}},yE.exports}var bE,CL;function she(){if(CL)return bE;CL=1;var t=nh(),e=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31],r=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,s=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,i=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,a=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,l=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,u=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,d=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,p=/^(?:\/(?:[^~/]|~0|~1)*)*$/,h=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,g=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;bE=v;function v(N){return N=N=="full"?"full":"fast",t.copy(v[N])}v.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":l,url:u,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:s,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:A,uuid:d,"json-pointer":p,"json-pointer-uri-fragment":h,"relative-json-pointer":g},v.full={date:x,time:E,"date-time":k,uri:R,"uri-reference":a,"uri-template":l,url:u,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:s,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:A,uuid:d,"json-pointer":p,"json-pointer-uri-fragment":h,"relative-json-pointer":g};function b(N){return N%4===0&&(N%100!==0||N%400===0)}function x(N){var M=N.match(e);if(!M)return!1;var I=+M[1],O=+M[2],L=+M[3];return O>=1&&O<=12&&L>=1&&L<=(O==2&&b(I)?29:n[O])}function E(N,M){var I=N.match(r);if(!I)return!1;var O=I[1],L=I[2],z=I[3],G=I[5];return(O<=23&&L<=59&&z<=59||O==23&&L==59&&z==60)&&(!M||G)}var S=/t|\s/i;function k(N){var M=N.split(S);return M.length==2&&x(M[0])&&E(M[1],!0)}var T=/\/|:/;function R(N){return T.test(N)&&i.test(N)}var j=/[^\\]\\Z/;function A(N){if(j.test(N))return!1;try{return new RegExp(N),!0}catch{return!1}}return bE}var xE,AL;function ihe(){return AL||(AL=1,xE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.errSchemaPath+"/"+n,d=!e.opts.allErrors,p="data"+(a||""),h="valid"+i,g,v;if(l=="#"||l=="#/")e.isRoot?(g=e.async,v="validate"):(g=e.root.schema.$async===!0,v="root.refVal[0]");else{var b=e.resolveRef(e.baseId,l,e.isRoot);if(b===void 0){var x=e.MissingRefError.message(e.baseId,l);if(e.opts.missingRefs=="fail"){e.logger.error(x);var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { ref: '"+e.util.escapeQuotes(l)+"' } ",e.opts.messages!==!1&&(s+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(l)+"' "),e.opts.verbose&&(s+=" , schema: "+e.util.toQuotedString(l)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d&&(s+=" if (false) { ")}else if(e.opts.missingRefs=="ignore")e.logger.warn(x),d&&(s+=" if (true) { ");else throw new e.MissingRefError(e.baseId,l,x)}else if(b.inline){var k=e.util.copy(e);k.level++;var T="valid"+k.level;k.schema=b.schema,k.schemaPath="",k.errSchemaPath=l;var R=e.validate(k).replace(/validate\.schema/g,b.code);s+=" "+R+" ",d&&(s+=" if ("+T+") { ")}else g=b.$async===!0||e.async&&b.$async!==!1,v=b.code}if(v){var E=E||[];E.push(s),s="",e.opts.passContext?s+=" "+v+".call(this, ":s+=" "+v+"( ",s+=" "+p+", (dataPath || '')",e.errorPath!='""'&&(s+=" + "+e.errorPath);var j=a?"data"+(a-1||""):"parentData",A=a?e.dataPathArr[a]:"parentDataProperty";s+=" , "+j+" , "+A+", rootData) ";var N=s;if(s=E.pop(),g){if(!e.async)throw new Error("async schema referenced by sync schema");d&&(s+=" var "+h+"; "),s+=" try { await "+N+"; ",d&&(s+=" "+h+" = true; "),s+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",d&&(s+=" "+h+" = false; "),s+=" } ",d&&(s+=" if ("+h+") { ")}else s+=" if (!"+N+") { if (vErrors === null) vErrors = "+v+".errors; else vErrors = vErrors.concat("+v+".errors); errors = vErrors.length; } ",d&&(s+=" else { ")}return s}),xE}var _E,NL;function ahe(){return NL||(NL=1,_E=function(e,n,r){var s=" ",i=e.schema[n],a=e.schemaPath+e.util.getProperty(n),l=e.errSchemaPath+"/"+n,u=!e.opts.allErrors,d=e.util.copy(e),p="";d.level++;var h="valid"+d.level,g=d.baseId,v=!0,b=i;if(b)for(var x,E=-1,S=b.length-1;E<S;)x=b[E+=1],(e.opts.strictKeywords?typeof x=="object"&&Object.keys(x).length>0||x===!1:e.util.schemaHasRules(x,e.RULES.all))&&(v=!1,d.schema=x,d.schemaPath=a+"["+E+"]",d.errSchemaPath=l+"/"+E,s+=" "+e.validate(d)+" ",d.baseId=g,u&&(s+=" if ("+h+") { ",p+="}"));return u&&(v?s+=" if (true) { ":s+=" "+p.slice(0,-1)+" "),s}),_E}var wE,RL;function ohe(){return RL||(RL=1,wE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S=l.every(function(M){return e.opts.strictKeywords?typeof M=="object"&&Object.keys(M).length>0||M===!1:e.util.schemaHasRules(M,e.RULES.all)});if(S){var k=b.baseId;s+=" var "+v+" = errors; var "+g+" = false; ";var T=e.compositeRule;e.compositeRule=b.compositeRule=!0;var R=l;if(R)for(var j,A=-1,N=R.length-1;A<N;)j=R[A+=1],b.schema=j,b.schemaPath=u+"["+A+"]",b.errSchemaPath=d+"/"+A,s+=" "+e.validate(b)+" ",b.baseId=k,s+=" "+g+" = "+g+" || "+E+"; if (!"+g+") { ",x+="}";e.compositeRule=b.compositeRule=T,s+=" "+x+" if (!"+g+") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),s+=" } else { errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; } ",e.opts.allErrors&&(s+=" } ")}else p&&(s+=" if (true) { ");return s}),wE}var SE,jL;function lhe(){return jL||(jL=1,SE=function(e,n,r){var s=" ",i=e.schema[n],a=e.errSchemaPath+"/"+n;e.opts.allErrors;var l=e.util.toQuotedString(i);return e.opts.$comment===!0?s+=" console.log("+l+");":typeof e.opts.$comment=="function"&&(s+=" self._opts.$comment("+l+", "+e.util.toQuotedString(a)+", validate.root.schema);"),s}),SE}var EE,ML;function che(){return ML||(ML=1,EE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data;v&&(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; "),v||(s+=" var schema"+i+" = validate.schema"+u+";"),s+="var "+g+" = equal("+h+", schema"+i+"); if (!"+g+") { ";var b=b||[];b.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { allowedValue: schema"+i+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be equal to constant' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var x=s;return s=b.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+x+"]); ":s+=" validate.errors = ["+x+"]; return false; ":s+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" }",p&&(s+=" else { "),s}),EE}var kE,OL;function uhe(){return OL||(OL=1,kE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S="i"+i,k=b.dataLevel=e.dataLevel+1,T="data"+k,R=e.baseId,j=e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all);if(s+="var "+v+" = errors;var "+g+";",j){var A=e.compositeRule;e.compositeRule=b.compositeRule=!0,b.schema=l,b.schemaPath=u,b.errSchemaPath=d,s+=" var "+E+" = false; for (var "+S+" = 0; "+S+" < "+h+".length; "+S+"++) { ",b.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0);var N=h+"["+S+"]";b.dataPathArr[k]=S;var M=e.validate(b);b.baseId=R,e.util.varOccurences(M,T)<2?s+=" "+e.util.varReplace(M,T,N)+" ":s+=" var "+T+" = "+N+"; "+M+" ",s+=" if ("+E+") break; } ",e.compositeRule=b.compositeRule=A,s+=" "+x+" if (!"+E+") {"}else s+=" if ("+h+".length == 0) {";var I=I||[];I.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should contain a valid item' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var O=s;return s=I.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+O+"]); ":s+=" validate.errors = ["+O+"]; return false; ":s+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { ",j&&(s+=" errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; } "),e.opts.allErrors&&(s+=" } "),s}),kE}var TE,PL;function dhe(){return PL||(PL=1,TE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e),b="";v.level++;var x="valid"+v.level,E={},S={},k=e.opts.ownProperties;for(A in l)if(A!="__proto__"){var T=l[A],R=Array.isArray(T)?S:E;R[A]=T}s+="var "+g+" = errors;";var j=e.errorPath;s+="var missing"+i+";";for(var A in S)if(R=S[A],R.length){if(s+=" if ( "+h+e.util.getProperty(A)+" !== undefined ",k&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(A)+"') "),p){s+=" && ( ";var N=R;if(N)for(var M,I=-1,O=N.length-1;I<O;){M=N[I+=1],I&&(s+=" || ");var L=e.util.getProperty(M),z=h+L;s+=" ( ( "+z+" === undefined ",k&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(M)+"') "),s+=") && (missing"+i+" = "+e.util.toQuotedString(e.opts.jsonPointers?M:L)+") ) "}s+=")) { ";var G="missing"+i,W="' + "+G+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(j,G,!0):j+" + "+G);var X=X||[];X.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { property: '"+e.util.escapeQuotes(A)+"', missingProperty: '"+W+"', depsCount: "+R.length+", deps: '"+e.util.escapeQuotes(R.length==1?R[0]:R.join(", "))+"' } ",e.opts.messages!==!1&&(s+=" , message: 'should have ",R.length==1?s+="property "+e.util.escapeQuotes(R[0]):s+="properties "+e.util.escapeQuotes(R.join(", ")),s+=" when property "+e.util.escapeQuotes(A)+" is present' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var F=s;s=X.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+F+"]); ":s+=" validate.errors = ["+F+"]; return false; ":s+=" var err = "+F+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{s+=" ) { ";var Y=R;if(Y)for(var M,H=-1,te=Y.length-1;H<te;){M=Y[H+=1];var L=e.util.getProperty(M),W=e.util.escapeQuotes(M),z=h+L;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(j,M,e.opts.jsonPointers)),s+=" if ( "+z+" === undefined ",k&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(M)+"') "),s+=") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { property: '"+e.util.escapeQuotes(A)+"', missingProperty: '"+W+"', depsCount: "+R.length+", deps: '"+e.util.escapeQuotes(R.length==1?R[0]:R.join(", "))+"' } ",e.opts.messages!==!1&&(s+=" , message: 'should have ",R.length==1?s+="property "+e.util.escapeQuotes(R[0]):s+="properties "+e.util.escapeQuotes(R.join(", ")),s+=" when property "+e.util.escapeQuotes(A)+" is present' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}s+=" } ",p&&(b+="}",s+=" else { ")}e.errorPath=j;var P=v.baseId;for(var A in E){var T=E[A];(e.opts.strictKeywords?typeof T=="object"&&Object.keys(T).length>0||T===!1:e.util.schemaHasRules(T,e.RULES.all))&&(s+=" "+x+" = true; if ( "+h+e.util.getProperty(A)+" !== undefined ",k&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(A)+"') "),s+=") { ",v.schema=T,v.schemaPath=u+e.util.getProperty(A),v.errSchemaPath=d+"/"+e.util.escapeFragment(A),s+=" "+e.validate(v)+" ",v.baseId=P,s+=" } ",p&&(s+=" if ("+x+") { ",b+="}"))}return p&&(s+=" "+b+" if ("+g+" == errors) {"),s}),TE}var CE,IL;function fhe(){return IL||(IL=1,CE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data;v&&(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ");var b="i"+i,x="schema"+i;v||(s+=" var "+x+" = validate.schema"+u+";"),s+="var "+g+";",v&&(s+=" if (schema"+i+" === undefined) "+g+" = true; else if (!Array.isArray(schema"+i+")) "+g+" = false; else {"),s+=""+g+" = false;for (var "+b+"=0; "+b+"<"+x+".length; "+b+"++) if (equal("+h+", "+x+"["+b+"])) { "+g+" = true; break; }",v&&(s+=" } "),s+=" if (!"+g+") { ";var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { allowedValues: schema"+i+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" }",p&&(s+=" else { "),s}),CE}var AE,DL;function hhe(){return DL||(DL=1,AE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||"");if(e.opts.format===!1)return p&&(s+=" if (true) { "),s;var g=e.opts.$data&&l&&l.$data,v;g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l;var b=e.opts.unknownFormats,x=Array.isArray(b);if(g){var E="format"+i,S="isObject"+i,k="formatType"+i;s+=" var "+E+" = formats["+v+"]; var "+S+" = typeof "+E+" == 'object' && !("+E+" instanceof RegExp) && "+E+".validate; var "+k+" = "+S+" && "+E+".type || 'string'; if ("+S+") { ",e.async&&(s+=" var async"+i+" = "+E+".async; "),s+=" "+E+" = "+E+".validate; } if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'string') || "),s+=" (",b!="ignore"&&(s+=" ("+v+" && !"+E+" ",x&&(s+=" && self._opts.unknownFormats.indexOf("+v+") == -1 "),s+=") || "),s+=" ("+E+" && "+k+" == '"+r+"' && !(typeof "+E+" == 'function' ? ",e.async?s+=" (async"+i+" ? await "+E+"("+h+") : "+E+"("+h+")) ":s+=" "+E+"("+h+") ",s+=" : "+E+".test("+h+"))))) {"}else{var E=e.formats[l];if(!E){if(b=="ignore")return e.logger.warn('unknown format "'+l+'" ignored in schema at path "'+e.errSchemaPath+'"'),p&&(s+=" if (true) { "),s;if(x&&b.indexOf(l)>=0)return p&&(s+=" if (true) { "),s;throw new Error('unknown format "'+l+'" is used in schema at path "'+e.errSchemaPath+'"')}var S=typeof E=="object"&&!(E instanceof RegExp)&&E.validate,k=S&&E.type||"string";if(S){var T=E.async===!0;E=E.validate}if(k!=r)return p&&(s+=" if (true) { "),s;if(T){if(!e.async)throw new Error("async format in sync schema");var R="formats"+e.util.getProperty(l)+".validate";s+=" if (!(await "+R+"("+h+"))) { "}else{s+=" if (! ";var R="formats"+e.util.getProperty(l);S&&(R+=".validate"),typeof E=="function"?s+=" "+R+"("+h+") ":s+=" "+R+".test("+h+") ",s+=") { "}}var j=j||[];j.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { format: ",g?s+=""+v:s+=""+e.util.toQuotedString(l),s+=" } ",e.opts.messages!==!1&&(s+=` , message: 'should match format "`,g?s+="' + "+v+" + '":s+=""+e.util.escapeQuotes(l),s+=`"' `),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+e.util.toQuotedString(l),s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var A=s;return s=j.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+A+"]); ":s+=" validate.errors = ["+A+"]; return false; ":s+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",p&&(s+=" else { "),s}),AE}var NE,LL;function phe(){return LL||(LL=1,NE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e);b.level++;var x="valid"+b.level,E=e.schema.then,S=e.schema.else,k=E!==void 0&&(e.opts.strictKeywords?typeof E=="object"&&Object.keys(E).length>0||E===!1:e.util.schemaHasRules(E,e.RULES.all)),T=S!==void 0&&(e.opts.strictKeywords?typeof S=="object"&&Object.keys(S).length>0||S===!1:e.util.schemaHasRules(S,e.RULES.all)),R=b.baseId;if(k||T){var j;b.createErrors=!1,b.schema=l,b.schemaPath=u,b.errSchemaPath=d,s+=" var "+v+" = errors; var "+g+" = true; ";var A=e.compositeRule;e.compositeRule=b.compositeRule=!0,s+=" "+e.validate(b)+" ",b.baseId=R,b.createErrors=!0,s+=" errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; } ",e.compositeRule=b.compositeRule=A,k?(s+=" if ("+x+") { ",b.schema=e.schema.then,b.schemaPath=e.schemaPath+".then",b.errSchemaPath=e.errSchemaPath+"/then",s+=" "+e.validate(b)+" ",b.baseId=R,s+=" "+g+" = "+x+"; ",k&&T?(j="ifClause"+i,s+=" var "+j+" = 'then'; "):j="'then'",s+=" } ",T&&(s+=" else { ")):s+=" if (!"+x+") { ",T&&(b.schema=e.schema.else,b.schemaPath=e.schemaPath+".else",b.errSchemaPath=e.errSchemaPath+"/else",s+=" "+e.validate(b)+" ",b.baseId=R,s+=" "+g+" = "+x+"; ",k&&T?(j="ifClause"+i,s+=" var "+j+" = 'else'; "):j="'else'",s+=" } "),s+=" if (!"+g+") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { failingKeyword: "+j+" } ",e.opts.messages!==!1&&(s+=` , message: 'should match "' + `+j+` + '" schema' `),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),s+=" } ",p&&(s+=" else { ")}else p&&(s+=" if (true) { ");return s}),NE}var RE,$L;function mhe(){return $L||($L=1,RE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S="i"+i,k=b.dataLevel=e.dataLevel+1,T="data"+k,R=e.baseId;if(s+="var "+v+" = errors;var "+g+";",Array.isArray(l)){var j=e.schema.additionalItems;if(j===!1){s+=" "+g+" = "+h+".length <= "+l.length+"; ";var A=d;d=e.errSchemaPath+"/additionalItems",s+=" if (!"+g+") { ";var N=N||[];N.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+l.length+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have more than "+l.length+" items' "),e.opts.verbose&&(s+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var M=s;s=N.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+M+"]); ":s+=" validate.errors = ["+M+"]; return false; ":s+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",d=A,p&&(x+="}",s+=" else { ")}var I=l;if(I){for(var O,L=-1,z=I.length-1;L<z;)if(O=I[L+=1],e.opts.strictKeywords?typeof O=="object"&&Object.keys(O).length>0||O===!1:e.util.schemaHasRules(O,e.RULES.all)){s+=" "+E+" = true; if ("+h+".length > "+L+") { ";var G=h+"["+L+"]";b.schema=O,b.schemaPath=u+"["+L+"]",b.errSchemaPath=d+"/"+L,b.errorPath=e.util.getPathExpr(e.errorPath,L,e.opts.jsonPointers,!0),b.dataPathArr[k]=L;var W=e.validate(b);b.baseId=R,e.util.varOccurences(W,T)<2?s+=" "+e.util.varReplace(W,T,G)+" ":s+=" var "+T+" = "+G+"; "+W+" ",s+=" } ",p&&(s+=" if ("+E+") { ",x+="}")}}if(typeof j=="object"&&(e.opts.strictKeywords?typeof j=="object"&&Object.keys(j).length>0||j===!1:e.util.schemaHasRules(j,e.RULES.all))){b.schema=j,b.schemaPath=e.schemaPath+".additionalItems",b.errSchemaPath=e.errSchemaPath+"/additionalItems",s+=" "+E+" = true; if ("+h+".length > "+l.length+") { for (var "+S+" = "+l.length+"; "+S+" < "+h+".length; "+S+"++) { ",b.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0);var G=h+"["+S+"]";b.dataPathArr[k]=S;var W=e.validate(b);b.baseId=R,e.util.varOccurences(W,T)<2?s+=" "+e.util.varReplace(W,T,G)+" ":s+=" var "+T+" = "+G+"; "+W+" ",p&&(s+=" if (!"+E+") break; "),s+=" } } ",p&&(s+=" if ("+E+") { ",x+="}")}}else if(e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all)){b.schema=l,b.schemaPath=u,b.errSchemaPath=d,s+=" for (var "+S+" = 0; "+S+" < "+h+".length; "+S+"++) { ",b.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0);var G=h+"["+S+"]";b.dataPathArr[k]=S;var W=e.validate(b);b.baseId=R,e.util.varOccurences(W,T)<2?s+=" "+e.util.varReplace(W,T,G)+" ":s+=" var "+T+" = "+G+"; "+W+" ",p&&(s+=" if (!"+E+") break; "),s+=" }"}return p&&(s+=" "+x+" if ("+v+" == errors) {"),s}),RE}var jE,zL;function FL(){return zL||(zL=1,jE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,R,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l;var b=n=="maximum",x=b?"exclusiveMaximum":"exclusiveMinimum",E=e.schema[x],S=e.opts.$data&&E&&E.$data,k=b?"<":">",T=b?">":"<",R=void 0;if(!(g||typeof l=="number"||l===void 0))throw new Error(n+" must be number");if(!(S||E===void 0||typeof E=="number"||typeof E=="boolean"))throw new Error(x+" must be number or boolean");if(S){var j=e.util.getData(E.$data,a,e.dataPathArr),A="exclusive"+i,N="exclType"+i,M="exclIsNumber"+i,I="op"+i,O="' + "+I+" + '";s+=" var schemaExcl"+i+" = "+j+"; ",j="schemaExcl"+i,s+=" var "+A+"; var "+N+" = typeof "+j+"; if ("+N+" != 'boolean' && "+N+" != 'undefined' && "+N+" != 'number') { ";var R=x,L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(R||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: '"+x+" should be boolean' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" "+N+" == 'number' ? ( ("+A+" = "+v+" === undefined || "+j+" "+k+"= "+v+") ? "+h+" "+T+"= "+j+" : "+h+" "+T+" "+v+" ) : ( ("+A+" = "+j+" === true) ? "+h+" "+T+"= "+v+" : "+h+" "+T+" "+v+" ) || "+h+" !== "+h+") { var op"+i+" = "+A+" ? '"+k+"' : '"+k+"='; ",l===void 0&&(R=x,d=e.errSchemaPath+"/"+x,v=j,g=S)}else{var M=typeof E=="number",O=k;if(M&&g){var I="'"+O+"'";s+=" if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" ( "+v+" === undefined || "+E+" "+k+"= "+v+" ? "+h+" "+T+"= "+E+" : "+h+" "+T+" "+v+" ) || "+h+" !== "+h+") { "}else{M&&l===void 0?(A=!0,R=x,d=e.errSchemaPath+"/"+x,v=E,T+="="):(M&&(v=Math[b?"min":"max"](E,l)),E===(M?v:!0)?(A=!0,R=x,d=e.errSchemaPath+"/"+x,T+="="):(A=!1,O+="="));var I="'"+O+"'";s+=" if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" "+h+" "+T+" "+v+" || "+h+" !== "+h+") { "}}R=R||n;var L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(R||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { comparison: "+I+", limit: "+v+", exclusive: "+A+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be "+O+" ",g?s+="' + "+v:s+=""+v+"'"),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;return s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",p&&(s+=" else { "),s}),jE}var ME,UL;function BL(){return UL||(UL=1,ME=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,x,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");var b=n=="maxItems"?">":"<";s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" "+h+".length "+b+" "+v+") { ";var x=n,E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(x||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have ",n=="maxItems"?s+="more":s+="fewer",s+=" than ",g?s+="' + "+v+" + '":s+=""+l,s+=" items' "),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),ME}var OE,qL;function VL(){return qL||(qL=1,OE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,x,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");var b=n=="maxLength"?">":"<";s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),e.opts.unicode===!1?s+=" "+h+".length ":s+=" ucs2length("+h+") ",s+=" "+b+" "+v+") { ";var x=n,E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(x||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT be ",n=="maxLength"?s+="longer":s+="shorter",s+=" than ",g?s+="' + "+v+" + '":s+=""+l,s+=" characters' "),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),OE}var PE,HL;function GL(){return HL||(HL=1,PE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,x,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");var b=n=="maxProperties"?">":"<";s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" Object.keys("+h+").length "+b+" "+v+") { ";var x=n,E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(x||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have ",n=="maxProperties"?s+="more":s+="fewer",s+=" than ",g?s+="' + "+v+" + '":s+=""+l,s+=" properties' "),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),PE}var IE,WL;function ghe(){return WL||(WL=1,IE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");s+="var division"+i+";if (",g&&(s+=" "+v+" !== undefined && ( typeof "+v+" != 'number' || "),s+=" (division"+i+" = "+h+" / "+v+", ",e.opts.multipleOfPrecision?s+=" Math.abs(Math.round(division"+i+") - division"+i+") > 1e-"+e.opts.multipleOfPrecision+" ":s+=" division"+i+" !== parseInt(division"+i+") ",s+=" ) ",g&&(s+=" ) "),s+=" ) { ";var b=b||[];b.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { multipleOf: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be multiple of ",g?s+="' + "+v:s+=""+v+"'"),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var x=s;return s=b.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+x+"]); ":s+=" validate.errors = ["+x+"]; return false; ":s+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),IE}var DE,YL;function vhe(){return YL||(YL=1,DE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e);v.level++;var b="valid"+v.level;if(e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all)){v.schema=l,v.schemaPath=u,v.errSchemaPath=d,s+=" var "+g+" = errors; ";var x=e.compositeRule;e.compositeRule=v.compositeRule=!0,v.createErrors=!1;var E;v.opts.allErrors&&(E=v.opts.allErrors,v.opts.allErrors=!1),s+=" "+e.validate(v)+" ",v.createErrors=!0,E&&(v.opts.allErrors=E),e.compositeRule=v.compositeRule=x,s+=" if ("+b+") { ";var S=S||[];S.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should NOT be valid' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var k=s;s=S.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+k+"]); ":s+=" validate.errors = ["+k+"]; return false; ":s+=" var err = "+k+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { errors = "+g+"; if (vErrors !== null) { if ("+g+") vErrors.length = "+g+"; else vErrors = null; } ",e.opts.allErrors&&(s+=" } ")}else s+=" var err = ",e.createErrors!==!1?(s+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should NOT be valid' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",p&&(s+=" if (false) { ");return s}),DE}var LE,KL;function yhe(){return KL||(KL=1,LE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S=b.baseId,k="prevValid"+i,T="passingSchemas"+i;s+="var "+v+" = errors , "+k+" = false , "+g+" = false , "+T+" = null; ";var R=e.compositeRule;e.compositeRule=b.compositeRule=!0;var j=l;if(j)for(var A,N=-1,M=j.length-1;N<M;)A=j[N+=1],(e.opts.strictKeywords?typeof A=="object"&&Object.keys(A).length>0||A===!1:e.util.schemaHasRules(A,e.RULES.all))?(b.schema=A,b.schemaPath=u+"["+N+"]",b.errSchemaPath=d+"/"+N,s+=" "+e.validate(b)+" ",b.baseId=S):s+=" var "+E+" = true; ",N&&(s+=" if ("+E+" && "+k+") { "+g+" = false; "+T+" = ["+T+", "+N+"]; } else { ",x+="}"),s+=" if ("+E+") { "+g+" = "+k+" = true; "+T+" = "+N+"; }";return e.compositeRule=b.compositeRule=R,s+=""+x+"if (!"+g+") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { passingSchemas: "+T+" } ",e.opts.messages!==!1&&(s+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),s+="} else { errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; }",e.opts.allErrors&&(s+=" } "),s}),LE}var $E,XL;function bhe(){return XL||(XL=1,$E=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l;var b=g?"(new RegExp("+v+"))":e.usePattern(l);s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'string') || "),s+=" !"+b+".test("+h+") ) { ";var x=x||[];x.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { pattern: ",g?s+=""+v:s+=""+e.util.toQuotedString(l),s+=" } ",e.opts.messages!==!1&&(s+=` , message: 'should match pattern "`,g?s+="' + "+v+" + '":s+=""+e.util.escapeQuotes(l),s+=`"' `),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+e.util.toQuotedString(l),s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var E=s;return s=x.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+E+"]); ":s+=" validate.errors = ["+E+"]; return false; ":s+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),$E}var zE,QL;function xhe(){return QL||(QL=1,zE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e),b="";v.level++;var x="valid"+v.level,E="key"+i,S="idx"+i,k=v.dataLevel=e.dataLevel+1,T="data"+k,R="dataProperties"+i,j=Object.keys(l||{}).filter(H),A=e.schema.patternProperties||{},N=Object.keys(A).filter(H),M=e.schema.additionalProperties,I=j.length||N.length,O=M===!1,L=typeof M=="object"&&Object.keys(M).length,z=e.opts.removeAdditional,G=O||L||z,W=e.opts.ownProperties,X=e.baseId,F=e.schema.required;if(F&&!(e.opts.$data&&F.$data)&&F.length<e.opts.loopRequired)var Y=e.util.toHash(F);function H(Te){return Te!=="__proto__"}if(s+="var "+g+" = errors;var "+x+" = true;",W&&(s+=" var "+R+" = undefined;"),G){if(W?s+=" "+R+" = "+R+" || Object.keys("+h+"); for (var "+S+"=0; "+S+"<"+R+".length; "+S+"++) { var "+E+" = "+R+"["+S+"]; ":s+=" for (var "+E+" in "+h+") { ",I){if(s+=" var isAdditional"+i+" = !(false ",j.length)if(j.length>8)s+=" || validate.schema"+u+".hasOwnProperty("+E+") ";else{var te=j;if(te)for(var P,re=-1,ue=te.length-1;re<ue;)P=te[re+=1],s+=" || "+E+" == "+e.util.toQuotedString(P)+" "}if(N.length){var D=N;if(D)for(var Z,he=-1,V=D.length-1;he<V;)Z=D[he+=1],s+=" || "+e.usePattern(Z)+".test("+E+") "}s+=" ); if (isAdditional"+i+") { "}if(z=="all")s+=" delete "+h+"["+E+"]; ";else{var U=e.errorPath,K="' + "+E+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers)),O)if(z)s+=" delete "+h+"["+E+"]; ";else{s+=" "+x+" = false; ";var ae=d;d=e.errSchemaPath+"/additionalProperties";var B=B||[];B.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { additionalProperty: '"+K+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is an invalid additional property":s+="should NOT have additional properties",s+="' "),e.opts.verbose&&(s+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var J=s;s=B.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+J+"]); ":s+=" validate.errors = ["+J+"]; return false; ":s+=" var err = "+J+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d=ae,p&&(s+=" break; ")}else if(L)if(z=="failing"){s+=" var "+g+" = errors; ";var oe=e.compositeRule;e.compositeRule=v.compositeRule=!0,v.schema=M,v.schemaPath=e.schemaPath+".additionalProperties",v.errSchemaPath=e.errSchemaPath+"/additionalProperties",v.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers);var fe=h+"["+E+"]";v.dataPathArr[k]=E;var be=e.validate(v);v.baseId=X,e.util.varOccurences(be,T)<2?s+=" "+e.util.varReplace(be,T,fe)+" ":s+=" var "+T+" = "+fe+"; "+be+" ",s+=" if (!"+x+") { errors = "+g+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+h+"["+E+"]; } ",e.compositeRule=v.compositeRule=oe}else{v.schema=M,v.schemaPath=e.schemaPath+".additionalProperties",v.errSchemaPath=e.errSchemaPath+"/additionalProperties",v.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers);var fe=h+"["+E+"]";v.dataPathArr[k]=E;var be=e.validate(v);v.baseId=X,e.util.varOccurences(be,T)<2?s+=" "+e.util.varReplace(be,T,fe)+" ":s+=" var "+T+" = "+fe+"; "+be+" ",p&&(s+=" if (!"+x+") break; ")}e.errorPath=U}I&&(s+=" } "),s+=" } ",p&&(s+=" if ("+x+") { ",b+="}")}var Ae=e.opts.useDefaults&&!e.compositeRule;if(j.length){var Oe=j;if(Oe)for(var P,Ne=-1,Qe=Oe.length-1;Ne<Qe;){P=Oe[Ne+=1];var dt=l[P];if(e.opts.strictKeywords?typeof dt=="object"&&Object.keys(dt).length>0||dt===!1:e.util.schemaHasRules(dt,e.RULES.all)){var Be=e.util.getProperty(P),fe=h+Be,pt=Ae&&dt.default!==void 0;v.schema=dt,v.schemaPath=u+Be,v.errSchemaPath=d+"/"+e.util.escapeFragment(P),v.errorPath=e.util.getPath(e.errorPath,P,e.opts.jsonPointers),v.dataPathArr[k]=e.util.toQuotedString(P);var be=e.validate(v);if(v.baseId=X,e.util.varOccurences(be,T)<2){be=e.util.varReplace(be,T,fe);var De=fe}else{var De=T;s+=" var "+T+" = "+fe+"; "}if(pt)s+=" "+be+" ";else{if(Y&&Y[P]){s+=" if ( "+De+" === undefined ",W&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(P)+"') "),s+=") { "+x+" = false; ";var U=e.errorPath,ae=d,et=e.util.escapeQuotes(P);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(U,P,e.opts.jsonPointers)),d=e.errSchemaPath+"/required";var B=B||[];B.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+et+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+et+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var J=s;s=B.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+J+"]); ":s+=" validate.errors = ["+J+"]; return false; ":s+=" var err = "+J+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d=ae,e.errorPath=U,s+=" } else { "}else p?(s+=" if ( "+De+" === undefined ",W&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(P)+"') "),s+=") { "+x+" = true; } else { "):(s+=" if ("+De+" !== undefined ",W&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(P)+"') "),s+=" ) { ");s+=" "+be+" } "}}p&&(s+=" if ("+x+") { ",b+="}")}}if(N.length){var ot=N;if(ot)for(var Z,lr=-1,xe=ot.length-1;lr<xe;){Z=ot[lr+=1];var dt=A[Z];if(e.opts.strictKeywords?typeof dt=="object"&&Object.keys(dt).length>0||dt===!1:e.util.schemaHasRules(dt,e.RULES.all)){v.schema=dt,v.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(Z),v.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(Z),W?s+=" "+R+" = "+R+" || Object.keys("+h+"); for (var "+S+"=0; "+S+"<"+R+".length; "+S+"++) { var "+E+" = "+R+"["+S+"]; ":s+=" for (var "+E+" in "+h+") { ",s+=" if ("+e.usePattern(Z)+".test("+E+")) { ",v.errorPath=e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers);var fe=h+"["+E+"]";v.dataPathArr[k]=E;var be=e.validate(v);v.baseId=X,e.util.varOccurences(be,T)<2?s+=" "+e.util.varReplace(be,T,fe)+" ":s+=" var "+T+" = "+fe+"; "+be+" ",p&&(s+=" if (!"+x+") break; "),s+=" } ",p&&(s+=" else "+x+" = true; "),s+=" } ",p&&(s+=" if ("+x+") { ",b+="}")}}}return p&&(s+=" "+b+" if ("+g+" == errors) {"),s}),zE}var FE,JL;function _he(){return JL||(JL=1,FE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e),b="";v.level++;var x="valid"+v.level;if(s+="var "+g+" = errors;",e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all)){v.schema=l,v.schemaPath=u,v.errSchemaPath=d;var E="key"+i,S="idx"+i,k="i"+i,T="' + "+E+" + '",R=v.dataLevel=e.dataLevel+1,j="data"+R,A="dataProperties"+i,N=e.opts.ownProperties,M=e.baseId;N&&(s+=" var "+A+" = undefined; "),N?s+=" "+A+" = "+A+" || Object.keys("+h+"); for (var "+S+"=0; "+S+"<"+A+".length; "+S+"++) { var "+E+" = "+A+"["+S+"]; ":s+=" for (var "+E+" in "+h+") { ",s+=" var startErrs"+i+" = errors; ";var I=E,O=e.compositeRule;e.compositeRule=v.compositeRule=!0;var L=e.validate(v);v.baseId=M,e.util.varOccurences(L,j)<2?s+=" "+e.util.varReplace(L,j,I)+" ":s+=" var "+j+" = "+I+"; "+L+" ",e.compositeRule=v.compositeRule=O,s+=" if (!"+x+") { for (var "+k+"=startErrs"+i+"; "+k+"<errors; "+k+"++) { vErrors["+k+"].propertyName = "+E+"; } var err = ",e.createErrors!==!1?(s+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { propertyName: '"+T+"' } ",e.opts.messages!==!1&&(s+=" , message: 'property name \\'"+T+"\\' is invalid' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),p&&(s+=" break; "),s+=" } }"}return p&&(s+=" "+b+" if ("+g+" == errors) {"),s}),FE}var UE,ZL;function whe(){return ZL||(ZL=1,UE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data;v&&(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ");var b="schema"+i;if(!v)if(l.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var x=[],E=l;if(E)for(var S,k=-1,T=E.length-1;k<T;){S=E[k+=1];var R=e.schema.properties[S];R&&(e.opts.strictKeywords?typeof R=="object"&&Object.keys(R).length>0||R===!1:e.util.schemaHasRules(R,e.RULES.all))||(x[x.length]=S)}}else var x=l;if(v||x.length){var j=e.errorPath,A=v||x.length>=e.opts.loopRequired,N=e.opts.ownProperties;if(p)if(s+=" var missing"+i+"; ",A){v||(s+=" var "+b+" = validate.schema"+u+"; ");var M="i"+i,I="schema"+i+"["+M+"]",O="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(j,I,e.opts.jsonPointers)),s+=" var "+g+" = true; ",v&&(s+=" if (schema"+i+" === undefined) "+g+" = true; else if (!Array.isArray(schema"+i+")) "+g+" = false; else {"),s+=" for (var "+M+" = 0; "+M+" < "+b+".length; "+M+"++) { "+g+" = "+h+"["+b+"["+M+"]] !== undefined ",N&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", "+b+"["+M+"]) "),s+="; if (!"+g+") break; } ",v&&(s+=" } "),s+=" if (!"+g+") { ";var L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { "}else{s+=" if ( ";var G=x;if(G)for(var W,M=-1,X=G.length-1;M<X;){W=G[M+=1],M&&(s+=" || ");var F=e.util.getProperty(W),Y=h+F;s+=" ( ( "+Y+" === undefined ",N&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(W)+"') "),s+=") && (missing"+i+" = "+e.util.toQuotedString(e.opts.jsonPointers?W:F)+") ) "}s+=") { ";var I="missing"+i,O="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(j,I,!0):j+" + "+I);var L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { "}else if(A){v||(s+=" var "+b+" = validate.schema"+u+"; ");var M="i"+i,I="schema"+i+"["+M+"]",O="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(j,I,e.opts.jsonPointers)),v&&(s+=" if ("+b+" && !Array.isArray("+b+")) { var err = ",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+b+" !== undefined) { "),s+=" for (var "+M+" = 0; "+M+" < "+b+".length; "+M+"++) { if ("+h+"["+b+"["+M+"]] === undefined ",N&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", "+b+"["+M+"]) "),s+=") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",v&&(s+=" } ")}else{var H=x;if(H)for(var W,te=-1,P=H.length-1;te<P;){W=H[te+=1];var F=e.util.getProperty(W),O=e.util.escapeQuotes(W),Y=h+F;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(j,W,e.opts.jsonPointers)),s+=" if ( "+Y+" === undefined ",N&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(W)+"') "),s+=") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=j}else p&&(s+=" if (true) {");return s}),UE}var BE,e3;function She(){return e3||(e3=1,BE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data,b;if(v?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",b="schema"+i):b=l,(l||v)&&e.opts.uniqueItems!==!1){v&&(s+=" var "+g+"; if ("+b+" === false || "+b+" === undefined) "+g+" = true; else if (typeof "+b+" != 'boolean') "+g+" = false; else { "),s+=" var i = "+h+".length , "+g+" = true , j; if (i > 1) { ";var x=e.schema.items&&e.schema.items.type,E=Array.isArray(x);if(!x||x=="object"||x=="array"||E&&(x.indexOf("object")>=0||x.indexOf("array")>=0))s+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+h+"[i], "+h+"[j])) { "+g+" = false; break outer; } } } ";else{s+=" var itemIndices = {}, item; for (;i--;) { var item = "+h+"[i]; ";var S="checkDataType"+(E?"s":"");s+=" if ("+e.util[S](x,"item",e.opts.strictNumbers,!0)+") continue; ",E&&(s+=` if (typeof item == 'string') item = '"' + item; `),s+=" if (typeof itemIndices[item] == 'number') { "+g+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}s+=" } ",v&&(s+=" } "),s+=" if (!"+g+") { ";var k=k||[];k.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { i: i, j: j } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(s+=" , schema: ",v?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var T=s;s=k.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+T+"]); ":s+=" validate.errors = ["+T+"]; return false; ":s+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",p&&(s+=" else { ")}else p&&(s+=" if (true) { ");return s}),BE}var qE,t3;function Ehe(){return t3||(t3=1,qE={$ref:ihe(),allOf:ahe(),anyOf:ohe(),$comment:lhe(),const:che(),contains:uhe(),dependencies:dhe(),enum:fhe(),format:hhe(),if:phe(),items:mhe(),maximum:FL(),minimum:FL(),maxItems:BL(),minItems:BL(),maxLength:VL(),minLength:VL(),maxProperties:GL(),minProperties:GL(),multipleOf:ghe(),not:vhe(),oneOf:yhe(),pattern:bhe(),properties:xhe(),propertyNames:_he(),required:whe(),uniqueItems:She(),validate:eV()}),qE}var VE,n3;function khe(){if(n3)return VE;n3=1;var t=Ehe(),e=nh().toHash;return VE=function(){var r=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],s=["type","$comment"],i=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],a=["number","integer","string","array","object","boolean","null"];return r.all=e(s),r.types=e(a),r.forEach(function(l){l.rules=l.rules.map(function(u){var d;if(typeof u=="object"){var p=Object.keys(u)[0];d=u[p],u=p,d.forEach(function(g){s.push(g),r.all[g]=!0})}s.push(u);var h=r.all[u]={keyword:u,code:t[u],implements:d};return h}),r.all.$comment={keyword:"$comment",code:t.$comment},l.type&&(r.types[l.type]=l)}),r.keywords=e(s.concat(i)),r.custom={},r},VE}var HE,r3;function The(){if(r3)return HE;r3=1;var t=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];return HE=function(e,n){for(var r=0;r<n.length;r++){e=JSON.parse(JSON.stringify(e));var s=n[r].split("/"),i=e,a;for(a=1;a<s.length;a++)i=i[s[a]];for(a=0;a<t.length;a++){var l=t[a],u=i[l];u&&(i[l]={anyOf:[u,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e},HE}var GE,s3;function Che(){if(s3)return GE;s3=1;var t=KN().MissingRef;GE=e;function e(n,r,s){var i=this;if(typeof this._opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");typeof r=="function"&&(s=r,r=void 0);var a=l(n).then(function(){var d=i._addSchema(n,void 0,r);return d.validate||u(d)});return s&&a.then(function(d){s(null,d)},s),a;function l(d){var p=d.$schema;return p&&!i.getSchema(p)?e.call(i,{$ref:p},!0):Promise.resolve()}function u(d){try{return i._compile(d)}catch(h){if(h instanceof t)return p(h);throw h}function p(h){var g=h.missingSchema;if(x(g))throw new Error("Schema "+g+" is loaded but "+h.missingRef+" cannot be resolved");var v=i._loadingSchemas[g];return v||(v=i._loadingSchemas[g]=i._opts.loadSchema(g),v.then(b,b)),v.then(function(E){if(!x(g))return l(E).then(function(){x(g)||i.addSchema(E,g,void 0,r)})}).then(function(){return u(d)});function b(){delete i._loadingSchemas[g]}function x(E){return i._refs[E]||i._schemas[E]}}}}return GE}var WE,i3;function Ahe(){return i3||(i3=1,WE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h,g="data"+(a||""),v="valid"+i,b="errs__"+i,x=e.opts.$data&&l&&l.$data,E;x?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",E="schema"+i):E=l;var S=this,k="definition"+i,T=S.definition,R="",j,A,N,M,I;if(x&&T.$data){I="keywordValidate"+i;var O=T.validateSchema;s+=" var "+k+" = RULES.custom['"+n+"'].definition; var "+I+" = "+k+".validate;"}else{if(M=e.useCustomRule(S,l,e.schema,e),!M)return;E="validate.schema"+u,I=M.code,j=T.compile,A=T.inline,N=T.macro}var L=I+".errors",z="i"+i,G="ruleErr"+i,W=T.async;if(W&&!e.async)throw new Error("async keyword in sync schema");if(A||N||(s+=""+L+" = null;"),s+="var "+b+" = errors;var "+v+";",x&&T.$data&&(R+="}",s+=" if ("+E+" === undefined) { "+v+" = true; } else { ",O&&(R+="}",s+=" "+v+" = "+k+".validateSchema("+E+"); if ("+v+") { ")),A)T.statements?s+=" "+M.validate+" ":s+=" "+v+" = "+M.validate+"; ";else if(N){var X=e.util.copy(e),R="";X.level++;var F="valid"+X.level;X.schema=M.validate,X.schemaPath="";var Y=e.compositeRule;e.compositeRule=X.compositeRule=!0;var H=e.validate(X).replace(/validate\.schema/g,I);e.compositeRule=X.compositeRule=Y,s+=" "+H}else{var te=te||[];te.push(s),s="",s+=" "+I+".call( ",e.opts.passContext?s+="this":s+="self",j||T.schema===!1?s+=" , "+g+" ":s+=" , "+E+" , "+g+" , validate.schema"+e.schemaPath+" ",s+=" , (dataPath || '')",e.errorPath!='""'&&(s+=" + "+e.errorPath);var P=a?"data"+(a-1||""):"parentData",re=a?e.dataPathArr[a]:"parentDataProperty";s+=" , "+P+" , "+re+" , rootData ) ";var ue=s;s=te.pop(),T.errors===!1?(s+=" "+v+" = ",W&&(s+="await "),s+=""+ue+"; "):W?(L="customErrors"+i,s+=" var "+L+" = null; try { "+v+" = await "+ue+"; } catch (e) { "+v+" = false; if (e instanceof ValidationError) "+L+" = e.errors; else throw e; } "):s+=" "+L+" = null; "+v+" = "+ue+"; "}if(T.modifying&&(s+=" if ("+P+") "+g+" = "+P+"["+re+"];"),s+=""+R,T.valid)p&&(s+=" if (true) { ");else{s+=" if ( ",T.valid===void 0?(s+=" !",N?s+=""+F:s+=""+v):s+=" "+!T.valid+" ",s+=") { ",h=S.keyword;var te=te||[];te.push(s),s="";var te=te||[];te.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(h||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+S.keyword+"' } ",e.opts.messages!==!1&&(s+=` , message: 'should pass "`+S.keyword+`" keyword validation' `),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+g+" "),s+=" } "):s+=" {} ";var D=s;s=te.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+D+"]); ":s+=" validate.errors = ["+D+"]; return false; ":s+=" var err = "+D+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var Z=s;s=te.pop(),A?T.errors?T.errors!="full"&&(s+=" for (var "+z+"="+b+"; "+z+"<errors; "+z+"++) { var "+G+" = vErrors["+z+"]; if ("+G+".dataPath === undefined) "+G+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+G+".schemaPath === undefined) { "+G+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(s+=" "+G+".schema = "+E+"; "+G+".data = "+g+"; "),s+=" } "):T.errors===!1?s+=" "+Z+" ":(s+=" if ("+b+" == errors) { "+Z+" } else { for (var "+z+"="+b+"; "+z+"<errors; "+z+"++) { var "+G+" = vErrors["+z+"]; if ("+G+".dataPath === undefined) "+G+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+G+".schemaPath === undefined) { "+G+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(s+=" "+G+".schema = "+E+"; "+G+".data = "+g+"; "),s+=" } } "):N?(s+=" var err = ",e.createErrors!==!1?(s+=" { keyword: '"+(h||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+S.keyword+"' } ",e.opts.messages!==!1&&(s+=` , message: 'should pass "`+S.keyword+`" keyword validation' `),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+g+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; ")):T.errors===!1?s+=" "+Z+" ":(s+=" if (Array.isArray("+L+")) { if (vErrors === null) vErrors = "+L+"; else vErrors = vErrors.concat("+L+"); errors = vErrors.length; for (var "+z+"="+b+"; "+z+"<errors; "+z+"++) { var "+G+" = vErrors["+z+"]; if ("+G+".dataPath === undefined) "+G+".dataPath = (dataPath || '') + "+e.errorPath+"; "+G+'.schemaPath = "'+d+'"; ',e.opts.verbose&&(s+=" "+G+".schema = "+E+"; "+G+".data = "+g+"; "),s+=" } } else { "+Z+" } "),s+=" } ",p&&(s+=" else { ")}return s}),WE}const Nhe="http://json-schema.org/draft-07/schema#",Rhe="http://json-schema.org/draft-07/schema#",jhe="Core schema meta-schema",Mhe={schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},Ohe=["object","boolean"],Phe={$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},tV={$schema:Nhe,$id:Rhe,title:jhe,definitions:Mhe,type:Ohe,properties:Phe,default:!0};var YE,a3;function Ihe(){if(a3)return YE;a3=1;var t=tV;return YE={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:t.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:t.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}},YE}var KE,o3;function Dhe(){if(o3)return KE;o3=1;var t=/^[a-z_$][a-z0-9_$-]*$/i,e=Ahe(),n=Ihe();KE={add:r,get:s,remove:i,validate:a};function r(l,u){var d=this.RULES;if(d.keywords[l])throw new Error("Keyword "+l+" is already defined");if(!t.test(l))throw new Error("Keyword "+l+" is not a valid identifier");if(u){this.validateKeyword(u,!0);var p=u.type;if(Array.isArray(p))for(var h=0;h<p.length;h++)v(l,p[h],u);else v(l,p,u);var g=u.metaSchema;g&&(u.$data&&this._opts.$data&&(g={anyOf:[g,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),u.validateSchema=this.compile(g,!0))}d.keywords[l]=d.all[l]=!0;function v(b,x,E){for(var S,k=0;k<d.length;k++){var T=d[k];if(T.type==x){S=T;break}}S||(S={type:x,rules:[]},d.push(S));var R={keyword:b,definition:E,custom:!0,code:e,implements:E.implements};S.rules.push(R),d.custom[b]=R}return this}function s(l){var u=this.RULES.custom[l];return u?u.definition:this.RULES.keywords[l]||!1}function i(l){var u=this.RULES;delete u.keywords[l],delete u.all[l],delete u.custom[l];for(var d=0;d<u.length;d++)for(var p=u[d].rules,h=0;h<p.length;h++)if(p[h].keyword==l){p.splice(h,1);break}return this}function a(l,u){a.errors=null;var d=this._validateKeyword=this._validateKeyword||this.compile(n,!0);if(d(l))return!0;if(a.errors=d.errors,u)throw new Error("custom keyword definition is invalid: "+this.errorsText(d.errors));return!1}return KE}const Lhe="http://json-schema.org/draft-07/schema#",$he="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",zhe="Meta-schema for $data reference (JSON Schema extension proposal)",Fhe="object",Uhe=["$data"],Bhe={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},qhe=!1,Vhe={$schema:Lhe,$id:$he,description:zhe,type:Fhe,required:Uhe,properties:Bhe,additionalProperties:qhe};var XE,l3;function Hhe(){if(l3)return XE;l3=1;var t=nhe(),e=YN(),n=rhe(),r=Jq(),s=Zq(),i=she(),a=khe(),l=The(),u=nh();XE=b,b.prototype.validate=x,b.prototype.compile=E,b.prototype.addSchema=S,b.prototype.addMetaSchema=k,b.prototype.validateSchema=T,b.prototype.getSchema=j,b.prototype.removeSchema=M,b.prototype.addFormat=Y,b.prototype.errorsText=F,b.prototype._addSchema=O,b.prototype._compile=L,b.prototype.compileAsync=Che();var d=Dhe();b.prototype.addKeyword=d.add,b.prototype.getKeyword=d.get,b.prototype.removeKeyword=d.remove,b.prototype.validateKeyword=d.validate;var p=KN();b.ValidationError=p.Validation,b.MissingRefError=p.MissingRef,b.$dataMetaSchema=l;var h="http://json-schema.org/draft-07/schema",g=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],v=["/properties"];function b(V){if(!(this instanceof b))return new b(V);V=this._opts=u.copy(V)||{},Z(this),this._schemas={},this._refs={},this._fragments={},this._formats=i(V.format),this._cache=V.cache||new n,this._loadingSchemas={},this._compilations=[],this.RULES=a(),this._getId=z(V),V.loopRequired=V.loopRequired||1/0,V.errorDataPath=="property"&&(V._errorDataPathProperty=!0),V.serialize===void 0&&(V.serialize=s),this._metaOpts=D(this),V.formats&&P(this),V.keywords&&re(this),H(this),typeof V.meta=="object"&&this.addMetaSchema(V.meta),V.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),te(this)}function x(V,U){var K;if(typeof V=="string"){if(K=this.getSchema(V),!K)throw new Error('no schema with key or ref "'+V+'"')}else{var ae=this._addSchema(V);K=ae.validate||this._compile(ae)}var B=K(U);return K.$async!==!0&&(this.errors=K.errors),B}function E(V,U){var K=this._addSchema(V,void 0,U);return K.validate||this._compile(K)}function S(V,U,K,ae){if(Array.isArray(V)){for(var B=0;B<V.length;B++)this.addSchema(V[B],void 0,K,ae);return this}var J=this._getId(V);if(J!==void 0&&typeof J!="string")throw new Error("schema id must be string");return U=e.normalizeId(U||J),ue(this,U),this._schemas[U]=this._addSchema(V,K,ae,!0),this}function k(V,U,K){return this.addSchema(V,U,K,!0),this}function T(V,U){var K=V.$schema;if(K!==void 0&&typeof K!="string")throw new Error("$schema must be a string");if(K=K||this._opts.defaultMeta||R(this),!K)return this.logger.warn("meta-schema not available"),this.errors=null,!0;var ae=this.validate(K,V);if(!ae&&U){var B="schema is invalid: "+this.errorsText();if(this._opts.validateSchema=="log")this.logger.error(B);else throw new Error(B)}return ae}function R(V){var U=V._opts.meta;return V._opts.defaultMeta=typeof U=="object"?V._getId(U)||U:V.getSchema(h)?h:void 0,V._opts.defaultMeta}function j(V){var U=N(this,V);switch(typeof U){case"object":return U.validate||this._compile(U);case"string":return this.getSchema(U);case"undefined":return A(this,V)}}function A(V,U){var K=e.schema.call(V,{schema:{}},U);if(K){var ae=K.schema,B=K.root,J=K.baseId,oe=t.call(V,ae,B,void 0,J);return V._fragments[U]=new r({ref:U,fragment:!0,schema:ae,root:B,baseId:J,validate:oe}),oe}}function N(V,U){return U=e.normalizeId(U),V._schemas[U]||V._refs[U]||V._fragments[U]}function M(V){if(V instanceof RegExp)return I(this,this._schemas,V),I(this,this._refs,V),this;switch(typeof V){case"undefined":return I(this,this._schemas),I(this,this._refs),this._cache.clear(),this;case"string":var U=N(this,V);return U&&this._cache.del(U.cacheKey),delete this._schemas[V],delete this._refs[V],this;case"object":var K=this._opts.serialize,ae=K?K(V):V;this._cache.del(ae);var B=this._getId(V);B&&(B=e.normalizeId(B),delete this._schemas[B],delete this._refs[B])}return this}function I(V,U,K){for(var ae in U){var B=U[ae];!B.meta&&(!K||K.test(ae))&&(V._cache.del(B.cacheKey),delete U[ae])}}function O(V,U,K,ae){if(typeof V!="object"&&typeof V!="boolean")throw new Error("schema should be object or boolean");var B=this._opts.serialize,J=B?B(V):V,oe=this._cache.get(J);if(oe)return oe;ae=ae||this._opts.addUsedSchema!==!1;var fe=e.normalizeId(this._getId(V));fe&&ae&&ue(this,fe);var be=this._opts.validateSchema!==!1&&!U,Ae;be&&!(Ae=fe&&fe==e.normalizeId(V.$schema))&&this.validateSchema(V,!0);var Oe=e.ids.call(this,V),Ne=new r({id:fe,schema:V,localRefs:Oe,cacheKey:J,meta:K});return fe[0]!="#"&&ae&&(this._refs[fe]=Ne),this._cache.put(J,Ne),be&&Ae&&this.validateSchema(V,!0),Ne}function L(V,U){if(V.compiling)return V.validate=B,B.schema=V.schema,B.errors=null,B.root=U||B,V.schema.$async===!0&&(B.$async=!0),B;V.compiling=!0;var K;V.meta&&(K=this._opts,this._opts=this._metaOpts);var ae;try{ae=t.call(this,V.schema,U,V.localRefs)}catch(J){throw delete V.validate,J}finally{V.compiling=!1,V.meta&&(this._opts=K)}return V.validate=ae,V.refs=ae.refs,V.refVal=ae.refVal,V.root=ae.root,ae;function B(){var J=V.validate,oe=J.apply(this,arguments);return B.errors=J.errors,oe}}function z(V){switch(V.schemaId){case"auto":return X;case"id":return G;default:return W}}function G(V){return V.$id&&this.logger.warn("schema $id ignored",V.$id),V.id}function W(V){return V.id&&this.logger.warn("schema id ignored",V.id),V.$id}function X(V){if(V.$id&&V.id&&V.$id!=V.id)throw new Error("schema $id is different from id");return V.$id||V.id}function F(V,U){if(V=V||this.errors,!V)return"No errors";U=U||{};for(var K=U.separator===void 0?", ":U.separator,ae=U.dataVar===void 0?"data":U.dataVar,B="",J=0;J<V.length;J++){var oe=V[J];oe&&(B+=ae+oe.dataPath+" "+oe.message+K)}return B.slice(0,-K.length)}function Y(V,U){return typeof U=="string"&&(U=new RegExp(U)),this._formats[V]=U,this}function H(V){var U;if(V._opts.$data&&(U=Vhe,V.addMetaSchema(U,U.$id,!0)),V._opts.meta!==!1){var K=tV;V._opts.$data&&(K=l(K,v)),V.addMetaSchema(K,h,!0),V._refs["http://json-schema.org/schema"]=h}}function te(V){var U=V._opts.schemas;if(U)if(Array.isArray(U))V.addSchema(U);else for(var K in U)V.addSchema(U[K],K)}function P(V){for(var U in V._opts.formats){var K=V._opts.formats[U];V.addFormat(U,K)}}function re(V){for(var U in V._opts.keywords){var K=V._opts.keywords[U];V.addKeyword(U,K)}}function ue(V,U){if(V._schemas[U]||V._refs[U])throw new Error('schema with key or id "'+U+'" already exists')}function D(V){for(var U=u.copy(V._opts),K=0;K<g.length;K++)delete U[g[K]];return U}function Z(V){var U=V._opts.logger;if(U===!1)V.logger={log:he,warn:he,error:he};else{if(U===void 0&&(U=console),!(typeof U=="object"&&U.log&&U.warn&&U.error))throw new Error("logger must implement log, warn and error methods");V.logger=U}}function he(){}return XE}var Ghe=Hhe();const Whe=Vf(Ghe),c3=new Whe;function Yhe(t,e){const n={structuredErrors:void 0,unstructuredStatus:"not_applicable"};if(!e)return n;if(t.structuredContent)try{const r=c3.compile(e),s=r(t.structuredContent);n.structuredErrors=s?null:r.errors||[]}catch{n.structuredErrors=n.structuredErrors=[{keyword:"schema-compilation",instancePath:"",schemaPath:"",params:{},message:"The provided outputSchema is invalid and could not be compiled."}]}if(typeof t.content[0].text=="string")try{const r=JSON.parse(t.content[0].text),i=c3.compile(e)(r);n.unstructuredStatus=i?"valid":"schema_mismatch"}catch{n.unstructuredStatus="invalid_json"}return n}function Khe({serverConfig:t,serverName:e}){const n=GN("ToolsTab"),[r,s]=w.useState({}),[i,a]=w.useState(""),[l,u]=w.useState([]),[d,p]=w.useState(null),[h,g]=w.useState(null),[v,b]=w.useState(!1),[x,E]=w.useState(void 0),[S,k]=w.useState("not_applicable"),[T,R]=w.useState(!1),[j,A]=w.useState(!1),[N,M]=w.useState(""),[I,O]=w.useState(null),[L,z]=w.useState(!1),[G,W]=w.useState(""),[X,F]=w.useState("tools"),[Y,H]=w.useState(null),[te,P]=w.useState(null),[re,ue]=w.useState(null),[D,Z]=w.useState(null),[he,V]=w.useState(null),[U,K]=w.useState([]),[ae,B]=w.useState(!1),[J,oe]=w.useState(null),[fe,be]=w.useState({title:""}),Ae=w.useMemo(()=>{if(!t)return"none";try{if(t.url)return`http:${t.url}`;if(t.command){const Pe=(t.args||[]).join(" ");return`stdio:${t.command} ${Pe}`.trim()}return JSON.stringify(t)}catch{return"unknown"}},[t]);w.useEffect(()=>{if(!t||!e){s({}),a(""),u([]),p(null),g(null),b(!1),E(void 0),k("not_applicable"),M(""),O(null);return}Oe()},[t,e]),w.useEffect(()=>{t&&K(Ll(Ae))},[t,Ae]),w.useEffect(()=>{i&&r[i]&&u($fe(r[i].inputSchema))},[i,r]);const Oe=async()=>{if(!e){n.warn("Cannot fetch tools: no serverId available");return}A(!0),M(""),s({}),a(""),u([]),p(null),g(null),b(!1),E(void 0),k("not_applicable");try{const bt=(await AN(e)).tools??[],Xt=Object.fromEntries(bt.map(vt=>[vt.name,vt]));s(Xt),n.info("Tools fetched",{serverId:e,toolCount:bt.length})}catch(Pe){const bt=Pe instanceof Error?Pe.message:"Unknown error";n.error("Failed to fetch tools",{error:bt}),M(bt)}finally{A(!1)}},Ne=(Pe,bt)=>{u(Xt=>Xt.map(vt=>vt.name===Pe?{...vt,value:bt}:vt))},Qe=Pe=>{u(bt=>zfe(bt,Pe))},dt=()=>Ffe(l,(Pe,bt)=>n.warn(Pe,bt)),Be=Pe=>Pe?r[Pe]?._meta:void 0,pt=(Pe,bt,Xt)=>{if("result"in Pe&&Pe.status==="completed"){O(null);const vt=Pe.result;p(vt);const Qt=vt;if(Qt?.structuredContent){g(Qt.structuredContent);const Yo=Be(bt)?.["openai/outputTemplate"];b(!Yo)}else g(null),b(!1);const cr=r[bt];if(cr?.outputSchema){const br=Yhe(Qt,cr.outputSchema);E(br.structuredErrors),k(br.unstructuredStatus),br.structuredErrors&&n.warn("Schema validation failed",{errors:br.structuredErrors})}else E(void 0),k("not_applicable");n.info("Tool execution completed",{toolName:bt,duration:Date.now()-Xt});return}if("status"in Pe&&Pe.status==="elicitation_required"){O({executionId:Pe.executionId,requestId:Pe.requestId,request:Pe.request,timestamp:Pe.timestamp});return}"error"in Pe&&Pe.error&&M(Pe.error)},De=async()=>{if(!i){n.warn("Cannot execute tool: no tool selected");return}if(!e){n.warn("Cannot execute tool: no serverId available");return}R(!0),M(""),p(null),g(null),b(!1),E(void 0),k("not_applicable");const Pe=Date.now(),bt=`tool-${Pe}`,Xt=new Date;try{const vt=dt();P(bt),ue(i),Z(vt),V(Xt);const Qt=await ZS(e,i,vt);pt(Qt,i,Pe)}catch(vt){console.error("executeTool",vt);const Qt=vt instanceof Error?vt.message:"Unknown error";n.error("Tool execution network error",{toolName:i,error:Qt}),M(Qt)}finally{R(!1)}},et=async(Pe,bt)=>{if(!I){n.warn("Cannot handle elicitation response: no active request");return}z(!0);try{const Xt=Pe==="accept"?{action:"accept",content:bt??{}}:{action:Pe},vt=await Bue(I.requestId,Xt);pt(vt,i,Date.now())}catch(Xt){const vt=Xt instanceof Error?Xt.message:"Unknown error";n.error("Error responding to elicitation",{requestId:I.requestId,action:Pe,error:vt}),M(vt)}finally{z(!1)}},ot=()=>{i&&(oe(null),be({title:i,description:""}),B(!0))},lr=Pe=>{a(Pe.toolName),setTimeout(()=>Qe(Pe.parameters),50)},xe=Pe=>{Bfe(Ae,Pe),K(Ll(Ae))},Te=Pe=>{const bt=qfe(Ae,Pe.id);K(Ll(Ae)),bt?.id&&(H(bt.id),setTimeout(()=>H(null),2e3))},st=Pe=>{oe(Pe.id),be({title:Pe.title,description:Pe.description}),B(!0)},qe=Object.keys(r),At=G.trim()?qe.filter(Pe=>{const bt=r[Pe];return`${Pe} ${bt?.description??""}`.toLowerCase().includes(G.trim().toLowerCase())}):qe,Jn=G.trim()?U.filter(Pe=>`${Pe.title} ${Pe.description??""}`.toLowerCase().includes(G.trim().toLowerCase())):U,Zn=I?{requestId:I.requestId,message:I.request.message,schema:I.request.requestedSchema,timestamp:I.timestamp}:null;return t?f.jsxs("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:[f.jsxs(Tf,{direction:"vertical",className:"flex-1",children:[f.jsx(ni,{defaultSize:70,minSize:30,children:f.jsxs(Tf,{direction:"horizontal",className:"h-full",children:[f.jsx(Ife,{activeTab:X,onChangeTab:F,tools:r,toolNames:qe,filteredToolNames:At,selectedToolName:i,fetchingTools:j,searchQuery:G,onSearchQueryChange:W,onRefresh:Oe,onSelectTool:a,savedRequests:Jn,highlightedRequestId:Y,onLoadRequest:lr,onRenameRequest:st,onDuplicateRequest:Te,onDeleteRequest:xe}),f.jsx(Cf,{withHandle:!0}),i?f.jsx(Tde,{selectedTool:i,toolDescription:r[i]?.description,formFields:l,loading:T,waitingOnElicitation:!!I,onExecute:De,onSave:ot,onFieldChange:Ne}):f.jsx(ni,{defaultSize:70,minSize:50,children:f.jsx("div",{className:"h-full flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:f.jsx(kk,{className:"h-5 w-5 text-muted-foreground"})}),f.jsx("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a tool"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a tool from the left to configure parameters"})]})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:40,minSize:15,maxSize:85,children:f.jsx(Mfe,{error:N,showStructured:v,onToggleStructured:b,structuredResult:h,result:d,validationErrors:x,unstructuredValidationResult:S,serverId:e,toolCallId:te??void 0,toolName:re??void 0,toolParameters:D??void 0,toolCallTimestamp:he??void 0,toolMeta:Be(re),onExecuteFromUI:async(Pe,bt)=>{e&&await ZS(e,Pe,bt||{})},onHandleIntent:async(Pe,bt)=>{e&&await ZS(e,"handleIntent",{intent:Pe,params:bt||{}})},onSendFollowup:Pe=>{n.info("OpenAI component requested follow-up",{message:Pe})}})})]}),f.jsx(ST,{elicitationRequest:Zn,onResponse:et,loading:L}),f.jsx(Dfe,{open:ae,defaultTitle:fe.title,defaultDescription:fe.description,onCancel:()=>B(!1),onSave:({title:Pe,description:bt})=>{if(J){Vfe(Ae,J,{title:Pe,description:bt}),K(Ll(Ae)),oe(null),B(!1),F("saved"),H(J),setTimeout(()=>H(null),2e3);return}const Xt=dt(),vt=HN(Ae,{title:Pe,description:bt,toolName:i,parameters:Xt});K(Ll(Ae)),B(!1),F("saved"),vt?.id&&(H(vt.id),setTimeout(()=>H(null),2e3))}})]}):f.jsx(th,{icon:kk,title:"No Server Selected",description:"Connect to an MCP server to explore and test its available tools."})}function Xhe({serverConfig:t,serverName:e}){const[n,r]=w.useState([]),[s,i]=w.useState(""),[a,l]=w.useState(null),[u,d]=w.useState(!1),[p,h]=w.useState(!1),[g,v]=w.useState(""),b=w.useMemo(()=>n.find(S=>S.uri===s)??null,[n,s]);w.useEffect(()=>{t&&e&&x()},[t,e]);const x=async()=>{if(e){h(!0),v(""),r([]);try{const S=await fetch("/api/mcp/resources/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e})}),k=await S.json();if(S.ok){const T=Array.isArray(k.resources)?k.resources:[];r(T),T.length===0?(i(""),l(null)):T.some(R=>R.uri===s)||(i(T[0].uri),l(null))}else v(k.error||"Failed to fetch resources")}catch(S){v(`Network error fetching resources: ${S}`)}finally{h(!1)}}},E=async S=>{if(e){d(!0),v("");try{const k=await fetch("/api/mcp/resources/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e,uri:S})}),T=await k.json();k.ok?l(T.content??null):v(T.error||"Failed to read resource")}catch(k){v(`Network error reading resource: ${k}`)}finally{d(!1)}}};return!t||!e?f.jsx(th,{icon:MS,title:"No Server Selected",description:"Connect to an MCP server to browse and explore its available resources."}):f.jsx("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:f.jsxs(Tf,{direction:"vertical",className:"flex-1",children:[f.jsx(ni,{defaultSize:70,minSize:30,children:f.jsxs(Tf,{direction:"horizontal",className:"h-full",children:[f.jsx(ni,{defaultSize:30,minSize:20,maxSize:50,children:f.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(MS,{className:"h-3 w-3 text-muted-foreground"}),f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Resources"}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono",children:n.length})]}),f.jsx(Ie,{onClick:x,variant:"ghost",size:"sm",disabled:p,children:f.jsx(ir,{className:`h-3 w-3 ${p?"animate-spin":""} cursor-pointer`})})]}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-2",children:p?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(ir,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading resources..."}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available resources from server"})]}):n.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:"No resources available"})}):f.jsx("div",{className:"space-y-1",children:n.map(S=>f.jsx("div",{className:`cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ${s===S.uri?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"}`,onClick:()=>i(S.uri),children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(kse,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f.jsx("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:S.name})]}),S.description&&f.jsx("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:S.description}),f.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1 font-mono truncate",children:S.uri}),S.mimeType&&f.jsx(vr,{variant:"outline",className:"text-xs mt-2 font-mono",children:S.mimeType})]}),f.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},S.uri))})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:70,minSize:50,children:f.jsx("div",{className:"h-full flex flex-col bg-background",children:s?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"flex items-center gap-3",children:f.jsx("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:b?.name||s})}),f.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate max-w-md",children:s})]}),f.jsx(Ie,{onClick:()=>E(s),disabled:u,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:u?f.jsxs(f.Fragment,{children:[f.jsx(ir,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Reading"})]}):f.jsxs(f.Fragment,{children:[f.jsx(lI,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Read"})]})})]}),b?.description&&f.jsx("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:f.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:b.description})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"px-6 py-6",children:a?f.jsx("div",{className:"space-y-4",children:a?.contents?.map((S,k)=>f.jsxs("div",{className:"group",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[f.jsx(vr,{variant:"secondary",className:"text-xs font-mono font-medium",children:S.type}),S.mimeType&&f.jsx(vr,{variant:"outline",className:"text-xs font-mono",children:S.mimeType})]}),f.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:S.type==="text"?f.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap p-4 bg-background overflow-auto max-h-96",children:S.text}):f.jsx("div",{className:"p-4",children:f.jsx(zl,{src:S,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"0",borderRadius:"0",border:"none"}})})})]},k))}):f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(lI,{className:"h-4 w-4 text-muted-foreground"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Ready to read resource"}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Click the Read button to view resource content"})]})})})})]}):f.jsx("div",{className:"h-full flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:f.jsx(MS,{className:"h-5 w-5 text-muted-foreground"})}),f.jsx("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a resource"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a resource from the left to preview its content"})]})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:30,minSize:15,maxSize:70,children:f.jsxs("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[f.jsx("div",{className:"flex items-center justify-between p-4 border-b border-border",children:f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Status"})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:g?f.jsx("div",{className:"p-4",children:f.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:g})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Resource operations status will appear here"})})})]})})]})})}function Qhe({serverConfig:t,serverName:e}){const[n,r]=w.useState([]),[s,i]=w.useState(""),[a,l]=w.useState([]),[u,d]=w.useState(null),[p,h]=w.useState(!1),[g,v]=w.useState(!1),[b,x]=w.useState(""),E=w.useMemo(()=>n.find(N=>N.name===s)??null,[n,s]);w.useEffect(()=>{t&&e&&S()},[t,e]),w.useEffect(()=>{E?.arguments?k(E.arguments):l([])},[E]);const S=async()=>{if(e){v(!0),x("");try{const N=await fetch("/api/mcp/prompts/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e})}),M=await N.json();if(N.ok){const I=Array.isArray(M.prompts)?M.prompts:[];r(I),I.length===0?(i(""),d(null)):I.some(O=>O.name===s)||(i(I[0].name),d(null))}else x(M.error||"Could not fetch prompts")}catch(N){x(`Could not fetch prompts: ${N}`)}finally{v(!1)}}},k=N=>{if(!N||N.length===0){l([]);return}const M=N.map(I=>({name:I.name,type:"string",description:I.description,required:!!I.required,value:""}));l(M)},T=(N,M)=>{l(I=>I.map(O=>O.name===N?{...O,value:M}:O))},R=()=>{const N={};return a.forEach(M=>{if(M.value!==""&&M.value!==null&&M.value!==void 0){let I;M.type==="array"||M.type==="object"?I=typeof M.value=="string"?M.value:JSON.stringify(M.value):M.type==="boolean"?I=M.value?"true":"false":(M.type==="number"||M.type,I=String(M.value)),N[M.name]=I}}),N},j=async()=>{if(!(!s||!e)){h(!0),x("");try{const N=R(),M=await fetch("/api/mcp/prompts/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e,name:s,args:N})}),I=await M.json();M.ok?d(I.content):x(I.error||"Failed to get prompt")}catch(N){x(`Error getting prompt: ${N}`)}finally{h(!1)}}},A=n.map(N=>N.name);return!t||!e?f.jsx(th,{icon:Gy,title:"No Server Selected",description:"Connect to an MCP server to explore and test its available prompts."}):f.jsx("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:f.jsxs(Tf,{direction:"vertical",className:"flex-1",children:[f.jsx(ni,{defaultSize:70,minSize:30,children:f.jsxs(Tf,{direction:"horizontal",className:"h-full",children:[f.jsx(ni,{defaultSize:30,minSize:20,maxSize:50,children:f.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Gy,{className:"h-3 w-3 text-muted-foreground"}),f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Prompts"}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono",children:A.length})]}),f.jsx(Ie,{onClick:S,variant:"ghost",size:"sm",disabled:g,children:f.jsx(ir,{className:`h-3 w-3 ${g?"animate-spin":""} cursor-pointer`})})]}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-2",children:g?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(ir,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading prompts..."}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available prompts from server"})]}):A.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:"No prompts available"})}):f.jsx("div",{className:"space-y-1",children:n.map(N=>{const M=s===N.name,I=N.title??N.name;return f.jsx("div",{className:`cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ${M?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"}`,onClick:()=>{i(N.name)},children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:N.name}),N.title&&f.jsx("span",{className:"text-xs font-semibold text-foreground",children:I})]}),N.description&&f.jsx("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:N.description})]}),f.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},N.name)})})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:70,minSize:50,children:f.jsx("div",{className:"h-full flex flex-col bg-background",children:s?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[f.jsx("div",{className:"space-y-2",children:f.jsx("div",{className:"flex items-center gap-3",children:f.jsx("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:s})})}),f.jsx(Ie,{onClick:j,disabled:p||!s,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:p?f.jsxs(f.Fragment,{children:[f.jsx(ir,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Loading"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Cb,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Get Prompt"})]})})]}),E?.description&&f.jsx("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:f.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:E.description})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"px-6 py-6",children:a.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(Cb,{className:"h-4 w-4 text-muted-foreground"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"No parameters required"}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"This prompt can be retrieved directly"})]}):f.jsx("div",{className:"space-y-8",children:a.map(N=>f.jsxs("div",{className:"group",children:[f.jsxs("div",{className:"flex items-start justify-between mb-3",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("code",{className:"font-mono text-xs font-semibold text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:N.name}),N.required&&f.jsx("div",{className:"w-1.5 h-1.5 bg-amber-400 dark:bg-amber-500 rounded-full",title:"Required field"})]}),N.description&&f.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed max-w-md font-medium",children:N.description})]}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono font-medium",children:N.type})]}),f.jsx("div",{className:"space-y-2",children:N.type==="enum"?f.jsxs(Qc,{value:String(N.value),onValueChange:M=>T(N.name,M),children:[f.jsx(Zc,{className:"w-full bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs",children:f.jsx(Jc,{placeholder:"Select an option",className:"font-mono text-xs"})}),f.jsx(eu,{children:N.enum?.map(M=>f.jsx(Qs,{value:M,className:"font-mono text-xs",children:M},M))})]}):N.type==="boolean"?f.jsxs("div",{className:"flex items-center space-x-3 py-2",children:[f.jsx("input",{type:"checkbox",checked:N.value===!0,onChange:M=>T(N.name,M.target.checked),className:"w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"}),f.jsx("span",{className:"text-xs text-foreground font-medium",children:N.value===!0?"Enabled":"Disabled"})]}):N.type==="array"||N.type==="object"?f.jsx(Ho,{value:typeof N.value=="string"?N.value:JSON.stringify(N.value,null,2),onChange:M=>T(N.name,M.target.value),placeholder:`Enter ${N.type} as JSON`,className:"font-mono text-xs h-20 bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 resize-none"}):f.jsx(Un,{type:N.type==="number"||N.type==="integer"?"number":"text",value:String(N.value),onChange:M=>T(N.name,M.target.value),placeholder:`Enter ${N.name}`,className:"bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs"})})]},N.name))})})})})]}):f.jsx("div",{className:"h-full flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:f.jsx(Gy,{className:"h-5 w-5 text-muted-foreground"})}),f.jsx("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a prompt"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a prompt from the left to view details"})]})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:30,minSize:15,maxSize:70,children:f.jsxs("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[f.jsx("div",{className:"flex items-center justify-between p-4 border-b border-border",children:f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Prompt Content"})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:b?f.jsx("div",{className:"p-4",children:f.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:b})}):u?f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-4",children:typeof u=="string"?f.jsx("pre",{className:"whitespace-pre-wrap text-xs font-mono bg-muted p-4 rounded-md border border-border",children:u}):f.jsx(zl,{src:u,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Get a prompt to see its content here"})})})]})})]})})}var nV=t=>{throw TypeError(t)},XN=(t,e,n)=>e.has(t)||nV("Cannot "+n),Ht=(t,e,n)=>(XN(t,e,"read from private field"),n?n.call(t):e.get(t)),Ts=(t,e,n)=>e.has(t)?nV("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),sr=(t,e,n,r)=>(XN(t,e,"write to private field"),e.set(t,n),n),Kn=(t,e,n)=>(XN(t,e,"access private method"),n),Jhe=class extends Error{constructor(){super(...arguments),this.status=500,this.name="NoClientIdProvidedException",this.message='Missing Client ID. Pass it to the constructor (createClient("client_01HXRMBQ9BJ3E7QSTQ9X2PHVB7"))'}};function Zhe(t,e){if(!e.has("code"))return!1;const{pathname:r}=window.location,s=new URL(t).pathname;return r===s||r===`${s}/`}function epe(){let t={};function e(i,a){t[i]=a}function n(i){return t[i]}function r(i){delete t[i]}function s(){t={}}return{setItem:e,getItem:n,removeItem:r,reset:s}}var Ms=epe();async function tpe(){const t=npe(),e=await rpe(t);return{codeVerifier:t,codeChallenge:e}}function npe(){const t=crypto.getRandomValues(new Uint32Array(96));return rV(t)}async function rpe(t){const e=await spe(t);return rV(e)}function rV(t){return btoa(Array.from(new Uint8Array(t),e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function spe(t){const n=new TextEncoder().encode(t);return crypto.subtle.digest("SHA-256",n)}function u3(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return atob(e+n)}function ipe(t){const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT format");try{const n=JSON.parse(u3(e[0])),r=JSON.parse(u3(e[1]));return{header:n,payload:r}}catch(n){throw new Error(`Failed to decode JWT: ${n instanceof Error?n.message:String(n)}`)}}var ts={codeVerifier:"workos:code-verifier",user:"workos:user",accessToken:"workos:access-token",refreshToken:"workos:refresh-token",expiresAt:"workos:expires-at"};function D0(t){return ipe(t).payload}function sV(t,{devMode:e=!1}={}){const{user:n,accessToken:r,refreshToken:s}=t;Ms.setItem(ts.user,n),Ms.setItem(ts.accessToken,r),(e?window.localStorage:Ms).setItem(ts.refreshToken,s);const{exp:i,iat:a}=D0(r),l=i-a,u=Date.now()+l*1e3;Ms.setItem(ts.expiresAt,u)}function iV({devMode:t=!1}={}){Ms.removeItem(ts.user),Ms.removeItem(ts.accessToken),(t?window.localStorage:Ms).removeItem(ts.refreshToken)}function aV({devMode:t=!1}={}){return(t?window.localStorage:Ms).getItem(ts.refreshToken)}function ape(t){const e=new URLSearchParams,n=Object.keys(t).sort();for(const r of n){const s=t[r];s&&e.append(r,s)}return e.toString()}var QN=class extends Error{},sx=class extends QN{},ope=class extends QN{},BT=class extends QN{constructor(){super(...arguments),this.message="No access token available"}},lpe=class Vp{constructor(){this.locked=new Map,this.addToLocked=(e,n)=>{let r=this.locked.get(e);r===void 0?n===void 0?this.locked.set(e,[]):this.locked.set(e,[n]):n!==void 0&&(r.unshift(n),this.locked.set(e,r))},this.isLocked=e=>this.locked.has(e),this.lock=e=>new Promise((n,r)=>{this.isLocked(e)?this.addToLocked(e,n):(this.addToLocked(e),n())}),this.unlock=e=>{let n=this.locked.get(e);if(n===void 0||n.length===0){this.locked.delete(e);return}let r=n.pop();this.locked.set(e,n),r!==void 0&&setTimeout(r,0)}}static getInstance(){return Vp.instance===void 0&&(Vp.instance=new Vp),Vp.instance}};function Ed(){return lpe.getInstance()}var QE="browser-tabs-lock-key",fy={key:async t=>{throw new Error("Unsupported")},getItem:async t=>{throw new Error("Unsupported")},clear:async()=>window.localStorage.clear(),removeItem:async t=>{throw new Error("Unsupported")},setItem:async(t,e)=>{throw new Error("Unsupported")},keySync:t=>window.localStorage.key(t),getItemSync:t=>window.localStorage.getItem(t),clearSync:()=>window.localStorage.clear(),removeItemSync:t=>window.localStorage.removeItem(t),setItemSync:(t,e)=>window.localStorage.setItem(t,e)};function JE(t){return new Promise(e=>setTimeout(e,t))}function qT(t){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";let n="";for(let r=0;r<t;r++){const s=Math.floor(Math.random()*e.length);n+=e[s]}return n}function cpe(){return Date.now().toString()+qT(15)}var oV=class us{constructor(e){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=cpe(),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=e,us.waiters===void 0&&(us.waiters=[])}async acquireLock(e,n=5e3){let r=Date.now()+qT(4);const s=Date.now()+n,i=`${QE}-${e}`,a=this.storageHandler===void 0?fy:this.storageHandler;for(;Date.now()<s;){if(await JE(30),a.getItemSync(i)===null){const u=`${this.id}-${e}-${r}`;await JE(Math.floor(Math.random()*25)),a.setItemSync(i,JSON.stringify({id:this.id,iat:r,timeoutKey:u,timeAcquired:Date.now(),timeRefreshed:Date.now()})),await JE(30);let d=a.getItemSync(i);if(d!==null){let p=JSON.parse(d);if(p.id===this.id&&p.iat===r)return this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(i,r),!0}}else us.lockCorrector(this.storageHandler===void 0?fy:this.storageHandler),await this.waitForSomethingToChange(s);r=Date.now()+qT(4)}return!1}async refreshLockWhileAcquired(e,n){setTimeout(async()=>{if(await Ed().lock(n),!this.acquiredIatSet.has(n)){Ed().unlock(n);return}const r=this.storageHandler===void 0?fy:this.storageHandler;let s=r.getItemSync(e);if(s!==null){let i=JSON.parse(s);i.timeRefreshed=Date.now(),r.setItemSync(e,JSON.stringify(i)),Ed().unlock(n)}else{Ed().unlock(n);return}this.refreshLockWhileAcquired(e,n)},1e3)}async waitForSomethingToChange(e){await new Promise(n=>{let r=!1,s=Date.now();const i=50;let a=!1;function l(){if(a||(window.removeEventListener("storage",l),us.removeFromWaiting(l),clearTimeout(u),a=!0),!r){r=!0;let d=i-(Date.now()-s);d>0?setTimeout(n,d):n(null)}}window.addEventListener("storage",l),us.addToWaiting(l);let u=setTimeout(l,Math.max(0,e-Date.now()))})}static addToWaiting(e){this.removeFromWaiting(e),us.waiters!==void 0&&us.waiters.push(e)}static removeFromWaiting(e){us.waiters!==void 0&&(us.waiters=us.waiters.filter(n=>n!==e))}static notifyWaiters(){if(us.waiters===void 0)return;[...us.waiters].forEach(n=>n())}async releaseLock(e){return await this.releaseLock__private__(e)}async releaseLock__private__(e){const n=this.storageHandler===void 0?fy:this.storageHandler,r=`${QE}-${e}`;let s=n.getItemSync(r);if(s===null)return;let i=JSON.parse(s);i.id===this.id&&(await Ed().lock(i.iat),this.acquiredIatSet.delete(i.iat),n.removeItemSync(r),Ed().unlock(i.iat),us.notifyWaiters())}static lockCorrector(e){const n=Date.now()-5e3,r=e,s=[];let i=0;for(;;){let l=r.keySync(i);if(l===null)break;s.push(l),i++}let a=!1;for(let l=0;l<s.length;l++){const u=s[l];if(u.includes(QE)){let d=r.getItemSync(u);if(d!==null){let p=JSON.parse(d);(p.timeRefreshed===void 0&&p.timeAcquired<n||p.timeRefreshed!==void 0&&p.timeRefreshed<n)&&(r.removeItemSync(u),a=!0)}}}a&&us.notifyWaiters()}};oV.waiters=void 0;var upe=oV,dpe=1e4;function fpe(t,e,{timeout:n=dpe}={}){return"locks"in navigator?hpe(t,e,n):ppe(t,e,n)}async function hpe(t,e,n){try{return await navigator.locks.request(t,{signal:AbortSignal.timeout(n)},e)}catch(r){if(r instanceof DOMException)switch(r.name){case"AbortError":throw new JN("AcquisitionTimeoutError",t,"Native")}throw r}}async function ppe(t,e,n){const r=new upe;try{if(await r.acquireLock(t,n))return await e();throw new JN("AcquisitionTimeoutError",t,"Vendor")}finally{await r.releaseLock(t)}}var JN=class extends Error{constructor(t,e,n){super(`Lock acquisition timed out for "${e}" (${n})`),this.name=t,this.lockName=e}},mpe=t=>({object:t.object,id:t.id,email:t.email,emailVerified:t.email_verified,firstName:t.first_name,profilePictureUrl:t.profile_picture_url,lastName:t.last_name,lastSignInAt:t.last_sign_in_at,externalId:t.external_id,createdAt:t.created_at,updatedAt:t.updated_at}),d3=t=>{const{user:e,organization_id:n,access_token:r,refresh_token:s,impersonator:i,...a}=t;return{user:mpe(e),organizationId:n,accessToken:r,refreshToken:s,impersonator:i,...a}},gpe="api.workos.com",Vd,$d,Zy,VT,vpe=class{constructor({clientId:t,hostname:e=gpe,port:n,https:r=!0}){Ts(this,Zy),Ts(this,Vd),Ts(this,$d),sr(this,Vd,`${r?"https":"http"}://${e}${n?`:${n}`:""}`),sr(this,$d,t)}async authenticateWithRefreshToken({refreshToken:t,organizationId:e,useCookie:n}){const r=await Kn(this,Zy,VT).call(this,"/user_management/authenticate",{useCookie:n,body:{client_id:Ht(this,$d),grant_type:"refresh_token",...!n&&{refresh_token:t},organization_id:e}});if(r.ok){const s=await r.json();return d3(s)}else{const s=await r.json();throw new sx(s.error_description)}}async authenticateWithCode({code:t,codeVerifier:e,useCookie:n}){const r=await Kn(this,Zy,VT).call(this,"/user_management/authenticate",{useCookie:n,body:{code:t,client_id:Ht(this,$d),grant_type:"authorization_code",code_verifier:e}});if(r.ok){const i=await r.json();return d3(i)}const s=await r.json();throw new ope(s.error_description)}getAuthorizationUrl({connectionId:t,context:e,domainHint:n,loginHint:r,organizationId:s,provider:i="authkit",redirectUri:a,state:l,screenHint:u,passwordResetToken:d,invitationToken:p,codeChallenge:h,codeChallengeMethod:g}){if(!i&&!t&&!s)throw new TypeError("Incomplete arguments. Need to specify either a 'connectionId', 'organizationId', or 'provider'.");if(i!=="authkit"&&u)throw new TypeError("'screenHint' is only supported for 'authkit' provider");e&&console.warn("`context` is deprecated. We previously required initiate login endpoints to return the\n`context` query parameter when getting the authorization URL. This is no longer necessary.");const v=ape({connection_id:t,organization_id:s,domain_hint:n,login_hint:r,provider:i,client_id:Ht(this,$d),redirect_uri:a,response_type:"code",state:l,screen_hint:u,invitation_token:p,password_reset_token:d,code_challenge:h,code_challenge_method:g});return`${Ht(this,Vd)}/user_management/authorize?${v}`}getLogoutUrl({sessionId:t,returnTo:e}){const n=new URL("/user_management/sessions/logout",Ht(this,Vd));return n.searchParams.set("session_id",t),e&&n.searchParams.set("return_to",e),n}};Vd=new WeakMap;$d=new WeakMap;Zy=new WeakSet;VT=function(t,{body:e,useCookie:n}){return fetch(new URL(t,Ht(this,Vd)),{method:"POST",...n&&{credentials:"include"},headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json"},body:JSON.stringify(e)})};var f3="workos_organization_id",ype="WORKOS_REFRESH_SESSION",gr,ix,nu,tm,Aa,ax,ox,$m,zm,lx,On,lV,nm,rm,cV,ZN,Hp,eR,tR,nR,bpe=class{constructor(t,{apiHostname:e,https:n,port:r,redirectUri:s=window.origin,devMode:i=location.hostname==="localhost"||location.hostname==="127.0.0.1",onBeforeAutoRefresh:a=()=>!document.hidden,onRedirectCallback:l=h=>{},onRefresh:u,onRefreshFailure:d,refreshBufferInterval:p=10}={}){if(Ts(this,On),Ts(this,gr),Ts(this,ix),Ts(this,nu),Ts(this,tm),Ts(this,Aa),Ts(this,ax),Ts(this,ox),Ts(this,$m),Ts(this,zm),Ts(this,lx),!t)throw new Jhe;sr(this,nu,new vpe({clientId:t,hostname:e,port:r,https:n})),sr(this,Aa,i),sr(this,tm,s),sr(this,gr,{tag:"INITIAL"}),sr(this,ax,a),sr(this,ox,l),sr(this,$m,u),sr(this,zm,d),sr(this,lx,p)}async initialize(){if(Ht(this,gr).tag!=="INITIAL")return;const t=new URLSearchParams(window.location.search);if(Zhe(Ht(this,tm),t))await Kn(this,On,lV).call(this);else if(document.cookie.includes("workos-has-session=")||aV({devMode:Ht(this,Aa)}))try{await Kn(this,On,rm).call(this),Kn(this,On,nm).call(this)}catch{}}async getSignInUrl(t={}){return await Kn(this,On,Hp).call(this,{...t,type:"sign-in"})}async getSignUpUrl(t={}){return await Kn(this,On,Hp).call(this,{...t,type:"sign-up"})}async signIn(t={}){const e=await Kn(this,On,Hp).call(this,{...t,type:"sign-in"});window.location.assign(e)}async signUp(t={}){const e=await Kn(this,On,Hp).call(this,{...t,type:"sign-up"});window.location.assign(e)}signOut(t={navigate:!0}){const e=t.navigate??!0,n=Ms.getItem(ts.accessToken);if(typeof n!="string")return;const{sid:r}=D0(n),s=Ht(this,nu).getLogoutUrl({sessionId:r,returnTo:t?.returnTo});if(s)if(iV({devMode:Ht(this,Aa)}),e)window.location.assign(s);else return new Promise(async i=>{fetch(s,{mode:"no-cors",credentials:"include"}).catch(a=>{console.warn("AuthKit: Failed to send logout request",a)}).finally(i)})}async getAccessToken(t){if(t?.forceRefresh||Kn(this,On,ZN).call(this))try{await Kn(this,On,rm).call(this)}catch(n){throw n instanceof sx?new BT:n}const e=Kn(this,On,eR).call(this);if(!e)throw new BT;return e}getUser(){const t=Ms.getItem(ts.user);return t||null}dispose(){clearTimeout(Ht(this,ix)),Ms.reset()}async switchToOrganization({organizationId:t,signInOpts:e={}}){try{await Kn(this,On,rm).call(this,{organizationId:t})}catch(n){if(n instanceof sx)this.signIn({...e,organizationId:t});else throw n}}};gr=new WeakMap;ix=new WeakMap;nu=new WeakMap;tm=new WeakMap;Aa=new WeakMap;ax=new WeakMap;ox=new WeakMap;$m=new WeakMap;zm=new WeakMap;lx=new WeakMap;On=new WeakSet;lV=async function(){if(Ht(this,gr).tag!=="INITIAL")return;const t=new URL(window.location.href),e=t.searchParams.get("code"),n=t.searchParams.get("state"),r=n?JSON.parse(n):void 0,s=window.sessionStorage.getItem(ts.codeVerifier);if(e)if(s)try{sr(this,gr,{tag:"AUTHENTICATING",response:Ht(this,nu).authenticateWithCode({code:e,codeVerifier:s,useCookie:Ht(this,On,tR)})});const a=await Ht(this,gr).response;a&&(sr(this,gr,{tag:"AUTHENTICATED"}),Kn(this,On,nm).call(this),sV(a,{devMode:Ht(this,Aa)}),Kn(this,On,nR).call(this,a),Ht(this,ox).call(this,{state:r,...a}))}catch(a){sr(this,gr,{tag:"ERROR"}),console.error(a)}else sr(this,gr,{tag:"ERROR"}),console.error(`Couldn't exchange code.
|
|
1775
|
+
Error:`,a),(n==="error"?console.error:n==="warn"?console.warn:n==="debug"?console.debug:console.log)(...h)}function Qfe(){const[,t]=w.useState({});return w.useEffect(()=>{const e=Yi.subscribe(()=>{t({})});return()=>{e()}},[]),{entries:Yi.getEntries(),config:Yi.getConfig(),setConfig:Yi.setConfig.bind(Yi),clearBuffer:Yi.clearBuffer.bind(Yi)}}var qp={exports:{}};/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */var Jfe=qp.exports,mL;function Zfe(){return mL||(mL=1,function(t,e){(function(n,r){r(e)})(Jfe,function(n){function r(){for(var ne=arguments.length,Q=Array(ne),se=0;se<ne;se++)Q[se]=arguments[se];if(Q.length>1){Q[0]=Q[0].slice(0,-1);for(var ye=Q.length-1,me=1;me<ye;++me)Q[me]=Q[me].slice(1,-1);return Q[ye]=Q[ye].slice(1),Q.join("")}else return Q[0]}function s(ne){return"(?:"+ne+")"}function i(ne){return ne===void 0?"undefined":ne===null?"null":Object.prototype.toString.call(ne).split(" ").pop().split("]").shift().toLowerCase()}function a(ne){return ne.toUpperCase()}function l(ne){return ne!=null?ne instanceof Array?ne:typeof ne.length!="number"||ne.split||ne.setInterval||ne.call?[ne]:Array.prototype.slice.call(ne):[]}function u(ne,Q){var se=ne;if(Q)for(var ye in Q)se[ye]=Q[ye];return se}function d(ne){var Q="[A-Za-z]",se="[0-9]",ye=r(se,"[A-Fa-f]"),me=s(s("%[EFef]"+ye+"%"+ye+ye+"%"+ye+ye)+"|"+s("%[89A-Fa-f]"+ye+"%"+ye+ye)+"|"+s("%"+ye+ye)),nt="[\\:\\/\\?\\#\\[\\]\\@]",tt="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",Mt=r(nt,tt),sn=ne?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",hn=ne?"[\\uE000-\\uF8FF]":"[]",at=r(Q,se,"[\\-\\.\\_\\~]",sn);s(Q+r(Q,se,"[\\+\\-\\.]")+"*"),s(s(me+"|"+r(at,tt,"[\\:]"))+"*");var ln=s(s("25[0-5]")+"|"+s("2[0-4]"+se)+"|"+s("1"+se+se)+"|"+s("0?[1-9]"+se)+"|0?0?"+se),jn=s(ln+"\\."+ln+"\\."+ln+"\\."+ln),lt=s(ye+"{1,4}"),an=s(s(lt+"\\:"+lt)+"|"+jn),Hn=s(s(lt+"\\:")+"{6}"+an),yn=s("\\:\\:"+s(lt+"\\:")+"{5}"+an),zi=s(s(lt)+"?\\:\\:"+s(lt+"\\:")+"{4}"+an),oi=s(s(s(lt+"\\:")+"{0,1}"+lt)+"?\\:\\:"+s(lt+"\\:")+"{3}"+an),as=s(s(s(lt+"\\:")+"{0,2}"+lt)+"?\\:\\:"+s(lt+"\\:")+"{2}"+an),Fi=s(s(s(lt+"\\:")+"{0,3}"+lt)+"?\\:\\:"+lt+"\\:"+an),zr=s(s(s(lt+"\\:")+"{0,4}"+lt)+"?\\:\\:"+an),Qr=s(s(s(lt+"\\:")+"{0,5}"+lt)+"?\\:\\:"+lt),zs=s(s(s(lt+"\\:")+"{0,6}"+lt)+"?\\:\\:"),bs=s([Hn,yn,zi,oi,as,Fi,zr,Qr,zs].join("|")),Fs=s(s(at+"|"+me)+"+");s("[vV]"+ye+"+\\."+r(at,tt,"[\\:]")+"+"),s(s(me+"|"+r(at,tt))+"*");var Qa=s(me+"|"+r(at,tt,"[\\:\\@]"));return s(s(me+"|"+r(at,tt,"[\\@]"))+"+"),s(s(Qa+"|"+r("[\\/\\?]",hn))+"*"),{NOT_SCHEME:new RegExp(r("[^]",Q,se,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(r("[^\\%\\:]",at,tt),"g"),NOT_HOST:new RegExp(r("[^\\%\\[\\]\\:]",at,tt),"g"),NOT_PATH:new RegExp(r("[^\\%\\/\\:\\@]",at,tt),"g"),NOT_PATH_NOSCHEME:new RegExp(r("[^\\%\\/\\@]",at,tt),"g"),NOT_QUERY:new RegExp(r("[^\\%]",at,tt,"[\\:\\@\\/\\?]",hn),"g"),NOT_FRAGMENT:new RegExp(r("[^\\%]",at,tt,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(r("[^]",at,tt),"g"),UNRESERVED:new RegExp(at,"g"),OTHER_CHARS:new RegExp(r("[^\\%]",at,Mt),"g"),PCT_ENCODED:new RegExp(me,"g"),IPV4ADDRESS:new RegExp("^("+jn+")$"),IPV6ADDRESS:new RegExp("^\\[?("+bs+")"+s(s("\\%25|\\%(?!"+ye+"{2})")+"("+Fs+")")+"?\\]?$")}}var p=d(!1),h=d(!0),g=function(){function ne(Q,se){var ye=[],me=!0,nt=!1,tt=void 0;try{for(var Mt=Q[Symbol.iterator](),sn;!(me=(sn=Mt.next()).done)&&(ye.push(sn.value),!(se&&ye.length===se));me=!0);}catch(hn){nt=!0,tt=hn}finally{try{!me&&Mt.return&&Mt.return()}finally{if(nt)throw tt}}return ye}return function(Q,se){if(Array.isArray(Q))return Q;if(Symbol.iterator in Object(Q))return ne(Q,se);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),v=function(ne){if(Array.isArray(ne)){for(var Q=0,se=Array(ne.length);Q<ne.length;Q++)se[Q]=ne[Q];return se}else return Array.from(ne)},b=2147483647,x=36,E=1,S=26,k=38,T=700,R=72,j=128,A="-",N=/^xn--/,M=/[^\0-\x7E]/,I=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=x-E,z=Math.floor,G=String.fromCharCode;function W(ne){throw new RangeError(O[ne])}function X(ne,Q){for(var se=[],ye=ne.length;ye--;)se[ye]=Q(ne[ye]);return se}function F(ne,Q){var se=ne.split("@"),ye="";se.length>1&&(ye=se[0]+"@",ne=se[1]),ne=ne.replace(I,".");var me=ne.split("."),nt=X(me,Q).join(".");return ye+nt}function Y(ne){for(var Q=[],se=0,ye=ne.length;se<ye;){var me=ne.charCodeAt(se++);if(me>=55296&&me<=56319&&se<ye){var nt=ne.charCodeAt(se++);(nt&64512)==56320?Q.push(((me&1023)<<10)+(nt&1023)+65536):(Q.push(me),se--)}else Q.push(me)}return Q}var H=function(Q){return String.fromCodePoint.apply(String,v(Q))},te=function(Q){return Q-48<10?Q-22:Q-65<26?Q-65:Q-97<26?Q-97:x},P=function(Q,se){return Q+22+75*(Q<26)-((se!=0)<<5)},re=function(Q,se,ye){var me=0;for(Q=ye?z(Q/T):Q>>1,Q+=z(Q/se);Q>L*S>>1;me+=x)Q=z(Q/L);return z(me+(L+1)*Q/(Q+k))},ue=function(Q){var se=[],ye=Q.length,me=0,nt=j,tt=R,Mt=Q.lastIndexOf(A);Mt<0&&(Mt=0);for(var sn=0;sn<Mt;++sn)Q.charCodeAt(sn)>=128&&W("not-basic"),se.push(Q.charCodeAt(sn));for(var hn=Mt>0?Mt+1:0;hn<ye;){for(var at=me,ln=1,jn=x;;jn+=x){hn>=ye&&W("invalid-input");var lt=te(Q.charCodeAt(hn++));(lt>=x||lt>z((b-me)/ln))&&W("overflow"),me+=lt*ln;var an=jn<=tt?E:jn>=tt+S?S:jn-tt;if(lt<an)break;var Hn=x-an;ln>z(b/Hn)&&W("overflow"),ln*=Hn}var yn=se.length+1;tt=re(me-at,yn,at==0),z(me/yn)>b-nt&&W("overflow"),nt+=z(me/yn),me%=yn,se.splice(me++,0,nt)}return String.fromCodePoint.apply(String,se)},D=function(Q){var se=[];Q=Y(Q);var ye=Q.length,me=j,nt=0,tt=R,Mt=!0,sn=!1,hn=void 0;try{for(var at=Q[Symbol.iterator](),ln;!(Mt=(ln=at.next()).done);Mt=!0){var jn=ln.value;jn<128&&se.push(G(jn))}}catch(ha){sn=!0,hn=ha}finally{try{!Mt&&at.return&&at.return()}finally{if(sn)throw hn}}var lt=se.length,an=lt;for(lt&&se.push(A);an<ye;){var Hn=b,yn=!0,zi=!1,oi=void 0;try{for(var as=Q[Symbol.iterator](),Fi;!(yn=(Fi=as.next()).done);yn=!0){var zr=Fi.value;zr>=me&&zr<Hn&&(Hn=zr)}}catch(ha){zi=!0,oi=ha}finally{try{!yn&&as.return&&as.return()}finally{if(zi)throw oi}}var Qr=an+1;Hn-me>z((b-nt)/Qr)&&W("overflow"),nt+=(Hn-me)*Qr,me=Hn;var zs=!0,bs=!1,Fs=void 0;try{for(var Qa=Q[Symbol.iterator](),Fg;!(zs=(Fg=Qa.next()).done);zs=!0){var mh=Fg.value;if(mh<me&&++nt>b&&W("overflow"),mh==me){for(var Fr=nt,mc=x;;mc+=x){var Lu=mc<=tt?E:mc>=tt+S?S:mc-tt;if(Fr<Lu)break;var gc=Fr-Lu,gh=x-Lu;se.push(G(P(Lu+gc%gh,0))),Fr=z(gc/gh)}se.push(G(P(Fr,0))),tt=re(nt,Qr,an==lt),nt=0,++an}}}catch(ha){bs=!0,Fs=ha}finally{try{!zs&&Qa.return&&Qa.return()}finally{if(bs)throw Fs}}++nt,++me}return se.join("")},Z=function(Q){return F(Q,function(se){return N.test(se)?ue(se.slice(4).toLowerCase()):se})},he=function(Q){return F(Q,function(se){return M.test(se)?"xn--"+D(se):se})},V={version:"2.1.0",ucs2:{decode:Y,encode:H},decode:ue,encode:D,toASCII:he,toUnicode:Z},U={};function K(ne){var Q=ne.charCodeAt(0),se=void 0;return Q<16?se="%0"+Q.toString(16).toUpperCase():Q<128?se="%"+Q.toString(16).toUpperCase():Q<2048?se="%"+(Q>>6|192).toString(16).toUpperCase()+"%"+(Q&63|128).toString(16).toUpperCase():se="%"+(Q>>12|224).toString(16).toUpperCase()+"%"+(Q>>6&63|128).toString(16).toUpperCase()+"%"+(Q&63|128).toString(16).toUpperCase(),se}function ae(ne){for(var Q="",se=0,ye=ne.length;se<ye;){var me=parseInt(ne.substr(se+1,2),16);if(me<128)Q+=String.fromCharCode(me),se+=3;else if(me>=194&&me<224){if(ye-se>=6){var nt=parseInt(ne.substr(se+4,2),16);Q+=String.fromCharCode((me&31)<<6|nt&63)}else Q+=ne.substr(se,6);se+=6}else if(me>=224){if(ye-se>=9){var tt=parseInt(ne.substr(se+4,2),16),Mt=parseInt(ne.substr(se+7,2),16);Q+=String.fromCharCode((me&15)<<12|(tt&63)<<6|Mt&63)}else Q+=ne.substr(se,9);se+=9}else Q+=ne.substr(se,3),se+=3}return Q}function B(ne,Q){function se(ye){var me=ae(ye);return me.match(Q.UNRESERVED)?me:ye}return ne.scheme&&(ne.scheme=String(ne.scheme).replace(Q.PCT_ENCODED,se).toLowerCase().replace(Q.NOT_SCHEME,"")),ne.userinfo!==void 0&&(ne.userinfo=String(ne.userinfo).replace(Q.PCT_ENCODED,se).replace(Q.NOT_USERINFO,K).replace(Q.PCT_ENCODED,a)),ne.host!==void 0&&(ne.host=String(ne.host).replace(Q.PCT_ENCODED,se).toLowerCase().replace(Q.NOT_HOST,K).replace(Q.PCT_ENCODED,a)),ne.path!==void 0&&(ne.path=String(ne.path).replace(Q.PCT_ENCODED,se).replace(ne.scheme?Q.NOT_PATH:Q.NOT_PATH_NOSCHEME,K).replace(Q.PCT_ENCODED,a)),ne.query!==void 0&&(ne.query=String(ne.query).replace(Q.PCT_ENCODED,se).replace(Q.NOT_QUERY,K).replace(Q.PCT_ENCODED,a)),ne.fragment!==void 0&&(ne.fragment=String(ne.fragment).replace(Q.PCT_ENCODED,se).replace(Q.NOT_FRAGMENT,K).replace(Q.PCT_ENCODED,a)),ne}function J(ne){return ne.replace(/^0*(.*)/,"$1")||"0"}function oe(ne,Q){var se=ne.match(Q.IPV4ADDRESS)||[],ye=g(se,2),me=ye[1];return me?me.split(".").map(J).join("."):ne}function fe(ne,Q){var se=ne.match(Q.IPV6ADDRESS)||[],ye=g(se,3),me=ye[1],nt=ye[2];if(me){for(var tt=me.toLowerCase().split("::").reverse(),Mt=g(tt,2),sn=Mt[0],hn=Mt[1],at=hn?hn.split(":").map(J):[],ln=sn.split(":").map(J),jn=Q.IPV4ADDRESS.test(ln[ln.length-1]),lt=jn?7:8,an=ln.length-lt,Hn=Array(lt),yn=0;yn<lt;++yn)Hn[yn]=at[yn]||ln[an+yn]||"";jn&&(Hn[lt-1]=oe(Hn[lt-1],Q));var zi=Hn.reduce(function(Qr,zs,bs){if(!zs||zs==="0"){var Fs=Qr[Qr.length-1];Fs&&Fs.index+Fs.length===bs?Fs.length++:Qr.push({index:bs,length:1})}return Qr},[]),oi=zi.sort(function(Qr,zs){return zs.length-Qr.length})[0],as=void 0;if(oi&&oi.length>1){var Fi=Hn.slice(0,oi.index),zr=Hn.slice(oi.index+oi.length);as=Fi.join(":")+"::"+zr.join(":")}else as=Hn.join(":");return nt&&(as+="%"+nt),as}else return ne}var be=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Ae="".match(/(){0}/)[1]===void 0;function Oe(ne){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se={},ye=Q.iri!==!1?h:p;Q.reference==="suffix"&&(ne=(Q.scheme?Q.scheme+":":"")+"//"+ne);var me=ne.match(be);if(me){Ae?(se.scheme=me[1],se.userinfo=me[3],se.host=me[4],se.port=parseInt(me[5],10),se.path=me[6]||"",se.query=me[7],se.fragment=me[8],isNaN(se.port)&&(se.port=me[5])):(se.scheme=me[1]||void 0,se.userinfo=ne.indexOf("@")!==-1?me[3]:void 0,se.host=ne.indexOf("//")!==-1?me[4]:void 0,se.port=parseInt(me[5],10),se.path=me[6]||"",se.query=ne.indexOf("?")!==-1?me[7]:void 0,se.fragment=ne.indexOf("#")!==-1?me[8]:void 0,isNaN(se.port)&&(se.port=ne.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?me[4]:void 0)),se.host&&(se.host=fe(oe(se.host,ye),ye)),se.scheme===void 0&&se.userinfo===void 0&&se.host===void 0&&se.port===void 0&&!se.path&&se.query===void 0?se.reference="same-document":se.scheme===void 0?se.reference="relative":se.fragment===void 0?se.reference="absolute":se.reference="uri",Q.reference&&Q.reference!=="suffix"&&Q.reference!==se.reference&&(se.error=se.error||"URI is not a "+Q.reference+" reference.");var nt=U[(Q.scheme||se.scheme||"").toLowerCase()];if(!Q.unicodeSupport&&(!nt||!nt.unicodeSupport)){if(se.host&&(Q.domainHost||nt&&nt.domainHost))try{se.host=V.toASCII(se.host.replace(ye.PCT_ENCODED,ae).toLowerCase())}catch(tt){se.error=se.error||"Host's domain name can not be converted to ASCII via punycode: "+tt}B(se,p)}else B(se,ye);nt&&nt.parse&&nt.parse(se,Q)}else se.error=se.error||"URI can not be parsed.";return se}function Ne(ne,Q){var se=Q.iri!==!1?h:p,ye=[];return ne.userinfo!==void 0&&(ye.push(ne.userinfo),ye.push("@")),ne.host!==void 0&&ye.push(fe(oe(String(ne.host),se),se).replace(se.IPV6ADDRESS,function(me,nt,tt){return"["+nt+(tt?"%25"+tt:"")+"]"})),(typeof ne.port=="number"||typeof ne.port=="string")&&(ye.push(":"),ye.push(String(ne.port))),ye.length?ye.join(""):void 0}var Qe=/^\.\.?\//,dt=/^\/\.(\/|$)/,Be=/^\/\.\.(\/|$)/,pt=/^\/?(?:.|\n)*?(?=\/|$)/;function De(ne){for(var Q=[];ne.length;)if(ne.match(Qe))ne=ne.replace(Qe,"");else if(ne.match(dt))ne=ne.replace(dt,"/");else if(ne.match(Be))ne=ne.replace(Be,"/"),Q.pop();else if(ne==="."||ne==="..")ne="";else{var se=ne.match(pt);if(se){var ye=se[0];ne=ne.slice(ye.length),Q.push(ye)}else throw new Error("Unexpected dot segment condition")}return Q.join("")}function et(ne){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=Q.iri?h:p,ye=[],me=U[(Q.scheme||ne.scheme||"").toLowerCase()];if(me&&me.serialize&&me.serialize(ne,Q),ne.host&&!se.IPV6ADDRESS.test(ne.host)){if(Q.domainHost||me&&me.domainHost)try{ne.host=Q.iri?V.toUnicode(ne.host):V.toASCII(ne.host.replace(se.PCT_ENCODED,ae).toLowerCase())}catch(Mt){ne.error=ne.error||"Host's domain name can not be converted to "+(Q.iri?"Unicode":"ASCII")+" via punycode: "+Mt}}B(ne,se),Q.reference!=="suffix"&&ne.scheme&&(ye.push(ne.scheme),ye.push(":"));var nt=Ne(ne,Q);if(nt!==void 0&&(Q.reference!=="suffix"&&ye.push("//"),ye.push(nt),ne.path&&ne.path.charAt(0)!=="/"&&ye.push("/")),ne.path!==void 0){var tt=ne.path;!Q.absolutePath&&(!me||!me.absolutePath)&&(tt=De(tt)),nt===void 0&&(tt=tt.replace(/^\/\//,"/%2F")),ye.push(tt)}return ne.query!==void 0&&(ye.push("?"),ye.push(ne.query)),ne.fragment!==void 0&&(ye.push("#"),ye.push(ne.fragment)),ye.join("")}function ot(ne,Q){var se=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ye=arguments[3],me={};return ye||(ne=Oe(et(ne,se),se),Q=Oe(et(Q,se),se)),se=se||{},!se.tolerant&&Q.scheme?(me.scheme=Q.scheme,me.userinfo=Q.userinfo,me.host=Q.host,me.port=Q.port,me.path=De(Q.path||""),me.query=Q.query):(Q.userinfo!==void 0||Q.host!==void 0||Q.port!==void 0?(me.userinfo=Q.userinfo,me.host=Q.host,me.port=Q.port,me.path=De(Q.path||""),me.query=Q.query):(Q.path?(Q.path.charAt(0)==="/"?me.path=De(Q.path):((ne.userinfo!==void 0||ne.host!==void 0||ne.port!==void 0)&&!ne.path?me.path="/"+Q.path:ne.path?me.path=ne.path.slice(0,ne.path.lastIndexOf("/")+1)+Q.path:me.path=Q.path,me.path=De(me.path)),me.query=Q.query):(me.path=ne.path,Q.query!==void 0?me.query=Q.query:me.query=ne.query),me.userinfo=ne.userinfo,me.host=ne.host,me.port=ne.port),me.scheme=ne.scheme),me.fragment=Q.fragment,me}function lr(ne,Q,se){var ye=u({scheme:"null"},se);return et(ot(Oe(ne,ye),Oe(Q,ye),ye,!0),ye)}function xe(ne,Q){return typeof ne=="string"?ne=et(Oe(ne,Q),Q):i(ne)==="object"&&(ne=Oe(et(ne,Q),Q)),ne}function Te(ne,Q,se){return typeof ne=="string"?ne=et(Oe(ne,se),se):i(ne)==="object"&&(ne=et(ne,se)),typeof Q=="string"?Q=et(Oe(Q,se),se):i(Q)==="object"&&(Q=et(Q,se)),ne===Q}function st(ne,Q){return ne&&ne.toString().replace(!Q||!Q.iri?p.ESCAPE:h.ESCAPE,K)}function qe(ne,Q){return ne&&ne.toString().replace(!Q||!Q.iri?p.PCT_ENCODED:h.PCT_ENCODED,ae)}var At={scheme:"http",domainHost:!0,parse:function(Q,se){return Q.host||(Q.error=Q.error||"HTTP URIs must have a host."),Q},serialize:function(Q,se){var ye=String(Q.scheme).toLowerCase()==="https";return(Q.port===(ye?443:80)||Q.port==="")&&(Q.port=void 0),Q.path||(Q.path="/"),Q}},Jn={scheme:"https",domainHost:At.domainHost,parse:At.parse,serialize:At.serialize};function Zn(ne){return typeof ne.secure=="boolean"?ne.secure:String(ne.scheme).toLowerCase()==="wss"}var Pe={scheme:"ws",domainHost:!0,parse:function(Q,se){var ye=Q;return ye.secure=Zn(ye),ye.resourceName=(ye.path||"/")+(ye.query?"?"+ye.query:""),ye.path=void 0,ye.query=void 0,ye},serialize:function(Q,se){if((Q.port===(Zn(Q)?443:80)||Q.port==="")&&(Q.port=void 0),typeof Q.secure=="boolean"&&(Q.scheme=Q.secure?"wss":"ws",Q.secure=void 0),Q.resourceName){var ye=Q.resourceName.split("?"),me=g(ye,2),nt=me[0],tt=me[1];Q.path=nt&&nt!=="/"?nt:void 0,Q.query=tt,Q.resourceName=void 0}return Q.fragment=void 0,Q}},bt={scheme:"wss",domainHost:Pe.domainHost,parse:Pe.parse,serialize:Pe.serialize},Xt={},vt="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",Qt="[0-9A-Fa-f]",cr=s(s("%[EFef]"+Qt+"%"+Qt+Qt+"%"+Qt+Qt)+"|"+s("%[89A-Fa-f]"+Qt+"%"+Qt+Qt)+"|"+s("%"+Qt+Qt)),br="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Yo="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",pc=r(Yo,'[\\"\\\\]'),fa="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Du=new RegExp(vt,"g"),ft=new RegExp(cr,"g"),Ln=new RegExp(r("[^]",br,"[\\.]",'[\\"]',pc),"g"),$n=new RegExp(r("[^]",vt,fa),"g"),xr=$n;function $i(ne){var Q=ae(ne);return Q.match(Du)?Q:ne}var Vn={scheme:"mailto",parse:function(Q,se){var ye=Q,me=ye.to=ye.path?ye.path.split(","):[];if(ye.path=void 0,ye.query){for(var nt=!1,tt={},Mt=ye.query.split("&"),sn=0,hn=Mt.length;sn<hn;++sn){var at=Mt[sn].split("=");switch(at[0]){case"to":for(var ln=at[1].split(","),jn=0,lt=ln.length;jn<lt;++jn)me.push(ln[jn]);break;case"subject":ye.subject=qe(at[1],se);break;case"body":ye.body=qe(at[1],se);break;default:nt=!0,tt[qe(at[0],se)]=qe(at[1],se);break}}nt&&(ye.headers=tt)}ye.query=void 0;for(var an=0,Hn=me.length;an<Hn;++an){var yn=me[an].split("@");if(yn[0]=qe(yn[0]),se.unicodeSupport)yn[1]=qe(yn[1],se).toLowerCase();else try{yn[1]=V.toASCII(qe(yn[1],se).toLowerCase())}catch(zi){ye.error=ye.error||"Email address's domain name can not be converted to ASCII via punycode: "+zi}me[an]=yn.join("@")}return ye},serialize:function(Q,se){var ye=Q,me=l(Q.to);if(me){for(var nt=0,tt=me.length;nt<tt;++nt){var Mt=String(me[nt]),sn=Mt.lastIndexOf("@"),hn=Mt.slice(0,sn).replace(ft,$i).replace(ft,a).replace(Ln,K),at=Mt.slice(sn+1);try{at=se.iri?V.toUnicode(at):V.toASCII(qe(at,se).toLowerCase())}catch(an){ye.error=ye.error||"Email address's domain name can not be converted to "+(se.iri?"Unicode":"ASCII")+" via punycode: "+an}me[nt]=hn+"@"+at}ye.path=me.join(",")}var ln=Q.headers=Q.headers||{};Q.subject&&(ln.subject=Q.subject),Q.body&&(ln.body=Q.body);var jn=[];for(var lt in ln)ln[lt]!==Xt[lt]&&jn.push(lt.replace(ft,$i).replace(ft,a).replace($n,K)+"="+ln[lt].replace(ft,$i).replace(ft,a).replace(xr,K));return jn.length&&(ye.query=jn.join("&")),ye}},zn=/^([^\:]+)\:(.*)/,Rn={scheme:"urn",parse:function(Q,se){var ye=Q.path&&Q.path.match(zn),me=Q;if(ye){var nt=se.scheme||me.scheme||"urn",tt=ye[1].toLowerCase(),Mt=ye[2],sn=nt+":"+(se.nid||tt),hn=U[sn];me.nid=tt,me.nss=Mt,me.path=void 0,hn&&(me=hn.parse(me,se))}else me.error=me.error||"URN can not be parsed.";return me},serialize:function(Q,se){var ye=se.scheme||Q.scheme||"urn",me=Q.nid,nt=ye+":"+(se.nid||me),tt=U[nt];tt&&(Q=tt.serialize(Q,se));var Mt=Q,sn=Q.nss;return Mt.path=(me||se.nid)+":"+sn,Mt}},fn=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,er={scheme:"urn:uuid",parse:function(Q,se){var ye=Q;return ye.uuid=ye.nss,ye.nss=void 0,!se.tolerant&&(!ye.uuid||!ye.uuid.match(fn))&&(ye.error=ye.error||"UUID is not valid."),ye},serialize:function(Q,se){var ye=Q;return ye.nss=(Q.uuid||"").toLowerCase(),ye}};U[At.scheme]=At,U[Jn.scheme]=Jn,U[Pe.scheme]=Pe,U[bt.scheme]=bt,U[Vn.scheme]=Vn,U[Rn.scheme]=Rn,U[er.scheme]=er,n.SCHEMES=U,n.pctEncChar=K,n.pctDecChars=ae,n.parse=Oe,n.removeDotSegments=De,n.serialize=et,n.resolveComponents=ot,n.resolve=lr,n.normalize=xe,n.equal=Te,n.escapeComponent=st,n.unescapeComponent=qe,Object.defineProperty(n,"__esModule",{value:!0})})}(qp,qp.exports)),qp.exports}var lE,gL;function WN(){return gL||(gL=1,lE=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var a=i[s];if(!t(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}),lE}var cE,vL;function ehe(){return vL||(vL=1,cE=function(e){for(var n=0,r=e.length,s=0,i;s<r;)n++,i=e.charCodeAt(s++),i>=55296&&i<=56319&&s<r&&(i=e.charCodeAt(s),(i&64512)==56320&&s++);return n}),cE}var uE,yL;function nh(){if(yL)return uE;yL=1,uE={copy:t,checkDataType:e,checkDataTypes:n,coerceToTypes:s,toHash:i,getProperty:u,escapeQuotes:d,equal:WN(),ucs2length:ehe(),varOccurences:p,varReplace:h,schemaHasRules:g,schemaHasRulesExcept:v,schemaUnknownRules:b,toQuotedString:x,getPathExpr:E,getPath:S,getData:R,unescapeFragment:A,unescapeJsonPointer:I,escapeFragment:N,escapeJsonPointer:M};function t(O,L){L=L||{};for(var z in O)L[z]=O[z];return L}function e(O,L,z,G){var W=G?" !== ":" === ",X=G?" || ":" && ",F=G?"!":"",Y=G?"":"!";switch(O){case"null":return L+W+"null";case"array":return F+"Array.isArray("+L+")";case"object":return"("+F+L+X+"typeof "+L+W+'"object"'+X+Y+"Array.isArray("+L+"))";case"integer":return"(typeof "+L+W+'"number"'+X+Y+"("+L+" % 1)"+X+L+W+L+(z?X+F+"isFinite("+L+")":"")+")";case"number":return"(typeof "+L+W+'"'+O+'"'+(z?X+F+"isFinite("+L+")":"")+")";default:return"typeof "+L+W+'"'+O+'"'}}function n(O,L,z){switch(O.length){case 1:return e(O[0],L,z,!0);default:var G="",W=i(O);W.array&&W.object&&(G=W.null?"(":"(!"+L+" || ",G+="typeof "+L+' !== "object")',delete W.null,delete W.array,delete W.object),W.number&&delete W.integer;for(var X in W)G+=(G?" && ":"")+e(X,L,z,!0);return G}}var r=i(["string","number","integer","boolean","null"]);function s(O,L){if(Array.isArray(L)){for(var z=[],G=0;G<L.length;G++){var W=L[G];(r[W]||O==="array"&&W==="array")&&(z[z.length]=W)}if(z.length)return z}else{if(r[L])return[L];if(O==="array"&&L==="array")return["array"]}}function i(O){for(var L={},z=0;z<O.length;z++)L[O[z]]=!0;return L}var a=/^[a-z$_][a-z$_0-9]*$/i,l=/'|\\/g;function u(O){return typeof O=="number"?"["+O+"]":a.test(O)?"."+O:"['"+d(O)+"']"}function d(O){return O.replace(l,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function p(O,L){L+="[^0-9]";var z=O.match(new RegExp(L,"g"));return z?z.length:0}function h(O,L,z){return L+="([^0-9])",z=z.replace(/\$/g,"$$$$"),O.replace(new RegExp(L,"g"),z+"$1")}function g(O,L){if(typeof O=="boolean")return!O;for(var z in O)if(L[z])return!0}function v(O,L,z){if(typeof O=="boolean")return!O&&z!="not";for(var G in O)if(G!=z&&L[G])return!0}function b(O,L){if(typeof O!="boolean"){for(var z in O)if(!L[z])return z}}function x(O){return"'"+d(O)+"'"}function E(O,L,z,G){var W=z?"'/' + "+L+(G?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):G?"'[' + "+L+" + ']'":"'[\\'' + "+L+" + '\\']'";return j(O,W)}function S(O,L,z){var G=x(z?"/"+M(L):u(L));return j(O,G)}var k=/^\/(?:[^~]|~0|~1)*$/,T=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function R(O,L,z){var G,W,X,F;if(O==="")return"rootData";if(O[0]=="/"){if(!k.test(O))throw new Error("Invalid JSON-pointer: "+O);W=O,X="rootData"}else{if(F=O.match(T),!F)throw new Error("Invalid JSON-pointer: "+O);if(G=+F[1],W=F[2],W=="#"){if(G>=L)throw new Error("Cannot access property/index "+G+" levels up, current level is "+L);return z[L-G]}if(G>L)throw new Error("Cannot access data "+G+" levels up, current level is "+L);if(X="data"+(L-G||""),!W)return X}for(var Y=X,H=W.split("/"),te=0;te<H.length;te++){var P=H[te];P&&(X+=u(I(P)),Y+=" && "+X)}return Y}function j(O,L){return O=='""'?L:(O+" + "+L).replace(/([^\\])' \+ '/g,"$1")}function A(O){return I(decodeURIComponent(O))}function N(O){return encodeURIComponent(M(O))}function M(O){return O.replace(/~/g,"~0").replace(/\//g,"~1")}function I(O){return O.replace(/~1/g,"/").replace(/~0/g,"~")}return uE}var dE,bL;function Jq(){if(bL)return dE;bL=1;var t=nh();dE=e;function e(n){t.copy(n,this)}return dE}var fE={exports:{}},xL;function the(){if(xL)return fE.exports;xL=1;var t=fE.exports=function(r,s,i){typeof s=="function"&&(i=s,s={}),i=s.cb||i;var a=typeof i=="function"?i:i.pre||function(){},l=i.post||function(){};e(s,a,l,r,"",r)};t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function e(r,s,i,a,l,u,d,p,h,g){if(a&&typeof a=="object"&&!Array.isArray(a)){s(a,l,u,d,p,h,g);for(var v in a){var b=a[v];if(Array.isArray(b)){if(v in t.arrayKeywords)for(var x=0;x<b.length;x++)e(r,s,i,b[x],l+"/"+v+"/"+x,u,l,v,a,x)}else if(v in t.propsKeywords){if(b&&typeof b=="object")for(var E in b)e(r,s,i,b[E],l+"/"+v+"/"+n(E),u,l,v,a,E)}else(v in t.keywords||r.allKeys&&!(v in t.skipKeywords))&&e(r,s,i,b,l+"/"+v,u,l,v,a)}i(a,l,u,d,p,h,g)}}function n(r){return r.replace(/~/g,"~0").replace(/\//g,"~1")}return fE.exports}var hE,_L;function YN(){if(_L)return hE;_L=1;var t=Zfe(),e=WN(),n=nh(),r=Jq(),s=the();hE=i,i.normalizeId=S,i.fullPath=b,i.url=k,i.ids=T,i.inlineRef=h,i.schema=a;function i(R,j,A){var N=this._refs[A];if(typeof N=="string")if(this._refs[N])N=this._refs[N];else return i.call(this,R,j,N);if(N=N||this._schemas[A],N instanceof r)return h(N.schema,this._opts.inlineRefs)?N.schema:N.validate||this._compile(N);var M=a.call(this,j,A),I,O,L;return M&&(I=M.schema,j=M.root,L=M.baseId),I instanceof r?O=I.validate||R.call(this,I.schema,j,void 0,L):I!==void 0&&(O=h(I,this._opts.inlineRefs)?I:R.call(this,I,j,void 0,L)),O}function a(R,j){var A=t.parse(j),N=x(A),M=b(this._getId(R.schema));if(Object.keys(R.schema).length===0||N!==M){var I=S(N),O=this._refs[I];if(typeof O=="string")return l.call(this,R,O,A);if(O instanceof r)O.validate||this._compile(O),R=O;else if(O=this._schemas[I],O instanceof r){if(O.validate||this._compile(O),I==S(j))return{schema:O,root:R,baseId:M};R=O}else return;if(!R.schema)return;M=b(this._getId(R.schema))}return d.call(this,A,M,R.schema,R)}function l(R,j,A){var N=a.call(this,R,j);if(N){var M=N.schema,I=N.baseId;R=N.root;var O=this._getId(M);return O&&(I=k(I,O)),d.call(this,A,I,M,R)}}var u=n.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function d(R,j,A,N){if(R.fragment=R.fragment||"",R.fragment.slice(0,1)=="/"){for(var M=R.fragment.split("/"),I=1;I<M.length;I++){var O=M[I];if(O){if(O=n.unescapeFragment(O),A=A[O],A===void 0)break;var L;if(!u[O]&&(L=this._getId(A),L&&(j=k(j,L)),A.$ref)){var z=k(j,A.$ref),G=a.call(this,N,z);G&&(A=G.schema,N=G.root,j=G.baseId)}}}if(A!==void 0&&A!==N.schema)return{schema:A,root:N,baseId:j}}}var p=n.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function h(R,j){if(j===!1)return!1;if(j===void 0||j===!0)return g(R);if(j)return v(R)<=j}function g(R){var j;if(Array.isArray(R)){for(var A=0;A<R.length;A++)if(j=R[A],typeof j=="object"&&!g(j))return!1}else for(var N in R)if(N=="$ref"||(j=R[N],typeof j=="object"&&!g(j)))return!1;return!0}function v(R){var j=0,A;if(Array.isArray(R)){for(var N=0;N<R.length;N++)if(A=R[N],typeof A=="object"&&(j+=v(A)),j==1/0)return 1/0}else for(var M in R){if(M=="$ref")return 1/0;if(p[M])j++;else if(A=R[M],typeof A=="object"&&(j+=v(A)+1),j==1/0)return 1/0}return j}function b(R,j){j!==!1&&(R=S(R));var A=t.parse(R);return x(A)}function x(R){return t.serialize(R).split("#")[0]+"#"}var E=/#\/?$/;function S(R){return R?R.replace(E,""):""}function k(R,j){return j=S(j),t.resolve(R,j)}function T(R){var j=S(this._getId(R)),A={"":j},N={"":b(j,!1)},M={},I=this;return s(R,{allKeys:!0},function(O,L,z,G,W,X,F){if(L!==""){var Y=I._getId(O),H=A[G],te=N[G]+"/"+W;if(F!==void 0&&(te+="/"+(typeof F=="number"?F:n.escapeFragment(F))),typeof Y=="string"){Y=H=S(H?t.resolve(H,Y):Y);var P=I._refs[Y];if(typeof P=="string"&&(P=I._refs[P]),P&&P.schema){if(!e(O,P.schema))throw new Error('id "'+Y+'" resolves to more than one schema')}else if(Y!=S(te))if(Y[0]=="#"){if(M[Y]&&!e(O,M[Y]))throw new Error('id "'+Y+'" resolves to more than one schema');M[Y]=O}else I._refs[Y]=te}A[L]=H,N[L]=te}}),M}return hE}var pE,wL;function KN(){if(wL)return pE;wL=1;var t=YN();pE={Validation:r(e),MissingRef:r(n)};function e(s){this.message="validation failed",this.errors=s,this.ajv=this.validation=!0}n.message=function(s,i){return"can't resolve reference "+i+" from id "+s};function n(s,i,a){this.message=a||n.message(s,i),this.missingRef=t.url(s,i),this.missingSchema=t.normalizeId(t.fullPath(this.missingRef))}function r(s){return s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s}return pE}var mE,SL;function Zq(){return SL||(SL=1,mE=function(t,e){e||(e={}),typeof e=="function"&&(e={cmp:e});var n=typeof e.cycles=="boolean"?e.cycles:!1,r=e.cmp&&function(i){return function(a){return function(l,u){var d={key:l,value:a[l]},p={key:u,value:a[u]};return i(d,p)}}}(e.cmp),s=[];return function i(a){if(a&&a.toJSON&&typeof a.toJSON=="function"&&(a=a.toJSON()),a!==void 0){if(typeof a=="number")return isFinite(a)?""+a:"null";if(typeof a!="object")return JSON.stringify(a);var l,u;if(Array.isArray(a)){for(u="[",l=0;l<a.length;l++)l&&(u+=","),u+=i(a[l])||"null";return u+"]"}if(a===null)return"null";if(s.indexOf(a)!==-1){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var d=s.push(a)-1,p=Object.keys(a).sort(r&&r(a));for(u="",l=0;l<p.length;l++){var h=p[l],g=i(a[h]);g&&(u&&(u+=","),u+=JSON.stringify(h)+":"+g)}return s.splice(d,1),"{"+u+"}"}}(t)}),mE}var gE,EL;function eV(){return EL||(EL=1,gE=function(e,n,r){var s="",i=e.schema.$async===!0,a=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),l=e.self._getId(e.schema);if(e.opts.strictKeywords){var u=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(u){var d="unknown keyword: "+u;if(e.opts.strictKeywords==="log")e.logger.warn(d);else throw new Error(d)}}if(e.isTop&&(s+=" var validate = ",i&&(e.async=!0,s+="async "),s+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",l&&(e.opts.sourceCode||e.opts.processCode)&&(s+=" "+("/*# sourceURL="+l+" */")+" ")),typeof e.schema=="boolean"||!(a||e.schema.$ref)){var n="false schema",p=e.level,h=e.dataLevel,g=e.schema[n],v=e.schemaPath+e.util.getProperty(n),b=e.errSchemaPath+"/"+n,j=!e.opts.allErrors,M,x="data"+(h||""),R="valid"+p;if(e.schema===!1){e.isTop?j=!0:s+=" var "+R+" = false; ";var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"false schema")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'boolean schema is false' "),e.opts.verbose&&(s+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?i?s+=" return data; ":s+=" validate.errors = null; return true; ":s+=" var "+R+" = true; ";return e.isTop&&(s+=" }; return validate; "),s}if(e.isTop){var k=e.isTop,p=e.level=0,h=e.dataLevel=0,x="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],e.schema.default!==void 0&&e.opts.useDefaults&&e.opts.strictDefaults){var T="default is ignored in the schema root";if(e.opts.strictDefaults==="log")e.logger.warn(T);else throw new Error(T)}s+=" var vErrors = null; ",s+=" var errors = 0; ",s+=" if (rootData === undefined) rootData = data; "}else{var p=e.level,h=e.dataLevel,x="data"+(h||"");if(l&&(e.baseId=e.resolve.url(e.baseId,l)),i&&!e.async)throw new Error("async schema in sync schema");s+=" var errs_"+p+" = errors;"}var R="valid"+p,j=!e.opts.allErrors,A="",N="",M,I=e.schema.type,O=Array.isArray(I);if(I&&e.opts.nullable&&e.schema.nullable===!0&&(O?I.indexOf("null")==-1&&(I=I.concat("null")):I!="null"&&(I=[I,"null"],O=!0)),O&&I.length==1&&(I=I[0],O=!1),e.schema.$ref&&a){if(e.opts.extendRefs=="fail")throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');e.opts.extendRefs!==!0&&(a=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(s+=" "+e.RULES.all.$comment.code(e,"$comment")),I){if(e.opts.coerceTypes)var L=e.util.coerceToTypes(e.opts.coerceTypes,I);var z=e.RULES.types[I];if(L||O||z===!0||z&&!dt(z)){var v=e.schemaPath+".type",b=e.errSchemaPath+"/type",v=e.schemaPath+".type",b=e.errSchemaPath+"/type",G=O?"checkDataTypes":"checkDataType";if(s+=" if ("+e.util[G](I,x,e.opts.strictNumbers,!0)+") { ",L){var W="dataType"+p,X="coerced"+p;s+=" var "+W+" = typeof "+x+"; var "+X+" = undefined; ",e.opts.coerceTypes=="array"&&(s+=" if ("+W+" == 'object' && Array.isArray("+x+") && "+x+".length == 1) { "+x+" = "+x+"[0]; "+W+" = typeof "+x+"; if ("+e.util.checkDataType(e.schema.type,x,e.opts.strictNumbers)+") "+X+" = "+x+"; } "),s+=" if ("+X+" !== undefined) ; ";var F=L;if(F)for(var Y,H=-1,te=F.length-1;H<te;)Y=F[H+=1],Y=="string"?s+=" else if ("+W+" == 'number' || "+W+" == 'boolean') "+X+" = '' + "+x+"; else if ("+x+" === null) "+X+" = ''; ":Y=="number"||Y=="integer"?(s+=" else if ("+W+" == 'boolean' || "+x+" === null || ("+W+" == 'string' && "+x+" && "+x+" == +"+x+" ",Y=="integer"&&(s+=" && !("+x+" % 1)"),s+=")) "+X+" = +"+x+"; "):Y=="boolean"?s+=" else if ("+x+" === 'false' || "+x+" === 0 || "+x+" === null) "+X+" = false; else if ("+x+" === 'true' || "+x+" === 1) "+X+" = true; ":Y=="null"?s+=" else if ("+x+" === '' || "+x+" === 0 || "+x+" === false) "+X+" = null; ":e.opts.coerceTypes=="array"&&Y=="array"&&(s+=" else if ("+W+" == 'string' || "+W+" == 'number' || "+W+" == 'boolean' || "+x+" == null) "+X+" = ["+x+"]; ");s+=" else { ";var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: { type: '",O?s+=""+I.join(","):s+=""+I,s+="' } ",e.opts.messages!==!1&&(s+=" , message: 'should be ",O?s+=""+I.join(","):s+=""+I,s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+v+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } if ("+X+" !== undefined) { ";var P=h?"data"+(h-1||""):"parentData",re=h?e.dataPathArr[h]:"parentDataProperty";s+=" "+x+" = "+X+"; ",h||(s+="if ("+P+" !== undefined)"),s+=" "+P+"["+re+"] = "+X+"; } "}else{var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: { type: '",O?s+=""+I.join(","):s+=""+I,s+="' } ",e.opts.messages!==!1&&(s+=" , message: 'should be ",O?s+=""+I.join(","):s+=""+I,s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+v+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}s+=" } "}}if(e.schema.$ref&&!a)s+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",j&&(s+=" } if (errors === ",k?s+="0":s+="errs_"+p,s+=") { ",N+="}");else{var ue=e.RULES;if(ue){for(var z,D=-1,Z=ue.length-1;D<Z;)if(z=ue[D+=1],dt(z)){if(z.type&&(s+=" if ("+e.util.checkDataType(z.type,x,e.opts.strictNumbers)+") { "),e.opts.useDefaults){if(z.type=="object"&&e.schema.properties){var g=e.schema.properties,he=Object.keys(g),V=he;if(V)for(var U,K=-1,ae=V.length-1;K<ae;){U=V[K+=1];var B=g[U];if(B.default!==void 0){var J=x+e.util.getProperty(U);if(e.compositeRule){if(e.opts.strictDefaults){var T="default is ignored for: "+J;if(e.opts.strictDefaults==="log")e.logger.warn(T);else throw new Error(T)}}else s+=" if ("+J+" === undefined ",e.opts.useDefaults=="empty"&&(s+=" || "+J+" === null || "+J+" === '' "),s+=" ) "+J+" = ",e.opts.useDefaults=="shared"?s+=" "+e.useDefault(B.default)+" ":s+=" "+JSON.stringify(B.default)+" ",s+="; "}}}else if(z.type=="array"&&Array.isArray(e.schema.items)){var oe=e.schema.items;if(oe){for(var B,H=-1,fe=oe.length-1;H<fe;)if(B=oe[H+=1],B.default!==void 0){var J=x+"["+H+"]";if(e.compositeRule){if(e.opts.strictDefaults){var T="default is ignored for: "+J;if(e.opts.strictDefaults==="log")e.logger.warn(T);else throw new Error(T)}}else s+=" if ("+J+" === undefined ",e.opts.useDefaults=="empty"&&(s+=" || "+J+" === null || "+J+" === '' "),s+=" ) "+J+" = ",e.opts.useDefaults=="shared"?s+=" "+e.useDefault(B.default)+" ":s+=" "+JSON.stringify(B.default)+" ",s+="; "}}}}var be=z.rules;if(be){for(var Ae,Oe=-1,Ne=be.length-1;Oe<Ne;)if(Ae=be[Oe+=1],Be(Ae)){var Qe=Ae.code(e,Ae.keyword,z.type);Qe&&(s+=" "+Qe+" ",j&&(A+="}"))}}if(j&&(s+=" "+A+" ",A=""),z.type&&(s+=" } ",I&&I===z.type&&!L)){s+=" else { ";var v=e.schemaPath+".type",b=e.errSchemaPath+"/type",E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(M||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(b)+" , params: { type: '",O?s+=""+I.join(","):s+=""+I,s+="' } ",e.opts.messages!==!1&&(s+=" , message: 'should be ",O?s+=""+I.join(","):s+=""+I,s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+v+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+x+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&j?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } "}j&&(s+=" if (errors === ",k?s+="0":s+="errs_"+p,s+=") { ",N+="}")}}}j&&(s+=" "+N+" "),k?(i?(s+=" if (errors === 0) return data; ",s+=" else throw new ValidationError(vErrors); "):(s+=" validate.errors = vErrors; ",s+=" return errors === 0; "),s+=" }; return validate;"):s+=" var "+R+" = errors === errs_"+p+";";function dt(De){for(var et=De.rules,ot=0;ot<et.length;ot++)if(Be(et[ot]))return!0}function Be(De){return e.schema[De.keyword]!==void 0||De.implements&&pt(De)}function pt(De){for(var et=De.implements,ot=0;ot<et.length;ot++)if(e.schema[et[ot]]!==void 0)return!0}return s}),gE}var vE,kL;function nhe(){if(kL)return vE;kL=1;var t=YN(),e=nh(),n=KN(),r=Zq(),s=eV(),i=e.ucs2length,a=WN(),l=n.Validation;vE=u;function u(S,k,T,R){var j=this,A=this._opts,N=[void 0],M={},I=[],O={},L=[],z={},G=[];k=k||{schema:S,refVal:N,refs:M};var W=d.call(this,S,k,R),X=this._compilations[W.index];if(W.compiling)return X.callValidate=P;var F=this._formats,Y=this.RULES;try{var H=re(S,k,T,R);X.validate=H;var te=X.callValidate;return te&&(te.schema=H.schema,te.errors=null,te.refs=H.refs,te.refVal=H.refVal,te.root=H.root,te.$async=H.$async,A.sourceCode&&(te.source=H.source)),H}finally{p.call(this,S,k,R)}function P(){var B=X.validate,J=B.apply(this,arguments);return P.errors=B.errors,J}function re(B,J,oe,fe){var be=!J||J&&J.schema==B;if(J.schema!=k.schema)return u.call(j,B,J,oe,fe);var Ae=B.$async===!0,Oe=s({isTop:!0,schema:B,isRoot:be,baseId:fe,root:J,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:n.MissingRef,RULES:Y,validate:s,util:e,resolve:t,resolveRef:ue,usePattern:U,useDefault:K,useCustomRule:ae,opts:A,formats:F,logger:j.logger,self:j});Oe=E(N,b)+E(I,g)+E(L,v)+E(G,x)+Oe,A.processCode&&(Oe=A.processCode(Oe,B));var Ne;try{var Qe=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",Oe);Ne=Qe(j,Y,F,k,N,L,G,a,i,l),N[0]=Ne}catch(dt){throw j.logger.error("Error compiling schema, function code:",Oe),dt}return Ne.schema=B,Ne.errors=null,Ne.refs=M,Ne.refVal=N,Ne.root=be?Ne:J,Ae&&(Ne.$async=!0),A.sourceCode===!0&&(Ne.source={code:Oe,patterns:I,defaults:L}),Ne}function ue(B,J,oe){J=t.url(B,J);var fe=M[J],be,Ae;if(fe!==void 0)return be=N[fe],Ae="refVal["+fe+"]",V(be,Ae);if(!oe&&k.refs){var Oe=k.refs[J];if(Oe!==void 0)return be=k.refVal[Oe],Ae=D(J,be),V(be,Ae)}Ae=D(J);var Ne=t.call(j,re,k,J);if(Ne===void 0){var Qe=T&&T[J];Qe&&(Ne=t.inlineRef(Qe,A.inlineRefs)?Qe:u.call(j,Qe,k,T,B))}if(Ne===void 0)Z(J);else return he(J,Ne),V(Ne,Ae)}function D(B,J){var oe=N.length;return N[oe]=J,M[B]=oe,"refVal"+oe}function Z(B){delete M[B]}function he(B,J){var oe=M[B];N[oe]=J}function V(B,J){return typeof B=="object"||typeof B=="boolean"?{code:J,schema:B,inline:!0}:{code:J,$async:B&&!!B.$async}}function U(B){var J=O[B];return J===void 0&&(J=O[B]=I.length,I[J]=B),"pattern"+J}function K(B){switch(typeof B){case"boolean":case"number":return""+B;case"string":return e.toQuotedString(B);case"object":if(B===null)return"null";var J=r(B),oe=z[J];return oe===void 0&&(oe=z[J]=L.length,L[oe]=B),"default"+oe}}function ae(B,J,oe,fe){if(j._opts.validateSchema!==!1){var be=B.definition.dependencies;if(be&&!be.every(function(et){return Object.prototype.hasOwnProperty.call(oe,et)}))throw new Error("parent schema must have all required keywords: "+be.join(","));var Ae=B.definition.validateSchema;if(Ae){var Oe=Ae(J);if(!Oe){var Ne="keyword schema is invalid: "+j.errorsText(Ae.errors);if(j._opts.validateSchema=="log")j.logger.error(Ne);else throw new Error(Ne)}}}var Qe=B.definition.compile,dt=B.definition.inline,Be=B.definition.macro,pt;if(Qe)pt=Qe.call(j,J,oe,fe);else if(Be)pt=Be.call(j,J,oe,fe),A.validateSchema!==!1&&j.validateSchema(pt,!0);else if(dt)pt=dt.call(j,fe,B.keyword,J,oe);else if(pt=B.definition.validate,!pt)return;if(pt===void 0)throw new Error('custom keyword "'+B.keyword+'"failed to compile');var De=G.length;return G[De]=pt,{code:"customRule"+De,validate:pt}}}function d(S,k,T){var R=h.call(this,S,k,T);return R>=0?{index:R,compiling:!0}:(R=this._compilations.length,this._compilations[R]={schema:S,root:k,baseId:T},{index:R,compiling:!1})}function p(S,k,T){var R=h.call(this,S,k,T);R>=0&&this._compilations.splice(R,1)}function h(S,k,T){for(var R=0;R<this._compilations.length;R++){var j=this._compilations[R];if(j.schema==S&&j.root==k&&j.baseId==T)return R}return-1}function g(S,k){return"var pattern"+S+" = new RegExp("+e.toQuotedString(k[S])+");"}function v(S){return"var default"+S+" = defaults["+S+"];"}function b(S,k){return k[S]===void 0?"":"var refVal"+S+" = refVal["+S+"];"}function x(S){return"var customRule"+S+" = customRules["+S+"];"}function E(S,k){if(!S.length)return"";for(var T="",R=0;R<S.length;R++)T+=k(R,S);return T}return vE}var yE={exports:{}},TL;function rhe(){if(TL)return yE.exports;TL=1;var t=yE.exports=function(){this._cache={}};return t.prototype.put=function(n,r){this._cache[n]=r},t.prototype.get=function(n){return this._cache[n]},t.prototype.del=function(n){delete this._cache[n]},t.prototype.clear=function(){this._cache={}},yE.exports}var bE,CL;function she(){if(CL)return bE;CL=1;var t=nh(),e=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31],r=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,s=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,i=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,a=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,l=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,u=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,d=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,p=/^(?:\/(?:[^~/]|~0|~1)*)*$/,h=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,g=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;bE=v;function v(N){return N=N=="full"?"full":"fast",t.copy(v[N])}v.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":l,url:u,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:s,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:A,uuid:d,"json-pointer":p,"json-pointer-uri-fragment":h,"relative-json-pointer":g},v.full={date:x,time:E,"date-time":k,uri:R,"uri-reference":a,"uri-template":l,url:u,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:s,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:A,uuid:d,"json-pointer":p,"json-pointer-uri-fragment":h,"relative-json-pointer":g};function b(N){return N%4===0&&(N%100!==0||N%400===0)}function x(N){var M=N.match(e);if(!M)return!1;var I=+M[1],O=+M[2],L=+M[3];return O>=1&&O<=12&&L>=1&&L<=(O==2&&b(I)?29:n[O])}function E(N,M){var I=N.match(r);if(!I)return!1;var O=I[1],L=I[2],z=I[3],G=I[5];return(O<=23&&L<=59&&z<=59||O==23&&L==59&&z==60)&&(!M||G)}var S=/t|\s/i;function k(N){var M=N.split(S);return M.length==2&&x(M[0])&&E(M[1],!0)}var T=/\/|:/;function R(N){return T.test(N)&&i.test(N)}var j=/[^\\]\\Z/;function A(N){if(j.test(N))return!1;try{return new RegExp(N),!0}catch{return!1}}return bE}var xE,AL;function ihe(){return AL||(AL=1,xE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.errSchemaPath+"/"+n,d=!e.opts.allErrors,p="data"+(a||""),h="valid"+i,g,v;if(l=="#"||l=="#/")e.isRoot?(g=e.async,v="validate"):(g=e.root.schema.$async===!0,v="root.refVal[0]");else{var b=e.resolveRef(e.baseId,l,e.isRoot);if(b===void 0){var x=e.MissingRefError.message(e.baseId,l);if(e.opts.missingRefs=="fail"){e.logger.error(x);var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { ref: '"+e.util.escapeQuotes(l)+"' } ",e.opts.messages!==!1&&(s+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(l)+"' "),e.opts.verbose&&(s+=" , schema: "+e.util.toQuotedString(l)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),s+=" } "):s+=" {} ";var S=s;s=E.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d&&(s+=" if (false) { ")}else if(e.opts.missingRefs=="ignore")e.logger.warn(x),d&&(s+=" if (true) { ");else throw new e.MissingRefError(e.baseId,l,x)}else if(b.inline){var k=e.util.copy(e);k.level++;var T="valid"+k.level;k.schema=b.schema,k.schemaPath="",k.errSchemaPath=l;var R=e.validate(k).replace(/validate\.schema/g,b.code);s+=" "+R+" ",d&&(s+=" if ("+T+") { ")}else g=b.$async===!0||e.async&&b.$async!==!1,v=b.code}if(v){var E=E||[];E.push(s),s="",e.opts.passContext?s+=" "+v+".call(this, ":s+=" "+v+"( ",s+=" "+p+", (dataPath || '')",e.errorPath!='""'&&(s+=" + "+e.errorPath);var j=a?"data"+(a-1||""):"parentData",A=a?e.dataPathArr[a]:"parentDataProperty";s+=" , "+j+" , "+A+", rootData) ";var N=s;if(s=E.pop(),g){if(!e.async)throw new Error("async schema referenced by sync schema");d&&(s+=" var "+h+"; "),s+=" try { await "+N+"; ",d&&(s+=" "+h+" = true; "),s+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",d&&(s+=" "+h+" = false; "),s+=" } ",d&&(s+=" if ("+h+") { ")}else s+=" if (!"+N+") { if (vErrors === null) vErrors = "+v+".errors; else vErrors = vErrors.concat("+v+".errors); errors = vErrors.length; } ",d&&(s+=" else { ")}return s}),xE}var _E,NL;function ahe(){return NL||(NL=1,_E=function(e,n,r){var s=" ",i=e.schema[n],a=e.schemaPath+e.util.getProperty(n),l=e.errSchemaPath+"/"+n,u=!e.opts.allErrors,d=e.util.copy(e),p="";d.level++;var h="valid"+d.level,g=d.baseId,v=!0,b=i;if(b)for(var x,E=-1,S=b.length-1;E<S;)x=b[E+=1],(e.opts.strictKeywords?typeof x=="object"&&Object.keys(x).length>0||x===!1:e.util.schemaHasRules(x,e.RULES.all))&&(v=!1,d.schema=x,d.schemaPath=a+"["+E+"]",d.errSchemaPath=l+"/"+E,s+=" "+e.validate(d)+" ",d.baseId=g,u&&(s+=" if ("+h+") { ",p+="}"));return u&&(v?s+=" if (true) { ":s+=" "+p.slice(0,-1)+" "),s}),_E}var wE,RL;function ohe(){return RL||(RL=1,wE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S=l.every(function(M){return e.opts.strictKeywords?typeof M=="object"&&Object.keys(M).length>0||M===!1:e.util.schemaHasRules(M,e.RULES.all)});if(S){var k=b.baseId;s+=" var "+v+" = errors; var "+g+" = false; ";var T=e.compositeRule;e.compositeRule=b.compositeRule=!0;var R=l;if(R)for(var j,A=-1,N=R.length-1;A<N;)j=R[A+=1],b.schema=j,b.schemaPath=u+"["+A+"]",b.errSchemaPath=d+"/"+A,s+=" "+e.validate(b)+" ",b.baseId=k,s+=" "+g+" = "+g+" || "+E+"; if (!"+g+") { ",x+="}";e.compositeRule=b.compositeRule=T,s+=" "+x+" if (!"+g+") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),s+=" } else { errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; } ",e.opts.allErrors&&(s+=" } ")}else p&&(s+=" if (true) { ");return s}),wE}var SE,jL;function lhe(){return jL||(jL=1,SE=function(e,n,r){var s=" ",i=e.schema[n],a=e.errSchemaPath+"/"+n;e.opts.allErrors;var l=e.util.toQuotedString(i);return e.opts.$comment===!0?s+=" console.log("+l+");":typeof e.opts.$comment=="function"&&(s+=" self._opts.$comment("+l+", "+e.util.toQuotedString(a)+", validate.root.schema);"),s}),SE}var EE,ML;function che(){return ML||(ML=1,EE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data;v&&(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; "),v||(s+=" var schema"+i+" = validate.schema"+u+";"),s+="var "+g+" = equal("+h+", schema"+i+"); if (!"+g+") { ";var b=b||[];b.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { allowedValue: schema"+i+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be equal to constant' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var x=s;return s=b.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+x+"]); ":s+=" validate.errors = ["+x+"]; return false; ":s+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" }",p&&(s+=" else { "),s}),EE}var kE,OL;function uhe(){return OL||(OL=1,kE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S="i"+i,k=b.dataLevel=e.dataLevel+1,T="data"+k,R=e.baseId,j=e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all);if(s+="var "+v+" = errors;var "+g+";",j){var A=e.compositeRule;e.compositeRule=b.compositeRule=!0,b.schema=l,b.schemaPath=u,b.errSchemaPath=d,s+=" var "+E+" = false; for (var "+S+" = 0; "+S+" < "+h+".length; "+S+"++) { ",b.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0);var N=h+"["+S+"]";b.dataPathArr[k]=S;var M=e.validate(b);b.baseId=R,e.util.varOccurences(M,T)<2?s+=" "+e.util.varReplace(M,T,N)+" ":s+=" var "+T+" = "+N+"; "+M+" ",s+=" if ("+E+") break; } ",e.compositeRule=b.compositeRule=A,s+=" "+x+" if (!"+E+") {"}else s+=" if ("+h+".length == 0) {";var I=I||[];I.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should contain a valid item' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var O=s;return s=I.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+O+"]); ":s+=" validate.errors = ["+O+"]; return false; ":s+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { ",j&&(s+=" errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; } "),e.opts.allErrors&&(s+=" } "),s}),kE}var TE,PL;function dhe(){return PL||(PL=1,TE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e),b="";v.level++;var x="valid"+v.level,E={},S={},k=e.opts.ownProperties;for(A in l)if(A!="__proto__"){var T=l[A],R=Array.isArray(T)?S:E;R[A]=T}s+="var "+g+" = errors;";var j=e.errorPath;s+="var missing"+i+";";for(var A in S)if(R=S[A],R.length){if(s+=" if ( "+h+e.util.getProperty(A)+" !== undefined ",k&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(A)+"') "),p){s+=" && ( ";var N=R;if(N)for(var M,I=-1,O=N.length-1;I<O;){M=N[I+=1],I&&(s+=" || ");var L=e.util.getProperty(M),z=h+L;s+=" ( ( "+z+" === undefined ",k&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(M)+"') "),s+=") && (missing"+i+" = "+e.util.toQuotedString(e.opts.jsonPointers?M:L)+") ) "}s+=")) { ";var G="missing"+i,W="' + "+G+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(j,G,!0):j+" + "+G);var X=X||[];X.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { property: '"+e.util.escapeQuotes(A)+"', missingProperty: '"+W+"', depsCount: "+R.length+", deps: '"+e.util.escapeQuotes(R.length==1?R[0]:R.join(", "))+"' } ",e.opts.messages!==!1&&(s+=" , message: 'should have ",R.length==1?s+="property "+e.util.escapeQuotes(R[0]):s+="properties "+e.util.escapeQuotes(R.join(", ")),s+=" when property "+e.util.escapeQuotes(A)+" is present' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var F=s;s=X.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+F+"]); ":s+=" validate.errors = ["+F+"]; return false; ":s+=" var err = "+F+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{s+=" ) { ";var Y=R;if(Y)for(var M,H=-1,te=Y.length-1;H<te;){M=Y[H+=1];var L=e.util.getProperty(M),W=e.util.escapeQuotes(M),z=h+L;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(j,M,e.opts.jsonPointers)),s+=" if ( "+z+" === undefined ",k&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(M)+"') "),s+=") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { property: '"+e.util.escapeQuotes(A)+"', missingProperty: '"+W+"', depsCount: "+R.length+", deps: '"+e.util.escapeQuotes(R.length==1?R[0]:R.join(", "))+"' } ",e.opts.messages!==!1&&(s+=" , message: 'should have ",R.length==1?s+="property "+e.util.escapeQuotes(R[0]):s+="properties "+e.util.escapeQuotes(R.join(", ")),s+=" when property "+e.util.escapeQuotes(A)+" is present' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}s+=" } ",p&&(b+="}",s+=" else { ")}e.errorPath=j;var P=v.baseId;for(var A in E){var T=E[A];(e.opts.strictKeywords?typeof T=="object"&&Object.keys(T).length>0||T===!1:e.util.schemaHasRules(T,e.RULES.all))&&(s+=" "+x+" = true; if ( "+h+e.util.getProperty(A)+" !== undefined ",k&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(A)+"') "),s+=") { ",v.schema=T,v.schemaPath=u+e.util.getProperty(A),v.errSchemaPath=d+"/"+e.util.escapeFragment(A),s+=" "+e.validate(v)+" ",v.baseId=P,s+=" } ",p&&(s+=" if ("+x+") { ",b+="}"))}return p&&(s+=" "+b+" if ("+g+" == errors) {"),s}),TE}var CE,IL;function fhe(){return IL||(IL=1,CE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data;v&&(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ");var b="i"+i,x="schema"+i;v||(s+=" var "+x+" = validate.schema"+u+";"),s+="var "+g+";",v&&(s+=" if (schema"+i+" === undefined) "+g+" = true; else if (!Array.isArray(schema"+i+")) "+g+" = false; else {"),s+=""+g+" = false;for (var "+b+"=0; "+b+"<"+x+".length; "+b+"++) if (equal("+h+", "+x+"["+b+"])) { "+g+" = true; break; }",v&&(s+=" } "),s+=" if (!"+g+") { ";var E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { allowedValues: schema"+i+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" }",p&&(s+=" else { "),s}),CE}var AE,DL;function hhe(){return DL||(DL=1,AE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||"");if(e.opts.format===!1)return p&&(s+=" if (true) { "),s;var g=e.opts.$data&&l&&l.$data,v;g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l;var b=e.opts.unknownFormats,x=Array.isArray(b);if(g){var E="format"+i,S="isObject"+i,k="formatType"+i;s+=" var "+E+" = formats["+v+"]; var "+S+" = typeof "+E+" == 'object' && !("+E+" instanceof RegExp) && "+E+".validate; var "+k+" = "+S+" && "+E+".type || 'string'; if ("+S+") { ",e.async&&(s+=" var async"+i+" = "+E+".async; "),s+=" "+E+" = "+E+".validate; } if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'string') || "),s+=" (",b!="ignore"&&(s+=" ("+v+" && !"+E+" ",x&&(s+=" && self._opts.unknownFormats.indexOf("+v+") == -1 "),s+=") || "),s+=" ("+E+" && "+k+" == '"+r+"' && !(typeof "+E+" == 'function' ? ",e.async?s+=" (async"+i+" ? await "+E+"("+h+") : "+E+"("+h+")) ":s+=" "+E+"("+h+") ",s+=" : "+E+".test("+h+"))))) {"}else{var E=e.formats[l];if(!E){if(b=="ignore")return e.logger.warn('unknown format "'+l+'" ignored in schema at path "'+e.errSchemaPath+'"'),p&&(s+=" if (true) { "),s;if(x&&b.indexOf(l)>=0)return p&&(s+=" if (true) { "),s;throw new Error('unknown format "'+l+'" is used in schema at path "'+e.errSchemaPath+'"')}var S=typeof E=="object"&&!(E instanceof RegExp)&&E.validate,k=S&&E.type||"string";if(S){var T=E.async===!0;E=E.validate}if(k!=r)return p&&(s+=" if (true) { "),s;if(T){if(!e.async)throw new Error("async format in sync schema");var R="formats"+e.util.getProperty(l)+".validate";s+=" if (!(await "+R+"("+h+"))) { "}else{s+=" if (! ";var R="formats"+e.util.getProperty(l);S&&(R+=".validate"),typeof E=="function"?s+=" "+R+"("+h+") ":s+=" "+R+".test("+h+") ",s+=") { "}}var j=j||[];j.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { format: ",g?s+=""+v:s+=""+e.util.toQuotedString(l),s+=" } ",e.opts.messages!==!1&&(s+=` , message: 'should match format "`,g?s+="' + "+v+" + '":s+=""+e.util.escapeQuotes(l),s+=`"' `),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+e.util.toQuotedString(l),s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var A=s;return s=j.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+A+"]); ":s+=" validate.errors = ["+A+"]; return false; ":s+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",p&&(s+=" else { "),s}),AE}var NE,LL;function phe(){return LL||(LL=1,NE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e);b.level++;var x="valid"+b.level,E=e.schema.then,S=e.schema.else,k=E!==void 0&&(e.opts.strictKeywords?typeof E=="object"&&Object.keys(E).length>0||E===!1:e.util.schemaHasRules(E,e.RULES.all)),T=S!==void 0&&(e.opts.strictKeywords?typeof S=="object"&&Object.keys(S).length>0||S===!1:e.util.schemaHasRules(S,e.RULES.all)),R=b.baseId;if(k||T){var j;b.createErrors=!1,b.schema=l,b.schemaPath=u,b.errSchemaPath=d,s+=" var "+v+" = errors; var "+g+" = true; ";var A=e.compositeRule;e.compositeRule=b.compositeRule=!0,s+=" "+e.validate(b)+" ",b.baseId=R,b.createErrors=!0,s+=" errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; } ",e.compositeRule=b.compositeRule=A,k?(s+=" if ("+x+") { ",b.schema=e.schema.then,b.schemaPath=e.schemaPath+".then",b.errSchemaPath=e.errSchemaPath+"/then",s+=" "+e.validate(b)+" ",b.baseId=R,s+=" "+g+" = "+x+"; ",k&&T?(j="ifClause"+i,s+=" var "+j+" = 'then'; "):j="'then'",s+=" } ",T&&(s+=" else { ")):s+=" if (!"+x+") { ",T&&(b.schema=e.schema.else,b.schemaPath=e.schemaPath+".else",b.errSchemaPath=e.errSchemaPath+"/else",s+=" "+e.validate(b)+" ",b.baseId=R,s+=" "+g+" = "+x+"; ",k&&T?(j="ifClause"+i,s+=" var "+j+" = 'else'; "):j="'else'",s+=" } "),s+=" if (!"+g+") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { failingKeyword: "+j+" } ",e.opts.messages!==!1&&(s+=` , message: 'should match "' + `+j+` + '" schema' `),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),s+=" } ",p&&(s+=" else { ")}else p&&(s+=" if (true) { ");return s}),NE}var RE,$L;function mhe(){return $L||($L=1,RE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S="i"+i,k=b.dataLevel=e.dataLevel+1,T="data"+k,R=e.baseId;if(s+="var "+v+" = errors;var "+g+";",Array.isArray(l)){var j=e.schema.additionalItems;if(j===!1){s+=" "+g+" = "+h+".length <= "+l.length+"; ";var A=d;d=e.errSchemaPath+"/additionalItems",s+=" if (!"+g+") { ";var N=N||[];N.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+l.length+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have more than "+l.length+" items' "),e.opts.verbose&&(s+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var M=s;s=N.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+M+"]); ":s+=" validate.errors = ["+M+"]; return false; ":s+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",d=A,p&&(x+="}",s+=" else { ")}var I=l;if(I){for(var O,L=-1,z=I.length-1;L<z;)if(O=I[L+=1],e.opts.strictKeywords?typeof O=="object"&&Object.keys(O).length>0||O===!1:e.util.schemaHasRules(O,e.RULES.all)){s+=" "+E+" = true; if ("+h+".length > "+L+") { ";var G=h+"["+L+"]";b.schema=O,b.schemaPath=u+"["+L+"]",b.errSchemaPath=d+"/"+L,b.errorPath=e.util.getPathExpr(e.errorPath,L,e.opts.jsonPointers,!0),b.dataPathArr[k]=L;var W=e.validate(b);b.baseId=R,e.util.varOccurences(W,T)<2?s+=" "+e.util.varReplace(W,T,G)+" ":s+=" var "+T+" = "+G+"; "+W+" ",s+=" } ",p&&(s+=" if ("+E+") { ",x+="}")}}if(typeof j=="object"&&(e.opts.strictKeywords?typeof j=="object"&&Object.keys(j).length>0||j===!1:e.util.schemaHasRules(j,e.RULES.all))){b.schema=j,b.schemaPath=e.schemaPath+".additionalItems",b.errSchemaPath=e.errSchemaPath+"/additionalItems",s+=" "+E+" = true; if ("+h+".length > "+l.length+") { for (var "+S+" = "+l.length+"; "+S+" < "+h+".length; "+S+"++) { ",b.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0);var G=h+"["+S+"]";b.dataPathArr[k]=S;var W=e.validate(b);b.baseId=R,e.util.varOccurences(W,T)<2?s+=" "+e.util.varReplace(W,T,G)+" ":s+=" var "+T+" = "+G+"; "+W+" ",p&&(s+=" if (!"+E+") break; "),s+=" } } ",p&&(s+=" if ("+E+") { ",x+="}")}}else if(e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all)){b.schema=l,b.schemaPath=u,b.errSchemaPath=d,s+=" for (var "+S+" = 0; "+S+" < "+h+".length; "+S+"++) { ",b.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0);var G=h+"["+S+"]";b.dataPathArr[k]=S;var W=e.validate(b);b.baseId=R,e.util.varOccurences(W,T)<2?s+=" "+e.util.varReplace(W,T,G)+" ":s+=" var "+T+" = "+G+"; "+W+" ",p&&(s+=" if (!"+E+") break; "),s+=" }"}return p&&(s+=" "+x+" if ("+v+" == errors) {"),s}),RE}var jE,zL;function FL(){return zL||(zL=1,jE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,R,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l;var b=n=="maximum",x=b?"exclusiveMaximum":"exclusiveMinimum",E=e.schema[x],S=e.opts.$data&&E&&E.$data,k=b?"<":">",T=b?">":"<",R=void 0;if(!(g||typeof l=="number"||l===void 0))throw new Error(n+" must be number");if(!(S||E===void 0||typeof E=="number"||typeof E=="boolean"))throw new Error(x+" must be number or boolean");if(S){var j=e.util.getData(E.$data,a,e.dataPathArr),A="exclusive"+i,N="exclType"+i,M="exclIsNumber"+i,I="op"+i,O="' + "+I+" + '";s+=" var schemaExcl"+i+" = "+j+"; ",j="schemaExcl"+i,s+=" var "+A+"; var "+N+" = typeof "+j+"; if ("+N+" != 'boolean' && "+N+" != 'undefined' && "+N+" != 'number') { ";var R=x,L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(R||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: '"+x+" should be boolean' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" "+N+" == 'number' ? ( ("+A+" = "+v+" === undefined || "+j+" "+k+"= "+v+") ? "+h+" "+T+"= "+j+" : "+h+" "+T+" "+v+" ) : ( ("+A+" = "+j+" === true) ? "+h+" "+T+"= "+v+" : "+h+" "+T+" "+v+" ) || "+h+" !== "+h+") { var op"+i+" = "+A+" ? '"+k+"' : '"+k+"='; ",l===void 0&&(R=x,d=e.errSchemaPath+"/"+x,v=j,g=S)}else{var M=typeof E=="number",O=k;if(M&&g){var I="'"+O+"'";s+=" if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" ( "+v+" === undefined || "+E+" "+k+"= "+v+" ? "+h+" "+T+"= "+E+" : "+h+" "+T+" "+v+" ) || "+h+" !== "+h+") { "}else{M&&l===void 0?(A=!0,R=x,d=e.errSchemaPath+"/"+x,v=E,T+="="):(M&&(v=Math[b?"min":"max"](E,l)),E===(M?v:!0)?(A=!0,R=x,d=e.errSchemaPath+"/"+x,T+="="):(A=!1,O+="="));var I="'"+O+"'";s+=" if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" "+h+" "+T+" "+v+" || "+h+" !== "+h+") { "}}R=R||n;var L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(R||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { comparison: "+I+", limit: "+v+", exclusive: "+A+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be "+O+" ",g?s+="' + "+v:s+=""+v+"'"),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;return s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",p&&(s+=" else { "),s}),jE}var ME,UL;function BL(){return UL||(UL=1,ME=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,x,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");var b=n=="maxItems"?">":"<";s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" "+h+".length "+b+" "+v+") { ";var x=n,E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(x||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have ",n=="maxItems"?s+="more":s+="fewer",s+=" than ",g?s+="' + "+v+" + '":s+=""+l,s+=" items' "),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),ME}var OE,qL;function VL(){return qL||(qL=1,OE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,x,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");var b=n=="maxLength"?">":"<";s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),e.opts.unicode===!1?s+=" "+h+".length ":s+=" ucs2length("+h+") ",s+=" "+b+" "+v+") { ";var x=n,E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(x||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT be ",n=="maxLength"?s+="longer":s+="shorter",s+=" than ",g?s+="' + "+v+" + '":s+=""+l,s+=" characters' "),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),OE}var PE,HL;function GL(){return HL||(HL=1,PE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,x,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");var b=n=="maxProperties"?">":"<";s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'number') || "),s+=" Object.keys("+h+").length "+b+" "+v+") { ";var x=n,E=E||[];E.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(x||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { limit: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have ",n=="maxProperties"?s+="more":s+="fewer",s+=" than ",g?s+="' + "+v+" + '":s+=""+l,s+=" properties' "),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var S=s;return s=E.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),PE}var IE,WL;function ghe(){return WL||(WL=1,IE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;if(g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l,!(g||typeof l=="number"))throw new Error(n+" must be number");s+="var division"+i+";if (",g&&(s+=" "+v+" !== undefined && ( typeof "+v+" != 'number' || "),s+=" (division"+i+" = "+h+" / "+v+", ",e.opts.multipleOfPrecision?s+=" Math.abs(Math.round(division"+i+") - division"+i+") > 1e-"+e.opts.multipleOfPrecision+" ":s+=" division"+i+" !== parseInt(division"+i+") ",s+=" ) ",g&&(s+=" ) "),s+=" ) { ";var b=b||[];b.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { multipleOf: "+v+" } ",e.opts.messages!==!1&&(s+=" , message: 'should be multiple of ",g?s+="' + "+v:s+=""+v+"'"),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var x=s;return s=b.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+x+"]); ":s+=" validate.errors = ["+x+"]; return false; ":s+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),IE}var DE,YL;function vhe(){return YL||(YL=1,DE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e);v.level++;var b="valid"+v.level;if(e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all)){v.schema=l,v.schemaPath=u,v.errSchemaPath=d,s+=" var "+g+" = errors; ";var x=e.compositeRule;e.compositeRule=v.compositeRule=!0,v.createErrors=!1;var E;v.opts.allErrors&&(E=v.opts.allErrors,v.opts.allErrors=!1),s+=" "+e.validate(v)+" ",v.createErrors=!0,E&&(v.opts.allErrors=E),e.compositeRule=v.compositeRule=x,s+=" if ("+b+") { ";var S=S||[];S.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should NOT be valid' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var k=s;s=S.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+k+"]); ":s+=" validate.errors = ["+k+"]; return false; ":s+=" var err = "+k+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { errors = "+g+"; if (vErrors !== null) { if ("+g+") vErrors.length = "+g+"; else vErrors = null; } ",e.opts.allErrors&&(s+=" } ")}else s+=" var err = ",e.createErrors!==!1?(s+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: {} ",e.opts.messages!==!1&&(s+=" , message: 'should NOT be valid' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",p&&(s+=" if (false) { ");return s}),DE}var LE,KL;function yhe(){return KL||(KL=1,LE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v="errs__"+i,b=e.util.copy(e),x="";b.level++;var E="valid"+b.level,S=b.baseId,k="prevValid"+i,T="passingSchemas"+i;s+="var "+v+" = errors , "+k+" = false , "+g+" = false , "+T+" = null; ";var R=e.compositeRule;e.compositeRule=b.compositeRule=!0;var j=l;if(j)for(var A,N=-1,M=j.length-1;N<M;)A=j[N+=1],(e.opts.strictKeywords?typeof A=="object"&&Object.keys(A).length>0||A===!1:e.util.schemaHasRules(A,e.RULES.all))?(b.schema=A,b.schemaPath=u+"["+N+"]",b.errSchemaPath=d+"/"+N,s+=" "+e.validate(b)+" ",b.baseId=S):s+=" var "+E+" = true; ",N&&(s+=" if ("+E+" && "+k+") { "+g+" = false; "+T+" = ["+T+", "+N+"]; } else { ",x+="}"),s+=" if ("+E+") { "+g+" = "+k+" = true; "+T+" = "+N+"; }";return e.compositeRule=b.compositeRule=R,s+=""+x+"if (!"+g+") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { passingSchemas: "+T+" } ",e.opts.messages!==!1&&(s+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),s+="} else { errors = "+v+"; if (vErrors !== null) { if ("+v+") vErrors.length = "+v+"; else vErrors = null; }",e.opts.allErrors&&(s+=" } "),s}),LE}var $E,XL;function bhe(){return XL||(XL=1,$E=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g=e.opts.$data&&l&&l.$data,v;g?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",v="schema"+i):v=l;var b=g?"(new RegExp("+v+"))":e.usePattern(l);s+="if ( ",g&&(s+=" ("+v+" !== undefined && typeof "+v+" != 'string') || "),s+=" !"+b+".test("+h+") ) { ";var x=x||[];x.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { pattern: ",g?s+=""+v:s+=""+e.util.toQuotedString(l),s+=" } ",e.opts.messages!==!1&&(s+=` , message: 'should match pattern "`,g?s+="' + "+v+" + '":s+=""+e.util.escapeQuotes(l),s+=`"' `),e.opts.verbose&&(s+=" , schema: ",g?s+="validate.schema"+u:s+=""+e.util.toQuotedString(l),s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var E=s;return s=x.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+E+"]); ":s+=" validate.errors = ["+E+"]; return false; ":s+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",p&&(s+=" else { "),s}),$E}var zE,QL;function xhe(){return QL||(QL=1,zE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e),b="";v.level++;var x="valid"+v.level,E="key"+i,S="idx"+i,k=v.dataLevel=e.dataLevel+1,T="data"+k,R="dataProperties"+i,j=Object.keys(l||{}).filter(H),A=e.schema.patternProperties||{},N=Object.keys(A).filter(H),M=e.schema.additionalProperties,I=j.length||N.length,O=M===!1,L=typeof M=="object"&&Object.keys(M).length,z=e.opts.removeAdditional,G=O||L||z,W=e.opts.ownProperties,X=e.baseId,F=e.schema.required;if(F&&!(e.opts.$data&&F.$data)&&F.length<e.opts.loopRequired)var Y=e.util.toHash(F);function H(Te){return Te!=="__proto__"}if(s+="var "+g+" = errors;var "+x+" = true;",W&&(s+=" var "+R+" = undefined;"),G){if(W?s+=" "+R+" = "+R+" || Object.keys("+h+"); for (var "+S+"=0; "+S+"<"+R+".length; "+S+"++) { var "+E+" = "+R+"["+S+"]; ":s+=" for (var "+E+" in "+h+") { ",I){if(s+=" var isAdditional"+i+" = !(false ",j.length)if(j.length>8)s+=" || validate.schema"+u+".hasOwnProperty("+E+") ";else{var te=j;if(te)for(var P,re=-1,ue=te.length-1;re<ue;)P=te[re+=1],s+=" || "+E+" == "+e.util.toQuotedString(P)+" "}if(N.length){var D=N;if(D)for(var Z,he=-1,V=D.length-1;he<V;)Z=D[he+=1],s+=" || "+e.usePattern(Z)+".test("+E+") "}s+=" ); if (isAdditional"+i+") { "}if(z=="all")s+=" delete "+h+"["+E+"]; ";else{var U=e.errorPath,K="' + "+E+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers)),O)if(z)s+=" delete "+h+"["+E+"]; ";else{s+=" "+x+" = false; ";var ae=d;d=e.errSchemaPath+"/additionalProperties";var B=B||[];B.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { additionalProperty: '"+K+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is an invalid additional property":s+="should NOT have additional properties",s+="' "),e.opts.verbose&&(s+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var J=s;s=B.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+J+"]); ":s+=" validate.errors = ["+J+"]; return false; ":s+=" var err = "+J+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d=ae,p&&(s+=" break; ")}else if(L)if(z=="failing"){s+=" var "+g+" = errors; ";var oe=e.compositeRule;e.compositeRule=v.compositeRule=!0,v.schema=M,v.schemaPath=e.schemaPath+".additionalProperties",v.errSchemaPath=e.errSchemaPath+"/additionalProperties",v.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers);var fe=h+"["+E+"]";v.dataPathArr[k]=E;var be=e.validate(v);v.baseId=X,e.util.varOccurences(be,T)<2?s+=" "+e.util.varReplace(be,T,fe)+" ":s+=" var "+T+" = "+fe+"; "+be+" ",s+=" if (!"+x+") { errors = "+g+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+h+"["+E+"]; } ",e.compositeRule=v.compositeRule=oe}else{v.schema=M,v.schemaPath=e.schemaPath+".additionalProperties",v.errSchemaPath=e.errSchemaPath+"/additionalProperties",v.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers);var fe=h+"["+E+"]";v.dataPathArr[k]=E;var be=e.validate(v);v.baseId=X,e.util.varOccurences(be,T)<2?s+=" "+e.util.varReplace(be,T,fe)+" ":s+=" var "+T+" = "+fe+"; "+be+" ",p&&(s+=" if (!"+x+") break; ")}e.errorPath=U}I&&(s+=" } "),s+=" } ",p&&(s+=" if ("+x+") { ",b+="}")}var Ae=e.opts.useDefaults&&!e.compositeRule;if(j.length){var Oe=j;if(Oe)for(var P,Ne=-1,Qe=Oe.length-1;Ne<Qe;){P=Oe[Ne+=1];var dt=l[P];if(e.opts.strictKeywords?typeof dt=="object"&&Object.keys(dt).length>0||dt===!1:e.util.schemaHasRules(dt,e.RULES.all)){var Be=e.util.getProperty(P),fe=h+Be,pt=Ae&&dt.default!==void 0;v.schema=dt,v.schemaPath=u+Be,v.errSchemaPath=d+"/"+e.util.escapeFragment(P),v.errorPath=e.util.getPath(e.errorPath,P,e.opts.jsonPointers),v.dataPathArr[k]=e.util.toQuotedString(P);var be=e.validate(v);if(v.baseId=X,e.util.varOccurences(be,T)<2){be=e.util.varReplace(be,T,fe);var De=fe}else{var De=T;s+=" var "+T+" = "+fe+"; "}if(pt)s+=" "+be+" ";else{if(Y&&Y[P]){s+=" if ( "+De+" === undefined ",W&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(P)+"') "),s+=") { "+x+" = false; ";var U=e.errorPath,ae=d,et=e.util.escapeQuotes(P);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(U,P,e.opts.jsonPointers)),d=e.errSchemaPath+"/required";var B=B||[];B.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+et+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+et+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var J=s;s=B.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+J+"]); ":s+=" validate.errors = ["+J+"]; return false; ":s+=" var err = "+J+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d=ae,e.errorPath=U,s+=" } else { "}else p?(s+=" if ( "+De+" === undefined ",W&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(P)+"') "),s+=") { "+x+" = true; } else { "):(s+=" if ("+De+" !== undefined ",W&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(P)+"') "),s+=" ) { ");s+=" "+be+" } "}}p&&(s+=" if ("+x+") { ",b+="}")}}if(N.length){var ot=N;if(ot)for(var Z,lr=-1,xe=ot.length-1;lr<xe;){Z=ot[lr+=1];var dt=A[Z];if(e.opts.strictKeywords?typeof dt=="object"&&Object.keys(dt).length>0||dt===!1:e.util.schemaHasRules(dt,e.RULES.all)){v.schema=dt,v.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(Z),v.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(Z),W?s+=" "+R+" = "+R+" || Object.keys("+h+"); for (var "+S+"=0; "+S+"<"+R+".length; "+S+"++) { var "+E+" = "+R+"["+S+"]; ":s+=" for (var "+E+" in "+h+") { ",s+=" if ("+e.usePattern(Z)+".test("+E+")) { ",v.errorPath=e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers);var fe=h+"["+E+"]";v.dataPathArr[k]=E;var be=e.validate(v);v.baseId=X,e.util.varOccurences(be,T)<2?s+=" "+e.util.varReplace(be,T,fe)+" ":s+=" var "+T+" = "+fe+"; "+be+" ",p&&(s+=" if (!"+x+") break; "),s+=" } ",p&&(s+=" else "+x+" = true; "),s+=" } ",p&&(s+=" if ("+x+") { ",b+="}")}}}return p&&(s+=" "+b+" if ("+g+" == errors) {"),s}),zE}var FE,JL;function _he(){return JL||(JL=1,FE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="errs__"+i,v=e.util.copy(e),b="";v.level++;var x="valid"+v.level;if(s+="var "+g+" = errors;",e.opts.strictKeywords?typeof l=="object"&&Object.keys(l).length>0||l===!1:e.util.schemaHasRules(l,e.RULES.all)){v.schema=l,v.schemaPath=u,v.errSchemaPath=d;var E="key"+i,S="idx"+i,k="i"+i,T="' + "+E+" + '",R=v.dataLevel=e.dataLevel+1,j="data"+R,A="dataProperties"+i,N=e.opts.ownProperties,M=e.baseId;N&&(s+=" var "+A+" = undefined; "),N?s+=" "+A+" = "+A+" || Object.keys("+h+"); for (var "+S+"=0; "+S+"<"+A+".length; "+S+"++) { var "+E+" = "+A+"["+S+"]; ":s+=" for (var "+E+" in "+h+") { ",s+=" var startErrs"+i+" = errors; ";var I=E,O=e.compositeRule;e.compositeRule=v.compositeRule=!0;var L=e.validate(v);v.baseId=M,e.util.varOccurences(L,j)<2?s+=" "+e.util.varReplace(L,j,I)+" ":s+=" var "+j+" = "+I+"; "+L+" ",e.compositeRule=v.compositeRule=O,s+=" if (!"+x+") { for (var "+k+"=startErrs"+i+"; "+k+"<errors; "+k+"++) { vErrors["+k+"].propertyName = "+E+"; } var err = ",e.createErrors!==!1?(s+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { propertyName: '"+T+"' } ",e.opts.messages!==!1&&(s+=" , message: 'property name \\'"+T+"\\' is invalid' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; "),p&&(s+=" break; "),s+=" } }"}return p&&(s+=" "+b+" if ("+g+" == errors) {"),s}),FE}var UE,ZL;function whe(){return ZL||(ZL=1,UE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data;v&&(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ");var b="schema"+i;if(!v)if(l.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var x=[],E=l;if(E)for(var S,k=-1,T=E.length-1;k<T;){S=E[k+=1];var R=e.schema.properties[S];R&&(e.opts.strictKeywords?typeof R=="object"&&Object.keys(R).length>0||R===!1:e.util.schemaHasRules(R,e.RULES.all))||(x[x.length]=S)}}else var x=l;if(v||x.length){var j=e.errorPath,A=v||x.length>=e.opts.loopRequired,N=e.opts.ownProperties;if(p)if(s+=" var missing"+i+"; ",A){v||(s+=" var "+b+" = validate.schema"+u+"; ");var M="i"+i,I="schema"+i+"["+M+"]",O="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(j,I,e.opts.jsonPointers)),s+=" var "+g+" = true; ",v&&(s+=" if (schema"+i+" === undefined) "+g+" = true; else if (!Array.isArray(schema"+i+")) "+g+" = false; else {"),s+=" for (var "+M+" = 0; "+M+" < "+b+".length; "+M+"++) { "+g+" = "+h+"["+b+"["+M+"]] !== undefined ",N&&(s+=" && Object.prototype.hasOwnProperty.call("+h+", "+b+"["+M+"]) "),s+="; if (!"+g+") break; } ",v&&(s+=" } "),s+=" if (!"+g+") { ";var L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { "}else{s+=" if ( ";var G=x;if(G)for(var W,M=-1,X=G.length-1;M<X;){W=G[M+=1],M&&(s+=" || ");var F=e.util.getProperty(W),Y=h+F;s+=" ( ( "+Y+" === undefined ",N&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(W)+"') "),s+=") && (missing"+i+" = "+e.util.toQuotedString(e.opts.jsonPointers?W:F)+") ) "}s+=") { ";var I="missing"+i,O="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(j,I,!0):j+" + "+I);var L=L||[];L.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var z=s;s=L.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+z+"]); ":s+=" validate.errors = ["+z+"]; return false; ":s+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else { "}else if(A){v||(s+=" var "+b+" = validate.schema"+u+"; ");var M="i"+i,I="schema"+i+"["+M+"]",O="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(j,I,e.opts.jsonPointers)),v&&(s+=" if ("+b+" && !Array.isArray("+b+")) { var err = ",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+b+" !== undefined) { "),s+=" for (var "+M+" = 0; "+M+" < "+b+".length; "+M+"++) { if ("+h+"["+b+"["+M+"]] === undefined ",N&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", "+b+"["+M+"]) "),s+=") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",v&&(s+=" } ")}else{var H=x;if(H)for(var W,te=-1,P=H.length-1;te<P;){W=H[te+=1];var F=e.util.getProperty(W),O=e.util.escapeQuotes(W),Y=h+F;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(j,W,e.opts.jsonPointers)),s+=" if ( "+Y+" === undefined ",N&&(s+=" || ! Object.prototype.hasOwnProperty.call("+h+", '"+e.util.escapeQuotes(W)+"') "),s+=") { var err = ",e.createErrors!==!1?(s+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(s+=" , message: '",e.opts._errorDataPathProperty?s+="is a required property":s+="should have required property \\'"+O+"\\'",s+="' "),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=j}else p&&(s+=" if (true) {");return s}),UE}var BE,e3;function She(){return e3||(e3=1,BE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h="data"+(a||""),g="valid"+i,v=e.opts.$data&&l&&l.$data,b;if(v?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",b="schema"+i):b=l,(l||v)&&e.opts.uniqueItems!==!1){v&&(s+=" var "+g+"; if ("+b+" === false || "+b+" === undefined) "+g+" = true; else if (typeof "+b+" != 'boolean') "+g+" = false; else { "),s+=" var i = "+h+".length , "+g+" = true , j; if (i > 1) { ";var x=e.schema.items&&e.schema.items.type,E=Array.isArray(x);if(!x||x=="object"||x=="array"||E&&(x.indexOf("object")>=0||x.indexOf("array")>=0))s+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+h+"[i], "+h+"[j])) { "+g+" = false; break outer; } } } ";else{s+=" var itemIndices = {}, item; for (;i--;) { var item = "+h+"[i]; ";var S="checkDataType"+(E?"s":"");s+=" if ("+e.util[S](x,"item",e.opts.strictNumbers,!0)+") continue; ",E&&(s+=` if (typeof item == 'string') item = '"' + item; `),s+=" if (typeof itemIndices[item] == 'number') { "+g+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}s+=" } ",v&&(s+=" } "),s+=" if (!"+g+") { ";var k=k||[];k.push(s),s="",e.createErrors!==!1?(s+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { i: i, j: j } ",e.opts.messages!==!1&&(s+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(s+=" , schema: ",v?s+="validate.schema"+u:s+=""+l,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var T=s;s=k.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+T+"]); ":s+=" validate.errors = ["+T+"]; return false; ":s+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",p&&(s+=" else { ")}else p&&(s+=" if (true) { ");return s}),BE}var qE,t3;function Ehe(){return t3||(t3=1,qE={$ref:ihe(),allOf:ahe(),anyOf:ohe(),$comment:lhe(),const:che(),contains:uhe(),dependencies:dhe(),enum:fhe(),format:hhe(),if:phe(),items:mhe(),maximum:FL(),minimum:FL(),maxItems:BL(),minItems:BL(),maxLength:VL(),minLength:VL(),maxProperties:GL(),minProperties:GL(),multipleOf:ghe(),not:vhe(),oneOf:yhe(),pattern:bhe(),properties:xhe(),propertyNames:_he(),required:whe(),uniqueItems:She(),validate:eV()}),qE}var VE,n3;function khe(){if(n3)return VE;n3=1;var t=Ehe(),e=nh().toHash;return VE=function(){var r=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],s=["type","$comment"],i=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],a=["number","integer","string","array","object","boolean","null"];return r.all=e(s),r.types=e(a),r.forEach(function(l){l.rules=l.rules.map(function(u){var d;if(typeof u=="object"){var p=Object.keys(u)[0];d=u[p],u=p,d.forEach(function(g){s.push(g),r.all[g]=!0})}s.push(u);var h=r.all[u]={keyword:u,code:t[u],implements:d};return h}),r.all.$comment={keyword:"$comment",code:t.$comment},l.type&&(r.types[l.type]=l)}),r.keywords=e(s.concat(i)),r.custom={},r},VE}var HE,r3;function The(){if(r3)return HE;r3=1;var t=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];return HE=function(e,n){for(var r=0;r<n.length;r++){e=JSON.parse(JSON.stringify(e));var s=n[r].split("/"),i=e,a;for(a=1;a<s.length;a++)i=i[s[a]];for(a=0;a<t.length;a++){var l=t[a],u=i[l];u&&(i[l]={anyOf:[u,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e},HE}var GE,s3;function Che(){if(s3)return GE;s3=1;var t=KN().MissingRef;GE=e;function e(n,r,s){var i=this;if(typeof this._opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");typeof r=="function"&&(s=r,r=void 0);var a=l(n).then(function(){var d=i._addSchema(n,void 0,r);return d.validate||u(d)});return s&&a.then(function(d){s(null,d)},s),a;function l(d){var p=d.$schema;return p&&!i.getSchema(p)?e.call(i,{$ref:p},!0):Promise.resolve()}function u(d){try{return i._compile(d)}catch(h){if(h instanceof t)return p(h);throw h}function p(h){var g=h.missingSchema;if(x(g))throw new Error("Schema "+g+" is loaded but "+h.missingRef+" cannot be resolved");var v=i._loadingSchemas[g];return v||(v=i._loadingSchemas[g]=i._opts.loadSchema(g),v.then(b,b)),v.then(function(E){if(!x(g))return l(E).then(function(){x(g)||i.addSchema(E,g,void 0,r)})}).then(function(){return u(d)});function b(){delete i._loadingSchemas[g]}function x(E){return i._refs[E]||i._schemas[E]}}}}return GE}var WE,i3;function Ahe(){return i3||(i3=1,WE=function(e,n,r){var s=" ",i=e.level,a=e.dataLevel,l=e.schema[n],u=e.schemaPath+e.util.getProperty(n),d=e.errSchemaPath+"/"+n,p=!e.opts.allErrors,h,g="data"+(a||""),v="valid"+i,b="errs__"+i,x=e.opts.$data&&l&&l.$data,E;x?(s+=" var schema"+i+" = "+e.util.getData(l.$data,a,e.dataPathArr)+"; ",E="schema"+i):E=l;var S=this,k="definition"+i,T=S.definition,R="",j,A,N,M,I;if(x&&T.$data){I="keywordValidate"+i;var O=T.validateSchema;s+=" var "+k+" = RULES.custom['"+n+"'].definition; var "+I+" = "+k+".validate;"}else{if(M=e.useCustomRule(S,l,e.schema,e),!M)return;E="validate.schema"+u,I=M.code,j=T.compile,A=T.inline,N=T.macro}var L=I+".errors",z="i"+i,G="ruleErr"+i,W=T.async;if(W&&!e.async)throw new Error("async keyword in sync schema");if(A||N||(s+=""+L+" = null;"),s+="var "+b+" = errors;var "+v+";",x&&T.$data&&(R+="}",s+=" if ("+E+" === undefined) { "+v+" = true; } else { ",O&&(R+="}",s+=" "+v+" = "+k+".validateSchema("+E+"); if ("+v+") { ")),A)T.statements?s+=" "+M.validate+" ":s+=" "+v+" = "+M.validate+"; ";else if(N){var X=e.util.copy(e),R="";X.level++;var F="valid"+X.level;X.schema=M.validate,X.schemaPath="";var Y=e.compositeRule;e.compositeRule=X.compositeRule=!0;var H=e.validate(X).replace(/validate\.schema/g,I);e.compositeRule=X.compositeRule=Y,s+=" "+H}else{var te=te||[];te.push(s),s="",s+=" "+I+".call( ",e.opts.passContext?s+="this":s+="self",j||T.schema===!1?s+=" , "+g+" ":s+=" , "+E+" , "+g+" , validate.schema"+e.schemaPath+" ",s+=" , (dataPath || '')",e.errorPath!='""'&&(s+=" + "+e.errorPath);var P=a?"data"+(a-1||""):"parentData",re=a?e.dataPathArr[a]:"parentDataProperty";s+=" , "+P+" , "+re+" , rootData ) ";var ue=s;s=te.pop(),T.errors===!1?(s+=" "+v+" = ",W&&(s+="await "),s+=""+ue+"; "):W?(L="customErrors"+i,s+=" var "+L+" = null; try { "+v+" = await "+ue+"; } catch (e) { "+v+" = false; if (e instanceof ValidationError) "+L+" = e.errors; else throw e; } "):s+=" "+L+" = null; "+v+" = "+ue+"; "}if(T.modifying&&(s+=" if ("+P+") "+g+" = "+P+"["+re+"];"),s+=""+R,T.valid)p&&(s+=" if (true) { ");else{s+=" if ( ",T.valid===void 0?(s+=" !",N?s+=""+F:s+=""+v):s+=" "+!T.valid+" ",s+=") { ",h=S.keyword;var te=te||[];te.push(s),s="";var te=te||[];te.push(s),s="",e.createErrors!==!1?(s+=" { keyword: '"+(h||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+S.keyword+"' } ",e.opts.messages!==!1&&(s+=` , message: 'should pass "`+S.keyword+`" keyword validation' `),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+g+" "),s+=" } "):s+=" {} ";var D=s;s=te.pop(),!e.compositeRule&&p?e.async?s+=" throw new ValidationError(["+D+"]); ":s+=" validate.errors = ["+D+"]; return false; ":s+=" var err = "+D+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var Z=s;s=te.pop(),A?T.errors?T.errors!="full"&&(s+=" for (var "+z+"="+b+"; "+z+"<errors; "+z+"++) { var "+G+" = vErrors["+z+"]; if ("+G+".dataPath === undefined) "+G+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+G+".schemaPath === undefined) { "+G+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(s+=" "+G+".schema = "+E+"; "+G+".data = "+g+"; "),s+=" } "):T.errors===!1?s+=" "+Z+" ":(s+=" if ("+b+" == errors) { "+Z+" } else { for (var "+z+"="+b+"; "+z+"<errors; "+z+"++) { var "+G+" = vErrors["+z+"]; if ("+G+".dataPath === undefined) "+G+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+G+".schemaPath === undefined) { "+G+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(s+=" "+G+".schema = "+E+"; "+G+".data = "+g+"; "),s+=" } } "):N?(s+=" var err = ",e.createErrors!==!1?(s+=" { keyword: '"+(h||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+S.keyword+"' } ",e.opts.messages!==!1&&(s+=` , message: 'should pass "`+S.keyword+`" keyword validation' `),e.opts.verbose&&(s+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+g+" "),s+=" } "):s+=" {} ",s+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?s+=" throw new ValidationError(vErrors); ":s+=" validate.errors = vErrors; return false; ")):T.errors===!1?s+=" "+Z+" ":(s+=" if (Array.isArray("+L+")) { if (vErrors === null) vErrors = "+L+"; else vErrors = vErrors.concat("+L+"); errors = vErrors.length; for (var "+z+"="+b+"; "+z+"<errors; "+z+"++) { var "+G+" = vErrors["+z+"]; if ("+G+".dataPath === undefined) "+G+".dataPath = (dataPath || '') + "+e.errorPath+"; "+G+'.schemaPath = "'+d+'"; ',e.opts.verbose&&(s+=" "+G+".schema = "+E+"; "+G+".data = "+g+"; "),s+=" } } else { "+Z+" } "),s+=" } ",p&&(s+=" else { ")}return s}),WE}const Nhe="http://json-schema.org/draft-07/schema#",Rhe="http://json-schema.org/draft-07/schema#",jhe="Core schema meta-schema",Mhe={schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},Ohe=["object","boolean"],Phe={$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},tV={$schema:Nhe,$id:Rhe,title:jhe,definitions:Mhe,type:Ohe,properties:Phe,default:!0};var YE,a3;function Ihe(){if(a3)return YE;a3=1;var t=tV;return YE={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:t.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:t.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}},YE}var KE,o3;function Dhe(){if(o3)return KE;o3=1;var t=/^[a-z_$][a-z0-9_$-]*$/i,e=Ahe(),n=Ihe();KE={add:r,get:s,remove:i,validate:a};function r(l,u){var d=this.RULES;if(d.keywords[l])throw new Error("Keyword "+l+" is already defined");if(!t.test(l))throw new Error("Keyword "+l+" is not a valid identifier");if(u){this.validateKeyword(u,!0);var p=u.type;if(Array.isArray(p))for(var h=0;h<p.length;h++)v(l,p[h],u);else v(l,p,u);var g=u.metaSchema;g&&(u.$data&&this._opts.$data&&(g={anyOf:[g,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),u.validateSchema=this.compile(g,!0))}d.keywords[l]=d.all[l]=!0;function v(b,x,E){for(var S,k=0;k<d.length;k++){var T=d[k];if(T.type==x){S=T;break}}S||(S={type:x,rules:[]},d.push(S));var R={keyword:b,definition:E,custom:!0,code:e,implements:E.implements};S.rules.push(R),d.custom[b]=R}return this}function s(l){var u=this.RULES.custom[l];return u?u.definition:this.RULES.keywords[l]||!1}function i(l){var u=this.RULES;delete u.keywords[l],delete u.all[l],delete u.custom[l];for(var d=0;d<u.length;d++)for(var p=u[d].rules,h=0;h<p.length;h++)if(p[h].keyword==l){p.splice(h,1);break}return this}function a(l,u){a.errors=null;var d=this._validateKeyword=this._validateKeyword||this.compile(n,!0);if(d(l))return!0;if(a.errors=d.errors,u)throw new Error("custom keyword definition is invalid: "+this.errorsText(d.errors));return!1}return KE}const Lhe="http://json-schema.org/draft-07/schema#",$he="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",zhe="Meta-schema for $data reference (JSON Schema extension proposal)",Fhe="object",Uhe=["$data"],Bhe={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},qhe=!1,Vhe={$schema:Lhe,$id:$he,description:zhe,type:Fhe,required:Uhe,properties:Bhe,additionalProperties:qhe};var XE,l3;function Hhe(){if(l3)return XE;l3=1;var t=nhe(),e=YN(),n=rhe(),r=Jq(),s=Zq(),i=she(),a=khe(),l=The(),u=nh();XE=b,b.prototype.validate=x,b.prototype.compile=E,b.prototype.addSchema=S,b.prototype.addMetaSchema=k,b.prototype.validateSchema=T,b.prototype.getSchema=j,b.prototype.removeSchema=M,b.prototype.addFormat=Y,b.prototype.errorsText=F,b.prototype._addSchema=O,b.prototype._compile=L,b.prototype.compileAsync=Che();var d=Dhe();b.prototype.addKeyword=d.add,b.prototype.getKeyword=d.get,b.prototype.removeKeyword=d.remove,b.prototype.validateKeyword=d.validate;var p=KN();b.ValidationError=p.Validation,b.MissingRefError=p.MissingRef,b.$dataMetaSchema=l;var h="http://json-schema.org/draft-07/schema",g=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],v=["/properties"];function b(V){if(!(this instanceof b))return new b(V);V=this._opts=u.copy(V)||{},Z(this),this._schemas={},this._refs={},this._fragments={},this._formats=i(V.format),this._cache=V.cache||new n,this._loadingSchemas={},this._compilations=[],this.RULES=a(),this._getId=z(V),V.loopRequired=V.loopRequired||1/0,V.errorDataPath=="property"&&(V._errorDataPathProperty=!0),V.serialize===void 0&&(V.serialize=s),this._metaOpts=D(this),V.formats&&P(this),V.keywords&&re(this),H(this),typeof V.meta=="object"&&this.addMetaSchema(V.meta),V.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),te(this)}function x(V,U){var K;if(typeof V=="string"){if(K=this.getSchema(V),!K)throw new Error('no schema with key or ref "'+V+'"')}else{var ae=this._addSchema(V);K=ae.validate||this._compile(ae)}var B=K(U);return K.$async!==!0&&(this.errors=K.errors),B}function E(V,U){var K=this._addSchema(V,void 0,U);return K.validate||this._compile(K)}function S(V,U,K,ae){if(Array.isArray(V)){for(var B=0;B<V.length;B++)this.addSchema(V[B],void 0,K,ae);return this}var J=this._getId(V);if(J!==void 0&&typeof J!="string")throw new Error("schema id must be string");return U=e.normalizeId(U||J),ue(this,U),this._schemas[U]=this._addSchema(V,K,ae,!0),this}function k(V,U,K){return this.addSchema(V,U,K,!0),this}function T(V,U){var K=V.$schema;if(K!==void 0&&typeof K!="string")throw new Error("$schema must be a string");if(K=K||this._opts.defaultMeta||R(this),!K)return this.logger.warn("meta-schema not available"),this.errors=null,!0;var ae=this.validate(K,V);if(!ae&&U){var B="schema is invalid: "+this.errorsText();if(this._opts.validateSchema=="log")this.logger.error(B);else throw new Error(B)}return ae}function R(V){var U=V._opts.meta;return V._opts.defaultMeta=typeof U=="object"?V._getId(U)||U:V.getSchema(h)?h:void 0,V._opts.defaultMeta}function j(V){var U=N(this,V);switch(typeof U){case"object":return U.validate||this._compile(U);case"string":return this.getSchema(U);case"undefined":return A(this,V)}}function A(V,U){var K=e.schema.call(V,{schema:{}},U);if(K){var ae=K.schema,B=K.root,J=K.baseId,oe=t.call(V,ae,B,void 0,J);return V._fragments[U]=new r({ref:U,fragment:!0,schema:ae,root:B,baseId:J,validate:oe}),oe}}function N(V,U){return U=e.normalizeId(U),V._schemas[U]||V._refs[U]||V._fragments[U]}function M(V){if(V instanceof RegExp)return I(this,this._schemas,V),I(this,this._refs,V),this;switch(typeof V){case"undefined":return I(this,this._schemas),I(this,this._refs),this._cache.clear(),this;case"string":var U=N(this,V);return U&&this._cache.del(U.cacheKey),delete this._schemas[V],delete this._refs[V],this;case"object":var K=this._opts.serialize,ae=K?K(V):V;this._cache.del(ae);var B=this._getId(V);B&&(B=e.normalizeId(B),delete this._schemas[B],delete this._refs[B])}return this}function I(V,U,K){for(var ae in U){var B=U[ae];!B.meta&&(!K||K.test(ae))&&(V._cache.del(B.cacheKey),delete U[ae])}}function O(V,U,K,ae){if(typeof V!="object"&&typeof V!="boolean")throw new Error("schema should be object or boolean");var B=this._opts.serialize,J=B?B(V):V,oe=this._cache.get(J);if(oe)return oe;ae=ae||this._opts.addUsedSchema!==!1;var fe=e.normalizeId(this._getId(V));fe&&ae&&ue(this,fe);var be=this._opts.validateSchema!==!1&&!U,Ae;be&&!(Ae=fe&&fe==e.normalizeId(V.$schema))&&this.validateSchema(V,!0);var Oe=e.ids.call(this,V),Ne=new r({id:fe,schema:V,localRefs:Oe,cacheKey:J,meta:K});return fe[0]!="#"&&ae&&(this._refs[fe]=Ne),this._cache.put(J,Ne),be&&Ae&&this.validateSchema(V,!0),Ne}function L(V,U){if(V.compiling)return V.validate=B,B.schema=V.schema,B.errors=null,B.root=U||B,V.schema.$async===!0&&(B.$async=!0),B;V.compiling=!0;var K;V.meta&&(K=this._opts,this._opts=this._metaOpts);var ae;try{ae=t.call(this,V.schema,U,V.localRefs)}catch(J){throw delete V.validate,J}finally{V.compiling=!1,V.meta&&(this._opts=K)}return V.validate=ae,V.refs=ae.refs,V.refVal=ae.refVal,V.root=ae.root,ae;function B(){var J=V.validate,oe=J.apply(this,arguments);return B.errors=J.errors,oe}}function z(V){switch(V.schemaId){case"auto":return X;case"id":return G;default:return W}}function G(V){return V.$id&&this.logger.warn("schema $id ignored",V.$id),V.id}function W(V){return V.id&&this.logger.warn("schema id ignored",V.id),V.$id}function X(V){if(V.$id&&V.id&&V.$id!=V.id)throw new Error("schema $id is different from id");return V.$id||V.id}function F(V,U){if(V=V||this.errors,!V)return"No errors";U=U||{};for(var K=U.separator===void 0?", ":U.separator,ae=U.dataVar===void 0?"data":U.dataVar,B="",J=0;J<V.length;J++){var oe=V[J];oe&&(B+=ae+oe.dataPath+" "+oe.message+K)}return B.slice(0,-K.length)}function Y(V,U){return typeof U=="string"&&(U=new RegExp(U)),this._formats[V]=U,this}function H(V){var U;if(V._opts.$data&&(U=Vhe,V.addMetaSchema(U,U.$id,!0)),V._opts.meta!==!1){var K=tV;V._opts.$data&&(K=l(K,v)),V.addMetaSchema(K,h,!0),V._refs["http://json-schema.org/schema"]=h}}function te(V){var U=V._opts.schemas;if(U)if(Array.isArray(U))V.addSchema(U);else for(var K in U)V.addSchema(U[K],K)}function P(V){for(var U in V._opts.formats){var K=V._opts.formats[U];V.addFormat(U,K)}}function re(V){for(var U in V._opts.keywords){var K=V._opts.keywords[U];V.addKeyword(U,K)}}function ue(V,U){if(V._schemas[U]||V._refs[U])throw new Error('schema with key or id "'+U+'" already exists')}function D(V){for(var U=u.copy(V._opts),K=0;K<g.length;K++)delete U[g[K]];return U}function Z(V){var U=V._opts.logger;if(U===!1)V.logger={log:he,warn:he,error:he};else{if(U===void 0&&(U=console),!(typeof U=="object"&&U.log&&U.warn&&U.error))throw new Error("logger must implement log, warn and error methods");V.logger=U}}function he(){}return XE}var Ghe=Hhe();const Whe=Vf(Ghe),c3=new Whe;function Yhe(t,e){const n={structuredErrors:void 0,unstructuredStatus:"not_applicable"};if(!e)return n;if(t.structuredContent)try{const r=c3.compile(e),s=r(t.structuredContent);n.structuredErrors=s?null:r.errors||[]}catch{n.structuredErrors=n.structuredErrors=[{keyword:"schema-compilation",instancePath:"",schemaPath:"",params:{},message:"The provided outputSchema is invalid and could not be compiled."}]}if(typeof t.content[0].text=="string")try{const r=JSON.parse(t.content[0].text),i=c3.compile(e)(r);n.unstructuredStatus=i?"valid":"schema_mismatch"}catch{n.unstructuredStatus="invalid_json"}return n}function Khe({serverConfig:t,serverName:e}){const n=GN("ToolsTab"),[r,s]=w.useState({}),[i,a]=w.useState(""),[l,u]=w.useState([]),[d,p]=w.useState(null),[h,g]=w.useState(null),[v,b]=w.useState(!1),[x,E]=w.useState(void 0),[S,k]=w.useState("not_applicable"),[T,R]=w.useState(!1),[j,A]=w.useState(!1),[N,M]=w.useState(""),[I,O]=w.useState(null),[L,z]=w.useState(!1),[G,W]=w.useState(""),[X,F]=w.useState("tools"),[Y,H]=w.useState(null),[te,P]=w.useState(null),[re,ue]=w.useState(null),[D,Z]=w.useState(null),[he,V]=w.useState(null),[U,K]=w.useState([]),[ae,B]=w.useState(!1),[J,oe]=w.useState(null),[fe,be]=w.useState({title:""}),Ae=w.useMemo(()=>{if(!t)return"none";try{if(t.url)return`http:${t.url}`;if(t.command){const Pe=(t.args||[]).join(" ");return`stdio:${t.command} ${Pe}`.trim()}return JSON.stringify(t)}catch{return"unknown"}},[t]);w.useEffect(()=>{if(!t||!e){s({}),a(""),u([]),p(null),g(null),b(!1),E(void 0),k("not_applicable"),M(""),O(null);return}Oe()},[t,e]),w.useEffect(()=>{t&&K(Ll(Ae))},[t,Ae]),w.useEffect(()=>{i&&r[i]&&u($fe(r[i].inputSchema))},[i,r]);const Oe=async()=>{if(!e){n.warn("Cannot fetch tools: no serverId available");return}A(!0),M(""),s({}),a(""),u([]),p(null),g(null),b(!1),E(void 0),k("not_applicable");try{const bt=(await AN(e)).tools??[],Xt=Object.fromEntries(bt.map(vt=>[vt.name,vt]));s(Xt),n.info("Tools fetched",{serverId:e,toolCount:bt.length})}catch(Pe){const bt=Pe instanceof Error?Pe.message:"Unknown error";n.error("Failed to fetch tools",{error:bt}),M(bt)}finally{A(!1)}},Ne=(Pe,bt)=>{u(Xt=>Xt.map(vt=>vt.name===Pe?{...vt,value:bt}:vt))},Qe=Pe=>{u(bt=>zfe(bt,Pe))},dt=()=>Ffe(l,(Pe,bt)=>n.warn(Pe,bt)),Be=Pe=>Pe?r[Pe]?._meta:void 0,pt=(Pe,bt,Xt)=>{if("result"in Pe&&Pe.status==="completed"){O(null);const vt=Pe.result;p(vt);const Qt=vt;if(Qt?.structuredContent){g(Qt.structuredContent);const Yo=Be(bt)?.["openai/outputTemplate"];b(!Yo)}else g(null),b(!1);const cr=r[bt];if(cr?.outputSchema){const br=Yhe(Qt,cr.outputSchema);E(br.structuredErrors),k(br.unstructuredStatus),br.structuredErrors&&n.warn("Schema validation failed",{errors:br.structuredErrors})}else E(void 0),k("not_applicable");n.info("Tool execution completed",{toolName:bt,duration:Date.now()-Xt});return}if("status"in Pe&&Pe.status==="elicitation_required"){O({executionId:Pe.executionId,requestId:Pe.requestId,request:Pe.request,timestamp:Pe.timestamp});return}"error"in Pe&&Pe.error&&M(Pe.error)},De=async()=>{if(!i){n.warn("Cannot execute tool: no tool selected");return}if(!e){n.warn("Cannot execute tool: no serverId available");return}R(!0),M(""),p(null),g(null),b(!1),E(void 0),k("not_applicable");const Pe=Date.now(),bt=`tool-${Pe}`,Xt=new Date;try{const vt=dt();P(bt),ue(i),Z(vt),V(Xt);const Qt=await ZS(e,i,vt);pt(Qt,i,Pe)}catch(vt){console.error("executeTool",vt);const Qt=vt instanceof Error?vt.message:"Unknown error";n.error("Tool execution network error",{toolName:i,error:Qt}),M(Qt)}finally{R(!1)}},et=async(Pe,bt)=>{if(!I){n.warn("Cannot handle elicitation response: no active request");return}z(!0);try{const Xt=Pe==="accept"?{action:"accept",content:bt??{}}:{action:Pe},vt=await Bue(I.requestId,Xt);pt(vt,i,Date.now())}catch(Xt){const vt=Xt instanceof Error?Xt.message:"Unknown error";n.error("Error responding to elicitation",{requestId:I.requestId,action:Pe,error:vt}),M(vt)}finally{z(!1)}},ot=()=>{i&&(oe(null),be({title:i,description:""}),B(!0))},lr=Pe=>{a(Pe.toolName),setTimeout(()=>Qe(Pe.parameters),50)},xe=Pe=>{Bfe(Ae,Pe),K(Ll(Ae))},Te=Pe=>{const bt=qfe(Ae,Pe.id);K(Ll(Ae)),bt?.id&&(H(bt.id),setTimeout(()=>H(null),2e3))},st=Pe=>{oe(Pe.id),be({title:Pe.title,description:Pe.description}),B(!0)},qe=Object.keys(r),At=G.trim()?qe.filter(Pe=>{const bt=r[Pe];return`${Pe} ${bt?.description??""}`.toLowerCase().includes(G.trim().toLowerCase())}):qe,Jn=G.trim()?U.filter(Pe=>`${Pe.title} ${Pe.description??""}`.toLowerCase().includes(G.trim().toLowerCase())):U,Zn=I?{requestId:I.requestId,message:I.request.message,schema:I.request.requestedSchema,timestamp:I.timestamp}:null;return t?f.jsxs("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:[f.jsxs(Tf,{direction:"vertical",className:"flex-1",children:[f.jsx(ni,{defaultSize:70,minSize:30,children:f.jsxs(Tf,{direction:"horizontal",className:"h-full",children:[f.jsx(Ife,{activeTab:X,onChangeTab:F,tools:r,toolNames:qe,filteredToolNames:At,selectedToolName:i,fetchingTools:j,searchQuery:G,onSearchQueryChange:W,onRefresh:Oe,onSelectTool:a,savedRequests:Jn,highlightedRequestId:Y,onLoadRequest:lr,onRenameRequest:st,onDuplicateRequest:Te,onDeleteRequest:xe}),f.jsx(Cf,{withHandle:!0}),i?f.jsx(Tde,{selectedTool:i,toolDescription:r[i]?.description,formFields:l,loading:T,waitingOnElicitation:!!I,onExecute:De,onSave:ot,onFieldChange:Ne}):f.jsx(ni,{defaultSize:70,minSize:50,children:f.jsx("div",{className:"h-full flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:f.jsx(kk,{className:"h-5 w-5 text-muted-foreground"})}),f.jsx("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a tool"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a tool from the left to configure parameters"})]})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:40,minSize:15,maxSize:85,children:f.jsx(Mfe,{error:N,showStructured:v,onToggleStructured:b,structuredResult:h,result:d,validationErrors:x,unstructuredValidationResult:S,serverId:e,toolCallId:te??void 0,toolName:re??void 0,toolParameters:D??void 0,toolCallTimestamp:he??void 0,toolMeta:Be(re),onExecuteFromUI:async(Pe,bt)=>e?await ZS(e,Pe,bt||{}):{error:"No server selected"},onHandleIntent:async(Pe,bt)=>{e&&await ZS(e,"handleIntent",{intent:Pe,params:bt||{}})},onSendFollowup:Pe=>{n.info("OpenAI component requested follow-up",{message:Pe})}})})]}),f.jsx(ST,{elicitationRequest:Zn,onResponse:et,loading:L}),f.jsx(Dfe,{open:ae,defaultTitle:fe.title,defaultDescription:fe.description,onCancel:()=>B(!1),onSave:({title:Pe,description:bt})=>{if(J){Vfe(Ae,J,{title:Pe,description:bt}),K(Ll(Ae)),oe(null),B(!1),F("saved"),H(J),setTimeout(()=>H(null),2e3);return}const Xt=dt(),vt=HN(Ae,{title:Pe,description:bt,toolName:i,parameters:Xt});K(Ll(Ae)),B(!1),F("saved"),vt?.id&&(H(vt.id),setTimeout(()=>H(null),2e3))}})]}):f.jsx(th,{icon:kk,title:"No Server Selected",description:"Connect to an MCP server to explore and test its available tools."})}function Xhe({serverConfig:t,serverName:e}){const[n,r]=w.useState([]),[s,i]=w.useState(""),[a,l]=w.useState(null),[u,d]=w.useState(!1),[p,h]=w.useState(!1),[g,v]=w.useState(""),b=w.useMemo(()=>n.find(S=>S.uri===s)??null,[n,s]);w.useEffect(()=>{t&&e&&x()},[t,e]);const x=async()=>{if(e){h(!0),v(""),r([]);try{const S=await fetch("/api/mcp/resources/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e})}),k=await S.json();if(S.ok){const T=Array.isArray(k.resources)?k.resources:[];r(T),T.length===0?(i(""),l(null)):T.some(R=>R.uri===s)||(i(T[0].uri),l(null))}else v(k.error||"Failed to fetch resources")}catch(S){v(`Network error fetching resources: ${S}`)}finally{h(!1)}}},E=async S=>{if(e){d(!0),v("");try{const k=await fetch("/api/mcp/resources/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e,uri:S})}),T=await k.json();k.ok?l(T.content??null):v(T.error||"Failed to read resource")}catch(k){v(`Network error reading resource: ${k}`)}finally{d(!1)}}};return!t||!e?f.jsx(th,{icon:MS,title:"No Server Selected",description:"Connect to an MCP server to browse and explore its available resources."}):f.jsx("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:f.jsxs(Tf,{direction:"vertical",className:"flex-1",children:[f.jsx(ni,{defaultSize:70,minSize:30,children:f.jsxs(Tf,{direction:"horizontal",className:"h-full",children:[f.jsx(ni,{defaultSize:30,minSize:20,maxSize:50,children:f.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(MS,{className:"h-3 w-3 text-muted-foreground"}),f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Resources"}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono",children:n.length})]}),f.jsx(Ie,{onClick:x,variant:"ghost",size:"sm",disabled:p,children:f.jsx(ir,{className:`h-3 w-3 ${p?"animate-spin":""} cursor-pointer`})})]}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-2",children:p?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(ir,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading resources..."}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available resources from server"})]}):n.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:"No resources available"})}):f.jsx("div",{className:"space-y-1",children:n.map(S=>f.jsx("div",{className:`cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ${s===S.uri?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"}`,onClick:()=>i(S.uri),children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(kse,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f.jsx("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:S.name})]}),S.description&&f.jsx("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:S.description}),f.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1 font-mono truncate",children:S.uri}),S.mimeType&&f.jsx(vr,{variant:"outline",className:"text-xs mt-2 font-mono",children:S.mimeType})]}),f.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},S.uri))})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:70,minSize:50,children:f.jsx("div",{className:"h-full flex flex-col bg-background",children:s?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"flex items-center gap-3",children:f.jsx("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:b?.name||s})}),f.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate max-w-md",children:s})]}),f.jsx(Ie,{onClick:()=>E(s),disabled:u,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:u?f.jsxs(f.Fragment,{children:[f.jsx(ir,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Reading"})]}):f.jsxs(f.Fragment,{children:[f.jsx(lI,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Read"})]})})]}),b?.description&&f.jsx("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:f.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:b.description})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"px-6 py-6",children:a?f.jsx("div",{className:"space-y-4",children:a?.contents?.map((S,k)=>f.jsxs("div",{className:"group",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[f.jsx(vr,{variant:"secondary",className:"text-xs font-mono font-medium",children:S.type}),S.mimeType&&f.jsx(vr,{variant:"outline",className:"text-xs font-mono",children:S.mimeType})]}),f.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:S.type==="text"?f.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap p-4 bg-background overflow-auto max-h-96",children:S.text}):f.jsx("div",{className:"p-4",children:f.jsx(zl,{src:S,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"0",borderRadius:"0",border:"none"}})})})]},k))}):f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(lI,{className:"h-4 w-4 text-muted-foreground"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Ready to read resource"}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Click the Read button to view resource content"})]})})})})]}):f.jsx("div",{className:"h-full flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:f.jsx(MS,{className:"h-5 w-5 text-muted-foreground"})}),f.jsx("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a resource"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a resource from the left to preview its content"})]})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:30,minSize:15,maxSize:70,children:f.jsxs("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[f.jsx("div",{className:"flex items-center justify-between p-4 border-b border-border",children:f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Status"})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:g?f.jsx("div",{className:"p-4",children:f.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:g})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Resource operations status will appear here"})})})]})})]})})}function Qhe({serverConfig:t,serverName:e}){const[n,r]=w.useState([]),[s,i]=w.useState(""),[a,l]=w.useState([]),[u,d]=w.useState(null),[p,h]=w.useState(!1),[g,v]=w.useState(!1),[b,x]=w.useState(""),E=w.useMemo(()=>n.find(N=>N.name===s)??null,[n,s]);w.useEffect(()=>{t&&e&&S()},[t,e]),w.useEffect(()=>{E?.arguments?k(E.arguments):l([])},[E]);const S=async()=>{if(e){v(!0),x("");try{const N=await fetch("/api/mcp/prompts/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e})}),M=await N.json();if(N.ok){const I=Array.isArray(M.prompts)?M.prompts:[];r(I),I.length===0?(i(""),d(null)):I.some(O=>O.name===s)||(i(I[0].name),d(null))}else x(M.error||"Could not fetch prompts")}catch(N){x(`Could not fetch prompts: ${N}`)}finally{v(!1)}}},k=N=>{if(!N||N.length===0){l([]);return}const M=N.map(I=>({name:I.name,type:"string",description:I.description,required:!!I.required,value:""}));l(M)},T=(N,M)=>{l(I=>I.map(O=>O.name===N?{...O,value:M}:O))},R=()=>{const N={};return a.forEach(M=>{if(M.value!==""&&M.value!==null&&M.value!==void 0){let I;M.type==="array"||M.type==="object"?I=typeof M.value=="string"?M.value:JSON.stringify(M.value):M.type==="boolean"?I=M.value?"true":"false":(M.type==="number"||M.type,I=String(M.value)),N[M.name]=I}}),N},j=async()=>{if(!(!s||!e)){h(!0),x("");try{const N=R(),M=await fetch("/api/mcp/prompts/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e,name:s,args:N})}),I=await M.json();M.ok?d(I.content):x(I.error||"Failed to get prompt")}catch(N){x(`Error getting prompt: ${N}`)}finally{h(!1)}}},A=n.map(N=>N.name);return!t||!e?f.jsx(th,{icon:Gy,title:"No Server Selected",description:"Connect to an MCP server to explore and test its available prompts."}):f.jsx("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:f.jsxs(Tf,{direction:"vertical",className:"flex-1",children:[f.jsx(ni,{defaultSize:70,minSize:30,children:f.jsxs(Tf,{direction:"horizontal",className:"h-full",children:[f.jsx(ni,{defaultSize:30,minSize:20,maxSize:50,children:f.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Gy,{className:"h-3 w-3 text-muted-foreground"}),f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Prompts"}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono",children:A.length})]}),f.jsx(Ie,{onClick:S,variant:"ghost",size:"sm",disabled:g,children:f.jsx(ir,{className:`h-3 w-3 ${g?"animate-spin":""} cursor-pointer`})})]}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-2",children:g?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(ir,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading prompts..."}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available prompts from server"})]}):A.length===0?f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-muted-foreground",children:"No prompts available"})}):f.jsx("div",{className:"space-y-1",children:n.map(N=>{const M=s===N.name,I=N.title??N.name;return f.jsx("div",{className:`cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ${M?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"}`,onClick:()=>{i(N.name)},children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:N.name}),N.title&&f.jsx("span",{className:"text-xs font-semibold text-foreground",children:I})]}),N.description&&f.jsx("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:N.description})]}),f.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},N.name)})})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:70,minSize:50,children:f.jsx("div",{className:"h-full flex flex-col bg-background",children:s?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[f.jsx("div",{className:"space-y-2",children:f.jsx("div",{className:"flex items-center gap-3",children:f.jsx("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:s})})}),f.jsx(Ie,{onClick:j,disabled:p||!s,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:p?f.jsxs(f.Fragment,{children:[f.jsx(ir,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Loading"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Cb,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),f.jsx("span",{className:"font-mono text-xs",children:"Get Prompt"})]})})]}),E?.description&&f.jsx("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:f.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:E.description})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"px-6 py-6",children:a.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[f.jsx("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:f.jsx(Cb,{className:"h-4 w-4 text-muted-foreground"})}),f.jsx("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"No parameters required"}),f.jsx("p",{className:"text-xs text-muted-foreground/70",children:"This prompt can be retrieved directly"})]}):f.jsx("div",{className:"space-y-8",children:a.map(N=>f.jsxs("div",{className:"group",children:[f.jsxs("div",{className:"flex items-start justify-between mb-3",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("code",{className:"font-mono text-xs font-semibold text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:N.name}),N.required&&f.jsx("div",{className:"w-1.5 h-1.5 bg-amber-400 dark:bg-amber-500 rounded-full",title:"Required field"})]}),N.description&&f.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed max-w-md font-medium",children:N.description})]}),f.jsx(vr,{variant:"secondary",className:"text-xs font-mono font-medium",children:N.type})]}),f.jsx("div",{className:"space-y-2",children:N.type==="enum"?f.jsxs(Qc,{value:String(N.value),onValueChange:M=>T(N.name,M),children:[f.jsx(Zc,{className:"w-full bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs",children:f.jsx(Jc,{placeholder:"Select an option",className:"font-mono text-xs"})}),f.jsx(eu,{children:N.enum?.map(M=>f.jsx(Qs,{value:M,className:"font-mono text-xs",children:M},M))})]}):N.type==="boolean"?f.jsxs("div",{className:"flex items-center space-x-3 py-2",children:[f.jsx("input",{type:"checkbox",checked:N.value===!0,onChange:M=>T(N.name,M.target.checked),className:"w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"}),f.jsx("span",{className:"text-xs text-foreground font-medium",children:N.value===!0?"Enabled":"Disabled"})]}):N.type==="array"||N.type==="object"?f.jsx(Ho,{value:typeof N.value=="string"?N.value:JSON.stringify(N.value,null,2),onChange:M=>T(N.name,M.target.value),placeholder:`Enter ${N.type} as JSON`,className:"font-mono text-xs h-20 bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 resize-none"}):f.jsx(Un,{type:N.type==="number"||N.type==="integer"?"number":"text",value:String(N.value),onChange:M=>T(N.name,M.target.value),placeholder:`Enter ${N.name}`,className:"bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs"})})]},N.name))})})})})]}):f.jsx("div",{className:"h-full flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:f.jsx(Gy,{className:"h-5 w-5 text-muted-foreground"})}),f.jsx("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a prompt"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a prompt from the left to view details"})]})})})})]})}),f.jsx(Cf,{withHandle:!0}),f.jsx(ni,{defaultSize:30,minSize:15,maxSize:70,children:f.jsxs("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[f.jsx("div",{className:"flex items-center justify-between p-4 border-b border-border",children:f.jsx("h2",{className:"text-xs font-semibold text-foreground",children:"Prompt Content"})}),f.jsx("div",{className:"flex-1 overflow-hidden",children:b?f.jsx("div",{className:"p-4",children:f.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:b})}):u?f.jsx(La,{className:"h-full",children:f.jsx("div",{className:"p-4",children:typeof u=="string"?f.jsx("pre",{className:"whitespace-pre-wrap text-xs font-mono bg-muted p-4 rounded-md border border-border",children:u}):f.jsx(zl,{src:u,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"Get a prompt to see its content here"})})})]})})]})})}var nV=t=>{throw TypeError(t)},XN=(t,e,n)=>e.has(t)||nV("Cannot "+n),Ht=(t,e,n)=>(XN(t,e,"read from private field"),n?n.call(t):e.get(t)),Ts=(t,e,n)=>e.has(t)?nV("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),sr=(t,e,n,r)=>(XN(t,e,"write to private field"),e.set(t,n),n),Kn=(t,e,n)=>(XN(t,e,"access private method"),n),Jhe=class extends Error{constructor(){super(...arguments),this.status=500,this.name="NoClientIdProvidedException",this.message='Missing Client ID. Pass it to the constructor (createClient("client_01HXRMBQ9BJ3E7QSTQ9X2PHVB7"))'}};function Zhe(t,e){if(!e.has("code"))return!1;const{pathname:r}=window.location,s=new URL(t).pathname;return r===s||r===`${s}/`}function epe(){let t={};function e(i,a){t[i]=a}function n(i){return t[i]}function r(i){delete t[i]}function s(){t={}}return{setItem:e,getItem:n,removeItem:r,reset:s}}var Ms=epe();async function tpe(){const t=npe(),e=await rpe(t);return{codeVerifier:t,codeChallenge:e}}function npe(){const t=crypto.getRandomValues(new Uint32Array(96));return rV(t)}async function rpe(t){const e=await spe(t);return rV(e)}function rV(t){return btoa(Array.from(new Uint8Array(t),e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function spe(t){const n=new TextEncoder().encode(t);return crypto.subtle.digest("SHA-256",n)}function u3(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return atob(e+n)}function ipe(t){const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT format");try{const n=JSON.parse(u3(e[0])),r=JSON.parse(u3(e[1]));return{header:n,payload:r}}catch(n){throw new Error(`Failed to decode JWT: ${n instanceof Error?n.message:String(n)}`)}}var ts={codeVerifier:"workos:code-verifier",user:"workos:user",accessToken:"workos:access-token",refreshToken:"workos:refresh-token",expiresAt:"workos:expires-at"};function D0(t){return ipe(t).payload}function sV(t,{devMode:e=!1}={}){const{user:n,accessToken:r,refreshToken:s}=t;Ms.setItem(ts.user,n),Ms.setItem(ts.accessToken,r),(e?window.localStorage:Ms).setItem(ts.refreshToken,s);const{exp:i,iat:a}=D0(r),l=i-a,u=Date.now()+l*1e3;Ms.setItem(ts.expiresAt,u)}function iV({devMode:t=!1}={}){Ms.removeItem(ts.user),Ms.removeItem(ts.accessToken),(t?window.localStorage:Ms).removeItem(ts.refreshToken)}function aV({devMode:t=!1}={}){return(t?window.localStorage:Ms).getItem(ts.refreshToken)}function ape(t){const e=new URLSearchParams,n=Object.keys(t).sort();for(const r of n){const s=t[r];s&&e.append(r,s)}return e.toString()}var QN=class extends Error{},sx=class extends QN{},ope=class extends QN{},BT=class extends QN{constructor(){super(...arguments),this.message="No access token available"}},lpe=class Vp{constructor(){this.locked=new Map,this.addToLocked=(e,n)=>{let r=this.locked.get(e);r===void 0?n===void 0?this.locked.set(e,[]):this.locked.set(e,[n]):n!==void 0&&(r.unshift(n),this.locked.set(e,r))},this.isLocked=e=>this.locked.has(e),this.lock=e=>new Promise((n,r)=>{this.isLocked(e)?this.addToLocked(e,n):(this.addToLocked(e),n())}),this.unlock=e=>{let n=this.locked.get(e);if(n===void 0||n.length===0){this.locked.delete(e);return}let r=n.pop();this.locked.set(e,n),r!==void 0&&setTimeout(r,0)}}static getInstance(){return Vp.instance===void 0&&(Vp.instance=new Vp),Vp.instance}};function Ed(){return lpe.getInstance()}var QE="browser-tabs-lock-key",fy={key:async t=>{throw new Error("Unsupported")},getItem:async t=>{throw new Error("Unsupported")},clear:async()=>window.localStorage.clear(),removeItem:async t=>{throw new Error("Unsupported")},setItem:async(t,e)=>{throw new Error("Unsupported")},keySync:t=>window.localStorage.key(t),getItemSync:t=>window.localStorage.getItem(t),clearSync:()=>window.localStorage.clear(),removeItemSync:t=>window.localStorage.removeItem(t),setItemSync:(t,e)=>window.localStorage.setItem(t,e)};function JE(t){return new Promise(e=>setTimeout(e,t))}function qT(t){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";let n="";for(let r=0;r<t;r++){const s=Math.floor(Math.random()*e.length);n+=e[s]}return n}function cpe(){return Date.now().toString()+qT(15)}var oV=class us{constructor(e){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=cpe(),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=e,us.waiters===void 0&&(us.waiters=[])}async acquireLock(e,n=5e3){let r=Date.now()+qT(4);const s=Date.now()+n,i=`${QE}-${e}`,a=this.storageHandler===void 0?fy:this.storageHandler;for(;Date.now()<s;){if(await JE(30),a.getItemSync(i)===null){const u=`${this.id}-${e}-${r}`;await JE(Math.floor(Math.random()*25)),a.setItemSync(i,JSON.stringify({id:this.id,iat:r,timeoutKey:u,timeAcquired:Date.now(),timeRefreshed:Date.now()})),await JE(30);let d=a.getItemSync(i);if(d!==null){let p=JSON.parse(d);if(p.id===this.id&&p.iat===r)return this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(i,r),!0}}else us.lockCorrector(this.storageHandler===void 0?fy:this.storageHandler),await this.waitForSomethingToChange(s);r=Date.now()+qT(4)}return!1}async refreshLockWhileAcquired(e,n){setTimeout(async()=>{if(await Ed().lock(n),!this.acquiredIatSet.has(n)){Ed().unlock(n);return}const r=this.storageHandler===void 0?fy:this.storageHandler;let s=r.getItemSync(e);if(s!==null){let i=JSON.parse(s);i.timeRefreshed=Date.now(),r.setItemSync(e,JSON.stringify(i)),Ed().unlock(n)}else{Ed().unlock(n);return}this.refreshLockWhileAcquired(e,n)},1e3)}async waitForSomethingToChange(e){await new Promise(n=>{let r=!1,s=Date.now();const i=50;let a=!1;function l(){if(a||(window.removeEventListener("storage",l),us.removeFromWaiting(l),clearTimeout(u),a=!0),!r){r=!0;let d=i-(Date.now()-s);d>0?setTimeout(n,d):n(null)}}window.addEventListener("storage",l),us.addToWaiting(l);let u=setTimeout(l,Math.max(0,e-Date.now()))})}static addToWaiting(e){this.removeFromWaiting(e),us.waiters!==void 0&&us.waiters.push(e)}static removeFromWaiting(e){us.waiters!==void 0&&(us.waiters=us.waiters.filter(n=>n!==e))}static notifyWaiters(){if(us.waiters===void 0)return;[...us.waiters].forEach(n=>n())}async releaseLock(e){return await this.releaseLock__private__(e)}async releaseLock__private__(e){const n=this.storageHandler===void 0?fy:this.storageHandler,r=`${QE}-${e}`;let s=n.getItemSync(r);if(s===null)return;let i=JSON.parse(s);i.id===this.id&&(await Ed().lock(i.iat),this.acquiredIatSet.delete(i.iat),n.removeItemSync(r),Ed().unlock(i.iat),us.notifyWaiters())}static lockCorrector(e){const n=Date.now()-5e3,r=e,s=[];let i=0;for(;;){let l=r.keySync(i);if(l===null)break;s.push(l),i++}let a=!1;for(let l=0;l<s.length;l++){const u=s[l];if(u.includes(QE)){let d=r.getItemSync(u);if(d!==null){let p=JSON.parse(d);(p.timeRefreshed===void 0&&p.timeAcquired<n||p.timeRefreshed!==void 0&&p.timeRefreshed<n)&&(r.removeItemSync(u),a=!0)}}}a&&us.notifyWaiters()}};oV.waiters=void 0;var upe=oV,dpe=1e4;function fpe(t,e,{timeout:n=dpe}={}){return"locks"in navigator?hpe(t,e,n):ppe(t,e,n)}async function hpe(t,e,n){try{return await navigator.locks.request(t,{signal:AbortSignal.timeout(n)},e)}catch(r){if(r instanceof DOMException)switch(r.name){case"AbortError":throw new JN("AcquisitionTimeoutError",t,"Native")}throw r}}async function ppe(t,e,n){const r=new upe;try{if(await r.acquireLock(t,n))return await e();throw new JN("AcquisitionTimeoutError",t,"Vendor")}finally{await r.releaseLock(t)}}var JN=class extends Error{constructor(t,e,n){super(`Lock acquisition timed out for "${e}" (${n})`),this.name=t,this.lockName=e}},mpe=t=>({object:t.object,id:t.id,email:t.email,emailVerified:t.email_verified,firstName:t.first_name,profilePictureUrl:t.profile_picture_url,lastName:t.last_name,lastSignInAt:t.last_sign_in_at,externalId:t.external_id,createdAt:t.created_at,updatedAt:t.updated_at}),d3=t=>{const{user:e,organization_id:n,access_token:r,refresh_token:s,impersonator:i,...a}=t;return{user:mpe(e),organizationId:n,accessToken:r,refreshToken:s,impersonator:i,...a}},gpe="api.workos.com",Vd,$d,Zy,VT,vpe=class{constructor({clientId:t,hostname:e=gpe,port:n,https:r=!0}){Ts(this,Zy),Ts(this,Vd),Ts(this,$d),sr(this,Vd,`${r?"https":"http"}://${e}${n?`:${n}`:""}`),sr(this,$d,t)}async authenticateWithRefreshToken({refreshToken:t,organizationId:e,useCookie:n}){const r=await Kn(this,Zy,VT).call(this,"/user_management/authenticate",{useCookie:n,body:{client_id:Ht(this,$d),grant_type:"refresh_token",...!n&&{refresh_token:t},organization_id:e}});if(r.ok){const s=await r.json();return d3(s)}else{const s=await r.json();throw new sx(s.error_description)}}async authenticateWithCode({code:t,codeVerifier:e,useCookie:n}){const r=await Kn(this,Zy,VT).call(this,"/user_management/authenticate",{useCookie:n,body:{code:t,client_id:Ht(this,$d),grant_type:"authorization_code",code_verifier:e}});if(r.ok){const i=await r.json();return d3(i)}const s=await r.json();throw new ope(s.error_description)}getAuthorizationUrl({connectionId:t,context:e,domainHint:n,loginHint:r,organizationId:s,provider:i="authkit",redirectUri:a,state:l,screenHint:u,passwordResetToken:d,invitationToken:p,codeChallenge:h,codeChallengeMethod:g}){if(!i&&!t&&!s)throw new TypeError("Incomplete arguments. Need to specify either a 'connectionId', 'organizationId', or 'provider'.");if(i!=="authkit"&&u)throw new TypeError("'screenHint' is only supported for 'authkit' provider");e&&console.warn("`context` is deprecated. We previously required initiate login endpoints to return the\n`context` query parameter when getting the authorization URL. This is no longer necessary.");const v=ape({connection_id:t,organization_id:s,domain_hint:n,login_hint:r,provider:i,client_id:Ht(this,$d),redirect_uri:a,response_type:"code",state:l,screen_hint:u,invitation_token:p,password_reset_token:d,code_challenge:h,code_challenge_method:g});return`${Ht(this,Vd)}/user_management/authorize?${v}`}getLogoutUrl({sessionId:t,returnTo:e}){const n=new URL("/user_management/sessions/logout",Ht(this,Vd));return n.searchParams.set("session_id",t),e&&n.searchParams.set("return_to",e),n}};Vd=new WeakMap;$d=new WeakMap;Zy=new WeakSet;VT=function(t,{body:e,useCookie:n}){return fetch(new URL(t,Ht(this,Vd)),{method:"POST",...n&&{credentials:"include"},headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json"},body:JSON.stringify(e)})};var f3="workos_organization_id",ype="WORKOS_REFRESH_SESSION",gr,ix,nu,tm,Aa,ax,ox,$m,zm,lx,On,lV,nm,rm,cV,ZN,Hp,eR,tR,nR,bpe=class{constructor(t,{apiHostname:e,https:n,port:r,redirectUri:s=window.origin,devMode:i=location.hostname==="localhost"||location.hostname==="127.0.0.1",onBeforeAutoRefresh:a=()=>!document.hidden,onRedirectCallback:l=h=>{},onRefresh:u,onRefreshFailure:d,refreshBufferInterval:p=10}={}){if(Ts(this,On),Ts(this,gr),Ts(this,ix),Ts(this,nu),Ts(this,tm),Ts(this,Aa),Ts(this,ax),Ts(this,ox),Ts(this,$m),Ts(this,zm),Ts(this,lx),!t)throw new Jhe;sr(this,nu,new vpe({clientId:t,hostname:e,port:r,https:n})),sr(this,Aa,i),sr(this,tm,s),sr(this,gr,{tag:"INITIAL"}),sr(this,ax,a),sr(this,ox,l),sr(this,$m,u),sr(this,zm,d),sr(this,lx,p)}async initialize(){if(Ht(this,gr).tag!=="INITIAL")return;const t=new URLSearchParams(window.location.search);if(Zhe(Ht(this,tm),t))await Kn(this,On,lV).call(this);else if(document.cookie.includes("workos-has-session=")||aV({devMode:Ht(this,Aa)}))try{await Kn(this,On,rm).call(this),Kn(this,On,nm).call(this)}catch{}}async getSignInUrl(t={}){return await Kn(this,On,Hp).call(this,{...t,type:"sign-in"})}async getSignUpUrl(t={}){return await Kn(this,On,Hp).call(this,{...t,type:"sign-up"})}async signIn(t={}){const e=await Kn(this,On,Hp).call(this,{...t,type:"sign-in"});window.location.assign(e)}async signUp(t={}){const e=await Kn(this,On,Hp).call(this,{...t,type:"sign-up"});window.location.assign(e)}signOut(t={navigate:!0}){const e=t.navigate??!0,n=Ms.getItem(ts.accessToken);if(typeof n!="string")return;const{sid:r}=D0(n),s=Ht(this,nu).getLogoutUrl({sessionId:r,returnTo:t?.returnTo});if(s)if(iV({devMode:Ht(this,Aa)}),e)window.location.assign(s);else return new Promise(async i=>{fetch(s,{mode:"no-cors",credentials:"include"}).catch(a=>{console.warn("AuthKit: Failed to send logout request",a)}).finally(i)})}async getAccessToken(t){if(t?.forceRefresh||Kn(this,On,ZN).call(this))try{await Kn(this,On,rm).call(this)}catch(n){throw n instanceof sx?new BT:n}const e=Kn(this,On,eR).call(this);if(!e)throw new BT;return e}getUser(){const t=Ms.getItem(ts.user);return t||null}dispose(){clearTimeout(Ht(this,ix)),Ms.reset()}async switchToOrganization({organizationId:t,signInOpts:e={}}){try{await Kn(this,On,rm).call(this,{organizationId:t})}catch(n){if(n instanceof sx)this.signIn({...e,organizationId:t});else throw n}}};gr=new WeakMap;ix=new WeakMap;nu=new WeakMap;tm=new WeakMap;Aa=new WeakMap;ax=new WeakMap;ox=new WeakMap;$m=new WeakMap;zm=new WeakMap;lx=new WeakMap;On=new WeakSet;lV=async function(){if(Ht(this,gr).tag!=="INITIAL")return;const t=new URL(window.location.href),e=t.searchParams.get("code"),n=t.searchParams.get("state"),r=n?JSON.parse(n):void 0,s=window.sessionStorage.getItem(ts.codeVerifier);if(e)if(s)try{sr(this,gr,{tag:"AUTHENTICATING",response:Ht(this,nu).authenticateWithCode({code:e,codeVerifier:s,useCookie:Ht(this,On,tR)})});const a=await Ht(this,gr).response;a&&(sr(this,gr,{tag:"AUTHENTICATED"}),Kn(this,On,nm).call(this),sV(a,{devMode:Ht(this,Aa)}),Kn(this,On,nR).call(this,a),Ht(this,ox).call(this,{state:r,...a}))}catch(a){sr(this,gr,{tag:"ERROR"}),console.error(a)}else sr(this,gr,{tag:"ERROR"}),console.error(`Couldn't exchange code.
|
|
1776
1776
|
|
|
1777
1777
|
An authorization_code was supplied for a login which did not originate at the application. This could happen for various reasons:
|
|
1778
1778
|
|
|
@@ -1814,10 +1814,10 @@ An authorization_code was supplied for a login which did not originate at the ap
|
|
|
1814
1814
|
`))+1))}const a="#".repeat(s),l=n.enter("headingAtx"),u=n.enter("phrasing");i.move(a+" ");let d=n.containerPhrasing(t,{before:"# ",after:`
|
|
1815
1815
|
`,...i.current()});return/^[\t ]/.test(d)&&(d=Wm(d.charCodeAt(0))+d.slice(1)),d=d?a+" "+d:a,n.options.closeAtx&&(d+=" "+a),u(),l(),d}j8.peek=TSe;function j8(t){return t.value||""}function TSe(){return"<"}M8.peek=CSe;function M8(t,e,n,r){const s=ZR(n),i=s==='"'?"Quote":"Apostrophe",a=n.enter("image");let l=n.enter("label");const u=n.createTracker(r);let d=u.move("![");return d+=u.move(n.safe(t.alt,{before:d,after:"]",...u.current()})),d+=u.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(t.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(l=n.enter("destinationRaw"),d+=u.move(n.safe(t.url,{before:d,after:t.title?" ":")",...u.current()}))),l(),t.title&&(l=n.enter(`title${i}`),d+=u.move(" "+s),d+=u.move(n.safe(t.title,{before:d,after:s,...u.current()})),d+=u.move(s),l()),d+=u.move(")"),a(),d}function CSe(){return"!"}O8.peek=ASe;function O8(t,e,n,r){const s=t.referenceType,i=n.enter("imageReference");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");const d=n.safe(t.alt,{before:u,after:"]",...l.current()});u+=l.move(d+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(t),{before:u,after:"]",...l.current()});return a(),n.stack=p,i(),s==="full"||!d||d!==h?u+=l.move(h+"]"):s==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function ASe(){return"!"}P8.peek=NSe;function P8(t,e,n){let r=t.value||"",s="`",i=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i<n.unsafe.length;){const a=n.unsafe[i],l=n.compilePattern(a);let u;if(a.atBreak)for(;u=l.exec(r);){let d=u.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(u.index+1)}}return s+r+s}function NSe(){return"`"}function I8(t,e){const n=VR(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}D8.peek=RSe;function D8(t,e,n,r){const s=ZR(n),i=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let l,u;if(I8(t,n)){const p=n.stack;n.stack=[],l=n.enter("autolink");let h=a.move("<");return h+=a.move(n.containerPhrasing(t,{before:h,after:">",...a.current()})),h+=a.move(">"),l(),n.stack=p,h}l=n.enter("link"),u=n.enter("label");let d=a.move("[");return d+=a.move(n.containerPhrasing(t,{before:d,after:"](",...a.current()})),d+=a.move("]("),u(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(u=n.enter("destinationLiteral"),d+=a.move("<"),d+=a.move(n.safe(t.url,{before:d,after:">",...a.current()})),d+=a.move(">")):(u=n.enter("destinationRaw"),d+=a.move(n.safe(t.url,{before:d,after:t.title?" ":")",...a.current()}))),u(),t.title&&(u=n.enter(`title${i}`),d+=a.move(" "+s),d+=a.move(n.safe(t.title,{before:d,after:s,...a.current()})),d+=a.move(s),u()),d+=a.move(")"),l(),d}function RSe(t,e,n){return I8(t,n)?"<":"["}L8.peek=jSe;function L8(t,e,n,r){const s=t.referenceType,i=n.enter("linkReference");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("[");const d=n.containerPhrasing(t,{before:u,after:"]",...l.current()});u+=l.move(d+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(t),{before:u,after:"]",...l.current()});return a(),n.stack=p,i(),s==="full"||!d||d!==h?u+=l.move(h+"]"):s==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function jSe(){return"["}function ej(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function MSe(t){const e=ej(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function OSe(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function $8(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function PSe(t,e,n,r){const s=n.enter("list"),i=n.bulletCurrent;let a=t.ordered?OSe(n):ej(n);const l=t.ordered?a==="."?")":".":MSe(n);let u=e&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!t.ordered){const p=t.children?t.children[0]:void 0;if((a==="*"||a==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),$8(n)===a&&p){let h=-1;for(;++h<t.children.length;){const g=t.children[h];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(a=l),n.bulletCurrent=a;const d=n.containerFlow(t,r);return n.bulletLastUsed=a,n.bulletCurrent=i,s(),d}function ISe(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function DSe(t,e,n,r){const s=ISe(n);let i=n.bulletCurrent||ej(n);e&&e.type==="list"&&e.ordered&&(i=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+i);let a=i.length+1;(s==="tab"||s==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(a=Math.ceil(a/4)*4);const l=n.createTracker(r);l.move(i+" ".repeat(a-i.length)),l.shift(a);const u=n.enter("listItem"),d=n.indentLines(n.containerFlow(t,l.current()),p);return u(),d;function p(h,g,v){return g?(v?"":" ".repeat(a))+h:(v?i:i+" ".repeat(a-i.length))+h}}function LSe(t,e,n,r){const s=n.enter("paragraph"),i=n.enter("phrasing"),a=n.containerPhrasing(t,r);return i(),s(),a}const $Se=V0(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function zSe(t,e,n,r){return(t.children.some(function(a){return $Se(a)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function FSe(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}z8.peek=USe;function z8(t,e,n,r){const s=FSe(n),i=n.enter("strong"),a=n.createTracker(r),l=a.move(s+s);let u=a.move(n.containerPhrasing(t,{after:s,before:l,...a.current()}));const d=u.charCodeAt(0),p=bx(r.before.charCodeAt(r.before.length-1),d,s);p.inside&&(u=Wm(d)+u.slice(1));const h=u.charCodeAt(u.length-1),g=bx(r.after.charCodeAt(0),h,s);g.inside&&(u=u.slice(0,-1)+Wm(h));const v=a.move(s+s);return i(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},l+u+v}function USe(t,e,n){return n.options.strong||"*"}function BSe(t,e,n,r){return n.safe(t.value,r)}function qSe(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function VSe(t,e,n){const r=($8(n)+(n.options.ruleSpaces?" ":"")).repeat(qSe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const F8={blockquote:hSe,break:v4,code:bSe,definition:_Se,emphasis:R8,hardBreak:v4,heading:kSe,html:j8,image:M8,imageReference:O8,inlineCode:P8,link:D8,linkReference:L8,list:PSe,listItem:DSe,paragraph:LSe,root:zSe,strong:z8,text:BSe,thematicBreak:VSe};function HSe(){return{enter:{table:GSe,tableData:y4,tableHeader:y4,tableRow:YSe},exit:{codeText:KSe,table:WSe,tableData:j1,tableHeader:j1,tableRow:j1}}}function GSe(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function WSe(t){this.exit(t),this.data.inTable=void 0}function YSe(t){this.enter({type:"tableRow",children:[]},t)}function j1(t){this.exit(t)}function y4(t){this.enter({type:"tableCell",children:[]},t)}function KSe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,XSe));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function XSe(t,e){return e==="|"?e:t}function QSe(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,s=e.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
1816
1816
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:u,tableRow:l}};function a(v,b,x,E){return d(p(v,x,E),v.align)}function l(v,b,x,E){const S=h(v,x,E),k=d([S]);return k.slice(0,k.indexOf(`
|
|
1817
|
-
`))}function u(v,b,x,E){const S=x.enter("tableCell"),k=x.enter("phrasing"),T=x.containerPhrasing(v,{...E,before:i,after:i});return k(),S(),T}function d(v,b){return dSe(v,{align:b,alignDelimiters:r,padding:n,stringLength:s})}function p(v,b,x){const E=v.children;let S=-1;const k=[],T=b.enter("table");for(;++S<E.length;)k[S]=h(E[S],b,x);return T(),k}function h(v,b,x){const E=v.children;let S=-1;const k=[],T=b.enter("tableRow");for(;++S<E.length;)k[S]=u(E[S],v,b,x);return T(),k}function g(v,b,x){let E=F8.inlineCode(v,b,x);return x.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function JSe(){return{exit:{taskListCheckValueChecked:b4,taskListCheckValueUnchecked:b4,paragraph:eEe}}}function ZSe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tEe}}}function b4(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function eEe(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=e.children;let i=-1,a;for(;++i<s.length;){const l=s[i];if(l.type==="paragraph"){a=l;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function tEe(t,e,n,r){const s=t.children[0],i=typeof t.checked=="boolean"&&s&&s.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",l=n.createTracker(r);i&&l.move(a);let u=F8.listItem(t,e,n,{...r,...l.current()});return i&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(p){return p+a}}function nEe(){return[Pwe(),tSe(),iSe(),HSe(),JSe()]}function rEe(t){return{extensions:[Iwe(),nSe(t),aSe(),QSe(t),ZSe()]}}const sEe={tokenize:uEe,partial:!0},U8={tokenize:dEe,partial:!0},B8={tokenize:fEe,partial:!0},q8={tokenize:hEe,partial:!0},iEe={tokenize:pEe,partial:!0},V8={name:"wwwAutolink",tokenize:lEe,previous:G8},H8={name:"protocolAutolink",tokenize:cEe,previous:W8},Wo={name:"emailAutolink",tokenize:oEe,previous:Y8},Ka={};function aEe(){return{text:Ka}}let zc=48;for(;zc<123;)Ka[zc]=Wo,zc++,zc===58?zc=65:zc===91&&(zc=97);Ka[43]=Wo;Ka[45]=Wo;Ka[46]=Wo;Ka[95]=Wo;Ka[72]=[Wo,H8];Ka[104]=[Wo,H8];Ka[87]=[Wo,V8];Ka[119]=[Wo,V8];function oEe(t,e,n){const r=this;let s,i;return a;function a(h){return!wC(h)||!Y8.call(r,r.previous)||tj(r.events)?n(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),l(h))}function l(h){return wC(h)?(t.consume(h),l):h===64?(t.consume(h),u):n(h)}function u(h){return h===46?t.check(iEe,p,d)(h):h===45||h===95||rs(h)?(i=!0,t.consume(h),u):p(h)}function d(h){return t.consume(h),s=!0,u}function p(h){return i&&s&&fs(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(h)):n(h)}}function lEe(t,e,n){const r=this;return s;function s(a){return a!==87&&a!==119||!G8.call(r,r.previous)||tj(r.events)?n(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(sEe,t.attempt(U8,t.attempt(B8,i),n),n)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function cEe(t,e,n){const r=this;let s="",i=!1;return a;function a(h){return(h===72||h===104)&&W8.call(r,r.previous)&&!tj(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),t.consume(h),l):n(h)}function l(h){if(fs(h)&&s.length<5)return s+=String.fromCodePoint(h),t.consume(h),l;if(h===58){const g=s.toLowerCase();if(g==="http"||g==="https")return t.consume(h),u}return n(h)}function u(h){return h===47?(t.consume(h),i?d:(i=!0,u)):n(h)}function d(h){return h===null||gx(h)||_n(h)||Su(h)||U0(h)?n(h):t.attempt(U8,t.attempt(B8,p),n)(h)}function p(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(h)}}function uEe(t,e,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,t.consume(a),s):a===46&&r===3?(t.consume(a),i):n(a)}function i(a){return a===null?n(a):e(a)}}function dEe(t,e,n){let r,s,i;return a;function a(d){return d===46||d===95?t.check(q8,u,l)(d):d===null||_n(d)||Su(d)||d!==45&&U0(d)?u(d):(i=!0,t.consume(d),a)}function l(d){return d===95?r=!0:(s=r,r=void 0),t.consume(d),a}function u(d){return s||r||!i?n(d):e(d)}}function fEe(t,e){let n=0,r=0;return s;function s(a){return a===40?(n++,t.consume(a),s):a===41&&r<n?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(q8,e,i)(a):a===null||_n(a)||Su(a)?e(a):(t.consume(a),s)}function i(a){return a===41&&r++,t.consume(a),s}}function hEe(t,e,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(t.consume(l),r):l===38?(t.consume(l),i):l===93?(t.consume(l),s):l===60||l===null||_n(l)||Su(l)?e(l):n(l)}function s(l){return l===null||l===40||l===91||_n(l)||Su(l)?e(l):r(l)}function i(l){return fs(l)?a(l):n(l)}function a(l){return l===59?(t.consume(l),r):fs(l)?(t.consume(l),a):n(l)}}function pEe(t,e,n){return r;function r(i){return t.consume(i),s}function s(i){return rs(i)?n(i):e(i)}}function G8(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||_n(t)}function W8(t){return!fs(t)}function Y8(t){return!(t===47||wC(t))}function wC(t){return t===43||t===45||t===46||t===95||rs(t)}function tj(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const mEe={tokenize:SEe,partial:!0};function gEe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:xEe,continuation:{tokenize:_Ee},exit:wEe}},text:{91:{name:"gfmFootnoteCall",tokenize:bEe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:vEe,resolveTo:yEe}}}}function vEe(t,e,n){const r=this;let s=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const u=r.events[s][1];if(u.type==="labelImage"){a=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return l;function l(u){if(!a||!a._balanced)return n(u);const d=na(r.sliceSerialize({start:a.end,end:r.now()}));return d.codePointAt(0)!==94||!i.includes(d.slice(1))?n(u):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),e(u))}}function yEe(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",s,e],["exit",s,e],["enter",i,e],["enter",a,e],["exit",a,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...l),t}function bEe(t,e,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,a;return l;function l(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),u}function u(h){return h!==94?n(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",d)}function d(h){if(i>999||h===93&&!a||h===null||h===91||_n(h))return n(h);if(h===93){t.exit("chunkString");const g=t.exit("gfmFootnoteCallString");return s.includes(na(r.sliceSerialize(g)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(h)}return _n(h)||(a=!0),i++,t.consume(h),h===92?p:d}function p(h){return h===91||h===92||h===93?(t.consume(h),i++,d):d(h)}}function xEe(t,e,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,a=0,l;return u;function u(b){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(b){return b===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",p):n(b)}function p(b){if(a>999||b===93&&!l||b===null||b===91||_n(b))return n(b);if(b===93){t.exit("chunkString");const x=t.exit("gfmFootnoteDefinitionLabelString");return i=na(r.sliceSerialize(x)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),g}return _n(b)||(l=!0),a++,t.consume(b),b===92?h:p}function h(b){return b===91||b===92||b===93?(t.consume(b),a++,p):p(b)}function g(b){return b===58?(t.enter("definitionMarker"),t.consume(b),t.exit("definitionMarker"),s.includes(i)||s.push(i),en(t,v,"gfmFootnoteDefinitionWhitespace")):n(b)}function v(b){return e(b)}}function _Ee(t,e,n){return t.check(Ag,e,t.attempt(mEe,e,n))}function wEe(t){t.exit("gfmFootnoteDefinition")}function SEe(t,e,n){const r=this;return en(t,s,"gfmFootnoteDefinitionIndent",5);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(i):n(i)}}function EEe(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:i,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(a,l){let u=-1;for(;++u<a.length;)if(a[u][0]==="enter"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._close){let d=u;for(;d--;)if(a[d][0]==="exit"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[d][1].end.offset-a[d][1].start.offset){a[u][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[u][1].end)},h={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[u][1].start)},g=[["enter",p,l],["enter",a[d][1],l],["exit",a[d][1],l],["enter",h,l]],v=l.parser.constructs.insideSpan.null;v&&si(g,g.length,0,B0(v,a.slice(d+1,u),l)),si(g,g.length,0,[["exit",h,l],["enter",a[u][1],l],["exit",a[u][1],l],["exit",p,l]]),si(a,d-1,u-d+3,g),u=d+g.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type==="strikethroughSequenceTemporary"&&(a[u][1].type="data");return a}function i(a,l,u){const d=this.previous,p=this.events;let h=0;return g;function g(b){return d===126&&p[p.length-1][1].type!=="characterEscape"?u(b):(a.enter("strikethroughSequenceTemporary"),v(b))}function v(b){const x=jf(d);if(b===126)return h>1?u(b):(a.consume(b),h++,v);if(h<2&&!n)return u(b);const E=a.exit("strikethroughSequenceTemporary"),S=jf(b);return E._open=!S||S===2&&!!x,E._close=!x||x===2&&!!S,l(b)}}}class kEe{constructor(){this.map=[]}add(e,n,r){TEe(this,e,n,r)}consume(e){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let s=r.pop();for(;s;){for(const i of s)e.push(i);s=r.pop()}this.map.length=0}}function TEe(t,e,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<t.map.length;){if(t.map[s][0]===e){t.map[s][1]+=n,t.map[s][2].push(...r);return}s+=1}t.map.push([e,n,r])}}function CEe(t,e){let n=!1;const r=[];for(;e<t.length;){const s=t[e];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const i=r.length-1;r[i]=r[i]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function AEe(){return{flow:{null:{name:"table",tokenize:NEe,resolveAll:REe}}}}function NEe(t,e,n){const r=this;let s=0,i=0,a;return l;function l(O){let L=r.events.length-1;for(;L>-1;){const W=r.events[L][1].type;if(W==="lineEnding"||W==="linePrefix")L--;else break}const z=L>-1?r.events[L][1].type:null,G=z==="tableHead"||z==="tableRow"?A:u;return G===A&&r.parser.lazy[r.now().line]?n(O):G(O)}function u(O){return t.enter("tableHead"),t.enter("tableRow"),d(O)}function d(O){return O===124||(a=!0,i+=1),p(O)}function p(O){return O===null?n(O):ct(O)?i>1?(i=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),v):n(O):Gt(O)?en(t,p,"whitespace")(O):(i+=1,a&&(a=!1,s+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),a=!0,p):(t.enter("data"),h(O)))}function h(O){return O===null||O===124||_n(O)?(t.exit("data"),p(O)):(t.consume(O),O===92?g:h)}function g(O){return O===92||O===124?(t.consume(O),h):h(O)}function v(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(t.enter("tableDelimiterRow"),a=!1,Gt(O)?en(t,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):b(O))}function b(O){return O===45||O===58?E(O):O===124?(a=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),x):j(O)}function x(O){return Gt(O)?en(t,E,"whitespace")(O):E(O)}function E(O){return O===58?(i+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),S):O===45?(i+=1,S(O)):O===null||ct(O)?R(O):j(O)}function S(O){return O===45?(t.enter("tableDelimiterFiller"),k(O)):j(O)}function k(O){return O===45?(t.consume(O),k):O===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),T):(t.exit("tableDelimiterFiller"),T(O))}function T(O){return Gt(O)?en(t,R,"whitespace")(O):R(O)}function R(O){return O===124?b(O):O===null||ct(O)?!a||s!==i?j(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):j(O)}function j(O){return n(O)}function A(O){return t.enter("tableRow"),N(O)}function N(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),N):O===null||ct(O)?(t.exit("tableRow"),e(O)):Gt(O)?en(t,N,"whitespace")(O):(t.enter("data"),M(O))}function M(O){return O===null||O===124||_n(O)?(t.exit("data"),N(O)):(t.consume(O),O===92?I:M)}function I(O){return O===92||O===124?(t.consume(O),M):M(O)}}function REe(t,e){let n=-1,r=!0,s=0,i=[0,0,0,0],a=[0,0,0,0],l=!1,u=0,d,p,h;const g=new kEe;for(;++n<t.length;){const v=t[n],b=v[1];v[0]==="enter"?b.type==="tableHead"?(l=!1,u!==0&&(x4(g,e,u,d,p),p=void 0,u=0),d={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},g.add(n,0,[["enter",d,e]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,h=void 0,i=[0,0,0,0],a=[0,n+1,0,0],l&&(l=!1,p={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},g.add(n,0,[["enter",p,e]])),s=b.type==="tableDelimiterRow"?2:p?3:1):s&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],h=_y(g,e,i,s,void 0,h),i=[0,0,0,0]),a[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(a[0]=a[1],h=_y(g,e,i,s,void 0,h)),i=a,a=[i[1],n,0,0])):b.type==="tableHead"?(l=!0,u=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(u=n,i[1]!==0?(a[0]=a[1],h=_y(g,e,i,s,n,h)):a[1]!==0&&(h=_y(g,e,a,s,n,h)),s=0):s&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&x4(g,e,u,d,p),g.consume(e.events),n=-1;++n<e.events.length;){const v=e.events[n];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=CEe(e.events,n))}return t}function _y(t,e,n,r,s,i){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(i.end=Object.assign({},zd(e.events,n[0])),t.add(n[0],0,[["exit",i,e]]));const u=zd(e.events,n[1]);if(i={type:a,start:Object.assign({},u),end:Object.assign({},u)},t.add(n[1],0,[["enter",i,e]]),n[2]!==0){const d=zd(e.events,n[2]),p=zd(e.events,n[3]),h={type:l,start:Object.assign({},d),end:Object.assign({},p)};if(t.add(n[2],0,[["enter",h,e]]),r!==2){const g=e.events[n[2]],v=e.events[n[3]];if(g[1].end=Object.assign({},v[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,x=n[3]-n[2]-1;t.add(b,x,[])}}t.add(n[3]+1,0,[["exit",h,e]])}return s!==void 0&&(i.end=Object.assign({},zd(e.events,s)),t.add(s,0,[["exit",i,e]]),i=void 0),i}function x4(t,e,n,r,s){const i=[],a=zd(e.events,n);s&&(s.end=Object.assign({},a),i.push(["exit",s,e])),r.end=Object.assign({},a),i.push(["exit",r,e]),t.add(n+1,0,i)}function zd(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const jEe={name:"tasklistCheck",tokenize:OEe};function MEe(){return{text:{91:jEe}}}function OEe(t,e,n){const r=this;return s;function s(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(u),t.exit("taskListCheckMarker"),i)}function i(u){return _n(u)?(t.enter("taskListCheckValueUnchecked"),t.consume(u),t.exit("taskListCheckValueUnchecked"),a):u===88||u===120?(t.enter("taskListCheckValueChecked"),t.consume(u),t.exit("taskListCheckValueChecked"),a):n(u)}function a(u){return u===93?(t.enter("taskListCheckMarker"),t.consume(u),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),l):n(u)}function l(u){return ct(u)?e(u):Gt(u)?t.check({tokenize:PEe},e,n)(u):n(u)}}function PEe(t,e,n){return en(t,r,"whitespace");function r(s){return s===null?n(s):e(s)}}function IEe(t){return i8([aEe(),gEe(),EEe(t),AEe(),MEe()])}const DEe={};function LEe(t){const e=this,n=t||DEe,r=e.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(IEe(n)),i.push(nEe()),a.push(rEe(n))}function $Ee({node:t,inline:e,className:n,children:r,...s}){return e?f.jsx("code",{className:`${n} text-sm bg-zinc-100 dark:bg-zinc-800 py-0.5 px-1 rounded-md`,...s,children:r}):f.jsx("div",{className:"not-prose flex flex-col",children:f.jsx("div",{...s,className:"text-sm w-full overflow-x-auto dark:bg-zinc-900 p-4 border border-zinc-200 dark:border-zinc-700 rounded-xl dark:text-zinc-50 text-zinc-900 font-mono whitespace-pre-wrap break-words",children:r})})}const zEe={code:$Ee,pre:({children:t})=>f.jsx(f.Fragment,{children:t}),img:({src:t,alt:e,...n})=>{if(!t)return null;const[r,s]=w.useState(!1),[i,a]=w.useState(!1);return i?f.jsxs("div",{className:"my-4 p-4 bg-muted/50 rounded-lg border border-border/30 text-center text-muted-foreground",children:["Failed to load image: ",e||"Image"]}):f.jsx("div",{className:"my-4 flex justify-center",children:f.jsx("img",{src:t,alt:e||"Image",className:`max-w-full h-auto rounded-lg border border-border/30 shadow-sm cursor-pointer transition-all hover:shadow-md ${r?"max-h-none":"max-h-96"}`,loading:"lazy",onClick:()=>s(!r),onError:()=>a(!0),title:r?"Click to collapse":"Click to expand",...n})})},ol:({children:t,...e})=>f.jsx("ol",{className:"list-decimal list-outside ml-4",...e,children:t}),li:({children:t,...e})=>f.jsx("li",{className:"py-1",...e,children:t}),ul:({children:t,...e})=>f.jsx("ul",{className:"list-decimal list-outside ml-4",...e,children:t}),strong:({children:t,...e})=>f.jsx("span",{className:"font-semibold",...e,children:t}),a:({children:t,...e})=>f.jsx("a",{className:"text-blue-500 hover:underline",target:"_blank",rel:"noreferrer",...e,children:t}),h1:({children:t,...e})=>f.jsx("h1",{className:"text-3xl font-semibold mt-6 mb-2",...e,children:t}),h2:({children:t,...e})=>f.jsx("h2",{className:"text-2xl font-semibold mt-6 mb-2",...e,children:t}),h3:({children:t,...e})=>f.jsx("h3",{className:"text-xl font-semibold mt-6 mb-2",...e,children:t}),h4:({children:t,...e})=>f.jsx("h4",{className:"text-lg font-semibold mt-6 mb-2",...e,children:t}),h5:({children:t,...e})=>f.jsx("h5",{className:"text-base font-semibold mt-6 mb-2",...e,children:t}),h6:({children:t,...e})=>f.jsx("h6",{className:"text-sm font-semibold mt-6 mb-2",...e,children:t})},FEe=[LEe],UEe=({children:t})=>f.jsx(Ewe,{remarkPlugins:FEe,components:zEe,children:t}),_4=UEe;function w4({message:t,onSave:e,onCancel:n}){const[r,s]=w.useState(t.content),i=w.useRef(null);w.useEffect(()=>{i.current&&(i.current.focus(),i.current.select(),a())},[]);const a=()=>{i.current&&(i.current.style.height="auto",i.current.style.height=`${i.current.scrollHeight}px`)},l=()=>{r.trim()!==t.content.trim()?e(r.trim()):n()},u=d=>{d.key==="Enter"&&(d.metaKey||d.ctrlKey)&&(d.preventDefault(),l()),d.key==="Escape"&&(d.preventDefault(),n())};return f.jsxs("div",{className:"w-full space-y-3",children:[f.jsx(Ho,{ref:i,value:r,onChange:d=>{s(d.target.value),a()},onKeyDown:u,className:"min-h-[100px] resize-none",placeholder:"Edit your message..."}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ie,{variant:"outline",size:"sm",onClick:n,children:"Cancel"}),f.jsx(Ie,{size:"sm",onClick:l,disabled:!r.trim(),children:"Save"})]})]})}function S4({data:t,className:e}){const[n,r]=w.useState(!1),s=JSON.stringify(t,null,2),i=async()=>{try{await navigator.clipboard.writeText(s),r(!0),setTimeout(()=>r(!1),2e3)}catch(l){console.error("Failed to copy:",l)}},a=l=>l.replace(/"([^"]+)":/g,'<span class="text-blue-600/70 dark:text-blue-400/70">"$1"</span>:').replace(/: "([^"]*)"/g,': <span class="text-foreground">"$1"</span>').replace(/: (true|false)/g,': <span class="text-purple-600/70 dark:text-purple-400/70">$1</span>').replace(/: (null)/g,': <span class="text-muted-foreground/60">$1</span>').replace(/: (-?\d+(?:\.\d+)?)/g,': <span class="text-orange-600/70 dark:text-orange-400/70">$1</span>');return f.jsxs("div",{className:Me("relative group",e),children:[f.jsx("button",{onClick:i,className:"absolute top-2 right-2 p-1.5 rounded-md bg-background/80 backdrop-blur-sm border opacity-0 group-hover:opacity-100 transition-opacity hover:bg-muted",title:"Copy JSON",children:n?f.jsx(Ti,{className:"h-3 w-3 text-green-600/70 dark:text-green-400/70"}):f.jsx(Po,{className:"h-3 w-3"})}),f.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap overflow-x-auto p-3 bg-muted/20 rounded-md border",children:f.jsx("code",{dangerouslySetInnerHTML:{__html:a(s)}})})]})}function K8({data:t,depth:e=0}){const[n,r]=w.useState(e<2);if(typeof t!="object"||t===null)return f.jsx("span",{className:Me("text-sm",typeof t=="string"&&"text-foreground",typeof t=="number"&&"text-orange-600/70 dark:text-orange-400/70",typeof t=="boolean"&&"text-purple-600/70 dark:text-purple-400/70",t===null&&"text-muted-foreground/60"),children:typeof t=="string"?`"${t}"`:String(t)});const s=Array.isArray(t),i=s?t.map((u,d)=>[d,u]):Object.entries(t),a=s?"[":"{",l=s?"]":"}";return i.length===0?f.jsxs("span",{className:"text-sm text-muted-foreground",children:[a,l]}):f.jsxs("div",{className:"text-sm",children:[f.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1 hover:bg-muted/50 rounded px-1 transition-colors",children:[n?f.jsx(Au,{className:"h-3 w-3"}):f.jsx(Ba,{className:"h-3 w-3"}),f.jsxs("span",{className:"text-muted-foreground",children:[a," ",!n&&`${i.length} items`]})]}),n&&f.jsx("div",{className:"ml-4 border-l border-border pl-2 space-y-1",children:i.map(([u,d])=>f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("span",{className:"text-blue-600/70 dark:text-blue-400/70 font-medium min-w-0 flex-shrink-0",children:[s?`[${u}]`:`"${u}"`,":"]}),f.jsx("div",{className:"min-w-0 flex-1",children:f.jsx(K8,{data:d,depth:e+1})})]},u))}),n&&f.jsx("span",{className:"text-muted-foreground ml-4",children:l})]})}function E4({toolCall:t,toolResult:e,className:n,serverConfigs:r,onCallTool:s,onSendFollowup:i,toolMeta:a,serverId:l}){const[u,d]=w.useState(!1),[p,h]=w.useState(!1),v=e?e.error?"error":"completed":t.status,b=()=>{switch(v){case"completed":return f.jsxs("div",{className:"relative",children:[f.jsx(sf,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70"}),f.jsx("div",{className:"absolute inset-0 animate-ping",children:f.jsx(sf,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70 opacity-20"})})]});case"error":return f.jsxs("div",{className:"relative",children:[f.jsx(af,{className:"h-4 w-4 text-red-600/70 dark:text-red-400/70"}),f.jsx("div",{className:"absolute inset-0 animate-pulse",children:f.jsx(af,{className:"h-4 w-4 text-red-600/70 dark:text-red-400/70 opacity-30"})})]});case"executing":return f.jsxs("div",{className:"relative",children:[f.jsx(oI,{className:"h-4 w-4 text-blue-600/70 dark:text-blue-400/70 animate-spin"}),f.jsx("div",{className:"absolute inset-0 animate-ping",children:f.jsx("div",{className:"h-4 w-4 bg-blue-600/30 dark:bg-blue-400/30 rounded-full"})})]});default:return f.jsx(oI,{className:"h-4 w-4 text-muted-foreground/60"})}};return f.jsxs("div",{className:Me("border rounded-lg bg-gradient-to-br from-muted/20 to-muted/40 backdrop-blur-sm shadow-sm hover:shadow-md transition-all duration-200",v==="completed"&&"border-green-200/50 dark:border-green-800/50",v==="error"&&"border-red-200/50 dark:border-red-800/50",v==="executing"&&"border-blue-200/50 dark:border-blue-800/50 shadow-md animate-pulse",n),children:[f.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-muted/30 transition-all duration-200 rounded-t-lg",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2 rounded-md bg-background/50 border",children:f.jsx(A0,{className:"h-4 w-4 text-muted-foreground"})}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"font-semibold text-sm",children:t.name}),v==="executing"&&f.jsx("span",{className:"text-xs text-blue-600/70 dark:text-blue-400/70 font-medium",children:"Running..."}),b()]})]}),f.jsx("div",{className:"flex items-center gap-2",children:u?f.jsx(Au,{className:"h-4 w-4 text-muted-foreground"}):f.jsx(Ba,{className:"h-4 w-4 text-muted-foreground"})})]}),u&&f.jsxs("div",{className:"border-t bg-background/30 backdrop-blur-sm",children:[Object.keys(t.parameters).length>0&&f.jsxs("div",{className:"p-4 border-b border-border/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-600/70 dark:bg-blue-400/70"}),"Parameters"]}),f.jsx("button",{onClick:()=>h(!p),className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded bg-muted/50 hover:bg-muted",children:p?"Raw JSON":"Tree View"})]}),p?f.jsx(K8,{data:t.parameters}):f.jsx(S4,{data:t.parameters})]}),e&&f.jsxs("div",{className:"p-4",children:[f.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3 flex items-center gap-2",children:[f.jsx("div",{className:Me("w-2 h-2 rounded-full",e.error?"bg-red-600/70 dark:bg-red-400/70":"bg-green-600/70 dark:bg-green-400/70")}),e.error?"Error":"Result"]}),f.jsx("div",{children:e.error?f.jsx("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx(af,{className:"h-5 w-5 text-red-600/70 dark:text-red-400/70 flex-shrink-0 mt-0.5"}),f.jsxs("div",{children:[f.jsx("p",{className:"font-medium text-foreground mb-1",children:"Tool execution failed"}),f.jsx("p",{className:"text-muted-foreground text-sm",children:e.error})]})]})}):f.jsxs("div",{className:"bg-green-50/30 dark:bg-green-950/20 border border-green-200/50 dark:border-green-800/50 rounded-lg",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-100/30 dark:bg-green-900/20 border-b border-green-200/50 dark:border-green-800/50",children:[f.jsx(sf,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70"}),f.jsx("span",{className:"text-sm font-medium text-foreground",children:"Tool executed successfully"})]}),f.jsx("div",{className:"p-4",children:(()=>{const x=R=>{if(!R)return null;const j=Array.isArray(R)?R[0]:R;if(!j)return null;const A=j?.resource;if(A&&typeof A=="object"&&typeof A.uri=="string"&&A.uri.startsWith("ui://"))return A;const N=j?.content;if(Array.isArray(N)){for(const M of N)if(M?.type==="resource"&&M?.resource?.uri&&typeof M.resource.uri=="string"&&M.resource.uri.startsWith("ui://"))return M.resource}return null},E=e?.result,S=a?.["openai/outputTemplate"];if(S&&typeof S=="string"){const R=l||e.serverId;return f.jsx(Vq,{componentUrl:S,toolCall:t,toolResult:e,onCallTool:s,onSendFollowup:i,serverId:R,toolMeta:a})}const k=x(E);if(k)return f.jsx(DN,{resource:k,htmlProps:{autoResizeIframe:!0,style:{width:"100%",overflow:"visible"}},onUIAction:async R=>{if(R.type==="tool"&&R.payload?.toolName){const j=(()=>{if(r&&typeof r=="object"&&Object.keys(r).length===1)return Object.keys(r)[0]})();fetch("/api/mcp/tools/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolName:R.payload.toolName,parameters:R.payload.params||{},...j?{serverId:j}:{}})}).catch(()=>{})}else R.type==="link"&&R.payload?.url&&window.open(R.payload.url,"_blank","noopener,noreferrer");return{status:"handled"}}});const T=E?.result||E;return typeof T=="object"?f.jsx(S4,{data:T}):f.jsx("div",{className:"text-sm text-foreground bg-muted/30 p-3 rounded border",children:String(T)})})()})]})})]})]})]})}const BEe="/claude_logo.png",qEe="/openai_logo.png",VEe="/deepseek_logo.svg",HEe="/google_logo.png",GEe="/meta_logo.svg",k4="/ollama_logo.svg",T4="/ollama_dark.png",C4="/grok_light.svg",A4="/grok_dark.png",X8=(t,e)=>{switch(t){case"anthropic":return BEe;case"openai":return qEe;case"deepseek":return VEe;case"google":return HEe;case"ollama":return e==="dark"||e==="system"&&typeof document<"u"&&document.documentElement.classList.contains("dark")?T4:k4;case"meta":return GEe;case"x-ai":return e==="dark"||e==="system"&&typeof document<"u"&&document.documentElement.classList.contains("dark")?A4:C4;default:return null}},WEe=(t,e)=>X8(t.provider,e),YEe=t=>{switch(t){case"anthropic":return"text-orange-600 dark:text-orange-400";case"openai":return"text-green-600 dark:text-green-400";case"deepseek":return"text-blue-600 dark:text-blue-400";case"google":return"text-red-600 dark:text-red-400";case"ollama":return"text-gray-600 dark:text-gray-400";case"x-ai":return"text-purple-600 dark:text-purple-400";default:return"text-blue-600 dark:text-blue-400"}},N4=t=>{let e;const n=new Set,r=(d,p)=>{const h=typeof d=="function"?d(e):d;if(!Object.is(h,e)){const g=e;e=p??(typeof h!="object"||h===null)?h:Object.assign({},e,h),n.forEach(v=>v(e,g))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=e=t(r,s,l);return l},KEe=t=>t?N4(t):N4,XEe=t=>t;function QEe(t,e=XEe){const n=Ee.useSyncExternalStore(t.subscribe,Ee.useCallback(()=>e(t.getState()),[t,e]),Ee.useCallback(()=>e(t.getInitialState()),[t,e]));return Ee.useDebugValue(n),n}const JEe=t=>KEe()(e=>({themeMode:t?.themeMode??"light",themePreset:t?.themePreset??"default",setThemeMode:n=>e({themeMode:n}),setThemePreset:n=>e({themePreset:n})})),Q8=w.createContext(null),ZEe=({children:t,themeMode:e,themePreset:n})=>{const r=w.useRef(null);return r.current??=JEe({themeMode:e,themePreset:n}),f.jsx(Q8.Provider,{value:r.current,children:t})},Ym=t=>{const e=w.useContext(Q8);if(!e)throw new Error("Missing PreferencesStoreProvider");return QEe(e,t)},R4=({attachment:t,align:e="left"})=>{const[n,r]=w.useState(!1),[s,i]=w.useState(!1);return n?f.jsxs("div",{className:`px-3 py-2 bg-muted rounded-lg text-sm text-muted-foreground ${e==="right"?"text-right":""}`,children:["Failed to load image: ",t.name]}):f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{className:`text-xs text-muted-foreground font-medium ${e==="right"?"text-right":""}`,children:t.name}),f.jsx("div",{className:"flex justify-center",children:f.jsx("img",{src:t.url,alt:t.name,className:`max-w-full h-auto rounded-lg border border-border/30 shadow-sm cursor-pointer transition-all hover:shadow-md ${s?"max-h-none":"max-h-96"}`,loading:"lazy",onClick:()=>i(!s),onError:()=>r(!0),title:s?"Click to collapse":"Click to expand"})})]})},j4=()=>f.jsxs("div",{className:"flex items-center gap-2 py-2",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:"Thinking"}),f.jsxs("div",{className:"flex space-x-1",children:[f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce [animation-delay:-0.2s]"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce [animation-delay:-0.4s]"})]})]}),e1e=({message:t,isLoading:e=!1,onEdit:n,onRegenerate:r,onCopy:s,isReadonly:i=!1,showActions:a=!0,model:l,serverConfigs:u,onCallTool:d,onSendFollowup:p,toolsMetadata:h,serverId:g})=>{const[v,b]=w.useState("view"),[x,E]=w.useState(!1),[S,k]=w.useState(!1),T=Ym(I=>I.themeMode),R=()=>{s?s(t.content):navigator.clipboard.writeText(t.content),k(!0),setTimeout(()=>k(!1),2e3)},j=I=>{n&&n(t.id,I),b("view")},A=()=>{b("view")},N=()=>{r&&r(t.id)},M=t.role==="assistant"&&e&&(!t.content||t.content.trim()==="");return f.jsx(hx,{children:f.jsxs(ei.div,{"data-testid":`message-${t.role}`,className:"w-full mx-auto max-w-4xl px-4 group/message",initial:{y:5,opacity:0},animate:{y:0,opacity:1},"data-role":t.role,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),children:[t.role==="assistant"&&f.jsxs("div",{className:"flex gap-4 w-full",children:[f.jsx("div",{className:"size-8 flex items-center rounded-full justify-center shrink-0 bg-muted/50",children:f.jsx("img",{src:WEe(l,T),alt:`${l?.id} logo`,className:"h-4 w-4 object-contain"})}),f.jsxs("div",{className:"flex flex-col gap-4 w-full min-w-0",children:[t.attachments&&t.attachments.length>0&&f.jsx("div",{className:"flex flex-col gap-3",children:t.attachments.map(I=>PD({type:I.contentType})?f.jsx(R4,{attachment:I},I.id):f.jsxs("div",{className:"px-3 py-2 bg-muted rounded-lg text-sm flex items-center gap-2",children:[f.jsx("span",{children:"📎"}),f.jsx("span",{children:I.name}),I.size&&f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.size/1024).toFixed(1)," KB)"]})]},I.id))}),t.contentBlocks&&t.contentBlocks.length>0?f.jsx("div",{className:"space-y-4",children:t.contentBlocks.map((I,O)=>I.type==="text"&&I.content?f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:O*.05},className:"prose prose-sm max-w-none dark:prose-invert prose-p:leading-relaxed prose-pre:bg-muted/50 prose-pre:border prose-pre:border-border/30 flex-1 min-w-0",children:f.jsx(_4,{children:iE(I.content)})},I.id):I.type==="tool_call"&&I.toolCall?f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:O*.05},children:f.jsx(E4,{toolCall:I.toolCall,toolResult:I.toolResult,serverConfigs:u,onCallTool:d,onSendFollowup:p,toolMeta:h?.[I.toolCall.name],serverId:g})},I.id):null)}):f.jsxs(f.Fragment,{children:[t.toolCalls&&t.toolCalls.length>0&&f.jsx("div",{className:"space-y-2",children:t.toolCalls.map((I,O)=>{const L=t.toolResults?.find(z=>z.toolCallId===I.id);return f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:O*.1},children:f.jsx(E4,{toolCall:I,toolResult:L,serverConfigs:u,onCallTool:d,onSendFollowup:p,toolMeta:h?.[I.name],serverId:g})},I.id)})}),M?f.jsx(ei.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:f.jsx(j4,{})}):v==="view"&&t.content?f.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert prose-p:leading-relaxed prose-pre:bg-muted/50 prose-pre:border prose-pre:border-border/30 flex-1 min-w-0",children:f.jsx(_4,{children:iE(t.content)})}):null]}),M&&t.contentBlocks&&f.jsx(ei.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:f.jsx(j4,{})}),v==="view"&&x&&f.jsxs("div",{className:"flex items-center justify-between mt-4",children:[f.jsx("div",{className:"text-xs text-muted-foreground/60",children:MD(t.timestamp)}),a&&!i&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:R,children:S?f.jsx(Ti,{size:14}):f.jsx(Po,{size:14})})}),f.jsx(Pa,{children:"Copy"})]}),r&&f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:N,children:f.jsx(rie,{size:14})})}),f.jsx(Pa,{children:"Regenerate"})]})]})]}),v==="edit"&&f.jsx("div",{className:"flex flex-row gap-2 items-start",children:f.jsx(w4,{message:t,onSave:j,onCancel:A})})]})]}),t.role==="user"&&f.jsx("div",{className:"flex justify-end w-full",children:f.jsxs("div",{className:"flex flex-col gap-2 max-w-2xl",children:[t.attachments&&t.attachments.length>0&&f.jsx("div",{className:"flex flex-col gap-3",children:t.attachments.map(I=>PD({type:I.contentType})?f.jsx(R4,{attachment:I,align:"right"},I.id):f.jsxs("div",{className:"px-3 py-2 bg-muted rounded-lg text-sm flex items-center gap-2 justify-end",children:[f.jsx("span",{children:I.name}),f.jsx("span",{children:"📎"}),I.size&&f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.size/1024).toFixed(1)," KB)"]})]},I.id))}),v==="view"?f.jsxs("div",{className:"flex items-start gap-2 justify-end",children:[a&&!i&&x&&f.jsx("div",{className:"flex items-center gap-1 mt-1",children:f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:R,children:f.jsx(Po,{size:14})})}),f.jsx(Pa,{children:"Copy"})]})}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{"data-testid":"message-content",className:"bg-primary text-primary-foreground px-4 py-3 rounded-2xl max-w-fit",children:f.jsx("div",{className:"whitespace-pre-wrap break-words font-medium",children:iE(t.content)})}),x&&f.jsx("div",{className:"absolute -bottom-6 right-0 text-xs text-muted-foreground/60",children:MD(t.timestamp)})]})]}):f.jsx("div",{className:"w-full",children:f.jsx(w4,{message:t,onSave:j,onCancel:A})})]})})]})})},t1e=w.memo(e1e,(t,e)=>t.message.id===e.message.id&&t.message.content===e.message.content&&t.isLoading===e.isLoading&&JSON.stringify(t.message.toolCalls)===JSON.stringify(e.message.toolCalls)&&JSON.stringify(t.message.toolResults)===JSON.stringify(e.message.toolResults));function M1({provider:t}){const e=Ym(r=>r.themeMode),n=X8(t,e);return n?f.jsx("img",{src:n,width:12,height:12,alt:`${t} logo`,className:"h-3 w-3 object-contain"}):f.jsx("div",{className:kT("h-3 w-3 rounded-sm",YEe(t))})}var Ea=[],xi=[],n1e=Uint8Array,O1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Cd=0,r1e=O1.length;Cd<r1e;++Cd)Ea[Cd]=O1[Cd],xi[O1.charCodeAt(Cd)]=Cd;xi[45]=62;xi[95]=63;function s1e(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function i1e(t,e,n){return(e+n)*3/4-n}function Km(t){var e,n=s1e(t),r=n[0],s=n[1],i=new n1e(i1e(t,r,s)),a=0,l=s>0?r-4:r,u;for(u=0;u<l;u+=4)e=xi[t.charCodeAt(u)]<<18|xi[t.charCodeAt(u+1)]<<12|xi[t.charCodeAt(u+2)]<<6|xi[t.charCodeAt(u+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return s===2&&(e=xi[t.charCodeAt(u)]<<2|xi[t.charCodeAt(u+1)]>>4,i[a++]=e&255),s===1&&(e=xi[t.charCodeAt(u)]<<10|xi[t.charCodeAt(u+1)]<<4|xi[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function a1e(t){return Ea[t>>18&63]+Ea[t>>12&63]+Ea[t>>6&63]+Ea[t&63]}function o1e(t,e,n){for(var r,s=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(a1e(r));return s.join("")}function Xm(t){for(var e,n=t.length,r=n%3,s=[],i=16383,a=0,l=n-r;a<l;a+=i)s.push(o1e(t,a,a+i>l?l:a+i));return r===1?(e=t[n-1],s.push(Ea[e>>2]+Ea[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],s.push(Ea[e>>10]+Ea[e>>4&63]+Ea[e<<2&63]+"=")),s.join("")}function So(t){if(t===void 0)return{};if(!J8(t))throw new Error(`The arguments to a Convex function must be an object. Received: ${t}`);return t}function l1e(t){if(typeof t>"u")throw new Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if(typeof t!="string")throw new Error(`Invalid deployment address: found ${t}".`);if(!(t.startsWith("http:")||t.startsWith("https:")))throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${t}".`);try{new URL(t)}catch{throw new Error(`Invalid deployment address: "${t}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(t.endsWith(".convex.site"))throw new Error(`Invalid deployment address: "${t}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}function J8(t){const e=typeof t=="object",n=Object.getPrototypeOf(t),r=n===null||n===Object.prototype||n?.constructor?.name==="Object";return e&&r}const Z8=!0,Mf=BigInt("-9223372036854775808"),nj=BigInt("9223372036854775807"),SC=BigInt("0"),c1e=BigInt("8"),u1e=BigInt("256");function e7(t){return Number.isNaN(t)||!Number.isFinite(t)||Object.is(t,-0)}function d1e(t){t<SC&&(t-=Mf+Mf);let e=t.toString(16);e.length%2===1&&(e="0"+e);const n=new Uint8Array(new ArrayBuffer(8));let r=0;for(const s of e.match(/.{2}/g).reverse())n.set([parseInt(s,16)],r++),t>>=c1e;return Xm(n)}function f1e(t){const e=Km(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);let n=SC,r=SC;for(const s of e)n+=BigInt(s)*u1e**r,r++;return n>nj&&(n+=Mf+Mf),n}function h1e(t){if(t<Mf||nj<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);const e=new ArrayBuffer(8);return new DataView(e).setBigInt64(0,t,!0),Xm(new Uint8Array(e))}function p1e(t){const e=Km(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);return new DataView(e.buffer).getBigInt64(0,!0)}const m1e=DataView.prototype.setBigInt64?h1e:d1e,g1e=DataView.prototype.getBigInt64?p1e:f1e,M4=1024;function t7(t){if(t.length>M4)throw new Error(`Field name ${t} exceeds maximum field name length ${M4}.`);if(t.startsWith("$"))throw new Error(`Field name ${t} starts with a '$', which is reserved.`);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<32||n>=127)throw new Error(`Field name ${t} has invalid character '${t[e]}': Field names can only contain non-control ASCII characters`)}}function Of(t){if(t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>Of(r));if(typeof t!="object")throw new Error(`Unexpected type of ${t}`);const e=Object.entries(t);if(e.length===1){const r=e[0][0];if(r==="$bytes"){if(typeof t.$bytes!="string")throw new Error(`Malformed $bytes field on ${t}`);return Km(t.$bytes).buffer}if(r==="$integer"){if(typeof t.$integer!="string")throw new Error(`Malformed $integer field on ${t}`);return g1e(t.$integer)}if(r==="$float"){if(typeof t.$float!="string")throw new Error(`Malformed $float field on ${t}`);const s=Km(t.$float);if(s.byteLength!==8)throw new Error(`Received ${s.byteLength} bytes, expected 8 for $float`);const a=new DataView(s.buffer).getFloat64(0,Z8);if(!e7(a))throw new Error(`Float ${a} should be encoded as a number`);return a}if(r==="$set")throw new Error("Received a Set which is no longer supported as a Convex type.");if(r==="$map")throw new Error("Received a Map which is no longer supported as a Convex type.")}const n={};for(const[r,s]of Object.entries(t))t7(r),n[r]=Of(s);return n}function fm(t){return JSON.stringify(t,(e,n)=>n===void 0?"undefined":typeof n=="bigint"?`${n.toString()}n`:n)}function EC(t,e,n,r){if(t===void 0){const a=n&&` (present at path ${n} in original object ${fm(e)})`;throw new Error(`undefined is not a valid Convex value${a}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(t===null)return t;if(typeof t=="bigint"){if(t<Mf||nj<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:m1e(t)}}if(typeof t=="number")if(e7(t)){const a=new ArrayBuffer(8);return new DataView(a).setFloat64(0,t,Z8),{$float:Xm(new Uint8Array(a))}}else return t;if(typeof t=="boolean"||typeof t=="string")return t;if(t instanceof ArrayBuffer)return{$bytes:Xm(new Uint8Array(t))};if(Array.isArray(t))return t.map((a,l)=>EC(a,e,n+`[${l}]`));if(t instanceof Set)throw new Error(P1(n,"Set",[...t],e));if(t instanceof Map)throw new Error(P1(n,"Map",[...t],e));if(!J8(t)){const a=t?.constructor?.name,l=a?`${a} `:"";throw new Error(P1(n,l,t,e))}const s={},i=Object.entries(t);i.sort(([a,l],[u,d])=>a===u?0:a<u?-1:1);for(const[a,l]of i)l!==void 0&&(t7(a),s[a]=EC(l,e,n+`.${a}`));return s}function P1(t,e,n,r){return t?`${e}${fm(n)} is not a supported Convex type (present at path ${t} in original object ${fm(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${e}${fm(n)} is not a supported Convex type.`}function Ql(t){return EC(t,t,"")}var v1e=Object.defineProperty,y1e=(t,e,n)=>e in t?v1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,I1=(t,e,n)=>y1e(t,typeof e!="symbol"?e+"":e,n),O4,P4;const b1e=Symbol.for("ConvexError");class kC extends(P4=Error,O4=b1e,P4){constructor(e){super(typeof e=="string"?e:fm(e)),I1(this,"name","ConvexError"),I1(this,"data"),I1(this,O4,!0),this.data=e}}const n7=()=>Array.from({length:4},()=>0);n7();n7();const I4="1.27.5";var x1e=Object.defineProperty,_1e=(t,e,n)=>e in t?x1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D4=(t,e,n)=>_1e(t,typeof e!="symbol"?e+"":e,n);const w1e="color:rgb(0, 145, 255)";function r7(t){switch(t){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class s7{constructor(e){D4(this,"_onLogLineFuncs"),D4(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let n=Math.random().toString(36).substring(2,15);for(let r=0;r<10&&this._onLogLineFuncs[n]!==void 0;r++)n=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[n]=e,()=>{delete this._onLogLineFuncs[n]}}logVerbose(...e){if(this._verbose)for(const n of Object.values(this._onLogLineFuncs))n("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const n of Object.values(this._onLogLineFuncs))n("info",...e)}warn(...e){for(const n of Object.values(this._onLogLineFuncs))n("warn",...e)}error(...e){for(const n of Object.values(this._onLogLineFuncs))n("error",...e)}}function i7(t){const e=new s7(t);return e.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),e}function a7(t){return new s7(t)}function xx(t,e,n,r,s){const i=r7(n);if(typeof s=="object"&&(s=`ConvexError ${JSON.stringify(s.errorData,null,2)}`),e==="info"){const a=s.match(/^\[.*?\] /);if(a===null){t.error(`[CONVEX ${i}(${r})] Could not parse console.log`);return}const l=s.slice(1,a[0].length-2),u=s.slice(a[0].length);t.log(`%c[CONVEX ${i}(${r})] [${l}]`,w1e,u)}else t.error(`[CONVEX ${i}(${r})] ${s}`)}function S1e(t,e){const n=`[CONVEX FATAL ERROR] ${e}`;return t.error(n),new Error(n)}function Xd(t,e,n){return`[CONVEX ${r7(t)}(${e})] ${n.errorMessage}
|
|
1818
|
-
Called by client`}function TC(t,e){return e.data=t.errorData,e}function _x(t){const e=t.split(":");let n,r;return e.length===1?(n=e[0],r="default"):(n=e.slice(0,e.length-1).join(":"),r=e[e.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function iu(t,e){return JSON.stringify({udfPath:_x(t),args:Ql(e)})}var E1e=Object.defineProperty,k1e=(t,e,n)=>e in t?E1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xa=(t,e,n)=>k1e(t,typeof e!="symbol"?e+"":e,n);class T1e{constructor(){xa(this,"nextQueryId"),xa(this,"querySetVersion"),xa(this,"querySet"),xa(this,"queryIdToToken"),xa(this,"identityVersion"),xa(this,"auth"),xa(this,"outstandingQueriesOlderThanRestart"),xa(this,"outstandingAuthOlderThanRestart"),xa(this,"paused"),xa(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,n,r,s){const i=_x(e),a=iu(i,n),l=this.querySet.get(a);if(l!==void 0)return l.numSubscribers+=1,{queryToken:a,modification:null,unsubscribe:()=>this.removeSubscriber(a)};{const u=this.nextQueryId++,d={id:u,canonicalizedUdfPath:i,args:n,numSubscribers:1,journal:r,componentPath:s};this.querySet.set(a,d),this.queryIdToToken.set(u,a);const p=this.querySetVersion,h=this.querySetVersion+1,g={type:"Add",queryId:u,udfPath:i,args:[Ql(n)],journal:r,componentPath:s};return this.paused?this.pendingQuerySetModifications.set(u,g):this.querySetVersion=h,{queryToken:a,modification:{type:"ModifyQuerySet",baseVersion:p,newVersion:h,modifications:[g]},unsubscribe:()=>this.removeSubscriber(a)}}}transition(e){for(const n of e.modifications)switch(n.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);const r=n.journal;if(r!==void 0){const s=this.queryIdToToken.get(n.queryId);s!==void 0&&(this.querySet.get(s).journal=r)}break}case"QueryRemoved":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);break}default:throw new Error(`Invalid modification ${n.type}`)}}queryId(e,n){const r=_x(e),s=iu(r,n),i=this.querySet.get(s);return i!==void 0?i.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const n=this.identityVersion;return this.paused||(this.identityVersion=n+1),{type:"Authenticate",baseVersion:n,...this.auth}}setAdminAuth(e,n){const r={tokenType:"Admin",value:e,impersonating:n};this.auth=r;const s=this.identityVersion;return this.paused||(this.identityVersion=s+1),{type:"Authenticate",baseVersion:s,...r}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).canonicalizedUdfPath:null}queryArgs(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(e){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const n=[];for(const i of this.querySet.values()){const a={type:"Add",queryId:i.id,udfPath:i.canonicalizedUdfPath,args:[Ql(i.args)],journal:i.journal,componentPath:i.componentPath};n.push(a),e.has(i.id)||this.outstandingQueriesOlderThanRestart.add(i.id)}this.querySetVersion=1;const r={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:n};if(!this.auth)return this.identityVersion=0,[r,void 0];this.outstandingAuthOlderThanRestart=!0;const s={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[r,s]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,n=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,n]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const n=this.querySet.get(e);if(n.numSubscribers>1)return n.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(n.id),this.outstandingQueriesOlderThanRestart.delete(n.id);const r=this.querySetVersion,s=this.querySetVersion+1,i={type:"Remove",queryId:n.id};return this.paused?this.pendingQuerySetModifications.has(n.id)?this.pendingQuerySetModifications.delete(n.id):this.pendingQuerySetModifications.set(n.id,i):this.querySetVersion=s,{type:"ModifyQuerySet",baseVersion:r,newVersion:s,modifications:[i]}}}}var C1e=Object.defineProperty,A1e=(t,e,n)=>e in t?C1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,wy=(t,e,n)=>A1e(t,typeof e!="symbol"?e+"":e,n);class N1e{constructor(e,n){this.logger=e,this.markConnectionStateDirty=n,wy(this,"inflightRequests"),wy(this,"requestsOlderThanRestart"),wy(this,"inflightMutationsCount",0),wy(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,n){const r=new Promise(s=>{const i=n?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:i,requestedAt:new Date,onResult:s}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),r}onResponse(e){const n=this.inflightRequests.get(e.requestId);if(n===void 0||n.status.status==="Completed")return null;const r=n.message.type==="Mutation"?"mutation":"action",s=n.message.udfPath;for(const u of e.logLines)xx(this.logger,"info",r,s,u);const i=n.status;let a,l;if(e.success)a={success:!0,logLines:e.logLines,value:Of(e.result)},l=()=>i.onResult(a);else{const u=e.result,{errorData:d}=e;xx(this.logger,"error",r,s,u),a={success:!1,errorMessage:u,errorData:d!==void 0?Of(d):void 0,logLines:e.logLines},l=()=>i.onResult(a)}return e.type==="ActionResponse"||!e.success?(l(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),n.message.type==="Action"?this.inflightActionsCount--:n.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:a}):(n.status={status:"Completed",result:a,ts:e.ts,onResolve:l},null)}removeCompleted(e){const n=new Map;for(const[r,s]of this.inflightRequests.entries()){const i=s.status;i.status==="Completed"&&i.ts.lessThanOrEqual(e)&&(i.onResolve(),n.set(r,i.result),s.message.type==="Mutation"?this.inflightMutationsCount--:s.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(r),this.requestsOlderThanRestart.delete(r))}return n.size>0&&this.markConnectionStateDirty(),n}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[n,r]of this.inflightRequests){if(r.status.status==="NotSent"){r.status.status="Requested",e.push(r.message);continue}if(r.message.type==="Mutation")e.push(r.message);else if(r.message.type==="Action"){if(this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n),this.inflightActionsCount--,r.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");r.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,n]of this.inflightRequests)if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const n of this.inflightRequests.values())n.status.status!=="Completed"&&n.status.requestedAt.getTime()<e&&(e=n.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}const Qm=Symbol.for("functionName"),R1e=Symbol.for("toReferencePath");function j1e(t){return t[R1e]??null}function M1e(t){return t.startsWith("function://")}function O1e(t){let e;if(typeof t=="string")M1e(t)?e={functionHandle:t}:e={name:t};else if(t[Qm])e={name:t[Qm]};else{const n=j1e(t);if(!n)throw new Error(`${t} is not a functionReference`);e={reference:n}}return e}function Ps(t){const e=O1e(t);if(e.name===void 0)throw e.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${e.functionHandle}`):e.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${e.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(e)}`);if(typeof t=="string")return t;const n=t[Qm];if(!n)throw new Error(`${t} is not a functionReference`);return n}function rj(t){return{[Qm]:t}}function o7(t=[]){const e={get(n,r){if(typeof r=="string"){const s=[...t,r];return o7(s)}else if(r===Qm){if(t.length<2){const a=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${a}\``)}const s=t.slice(0,-1).join("/"),i=t[t.length-1];return i==="default"?s:s+":"+i}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}o7();var P1e=Object.defineProperty,I1e=(t,e,n)=>e in t?P1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,wx=(t,e,n)=>I1e(t,typeof e!="symbol"?e+"":e,n);class Jm{constructor(e){wx(this,"queryResults"),wx(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...n){const r=So(n[0]),s=Ps(e),i=this.queryResults.get(iu(s,r));if(i!==void 0)return Jm.queryValue(i.result)}getAllQueries(e){const n=[],r=Ps(e);for(const s of this.queryResults.values())s.udfPath===_x(r)&&n.push({args:s.args,value:Jm.queryValue(s.result)});return n}setQuery(e,n,r){const s=So(n),i=Ps(e),a=iu(i,s);let l;r===void 0?l=void 0:l={success:!0,value:r,logLines:[]};const u={udfPath:i,args:s,result:l};this.queryResults.set(a,u),this.modifiedQueries.push(a)}static queryValue(e){if(e!==void 0)return e.success?e.value:void 0}}class D1e{constructor(){wx(this,"queryResults"),wx(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,n){this.optimisticUpdates=this.optimisticUpdates.filter(a=>!n.has(a.mutationId));const r=this.queryResults;this.queryResults=new Map(e);const s=new Jm(this.queryResults);for(const a of this.optimisticUpdates)a.update(s);const i=[];for(const[a,l]of this.queryResults){const u=r.get(a);(u===void 0||u.result!==l.result)&&i.push(a)}return i}applyOptimisticUpdate(e,n){this.optimisticUpdates.push({update:e,mutationId:n});const r=new Jm(this.queryResults);return e(r),r.modifiedQueries}rawQueryResult(e){return this.queryResults.get(e)}queryResult(e){const n=this.queryResults.get(e);if(n===void 0)return;const r=n.result;if(r!==void 0){if(r.success)return r.value;throw r.errorData!==void 0?TC(r,new kC(Xd("query",n.udfPath,r))):new Error(Xd("query",n.udfPath,r))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}}var L1e=Object.defineProperty,$1e=(t,e,n)=>e in t?L1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D1=(t,e,n)=>$1e(t,typeof e!="symbol"?e+"":e,n);class Xs{constructor(e,n){D1(this,"low"),D1(this,"high"),D1(this,"__isUnsignedLong__"),this.low=e|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(e){return(e&&e.__isUnsignedLong__)===!0}static fromBytesLE(e){return new Xs(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){const e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?L4:e>=z1e?F1e:new Xs(e%hm|0,e/hm|0)}toString(){return(BigInt(this.high)*BigInt(hm)+BigInt(this.low)).toString()}equals(e){return Xs.isLong(e)||(e=Xs.fromValue(e)),this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return Xs.isLong(e)||(e=Xs.fromValue(e)),this.equals(e)?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return this.comp(e)<=0}static fromValue(e){return typeof e=="number"?Xs.fromNumber(e):new Xs(e.low,e.high)}}const L4=new Xs(0,0),$4=65536,hm=$4*$4,z1e=hm*hm,F1e=new Xs(-1,-1);var U1e=Object.defineProperty,B1e=(t,e,n)=>e in t?U1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Sy=(t,e,n)=>B1e(t,typeof e!="symbol"?e+"":e,n);class z4{constructor(e,n){Sy(this,"version"),Sy(this,"remoteQuerySet"),Sy(this,"queryPath"),Sy(this,"logger"),this.version={querySet:0,ts:Xs.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=n}transition(e){const n=e.startVersion;if(this.version.querySet!==n.querySet||this.version.ts.notEquals(n.ts)||this.version.identity!==n.identity)throw new Error(`Invalid start version: ${n.ts.toString()}:${n.querySet}`);for(const r of e.modifications)switch(r.type){case"QueryUpdated":{const s=this.queryPath(r.queryId);if(s)for(const a of r.logLines)xx(this.logger,"info","query",s,a);const i=Of(r.value??null);this.remoteQuerySet.set(r.queryId,{success:!0,value:i,logLines:r.logLines});break}case"QueryFailed":{const s=this.queryPath(r.queryId);if(s)for(const a of r.logLines)xx(this.logger,"info","query",s,a);const{errorData:i}=r;this.remoteQuerySet.set(r.queryId,{success:!1,errorMessage:r.errorMessage,errorData:i!==void 0?Of(i):void 0,logLines:r.logLines});break}case"QueryRemoved":{this.remoteQuerySet.delete(r.queryId);break}default:throw new Error(`Invalid modification ${r.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function L1(t){const e=Km(t);return Xs.fromBytesLE(Array.from(e))}function q1e(t){const e=new Uint8Array(t.toBytesLE());return Xm(e)}function F4(t){switch(t.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...t};case"MutationResponse":return t.success?{...t,ts:L1(t.ts)}:{...t};case"Transition":return{...t,startVersion:{...t.startVersion,ts:L1(t.startVersion.ts)},endVersion:{...t.endVersion,ts:L1(t.endVersion.ts)}}}}function V1e(t){switch(t.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...t};case"Connect":return t.maxObservedTimestamp!==void 0?{...t,maxObservedTimestamp:q1e(t.maxObservedTimestamp)}:{...t,maxObservedTimestamp:void 0}}}var H1e=Object.defineProperty,G1e=(t,e,n)=>e in t?H1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Vr=(t,e,n)=>G1e(t,typeof e!="symbol"?e+"":e,n);const W1e=1e3,Y1e=1001,K1e=1005,X1e=4040;let ab;function ob(){return ab===void 0&&(ab=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(ab+performance.now())}function U4(){return`t=${Math.round((ob()-ab)/100)/10}s`}const l7={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function Q1e(t){if(t===void 0)return"Unknown";for(const e of Object.keys(l7))if(t.startsWith(e))return e;return"Unknown"}class J1e{constructor(e,n,r,s,i,a){this.markConnectionStateDirty=i,this.debug=a,Vr(this,"socket"),Vr(this,"connectionCount"),Vr(this,"_hasEverConnected",!1),Vr(this,"lastCloseReason"),Vr(this,"transitionChunkBuffer",null),Vr(this,"defaultInitialBackoff"),Vr(this,"maxBackoff"),Vr(this,"retries"),Vr(this,"serverInactivityThreshold"),Vr(this,"reconnectDueToServerInactivityTimeout"),Vr(this,"uri"),Vr(this,"onOpen"),Vr(this,"onResume"),Vr(this,"onMessage"),Vr(this,"webSocketConstructor"),Vr(this,"logger"),Vr(this,"onServerDisconnectError"),this.webSocketConstructor=r,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=n.onOpen,this.onResume=n.onResume,this.onMessage=n.onMessage,this.onServerDisconnectError=n.onServerDisconnectError,this.logger=s,this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.messageLength!==e.messageLength))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,messageLength:e.messageLength}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const n=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${n}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const n=this.transitionChunkBuffer.chunks.join("");if(this.transitionChunkBuffer=null,n.length!==e.messageLength)throw new Error(`Assembled Transition length mismatch: expected ${e.messageLength}, got ${n.length}`);const r=F4(JSON.parse(n));if(r.type!=="Transition")throw new Error(`Expected Transition, got ${r.type} after assembling chunks`);return r}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:ob()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",U4(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",U4())),this.connectionCount+=1,this.lastCloseReason=null},e.onerror=n=>{this.transitionChunkBuffer=null;const r=n.message;r&&this.logger.log(`WebSocket error message: ${r}`)},e.onmessage=n=>{this.resetServerInactivityTimeout();const r=n.data.length;let s=F4(JSON.parse(n.data));if(this._logVerbose(`received ws message with type ${s.type}`),s.type==="Ping")return;if(s.type==="TransitionChunk"){const a=this.assembleTransition(s);if(!a)return;s=a,this._logVerbose(`assembled full ws message of type ${s.type}`)}if(this.transitionChunkBuffer!==null)throw new Error(`Received unexpected ${s.type} while buffering TransitionChunks`);s.type==="Transition"&&this.reportLargeTransition({messageLength:r,transition:s}),this.onMessage(s).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())},e.onclose=n=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=n.reason||`closed with code ${n.code}`),n.code!==W1e&&n.code!==Y1e&&n.code!==K1e&&n.code!==X1e){let s=`WebSocket closed with code ${n.code}`;n.reason&&(s+=`: ${n.reason}`),this.logger.log(s),this.onServerDisconnectError&&n.reason&&this.onServerDisconnectError(s)}const r=Q1e(n.reason);this.scheduleReconnect(r)}}socketState(){return this.socket.state}sendMessage(e){const n={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const r=V1e(e),s=JSON.stringify(r);let i=!1;try{this.socket.ws.send(s),i=!0}catch(a){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${a}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${i?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(n)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(n)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.socket={state:"disconnected"};const n=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(n)}ms`),setTimeout(()=>this.connect(),n)}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":{this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return}default:this.socket}}close(){switch(this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return new Promise(n=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),n()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws,n=new Promise(r=>{e.onclose=()=>{r()}});return e.close(),n}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":{this.socket={...this.socket,paused:"yes"};return}default:{this.socket;return}}}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:ob()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const r=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:l7[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const s=Math.min(r,this.maxBackoff),i=s*(Math.random()-.5);return s+i}reportLargeTransition({transition:e,messageLength:n}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const r=ob()-e.clientClockSkew-e.serverTs/1e6,s=`${Math.round(r)}ms`,i=`${Math.round(n/1e4)/100}MB`,a=n/(r/1e3),l=`${Math.round(a/1e4)/100}MB per second`;this._logVerbose(`received ${i} transition in ${s} at ${l}`),n>2e7?this.logger.log(`received query results totaling more that 20MB (${i}) which will take a long time to download on slower connections`):r>2e4&&this.logger.log(`received query results totaling ${i} which took more than 20s to arrive (${s})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:r,messageLength:n}})}}function Z1e(){return eke()}function eke(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class Yp extends Error{}Yp.prototype.name="InvalidTokenError";function tke(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function nke(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return tke(e)}catch{return atob(e)}}function c7(t,e){if(typeof t!="string")throw new Yp("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new Yp(`Invalid token specified: missing part #${n+1}`);let s;try{s=nke(r)}catch(i){throw new Yp(`Invalid token specified: invalid base64 for part #${n+1} (${i.message})`)}try{return JSON.parse(s)}catch(i){throw new Yp(`Invalid token specified: invalid json for part #${n+1} (${i.message})`)}}var rke=Object.defineProperty,ske=(t,e,n)=>e in t?rke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vi=(t,e,n)=>ske(t,typeof e!="symbol"?e+"":e,n);const ike=20*24*60*60*1e3,B4=2;class ake{constructor(e,n,r){vi(this,"authState",{state:"noAuth"}),vi(this,"configVersion",0),vi(this,"syncState"),vi(this,"authenticate"),vi(this,"stopSocket"),vi(this,"tryRestartSocket"),vi(this,"pauseSocket"),vi(this,"resumeSocket"),vi(this,"clearAuth"),vi(this,"logger"),vi(this,"refreshTokenLeewaySeconds"),vi(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=n.authenticate,this.stopSocket=n.stopSocket,this.tryRestartSocket=n.tryRestartSocket,this.pauseSocket=n.pauseSocket,this.resumeSocket=n.resumeSocket,this.clearAuth=n.clearAuth,this.logger=r.logger,this.refreshTokenLeewaySeconds=r.refreshTokenLeewaySeconds}async setConfig(e,n){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const r=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});r.isFromOutdatedConfig||(r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:{fetchToken:e,onAuthChange:n},hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:{fetchToken:e,onAuthChange:n}}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket())}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid"),this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:n}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(n+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=B4){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${B4-this.tokenConfirmationAttempts} attempts remaining`)),await this.stopSocket();const n=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});n.isFromOutdatedConfig||(n.value&&this.syncState.isNewAuth(n.value)?(this.authenticate(n.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:n.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:s}=n;if(!r||!s){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const i=s-r;if(i<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let a=Math.min(ike,(i-this.refreshTokenLeewaySeconds)*1e3);a<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${i}s`),a=0);const l=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},a);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:l,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`)}async fetchTokenAndGuardAgainstRace(e,n){const r=++this.configVersion;this._logVerbose(`fetching token with config version ${r}`);const s=await e(n);return this.configVersion!==r?(this._logVerbose(`stale config version, expected ${r}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:s}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.setAuthState({state:"noAuth"})}setAuthState(e){const n=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(n)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0;break}this.authState.state==="waitingForScheduledRefetch"&&(clearTimeout(this.authState.refetchTokenTimeoutId),this.syncState.markAuthCompletion()),this.authState=e}decodeToken(e){try{return c7(e)}catch(n){return this._logVerbose(`Error decoding token: ${n instanceof Error?n.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}const oke=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function lke(t,e){const n={sessionId:e};typeof performance>"u"||!performance.mark||performance.mark(t,{detail:n})}function cke(t){let e=t.name.slice(6);return e=e.charAt(0).toLowerCase()+e.slice(1),{name:e,startTime:t.startTime}}function uke(t){if(typeof performance>"u"||!performance.getEntriesByName)return[];const e=[];for(const n of oke){const r=performance.getEntriesByName(n).filter(s=>s.entryType==="mark").filter(s=>s.detail.sessionId===t);e.push(...r)}return e.map(cke)}var dke=Object.defineProperty,fke=(t,e,n)=>e in t?dke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fr=(t,e,n)=>fke(t,typeof e!="symbol"?e+"":e,n);class hke{constructor(e,n,r){if(fr(this,"address"),fr(this,"state"),fr(this,"requestManager"),fr(this,"webSocketManager"),fr(this,"authenticationManager"),fr(this,"remoteQuerySet"),fr(this,"optimisticQueryResults"),fr(this,"_transitionHandlerCounter",0),fr(this,"_nextRequestId"),fr(this,"_onTransitionFns",new Map),fr(this,"_sessionId"),fr(this,"firstMessageReceived",!1),fr(this,"debug"),fr(this,"logger"),fr(this,"maxObservedTimestamp"),fr(this,"connectionStateSubscribers",new Map),fr(this,"nextConnectionStateSubscriberId",0),fr(this,"_lastPublishedConnectionState"),fr(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const v=this.connectionState();if(JSON.stringify(v)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=v;for(const b of this.connectionStateSubscribers.values())b(v)}})}),fr(this,"mark",v=>{this.debug&&lke(v,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");r?.skipConvexDeploymentUrlCheck!==!0&&l1e(e),r={...r};const s=r.authRefreshTokenLeewaySeconds??2;let i=r.webSocketConstructor;if(!i&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");i=i||WebSocket,this.debug=r.reportDebugInfoToConvex??!1,this.address=e,this.logger=r.logger===!1?a7({verbose:r.verbose??!1}):r.logger!==!0&&r.logger?r.logger:i7({verbose:r.verbose??!1});const a=e.search("://");if(a===-1)throw new Error("Provided address was not an absolute URL.");const l=e.substring(a+3),u=e.substring(0,a);let d;if(u==="http")d="ws";else if(u==="https")d="wss";else throw new Error(`Unknown parent protocol ${u}`);const p=`${d}://${l}/api/${I4}/sync`;this.state=new T1e,this.remoteQuerySet=new z4(v=>this.state.queryPath(v),this.logger),this.requestManager=new N1e(this.logger,this.markConnectionStateDirty);const h=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new ake(this.state,{authenticate:v=>{const b=this.state.setAuth(v);return this.webSocketManager.sendMessage(b),b.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:h,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:s}),this.optimisticQueryResults=new D1e,this.addOnTransitionHandler(v=>{n(v.queries.map(b=>b.token))}),this._nextRequestId=0,this._sessionId=Z1e();const{unsavedChangesWarning:g}=r;if(typeof window>"u"||typeof window.addEventListener>"u"){if(g===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else g!==!1&&window.addEventListener("beforeunload",v=>{if(this.requestManager.hasIncompleteRequests()){v.preventDefault();const b="Are you sure you want to leave? Your changes may not be saved.";return(v||window.event).returnValue=b,b}});this.webSocketManager=new J1e(p,{onOpen:v=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...v,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp});const b=new Set(this.remoteQuerySet.remoteQueryResults().keys());this.remoteQuerySet=new z4(S=>this.state.queryPath(S),this.logger);const[x,E]=this.state.restart(b);E&&this.webSocketManager.sendMessage(E),this.webSocketManager.sendMessage(x);for(const S of this.requestManager.restart())this.webSocketManager.sendMessage(S)},onResume:()=>{const[v,b]=this.state.resume();b&&this.webSocketManager.sendMessage(b),v&&this.webSocketManager.sendMessage(v);for(const x of this.requestManager.resume())this.webSocketManager.sendMessage(x)},onMessage:v=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),v.type){case"Transition":{this.observedTimestamp(v.endVersion.ts),this.authenticationManager.onTransition(v),this.remoteQuerySet.transition(v),this.state.transition(v);const b=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(b);break}case"MutationResponse":{v.success&&this.observedTimestamp(v.ts);const b=this.requestManager.onResponse(v);b!==null&&this.notifyOnQueryResultChanges(new Map([[b.requestId,b.result]]));break}case"ActionResponse":{this.requestManager.onResponse(v);break}case"AuthError":{this.authenticationManager.onAuthError(v);break}case"FatalError":{const b=S1e(this.logger,v.error);throw this.webSocketManager.terminate(),b}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:r.onServerDisconnectError},i,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),r.expectAuth&&h()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()||this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const n=this.remoteQuerySet.remoteQueryResults(),r=new Map;for(const[i,a]of n){const l=this.state.queryToken(i);if(l!==null){const u={result:a,udfPath:this.state.queryPath(i),args:this.state.queryArgs(i)};r.set(l,u)}}const s=this.optimisticQueryResults.ingestQueryResultsFromServer(r,new Set(e.keys()));this.handleTransition({queries:s.map(i=>{const a=this.optimisticQueryResults.rawQueryResult(i);return{token:i,modification:{kind:"Updated",result:a.result}}}),reflectedMutations:Array.from(e).map(([i,a])=>({requestId:i,result:a})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const n of this._onTransitionFns.values())n(e)}addOnTransitionHandler(e){const n=this._transitionHandlerCounter++;return this._onTransitionFns.set(n,e),()=>this._onTransitionFns.delete(n)}getCurrentAuthClaims(){const e=this.state.getAuth();let n={};if(e&&e.tokenType==="User")try{n=e?c7(e.value):{}}catch{n={}}else return;return{token:e.value,decoded:n}}setAuth(e,n){this.authenticationManager.setConfig(e,n)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,n){const r=this.state.setAdminAuth(e,n);this.webSocketManager.sendMessage(r)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,n,r){const s=So(n),{modification:i,queryToken:a,unsubscribe:l}=this.state.subscribe(e,s,r?.journal,r?.componentPath);return i!==null&&this.webSocketManager.sendMessage(i),{queryToken:a,unsubscribe:()=>{const u=l();u&&this.webSocketManager.sendMessage(u)}}}localQueryResult(e,n){const r=So(n),s=iu(e,r);return this.optimisticQueryResults.queryResult(s)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,n){const r=So(n),s=iu(e,r);return this.optimisticQueryResults.queryLogs(s)}queryJournal(e,n){const r=So(n),s=iu(e,r);return this.state.queryJournal(s)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const n=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(n,e),()=>{this.connectionStateSubscribers.delete(n)}}async mutation(e,n,r){const s=await this.mutationInternal(e,n,r);if(!s.success)throw s.errorData!==void 0?TC(s,new kC(Xd("mutation",e,s))):new Error(Xd("mutation",e,s));return s.value}async mutationInternal(e,n,r,s){const{mutationPromise:i}=this.enqueueMutation(e,n,r,s);return i}enqueueMutation(e,n,r,s){const i=So(n);this.tryReportLongDisconnect();const a=this.nextRequestId;if(this._nextRequestId++,r!==void 0){const p=r.optimisticUpdate;if(p!==void 0){const h=b=>{p(b,i)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},v=this.optimisticQueryResults.applyOptimisticUpdate(h,a).map(b=>{const x=this.localQueryResultByToken(b);return{token:b,modification:{kind:"Updated",result:x===void 0?void 0:{success:!0,value:x,logLines:[]}}}});this.handleTransition({queries:v,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const l={type:"Mutation",requestId:a,udfPath:e,componentPath:s,args:[Ql(i)]},u=this.webSocketManager.sendMessage(l),d=this.requestManager.request(l,u);return{requestId:a,mutationPromise:d}}async action(e,n){const r=await this.actionInternal(e,n);if(!r.success)throw r.errorData!==void 0?TC(r,new kC(Xd("action",e,r))):new Error(Xd("action",e,r));return r.value}async actionInternal(e,n,r){const s=So(n),i=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const a={type:"Action",requestId:i,udfPath:e,componentPath:r,args:[Ql(s)]},l=this.webSocketManager.sendMessage(a);return this.requestManager.request(a,l)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=uke(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=60*1e3)return;const n=`${this.address}/api/debug_event`;fetch(n,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${I4}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(r=>{r.ok||this.logger.warn("Analytics request failed with response:",r.body)}).catch(r=>{this.logger.warn("Analytics response failed with error:",r)})}}function pke({getCurrentValue:t,subscribe:e}){const[n,r]=w.useState(()=>({getCurrentValue:t,subscribe:e,value:t()}));let s=n.value;return(n.getCurrentValue!==t||n.subscribe!==e)&&(s=t(),r({getCurrentValue:t,subscribe:e,value:s})),w.useEffect(()=>{let i=!1;const a=()=>{i||r(u=>{if(u.getCurrentValue!==t||u.subscribe!==e)return u;const d=t();return u.value===d?u:{...u,value:d}})},l=e(a);return a(),()=>{i=!0,l()}},[t,e]),s}var mke=Object.defineProperty,gke=(t,e,n)=>e in t?mke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_l=(t,e,n)=>gke(t,typeof e!="symbol"?e+"":e,n);const vke=5e3;if(typeof Ee>"u")throw new Error("Required dependency 'react' not found");function u7(t,e,n){function r(s){return Ske(s),e.mutation(t,s,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(i){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${Ps(t)}`);return u7(t,e,i)},r}function yke(t,e){return function(n){return e.action(t,n)}}class bke{constructor(e,n){if(_l(this,"address"),_l(this,"cachedSync"),_l(this,"listeners"),_l(this,"options"),_l(this,"closed",!1),_l(this,"_logger"),_l(this,"adminAuth"),_l(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=n?.logger===!1?a7({verbose:n?.verbose??!1}):n?.logger!==!0&&n?.logger?n.logger:i7({verbose:n?.verbose??!1}),this.options={...n,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=new hke(this.address,e=>this.transition(e),this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedSync)}setAuth(e,n){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,n??(()=>{}))}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,n){if(this.adminAuth=e,this.fakeUserIdentity=n,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,n)}watchQuery(e,...n){const[r,s]=n,i=Ps(e);return{onUpdate:a=>{const{queryToken:l,unsubscribe:u}=this.sync.subscribe(i,r,s),d=this.listeners.get(l);return d!==void 0?d.add(a):this.listeners.set(l,new Set([a])),()=>{if(this.closed)return;const p=this.listeners.get(l);p.delete(a),p.size===0&&this.listeners.delete(l),u()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(i,r)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(i,r)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(i,r)}}}prewarmQuery(e){const n=e.extendSubscriptionFor??vke,s=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(s,n)}mutation(e,...n){const[r,s]=n,i=Ps(e);return this.sync.mutation(i,r,s)}action(e,...n){const r=Ps(e);return this.sync.action(r,...n)}query(e,...n){const r=this.watchQuery(e,...n),s=r.localQueryResult();return s!==void 0?Promise.resolve(s):new Promise((i,a)=>{const l=r.onUpdate(()=>{l();try{i(r.localQueryResult())}catch(u){a(u)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}transition(e){for(const n of e){const r=this.listeners.get(n);if(r)for(const s of r)s()}}}const G0=Ee.createContext(void 0);function xke(){return w.useContext(G0)}const _ke=({client:t,children:e})=>Ee.createElement(G0.Provider,{value:t},e);function Sx(t,...e){const n=e[0]==="skip",r=e[0]==="skip"?{}:So(e[0]),s=typeof t=="string"?rj(t):t,i=Ps(s),a=w.useMemo(()=>n?{}:{query:{query:s,args:r}},[JSON.stringify(Ql(r)),i,n]),u=Cke(a).query;if(u instanceof Error)throw u;return u}function d7(t){const e=typeof t=="string"?rj(t):t,n=w.useContext(G0);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return w.useMemo(()=>u7(e,n),[n,Ps(e)])}function wke(t){const e=w.useContext(G0),n=rj(t);if(e===void 0)throw new Error("Could not find Convex client! `useAction` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return w.useMemo(()=>yke(n,e),[e,Ps(n)])}function Ske(t){if(typeof t=="object"&&t!==null&&"bubbles"in t&&"persist"in t&&"isDefaultPrevented"in t)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var Eke=Object.defineProperty,kke=(t,e,n)=>e in t?Eke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$1=(t,e,n)=>kke(t,typeof e!="symbol"?e+"":e,n);class Tke{constructor(e){$1(this,"createWatch"),$1(this,"queries"),$1(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const n of Object.keys(e)){const{query:r,args:s}=e[n];if(Ps(r),this.queries[n]===void 0)this.addQuery(n,r,s);else{const i=this.queries[n];(Ps(r)!==Ps(i.query)||JSON.stringify(Ql(s))!==JSON.stringify(Ql(i.args)))&&(this.removeQuery(n),this.addQuery(n,r,s))}}for(const n of Object.keys(this.queries))e[n]===void 0&&this.removeQuery(n)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const n={};for(const r of Object.keys(e)){const{query:s,args:i}=e[r];Ps(s);const a=this.createWatch(s,i);let l;try{l=a.localQueryResult()}catch(u){if(u instanceof Error)l=u;else throw u}n[r]=l}return n}setCreateWatch(e){this.createWatch=e;for(const n of Object.keys(this.queries)){const{query:r,args:s,watch:i}=this.queries[n],a=i.journal();this.removeQuery(n),this.addQuery(n,r,s,a)}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,n,r,s){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const i=this.createWatch(n,r,s),a=i.onUpdate(()=>this.notifyListeners());this.queries[e]={query:n,args:r,watch:i,unsubscribe:a}}removeQuery(e){const n=this.queries[e];if(n===void 0)throw new Error(`No query found with identifier ${e}.`);n.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}}function Cke(t){const e=xke();if(e===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");const n=w.useMemo(()=>(r,s,i)=>e.watchQuery(r,s,i?{journal:i}:{}),[e]);return Ake(t,n)}function Ake(t,e){const[n]=w.useState(()=>new Tke(e));n.createWatch!==e&&n.setCreateWatch(e),w.useEffect(()=>()=>n.destroy(),[n]);const r=w.useMemo(()=>({getCurrentValue:()=>n.getLocalResults(t),subscribe:s=>(n.setQueries(t),n.subscribe(s))}),[n,t]);return pke(r)}const f7=w.createContext(void 0);function Xa(){const t=w.useContext(f7);if(t===void 0)throw new Error("Could not find `ConvexProviderWithAuth` (or `ConvexProviderWithClerk` or `ConvexProviderWithAuth0`) as an ancestor component. This component may be missing, or you might have two instances of the `convex/react` module loaded in your project.");return t}function Nke({children:t,client:e,useAuth:n}){const{isLoading:r,isAuthenticated:s,fetchAccessToken:i}=n(),[a,l]=w.useState(null);return r&&a!==null&&l(null),!r&&!s&&a!==!1&&l(!1),Ee.createElement(f7.Provider,{value:{isLoading:a===null,isAuthenticated:s&&(a??!1)}},Ee.createElement(Rke,{authProviderAuthenticated:s,fetchAccessToken:i,authProviderLoading:r,client:e,setIsConvexAuthenticated:l}),Ee.createElement(_ke,{client:e},t),Ee.createElement(jke,{authProviderAuthenticated:s,fetchAccessToken:i,authProviderLoading:r,client:e,setIsConvexAuthenticated:l}))}function Rke({authProviderAuthenticated:t,fetchAccessToken:e,authProviderLoading:n,client:r,setIsConvexAuthenticated:s}){return w.useEffect(()=>{let i=!0;if(t)return r.setAuth(e,a=>{i&&s(()=>a)}),()=>{i=!1,s(a=>a?!1:null)}},[t,e,n,r,s]),null}function jke({authProviderAuthenticated:t,fetchAccessToken:e,authProviderLoading:n,client:r,setIsConvexAuthenticated:s}){return w.useEffect(()=>{if(t)return()=>{r.clearAuth(),s(()=>null)}},[t,e,n,r,s]),null}const Mke=t=>{const e=new Map;return t.forEach(n=>{const r=e.get(n.provider)||[];e.set(n.provider,[...r,n])}),e},q4=t=>{switch(t){case"anthropic":return"Anthropic";case"openai":return"OpenAI";case"deepseek":return"DeepSeek";case"google":return"Google AI";case"ollama":return"Ollama";case"meta":return"Meta";case"x-ai":return"xAI";default:return t}};function h7({currentModel:t,availableModels:e,onModelChange:n,disabled:r,isLoading:s,hideProvidedModels:i=!1}){const[a,l]=w.useState(!1),u=t,{isAuthenticated:d}=Xa(),p=Mke(e),h=Array.from(p.keys()).sort(),g=i?[]:h.filter(b=>(p.get(b)||[]).some(E=>ea(E.id))),v=h.filter(b=>(p.get(b)||[]).some(E=>!ea(E.id)));return f.jsxs(p0,{open:a,onOpenChange:l,children:[f.jsx(m0,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",disabled:r||s,className:"h-8 px-2 rounded-full hover:bg-muted/80 transition-colors text-xs cursor-pointer",children:f.jsxs(f.Fragment,{children:[f.jsx(M1,{provider:u.provider}),f.jsx("span",{className:"text-[10px] font-medium",children:u.name})]})})}),f.jsxs(g0,{align:"start",className:"min-w-[200px]",children:[g.length>0&&f.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"MCPJam Provided Models"}),g.map(b=>{const E=(p.get(b)||[]).filter(k=>ea(k.id)),S=E.length;return f.jsxs(fI,{children:[f.jsxs(hI,{className:"flex items-center gap-3 text-sm cursor-pointer",children:[f.jsx(M1,{provider:b}),f.jsxs("div",{className:"flex flex-col flex-1",children:[f.jsx("span",{className:"font-medium",children:q4(b)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," model",S!==1?"s":""]})]})]}),f.jsx(pI,{className:"min-w-[200px] max-h-[180px] overflow-y-auto",avoidCollisions:!0,collisionPadding:8,children:E.map(k=>{const T=ea(k.id),R=!!k.disabled||T&&!d,j=T&&!d?"Sign in to use MCPJam provided models":k.disabledReason,A=f.jsxs(To,{onSelect:()=>{n(k),l(!1)},className:"flex items-center gap-3 text-sm cursor-pointer",disabled:R,children:[f.jsx("div",{className:"flex flex-col flex-1",children:f.jsx("span",{className:"font-medium",children:k.name})}),k.id===t.id&&f.jsx("div",{className:"ml-auto w-2 h-2 bg-primary rounded-full"})]},k.id);return R?f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx("div",{className:"pointer-events-auto",children:A})}),f.jsx(Pa,{side:"right",children:j})]},k.id):A})})]},b)}),g.length>0&&v.length>0&&f.jsx("div",{className:"my-1 h-px bg-muted/50"}),v.length>0&&f.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"Your providers"}),v.map(b=>{const E=(p.get(b)||[]).filter(k=>!ea(k.id)),S=E.length;return f.jsxs(fI,{children:[f.jsxs(hI,{className:"flex items-center gap-3 text-sm cursor-pointer",children:[f.jsx(M1,{provider:b}),f.jsxs("div",{className:"flex flex-col flex-1",children:[f.jsx("span",{className:"font-medium",children:q4(b)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," model",S!==1?"s":""]})]})]}),f.jsx(pI,{className:"min-w-[200px] max-h-[180px] overflow-y-auto",avoidCollisions:!0,collisionPadding:8,children:E.map(k=>{const T=!!k.disabled,R=f.jsxs(To,{onSelect:()=>{n(k),l(!1)},className:"flex items-center gap-3 text-sm cursor-pointer",disabled:T,children:[f.jsx("div",{className:"flex flex-col flex-1",children:f.jsx("span",{className:"font-medium",children:k.name})}),k.id===t.id&&f.jsx("div",{className:"ml-auto w-2 h-2 bg-primary rounded-full"})]},k.id);return T?f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx("div",{className:"pointer-events-auto",children:R})}),f.jsx(Pa,{side:"right",children:k.disabledReason})]},k.id):R})})]},b)})]})]})}function Oke({className:t,defaultValue:e,value:n,min:r=0,max:s=100,...i}){const a=w.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,s],[n,e,r,s]);return f.jsxs(rre,{"data-slot":"slider",defaultValue:e,value:n,min:r,max:s,className:Me("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",t),...i,children:[f.jsx(sre,{"data-slot":"slider-track",className:Me("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:f.jsx(ire,{"data-slot":"slider-range",className:Me("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:a.length},(l,u)=>f.jsx(are,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},u))]})}function Pke({systemPrompt:t,onSystemPromptChange:e,temperature:n,onTemperatureChange:r,disabled:s,isLoading:i}){const[a,l]=w.useState(!1),[u,d]=w.useState(t),[p,h]=w.useState(n),g=x=>{l(x),x&&(d(t),h(n))},v=()=>{e(u),r(p),l(!1),It.success("System prompt and temperature updated")},b=()=>{d(t),h(n),l(!1)};return f.jsxs(aa,{open:a,onOpenChange:g,children:[f.jsx(eN,{asChild:!0,children:f.jsxs(Ie,{variant:"ghost",size:"sm",disabled:s||i,className:"h-8 px-2 rounded-full hover:bg-muted/80 transition-colors text-xs cursor-pointer",children:[f.jsx(lie,{className:"h-2 w-2 mr-1"}),f.jsx("span",{className:"text-[10px] font-medium",children:"System Prompt & Temperature"})]})}),f.jsxs(oa,{className:"sm:max-w-md",children:[f.jsx(la,{children:f.jsx(ca,{children:"System Prompt & Temperature"})}),f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-sm font-medium",children:"System Prompt"}),f.jsx(Ho,{value:u,onChange:x=>d(x.target.value),placeholder:"You are a helpful assistant with access to MCP tools.",className:"h-[140px] resize-none"})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("label",{className:"text-sm font-medium",children:"Temperature"}),f.jsx("span",{className:"text-sm text-muted-foreground",children:p.toFixed(1)})]}),f.jsx(Oke,{value:[p],onValueChange:x=>h(x[0]),min:0,max:2,step:.1,className:"w-full"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Lower values (0-0.3) for focused tasks, higher values (0.7-2.0) for creative tasks"})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ie,{variant:"ghost",onClick:b,className:"cursor-pointer",children:"Cancel"}),f.jsx(Ie,{onClick:v,className:"cursor-pointer",children:"Save"})]})]})]})]})}function V4({value:t,onChange:e,onSubmit:n,onStop:r,disabled:s=!1,isLoading:i=!1,placeholder:a="Type your message...",className:l,showScrollToBottom:u=!1,onScrollToBottom:d,currentModel:p,availableModels:h,onModelChange:g,systemPrompt:v,onSystemPromptChange:b,temperature:x,onTemperatureChange:E,isSendBlocked:S=!1}){const k=w.useRef(null),T=w.useRef(null),[R,j]=w.useState([]),[A,N]=w.useState([]),M=p;w.useEffect(()=>{I()},[t]);const I=()=>{k.current&&(k.current.style.height="auto",k.current.style.height=`${Math.min(k.current.scrollHeight,120)}px`)},O=()=>{k.current&&(k.current.style.height="auto")},L=w.useCallback(()=>{!t.trim()||s||i||A.length>0||S||(n(t.trim(),R.length>0?R:void 0),e(""),j([]),O(),setTimeout(()=>{k.current?.focus()},0))},[t,s,i,A.length,n,R,e,S]),z=X=>{X.key==="Enter"&&!X.shiftKey&&!X.nativeEvent.isComposing&&(X.preventDefault(),L())},G=w.useCallback(async X=>{const F=Array.from(X.target.files||[]);if(F.length!==0){N(F.map(Y=>Y.name));try{const Y=await Promise.all(F.map(async H=>(await new Promise(te=>setTimeout(te,1e3)),{id:Math.random().toString(36).substr(2,9),name:H.name,url:URL.createObjectURL(H),contentType:H.type,size:H.size})));j(H=>[...H,...Y])}catch(Y){console.error("Error uploading files:",Y)}finally{N([]),T.current&&(T.current.value="")}}},[]),W=X=>{j(F=>F.filter(Y=>Y.id!==X))};return f.jsxs("div",{className:"relative w-full",children:[f.jsx(hx,{children:u&&f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"absolute left-1/2 bottom-full mb-4 -translate-x-1/2 z-50",children:f.jsx(Ie,{size:"sm",variant:"outline",className:"rounded-full shadow-lg cursor-pointer",onClick:d,children:f.jsx(Bre,{className:"h-4 w-4"})})})}),f.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:G,accept:"image/*,.pdf,.txt,.json,.csv"}),(R.length>0||A.length>0)&&f.jsxs("div",{className:"mb-3 flex flex-wrap gap-2",children:[R.map(X=>f.jsxs("div",{className:"flex items-center gap-2 bg-muted px-3 py-2 rounded-lg text-sm",children:[f.jsx("span",{className:"truncate max-w-[200px]",children:X.name}),f.jsx("button",{onClick:()=>W(X.id),className:"text-muted-foreground hover:text-foreground cursor-pointer",children:"×"})]},X.id)),A.map(X=>f.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 px-3 py-2 rounded-lg text-sm animate-pulse",children:[f.jsx("span",{className:"truncate max-w-[200px]",children:X}),f.jsx("div",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"})]},X))]}),f.jsxs("div",{className:"relative",children:[f.jsx(Ho,{ref:k,value:t,onChange:X=>{S||e(X.target.value)},onKeyDown:z,placeholder:a,disabled:s,readOnly:s||S,className:kT("min-h-[56px] max-h-[120px] resize-none pl-16 pr-14 py-4 rounded-3xl","border-border/30 bg-background/50 focus-visible:border-border/50","focus-visible:ring-0 focus-visible:ring-offset-0","transition-all duration-200 ease-in-out overflow-y-auto","text-base placeholder:text-muted-foreground/60",S?"cursor-not-allowed bg-muted/30 text-muted-foreground":"",l),rows:1,autoFocus:!S}),f.jsx("div",{className:"absolute bottom-3 left-4 flex items-center gap-1",children:f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-full hover:bg-muted/80 transition-colors cursor-pointer",onClick:()=>T.current?.click(),disabled:s||i||S,children:f.jsx(Xse,{size:16})})}),f.jsx(Pa,{children:"Add files"})]})}),f.jsx("div",{className:"absolute bottom-3 right-4 flex items-center gap-1",children:i?f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",size:"sm",variant:"outline",className:"h-8 w-8 p-0 rounded-full border-border/30 hover:border-border/50 transition-colors cursor-pointer",onClick:r,children:f.jsx(yie,{size:16})})}),f.jsx(Pa,{children:"Stop generating"})]}):f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",size:"sm",className:kT("h-8 w-8 p-0 rounded-full transition-all duration-200 cursor-pointer",t.trim()&&!s&&A.length===0&&!S?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground cursor-not-allowed"),onClick:L,disabled:!t.trim()||s||A.length>0||S,children:f.jsx(hB,{size:16})})}),f.jsx(Pa,{children:"Send message"})]})})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[h.length>0&&M&&f.jsx(h7,{currentModel:M,availableModels:h,onModelChange:g,disabled:!1,isLoading:i}),b&&E&&f.jsx(Pke,{systemPrompt:v||"You are a helpful assistant with access to MCP tools.",onSystemPromptChange:b,temperature:x||0,onTemperatureChange:E,disabled:s,isLoading:i})]})]})}function Ike({serverConfigs:t,connectedServerConfigs:e,systemPrompt:n=""}){const r=w.useRef(null),[s,i]=w.useState(!0),{isAuthenticated:a}=Xa(),{signUp:l}=da(),u=ua(),[d,p]=w.useState(n||"You are a helpful assistant with access to MCP tools."),[h,g]=w.useState(1),[v,b]=w.useState({}),E=Object.keys(t||{}).filter(ae=>e?.[ae]?.connectionStatus==="connected"),S=E.length===0,{messages:k,isLoading:T,error:R,input:j,setInput:A,sendMessage:N,stopGeneration:M,regenerateMessage:I,clearChat:O,model:L,availableModels:z,setModel:G,elicitationRequest:W,elicitationLoading:X,handleElicitationResponse:F}=fV({systemPrompt:d,temperature:h,selectedServers:E,onError:ae=>{It.error(ae)}}),H=(L?ea(L.id):!1)&&!a,te="Sign in to use MCPJam provided models";w.useEffect(()=>{H&&A("")},[H,A]),w.useEffect(()=>{const ae=localStorage.getItem("chat-selected-model");if(ae&&z.length>0){const B=z.find(J=>J.id===ae);B&&(!L||L.id!==ae)&&G(B)}},[z]),w.useEffect(()=>{L&&localStorage.setItem("chat-selected-model",L.id)},[L]),w.useEffect(()=>{L&&g(Ede(L))},[L]),w.useEffect(()=>{const ae=async()=>{const B={};for(const J of E)try{const oe=await AN(J);oe.toolsMetadata&&Object.assign(B,oe.toolsMetadata)}catch(oe){console.error(`Failed to fetch tools for server ${J}:`,oe)}b(B)};E&&E.length>0?ae():b({})},[JSON.stringify(E)]);const P=k.length>0,re=H||S,ue=H?"Sign in to use free chat":"Connect an MCP server to send your first message",D=[{label:"Available tools",value:"What tools are available?",icon:yB}];w.useEffect(()=>{s&&r.current&&(r.current.scrollTop=r.current.scrollHeight)},[k,s]);const Z=()=>{if(!r.current)return;const{scrollTop:ae,scrollHeight:B,clientHeight:J}=r.current,fe=B-ae-J<100;i(fe)},he=ae=>{navigator.clipboard.writeText(ae)},V=async(ae,B)=>{try{const oe=await(await fetch("/api/mcp/tools/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolName:ae,parameters:B,...E.length===1?{serverId:E[0]}:{}})})).json();return console.log("handleCallTool",oe),oe.result}catch(J){throw console.error("handleCallTool",J),J}},U=ae=>{A(ae),N(ae)},K=(ae,B)=>f.jsxs("div",{className:"flex flex-col h-screen",children:[f.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4",children:[f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.35},className:"w-full max-w-xl space-y-6 text-center",children:ae}),f.jsxs(ei.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.35,delay:.05},className:"w-full max-w-2xl pt-10",children:[f.jsx(V4,{value:j,onChange:A,onSubmit:()=>{u.capture("send_message",{location:"chat_tab",platform:Ni(),environment:void 0,model_id:L?.id??null,model_name:L?.name??null,model_provider:L?.provider??null}),N(j)},onStop:M,disabled:z.length===0||B.disabled,isLoading:T,placeholder:B.placeholder,className:"border shadow-sm",currentModel:L||null,availableModels:z,onModelChange:G,onClearChat:O,hasMessages:!1,systemPrompt:d,onSystemPromptChange:p,temperature:h,onTemperatureChange:g,isSendBlocked:H}),z.length===0&&f.jsx(ei.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:"mt-3 text-center text-xs text-muted-foreground",children:"Configure API keys in Settings or start Ollama to enable chat"})]})]}),f.jsx(ST,{elicitationRequest:W,onResponse:F,loading:X})]});if(!P&&re)return K(H?f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("h2",{className:"text-base font-medium",children:"Create an account to use free models"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"or bring your own API key in the settings tab"})]}),f.jsx("div",{className:"flex justify-center gap-2",children:f.jsx(Ie,{onClick:()=>{u.capture("create_account",{location:"chat_tab",platform:Ni(),environment:void 0}),l()},style:{backgroundColor:"#E55A3A"},className:"hover:opacity-90 cursor-pointer",children:"Create account"})})]}):f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"space-y-1",children:f.jsx("h2",{className:"text-base font-medium",children:"You must connect to an MCP server"})}),f.jsxs("div",{className:"flex justify-center gap-2 text-xs text-muted-foreground",children:[f.jsxs("a",{href:"#servers",className:"inline-flex items-center gap-1 rounded-full border px-3 py-1 transition hover:bg-muted/30",children:[f.jsx(ise,{className:"h-3 w-3"})," Add server"]}),f.jsxs("a",{href:"#settings",className:"inline-flex items-center gap-1 rounded-full border px-3 py-1 transition hover:bg-muted/30",children:[f.jsx(ZA,{className:"h-3 w-3"})," Settings"]})]})]}),{placeholder:ue,disabled:!0});if(!P){const ae=f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("h2",{className:"text-base font-medium",children:"Test your servers"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Start typing or choose a quick suggestion to begin."})]}),f.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:D.map(({label:B,value:J,icon:oe})=>f.jsxs("button",{type:"button",onClick:()=>A(J),className:"inline-flex items-center gap-2 rounded-full border border-border/60 px-3 py-1.5 text-xs transition hover:border-border hover:bg-muted/40 cursor-pointer",children:[f.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"}),B]},B))})]});return K(ae,{placeholder:"Send a message...",disabled:!1})}return f.jsx(h0,{children:f.jsxs("div",{className:"relative bg-background h-screen overflow-hidden",children:[f.jsx("div",{ref:r,onScroll:Z,className:"h-full overflow-y-auto pb-40",children:f.jsx("div",{className:"max-w-4xl mx-auto px-4 pt-8 pb-8",children:f.jsxs(hx,{mode:"popLayout",children:[k.map((ae,B)=>f.jsx(ei.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,delay:B*.05},className:"mb-8",children:f.jsx(t1e,{message:ae,model:L||null,isLoading:T&&B===k.length-1,onEdit:()=>{},onRegenerate:I,onCopy:he,showActions:!0,serverConfigs:t,onCallTool:V,onSendFollowup:U,toolsMetadata:v,serverId:E.length===1?E[0]:void 0})},ae.id)),T&&k.length>0&&k[k.length-1].role==="user"&&f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"mb-8",children:f.jsxs("div",{className:"flex gap-4 items-start",children:[f.jsx("div",{className:"w-8 h-8 flex items-center rounded-full justify-center bg-muted/50 shrink-0",children:f.jsx(gB,{className:"h-4 w-4 text-muted-foreground"})}),f.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:"Thinking"}),f.jsxs("div",{className:"flex space-x-1",children:[f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce delay-100"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce delay-200"})]})]})]})})]})})}),f.jsx(hx,{children:R&&f.jsx(ei.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"absolute bottom-40 left-0 right-0 px-4 py-3 bg-destructive/5 border-t border-destructive/10 z-10",children:f.jsx("div",{className:"max-w-4xl mx-auto",children:f.jsx("p",{className:"text-sm text-destructive",children:R})})})}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t border-border/50 bg-background/80 backdrop-blur-sm",children:f.jsx("div",{className:"max-w-4xl mx-auto p-4",children:f.jsx("div",{children:f.jsx(V4,{value:j,onChange:A,onSubmit:(ae,B)=>{u.capture("send_message",{location:"chat_tab",platform:Ni(),environment:void 0,model_id:L?.id??null,model_name:L?.name??null,model_provider:L?.provider??null}),N(ae,B)},onStop:M,disabled:z.length===0||S||H,isLoading:T,placeholder:H?te:"Send a message...",className:"border-2 shadow-sm",currentModel:L,availableModels:z,onModelChange:G,onClearChat:O,hasMessages:P,systemPrompt:d,onSystemPromptChange:p,temperature:h,onTemperatureChange:g,isSendBlocked:H})})})}),f.jsx(ST,{elicitationRequest:W,onResponse:F,loading:X})]})})}function p7(t,e,n){const r=n.reduce((i,a)=>(a.status==="pending"||a.status==="running"||a.result==="pending"?i.pending+=1:a.result==="passed"?i.passed+=1:a.result==="failed"?i.failed+=1:a.result==="cancelled"&&(i.cancelled+=1),i.tokens+=a.tokensUsed||0,i),{passed:0,failed:0,cancelled:0,pending:0,tokens:0}),s=new Map;for(const i of n){const a=i.testCaseId;if(!a)continue;if(!s.has(a)){const u=e.find(p=>p._id===a),d=n.filter(p=>p.testCaseId===a).length;s.set(a,{testCaseId:a,title:u?.title||"Untitled",provider:u?.provider||"",model:u?.model||"",runs:d,passed:0,failed:0,cancelled:0,tokens:0})}const l=s.get(a);i.status==="pending"||i.status==="running"||i.result==="pending"||(i.result==="passed"?l.passed+=1:i.result==="failed"?l.failed+=1:i.result==="cancelled"&&(l.cancelled+=1)),l.tokens+=i.tokensUsed||0}return{filteredIterations:n,totals:r,byCase:Array.from(s.values())}}function Dke(t,e,n,r){const s=[];return t>0&&s.push(`${t} passed`),e>0&&s.push(`${e} failed`),n>0&&s.push(`${n} cancelled`),r>0&&s.push(`${r} pending`),s.join(" · ")||"No results"}function Lke({suite:t,onSelectSuite:e}){const{isAuthenticated:n}=Xa(),{user:r}=da(),s=t.config?.environment.servers,a=Sx("evals:getAllTestCasesAndIterationsBySuite",n&&!!r?{suiteId:t._id}:"skip"),l=w.useMemo(()=>a?p7(t,a.testCases,a.iterations):null,[t,a]),u=Array.isArray(t.config?.tests)?t.config.tests.length:0,d=w.useMemo(()=>{if(!Array.isArray(s))return[];const g=s.filter(b=>typeof b=="string").map(b=>b.trim()).filter(Boolean);if(g.length<=2)return g;const v=g.length-2;return[...g.slice(0,2),`+${v} more`]},[s]),p=l?.filteredIterations.length??0,h=()=>{if(!l)return"bg-zinc-300/50";const{passed:g,failed:v,cancelled:b,pending:x}=l.totals;if(g+v+b+x===0)return"bg-zinc-300/50";const S=g+v;if(S===0)return"bg-zinc-300/50";const k=v/S*100;return k===0?"bg-emerald-500/50":k<=30?"bg-amber-500/50":"bg-red-500/50"};return f.jsxs("button",{onClick:()=>e(t._id),className:"group relative flex w-full items-center gap-4 py-3 pl-4 pr-4 text-left transition-colors hover:bg-muted/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 cursor-pointer",children:[f.jsx("div",{className:`absolute left-0 top-0 h-full w-1 ${h()}`}),f.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] items-center gap-4",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"text-sm font-medium text-foreground",children:new Date(t._creationTime||0).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}),f.jsx("div",{className:"text-xs text-muted-foreground",children:d.length>0?d.join(", "):"No servers"})]}),f.jsxs("div",{className:"text-sm text-muted-foreground",children:[u," test",u!==1?"s":""," · ",p," ","iteration",p!==1?"s":""]}),f.jsx("div",{className:"text-sm text-muted-foreground",children:l?Dke(l.totals.passed,l.totals.failed,l.totals.cancelled,l.totals.pending):"Loading..."})]})]})}function $ke({suites:t,onSelectSuite:e}){if(t.length===0)return f.jsx("div",{className:"h-[calc(100vh-220px)] flex items-center justify-center rounded-xl border border-dashed",children:f.jsxs("div",{className:"text-center space-y-2",children:[f.jsx("div",{className:"text-lg font-semibold",children:"No evaluation suites yet"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Trigger a test run to see your evaluation history here."})]})});const n=[...t].sort((r,s)=>(s._creationTime||0)-(r._creationTime||0));return f.jsx("div",{className:"space-y-4",children:f.jsxs("div",{className:"overflow-hidden rounded-xl border",children:[f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] items-center gap-4 border-b bg-muted/50 px-4 py-2 text-xs font-semibold text-muted-foreground",children:[f.jsx("div",{children:"Created"}),f.jsx("div",{children:"Tests"}),f.jsx("div",{children:"Results"})]}),f.jsx("div",{className:"divide-y",children:n.map(r=>f.jsx(Lke,{suite:r,onSelectSuite:e},r._id))})]})})}function zke({iteration:t,testCase:e}){const n=wke("evals:getEvalTestBlob"),[r,s]=w.useState(null),[i,a]=w.useState(!1),[l,u]=w.useState(null);return w.useEffect(()=>{let d=!1;async function p(){if(!t.blob){s(null),a(!1),u(null);return}a(!0),u(null);try{const h=await n({blobId:t.blob});d||s(h)}catch(h){d||(u(h?.message||"Failed to load blob"),console.error("Blob load error:",h))}finally{d||a(!1)}}return p(),()=>{d=!0}},[t.blob,n]),f.jsxs("div",{className:"space-y-3 py-2",children:[(e?.expectedToolCalls.length||0)>0&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("div",{className:"text-xs font-semibold",children:"Expected tools"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:e?.expectedToolCalls.map((d,p)=>f.jsx(vr,{variant:"outline",className:"font-mono text-xs",children:d},p))})]}),t.actualToolCalls.length>0&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("div",{className:"text-xs font-semibold",children:"Actual tools called"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.actualToolCalls.map((d,p)=>f.jsx(vr,{variant:"outline",className:"font-mono text-xs",children:d},p))})]}),t.blob&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("div",{className:"text-xs font-semibold",children:"Trace"}),f.jsx("div",{className:"rounded-md bg-muted/20 p-3",children:i?f.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading trace"}):l?f.jsx("div",{className:"text-xs text-red-600",children:l}):f.jsx("pre",{className:"max-h-[360px] overflow-auto whitespace-pre-wrap break-words text-xs",children:JSON.stringify(r,null,2)})})]})]})}function Fke({suite:t,cases:e,iterations:n,aggregate:r,onBack:s}){const[i,a]=w.useState(null),[l,u]=w.useState(new Set),d=w.useMemo(()=>{const h=new Map,g=x=>{const E={runs:x.length,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null};let S=0,k=0;return x.forEach(T=>{T.result==="passed"?E.passed+=1:T.result==="failed"?E.failed+=1:T.result==="cancelled"?E.cancelled+=1:E.pending+=1,E.tokens+=T.tokensUsed||0;const R=T.startedAt??T.createdAt,j=T.updatedAt??T.createdAt;if(R&&j){const A=Math.max(j-R,0);S+=A,k+=1}}),k>0&&(E.avgDuration=S/k),E};e.forEach(x=>{h.set(x._id,{testCase:x,iterations:[],summary:{runs:0,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null}})});const v={testCase:null,iterations:[],summary:{runs:0,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null}};n.forEach(x=>{const E=x.testCaseId?h.get(x.testCaseId):void 0;E?E.iterations.push(x):v.iterations.push(x)});const b=e.map(x=>{const E=h.get(x._id),S=[...E.iterations].sort((k,T)=>k.iterationNumber!=null&&T.iterationNumber!=null?k.iterationNumber-T.iterationNumber:(k.createdAt??0)-(T.createdAt??0));return{...E,iterations:S,summary:g(S)}});if(v.iterations.length>0){const x=[...v.iterations].sort((E,S)=>E.iterationNumber!=null&&S.iterationNumber!=null?E.iterationNumber-S.iterationNumber:(E.createdAt??0)-(S.createdAt??0));b.push({...v,iterations:x,summary:g(x)})}return b},[e,n]),p=h=>h==="passed"?"bg-emerald-500/50":h==="failed"?"bg-red-500/50":h==="cancelled"?"bg-zinc-300/50":"bg-amber-500/50";return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{children:f.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,children:"← Back to suites"})}),f.jsx("div",{className:"space-y-4",children:d.map((h,g)=>{const{testCase:v,iterations:b}=h,x=b.length>0,E=v?._id??`unassigned-${g}`,S=l.has(E),k=100,T=v?.query&&v.query.length>k,R=T&&!S?v.query.slice(0,k)+"...":v?.query,j=()=>{u(A=>{const N=new Set(A);return N.has(E)?N.delete(E):N.add(E),N})};return f.jsxs("div",{className:"overflow-hidden rounded-xl border",children:[f.jsx("div",{className:"border-b bg-muted/50 px-4 py-2.5",children:f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-semibold pr-2",children:v?v.title:"Unassigned iterations"}),v?.provider?f.jsx(f.Fragment,{children:f.jsx("span",{className:"text-xs text-muted-foreground",children:v.provider})}):null,v?.model?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground",children:"•"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:v.model})]}):null]}),v?.query?f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsxs("p",{className:"text-xs text-muted-foreground italic flex-1",children:['"',R,'"']}),T?f.jsx("button",{onClick:j,className:"text-xs text-primary hover:underline focus:outline-none whitespace-nowrap",children:S?"Show less":"Show more"}):null]}):null]})}),x?f.jsx("div",{className:"divide-y",children:b.map(A=>{const N=i===A._id,M=A.startedAt??A.createdAt,I=A.updatedAt??A.createdAt,O=M&&I?Math.max(I-M,0):null,L=A.result==="pending";return f.jsxs("div",{className:`relative ${L?"opacity-60":""}`,children:[f.jsx("div",{className:`absolute left-0 top-0 h-full w-1 ${p(A.result)}`}),f.jsx("button",{onClick:()=>{L||a(z=>z===A._id?null:A._id)},disabled:L,className:`flex w-full items-center gap-4 px-4 py-3 text-left transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${L?"cursor-not-allowed":"cursor-pointer hover:bg-muted/50"}`,children:f.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-[auto_1fr_auto_auto] items-center gap-4 pl-3",children:[f.jsx("div",{className:"text-muted-foreground",children:L?f.jsx(Ba,{className:"h-4 w-4"}):N?f.jsx(Au,{className:"h-4 w-4"}):f.jsx(Ba,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-sm font-medium",children:["Iteration #",A.iterationNumber]}),L?f.jsx(mu,{className:"h-4 w-4 animate-spin text-amber-600"}):null]}),f.jsx("div",{className:"text-sm text-muted-foreground",children:L?"—":`${Number(A.tokensUsed||0).toLocaleString()} tokens`}),f.jsx("div",{className:"text-sm text-muted-foreground",children:L?"—":O!==null?Uke(O):"—"})]})}),N&&!L?f.jsx("div",{className:"border-t bg-muted/20 px-4 pb-4 pt-3 pl-8",children:f.jsx(zke,{iteration:A,testCase:v})}):null]},A._id)})}):f.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No iterations recorded for this test case yet."})]},E)})})]})}function Uke(t){if(t<1e3)return`${t}ms`;const e=Math.round(t/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60),r=e%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;const s=Math.floor(n/60),i=n%60;return i?`${s}h ${i}m`:`${s}h`}function Bke(){const{isAuthenticated:t,isLoading:e}=Xa(),{user:n}=da(),[r,s]=w.useState(null),i=t&&!!n,a=Sx("evals:getCurrentUserEvalTestSuitesWithMetadata",i?{}:"skip"),l=t&&!!n&&!!r,u=Sx("evals:getAllTestCasesAndIterationsBySuite",l?{suiteId:r}:"skip"),d=a?.testSuites,p=a===void 0,h=l&&u===void 0,g=w.useMemo(()=>!r||!d?null:d.find(x=>x._id===r)??null,[r,d]),v=w.useMemo(()=>u?[...u.iterations].sort((x,E)=>(E.startedAt||E.createdAt)-(x.startedAt||x.createdAt)):[],[u]),b=w.useMemo(()=>!g||!u?null:p7(g,u.testCases,u.iterations),[g,u]);return e?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})})}):!t||!n?f.jsx("div",{className:"p-6",children:f.jsx(th,{icon:mB,title:"Sign in to view your evals",description:"Create an account or sign in to see previous runs and metrics.",className:"h-[calc(100vh-200px)]"})}):p&&i?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading your eval data..."})]})})}):f.jsxs("div",{className:"space-y-6 p-6",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsx("h1",{className:"text-2xl font-semibold",children:"Evaluation results"})}),g?h?f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading suite details..."})]})}):f.jsx(Fke,{suite:g,cases:u?.testCases||[],iterations:v,aggregate:b,onBack:()=>s(null)}):f.jsx($ke,{suites:d||[],onSelectSuite:s})]})}const qke="modulepreload",Vke=function(t){return"/"+t},H4={},Hke=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){let d=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};var a=d;document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=l?.nonce||l?.getAttribute("nonce");s=d(n.map(p=>{if(p=Vke(p),p in H4)return;H4[p]=!0;const h=p.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const v=document.createElement("link");if(v.rel=h?"stylesheet":qke,h||(v.as="script"),v.crossOrigin="",v.href=p,u&&v.setAttribute("nonce",u),document.head.appendChild(v),h)return new Promise((b,x)=>{v.addEventListener("load",b),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return s.then(l=>{for(const u of l||[])u.status==="rejected"&&i(u.reason);return e().catch(i)})},CC={servers:{},selectedServer:"none",selectedMultipleServers:[],isMultiSelectMode:!1},Ep=(t,e,n={})=>({...t,connectionStatus:e,...n});function Gke(t,e){switch(e.type){case"HYDRATE_STATE":return e.payload;case"UPSERT_SERVER":return{...t,servers:{...t.servers,[e.name]:e.server}};case"CONNECT_REQUEST":{const n=t.servers[e.name],r=n?Ep(n,"connecting",{enabled:!0}):{name:e.name,config:e.config,lastConnectionTime:new Date,connectionStatus:"connecting",retryCount:0,enabled:!0};return{...t,servers:{...t.servers,[e.name]:{...r,config:e.config}},selectedServer:e.select?e.name:t.selectedServer}}case"CONNECT_SUCCESS":{const n=t.servers[e.name];return n?{...t,servers:{...t.servers,[e.name]:Ep(n,"connected",{config:e.config,lastConnectionTime:new Date,retryCount:0,lastError:void 0,oauthTokens:e.tokens??n.oauthTokens,enabled:!0})}}:t}case"CONNECT_FAILURE":{const n=t.servers[e.name];return n?{...t,servers:{...t.servers,[e.name]:Ep(n,"failed",{retryCount:n.retryCount,lastError:e.error})}}:t}case"RECONNECT_REQUEST":{const n=t.servers[e.name];return n?{...t,servers:{...t.servers,[e.name]:Ep(n,"connecting",{enabled:!0})}}:t}case"DISCONNECT":{const n=t.servers[e.name];if(!n)return t;const r=t.selectedServer===e.name?"none":t.selectedServer;return{...t,servers:{...t.servers,[e.name]:Ep(n,"disconnected",{enabled:!1,lastError:e.error??n.lastError})},selectedServer:r,selectedMultipleServers:t.selectedMultipleServers.filter(s=>s!==e.name)}}case"REMOVE_SERVER":{const{[e.name]:n,...r}=t.servers;return{...t,servers:r,selectedServer:t.selectedServer===e.name?"none":t.selectedServer,selectedMultipleServers:t.selectedMultipleServers.filter(s=>s!==e.name)}}case"SYNC_AGENT_STATUS":{const n=new Map(e.servers.map(s=>[s.id,s.status])),r={};for(const[s,i]of Object.entries(t.servers)){if(i.connectionStatus==="connecting"||i.connectionStatus==="oauth-flow"){r[s]=i;continue}const l=n.get(s);l?r[s]={...i,connectionStatus:l}:r[s]={...i,connectionStatus:"disconnected"}}return{...t,servers:r}}case"SELECT_SERVER":return{...t,selectedServer:e.name};case"SET_MULTI_SELECTED":return{...t,selectedMultipleServers:e.names};case"SET_MULTI_MODE":return{...t,isMultiSelectMode:e.enabled,selectedMultipleServers:e.enabled?[]:t.selectedMultipleServers};default:return t}}const m7="mcp-inspector-state";function Wke(t){const e=t.config;let n=e;if(e&&typeof e.url=="string")try{n={...e,url:new URL(e.url)}}catch{}return{...t,config:n,connectionStatus:t.connectionStatus||"disconnected",retryCount:t.retryCount||0,lastConnectionTime:t.lastConnectionTime?new Date(t.lastConnectionTime):new Date,enabled:t.enabled!==!1}}function Yke(){try{const t=localStorage.getItem(m7);if(!t)return CC;const e=JSON.parse(t);return{servers:Object.fromEntries(Object.entries(e.servers||{}).map(([r,s])=>[r,Wke(s)])),selectedServer:e.selectedServer||"none",selectedMultipleServers:e.selectedMultipleServers||[],isMultiSelectMode:e.isMultiSelectMode||!1}}catch{return CC}}function Kke(t){const e={...t,servers:Object.fromEntries(Object.entries(t.servers).map(([n,r])=>{const s=r.config,i=s&&s.url instanceof URL?{...s,url:s.url.toString()}:s;return[n,{...r,config:i}]}))};localStorage.setItem(m7,JSON.stringify(e))}async function Ey(t,e){return(await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:t,serverId:e})})).json()}async function Xke(t){return(await fetch(`/api/mcp/servers/${encodeURIComponent(t)}`,{method:"DELETE"})).json()}async function Qke(){return(await fetch("/api/mcp/servers")).json()}async function Jke(t,e){return(await fetch("/api/mcp/servers/reconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:t,serverConfig:e})})).json()}async function Zke(t){if(!t.oauthTokens)return{kind:"ready",serverConfig:t.config,tokens:void 0};const e=await pN(t.name);if(e.success&&e.serverConfig)return{kind:"ready",serverConfig:e.serverConfig,tokens:Ji(t.name)};const n=t.config?.url?.toString?.();if(n){Nm(t.name);const r={serverName:t.name,serverUrl:n,clientId:t.oauthTokens?.client_id,clientSecret:t.oauthTokens?.client_secret},s=await Bb(r);return s.success&&s.serverConfig?{kind:"ready",serverConfig:s.serverConfig,tokens:Ji(t.name)}:s.success&&!s.serverConfig?{kind:"redirect"}:{kind:"error",error:s.error||"OAuth init failed"}}return{kind:"error",error:"OAuth refresh failed and no URL present"}}function z1(t){return t.type==="stdio"?{command:t.command,args:t.args,env:t.env}:{url:new URL(t.url),requestInit:{headers:t.headers||{}}}}function g7(){const t=GN("Connections"),[e,n]=w.useReducer(Gke,CC),[r,s]=w.useState(!0),i=w.useRef(new Map),a=A=>{const M=(i.current.get(A)??0)+1;return i.current.set(A,M),M},l=(A,N)=>(i.current.get(A)??0)!==N;w.useEffect(()=>{try{const A=Yke();n({type:"HYDRATE_STATE",payload:A})}catch(A){t.error("Failed to load saved state",{error:A instanceof Error?A.message:"Unknown error"})}finally{s(!1)}},[t]),w.useEffect(()=>{r||Kke(e)},[e,r]);const u=A=>{if(A.type==="stdio")return!A.command||A.command.trim()===""?"Command is required for STDIO connections":null;if(!A.url||A.url.trim()==="")return"URL is required for HTTP connections";try{new URL(A.url)}catch(N){return`Invalid URL format: ${A.url} ${N}`}return null},d=w.useCallback(()=>{const A=Object.entries(e.servers).filter(([,N])=>N.connectionStatus==="connected").map(([N])=>N);n({type:"SET_MULTI_SELECTED",names:A})},[e.servers]),p=w.useCallback(async A=>{window.history.replaceState({},document.title,window.location.pathname);try{const N=await KB(A);if(N.success&&N.serverConfig&&N.serverName){const M=N.serverName;n({type:"CONNECT_REQUEST",name:M,config:N.serverConfig,select:!0});try{const I=await Ey(N.serverConfig,M);I.success?(n({type:"CONNECT_SUCCESS",name:M,config:N.serverConfig,tokens:Ji(M)}),t.info("OAuth connection successful",{serverName:M}),It.success(`OAuth connection successful! Connected to ${M}.`)):(n({type:"CONNECT_FAILURE",name:M,error:I.error||"Connection test failed after OAuth"}),t.error("OAuth connection test failed",{serverName:M,error:I.error}),It.error(`OAuth succeeded but connection test failed: ${I.error}`))}catch(I){const O=I instanceof Error?I.message:"Unknown connection error";n({type:"CONNECT_FAILURE",name:M,error:O}),t.error("OAuth connection test error",{serverName:M,error:O}),It.error(`OAuth succeeded but connection test failed: ${O}`)}}else throw new Error(N.error||"OAuth callback failed")}catch(N){const M=N instanceof Error?N.message:"Unknown error";It.error(`Error completing OAuth flow: ${M}`),t.error("OAuth callback failed",{error:M})}},[t]);w.useEffect(()=>{if(!r){const A=new URLSearchParams(window.location.search),N=A.get("code"),M=A.get("error");N?p(N):M&&(It.error(`OAuth authorization failed: ${M}`),localStorage.removeItem("mcp-oauth-pending"),window.history.replaceState({},document.title,window.location.pathname))}},[r,p]);const h=w.useCallback(async A=>{const N=u(A);if(N){It.error(N);return}const M=z1(A);n({type:"CONNECT_REQUEST",name:A.name,config:M,select:!0});const I=a(A.name);try{if(A.type==="http"&&A.useOAuth&&A.url){n({type:"UPSERT_SERVER",name:A.name,server:{name:A.name,config:M,lastConnectionTime:new Date,connectionStatus:"oauth-flow",retryCount:0,enabled:!0}});const{initiateOAuth:L}=await Hke(async()=>{const{initiateOAuth:W}=await Promise.resolve().then(()=>mle);return{initiateOAuth:W}},void 0),z={serverName:A.name,serverUrl:A.url,clientId:A.clientId,clientSecret:A.clientSecret};A.oauthScopes&&A.oauthScopes.length>0&&(z.scopes=A.oauthScopes);const G=await L(z);if(G.success){if(G.serverConfig){const W=await Ey(G.serverConfig,A.name);if(l(A.name,I))return;W.success?(n({type:"CONNECT_SUCCESS",name:A.name,config:G.serverConfig,tokens:Ji(A.name)}),It.success("Connected successfully with OAuth!")):(n({type:"CONNECT_FAILURE",name:A.name,error:W.error||"OAuth connection test failed"}),It.error(`OAuth succeeded but connection failed: ${W.error}`))}else It.success("OAuth flow initiated. You will be redirected to authorize access.");return}else{if(l(A.name,I))return;n({type:"CONNECT_FAILURE",name:A.name,error:G.error||"OAuth initialization failed"}),It.error(`OAuth initialization failed: ${G.error}`);return}}const O=await Ey(M,A.name);if(l(A.name,I))return;O.success?(n({type:"CONNECT_SUCCESS",name:A.name,config:M}),t.info("Connection successful",{serverName:A.name}),It.success("Connected successfully!")):(n({type:"CONNECT_FAILURE",name:A.name,error:O.error||"Connection test failed"}),t.error("Connection failed",{serverName:A.name,error:O.error}),It.error(`Failed to connect to ${A.name}`))}catch(O){const L=O instanceof Error?O.message:"Unknown error";if(l(A.name,I))return;n({type:"CONNECT_FAILURE",name:A.name,error:L}),t.error("Connection failed",{serverName:A.name,error:L}),It.error(`Network error: ${L}`)}},[e.servers,t]),g=w.useRef(!1);w.useEffect(()=>{!r&&!g.current&&(g.current=!0,fetch("/api/mcp-cli-config").then(A=>A.json()).then(A=>{const N=A.config;if(N){if(N.servers&&Array.isArray(N.servers)){const M=N.autoConnectServer;t.info("Processing CLI-provided MCP servers (from config file)",{serverCount:N.servers.length,autoConnectServer:M||"all",cliConfig:N}),N.servers.forEach(I=>{const O={name:I.name||"CLI Server",type:I.type==="sse"?"http":I.type||"stdio",command:I.command,args:I.args||[],url:I.url,env:I.env||{}},L=z1(O);n({type:"UPSERT_SERVER",name:O.name,server:{name:O.name,config:L,lastConnectionTime:new Date,connectionStatus:"disconnected",retryCount:0,enabled:!1}}),!M||I.name===M?(t.info("Auto-connecting to server",{serverName:I.name}),h(O)):t.info("Skipping auto-connect for server",{serverName:I.name,reason:"filtered out"})});return}if(N.command){t.info("Auto-connecting to CLI-provided MCP server",{cliConfig:N});const M={name:N.name||"CLI Server",type:"stdio",command:N.command,args:N.args||[],env:N.env||{}};h(M)}}}).catch(A=>{t.debug("Could not fetch CLI config from API",{error:A})}))},[r,h,t,e.servers]);const v=w.useCallback(async A=>{const N=e.servers[A];return N?.oauthTokens&&N.oauthTokens.access_token||null},[e.servers]),b=w.useCallback(async A=>{t.info("Disconnecting from server",{serverName:A}),n({type:"DISCONNECT",name:A});try{const N=await Xke(A);N.success||n({type:"DISCONNECT",name:A,error:N.error})}catch(N){n({type:"DISCONNECT",name:A,error:N instanceof Error?N.message:"Unknown error"})}},[]),x=w.useCallback(async A=>{t.info("Removing server",{serverName:A}),Nm(A),n({type:"REMOVE_SERVER",name:A})},[]),E=w.useCallback(async A=>{t.info("Reconnecting to server",{serverName:A});const N=e.servers[A];if(!N)throw new Error(`Server ${A} not found`);n({type:"RECONNECT_REQUEST",name:A});const M=a(A);try{const I=await Zke(N);if(I.kind==="redirect")return;if(I.kind==="error"){if(l(A,M))return;n({type:"CONNECT_FAILURE",name:A,error:I.error}),It.error(`Failed to connect: ${A}`);return}const O=await Jke(A,I.serverConfig);if(l(A,M))return;if(O.success)return n({type:"CONNECT_SUCCESS",name:A,config:I.serverConfig,tokens:I.tokens}),t.info("Reconnection successful",{serverName:A,result:O}),{success:!0};{n({type:"CONNECT_FAILURE",name:A,error:O.error||"Reconnection failed"}),t.error("Reconnection failed",{serverName:A,result:O});const L=O.error||`Failed to reconnect: ${A}`;It.error(L)}}catch(I){const O=I instanceof Error?I.message:"Unknown error";if(l(A,M))return;throw n({type:"CONNECT_FAILURE",name:A,error:O}),t.error("Reconnection failed",{serverName:A,error:O}),I}},[e.servers]);w.useEffect(()=>{if(r)return;(async()=>{try{const N=await Qke();N?.success&&N.servers&&n({type:"SYNC_AGENT_STATUS",servers:N.servers})}catch(N){t.debug("Failed to sync server status on startup",{error:N instanceof Error?N.message:"Unknown error"})}})()},[r,t]);const S=w.useCallback(A=>{n({type:"SELECT_SERVER",name:A})},[]),k=w.useCallback(A=>{n({type:"SET_MULTI_SELECTED",names:A})},[]),T=w.useCallback(A=>{n({type:"SET_MULTI_MODE",enabled:A})},[]),R=w.useCallback(A=>{const N=e.selectedMultipleServers,M=N.includes(A)?N.filter(I=>I!==A):[...N,A];n({type:"SET_MULTI_SELECTED",names:M})},[e.selectedMultipleServers]),j=w.useCallback(async(A,N)=>{const M=e.servers[A];if(M?.oauthTokens!=null&&N.useOAuth&&N.name===A&&N.type==="http"&&N.url===(M?.config).url?.toString()&&M){const L=z1(N);n({type:"CONNECT_REQUEST",name:A,config:L});try{if((await Ey(M.config,A)).success){n({type:"CONNECT_SUCCESS",name:A,config:L}),It.success("Server configuration updated successfully!");return}else console.warn("OAuth connection test failed, falling back to full reconnect")}catch(z){console.warn("OAuth connection test error, falling back to full reconnect",z)}}await b(A),await h(N),e.selectedServer===A&&N.name!==A&&S(N.name)},[e.servers,e.selectedServer,b,h]);return{appState:e,isLoading:r,connectedServerConfigs:e.servers,selectedServerEntry:e.servers[e.selectedServer],selectedMCPConfig:e.servers[e.selectedServer]?.config,selectedMCPConfigs:e.selectedMultipleServers.map(A=>e.servers[A]).filter(Boolean),selectedMCPConfigsMap:e.selectedMultipleServers.reduce((A,N)=>(e.servers[N]&&(A[N]=e.servers[N].config),A),{}),isMultiSelectMode:e.isMultiSelectMode,handleConnect:h,handleDisconnect:b,handleReconnect:E,handleUpdate:j,handleRemoveServer:x,setSelectedServer:S,setSelectedMCPConfigs:k,toggleMultiSelectMode:T,toggleServerSelection:R,getValidAccessToken:v,setSelectedMultipleServersToAllServers:d}}function eTe({server:t,selected:e,onToggle:n}){const[r,s]=w.useState(null),[i,a]=w.useState(!1),{label:l,Icon:u,iconClassName:d,indicatorColor:p}=bB(t.connectionStatus),h=_B(t.config),g=xB(t.config),v=JSON.stringify(t.config,null,2),b=()=>{n(t.name)},x=k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),b())},E=async(k,T,R)=>{k.stopPropagation();try{await navigator.clipboard.writeText(T),s(R),setTimeout(()=>s(null),2e3)}catch(j){console.error("Failed to copy text:",j)}},S=t.connectionStatus==="failed"?`${l} (${t.retryCount} retries)`:l;return f.jsxs(Fa,{role:"button",tabIndex:0,onClick:b,onKeyDown:x,className:Me("relative gap-3 p-3 border border-border/40 bg-card/40 transition-colors","hover:border-border cursor-pointer",e&&"border-primary/60 ring-2 ring-primary/30"),children:[f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{"aria-hidden":!0,className:"h-2 w-2 flex-shrink-0 rounded-full",style:{backgroundColor:p}}),f.jsx("div",{className:"min-w-0",children:f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:t.name}),f.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[f.jsx(u,{className:d}),f.jsx("span",{children:S})]})]})})]}),e&&f.jsxs(vr,{variant:"secondary",className:"h-5 px-1 text-[11px]",children:[f.jsx(Ti,{className:"mr-1 h-3 w-3"}),"Selected"]})]}),f.jsx("p",{className:"mt-0.5 text-[11px] uppercase tracking-wide text-muted-foreground",children:h}),f.jsxs("div",{className:"relative break-all rounded border border-border/30 bg-muted/30 p-1.5 font-mono text-[11px] text-muted-foreground",children:[f.jsx("div",{className:"pr-6",children:g}),f.jsx("button",{type:"button",onClick:k=>E(k,g,"command"),className:"absolute right-1 top-1 cursor-pointer p-1 text-muted-foreground/60 transition-colors hover:text-foreground",children:r==="command"?f.jsx(Ti,{className:"h-3 w-3 text-green-500"}):f.jsx(Po,{className:"h-3 w-3"})})]}),i&&f.jsxs("div",{className:"relative rounded border border-border/20 bg-muted/20 p-1.5 font-mono text-[11px] text-muted-foreground",children:[f.jsx("pre",{className:"max-h-40 overflow-auto pr-6 whitespace-pre-wrap",children:v}),f.jsx("button",{type:"button",onClick:k=>E(k,v,"config"),className:"absolute right-1 top-1 cursor-pointer p-1 text-muted-foreground/60 transition-colors hover:text-foreground",children:r==="config"?f.jsx(Ti,{className:"h-3 w-3 text-green-500"}):f.jsx(Po,{className:"h-3 w-3"})})]}),f.jsx("div",{className:"flex justify-end pt-0.5",children:f.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),a(T=>!T)},"aria-label":i?"Hide config":"Show config",className:"rounded-full border border-border/50 bg-background/70 p-1 text-muted-foreground transition-colors hover:text-foreground",children:i?f.jsx(pB,{className:"h-3 w-3"}):f.jsx(Au,{className:"h-3 w-3"})})})]})}const G4="mcp-inspector-eval-runner-preferences",wl=[{key:"servers",title:"Select Servers",description:"Choose the MCP servers to evaluate."},{key:"model",title:"Choose Model",description:"Pick the model and ensure credentials are ready."},{key:"tests",title:"Define Tests",description:"Author the scenarios you want to run or generate them with AI."},{key:"review",title:"Review & Run",description:"Confirm the configuration before launching the run."}],F1=(t,e)=>({title:"",query:"",runs:1,model:e?.id??"",provider:e?.provider??"",expectedToolCalls:[]});function tTe({availableModels:t,inline:e=!1}){const[n,r]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(!1),[u,d]=w.useState(0),[p,h]=w.useState(null),{isAuthenticated:g}=Xa(),{getAccessToken:v}=da(),{appState:b}=g7(),{getToken:x,hasToken:E}=rR(),[S,k]=w.useState([]),[T,R]=w.useState(null),[j,A]=w.useState([F1(1,null)]),N=w.useMemo(()=>Object.entries(b.servers).filter(([,B])=>B.connectionStatus==="connected"),[b.servers]),M=w.useMemo(()=>new Set(N.map(([B])=>B)),[N]);w.useEffect(()=>{if(!(typeof window>"u"))try{const B=localStorage.getItem(G4);if(!B)return;const J=JSON.parse(B);h({servers:J.servers??[],modelId:J.modelId??null})}catch(B){console.warn("Failed to load eval runner preferences",B)}},[]),w.useEffect(()=>{if(p&&p.servers?.length){const B=p.servers.filter(J=>M.has(J));B.length&&k(B)}},[p,M]),w.useEffect(()=>{if(t.length===0){R(null);return}if(p?.modelId){const B=t.find(J=>J.id===p.modelId);if(B){R(B);return}}R(B=>B&&t.some(oe=>oe.id===B.id)?B:t[0])},[t,p]),w.useEffect(()=>{if(!(typeof window>"u"))try{const B={servers:S,modelId:T?.id??null};localStorage.setItem(G4,JSON.stringify(B))}catch(B){console.warn("Failed to persist eval runner preferences",B)}},[S,T]),w.useEffect(()=>{A(B=>T?B.map((J,oe)=>J.model===T.id&&J.provider===T.provider?J:{...J,model:T.id,provider:T.provider}):B)},[T]),w.useEffect(()=>{!e&&!n&&d(0)},[e,n]);const I=T?ea(T.id):!1,O=T?.provider,L=O?E(O):!1,z=w.useMemo(()=>j.filter(B=>B.query.trim().length>0),[j]),G=w.useMemo(()=>({servers:S.length>0,model:!!T&&(I||O&&L),tests:z.length>0}),[z.length,T,I,O,L,S.length]),W=w.useMemo(()=>G.servers?G.model?G.tests?3:2:1:0,[G]),X=w.useMemo(()=>{switch(u){case 0:return G.servers;case 1:return G.model;case 2:return G.tests;case 3:return G.tests&&G.servers&&G.model;default:return!1}},[u,G]),F=B=>{k(J=>J.includes(B)?J.filter(oe=>oe!==B):[...J,B])},Y=B=>{A(J=>{const oe=J.length,fe=Array.from({length:B},(be,Ae)=>F1(oe+Ae+1,T));return[...J,...fe]})},H=()=>{Y(1)},te=B=>{A(J=>J.filter((oe,fe)=>fe!==B))},P=(B,J,oe)=>{A(fe=>{const be=[...fe];return be[B]={...be[B],[J]:oe},be})},re=async()=>{if(!g){It.error("Please sign in to generate tests");return}if(S.length===0){It.error("Please select at least one server");return}l(!0);try{const B=await v(),J=await fetch("/api/mcp/evals/generate-tests",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverIds:S,convexAuthToken:B})}),oe=await J.json();if(!J.ok)throw new Error(oe.error||"Failed to generate tests");if(oe.tests&&oe.tests.length>0){const fe=oe.tests.map((be,Ae)=>({title:be.title||`Generated test ${Ae+1}`,query:be.query||"",runs:Number(be.runs)>0?Number(be.runs):1,model:T?.id||"",provider:T?.provider||"",expectedToolCalls:Array.isArray(be.expectedToolCalls)?be.expectedToolCalls:[]}));A(fe),d(2),It.success(`Generated ${fe.length} test case(s).`)}}catch(B){console.error("Failed to generate tests:",B),It.error(B instanceof Error?B.message:"Failed to generate test cases")}finally{l(!1)}},ue=()=>{u>=wl.length-1||X&&d(B=>Math.min(B+1,wl.length-1))},D=()=>{u!==0&&d(B=>Math.max(B-1,0))},Z=async()=>{if(!g){It.error("Please sign in to run evals");return}if(S.length===0){It.error("Please select at least one server"),d(0);return}if(!T){It.error("Please select a model"),d(1);return}const B=ea(T.id),J=!B&&O?x(O):"";if(!B&&(!O||!J)){It.error(`Please configure your ${T.provider} API key in Settings`),d(1);return}if(z.length===0){It.error("Please add at least one test case with a query"),d(2);return}i(!0);try{const oe=await v(),fe=z.map(Oe=>({...Oe,model:T.id,provider:T.provider})),be=await fetch("/api/mcp/evals/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tests:fe,serverIds:S,llmConfig:{provider:T.provider,apiKey:B?"router":J||"router"},convexAuthToken:oe})}),Ae=await be.json();if(!be.ok)throw new Error(Ae.error||"Failed to start evals");It.success(Ae.message||"Evals started successfully!"),A([F1(1,T)]),d(3),e||r(!1),window.location.hash="eval-results"}catch(oe){It.error(oe instanceof Error?oe.message:"Failed to start evals")}finally{i(!1)}},he=()=>{switch(wl[u].key){case"servers":return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg pb-2",children:"Select servers to test"}),f.jsx("p",{className:"text-sm text-muted-foreground pb-2",children:"Choose at least one connected MCP server. You can evaluate multiple servers in the same run."})]})}),N.length>0?f.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2 xl:grid-cols-3",children:N.map(([B,J])=>{const oe=S.includes(B);return f.jsx(eTe,{server:J,selected:oe,onToggle:F},B)})}):f.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:[f.jsx("p",{className:"font-medium text-foreground",children:"No connected servers yet"}),f.jsx("p",{className:"mt-2",children:"Launch a server from the Servers tab to make it available here. Once connected, it will appear instantly."})]})]});case"model":return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg pb-2",children:"Choose your evaluation model"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"For example, if you want to simulate using your server with Claude Desktop, select an Anthropic model."})]})}),t.length===0?f.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:[f.jsx("p",{className:"font-medium text-foreground",children:"No models available"}),f.jsx("p",{className:"mt-2",children:"Connect a provider or enable MCPJam provided models in Settings to unlock model selection."})]}):T?f.jsxs("div",{className:"space-y-3",children:[f.jsx("div",{className:"flex items-center gap-3",children:f.jsx(h7,{currentModel:T,availableModels:t,onModelChange:R})}),!I&&!L&&O&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/5 p-3 text-sm",children:[f.jsx(Tm,{className:"mt-0.5 h-4 w-4 text-destructive"}),f.jsxs("div",{children:[f.jsxs("p",{className:"font-medium text-destructive",children:["Add your ",T.provider," API key"]}),f.jsx("p",{className:"text-muted-foreground",children:"Configure credentials in Settings to run this model. Keys are stored locally and never sent to our servers."})]})]})]}):null]});case"tests":return f.jsxs("div",{className:"space-y-6",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg pb-2",children:"Define your test cases"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Create testing scenarios that simulate how real users would use your server."})]})}),!G.servers||!G.model?f.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:[f.jsx("p",{className:"font-medium text-foreground",children:"Finish previous steps first"}),f.jsx("p",{className:"mt-2",children:"Select at least one server and choose a model to unlock test authoring. That ensures generated tests know which stack to target."})]}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2",children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Ie,{type:"button",variant:"outline",size:"lg",onClick:re,disabled:a,children:[f.jsx("span",{className:"bg-gradient-to-r from-purple-600 via-violet-600 to-indigo-600 bg-clip-text text-transparent",children:a?"Generating...":"Generate tests"}),f.jsx(yB,{className:"h-4 w-4 ml-2 fill-purple-600"})]})})}),a&&f.jsx("div",{className:"flex items-center justify-center rounded-lg border p-6",children:f.jsx("div",{className:"text-center text-sm text-muted-foreground",children:"Generating test cases..."})}),!a&&f.jsxs("div",{className:"space-y-12",children:[j.map((B,J)=>f.jsxs("div",{className:"space-y-3 rounded-lg border bg-background p-4",children:[f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Title"}),f.jsx(Un,{className:"w-full",value:B.title,onChange:oe=>P(J,"title",oe.target.value),placeholder:"(Paypal) List transactions"})]}),j.length>1&&f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>te(J),children:f.jsx(Nu,{className:"h-4 w-4"})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Query"}),f.jsx(Ho,{value:B.query,onChange:oe=>P(J,"query",oe.target.value),placeholder:"Can you find the most recent Paypal transactions, then create an invoice?",rows:3})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Runs"}),f.jsx(Un,{type:"number",min:1,value:B.runs,onChange:oe=>P(J,"runs",Number(oe.target.value)>0?Number(oe.target.value):1)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Expected tools (comma separated)"}),f.jsx(Un,{value:B.expectedToolCalls.join(", "),onChange:oe=>P(J,"expectedToolCalls",oe.target.value.split(",").map(fe=>fe.trim()).filter(Boolean)),placeholder:"paypal_list_transactions, paypal_create_invoice"})]})]})]},J)),f.jsxs(Ie,{type:"button",variant:"outline",onClick:H,"aria-label":"Add test",className:"w-full",children:[f.jsx(Ab,{className:"h-4 w-4 mr-2"}),"Add test case"]})]})]})]});case"review":return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h3",{className:"text-lg",children:"Review your tests"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"After confirming the run, you will see your run begin in the eval results tab."})]}),f.jsxs("div",{className:"space-y-4 rounded-lg border bg-background p-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Servers"}),f.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:S.map(B=>f.jsx(vr,{variant:"outline",children:B},B))})]}),f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(0),children:"Edit"})]}),f.jsx(Ck,{}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Model"}),T?f.jsx("div",{className:"mt-2 flex items-center gap-2",children:f.jsx(vr,{variant:"outline",children:T.name})}):f.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"No model selected"})]}),f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(1),children:"Edit"})]}),f.jsx(Ck,{}),f.jsxs("div",{className:"flex items-start justify-between gap-6",children:[f.jsxs("div",{className:"flex-1",children:[f.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Tests"}),f.jsx("div",{className:"mt-3 space-y-3",children:z.map((B,J)=>f.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[f.jsx("p",{className:"text-sm font-semibold text-foreground",children:B.title}),f.jsx("p",{className:"mt-1 line-clamp-2 text-sm text-muted-foreground",children:B.query}),f.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[f.jsxs("span",{children:[B.runs," run",B.runs===1?"":"s"]}),B.expectedToolCalls.length>0&&f.jsxs("span",{children:["Tools: ",B.expectedToolCalls.join(", ")]})]})]},J))})]}),f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(2),children:"Edit"})]})]})]});default:return null}},V=f.jsx("ol",{className:"flex flex-col items-center gap-4 text-center md:flex-row md:gap-6",children:wl.map((B,J)=>{const oe=u===J,fe=J<u&&J<=W,be=J<=Math.max(W,u);return f.jsx("li",{className:"flex flex-col items-center gap-2",children:f.jsxs("button",{type:"button",onClick:()=>be?d(J):void 0,disabled:!be,className:Me("flex flex-col items-center gap-2 transition",!be&&"cursor-not-allowed opacity-60"),children:[f.jsx("span",{className:Me("flex h-8 w-8 items-center justify-center rounded-full border text-sm font-medium",fe&&"border-primary bg-primary text-primary-foreground",oe&&!fe&&"border-primary bg-primary/10 text-primary",!oe&&!fe&&"border-border text-muted-foreground"),children:J+1}),f.jsx("span",{className:Me("text-xs leading-tight",oe?"text-foreground":"text-muted-foreground"),children:B.title})]})},B.key)})}),U=u<wl.length-1?!X:s||!X,K=U?"secondary":"default",ae=f.jsxs("div",{className:Me("mx-auto flex w-full flex-col gap-8 pb-10 pt-4",e?"max-w-none px-4 sm:px-6 md:px-12 lg:px-32":"max-w-3xl px-4"),children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.jsxs(Ie,{type:"button",variant:"outline",onClick:D,disabled:u===0,"aria-label":"Back",className:"justify-center gap-2",children:[f.jsx(Kre,{className:"h-4 w-4"}),"Back"]}),f.jsx("div",{className:"flex flex-1 justify-center",children:f.jsx("div",{className:"max-w-xl",children:V})}),f.jsxs(Ie,{type:"button",variant:K,onClick:()=>{u<wl.length-1?ue():Z()},disabled:U,"aria-label":u===wl.length-1?"Start":"Next",className:Me("justify-center gap-2",!U&&"shadow-sm"),children:[u===wl.length-1?"Start":"Next",f.jsx(Ba,{className:"h-4 w-4"})]})]}),f.jsx("div",{className:"space-y-6",children:he()})]});return e?ae:f.jsxs(aa,{open:n,onOpenChange:r,children:[f.jsx(eN,{asChild:!0,children:f.jsxs(Ie,{children:[f.jsx(Ab,{className:"mr-2 h-4 w-4"}),"New eval run"]})}),f.jsxs(oa,{className:"max-h-[80vh] w-full max-w-4xl overflow-y-auto sm:max-w-4xl",children:[f.jsxs(la,{className:"mx-auto w-full max-w-3xl gap-1 text-left",children:[f.jsx(ca,{children:"Create eval run"}),f.jsx(Jf,{children:"Follow the guided steps to configure your evaluation and run it with confidence."})]}),ae]})]})}function nTe(){const{isAuthenticated:t,isLoading:e}=Xa(),{user:n}=da(),{availableModels:r}=fV({systemPrompt:"",temperature:1,selectedServers:[]});return e?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})})}):!t||!n?f.jsx("div",{className:"p-6",children:f.jsx(th,{icon:mB,title:"Sign in to run evals",description:"Create an account or sign in to generate and launch evaluation runs.",className:"h-[calc(100vh-200px)]"})}):f.jsxs("div",{className:"space-y-6 p-6",children:[f.jsx("div",{className:"space-y-2",children:f.jsx("h1",{className:"text-2xl font-semibold",children:"Evaluation runner"})}),f.jsx("div",{className:"w-full",children:f.jsx(tTe,{availableModels:r,inline:!0})})]})}function rTe({config:t,isConfigured:e,onEdit:n,onDelete:r}){const s=t.description?.trim();return f.jsxs(Fa,{className:Me("group h-full gap-4 border bg-card px-6 py-6 transition-all hover:border-primary/40 hover:shadow-md dark:hover:shadow-xl",e?"border-green-200/80 dark:border-green-400/30":"border-border/60"),children:[f.jsxs("div",{className:"flex items-start justify-between gap-6",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("img",{src:t.logo,alt:t.logoAlt,className:"size-6 object-contain"}),f.jsxs("div",{className:"",children:[f.jsxs("h3",{className:"text-md font-semibold text-foreground pb-1",children:[t.name," ",e&&f.jsx("span",{className:"text-md",children:"✔️"})]}),s?f.jsx("p",{className:"line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:s}):null]})]}),e?f.jsxs(p0,{children:[f.jsx(m0,{asChild:!0,children:f.jsx(Ie,{size:"icon",variant:"ghost",className:"size-8 rounded-md border border-transparent hover:bg-muted/50",children:f.jsx(bse,{className:"size-4"})})}),f.jsx(g0,{align:"end",className:"w-44",children:f.jsx(To,{variant:"destructive",onClick:()=>r(t.id),children:"Remove provider"})})]}):null]}),f.jsx("div",{className:"space-y-4",children:f.jsx(Ie,{size:"sm",variant:e?"outline":"secondary",className:"w-full",onClick:()=>n(t.id),children:e?"Manage":"Configure"})})]})}function sTe({baseUrl:t,onEdit:e}){const n=!!t;return f.jsxs(Fa,{className:Me("group h-full gap-4 border bg-card px-6 py-6 transition-all hover:border-primary/40 hover:shadow-md dark:hover:shadow-xl",n?"border-green-200/80 dark:border-green-400/30":"border-border/60"),children:[f.jsx("div",{className:"flex items-start justify-between gap-6",children:f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("img",{src:"/ollama_logo.svg",alt:"Ollama",className:"size-6 object-contain"}),f.jsxs("div",{className:"",children:[f.jsxs("h3",{className:"text-md font-semibold text-foreground pb-1",children:["Ollama ",n&&f.jsx("span",{className:"text-md",children:"✔️"})]}),f.jsx("p",{className:"line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:n?"Local models available":"Install and connect Ollama locally"})]})]})}),f.jsx("div",{className:"space-y-4",children:f.jsx(Ie,{size:"sm",variant:n?"outline":"secondary",className:"w-full",onClick:e,children:n?"Manage":"Configure"})})]})}function iTe({providerConfigs:t,hasToken:e,onEditProvider:n,onDeleteProvider:r,ollamaBaseUrl:s,onEditOllama:i}){return f.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[t.map(a=>{const l=e(a.id);return f.jsx(rTe,{config:a,isConfigured:l,onEdit:n,onDelete:r},a.id)}),f.jsx(sTe,{baseUrl:s,onEdit:i})]})}function aTe({open:t,onOpenChange:e,provider:n,value:r,onValueChange:s,onSave:i,onCancel:a}){const l=ua();return f.jsx(aa,{open:t,onOpenChange:e,children:f.jsxs(oa,{className:"max-w-md",children:[f.jsx(la,{children:f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[n&&f.jsx("div",{className:"w-12 h-12 rounded-lg bg-white p-2 border",children:f.jsx("img",{src:n.logo,alt:n.logoAlt,className:"w-full h-full object-contain"})}),f.jsxs("div",{children:[f.jsxs(ca,{className:"text-left",children:["Configure ",n?.name]}),f.jsx(Jf,{className:"text-left",children:n?.description})]})]})}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{htmlFor:"api-key",className:"text-sm font-medium",children:"API Key"}),f.jsx(Un,{id:"api-key",type:"password",value:r,onChange:u=>s(u.target.value),placeholder:n?.placeholder,className:"mt-1"})]}),f.jsxs("div",{className:"flex items-center gap-2 p-3 bg-blue-50 dark:bg-blue-950/20 rounded-lg",children:[f.jsx(JA,{className:"w-4 h-4 text-blue-600"}),f.jsxs("span",{className:"text-sm text-blue-600",children:["Need an API key?"," ",f.jsx("button",{onClick:()=>n&&window.open(n.getApiKeyUrl,"_blank"),className:"underline hover:no-underline",children:"Get one here"})]})]})]}),f.jsxs(v0,{children:[f.jsx(Ie,{variant:"outline",onClick:a,children:"Cancel"}),f.jsx(Ie,{onClick:()=>{l.capture("save_api_key",{location:"provider_config_dialog",platform:Ni(),environment:void 0}),i()},disabled:!r.trim(),children:"Save API Key"})]})]})})}function oTe({open:t,onOpenChange:e,value:n,onValueChange:r,onSave:s,onCancel:i}){return f.jsx(aa,{open:t,onOpenChange:e,children:f.jsxs(oa,{className:"max-w-md",children:[f.jsx(la,{children:f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"w-12 h-12 rounded-lg bg-white p-2 border",children:f.jsx("img",{src:"/ollama_logo.svg",alt:"Ollama",className:"w-full h-full object-contain"})}),f.jsxs("div",{children:[f.jsx(ca,{className:"text-left pb-2",children:"Configure Ollama URL"}),f.jsx(Jf,{className:"text-left",children:"Set the base URL for your Ollama instance"})]})]})}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{htmlFor:"ollama-url",className:"text-sm font-medium",children:"Base URL"}),f.jsx(Un,{id:"ollama-url",type:"url",value:n,onChange:a=>r(a.target.value),placeholder:"http://localhost:11434/api",className:"mt-1"})]}),f.jsxs("div",{className:"flex items-center gap-2 p-3 bg-blue-50 dark:bg-blue-950/20 rounded-lg",children:[f.jsx(JA,{className:"w-4 h-4 text-blue-600"}),f.jsxs("span",{className:"text-sm text-blue-600",children:["Need help?"," ",f.jsx("button",{onClick:()=>window.open("https://ollama.ai/download","_blank"),className:"underline hover:no-underline",children:"Download Ollama"})]})]})]}),f.jsxs(v0,{children:[f.jsx(Ie,{variant:"outline",onClick:i,children:"Cancel"}),f.jsx(Ie,{onClick:s,disabled:!n.trim(),children:"Save URL"})]})]})})}function lTe({...t}){return f.jsx(kJ,{"data-slot":"alert-dialog",...t})}function cTe({...t}){return f.jsx(TJ,{"data-slot":"alert-dialog-trigger",...t})}function uTe({...t}){return f.jsx(CJ,{"data-slot":"alert-dialog-portal",...t})}function dTe({className:t,...e}){return f.jsx(AJ,{"data-slot":"alert-dialog-overlay",className:Me("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function fTe({className:t,...e}){return f.jsxs(uTe,{children:[f.jsx(dTe,{}),f.jsx(NJ,{"data-slot":"alert-dialog-content",className:Me("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...e})]})}function hTe({className:t,...e}){return f.jsx("div",{"data-slot":"alert-dialog-header",className:Me("flex flex-col gap-2 text-center sm:text-left",t),...e})}function pTe({className:t,...e}){return f.jsx("div",{"data-slot":"alert-dialog-footer",className:Me("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function mTe({className:t,...e}){return f.jsx(MJ,{"data-slot":"alert-dialog-title",className:Me("text-lg font-semibold",t),...e})}function gTe({className:t,...e}){return f.jsx(OJ,{"data-slot":"alert-dialog-description",className:Me("text-muted-foreground text-sm",t),...e})}function vTe({className:t,...e}){return f.jsx(RJ,{className:Me(QA(),t),...e})}function yTe({className:t,...e}){return f.jsx(jJ,{className:Me(QA({variant:"outline"}),t),...e})}function xn(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function Jl(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}const v7=6048e5,bTe=864e5,y7=6e4,b7=36e5,ky=43200,W4=1440;let xTe={};function Rg(){return xTe}function Zm(t,e){const n=Rg(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=xn(t),i=s.getDay(),a=(i<r?7:0)+i-r;return s.setDate(s.getDate()-a),s.setHours(0,0,0,0),s}function Ex(t){return Zm(t,{weekStartsOn:1})}function x7(t){const e=xn(t),n=e.getFullYear(),r=Jl(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const s=Ex(r),i=Jl(t,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const a=Ex(i);return e.getTime()>=s.getTime()?n+1:e.getTime()>=a.getTime()?n:n-1}function Y4(t){const e=xn(t);return e.setHours(0,0,0,0),e}function kx(t){const e=xn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function _Te(t,e){const n=Y4(t),r=Y4(e),s=+n-kx(n),i=+r-kx(r);return Math.round((s-i)/bTe)}function wTe(t){const e=x7(t),n=Jl(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),Ex(n)}function lb(t,e){const n=xn(t),r=xn(e),s=n.getTime()-r.getTime();return s<0?-1:s>0?1:s}function STe(t){return Jl(t,Date.now())}function ETe(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function kTe(t){if(!ETe(t)&&typeof t!="number")return!1;const e=xn(t);return!isNaN(Number(e))}function TTe(t,e){const n=xn(t),r=xn(e),s=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return s*12+i}function CTe(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function ATe(t,e){return+xn(t)-+xn(e)}function NTe(t){const e=xn(t);return e.setHours(23,59,59,999),e}function RTe(t){const e=xn(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function jTe(t){const e=xn(t);return+NTe(e)==+RTe(e)}function MTe(t,e){const n=xn(t),r=xn(e),s=lb(n,r),i=Math.abs(TTe(n,r));let a;if(i<1)a=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-s*i);let l=lb(n,r)===-s;jTe(xn(t))&&i===1&&lb(t,r)===1&&(l=!1),a=s*(i-Number(l))}return a===0?0:a}function OTe(t,e,n){const r=ATe(t,e)/1e3;return CTe(n?.roundingMethod)(r)}function PTe(t){const e=xn(t),n=Jl(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}const ITe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},DTe=(t,e,n)=>{let r;const s=ITe[t];return typeof s=="string"?r=s:e===1?r=s.one:r=s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function U1(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const LTe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},$Te={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},zTe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},FTe={date:U1({formats:LTe,defaultWidth:"full"}),time:U1({formats:$Te,defaultWidth:"full"}),dateTime:U1({formats:zTe,defaultWidth:"full"})},UTe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},BTe=(t,e,n,r)=>UTe[t];function kp(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let s;if(r==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,l=n?.width?String(n.width):a;s=t.formattingValues[l]||t.formattingValues[a]}else{const a=t.defaultWidth,l=n?.width?String(n.width):t.defaultWidth;s=t.values[l]||t.values[a]}const i=t.argumentCallback?t.argumentCallback(e):e;return s[i]}}const qTe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},VTe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},HTe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},GTe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},WTe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},YTe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},KTe=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},XTe={ordinalNumber:KTe,era:kp({values:qTe,defaultWidth:"wide"}),quarter:kp({values:VTe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:kp({values:HTe,defaultWidth:"wide"}),day:kp({values:GTe,defaultWidth:"wide"}),dayPeriod:kp({values:WTe,defaultWidth:"wide",formattingValues:YTe,defaultFormattingWidth:"wide"})};function Tp(t){return(e,n={})=>{const r=n.width,s=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=e.match(s);if(!i)return null;const a=i[0],l=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],u=Array.isArray(l)?JTe(l,h=>h.test(a)):QTe(l,h=>h.test(a));let d;d=t.valueCallback?t.valueCallback(u):u,d=n.valueCallback?n.valueCallback(d):d;const p=e.slice(a.length);return{value:d,rest:p}}}function QTe(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function JTe(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function ZTe(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const s=r[0],i=e.match(t.parsePattern);if(!i)return null;let a=t.valueCallback?t.valueCallback(i[0]):i[0];a=n.valueCallback?n.valueCallback(a):a;const l=e.slice(s.length);return{value:a,rest:l}}}const eCe=/^(\d+)(th|st|nd|rd)?/i,tCe=/\d+/i,nCe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},rCe={any:[/^b/i,/^(a|c)/i]},sCe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},iCe={any:[/1/i,/2/i,/3/i,/4/i]},aCe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},oCe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},lCe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},cCe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},uCe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},dCe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},fCe={ordinalNumber:ZTe({matchPattern:eCe,parsePattern:tCe,valueCallback:t=>parseInt(t,10)}),era:Tp({matchPatterns:nCe,defaultMatchWidth:"wide",parsePatterns:rCe,defaultParseWidth:"any"}),quarter:Tp({matchPatterns:sCe,defaultMatchWidth:"wide",parsePatterns:iCe,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Tp({matchPatterns:aCe,defaultMatchWidth:"wide",parsePatterns:oCe,defaultParseWidth:"any"}),day:Tp({matchPatterns:lCe,defaultMatchWidth:"wide",parsePatterns:cCe,defaultParseWidth:"any"}),dayPeriod:Tp({matchPatterns:uCe,defaultMatchWidth:"any",parsePatterns:dCe,defaultParseWidth:"any"})},_7={code:"en-US",formatDistance:DTe,formatLong:FTe,formatRelative:BTe,localize:XTe,match:fCe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function hCe(t){const e=xn(t);return _Te(e,PTe(e))+1}function pCe(t){const e=xn(t),n=+Ex(e)-+wTe(e);return Math.round(n/v7)+1}function w7(t,e){const n=xn(t),r=n.getFullYear(),s=Rg(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,a=Jl(t,0);a.setFullYear(r+1,0,i),a.setHours(0,0,0,0);const l=Zm(a,e),u=Jl(t,0);u.setFullYear(r,0,i),u.setHours(0,0,0,0);const d=Zm(u,e);return n.getTime()>=l.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function mCe(t,e){const n=Rg(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=w7(t,e),i=Jl(t,0);return i.setFullYear(s,0,r),i.setHours(0,0,0,0),Zm(i,e)}function gCe(t,e){const n=xn(t),r=+Zm(n,e)-+mCe(n,e);return Math.round(r/v7)+1}function dn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const Sl={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return dn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):dn(n+1,2)},d(t,e){return dn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return dn(t.getHours()%12||12,e.length)},H(t,e){return dn(t.getHours(),e.length)},m(t,e){return dn(t.getMinutes(),e.length)},s(t,e){return dn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return dn(s,e.length)}},Ad={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},K4={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return Sl.y(t,e)},Y:function(t,e,n,r){const s=w7(t,r),i=s>0?s:1-s;if(e==="YY"){const a=i%100;return dn(a,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):dn(i,e.length)},R:function(t,e){const n=x7(t);return dn(n,e.length)},u:function(t,e){const n=t.getFullYear();return dn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return dn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return dn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return Sl.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return dn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const s=gCe(t,r);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):dn(s,e.length)},I:function(t,e,n){const r=pCe(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):dn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Sl.d(t,e)},D:function(t,e,n){const r=hCe(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):dn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const s=t.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return dn(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const s=t.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return dn(i,e.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),s=r===0?7:r;switch(e){case"i":return String(s);case"ii":return dn(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let s;switch(r===12?s=Ad.noon:r===0?s=Ad.midnight:s=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let s;switch(r>=17?s=Ad.evening:r>=12?s=Ad.afternoon:r>=4?s=Ad.morning:s=Ad.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Sl.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Sl.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):dn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):dn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Sl.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Sl.s(t,e)},S:function(t,e){return Sl.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return Q4(r);case"XXXX":case"XX":return qc(r);case"XXXXX":case"XXX":default:return qc(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return Q4(r);case"xxxx":case"xx":return qc(r);case"xxxxx":case"xxx":default:return qc(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+X4(r,":");case"OOOO":default:return"GMT"+qc(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+X4(r,":");case"zzzz":default:return"GMT"+qc(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return dn(r,e.length)},T:function(t,e,n){const r=t.getTime();return dn(r,e.length)}};function X4(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=Math.trunc(r/60),i=r%60;return i===0?n+String(s):n+String(s)+e+dn(i,2)}function Q4(t,e){return t%60===0?(t>0?"-":"+")+dn(Math.abs(t)/60,2):qc(t,e)}function qc(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=dn(Math.trunc(r/60),2),i=dn(r%60,2);return n+s+e+i}const J4=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},S7=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},vCe=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return J4(t,e);let i;switch(r){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",J4(r,e)).replace("{{time}}",S7(s,e))},yCe={p:S7,P:vCe},bCe=/^D+$/,xCe=/^Y+$/,_Ce=["D","DD","YY","YYYY"];function wCe(t){return bCe.test(t)}function SCe(t){return xCe.test(t)}function ECe(t,e,n){const r=kCe(t,e,n);if(console.warn(r),_Ce.includes(t))throw new RangeError(r)}function kCe(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const TCe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,CCe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ACe=/^'([^]*?)'?$/,NCe=/''/g,RCe=/[a-zA-Z]/;function E7(t,e,n){const r=Rg(),s=r.locale??_7,i=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,l=xn(t);if(!kTe(l))throw new RangeError("Invalid time value");let u=e.match(CCe).map(p=>{const h=p[0];if(h==="p"||h==="P"){const g=yCe[h];return g(p,s.formatLong)}return p}).join("").match(TCe).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const h=p[0];if(h==="'")return{isToken:!1,value:jCe(p)};if(K4[h])return{isToken:!0,value:p};if(h.match(RCe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:p}});s.localize.preprocessor&&(u=s.localize.preprocessor(l,u));const d={firstWeekContainsDate:i,weekStartsOn:a,locale:s};return u.map(p=>{if(!p.isToken)return p.value;const h=p.value;(SCe(h)||wCe(h))&&ECe(h,e,String(t));const g=K4[h[0]];return g(l,h,s.localize,d)}).join("")}function jCe(t){const e=t.match(ACe);return e?e[1].replace(NCe,"'"):t}function MCe(t,e,n){const r=Rg(),s=n?.locale??r.locale??_7,i=2520,a=lb(t,e);if(isNaN(a))throw new RangeError("Invalid time value");const l=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a});let u,d;a>0?(u=xn(e),d=xn(t)):(u=xn(t),d=xn(e));const p=OTe(d,u),h=(kx(d)-kx(u))/1e3,g=Math.round((p-h)/60);let v;if(g<2)return n?.includeSeconds?p<5?s.formatDistance("lessThanXSeconds",5,l):p<10?s.formatDistance("lessThanXSeconds",10,l):p<20?s.formatDistance("lessThanXSeconds",20,l):p<40?s.formatDistance("halfAMinute",0,l):p<60?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",1,l):g===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",g,l);if(g<45)return s.formatDistance("xMinutes",g,l);if(g<90)return s.formatDistance("aboutXHours",1,l);if(g<W4){const b=Math.round(g/60);return s.formatDistance("aboutXHours",b,l)}else{if(g<i)return s.formatDistance("xDays",1,l);if(g<ky){const b=Math.round(g/W4);return s.formatDistance("xDays",b,l)}else if(g<ky*2)return v=Math.round(g/ky),s.formatDistance("aboutXMonths",v,l)}if(v=MTe(d,u),v<12){const b=Math.round(g/ky);return s.formatDistance("xMonths",b,l)}else{const b=v%12,x=Math.trunc(v/12);return b<3?s.formatDistance("aboutXYears",x,l):b<9?s.formatDistance("overXYears",x,l):s.formatDistance("almostXYears",x+1,l)}}function OCe(t,e){return MCe(t,STe(t),e)}function PCe(t,e){const r=$Ce(t);let s;if(r.date){const u=zCe(r.date,2);s=FCe(u.restDateString,u.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const i=s.getTime();let a=0,l;if(r.time&&(a=UCe(r.time),isNaN(a)))return new Date(NaN);if(r.timezone){if(l=BCe(r.timezone),isNaN(l))return new Date(NaN)}else{const u=new Date(i+a),d=new Date(0);return d.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),d.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),d}return new Date(i+a+l)}const Ty={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ICe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,DCe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,LCe=/^([+-])(\d{2})(?::?(\d{2}))?$/;function $Ce(t){const e={},n=t.split(Ty.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],Ty.timeZoneDelimiter.test(e.date)&&(e.date=t.split(Ty.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const s=Ty.timezone.exec(r);s?(e.time=r.replace(s[1],""),e.timezone=s[1]):e.time=r}return e}function zCe(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const s=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?s:i*100,restDateString:t.slice((r[1]||r[2]).length)}}function FCe(t,e){if(e===null)return new Date(NaN);const n=t.match(ICe);if(!n)return new Date(NaN);const r=!!n[4],s=Cp(n[1]),i=Cp(n[2])-1,a=Cp(n[3]),l=Cp(n[4]),u=Cp(n[5])-1;if(r)return WCe(e,l,u)?qCe(e,l,u):new Date(NaN);{const d=new Date(0);return!HCe(e,i,a)||!GCe(e,s)?new Date(NaN):(d.setUTCFullYear(e,i,Math.max(s,a)),d)}}function Cp(t){return t?parseInt(t):1}function UCe(t){const e=t.match(DCe);if(!e)return NaN;const n=B1(e[1]),r=B1(e[2]),s=B1(e[3]);return YCe(n,r,s)?n*b7+r*y7+s*1e3:NaN}function B1(t){return t&&parseFloat(t.replace(",","."))||0}function BCe(t){if(t==="Z")return 0;const e=t.match(LCe);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;return KCe(r,s)?n*(r*b7+s*y7):NaN}function qCe(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const s=r.getUTCDay()||7,i=(e-1)*7+n+1-s;return r.setUTCDate(r.getUTCDate()+i),r}const VCe=[31,null,31,30,31,30,31,31,30,31,30,31];function k7(t){return t%400===0||t%4===0&&t%100!==0}function HCe(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(VCe[e]||(k7(t)?29:28))}function GCe(t,e){return e>=1&&e<=(k7(t)?366:365)}function WCe(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function YCe(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function KCe(t,e){return e>=0&&e<=59}function Z4({value:t,isCopied:e,onCopy:n,copyLabel:r,tooltip:s="Copy to clipboard"}){return f.jsxs("div",{className:"relative w-full",children:[f.jsx(Un,{readOnly:!0,value:t,className:"h-12 w-full rounded-lg border border-border/40 bg-background/50 font-mono text-sm tracking-wide text-foreground pr-16 shadow-sm focus-visible:border-primary focus-visible:ring-1 focus-visible:ring-primary/20",style:{fontFamily:'ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace'}}),f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",variant:"ghost",onClick:n,className:"absolute right-3 top-3 h-6 w-6 p-0 rounded-md border-0 bg-transparent text-foreground/60 hover:text-foreground hover:bg-foreground/10 transition-all duration-200",children:e?f.jsx(Ti,{className:"h-4 w-4"}):f.jsx(Po,{className:"h-4 w-4"})})}),f.jsx(Pa,{side:"bottom",children:s})]})]})}function XCe(){const[t,e]=w.useState(null),[n,r]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(!1),[u,d]=w.useState(!1),{isAuthenticated:p,isLoading:h}=Xa(),{signIn:g}=da(),v=ua(),b=Sx("apiKeys:list"),x=d7("apiKeys:regenerateAndGet"),E=async()=>{if(t)try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),2e3)}catch(R){console.error("Clipboard error",R)}},S=async()=>{if(!p)return!1;try{r(!0),i(!1);const R=await x();return e(R.apiKey),d(!0),!0}catch(R){return console.error("Failed to generate key",R),!1}finally{r(!1)}};if(h)return f.jsx("div",{className:"rounded-md border p-3 text-sm text-muted-foreground",children:"Checking authentication…"});if(!p)return f.jsxs("div",{className:"space-y-3 rounded-md border p-4",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("h3",{className:"text-lg font-semibold",children:"MCPJam API Key"})}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Sign in to view and manage your API key."}),f.jsx(Ie,{type:"button",onClick:()=>{v.capture("sign_in",{location:"account_api_key_section",platform:Ni(),environment:void 0}),g()},size:"sm",children:"Sign in"})]});const k=b&&b.length>0?b[0]:null,T=(R,j="Never")=>{if(!R)return j;const A=new Date(R),N=OCe(A,{addSuffix:!0});return`${E7(A,"PP p")} · ${N}`};return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("h3",{className:"text-lg font-semibold",children:"MCPJam API Key"})}),b===void 0?f.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading API key status…"}):t?f.jsxs("div",{className:"space-y-4",children:[f.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Copy and save this key now. You won't be able to view it again later."}),f.jsx(Z4,{value:t,isCopied:s,onCopy:E,copyLabel:"Copy key"})]}):(b?.length??0)===0?f.jsx("div",{className:"space-y-4",children:f.jsx(Ie,{type:"button",onClick:()=>{S()},disabled:n,children:n?"Generating…":"Generate API key"})}):f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs(lTe,{open:a,onOpenChange:l,children:[f.jsx(cTe,{asChild:!0,children:f.jsxs(Ie,{type:"button",variant:"outline",disabled:n,className:"inline-flex items-center gap-2.5 rounded-lg border border-border/50 bg-background px-4 py-2.5 text-sm font-medium text-foreground/80 hover:border-border hover:bg-background/80 hover:text-foreground transition-all duration-200",children:[f.jsx(ir,{className:`h-4 w-4 ${n?"animate-spin":""} text-foreground/60`}),f.jsx("span",{children:n?"Regenerating…":"Regenerate"})]})}),f.jsxs(fTe,{children:[f.jsxs(hTe,{children:[f.jsx(mTe,{className:"text-lg font-semibold",children:"Confirm"}),f.jsx(gTe,{className:"text-sm text-muted-foreground leading-relaxed",children:"Regenerating an API key will replace your previous API key."})]}),f.jsxs(pTe,{className:"gap-3",children:[f.jsx(yTe,{disabled:n,className:"font-medium",children:"Cancel"}),f.jsx(vTe,{onClick:async R=>{R.preventDefault(),await S()&&l(!1)},disabled:n,className:"font-medium",children:n?"Regenerating…":"Regenerate"})]})]})]})}),k?f.jsx("div",{className:"rounded-lg border border-border/30 bg-background/50 p-4",children:f.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground/50 uppercase tracking-wide",children:"Created"}),f.jsx("span",{className:"text-xs text-foreground/70",children:T(k.createdAt)})]}),f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground/50 uppercase tracking-wide",children:"Last Used"}),f.jsx("span",{className:"text-xs text-foreground/70",children:T(k.lastUsedAt,"Never used")})]})]})}):null]}),f.jsx(aa,{open:!!t&&u,onOpenChange:R=>{R||i(!1),d(R)},children:f.jsxs(oa,{children:[f.jsxs(la,{children:[f.jsx(ca,{children:"API Key"}),f.jsx(Jf,{children:"Copy and store this key securely. You will not be able to view it again."})]}),f.jsx(Z4,{value:t??"",isCopied:s,onCopy:E,copyLabel:"Copy"})]})})]})}function QCe(){const{tokens:t,setToken:e,clearToken:n,hasToken:r,getOllamaBaseUrl:s,setOllamaBaseUrl:i}=rR(),[a,l]=w.useState(""),[u,d]=w.useState(!1),[p,h]=w.useState(null),[g,v]=w.useState(!1),[b,x]=w.useState(""),E=[{id:"openai",name:"OpenAI",logo:"/openai_logo.png",logoAlt:"OpenAI",description:"GPT-4, GPT-4o, GPT-4o-mini, GPT-4.1, GPT-5, etc.",placeholder:"sk-...",getApiKeyUrl:"https://platform.openai.com/api-keys"},{id:"anthropic",name:"Anthropic",logo:"/claude_logo.png",logoAlt:"Claude",description:"Claude 3.5, Claude 3.7, Claude Opus 4, etc.",placeholder:"sk-ant-...",getApiKeyUrl:"https://console.anthropic.com/"},{id:"deepseek",name:"DeepSeek",logo:"/deepseek_logo.svg",logoAlt:"DeepSeek",description:"DeepSeek Chat, DeepSeek Reasoner, etc.",placeholder:"sk-...",getApiKeyUrl:"https://platform.deepseek.com/api_keys"},{id:"google",name:"Google AI",logo:"/google_logo.png",logoAlt:"Google AI",description:"Gemini 2.5, Gemini 2.5 Flash, Gemini 2.5 Flash Lite",placeholder:"AI...",getApiKeyUrl:"https://aistudio.google.com/app/apikey"}],S=M=>{const I=E.find(O=>O.id===M);I&&(h(I),l(t[M]||""),d(!0))},k=()=>{p&&(e(p.id,a),d(!1),h(null),l(""))},T=()=>{d(!1),h(null),l("")},R=M=>{n(M)},j=()=>{x(s()),v(!0)},A=()=>{i(b),v(!1),x("")},N=()=>{v(!1),x("")};return f.jsxs("div",{className:"container mx-auto p-6 max-w-6xl space-y-8",children:[f.jsx("div",{className:"flex items-center gap-3 mb-6",children:f.jsx("h1",{className:"text-2xl font-bold",children:"Settings"})}),f.jsx(XCe,{}),f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{children:f.jsx("h3",{className:"text-lg font-semibold",children:"LLM Provider API Keys"})}),f.jsx(iTe,{providerConfigs:E,hasToken:M=>r(M),onEditProvider:S,onDeleteProvider:R,ollamaBaseUrl:s(),onEditOllama:j})]}),f.jsx(aTe,{open:u,onOpenChange:d,provider:p,value:a,onValueChange:l,onSave:k,onCancel:T}),f.jsx(oTe,{open:g,onOpenChange:v,value:b,onValueChange:x,onSave:A,onCancel:N})]})}const JCe=(t,e="HH:mm:ss.SSS")=>{const n=typeof t=="string"?PCe(t):t;return E7(n,e)},ZCe={error:"bg-red-500/10 text-red-700 border-red-200 dark:text-red-400 dark:border-red-800",warn:"bg-yellow-500/10 text-yellow-700 border-yellow-200 dark:text-yellow-400 dark:border-yellow-800",info:"bg-blue-500/10 text-blue-700 border-blue-200 dark:text-blue-400 dark:border-blue-800",debug:"bg-purple-500/10 text-purple-700 border-purple-200 dark:text-purple-400 dark:border-purple-800",trace:"bg-gray-500/10 text-gray-700 border-gray-200 dark:text-gray-400 dark:border-gray-800"};function T7({level:t}){return f.jsx(vr,{variant:"outline",className:Me("font-mono",ZCe[t]),children:t.toUpperCase()})}function eAe({entry:t,isExpanded:e,onToggleExpand:n}){const r=t.data!==void 0||t.error!==void 0;return f.jsxs("div",{className:"border rounded-lg font-mono",children:[f.jsx("div",{className:`p-3 cursor-pointer hover:bg-muted/50 ${r?"":"cursor-default"}`,onClick:r?n:void 0,children:f.jsxs("div",{className:"flex items-start gap-3",children:[r&&f.jsx("div",{className:"mt-0.5",children:e?f.jsx(Au,{className:"h-4 w-4 text-muted-foreground"}):f.jsx(Ba,{className:"h-4 w-4 text-muted-foreground"})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:`[${JCe(t.timestamp)}]`}),f.jsx(T7,{level:t.level}),f.jsx(vr,{variant:"secondary",children:t.context}),f.jsx("span",{className:"flex-1 break-words",children:t.message})]})})]})}),e&&r&&f.jsxs("div",{className:"border-t bg-muted/20 p-3 space-y-3",children:[t.data!==void 0&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"DATA:"}),f.jsx("div",{className:"text-xs bg-background border rounded overflow-auto max-h-60",children:f.jsx(zl,{src:t.data,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"0",borderRadius:"0",border:"none"}})})]}),t.error&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"ERROR:"}),f.jsxs("pre",{className:"text-xs bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded p-2 overflow-auto max-h-40 text-red-700 dark:text-red-400",children:[t.error.message,t.error.stack&&`
|
|
1817
|
+
`))}function u(v,b,x,E){const S=x.enter("tableCell"),k=x.enter("phrasing"),T=x.containerPhrasing(v,{...E,before:i,after:i});return k(),S(),T}function d(v,b){return dSe(v,{align:b,alignDelimiters:r,padding:n,stringLength:s})}function p(v,b,x){const E=v.children;let S=-1;const k=[],T=b.enter("table");for(;++S<E.length;)k[S]=h(E[S],b,x);return T(),k}function h(v,b,x){const E=v.children;let S=-1;const k=[],T=b.enter("tableRow");for(;++S<E.length;)k[S]=u(E[S],v,b,x);return T(),k}function g(v,b,x){let E=F8.inlineCode(v,b,x);return x.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function JSe(){return{exit:{taskListCheckValueChecked:b4,taskListCheckValueUnchecked:b4,paragraph:eEe}}}function ZSe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tEe}}}function b4(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function eEe(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=e.children;let i=-1,a;for(;++i<s.length;){const l=s[i];if(l.type==="paragraph"){a=l;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function tEe(t,e,n,r){const s=t.children[0],i=typeof t.checked=="boolean"&&s&&s.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",l=n.createTracker(r);i&&l.move(a);let u=F8.listItem(t,e,n,{...r,...l.current()});return i&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(p){return p+a}}function nEe(){return[Pwe(),tSe(),iSe(),HSe(),JSe()]}function rEe(t){return{extensions:[Iwe(),nSe(t),aSe(),QSe(t),ZSe()]}}const sEe={tokenize:uEe,partial:!0},U8={tokenize:dEe,partial:!0},B8={tokenize:fEe,partial:!0},q8={tokenize:hEe,partial:!0},iEe={tokenize:pEe,partial:!0},V8={name:"wwwAutolink",tokenize:lEe,previous:G8},H8={name:"protocolAutolink",tokenize:cEe,previous:W8},Wo={name:"emailAutolink",tokenize:oEe,previous:Y8},Ka={};function aEe(){return{text:Ka}}let zc=48;for(;zc<123;)Ka[zc]=Wo,zc++,zc===58?zc=65:zc===91&&(zc=97);Ka[43]=Wo;Ka[45]=Wo;Ka[46]=Wo;Ka[95]=Wo;Ka[72]=[Wo,H8];Ka[104]=[Wo,H8];Ka[87]=[Wo,V8];Ka[119]=[Wo,V8];function oEe(t,e,n){const r=this;let s,i;return a;function a(h){return!wC(h)||!Y8.call(r,r.previous)||tj(r.events)?n(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),l(h))}function l(h){return wC(h)?(t.consume(h),l):h===64?(t.consume(h),u):n(h)}function u(h){return h===46?t.check(iEe,p,d)(h):h===45||h===95||rs(h)?(i=!0,t.consume(h),u):p(h)}function d(h){return t.consume(h),s=!0,u}function p(h){return i&&s&&fs(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(h)):n(h)}}function lEe(t,e,n){const r=this;return s;function s(a){return a!==87&&a!==119||!G8.call(r,r.previous)||tj(r.events)?n(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(sEe,t.attempt(U8,t.attempt(B8,i),n),n)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function cEe(t,e,n){const r=this;let s="",i=!1;return a;function a(h){return(h===72||h===104)&&W8.call(r,r.previous)&&!tj(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),t.consume(h),l):n(h)}function l(h){if(fs(h)&&s.length<5)return s+=String.fromCodePoint(h),t.consume(h),l;if(h===58){const g=s.toLowerCase();if(g==="http"||g==="https")return t.consume(h),u}return n(h)}function u(h){return h===47?(t.consume(h),i?d:(i=!0,u)):n(h)}function d(h){return h===null||gx(h)||_n(h)||Su(h)||U0(h)?n(h):t.attempt(U8,t.attempt(B8,p),n)(h)}function p(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(h)}}function uEe(t,e,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,t.consume(a),s):a===46&&r===3?(t.consume(a),i):n(a)}function i(a){return a===null?n(a):e(a)}}function dEe(t,e,n){let r,s,i;return a;function a(d){return d===46||d===95?t.check(q8,u,l)(d):d===null||_n(d)||Su(d)||d!==45&&U0(d)?u(d):(i=!0,t.consume(d),a)}function l(d){return d===95?r=!0:(s=r,r=void 0),t.consume(d),a}function u(d){return s||r||!i?n(d):e(d)}}function fEe(t,e){let n=0,r=0;return s;function s(a){return a===40?(n++,t.consume(a),s):a===41&&r<n?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(q8,e,i)(a):a===null||_n(a)||Su(a)?e(a):(t.consume(a),s)}function i(a){return a===41&&r++,t.consume(a),s}}function hEe(t,e,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(t.consume(l),r):l===38?(t.consume(l),i):l===93?(t.consume(l),s):l===60||l===null||_n(l)||Su(l)?e(l):n(l)}function s(l){return l===null||l===40||l===91||_n(l)||Su(l)?e(l):r(l)}function i(l){return fs(l)?a(l):n(l)}function a(l){return l===59?(t.consume(l),r):fs(l)?(t.consume(l),a):n(l)}}function pEe(t,e,n){return r;function r(i){return t.consume(i),s}function s(i){return rs(i)?n(i):e(i)}}function G8(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||_n(t)}function W8(t){return!fs(t)}function Y8(t){return!(t===47||wC(t))}function wC(t){return t===43||t===45||t===46||t===95||rs(t)}function tj(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const mEe={tokenize:SEe,partial:!0};function gEe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:xEe,continuation:{tokenize:_Ee},exit:wEe}},text:{91:{name:"gfmFootnoteCall",tokenize:bEe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:vEe,resolveTo:yEe}}}}function vEe(t,e,n){const r=this;let s=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const u=r.events[s][1];if(u.type==="labelImage"){a=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return l;function l(u){if(!a||!a._balanced)return n(u);const d=na(r.sliceSerialize({start:a.end,end:r.now()}));return d.codePointAt(0)!==94||!i.includes(d.slice(1))?n(u):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),e(u))}}function yEe(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",s,e],["exit",s,e],["enter",i,e],["enter",a,e],["exit",a,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...l),t}function bEe(t,e,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,a;return l;function l(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),u}function u(h){return h!==94?n(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",d)}function d(h){if(i>999||h===93&&!a||h===null||h===91||_n(h))return n(h);if(h===93){t.exit("chunkString");const g=t.exit("gfmFootnoteCallString");return s.includes(na(r.sliceSerialize(g)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(h)}return _n(h)||(a=!0),i++,t.consume(h),h===92?p:d}function p(h){return h===91||h===92||h===93?(t.consume(h),i++,d):d(h)}}function xEe(t,e,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,a=0,l;return u;function u(b){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(b){return b===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",p):n(b)}function p(b){if(a>999||b===93&&!l||b===null||b===91||_n(b))return n(b);if(b===93){t.exit("chunkString");const x=t.exit("gfmFootnoteDefinitionLabelString");return i=na(r.sliceSerialize(x)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),g}return _n(b)||(l=!0),a++,t.consume(b),b===92?h:p}function h(b){return b===91||b===92||b===93?(t.consume(b),a++,p):p(b)}function g(b){return b===58?(t.enter("definitionMarker"),t.consume(b),t.exit("definitionMarker"),s.includes(i)||s.push(i),en(t,v,"gfmFootnoteDefinitionWhitespace")):n(b)}function v(b){return e(b)}}function _Ee(t,e,n){return t.check(Ag,e,t.attempt(mEe,e,n))}function wEe(t){t.exit("gfmFootnoteDefinition")}function SEe(t,e,n){const r=this;return en(t,s,"gfmFootnoteDefinitionIndent",5);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(i):n(i)}}function EEe(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:i,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(a,l){let u=-1;for(;++u<a.length;)if(a[u][0]==="enter"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._close){let d=u;for(;d--;)if(a[d][0]==="exit"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[d][1].end.offset-a[d][1].start.offset){a[u][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[u][1].end)},h={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[u][1].start)},g=[["enter",p,l],["enter",a[d][1],l],["exit",a[d][1],l],["enter",h,l]],v=l.parser.constructs.insideSpan.null;v&&si(g,g.length,0,B0(v,a.slice(d+1,u),l)),si(g,g.length,0,[["exit",h,l],["enter",a[u][1],l],["exit",a[u][1],l],["exit",p,l]]),si(a,d-1,u-d+3,g),u=d+g.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type==="strikethroughSequenceTemporary"&&(a[u][1].type="data");return a}function i(a,l,u){const d=this.previous,p=this.events;let h=0;return g;function g(b){return d===126&&p[p.length-1][1].type!=="characterEscape"?u(b):(a.enter("strikethroughSequenceTemporary"),v(b))}function v(b){const x=jf(d);if(b===126)return h>1?u(b):(a.consume(b),h++,v);if(h<2&&!n)return u(b);const E=a.exit("strikethroughSequenceTemporary"),S=jf(b);return E._open=!S||S===2&&!!x,E._close=!x||x===2&&!!S,l(b)}}}class kEe{constructor(){this.map=[]}add(e,n,r){TEe(this,e,n,r)}consume(e){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let s=r.pop();for(;s;){for(const i of s)e.push(i);s=r.pop()}this.map.length=0}}function TEe(t,e,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<t.map.length;){if(t.map[s][0]===e){t.map[s][1]+=n,t.map[s][2].push(...r);return}s+=1}t.map.push([e,n,r])}}function CEe(t,e){let n=!1;const r=[];for(;e<t.length;){const s=t[e];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const i=r.length-1;r[i]=r[i]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function AEe(){return{flow:{null:{name:"table",tokenize:NEe,resolveAll:REe}}}}function NEe(t,e,n){const r=this;let s=0,i=0,a;return l;function l(O){let L=r.events.length-1;for(;L>-1;){const W=r.events[L][1].type;if(W==="lineEnding"||W==="linePrefix")L--;else break}const z=L>-1?r.events[L][1].type:null,G=z==="tableHead"||z==="tableRow"?A:u;return G===A&&r.parser.lazy[r.now().line]?n(O):G(O)}function u(O){return t.enter("tableHead"),t.enter("tableRow"),d(O)}function d(O){return O===124||(a=!0,i+=1),p(O)}function p(O){return O===null?n(O):ct(O)?i>1?(i=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),v):n(O):Gt(O)?en(t,p,"whitespace")(O):(i+=1,a&&(a=!1,s+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),a=!0,p):(t.enter("data"),h(O)))}function h(O){return O===null||O===124||_n(O)?(t.exit("data"),p(O)):(t.consume(O),O===92?g:h)}function g(O){return O===92||O===124?(t.consume(O),h):h(O)}function v(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(t.enter("tableDelimiterRow"),a=!1,Gt(O)?en(t,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):b(O))}function b(O){return O===45||O===58?E(O):O===124?(a=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),x):j(O)}function x(O){return Gt(O)?en(t,E,"whitespace")(O):E(O)}function E(O){return O===58?(i+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),S):O===45?(i+=1,S(O)):O===null||ct(O)?R(O):j(O)}function S(O){return O===45?(t.enter("tableDelimiterFiller"),k(O)):j(O)}function k(O){return O===45?(t.consume(O),k):O===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),T):(t.exit("tableDelimiterFiller"),T(O))}function T(O){return Gt(O)?en(t,R,"whitespace")(O):R(O)}function R(O){return O===124?b(O):O===null||ct(O)?!a||s!==i?j(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):j(O)}function j(O){return n(O)}function A(O){return t.enter("tableRow"),N(O)}function N(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),N):O===null||ct(O)?(t.exit("tableRow"),e(O)):Gt(O)?en(t,N,"whitespace")(O):(t.enter("data"),M(O))}function M(O){return O===null||O===124||_n(O)?(t.exit("data"),N(O)):(t.consume(O),O===92?I:M)}function I(O){return O===92||O===124?(t.consume(O),M):M(O)}}function REe(t,e){let n=-1,r=!0,s=0,i=[0,0,0,0],a=[0,0,0,0],l=!1,u=0,d,p,h;const g=new kEe;for(;++n<t.length;){const v=t[n],b=v[1];v[0]==="enter"?b.type==="tableHead"?(l=!1,u!==0&&(x4(g,e,u,d,p),p=void 0,u=0),d={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},g.add(n,0,[["enter",d,e]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,h=void 0,i=[0,0,0,0],a=[0,n+1,0,0],l&&(l=!1,p={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},g.add(n,0,[["enter",p,e]])),s=b.type==="tableDelimiterRow"?2:p?3:1):s&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],h=_y(g,e,i,s,void 0,h),i=[0,0,0,0]),a[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(a[0]=a[1],h=_y(g,e,i,s,void 0,h)),i=a,a=[i[1],n,0,0])):b.type==="tableHead"?(l=!0,u=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(u=n,i[1]!==0?(a[0]=a[1],h=_y(g,e,i,s,n,h)):a[1]!==0&&(h=_y(g,e,a,s,n,h)),s=0):s&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&x4(g,e,u,d,p),g.consume(e.events),n=-1;++n<e.events.length;){const v=e.events[n];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=CEe(e.events,n))}return t}function _y(t,e,n,r,s,i){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(i.end=Object.assign({},zd(e.events,n[0])),t.add(n[0],0,[["exit",i,e]]));const u=zd(e.events,n[1]);if(i={type:a,start:Object.assign({},u),end:Object.assign({},u)},t.add(n[1],0,[["enter",i,e]]),n[2]!==0){const d=zd(e.events,n[2]),p=zd(e.events,n[3]),h={type:l,start:Object.assign({},d),end:Object.assign({},p)};if(t.add(n[2],0,[["enter",h,e]]),r!==2){const g=e.events[n[2]],v=e.events[n[3]];if(g[1].end=Object.assign({},v[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,x=n[3]-n[2]-1;t.add(b,x,[])}}t.add(n[3]+1,0,[["exit",h,e]])}return s!==void 0&&(i.end=Object.assign({},zd(e.events,s)),t.add(s,0,[["exit",i,e]]),i=void 0),i}function x4(t,e,n,r,s){const i=[],a=zd(e.events,n);s&&(s.end=Object.assign({},a),i.push(["exit",s,e])),r.end=Object.assign({},a),i.push(["exit",r,e]),t.add(n+1,0,i)}function zd(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const jEe={name:"tasklistCheck",tokenize:OEe};function MEe(){return{text:{91:jEe}}}function OEe(t,e,n){const r=this;return s;function s(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(u),t.exit("taskListCheckMarker"),i)}function i(u){return _n(u)?(t.enter("taskListCheckValueUnchecked"),t.consume(u),t.exit("taskListCheckValueUnchecked"),a):u===88||u===120?(t.enter("taskListCheckValueChecked"),t.consume(u),t.exit("taskListCheckValueChecked"),a):n(u)}function a(u){return u===93?(t.enter("taskListCheckMarker"),t.consume(u),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),l):n(u)}function l(u){return ct(u)?e(u):Gt(u)?t.check({tokenize:PEe},e,n)(u):n(u)}}function PEe(t,e,n){return en(t,r,"whitespace");function r(s){return s===null?n(s):e(s)}}function IEe(t){return i8([aEe(),gEe(),EEe(t),AEe(),MEe()])}const DEe={};function LEe(t){const e=this,n=t||DEe,r=e.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(IEe(n)),i.push(nEe()),a.push(rEe(n))}function $Ee({node:t,inline:e,className:n,children:r,...s}){return e?f.jsx("code",{className:`${n} text-sm bg-zinc-100 dark:bg-zinc-800 py-0.5 px-1 rounded-md`,...s,children:r}):f.jsx("div",{className:"not-prose flex flex-col",children:f.jsx("div",{...s,className:"text-sm w-full overflow-x-auto dark:bg-zinc-900 p-4 border border-zinc-200 dark:border-zinc-700 rounded-xl dark:text-zinc-50 text-zinc-900 font-mono whitespace-pre-wrap break-words",children:r})})}const zEe={code:$Ee,pre:({children:t})=>f.jsx(f.Fragment,{children:t}),img:({src:t,alt:e,...n})=>{if(!t)return null;const[r,s]=w.useState(!1),[i,a]=w.useState(!1);return i?f.jsxs("div",{className:"my-4 p-4 bg-muted/50 rounded-lg border border-border/30 text-center text-muted-foreground",children:["Failed to load image: ",e||"Image"]}):f.jsx("div",{className:"my-4 flex justify-center",children:f.jsx("img",{src:t,alt:e||"Image",className:`max-w-full h-auto rounded-lg border border-border/30 shadow-sm cursor-pointer transition-all hover:shadow-md ${r?"max-h-none":"max-h-96"}`,loading:"lazy",onClick:()=>s(!r),onError:()=>a(!0),title:r?"Click to collapse":"Click to expand",...n})})},ol:({children:t,...e})=>f.jsx("ol",{className:"list-decimal list-outside ml-4",...e,children:t}),li:({children:t,...e})=>f.jsx("li",{className:"py-1",...e,children:t}),ul:({children:t,...e})=>f.jsx("ul",{className:"list-decimal list-outside ml-4",...e,children:t}),strong:({children:t,...e})=>f.jsx("span",{className:"font-semibold",...e,children:t}),a:({children:t,...e})=>f.jsx("a",{className:"text-blue-500 hover:underline",target:"_blank",rel:"noreferrer",...e,children:t}),h1:({children:t,...e})=>f.jsx("h1",{className:"text-3xl font-semibold mt-6 mb-2",...e,children:t}),h2:({children:t,...e})=>f.jsx("h2",{className:"text-2xl font-semibold mt-6 mb-2",...e,children:t}),h3:({children:t,...e})=>f.jsx("h3",{className:"text-xl font-semibold mt-6 mb-2",...e,children:t}),h4:({children:t,...e})=>f.jsx("h4",{className:"text-lg font-semibold mt-6 mb-2",...e,children:t}),h5:({children:t,...e})=>f.jsx("h5",{className:"text-base font-semibold mt-6 mb-2",...e,children:t}),h6:({children:t,...e})=>f.jsx("h6",{className:"text-sm font-semibold mt-6 mb-2",...e,children:t})},FEe=[LEe],UEe=({children:t})=>f.jsx(Ewe,{remarkPlugins:FEe,components:zEe,children:t}),_4=UEe;function w4({message:t,onSave:e,onCancel:n}){const[r,s]=w.useState(t.content),i=w.useRef(null);w.useEffect(()=>{i.current&&(i.current.focus(),i.current.select(),a())},[]);const a=()=>{i.current&&(i.current.style.height="auto",i.current.style.height=`${i.current.scrollHeight}px`)},l=()=>{r.trim()!==t.content.trim()?e(r.trim()):n()},u=d=>{d.key==="Enter"&&(d.metaKey||d.ctrlKey)&&(d.preventDefault(),l()),d.key==="Escape"&&(d.preventDefault(),n())};return f.jsxs("div",{className:"w-full space-y-3",children:[f.jsx(Ho,{ref:i,value:r,onChange:d=>{s(d.target.value),a()},onKeyDown:u,className:"min-h-[100px] resize-none",placeholder:"Edit your message..."}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ie,{variant:"outline",size:"sm",onClick:n,children:"Cancel"}),f.jsx(Ie,{size:"sm",onClick:l,disabled:!r.trim(),children:"Save"})]})]})}function S4({data:t,className:e}){const[n,r]=w.useState(!1),s=JSON.stringify(t,null,2),i=async()=>{try{await navigator.clipboard.writeText(s),r(!0),setTimeout(()=>r(!1),2e3)}catch(l){console.error("Failed to copy:",l)}},a=l=>l.replace(/"([^"]+)":/g,'<span class="text-blue-600/70 dark:text-blue-400/70">"$1"</span>:').replace(/: "([^"]*)"/g,': <span class="text-foreground">"$1"</span>').replace(/: (true|false)/g,': <span class="text-purple-600/70 dark:text-purple-400/70">$1</span>').replace(/: (null)/g,': <span class="text-muted-foreground/60">$1</span>').replace(/: (-?\d+(?:\.\d+)?)/g,': <span class="text-orange-600/70 dark:text-orange-400/70">$1</span>');return f.jsxs("div",{className:Me("relative group",e),children:[f.jsx("button",{onClick:i,className:"absolute top-2 right-2 p-1.5 rounded-md bg-background/80 backdrop-blur-sm border opacity-0 group-hover:opacity-100 transition-opacity hover:bg-muted",title:"Copy JSON",children:n?f.jsx(Ti,{className:"h-3 w-3 text-green-600/70 dark:text-green-400/70"}):f.jsx(Po,{className:"h-3 w-3"})}),f.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap overflow-x-auto p-3 bg-muted/20 rounded-md border",children:f.jsx("code",{dangerouslySetInnerHTML:{__html:a(s)}})})]})}function K8({data:t,depth:e=0}){const[n,r]=w.useState(e<2);if(typeof t!="object"||t===null)return f.jsx("span",{className:Me("text-sm",typeof t=="string"&&"text-foreground",typeof t=="number"&&"text-orange-600/70 dark:text-orange-400/70",typeof t=="boolean"&&"text-purple-600/70 dark:text-purple-400/70",t===null&&"text-muted-foreground/60"),children:typeof t=="string"?`"${t}"`:String(t)});const s=Array.isArray(t),i=s?t.map((u,d)=>[d,u]):Object.entries(t),a=s?"[":"{",l=s?"]":"}";return i.length===0?f.jsxs("span",{className:"text-sm text-muted-foreground",children:[a,l]}):f.jsxs("div",{className:"text-sm",children:[f.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1 hover:bg-muted/50 rounded px-1 transition-colors",children:[n?f.jsx(Au,{className:"h-3 w-3"}):f.jsx(Ba,{className:"h-3 w-3"}),f.jsxs("span",{className:"text-muted-foreground",children:[a," ",!n&&`${i.length} items`]})]}),n&&f.jsx("div",{className:"ml-4 border-l border-border pl-2 space-y-1",children:i.map(([u,d])=>f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("span",{className:"text-blue-600/70 dark:text-blue-400/70 font-medium min-w-0 flex-shrink-0",children:[s?`[${u}]`:`"${u}"`,":"]}),f.jsx("div",{className:"min-w-0 flex-1",children:f.jsx(K8,{data:d,depth:e+1})})]},u))}),n&&f.jsx("span",{className:"text-muted-foreground ml-4",children:l})]})}function E4({toolCall:t,toolResult:e,className:n,serverConfigs:r,onCallTool:s,onSendFollowup:i,toolMeta:a,serverId:l}){const[u,d]=w.useState(!1),[p,h]=w.useState(!1),v=e?e.error?"error":"completed":t.status,b=()=>{switch(v){case"completed":return f.jsxs("div",{className:"relative",children:[f.jsx(sf,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70"}),f.jsx("div",{className:"absolute inset-0 animate-ping",children:f.jsx(sf,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70 opacity-20"})})]});case"error":return f.jsxs("div",{className:"relative",children:[f.jsx(af,{className:"h-4 w-4 text-red-600/70 dark:text-red-400/70"}),f.jsx("div",{className:"absolute inset-0 animate-pulse",children:f.jsx(af,{className:"h-4 w-4 text-red-600/70 dark:text-red-400/70 opacity-30"})})]});case"executing":return f.jsxs("div",{className:"relative",children:[f.jsx(oI,{className:"h-4 w-4 text-blue-600/70 dark:text-blue-400/70 animate-spin"}),f.jsx("div",{className:"absolute inset-0 animate-ping",children:f.jsx("div",{className:"h-4 w-4 bg-blue-600/30 dark:bg-blue-400/30 rounded-full"})})]});default:return f.jsx(oI,{className:"h-4 w-4 text-muted-foreground/60"})}};return f.jsxs("div",{className:Me("border rounded-lg bg-gradient-to-br from-muted/20 to-muted/40 backdrop-blur-sm shadow-sm hover:shadow-md transition-all duration-200",v==="completed"&&"border-green-200/50 dark:border-green-800/50",v==="error"&&"border-red-200/50 dark:border-red-800/50",v==="executing"&&"border-blue-200/50 dark:border-blue-800/50 shadow-md animate-pulse",n),children:[f.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-muted/30 transition-all duration-200 rounded-t-lg",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2 rounded-md bg-background/50 border",children:f.jsx(A0,{className:"h-4 w-4 text-muted-foreground"})}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"font-semibold text-sm",children:t.name}),v==="executing"&&f.jsx("span",{className:"text-xs text-blue-600/70 dark:text-blue-400/70 font-medium",children:"Running..."}),b()]})]}),f.jsx("div",{className:"flex items-center gap-2",children:u?f.jsx(Au,{className:"h-4 w-4 text-muted-foreground"}):f.jsx(Ba,{className:"h-4 w-4 text-muted-foreground"})})]}),u&&f.jsxs("div",{className:"border-t bg-background/30 backdrop-blur-sm",children:[Object.keys(t.parameters).length>0&&f.jsxs("div",{className:"p-4 border-b border-border/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-600/70 dark:bg-blue-400/70"}),"Parameters"]}),f.jsx("button",{onClick:()=>h(!p),className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded bg-muted/50 hover:bg-muted",children:p?"Raw JSON":"Tree View"})]}),p?f.jsx(K8,{data:t.parameters}):f.jsx(S4,{data:t.parameters})]}),e&&f.jsxs("div",{className:"p-4",children:[f.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3 flex items-center gap-2",children:[f.jsx("div",{className:Me("w-2 h-2 rounded-full",e.error?"bg-red-600/70 dark:bg-red-400/70":"bg-green-600/70 dark:bg-green-400/70")}),e.error?"Error":"Result"]}),f.jsx("div",{children:e.error?f.jsx("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx(af,{className:"h-5 w-5 text-red-600/70 dark:text-red-400/70 flex-shrink-0 mt-0.5"}),f.jsxs("div",{children:[f.jsx("p",{className:"font-medium text-foreground mb-1",children:"Tool execution failed"}),f.jsx("p",{className:"text-muted-foreground text-sm",children:e.error})]})]})}):f.jsxs("div",{className:"bg-green-50/30 dark:bg-green-950/20 border border-green-200/50 dark:border-green-800/50 rounded-lg",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-100/30 dark:bg-green-900/20 border-b border-green-200/50 dark:border-green-800/50",children:[f.jsx(sf,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70"}),f.jsx("span",{className:"text-sm font-medium text-foreground",children:"Tool executed successfully"})]}),f.jsx("div",{className:"p-4",children:(()=>{const x=R=>{if(!R)return null;const j=Array.isArray(R)?R[0]:R;if(!j)return null;const A=j?.resource;if(A&&typeof A=="object"&&typeof A.uri=="string"&&A.uri.startsWith("ui://"))return A;const N=j?.content;if(Array.isArray(N)){for(const M of N)if(M?.type==="resource"&&M?.resource?.uri&&typeof M.resource.uri=="string"&&M.resource.uri.startsWith("ui://"))return M.resource}return null},E=e?.result,S=a?.["openai/outputTemplate"];if(S&&typeof S=="string"){const R=l||e.serverId;return f.jsx(Vq,{componentUrl:S,toolCall:t,toolResult:e,onCallTool:s,onSendFollowup:i,serverId:R,toolMeta:a})}const k=x(E);if(k)return f.jsx(DN,{resource:k,htmlProps:{autoResizeIframe:!0,style:{width:"100%",overflow:"visible"}},onUIAction:async R=>{if(R.type==="tool"&&R.payload?.toolName){const j=(()=>{if(r&&typeof r=="object"&&Object.keys(r).length===1)return Object.keys(r)[0]})();fetch("/api/mcp/tools/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolName:R.payload.toolName,parameters:R.payload.params||{},...j?{serverId:j}:{}})}).catch(()=>{})}else R.type==="link"&&R.payload?.url&&window.open(R.payload.url,"_blank","noopener,noreferrer");return{status:"handled"}}});const T=E?.result||E;return typeof T=="object"?f.jsx(S4,{data:T}):f.jsx("div",{className:"text-sm text-foreground bg-muted/30 p-3 rounded border",children:String(T)})})()})]})})]})]})]})}const BEe="/claude_logo.png",qEe="/openai_logo.png",VEe="/deepseek_logo.svg",HEe="/google_logo.png",GEe="/meta_logo.svg",k4="/ollama_logo.svg",T4="/ollama_dark.png",C4="/grok_light.svg",A4="/grok_dark.png",X8=(t,e)=>{switch(t){case"anthropic":return BEe;case"openai":return qEe;case"deepseek":return VEe;case"google":return HEe;case"ollama":return e==="dark"||e==="system"&&typeof document<"u"&&document.documentElement.classList.contains("dark")?T4:k4;case"meta":return GEe;case"x-ai":return e==="dark"||e==="system"&&typeof document<"u"&&document.documentElement.classList.contains("dark")?A4:C4;default:return null}},WEe=(t,e)=>X8(t.provider,e),YEe=t=>{switch(t){case"anthropic":return"text-orange-600 dark:text-orange-400";case"openai":return"text-green-600 dark:text-green-400";case"deepseek":return"text-blue-600 dark:text-blue-400";case"google":return"text-red-600 dark:text-red-400";case"ollama":return"text-gray-600 dark:text-gray-400";case"x-ai":return"text-purple-600 dark:text-purple-400";default:return"text-blue-600 dark:text-blue-400"}},N4=t=>{let e;const n=new Set,r=(d,p)=>{const h=typeof d=="function"?d(e):d;if(!Object.is(h,e)){const g=e;e=p??(typeof h!="object"||h===null)?h:Object.assign({},e,h),n.forEach(v=>v(e,g))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=e=t(r,s,l);return l},KEe=t=>t?N4(t):N4,XEe=t=>t;function QEe(t,e=XEe){const n=Ee.useSyncExternalStore(t.subscribe,Ee.useCallback(()=>e(t.getState()),[t,e]),Ee.useCallback(()=>e(t.getInitialState()),[t,e]));return Ee.useDebugValue(n),n}const JEe=t=>KEe()(e=>({themeMode:t?.themeMode??"light",themePreset:t?.themePreset??"default",setThemeMode:n=>e({themeMode:n}),setThemePreset:n=>e({themePreset:n})})),Q8=w.createContext(null),ZEe=({children:t,themeMode:e,themePreset:n})=>{const r=w.useRef(null);return r.current??=JEe({themeMode:e,themePreset:n}),f.jsx(Q8.Provider,{value:r.current,children:t})},Ym=t=>{const e=w.useContext(Q8);if(!e)throw new Error("Missing PreferencesStoreProvider");return QEe(e,t)},R4=({attachment:t,align:e="left"})=>{const[n,r]=w.useState(!1),[s,i]=w.useState(!1);return n?f.jsxs("div",{className:`px-3 py-2 bg-muted rounded-lg text-sm text-muted-foreground ${e==="right"?"text-right":""}`,children:["Failed to load image: ",t.name]}):f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{className:`text-xs text-muted-foreground font-medium ${e==="right"?"text-right":""}`,children:t.name}),f.jsx("div",{className:"flex justify-center",children:f.jsx("img",{src:t.url,alt:t.name,className:`max-w-full h-auto rounded-lg border border-border/30 shadow-sm cursor-pointer transition-all hover:shadow-md ${s?"max-h-none":"max-h-96"}`,loading:"lazy",onClick:()=>i(!s),onError:()=>r(!0),title:s?"Click to collapse":"Click to expand"})})]})},j4=()=>f.jsxs("div",{className:"flex items-center gap-2 py-2",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:"Thinking"}),f.jsxs("div",{className:"flex space-x-1",children:[f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce [animation-delay:-0.2s]"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce [animation-delay:-0.4s]"})]})]}),e1e=({message:t,isLoading:e=!1,onEdit:n,onRegenerate:r,onCopy:s,isReadonly:i=!1,showActions:a=!0,model:l,serverConfigs:u,onCallTool:d,onSendFollowup:p,toolsMetadata:h,serverId:g})=>{const[v,b]=w.useState("view"),[x,E]=w.useState(!1),[S,k]=w.useState(!1),T=Ym(I=>I.themeMode),R=()=>{s?s(t.content):navigator.clipboard.writeText(t.content),k(!0),setTimeout(()=>k(!1),2e3)},j=I=>{n&&n(t.id,I),b("view")},A=()=>{b("view")},N=()=>{r&&r(t.id)},M=t.role==="assistant"&&e&&(!t.content||t.content.trim()==="");return f.jsx(hx,{children:f.jsxs(ei.div,{"data-testid":`message-${t.role}`,className:"w-full mx-auto max-w-4xl px-4 group/message",initial:{y:5,opacity:0},animate:{y:0,opacity:1},"data-role":t.role,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),children:[t.role==="assistant"&&f.jsxs("div",{className:"flex gap-4 w-full",children:[f.jsx("div",{className:"size-8 flex items-center rounded-full justify-center shrink-0 bg-muted/50",children:f.jsx("img",{src:WEe(l,T),alt:`${l?.id} logo`,className:"h-4 w-4 object-contain"})}),f.jsxs("div",{className:"flex flex-col gap-4 w-full min-w-0",children:[t.attachments&&t.attachments.length>0&&f.jsx("div",{className:"flex flex-col gap-3",children:t.attachments.map(I=>PD({type:I.contentType})?f.jsx(R4,{attachment:I},I.id):f.jsxs("div",{className:"px-3 py-2 bg-muted rounded-lg text-sm flex items-center gap-2",children:[f.jsx("span",{children:"📎"}),f.jsx("span",{children:I.name}),I.size&&f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.size/1024).toFixed(1)," KB)"]})]},I.id))}),t.contentBlocks&&t.contentBlocks.length>0?f.jsx("div",{className:"space-y-4",children:t.contentBlocks.map((I,O)=>I.type==="text"&&I.content?f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:O*.05},className:"prose prose-sm max-w-none dark:prose-invert prose-p:leading-relaxed prose-pre:bg-muted/50 prose-pre:border prose-pre:border-border/30 flex-1 min-w-0",children:f.jsx(_4,{children:iE(I.content)})},I.id):I.type==="tool_call"&&I.toolCall?f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:O*.05},children:f.jsx(E4,{toolCall:I.toolCall,toolResult:I.toolResult,serverConfigs:u,onCallTool:d,onSendFollowup:p,toolMeta:h?.[I.toolCall.name],serverId:g})},I.id):null)}):f.jsxs(f.Fragment,{children:[t.toolCalls&&t.toolCalls.length>0&&f.jsx("div",{className:"space-y-2",children:t.toolCalls.map((I,O)=>{const L=t.toolResults?.find(z=>z.toolCallId===I.id);return f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:O*.1},children:f.jsx(E4,{toolCall:I,toolResult:L,serverConfigs:u,onCallTool:d,onSendFollowup:p,toolMeta:h?.[I.name],serverId:g})},I.id)})}),M?f.jsx(ei.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:f.jsx(j4,{})}):v==="view"&&t.content?f.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert prose-p:leading-relaxed prose-pre:bg-muted/50 prose-pre:border prose-pre:border-border/30 flex-1 min-w-0",children:f.jsx(_4,{children:iE(t.content)})}):null]}),M&&t.contentBlocks&&f.jsx(ei.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:f.jsx(j4,{})}),v==="view"&&x&&f.jsxs("div",{className:"flex items-center justify-between mt-4",children:[f.jsx("div",{className:"text-xs text-muted-foreground/60",children:MD(t.timestamp)}),a&&!i&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:R,children:S?f.jsx(Ti,{size:14}):f.jsx(Po,{size:14})})}),f.jsx(Pa,{children:"Copy"})]}),r&&f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:N,children:f.jsx(rie,{size:14})})}),f.jsx(Pa,{children:"Regenerate"})]})]})]}),v==="edit"&&f.jsx("div",{className:"flex flex-row gap-2 items-start",children:f.jsx(w4,{message:t,onSave:j,onCancel:A})})]})]}),t.role==="user"&&f.jsx("div",{className:"flex justify-end w-full",children:f.jsxs("div",{className:"flex flex-col gap-2 max-w-2xl",children:[t.attachments&&t.attachments.length>0&&f.jsx("div",{className:"flex flex-col gap-3",children:t.attachments.map(I=>PD({type:I.contentType})?f.jsx(R4,{attachment:I,align:"right"},I.id):f.jsxs("div",{className:"px-3 py-2 bg-muted rounded-lg text-sm flex items-center gap-2 justify-end",children:[f.jsx("span",{children:I.name}),f.jsx("span",{children:"📎"}),I.size&&f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.size/1024).toFixed(1)," KB)"]})]},I.id))}),v==="view"?f.jsxs("div",{className:"flex items-start gap-2 justify-end",children:[a&&!i&&x&&f.jsx("div",{className:"flex items-center gap-1 mt-1",children:f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:R,children:f.jsx(Po,{size:14})})}),f.jsx(Pa,{children:"Copy"})]})}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{"data-testid":"message-content",className:"bg-primary text-primary-foreground px-4 py-3 rounded-2xl max-w-fit",children:f.jsx("div",{className:"whitespace-pre-wrap break-words font-medium",children:iE(t.content)})}),x&&f.jsx("div",{className:"absolute -bottom-6 right-0 text-xs text-muted-foreground/60",children:MD(t.timestamp)})]})]}):f.jsx("div",{className:"w-full",children:f.jsx(w4,{message:t,onSave:j,onCancel:A})})]})})]})})},t1e=w.memo(e1e,(t,e)=>t.message.id===e.message.id&&t.message.content===e.message.content&&t.isLoading===e.isLoading&&JSON.stringify(t.message.toolCalls)===JSON.stringify(e.message.toolCalls)&&JSON.stringify(t.message.toolResults)===JSON.stringify(e.message.toolResults));function M1({provider:t}){const e=Ym(r=>r.themeMode),n=X8(t,e);return n?f.jsx("img",{src:n,width:12,height:12,alt:`${t} logo`,className:"h-3 w-3 object-contain"}):f.jsx("div",{className:kT("h-3 w-3 rounded-sm",YEe(t))})}var Ea=[],xi=[],n1e=Uint8Array,O1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Cd=0,r1e=O1.length;Cd<r1e;++Cd)Ea[Cd]=O1[Cd],xi[O1.charCodeAt(Cd)]=Cd;xi[45]=62;xi[95]=63;function s1e(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function i1e(t,e,n){return(e+n)*3/4-n}function Km(t){var e,n=s1e(t),r=n[0],s=n[1],i=new n1e(i1e(t,r,s)),a=0,l=s>0?r-4:r,u;for(u=0;u<l;u+=4)e=xi[t.charCodeAt(u)]<<18|xi[t.charCodeAt(u+1)]<<12|xi[t.charCodeAt(u+2)]<<6|xi[t.charCodeAt(u+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return s===2&&(e=xi[t.charCodeAt(u)]<<2|xi[t.charCodeAt(u+1)]>>4,i[a++]=e&255),s===1&&(e=xi[t.charCodeAt(u)]<<10|xi[t.charCodeAt(u+1)]<<4|xi[t.charCodeAt(u+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function a1e(t){return Ea[t>>18&63]+Ea[t>>12&63]+Ea[t>>6&63]+Ea[t&63]}function o1e(t,e,n){for(var r,s=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(a1e(r));return s.join("")}function Xm(t){for(var e,n=t.length,r=n%3,s=[],i=16383,a=0,l=n-r;a<l;a+=i)s.push(o1e(t,a,a+i>l?l:a+i));return r===1?(e=t[n-1],s.push(Ea[e>>2]+Ea[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],s.push(Ea[e>>10]+Ea[e>>4&63]+Ea[e<<2&63]+"=")),s.join("")}function So(t){if(t===void 0)return{};if(!J8(t))throw new Error(`The arguments to a Convex function must be an object. Received: ${t}`);return t}function l1e(t){if(typeof t>"u")throw new Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if(typeof t!="string")throw new Error(`Invalid deployment address: found ${t}".`);if(!(t.startsWith("http:")||t.startsWith("https:")))throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${t}".`);try{new URL(t)}catch{throw new Error(`Invalid deployment address: "${t}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(t.endsWith(".convex.site"))throw new Error(`Invalid deployment address: "${t}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}function J8(t){const e=typeof t=="object",n=Object.getPrototypeOf(t),r=n===null||n===Object.prototype||n?.constructor?.name==="Object";return e&&r}const Z8=!0,Mf=BigInt("-9223372036854775808"),nj=BigInt("9223372036854775807"),SC=BigInt("0"),c1e=BigInt("8"),u1e=BigInt("256");function e7(t){return Number.isNaN(t)||!Number.isFinite(t)||Object.is(t,-0)}function d1e(t){t<SC&&(t-=Mf+Mf);let e=t.toString(16);e.length%2===1&&(e="0"+e);const n=new Uint8Array(new ArrayBuffer(8));let r=0;for(const s of e.match(/.{2}/g).reverse())n.set([parseInt(s,16)],r++),t>>=c1e;return Xm(n)}function f1e(t){const e=Km(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);let n=SC,r=SC;for(const s of e)n+=BigInt(s)*u1e**r,r++;return n>nj&&(n+=Mf+Mf),n}function h1e(t){if(t<Mf||nj<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);const e=new ArrayBuffer(8);return new DataView(e).setBigInt64(0,t,!0),Xm(new Uint8Array(e))}function p1e(t){const e=Km(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);return new DataView(e.buffer).getBigInt64(0,!0)}const m1e=DataView.prototype.setBigInt64?h1e:d1e,g1e=DataView.prototype.getBigInt64?p1e:f1e,M4=1024;function t7(t){if(t.length>M4)throw new Error(`Field name ${t} exceeds maximum field name length ${M4}.`);if(t.startsWith("$"))throw new Error(`Field name ${t} starts with a '$', which is reserved.`);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<32||n>=127)throw new Error(`Field name ${t} has invalid character '${t[e]}': Field names can only contain non-control ASCII characters`)}}function Of(t){if(t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>Of(r));if(typeof t!="object")throw new Error(`Unexpected type of ${t}`);const e=Object.entries(t);if(e.length===1){const r=e[0][0];if(r==="$bytes"){if(typeof t.$bytes!="string")throw new Error(`Malformed $bytes field on ${t}`);return Km(t.$bytes).buffer}if(r==="$integer"){if(typeof t.$integer!="string")throw new Error(`Malformed $integer field on ${t}`);return g1e(t.$integer)}if(r==="$float"){if(typeof t.$float!="string")throw new Error(`Malformed $float field on ${t}`);const s=Km(t.$float);if(s.byteLength!==8)throw new Error(`Received ${s.byteLength} bytes, expected 8 for $float`);const a=new DataView(s.buffer).getFloat64(0,Z8);if(!e7(a))throw new Error(`Float ${a} should be encoded as a number`);return a}if(r==="$set")throw new Error("Received a Set which is no longer supported as a Convex type.");if(r==="$map")throw new Error("Received a Map which is no longer supported as a Convex type.")}const n={};for(const[r,s]of Object.entries(t))t7(r),n[r]=Of(s);return n}function fm(t){return JSON.stringify(t,(e,n)=>n===void 0?"undefined":typeof n=="bigint"?`${n.toString()}n`:n)}function EC(t,e,n,r){if(t===void 0){const a=n&&` (present at path ${n} in original object ${fm(e)})`;throw new Error(`undefined is not a valid Convex value${a}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(t===null)return t;if(typeof t=="bigint"){if(t<Mf||nj<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:m1e(t)}}if(typeof t=="number")if(e7(t)){const a=new ArrayBuffer(8);return new DataView(a).setFloat64(0,t,Z8),{$float:Xm(new Uint8Array(a))}}else return t;if(typeof t=="boolean"||typeof t=="string")return t;if(t instanceof ArrayBuffer)return{$bytes:Xm(new Uint8Array(t))};if(Array.isArray(t))return t.map((a,l)=>EC(a,e,n+`[${l}]`));if(t instanceof Set)throw new Error(P1(n,"Set",[...t],e));if(t instanceof Map)throw new Error(P1(n,"Map",[...t],e));if(!J8(t)){const a=t?.constructor?.name,l=a?`${a} `:"";throw new Error(P1(n,l,t,e))}const s={},i=Object.entries(t);i.sort(([a,l],[u,d])=>a===u?0:a<u?-1:1);for(const[a,l]of i)l!==void 0&&(t7(a),s[a]=EC(l,e,n+`.${a}`));return s}function P1(t,e,n,r){return t?`${e}${fm(n)} is not a supported Convex type (present at path ${t} in original object ${fm(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${e}${fm(n)} is not a supported Convex type.`}function Ql(t){return EC(t,t,"")}var v1e=Object.defineProperty,y1e=(t,e,n)=>e in t?v1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,I1=(t,e,n)=>y1e(t,typeof e!="symbol"?e+"":e,n),O4,P4;const b1e=Symbol.for("ConvexError");class kC extends(P4=Error,O4=b1e,P4){constructor(e){super(typeof e=="string"?e:fm(e)),I1(this,"name","ConvexError"),I1(this,"data"),I1(this,O4,!0),this.data=e}}const n7=()=>Array.from({length:4},()=>0);n7();n7();const I4="1.28.0";var x1e=Object.defineProperty,_1e=(t,e,n)=>e in t?x1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D4=(t,e,n)=>_1e(t,typeof e!="symbol"?e+"":e,n);const w1e="color:rgb(0, 145, 255)";function r7(t){switch(t){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class s7{constructor(e){D4(this,"_onLogLineFuncs"),D4(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let n=Math.random().toString(36).substring(2,15);for(let r=0;r<10&&this._onLogLineFuncs[n]!==void 0;r++)n=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[n]=e,()=>{delete this._onLogLineFuncs[n]}}logVerbose(...e){if(this._verbose)for(const n of Object.values(this._onLogLineFuncs))n("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const n of Object.values(this._onLogLineFuncs))n("info",...e)}warn(...e){for(const n of Object.values(this._onLogLineFuncs))n("warn",...e)}error(...e){for(const n of Object.values(this._onLogLineFuncs))n("error",...e)}}function i7(t){const e=new s7(t);return e.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),e}function a7(t){return new s7(t)}function xx(t,e,n,r,s){const i=r7(n);if(typeof s=="object"&&(s=`ConvexError ${JSON.stringify(s.errorData,null,2)}`),e==="info"){const a=s.match(/^\[.*?\] /);if(a===null){t.error(`[CONVEX ${i}(${r})] Could not parse console.log`);return}const l=s.slice(1,a[0].length-2),u=s.slice(a[0].length);t.log(`%c[CONVEX ${i}(${r})] [${l}]`,w1e,u)}else t.error(`[CONVEX ${i}(${r})] ${s}`)}function S1e(t,e){const n=`[CONVEX FATAL ERROR] ${e}`;return t.error(n),new Error(n)}function Xd(t,e,n){return`[CONVEX ${r7(t)}(${e})] ${n.errorMessage}
|
|
1818
|
+
Called by client`}function TC(t,e){return e.data=t.errorData,e}function _x(t){const e=t.split(":");let n,r;return e.length===1?(n=e[0],r="default"):(n=e.slice(0,e.length-1).join(":"),r=e[e.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function iu(t,e){return JSON.stringify({udfPath:_x(t),args:Ql(e)})}var E1e=Object.defineProperty,k1e=(t,e,n)=>e in t?E1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xa=(t,e,n)=>k1e(t,typeof e!="symbol"?e+"":e,n);class T1e{constructor(){xa(this,"nextQueryId"),xa(this,"querySetVersion"),xa(this,"querySet"),xa(this,"queryIdToToken"),xa(this,"identityVersion"),xa(this,"auth"),xa(this,"outstandingQueriesOlderThanRestart"),xa(this,"outstandingAuthOlderThanRestart"),xa(this,"paused"),xa(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,n,r,s){const i=_x(e),a=iu(i,n),l=this.querySet.get(a);if(l!==void 0)return l.numSubscribers+=1,{queryToken:a,modification:null,unsubscribe:()=>this.removeSubscriber(a)};{const u=this.nextQueryId++,d={id:u,canonicalizedUdfPath:i,args:n,numSubscribers:1,journal:r,componentPath:s};this.querySet.set(a,d),this.queryIdToToken.set(u,a);const p=this.querySetVersion,h=this.querySetVersion+1,g={type:"Add",queryId:u,udfPath:i,args:[Ql(n)],journal:r,componentPath:s};return this.paused?this.pendingQuerySetModifications.set(u,g):this.querySetVersion=h,{queryToken:a,modification:{type:"ModifyQuerySet",baseVersion:p,newVersion:h,modifications:[g]},unsubscribe:()=>this.removeSubscriber(a)}}}transition(e){for(const n of e.modifications)switch(n.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);const r=n.journal;if(r!==void 0){const s=this.queryIdToToken.get(n.queryId);s!==void 0&&(this.querySet.get(s).journal=r)}break}case"QueryRemoved":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);break}default:throw new Error(`Invalid modification ${n.type}`)}}queryId(e,n){const r=_x(e),s=iu(r,n),i=this.querySet.get(s);return i!==void 0?i.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const n=this.identityVersion;return this.paused||(this.identityVersion=n+1),{type:"Authenticate",baseVersion:n,...this.auth}}setAdminAuth(e,n){const r={tokenType:"Admin",value:e,impersonating:n};this.auth=r;const s=this.identityVersion;return this.paused||(this.identityVersion=s+1),{type:"Authenticate",baseVersion:s,...r}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).canonicalizedUdfPath:null}queryArgs(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(e){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const n=[];for(const i of this.querySet.values()){const a={type:"Add",queryId:i.id,udfPath:i.canonicalizedUdfPath,args:[Ql(i.args)],journal:i.journal,componentPath:i.componentPath};n.push(a),e.has(i.id)||this.outstandingQueriesOlderThanRestart.add(i.id)}this.querySetVersion=1;const r={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:n};if(!this.auth)return this.identityVersion=0,[r,void 0];this.outstandingAuthOlderThanRestart=!0;const s={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[r,s]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,n=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,n]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const n=this.querySet.get(e);if(n.numSubscribers>1)return n.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(n.id),this.outstandingQueriesOlderThanRestart.delete(n.id);const r=this.querySetVersion,s=this.querySetVersion+1,i={type:"Remove",queryId:n.id};return this.paused?this.pendingQuerySetModifications.has(n.id)?this.pendingQuerySetModifications.delete(n.id):this.pendingQuerySetModifications.set(n.id,i):this.querySetVersion=s,{type:"ModifyQuerySet",baseVersion:r,newVersion:s,modifications:[i]}}}}var C1e=Object.defineProperty,A1e=(t,e,n)=>e in t?C1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,wy=(t,e,n)=>A1e(t,typeof e!="symbol"?e+"":e,n);class N1e{constructor(e,n){this.logger=e,this.markConnectionStateDirty=n,wy(this,"inflightRequests"),wy(this,"requestsOlderThanRestart"),wy(this,"inflightMutationsCount",0),wy(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,n){const r=new Promise(s=>{const i=n?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:i,requestedAt:new Date,onResult:s}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),r}onResponse(e){const n=this.inflightRequests.get(e.requestId);if(n===void 0||n.status.status==="Completed")return null;const r=n.message.type==="Mutation"?"mutation":"action",s=n.message.udfPath;for(const u of e.logLines)xx(this.logger,"info",r,s,u);const i=n.status;let a,l;if(e.success)a={success:!0,logLines:e.logLines,value:Of(e.result)},l=()=>i.onResult(a);else{const u=e.result,{errorData:d}=e;xx(this.logger,"error",r,s,u),a={success:!1,errorMessage:u,errorData:d!==void 0?Of(d):void 0,logLines:e.logLines},l=()=>i.onResult(a)}return e.type==="ActionResponse"||!e.success?(l(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),n.message.type==="Action"?this.inflightActionsCount--:n.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:a}):(n.status={status:"Completed",result:a,ts:e.ts,onResolve:l},null)}removeCompleted(e){const n=new Map;for(const[r,s]of this.inflightRequests.entries()){const i=s.status;i.status==="Completed"&&i.ts.lessThanOrEqual(e)&&(i.onResolve(),n.set(r,i.result),s.message.type==="Mutation"?this.inflightMutationsCount--:s.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(r),this.requestsOlderThanRestart.delete(r))}return n.size>0&&this.markConnectionStateDirty(),n}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[n,r]of this.inflightRequests){if(r.status.status==="NotSent"){r.status.status="Requested",e.push(r.message);continue}if(r.message.type==="Mutation")e.push(r.message);else if(r.message.type==="Action"){if(this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n),this.inflightActionsCount--,r.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");r.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,n]of this.inflightRequests)if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const n of this.inflightRequests.values())n.status.status!=="Completed"&&n.status.requestedAt.getTime()<e&&(e=n.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}const Qm=Symbol.for("functionName"),R1e=Symbol.for("toReferencePath");function j1e(t){return t[R1e]??null}function M1e(t){return t.startsWith("function://")}function O1e(t){let e;if(typeof t=="string")M1e(t)?e={functionHandle:t}:e={name:t};else if(t[Qm])e={name:t[Qm]};else{const n=j1e(t);if(!n)throw new Error(`${t} is not a functionReference`);e={reference:n}}return e}function Ps(t){const e=O1e(t);if(e.name===void 0)throw e.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${e.functionHandle}`):e.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${e.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(e)}`);if(typeof t=="string")return t;const n=t[Qm];if(!n)throw new Error(`${t} is not a functionReference`);return n}function rj(t){return{[Qm]:t}}function o7(t=[]){const e={get(n,r){if(typeof r=="string"){const s=[...t,r];return o7(s)}else if(r===Qm){if(t.length<2){const a=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${a}\``)}const s=t.slice(0,-1).join("/"),i=t[t.length-1];return i==="default"?s:s+":"+i}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}o7();var P1e=Object.defineProperty,I1e=(t,e,n)=>e in t?P1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,wx=(t,e,n)=>I1e(t,typeof e!="symbol"?e+"":e,n);class Jm{constructor(e){wx(this,"queryResults"),wx(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...n){const r=So(n[0]),s=Ps(e),i=this.queryResults.get(iu(s,r));if(i!==void 0)return Jm.queryValue(i.result)}getAllQueries(e){const n=[],r=Ps(e);for(const s of this.queryResults.values())s.udfPath===_x(r)&&n.push({args:s.args,value:Jm.queryValue(s.result)});return n}setQuery(e,n,r){const s=So(n),i=Ps(e),a=iu(i,s);let l;r===void 0?l=void 0:l={success:!0,value:r,logLines:[]};const u={udfPath:i,args:s,result:l};this.queryResults.set(a,u),this.modifiedQueries.push(a)}static queryValue(e){if(e!==void 0)return e.success?e.value:void 0}}class D1e{constructor(){wx(this,"queryResults"),wx(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,n){this.optimisticUpdates=this.optimisticUpdates.filter(a=>!n.has(a.mutationId));const r=this.queryResults;this.queryResults=new Map(e);const s=new Jm(this.queryResults);for(const a of this.optimisticUpdates)a.update(s);const i=[];for(const[a,l]of this.queryResults){const u=r.get(a);(u===void 0||u.result!==l.result)&&i.push(a)}return i}applyOptimisticUpdate(e,n){this.optimisticUpdates.push({update:e,mutationId:n});const r=new Jm(this.queryResults);return e(r),r.modifiedQueries}rawQueryResult(e){return this.queryResults.get(e)}queryResult(e){const n=this.queryResults.get(e);if(n===void 0)return;const r=n.result;if(r!==void 0){if(r.success)return r.value;throw r.errorData!==void 0?TC(r,new kC(Xd("query",n.udfPath,r))):new Error(Xd("query",n.udfPath,r))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}}var L1e=Object.defineProperty,$1e=(t,e,n)=>e in t?L1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D1=(t,e,n)=>$1e(t,typeof e!="symbol"?e+"":e,n);class Xs{constructor(e,n){D1(this,"low"),D1(this,"high"),D1(this,"__isUnsignedLong__"),this.low=e|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(e){return(e&&e.__isUnsignedLong__)===!0}static fromBytesLE(e){return new Xs(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){const e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?L4:e>=z1e?F1e:new Xs(e%hm|0,e/hm|0)}toString(){return(BigInt(this.high)*BigInt(hm)+BigInt(this.low)).toString()}equals(e){return Xs.isLong(e)||(e=Xs.fromValue(e)),this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return Xs.isLong(e)||(e=Xs.fromValue(e)),this.equals(e)?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return this.comp(e)<=0}static fromValue(e){return typeof e=="number"?Xs.fromNumber(e):new Xs(e.low,e.high)}}const L4=new Xs(0,0),$4=65536,hm=$4*$4,z1e=hm*hm,F1e=new Xs(-1,-1);var U1e=Object.defineProperty,B1e=(t,e,n)=>e in t?U1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Sy=(t,e,n)=>B1e(t,typeof e!="symbol"?e+"":e,n);class z4{constructor(e,n){Sy(this,"version"),Sy(this,"remoteQuerySet"),Sy(this,"queryPath"),Sy(this,"logger"),this.version={querySet:0,ts:Xs.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=n}transition(e){const n=e.startVersion;if(this.version.querySet!==n.querySet||this.version.ts.notEquals(n.ts)||this.version.identity!==n.identity)throw new Error(`Invalid start version: ${n.ts.toString()}:${n.querySet}:${n.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(const r of e.modifications)switch(r.type){case"QueryUpdated":{const s=this.queryPath(r.queryId);if(s)for(const a of r.logLines)xx(this.logger,"info","query",s,a);const i=Of(r.value??null);this.remoteQuerySet.set(r.queryId,{success:!0,value:i,logLines:r.logLines});break}case"QueryFailed":{const s=this.queryPath(r.queryId);if(s)for(const a of r.logLines)xx(this.logger,"info","query",s,a);const{errorData:i}=r;this.remoteQuerySet.set(r.queryId,{success:!1,errorMessage:r.errorMessage,errorData:i!==void 0?Of(i):void 0,logLines:r.logLines});break}case"QueryRemoved":{this.remoteQuerySet.delete(r.queryId);break}default:throw new Error(`Invalid modification ${r.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function L1(t){const e=Km(t);return Xs.fromBytesLE(Array.from(e))}function q1e(t){const e=new Uint8Array(t.toBytesLE());return Xm(e)}function F4(t){switch(t.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...t};case"MutationResponse":return t.success?{...t,ts:L1(t.ts)}:{...t};case"Transition":return{...t,startVersion:{...t.startVersion,ts:L1(t.startVersion.ts)},endVersion:{...t.endVersion,ts:L1(t.endVersion.ts)}}}}function V1e(t){switch(t.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...t};case"Connect":return t.maxObservedTimestamp!==void 0?{...t,maxObservedTimestamp:q1e(t.maxObservedTimestamp)}:{...t,maxObservedTimestamp:void 0}}}var H1e=Object.defineProperty,G1e=(t,e,n)=>e in t?H1e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Vr=(t,e,n)=>G1e(t,typeof e!="symbol"?e+"":e,n);const W1e=1e3,Y1e=1001,K1e=1005,X1e=4040;let ab;function ob(){return ab===void 0&&(ab=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(ab+performance.now())}function U4(){return`t=${Math.round((ob()-ab)/100)/10}s`}const l7={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function Q1e(t){if(t===void 0)return"Unknown";for(const e of Object.keys(l7))if(t.startsWith(e))return e;return"Unknown"}class J1e{constructor(e,n,r,s,i,a){this.markConnectionStateDirty=i,this.debug=a,Vr(this,"socket"),Vr(this,"connectionCount"),Vr(this,"_hasEverConnected",!1),Vr(this,"lastCloseReason"),Vr(this,"transitionChunkBuffer",null),Vr(this,"defaultInitialBackoff"),Vr(this,"maxBackoff"),Vr(this,"retries"),Vr(this,"serverInactivityThreshold"),Vr(this,"reconnectDueToServerInactivityTimeout"),Vr(this,"uri"),Vr(this,"onOpen"),Vr(this,"onResume"),Vr(this,"onMessage"),Vr(this,"webSocketConstructor"),Vr(this,"logger"),Vr(this,"onServerDisconnectError"),this.webSocketConstructor=r,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=n.onOpen,this.onResume=n.onResume,this.onMessage=n.onMessage,this.onServerDisconnectError=n.onServerDisconnectError,this.logger=s,this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const n=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${n}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const n=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;const r=F4(JSON.parse(n));if(r.type!=="Transition")throw new Error(`Expected Transition, got ${r.type} after assembling chunks`);return r}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:ob()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",U4(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",U4())),this.connectionCount+=1,this.lastCloseReason=null},e.onerror=n=>{this.transitionChunkBuffer=null;const r=n.message;r&&this.logger.log(`WebSocket error message: ${r}`)},e.onmessage=n=>{this.resetServerInactivityTimeout();const r=n.data.length;let s=F4(JSON.parse(n.data));if(this._logVerbose(`received ws message with type ${s.type}`),s.type==="Ping")return;if(s.type==="TransitionChunk"){const a=this.assembleTransition(s);if(!a)return;s=a,this._logVerbose(`assembled full ws message of type ${s.type}`)}this.transitionChunkBuffer!==null&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${s.type} while buffering TransitionChunks`)),s.type==="Transition"&&this.reportLargeTransition({messageLength:r,transition:s}),this.onMessage(s).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())},e.onclose=n=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=n.reason||`closed with code ${n.code}`),n.code!==W1e&&n.code!==Y1e&&n.code!==K1e&&n.code!==X1e){let s=`WebSocket closed with code ${n.code}`;n.reason&&(s+=`: ${n.reason}`),this.logger.log(s),this.onServerDisconnectError&&n.reason&&this.onServerDisconnectError(s)}const r=Q1e(n.reason);this.scheduleReconnect(r)}}socketState(){return this.socket.state}sendMessage(e){const n={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const r=V1e(e),s=JSON.stringify(r);let i=!1;try{this.socket.ws.send(s),i=!0}catch(a){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${a}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${i?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(n)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(n)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.socket={state:"disconnected"};const n=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(n)}ms`),setTimeout(()=>this.connect(),n)}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":{this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return}default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return e.onmessage=n=>{this._logVerbose("Ignoring message received after close")},new Promise(n=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),n()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws;e.onmessage=r=>{this._logVerbose("Ignoring message received after close")};const n=new Promise(r=>{e.onclose=()=>{r()}});return e.close(),n}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":{this.socket={...this.socket,paused:"yes"};return}default:{this.socket;return}}}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:ob()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const r=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:l7[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const s=Math.min(r,this.maxBackoff),i=s*(Math.random()-.5);return s+i}reportLargeTransition({transition:e,messageLength:n}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const r=ob()-e.clientClockSkew-e.serverTs/1e6,s=`${Math.round(r)}ms`,i=`${Math.round(n/1e4)/100}MB`,a=n/(r/1e3),l=`${Math.round(a/1e4)/100}MB per second`;this._logVerbose(`received ${i} transition in ${s} at ${l}`),n>2e7?this.logger.log(`received query results totaling more that 20MB (${i}) which will take a long time to download on slower connections`):r>2e4&&this.logger.log(`received query results totaling ${i} which took more than 20s to arrive (${s})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:r,messageLength:n}})}}function Z1e(){return eke()}function eke(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class Yp extends Error{}Yp.prototype.name="InvalidTokenError";function tke(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function nke(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return tke(e)}catch{return atob(e)}}function c7(t,e){if(typeof t!="string")throw new Yp("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new Yp(`Invalid token specified: missing part #${n+1}`);let s;try{s=nke(r)}catch(i){throw new Yp(`Invalid token specified: invalid base64 for part #${n+1} (${i.message})`)}try{return JSON.parse(s)}catch(i){throw new Yp(`Invalid token specified: invalid json for part #${n+1} (${i.message})`)}}var rke=Object.defineProperty,ske=(t,e,n)=>e in t?rke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vi=(t,e,n)=>ske(t,typeof e!="symbol"?e+"":e,n);const ike=20*24*60*60*1e3,B4=2;class ake{constructor(e,n,r){vi(this,"authState",{state:"noAuth"}),vi(this,"configVersion",0),vi(this,"syncState"),vi(this,"authenticate"),vi(this,"stopSocket"),vi(this,"tryRestartSocket"),vi(this,"pauseSocket"),vi(this,"resumeSocket"),vi(this,"clearAuth"),vi(this,"logger"),vi(this,"refreshTokenLeewaySeconds"),vi(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=n.authenticate,this.stopSocket=n.stopSocket,this.tryRestartSocket=n.tryRestartSocket,this.pauseSocket=n.pauseSocket,this.resumeSocket=n.resumeSocket,this.clearAuth=n.clearAuth,this.logger=r.logger,this.refreshTokenLeewaySeconds=r.refreshTokenLeewaySeconds}async setConfig(e,n){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const r=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});r.isFromOutdatedConfig||(r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:{fetchToken:e,onAuthChange:n},hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:{fetchToken:e,onAuthChange:n}}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket())}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid"),this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:n}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(n+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=B4){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${B4-this.tokenConfirmationAttempts} attempts remaining`)),await this.stopSocket();const n=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});n.isFromOutdatedConfig||(n.value&&this.syncState.isNewAuth(n.value)?(this.authenticate(n.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:n.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:s}=n;if(!r||!s){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const i=s-r;if(i<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let a=Math.min(ike,(i-this.refreshTokenLeewaySeconds)*1e3);a<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${i}s`),a=0);const l=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},a);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:l,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`)}async fetchTokenAndGuardAgainstRace(e,n){const r=++this.configVersion;this._logVerbose(`fetching token with config version ${r}`);const s=await e(n);return this.configVersion!==r?(this._logVerbose(`stale config version, expected ${r}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:s}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.setAuthState({state:"noAuth"})}setAuthState(e){const n=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(n)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0;break}this.authState.state==="waitingForScheduledRefetch"&&(clearTimeout(this.authState.refetchTokenTimeoutId),this.syncState.markAuthCompletion()),this.authState=e}decodeToken(e){try{return c7(e)}catch(n){return this._logVerbose(`Error decoding token: ${n instanceof Error?n.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}const oke=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function lke(t,e){const n={sessionId:e};typeof performance>"u"||!performance.mark||performance.mark(t,{detail:n})}function cke(t){let e=t.name.slice(6);return e=e.charAt(0).toLowerCase()+e.slice(1),{name:e,startTime:t.startTime}}function uke(t){if(typeof performance>"u"||!performance.getEntriesByName)return[];const e=[];for(const n of oke){const r=performance.getEntriesByName(n).filter(s=>s.entryType==="mark").filter(s=>s.detail.sessionId===t);e.push(...r)}return e.map(cke)}var dke=Object.defineProperty,fke=(t,e,n)=>e in t?dke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fr=(t,e,n)=>fke(t,typeof e!="symbol"?e+"":e,n);class hke{constructor(e,n,r){if(fr(this,"address"),fr(this,"state"),fr(this,"requestManager"),fr(this,"webSocketManager"),fr(this,"authenticationManager"),fr(this,"remoteQuerySet"),fr(this,"optimisticQueryResults"),fr(this,"_transitionHandlerCounter",0),fr(this,"_nextRequestId"),fr(this,"_onTransitionFns",new Map),fr(this,"_sessionId"),fr(this,"firstMessageReceived",!1),fr(this,"debug"),fr(this,"logger"),fr(this,"maxObservedTimestamp"),fr(this,"connectionStateSubscribers",new Map),fr(this,"nextConnectionStateSubscriberId",0),fr(this,"_lastPublishedConnectionState"),fr(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const v=this.connectionState();if(JSON.stringify(v)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=v;for(const b of this.connectionStateSubscribers.values())b(v)}})}),fr(this,"mark",v=>{this.debug&&lke(v,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");r?.skipConvexDeploymentUrlCheck!==!0&&l1e(e),r={...r};const s=r.authRefreshTokenLeewaySeconds??2;let i=r.webSocketConstructor;if(!i&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");i=i||WebSocket,this.debug=r.reportDebugInfoToConvex??!1,this.address=e,this.logger=r.logger===!1?a7({verbose:r.verbose??!1}):r.logger!==!0&&r.logger?r.logger:i7({verbose:r.verbose??!1});const a=e.search("://");if(a===-1)throw new Error("Provided address was not an absolute URL.");const l=e.substring(a+3),u=e.substring(0,a);let d;if(u==="http")d="ws";else if(u==="https")d="wss";else throw new Error(`Unknown parent protocol ${u}`);const p=`${d}://${l}/api/${I4}/sync`;this.state=new T1e,this.remoteQuerySet=new z4(v=>this.state.queryPath(v),this.logger),this.requestManager=new N1e(this.logger,this.markConnectionStateDirty);const h=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new ake(this.state,{authenticate:v=>{const b=this.state.setAuth(v);return this.webSocketManager.sendMessage(b),b.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:h,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:s}),this.optimisticQueryResults=new D1e,this.addOnTransitionHandler(v=>{n(v.queries.map(b=>b.token))}),this._nextRequestId=0,this._sessionId=Z1e();const{unsavedChangesWarning:g}=r;if(typeof window>"u"||typeof window.addEventListener>"u"){if(g===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else g!==!1&&window.addEventListener("beforeunload",v=>{if(this.requestManager.hasIncompleteRequests()){v.preventDefault();const b="Are you sure you want to leave? Your changes may not be saved.";return(v||window.event).returnValue=b,b}});this.webSocketManager=new J1e(p,{onOpen:v=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...v,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp});const b=new Set(this.remoteQuerySet.remoteQueryResults().keys());this.remoteQuerySet=new z4(S=>this.state.queryPath(S),this.logger);const[x,E]=this.state.restart(b);E&&this.webSocketManager.sendMessage(E),this.webSocketManager.sendMessage(x);for(const S of this.requestManager.restart())this.webSocketManager.sendMessage(S)},onResume:()=>{const[v,b]=this.state.resume();b&&this.webSocketManager.sendMessage(b),v&&this.webSocketManager.sendMessage(v);for(const x of this.requestManager.resume())this.webSocketManager.sendMessage(x)},onMessage:v=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),v.type){case"Transition":{this.observedTimestamp(v.endVersion.ts),this.authenticationManager.onTransition(v),this.remoteQuerySet.transition(v),this.state.transition(v);const b=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(b);break}case"MutationResponse":{v.success&&this.observedTimestamp(v.ts);const b=this.requestManager.onResponse(v);b!==null&&this.notifyOnQueryResultChanges(new Map([[b.requestId,b.result]]));break}case"ActionResponse":{this.requestManager.onResponse(v);break}case"AuthError":{this.authenticationManager.onAuthError(v);break}case"FatalError":{const b=S1e(this.logger,v.error);throw this.webSocketManager.terminate(),b}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:r.onServerDisconnectError},i,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),r.expectAuth&&h()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()||this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const n=this.remoteQuerySet.remoteQueryResults(),r=new Map;for(const[i,a]of n){const l=this.state.queryToken(i);if(l!==null){const u={result:a,udfPath:this.state.queryPath(i),args:this.state.queryArgs(i)};r.set(l,u)}}const s=this.optimisticQueryResults.ingestQueryResultsFromServer(r,new Set(e.keys()));this.handleTransition({queries:s.map(i=>{const a=this.optimisticQueryResults.rawQueryResult(i);return{token:i,modification:{kind:"Updated",result:a.result}}}),reflectedMutations:Array.from(e).map(([i,a])=>({requestId:i,result:a})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const n of this._onTransitionFns.values())n(e)}addOnTransitionHandler(e){const n=this._transitionHandlerCounter++;return this._onTransitionFns.set(n,e),()=>this._onTransitionFns.delete(n)}getCurrentAuthClaims(){const e=this.state.getAuth();let n={};if(e&&e.tokenType==="User")try{n=e?c7(e.value):{}}catch{n={}}else return;return{token:e.value,decoded:n}}setAuth(e,n){this.authenticationManager.setConfig(e,n)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,n){const r=this.state.setAdminAuth(e,n);this.webSocketManager.sendMessage(r)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,n,r){const s=So(n),{modification:i,queryToken:a,unsubscribe:l}=this.state.subscribe(e,s,r?.journal,r?.componentPath);return i!==null&&this.webSocketManager.sendMessage(i),{queryToken:a,unsubscribe:()=>{const u=l();u&&this.webSocketManager.sendMessage(u)}}}localQueryResult(e,n){const r=So(n),s=iu(e,r);return this.optimisticQueryResults.queryResult(s)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,n){const r=So(n),s=iu(e,r);return this.optimisticQueryResults.queryLogs(s)}queryJournal(e,n){const r=So(n),s=iu(e,r);return this.state.queryJournal(s)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const n=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(n,e),()=>{this.connectionStateSubscribers.delete(n)}}async mutation(e,n,r){const s=await this.mutationInternal(e,n,r);if(!s.success)throw s.errorData!==void 0?TC(s,new kC(Xd("mutation",e,s))):new Error(Xd("mutation",e,s));return s.value}async mutationInternal(e,n,r,s){const{mutationPromise:i}=this.enqueueMutation(e,n,r,s);return i}enqueueMutation(e,n,r,s){const i=So(n);this.tryReportLongDisconnect();const a=this.nextRequestId;if(this._nextRequestId++,r!==void 0){const p=r.optimisticUpdate;if(p!==void 0){const h=b=>{p(b,i)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},v=this.optimisticQueryResults.applyOptimisticUpdate(h,a).map(b=>{const x=this.localQueryResultByToken(b);return{token:b,modification:{kind:"Updated",result:x===void 0?void 0:{success:!0,value:x,logLines:[]}}}});this.handleTransition({queries:v,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const l={type:"Mutation",requestId:a,udfPath:e,componentPath:s,args:[Ql(i)]},u=this.webSocketManager.sendMessage(l),d=this.requestManager.request(l,u);return{requestId:a,mutationPromise:d}}async action(e,n){const r=await this.actionInternal(e,n);if(!r.success)throw r.errorData!==void 0?TC(r,new kC(Xd("action",e,r))):new Error(Xd("action",e,r));return r.value}async actionInternal(e,n,r){const s=So(n),i=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const a={type:"Action",requestId:i,udfPath:e,componentPath:r,args:[Ql(s)]},l=this.webSocketManager.sendMessage(a);return this.requestManager.request(a,l)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=uke(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=60*1e3)return;const n=`${this.address}/api/debug_event`;fetch(n,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${I4}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(r=>{r.ok||this.logger.warn("Analytics request failed with response:",r.body)}).catch(r=>{this.logger.warn("Analytics response failed with error:",r)})}}function pke({getCurrentValue:t,subscribe:e}){const[n,r]=w.useState(()=>({getCurrentValue:t,subscribe:e,value:t()}));let s=n.value;return(n.getCurrentValue!==t||n.subscribe!==e)&&(s=t(),r({getCurrentValue:t,subscribe:e,value:s})),w.useEffect(()=>{let i=!1;const a=()=>{i||r(u=>{if(u.getCurrentValue!==t||u.subscribe!==e)return u;const d=t();return u.value===d?u:{...u,value:d}})},l=e(a);return a(),()=>{i=!0,l()}},[t,e]),s}var mke=Object.defineProperty,gke=(t,e,n)=>e in t?mke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_l=(t,e,n)=>gke(t,typeof e!="symbol"?e+"":e,n);const vke=5e3;if(typeof Ee>"u")throw new Error("Required dependency 'react' not found");function u7(t,e,n){function r(s){return Ske(s),e.mutation(t,s,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(i){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${Ps(t)}`);return u7(t,e,i)},r}function yke(t,e){return function(n){return e.action(t,n)}}class bke{constructor(e,n){if(_l(this,"address"),_l(this,"cachedSync"),_l(this,"listeners"),_l(this,"options"),_l(this,"closed",!1),_l(this,"_logger"),_l(this,"adminAuth"),_l(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=n?.logger===!1?a7({verbose:n?.verbose??!1}):n?.logger!==!0&&n?.logger?n.logger:i7({verbose:n?.verbose??!1}),this.options={...n,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=new hke(this.address,e=>this.transition(e),this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedSync)}setAuth(e,n){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,n??(()=>{}))}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,n){if(this.adminAuth=e,this.fakeUserIdentity=n,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,n)}watchQuery(e,...n){const[r,s]=n,i=Ps(e);return{onUpdate:a=>{const{queryToken:l,unsubscribe:u}=this.sync.subscribe(i,r,s),d=this.listeners.get(l);return d!==void 0?d.add(a):this.listeners.set(l,new Set([a])),()=>{if(this.closed)return;const p=this.listeners.get(l);p.delete(a),p.size===0&&this.listeners.delete(l),u()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(i,r)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(i,r)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(i,r)}}}prewarmQuery(e){const n=e.extendSubscriptionFor??vke,s=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(s,n)}mutation(e,...n){const[r,s]=n,i=Ps(e);return this.sync.mutation(i,r,s)}action(e,...n){const r=Ps(e);return this.sync.action(r,...n)}query(e,...n){const r=this.watchQuery(e,...n),s=r.localQueryResult();return s!==void 0?Promise.resolve(s):new Promise((i,a)=>{const l=r.onUpdate(()=>{l();try{i(r.localQueryResult())}catch(u){a(u)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}transition(e){for(const n of e){const r=this.listeners.get(n);if(r)for(const s of r)s()}}}const G0=Ee.createContext(void 0);function xke(){return w.useContext(G0)}const _ke=({client:t,children:e})=>Ee.createElement(G0.Provider,{value:t},e);function Sx(t,...e){const n=e[0]==="skip",r=e[0]==="skip"?{}:So(e[0]),s=typeof t=="string"?rj(t):t,i=Ps(s),a=w.useMemo(()=>n?{}:{query:{query:s,args:r}},[JSON.stringify(Ql(r)),i,n]),u=Cke(a).query;if(u instanceof Error)throw u;return u}function d7(t){const e=typeof t=="string"?rj(t):t,n=w.useContext(G0);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return w.useMemo(()=>u7(e,n),[n,Ps(e)])}function wke(t){const e=w.useContext(G0),n=rj(t);if(e===void 0)throw new Error("Could not find Convex client! `useAction` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return w.useMemo(()=>yke(n,e),[e,Ps(n)])}function Ske(t){if(typeof t=="object"&&t!==null&&"bubbles"in t&&"persist"in t&&"isDefaultPrevented"in t)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var Eke=Object.defineProperty,kke=(t,e,n)=>e in t?Eke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$1=(t,e,n)=>kke(t,typeof e!="symbol"?e+"":e,n);class Tke{constructor(e){$1(this,"createWatch"),$1(this,"queries"),$1(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const n of Object.keys(e)){const{query:r,args:s}=e[n];if(Ps(r),this.queries[n]===void 0)this.addQuery(n,r,s);else{const i=this.queries[n];(Ps(r)!==Ps(i.query)||JSON.stringify(Ql(s))!==JSON.stringify(Ql(i.args)))&&(this.removeQuery(n),this.addQuery(n,r,s))}}for(const n of Object.keys(this.queries))e[n]===void 0&&this.removeQuery(n)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const n={};for(const r of Object.keys(e)){const{query:s,args:i}=e[r];Ps(s);const a=this.createWatch(s,i);let l;try{l=a.localQueryResult()}catch(u){if(u instanceof Error)l=u;else throw u}n[r]=l}return n}setCreateWatch(e){this.createWatch=e;for(const n of Object.keys(this.queries)){const{query:r,args:s,watch:i}=this.queries[n],a=i.journal();this.removeQuery(n),this.addQuery(n,r,s,a)}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,n,r,s){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const i=this.createWatch(n,r,s),a=i.onUpdate(()=>this.notifyListeners());this.queries[e]={query:n,args:r,watch:i,unsubscribe:a}}removeQuery(e){const n=this.queries[e];if(n===void 0)throw new Error(`No query found with identifier ${e}.`);n.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}}function Cke(t){const e=xke();if(e===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");const n=w.useMemo(()=>(r,s,i)=>e.watchQuery(r,s,i?{journal:i}:{}),[e]);return Ake(t,n)}function Ake(t,e){const[n]=w.useState(()=>new Tke(e));n.createWatch!==e&&n.setCreateWatch(e),w.useEffect(()=>()=>n.destroy(),[n]);const r=w.useMemo(()=>({getCurrentValue:()=>n.getLocalResults(t),subscribe:s=>(n.setQueries(t),n.subscribe(s))}),[n,t]);return pke(r)}const f7=w.createContext(void 0);function Xa(){const t=w.useContext(f7);if(t===void 0)throw new Error("Could not find `ConvexProviderWithAuth` (or `ConvexProviderWithClerk` or `ConvexProviderWithAuth0`) as an ancestor component. This component may be missing, or you might have two instances of the `convex/react` module loaded in your project.");return t}function Nke({children:t,client:e,useAuth:n}){const{isLoading:r,isAuthenticated:s,fetchAccessToken:i}=n(),[a,l]=w.useState(null);return r&&a!==null&&l(null),!r&&!s&&a!==!1&&l(!1),Ee.createElement(f7.Provider,{value:{isLoading:a===null,isAuthenticated:s&&(a??!1)}},Ee.createElement(Rke,{authProviderAuthenticated:s,fetchAccessToken:i,authProviderLoading:r,client:e,setIsConvexAuthenticated:l}),Ee.createElement(_ke,{client:e},t),Ee.createElement(jke,{authProviderAuthenticated:s,fetchAccessToken:i,authProviderLoading:r,client:e,setIsConvexAuthenticated:l}))}function Rke({authProviderAuthenticated:t,fetchAccessToken:e,authProviderLoading:n,client:r,setIsConvexAuthenticated:s}){return w.useEffect(()=>{let i=!0;if(t)return r.setAuth(e,a=>{i&&s(()=>a)}),()=>{i=!1,s(a=>a?!1:null)}},[t,e,n,r,s]),null}function jke({authProviderAuthenticated:t,fetchAccessToken:e,authProviderLoading:n,client:r,setIsConvexAuthenticated:s}){return w.useEffect(()=>{if(t)return()=>{r.clearAuth(),s(()=>null)}},[t,e,n,r,s]),null}const Mke=t=>{const e=new Map;return t.forEach(n=>{const r=e.get(n.provider)||[];e.set(n.provider,[...r,n])}),e},q4=t=>{switch(t){case"anthropic":return"Anthropic";case"openai":return"OpenAI";case"deepseek":return"DeepSeek";case"google":return"Google AI";case"ollama":return"Ollama";case"meta":return"Meta";case"x-ai":return"xAI";default:return t}};function h7({currentModel:t,availableModels:e,onModelChange:n,disabled:r,isLoading:s,hideProvidedModels:i=!1}){const[a,l]=w.useState(!1),u=t,{isAuthenticated:d}=Xa(),p=Mke(e),h=Array.from(p.keys()).sort(),g=i?[]:h.filter(b=>(p.get(b)||[]).some(E=>ea(E.id))),v=h.filter(b=>(p.get(b)||[]).some(E=>!ea(E.id)));return f.jsxs(p0,{open:a,onOpenChange:l,children:[f.jsx(m0,{asChild:!0,children:f.jsx(Ie,{variant:"ghost",size:"sm",disabled:r||s,className:"h-8 px-2 rounded-full hover:bg-muted/80 transition-colors text-xs cursor-pointer",children:f.jsxs(f.Fragment,{children:[f.jsx(M1,{provider:u.provider}),f.jsx("span",{className:"text-[10px] font-medium",children:u.name})]})})}),f.jsxs(g0,{align:"start",className:"min-w-[200px]",children:[g.length>0&&f.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"MCPJam Provided Models"}),g.map(b=>{const E=(p.get(b)||[]).filter(k=>ea(k.id)),S=E.length;return f.jsxs(fI,{children:[f.jsxs(hI,{className:"flex items-center gap-3 text-sm cursor-pointer",children:[f.jsx(M1,{provider:b}),f.jsxs("div",{className:"flex flex-col flex-1",children:[f.jsx("span",{className:"font-medium",children:q4(b)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," model",S!==1?"s":""]})]})]}),f.jsx(pI,{className:"min-w-[200px] max-h-[180px] overflow-y-auto",avoidCollisions:!0,collisionPadding:8,children:E.map(k=>{const T=ea(k.id),R=!!k.disabled||T&&!d,j=T&&!d?"Sign in to use MCPJam provided models":k.disabledReason,A=f.jsxs(To,{onSelect:()=>{n(k),l(!1)},className:"flex items-center gap-3 text-sm cursor-pointer",disabled:R,children:[f.jsx("div",{className:"flex flex-col flex-1",children:f.jsx("span",{className:"font-medium",children:k.name})}),k.id===t.id&&f.jsx("div",{className:"ml-auto w-2 h-2 bg-primary rounded-full"})]},k.id);return R?f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx("div",{className:"pointer-events-auto",children:A})}),f.jsx(Pa,{side:"right",children:j})]},k.id):A})})]},b)}),g.length>0&&v.length>0&&f.jsx("div",{className:"my-1 h-px bg-muted/50"}),v.length>0&&f.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"Your providers"}),v.map(b=>{const E=(p.get(b)||[]).filter(k=>!ea(k.id)),S=E.length;return f.jsxs(fI,{children:[f.jsxs(hI,{className:"flex items-center gap-3 text-sm cursor-pointer",children:[f.jsx(M1,{provider:b}),f.jsxs("div",{className:"flex flex-col flex-1",children:[f.jsx("span",{className:"font-medium",children:q4(b)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[S," model",S!==1?"s":""]})]})]}),f.jsx(pI,{className:"min-w-[200px] max-h-[180px] overflow-y-auto",avoidCollisions:!0,collisionPadding:8,children:E.map(k=>{const T=!!k.disabled,R=f.jsxs(To,{onSelect:()=>{n(k),l(!1)},className:"flex items-center gap-3 text-sm cursor-pointer",disabled:T,children:[f.jsx("div",{className:"flex flex-col flex-1",children:f.jsx("span",{className:"font-medium",children:k.name})}),k.id===t.id&&f.jsx("div",{className:"ml-auto w-2 h-2 bg-primary rounded-full"})]},k.id);return T?f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx("div",{className:"pointer-events-auto",children:R})}),f.jsx(Pa,{side:"right",children:k.disabledReason})]},k.id):R})})]},b)})]})]})}function Oke({className:t,defaultValue:e,value:n,min:r=0,max:s=100,...i}){const a=w.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,s],[n,e,r,s]);return f.jsxs(rre,{"data-slot":"slider",defaultValue:e,value:n,min:r,max:s,className:Me("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",t),...i,children:[f.jsx(sre,{"data-slot":"slider-track",className:Me("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:f.jsx(ire,{"data-slot":"slider-range",className:Me("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:a.length},(l,u)=>f.jsx(are,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},u))]})}function Pke({systemPrompt:t,onSystemPromptChange:e,temperature:n,onTemperatureChange:r,disabled:s,isLoading:i}){const[a,l]=w.useState(!1),[u,d]=w.useState(t),[p,h]=w.useState(n),g=x=>{l(x),x&&(d(t),h(n))},v=()=>{e(u),r(p),l(!1),It.success("System prompt and temperature updated")},b=()=>{d(t),h(n),l(!1)};return f.jsxs(aa,{open:a,onOpenChange:g,children:[f.jsx(eN,{asChild:!0,children:f.jsxs(Ie,{variant:"ghost",size:"sm",disabled:s||i,className:"h-8 px-2 rounded-full hover:bg-muted/80 transition-colors text-xs cursor-pointer",children:[f.jsx(lie,{className:"h-2 w-2 mr-1"}),f.jsx("span",{className:"text-[10px] font-medium",children:"System Prompt & Temperature"})]})}),f.jsxs(oa,{className:"sm:max-w-md",children:[f.jsx(la,{children:f.jsx(ca,{children:"System Prompt & Temperature"})}),f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-sm font-medium",children:"System Prompt"}),f.jsx(Ho,{value:u,onChange:x=>d(x.target.value),placeholder:"You are a helpful assistant with access to MCP tools.",className:"h-[140px] resize-none"})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("label",{className:"text-sm font-medium",children:"Temperature"}),f.jsx("span",{className:"text-sm text-muted-foreground",children:p.toFixed(1)})]}),f.jsx(Oke,{value:[p],onValueChange:x=>h(x[0]),min:0,max:2,step:.1,className:"w-full"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Lower values (0-0.3) for focused tasks, higher values (0.7-2.0) for creative tasks"})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Ie,{variant:"ghost",onClick:b,className:"cursor-pointer",children:"Cancel"}),f.jsx(Ie,{onClick:v,className:"cursor-pointer",children:"Save"})]})]})]})]})}function V4({value:t,onChange:e,onSubmit:n,onStop:r,disabled:s=!1,isLoading:i=!1,placeholder:a="Type your message...",className:l,showScrollToBottom:u=!1,onScrollToBottom:d,currentModel:p,availableModels:h,onModelChange:g,systemPrompt:v,onSystemPromptChange:b,temperature:x,onTemperatureChange:E,isSendBlocked:S=!1}){const k=w.useRef(null),T=w.useRef(null),[R,j]=w.useState([]),[A,N]=w.useState([]),M=p;w.useEffect(()=>{I()},[t]);const I=()=>{k.current&&(k.current.style.height="auto",k.current.style.height=`${Math.min(k.current.scrollHeight,120)}px`)},O=()=>{k.current&&(k.current.style.height="auto")},L=w.useCallback(()=>{!t.trim()||s||i||A.length>0||S||(n(t.trim(),R.length>0?R:void 0),e(""),j([]),O(),setTimeout(()=>{k.current?.focus()},0))},[t,s,i,A.length,n,R,e,S]),z=X=>{X.key==="Enter"&&!X.shiftKey&&!X.nativeEvent.isComposing&&(X.preventDefault(),L())},G=w.useCallback(async X=>{const F=Array.from(X.target.files||[]);if(F.length!==0){N(F.map(Y=>Y.name));try{const Y=await Promise.all(F.map(async H=>(await new Promise(te=>setTimeout(te,1e3)),{id:Math.random().toString(36).substr(2,9),name:H.name,url:URL.createObjectURL(H),contentType:H.type,size:H.size})));j(H=>[...H,...Y])}catch(Y){console.error("Error uploading files:",Y)}finally{N([]),T.current&&(T.current.value="")}}},[]),W=X=>{j(F=>F.filter(Y=>Y.id!==X))};return f.jsxs("div",{className:"relative w-full",children:[f.jsx(hx,{children:u&&f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"absolute left-1/2 bottom-full mb-4 -translate-x-1/2 z-50",children:f.jsx(Ie,{size:"sm",variant:"outline",className:"rounded-full shadow-lg cursor-pointer",onClick:d,children:f.jsx(Bre,{className:"h-4 w-4"})})})}),f.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:G,accept:"image/*,.pdf,.txt,.json,.csv"}),(R.length>0||A.length>0)&&f.jsxs("div",{className:"mb-3 flex flex-wrap gap-2",children:[R.map(X=>f.jsxs("div",{className:"flex items-center gap-2 bg-muted px-3 py-2 rounded-lg text-sm",children:[f.jsx("span",{className:"truncate max-w-[200px]",children:X.name}),f.jsx("button",{onClick:()=>W(X.id),className:"text-muted-foreground hover:text-foreground cursor-pointer",children:"×"})]},X.id)),A.map(X=>f.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 px-3 py-2 rounded-lg text-sm animate-pulse",children:[f.jsx("span",{className:"truncate max-w-[200px]",children:X}),f.jsx("div",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"})]},X))]}),f.jsxs("div",{className:"relative",children:[f.jsx(Ho,{ref:k,value:t,onChange:X=>{S||e(X.target.value)},onKeyDown:z,placeholder:a,disabled:s,readOnly:s||S,className:kT("min-h-[56px] max-h-[120px] resize-none pl-16 pr-14 py-4 rounded-3xl","border-border/30 bg-background/50 focus-visible:border-border/50","focus-visible:ring-0 focus-visible:ring-offset-0","transition-all duration-200 ease-in-out overflow-y-auto","text-base placeholder:text-muted-foreground/60",S?"cursor-not-allowed bg-muted/30 text-muted-foreground":"",l),rows:1,autoFocus:!S}),f.jsx("div",{className:"absolute bottom-3 left-4 flex items-center gap-1",children:f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-full hover:bg-muted/80 transition-colors cursor-pointer",onClick:()=>T.current?.click(),disabled:s||i||S,children:f.jsx(Xse,{size:16})})}),f.jsx(Pa,{children:"Add files"})]})}),f.jsx("div",{className:"absolute bottom-3 right-4 flex items-center gap-1",children:i?f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",size:"sm",variant:"outline",className:"h-8 w-8 p-0 rounded-full border-border/30 hover:border-border/50 transition-colors cursor-pointer",onClick:r,children:f.jsx(yie,{size:16})})}),f.jsx(Pa,{children:"Stop generating"})]}):f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",size:"sm",className:kT("h-8 w-8 p-0 rounded-full transition-all duration-200 cursor-pointer",t.trim()&&!s&&A.length===0&&!S?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground cursor-not-allowed"),onClick:L,disabled:!t.trim()||s||A.length>0||S,children:f.jsx(hB,{size:16})})}),f.jsx(Pa,{children:"Send message"})]})})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[h.length>0&&M&&f.jsx(h7,{currentModel:M,availableModels:h,onModelChange:g,disabled:!1,isLoading:i}),b&&E&&f.jsx(Pke,{systemPrompt:v||"You are a helpful assistant with access to MCP tools.",onSystemPromptChange:b,temperature:x||0,onTemperatureChange:E,disabled:s,isLoading:i})]})]})}function Ike({serverConfigs:t,connectedServerConfigs:e,systemPrompt:n=""}){const r=w.useRef(null),[s,i]=w.useState(!0),{isAuthenticated:a}=Xa(),{signUp:l}=da(),u=ua(),[d,p]=w.useState(n||"You are a helpful assistant with access to MCP tools."),[h,g]=w.useState(1),[v,b]=w.useState({}),E=Object.keys(t||{}).filter(ae=>e?.[ae]?.connectionStatus==="connected"),S=E.length===0,{messages:k,isLoading:T,error:R,input:j,setInput:A,sendMessage:N,stopGeneration:M,regenerateMessage:I,clearChat:O,model:L,availableModels:z,setModel:G,elicitationRequest:W,elicitationLoading:X,handleElicitationResponse:F}=fV({systemPrompt:d,temperature:h,selectedServers:E,onError:ae=>{It.error(ae)}}),H=(L?ea(L.id):!1)&&!a,te="Sign in to use MCPJam provided models";w.useEffect(()=>{H&&A("")},[H,A]),w.useEffect(()=>{const ae=localStorage.getItem("chat-selected-model");if(ae&&z.length>0){const B=z.find(J=>J.id===ae);B&&(!L||L.id!==ae)&&G(B)}},[z]),w.useEffect(()=>{L&&localStorage.setItem("chat-selected-model",L.id)},[L]),w.useEffect(()=>{L&&g(Ede(L))},[L]),w.useEffect(()=>{const ae=async()=>{const B={};for(const J of E)try{const oe=await AN(J);oe.toolsMetadata&&Object.assign(B,oe.toolsMetadata)}catch(oe){console.error(`Failed to fetch tools for server ${J}:`,oe)}b(B)};E&&E.length>0?ae():b({})},[JSON.stringify(E)]);const P=k.length>0,re=H||S,ue=H?"Sign in to use free chat":"Connect an MCP server to send your first message",D=[{label:"Available tools",value:"What tools are available?",icon:yB}];w.useEffect(()=>{s&&r.current&&(r.current.scrollTop=r.current.scrollHeight)},[k,s]);const Z=()=>{if(!r.current)return;const{scrollTop:ae,scrollHeight:B,clientHeight:J}=r.current,fe=B-ae-J<100;i(fe)},he=ae=>{navigator.clipboard.writeText(ae)},V=async(ae,B)=>{try{const oe=await(await fetch("/api/mcp/tools/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolName:ae,parameters:B,...E.length===1?{serverId:E[0]}:{}})})).json();return console.log("handleCallTool",oe),oe.result}catch(J){throw console.error("handleCallTool",J),J}},U=ae=>{A(ae),N(ae)},K=(ae,B)=>f.jsxs("div",{className:"flex flex-col h-screen",children:[f.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4",children:[f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.35},className:"w-full max-w-xl space-y-6 text-center",children:ae}),f.jsxs(ei.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.35,delay:.05},className:"w-full max-w-2xl pt-10",children:[f.jsx(V4,{value:j,onChange:A,onSubmit:()=>{u.capture("send_message",{location:"chat_tab",platform:Ni(),environment:void 0,model_id:L?.id??null,model_name:L?.name??null,model_provider:L?.provider??null}),N(j)},onStop:M,disabled:z.length===0||B.disabled,isLoading:T,placeholder:B.placeholder,className:"border shadow-sm",currentModel:L||null,availableModels:z,onModelChange:G,onClearChat:O,hasMessages:!1,systemPrompt:d,onSystemPromptChange:p,temperature:h,onTemperatureChange:g,isSendBlocked:H}),z.length===0&&f.jsx(ei.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:"mt-3 text-center text-xs text-muted-foreground",children:"Configure API keys in Settings or start Ollama to enable chat"})]})]}),f.jsx(ST,{elicitationRequest:W,onResponse:F,loading:X})]});if(!P&&re)return K(H?f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("h2",{className:"text-base font-medium",children:"Create an account to use free models"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"or bring your own API key in the settings tab"})]}),f.jsx("div",{className:"flex justify-center gap-2",children:f.jsx(Ie,{onClick:()=>{u.capture("create_account",{location:"chat_tab",platform:Ni(),environment:void 0}),l()},style:{backgroundColor:"#E55A3A"},className:"hover:opacity-90 cursor-pointer",children:"Create account"})})]}):f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"space-y-1",children:f.jsx("h2",{className:"text-base font-medium",children:"You must connect to an MCP server"})}),f.jsxs("div",{className:"flex justify-center gap-2 text-xs text-muted-foreground",children:[f.jsxs("a",{href:"#servers",className:"inline-flex items-center gap-1 rounded-full border px-3 py-1 transition hover:bg-muted/30",children:[f.jsx(ise,{className:"h-3 w-3"})," Add server"]}),f.jsxs("a",{href:"#settings",className:"inline-flex items-center gap-1 rounded-full border px-3 py-1 transition hover:bg-muted/30",children:[f.jsx(ZA,{className:"h-3 w-3"})," Settings"]})]})]}),{placeholder:ue,disabled:!0});if(!P){const ae=f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("h2",{className:"text-base font-medium",children:"Test your servers"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Start typing or choose a quick suggestion to begin."})]}),f.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:D.map(({label:B,value:J,icon:oe})=>f.jsxs("button",{type:"button",onClick:()=>A(J),className:"inline-flex items-center gap-2 rounded-full border border-border/60 px-3 py-1.5 text-xs transition hover:border-border hover:bg-muted/40 cursor-pointer",children:[f.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"}),B]},B))})]});return K(ae,{placeholder:"Send a message...",disabled:!1})}return f.jsx(h0,{children:f.jsxs("div",{className:"relative bg-background h-screen overflow-hidden",children:[f.jsx("div",{ref:r,onScroll:Z,className:"h-full overflow-y-auto pb-40",children:f.jsx("div",{className:"max-w-4xl mx-auto px-4 pt-8 pb-8",children:f.jsxs(hx,{mode:"popLayout",children:[k.map((ae,B)=>f.jsx(ei.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,delay:B*.05},className:"mb-8",children:f.jsx(t1e,{message:ae,model:L||null,isLoading:T&&B===k.length-1,onEdit:()=>{},onRegenerate:I,onCopy:he,showActions:!0,serverConfigs:t,onCallTool:V,onSendFollowup:U,toolsMetadata:v,serverId:E.length===1?E[0]:void 0})},ae.id)),T&&k.length>0&&k[k.length-1].role==="user"&&f.jsx(ei.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"mb-8",children:f.jsxs("div",{className:"flex gap-4 items-start",children:[f.jsx("div",{className:"w-8 h-8 flex items-center rounded-full justify-center bg-muted/50 shrink-0",children:f.jsx(gB,{className:"h-4 w-4 text-muted-foreground"})}),f.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:"Thinking"}),f.jsxs("div",{className:"flex space-x-1",children:[f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce delay-100"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce delay-200"})]})]})]})})]})})}),f.jsx(hx,{children:R&&f.jsx(ei.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"absolute bottom-40 left-0 right-0 px-4 py-3 bg-destructive/5 border-t border-destructive/10 z-10",children:f.jsx("div",{className:"max-w-4xl mx-auto",children:f.jsx("p",{className:"text-sm text-destructive",children:R})})})}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t border-border/50 bg-background/80 backdrop-blur-sm",children:f.jsx("div",{className:"max-w-4xl mx-auto p-4",children:f.jsx("div",{children:f.jsx(V4,{value:j,onChange:A,onSubmit:(ae,B)=>{u.capture("send_message",{location:"chat_tab",platform:Ni(),environment:void 0,model_id:L?.id??null,model_name:L?.name??null,model_provider:L?.provider??null}),N(ae,B)},onStop:M,disabled:z.length===0||S||H,isLoading:T,placeholder:H?te:"Send a message...",className:"border-2 shadow-sm",currentModel:L,availableModels:z,onModelChange:G,onClearChat:O,hasMessages:P,systemPrompt:d,onSystemPromptChange:p,temperature:h,onTemperatureChange:g,isSendBlocked:H})})})}),f.jsx(ST,{elicitationRequest:W,onResponse:F,loading:X})]})})}function p7(t,e,n){const r=n.reduce((i,a)=>(a.status==="pending"||a.status==="running"||a.result==="pending"?i.pending+=1:a.result==="passed"?i.passed+=1:a.result==="failed"?i.failed+=1:a.result==="cancelled"&&(i.cancelled+=1),i.tokens+=a.tokensUsed||0,i),{passed:0,failed:0,cancelled:0,pending:0,tokens:0}),s=new Map;for(const i of n){const a=i.testCaseId;if(!a)continue;if(!s.has(a)){const u=e.find(p=>p._id===a),d=n.filter(p=>p.testCaseId===a).length;s.set(a,{testCaseId:a,title:u?.title||"Untitled",provider:u?.provider||"",model:u?.model||"",runs:d,passed:0,failed:0,cancelled:0,tokens:0})}const l=s.get(a);i.status==="pending"||i.status==="running"||i.result==="pending"||(i.result==="passed"?l.passed+=1:i.result==="failed"?l.failed+=1:i.result==="cancelled"&&(l.cancelled+=1)),l.tokens+=i.tokensUsed||0}return{filteredIterations:n,totals:r,byCase:Array.from(s.values())}}function Dke(t,e,n,r){const s=[];return t>0&&s.push(`${t} passed`),e>0&&s.push(`${e} failed`),n>0&&s.push(`${n} cancelled`),r>0&&s.push(`${r} pending`),s.join(" · ")||"No results"}function Lke({suite:t,onSelectSuite:e}){const{isAuthenticated:n}=Xa(),{user:r}=da(),s=t.config?.environment.servers,a=Sx("evals:getAllTestCasesAndIterationsBySuite",n&&!!r?{suiteId:t._id}:"skip"),l=w.useMemo(()=>a?p7(t,a.testCases,a.iterations):null,[t,a]),u=Array.isArray(t.config?.tests)?t.config.tests.length:0,d=w.useMemo(()=>{if(!Array.isArray(s))return[];const g=s.filter(b=>typeof b=="string").map(b=>b.trim()).filter(Boolean);if(g.length<=2)return g;const v=g.length-2;return[...g.slice(0,2),`+${v} more`]},[s]),p=l?.filteredIterations.length??0,h=()=>{if(!l)return"bg-zinc-300/50";const{passed:g,failed:v,cancelled:b,pending:x}=l.totals;if(g+v+b+x===0)return"bg-zinc-300/50";const S=g+v;if(S===0)return"bg-zinc-300/50";const k=v/S*100;return k===0?"bg-emerald-500/50":k<=30?"bg-amber-500/50":"bg-red-500/50"};return f.jsxs("button",{onClick:()=>e(t._id),className:"group relative flex w-full items-center gap-4 py-3 pl-4 pr-4 text-left transition-colors hover:bg-muted/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 cursor-pointer",children:[f.jsx("div",{className:`absolute left-0 top-0 h-full w-1 ${h()}`}),f.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] items-center gap-4",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"text-sm font-medium text-foreground",children:new Date(t._creationTime||0).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}),f.jsx("div",{className:"text-xs text-muted-foreground",children:d.length>0?d.join(", "):"No servers"})]}),f.jsxs("div",{className:"text-sm text-muted-foreground",children:[u," test",u!==1?"s":""," · ",p," ","iteration",p!==1?"s":""]}),f.jsx("div",{className:"text-sm text-muted-foreground",children:l?Dke(l.totals.passed,l.totals.failed,l.totals.cancelled,l.totals.pending):"Loading..."})]})]})}function $ke({suites:t,onSelectSuite:e}){if(t.length===0)return f.jsx("div",{className:"h-[calc(100vh-220px)] flex items-center justify-center rounded-xl border border-dashed",children:f.jsxs("div",{className:"text-center space-y-2",children:[f.jsx("div",{className:"text-lg font-semibold",children:"No evaluation suites yet"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Trigger a test run to see your evaluation history here."})]})});const n=[...t].sort((r,s)=>(s._creationTime||0)-(r._creationTime||0));return f.jsx("div",{className:"space-y-4",children:f.jsxs("div",{className:"overflow-hidden rounded-xl border",children:[f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] items-center gap-4 border-b bg-muted/50 px-4 py-2 text-xs font-semibold text-muted-foreground",children:[f.jsx("div",{children:"Created"}),f.jsx("div",{children:"Tests"}),f.jsx("div",{children:"Results"})]}),f.jsx("div",{className:"divide-y",children:n.map(r=>f.jsx(Lke,{suite:r,onSelectSuite:e},r._id))})]})})}function zke({iteration:t,testCase:e}){const n=wke("evals:getEvalTestBlob"),[r,s]=w.useState(null),[i,a]=w.useState(!1),[l,u]=w.useState(null);return w.useEffect(()=>{let d=!1;async function p(){if(!t.blob){s(null),a(!1),u(null);return}a(!0),u(null);try{const h=await n({blobId:t.blob});d||s(h)}catch(h){d||(u(h?.message||"Failed to load blob"),console.error("Blob load error:",h))}finally{d||a(!1)}}return p(),()=>{d=!0}},[t.blob,n]),f.jsxs("div",{className:"space-y-3 py-2",children:[(e?.expectedToolCalls.length||0)>0&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("div",{className:"text-xs font-semibold",children:"Expected tools"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:e?.expectedToolCalls.map((d,p)=>f.jsx(vr,{variant:"outline",className:"font-mono text-xs",children:d},p))})]}),t.actualToolCalls.length>0&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("div",{className:"text-xs font-semibold",children:"Actual tools called"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.actualToolCalls.map((d,p)=>f.jsx(vr,{variant:"outline",className:"font-mono text-xs",children:d},p))})]}),t.blob&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("div",{className:"text-xs font-semibold",children:"Trace"}),f.jsx("div",{className:"rounded-md bg-muted/20 p-3",children:i?f.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading trace"}):l?f.jsx("div",{className:"text-xs text-red-600",children:l}):f.jsx("pre",{className:"max-h-[360px] overflow-auto whitespace-pre-wrap break-words text-xs",children:JSON.stringify(r,null,2)})})]})]})}function Fke({suite:t,cases:e,iterations:n,aggregate:r,onBack:s}){const[i,a]=w.useState(null),[l,u]=w.useState(new Set),d=w.useMemo(()=>{const h=new Map,g=x=>{const E={runs:x.length,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null};let S=0,k=0;return x.forEach(T=>{T.result==="passed"?E.passed+=1:T.result==="failed"?E.failed+=1:T.result==="cancelled"?E.cancelled+=1:E.pending+=1,E.tokens+=T.tokensUsed||0;const R=T.startedAt??T.createdAt,j=T.updatedAt??T.createdAt;if(R&&j){const A=Math.max(j-R,0);S+=A,k+=1}}),k>0&&(E.avgDuration=S/k),E};e.forEach(x=>{h.set(x._id,{testCase:x,iterations:[],summary:{runs:0,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null}})});const v={testCase:null,iterations:[],summary:{runs:0,passed:0,failed:0,cancelled:0,pending:0,tokens:0,avgDuration:null}};n.forEach(x=>{const E=x.testCaseId?h.get(x.testCaseId):void 0;E?E.iterations.push(x):v.iterations.push(x)});const b=e.map(x=>{const E=h.get(x._id),S=[...E.iterations].sort((k,T)=>k.iterationNumber!=null&&T.iterationNumber!=null?k.iterationNumber-T.iterationNumber:(k.createdAt??0)-(T.createdAt??0));return{...E,iterations:S,summary:g(S)}});if(v.iterations.length>0){const x=[...v.iterations].sort((E,S)=>E.iterationNumber!=null&&S.iterationNumber!=null?E.iterationNumber-S.iterationNumber:(E.createdAt??0)-(S.createdAt??0));b.push({...v,iterations:x,summary:g(x)})}return b},[e,n]),p=h=>h==="passed"?"bg-emerald-500/50":h==="failed"?"bg-red-500/50":h==="cancelled"?"bg-zinc-300/50":"bg-amber-500/50";return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{children:f.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,children:"← Back to suites"})}),f.jsx("div",{className:"space-y-4",children:d.map((h,g)=>{const{testCase:v,iterations:b}=h,x=b.length>0,E=v?._id??`unassigned-${g}`,S=l.has(E),k=100,T=v?.query&&v.query.length>k,R=T&&!S?v.query.slice(0,k)+"...":v?.query,j=()=>{u(A=>{const N=new Set(A);return N.has(E)?N.delete(E):N.add(E),N})};return f.jsxs("div",{className:"overflow-hidden rounded-xl border",children:[f.jsx("div",{className:"border-b bg-muted/50 px-4 py-2.5",children:f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-semibold pr-2",children:v?v.title:"Unassigned iterations"}),v?.provider?f.jsx(f.Fragment,{children:f.jsx("span",{className:"text-xs text-muted-foreground",children:v.provider})}):null,v?.model?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-muted-foreground",children:"•"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:v.model})]}):null]}),v?.query?f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsxs("p",{className:"text-xs text-muted-foreground italic flex-1",children:['"',R,'"']}),T?f.jsx("button",{onClick:j,className:"text-xs text-primary hover:underline focus:outline-none whitespace-nowrap",children:S?"Show less":"Show more"}):null]}):null]})}),x?f.jsx("div",{className:"divide-y",children:b.map(A=>{const N=i===A._id,M=A.startedAt??A.createdAt,I=A.updatedAt??A.createdAt,O=M&&I?Math.max(I-M,0):null,L=A.result==="pending";return f.jsxs("div",{className:`relative ${L?"opacity-60":""}`,children:[f.jsx("div",{className:`absolute left-0 top-0 h-full w-1 ${p(A.result)}`}),f.jsx("button",{onClick:()=>{L||a(z=>z===A._id?null:A._id)},disabled:L,className:`flex w-full items-center gap-4 px-4 py-3 text-left transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${L?"cursor-not-allowed":"cursor-pointer hover:bg-muted/50"}`,children:f.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-[auto_1fr_auto_auto] items-center gap-4 pl-3",children:[f.jsx("div",{className:"text-muted-foreground",children:L?f.jsx(Ba,{className:"h-4 w-4"}):N?f.jsx(Au,{className:"h-4 w-4"}):f.jsx(Ba,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-sm font-medium",children:["Iteration #",A.iterationNumber]}),L?f.jsx(mu,{className:"h-4 w-4 animate-spin text-amber-600"}):null]}),f.jsx("div",{className:"text-sm text-muted-foreground",children:L?"—":`${Number(A.tokensUsed||0).toLocaleString()} tokens`}),f.jsx("div",{className:"text-sm text-muted-foreground",children:L?"—":O!==null?Uke(O):"—"})]})}),N&&!L?f.jsx("div",{className:"border-t bg-muted/20 px-4 pb-4 pt-3 pl-8",children:f.jsx(zke,{iteration:A,testCase:v})}):null]},A._id)})}):f.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No iterations recorded for this test case yet."})]},E)})})]})}function Uke(t){if(t<1e3)return`${t}ms`;const e=Math.round(t/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60),r=e%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;const s=Math.floor(n/60),i=n%60;return i?`${s}h ${i}m`:`${s}h`}function Bke(){const{isAuthenticated:t,isLoading:e}=Xa(),{user:n}=da(),[r,s]=w.useState(null),i=t&&!!n,a=Sx("evals:getCurrentUserEvalTestSuitesWithMetadata",i?{}:"skip"),l=t&&!!n&&!!r,u=Sx("evals:getAllTestCasesAndIterationsBySuite",l?{suiteId:r}:"skip"),d=a?.testSuites,p=a===void 0,h=l&&u===void 0,g=w.useMemo(()=>!r||!d?null:d.find(x=>x._id===r)??null,[r,d]),v=w.useMemo(()=>u?[...u.iterations].sort((x,E)=>(E.startedAt||E.createdAt)-(x.startedAt||x.createdAt)):[],[u]),b=w.useMemo(()=>!g||!u?null:p7(g,u.testCases,u.iterations),[g,u]);return e?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})})}):!t||!n?f.jsx("div",{className:"p-6",children:f.jsx(th,{icon:mB,title:"Sign in to view your evals",description:"Create an account or sign in to see previous runs and metrics.",className:"h-[calc(100vh-200px)]"})}):p&&i?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading your eval data..."})]})})}):f.jsxs("div",{className:"space-y-6 p-6",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsx("h1",{className:"text-2xl font-semibold",children:"Evaluation results"})}),g?h?f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading suite details..."})]})}):f.jsx(Fke,{suite:g,cases:u?.testCases||[],iterations:v,aggregate:b,onBack:()=>s(null)}):f.jsx($ke,{suites:d||[],onSelectSuite:s})]})}const qke="modulepreload",Vke=function(t){return"/"+t},H4={},Hke=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){let d=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};var a=d;document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=l?.nonce||l?.getAttribute("nonce");s=d(n.map(p=>{if(p=Vke(p),p in H4)return;H4[p]=!0;const h=p.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const v=document.createElement("link");if(v.rel=h?"stylesheet":qke,h||(v.as="script"),v.crossOrigin="",v.href=p,u&&v.setAttribute("nonce",u),document.head.appendChild(v),h)return new Promise((b,x)=>{v.addEventListener("load",b),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return s.then(l=>{for(const u of l||[])u.status==="rejected"&&i(u.reason);return e().catch(i)})},CC={servers:{},selectedServer:"none",selectedMultipleServers:[],isMultiSelectMode:!1},Ep=(t,e,n={})=>({...t,connectionStatus:e,...n});function Gke(t,e){switch(e.type){case"HYDRATE_STATE":return e.payload;case"UPSERT_SERVER":return{...t,servers:{...t.servers,[e.name]:e.server}};case"CONNECT_REQUEST":{const n=t.servers[e.name],r=n?Ep(n,"connecting",{enabled:!0}):{name:e.name,config:e.config,lastConnectionTime:new Date,connectionStatus:"connecting",retryCount:0,enabled:!0};return{...t,servers:{...t.servers,[e.name]:{...r,config:e.config}},selectedServer:e.select?e.name:t.selectedServer}}case"CONNECT_SUCCESS":{const n=t.servers[e.name];return n?{...t,servers:{...t.servers,[e.name]:Ep(n,"connected",{config:e.config,lastConnectionTime:new Date,retryCount:0,lastError:void 0,oauthTokens:e.tokens??n.oauthTokens,enabled:!0})}}:t}case"CONNECT_FAILURE":{const n=t.servers[e.name];return n?{...t,servers:{...t.servers,[e.name]:Ep(n,"failed",{retryCount:n.retryCount,lastError:e.error})}}:t}case"RECONNECT_REQUEST":{const n=t.servers[e.name];return n?{...t,servers:{...t.servers,[e.name]:Ep(n,"connecting",{enabled:!0})}}:t}case"DISCONNECT":{const n=t.servers[e.name];if(!n)return t;const r=t.selectedServer===e.name?"none":t.selectedServer;return{...t,servers:{...t.servers,[e.name]:Ep(n,"disconnected",{enabled:!1,lastError:e.error??n.lastError})},selectedServer:r,selectedMultipleServers:t.selectedMultipleServers.filter(s=>s!==e.name)}}case"REMOVE_SERVER":{const{[e.name]:n,...r}=t.servers;return{...t,servers:r,selectedServer:t.selectedServer===e.name?"none":t.selectedServer,selectedMultipleServers:t.selectedMultipleServers.filter(s=>s!==e.name)}}case"SYNC_AGENT_STATUS":{const n=new Map(e.servers.map(s=>[s.id,s.status])),r={};for(const[s,i]of Object.entries(t.servers)){if(i.connectionStatus==="connecting"||i.connectionStatus==="oauth-flow"){r[s]=i;continue}const l=n.get(s);l?r[s]={...i,connectionStatus:l}:r[s]={...i,connectionStatus:"disconnected"}}return{...t,servers:r}}case"SELECT_SERVER":return{...t,selectedServer:e.name};case"SET_MULTI_SELECTED":return{...t,selectedMultipleServers:e.names};case"SET_MULTI_MODE":return{...t,isMultiSelectMode:e.enabled,selectedMultipleServers:e.enabled?[]:t.selectedMultipleServers};default:return t}}const m7="mcp-inspector-state";function Wke(t){const e=t.config;let n=e;if(e&&typeof e.url=="string")try{n={...e,url:new URL(e.url)}}catch{}return{...t,config:n,connectionStatus:t.connectionStatus||"disconnected",retryCount:t.retryCount||0,lastConnectionTime:t.lastConnectionTime?new Date(t.lastConnectionTime):new Date,enabled:t.enabled!==!1}}function Yke(){try{const t=localStorage.getItem(m7);if(!t)return CC;const e=JSON.parse(t);return{servers:Object.fromEntries(Object.entries(e.servers||{}).map(([r,s])=>[r,Wke(s)])),selectedServer:e.selectedServer||"none",selectedMultipleServers:e.selectedMultipleServers||[],isMultiSelectMode:e.isMultiSelectMode||!1}}catch{return CC}}function Kke(t){const e={...t,servers:Object.fromEntries(Object.entries(t.servers).map(([n,r])=>{const s=r.config,i=s&&s.url instanceof URL?{...s,url:s.url.toString()}:s;return[n,{...r,config:i}]}))};localStorage.setItem(m7,JSON.stringify(e))}async function Ey(t,e){return(await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:t,serverId:e})})).json()}async function Xke(t){return(await fetch(`/api/mcp/servers/${encodeURIComponent(t)}`,{method:"DELETE"})).json()}async function Qke(){return(await fetch("/api/mcp/servers")).json()}async function Jke(t,e){return(await fetch("/api/mcp/servers/reconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:t,serverConfig:e})})).json()}async function Zke(t){if(!t.oauthTokens)return{kind:"ready",serverConfig:t.config,tokens:void 0};const e=await pN(t.name);if(e.success&&e.serverConfig)return{kind:"ready",serverConfig:e.serverConfig,tokens:Ji(t.name)};const n=t.config?.url?.toString?.();if(n){Nm(t.name);const r={serverName:t.name,serverUrl:n,clientId:t.oauthTokens?.client_id,clientSecret:t.oauthTokens?.client_secret},s=await Bb(r);return s.success&&s.serverConfig?{kind:"ready",serverConfig:s.serverConfig,tokens:Ji(t.name)}:s.success&&!s.serverConfig?{kind:"redirect"}:{kind:"error",error:s.error||"OAuth init failed"}}return{kind:"error",error:"OAuth refresh failed and no URL present"}}function z1(t){return t.type==="stdio"?{command:t.command,args:t.args,env:t.env}:{url:new URL(t.url),requestInit:{headers:t.headers||{}}}}function g7(){const t=GN("Connections"),[e,n]=w.useReducer(Gke,CC),[r,s]=w.useState(!0),i=w.useRef(new Map),a=A=>{const M=(i.current.get(A)??0)+1;return i.current.set(A,M),M},l=(A,N)=>(i.current.get(A)??0)!==N;w.useEffect(()=>{try{const A=Yke();n({type:"HYDRATE_STATE",payload:A})}catch(A){t.error("Failed to load saved state",{error:A instanceof Error?A.message:"Unknown error"})}finally{s(!1)}},[t]),w.useEffect(()=>{r||Kke(e)},[e,r]);const u=A=>{if(A.type==="stdio")return!A.command||A.command.trim()===""?"Command is required for STDIO connections":null;if(!A.url||A.url.trim()==="")return"URL is required for HTTP connections";try{new URL(A.url)}catch(N){return`Invalid URL format: ${A.url} ${N}`}return null},d=w.useCallback(()=>{const A=Object.entries(e.servers).filter(([,N])=>N.connectionStatus==="connected").map(([N])=>N);n({type:"SET_MULTI_SELECTED",names:A})},[e.servers]),p=w.useCallback(async A=>{window.history.replaceState({},document.title,window.location.pathname);try{const N=await KB(A);if(N.success&&N.serverConfig&&N.serverName){const M=N.serverName;n({type:"CONNECT_REQUEST",name:M,config:N.serverConfig,select:!0});try{const I=await Ey(N.serverConfig,M);I.success?(n({type:"CONNECT_SUCCESS",name:M,config:N.serverConfig,tokens:Ji(M)}),t.info("OAuth connection successful",{serverName:M}),It.success(`OAuth connection successful! Connected to ${M}.`)):(n({type:"CONNECT_FAILURE",name:M,error:I.error||"Connection test failed after OAuth"}),t.error("OAuth connection test failed",{serverName:M,error:I.error}),It.error(`OAuth succeeded but connection test failed: ${I.error}`))}catch(I){const O=I instanceof Error?I.message:"Unknown connection error";n({type:"CONNECT_FAILURE",name:M,error:O}),t.error("OAuth connection test error",{serverName:M,error:O}),It.error(`OAuth succeeded but connection test failed: ${O}`)}}else throw new Error(N.error||"OAuth callback failed")}catch(N){const M=N instanceof Error?N.message:"Unknown error";It.error(`Error completing OAuth flow: ${M}`),t.error("OAuth callback failed",{error:M})}},[t]);w.useEffect(()=>{if(!r){const A=new URLSearchParams(window.location.search),N=A.get("code"),M=A.get("error");N?p(N):M&&(It.error(`OAuth authorization failed: ${M}`),localStorage.removeItem("mcp-oauth-pending"),window.history.replaceState({},document.title,window.location.pathname))}},[r,p]);const h=w.useCallback(async A=>{const N=u(A);if(N){It.error(N);return}const M=z1(A);n({type:"CONNECT_REQUEST",name:A.name,config:M,select:!0});const I=a(A.name);try{if(A.type==="http"&&A.useOAuth&&A.url){n({type:"UPSERT_SERVER",name:A.name,server:{name:A.name,config:M,lastConnectionTime:new Date,connectionStatus:"oauth-flow",retryCount:0,enabled:!0}});const{initiateOAuth:L}=await Hke(async()=>{const{initiateOAuth:W}=await Promise.resolve().then(()=>mle);return{initiateOAuth:W}},void 0),z={serverName:A.name,serverUrl:A.url,clientId:A.clientId,clientSecret:A.clientSecret};A.oauthScopes&&A.oauthScopes.length>0&&(z.scopes=A.oauthScopes);const G=await L(z);if(G.success){if(G.serverConfig){const W=await Ey(G.serverConfig,A.name);if(l(A.name,I))return;W.success?(n({type:"CONNECT_SUCCESS",name:A.name,config:G.serverConfig,tokens:Ji(A.name)}),It.success("Connected successfully with OAuth!")):(n({type:"CONNECT_FAILURE",name:A.name,error:W.error||"OAuth connection test failed"}),It.error(`OAuth succeeded but connection failed: ${W.error}`))}else It.success("OAuth flow initiated. You will be redirected to authorize access.");return}else{if(l(A.name,I))return;n({type:"CONNECT_FAILURE",name:A.name,error:G.error||"OAuth initialization failed"}),It.error(`OAuth initialization failed: ${G.error}`);return}}const O=await Ey(M,A.name);if(l(A.name,I))return;O.success?(n({type:"CONNECT_SUCCESS",name:A.name,config:M}),t.info("Connection successful",{serverName:A.name}),It.success("Connected successfully!")):(n({type:"CONNECT_FAILURE",name:A.name,error:O.error||"Connection test failed"}),t.error("Connection failed",{serverName:A.name,error:O.error}),It.error(`Failed to connect to ${A.name}`))}catch(O){const L=O instanceof Error?O.message:"Unknown error";if(l(A.name,I))return;n({type:"CONNECT_FAILURE",name:A.name,error:L}),t.error("Connection failed",{serverName:A.name,error:L}),It.error(`Network error: ${L}`)}},[e.servers,t]),g=w.useRef(!1);w.useEffect(()=>{!r&&!g.current&&(g.current=!0,fetch("/api/mcp-cli-config").then(A=>A.json()).then(A=>{const N=A.config;if(N){if(N.servers&&Array.isArray(N.servers)){const M=N.autoConnectServer;t.info("Processing CLI-provided MCP servers (from config file)",{serverCount:N.servers.length,autoConnectServer:M||"all",cliConfig:N}),N.servers.forEach(I=>{const O={name:I.name||"CLI Server",type:I.type==="sse"?"http":I.type||"stdio",command:I.command,args:I.args||[],url:I.url,env:I.env||{}},L=z1(O);n({type:"UPSERT_SERVER",name:O.name,server:{name:O.name,config:L,lastConnectionTime:new Date,connectionStatus:"disconnected",retryCount:0,enabled:!1}}),!M||I.name===M?(t.info("Auto-connecting to server",{serverName:I.name}),h(O)):t.info("Skipping auto-connect for server",{serverName:I.name,reason:"filtered out"})});return}if(N.command){t.info("Auto-connecting to CLI-provided MCP server",{cliConfig:N});const M={name:N.name||"CLI Server",type:"stdio",command:N.command,args:N.args||[],env:N.env||{}};h(M)}}}).catch(A=>{t.debug("Could not fetch CLI config from API",{error:A})}))},[r,h,t,e.servers]);const v=w.useCallback(async A=>{const N=e.servers[A];return N?.oauthTokens&&N.oauthTokens.access_token||null},[e.servers]),b=w.useCallback(async A=>{t.info("Disconnecting from server",{serverName:A}),n({type:"DISCONNECT",name:A});try{const N=await Xke(A);N.success||n({type:"DISCONNECT",name:A,error:N.error})}catch(N){n({type:"DISCONNECT",name:A,error:N instanceof Error?N.message:"Unknown error"})}},[]),x=w.useCallback(async A=>{t.info("Removing server",{serverName:A}),Nm(A),n({type:"REMOVE_SERVER",name:A})},[]),E=w.useCallback(async A=>{t.info("Reconnecting to server",{serverName:A});const N=e.servers[A];if(!N)throw new Error(`Server ${A} not found`);n({type:"RECONNECT_REQUEST",name:A});const M=a(A);try{const I=await Zke(N);if(I.kind==="redirect")return;if(I.kind==="error"){if(l(A,M))return;n({type:"CONNECT_FAILURE",name:A,error:I.error}),It.error(`Failed to connect: ${A}`);return}const O=await Jke(A,I.serverConfig);if(l(A,M))return;if(O.success)return n({type:"CONNECT_SUCCESS",name:A,config:I.serverConfig,tokens:I.tokens}),t.info("Reconnection successful",{serverName:A,result:O}),{success:!0};{n({type:"CONNECT_FAILURE",name:A,error:O.error||"Reconnection failed"}),t.error("Reconnection failed",{serverName:A,result:O});const L=O.error||`Failed to reconnect: ${A}`;It.error(L)}}catch(I){const O=I instanceof Error?I.message:"Unknown error";if(l(A,M))return;throw n({type:"CONNECT_FAILURE",name:A,error:O}),t.error("Reconnection failed",{serverName:A,error:O}),I}},[e.servers]);w.useEffect(()=>{if(r)return;(async()=>{try{const N=await Qke();N?.success&&N.servers&&n({type:"SYNC_AGENT_STATUS",servers:N.servers})}catch(N){t.debug("Failed to sync server status on startup",{error:N instanceof Error?N.message:"Unknown error"})}})()},[r,t]);const S=w.useCallback(A=>{n({type:"SELECT_SERVER",name:A})},[]),k=w.useCallback(A=>{n({type:"SET_MULTI_SELECTED",names:A})},[]),T=w.useCallback(A=>{n({type:"SET_MULTI_MODE",enabled:A})},[]),R=w.useCallback(A=>{const N=e.selectedMultipleServers,M=N.includes(A)?N.filter(I=>I!==A):[...N,A];n({type:"SET_MULTI_SELECTED",names:M})},[e.selectedMultipleServers]),j=w.useCallback(async(A,N)=>{const M=e.servers[A];if(M?.oauthTokens!=null&&N.useOAuth&&N.name===A&&N.type==="http"&&N.url===(M?.config).url?.toString()&&M){const L=z1(N);n({type:"CONNECT_REQUEST",name:A,config:L});try{if((await Ey(M.config,A)).success){n({type:"CONNECT_SUCCESS",name:A,config:L}),It.success("Server configuration updated successfully!");return}else console.warn("OAuth connection test failed, falling back to full reconnect")}catch(z){console.warn("OAuth connection test error, falling back to full reconnect",z)}}await b(A),await h(N),e.selectedServer===A&&N.name!==A&&S(N.name)},[e.servers,e.selectedServer,b,h]);return{appState:e,isLoading:r,connectedServerConfigs:e.servers,selectedServerEntry:e.servers[e.selectedServer],selectedMCPConfig:e.servers[e.selectedServer]?.config,selectedMCPConfigs:e.selectedMultipleServers.map(A=>e.servers[A]).filter(Boolean),selectedMCPConfigsMap:e.selectedMultipleServers.reduce((A,N)=>(e.servers[N]&&(A[N]=e.servers[N].config),A),{}),isMultiSelectMode:e.isMultiSelectMode,handleConnect:h,handleDisconnect:b,handleReconnect:E,handleUpdate:j,handleRemoveServer:x,setSelectedServer:S,setSelectedMCPConfigs:k,toggleMultiSelectMode:T,toggleServerSelection:R,getValidAccessToken:v,setSelectedMultipleServersToAllServers:d}}function eTe({server:t,selected:e,onToggle:n}){const[r,s]=w.useState(null),[i,a]=w.useState(!1),{label:l,Icon:u,iconClassName:d,indicatorColor:p}=bB(t.connectionStatus),h=_B(t.config),g=xB(t.config),v=JSON.stringify(t.config,null,2),b=()=>{n(t.name)},x=k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),b())},E=async(k,T,R)=>{k.stopPropagation();try{await navigator.clipboard.writeText(T),s(R),setTimeout(()=>s(null),2e3)}catch(j){console.error("Failed to copy text:",j)}},S=t.connectionStatus==="failed"?`${l} (${t.retryCount} retries)`:l;return f.jsxs(Fa,{role:"button",tabIndex:0,onClick:b,onKeyDown:x,className:Me("relative gap-3 p-3 border border-border/40 bg-card/40 transition-colors","hover:border-border cursor-pointer",e&&"border-primary/60 ring-2 ring-primary/30"),children:[f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{"aria-hidden":!0,className:"h-2 w-2 flex-shrink-0 rounded-full",style:{backgroundColor:p}}),f.jsx("div",{className:"min-w-0",children:f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:t.name}),f.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[f.jsx(u,{className:d}),f.jsx("span",{children:S})]})]})})]}),e&&f.jsxs(vr,{variant:"secondary",className:"h-5 px-1 text-[11px]",children:[f.jsx(Ti,{className:"mr-1 h-3 w-3"}),"Selected"]})]}),f.jsx("p",{className:"mt-0.5 text-[11px] uppercase tracking-wide text-muted-foreground",children:h}),f.jsxs("div",{className:"relative break-all rounded border border-border/30 bg-muted/30 p-1.5 font-mono text-[11px] text-muted-foreground",children:[f.jsx("div",{className:"pr-6",children:g}),f.jsx("button",{type:"button",onClick:k=>E(k,g,"command"),className:"absolute right-1 top-1 cursor-pointer p-1 text-muted-foreground/60 transition-colors hover:text-foreground",children:r==="command"?f.jsx(Ti,{className:"h-3 w-3 text-green-500"}):f.jsx(Po,{className:"h-3 w-3"})})]}),i&&f.jsxs("div",{className:"relative rounded border border-border/20 bg-muted/20 p-1.5 font-mono text-[11px] text-muted-foreground",children:[f.jsx("pre",{className:"max-h-40 overflow-auto pr-6 whitespace-pre-wrap",children:v}),f.jsx("button",{type:"button",onClick:k=>E(k,v,"config"),className:"absolute right-1 top-1 cursor-pointer p-1 text-muted-foreground/60 transition-colors hover:text-foreground",children:r==="config"?f.jsx(Ti,{className:"h-3 w-3 text-green-500"}):f.jsx(Po,{className:"h-3 w-3"})})]}),f.jsx("div",{className:"flex justify-end pt-0.5",children:f.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),a(T=>!T)},"aria-label":i?"Hide config":"Show config",className:"rounded-full border border-border/50 bg-background/70 p-1 text-muted-foreground transition-colors hover:text-foreground",children:i?f.jsx(pB,{className:"h-3 w-3"}):f.jsx(Au,{className:"h-3 w-3"})})})]})}const G4="mcp-inspector-eval-runner-preferences",wl=[{key:"servers",title:"Select Servers",description:"Choose the MCP servers to evaluate."},{key:"model",title:"Choose Model",description:"Pick the model and ensure credentials are ready."},{key:"tests",title:"Define Tests",description:"Author the scenarios you want to run or generate them with AI."},{key:"review",title:"Review & Run",description:"Confirm the configuration before launching the run."}],F1=(t,e)=>({title:"",query:"",runs:1,model:e?.id??"",provider:e?.provider??"",expectedToolCalls:[]});function tTe({availableModels:t,inline:e=!1}){const[n,r]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(!1),[u,d]=w.useState(0),[p,h]=w.useState(null),{isAuthenticated:g}=Xa(),{getAccessToken:v}=da(),{appState:b}=g7(),{getToken:x,hasToken:E}=rR(),[S,k]=w.useState([]),[T,R]=w.useState(null),[j,A]=w.useState([F1(1,null)]),N=w.useMemo(()=>Object.entries(b.servers).filter(([,B])=>B.connectionStatus==="connected"),[b.servers]),M=w.useMemo(()=>new Set(N.map(([B])=>B)),[N]);w.useEffect(()=>{if(!(typeof window>"u"))try{const B=localStorage.getItem(G4);if(!B)return;const J=JSON.parse(B);h({servers:J.servers??[],modelId:J.modelId??null})}catch(B){console.warn("Failed to load eval runner preferences",B)}},[]),w.useEffect(()=>{if(p&&p.servers?.length){const B=p.servers.filter(J=>M.has(J));B.length&&k(B)}},[p,M]),w.useEffect(()=>{if(t.length===0){R(null);return}if(p?.modelId){const B=t.find(J=>J.id===p.modelId);if(B){R(B);return}}R(B=>B&&t.some(oe=>oe.id===B.id)?B:t[0])},[t,p]),w.useEffect(()=>{if(!(typeof window>"u"))try{const B={servers:S,modelId:T?.id??null};localStorage.setItem(G4,JSON.stringify(B))}catch(B){console.warn("Failed to persist eval runner preferences",B)}},[S,T]),w.useEffect(()=>{A(B=>T?B.map((J,oe)=>J.model===T.id&&J.provider===T.provider?J:{...J,model:T.id,provider:T.provider}):B)},[T]),w.useEffect(()=>{!e&&!n&&d(0)},[e,n]);const I=T?ea(T.id):!1,O=T?.provider,L=O?E(O):!1,z=w.useMemo(()=>j.filter(B=>B.query.trim().length>0),[j]),G=w.useMemo(()=>({servers:S.length>0,model:!!T&&(I||O&&L),tests:z.length>0}),[z.length,T,I,O,L,S.length]),W=w.useMemo(()=>G.servers?G.model?G.tests?3:2:1:0,[G]),X=w.useMemo(()=>{switch(u){case 0:return G.servers;case 1:return G.model;case 2:return G.tests;case 3:return G.tests&&G.servers&&G.model;default:return!1}},[u,G]),F=B=>{k(J=>J.includes(B)?J.filter(oe=>oe!==B):[...J,B])},Y=B=>{A(J=>{const oe=J.length,fe=Array.from({length:B},(be,Ae)=>F1(oe+Ae+1,T));return[...J,...fe]})},H=()=>{Y(1)},te=B=>{A(J=>J.filter((oe,fe)=>fe!==B))},P=(B,J,oe)=>{A(fe=>{const be=[...fe];return be[B]={...be[B],[J]:oe},be})},re=async()=>{if(!g){It.error("Please sign in to generate tests");return}if(S.length===0){It.error("Please select at least one server");return}l(!0);try{const B=await v(),J=await fetch("/api/mcp/evals/generate-tests",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverIds:S,convexAuthToken:B})}),oe=await J.json();if(!J.ok)throw new Error(oe.error||"Failed to generate tests");if(oe.tests&&oe.tests.length>0){const fe=oe.tests.map((be,Ae)=>({title:be.title||`Generated test ${Ae+1}`,query:be.query||"",runs:Number(be.runs)>0?Number(be.runs):1,model:T?.id||"",provider:T?.provider||"",expectedToolCalls:Array.isArray(be.expectedToolCalls)?be.expectedToolCalls:[]}));A(fe),d(2),It.success(`Generated ${fe.length} test case(s).`)}}catch(B){console.error("Failed to generate tests:",B),It.error(B instanceof Error?B.message:"Failed to generate test cases")}finally{l(!1)}},ue=()=>{u>=wl.length-1||X&&d(B=>Math.min(B+1,wl.length-1))},D=()=>{u!==0&&d(B=>Math.max(B-1,0))},Z=async()=>{if(!g){It.error("Please sign in to run evals");return}if(S.length===0){It.error("Please select at least one server"),d(0);return}if(!T){It.error("Please select a model"),d(1);return}const B=ea(T.id),J=!B&&O?x(O):"";if(!B&&(!O||!J)){It.error(`Please configure your ${T.provider} API key in Settings`),d(1);return}if(z.length===0){It.error("Please add at least one test case with a query"),d(2);return}i(!0);try{const oe=await v(),fe=z.map(Oe=>({...Oe,model:T.id,provider:T.provider})),be=await fetch("/api/mcp/evals/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tests:fe,serverIds:S,llmConfig:{provider:T.provider,apiKey:B?"router":J||"router"},convexAuthToken:oe})}),Ae=await be.json();if(!be.ok)throw new Error(Ae.error||"Failed to start evals");It.success(Ae.message||"Evals started successfully!"),A([F1(1,T)]),d(3),e||r(!1),window.location.hash="eval-results"}catch(oe){It.error(oe instanceof Error?oe.message:"Failed to start evals")}finally{i(!1)}},he=()=>{switch(wl[u].key){case"servers":return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg pb-2",children:"Select servers to test"}),f.jsx("p",{className:"text-sm text-muted-foreground pb-2",children:"Choose at least one connected MCP server. You can evaluate multiple servers in the same run."})]})}),N.length>0?f.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2 xl:grid-cols-3",children:N.map(([B,J])=>{const oe=S.includes(B);return f.jsx(eTe,{server:J,selected:oe,onToggle:F},B)})}):f.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:[f.jsx("p",{className:"font-medium text-foreground",children:"No connected servers yet"}),f.jsx("p",{className:"mt-2",children:"Launch a server from the Servers tab to make it available here. Once connected, it will appear instantly."})]})]});case"model":return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg pb-2",children:"Choose your evaluation model"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"For example, if you want to simulate using your server with Claude Desktop, select an Anthropic model."})]})}),t.length===0?f.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:[f.jsx("p",{className:"font-medium text-foreground",children:"No models available"}),f.jsx("p",{className:"mt-2",children:"Connect a provider or enable MCPJam provided models in Settings to unlock model selection."})]}):T?f.jsxs("div",{className:"space-y-3",children:[f.jsx("div",{className:"flex items-center gap-3",children:f.jsx(h7,{currentModel:T,availableModels:t,onModelChange:R})}),!I&&!L&&O&&f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/5 p-3 text-sm",children:[f.jsx(Tm,{className:"mt-0.5 h-4 w-4 text-destructive"}),f.jsxs("div",{children:[f.jsxs("p",{className:"font-medium text-destructive",children:["Add your ",T.provider," API key"]}),f.jsx("p",{className:"text-muted-foreground",children:"Configure credentials in Settings to run this model. Keys are stored locally and never sent to our servers."})]})]})]}):null]});case"tests":return f.jsxs("div",{className:"space-y-6",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg pb-2",children:"Define your test cases"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Create testing scenarios that simulate how real users would use your server."})]})}),!G.servers||!G.model?f.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:[f.jsx("p",{className:"font-medium text-foreground",children:"Finish previous steps first"}),f.jsx("p",{className:"mt-2",children:"Select at least one server and choose a model to unlock test authoring. That ensures generated tests know which stack to target."})]}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2",children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Ie,{type:"button",variant:"outline",size:"lg",onClick:re,disabled:a,children:[f.jsx("span",{className:"bg-gradient-to-r from-purple-600 via-violet-600 to-indigo-600 bg-clip-text text-transparent",children:a?"Generating...":"Generate tests"}),f.jsx(yB,{className:"h-4 w-4 ml-2 fill-purple-600"})]})})}),a&&f.jsx("div",{className:"flex items-center justify-center rounded-lg border p-6",children:f.jsx("div",{className:"text-center text-sm text-muted-foreground",children:"Generating test cases..."})}),!a&&f.jsxs("div",{className:"space-y-12",children:[j.map((B,J)=>f.jsxs("div",{className:"space-y-3 rounded-lg border bg-background p-4",children:[f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Title"}),f.jsx(Un,{className:"w-full",value:B.title,onChange:oe=>P(J,"title",oe.target.value),placeholder:"(Paypal) List transactions"})]}),j.length>1&&f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>te(J),children:f.jsx(Nu,{className:"h-4 w-4"})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Query"}),f.jsx(Ho,{value:B.query,onChange:oe=>P(J,"query",oe.target.value),placeholder:"Can you find the most recent Paypal transactions, then create an invoice?",rows:3})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Runs"}),f.jsx(Un,{type:"number",min:1,value:B.runs,onChange:oe=>P(J,"runs",Number(oe.target.value)>0?Number(oe.target.value):1)})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Hc,{className:"text-xs uppercase text-muted-foreground",children:"Expected tools (comma separated)"}),f.jsx(Un,{value:B.expectedToolCalls.join(", "),onChange:oe=>P(J,"expectedToolCalls",oe.target.value.split(",").map(fe=>fe.trim()).filter(Boolean)),placeholder:"paypal_list_transactions, paypal_create_invoice"})]})]})]},J)),f.jsxs(Ie,{type:"button",variant:"outline",onClick:H,"aria-label":"Add test",className:"w-full",children:[f.jsx(Ab,{className:"h-4 w-4 mr-2"}),"Add test case"]})]})]})]});case"review":return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h3",{className:"text-lg",children:"Review your tests"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"After confirming the run, you will see your run begin in the eval results tab."})]}),f.jsxs("div",{className:"space-y-4 rounded-lg border bg-background p-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Servers"}),f.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:S.map(B=>f.jsx(vr,{variant:"outline",children:B},B))})]}),f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(0),children:"Edit"})]}),f.jsx(Ck,{}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Model"}),T?f.jsx("div",{className:"mt-2 flex items-center gap-2",children:f.jsx(vr,{variant:"outline",children:T.name})}):f.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"No model selected"})]}),f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(1),children:"Edit"})]}),f.jsx(Ck,{}),f.jsxs("div",{className:"flex items-start justify-between gap-6",children:[f.jsxs("div",{className:"flex-1",children:[f.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Tests"}),f.jsx("div",{className:"mt-3 space-y-3",children:z.map((B,J)=>f.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[f.jsx("p",{className:"text-sm font-semibold text-foreground",children:B.title}),f.jsx("p",{className:"mt-1 line-clamp-2 text-sm text-muted-foreground",children:B.query}),f.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[f.jsxs("span",{children:[B.runs," run",B.runs===1?"":"s"]}),B.expectedToolCalls.length>0&&f.jsxs("span",{children:["Tools: ",B.expectedToolCalls.join(", ")]})]})]},J))})]}),f.jsx(Ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(2),children:"Edit"})]})]})]});default:return null}},V=f.jsx("ol",{className:"flex flex-col items-center gap-4 text-center md:flex-row md:gap-6",children:wl.map((B,J)=>{const oe=u===J,fe=J<u&&J<=W,be=J<=Math.max(W,u);return f.jsx("li",{className:"flex flex-col items-center gap-2",children:f.jsxs("button",{type:"button",onClick:()=>be?d(J):void 0,disabled:!be,className:Me("flex flex-col items-center gap-2 transition",!be&&"cursor-not-allowed opacity-60"),children:[f.jsx("span",{className:Me("flex h-8 w-8 items-center justify-center rounded-full border text-sm font-medium",fe&&"border-primary bg-primary text-primary-foreground",oe&&!fe&&"border-primary bg-primary/10 text-primary",!oe&&!fe&&"border-border text-muted-foreground"),children:J+1}),f.jsx("span",{className:Me("text-xs leading-tight",oe?"text-foreground":"text-muted-foreground"),children:B.title})]})},B.key)})}),U=u<wl.length-1?!X:s||!X,K=U?"secondary":"default",ae=f.jsxs("div",{className:Me("mx-auto flex w-full flex-col gap-8 pb-10 pt-4",e?"max-w-none px-4 sm:px-6 md:px-12 lg:px-32":"max-w-3xl px-4"),children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.jsxs(Ie,{type:"button",variant:"outline",onClick:D,disabled:u===0,"aria-label":"Back",className:"justify-center gap-2",children:[f.jsx(Kre,{className:"h-4 w-4"}),"Back"]}),f.jsx("div",{className:"flex flex-1 justify-center",children:f.jsx("div",{className:"max-w-xl",children:V})}),f.jsxs(Ie,{type:"button",variant:K,onClick:()=>{u<wl.length-1?ue():Z()},disabled:U,"aria-label":u===wl.length-1?"Start":"Next",className:Me("justify-center gap-2",!U&&"shadow-sm"),children:[u===wl.length-1?"Start":"Next",f.jsx(Ba,{className:"h-4 w-4"})]})]}),f.jsx("div",{className:"space-y-6",children:he()})]});return e?ae:f.jsxs(aa,{open:n,onOpenChange:r,children:[f.jsx(eN,{asChild:!0,children:f.jsxs(Ie,{children:[f.jsx(Ab,{className:"mr-2 h-4 w-4"}),"New eval run"]})}),f.jsxs(oa,{className:"max-h-[80vh] w-full max-w-4xl overflow-y-auto sm:max-w-4xl",children:[f.jsxs(la,{className:"mx-auto w-full max-w-3xl gap-1 text-left",children:[f.jsx(ca,{children:"Create eval run"}),f.jsx(Jf,{children:"Follow the guided steps to configure your evaluation and run it with confidence."})]}),ae]})]})}function nTe(){const{isAuthenticated:t,isLoading:e}=Xa(),{user:n}=da(),{availableModels:r}=fV({systemPrompt:"",temperature:1,selectedServers:[]});return e?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"flex h-64 items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})})}):!t||!n?f.jsx("div",{className:"p-6",children:f.jsx(th,{icon:mB,title:"Sign in to run evals",description:"Create an account or sign in to generate and launch evaluation runs.",className:"h-[calc(100vh-200px)]"})}):f.jsxs("div",{className:"space-y-6 p-6",children:[f.jsx("div",{className:"space-y-2",children:f.jsx("h1",{className:"text-2xl font-semibold",children:"Evaluation runner"})}),f.jsx("div",{className:"w-full",children:f.jsx(tTe,{availableModels:r,inline:!0})})]})}function rTe({config:t,isConfigured:e,onEdit:n,onDelete:r}){const s=t.description?.trim();return f.jsxs(Fa,{className:Me("group h-full gap-4 border bg-card px-6 py-6 transition-all hover:border-primary/40 hover:shadow-md dark:hover:shadow-xl",e?"border-green-200/80 dark:border-green-400/30":"border-border/60"),children:[f.jsxs("div",{className:"flex items-start justify-between gap-6",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("img",{src:t.logo,alt:t.logoAlt,className:"size-6 object-contain"}),f.jsxs("div",{className:"",children:[f.jsxs("h3",{className:"text-md font-semibold text-foreground pb-1",children:[t.name," ",e&&f.jsx("span",{className:"text-md",children:"✔️"})]}),s?f.jsx("p",{className:"line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:s}):null]})]}),e?f.jsxs(p0,{children:[f.jsx(m0,{asChild:!0,children:f.jsx(Ie,{size:"icon",variant:"ghost",className:"size-8 rounded-md border border-transparent hover:bg-muted/50",children:f.jsx(bse,{className:"size-4"})})}),f.jsx(g0,{align:"end",className:"w-44",children:f.jsx(To,{variant:"destructive",onClick:()=>r(t.id),children:"Remove provider"})})]}):null]}),f.jsx("div",{className:"space-y-4",children:f.jsx(Ie,{size:"sm",variant:e?"outline":"secondary",className:"w-full",onClick:()=>n(t.id),children:e?"Manage":"Configure"})})]})}function sTe({baseUrl:t,onEdit:e}){const n=!!t;return f.jsxs(Fa,{className:Me("group h-full gap-4 border bg-card px-6 py-6 transition-all hover:border-primary/40 hover:shadow-md dark:hover:shadow-xl",n?"border-green-200/80 dark:border-green-400/30":"border-border/60"),children:[f.jsx("div",{className:"flex items-start justify-between gap-6",children:f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("img",{src:"/ollama_logo.svg",alt:"Ollama",className:"size-6 object-contain"}),f.jsxs("div",{className:"",children:[f.jsxs("h3",{className:"text-md font-semibold text-foreground pb-1",children:["Ollama ",n&&f.jsx("span",{className:"text-md",children:"✔️"})]}),f.jsx("p",{className:"line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:n?"Local models available":"Install and connect Ollama locally"})]})]})}),f.jsx("div",{className:"space-y-4",children:f.jsx(Ie,{size:"sm",variant:n?"outline":"secondary",className:"w-full",onClick:e,children:n?"Manage":"Configure"})})]})}function iTe({providerConfigs:t,hasToken:e,onEditProvider:n,onDeleteProvider:r,ollamaBaseUrl:s,onEditOllama:i}){return f.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[t.map(a=>{const l=e(a.id);return f.jsx(rTe,{config:a,isConfigured:l,onEdit:n,onDelete:r},a.id)}),f.jsx(sTe,{baseUrl:s,onEdit:i})]})}function aTe({open:t,onOpenChange:e,provider:n,value:r,onValueChange:s,onSave:i,onCancel:a}){const l=ua();return f.jsx(aa,{open:t,onOpenChange:e,children:f.jsxs(oa,{className:"max-w-md",children:[f.jsx(la,{children:f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[n&&f.jsx("div",{className:"w-12 h-12 rounded-lg bg-white p-2 border",children:f.jsx("img",{src:n.logo,alt:n.logoAlt,className:"w-full h-full object-contain"})}),f.jsxs("div",{children:[f.jsxs(ca,{className:"text-left",children:["Configure ",n?.name]}),f.jsx(Jf,{className:"text-left",children:n?.description})]})]})}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{htmlFor:"api-key",className:"text-sm font-medium",children:"API Key"}),f.jsx(Un,{id:"api-key",type:"password",value:r,onChange:u=>s(u.target.value),placeholder:n?.placeholder,className:"mt-1"})]}),f.jsxs("div",{className:"flex items-center gap-2 p-3 bg-blue-50 dark:bg-blue-950/20 rounded-lg",children:[f.jsx(JA,{className:"w-4 h-4 text-blue-600"}),f.jsxs("span",{className:"text-sm text-blue-600",children:["Need an API key?"," ",f.jsx("button",{onClick:()=>n&&window.open(n.getApiKeyUrl,"_blank"),className:"underline hover:no-underline",children:"Get one here"})]})]})]}),f.jsxs(v0,{children:[f.jsx(Ie,{variant:"outline",onClick:a,children:"Cancel"}),f.jsx(Ie,{onClick:()=>{l.capture("save_api_key",{location:"provider_config_dialog",platform:Ni(),environment:void 0}),i()},disabled:!r.trim(),children:"Save API Key"})]})]})})}function oTe({open:t,onOpenChange:e,value:n,onValueChange:r,onSave:s,onCancel:i}){return f.jsx(aa,{open:t,onOpenChange:e,children:f.jsxs(oa,{className:"max-w-md",children:[f.jsx(la,{children:f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"w-12 h-12 rounded-lg bg-white p-2 border",children:f.jsx("img",{src:"/ollama_logo.svg",alt:"Ollama",className:"w-full h-full object-contain"})}),f.jsxs("div",{children:[f.jsx(ca,{className:"text-left pb-2",children:"Configure Ollama URL"}),f.jsx(Jf,{className:"text-left",children:"Set the base URL for your Ollama instance"})]})]})}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{htmlFor:"ollama-url",className:"text-sm font-medium",children:"Base URL"}),f.jsx(Un,{id:"ollama-url",type:"url",value:n,onChange:a=>r(a.target.value),placeholder:"http://localhost:11434/api",className:"mt-1"})]}),f.jsxs("div",{className:"flex items-center gap-2 p-3 bg-blue-50 dark:bg-blue-950/20 rounded-lg",children:[f.jsx(JA,{className:"w-4 h-4 text-blue-600"}),f.jsxs("span",{className:"text-sm text-blue-600",children:["Need help?"," ",f.jsx("button",{onClick:()=>window.open("https://ollama.ai/download","_blank"),className:"underline hover:no-underline",children:"Download Ollama"})]})]})]}),f.jsxs(v0,{children:[f.jsx(Ie,{variant:"outline",onClick:i,children:"Cancel"}),f.jsx(Ie,{onClick:s,disabled:!n.trim(),children:"Save URL"})]})]})})}function lTe({...t}){return f.jsx(kJ,{"data-slot":"alert-dialog",...t})}function cTe({...t}){return f.jsx(TJ,{"data-slot":"alert-dialog-trigger",...t})}function uTe({...t}){return f.jsx(CJ,{"data-slot":"alert-dialog-portal",...t})}function dTe({className:t,...e}){return f.jsx(AJ,{"data-slot":"alert-dialog-overlay",className:Me("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function fTe({className:t,...e}){return f.jsxs(uTe,{children:[f.jsx(dTe,{}),f.jsx(NJ,{"data-slot":"alert-dialog-content",className:Me("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...e})]})}function hTe({className:t,...e}){return f.jsx("div",{"data-slot":"alert-dialog-header",className:Me("flex flex-col gap-2 text-center sm:text-left",t),...e})}function pTe({className:t,...e}){return f.jsx("div",{"data-slot":"alert-dialog-footer",className:Me("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function mTe({className:t,...e}){return f.jsx(MJ,{"data-slot":"alert-dialog-title",className:Me("text-lg font-semibold",t),...e})}function gTe({className:t,...e}){return f.jsx(OJ,{"data-slot":"alert-dialog-description",className:Me("text-muted-foreground text-sm",t),...e})}function vTe({className:t,...e}){return f.jsx(RJ,{className:Me(QA(),t),...e})}function yTe({className:t,...e}){return f.jsx(jJ,{className:Me(QA({variant:"outline"}),t),...e})}function xn(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function Jl(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}const v7=6048e5,bTe=864e5,y7=6e4,b7=36e5,ky=43200,W4=1440;let xTe={};function Rg(){return xTe}function Zm(t,e){const n=Rg(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=xn(t),i=s.getDay(),a=(i<r?7:0)+i-r;return s.setDate(s.getDate()-a),s.setHours(0,0,0,0),s}function Ex(t){return Zm(t,{weekStartsOn:1})}function x7(t){const e=xn(t),n=e.getFullYear(),r=Jl(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const s=Ex(r),i=Jl(t,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const a=Ex(i);return e.getTime()>=s.getTime()?n+1:e.getTime()>=a.getTime()?n:n-1}function Y4(t){const e=xn(t);return e.setHours(0,0,0,0),e}function kx(t){const e=xn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function _Te(t,e){const n=Y4(t),r=Y4(e),s=+n-kx(n),i=+r-kx(r);return Math.round((s-i)/bTe)}function wTe(t){const e=x7(t),n=Jl(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),Ex(n)}function lb(t,e){const n=xn(t),r=xn(e),s=n.getTime()-r.getTime();return s<0?-1:s>0?1:s}function STe(t){return Jl(t,Date.now())}function ETe(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function kTe(t){if(!ETe(t)&&typeof t!="number")return!1;const e=xn(t);return!isNaN(Number(e))}function TTe(t,e){const n=xn(t),r=xn(e),s=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return s*12+i}function CTe(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function ATe(t,e){return+xn(t)-+xn(e)}function NTe(t){const e=xn(t);return e.setHours(23,59,59,999),e}function RTe(t){const e=xn(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function jTe(t){const e=xn(t);return+NTe(e)==+RTe(e)}function MTe(t,e){const n=xn(t),r=xn(e),s=lb(n,r),i=Math.abs(TTe(n,r));let a;if(i<1)a=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-s*i);let l=lb(n,r)===-s;jTe(xn(t))&&i===1&&lb(t,r)===1&&(l=!1),a=s*(i-Number(l))}return a===0?0:a}function OTe(t,e,n){const r=ATe(t,e)/1e3;return CTe(n?.roundingMethod)(r)}function PTe(t){const e=xn(t),n=Jl(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}const ITe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},DTe=(t,e,n)=>{let r;const s=ITe[t];return typeof s=="string"?r=s:e===1?r=s.one:r=s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function U1(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const LTe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},$Te={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},zTe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},FTe={date:U1({formats:LTe,defaultWidth:"full"}),time:U1({formats:$Te,defaultWidth:"full"}),dateTime:U1({formats:zTe,defaultWidth:"full"})},UTe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},BTe=(t,e,n,r)=>UTe[t];function kp(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let s;if(r==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,l=n?.width?String(n.width):a;s=t.formattingValues[l]||t.formattingValues[a]}else{const a=t.defaultWidth,l=n?.width?String(n.width):t.defaultWidth;s=t.values[l]||t.values[a]}const i=t.argumentCallback?t.argumentCallback(e):e;return s[i]}}const qTe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},VTe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},HTe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},GTe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},WTe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},YTe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},KTe=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},XTe={ordinalNumber:KTe,era:kp({values:qTe,defaultWidth:"wide"}),quarter:kp({values:VTe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:kp({values:HTe,defaultWidth:"wide"}),day:kp({values:GTe,defaultWidth:"wide"}),dayPeriod:kp({values:WTe,defaultWidth:"wide",formattingValues:YTe,defaultFormattingWidth:"wide"})};function Tp(t){return(e,n={})=>{const r=n.width,s=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=e.match(s);if(!i)return null;const a=i[0],l=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],u=Array.isArray(l)?JTe(l,h=>h.test(a)):QTe(l,h=>h.test(a));let d;d=t.valueCallback?t.valueCallback(u):u,d=n.valueCallback?n.valueCallback(d):d;const p=e.slice(a.length);return{value:d,rest:p}}}function QTe(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function JTe(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function ZTe(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const s=r[0],i=e.match(t.parsePattern);if(!i)return null;let a=t.valueCallback?t.valueCallback(i[0]):i[0];a=n.valueCallback?n.valueCallback(a):a;const l=e.slice(s.length);return{value:a,rest:l}}}const eCe=/^(\d+)(th|st|nd|rd)?/i,tCe=/\d+/i,nCe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},rCe={any:[/^b/i,/^(a|c)/i]},sCe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},iCe={any:[/1/i,/2/i,/3/i,/4/i]},aCe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},oCe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},lCe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},cCe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},uCe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},dCe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},fCe={ordinalNumber:ZTe({matchPattern:eCe,parsePattern:tCe,valueCallback:t=>parseInt(t,10)}),era:Tp({matchPatterns:nCe,defaultMatchWidth:"wide",parsePatterns:rCe,defaultParseWidth:"any"}),quarter:Tp({matchPatterns:sCe,defaultMatchWidth:"wide",parsePatterns:iCe,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Tp({matchPatterns:aCe,defaultMatchWidth:"wide",parsePatterns:oCe,defaultParseWidth:"any"}),day:Tp({matchPatterns:lCe,defaultMatchWidth:"wide",parsePatterns:cCe,defaultParseWidth:"any"}),dayPeriod:Tp({matchPatterns:uCe,defaultMatchWidth:"any",parsePatterns:dCe,defaultParseWidth:"any"})},_7={code:"en-US",formatDistance:DTe,formatLong:FTe,formatRelative:BTe,localize:XTe,match:fCe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function hCe(t){const e=xn(t);return _Te(e,PTe(e))+1}function pCe(t){const e=xn(t),n=+Ex(e)-+wTe(e);return Math.round(n/v7)+1}function w7(t,e){const n=xn(t),r=n.getFullYear(),s=Rg(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,a=Jl(t,0);a.setFullYear(r+1,0,i),a.setHours(0,0,0,0);const l=Zm(a,e),u=Jl(t,0);u.setFullYear(r,0,i),u.setHours(0,0,0,0);const d=Zm(u,e);return n.getTime()>=l.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function mCe(t,e){const n=Rg(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=w7(t,e),i=Jl(t,0);return i.setFullYear(s,0,r),i.setHours(0,0,0,0),Zm(i,e)}function gCe(t,e){const n=xn(t),r=+Zm(n,e)-+mCe(n,e);return Math.round(r/v7)+1}function dn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const Sl={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return dn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):dn(n+1,2)},d(t,e){return dn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return dn(t.getHours()%12||12,e.length)},H(t,e){return dn(t.getHours(),e.length)},m(t,e){return dn(t.getMinutes(),e.length)},s(t,e){return dn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return dn(s,e.length)}},Ad={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},K4={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return Sl.y(t,e)},Y:function(t,e,n,r){const s=w7(t,r),i=s>0?s:1-s;if(e==="YY"){const a=i%100;return dn(a,2)}return e==="Yo"?n.ordinalNumber(i,{unit:"year"}):dn(i,e.length)},R:function(t,e){const n=x7(t);return dn(n,e.length)},u:function(t,e){const n=t.getFullYear();return dn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return dn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return dn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return Sl.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return dn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const s=gCe(t,r);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):dn(s,e.length)},I:function(t,e,n){const r=pCe(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):dn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Sl.d(t,e)},D:function(t,e,n){const r=hCe(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):dn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const s=t.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return dn(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const s=t.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return dn(i,e.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),s=r===0?7:r;switch(e){case"i":return String(s);case"ii":return dn(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let s;switch(r===12?s=Ad.noon:r===0?s=Ad.midnight:s=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let s;switch(r>=17?s=Ad.evening:r>=12?s=Ad.afternoon:r>=4?s=Ad.morning:s=Ad.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Sl.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Sl.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):dn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):dn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Sl.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Sl.s(t,e)},S:function(t,e){return Sl.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return Q4(r);case"XXXX":case"XX":return qc(r);case"XXXXX":case"XXX":default:return qc(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return Q4(r);case"xxxx":case"xx":return qc(r);case"xxxxx":case"xxx":default:return qc(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+X4(r,":");case"OOOO":default:return"GMT"+qc(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+X4(r,":");case"zzzz":default:return"GMT"+qc(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return dn(r,e.length)},T:function(t,e,n){const r=t.getTime();return dn(r,e.length)}};function X4(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=Math.trunc(r/60),i=r%60;return i===0?n+String(s):n+String(s)+e+dn(i,2)}function Q4(t,e){return t%60===0?(t>0?"-":"+")+dn(Math.abs(t)/60,2):qc(t,e)}function qc(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=dn(Math.trunc(r/60),2),i=dn(r%60,2);return n+s+e+i}const J4=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},S7=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},vCe=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return J4(t,e);let i;switch(r){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",J4(r,e)).replace("{{time}}",S7(s,e))},yCe={p:S7,P:vCe},bCe=/^D+$/,xCe=/^Y+$/,_Ce=["D","DD","YY","YYYY"];function wCe(t){return bCe.test(t)}function SCe(t){return xCe.test(t)}function ECe(t,e,n){const r=kCe(t,e,n);if(console.warn(r),_Ce.includes(t))throw new RangeError(r)}function kCe(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const TCe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,CCe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ACe=/^'([^]*?)'?$/,NCe=/''/g,RCe=/[a-zA-Z]/;function E7(t,e,n){const r=Rg(),s=r.locale??_7,i=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,l=xn(t);if(!kTe(l))throw new RangeError("Invalid time value");let u=e.match(CCe).map(p=>{const h=p[0];if(h==="p"||h==="P"){const g=yCe[h];return g(p,s.formatLong)}return p}).join("").match(TCe).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const h=p[0];if(h==="'")return{isToken:!1,value:jCe(p)};if(K4[h])return{isToken:!0,value:p};if(h.match(RCe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:p}});s.localize.preprocessor&&(u=s.localize.preprocessor(l,u));const d={firstWeekContainsDate:i,weekStartsOn:a,locale:s};return u.map(p=>{if(!p.isToken)return p.value;const h=p.value;(SCe(h)||wCe(h))&&ECe(h,e,String(t));const g=K4[h[0]];return g(l,h,s.localize,d)}).join("")}function jCe(t){const e=t.match(ACe);return e?e[1].replace(NCe,"'"):t}function MCe(t,e,n){const r=Rg(),s=n?.locale??r.locale??_7,i=2520,a=lb(t,e);if(isNaN(a))throw new RangeError("Invalid time value");const l=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a});let u,d;a>0?(u=xn(e),d=xn(t)):(u=xn(t),d=xn(e));const p=OTe(d,u),h=(kx(d)-kx(u))/1e3,g=Math.round((p-h)/60);let v;if(g<2)return n?.includeSeconds?p<5?s.formatDistance("lessThanXSeconds",5,l):p<10?s.formatDistance("lessThanXSeconds",10,l):p<20?s.formatDistance("lessThanXSeconds",20,l):p<40?s.formatDistance("halfAMinute",0,l):p<60?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",1,l):g===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",g,l);if(g<45)return s.formatDistance("xMinutes",g,l);if(g<90)return s.formatDistance("aboutXHours",1,l);if(g<W4){const b=Math.round(g/60);return s.formatDistance("aboutXHours",b,l)}else{if(g<i)return s.formatDistance("xDays",1,l);if(g<ky){const b=Math.round(g/W4);return s.formatDistance("xDays",b,l)}else if(g<ky*2)return v=Math.round(g/ky),s.formatDistance("aboutXMonths",v,l)}if(v=MTe(d,u),v<12){const b=Math.round(g/ky);return s.formatDistance("xMonths",b,l)}else{const b=v%12,x=Math.trunc(v/12);return b<3?s.formatDistance("aboutXYears",x,l):b<9?s.formatDistance("overXYears",x,l):s.formatDistance("almostXYears",x+1,l)}}function OCe(t,e){return MCe(t,STe(t),e)}function PCe(t,e){const r=$Ce(t);let s;if(r.date){const u=zCe(r.date,2);s=FCe(u.restDateString,u.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const i=s.getTime();let a=0,l;if(r.time&&(a=UCe(r.time),isNaN(a)))return new Date(NaN);if(r.timezone){if(l=BCe(r.timezone),isNaN(l))return new Date(NaN)}else{const u=new Date(i+a),d=new Date(0);return d.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),d.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),d}return new Date(i+a+l)}const Ty={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ICe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,DCe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,LCe=/^([+-])(\d{2})(?::?(\d{2}))?$/;function $Ce(t){const e={},n=t.split(Ty.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],Ty.timeZoneDelimiter.test(e.date)&&(e.date=t.split(Ty.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const s=Ty.timezone.exec(r);s?(e.time=r.replace(s[1],""),e.timezone=s[1]):e.time=r}return e}function zCe(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const s=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?s:i*100,restDateString:t.slice((r[1]||r[2]).length)}}function FCe(t,e){if(e===null)return new Date(NaN);const n=t.match(ICe);if(!n)return new Date(NaN);const r=!!n[4],s=Cp(n[1]),i=Cp(n[2])-1,a=Cp(n[3]),l=Cp(n[4]),u=Cp(n[5])-1;if(r)return WCe(e,l,u)?qCe(e,l,u):new Date(NaN);{const d=new Date(0);return!HCe(e,i,a)||!GCe(e,s)?new Date(NaN):(d.setUTCFullYear(e,i,Math.max(s,a)),d)}}function Cp(t){return t?parseInt(t):1}function UCe(t){const e=t.match(DCe);if(!e)return NaN;const n=B1(e[1]),r=B1(e[2]),s=B1(e[3]);return YCe(n,r,s)?n*b7+r*y7+s*1e3:NaN}function B1(t){return t&&parseFloat(t.replace(",","."))||0}function BCe(t){if(t==="Z")return 0;const e=t.match(LCe);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;return KCe(r,s)?n*(r*b7+s*y7):NaN}function qCe(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const s=r.getUTCDay()||7,i=(e-1)*7+n+1-s;return r.setUTCDate(r.getUTCDate()+i),r}const VCe=[31,null,31,30,31,30,31,31,30,31,30,31];function k7(t){return t%400===0||t%4===0&&t%100!==0}function HCe(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(VCe[e]||(k7(t)?29:28))}function GCe(t,e){return e>=1&&e<=(k7(t)?366:365)}function WCe(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function YCe(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function KCe(t,e){return e>=0&&e<=59}function Z4({value:t,isCopied:e,onCopy:n,copyLabel:r,tooltip:s="Copy to clipboard"}){return f.jsxs("div",{className:"relative w-full",children:[f.jsx(Un,{readOnly:!0,value:t,className:"h-12 w-full rounded-lg border border-border/40 bg-background/50 font-mono text-sm tracking-wide text-foreground pr-16 shadow-sm focus-visible:border-primary focus-visible:ring-1 focus-visible:ring-primary/20",style:{fontFamily:'ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace'}}),f.jsxs(Ma,{children:[f.jsx(Oa,{asChild:!0,children:f.jsx(Ie,{type:"button",variant:"ghost",onClick:n,className:"absolute right-3 top-3 h-6 w-6 p-0 rounded-md border-0 bg-transparent text-foreground/60 hover:text-foreground hover:bg-foreground/10 transition-all duration-200",children:e?f.jsx(Ti,{className:"h-4 w-4"}):f.jsx(Po,{className:"h-4 w-4"})})}),f.jsx(Pa,{side:"bottom",children:s})]})]})}function XCe(){const[t,e]=w.useState(null),[n,r]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(!1),[u,d]=w.useState(!1),{isAuthenticated:p,isLoading:h}=Xa(),{signIn:g}=da(),v=ua(),b=Sx("apiKeys:list"),x=d7("apiKeys:regenerateAndGet"),E=async()=>{if(t)try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),2e3)}catch(R){console.error("Clipboard error",R)}},S=async()=>{if(!p)return!1;try{r(!0),i(!1);const R=await x();return e(R.apiKey),d(!0),!0}catch(R){return console.error("Failed to generate key",R),!1}finally{r(!1)}};if(h)return f.jsx("div",{className:"rounded-md border p-3 text-sm text-muted-foreground",children:"Checking authentication…"});if(!p)return f.jsxs("div",{className:"space-y-3 rounded-md border p-4",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("h3",{className:"text-lg font-semibold",children:"MCPJam API Key"})}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Sign in to view and manage your API key."}),f.jsx(Ie,{type:"button",onClick:()=>{v.capture("sign_in",{location:"account_api_key_section",platform:Ni(),environment:void 0}),g()},size:"sm",children:"Sign in"})]});const k=b&&b.length>0?b[0]:null,T=(R,j="Never")=>{if(!R)return j;const A=new Date(R),N=OCe(A,{addSuffix:!0});return`${E7(A,"PP p")} · ${N}`};return f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("h3",{className:"text-lg font-semibold",children:"MCPJam API Key"})}),b===void 0?f.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading API key status…"}):t?f.jsxs("div",{className:"space-y-4",children:[f.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Copy and save this key now. You won't be able to view it again later."}),f.jsx(Z4,{value:t,isCopied:s,onCopy:E,copyLabel:"Copy key"})]}):(b?.length??0)===0?f.jsx("div",{className:"space-y-4",children:f.jsx(Ie,{type:"button",onClick:()=>{S()},disabled:n,children:n?"Generating…":"Generate API key"})}):f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs(lTe,{open:a,onOpenChange:l,children:[f.jsx(cTe,{asChild:!0,children:f.jsxs(Ie,{type:"button",variant:"outline",disabled:n,className:"inline-flex items-center gap-2.5 rounded-lg border border-border/50 bg-background px-4 py-2.5 text-sm font-medium text-foreground/80 hover:border-border hover:bg-background/80 hover:text-foreground transition-all duration-200",children:[f.jsx(ir,{className:`h-4 w-4 ${n?"animate-spin":""} text-foreground/60`}),f.jsx("span",{children:n?"Regenerating…":"Regenerate"})]})}),f.jsxs(fTe,{children:[f.jsxs(hTe,{children:[f.jsx(mTe,{className:"text-lg font-semibold",children:"Confirm"}),f.jsx(gTe,{className:"text-sm text-muted-foreground leading-relaxed",children:"Regenerating an API key will replace your previous API key."})]}),f.jsxs(pTe,{className:"gap-3",children:[f.jsx(yTe,{disabled:n,className:"font-medium",children:"Cancel"}),f.jsx(vTe,{onClick:async R=>{R.preventDefault(),await S()&&l(!1)},disabled:n,className:"font-medium",children:n?"Regenerating…":"Regenerate"})]})]})]})}),k?f.jsx("div",{className:"rounded-lg border border-border/30 bg-background/50 p-4",children:f.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground/50 uppercase tracking-wide",children:"Created"}),f.jsx("span",{className:"text-xs text-foreground/70",children:T(k.createdAt)})]}),f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground/50 uppercase tracking-wide",children:"Last Used"}),f.jsx("span",{className:"text-xs text-foreground/70",children:T(k.lastUsedAt,"Never used")})]})]})}):null]}),f.jsx(aa,{open:!!t&&u,onOpenChange:R=>{R||i(!1),d(R)},children:f.jsxs(oa,{children:[f.jsxs(la,{children:[f.jsx(ca,{children:"API Key"}),f.jsx(Jf,{children:"Copy and store this key securely. You will not be able to view it again."})]}),f.jsx(Z4,{value:t??"",isCopied:s,onCopy:E,copyLabel:"Copy"})]})})]})}function QCe(){const{tokens:t,setToken:e,clearToken:n,hasToken:r,getOllamaBaseUrl:s,setOllamaBaseUrl:i}=rR(),[a,l]=w.useState(""),[u,d]=w.useState(!1),[p,h]=w.useState(null),[g,v]=w.useState(!1),[b,x]=w.useState(""),E=[{id:"openai",name:"OpenAI",logo:"/openai_logo.png",logoAlt:"OpenAI",description:"GPT-4, GPT-4o, GPT-4o-mini, GPT-4.1, GPT-5, etc.",placeholder:"sk-...",getApiKeyUrl:"https://platform.openai.com/api-keys"},{id:"anthropic",name:"Anthropic",logo:"/claude_logo.png",logoAlt:"Claude",description:"Claude 3.5, Claude 3.7, Claude Opus 4, etc.",placeholder:"sk-ant-...",getApiKeyUrl:"https://console.anthropic.com/"},{id:"deepseek",name:"DeepSeek",logo:"/deepseek_logo.svg",logoAlt:"DeepSeek",description:"DeepSeek Chat, DeepSeek Reasoner, etc.",placeholder:"sk-...",getApiKeyUrl:"https://platform.deepseek.com/api_keys"},{id:"google",name:"Google AI",logo:"/google_logo.png",logoAlt:"Google AI",description:"Gemini 2.5, Gemini 2.5 Flash, Gemini 2.5 Flash Lite",placeholder:"AI...",getApiKeyUrl:"https://aistudio.google.com/app/apikey"}],S=M=>{const I=E.find(O=>O.id===M);I&&(h(I),l(t[M]||""),d(!0))},k=()=>{p&&(e(p.id,a),d(!1),h(null),l(""))},T=()=>{d(!1),h(null),l("")},R=M=>{n(M)},j=()=>{x(s()),v(!0)},A=()=>{i(b),v(!1),x("")},N=()=>{v(!1),x("")};return f.jsxs("div",{className:"container mx-auto p-6 max-w-6xl space-y-8",children:[f.jsx("div",{className:"flex items-center gap-3 mb-6",children:f.jsx("h1",{className:"text-2xl font-bold",children:"Settings"})}),f.jsx(XCe,{}),f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{children:f.jsx("h3",{className:"text-lg font-semibold",children:"LLM Provider API Keys"})}),f.jsx(iTe,{providerConfigs:E,hasToken:M=>r(M),onEditProvider:S,onDeleteProvider:R,ollamaBaseUrl:s(),onEditOllama:j})]}),f.jsx(aTe,{open:u,onOpenChange:d,provider:p,value:a,onValueChange:l,onSave:k,onCancel:T}),f.jsx(oTe,{open:g,onOpenChange:v,value:b,onValueChange:x,onSave:A,onCancel:N})]})}const JCe=(t,e="HH:mm:ss.SSS")=>{const n=typeof t=="string"?PCe(t):t;return E7(n,e)},ZCe={error:"bg-red-500/10 text-red-700 border-red-200 dark:text-red-400 dark:border-red-800",warn:"bg-yellow-500/10 text-yellow-700 border-yellow-200 dark:text-yellow-400 dark:border-yellow-800",info:"bg-blue-500/10 text-blue-700 border-blue-200 dark:text-blue-400 dark:border-blue-800",debug:"bg-purple-500/10 text-purple-700 border-purple-200 dark:text-purple-400 dark:border-purple-800",trace:"bg-gray-500/10 text-gray-700 border-gray-200 dark:text-gray-400 dark:border-gray-800"};function T7({level:t}){return f.jsx(vr,{variant:"outline",className:Me("font-mono",ZCe[t]),children:t.toUpperCase()})}function eAe({entry:t,isExpanded:e,onToggleExpand:n}){const r=t.data!==void 0||t.error!==void 0;return f.jsxs("div",{className:"border rounded-lg font-mono",children:[f.jsx("div",{className:`p-3 cursor-pointer hover:bg-muted/50 ${r?"":"cursor-default"}`,onClick:r?n:void 0,children:f.jsxs("div",{className:"flex items-start gap-3",children:[r&&f.jsx("div",{className:"mt-0.5",children:e?f.jsx(Au,{className:"h-4 w-4 text-muted-foreground"}):f.jsx(Ba,{className:"h-4 w-4 text-muted-foreground"})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:`[${JCe(t.timestamp)}]`}),f.jsx(T7,{level:t.level}),f.jsx(vr,{variant:"secondary",children:t.context}),f.jsx("span",{className:"flex-1 break-words",children:t.message})]})})]})}),e&&r&&f.jsxs("div",{className:"border-t bg-muted/20 p-3 space-y-3",children:[t.data!==void 0&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"DATA:"}),f.jsx("div",{className:"text-xs bg-background border rounded overflow-auto max-h-60",children:f.jsx(zl,{src:t.data,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"0",borderRadius:"0",border:"none"}})})]}),t.error&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"ERROR:"}),f.jsxs("pre",{className:"text-xs bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded p-2 overflow-auto max-h-40 text-red-700 dark:text-red-400",children:[t.error.message,t.error.stack&&`
|
|
1819
1819
|
|
|
1820
|
-
${t.error.stack}`]})]})]})]})}const tAe=["error","warn","info","debug","trace"];function nAe(){const{entries:t}=Qfe(),e=GN("JSON-RPC"),[n,r]=w.useState(new Set),[s,i]=w.useState("all"),[a,l]=w.useState("all"),[u,d]=w.useState(""),[p,h]=w.useState(!1),g=w.useRef(null),v=w.useRef(null),b=w.useMemo(()=>{const k=new Set;for(const T of t){const R=T?.data?.serverId;typeof R=="string"&&R.length>0&&k.add(R)}return Array.from(k).sort()},[t]),x=w.useMemo(()=>{let k=s==="all"?t:t.filter(R=>R.level===s);if(a!=="all"&&(k=k.filter(R=>R?.data?.serverId===a)),!u.trim())return k;const T=u.toLowerCase();return k.filter(R=>R.message.toLowerCase().includes(T)||R.context.toLowerCase().includes(T)||R.data&&JSON.stringify(R.data).toLowerCase().includes(T))},[t,s,a,u]);w.useEffect(()=>{const k=()=>{if(g.current){const{scrollTop:R}=g.current;h(R>200)}},T=g.current;if(T)return T.addEventListener("scroll",k),()=>T.removeEventListener("scroll",k)},[]);const E=()=>{g.current&&g.current.scrollTo({top:0,behavior:"smooth"})};w.useEffect(()=>{let k=null;try{const T=new URLSearchParams;T.set("replay","200"),k=new EventSource(`/api/mcp/servers/rpc/stream?${T.toString()}`),k.onmessage=R=>{try{const j=JSON.parse(R.data);if(j&&j.type==="rpc"){const A=j.serverId,N=j.direction,M=j.message,I=j.timestamp,O=typeof N=="string"?N.toUpperCase():"",L=M,z=typeof L?.method=="string"?L.method:L?.result!==void 0?"result":L?.error!==void 0?"error":"unknown",G=`[${A}] ${O} - ${z}`;e.
|
|
1820
|
+
${t.error.stack}`]})]})]})]})}const tAe=["error","warn","info","debug","trace"];function nAe(){const{entries:t}=Qfe(),e=GN("JSON-RPC"),[n,r]=w.useState(new Set),[s,i]=w.useState("all"),[a,l]=w.useState("all"),[u,d]=w.useState(""),[p,h]=w.useState(!1),g=w.useRef(null),v=w.useRef(null),b=w.useMemo(()=>{const k=new Set;for(const T of t){const R=T?.data?.serverId;typeof R=="string"&&R.length>0&&k.add(R)}return Array.from(k).sort()},[t]),x=w.useMemo(()=>{let k=s==="all"?t:t.filter(R=>R.level===s);if(a!=="all"&&(k=k.filter(R=>R?.data?.serverId===a)),!u.trim())return k;const T=u.toLowerCase();return k.filter(R=>R.message.toLowerCase().includes(T)||R.context.toLowerCase().includes(T)||R.data&&JSON.stringify(R.data).toLowerCase().includes(T))},[t,s,a,u]);w.useEffect(()=>{const k=()=>{if(g.current){const{scrollTop:R}=g.current;h(R>200)}},T=g.current;if(T)return T.addEventListener("scroll",k),()=>T.removeEventListener("scroll",k)},[]);const E=()=>{g.current&&g.current.scrollTo({top:0,behavior:"smooth"})};w.useEffect(()=>{let k=null;try{const T=new URLSearchParams;T.set("replay","200"),k=new EventSource(`/api/mcp/servers/rpc/stream?${T.toString()}`),k.onmessage=R=>{try{const j=JSON.parse(R.data);if(j&&j.type==="rpc"){const A=j.serverId,N=j.direction,M=j.message,I=j.timestamp,O=typeof N=="string"?N.toUpperCase():"",L=M,z=typeof L?.method=="string"?L.method:L?.result!==void 0?"result":L?.error!==void 0?"error":"unknown",G=`[${A}] ${O} - ${z}`;e.info(G,{serverId:A,direction:N,method:z,timestamp:I,message:M})}}catch{}},k.onerror=()=>{try{k?.close()}catch{}}}catch{}return()=>{try{k?.close()}catch{}}},[e]);const S=k=>{const T=new Set(n);T.has(k)?T.delete(k):T.add(k),r(T)};return f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"border-b bg-background p-4 space-y-4 flex-shrink-0 sticky top-0 z-10",children:[f.jsx("h2",{className:"text-lg font-semibold",children:"Tracing"}),f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsxs(Qc,{value:s,onValueChange:k=>i(k),children:[f.jsx(Zc,{className:"w-32",children:f.jsx(Jc,{})}),f.jsxs(eu,{children:[f.jsx(Qs,{value:"all",children:"All Levels"}),tAe.map(k=>f.jsx(Qs,{value:k,children:f.jsx(T7,{level:k})},k))]})]}),f.jsxs(Qc,{value:a,onValueChange:k=>l(k),children:[f.jsx(Zc,{className:"w-56",children:f.jsx(Jc,{placeholder:"All Servers"})}),f.jsxs(eu,{children:[f.jsx(Qs,{value:"all",children:"All Servers"}),b.map(k=>f.jsx(Qs,{value:k,children:k},k))]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx(vB,{className:"h-4 w-4"}),f.jsx(Un,{placeholder:"Search logs...",value:u,onChange:k=>d(k.target.value),className:"h-8"})]})]}),f.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[f.jsxs("span",{children:["Total: ",t.length]}),f.jsxs("span",{children:["Filtered: ",x.length]})]})]}),f.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto p-4 space-y-2 font-mono text-sm min-h-0",children:[x.length===0?f.jsx("div",{className:"text-center text-muted-foreground py-8",children:t.length===0?"No logs yet":"No logs match current filters"}):x.map((k,T)=>{const R=n.has(T);return f.jsx(eAe,{entry:k,isExpanded:R,onToggleExpand:()=>S(T)},`${k.timestamp}-${T}`)}),f.jsx("div",{ref:v})]}),p&&f.jsxs(Ie,{onClick:E,size:"sm",className:"fixed bottom-4 right-4 z-20 shadow-lg",variant:"secondary",children:[f.jsx(hB,{className:"h-4 w-4 mr-1"}),"Top"]})]})}const e$="mcpjam-interceptor-proxies";function rAe({connectedServerConfigs:t,selectedServer:e}){const[n,r]=w.useState({}),s=w.useRef({}),[i,a]=w.useState(!1),l=e&&e!=="none"?n[e]:null,u=k=>{try{localStorage.setItem(e$,JSON.stringify(k))}catch(T){console.error("Failed to save proxy state to localStorage:",T)}},d=w.useMemo(()=>`${new URL(window.location.href).origin}/api/mcp/interceptor`,[]),p=(k,T)=>{s.current[T]&&(s.current[T].close(),delete s.current[T]);const R=new EventSource(`${d}/${k}/stream`);R.onmessage=j=>{try{if(j.data==="[DONE]")return;const A=JSON.parse(j.data);console.log(`Stream message for ${T}:`,A),A.type==="log"&&A.log?r(N=>{const M={...N,[T]:{...N[T],logs:[...N[T]?.logs||[],A.log]}};return u(M),M}):A.type==="cleared"&&r(N=>{const M={...N,[T]:{...N[T],logs:[]}};return u(M),M})}catch(A){console.error("Error parsing stream message:",A)}},R.onopen=()=>{console.log(`Stream connected for ${T} interceptor:`,k)},R.onerror=j=>{console.error(`Stream error for ${T}:`,j)},s.current[T]=R};w.useEffect(()=>{let k=!1;return(async()=>{try{const T=localStorage.getItem(e$);if(!T)return;const R=JSON.parse(T),j=Object.entries(R).filter(([N])=>t[N]?.connectionStatus==="connected"),A={};await Promise.all(j.map(async([N,M])=>{try{const I=await fetch(`${d}/${M.interceptorId}`);!k&&I.ok&&(A[N]=M,p(M.interceptorId,N))}catch{}})),k||(r(A),u(A))}catch(T){console.error("Failed to load proxy state from localStorage:",T)}})(),()=>{k=!0,Object.values(s.current).forEach(T=>T.close()),s.current={}}},[t,d]),w.useEffect(()=>{const k=Object.keys(n).filter(T=>{const R=t[T];return!R||R.connectionStatus!=="connected"});if(k.length>0){const T={...n};let R=!1;k.forEach(j=>{console.log(`Server ${j} disconnected, cleaning up proxy`),T[j]?.interceptorId&&fetch(`${d}/${T[j].interceptorId}`,{method:"DELETE"}).catch(()=>{}),s.current[j]&&(s.current[j].close(),delete s.current[j]),delete T[j],R=!0}),R&&(r(T),u(T))}},[t,n,d]);const h=async()=>{if(!e||e==="none"){alert("Please select a connected server");return}const k=e;if(!t[k]){alert("Selected server is not connected");return}a(!0);try{const R=await(await fetch(`${d}/create`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({serverId:k})})).json();if(!R.success){alert(R.error||"Failed to create interceptor");return}const j=R.id,A=R.publicProxyUrl||R.proxyUrl,N={...n,[k]:{interceptorId:j,proxyUrl:A||`${d}/${j}/proxy`,logs:[]}};r(N),u(N),p(j,k)}catch(T){console.error("Failed to create proxy:",T),alert("Failed to create interceptor")}finally{a(!1)}},g=async()=>{if(!e||e==="none"||!l)return;try{await fetch(`${d}/${l.interceptorId}`,{method:"DELETE"})}catch{}s.current[e]&&(s.current[e].close(),delete s.current[e]);const k={...n};delete k[e],r(k),u(k)},v=async()=>{if(!e||e==="none"||!l)return;try{await fetch(`${d}/${l.interceptorId}/clear`,{method:"POST"})}catch{}const k={...n,[e]:{...n[e],logs:[]}};r(k),u(k)},[b,x]=w.useState(!1),E=()=>{const k=t[e]?.name||e||"server",T=l?.proxyUrl||"";return[`"${k}": {`,' "type": "http",',` "url": "${T}",`,' "headers": {}',"}"].join(`
|
|
1821
1821
|
`)},S=async()=>{try{await navigator.clipboard.writeText(E()),x(!0),setTimeout(()=>x(!1),1e3)}catch(k){console.error("Failed to copy config JSON:",k)}};return f.jsxs("div",{className:"p-4 space-y-4",children:[f.jsxs(Fa,{className:"p-4",children:[f.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Proxy Configuration"}),f.jsx("div",{className:"space-y-3",children:l?f.jsxs("div",{className:"p-3 rounded border",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"text-sm font-medium",children:["Active Proxy for"," ",t[e]?.name||e]}),f.jsx("span",{className:"mr-1 inline-block size-1.5 rounded-full bg-orange-500"})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(Ie,{variant:"outline",size:"sm",onClick:g,children:"Stop Proxy"})})]}),f.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 items-start",children:[f.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[f.jsx("div",{className:"mb-2 font-medium text-foreground",children:"How this proxy works"}),f.jsx("p",{children:"This creates a HTTP proxy that forwards requests to your connected MCP server. Add the JSON entry on the right in your client’s configuration. Auth credentials are the same as your server's and are injected automatically."})]}),f.jsxs("div",{className:"sm:col-start-2",children:[f.jsx("label",{className:"text-xs font-medium mb-1 block text-muted-foreground",children:"MCP HTTP config entry (no outer braces)"}),f.jsxs("div",{className:"relative",children:[f.jsx("pre",{className:"block p-2 pr-10 bg-transparent border rounded text-xs whitespace-pre leading-relaxed font-mono",children:E()}),f.jsx("button",{onClick:S,title:"Copy config entry",className:`absolute top-2 right-2 p-1 rounded transition-all duration-200 ${b?"text-foreground scale-110":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:b?f.jsx(Ti,{className:"h-3 w-3"}):f.jsx(Po,{className:"h-3 w-3"})})]})]})]})]}):f.jsx("div",{className:"p-3 bg-muted rounded border",children:f.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"text-sm font-medium mb-1 truncate",children:e!=="none"?`Create proxy for ${t[e]?.name}`:"No server selected"}),f.jsx("div",{className:"text-xs text-muted-foreground",children:e?"Create a local HTTP proxy URL to your connected server":"Select a server above to create a proxy"})]}),f.jsx("div",{className:"shrink-0 self-start sm:self-auto",children:f.jsx(Ie,{onClick:h,disabled:!e||e==="none"||i,children:i?f.jsxs(f.Fragment,{children:[f.jsx(mu,{className:"animate-spin"}),"Creating..."]}):f.jsx(f.Fragment,{children:"Create Proxy"})})})]})})})]}),f.jsxs(Fa,{className:"p-4",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("h2",{className:"text-lg font-semibold",children:"Request Logs"}),f.jsx(Ie,{variant:"outline",size:"sm",onClick:v,disabled:!l,children:"Clear Logs"})]}),f.jsx("div",{className:"border rounded-md bg-muted/30 max-h-[60vh] overflow-auto",children:!l?.logs||l.logs.length===0?f.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"No requests logged yet"}):f.jsx("div",{className:"divide-y",children:l.logs.map(k=>f.jsxs("div",{className:"p-3 text-sm",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-mono ${k.direction==="request"?"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}`,children:k.direction}),"method"in k?f.jsxs("span",{className:"font-mono",children:[f.jsx("span",{className:"font-semibold text-orange-600 dark:text-orange-400",children:k.method}),(()=>{try{const T=JSON.parse(k.body||"{}");return T.method?f.jsxs("span",{className:"font-semibold text-foreground",children:[" ",T.method]}):null}catch{return null}})()]}):f.jsxs("span",{className:"font-mono font-semibold text-gray-600 dark:text-gray-400",children:[k.status," ",k.statusText]}),f.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:new Date(k.timestamp).toLocaleTimeString()})]}),"url"in k&&f.jsx("div",{className:"text-xs text-muted-foreground font-mono mb-1",children:k.url}),k.body&&(()=>{let T=null;try{const R=k.body.trim();(R.startsWith("{")||R.startsWith("["))&&(T=JSON.parse(R))}catch{}return T?f.jsxs("div",{className:"text-xs bg-background p-2 rounded border mt-1 overflow-auto",children:[f.jsx("style",{children:`
|
|
1822
1822
|
/*
|
|
1823
1823
|
* react18-json-view uses CSS variables on the root
|
|
@@ -1872,4 +1872,4 @@ now you can use replayer.getMirror() to access the mirror instance of a replayer
|
|
|
1872
1872
|
or you can use record.mirror to access the mirror instance during recording.`;let rz={map:{},getId(){return console.error(Fd),-1},getNode(){return console.error(Fd),null},removeNodeFromMap(){console.error(Fd)},has(){return console.error(Fd),!1},reset(){console.error(Fd)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(rz=new Proxy(rz,{get(t,e,n){return e==="map"&&console.error(Fd),Reflect.get(t,e,n)}}));function sg(t,e,n={}){let r=null,s=0;return function(...i){const a=Date.now();!s&&n.leading===!1&&(s=a);const l=e-(a-s),u=this;l<=0||l>e?(r&&(yPe(r),r=null),s=a,t.apply(u,i)):!r&&n.trailing!==!1&&(r=s_(()=>{s=n.leading===!1?0:Date.now(),r=null,t.apply(u,i)},l))}}function lW(t,e,n,r,s=window){const i=s.Object.getOwnPropertyDescriptor(t,e);return s.Object.defineProperty(t,e,r?n:{set(a){s_(()=>{n.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>lW(t,e,i||{},!0)}function Aj(t,e,n){try{if(!(e in t))return()=>{};const r=t[e],s=n(r);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:r}})),t[e]=s,()=>{t[e]=r}}catch{return()=>{}}}let Dx=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(Dx=()=>new Date().getTime());function cW(t){const e=t.document;return{left:e.scrollingElement?e.scrollingElement.scrollLeft:t.pageXOffset!==void 0?t.pageXOffset:jl([e,"optionalAccess",n=>n.documentElement,"access",n=>n.scrollLeft])||jl([e,"optionalAccess",n=>n.body,"optionalAccess",n=>n.parentElement,"optionalAccess",n=>n.scrollLeft])||jl([e,"optionalAccess",n=>n.body,"optionalAccess",n=>n.scrollLeft])||0,top:e.scrollingElement?e.scrollingElement.scrollTop:t.pageYOffset!==void 0?t.pageYOffset:jl([e,"optionalAccess",n=>n.documentElement,"access",n=>n.scrollTop])||jl([e,"optionalAccess",n=>n.body,"optionalAccess",n=>n.parentElement,"optionalAccess",n=>n.scrollTop])||jl([e,"optionalAccess",n=>n.body,"optionalAccess",n=>n.scrollTop])||0}}function uW(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function dW(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function fW(t){return t?t.nodeType===t.ELEMENT_NODE?t:t.parentElement:null}function Js(t,e,n,r,s){if(!t)return!1;const i=fW(t);if(!i)return!1;const a=Jd(e,n);if(!s){const d=r&&i.matches(r);return a(i)&&!d}const l=Xc(i,a);let u=-1;return l<0?!1:(r&&(u=Xc(i,Jd(null,r))),l>-1&&u<0?!0:l<u)}function fPe(t,e){return e.getId(t)!==-1}function ek(t,e){return e.getId(t)===rg}function hW(t,e){if(vm(t))return!1;const n=e.getId(t);return e.has(n)?t.parentNode&&t.parentNode.nodeType===t.DOCUMENT_NODE?!1:t.parentNode?hW(t.parentNode,e):!0:!0}function eA(t){return!!t.changedTouches}function hPe(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let n=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do if(this===n)return!0;while(n=n&&n.parentNode);return!1})}function pW(t,e){return!!(t.nodeName==="IFRAME"&&e.getMeta(t))}function mW(t,e){return!!(t.nodeName==="LINK"&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&t.getAttribute("rel")==="stylesheet"&&e.getMeta(t))}function tA(t){return!!jl([t,"optionalAccess",e=>e.shadowRoot])}class pPe{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){return Jje(this.styleIDMap.get(e),()=>-1)}has(e){return this.styleIDMap.has(e)}add(e,n){if(this.has(e))return this.getId(e);let r;return n===void 0?r=this.id++:r=n,this.styleIDMap.set(e,r),this.idStyleMap.set(r,e),r}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function gW(t){let e=null;return jl([t,"access",n=>n.getRootNode,"optionalCall",n=>n(),"optionalAccess",n=>n.nodeType])===Node.DOCUMENT_FRAGMENT_NODE&&t.getRootNode().host&&(e=t.getRootNode().host),e}function mPe(t){let e=t,n;for(;n=gW(e);)e=n;return e}function gPe(t){const e=t.ownerDocument;if(!e)return!1;const n=mPe(t);return e.contains(n)}function vW(t){const e=t.ownerDocument;return e?e.contains(t)||gPe(t):!1}const sz={};function Nj(t){const e=sz[t];if(e)return e;const n=window.document;let r=window[t];if(n&&typeof n.createElement=="function")try{const s=n.createElement("iframe");s.hidden=!0,n.head.appendChild(s);const i=s.contentWindow;i&&i[t]&&(r=i[t]),n.head.removeChild(s)}catch{}return sz[t]=r.bind(window)}function vPe(...t){return Nj("requestAnimationFrame")(...t)}function s_(...t){return Nj("setTimeout")(...t)}function yPe(...t){return Nj("clearTimeout")(...t)}var Ft=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Ft||{}),Tt=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(Tt||{}),ds=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(ds||{}),vo=(t=>(t[t.Mouse=0]="Mouse",t[t.Pen=1]="Pen",t[t.Touch=2]="Touch",t))(vo||{}),iz;(function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"})(iz||(iz={}));var az;(function(t){t[t.PLACEHOLDER=0]="PLACEHOLDER",t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",t[t.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",t[t.ENTITY_NODE=6]="ENTITY_NODE",t[t.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE",t[t.DOCUMENT_NODE=9]="DOCUMENT_NODE",t[t.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",t[t.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"})(az||(az={}));function Rj(t){try{return t.contentDocument}catch{}}function bPe(t){try{return t.contentWindow}catch{}}function xPe(t){let e,n=t[0],r=1;for(;r<t.length;){const s=t[r],i=t[r+1];if(r+=2,(s==="optionalAccess"||s==="optionalCall")&&n==null)return;s==="access"||s==="optionalAccess"?(e=n,n=i(n)):(s==="call"||s==="optionalCall")&&(n=i((...a)=>n.call(e,...a)),e=void 0)}return n}function oz(t){return"__ln"in t}class _Pe{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let n=this.head;for(let r=0;r<e;r++)n=xPe([n,"optionalAccess",s=>s.next])||null;return n}addNode(e){const n={value:e,previous:null,next:null};if(e.__ln=n,e.previousSibling&&oz(e.previousSibling)){const r=e.previousSibling.__ln.next;n.next=r,n.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(e.nextSibling&&oz(e.nextSibling)&&e.nextSibling.__ln.previous){const r=e.nextSibling.__ln.previous;n.previous=r,n.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;n.next===null&&(this.tail=n),this.length++}removeNode(e){const n=e.__ln;this.head&&(n.previous?(n.previous.next=n.next,n.next?n.next.previous=n.previous:this.tail=n.previous):(this.head=n.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const lz=(t,e)=>`${t}@${e}`;class wPe{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],n=new Set,r=new _Pe,s=u=>{let d=u,p=rg;for(;p===rg;)d=d&&d.nextSibling,p=d&&this.mirror.getId(d);return p},i=u=>{if(!u.parentNode||!vW(u))return;const d=vm(u.parentNode)?this.mirror.getId(gW(u)):this.mirror.getId(u.parentNode),p=s(u);if(d===-1||p===-1)return r.addNode(u);const h=Zd(u,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskAllText:this.maskAllText,unblockSelector:this.unblockSelector,maskTextClass:this.maskTextClass,unmaskTextClass:this.unmaskTextClass,maskTextSelector:this.maskTextSelector,unmaskTextSelector:this.unmaskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskAttributeFn:this.maskAttributeFn,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:g=>{pW(g,this.mirror)&&!Js(g,this.blockClass,this.blockSelector,this.unblockSelector,!1)&&this.iframeManager.addIframe(g),mW(g,this.mirror)&&this.stylesheetManager.trackLinkElement(g),tA(u)&&this.shadowDomManager.addShadowRoot(u.shadowRoot,this.doc)},onIframeLoad:(g,v)=>{Js(g,this.blockClass,this.blockSelector,this.unblockSelector,!1)||(this.iframeManager.attachIframe(g,v),g.contentWindow&&this.canvasManager.addWindow(g.contentWindow),this.shadowDomManager.observeAttachShadow(g))},onStylesheetLoad:(g,v)=>{this.stylesheetManager.attachLinkElement(g,v)}});h&&(e.push({parentId:d,nextId:p,node:h}),n.add(h.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const u of this.movedSet)cz(this.removes,u,this.mirror)&&!this.movedSet.has(u.parentNode)||i(u);for(const u of this.addedSet)!uz(this.droppedSet,u)&&!cz(this.removes,u,this.mirror)||uz(this.movedSet,u)?i(u):this.droppedSet.add(u);let a=null;for(;r.length;){let u=null;if(a){const d=this.mirror.getId(a.value.parentNode),p=s(a.value);d!==-1&&p!==-1&&(u=a)}if(!u){let d=r.tail;for(;d;){const p=d;if(d=d.previous,p){const h=this.mirror.getId(p.value.parentNode);if(s(p.value)===-1)continue;if(h!==-1){u=p;break}else{const v=p.value;if(v.parentNode&&v.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const b=v.parentNode.host;if(this.mirror.getId(b)!==-1){u=p;break}}}}}}if(!u){for(;r.head;)r.removeNode(r.head.value);break}a=u.previous,r.removeNode(u.value),i(u.value)}const l={texts:this.texts.map(u=>({id:this.mirror.getId(u.node),value:u.value})).filter(u=>!n.has(u.id)).filter(u=>this.mirror.has(u.id)),attributes:this.attributes.map(u=>{const{attributes:d}=u;if(typeof d.style=="string"){const p=JSON.stringify(u.styleDiff),h=JSON.stringify(u._unchangedStyles);p.length<d.style.length&&(p+h).split("var(").length===d.style.split("var(").length&&(d.style=u.styleDiff)}return{id:this.mirror.getId(u.node),attributes:d}}).filter(u=>!n.has(u.id)).filter(u=>this.mirror.has(u.id)),removes:this.removes,adds:e};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=e=>{if(!ek(e.target,this.mirror))switch(e.type){case"characterData":{const n=e.target.textContent;!Js(e.target,this.blockClass,this.blockSelector,this.unblockSelector,!1)&&n!==e.oldValue&&this.texts.push({value:Bf(e.target,this.maskTextClass,this.maskTextSelector,this.unmaskTextClass,this.unmaskTextSelector,this.maskAllText)&&n?this.maskTextFn?this.maskTextFn(n,fW(e.target)):n.replace(/[\S]/g,"*"):n,node:e.target});break}case"attributes":{const n=e.target;let r=e.attributeName,s=e.target.getAttribute(r);if(r==="value"){const a=Tj(n),l=n.tagName;s=Px(n,l,a);const u=n_({maskInputOptions:this.maskInputOptions,tagName:l,type:a}),d=Bf(e.target,this.maskTextClass,this.maskTextSelector,this.unmaskTextClass,this.unmaskTextSelector,u);s=ng({isMasked:d,element:n,value:s,maskInputFn:this.maskInputFn})}if(Js(e.target,this.blockClass,this.blockSelector,this.unblockSelector,!1)||s===e.oldValue)return;let i=this.attributeMap.get(e.target);if(n.tagName==="IFRAME"&&r==="src"&&!this.keepIframeSrcFn(s))if(!Rj(n))r="rr_src";else return;if(i||(i={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(e.target,i)),r==="type"&&n.tagName==="INPUT"&&(e.oldValue||"").toLowerCase()==="password"&&n.setAttribute("data-rr-is-password","true"),!oW(n.tagName,r)&&(i.attributes[r]=aW(this.doc,Uf(n.tagName),Uf(r),s,n,this.maskAttributeFn),r==="style")){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const a=this.unattachedDoc.createElement("span");e.oldValue&&a.setAttribute("style",e.oldValue);for(const l of Array.from(n.style)){const u=n.style.getPropertyValue(l),d=n.style.getPropertyPriority(l);u!==a.style.getPropertyValue(l)||d!==a.style.getPropertyPriority(l)?d===""?i.styleDiff[l]=u:i.styleDiff[l]=[u,d]:i._unchangedStyles[l]=[u,d]}for(const l of Array.from(a.style))n.style.getPropertyValue(l)===""&&(i.styleDiff[l]=!1)}break}case"childList":{if(Js(e.target,this.blockClass,this.blockSelector,this.unblockSelector,!0))return;e.addedNodes.forEach(n=>this.genAdds(n,e.target)),e.removedNodes.forEach(n=>{const r=this.mirror.getId(n),s=vm(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Js(e.target,this.blockClass,this.blockSelector,this.unblockSelector,!1)||ek(n,this.mirror)||!fPe(n,this.mirror)||(this.addedSet.has(n)?(nA(this.addedSet,n),this.droppedSet.add(n)):this.addedSet.has(e.target)&&r===-1||hW(e.target,this.mirror)||(this.movedSet.has(n)&&this.movedMap[lz(r,s)]?nA(this.movedSet,n):this.removes.push({parentId:s,id:r,isShadow:vm(e.target)&&ym(e.target)?!0:void 0})),this.mapRemoves.push(n))});break}}},this.genAdds=(e,n)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!(this.addedSet.has(e)||this.movedSet.has(e))){if(this.mirror.hasNode(e)){if(ek(e,this.mirror))return;this.movedSet.add(e);let r=null;n&&this.mirror.hasNode(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[lz(this.mirror.getId(e),r)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Js(e,this.blockClass,this.blockSelector,this.unblockSelector,!1)||(e.childNodes.forEach(r=>this.genAdds(r)),tA(e)&&e.shadowRoot.childNodes.forEach(r=>{this.processedNodeManager.add(r,this),this.genAdds(r,e)}))}}}init(e){["mutationCb","blockClass","blockSelector","unblockSelector","maskAllText","maskTextClass","unmaskTextClass","maskTextSelector","unmaskTextSelector","inlineStylesheet","maskInputOptions","maskAttributeFn","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(n=>{this[n]=e[n]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function nA(t,e){t.delete(e),e.childNodes.forEach(n=>nA(t,n))}function cz(t,e,n){return t.length===0?!1:SPe(t,e,n)}function SPe(t,e,n){let r=e.parentNode;for(;r;){const s=n.getId(r);if(t.some(i=>i.id===s))return!0;r=r.parentNode}return!1}function uz(t,e){return t.size===0?!1:yW(t,e)}function yW(t,e){const{parentNode:n}=e;return n?t.has(n)?!0:yW(t,n):!1}let bm;function EPe(t){bm=t}function kPe(){bm=void 0}const Zt=t=>bm?(...n)=>{try{return t(...n)}catch(r){if(bm&&bm(r)===!0)return()=>{};throw r}}:t;function Qi(t){let e,n=t[0],r=1;for(;r<t.length;){const s=t[r],i=t[r+1];if(r+=2,(s==="optionalAccess"||s==="optionalCall")&&n==null)return;s==="access"||s==="optionalAccess"?(e=n,n=i(n)):(s==="call"||s==="optionalCall")&&(n=i((...a)=>n.call(e,...a)),e=void 0)}return n}const ef=[];function $g(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0]}catch{}return t&&t.target}function bW(t,e){const n=new wPe;ef.push(n),n.init(t);let r=window.MutationObserver||window.__rrMutationObserver;const s=Qi([window,"optionalAccess",a=>a.Zone,"optionalAccess",a=>a.__symbol__,"optionalCall",a=>a("MutationObserver")]);s&&window[s]&&(r=window[s]);const i=new r(Zt(a=>{t.onMutation&&t.onMutation(a)===!1||n.processMutations.bind(n)(a)}));return i.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),i}function TPe({mousemoveCb:t,sampling:e,doc:n,mirror:r}){if(e.mousemove===!1)return()=>{};const s=typeof e.mousemove=="number"?e.mousemove:50,i=typeof e.mousemoveCallback=="number"?e.mousemoveCallback:500;let a=[],l;const u=sg(Zt(h=>{const g=Date.now()-l;t(a.map(v=>(v.timeOffset-=g,v)),h),a=[],l=null}),i),d=Zt(sg(Zt(h=>{const g=$g(h),{clientX:v,clientY:b}=eA(h)?h.changedTouches[0]:h;l||(l=Dx()),a.push({x:v,y:b,id:r.getId(g),timeOffset:Dx()-l}),u(typeof DragEvent<"u"&&h instanceof DragEvent?Tt.Drag:h instanceof MouseEvent?Tt.MouseMove:Tt.TouchMove)}),s,{trailing:!1})),p=[hs("mousemove",d,n),hs("touchmove",d,n),hs("drag",d,n)];return Zt(()=>{p.forEach(h=>h())})}function CPe({mouseInteractionCb:t,doc:e,mirror:n,blockClass:r,blockSelector:s,unblockSelector:i,sampling:a}){if(a.mouseInteraction===!1)return()=>{};const l=a.mouseInteraction===!0||a.mouseInteraction===void 0?{}:a.mouseInteraction,u=[];let d=null;const p=h=>g=>{const v=$g(g);if(Js(v,r,s,i,!0))return;let b=null,x=h;if("pointerType"in g){switch(g.pointerType){case"mouse":b=vo.Mouse;break;case"touch":b=vo.Touch;break;case"pen":b=vo.Pen;break}b===vo.Touch?ds[h]===ds.MouseDown?x="TouchStart":ds[h]===ds.MouseUp&&(x="TouchEnd"):vo.Pen}else eA(g)&&(b=vo.Touch);b!==null?(d=b,(x.startsWith("Touch")&&b===vo.Touch||x.startsWith("Mouse")&&b===vo.Mouse)&&(b=null)):ds[h]===ds.Click&&(b=d,d=null);const E=eA(g)?g.changedTouches[0]:g;if(!E)return;const S=n.getId(v),{clientX:k,clientY:T}=E;Zt(t)({type:ds[x],id:S,x:k,y:T,...b!==null&&{pointerType:b}})};return Object.keys(ds).filter(h=>Number.isNaN(Number(h))&&!h.endsWith("_Departed")&&l[h]!==!1).forEach(h=>{let g=Uf(h);const v=p(h);if(window.PointerEvent)switch(ds[h]){case ds.MouseDown:case ds.MouseUp:g=g.replace("mouse","pointer");break;case ds.TouchStart:case ds.TouchEnd:return}u.push(hs(g,v,e))}),Zt(()=>{u.forEach(h=>h())})}function xW({scrollCb:t,doc:e,mirror:n,blockClass:r,blockSelector:s,unblockSelector:i,sampling:a}){const l=Zt(sg(Zt(u=>{const d=$g(u);if(!d||Js(d,r,s,i,!0))return;const p=n.getId(d);if(d===e&&e.defaultView){const h=cW(e.defaultView);t({id:p,x:h.left,y:h.top})}else t({id:p,x:d.scrollLeft,y:d.scrollTop})}),a.scroll||100));return hs("scroll",l,e)}function APe({viewportResizeCb:t},{win:e}){let n=-1,r=-1;const s=Zt(sg(Zt(()=>{const i=uW(),a=dW();(n!==i||r!==a)&&(t({width:Number(a),height:Number(i)}),n=i,r=a)}),200));return hs("resize",s,e)}const NPe=["INPUT","TEXTAREA","SELECT"],dz=new WeakMap;function RPe({inputCb:t,doc:e,mirror:n,blockClass:r,blockSelector:s,unblockSelector:i,ignoreClass:a,ignoreSelector:l,maskInputOptions:u,maskInputFn:d,sampling:p,userTriggeredOnInput:h,maskTextClass:g,unmaskTextClass:v,maskTextSelector:b,unmaskTextSelector:x}){function E(N){let M=$g(N);const I=N.isTrusted,O=M&&JC(M.tagName);if(O==="OPTION"&&(M=M.parentElement),!M||!O||NPe.indexOf(O)<0||Js(M,r,s,i,!0))return;const L=M;if(L.classList.contains(a)||l&&L.matches(l))return;const z=Tj(M);let G=Px(L,O,z),W=!1;const X=n_({maskInputOptions:u,tagName:O,type:z}),F=Bf(M,g,b,v,x,X);(z==="radio"||z==="checkbox")&&(W=M.checked),G=ng({isMasked:F,element:M,value:G,maskInputFn:d}),S(M,h?{text:G,isChecked:W,userTriggered:I}:{text:G,isChecked:W});const Y=M.name;z==="radio"&&Y&&W&&e.querySelectorAll(`input[type="radio"][name="${Y}"]`).forEach(H=>{if(H!==M){const te=ng({isMasked:F,element:H,value:Px(H,O,z),maskInputFn:d});S(H,h?{text:te,isChecked:!W,userTriggered:!1}:{text:te,isChecked:!W})}})}function S(N,M){const I=dz.get(N);if(!I||I.text!==M.text||I.isChecked!==M.isChecked){dz.set(N,M);const O=n.getId(N);Zt(t)({...M,id:O})}}const T=(p.input==="last"?["change"]:["input","change"]).map(N=>hs(N,Zt(E),e)),R=e.defaultView;if(!R)return()=>{T.forEach(N=>N())};const j=R.Object.getOwnPropertyDescriptor(R.HTMLInputElement.prototype,"value"),A=[[R.HTMLInputElement.prototype,"value"],[R.HTMLInputElement.prototype,"checked"],[R.HTMLSelectElement.prototype,"value"],[R.HTMLTextAreaElement.prototype,"value"],[R.HTMLSelectElement.prototype,"selectedIndex"],[R.HTMLOptionElement.prototype,"selected"]];return j&&j.set&&T.push(...A.map(N=>lW(N[0],N[1],{set(){Zt(E)({target:this,isTrusted:!1})}},!1,R))),Zt(()=>{T.forEach(N=>N())})}function Lx(t){const e=[];function n(r,s){if(Fy("CSSGroupingRule")&&r.parentRule instanceof CSSGroupingRule||Fy("CSSMediaRule")&&r.parentRule instanceof CSSMediaRule||Fy("CSSSupportsRule")&&r.parentRule instanceof CSSSupportsRule||Fy("CSSConditionRule")&&r.parentRule instanceof CSSConditionRule){const a=Array.from(r.parentRule.cssRules).indexOf(r);s.unshift(a)}else if(r.parentStyleSheet){const a=Array.from(r.parentStyleSheet.cssRules).indexOf(r);s.unshift(a)}return s}return n(t,e)}function Ml(t,e,n){let r,s;return t?(t.ownerNode?r=e.getId(t.ownerNode):s=n.getId(t),{styleId:s,id:r}):{}}function jPe({styleSheetRuleCb:t,mirror:e,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const s=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(s,{apply:Zt((p,h,g)=>{const[v,b]=g,{id:x,styleId:E}=Ml(h,e,n.styleMirror);return(x&&x!==-1||E&&E!==-1)&&t({id:x,styleId:E,adds:[{rule:v,index:b}]}),p.apply(h,g)})});const i=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Zt((p,h,g)=>{const[v]=g,{id:b,styleId:x}=Ml(h,e,n.styleMirror);return(b&&b!==-1||x&&x!==-1)&&t({id:b,styleId:x,removes:[{index:v}]}),p.apply(h,g)})});let a;r.CSSStyleSheet.prototype.replace&&(a=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:Zt((p,h,g)=>{const[v]=g,{id:b,styleId:x}=Ml(h,e,n.styleMirror);return(b&&b!==-1||x&&x!==-1)&&t({id:b,styleId:x,replace:v}),p.apply(h,g)})}));let l;r.CSSStyleSheet.prototype.replaceSync&&(l=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:Zt((p,h,g)=>{const[v]=g,{id:b,styleId:x}=Ml(h,e,n.styleMirror);return(b&&b!==-1||x&&x!==-1)&&t({id:b,styleId:x,replaceSync:v}),p.apply(h,g)})}));const u={};Uy("CSSGroupingRule")?u.CSSGroupingRule=r.CSSGroupingRule:(Uy("CSSMediaRule")&&(u.CSSMediaRule=r.CSSMediaRule),Uy("CSSConditionRule")&&(u.CSSConditionRule=r.CSSConditionRule),Uy("CSSSupportsRule")&&(u.CSSSupportsRule=r.CSSSupportsRule));const d={};return Object.entries(u).forEach(([p,h])=>{d[p]={insertRule:h.prototype.insertRule,deleteRule:h.prototype.deleteRule},h.prototype.insertRule=new Proxy(d[p].insertRule,{apply:Zt((g,v,b)=>{const[x,E]=b,{id:S,styleId:k}=Ml(v.parentStyleSheet,e,n.styleMirror);return(S&&S!==-1||k&&k!==-1)&&t({id:S,styleId:k,adds:[{rule:x,index:[...Lx(v),E||0]}]}),g.apply(v,b)})}),h.prototype.deleteRule=new Proxy(d[p].deleteRule,{apply:Zt((g,v,b)=>{const[x]=b,{id:E,styleId:S}=Ml(v.parentStyleSheet,e,n.styleMirror);return(E&&E!==-1||S&&S!==-1)&&t({id:E,styleId:S,removes:[{index:[...Lx(v),x]}]}),g.apply(v,b)})})}),Zt(()=>{r.CSSStyleSheet.prototype.insertRule=s,r.CSSStyleSheet.prototype.deleteRule=i,a&&(r.CSSStyleSheet.prototype.replace=a),l&&(r.CSSStyleSheet.prototype.replaceSync=l),Object.entries(u).forEach(([p,h])=>{h.prototype.insertRule=d[p].insertRule,h.prototype.deleteRule=d[p].deleteRule})})}function _W({mirror:t,stylesheetManager:e},n){let r=null;n.nodeName==="#document"?r=t.getId(n):r=t.getId(n.host);const s=n.nodeName==="#document"?Qi([n,"access",a=>a.defaultView,"optionalAccess",a=>a.Document]):Qi([n,"access",a=>a.ownerDocument,"optionalAccess",a=>a.defaultView,"optionalAccess",a=>a.ShadowRoot]),i=Qi([s,"optionalAccess",a=>a.prototype])?Object.getOwnPropertyDescriptor(Qi([s,"optionalAccess",a=>a.prototype]),"adoptedStyleSheets"):void 0;return r===null||r===-1||!s||!i?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get(){return Qi([i,"access",a=>a.get,"optionalAccess",a=>a.call,"call",a=>a(this)])},set(a){const l=Qi([i,"access",u=>u.set,"optionalAccess",u=>u.call,"call",u=>u(this,a)]);if(r!==null&&r!==-1)try{e.adoptStyleSheets(a,r)}catch{}return l}}),Zt(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get:i.get,set:i.set})}))}function MPe({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:n,stylesheetManager:r},{win:s}){const i=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Zt((l,u,d)=>{const[p,h,g]=d;if(n.has(p))return i.apply(u,[p,h,g]);const{id:v,styleId:b}=Ml(Qi([u,"access",x=>x.parentRule,"optionalAccess",x=>x.parentStyleSheet]),e,r.styleMirror);return(v&&v!==-1||b&&b!==-1)&&t({id:v,styleId:b,set:{property:p,value:h,priority:g},index:Lx(u.parentRule)}),l.apply(u,d)})});const a=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:Zt((l,u,d)=>{const[p]=d;if(n.has(p))return a.apply(u,[p]);const{id:h,styleId:g}=Ml(Qi([u,"access",v=>v.parentRule,"optionalAccess",v=>v.parentStyleSheet]),e,r.styleMirror);return(h&&h!==-1||g&&g!==-1)&&t({id:h,styleId:g,remove:{property:p},index:Lx(u.parentRule)}),l.apply(u,d)})}),Zt(()=>{s.CSSStyleDeclaration.prototype.setProperty=i,s.CSSStyleDeclaration.prototype.removeProperty=a})}function OPe({mediaInteractionCb:t,blockClass:e,blockSelector:n,unblockSelector:r,mirror:s,sampling:i,doc:a}){const l=Zt(d=>sg(Zt(p=>{const h=$g(p);if(!h||Js(h,e,n,r,!0))return;const{currentTime:g,volume:v,muted:b,playbackRate:x}=h;t({type:d,id:s.getId(h),currentTime:g,volume:v,muted:b,playbackRate:x})}),i.media||500)),u=[hs("play",l(0),a),hs("pause",l(1),a),hs("seeked",l(2),a),hs("volumechange",l(3),a),hs("ratechange",l(4),a)];return Zt(()=>{u.forEach(d=>d())})}function PPe({fontCb:t,doc:e}){const n=e.defaultView;if(!n)return()=>{};const r=[],s=new WeakMap,i=n.FontFace;n.FontFace=function(u,d,p){const h=new i(u,d,p);return s.set(h,{family:u,buffer:typeof d!="string",descriptors:p,fontSource:typeof d=="string"?d:JSON.stringify(Array.from(new Uint8Array(d)))}),h};const a=Aj(e.fonts,"add",function(l){return function(u){return s_(Zt(()=>{const d=s.get(u);d&&(t(d),s.delete(u))}),0),l.apply(this,[u])}});return r.push(()=>{n.FontFace=i}),r.push(a),Zt(()=>{r.forEach(l=>l())})}function IPe(t){const{doc:e,mirror:n,blockClass:r,blockSelector:s,unblockSelector:i,selectionCb:a}=t;let l=!0;const u=Zt(()=>{const d=e.getSelection();if(!d||l&&Qi([d,"optionalAccess",g=>g.isCollapsed]))return;l=d.isCollapsed||!1;const p=[],h=d.rangeCount||0;for(let g=0;g<h;g++){const v=d.getRangeAt(g),{startContainer:b,startOffset:x,endContainer:E,endOffset:S}=v;Js(b,r,s,i,!0)||Js(E,r,s,i,!0)||p.push({start:n.getId(b),startOffset:x,end:n.getId(E),endOffset:S})}a({ranges:p})});return u(),hs("selectionchange",u)}function DPe({doc:t,customElementCb:e}){const n=t.defaultView;return!n||!n.customElements?()=>{}:Aj(n.customElements,"define",function(s){return function(i,a,l){try{e({define:{name:i}})}catch{}return s.apply(this,[i,a,l])}})}function LPe(t,e={}){const n=t.doc.defaultView;if(!n)return()=>{};let r;t.recordDOM&&(r=bW(t,t.doc));const s=TPe(t),i=CPe(t),a=xW(t),l=APe(t,{win:n}),u=RPe(t),d=OPe(t);let p=()=>{},h=()=>{},g=()=>{},v=()=>{};t.recordDOM&&(p=jPe(t,{win:n}),h=_W(t,t.doc),g=MPe(t,{win:n}),t.collectFonts&&(v=PPe(t)));const b=IPe(t),x=DPe(t),E=[];for(const S of t.plugins)E.push(S.observer(S.callback,n,S.options));return Zt(()=>{ef.forEach(S=>S.reset()),Qi([r,"optionalAccess",S=>S.disconnect,"call",S=>S()]),s(),i(),a(),l(),u(),d(),p(),h(),g(),v(),b(),x(),E.forEach(S=>S())})}function Fy(t){return typeof window[t]<"u"}function Uy(t){return!!(typeof window[t]<"u"&&window[t].prototype&&"insertRule"in window[t].prototype&&"deleteRule"in window[t].prototype)}class rA{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,n,r,s){const i=r||this.getIdToRemoteIdMap(e),a=s||this.getRemoteIdToIdMap(e);let l=i.get(n);return l||(l=this.generateIdFn(),i.set(n,l),a.set(l,n)),l}getIds(e,n){const r=this.getIdToRemoteIdMap(e),s=this.getRemoteIdToIdMap(e);return n.map(i=>this.getId(e,i,r,s))}getRemoteId(e,n,r){const s=r||this.getRemoteIdToIdMap(e);if(typeof n!="number")return n;const i=s.get(n);return i||-1}getRemoteIds(e,n){const r=this.getRemoteIdToIdMap(e);return n.map(s=>this.getRemoteId(e,s,r))}reset(e){if(!e){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let n=this.iframeIdToRemoteIdMap.get(e);return n||(n=new Map,this.iframeIdToRemoteIdMap.set(e,n)),n}getRemoteIdToIdMap(e){let n=this.iframeRemoteIdToIdMap.get(e);return n||(n=new Map,this.iframeRemoteIdToIdMap.set(e,n)),n}}function fz(t){let e,n=t[0],r=1;for(;r<t.length;){const s=t[r],i=t[r+1];if(r+=2,(s==="optionalAccess"||s==="optionalCall")&&n==null)return;s==="access"||s==="optionalAccess"?(e=n,n=i(n)):(s==="call"||s==="optionalCall")&&(n=i((...a)=>n.call(e,...a)),e=void 0)}return n}class $Pe{constructor(){this.crossOriginIframeMirror=new rA(Cj),this.crossOriginIframeRootIdMap=new WeakMap}addIframe(){}addLoadListener(){}attachIframe(){}}class zPe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new rA(Cj),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new rA(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,n){this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:n}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),fz([this,"access",s=>s.loadListener,"optionalCall",s=>s(e)]);const r=Rj(e);r&&r.adoptedStyleSheets&&r.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(r.adoptedStyleSheets,this.mirror.getId(r))}handleMessage(e){const n=e;if(n.data.type!=="rrweb"||n.origin!==n.data.origin||!e.source)return;const s=this.crossOriginIframeMap.get(e.source);if(!s)return;const i=this.transformCrossOriginEvent(s,n.data.event);i&&this.wrappedEmit(i,n.data.isCheckout)}transformCrossOriginEvent(e,n){switch(n.type){case Ft.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(n.data.node,e);const r=n.data.node.id;return this.crossOriginIframeRootIdMap.set(e,r),this.patchRootIdOnNode(n.data.node,r),{timestamp:n.timestamp,type:Ft.IncrementalSnapshot,data:{source:Tt.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:n.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Ft.Meta:case Ft.Load:case Ft.DomContentLoaded:return!1;case Ft.Plugin:return n;case Ft.Custom:return this.replaceIds(n.data.payload,e,["id","parentId","previousId","nextId"]),n;case Ft.IncrementalSnapshot:switch(n.data.source){case Tt.Mutation:return n.data.adds.forEach(r=>{this.replaceIds(r,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(r.node,e);const s=this.crossOriginIframeRootIdMap.get(e);s&&this.patchRootIdOnNode(r.node,s)}),n.data.removes.forEach(r=>{this.replaceIds(r,e,["parentId","id"])}),n.data.attributes.forEach(r=>{this.replaceIds(r,e,["id"])}),n.data.texts.forEach(r=>{this.replaceIds(r,e,["id"])}),n;case Tt.Drag:case Tt.TouchMove:case Tt.MouseMove:return n.data.positions.forEach(r=>{this.replaceIds(r,e,["id"])}),n;case Tt.ViewportResize:return!1;case Tt.MediaInteraction:case Tt.MouseInteraction:case Tt.Scroll:case Tt.CanvasMutation:case Tt.Input:return this.replaceIds(n.data,e,["id"]),n;case Tt.StyleSheetRule:case Tt.StyleDeclaration:return this.replaceIds(n.data,e,["id"]),this.replaceStyleIds(n.data,e,["styleId"]),n;case Tt.Font:return n;case Tt.Selection:return n.data.ranges.forEach(r=>{this.replaceIds(r,e,["start","end"])}),n;case Tt.AdoptedStyleSheet:return this.replaceIds(n.data,e,["id"]),this.replaceStyleIds(n.data,e,["styleIds"]),fz([n,"access",r=>r.data,"access",r=>r.styles,"optionalAccess",r=>r.forEach,"call",r=>r(s=>{this.replaceStyleIds(s,e,["styleId"])})]),n}}return!1}replace(e,n,r,s){for(const i of s)!Array.isArray(n[i])&&typeof n[i]!="number"||(Array.isArray(n[i])?n[i]=e.getIds(r,n[i]):n[i]=e.getId(r,n[i]));return n}replaceIds(e,n,r){return this.replace(this.crossOriginIframeMirror,e,n,r)}replaceStyleIds(e,n,r){return this.replace(this.crossOriginIframeStyleMirror,e,n,r)}replaceIdOnNode(e,n){this.replaceIds(e,n,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(r=>{this.replaceIdOnNode(r,n)})}patchRootIdOnNode(e,n){e.type!==Er.Document&&!e.rootId&&(e.rootId=n),"childNodes"in e&&e.childNodes.forEach(r=>{this.patchRootIdOnNode(r,n)})}}class FPe{init(){}addShadowRoot(){}observeAttachShadow(){}reset(){}}class UPe{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,n){if(!ym(e)||this.shadowDoms.has(e))return;this.shadowDoms.add(e),this.bypassOptions.canvasManager.addShadowRoot(e);const r=bW({...this.bypassOptions,doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>r.disconnect()),this.restoreHandlers.push(xW({...this.bypassOptions,scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),s_(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(_W({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){const n=Rj(e),r=bPe(e);!n||!r||this.patchAttachShadow(r.Element,n)}patchAttachShadow(e,n){const r=this;this.restoreHandlers.push(Aj(e.prototype,"attachShadow",function(s){return function(i){const a=s.call(this,i);return this.shadowRoot&&vW(this)&&r.addShadowRoot(this.shadowRoot,n),a}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet,this.bypassOptions.canvasManager.resetShadowRoots()}}class hz{reset(){}freeze(){}unfreeze(){}lock(){}unlock(){}snapshot(){}addWindow(){}addShadowRoot(){}resetShadowRoots(){}}class BPe{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new pPe,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,n){"_cssText"in n.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:n.id,attributes:n.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,n){if(e.length===0)return;const r={id:n,styleIds:[]},s=[];for(const i of e){let a;this.styleMirror.has(i)?a=this.styleMirror.getId(i):(a=this.styleMirror.add(i),s.push({styleId:a,rules:Array.from(i.rules||CSSRule,(l,u)=>({rule:eW(l),index:u}))})),r.styleIds.push(a)}s.length>0&&(r.styles=s),this.adoptedStyleSheetCb(r)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}class qPe{constructor(){this.nodeMap=new WeakMap,this.active=!1}inOtherBuffer(e,n){const r=this.nodeMap.get(e);return r&&Array.from(r).some(s=>s!==n)}add(e,n){this.active||(this.active=!0,vPe(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(n))}destroy(){}}let Yn,$x;try{if(Array.from([1],t=>t*2)[0]!==2){const t=document.createElement("iframe");document.body.appendChild(t),Array.from=fb([t,"access",e=>e.contentWindow,"optionalAccess",e=>e.Array,"access",e=>e.from])||Array.from,document.body.removeChild(t)}}catch(t){console.debug("Unable to override Array.from",t)}const Hi=BOe();function Ro(t={}){const{emit:e,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:i=null,unblockSelector:a=null,ignoreClass:l="rr-ignore",ignoreSelector:u=null,maskAllText:d=!1,maskTextClass:p="rr-mask",unmaskTextClass:h=null,maskTextSelector:g=null,unmaskTextSelector:v=null,inlineStylesheet:b=!0,maskAllInputs:x,maskInputOptions:E,slimDOMOptions:S,maskAttributeFn:k,maskInputFn:T,maskTextFn:R,maxCanvasSize:j=null,packFn:A,sampling:N={},dataURLOptions:M={},mousemoveWait:I,recordDOM:O=!0,recordCanvas:L=!1,recordCrossOriginIframes:z=!1,recordAfter:G=t.recordAfter==="DOMContentLoaded"?t.recordAfter:"load",userTriggeredOnInput:W=!1,collectFonts:X=!1,inlineImages:F=!1,plugins:Y,keepIframeSrcFn:H=()=>!1,ignoreCSSAttributes:te=new Set([]),errorHandler:P,onMutation:re,getCanvasManager:ue}=t;EPe(P);const D=z?window.parent===window:!0;let Z=!1;if(!D)try{window.parent.document&&(Z=!1)}catch{Z=!0}if(D&&!e)throw new Error("emit function is required");if(!D&&!Z)return()=>{};I!==void 0&&N.mousemove===void 0&&(N.mousemove=I),Hi.reset();const he=x===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,radio:!0,checkbox:!0}:E!==void 0?E:{},V=S===!0||S==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:S==="all",headMetaDescKeywords:S==="all"}:S||{};hPe();let U,K=0;const ae=Be=>{for(const pt of Y||[])pt.eventProcessor&&(Be=pt.eventProcessor(Be));return A&&!Z&&(Be=A(Be)),Be};Yn=(Be,pt)=>{const De=Be;if(De.timestamp=Dx(),fb([ef,"access",et=>et[0],"optionalAccess",et=>et.isFrozen,"call",et=>et()])&&De.type!==Ft.FullSnapshot&&!(De.type===Ft.IncrementalSnapshot&&De.data.source===Tt.Mutation)&&ef.forEach(et=>et.unfreeze()),D)fb([e,"optionalCall",et=>et(ae(De),pt)]);else if(Z){const et={type:"rrweb",event:ae(De),origin:window.location.origin,isCheckout:pt};window.parent.postMessage(et,"*")}if(De.type===Ft.FullSnapshot)U=De,K=0;else if(De.type===Ft.IncrementalSnapshot){if(De.data.source===Tt.Mutation&&De.data.isAttachIframe)return;K++;const et=r&&K>=r,ot=n&&U&&De.timestamp-U.timestamp>n;(et||ot)&&dt(!0)}};const B=Be=>{Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.Mutation,...Be}})},J=Be=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.Scroll,...Be}}),oe=Be=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.CanvasMutation,...Be}}),fe=Be=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.AdoptedStyleSheet,...Be}}),be=new BPe({mutationCb:B,adoptedStyleSheetCb:fe}),Ae=typeof __RRWEB_EXCLUDE_IFRAME__=="boolean"&&__RRWEB_EXCLUDE_IFRAME__?new $Pe:new zPe({mirror:Hi,mutationCb:B,stylesheetManager:be,recordCrossOriginIframes:z,wrappedEmit:Yn});for(const Be of Y||[])Be.getMirror&&Be.getMirror({nodeMirror:Hi,crossOriginIframeMirror:Ae.crossOriginIframeMirror,crossOriginIframeStyleMirror:Ae.crossOriginIframeStyleMirror});const Oe=new qPe,Ne=HPe(ue,{mirror:Hi,win:window,mutationCb:Be=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.CanvasMutation,...Be}}),recordCanvas:L,blockClass:s,blockSelector:i,unblockSelector:a,maxCanvasSize:j,sampling:N.canvas,dataURLOptions:M,errorHandler:P}),Qe=typeof __RRWEB_EXCLUDE_SHADOW_DOM__=="boolean"&&__RRWEB_EXCLUDE_SHADOW_DOM__?new FPe:new UPe({mutationCb:B,scrollCb:J,bypassOptions:{onMutation:re,blockClass:s,blockSelector:i,unblockSelector:a,maskAllText:d,maskTextClass:p,unmaskTextClass:h,maskTextSelector:g,unmaskTextSelector:v,inlineStylesheet:b,maskInputOptions:he,dataURLOptions:M,maskAttributeFn:k,maskTextFn:R,maskInputFn:T,recordCanvas:L,inlineImages:F,sampling:N,slimDOMOptions:V,iframeManager:Ae,stylesheetManager:be,canvasManager:Ne,keepIframeSrcFn:H,processedNodeManager:Oe},mirror:Hi}),dt=(Be=!1)=>{if(!O)return;Yn({type:Ft.Meta,data:{href:window.location.href,width:dW(),height:uW()}},Be),be.reset(),Qe.init(),ef.forEach(De=>De.lock());const pt=dPe(document,{mirror:Hi,blockClass:s,blockSelector:i,unblockSelector:a,maskAllText:d,maskTextClass:p,unmaskTextClass:h,maskTextSelector:g,unmaskTextSelector:v,inlineStylesheet:b,maskAllInputs:he,maskAttributeFn:k,maskInputFn:T,maskTextFn:R,slimDOM:V,dataURLOptions:M,recordCanvas:L,inlineImages:F,onSerialize:De=>{pW(De,Hi)&&Ae.addIframe(De),mW(De,Hi)&&be.trackLinkElement(De),tA(De)&&Qe.addShadowRoot(De.shadowRoot,document)},onIframeLoad:(De,et)=>{Ae.attachIframe(De,et),De.contentWindow&&Ne.addWindow(De.contentWindow),Qe.observeAttachShadow(De)},onStylesheetLoad:(De,et)=>{be.attachLinkElement(De,et)},keepIframeSrcFn:H});if(!pt)return console.warn("Failed to snapshot the document");Yn({type:Ft.FullSnapshot,data:{node:pt,initialOffset:cW(window)}}),ef.forEach(De=>De.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&be.adoptStyleSheets(document.adoptedStyleSheets,Hi.getId(document))};$x=dt;try{const Be=[],pt=et=>Zt(LPe)({onMutation:re,mutationCb:B,mousemoveCb:(ot,lr)=>Yn({type:Ft.IncrementalSnapshot,data:{source:lr,positions:ot}}),mouseInteractionCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.MouseInteraction,...ot}}),scrollCb:J,viewportResizeCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.ViewportResize,...ot}}),inputCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.Input,...ot}}),mediaInteractionCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.MediaInteraction,...ot}}),styleSheetRuleCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.StyleSheetRule,...ot}}),styleDeclarationCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.StyleDeclaration,...ot}}),canvasMutationCb:oe,fontCb:ot=>Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.Font,...ot}}),selectionCb:ot=>{Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.Selection,...ot}})},customElementCb:ot=>{Yn({type:Ft.IncrementalSnapshot,data:{source:Tt.CustomElement,...ot}})},blockClass:s,ignoreClass:l,ignoreSelector:u,maskAllText:d,maskTextClass:p,unmaskTextClass:h,maskTextSelector:g,unmaskTextSelector:v,maskInputOptions:he,inlineStylesheet:b,sampling:N,recordDOM:O,recordCanvas:L,inlineImages:F,userTriggeredOnInput:W,collectFonts:X,doc:et,maskAttributeFn:k,maskInputFn:T,maskTextFn:R,keepIframeSrcFn:H,blockSelector:i,unblockSelector:a,slimDOMOptions:V,dataURLOptions:M,mirror:Hi,iframeManager:Ae,stylesheetManager:be,shadowDomManager:Qe,processedNodeManager:Oe,canvasManager:Ne,ignoreCSSAttributes:te,plugins:fb([Y,"optionalAccess",ot=>ot.filter,"call",ot=>ot(lr=>lr.observer),"optionalAccess",ot=>ot.map,"call",ot=>ot(lr=>({observer:lr.observer,options:lr.options,callback:xe=>Yn({type:Ft.Plugin,data:{plugin:lr.name,payload:xe}})}))])||[]},{});Ae.addLoadListener(et=>{try{Be.push(pt(et.contentDocument))}catch(ot){console.warn(ot)}});const De=()=>{dt(),Be.push(pt(document))};return document.readyState==="interactive"||document.readyState==="complete"?De():(Be.push(hs("DOMContentLoaded",()=>{Yn({type:Ft.DomContentLoaded,data:{}}),G==="DOMContentLoaded"&&De()})),Be.push(hs("load",()=>{Yn({type:Ft.Load,data:{}}),G==="load"&&De()},window))),()=>{Be.forEach(et=>et()),Oe.destroy(),$x=void 0,kPe()}}catch(Be){console.warn(Be)}}function VPe(t){if(!$x)throw new Error("please take full snapshot after start recording");$x(t)}Ro.mirror=Hi;Ro.takeFullSnapshot=VPe;function HPe(t,e){try{return t?t(e):new hz}catch{return console.warn("Unable to initialize CanvasManager"),new hz}}const GPe=3,WPe=5;function jj(t){return t>9999999999?t:t*1e3}function tk(t){return t>9999999999?t/1e3:t}function zg(t,e){e.category!=="sentry.transaction"&&(["ui.click","ui.input"].includes(e.category)?t.triggerUserActivity():t.checkAndHandleExpiredSession(),t.addUpdate(()=>(t.throttledAddEvent({type:Ft.Custom,timestamp:(e.timestamp||0)*1e3,data:{tag:"breadcrumb",payload:Ki(e,10,1e3)}}),e.category==="console")))}const YPe="button,a";function wW(t){return t.closest(YPe)||t}function SW(t){const e=EW(t);return!e||!(e instanceof Element)?e:wW(e)}function EW(t){return KPe(t)?t.target:t}function KPe(t){return typeof t=="object"&&!!t&&"target"in t}let Ol;function XPe(t){return Ol||(Ol=[],QPe()),Ol.push(t),()=>{const e=Ol?Ol.indexOf(t):-1;e>-1&&Ol.splice(e,1)}}function QPe(){Is(kn,"open",function(t){return function(...e){if(Ol)try{Ol.forEach(n=>n())}catch{}return t.apply(kn,e)}})}const JPe=new Set([Tt.Mutation,Tt.StyleSheetRule,Tt.StyleDeclaration,Tt.AdoptedStyleSheet,Tt.CanvasMutation,Tt.Selection,Tt.MediaInteraction]);function ZPe(t,e,n){t.handleClick(e,n)}class eIe{constructor(e,n,r=zg){this._lastMutation=0,this._lastScroll=0,this._clicks=[],this._timeout=n.timeout/1e3,this._threshold=n.threshold/1e3,this._scrollTimeout=n.scrollTimeout/1e3,this._replay=e,this._ignoreSelector=n.ignoreSelector,this._addBreadcrumbEvent=r}addListeners(){const e=XPe(()=>{this._lastMutation=pz()});this._teardown=()=>{e(),this._clicks=[],this._lastMutation=0,this._lastScroll=0}}removeListeners(){this._teardown&&this._teardown(),this._checkClickTimeout&&clearTimeout(this._checkClickTimeout)}handleClick(e,n){if(nIe(n,this._ignoreSelector)||!rIe(e))return;const r={timestamp:tk(e.timestamp),clickBreadcrumb:e,clickCount:0,node:n};this._clicks.some(s=>s.node===r.node&&Math.abs(s.timestamp-r.timestamp)<1)||(this._clicks.push(r),this._clicks.length===1&&this._scheduleCheckClicks())}registerMutation(e=Date.now()){this._lastMutation=tk(e)}registerScroll(e=Date.now()){this._lastScroll=tk(e)}registerClick(e){const n=wW(e);this._handleMultiClick(n)}_handleMultiClick(e){this._getClicks(e).forEach(n=>{n.clickCount++})}_getClicks(e){return this._clicks.filter(n=>n.node===e)}_checkClicks(){const e=[],n=pz();this._clicks.forEach(r=>{!r.mutationAfter&&this._lastMutation&&(r.mutationAfter=r.timestamp<=this._lastMutation?this._lastMutation-r.timestamp:void 0),!r.scrollAfter&&this._lastScroll&&(r.scrollAfter=r.timestamp<=this._lastScroll?this._lastScroll-r.timestamp:void 0),r.timestamp+this._timeout<=n&&e.push(r)});for(const r of e){const s=this._clicks.indexOf(r);s>-1&&(this._generateBreadcrumbs(r),this._clicks.splice(s,1))}this._clicks.length&&this._scheduleCheckClicks()}_generateBreadcrumbs(e){const n=this._replay,r=e.scrollAfter&&e.scrollAfter<=this._scrollTimeout,s=e.mutationAfter&&e.mutationAfter<=this._threshold,i=!r&&!s,{clickCount:a,clickBreadcrumb:l}=e;if(i){const u=Math.min(e.mutationAfter||this._timeout,this._timeout)*1e3,d=u<this._timeout*1e3?"mutation":"timeout",p={type:"default",message:l.message,timestamp:l.timestamp,category:"ui.slowClickDetected",data:{...l.data,url:kn.location.href,route:n.getCurrentRoute(),timeAfterClickMs:u,endReason:d,clickCount:a||1}};this._addBreadcrumbEvent(n,p);return}if(a>1){const u={type:"default",message:l.message,timestamp:l.timestamp,category:"ui.multiClick",data:{...l.data,url:kn.location.href,route:n.getCurrentRoute(),clickCount:a,metric:!0}};this._addBreadcrumbEvent(n,u)}}_scheduleCheckClicks(){this._checkClickTimeout&&clearTimeout(this._checkClickTimeout),this._checkClickTimeout=Ff(()=>this._checkClicks(),1e3)}}const tIe=["A","BUTTON","INPUT"];function nIe(t,e){return!!(!tIe.includes(t.tagName)||t.tagName==="INPUT"&&!["submit","button"].includes(t.getAttribute("type")||"")||t.tagName==="A"&&(t.hasAttribute("download")||t.hasAttribute("target")&&t.getAttribute("target")!=="_self")||e&&t.matches(e))}function rIe(t){return!!(t.data&&typeof t.data.nodeId=="number"&&t.timestamp)}function pz(){return Date.now()/1e3}function sIe(t,e){try{if(!iIe(e))return;const{source:n}=e.data;if(JPe.has(n)&&t.registerMutation(e.timestamp),n===Tt.Scroll&&t.registerScroll(e.timestamp),aIe(e)){const{type:r,id:s}=e.data,i=Ro.mirror.getNode(s);i instanceof HTMLElement&&r===ds.Click&&t.registerClick(i)}}catch{}}function iIe(t){return t.type===GPe}function aIe(t){return t.data.source===Tt.MouseInteraction}function Ra(t){return{timestamp:Date.now()/1e3,type:"default",...t}}var zx;(function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"})(zx||(zx={}));const oIe=new Set(["id","class","aria-label","role","name","alt","title","data-test-id","data-testid","disabled","aria-disabled","data-sentry-component"]);function lIe(t){const e={};!t["data-sentry-component"]&&t["data-sentry-element"]&&(t["data-sentry-component"]=t["data-sentry-element"]);for(const n in t)if(oIe.has(n)){let r=n;(n==="data-testid"||n==="data-test-id")&&(r="testId"),e[r]=t[n]}return e}const cIe=t=>e=>{if(!t.isEnabled())return;const n=uIe(e);if(!n)return;const r=e.name==="click",s=r?e.event:void 0;r&&t.clickDetector&&s&&s.target&&!s.altKey&&!s.metaKey&&!s.ctrlKey&&!s.shiftKey&&ZPe(t.clickDetector,n,SW(e.event)),zg(t,n)};function kW(t,e){const n=Ro.mirror.getId(t),r=n&&Ro.mirror.getNode(n),s=r&&Ro.mirror.getMeta(r),i=s&&fIe(s)?s:null;return{message:e,data:i?{nodeId:n,node:{id:n,tagName:i.tagName,textContent:Array.from(i.childNodes).map(a=>a.type===zx.Text&&a.textContent).filter(Boolean).map(a=>a.trim()).join(""),attributes:lIe(i.attributes)}}:{}}}function uIe(t){const{target:e,message:n}=dIe(t);return Ra({category:`ui.${t.name}`,...kW(e,n)})}function dIe(t){const e=t.name==="click";let n,r=null;try{r=e?SW(t.event):EW(t.event),n=Uo(r,{maxStringLength:200})||"<unknown>"}catch{n="<unknown>"}return{target:r,message:n}}function fIe(t){return t.type===zx.Element}function hIe(t,e){if(!t.isEnabled())return;t.updateUserActivity();const n=pIe(e);n&&zg(t,n)}function pIe(t){const{metaKey:e,shiftKey:n,ctrlKey:r,altKey:s,key:i,target:a}=t;if(!a||mIe(a)||!i)return null;const l=e||r||s,u=i.length===1;if(!l&&u)return null;const d=Uo(a,{maxStringLength:200})||"<unknown>",p=kW(a,d);return Ra({category:"ui.keyDown",message:d,data:{...p.data,metaKey:e,shiftKey:n,ctrlKey:r,altKey:s,key:i}})}function mIe(t){return t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable}const gIe={resource:_Ie,paint:bIe,navigation:xIe};function By(t,e){return({metric:n})=>void e.replayPerformanceEntries.push(t(n))}function vIe(t){return t.map(yIe).filter(Boolean)}function yIe(t){const e=gIe[t.entryType];return e?e(t):null}function qf(t){return((vs||kn.performance.timeOrigin)+t)/1e3}function bIe(t){const{duration:e,entryType:n,name:r,startTime:s}=t,i=qf(s);return{type:n,name:r,start:i,end:i+e,data:void 0}}function xIe(t){const{entryType:e,name:n,decodedBodySize:r,duration:s,domComplete:i,encodedBodySize:a,domContentLoadedEventStart:l,domContentLoadedEventEnd:u,domInteractive:d,loadEventStart:p,loadEventEnd:h,redirectCount:g,startTime:v,transferSize:b,type:x}=t;return s===0?null:{type:`${e}.${x}`,start:qf(v),end:qf(i),name:n,data:{size:b,decodedBodySize:r,encodedBodySize:a,duration:s,domInteractive:d,domContentLoadedEventStart:l,domContentLoadedEventEnd:u,loadEventStart:p,loadEventEnd:h,domComplete:i,redirectCount:g}}}function _Ie(t){const{entryType:e,initiatorType:n,name:r,responseEnd:s,startTime:i,decodedBodySize:a,encodedBodySize:l,responseStatus:u,transferSize:d}=t;return["fetch","xmlhttprequest"].includes(n)?null:{type:`${e}.${n}`,start:qf(i),end:qf(s),name:r,data:{size:d,statusCode:u,decodedBodySize:a,encodedBodySize:l}}}function wIe(t){const e=t.entries[t.entries.length-1],n=e&&e.element?[e.element]:void 0;return i_(t,"largest-contentful-paint",n)}function SIe(t){return t.sources!==void 0}function EIe(t){const e=[],n=[];for(const r of t.entries)if(SIe(r)){const s=[];for(const i of r.sources)if(i.node){n.push(i.node);const a=Ro.mirror.getId(i.node);a&&s.push(a)}e.push({value:r.value,nodeIds:s.length?s:void 0})}return i_(t,"cumulative-layout-shift",n,e)}function kIe(t){const e=t.entries[t.entries.length-1],n=e&&e.target?[e.target]:void 0;return i_(t,"first-input-delay",n)}function TIe(t){const e=t.entries[t.entries.length-1],n=e&&e.target?[e.target]:void 0;return i_(t,"interaction-to-next-paint",n)}function i_(t,e,n,r){const s=t.value,i=t.rating,a=qf(s);return{type:"web-vital",name:e,start:a,end:a,data:{value:s,size:s,rating:i,nodeIds:n?n.map(l=>Ro.mirror.getId(l)):void 0,attributions:r}}}function CIe(t){function e(s){t.performanceEntries.includes(s)||t.performanceEntries.push(s)}function n({entries:s}){s.forEach(e)}const r=[];return["navigation","paint","resource"].forEach(s=>{r.push(zf(s,n))}),r.push(BG(By(wIe,t)),_j(By(EIe,t)),qG(By(kIe,t)),VG(By(TIe,t))),()=>{r.forEach(s=>s())}}const yt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,AIe='var t=Uint8Array,n=Uint16Array,r=Int32Array,e=new t([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new t([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=function(t,e){for(var i=new n(31),a=0;a<31;++a)i[a]=e+=1<<t[a-1];var s=new r(i[30]);for(a=1;a<30;++a)for(var o=i[a];o<i[a+1];++o)s[o]=o-i[a]<<5|a;return{b:i,r:s}},o=s(e,2),f=o.b,h=o.r;f[28]=258,h[258]=28;for(var l=s(i,0).r,u=new n(32768),c=0;c<32768;++c){var v=(43690&c)>>1|(21845&c)<<1;v=(61680&(v=(52428&v)>>2|(13107&v)<<2))>>4|(3855&v)<<4,u[c]=((65280&v)>>8|(255&v)<<8)>>1}var d=function(t,r,e){for(var i=t.length,a=0,s=new n(r);a<i;++a)t[a]&&++s[t[a]-1];var o,f=new n(r);for(a=1;a<r;++a)f[a]=f[a-1]+s[a-1]<<1;if(e){o=new n(1<<r);var h=15-r;for(a=0;a<i;++a)if(t[a])for(var l=a<<4|t[a],c=r-t[a],v=f[t[a]-1]++<<c,d=v|(1<<c)-1;v<=d;++v)o[u[v]>>h]=l}else for(o=new n(i),a=0;a<i;++a)t[a]&&(o[a]=u[f[t[a]-1]++]>>15-t[a]);return o},g=new t(288);for(c=0;c<144;++c)g[c]=8;for(c=144;c<256;++c)g[c]=9;for(c=256;c<280;++c)g[c]=7;for(c=280;c<288;++c)g[c]=8;var w=new t(32);for(c=0;c<32;++c)w[c]=5;var p=d(g,9,0),y=d(w,5,0),m=function(t){return(t+7)/8|0},b=function(n,r,e){return(null==e||e>n.length)&&(e=n.length),new t(n.subarray(r,e))},M=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],E=function(t,n,r){var e=new Error(n||M[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,E),!r)throw e;return e},z=function(t,n,r){r<<=7&n;var e=n/8|0;t[e]|=r,t[e+1]|=r>>8},_=function(t,n,r){r<<=7&n;var e=n/8|0;t[e]|=r,t[e+1]|=r>>8,t[e+2]|=r>>16},x=function(r,e){for(var i=[],a=0;a<r.length;++a)r[a]&&i.push({s:a,f:r[a]});var s=i.length,o=i.slice();if(!s)return{t:F,l:0};if(1==s){var f=new t(i[0].s+1);return f[i[0].s]=1,{t:f,l:1}}i.sort((function(t,n){return t.f-n.f})),i.push({s:-1,f:25001});var h=i[0],l=i[1],u=0,c=1,v=2;for(i[0]={s:-1,f:h.f+l.f,l:h,r:l};c!=s-1;)h=i[i[u].f<i[v].f?u++:v++],l=i[u!=c&&i[u].f<i[v].f?u++:v++],i[c++]={s:-1,f:h.f+l.f,l:h,r:l};var d=o[0].s;for(a=1;a<s;++a)o[a].s>d&&(d=o[a].s);var g=new n(d+1),w=A(i[c-1],g,0);if(w>e){a=0;var p=0,y=w-e,m=1<<y;for(o.sort((function(t,n){return g[n.s]-g[t.s]||t.f-n.f}));a<s;++a){var b=o[a].s;if(!(g[b]>e))break;p+=m-(1<<w-g[b]),g[b]=e}for(p>>=y;p>0;){var M=o[a].s;g[M]<e?p-=1<<e-g[M]++-1:++a}for(;a>=0&&p;--a){var E=o[a].s;g[E]==e&&(--g[E],++p)}w=e}return{t:new t(g),l:w}},A=function(t,n,r){return-1==t.s?Math.max(A(t.l,n,r+1),A(t.r,n,r+1)):n[t.s]=r},D=function(t){for(var r=t.length;r&&!t[--r];);for(var e=new n(++r),i=0,a=t[0],s=1,o=function(t){e[i++]=t},f=1;f<=r;++f)if(t[f]==a&&f!=r)++s;else{if(!a&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(a),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(a);s=1,a=t[f]}return{c:e.subarray(0,i),n:r}},T=function(t,n){for(var r=0,e=0;e<n.length;++e)r+=t[e]*n[e];return r},k=function(t,n,r){var e=r.length,i=m(n+2);t[i]=255&e,t[i+1]=e>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var a=0;a<e;++a)t[i+a+4]=r[a];return 8*(i+4+e)},U=function(t,r,s,o,f,h,l,u,c,v,m){z(r,m++,s),++f[256];for(var b=x(f,15),M=b.t,E=b.l,A=x(h,15),U=A.t,C=A.l,F=D(M),I=F.c,S=F.n,L=D(U),O=L.c,j=L.n,q=new n(19),B=0;B<I.length;++B)++q[31&I[B]];for(B=0;B<O.length;++B)++q[31&O[B]];for(var G=x(q,7),H=G.t,J=G.l,K=19;K>4&&!H[a[K-1]];--K);var N,P,Q,R,V=v+5<<3,W=T(f,g)+T(h,w)+l,X=T(f,M)+T(h,U)+l+14+3*K+T(q,H)+2*q[16]+3*q[17]+7*q[18];if(c>=0&&V<=W&&V<=X)return k(r,m,t.subarray(c,c+v));if(z(r,m,1+(X<W)),m+=2,X<W){N=d(M,E,0),P=M,Q=d(U,C,0),R=U;var Y=d(H,J,0);z(r,m,S-257),z(r,m+5,j-1),z(r,m+10,K-4),m+=14;for(B=0;B<K;++B)z(r,m+3*B,H[a[B]]);m+=3*K;for(var Z=[I,O],$=0;$<2;++$){var tt=Z[$];for(B=0;B<tt.length;++B){var nt=31&tt[B];z(r,m,Y[nt]),m+=H[nt],nt>15&&(z(r,m,tt[B]>>5&127),m+=tt[B]>>12)}}}else N=p,P=g,Q=y,R=w;for(B=0;B<u;++B){var rt=o[B];if(rt>255){_(r,m,N[(nt=rt>>18&31)+257]),m+=P[nt+257],nt>7&&(z(r,m,rt>>23&31),m+=e[nt]);var et=31&rt;_(r,m,Q[et]),m+=R[et],et>3&&(_(r,m,rt>>5&8191),m+=i[et])}else _(r,m,N[rt]),m+=P[rt]}return _(r,m,N[256]),m+P[256]},C=new r([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),F=new t(0),I=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var r=n,e=9;--e;)r=(1&r&&-306674912)^r>>>1;t[n]=r}return t}(),S=function(){var t=-1;return{p:function(n){for(var r=t,e=0;e<n.length;++e)r=I[255&r^n[e]]^r>>>8;t=r},d:function(){return~t}}},L=function(){var t=1,n=0;return{p:function(r){for(var e=t,i=n,a=0|r.length,s=0;s!=a;){for(var o=Math.min(s+2655,a);s<o;++s)i+=e+=r[s];e=(65535&e)+15*(e>>16),i=(65535&i)+15*(i>>16)}t=e,n=i},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},O=function(a,s,o,f,u){if(!u&&(u={l:1},s.dictionary)){var c=s.dictionary.subarray(-32768),v=new t(c.length+a.length);v.set(c),v.set(a,c.length),a=v,u.w=c.length}return function(a,s,o,f,u,c){var v=c.z||a.length,d=new t(f+v+5*(1+Math.ceil(v/7e3))+u),g=d.subarray(f,d.length-u),w=c.l,p=7&(c.r||0);if(s){p&&(g[0]=c.r>>3);for(var y=C[s-1],M=y>>13,E=8191&y,z=(1<<o)-1,_=c.p||new n(32768),x=c.h||new n(z+1),A=Math.ceil(o/3),D=2*A,T=function(t){return(a[t]^a[t+1]<<A^a[t+2]<<D)&z},F=new r(25e3),I=new n(288),S=new n(32),L=0,O=0,j=c.i||0,q=0,B=c.w||0,G=0;j+2<v;++j){var H=T(j),J=32767&j,K=x[H];if(_[J]=K,x[H]=J,B<=j){var N=v-j;if((L>7e3||q>24576)&&(N>423||!w)){p=U(a,g,0,F,I,S,O,q,G,j-G,p),q=L=O=0,G=j;for(var P=0;P<286;++P)I[P]=0;for(P=0;P<30;++P)S[P]=0}var Q=2,R=0,V=E,W=J-K&32767;if(N>2&&H==T(j-W))for(var X=Math.min(M,N)-1,Y=Math.min(32767,j),Z=Math.min(258,N);W<=Y&&--V&&J!=K;){if(a[j+Q]==a[j+Q-W]){for(var $=0;$<Z&&a[j+$]==a[j+$-W];++$);if($>Q){if(Q=$,R=W,$>X)break;var tt=Math.min(W,$-2),nt=0;for(P=0;P<tt;++P){var rt=j-W+P&32767,et=rt-_[rt]&32767;et>nt&&(nt=et,K=rt)}}}W+=(J=K)-(K=_[J])&32767}if(R){F[q++]=268435456|h[Q]<<18|l[R];var it=31&h[Q],at=31&l[R];O+=e[it]+i[at],++I[257+it],++S[at],B=j+Q,++L}else F[q++]=a[j],++I[a[j]]}}for(j=Math.max(j,B);j<v;++j)F[q++]=a[j],++I[a[j]];p=U(a,g,w,F,I,S,O,q,G,j-G,p),w||(c.r=7&p|g[p/8|0]<<3,p-=7,c.h=x,c.p=_,c.i=j,c.w=B)}else{for(j=c.w||0;j<v+w;j+=65535){var st=j+65535;st>=v&&(g[p/8|0]=w,st=v),p=k(g,p+1,a.subarray(j,st))}c.i=v}return b(d,0,f+m(p)+u)}(a,null==s.level?6:s.level,null==s.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+s.mem,o,f,u)},j=function(t,n,r){for(;r;++n)t[n]=r,r>>>=8},q=function(t,n){var r=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&j(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),r){t[3]=8;for(var e=0;e<=r.length;++e)t[e+10]=r.charCodeAt(e)}},B=function(t){return 10+(t.filename?t.filename.length+1:0)},G=function(){function n(n,r){if("function"==typeof n&&(r=n,n={}),this.ondata=r,this.o=n||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new t(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return n.prototype.p=function(t,n){this.ondata(O(t,this.o,0,0,this.s),n)},n.prototype.push=function(n,r){this.ondata||E(5),this.s.l&&E(4);var e=n.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new t(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var a=this.b.length-this.s.z;a&&(this.b.set(n.subarray(0,a),this.s.z),this.s.z=this.b.length,this.p(this.b,!1)),this.b.set(this.b.subarray(-32768)),this.b.set(n.subarray(a),32768),this.s.z=n.length-a+32768,this.s.i=32766,this.s.w=32768}else this.b.set(n,this.s.z),this.s.z+=n.length;this.s.l=1&r,(this.s.z>this.s.w+8191||r)&&(this.p(this.b,r||!1),this.s.w=this.s.i,this.s.i-=2)},n}();var H=function(){function t(t,n){this.c=L(),this.v=1,G.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),G.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var r=O(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(function(t,n){var r=n.level,e=0==r?0:r<6?1:9==r?3:2;if(t[0]=120,t[1]=e<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var i=L();i.p(n.dictionary),j(t,2,i.d())}}(r,this.o),this.v=0),n&&j(r,r.length-4,this.c.d()),this.ondata(r,n)},t}(),J="undefined"!=typeof TextEncoder&&new TextEncoder,K="undefined"!=typeof TextDecoder&&new TextDecoder;try{K.decode(F,{stream:!0})}catch(t){}var N=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||E(5),this.d&&E(4),this.ondata(P(t),this.d=n||!1)},t}();function P(n,r){if(J)return J.encode(n);for(var e=n.length,i=new t(n.length+(n.length>>1)),a=0,s=function(t){i[a++]=t},o=0;o<e;++o){if(a+5>i.length){var f=new t(a+8+(e-o<<1));f.set(i),i=f}var h=n.charCodeAt(o);h<128||r?s(h):h<2048?(s(192|h>>6),s(128|63&h)):h>55295&&h<57344?(s(240|(h=65536+(1047552&h)|1023&n.charCodeAt(++o))>>18),s(128|h>>12&63),s(128|h>>6&63),s(128|63&h)):(s(224|h>>12),s(128|h>>6&63),s(128|63&h))}return b(i,0,a)}function Q(t){return function(t,n){n||(n={});var r=S(),e=t.length;r.p(t);var i=O(t,n,B(n),8),a=i.length;return q(i,n),j(i,a-8,r.d()),j(i,a-4,e),i}(P(t))}const R=new class{constructor(){this._init()}clear(){this._init()}addEvent(t){if(!t)throw new Error("Adding invalid event");const n=this._hasEvents?",":"";this.stream.push(n+t),this._hasEvents=!0}finish(){this.stream.push("]",!0);const t=function(t){let n=0;for(const r of t)n+=r.length;const r=new Uint8Array(n);for(let n=0,e=0,i=t.length;n<i;n++){const i=t[n];r.set(i,e),e+=i.length}return r}(this._deflatedData);return this._init(),t}_init(){this._hasEvents=!1,this._deflatedData=[],this.deflate=new H,this.deflate.ondata=(t,n)=>{this._deflatedData.push(t)},this.stream=new N(((t,n)=>{this.deflate.push(t,n)})),this.stream.push("[")}},V={clear:()=>{R.clear()},addEvent:t=>R.addEvent(t),finish:()=>R.finish(),compress:t=>Q(t)};addEventListener("message",(function(t){const n=t.data.method,r=t.data.id,e=t.data.arg;if(n in V&&"function"==typeof V[n])try{const t=V[n](e);postMessage({id:r,method:n,success:!0,response:t})}catch(t){postMessage({id:r,method:n,success:!1,response:t.message}),console.error(t)}})),postMessage({id:void 0,method:"init",success:!0,response:void 0});';function NIe(){const t=new Blob([AIe]);return URL.createObjectURL(t)}const mz=["info","warn","error","log"],mb="[Replay] ";function nk(t,e="info"){nc({category:"console",data:{logger:"replay"},level:e,message:`${mb}${t}`},{level:e})}function RIe(){let t=!1,e=!1;const n={exception:()=>{},infoTick:()=>{},setConfig:r=>{t=r.captureExceptions,e=r.traceInternals}};return yt?(mz.forEach(r=>{n[r]=(...s)=>{ze[r](mb,...s),e&&nk(s.join(""),TG(r))}}),n.exception=(r,...s)=>{s.length&&n.error&&n.error(...s),ze.error(mb,r),t?pG(r):e&&nk(r,"error")},n.infoTick=(...r)=>{ze.info(mb,...r),e&&setTimeout(()=>nk(r[0]),0)}):mz.forEach(r=>{n[r]=()=>{}}),n}const St=RIe();class Mj extends Error{constructor(){super(`Event buffer exceeded maximum size of ${kj}.`)}}class TW{constructor(){this.events=[],this._totalSize=0,this.hasCheckout=!1,this.waitForCheckout=!1}get hasEvents(){return this.events.length>0}get type(){return"sync"}destroy(){this.events=[]}async addEvent(e){const n=JSON.stringify(e).length;if(this._totalSize+=n,this._totalSize>kj)throw new Mj;this.events.push(e)}finish(){return new Promise(e=>{const n=this.events;this.clear(),e(JSON.stringify(n))})}clear(){this.events=[],this._totalSize=0,this.hasCheckout=!1}getEarliestTimestamp(){const e=this.events.map(n=>n.timestamp).sort()[0];return e?jj(e):null}}class jIe{constructor(e){this._worker=e,this._id=0}ensureReady(){return this._ensureReadyPromise?this._ensureReadyPromise:(this._ensureReadyPromise=new Promise((e,n)=>{this._worker.addEventListener("message",({data:r})=>{r.success?e():n()},{once:!0}),this._worker.addEventListener("error",r=>{n(r)},{once:!0})}),this._ensureReadyPromise)}destroy(){yt&&St.info("Destroying compression worker"),this._worker.terminate()}postMessage(e,n){const r=this._getAndIncrementId();return new Promise((s,i)=>{const a=({data:l})=>{const u=l;if(u.method===e&&u.id===r){if(this._worker.removeEventListener("message",a),!u.success){yt&&St.error("Error in compression worker: ",u.response),i(new Error("Error in compression worker"));return}s(u.response)}};this._worker.addEventListener("message",a),this._worker.postMessage({id:r,method:e,arg:n})})}_getAndIncrementId(){return this._id++}}class MIe{constructor(e){this._worker=new jIe(e),this._earliestTimestamp=null,this._totalSize=0,this.hasCheckout=!1,this.waitForCheckout=!1}get hasEvents(){return!!this._earliestTimestamp}get type(){return"worker"}ensureReady(){return this._worker.ensureReady()}destroy(){this._worker.destroy()}addEvent(e){const n=jj(e.timestamp);(!this._earliestTimestamp||n<this._earliestTimestamp)&&(this._earliestTimestamp=n);const r=JSON.stringify(e);return this._totalSize+=r.length,this._totalSize>kj?Promise.reject(new Mj):this._sendEventToWorker(r)}finish(){return this._finishRequest()}clear(){this._earliestTimestamp=null,this._totalSize=0,this.hasCheckout=!1,this._worker.postMessage("clear").then(null,e=>{yt&&St.exception(e,'Sending "clear" message to worker failed',e)})}getEarliestTimestamp(){return this._earliestTimestamp}_sendEventToWorker(e){return this._worker.postMessage("addEvent",e)}async _finishRequest(){const e=await this._worker.postMessage("finish");return this._earliestTimestamp=null,this._totalSize=0,e}}class OIe{constructor(e){this._fallback=new TW,this._compression=new MIe(e),this._used=this._fallback,this._ensureWorkerIsLoadedPromise=this._ensureWorkerIsLoaded()}get waitForCheckout(){return this._used.waitForCheckout}get type(){return this._used.type}get hasEvents(){return this._used.hasEvents}get hasCheckout(){return this._used.hasCheckout}set hasCheckout(e){this._used.hasCheckout=e}set waitForCheckout(e){this._used.waitForCheckout=e}destroy(){this._fallback.destroy(),this._compression.destroy()}clear(){return this._used.clear()}getEarliestTimestamp(){return this._used.getEarliestTimestamp()}addEvent(e){return this._used.addEvent(e)}async finish(){return await this.ensureWorkerIsLoaded(),this._used.finish()}ensureWorkerIsLoaded(){return this._ensureWorkerIsLoadedPromise}async _ensureWorkerIsLoaded(){try{await this._compression.ensureReady()}catch(e){yt&&St.exception(e,"Failed to load the compression worker, falling back to simple buffer");return}await this._switchToCompressionWorker()}async _switchToCompressionWorker(){const{events:e,hasCheckout:n,waitForCheckout:r}=this._fallback,s=[];for(const i of e)s.push(this._compression.addEvent(i));this._compression.hasCheckout=n,this._compression.waitForCheckout=r,this._used=this._compression;try{await Promise.all(s),this._fallback.clear()}catch(i){yt&&St.exception(i,"Failed to add events when switching buffers.")}}}function PIe({useCompression:t,workerUrl:e}){if(t&&window.Worker){const n=IIe(e);if(n)return n}return yt&&St.info("Using simple buffer"),new TW}function IIe(t){try{const e=t||DIe();if(!e)return;yt&&St.info(`Using compression worker${t?` from ${t}`:""}`);const n=new Worker(e);return new OIe(n)}catch(e){yt&&St.exception(e,"Failed to create compression worker")}}function DIe(){return typeof __SENTRY_EXCLUDE_REPLAY_WORKER__>"u"||!__SENTRY_EXCLUDE_REPLAY_WORKER__?NIe():""}function Oj(){try{return"sessionStorage"in kn&&!!kn.sessionStorage}catch{return!1}}function LIe(t){$Ie(),t.session=void 0}function $Ie(){if(Oj())try{kn.sessionStorage.removeItem(Sj)}catch{}}function CW(t){return t===void 0?!1:Math.random()<t}function AW(t){const e=Date.now(),n=t.id||ii(),r=t.started||e,s=t.lastActivity||e,i=t.segmentId||0,a=t.sampled,l=t.previousSessionId;return{id:n,started:r,lastActivity:s,segmentId:i,sampled:a,previousSessionId:l}}function Pj(t){if(Oj())try{kn.sessionStorage.setItem(Sj,JSON.stringify(t))}catch{}}function zIe(t,e){return CW(t)?"session":e?"buffer":!1}function gz({sessionSampleRate:t,allowBuffering:e,stickySession:n=!1},{previousSessionId:r}={}){const s=zIe(t,e),i=AW({sampled:s,previousSessionId:r});return n&&Pj(i),i}function FIe(){if(!Oj())return null;try{const t=kn.sessionStorage.getItem(Sj);if(!t)return null;const e=JSON.parse(t);return yt&&St.infoTick("Loading existing session"),AW(e)}catch{return null}}function sA(t,e,n=+new Date){return t===null||e===void 0||e<0?!0:e===0?!1:t+e<=n}function NW(t,{maxReplayDuration:e,sessionIdleExpire:n,targetTime:r=Date.now()}){return sA(t.started,e,r)||sA(t.lastActivity,n,r)}function RW(t,{sessionIdleExpire:e,maxReplayDuration:n}){return!(!NW(t,{sessionIdleExpire:e,maxReplayDuration:n})||t.sampled==="buffer"&&t.segmentId===0)}function rk({sessionIdleExpire:t,maxReplayDuration:e,previousSessionId:n},r){const s=r.stickySession&&FIe();return s?RW(s,{sessionIdleExpire:t,maxReplayDuration:e})?(yt&&St.infoTick("Session in sessionStorage is expired, creating new one..."),gz(r,{previousSessionId:s.id})):s:(yt&&St.infoTick("Creating new session"),gz(r,{previousSessionId:n}))}function UIe(t){return t.type===Ft.Custom}function Ij(t,e,n){return MW(t,e)?(jW(t,e,n),!0):!1}function BIe(t,e,n){return MW(t,e)?jW(t,e,n):Promise.resolve(null)}async function jW(t,e,n){const{eventBuffer:r}=t;if(!r||r.waitForCheckout&&!n)return null;const s=t.recordingMode==="buffer";try{n&&s&&r.clear(),n&&(r.hasCheckout=!0,r.waitForCheckout=!1);const i=t.getOptions(),a=qIe(e,i.beforeAddRecordingEvent);return a?await r.addEvent(a):void 0}catch(i){const a=i&&i instanceof Mj,l=a?"addEventSizeExceeded":"addEvent";if(a&&s)return r.clear(),r.waitForCheckout=!0,null;t.handleException(i),await t.stop({reason:l});const u=Yt();u&&u.recordDroppedEvent("internal_sdk_error","replay")}}function MW(t,e){if(!t.eventBuffer||t.isPaused()||!t.isEnabled())return!1;const n=jj(e.timestamp);return n+t.timeouts.sessionIdlePause<Date.now()?!1:n>t.getContext().initialTimestamp+t.getOptions().maxReplayDuration?(yt&&St.infoTick(`Skipping event with timestamp ${n} because it is after maxReplayDuration`),!1):!0}function qIe(t,e){try{if(typeof e=="function"&&UIe(t))return e(t)}catch(n){return yt&&St.exception(n,"An error occurred in the `beforeAddRecordingEvent` callback, skipping the event..."),null}return t}function Dj(t){return!t.type}function iA(t){return t.type==="transaction"}function VIe(t){return t.type==="replay_event"}function vz(t){return t.type==="feedback"}function HIe(t){return(e,n)=>{if(!t.isEnabled()||!Dj(e)&&!iA(e))return;const r=n&&n.statusCode;if(!(!r||r<200||r>=300)){if(iA(e)){GIe(t,e);return}WIe(t,e)}}}function GIe(t,e){const n=t.getContext();e.contexts&&e.contexts.trace&&e.contexts.trace.trace_id&&n.traceIds.size<100&&n.traceIds.add(e.contexts.trace.trace_id)}function WIe(t,e){const n=t.getContext();if(e.event_id&&n.errorIds.size<100&&n.errorIds.add(e.event_id),t.recordingMode!=="buffer"||!e.tags||!e.tags.replayId)return;const{beforeErrorSampling:r}=t.getOptions();typeof r=="function"&&!r(e)||Ff(async()=>{try{await t.sendBufferedReplayOrFlush()}catch(s){t.handleException(s)}})}function YIe(t){return e=>{!t.isEnabled()||!Dj(e)||KIe(t,e)}}function KIe(t,e){const n=e.exception&&e.exception.values&&e.exception.values[0]&&e.exception.values[0].value;if(typeof n=="string"&&(n.match(/(reactjs\.org\/docs\/error-decoder\.html\?invariant=|react\.dev\/errors\/)(418|419|422|423|425)/)||n.match(/(does not match server-rendered HTML|Hydration failed because)/i))){const r=Ra({category:"replay.hydrate-error",data:{url:$7()}});zg(t,r)}}function XIe(t){const e=Yt();e&&e.on("beforeAddBreadcrumb",n=>QIe(t,n))}function QIe(t,e){if(!t.isEnabled()||!OW(e))return;const n=JIe(e);n&&zg(t,n)}function JIe(t){return!OW(t)||["fetch","xhr","sentry.event","sentry.transaction"].includes(t.category)||t.category.startsWith("ui.")?null:t.category==="console"?ZIe(t):Ra(t)}function ZIe(t){const e=t.data&&t.data.arguments;if(!Array.isArray(e)||e.length===0)return Ra(t);let n=!1;const r=e.map(s=>{if(!s)return s;if(typeof s=="string")return s.length>zy?(n=!0,`${s.slice(0,zy)}…`):s;if(typeof s=="object")try{const i=Ki(s,7);return JSON.stringify(i).length>zy?(n=!0,`${JSON.stringify(i,null,2).slice(0,zy)}…`):i}catch{}return s});return Ra({...t,data:{...t.data,arguments:r,...n?{_meta:{warnings:["CONSOLE_ARG_TRUNCATED"]}}:{}}})}function OW(t){return!!t.category}function eDe(t,e){return t.type||!t.exception||!t.exception.values||!t.exception.values.length?!1:!!(e.originalException&&e.originalException.__rrweb__)}function PW(){const t=An().getPropagationContext().dsc;t&&delete t.replay_id;const e=$r();if(e){const n=Ou(e);delete n.replay_id}}function tDe(t,e){t.triggerUserActivity(),t.addUpdate(()=>e.timestamp?(t.throttledAddEvent({type:Ft.Custom,timestamp:e.timestamp*1e3,data:{tag:"breadcrumb",payload:{timestamp:e.timestamp,type:"default",category:"sentry.feedback",data:{feedbackId:e.event_id}}}}),!1):!0)}function nDe(t,e){return t.recordingMode!=="buffer"||e.message===Ej||!e.exception||e.type?!1:CW(t.getOptions().errorSampleRate)}function rDe(t){return Object.assign((e,n)=>!t.isEnabled()||t.isPaused()?e:VIe(e)?(delete e.breadcrumbs,e):!Dj(e)&&!iA(e)&&!vz(e)?e:t.checkAndHandleExpiredSession()?vz(e)?(t.flush(),e.contexts.feedback.replay_id=t.getSessionId(),tDe(t,e),e):eDe(e,n)&&!t.getOptions()._experiments.captureExceptions?(yt&&St.log("Ignoring error from rrweb internals",e),null):((nDe(t,e)||t.recordingMode==="session")&&(e.tags={...e.tags,replayId:t.getSessionId()}),e):(PW(),e),{id:"Replay"})}function a_(t,e){return e.map(({type:n,start:r,end:s,name:i,data:a})=>{const l=t.throttledAddEvent({type:Ft.Custom,timestamp:r,data:{tag:"performanceSpan",payload:{op:n,description:i,startTimestamp:r,endTimestamp:s,data:a}}});return typeof l=="string"?Promise.resolve(null):l})}function sDe(t){const{from:e,to:n}=t,r=Date.now()/1e3;return{type:"navigation.push",start:r,end:r,name:n,data:{previous:e}}}function iDe(t){return e=>{if(!t.isEnabled())return;const n=sDe(e);n!==null&&(t.getContext().urls.push(n.name),t.triggerUserActivity(),t.addUpdate(()=>(a_(t,[n]),!1)))}}function aDe(t,e){return yt&&t.getOptions()._experiments.traceInternals?!1:sje(e,Yt())}function IW(t,e){t.isEnabled()&&e!==null&&(aDe(t,e.name)||t.addUpdate(()=>(a_(t,[e]),!0)))}function o_(t){if(!t)return;const e=new TextEncoder;try{if(typeof t=="string")return e.encode(t).length;if(t instanceof URLSearchParams)return e.encode(t.toString()).length;if(t instanceof FormData){const n=zW(t);return e.encode(n).length}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength}catch{}}function DW(t){if(!t)return;const e=parseInt(t,10);return isNaN(e)?void 0:e}function LW(t){try{if(typeof t=="string")return[t];if(t instanceof URLSearchParams)return[t.toString()];if(t instanceof FormData)return[zW(t)];if(!t)return[void 0]}catch(e){return yt&&St.exception(e,"Failed to serialize body",t),[void 0,"BODY_PARSE_ERROR"]}return yt&&St.info("Skipping network body because of body type",t),[void 0,"UNPARSEABLE_BODY_TYPE"]}function Fx(t,e){if(!t)return{headers:{},size:void 0,_meta:{warnings:[e]}};const n={...t._meta},r=n.warnings||[];return n.warnings=[...r,e],t._meta=n,t}function $W(t,e){if(!e)return null;const{startTimestamp:n,endTimestamp:r,url:s,method:i,statusCode:a,request:l,response:u}=e;return{type:t,start:n/1e3,end:r/1e3,name:s,data:Nr({method:i,statusCode:a,request:l,response:u})}}function ig(t){return{headers:{},size:t,_meta:{warnings:["URL_SKIPPED"]}}}function Hl(t,e,n){if(!e&&Object.keys(t).length===0)return;if(!e)return{headers:t};if(!n)return{headers:t,size:e};const r={headers:t,size:e},{body:s,warnings:i}=oDe(n);return r.body=s,i&&i.length>0&&(r._meta={warnings:i}),r}function aA(t,e){return Object.entries(t).reduce((n,[r,s])=>{const i=r.toLowerCase();return e.includes(i)&&t[r]&&(n[i]=s),n},{})}function zW(t){return new URLSearchParams(t).toString()}function oDe(t){if(!t||typeof t!="string")return{body:t};const e=t.length>Q$,n=lDe(t);if(e){const r=t.slice(0,Q$);return n?{body:r,warnings:["MAYBE_JSON_TRUNCATED"]}:{body:`${r}…`,warnings:["TEXT_TRUNCATED"]}}if(n)try{return{body:JSON.parse(t)}}catch{}return{body:t}}function lDe(t){const e=t[0],n=t[t.length-1];return e==="["&&n==="]"||e==="{"&&n==="}"}function Ux(t,e){const n=cDe(t);return Vl(n,e)}function cDe(t,e=kn.document.baseURI){if(t.startsWith("http://")||t.startsWith("https://")||t.startsWith(kn.location.origin))return t;const n=new URL(t,e);if(n.origin!==new URL(e).origin)return t;const r=n.href;return!t.endsWith("/")&&r.endsWith("/")?r.slice(0,-1):r}async function uDe(t,e,n){try{const r=await fDe(t,e,n),s=$W("resource.fetch",r);IW(n.replay,s)}catch(r){yt&&St.exception(r,"Failed to capture fetch breadcrumb")}}function dDe(t,e){const{input:n,response:r}=e,s=n?FW(n):void 0,i=o_(s),a=r?DW(r.headers.get("content-length")):void 0;i!==void 0&&(t.data.request_body_size=i),a!==void 0&&(t.data.response_body_size=a)}async function fDe(t,e,n){const r=Date.now(),{startTimestamp:s=r,endTimestamp:i=r}=e,{url:a,method:l,status_code:u=0,request_body_size:d,response_body_size:p}=t.data,h=Ux(a,n.networkDetailAllowUrls)&&!Ux(a,n.networkDetailDenyUrls),g=h?hDe(n,e.input,d):ig(d),v=await pDe(h,n,e.response,p);return{startTimestamp:s,endTimestamp:i,url:a,method:l,statusCode:u,request:g,response:v}}function hDe({networkCaptureBodies:t,networkRequestHeaders:e},n,r){const s=n?vDe(n,e):{};if(!t)return Hl(s,r,void 0);const i=FW(n),[a,l]=LW(i),u=Hl(s,r,a);return l?Fx(u,l):u}async function pDe(t,{networkCaptureBodies:e,networkResponseHeaders:n},r,s){if(!t&&s!==void 0)return ig(s);const i=r?UW(r.headers,n):{};if(!r||!e&&s!==void 0)return Hl(i,s,void 0);const[a,l]=await gDe(r),u=mDe(a,{networkCaptureBodies:e,responseBodySize:s,captureDetails:t,headers:i});return l?Fx(u,l):u}function mDe(t,{networkCaptureBodies:e,responseBodySize:n,captureDetails:r,headers:s}){try{const i=t&&t.length&&n===void 0?o_(t):n;return r?e?Hl(s,i,t):Hl(s,i,void 0):ig(i)}catch(i){return yt&&St.exception(i,"Failed to serialize response body"),Hl(s,n,void 0)}}async function gDe(t){const e=yDe(t);if(!e)return[void 0,"BODY_PARSE_ERROR"];try{return[await bDe(e)]}catch(n){return n instanceof Error&&n.message.indexOf("Timeout")>-1?(yt&&St.warn("Parsing text body from response timed out"),[void 0,"BODY_PARSE_TIMEOUT"]):(yt&&St.exception(n,"Failed to get text body from response"),[void 0,"BODY_PARSE_ERROR"])}}function FW(t=[]){if(!(t.length!==2||typeof t[1]!="object"))return t[1].body}function UW(t,e){const n={};return e.forEach(r=>{t.get(r)&&(n[r]=t.get(r))}),n}function vDe(t,e){return t.length===1&&typeof t[0]!="string"?yz(t[0],e):t.length===2?yz(t[1],e):{}}function yz(t,e){if(!t)return{};const n=t.headers;return n?n instanceof Headers?UW(n,e):Array.isArray(n)?{}:aA(n,e):{}}function yDe(t){try{return t.clone()}catch(e){yt&&St.exception(e,"Failed to clone response body")}}function bDe(t){return new Promise((e,n)=>{const r=Ff(()=>n(new Error("Timeout while trying to read response body")),500);xDe(t).then(s=>e(s),s=>n(s)).finally(()=>clearTimeout(r))})}async function xDe(t){return await t.text()}async function _De(t,e,n){try{const r=SDe(t,e,n),s=$W("resource.xhr",r);IW(n.replay,s)}catch(r){yt&&St.exception(r,"Failed to capture xhr breadcrumb")}}function wDe(t,e){const{xhr:n,input:r}=e;if(!n)return;const s=o_(r),i=n.getResponseHeader("content-length")?DW(n.getResponseHeader("content-length")):CDe(n.response,n.responseType);s!==void 0&&(t.data.request_body_size=s),i!==void 0&&(t.data.response_body_size=i)}function SDe(t,e,n){const r=Date.now(),{startTimestamp:s=r,endTimestamp:i=r,input:a,xhr:l}=e,{url:u,method:d,status_code:p=0,request_body_size:h,response_body_size:g}=t.data;if(!u)return null;if(!l||!Ux(u,n.networkDetailAllowUrls)||Ux(u,n.networkDetailDenyUrls)){const A=ig(h),N=ig(g);return{startTimestamp:s,endTimestamp:i,url:u,method:d,statusCode:p,request:A,response:N}}const v=l[Kc],b=v?aA(v.request_headers,n.networkRequestHeaders):{},x=aA(EDe(l),n.networkResponseHeaders),[E,S]=n.networkCaptureBodies?LW(a):[void 0],[k,T]=n.networkCaptureBodies?kDe(l):[void 0],R=Hl(b,h,E),j=Hl(x,g,k);return{startTimestamp:s,endTimestamp:i,url:u,method:d,statusCode:p,request:S?Fx(R,S):R,response:T?Fx(j,T):j}}function EDe(t){const e=t.getAllResponseHeaders();return e?e.split(`\r
|
|
1873
1873
|
`).reduce((n,r)=>{const[s,i]=r.split(": ");return i&&(n[s.toLowerCase()]=i),n},{}):{}}function kDe(t){const e=[];try{return[t.responseText]}catch(n){e.push(n)}try{return TDe(t.response,t.responseType)}catch(n){e.push(n)}return yt&&St.warn("Failed to get xhr response body",...e),[void 0]}function TDe(t,e){try{if(typeof t=="string")return[t];if(t instanceof Document)return[t.body.outerHTML];if(e==="json"&&t&&typeof t=="object")return[JSON.stringify(t)];if(!t)return[void 0]}catch(n){return yt&&St.exception(n,"Failed to serialize body",t),[void 0,"BODY_PARSE_ERROR"]}return yt&&St.info("Skipping network body because of body type",t),[void 0,"UNPARSEABLE_BODY_TYPE"]}function CDe(t,e){try{const n=e==="json"&&t&&typeof t=="object"?JSON.stringify(t):t;return o_(n)}catch{return}}function ADe(t){const e=Yt();try{const{networkDetailAllowUrls:n,networkDetailDenyUrls:r,networkCaptureBodies:s,networkRequestHeaders:i,networkResponseHeaders:a}=t.getOptions(),l={replay:t,networkDetailAllowUrls:n,networkDetailDenyUrls:r,networkCaptureBodies:s,networkRequestHeaders:i,networkResponseHeaders:a};e&&e.on("beforeAddBreadcrumb",(u,d)=>NDe(l,u,d))}catch{}}function NDe(t,e,n){if(e.data)try{RDe(e)&&MDe(n)&&(wDe(e,n),_De(e,n,t)),jDe(e)&&ODe(n)&&(dDe(e,n),uDe(e,n,t))}catch(r){yt&&St.exception(r,"Error when enriching network breadcrumb")}}function RDe(t){return t.category==="xhr"}function jDe(t){return t.category==="fetch"}function MDe(t){return t&&t.xhr}function ODe(t){return t&&t.response}function PDe(t){const e=Yt();KG(cIe(t)),t_(iDe(t)),XIe(t),ADe(t);const n=rDe(t);LRe(n),e&&(e.on("beforeSendEvent",YIe(t)),e.on("afterSendEvent",HIe(t)),e.on("createDsc",r=>{const s=t.getSessionId();s&&t.isEnabled()&&t.recordingMode==="session"&&t.checkAndHandleExpiredSession()&&(r.replay_id=s)}),e.on("spanStart",r=>{t.lastActiveSpan=r}),e.on("spanEnd",r=>{t.lastActiveSpan=r}),e.on("beforeSendFeedback",(r,s)=>{const i=t.getSessionId();s&&s.includeReplay&&t.isEnabled()&&i&&r.contexts&&r.contexts.feedback&&(r.contexts.feedback.replay_id=i)}))}async function IDe(t){try{return Promise.all(a_(t,[DDe(kn.performance.memory)]))}catch{return[]}}function DDe(t){const{jsHeapSizeLimit:e,totalJSHeapSize:n,usedJSHeapSize:r}=t,s=Date.now()/1e3;return{type:"memory",name:"memory",start:s,end:s,data:{memory:{jsHeapSizeLimit:e,totalJSHeapSize:n,usedJSHeapSize:r}}}}function LDe(t,e,n){let r,s,i;const a=n&&n.maxWait?Math.max(n.maxWait,e):0;function l(){return u(),r=t(),r}function u(){s!==void 0&&clearTimeout(s),i!==void 0&&clearTimeout(i),s=i=void 0}function d(){return s!==void 0||i!==void 0?l():r}function p(){return s&&clearTimeout(s),s=Ff(l,e),a&&i===void 0&&(i=Ff(l,a)),r}return p.cancel=u,p.flush=d,p}const Fc=Kt.navigator;function $De(){return/iPhone|iPad|iPod/i.test(Fc&&Fc.userAgent||"")||/Macintosh/i.test(Fc&&Fc.userAgent||"")&&Fc&&Fc.maxTouchPoints&&Fc.maxTouchPoints>1?{sampling:{mousemove:!1}}:{}}function zDe(t){let e=!1;return(n,r)=>{if(!t.checkAndHandleExpiredSession()){yt&&St.warn("Received replay event after session expired.");return}const s=r||!e;e=!0,t.clickDetector&&sIe(t.clickDetector,n),t.addUpdate(()=>{if(t.recordingMode==="buffer"&&s&&t.setInitialState(),!Ij(t,n,s))return!0;if(!s)return!1;const i=t.session;if(UDe(t,s),t.recordingMode==="buffer"&&i&&t.eventBuffer){const a=t.eventBuffer.getEarliestTimestamp();a&&(yt&&St.info(`Updating session start time to earliest event in buffer to ${new Date(a)}`),i.started=a,t.getOptions().stickySession&&Pj(i))}return i&&i.previousSessionId||t.recordingMode==="session"&&t.flush(),!0})}}function FDe(t){const e=t.getOptions();return{type:Ft.Custom,timestamp:Date.now(),data:{tag:"options",payload:{shouldRecordCanvas:t.isRecordingCanvas(),sessionSampleRate:e.sessionSampleRate,errorSampleRate:e.errorSampleRate,useCompressionOption:e.useCompression,blockAllMedia:e.blockAllMedia,maskAllText:e.maskAllText,maskAllInputs:e.maskAllInputs,useCompression:t.eventBuffer?t.eventBuffer.type==="worker":!1,networkDetailHasUrls:e.networkDetailAllowUrls.length>0,networkCaptureBodies:e.networkCaptureBodies,networkRequestHasHeaders:e.networkRequestHeaders.length>0,networkResponseHasHeaders:e.networkResponseHeaders.length>0}}}}function UDe(t,e){!e||!t.session||t.session.segmentId!==0||Ij(t,FDe(t),!1)}function BDe(t,e,n,r){return Pu(lG(t,mj(t),r,n),[[{type:"replay_event"},t],[{type:"replay_recording",length:typeof e=="string"?new TextEncoder().encode(e).length:e.length},e]])}function qDe({recordingData:t,headers:e}){let n;const r=`${JSON.stringify(e)}
|
|
1874
1874
|
`;if(typeof t=="string")n=`${r}${t}`;else{const i=new TextEncoder().encode(r);n=new Uint8Array(i.length+t.length),n.set(i),n.set(t,i.length)}return n}async function VDe({client:t,scope:e,replayId:n,event:r}){const s=typeof t._integrations=="object"&&t._integrations!==null&&!Array.isArray(t._integrations)?Object.keys(t._integrations):void 0,i={event_id:n,integrations:s};t.emit("preprocessEvent",r,i);const a=await hG(t.getOptions(),r,i,e,t,Li());if(!a)return null;a.platform=a.platform||"javascript";const l=t.getSdkMetadata(),{name:u,version:d}=l&&l.sdk||{};return a.sdk={...a.sdk,name:u||"sentry.javascript.unknown",version:d||"0.0.0"},a}async function HDe({recordingData:t,replayId:e,segmentId:n,eventContext:r,timestamp:s,session:i}){const a=qDe({recordingData:t,headers:{segment_id:n}}),{urls:l,errorIds:u,traceIds:d,initialTimestamp:p}=r,h=Yt(),g=An(),v=h&&h.getTransport(),b=h&&h.getDsn();if(!h||!v||!b||!i.sampled)return Bo({});const x={type:SOe,replay_start_timestamp:p/1e3,timestamp:s/1e3,error_ids:u,trace_ids:d,urls:l,replay_id:e,segment_id:n,replay_type:i.sampled},E=await VDe({scope:g,client:h,replayId:e,event:x});if(!E)return h.recordDroppedEvent("event_processor","replay",x),yt&&St.info("An event processor returned `null`, will not send event."),Bo({});delete E.sdkProcessingMetadata;const S=BDe(E,a,b,h.getOptions().tunnel);let k;try{k=await v.send(S)}catch(R){const j=new Error(Ej);try{j.cause=R}catch{}throw j}if(typeof k.statusCode=="number"&&(k.statusCode<200||k.statusCode>=300))throw new BW(k.statusCode);const T=SG({},k);if(wG(T,"replay"))throw new Lj(T);return k}class BW extends Error{constructor(e){super(`Transport returned status code ${e}`)}}class Lj extends Error{constructor(e){super("Rate limit hit"),this.rateLimits=e}}async function qW(t,e={count:0,interval:NOe}){const{recordingData:n,onError:r}=t;if(n.length)try{return await HDe(t),!0}catch(s){if(s instanceof BW||s instanceof Lj)throw s;if(gG("Replays",{_retryCount:e.count}),r&&r(s),e.count>=ROe){const i=new Error(`${Ej} - max retries exceeded`);try{i.cause=s}catch{}throw i}return e.interval*=++e.count,new Promise((i,a)=>{Ff(async()=>{try{await qW(t,e),i(!0)}catch(l){a(l)}},e.interval)})}}const VW="__THROTTLED",GDe="__SKIPPED";function WDe(t,e,n){const r=new Map,s=l=>{const u=l-n;r.forEach((d,p)=>{p<u&&r.delete(p)})},i=()=>[...r.values()].reduce((l,u)=>l+u,0);let a=!1;return(...l)=>{const u=Math.floor(Date.now()/1e3);if(s(u),i()>=e){const p=a;return a=!0,p?GDe:VW}a=!1;const d=r.get(u)||0;return r.set(u,d+1),t(...l)}}class Pl{constructor({options:e,recordingOptions:n}){Pl.prototype.__init.call(this),Pl.prototype.__init2.call(this),Pl.prototype.__init3.call(this),Pl.prototype.__init4.call(this),Pl.prototype.__init5.call(this),Pl.prototype.__init6.call(this),this.eventBuffer=null,this.performanceEntries=[],this.replayPerformanceEntries=[],this.recordingMode="session",this.timeouts={sessionIdlePause:EOe,sessionIdleExpire:kOe},this._lastActivity=Date.now(),this._isEnabled=!1,this._isPaused=!1,this._requiresManualStart=!1,this._hasInitializedCoreListeners=!1,this._context={errorIds:new Set,traceIds:new Set,urls:[],initialTimestamp:Date.now(),initialUrl:""},this._recordingOptions=n,this._options=e,this._debouncedFlush=LDe(()=>this._flush(),this._options.flushMinDelay,{maxWait:this._options.flushMaxDelay}),this._throttledAddEvent=WDe((a,l)=>BIe(this,a,l),300,5);const{slowClickTimeout:r,slowClickIgnoreSelectors:s}=this.getOptions(),i=r?{threshold:Math.min(jOe,r),timeout:r,scrollTimeout:MOe,ignoreSelector:s?s.join(","):""}:void 0;if(i&&(this.clickDetector=new eIe(this,i)),yt){const a=e._experiments;St.setConfig({captureExceptions:!!a.captureExceptions,traceInternals:!!a.traceInternals})}}getContext(){return this._context}isEnabled(){return this._isEnabled}isPaused(){return this._isPaused}isRecordingCanvas(){return!!this._canvas}getOptions(){return this._options}handleException(e){yt&&St.exception(e),this._options.onError&&this._options.onError(e)}initializeSampling(e){const{errorSampleRate:n,sessionSampleRate:r}=this._options,s=n<=0&&r<=0;if(this._requiresManualStart=s,!s){if(this._initializeSessionForSampling(e),!this.session){yt&&St.exception(new Error("Unable to initialize and create session"));return}this.session.sampled!==!1&&(this.recordingMode=this.session.sampled==="buffer"&&this.session.segmentId===0?"buffer":"session",yt&&St.infoTick(`Starting replay in ${this.recordingMode} mode`),this._initializeRecording())}}start(){if(this._isEnabled&&this.recordingMode==="session"){yt&&St.info("Recording is already in progress");return}if(this._isEnabled&&this.recordingMode==="buffer"){yt&&St.info("Buffering is in progress, call `flush()` to save the replay");return}yt&&St.infoTick("Starting replay in session mode"),this._updateUserActivity();const e=rk({maxReplayDuration:this._options.maxReplayDuration,sessionIdleExpire:this.timeouts.sessionIdleExpire},{stickySession:this._options.stickySession,sessionSampleRate:1,allowBuffering:!1});this.session=e,this._initializeRecording()}startBuffering(){if(this._isEnabled){yt&&St.info("Buffering is in progress, call `flush()` to save the replay");return}yt&&St.infoTick("Starting replay in buffer mode");const e=rk({sessionIdleExpire:this.timeouts.sessionIdleExpire,maxReplayDuration:this._options.maxReplayDuration},{stickySession:this._options.stickySession,sessionSampleRate:0,allowBuffering:!0});this.session=e,this.recordingMode="buffer",this._initializeRecording()}startRecording(){try{const e=this._canvas;this._stopRecording=Ro({...this._recordingOptions,...this.recordingMode==="buffer"?{checkoutEveryNms:AOe}:this._options._experiments.continuousCheckout&&{checkoutEveryNms:Math.max(36e4,this._options._experiments.continuousCheckout)},emit:zDe(this),...$De(),onMutation:this._onMutationHandler,...e?{recordCanvas:e.recordCanvas,getCanvasManager:e.getCanvasManager,sampling:e.sampling,dataURLOptions:e.dataURLOptions}:{}})}catch(e){this.handleException(e)}}stopRecording(){try{return this._stopRecording&&(this._stopRecording(),this._stopRecording=void 0),!0}catch(e){return this.handleException(e),!1}}async stop({forceFlush:e=!1,reason:n}={}){if(this._isEnabled){this._isEnabled=!1;try{yt&&St.info(`Stopping Replay${n?` triggered by ${n}`:""}`),PW(),this._removeListeners(),this.stopRecording(),this._debouncedFlush.cancel(),e&&await this._flush({force:!0}),this.eventBuffer&&this.eventBuffer.destroy(),this.eventBuffer=null,LIe(this)}catch(r){this.handleException(r)}}}pause(){this._isPaused||(this._isPaused=!0,this.stopRecording(),yt&&St.info("Pausing replay"))}resume(){!this._isPaused||!this._checkSession()||(this._isPaused=!1,this.startRecording(),yt&&St.info("Resuming replay"))}async sendBufferedReplayOrFlush({continueRecording:e=!0}={}){if(this.recordingMode==="session")return this.flushImmediate();const n=Date.now();yt&&St.info("Converting buffer to session"),await this.flushImmediate();const r=this.stopRecording();!e||!r||this.recordingMode!=="session"&&(this.recordingMode="session",this.session&&(this._updateUserActivity(n),this._updateSessionActivity(n),this._maybeSaveSession()),this.startRecording())}addUpdate(e){const n=e();this.recordingMode!=="buffer"&&n!==!0&&this._debouncedFlush()}triggerUserActivity(){if(this._updateUserActivity(),!this._stopRecording){if(!this._checkSession())return;this.resume();return}this.checkAndHandleExpiredSession(),this._updateSessionActivity()}updateUserActivity(){this._updateUserActivity(),this._updateSessionActivity()}conditionalFlush(){return this.recordingMode==="buffer"?Promise.resolve():this.flushImmediate()}flush(){return this._debouncedFlush()}flushImmediate(){return this._debouncedFlush(),this._debouncedFlush.flush()}cancelFlush(){this._debouncedFlush.cancel()}getSessionId(){return this.session&&this.session.id}checkAndHandleExpiredSession(){if(this._lastActivity&&sA(this._lastActivity,this.timeouts.sessionIdlePause)&&this.session&&this.session.sampled==="session"){this.pause();return}return!!this._checkSession()}setInitialState(){const e=`${kn.location.pathname}${kn.location.hash}${kn.location.search}`,n=`${kn.location.origin}${e}`;this.performanceEntries=[],this.replayPerformanceEntries=[],this._clearContext(),this._context.initialUrl=n,this._context.initialTimestamp=Date.now(),this._context.urls.push(n)}throttledAddEvent(e,n){const r=this._throttledAddEvent(e,n);if(r===VW){const s=Ra({category:"replay.throttled"});this.addUpdate(()=>!Ij(this,{type:WPe,timestamp:s.timestamp||0,data:{tag:"breadcrumb",payload:s,metric:!0}}))}return r}getCurrentRoute(){const e=this.lastActiveSpan||$r(),n=e&&Kr(e),s=(n&&rn(n).data||{})[Na];if(!(!n||!s||!["route","custom"].includes(s)))return rn(n).description}_initializeRecording(){this.setInitialState(),this._updateSessionActivity(),this.eventBuffer=PIe({useCompression:this._options.useCompression,workerUrl:this._options.workerUrl}),this._removeListeners(),this._addListeners(),this._isEnabled=!0,this._isPaused=!1,this.startRecording()}_initializeSessionForSampling(e){const n=this._options.errorSampleRate>0,r=rk({sessionIdleExpire:this.timeouts.sessionIdleExpire,maxReplayDuration:this._options.maxReplayDuration,previousSessionId:e},{stickySession:this._options.stickySession,sessionSampleRate:this._options.sessionSampleRate,allowBuffering:n});this.session=r}_checkSession(){if(!this.session)return!1;const e=this.session;return RW(e,{sessionIdleExpire:this.timeouts.sessionIdleExpire,maxReplayDuration:this._options.maxReplayDuration})?(this._refreshSession(e),!1):!0}async _refreshSession(e){this._isEnabled&&(await this.stop({reason:"refresh session"}),this.initializeSampling(e.id))}_addListeners(){try{kn.document.addEventListener("visibilitychange",this._handleVisibilityChange),kn.addEventListener("blur",this._handleWindowBlur),kn.addEventListener("focus",this._handleWindowFocus),kn.addEventListener("keydown",this._handleKeyboardEvent),this.clickDetector&&this.clickDetector.addListeners(),this._hasInitializedCoreListeners||(PDe(this),this._hasInitializedCoreListeners=!0)}catch(e){this.handleException(e)}this._performanceCleanupCallback=CIe(this)}_removeListeners(){try{kn.document.removeEventListener("visibilitychange",this._handleVisibilityChange),kn.removeEventListener("blur",this._handleWindowBlur),kn.removeEventListener("focus",this._handleWindowFocus),kn.removeEventListener("keydown",this._handleKeyboardEvent),this.clickDetector&&this.clickDetector.removeListeners(),this._performanceCleanupCallback&&this._performanceCleanupCallback()}catch(e){this.handleException(e)}}__init(){this._handleVisibilityChange=()=>{kn.document.visibilityState==="visible"?this._doChangeToForegroundTasks():this._doChangeToBackgroundTasks()}}__init2(){this._handleWindowBlur=()=>{const e=Ra({category:"ui.blur"});this._doChangeToBackgroundTasks(e)}}__init3(){this._handleWindowFocus=()=>{const e=Ra({category:"ui.focus"});this._doChangeToForegroundTasks(e)}}__init4(){this._handleKeyboardEvent=e=>{hIe(this,e)}}_doChangeToBackgroundTasks(e){!this.session||NW(this.session,{maxReplayDuration:this._options.maxReplayDuration,sessionIdleExpire:this.timeouts.sessionIdleExpire})||(e&&this._createCustomBreadcrumb(e),this.conditionalFlush())}_doChangeToForegroundTasks(e){if(!this.session)return;if(!this.checkAndHandleExpiredSession()){yt&&St.info("Document has become active, but session has expired");return}e&&this._createCustomBreadcrumb(e)}_updateUserActivity(e=Date.now()){this._lastActivity=e}_updateSessionActivity(e=Date.now()){this.session&&(this.session.lastActivity=e,this._maybeSaveSession())}_createCustomBreadcrumb(e){this.addUpdate(()=>{this.throttledAddEvent({type:Ft.Custom,timestamp:e.timestamp||0,data:{tag:"breadcrumb",payload:e}})})}_addPerformanceEntries(){let e=vIe(this.performanceEntries).concat(this.replayPerformanceEntries);if(this.performanceEntries=[],this.replayPerformanceEntries=[],this._requiresManualStart){const n=this._context.initialTimestamp/1e3;e=e.filter(r=>r.start>=n)}return Promise.all(a_(this,e))}_clearContext(){this._context.errorIds.clear(),this._context.traceIds.clear(),this._context.urls=[]}_updateInitialTimestampFromEventBuffer(){const{session:e,eventBuffer:n}=this;if(!e||!n||this._requiresManualStart||e.segmentId)return;const r=n.getEarliestTimestamp();r&&r<this._context.initialTimestamp&&(this._context.initialTimestamp=r)}_popEventContext(){const e={initialTimestamp:this._context.initialTimestamp,initialUrl:this._context.initialUrl,errorIds:Array.from(this._context.errorIds),traceIds:Array.from(this._context.traceIds),urls:this._context.urls};return this._clearContext(),e}async _runFlush(){const e=this.getSessionId();if(!this.session||!this.eventBuffer||!e){yt&&St.error("No session or eventBuffer found to flush.");return}if(await this._addPerformanceEntries(),!(!this.eventBuffer||!this.eventBuffer.hasEvents)&&(await IDe(this),!!this.eventBuffer&&e===this.getSessionId()))try{this._updateInitialTimestampFromEventBuffer();const n=Date.now();if(n-this._context.initialTimestamp>this._options.maxReplayDuration+3e4)throw new Error("Session is too long, not sending replay");const r=this._popEventContext(),s=this.session.segmentId++;this._maybeSaveSession();const i=await this.eventBuffer.finish();await qW({replayId:e,recordingData:i,segmentId:s,eventContext:r,session:this.session,timestamp:n,onError:a=>this.handleException(a)})}catch(n){this.handleException(n),this.stop({reason:"sendReplay"});const r=Yt();if(r){const s=n instanceof Lj?"ratelimit_backoff":"send_error";r.recordDroppedEvent(s,"replay")}}}__init5(){this._flush=async({force:e=!1}={})=>{if(!this._isEnabled&&!e)return;if(!this.checkAndHandleExpiredSession()){yt&&St.error("Attempting to finish replay event after session expired.");return}if(!this.session)return;const n=this.session.started,s=Date.now()-n;this._debouncedFlush.cancel();const i=s<this._options.minReplayDuration,a=s>this._options.maxReplayDuration+5e3;if(i||a){yt&&St.info(`Session duration (${Math.floor(s/1e3)}s) is too ${i?"short":"long"}, not sending replay.`),i&&this._debouncedFlush();return}const l=this.eventBuffer;l&&this.session.segmentId===0&&!l.hasCheckout&&yt&&St.info("Flushing initial segment without checkout.");const u=!!this._flushLock;this._flushLock||(this._flushLock=this._runFlush());try{await this._flushLock}catch(d){this.handleException(d)}finally{this._flushLock=void 0,u&&this._debouncedFlush()}}}_maybeSaveSession(){this.session&&this._options.stickySession&&Pj(this.session)}__init6(){this._onMutationHandler=e=>{const n=e.length,r=this._options.mutationLimit,s=this._options.mutationBreadcrumbLimit,i=r&&n>r;if(n>s||i){const a=Ra({category:"replay.mutations",data:{count:n,limit:i}});this._createCustomBreadcrumb(a)}return i?(this.stop({reason:"mutationLimit",forceFlush:this.recordingMode==="session"}),!1):!0}}}function Ap(t,e){return[...t,...e].join(",")}function YDe({mask:t,unmask:e,block:n,unblock:r,ignore:s}){const i=["base","iframe[srcdoc]:not([src])"],a=Ap(t,[".sentry-mask","[data-sentry-mask]"]),l=Ap(e,[]);return{maskTextSelector:a,unmaskTextSelector:l,blockSelector:Ap(n,[".sentry-block","[data-sentry-block]",...i]),unblockSelector:Ap(r,[]),ignoreSelector:Ap(s,[".sentry-ignore","[data-sentry-ignore]",'input[type="file"]'])}}function KDe({el:t,key:e,maskAttributes:n,maskAllText:r,privacyOptions:s,value:i}){return!r||s.unmaskTextSelector&&t.matches(s.unmaskTextSelector)?i:n.includes(e)||e==="value"&&t.tagName==="INPUT"&&["submit","button"].includes(t.getAttribute("type")||"")?i.replace(/[\S]/g,"*"):i}const bz='img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]',XDe=["content-length","content-type","accept"];let xz=!1;const QDe=t=>new l_(t);class l_{static __initStatic(){this.id="Replay"}constructor({flushMinDelay:e=TOe,flushMaxDelay:n=COe,minReplayDuration:r=OOe,maxReplayDuration:s=J$,stickySession:i=!0,useCompression:a=!0,workerUrl:l,_experiments:u={},maskAllText:d=!0,maskAllInputs:p=!0,blockAllMedia:h=!0,mutationBreadcrumbLimit:g=750,mutationLimit:v=1e4,slowClickTimeout:b=7e3,slowClickIgnoreSelectors:x=[],networkDetailAllowUrls:E=[],networkDetailDenyUrls:S=[],networkCaptureBodies:k=!0,networkRequestHeaders:T=[],networkResponseHeaders:R=[],mask:j=[],maskAttributes:A=["title","placeholder"],unmask:N=[],block:M=[],unblock:I=[],ignore:O=[],maskFn:L,beforeAddRecordingEvent:z,beforeErrorSampling:G,onError:W}={}){this.name=l_.id;const X=YDe({mask:j,unmask:N,block:M,unblock:I,ignore:O});if(this._recordingOptions={maskAllInputs:p,maskAllText:d,maskInputOptions:{password:!0},maskTextFn:L,maskInputFn:L,maskAttributeFn:(F,Y,H)=>KDe({maskAttributes:A,maskAllText:d,privacyOptions:X,key:F,value:Y,el:H}),...X,slimDOMOptions:"all",inlineStylesheet:!0,inlineImages:!1,collectFonts:!0,errorHandler:F=>{try{F.__rrweb__=!0}catch{}}},this._initialOptions={flushMinDelay:e,flushMaxDelay:n,minReplayDuration:Math.min(r,POe),maxReplayDuration:Math.min(s,J$),stickySession:i,useCompression:a,workerUrl:l,blockAllMedia:h,maskAllInputs:p,maskAllText:d,mutationBreadcrumbLimit:g,mutationLimit:v,slowClickTimeout:b,slowClickIgnoreSelectors:x,networkDetailAllowUrls:E,networkDetailDenyUrls:S,networkCaptureBodies:k,networkRequestHeaders:_z(T),networkResponseHeaders:_z(R),beforeAddRecordingEvent:z,beforeErrorSampling:G,onError:W,_experiments:u},this._initialOptions.blockAllMedia&&(this._recordingOptions.blockSelector=this._recordingOptions.blockSelector?`${this._recordingOptions.blockSelector},${bz}`:bz),this._isInitialized&&B$())throw new Error("Multiple Sentry Session Replay instances are not supported");this._isInitialized=!0}get _isInitialized(){return xz}set _isInitialized(e){xz=e}afterAllSetup(e){!B$()||this._replay||(this._setup(e),this._initialize(e))}start(){this._replay&&this._replay.start()}startBuffering(){this._replay&&this._replay.startBuffering()}stop(){return this._replay?this._replay.stop({forceFlush:this._replay.recordingMode==="session"}):Promise.resolve()}flush(e){return this._replay?this._replay.isEnabled()?this._replay.sendBufferedReplayOrFlush(e):(this._replay.start(),Promise.resolve()):Promise.resolve()}getReplayId(){if(!(!this._replay||!this._replay.isEnabled()))return this._replay.getSessionId()}getRecordingMode(){if(!(!this._replay||!this._replay.isEnabled()))return this._replay.recordingMode}_initialize(e){this._replay&&(this._maybeLoadFromReplayCanvasIntegration(e),this._replay.initializeSampling())}_setup(e){const n=JDe(this._initialOptions,e);this._replay=new Pl({options:n,recordingOptions:this._recordingOptions})}_maybeLoadFromReplayCanvasIntegration(e){try{const n=e.getIntegrationByName("ReplayCanvas");if(!n)return;this._replay._canvas=n.getOptions()}catch{}}}l_.__initStatic();function JDe(t,e){const n=e.getOptions(),r={sessionSampleRate:0,errorSampleRate:0,...Nr(t)},s=Nx(n.replaysSessionSampleRate),i=Nx(n.replaysOnErrorSampleRate);return s==null&&i==null&&dc(()=>{console.warn("Replay is disabled because neither `replaysSessionSampleRate` nor `replaysOnErrorSampleRate` are set.")}),s!=null&&(r.sessionSampleRate=s),i!=null&&(r.errorSampleRate=i),r}function _z(t){return[...XDe,...t.map(e=>e.toLowerCase())]}const wz=new WeakMap,sk=new Map,gb={traceFetch:!0,traceXHR:!0,enableHTTPTimings:!0,trackFetchStreamPerformance:!1};function ZDe(t,e){const{traceFetch:n,traceXHR:r,trackFetchStreamPerformance:s,shouldCreateSpanForRequest:i,enableHTTPTimings:a,tracePropagationTargets:l}={traceFetch:gb.traceFetch,traceXHR:gb.traceXHR,trackFetchStreamPerformance:gb.trackFetchStreamPerformance,...e},u=typeof i=="function"?i:h=>!0,d=h=>nLe(h,l),p={};n&&(t.addEventProcessor(h=>(h.type==="transaction"&&h.spans&&h.spans.forEach(g=>{if(g.op==="http.client"){const v=sk.get(g.span_id);v&&(g.timestamp=v/1e3,sk.delete(g.span_id))}}),h)),s&&qje(h=>{if(h.response){const g=wz.get(h.response);g&&h.endTimestamp&&sk.set(g,h.endTimestamp)}}),jG(h=>{const g=Dje(h,u,d,p);if(h.response&&h.fetchData.__span&&wz.set(h.response,h.fetchData.__span),g){const v=HW(h.fetchData.url),b=v?cu(v).host:void 0;g.setAttributes({"http.url":v,"server.address":b})}a&&g&&Sz(g)})),r&&QG(h=>{const g=rLe(h,u,d,p);a&&g&&Sz(g)})}function eLe(t){return t.entryType==="resource"&&"initiatorType"in t&&typeof t.nextHopProtocol=="string"&&(t.initiatorType==="fetch"||t.initiatorType==="xmlhttprequest")}function Sz(t){const{url:e}=rn(t).data||{};if(!e||typeof e!="string")return;const n=zf("resource",({entries:r})=>{r.forEach(s=>{eLe(s)&&s.name.endsWith(e)&&(tLe(s).forEach(a=>t.setAttribute(...a)),setTimeout(n))})})}function _a(t=0){return((vs||performance.timeOrigin)+t)/1e3}function tLe(t){const{name:e,version:n}=YG(t.nextHopProtocol),r=[];return r.push(["network.protocol.version",n],["network.protocol.name",e]),vs?[...r,["http.request.redirect_start",_a(t.redirectStart)],["http.request.fetch_start",_a(t.fetchStart)],["http.request.domain_lookup_start",_a(t.domainLookupStart)],["http.request.domain_lookup_end",_a(t.domainLookupEnd)],["http.request.connect_start",_a(t.connectStart)],["http.request.secure_connection_start",_a(t.secureConnectionStart)],["http.request.connection_end",_a(t.connectEnd)],["http.request.request_start",_a(t.requestStart)],["http.request.response_start",_a(t.responseStart)],["http.request.response_end",_a(t.responseEnd)]]:r}function nLe(t,e){const n=Nt.location&&Nt.location.href;if(n){let r,s;try{r=new URL(t,n),s=new URL(n).origin}catch{return!1}const i=r.origin===s;return e?Vl(r.toString(),e)||i&&Vl(r.pathname,e):i}else{const r=!!t.match(/^\/(?!\/)/);return e?Vl(t,e):r}}function rLe(t,e,n,r){const s=t.xhr,i=s&&s[Kc];if(!s||s.__sentry_own_request__||!i)return;const a=tc()&&e(i.url);if(t.endTimestamp&&a){const h=s.__sentry_xhr_span_id__;if(!h)return;const g=r[h];g&&i.status_code!==void 0&&(G7(g,i.status_code),g.end(),delete r[h]);return}const l=HW(i.url),u=l?cu(l).host:void 0,d=!!$r(),p=a&&d?Og({name:`${i.method} ${i.url}`,attributes:{type:"xhr","http.method":i.method,"http.url":l,url:i.url,"server.address":u,[Dr]:"auto.http.browser",[Tu]:"http.client"}}):new uh;return s.__sentry_xhr_span_id__=p.spanContext().spanId,r[s.__sentry_xhr_span_id__]=p,n(i.url)&&sLe(s,tc()&&d?p:void 0),p}function sLe(t,e){const{"sentry-trace":n,baggage:r}=kG({span:e});n&&iLe(t,n,r)}function iLe(t,e,n){try{t.setRequestHeader("sentry-trace",e),n&&t.setRequestHeader("baggage",n)}catch{}}function HW(t){try{return new URL(t,Nt.location.origin).href}catch{return}}function aLe(){Nt&&Nt.document?Nt.document.addEventListener("visibilitychange",()=>{const t=$r();if(!t)return;const e=Kr(t);if(Nt.document.hidden&&e){const n="cancelled",{op:r,status:s}=rn(e);Ha&&ze.log(`[Tracing] Transaction: ${n} -> since tab moved to the background, op: ${r}`),s||e.setStatus({code:Or,message:n}),e.setAttribute("sentry.cancellation_reason","document.hidden"),e.end()}}):Ha&&ze.warn("[Tracing] Could not set up background tab detection due to lack of global document")}const oLe="BrowserTracing",lLe={...db,instrumentNavigation:!0,instrumentPageLoad:!0,markBackgroundSpan:!0,enableLongTask:!0,enableLongAnimationFrame:!0,enableInp:!0,_experiments:{},...gb},cLe=(t={})=>{FNe();const{enableInp:e,enableLongTask:n,enableLongAnimationFrame:r,_experiments:{enableInteractions:s,enableStandaloneClsSpans:i},beforeStartSpan:a,idleTimeout:l,finalTimeout:u,childSpanTimeout:d,markBackgroundSpan:p,traceFetch:h,traceXHR:g,trackFetchStreamPerformance:v,shouldCreateSpanForRequest:b,enableHTTPTimings:x,instrumentPageLoad:E,instrumentNavigation:S}={...lLe,...t},k=JMe({recordClsStandaloneSpans:i||!1});e&&S2e(),r&&Kt.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes("long-animation-frame")?e2e():n&&ZMe(),s&&t2e();const T={name:void 0,source:void 0};function R(j,A){const N=A.op==="pageload",M=a?a(A):A,I=M.attributes||{};A.name!==M.name&&(I[Na]="custom",M.attributes=I),T.name=M.name,T.source=I[Na];const O=fG(M,{idleTimeout:l,finalTimeout:u,childSpanTimeout:d,disableAutoFinish:N,beforeSpanEnd:z=>{k(),a2e(z,{recordClsOnPageloadSpan:!i})}});function L(){["interactive","complete"].includes(Nt.document.readyState)&&j.emit("idleSpanEnableAutoFinish",O)}return N&&Nt.document&&(Nt.document.addEventListener("readystatechange",()=>{L()}),L()),O}return{name:oLe,afterAllSetup(j){let A,N=Nt.location&&Nt.location.href;function M(){A&&!rn(A).timestamp&&(Ha&&ze.log(`[Tracing] Finishing current active span with op: ${rn(A).op}`),A.end())}j.on("startNavigationSpan",I=>{Yt()===j&&(M(),A=R(j,{op:"navigation",...I}))}),j.on("startPageLoadSpan",(I,O={})=>{if(Yt()!==j)return;M();const L=O.sentryTrace||Ez("sentry-trace"),z=O.baggage||Ez("baggage"),G=ONe(L,z);An().setPropagationContext(G),A=R(j,{op:"pageload",...I})}),j.on("spanEnd",I=>{const O=rn(I).op;if(I!==Kr(I)||O!=="navigation"&&O!=="pageload")return;const L=An(),z=L.getPropagationContext();L.setPropagationContext({...z,sampled:z.sampled!==void 0?z.sampled:Mu(I),dsc:z.dsc||Ou(I)})}),Nt.location&&(E&&uLe(j,{name:Nt.location.pathname,startTime:vs?vs/1e3:void 0,attributes:{[Na]:"url",[Dr]:"auto.pageload.browser"}}),S&&t_(({to:I,from:O})=>{if(O===void 0&&N&&N.indexOf(I)!==-1){N=void 0;return}O!==I&&(N=void 0,dLe(j,{name:Nt.location.pathname,attributes:{[Na]:"url",[Dr]:"auto.navigation.browser"}}))})),p&&aLe(),s&&fLe(l,u,d,T),e&&k2e(),ZDe(j,{traceFetch:h,traceXHR:g,trackFetchStreamPerformance:v,tracePropagationTargets:j.getOptions().tracePropagationTargets,shouldCreateSpanForRequest:b,enableHTTPTimings:x})}}};function uLe(t,e,n){t.emit("startPageLoadSpan",e,n),An().setTransactionName(e.name);const r=$r();return(r&&rn(r).op)==="pageload"?r:void 0}function dLe(t,e){Li().setPropagationContext({traceId:Zl()}),An().setPropagationContext({traceId:Zl()}),t.emit("startNavigationSpan",e),An().setTransactionName(e.name);const n=$r();return(n&&rn(n).op)==="navigation"?n:void 0}function Ez(t){const e=iNe(`meta[name=${t}]`);return e?e.getAttribute("content"):void 0}function fLe(t,e,n,r){let s;const i=()=>{const a="ui.action.click",l=$r(),u=l&&Kr(l);if(u){const d=rn(u).op;if(["navigation","pageload"].includes(d)){Ha&&ze.warn(`[Tracing] Did not create ${a} span because a pageload or navigation span is in progress.`);return}}if(s&&(s.setAttribute(PC,"interactionInterrupted"),s.end(),s=void 0),!r.name){Ha&&ze.warn(`[Tracing] Did not create ${a} transaction because _latestRouteName is missing.`);return}s=fG({name:r.name,op:a,attributes:{[Na]:r.source||"url"}},{idleTimeout:t,finalTimeout:e,childSpanTimeout:n})};Nt.document&&addEventListener("click",i,{once:!1,capture:!0})}function hLe(t){const e={...t};return EG(e,"react"),gG("react",{version:w.version}),wOe(e)}function pLe(){const{user:t}=da(),{isAuthenticated:e,isLoading:n}=Xa(),r=d7("users:ensureUser"),s=w.useRef(null);w.useEffect(()=>{e||(s.current=null,A$(null))},[e]),w.useEffect(()=>{if(!n){if(!e&&t)throw console.log("useEnsureDbUser: not authenticated"),new Error("Not authenticated");e&&t&&s.current!==t.id&&r().then(i=>{s.current=t.id,A$({id:t.id})}).catch(i=>{console.error("[auth] ensureUser failed",i),s.current=null})}},[e,n,t,r])}function mLe(){const t=ua(),{user:e}=da(),{isAuthenticated:n}=Xa();w.useEffect(()=>{t&&(n&&e?(t.identify(e.id,{email:e.email,name:e.firstName&&e.lastName?`${e.firstName} ${e.lastName}`:e.email,first_name:e.firstName,last_name:e.lastName}),t.register({user_id:e.id})):t.reset())},[t,n,e])}function kz({className:t,...e}){return f.jsx(BJ,{"data-slot":"avatar",className:Me("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...e})}function Tz({className:t,...e}){return f.jsx(qJ,{"data-slot":"avatar-image",className:Me("aspect-square size-full",t),...e})}function Cz({className:t,...e}){return f.jsx(VJ,{"data-slot":"avatar-fallback",className:Me("bg-muted flex size-full items-center justify-center rounded-full",t),...e})}function gLe(){const{isLoading:t}=Xa(),{user:e,signIn:n,signOut:r,signUp:s}=da(),i=ua();if(t)return f.jsx(Ie,{variant:"outline",size:"sm",disabled:!0,children:f.jsx(ir,{className:"h-3 w-3 mr-1.5 animate-spin"})});if(!e)return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ie,{variant:"outline",onClick:()=>{i.capture("sign_in",{location:"auth_upper_area",platform:Ni(),environment:void 0}),n()},children:"Sign in"}),f.jsx(Ie,{onClick:()=>{i.capture("create_account",{location:"auth_upper_area",platform:Ni(),environment:void 0}),s()},style:{backgroundColor:"#E55A3A"},children:"Create account"})]});const a=[e.firstName,e.lastName].filter(Boolean).join(" "),l=e.email,u=zX(a),d=()=>{const h=window.location.origin,v=h.includes("://localhost")?h.replace("://localhost","://127.0.0.1"):h;r({returnTo:v})},p=e.profilePictureUrl||void 0;return f.jsxs(p0,{children:[f.jsx(m0,{asChild:!0,children:f.jsx("button",{className:"flex size-10 items-center justify-center rounded-full border border-border/60 bg-background/80 shadow-sm outline-none transition hover:ring-2 hover:ring-ring/20 focus-visible:ring-2 focus-visible:ring-ring",children:f.jsxs(kz,{className:"size-9 cursor-pointer",children:[f.jsx(Tz,{src:p,alt:a}),f.jsx(Cz,{className:"bg-muted text-muted-foreground text-sm font-medium",children:u!=="?"?u:f.jsx(aI,{className:"size-4"})})]})})}),f.jsxs(g0,{className:"w-56",align:"end",children:[f.jsx(rae,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs(kz,{className:"size-10 cursor-pointer",children:[f.jsx(Tz,{src:p,alt:a}),f.jsx(Cz,{className:"bg-muted text-muted-foreground text-base font-semibold",children:u!=="?"?u:f.jsx(aI,{className:"size-5"})})]}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-sm font-medium leading-none truncate",children:a}),f.jsx("p",{className:"text-xs text-muted-foreground truncate",children:l})]})]})}),f.jsx(dI,{}),f.jsxs(To,{onClick:()=>window.location.hash="settings",className:"cursor-pointer",children:[f.jsx(ZA,{className:"size-4"}),"Settings"]}),f.jsx(dI,{}),f.jsxs(To,{variant:"destructive",onClick:d,className:"cursor-pointer",children:[f.jsx(Fse,{className:"size-4"}),"Log out"]})]})]})}function vLe(){const[t,e]=w.useState("servers"),n=ua();mLe(),w.useEffect(()=>{n.capture("app_launched",{platform:Ni(),environment:void 0,user_agent:navigator.userAgent})},[]),GAe(),pLe();const r=w.useMemo(()=>window.location.pathname.startsWith("/oauth/callback/debug"),[]),s=w.useMemo(()=>window.location.pathname==="/callback",[]),{appState:i,isLoading:a,connectedServerConfigs:l,selectedMCPConfig:u,handleConnect:d,handleDisconnect:p,handleReconnect:h,handleUpdate:g,handleRemoveServer:v,setSelectedServer:b,toggleServerSelection:x,selectedMCPConfigsMap:E,setSelectedMultipleServersToAllServers:S}=g7();w.useEffect(()=>{const T=()=>{const R=(window.location.hash||"#servers").replace("#","");e(R),R==="chat"&&S()};return T(),window.addEventListener("hashchange",T),()=>window.removeEventListener("hashchange",T)},[S]);const k=T=>{T==="chat"&&S(),window.location.hash=T,e(T)};return r?f.jsx(cAe,{}):s?(w.useEffect(()=>{const T=setTimeout(()=>{window.location.href="/"},5e3);return()=>clearTimeout(T)},[]),f.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Completing sign in..."}),f.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"If this takes too long, you'll be redirected automatically"})]})})):a?f.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),f.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})}):f.jsxs(ZEe,{themeMode:"light",themePreset:"default",children:[f.jsxs(EAe,{defaultOpen:!0,children:[f.jsx(LAe,{onNavigate:k,activeTab:t}),f.jsxs(CAe,{className:"flex flex-col",children:[f.jsx("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear drag",children:f.jsxs("div",{className:"flex w-full items-center justify-between px-4 lg:px-6",children:[f.jsx("div",{className:"flex items-center gap-1 lg:gap-2",children:f.jsx(TAe,{className:"-ml-1"})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(gLe,{})})]})}),f.jsxs("div",{className:"flex-1",children:[(t==="tools"||t==="resources"||t==="prompts"||t==="auth"||t==="chat"||t==="interceptor")&&f.jsx(FAe,{connectedServerConfigs:l,selectedServer:i.selectedServer,onServerChange:b,onConnect:d,isMultiSelectEnabled:t==="chat",onMultiServerToggle:x,selectedMultipleServers:i.selectedMultipleServers}),t==="servers"&&f.jsx(Vue,{connectedServerConfigs:l,onConnect:d,onDisconnect:p,onReconnect:h,onUpdate:g,onRemove:v}),t==="tools"&&f.jsx(Khe,{serverConfig:u,serverName:i.selectedServer}),t==="evals"&&f.jsx(nTe,{}),t==="eval-results"&&f.jsx(Bke,{}),t==="resources"&&f.jsx(Xhe,{serverConfig:u,serverName:i.selectedServer}),t==="prompts"&&f.jsx(Qhe,{serverConfig:u,serverName:i.selectedServer}),t==="auth"&&f.jsx(lAe,{serverConfig:u,serverEntry:i.servers[i.selectedServer],serverName:i.selectedServer}),t==="chat"&&f.jsx(Ike,{serverConfigs:E,connectedServerConfigs:l}),t==="interceptor"&&f.jsx(rAe,{connectedServerConfigs:l,selectedServer:i.selectedServer}),t==="tracing"&&f.jsx(nAe,{}),t==="settings"&&f.jsx(QCe,{})]})]})]}),f.jsx(HAe,{})]})}function yLe({children:t,client:e,useAuth:n}){const r=bLe(n);return f.jsx(Nke,{client:e,useAuth:r,children:t})}function bLe(t){return w.useMemo(()=>function(){const{isLoading:n,user:r,getAccessToken:s}=t(),i=w.useCallback(async()=>{try{return await s()}catch{return null}},[s]);return w.useMemo(()=>({isLoading:n,isAuthenticated:!!r,fetchAccessToken:i}),[n,r,i])},[t])}const xLe={environment:"prod",sendDefaultPii:!1,tracesSampleRate:.1,tracePropagationTargets:["localhost",/^\//,/^https?:\/\/[^/]*\.convex\.(cloud|site)/]},_Le={...xLe,dsn:"https://c9df3785c734acfe9dad2d0c1e963e28@o4510109778378752.ingest.us.sentry.io/4510111435063296",replaysSessionSampleRate:.1,replaysOnErrorSampleRate:1};function wLe(){hLe({..._Le,integrations:[QDe(),cLe()]})}wLe();const SLe="https://outstanding-fennec-304.convex.cloud",ELe="client_01K4C1TVPBE7JTBFQJF9SDW9P9",kLe=(()=>{const t="mcpjam://oauth/callback";return typeof window>"u"?t:window.location.protocol==="http:"||window.location.protocol==="https:"?`${window.location.origin}/callback`:t})(),TLe=new bke(SLe),CLe=iX.createRoot(document.getElementById("root")),ALe=f.jsx(Tpe,{clientId:ELe,redirectUri:kLe,children:f.jsx(yLe,{client:TLe,useAuth:da,children:f.jsx(vLe,{})})});CLe.render(f.jsx(w.StrictMode,{children:f.jsx(Mue,{apiKey:zue(),options:Fue(),children:ALe})}));
|
|
1875
|
-
//# sourceMappingURL=index-
|
|
1875
|
+
//# sourceMappingURL=index-B1QdI8CW.js.map
|