@marketrix.ai/widget 3.8.53 → 3.8.117
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.
- package/dist/src/components/base/icons.d.ts +0 -12
- package/dist/src/index.d.ts +0 -4
- package/dist/src/services/ApiService.d.ts +0 -6
- package/dist/src/services/DomService.d.ts +0 -33
- package/dist/src/services/ScreenShareService.d.ts +0 -7
- package/dist/src/services/SessionManager.d.ts +0 -6
- package/dist/src/services/SessionRecorder.d.ts +0 -15
- package/dist/src/services/StorageService.d.ts +0 -21
- package/dist/src/services/ValidationService.d.ts +0 -7
- package/dist/src/types/index.d.ts +0 -7
- package/dist/src/utils/apiUtils.d.ts +0 -3
- package/dist/src/utils/bootstrap.d.ts +0 -34
- package/dist/src/utils/chat.d.ts +0 -24
- package/dist/src/utils/{format.d.ts → color.d.ts} +0 -9
- package/dist/src/utils/{common.d.ts → logger.d.ts} +0 -3
- package/dist/src/utils/validation.d.ts +0 -9
- package/dist/widget.mjs +1 -1
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as a,useEffect as s,useId as c,useLayoutEffect as l,useMemo as d,useRef as u,useState as p}from"react";import{createRoot as h}from"react-dom/client";import{Fragment as m,jsx as f,jsxs as g}from"react/jsx-runtime";var y=2147483002,b=2147483001,w=2147483005;function v(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function x(e){return function(e){const t=v(e);if(!t)return.5;const[n,r,o]=[t.r/255,t.g/255,t.b/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*n+.7152*r+.0722*o}(e)>.5?"#000000":"#ffffff"}function k(e,t){if(e.startsWith("rgba")||e.startsWith("rgb")){const n=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t})`}const n=v(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`:(e.includes("gradient")||e.includes("linear-gradient"),e)}function _(e,t){const n=v(e);if(!n)return e;const r=1-t;return o=Math.round(n.r*r),i=Math.round(n.g*r),a=Math.round(n.b*r),`#${[o,i,a].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var o,i,a}var S=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),I=e=>{switch(e){case"show":return"Show";case"tell":return"Tell";case"do":return"Do";default:return e}},C={widget_background_color:"#ffffff",widget_text_color:"#1f2937",widget_border_color:"#e5e7eb",widget_accent_color:"#3b82f6",widget_secondary_color:"#6b7280",widget_border_radius:"20px",widget_font_size:"14px",widget_width:"400px",widget_height:"600px",widget_shadow:"0 5px 40px 0 rgba(0, 0, 0, 0.3)",widget_animation_duration:"300ms",widget_fade_duration:"200ms"};function E(e){return{color:{background:e.widget_background_color,foreground:e.widget_text_color,foregroundMuted:k(e.widget_text_color,.6),foregroundFaint:k(e.widget_text_color,.4),border:e.widget_border_color,borderMuted:k(e.widget_border_color,.3),primary:e.widget_accent_color,primaryForeground:x(e.widget_accent_color),primaryHover:k(e.widget_accent_color,.85),primaryMuted:k(e.widget_accent_color,.3),secondary:e.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:k(e.widget_secondary_color,.2),secondaryHover:k(e.widget_secondary_color,.3)},radius:e.widget_border_radius,shadow:e.widget_shadow,typography:{fontSizeBase:e.widget_font_size},motion:{durationAnimation:e.widget_animation_duration,durationFade:e.widget_fade_duration},size:{widgetWidth:e.widget_width,widgetHeight:e.widget_height}}}E(C);function T(e){return Array.isArray(e)?e:null==e?[]:[e]}var M="orpc",z=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function A(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function O(){return globalThis["__@orpc/shared@1.14.6/otel/config__"]}function N(e,t={},n){return(O()?.tracer)?.startSpan(e,t,n)}function R(e,t,n={}){if(!e)return;const r=function(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(r),n.signal?.aborted&&n.signal.reason===t||e.setStatus({code:2,message:r.message})}async function L({name:e,context:t,...n},r){const o=O()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw R(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function $(e,t){const n=O();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function D(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var P=Symbol.asyncDispose??Symbol.for("asyncDispose"),j=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=function(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}(async()=>{if(this.#e)return{done:!0,value:void 0};try{const t=await e();return t.done&&(this.#e=!0),t}catch(t){throw this.#e=!0,t}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),e}async[P](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function F({name:e,...t},n){let r;return new j(async()=>{r??=N(e);try{const e=await $(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw R(r,o,t),o}},async e=>{try{"next"!==e&&await $(r,()=>n.return?.())}catch(o){throw R(r,o,t),o}finally{r?.end()}})}function U(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function B(e){if(e)return JSON.parse(e)}function W(e){return JSON.stringify(e)}function H(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function Z(e){return!!e&&("object"==typeof e||"function"==typeof e)}function q(e,...t){return"function"==typeof e?e(...t):e}function V(e){return new Proxy(e,{get(e,t,n){const r=Reflect.get(e,t,n);return"then"!==t||"function"!=typeof r?r:new Proxy(r,{apply(t,n,r){if(2!==r.length||r.some(e=>{return!("function"==typeof(t=e)&&G.test(t.toString()));var t}))return Reflect.apply(t,n,r);let o=!0;r[0].call(n,V(new Proxy(e,{get:(e,t,n)=>{if(!o||"then"!==t)return Reflect.get(e,t,n);o=!1}})))}})}})}var G=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var J,K={BAD_REQUEST:{status:400,message:"Bad Request"},UNAUTHORIZED:{status:401,message:"Unauthorized"},FORBIDDEN:{status:403,message:"Forbidden"},NOT_FOUND:{status:404,message:"Not Found"},METHOD_NOT_SUPPORTED:{status:405,message:"Method Not Supported"},NOT_ACCEPTABLE:{status:406,message:"Not Acceptable"},TIMEOUT:{status:408,message:"Request Timeout"},CONFLICT:{status:409,message:"Conflict"},PRECONDITION_FAILED:{status:412,message:"Precondition Failed"},PAYLOAD_TOO_LARGE:{status:413,message:"Payload Too Large"},UNSUPPORTED_MEDIA_TYPE:{status:415,message:"Unsupported Media Type"},UNPROCESSABLE_CONTENT:{status:422,message:"Unprocessable Content"},TOO_MANY_REQUESTS:{status:429,message:"Too Many Requests"},CLIENT_CLOSED_REQUEST:{status:499,message:"Client Closed Request"},INTERNAL_SERVER_ERROR:{status:500,message:"Internal Server Error"},NOT_IMPLEMENTED:{status:501,message:"Not Implemented"},BAD_GATEWAY:{status:502,message:"Bad Gateway"},SERVICE_UNAVAILABLE:{status:503,message:"Service Unavailable"},GATEWAY_TIMEOUT:{status:504,message:"Gateway Timeout"}};var Y=class e extends Error{defined;code;status;data;static{const t=Symbol.for("__@orpc/client@1.14.6/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(J=globalThis[t]).add(e)}constructor(e,...t){const n=function(e){return e[0]??{}}(t);if(void 0!==n.status&&!X(n.status))throw new Error("[ORPCError] Invalid error status code.");const r=function(e,t){return t||K[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??K[e]?.status??500}(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(J.has(this)){const t=function(e){return Z(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&J.has(t))return!0}return super[Symbol.hasInstance](e)}};function X(e){return e<200||e>=400}function Q(e){if(!H(e))return!1;const t=["defined","code","status","message","data"];return!Object.keys(e).some(e=>!t.includes(e))&&("defined"in e&&"boolean"==typeof e.defined&&"code"in e&&"string"==typeof e.code&&"status"in e&&"number"==typeof e.status&&X(e.status)&&"message"in e&&"string"==typeof e.message)}function ee(e,t={}){return new Y(e.code,{...t,...e})}var te=class extends TypeError{},ne=class extends TypeError{},re=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}};function oe(e){const t=e.replace(/\n+$/,"").split(/\n/),n={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const r of t){const e=r.indexOf(":"),t=-1===e?r:r.slice(0,e),o=-1===e?"":r.slice(e+1).replace(/^\s/,"");if(0===e)n.comments.push(o);else if("data"===t)n.data??="",n.data+=`${o}\n`;else if("event"===t)n.event=o;else if("id"===t)n.id=o;else if("retry"===t){const e=Number.parseInt(o);Number.isInteger(e)&&e>=0&&e.toString()===o&&(n.retry=e)}}return n.data=n.data?.replace(/\n$/,""),n}var ie=class{constructor(e={}){this.options=e}incomplete="";feed(e){this.incomplete+=e;const t=this.incomplete.lastIndexOf("\n\n");if(-1===t)return;const n=this.incomplete.slice(0,t).split(/\n\n/);this.incomplete=this.incomplete.slice(t+2);for(const r of n){const e=oe(`${r}\n\n`);this.options.onEvent&&this.options.onEvent(e)}}end(){if(this.incomplete)throw new ne("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new ie({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function se(e){if(e.includes("\n"))throw new te("Event's id must not contain a newline character")}function ce(e){if(!Number.isInteger(e)||e<0)throw new te("Event's retry must be a integer and >= 0")}function le(e){if(e.includes("\n"))throw new te("Event's comment must not contain a newline character")}function de(e){let t="";return t+=function(e){let t="";for(const n of e??[])le(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new te("Event's event must not contain a newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(ce(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(se(e.id),t+=`id: ${e.id}\n`),t+=function(e){const t=e?.split(/\n/)??[];let n="";for(const r of t)n+=`data: ${r}\n`;return n}(e.data),t+="\n",t}var ue=Symbol("ORPC_EVENT_SOURCE_META");function pe(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&se(t.id),void 0!==t.retry&&ce(t.retry),void 0!==t.comments)for(const n of t.comments)le(n);return new Proxy(e,{get:(e,n,r)=>n===ue?t:Reflect.get(e,n,r)})}function he(e){return Z(e)?Reflect.get(e,ue):void 0}function me(e){const t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&"string"==typeof t[2])return function(e){try{return decodeURIComponent(e)}catch{return e}}(t[2]);const n=e.match(/filename="((?:\\"|[^"])*)"/i);return n&&"string"==typeof n[1]?n[1].replace(/\\"/g,'"'):void 0}function fe(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=he(e);t&&Z(n)&&(n=pe(n,t))}return n};return new j(async()=>{const{done:r,value:o}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let i=await t.value(o,r);if(i!==o){const e=he(o);e&&Z(i)&&(i=pe(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function ge(e,t={}){const n=t.path??[];return V(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,o)=>"string"!=typeof o?Reflect.get(r,o):ge(e,{...t,path:[...n,o]})}))}function ye(e,t={}){return L({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=me(n)??"blob",r=await e.blob();return new File([r],t,{type:r.type})}const r=e.headers.get("content-type");if(!r||r.startsWith("application/json"))return B(await e.text());if(r.startsWith("multipart/form-data"))return await e.formData();if(r.startsWith("application/x-www-form-urlencoded")){const t=await e.text();return new URLSearchParams(t)}if(r.startsWith("text/event-stream"))return function(e,t={}){const n=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new ae))?.getReader();let r,o=!1;return new j(async()=>{r??=N("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await $(r,()=>n.read());if(e){if(o)throw new z("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=B(t.data);return Z(e)&&(e=pe(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new re({data:B(t.data)});throw e=pe(e,t),r?.addEvent("error"),e}case"done":{let e=B(t.data);return Z(e)&&(e=pe(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof re||R(r,e,t),e}},async e=>{try{"next"!==e&&(o=!0,r?.addEvent("cancelled")),await $(r,()=>n?.cancel())}catch(i){throw R(r,i,t),i}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const o=await e.blob();return new File([o],"blob",{type:o.type})})}function be(e,t,n={}){if(e instanceof ReadableStream)return e;const r=t.get("content-disposition");return t.delete("content-type"),t.delete("content-disposition"),void 0!==e?e instanceof Blob?(t.set("content-type",e.type),t.set("content-length",e.size.toString()),t.set("content-disposition",r??function(e,t="inline"){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}(e instanceof File?e.name:"blob")),e):e instanceof FormData||e instanceof URLSearchParams?e:D(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,a=t.eventIteratorInitialComment??"";let s,c,l=!1;return new ReadableStream({start(e){c=N("stream_event_iterator"),i&&e.enqueue(de({comments:[a]}))},async pull(t){try{n&&(s=setInterval(()=>{t.enqueue(de({comments:[o]})),c?.addEvent("keepalive")},r));const i=await $(c,()=>e.next());if(clearInterval(s),l)return;const a=he(i.value);if(!i.done||void 0!==i.value||void 0!==a){const e=i.done?"done":"message";t.enqueue(de({...a,event:e,data:W(i.value)})),c?.addEvent(e)}i.done&&(t.close(),c?.end())}catch(i){if(clearInterval(s),l)return;i instanceof re?(t.enqueue(de({...he(i),event:"error",data:W(i.data)})),c?.addEvent("error"),t.close()):(R(c,i),t.error(i)),c?.end()}},async cancel(){try{l=!0,clearInterval(s),c?.addEvent("cancelled"),await $(c,()=>e.return?.())}catch(t){throw R(c,t),t}finally{c?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),W(e)):void 0}function we(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):void 0!==t[n]?t[n]=[t[n],e]:t[n]=e}),t}function ve(e,t={}){const n=function(e,t=new Headers){for(const[n,r]of Object.entries(e))if(Array.isArray(r))for(const e of r)t.append(n,e);else void 0!==r&&t.append(n,r);return t}(e.headers),r=be(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}var xe=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(const t of this.plugins)t.init?.(e)}},ke=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new xe(n.plugins).init(n),this.interceptors=T(n.interceptors),this.clientInterceptors=T(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return L({name:`${M}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",M),r?.setAttribute("rpc.method",e.join(".")),D(t)&&(t=F({name:"consume_event_iterator_input",signal:n.signal},t)),U(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=O();let i;const a=o?.trace.getActiveSpan()??r;a&&o&&(i=o?.trace.setSpan(o.context.active(),a));const s=await L({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await U(this.clientInterceptors,{...n,input:t,path:e,request:s},({input:e,path:t,request:n,...r})=>L({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await L({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return D(l)?F({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},_e=0,Se=1,Ie=2,Ce=3,Ee=4,Te=5,Me=6,ze=7,Ae=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],n=[],r=[],o=[]){for(const i of this.customSerializers)if(i.condition(e)){const a=this.serialize(i.serialize(e),t,n,r,o);return n.push([i.type,...t]),a}if(e instanceof Blob)return r.push(t),o.push(e),[e,n,r,o];if("bigint"==typeof e)return n.push([_e,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([Se,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([Ie,...t]),[null,n,r,o];if(e instanceof URL)return n.push([Ee,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([Te,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([Me,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([ze,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([Ce,...t,i]),null):this.serialize(e,[...t,i],n,r,o)[0]),n,r,o];if(H(e)){const i={};for(const a in e)"toJSON"===a&&"function"==typeof e[a]||(i[a]=this.serialize(e[a],[...t,a],n,r,o)[0]);return[i,n,r,o]}return[e,n,r,o]}deserialize(e,t,n,r){const o={data:e};n&&r&&n.forEach((e,t)=>{let n=o,i="data";e.forEach(e=>{if(n=n[i],i=e,!Object.hasOwn(n,i))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${i}`)}),n[i]=r(t)});for(const i of t){const e=i[0];let t=o,n="data";for(let r=1;r<i.length;r++)if(t=t[n],n=i[r],!Object.hasOwn(t,n))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${n}`);for(const r of this.customSerializers)if(r.type===e){t[n]=r.deserialize(t[n]);break}switch(e){case _e:t[n]=BigInt(t[n]);break;case Se:t[n]=new Date(t[n]??"Invalid Date");break;case Ie:t[n]=NaN;break;case Ce:t[n]=void 0;break;case Ee:t[n]=new URL(t[n]);break;case Te:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case Me:t[n]=new Set(t[n]);break;case ze:t[n]=new Map(t[n])}}return o.data}};var Oe,Ne=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??"POST",this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=function(e){return"function"==typeof e.forEach?we(e):e}(await q(this.headers,n,e,t));void 0!==n.lastEventId&&(r=function(e,t){const n={...e};for(const r in t)Array.isArray(t[r])?n[r]=[...T(n[r]),...t[r]]:void 0!==t[r]&&(Array.isArray(n[r])?n[r]=[...n[r],t[r]]:void 0!==n[r]?n[r]=[n[r],t[r]]:n[r]=t[r]);return n}(r,{"last-event-id":n.lastEventId}));const o=await q(this.expectedMethod,n,e,t),i=await q(this.baseUrl,n,e,t),a=new URL(i);a.pathname=`${a.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const s=this.serializer.serialize(t);if(!("GET"!==o||s instanceof FormData||D(s))){const i=await q(this.maxUrlLength,n,e,t),c=new URL(a);if(c.searchParams.append("data",W(s)),c.toString().length<=i)return{body:void 0,method:o,headers:r,url:c,signal:n.signal}}return{url:a,method:"GET"===o?this.fallbackMethod:o,headers:r,body:s,signal:n.signal}}async decode(e){const t=!X(e.status),n=await(async()=>{let t=!1;try{const n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(n){if(!t)throw new Error("Cannot parse response body, please check the response body and content-type.",{cause:n});throw new Error("Invalid RPC response format.",{cause:n})}})();if(!t){if(Q(n))throw ee(n);throw new Y((r=e.status,Object.entries(K).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},Re=class{constructor(e){this.jsonSerializer=e}serialize(e){return D(e)?fe(e,{value:async e=>this.#o(e,!1),error:async e=>{return new re({data:this.#o((t=e,t instanceof Y?t:new Y("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#o(e,!0)}#o(e,t){const[n,r,o,i]=this.jsonSerializer.serialize(e),a=0===r.length?void 0:r;if(!t||0===i.length)return{json:n,meta:a};const s=new FormData;return s.set("data",W({json:n,meta:a,maps:o})),i.forEach((e,t)=>{s.set(t.toString(),e)}),s}deserialize(e){return D(e)?fe(e,{value:async e=>this.#i(e),error:async e=>{if(!(e instanceof re))return e;const t=this.#i(e.data);return Q(t)?ee(t,{cause:e}):new re({data:t,cause:e})}}):this.#i(e)}#i(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},Le=class extends ke{constructor(e,t){super(new Ne(new Re(new Ae(t)),t),e,t)}},$e=class extends xe{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},De=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new $e(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=T(e.adapterInterceptors)}async call(e,t,n,r){const o=ve(e,this.toFetchRequestOptions);return function(e,t={}){return{body:A(()=>ye(e,t)),status:e.status,get headers(){const t=we(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await U(this.adapterInterceptors,{...t,request:o,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...o})=>this.fetch(e,r,o,t,n)),{signal:o.signal})}},Pe=class extends Le{constructor(e){super(new De(e),e)}};function je(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:a,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=a.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function a(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var Fe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ue=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Oe=globalThis).__zod_globalConfig??(Oe.__zod_globalConfig={});var Be=globalThis.__zod_globalConfig;function We(e){return e&&Object.assign(Be,e),Be}function He(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Ze(e,t){return"bigint"==typeof t?t.toString():t}function qe(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ve(e){return null==e}function Ge(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Je=/* @__PURE__*/Symbol("evaluating");function Ke(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Je)return void 0===r&&(r=Je,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ye(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xe(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}var et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var nt=/* @__PURE__*/qe(()=>{if(Be.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function rt(e){if(!1===tt(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==tt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function ot(e){return rt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var it=/* @__PURE__*/new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function st(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function ct(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}var lt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function dt(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function ut(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function pt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ht(e){return"string"==typeof e?e:e?.message}function mt(e,t,n){const r=e.message?e.message:ht(e.inst?._zod.def?.error?.(e))??ht(t?.error?.(e))??ht(n.customError?.(e))??ht(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...s}=e;return s.path??(s.path=[]),s.message=r,t?.reportInput&&(s.input=a),s}function ft(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function gt(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var yt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ze,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bt=je("$ZodError",yt),wt=je("$ZodError",yt,{Parent:Error});var vt=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Fe;if(a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>mt(e,i,We())));throw et(t,o?.callee),t}return a.value},xt=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>mt(e,i,We())));throw et(t,o?.callee),t}return a.value},kt=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Fe;return i.issues.length?{success:!1,error:new(e??bt)(i.issues.map(e=>mt(e,o,We())))}:{success:!0,data:i.value}},_t=/* @__PURE__*/kt(wt),St=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>mt(e,o,We())))}:{success:!0,data:i.value}},It=/* @__PURE__*/St(wt),Ct=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return vt(e)(t,n,o)},Et=e=>(t,n,r)=>vt(e)(t,n,r),Tt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return xt(e)(t,n,o)},Mt=e=>async(t,n,r)=>xt(e)(t,n,r),zt=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kt(e)(t,n,o)},At=e=>(t,n,r)=>kt(e)(t,n,r),Ot=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return St(e)(t,n,o)},Nt=e=>async(t,n,r)=>St(e)(t,n,r),Rt=/^[cC][0-9a-z]{6,}$/,Lt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dt=/^[0-9a-vA-V]{20}$/,Pt=/^[A-Za-z0-9]{27}$/,jt=/^[a-zA-Z0-9_-]{21}$/,Ft=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ut=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Bt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Wt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Ht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Zt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,qt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Vt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Gt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,Kt=/^https?$/,Yt=/^\+[1-9]\d{6,14}$/,Xt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Qt=/*@__PURE__*/new RegExp(`^${Xt}$`);function en(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}var tn=/^-?\d+$/,nn=/^-?\d+(?:\.\d+)?$/,rn=/^(?:true|false)$/i,on=/^null$/i,an=/^[^A-Z]*$/,sn=/^[^a-z]*$/,cn=/*@__PURE__*/je("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ln={number:"number",bigint:"bigint",object:"date"},dn=/*@__PURE__*/je("$ZodCheckLessThan",(e,t)=>{cn.init(e,t);const n=ln[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),un=/*@__PURE__*/je("$ZodCheckGreaterThan",(e,t)=>{cn.init(e,t);const n=ln[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pn=/*@__PURE__*/je("$ZodCheckMultipleOf",(e,t)=>{cn.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value!==BigInt(0):0!==function(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(n.value,t.value))&&n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),hn=/*@__PURE__*/je("$ZodCheckNumberFormat",(e,t)=>{cn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=lt[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=tn)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/je("$ZodCheckMaxLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ve(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=ft(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fn=/*@__PURE__*/je("$ZodCheckMinLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ve(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=ft(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gn=/*@__PURE__*/je("$ZodCheckLengthEquals",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ve(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=ft(r),a=o>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yn=/*@__PURE__*/je("$ZodCheckStringFormat",(e,t)=>{var n,r;cn.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=/* @__PURE__ */new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),bn=/*@__PURE__*/je("$ZodCheckRegex",(e,t)=>{yn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wn=/*@__PURE__*/je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=an),yn.init(e,t)}),vn=/*@__PURE__*/je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=sn),yn.init(e,t)}),xn=/*@__PURE__*/je("$ZodCheckIncludes",(e,t)=>{cn.init(e,t);const n=at(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),kn=/*@__PURE__*/je("$ZodCheckStartsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`^${at(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),_n=/*@__PURE__*/je("$ZodCheckEndsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`.*${at(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Sn=/*@__PURE__*/je("$ZodCheckOverwrite",(e,t)=>{cn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),In=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},Cn={major:4,minor:4,patch:3},En=/*@__PURE__*/je("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cn;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let r,o=dt(e);for(const i of t){if(i._zod.def.when){if(ut(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new Fe;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(o||(o=dt(e,t)))});else{if(e.issues.length===t)continue;o||(o=dt(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(dt(n))return n.aborted=!0,n;const a=t(o,r,i);if(a instanceof Promise){if(!1===i.async)throw new Fe;return a.then(t=>e._zod.parse(t,i))}return e._zod.parse(a,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,i)):n(t,o,i)}const a=e._zod.parse(o,i);if(a instanceof Promise){if(!1===i.async)throw new Fe;return a.then(e=>t(e,r,i))}return t(a,r,i)}}Ke(e,"~standard",()=>({validate:t=>{try{const n=_t(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return It(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Tn=/*@__PURE__*/je("$ZodString",(e,t)=>{var n;En.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Mn=/*@__PURE__*/je("$ZodStringFormat",(e,t)=>{yn.init(e,t),Tn.init(e,t)}),zn=/*@__PURE__*/je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ut),Mn.init(e,t)}),An=/*@__PURE__*/je("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Bt(e))}else t.pattern??(t.pattern=Bt());Mn.init(e,t)}),On=/*@__PURE__*/je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wt),Mn.init(e,t)}),Nn=/*@__PURE__*/je("$ZodURL",(e,t)=>{Mn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Kt.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Rn=/*@__PURE__*/je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Mn.init(e,t)}),Ln=/*@__PURE__*/je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jt),Mn.init(e,t)}),$n=/*@__PURE__*/je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Rt),Mn.init(e,t)}),Dn=/*@__PURE__*/je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),Mn.init(e,t)}),Pn=/*@__PURE__*/je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$t),Mn.init(e,t)}),jn=/*@__PURE__*/je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Dt),Mn.init(e,t)}),Fn=/*@__PURE__*/je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Pt),Mn.init(e,t)}),Un=/*@__PURE__*/je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=en({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Xt}T(?:${r})$`)}(t)),Mn.init(e,t)}),Bn=/*@__PURE__*/je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qt),Mn.init(e,t)}),Wn=/*@__PURE__*/je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${en(t)}$`)),Mn.init(e,t)}),Hn=/*@__PURE__*/je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ft),Mn.init(e,t)}),Zn=/*@__PURE__*/je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ht),Mn.init(e,t),e._zod.bag.format="ipv4"}),qn=/*@__PURE__*/je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Zt),Mn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Vn=/*@__PURE__*/je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qt),Mn.init(e,t)}),Gn=/*@__PURE__*/je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Vt),Mn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Jn(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Kn=/*@__PURE__*/je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Gt),Mn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Jn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Yn=/*@__PURE__*/je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jt),Mn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Jt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Jn(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Yt),Mn.init(e,t)});var Qn=/*@__PURE__*/je("$ZodJWT",(e,t)=>{Mn.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),er=/*@__PURE__*/je("$ZodNumber",(e,t)=>{En.init(e,t),e._zod.pattern=e._zod.bag.pattern??nn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),tr=/*@__PURE__*/je("$ZodNumberFormat",(e,t)=>{hn.init(e,t),er.init(e,t)}),nr=/*@__PURE__*/je("$ZodBoolean",(e,t)=>{En.init(e,t),e._zod.pattern=rn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),rr=/*@__PURE__*/je("$ZodNull",(e,t)=>{En.init(e,t),e._zod.pattern=on,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const r=t.value;return null===r||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),t}}),or=/*@__PURE__*/je("$ZodUnknown",(e,t)=>{En.init(e,t),e._zod.parse=e=>e}),ir=/*@__PURE__*/je("$ZodNever",(e,t)=>{En.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ar=/*@__PURE__*/je("$ZodDate",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(a){}const o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function sr(e,t,n){e.issues.length&&t.issues.push(...pt(n,e.issues)),t.value[n]=e.value}var cr=/*@__PURE__*/je("$ZodArray",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const a=o[e],s=t.element._zod.run({value:a,issues:[]},r);s instanceof Promise?i.push(s.then(t=>sr(t,n,e))):sr(s,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function lr(e,t,n,r,o,i){const a=n in r;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...pt(n,e.issues))}a||o?void 0===e.value?a&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function dr(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ur(e,t,n,r,o,i){const a=[],s=o.keySet,c=o.catchall._zod,l=c.def.type,d="optional"===c.optin,u="optional"===c.optout;for(const p in t){if("__proto__"===p)continue;if(s.has(p))continue;if("never"===l){a.push(p);continue}const o=c.run({value:t[p],issues:[]},r);o instanceof Promise?e.push(o.then(e=>lr(e,n,p,t,d,u))):lr(o,n,p,t,d,u)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var pr=/*@__PURE__*/je("$ZodObject",(e,t)=>{if(En.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=qe(()=>dr(t));Ke(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */new Set);for(const e of r.values)n[t].add(e)}}return n});const r=tt,o=t.catchall;let i;e._zod.parse=(t,a)=>{i??(i=n.value);const s=t.value;if(!r(s))return t.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),t;t.value={};const c=[],l=i.shape;for(const e of i.keys){const n=l[e],r="optional"===n._zod.optin,o="optional"===n._zod.optout,i=n._zod.run({value:s[e],issues:[]},a);i instanceof Promise?c.push(i.then(n=>lr(n,t,e,s,r,o))):lr(i,t,e,s,r,o)}return o?ur(c,s,t,a,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),hr=/*@__PURE__*/je("$ZodObjectJIT",(e,t)=>{pr.init(e,t);const n=e._zod.parse,r=qe(()=>dr(t));let o;const i=tt,a=!Be.jitless,s=a&&nt.value,c=t.catchall;let l;e._zod.parse=(d,u)=>{l??(l=r.value);const p=d.value;return i(p)?a&&s&&!1===u?.async&&!0!==u.jitless?(o||(o=(e=>{const t=new In(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Qe(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let a=0;for(const r of n.keys)i[r]="key_"+a++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],a=Qe(r),s=e[r],c="optional"===s?._zod?.optin,l="optional"===s?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&l?t.write(`\n if (${n}.issues.length) {\n if (${a} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${a} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${a}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${a}] = undefined;\n } else {\n newResult[${a}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,n)=>s(e,t,n)})(t.shape)),d=o(d,u),c?ur([],p,d,u,l,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function mr(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter(e=>!dt(e));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>mt(e,r,We())))}),t)}var fr=/*@__PURE__*/je("$ZodUnion",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Ke(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Ke(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ke(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Ge(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>mr(t,r,e,o)):mr(a,r,e,o)}}),gr=/*@__PURE__*/je("$ZodIntersection",(e,t)=>{En.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>br(e,t,n)):br(e,o,i)}});function yr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(rt(e)&&rt(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const i of r){const n=yr(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=yr(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function br(e,t,n){const r=/* @__PURE__ */new Map;let o;for(const s of t.issues)if("unrecognized_keys"===s.code){o??(o=s);for(const e of s.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(s);for(const s of n.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(s);const i=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&o&&e.issues.push({...o,keys:i}),dt(e))return e;const a=yr(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var wr=/*@__PURE__*/je("$ZodRecord",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!rt(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const s=/* @__PURE__ */new Set;for(const l of a)if("string"==typeof l||"number"==typeof l||"symbol"==typeof l){s.add("number"==typeof l?l.toString():l);const a=t.keyType._zod.run({value:l,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>mt(e,r,We())),input:l,path:[l],inst:e});continue}const c=a.value,d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(e=>{e.issues.length&&n.issues.push(...pt(l,e.issues)),n.value[c]=e.value})):(d.issues.length&&n.issues.push(...pt(l,d.issues)),n.value[c]=d.value)}let c;for(const e in o)s.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(o,a))continue;let s=t.keyType._zod.run({value:a,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&nn.test(a)&&s.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>mt(e,r,We())),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:o[a],issues:[]},r);c instanceof Promise?i.push(c.then(e=>{e.issues.length&&n.issues.push(...pt(a,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...pt(a,c.issues)),n.value[s.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),vr=/*@__PURE__*/je("$ZodEnum",(e,t)=>{En.init(e,t);const n=He(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>it.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),xr=/*@__PURE__*/je("$ZodLiteral",(e,t)=>{if(En.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?at(e):e?at(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),kr=/*@__PURE__*/je("$ZodTransform",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ue(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new Fe;return n.value=o,n.fallback=!0,n}});function _r(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Sr=/*@__PURE__*/je("$ZodOptional",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ke(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ge(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>_r(e,r)):_r(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ir=/*@__PURE__*/je("$ZodExactOptional",(e,t)=>{Sr.init(e,t),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Cr=/*@__PURE__*/je("$ZodNullable",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.innerType._zod.optin),Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ge(e.source)}|null)$`):void 0}),Ke(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Er=/*@__PURE__*/je("$ZodDefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Tr(e,t)):Tr(r,t)}});function Tr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Mr=/*@__PURE__*/je("$ZodPrefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),zr=/*@__PURE__*/je("$ZodNonOptional",(e,t)=>{En.init(e,t),Ke(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>Ar(t,e)):Ar(o,e)}});function Ar(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Or=/*@__PURE__*/je("$ZodCatch",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mt(e,n,We()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mt(e,n,We()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Nr=/*@__PURE__*/je("$ZodPipe",(e,t)=>{En.init(e,t),Ke(e._zod,"values",()=>t.in._zod.values),Ke(e._zod,"optin",()=>t.in._zod.optin),Ke(e._zod,"optout",()=>t.out._zod.optout),Ke(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Rr(e,t.in,n)):Rr(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Rr(e,t.out,n)):Rr(r,t.out,n)}});function Rr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Lr=/*@__PURE__*/je("$ZodReadonly",(e,t)=>{En.init(e,t),Ke(e._zod,"propValues",()=>t.innerType._zod.propValues),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"optin",()=>t.innerType?._zod?.optin),Ke(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then($r):$r(r)}});function $r(e){return e.value=Object.freeze(e.value),e}var Dr,Pr=/*@__PURE__*/je("$ZodCustom",(e,t)=>{cn.init(e,t),En.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>jr(t,n,r,e));jr(o,n,r,e)}});function jr(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(gt(e))}}var Fr=class{constructor(){this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(Dr=globalThis).__zod_globalRegistry??(Dr.__zod_globalRegistry=new Fr);var Ur=globalThis.__zod_globalRegistry;function Br(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}function Wr(e,t){return new dn({check:"less_than",...ct(t),value:e,inclusive:!1})}function Hr(e,t){return new dn({check:"less_than",...ct(t),value:e,inclusive:!0})}function Zr(e,t){return new un({check:"greater_than",...ct(t),value:e,inclusive:!1})}function qr(e,t){return new un({check:"greater_than",...ct(t),value:e,inclusive:!0})}function Vr(e,t){return new pn({check:"multiple_of",...ct(t),value:e})}function Gr(e,t){return new mn({check:"max_length",...ct(t),maximum:e})}function Jr(e,t){return new fn({check:"min_length",...ct(t),minimum:e})}function Kr(e,t){return new gn({check:"length_equals",...ct(t),length:e})}function Yr(e){return new Sn({check:"overwrite",tx:e})}function Xr(e,t){const n=new cn({check:"custom",...ct(t)});return n._zod.check=e,n}function Qr(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ur,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:/* @__PURE__ */new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function eo(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,r);else{const n=a.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(a.ref||(a.ref=i),eo(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),"input"===t.io&&ro(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function to(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=/* @__PURE__ */new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const a=r.schema;for(const e in a)delete a[e];a.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const n=i[1];if(t!==i[0]){if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}(e.metadataRegistry.get(i[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}else o(i)}}function no(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},a=n.ref;if(n.ref=null,a){r(a);const n=e.seen.get(a),s=n.schema;if(!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,s):(o.allOf=o.allOf??[],o.allOf.push(s)),Object.assign(o,i),t._zod.parent===a)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(s.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const s=t._zod.parent;if(s&&s!==a){r(s);const t=e.seen.get(s);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?o.$defs=a:o.definitions=a);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:oo(t,"input",e.processors),output:oo(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(s){throw new Error("Error converting schema to JSON.")}}function ro(e,t){const n=t??{seen:/* @__PURE__ */new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return ro(r.element,n);if("set"===r.type)return ro(r.valueType,n);if("lazy"===r.type)return ro(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return ro(r.innerType,n);if("intersection"===r.type)return ro(r.left,n)||ro(r.right,n);if("record"===r.type||"map"===r.type)return ro(r.keyType,n)||ro(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(ro(r.in,n)||ro(r.out,n));if("object"===r.type){for(const e in r.shape)if(ro(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(ro(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(ro(e,n))return!0;return!(!r.rest||!ro(r.rest,n))}return!1}var oo=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=Qr({...o??{},target:i,io:t,processors:n});return eo(e,a),to(a,e),no(a,e)},io={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ao=(e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r);t.seen.get(e).ref=o.innerType},so=/*@__PURE__*/je("ZodISODateTime",(e,t)=>{Un.init(e,t),$o.init(e,t)});function co(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}(so,e)}var lo=/*@__PURE__*/je("ZodISODate",(e,t)=>{Bn.init(e,t),$o.init(e,t)});function uo(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}(lo,e)}var po=/*@__PURE__*/je("ZodISOTime",(e,t)=>{Wn.init(e,t),$o.init(e,t)});function ho(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}(po,e)}var mo=/*@__PURE__*/je("ZodISODuration",(e,t)=>{Hn.init(e,t),$o.init(e,t)});function fo(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}(mo,e)}var go=(e,t)=>{bt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e},[...o,...i.path]));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))),r=r[n],o++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ze,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ze,2)}},isEmpty:{get:()=>0===e.issues.length}})},yo=/*@__PURE__*/je("ZodError",go,{Parent:Error}),bo=/* @__PURE__ */vt(yo),wo=/* @__PURE__ */xt(yo),vo=/* @__PURE__ */kt(yo),xo=/* @__PURE__ */St(yo),ko=/* @__PURE__ */Ct(yo),_o=/* @__PURE__ */Et(yo),So=/* @__PURE__ */Tt(yo),Io=/* @__PURE__ */Mt(yo),Co=/* @__PURE__ */zt(yo),Eo=/* @__PURE__ */At(yo),To=/* @__PURE__ */Ot(yo),Mo=/* @__PURE__ */Nt(yo),zo=/* @__PURE__ */new WeakMap;function Ao(e,t,n){const r=Object.getPrototypeOf(e);let o=zo.get(r);if(o||(o=/* @__PURE__ */new Set,zo.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Oo=/*@__PURE__*/je("ZodType",(e,t)=>(En.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:oo(e,"input"),output:oo(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Qr({...n,processors:t});return eo(e,r),to(r,e),no(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>bo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>vo(e,t,n),e.parseAsync=async(t,n)=>wo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ko(e,t,n),e.decode=(t,n)=>_o(e,t,n),e.encodeAsync=async(t,n)=>So(e,t,n),e.decodeAsync=async(t,n)=>Io(e,t,n),e.safeEncode=(t,n)=>Co(e,t,n),e.safeDecode=(t,n)=>Eo(e,t,n),e.safeEncodeAsync=async(t,n)=>To(e,t,n),e.safeDecodeAsync=async(t,n)=>Mo(e,t,n),Ao(e,"ZodType",{check(...e){const t=this.def;return this.clone(Xe(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return st(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ct(n)})}(ji,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */Xr(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(gt(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(gt(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(Yr(e))},optional(){return Ti(this)},exactOptional(){return new Mi({type:"optional",innerType:this})},nullable(){return Ai(this)},nullish(){return Ti(Ai(this))},nonoptional(e){return function(e,t){return new Ri({type:"nonoptional",innerType:e,...ct(t)})}(this,e)},array(){return fi(this)},or(e){return wi([this,e])},and(e){return new vi({type:"intersection",left:this,right:e})},transform(e){return Di(this,new Ci({type:"transform",transform:e}))},default(e){return t=e,new Oi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},prefault(e){return t=e,new Ni({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},catch(e){return new Li({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Di(this,e)},readonly(){return new Pi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Ur.add(t,{description:e}),t},meta(...e){if(0===e.length)return Ur.get(this);const t=this.clone();return Ur.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>Ur.get(e)?.description,configurable:!0}),e)),No=/*@__PURE__*/je("_ZodString",(e,t)=>{Tn.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:a,patterns:s,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),a&&(r.format=io[a]??a,""===r.format&&delete r.format,"time"===a&&delete r.format),c&&(r.contentEncoding=c),s&&s.size>0){const e=[...s];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ao(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new bn({check:"string_format",format:"regex",...ct(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new xn({check:"string_format",format:"includes",...ct(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new kn({check:"string_format",format:"starts_with",...ct(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new _n({check:"string_format",format:"ends_with",...ct(t),suffix:e})}(...e))},min(...e){return this.check(Jr(...e))},max(...e){return this.check(Gr(...e))},length(...e){return this.check(Kr(...e))},nonempty(...e){return this.check(Jr(1,...e))},lowercase(e){return this.check(function(e){return new wn({check:"string_format",format:"lowercase",...ct(e)})}(e))},uppercase(e){return this.check(function(e){return new vn({check:"string_format",format:"uppercase",...ct(e)})}(e))},trim(){return this.check(/* @__PURE__ */Yr(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
|
|
2
|
-
return Yr(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */Yr(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */Yr(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */Yr(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Ro=/*@__PURE__*/je("ZodString",(e,t)=>{Tn.init(e,t),No.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ct(t)})}(Do,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(Fo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(ti,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(Uo,t)),e.guid=t=>e.check(Br(Po,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(jo,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ct(t)})}(jo,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ct(t)})}(jo,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ct(t)})}(jo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(Bo,t)),e.guid=t=>e.check(Br(Po,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(Wo,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(Ho,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(Zo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(Xo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(Qo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(qo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(Vo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(Go,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(Jo,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(Ko,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(Yo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(ei,t)),e.datetime=t=>e.check(co(t)),e.date=t=>e.check(uo(t)),e.time=t=>e.check(ho(t)),e.duration=t=>e.check(fo(t))});function Lo(e){return function(e,t){return new e({type:"string",...ct(t)})}(Ro,e)}var $o=/*@__PURE__*/je("ZodStringFormat",(e,t)=>{Mn.init(e,t),No.init(e,t)}),Do=/*@__PURE__*/je("ZodEmail",(e,t)=>{On.init(e,t),$o.init(e,t)}),Po=/*@__PURE__*/je("ZodGUID",(e,t)=>{zn.init(e,t),$o.init(e,t)}),jo=/*@__PURE__*/je("ZodUUID",(e,t)=>{An.init(e,t),$o.init(e,t)}),Fo=/*@__PURE__*/je("ZodURL",(e,t)=>{Nn.init(e,t),$o.init(e,t)}),Uo=/*@__PURE__*/je("ZodEmoji",(e,t)=>{Rn.init(e,t),$o.init(e,t)}),Bo=/*@__PURE__*/je("ZodNanoID",(e,t)=>{Ln.init(e,t),$o.init(e,t)}),Wo=/*@__PURE__*/je("ZodCUID",(e,t)=>{$n.init(e,t),$o.init(e,t)}),Ho=/*@__PURE__*/je("ZodCUID2",(e,t)=>{Dn.init(e,t),$o.init(e,t)}),Zo=/*@__PURE__*/je("ZodULID",(e,t)=>{Pn.init(e,t),$o.init(e,t)}),qo=/*@__PURE__*/je("ZodXID",(e,t)=>{jn.init(e,t),$o.init(e,t)}),Vo=/*@__PURE__*/je("ZodKSUID",(e,t)=>{Fn.init(e,t),$o.init(e,t)}),Go=/*@__PURE__*/je("ZodIPv4",(e,t)=>{Zn.init(e,t),$o.init(e,t)}),Jo=/*@__PURE__*/je("ZodIPv6",(e,t)=>{qn.init(e,t),$o.init(e,t)}),Ko=/*@__PURE__*/je("ZodCIDRv4",(e,t)=>{Vn.init(e,t),$o.init(e,t)}),Yo=/*@__PURE__*/je("ZodCIDRv6",(e,t)=>{Gn.init(e,t),$o.init(e,t)}),Xo=/*@__PURE__*/je("ZodBase64",(e,t)=>{Kn.init(e,t),$o.init(e,t)}),Qo=/*@__PURE__*/je("ZodBase64URL",(e,t)=>{Yn.init(e,t),$o.init(e,t)}),ei=/*@__PURE__*/je("ZodE164",(e,t)=>{Xn.init(e,t),$o.init(e,t)}),ti=/*@__PURE__*/je("ZodJWT",(e,t)=>{Qn.init(e,t),$o.init(e,t)}),ni=/*@__PURE__*/je("ZodNumber",(e,t)=>{er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:i,format:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l}=e._zod.bag;"string"==typeof a&&a.includes("int")?r.type="integer":r.type="number";const d="number"==typeof l&&l>=(o??Number.NEGATIVE_INFINITY),u="number"==typeof c&&c<=(i??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof o&&(r.minimum=o),u?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof i&&(r.maximum=i),"number"==typeof s&&(r.multipleOf=s)})(e,t,n),Ao(e,"ZodNumber",{gt(e,t){return this.check(Zr(e,t))},gte(e,t){return this.check(qr(e,t))},min(e,t){return this.check(qr(e,t))},lt(e,t){return this.check(Wr(e,t))},lte(e,t){return this.check(Hr(e,t))},max(e,t){return this.check(Hr(e,t))},int(e){return this.check(ii(e))},safe(e){return this.check(ii(e))},positive(e){return this.check(Zr(0,e))},nonnegative(e){return this.check(qr(0,e))},negative(e){return this.check(Wr(0,e))},nonpositive(e){return this.check(Hr(0,e))},multipleOf(e,t){return this.check(Vr(e,t))},step(e,t){return this.check(Vr(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ri(e){return function(e,t){return new e({type:"number",checks:[],...ct(t)})}(ni,e)}var oi=/*@__PURE__*/je("ZodNumberFormat",(e,t)=>{tr.init(e,t),ni.init(e,t)});function ii(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(oi,e)}var ai=/*@__PURE__*/je("ZodBoolean",(e,t)=>{nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function si(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(ai,e)}var ci=/*@__PURE__*/je("ZodNull",(e,t)=>{rr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{"openapi-3.0"===t.target?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"})(0,e,t)});var li=/*@__PURE__*/je("ZodUnknown",(e,t)=>{or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function di(){return new li({type:"unknown"})}var ui=/*@__PURE__*/je("ZodNever",(e,t)=>{ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function pi(e){return function(e,t){return new e({type:"never",...ct(t)})}(ui,e)}var hi=/*@__PURE__*/je("ZodDate",(e,t)=>{ar.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,n)=>e.check(qr(t,n)),e.max=(t,n)=>e.check(Hr(t,n));const n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null}),mi=/*@__PURE__*/je("ZodArray",(e,t)=>{cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(o.minItems=a),"number"==typeof s&&(o.maxItems=s),o.type="array",o.items=eo(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Ao(e,"ZodArray",{min(e,t){return this.check(Jr(e,t))},nonempty(e){return this.check(Jr(1,e))},max(e,t){return this.check(Gr(e,t))},length(e,t){return this.check(Kr(e,t))},unwrap(){return this.element}})});function fi(e,t){return function(e,t,n){return new e({type:"array",element:t,...ct(n)})}(mi,e,t)}var gi=/*@__PURE__*/je("ZodObject",(e,t)=>{hr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const l in a)o.properties[l]=eo(a[l],t,{...r,path:[...r.path,"properties",l]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=eo(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),Ke(e,"shape",()=>t.shape),Ao(e,"ZodObject",{keyof(){return Si(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:di()})},loose(){return this.clone({...this._zod.def,catchall:di()})},strict(){return this.clone({...this._zod.def,catchall:pi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!rt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Ye(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!rt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Ye(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Ye(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return st(e,Xe(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ye(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return st(e,Xe(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ye(this,"shape",r),r},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return st(t,Xe(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Ye(this,"shape",o),o},checks:[]}))}(Ei,this,e[0])},required(...e){return t=Ri,n=this,r=e[0],st(n,Xe(n._zod.def,{get shape(){const e=n._zod.def.shape,o={...e};if(r)for(const n in r){if(!(n in o))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(o[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)o[n]=new t({type:"nonoptional",innerType:e[n]});return Ye(this,"shape",o),o}}));var t,n,r}})});function yi(e,t){return new gi({type:"object",shape:e??{},...ct(t)})}var bi=/*@__PURE__*/je("ZodUnion",(e,t)=>{fr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,a=o.options.map((e,n)=>eo(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=a:n.anyOf=a})(e,t,n,r),e.options=t.options});function wi(e,t){return new bi({type:"union",options:e,...ct(t)})}var vi=/*@__PURE__*/je("ZodIntersection",(e,t)=>{gr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=eo(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=eo(o.right,t,{...r,path:[...r.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]})(e,t,n,r)});var xi=/*@__PURE__*/je("ZodRecord",(e,t)=>{wr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,s=a._zod.bag?.patterns;if("loose"===i.mode&&s&&s.size>0){const e=eo(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of s)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=eo(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=eo(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=a._zod.values;if(c){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(o.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ki(e,t,n){return t&&t._zod?new xi({type:"record",keyType:e,valueType:t,...ct(n)}):new xi({type:"record",keyType:Lo(),valueType:e,...ct(t)})}var _i=/*@__PURE__*/je("ZodEnum",(e,t)=>{vr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=He(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new _i({...t,checks:[],...ct(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new _i({...t,checks:[],...ct(r),entries:o})}});function Si(e,t){return new _i({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ct(t)})}var Ii=/*@__PURE__*/je("ZodLiteral",(e,t)=>{xr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,o=[];for(const i of r.values)if(void 0===i){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof i){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(i))}else o.push(i);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});var Ci=/*@__PURE__*/je("ZodTransform",(e,t)=>{kr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ue(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(gt(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(gt(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});var Ei=/*@__PURE__*/je("ZodOptional",(e,t)=>{Sr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ti(e){return new Ei({type:"optional",innerType:e})}var Mi=/*@__PURE__*/je("ZodExactOptional",(e,t)=>{Ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var zi=/*@__PURE__*/je("ZodNullable",(e,t)=>{Cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=eo(o.innerType,t,r),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ai(e){return new zi({type:"nullable",innerType:e})}var Oi=/*@__PURE__*/je("ZodDefault",(e,t)=>{Er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Ni=/*@__PURE__*/je("ZodPrefault",(e,t)=>{Mr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Ri=/*@__PURE__*/je("ZodNonOptional",(e,t)=>{zr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Li=/*@__PURE__*/je("ZodCatch",(e,t)=>{Or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var $i=/*@__PURE__*/je("ZodPipe",(e,t)=>{Nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a="input"===t.io?i?o.out:o.in:o.out;eo(a,t,r),t.seen.get(e).ref=a})(e,t,0,r),e.in=t.in,e.out=t.out});function Di(e,t){return new $i({type:"pipe",in:e,out:t})}var Pi=/*@__PURE__*/je("ZodReadonly",(e,t)=>{Lr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var ji=/*@__PURE__*/je("ZodCustom",(e,t)=>{Pr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Fi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...ct(t)})}(ni,e)}function Ui(e){return function(e,t){return new e({type:"date",coerce:!0,...ct(t)})}(hi,e)}var Bi,Wi,Hi=Si(["created","active","suspended","pending_approval"]),Zi=yi({id:ri().optional(),created_at:Ui().optional(),updated_at:Ui().optional()}),qi=(yi({id:Fi()}),yi({slug:Lo()}),yi({widget_id:Fi()}),yi({simulation_id:Fi()}),yi({application_id:Fi()}),yi({user_id:Fi()}),yi({limit:Fi().optional().default(50),offset:Fi().optional().default(0)}),wi([Lo(),ri(),si(),fi(Lo()),function(e,t){return new e({type:"null",...ct(t)})}(ci,Bi)]),yi({type:Si(["doc","sim","session"]),id:Lo(),label:Lo()}),yi({success:function(e,t){return new Ii({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}(!0)})),Vi=(qi.extend({message:Lo()}),yi({name:Lo().min(1),params:ki(Lo(),di()).default({}),result:ki(Lo(),di()).default({})}),Lo().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),yi({start:Lo(),end:Lo(),action:Lo()}).passthrough()),Gi=yi({id:Lo(),label:Lo(),purpose:Lo(),elements:fi(ki(Lo(),di())).default([]),bbox:ki(Lo(),di()).default({}),screenshot:Lo().default(""),embedding:fi(ri()).nullish()}).passthrough(),Ji=yi({id:Lo(),title:Lo(),url:Lo(),summary:Lo().default(""),screenshot:Lo().default(""),sections:fi(Gi).default([]),sequence_ids:fi(ri()).default([]),embedding:fi(ri()).nullish()}).passthrough(),Ki=(yi({nodes:fi(Ji),edges:fi(Vi)}),yi({skill_id:ri().int(),params:ki(Lo(),Lo())}),Si(["free","startup","growth","enterprise"])),Yi=Si(["document","video"]),Xi=Si(["user","research"]),Qi=(Si(["pending","processing","waiting_review","completed","failed"]),Si(["queued","running","creating_knowledge","has_question","completed","failed","stopped"])),ea=Si(["pending","generating","completed","failed"]),ta=Si(["app","website"]),na=Si(["widget"]),ra=(Si(["tell","show","do"]),Si(["password","oauth"])),oa=(Zi.extend({is_super:si(),status:Hi,email:Lo().email(),external_id:Lo().nullish(),first_name:Lo().nullish(),last_name:Lo().nullish(),password:Lo().nullish(),image_url:Lo().nullish(),prompt_limit:ri().nullish(),last_login_at:Ui().nullish(),auth_method:ra.nullish()}).partial().extend({email:Lo().email(),password:Lo()}),Zi.extend({name:Lo(),slug:Lo(),status:Hi,package:Ki,ending_date:Ui().nullish(),external_workspace_id:Lo().nullish(),slack_webhook_configured:si().optional(),notify_all_members_on_question:si().optional()}),Zi.extend({workspace_id:ri(),application_id:ri().optional(),file_name:Lo().min(1),file_size:Fi(),file_type:Yi,file_url:Lo(),source_url:Lo().nullish(),source:Xi.default("user").optional()}),Si(["passed","needs_healing","failed"]),yi({ultimate_goal:Lo(),test_cases:fi(yi({test_title:Lo(),test_objective:Lo(),test_steps:fi(Lo()),expected_outcome:Lo(),priority:Si(["Low","Medium","High"])})),summary:yi({total_tests:ri(),high_priority:ri(),medium_priority:ri(),low_priority:ri(),estimated_time_minutes:ri()})}),yi({task_id:Lo(),condition:Si(["pass"]).optional()})),ia=yi({task_id:Lo(),title:Lo(),instructions:Lo(),status:Si(["pending","running","has_question","passed","failed","skipped","stopped"]),error_message:Lo().nullish(),started_at:Lo().nullish(),completed_at:Lo().nullish(),order_index:ri().int().nonnegative().default(0),tab_id:Lo().nullish(),step_count:ri().int().nonnegative().default(0),blocked_by:fi(oa).default([])}),aa=(Zi.extend({application_id:ri(),job_id:Lo(),browser_session_id:Lo().nullish(),status:Qi,status_message:Lo().nullish(),path:Lo().nullish(),instructions:Lo().nullish(),pinned:si().optional(),source:Si(["direct","qa"]).optional(),graph_id:Lo().nullish(),source_metadata:ki(Lo(),di()).nullish(),tasks:fi(ia).optional(),graph_status:ea.optional(),graph_steps_processed:ri().int().nonnegative().optional(),graph_steps_total:ri().int().nonnegative().optional(),graph_error:Lo().nullish(),created_by_user_id:ri().nullish(),persona_id:ri().nullish(),has_question:si().optional()}),Zi.extend({workspace_id:ri(),name:Lo(),slug:Lo(),type:ta,url:Lo().nullish(),username:Lo().nullish(),password:Lo().nullish(),allowed_domains:fi(Lo()).nullish().default([])}).omit({password:!0}),yi({chip_mode:Si(["show","tell","do"]),chip_text:Lo()})),sa=yi({widget_enabled:si(),widget_appearance:Si(["default","compact","full"]),widget_position:Si(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Si(["desktop","mobile","desktop_mobile"]),widget_header:Lo(),widget_body:Lo(),widget_greeting:Lo(),widget_feature_tell:si(),widget_feature_show:si(),widget_feature_do:si(),widget_feature_human:si(),widget_background_color:Lo(),widget_text_color:Lo(),widget_border_color:Lo(),widget_accent_color:Lo(),widget_secondary_color:Lo(),widget_border_radius:Lo(),widget_font_size:Lo(),widget_width:Lo(),widget_height:Lo(),widget_shadow:Lo(),widget_animation_duration:Lo(),widget_fade_duration:Lo(),widget_bounce_effect:si(),widget_chips:fi(aa)}),ca=(Zi.extend({application_id:ri(),type:na,settings:sa,status:Hi,marketrix_id:Lo(),marketrix_key:Lo(),snippet:Lo().nullish()}),Zi.extend({widget_id:ri(),url_pattern:Lo(),message:fi(Lo()),description:Lo().optional()}),Si(["pending","running","completed","failed","stopped"]),Si(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_application","update_application","delete_application","create_widget","update_widget","delete_widget","create_knowledge","update_knowledge","delete_knowledge","approve_user","deny_user","request_workspace","widget_question","qa_run_started","start_simulation","create_automation","update_automation","delete_automation","toggle_automation","slack_command"])),la=yi({details:Lo().optional(),id:ri().optional(),type:Lo().optional(),name:Lo().optional(),target_user_id:ri().optional(),target_user_email:Lo().optional(),reason:Lo().optional(),assigned_role:Lo().optional(),new_role:Lo().optional(),previous_role:Lo().optional(),workspace_name:Lo().optional(),workspace_slug:Lo().optional(),ip_address:Lo().optional(),user_agent:Lo().optional(),widget_type:Lo().optional(),created_by:ri().optional()}).passthrough(),da=(Zi.extend({workspace_id:ri(),user_id:ri(),type:ca,metadata:la.optional()}).partial().extend({type:ca}),yi({user_id:ri(),limit:ri(),used:ri(),remaining:ri()}),yi({description:Lo(),selected:si(),simulation_id:ri().nullable().optional(),task_id:Lo().nullable().optional(),status:Qi.nullable().optional()}),null),ua="";function pa(e){return ge(new Pe({url:e,headers:()=>{const e={};return da&&(e.Authorization=`Bearer ${da}`),e}}))}Wi=pa("");var ha=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ua&&(ua=e,Wi=pa(e))},ma={setAuthToken:e=>{da=e},clearAuthToken:()=>{da=null},getAuthToken:()=>da,configure:ha},fa=new Proxy({},{get:(e,t)=>t in ma?ma[t]:Wi[t]}),ga="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",ya={debug:0,info:1,warn:2,error:3};function ba(e){return ya[e]>=ya[ga]}function wa(e){return{debug:(e,...t)=>{ba("debug")},info:(e,...t)=>{ba("info")},warn:(e,...t)=>{ba("warn")},error:(e,...t)=>{ba("error")}}}var va=[{id:"navigate",name:"Navigate",description:"Navigate to a URL",displayAction:"Navigating",category:"navigation",actionType:"navigate"},{id:"search",name:"Search",description:"Search the web using a search engine",displayAction:"Searching",category:"navigation",actionType:"search"},{id:"click_element",name:"Click Element",description:"Click on an element by index or coordinates",displayAction:"Clicking element",category:"interaction",actionType:"click_element"},{id:"type_text",name:"Type Text",description:"Type text into an input field",displayAction:"Typing text",category:"interaction",actionType:"type_text"},{id:"scroll",name:"Scroll",description:"Scroll the page up or down",displayAction:"Scrolling",category:"interaction",actionType:"scroll"},{id:"scroll_to_text",name:"Scroll to Text",description:"Scroll until text is visible",displayAction:"Scrolling to text",category:"interaction",actionType:"scroll_to_text"},{id:"send_keys",name:"Send Keys",description:"Send keyboard keys or shortcuts",displayAction:"Pressing key",category:"interaction",actionType:"send_keys"},{id:"extract",name:"Extract",description:"Extract content from the page",displayAction:"Extracting content",category:"extraction",actionType:"extract"},{id:"get_dropdown_options",name:"Get Dropdown Options",description:"Get available options from a dropdown",displayAction:"Reading dropdown options",category:"extraction",actionType:"get_dropdown_options"},{id:"select_dropdown_option",name:"Select Dropdown Option",description:"Select an option from a dropdown",displayAction:"Selecting option",category:"interaction",actionType:"select_dropdown_option"},{id:"upload_file",name:"Upload File",description:"Upload a file to an input field",displayAction:"Uploading file",category:"interaction",actionType:"upload_file"},{id:"go_back",name:"Go Back",description:"Browser back button",displayAction:"Going back",category:"navigation",actionType:"go_back"},{id:"wait",name:"Wait",description:"Wait for a specified duration",displayAction:"Waiting",category:"utility",actionType:"wait"},{id:"switch_tab",name:"Switch Tab",description:"Switch to a different browser tab",displayAction:"Switching tab",category:"utility",actionType:"switch_tab"},{id:"close_tab",name:"Close Tab",description:"Close the current browser tab",displayAction:"Closing tab",category:"utility",actionType:"close_tab"},{id:"done",name:"Done",description:"Mark task as complete",displayAction:"Done",category:"utility",actionType:"done"},{id:"get_html",name:"Get HTML",description:"Get full page HTML with data-id attributes",displayAction:"Viewed your screen",category:"extraction",actionType:"get_html"},{id:"get_interactable_elements",name:"Get Interactable Elements",description:"Get list of interactable elements",displayAction:"Scanning elements",category:"extraction",actionType:"get_interactable_elements"},{id:"get_screenshot",name:"Get Screenshot",description:"Capture a screenshot of the page",displayAction:"Taking screenshot",category:"extraction",actionType:"get_screenshot"}];function xa(e){return e.includes("__THINKING__")}function ka(e){return xa(e)?e:`${e}\n\n__THINKING__`}function _a(e,t,n,r,o){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(o&&t&&("show"===n||"do"===n))if(e.isPlaceholder){if(void 0!==e.mode&&e.mode!==n)return!1}else if(e.mode!==n)return!1;if(r){const t=e.content.trim().length>0,n=e.parts&&e.parts.length>0;if(!t&&!n)return!1}return!0}function Sa(e){const{messages:t,isTaskRunning:n,currentMode:r,requireContent:o}=e;let i=-1;if(n&&("show"===r||"do"===r)){const e=!0;for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder,d=!o||s.content.trim().length>0||s.parts&&s.parts.length>0;if(c&&l&&d){i=a;break}}if(i<0&&!o)for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder;if(c&&l){i=a;break}}if(i<0)for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder;if(c&&!l){i=a;break}}}if(i<0){for(let e=t.length-1;e>=0;e--){const n=t[e],r="agent"===n.sender,a=n.isPlaceholder,s=!n.isSystemMessage,c=!n.isScreenAccessRequest,l=!o||n.content.trim().length>0||n.parts&&n.parts.length>0;if(r&&a&&s&&c&&l){i=e;break}}if(i<0&&!o)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&n.isPlaceholder&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}if(i<0&&(i=function(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest&&!n.isPlaceholder)return t}return-1}(t)),i<0)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}}return i>=0?{index:i,message:t[i]}:null}function Ia(e){const t={...e};if(!t.parts){t.parts=[];const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts.push({type:"text",content:e})}return t}var Ca=new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Ea=new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function Ta(e){return e?e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\(cancelled by cleanup\)/gi,"").replace(/Cancelled by cleanup/gi,"").replace(/\s+/g," ").trim():e}function Ma(e,t,n,r=!1){const o=Ia(e);if(!t||"show"!==n&&"do"!==n)return xa(o.content)?{...o,content:o.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:o;const i=r?"waiting-for-user":"thinking";return xa(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:ka(o.content),placeholderState:i}}var za=Object.fromEntries(va.map(e=>[e.id,e.displayAction]));var Aa="marketrix_chat_context",Oa={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Na=class e{static instance;context=null;constructor(){this.loadContext()}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadContext(){if("undefined"==typeof window)return this.context={...Oa},this.context;try{const e=localStorage.getItem(Aa);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Oa},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Oa},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Aa,JSON.stringify(this.context))}catch(e){}}getContext(){return this.context?this.context:this.loadContext()}updateContext(e){this.context||this.loadContext();const t=this.context;this.context={...t,...e},this.saveContext()}isValidChatId(e){return"string"==typeof e&&""!==e.trim()}getChatId(){if("undefined"!=typeof window&&this.isValidChatId(window.name)){const e=window.name;return e!==this.getContext().chat_id&&this.updateContext({chat_id:e}),e}return this.getContext().chat_id}setChatId(e){this.updateContext({chat_id:e}),"undefined"!=typeof window&&e&&(window.name=e,window.dispatchEvent(new CustomEvent("marketrix:chatid",{detail:{chatId:e}})))}getMessages(){return this.getContext().messages}setMessages(e){this.updateContext({messages:e})}getChatState(){const e=this.getContext();return{isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading}}setChatState(e){this.updateContext(e)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}clear(){this.context={...Oa},"undefined"!=typeof window&&localStorage.removeItem(Aa)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Ra=class e{static instance;chatId=null;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e}createInitialContext(e){try{if(Na.hasValidContext())return;Na.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}restore(){const e=Na.getContext();return{messages:e.chat_id?e.messages.map(e=>{if(e.id.startsWith("screenshare-"))return{...e,content:"Screenshare ended",videoStream:void 0,isSystemMessage:!0,timestamp:new Date(e.timestamp),parts:[{type:"text",content:"Screenshare ended"}]};const t={...e,timestamp:new Date(e.timestamp),videoStream:void 0,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts||[]};if(0===t.parts?.length&&t.content){const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts&&t.parts.push({type:"text",content:e})}return t}):[],isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading??!1}}persist(e){if(this.chatId)try{const t=e.messages.filter(e=>!e.isPlaceholder||("thinking"===e.placeholderState||"waiting-for-user"===e.placeholderState||(e.parts||[]).length>0)).filter(e=>!(e.isSystemMessage&&"Chat context changed"===e.content)).map(e=>{return{id:e.id,content:(t=e.content,t.replace(/__THINKING__/g,"")),sender:e.sender,timestamp:e.timestamp.toISOString(),mode:e.mode,isScreenAccessRequest:e.isScreenAccessRequest,screenShareStatus:e.screenShareStatus,isSystemMessage:e.isSystemMessage,isPlaceholder:e.isPlaceholder,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts};var t});Na.updateContext({chat_id:this.chatId,messages:t,isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading})}catch(t){}}}.getInstance();function La(e,t,n="user-message"){const r=[],o=e.trim();return o&&r.push({type:"text",content:o}),{id:`${n}-${Date.now()}`,content:o,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:r}}function $a(e,t,n,r="agent-message"){const o=[],i=e.trim();return i&&o.push({type:"text",content:i}),{id:n||`${r}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:o}}function Da(e,t,n="agent",r="system-message"){const o=[];return e&&o.push({type:"text",content:e}),{id:`${r}-${Date.now()}`,content:e,sender:n,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:o}}function Pa(e="show"){const t="Started screenshare";return{id:`started-screenshare-${Date.now()}`,content:t,sender:"user",timestamp:/* @__PURE__ */new Date,mode:e,isSystemMessage:!0,parts:[{type:"text",content:t}]}}function ja(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Fa=wa(),Ua=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Fa.debug("Loaded existing chat ID from storage:",this.chatId))}static getInstance(){return"undefined"==typeof window||"undefined"==typeof document?(e.instance||(e.instance=Object.create(e.prototype),e.instance.chatId=null,e.instance.initializationPromise=null),e.instance):(e.instance||(e.instance=new e),e.instance)}getChatId(){return this.chatId}async getOrCreateChatId(){if(this.chatId)return Fa.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Fa.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Fa.debug("Found chat ID in storage:",this.chatId),this.chatId;this.initializationPromise=this.createChatId();try{return await this.initializationPromise}finally{this.initializationPromise=null}}async createChatId(){try{Fa.info("Creating new chat ID...");const e=await fa.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Fa.info("Created and stored new chat ID:",this.chatId),Ra.createInitialContext(e),e}catch(e){throw Fa.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Na.getChatId()}storeChatId(e){Na.setChatId(e)}}.getInstance(),Ba=class e{static instance=null;abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;isIntentionallyDisconnected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;config;connectionId=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}getStatus(){return this.status}isConnected(){return"registered"===this.status}async connect(e,t){if(this.isIntentionallyDisconnected&&(this.isIntentionallyDisconnected=!1),this.isConnected()&&this.chatId===e)return;this.abortController&&(this.abortController.abort(),this.abortController=null),this.chatId=e,t&&(this.config=t),this.setStatus("connecting");const n=++this.connectionId;this.abortController=new AbortController;const r=this.abortController.signal;try{const t={chat_id:e};this.config?.mtxId&&this.config?.mtxKey?(t.marketrix_id=this.config.mtxId,t.marketrix_key=this.config.mtxKey):this.config?.mtxApp&&(t.application_id=this.config.mtxApp);const o=await fa.widgetStream(t,{signal:r});this.setStatus("connected"),this.consumeEvents(o,n)}catch(o){r.aborted||(this.setStatus("error"),this.notifyError(/* @__PURE__ */new Error("Stream connection failed")),this.scheduleReconnect())}}async consumeEvents(e,t){let n=!1;try{for await(const r of e){if(this.connectionId!==t){n=!0;break}this.handleMessage(r)}}catch(r){this.connectionId!==t?n=!0:this.isIntentionallyDisconnected||this.setStatus("error")}finally{n||this.connectionId!==t||this.isIntentionallyDisconnected||(this.setStatus("disconnected"),this.scheduleReconnect())}}disconnect(){this.isIntentionallyDisconnected=!0,this.clearReconnectTimer(),this.abortController&&(this.abortController.abort(),this.abortController=null),this.setStatus("disconnected"),this.chatId=null}send(e){return this.chatId?fa.widgetMessage({chat_id:this.chatId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${String(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(t=>t.onStatusChange?.(e)))}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}handleMessage(e){this.isIntentionallyDisconnected||"heartbeat"!==e.type&&("registered"===e.type&&e.chat_id===this.chatId&&(this.setStatus("registered"),this.reconnectAttempts=0,this.reconnectDelay=1e3,this.callbacks.forEach(t=>t.onRegistered?.(e.application_id))),"chat/error"===e.type&&"auth"===e.request_id&&(this.isIntentionallyDisconnected=!0),this.callbacks.forEach(t=>t.onMessage?.(e)))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.notifyError(/* @__PURE__ */new Error("Max reconnect attempts reached"));this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.isIntentionallyDisconnected&&this.chatId&&this.connect(this.chatId,this.config).catch(console.error)},e)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}},Wa=class{config;constructor(e){this.config=e}getChatId(){return Ua.getChatId()}getUserId(){if(this.config.userId&&"number"==typeof this.config.userId)return this.config.userId;try{const e=localStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}try{const e=sessionStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}return null}async logWidgetQuestion(e,t){try{const n=this.getUserId(),r={question:e,mode:t,chat_id:this.getChatId(),timestamp:/* @__PURE__ */(new Date).toISOString()};null!==n&&(r.user_id=n),this.config.mtxApp&&(r.application_id=this.config.mtxApp),this.config.mtxId&&this.config.mtxKey&&(r.marketrix_id=this.config.mtxId,r.marketrix_key=this.config.mtxKey),fa.activityLogCreate({type:"widget_question",metadata:r}).catch(e=>{})}catch(n){}}async sendMessage(e){if(!(await Ua.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const t=e.mode||"tell";if(e.message&&await this.logWidgetQuestion(e.message,t),!(this.config.mtxId&&this.config.mtxKey||this.config.mtxApp))throw new Error("Either mtxId + mtxKey or mtxApp is required");const n=e.requestId||`req_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,r={type:`chat/${t}`,request_id:n,content:e.message||""};return Ba.getInstance().send(r),{messageId:n,response:"",mode:t,timestamp:/* @__PURE__ */new Date}}updateConfig(e){this.config={...this.config,...e}}},Ha=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Na.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Na.setConfig(e),this.config=e}updateConfig(e){this.config||(this.config={}),this.config={...this.config,...e},this.saveConfig(this.config)}getConfig(){return this.config}shouldShowWidget(){return!!this.config&&(this.config.widget_enabled??!1)}}.getInstance();function Za(e,t={}){return{...t,...e}}function qa(e){if(!(e&&e instanceof Element))return!1;try{const n=e.tagName.toLowerCase(),r="button"===n;if(!(r||"input"===n||"textarea"===n||"select"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||"textbox"===e.getAttribute("role")||"checkbox"===e.getAttribute("role")||"radio"===e.getAttribute("role")||"switch"===e.getAttribute("role")||"tab"===e.getAttribute("role")||"menuitem"===e.getAttribute("role")||"true"===e.getAttribute("contenteditable")||e.hasAttribute("onclick")||e.hasAttribute("tabindex")&&parseInt(e.getAttribute("tabindex")||"-1",10)>=0))return!1;const o=(t,n)=>{if(r){e.tagName,e.id,e.className}};if(!0===e.disabled)return o("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return o("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return o("inert","ancestor is inert"),!1;const e=t instanceof Element?t.getRootNode():null;t=t instanceof Element?t.parentElement||(e instanceof ShadowRoot?e.host:null):null}}catch(t){}const i=e.hasAttribute("onclick");if(r&&i)return!0;let a,s;try{a=window.getComputedStyle(e)}catch(t){return o("computed-style","failed to get computed style"),!1}if("none"===a.display)return o("display","display is none"),!1;if("none"===a.pointerEvents)return o("pointer-events","pointer-events is none"),!1;try{s=e.getBoundingClientRect()}catch(t){return o("bounding-rect","failed to get bounding rect"),!1}if(s.width<=0||s.height<=0)return o("dimensions",`width=${s.width}, height=${s.height}`),!1;try{let t=e;for(;t&&t!==document.body;){const e=t.getRootNode(),n=t.parentElement||(e instanceof ShadowRoot?e.host:null);if(!n)break;let i,a;try{i=window.getComputedStyle(n),a=n.getBoundingClientRect()}catch{t=n;continue}if("hidden"===i.overflow||"clip"===i.overflow){const e=s.right<a.left||s.left>a.right||s.bottom<a.top||s.top>a.bottom;if(r){if(e)return o("overflow-clipping","completely outside parent bounds"),!1}else if(e)return!1}t=n}}catch(t){}try{let t=e.getRootNode();for(;t instanceof ShadowRoot;){const e=t.host;let n;try{n=e.getBoundingClientRect()}catch{break}if(n.width<=0||n.height<=0)return!1;t=e.getRootNode()}}catch(t){}return!0}catch(t){return!1}}var Va=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;indexingInProgress=!1;indexVersion=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}generateSelector(e){if(e.id&&1===document.querySelectorAll(`#${CSS.escape(e.id)}`).length)return`#${CSS.escape(e.id)}`;const t=[];let n=e;for(;n&&n!==document.body&&n.parentElement;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${CSS.escape(n.id)}`,t.unshift(e);break}{const t=n.parentElement;if(!t)break;const r=n.tagName,o=Array.from(t.children).filter(e=>e.tagName===r);if(o.length>1){e+=`:nth-of-type(${o.indexOf(n)+1})`}}t.unshift(e),n=n.parentElement}return t.join(" > ")}generateFingerprint(e,t){return{tagName:e.tagName,id:e.id||null,textContent:((e,t=100)=>{if(!e)return null;const n=e.trim().replace(/\s+/g," ");return n.length>t?n.slice(0,t):n})(e.textContent),type:e.getAttribute("type"),role:e.getAttribute("role"),ariaLabel:e.getAttribute("aria-label"),name:e.getAttribute("name"),href:e.getAttribute("href"),selector:t,indexVersion:this.indexVersion}}matchesFingerprint(e,t){return e.tagName===t.tagName&&(!(!t.id||e.id!==t.id)||(!t.type||e.getAttribute("type")===t.type)&&((!t.ariaLabel||e.getAttribute("aria-label")===t.ariaLabel)&&((!t.role||e.getAttribute("role")===t.role)&&((!t.href||"A"!==t.tagName||e.getAttribute("href")===t.href)&&(!t.name||e.getAttribute("name")===t.name)))))}validateElementAtIndex(e){const t=this.fingerprintMap.get(e);if(!t)return{isValid:!0};const n=this.elementMap.get(e);return n&&document.contains(n)?n instanceof HTMLElement&&!this.matchesFingerprint(n,t)?{isValid:!1,mismatchReason:"element_changed"}:{isValid:!0}:{isValid:!1,mismatchReason:"element_removed"}}indexInteractableElements(){if(this.indexingInProgress)return[];try{this.indexingInProgress=!0,this.clearIndex();const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e instanceof HTMLElement&&null===e.offsetParent&&"BODY"!==e.tagName){const t=window.getComputedStyle(e),n="fixed"===t.position||"sticky"===t.position;if("none"===t.display)return NodeFilter.FILTER_REJECT;if(!n){let t=e.parentElement,n=!1;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if("fixed"===e.position||"sticky"===e.position){n=!0;break}t=t.parentElement}if(!n)return NodeFilter.FILTER_REJECT}}return NodeFilter.FILTER_ACCEPT}});let t=e.nextNode(),n=0;const r=[];for(;t;){if(t instanceof HTMLElement){const e=t.matches('a[href], button, input, textarea, select, [role="button"]'),o=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),i="onclick"in t&&"function"==typeof t.onclick;if(e||o||i||qa(t)){this.elementMap.set(n,t),this.elementToSequence.set(t,n);const e=this.generateSelector(t);this.selectorMap.set(n,e);const o=this.generateFingerprint(t,e);this.fingerprintMap.set(n,o),r.push([n,t]),n++}}t=e.nextNode()}return this.indexVersion++,r}finally{this.indexingInProgress=!1}}getElementCoordinates(e){const t=e.getBoundingClientRect(),n=this.calculateGlobalZOrder(e);return{x:Math.round(t.left),y:Math.round(t.top),w:Math.round(t.width),h:Math.round(t.height),z:n}}isStackingContext(e){const t=window.getComputedStyle(e),n=t.position;if(("fixed"===n||"absolute"===n||"relative"===n||"sticky"===n)&&"auto"!==t.zIndex)return!0;if("auto"!==t.zIndex&&e.parentElement){const t=window.getComputedStyle(e.parentElement).display;if("flex"===t||"inline-flex"===t||"grid"===t||"inline-grid"===t)return!0}const r=parseFloat(t.opacity);if(!isNaN(r)&&r<1)return!0;if(t.transform&&"none"!==t.transform)return!0;if(t.filter&&"none"!==t.filter)return!0;const o=t.willChange;if(o&&(o.includes("transform")||o.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const i=t.contain;return!(!i||!(i.includes("layout")||i.includes("style")||i.includes("paint")))}calculateGlobalZOrder(e){let t=e;const n=[];for(;t&&t!==document.body&&t.parentElement;){const e=window.getComputedStyle(t);if(this.isStackingContext(t)){let r=0;if("auto"!==e.zIndex){const t=parseInt(e.zIndex,10);isNaN(t)||(r=t)}let o=0;t.parentElement&&(o=Array.from(t.parentElement.children).indexOf(t)),n.push({element:t,zIndex:r,domOrder:o})}t=t.parentElement}let r=1e6;for(let o=n.length-1;o>=0;o--){const e=n[o];r+=1e4*e.zIndex+e.domOrder}if(e.parentElement){r+=Array.from(e.parentElement.children).indexOf(e)}return r}getSnapshotHtml(){this.indexInteractableElements();const e=document.documentElement.cloneNode(!0);for(const[n,r]of this.elementMap.entries())if(r instanceof HTMLElement){const o=this.selectorMap.get(n);if(o)try{const t=(e.querySelector("body")||e).querySelector(o);if(t)if(t.setAttribute("data-id",n.toString()),"none"===window.getComputedStyle(r).display)t.setAttribute("data-x","0"),t.setAttribute("data-y","0"),t.setAttribute("data-w","0"),t.setAttribute("data-h","0"),t.setAttribute("data-z","0");else{const e=this.getElementCoordinates(r);t.setAttribute("data-x",e.x.toString()),t.setAttribute("data-y",e.y.toString()),t.setAttribute("data-w",e.w.toString()),t.setAttribute("data-h",e.h.toString()),t.setAttribute("data-z",e.z.toString())}}catch(t){}}return e.outerHTML}getInteractableElements(){this.indexInteractableElements();const e=[];for(const[t,n]of this.elementMap.entries())if(n instanceof HTMLElement){const r=this.fingerprintMap.get(t);r&&e.push({index:t,fingerprint:r,coords:this.getElementCoordinates(n),cssClasses:Array.from(n.classList)})}return e}getSequenceForElement(e){return this.elementToSequence.get(e)}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear()}checkInteractability(e,t){if(!document.body.contains(e))return`ELEMENT_NOT_INTERACTABLE: Element ${t} is not in the DOM`;const n=window.getComputedStyle(e);if("none"===n.display)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has display:none`;if("hidden"===n.visibility)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has visibility:hidden`;if(0===parseFloat(n.opacity))return`ELEMENT_NOT_INTERACTABLE: Element ${t} has opacity:0`;const r=e.getBoundingClientRect();if(0===r.width||0===r.height)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has zero dimensions`;if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth)return`ELEMENT_NOT_INTERACTABLE: Element ${t} is off-screen`;const o=r.left+r.width/2,i=r.top+r.height/2,a=document.elementFromPoint(o,i);if(a&&a!==e&&!e.contains(a)&&!(a.closest("#marketrix-show-highlight")||a.closest("#marketrix-show-popup")||a.closest("[data-marketrix-widget]"))){const e=a.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${a.className?`${e}.${a.className.split(" ")[0]}`:e}. The obscuring element may be a modal or overlay that needs to be dismissed first.`}return null}checkElementInteractable(e,t){return this.checkInteractability(e,t)}getElementByIndex(e){let t=null;if(this.elementMap.has(e)){const n=this.elementMap.get(e);n&&n instanceof HTMLElement&&(t=n)}if(!t&&this.selectorMap.has(e)){const n=this.selectorMap.get(e);if(n)try{const e=document.querySelector(n);e&&e instanceof HTMLElement&&(t=e)}catch(r){}}if(!t)return{element:null,error:`Element ${e} not found`};const n=this.checkInteractability(t,e);return n?{element:null,error:n}:{element:t}}getValidatedElement(e){const t=this.validateElementAtIndex(e);if(!t.isValid)return{element:null,validation:t,error:`DOM_CHANGED: Element at index ${e} ${"element_removed"===t.mismatchReason?"no longer exists":"has changed"}. Call get_html to get updated indices.`};const n=this.elementMap.get(e);if(!n)return{element:null,validation:t,error:`Element ${e} not found`};const r=this.checkInteractability(n,e);return r?{element:null,validation:t,error:r}:{element:n,validation:t}}}.getInstance(),Ga=null;async function Ja(){if(Ga?.active){const e=Ga.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Ga}const e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!e||0===e.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return Ga=e,e.getVideoTracks()[0].addEventListener("ended",()=>{Ga=null}),e}function Ka(){return null!==function(){if(Ga?.active){const e=Ga.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Ga}return Ga=null,null}()}var Ya=class e{static instance;currentPopup=null;currentHighlight=null;currentElement=null;currentOptions=null;currentPromise=null;resolvePromise=null;rejectPromise=null;clickHandler=null;scrollHandler=null;updateHighlightPosition=null;rafId=null;mutationObserver=null;visibilityCheckInterval=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async showToolAction(e){const{element:t,explanation:n,isClickAction:r=!1,toolName:o}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===n&&this.currentOptions.toolName===o&&this.currentPromise||(this.cleanup(),this.currentOptions=e,this.currentElement=t,t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),this.createHighlight(t),this.createPopup(n,r),this.setupPositionUpdates(),this.setupElementMonitoring(),this.setupVisibilityMonitoring(),r&&this.setupClickHandler(),this.currentPromise=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t}).finally(()=>{this.cleanup()})),this.currentPromise}cleanup(){this.rejectPromise&&(this.rejectPromise("Cancelled by cleanup"),this.rejectPromise=null),this.resolvePromise=null,this.clickHandler&&(document.removeEventListener("click",this.clickHandler,{capture:!0}),this.clickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:!0}),window.removeEventListener("resize",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("wheel",this.scrollHandler),this.scrollHandler=null),null!==this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.visibilityCheckInterval&&(clearInterval(this.visibilityCheckInterval),this.visibilityCheckInterval=null),this.updateHighlightPosition=null,this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentHighlight&&(this.currentHighlight.remove(),this.currentHighlight=null);const e=document.getElementById("marketrix-show-popup");e&&e.remove();const t=document.getElementById("marketrix-show-highlight");t&&t.remove(),this.currentElement=null,this.currentOptions=null,this.currentPromise=null,this.resolvePromise=null,this.rejectPromise=null}createHighlight(e){const t=e.getBoundingClientRect(),n=document.createElement("div");n.id="marketrix-show-highlight",n.style.cssText=`\n position: fixed;\n top: ${t.top}px;\n left: ${t.left}px;\n width: ${t.width}px;\n height: ${t.height}px;\n border: 3px solid #3b82f6;\n border-radius: 4px;\n box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.4);\n z-index: 2147483645;\n pointer-events: none;\n transition: none;\n `,document.body.appendChild(n),this.currentHighlight=n}createPopup(e,t){const n=document.createElement("div");n.id="marketrix-show-popup",n.innerHTML=t?`<div style="font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>`:`<div style="margin-bottom: 12px; font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>\n <div style="display: flex; gap: 8px; justify-content: flex-end;">\n <button id="marketrix-show-continue" style="\n background: #3b82f6; color: white; border: none; border-radius: 6px;\n padding: 8px 16px; font-size: 12px; font-weight: 500; cursor: pointer;\n ">Continue</button>\n </div>`,document.body.appendChild(n),this.currentPopup=n,t||this.setupContinueButton(n),this.updatePopupPosition()}setupPositionUpdates(){this.updateHighlightPosition=()=>{if(!this.currentElement||!this.currentHighlight)return;const e=this.currentElement.getBoundingClientRect();this.currentHighlight.style.top=`${e.top}px`,this.currentHighlight.style.left=`${e.left}px`,this.currentHighlight.style.width=`${e.width}px`,this.currentHighlight.style.height=`${e.height}px`,this.updatePopupPosition()},this.scrollHandler=()=>{null!==this.rafId&&window.cancelAnimationFrame(this.rafId),this.updateHighlightPosition?.()},window.addEventListener("scroll",this.scrollHandler,{capture:!0,passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("wheel",this.scrollHandler,{passive:!0})}updatePopupPosition(){if(!this.currentPopup||!this.currentElement)return;const e=this.currentElement.getBoundingClientRect(),t=320,n=120,r=10,o=e.left+e.width/2,i=e.top+e.height/2,a=[{left:e.right+20,top:i-60},{left:e.left-t-20,top:i-60},{left:o-160,top:e.top-n-20},{left:o-160,top:e.bottom+20}];let s=a[0];for(const d of a)if(d.left>=r&&d.left+t<=window.innerWidth-r&&d.top>=r&&d.top+n<=window.innerHeight-r){s=d;break}const c=Math.max(r,Math.min(s.left,window.innerWidth-t-r)),l=Math.max(r,Math.min(s.top,window.innerHeight-n-r));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${l}px;\n left: ${c}px;\n width: 320px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n z-index: 2147483646;\n padding: 16px;\n `}setupClickHandler(){this.clickHandler=e=>{if(this.currentElement&&this.resolvePromise&&e.composedPath().includes(this.currentElement)){e.preventDefault(),e.stopPropagation();const t=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,t(!0)}},document.addEventListener("click",this.clickHandler,{capture:!0})}setupContinueButton(e){window.requestAnimationFrame(()=>{const t=e.querySelector("#marketrix-show-continue");t&&t.addEventListener("click",e=>{if(e.stopPropagation(),this.resolvePromise){const e=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,e(!0)}})})}setupElementMonitoring(){this.currentElement&&(this.mutationObserver=new MutationObserver(()=>{this.currentElement&&!document.body.contains(this.currentElement)&&this.failWithElementGone("Element was removed from DOM")}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}setupVisibilityMonitoring(){this.visibilityCheckInterval=setInterval(()=>{if(!this.currentElement)return;const e=Va.getSequenceForElement(this.currentElement)??-1,t=Va.checkElementInteractable(this.currentElement,e);t&&this.failWithElementGone(t)},200)}failWithElementGone(e){if(this.rejectPromise){const t=this.rejectPromise;this.rejectPromise=null,this.resolvePromise=null,t(/* @__PURE__ */new Error(`ELEMENT_GONE: ${e}`))}this.cleanup()}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}}.getInstance(),Xa=class e{static instance;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async executeTool(e,t,n="do",r=""){try{if("show"===n&&this.requiresHighlight(e)){const n=t.index;if(void 0!==n){const{element:t,error:o}=Va.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await Ya.showToolAction({element:t,explanation:r||`Execute ${e}`,toolName:e,isClickAction:"click_element"===e})))return{success:!1,data:{text:""},error:"User cancelled action"}}}switch(e){case"navigate":return this.navigate(t);case"search":return this.search(t);case"click_element":return await this.clickElement(t);case"type_text":return this.typeText(t);case"scroll":return this.scroll(t);case"scroll_to_text":return this.scrollToText(t);case"extract":return this.extract(t);case"go_back":return this.goBack();case"wait":return await this.wait(t);case"select_dropdown_option":return this.selectDropdownOption(t);case"get_dropdown_options":return this.getDropdownOptions(t);case"send_keys":return this.sendKeys(t);case"upload_file":return this.uploadFile(t);case"close_tab":return this.closeTab();case"switch_tab":return this.switchTab(t);case"done":return this.done(t);case"get_html":return this.getHtml();case"get_interactable_elements":return this.getInteractableElements();case"get_screenshot":return await this.getScreenshot();default:return{success:!1,data:{text:""},error:`Unknown tool: ${e}`}}}catch(o){return Ya.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Ea.has(e)}navigate(e){return e.url?e.new_tab?(window.open(e.url,"_blank"),{success:!0,data:{text:`Opened ${e.url} in new tab`}}):(window.location.href=e.url,{success:!0,data:{text:`Navigating to ${e.url}`}}):{success:!1,data:{text:""},error:"URL is required"}}search(e){if(!e.query)return{success:!1,data:{text:""},error:"Query is required"};const t=e.engine||"duckduckgo",n=encodeURIComponent(e.query);let r=`https://duckduckgo.com/?q=${n}`;return"google"===t&&(r=`https://www.google.com/search?q=${n}`),"bing"===t&&(r=`https://www.bing.com/search?q=${n}`),window.location.href=r,{success:!0,data:{text:`Searching for "${e.query}" on ${t}`}}}async clickElement(e){if(void 0===e.index)return{success:!1,data:{text:""},error:"Index required"};const{element:t,error:n}=Va.getValidatedElement(e.index);return t?(t.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(e=>setTimeout(e,100)),setTimeout(()=>{try{t.click()}catch(e){try{t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}catch(n){}}},50),{success:!0,data:{text:`Clicked element ${e.index}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}typeText(e){if(void 0===e.index||void 0===e.text)return{success:!1,data:{text:""},error:"Index and text required"};const t=!1!==e.clear,{element:n,error:r}=Va.getValidatedElement(e.index);if(!n)return{success:!1,data:{text:""},error:r||`Element ${e.index} not found`};if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n.isContentEditable){const r=n;try{r.focus()}catch(o){}const i=t?e.text:r.value+e.text;let a=!1,s=null;if(!a)try{const e="TEXTAREA"===r.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(r,i),a=!0)}catch(o){s=o}if(!a)try{r.value=i,a=!0}catch(o){s=o}if(!a)try{r.focus(),t&&r.select(),document.execCommand("insertText",!1,e.text)&&(a=!0)}catch(o){s=o}if(!a)try{r.focus(),t&&(r.value="");for(const t of e.text)r.dispatchEvent(new KeyboardEvent("keydown",{key:t,bubbles:!0,cancelable:!0})),r.value+=t,r.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),r.dispatchEvent(new KeyboardEvent("keyup",{key:t,bubbles:!0,cancelable:!0}));a=!0}catch(o){s=o}if(!a)return{success:!1,data:{text:""},error:`Failed to set value: ${s instanceof Error?s.message:String(s)}`};try{const t=new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:e.text});r.dispatchEvent(t),r.dispatchEvent(new Event("change",{bubbles:!0})),r.dispatchEvent(new Event("blur",{bubbles:!0}))}catch(o){}}else if("value"in n)try{n.value=e.text,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set value on element: ${o instanceof Error?o.message:String(o)}`}}else try{n.textContent=e.text,n.dispatchEvent(new Event("input",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set textContent: ${o instanceof Error?o.message:String(o)}`}}return{success:!0,data:{text:`Typed text into element ${e.index}`}}}scroll(e){const t=.8*window.innerHeight;switch(e.direction){case"down":window.scrollBy({top:t,behavior:"smooth"});break;case"up":window.scrollBy({top:-t,behavior:"smooth"});break;case"left":window.scrollBy({left:-t,behavior:"smooth"});break;case"right":window.scrollBy({left:t,behavior:"smooth"});break;default:return{success:!1,data:{text:""},error:"Invalid direction"}}return{success:!0,data:{text:`Scrolled ${e.direction}`}}}scrollToText(e){if(!e.text)return{success:!1,data:{text:""},error:"Text required"};const t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT);let n;for(;n=t.nextNode();)if(n.textContent?.includes(e.text)&&n.parentElement)return n.parentElement.scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,data:{text:`Scrolled to "${e.text}"`}};return{success:!1,data:{text:""},error:`Text "${e.text}" not found`}}extract(e){const t=e.start_from_char??0,n=!1!==e.extract_links,r=document.body.innerText;return{success:!0,data:{title:document.title,url:window.location.href,text:r.slice(t,t+1e4),links:n?Array.from(document.querySelectorAll("a[href]")).slice(0,100).map(e=>({text:e.textContent?.trim()||"",href:e.getAttribute("href")})):[]}}}goBack(){return window.history.length>1?(window.history.back(),{success:!0,data:{text:"Navigated back"}}):{success:!1,data:{text:""},error:"No history"}}async wait(e){return void 0===e.seconds?{success:!1,data:{text:""},error:"Seconds required"}:(await new Promise(t=>setTimeout(t,1e3*e.seconds)),{success:!0,data:{text:`Waited ${e.seconds}s`}})}selectDropdownOption(e){if(void 0===e.index||!e.option)return{success:!1,data:{text:""},error:"Index/Option required"};const{element:t,error:n}=Va.getValidatedElement(e.index);if(!t)return{success:!1,data:{text:""},error:n||`Select ${e.index} not found`};if(!(t instanceof HTMLSelectElement))return{success:!1,data:{text:""},error:`Element ${e.index} is not a select element`};const r=Array.from(t.options).find(t=>t.value===e.option||t.text===e.option);return r?(t.value=r.value,t.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,data:{text:`Selected ${e.option}`}}):{success:!1,data:{text:""},error:`Option ${e.option} not found`}}getDropdownOptions(e){const t=e.index,{element:n,error:r}=Va.getValidatedElement(t);return n?n instanceof HTMLSelectElement?{success:!0,data:{options:Array.from(n.options).map(e=>({value:e.value,text:e.text}))}}:{success:!1,data:{options:[]},error:`Element ${t} is not a select element`}:{success:!1,data:{options:[]},error:r||`Select ${t} not found`}}sendKeys(e){if(void 0===e.index||!e.keys)return{success:!1,data:{text:""},error:"Index/Keys required"};const{element:t,error:n}=Va.getValidatedElement(e.index);return t?(t.focus(),t.dispatchEvent(new KeyboardEvent("keydown",{key:e.keys,bubbles:!0,cancelable:!0})),t.dispatchEvent(new KeyboardEvent("keyup",{key:e.keys,bubbles:!0,cancelable:!0})),{success:!0,data:{text:this.simulateKeyAction(t,e.keys)||`Sent keys ${e.keys}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}simulateKeyAction(e,t){switch(t){case"Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(-1!==n&&n<t.length-1){const e=t[n+1];return e.focus(),`Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Tab: no next focusable element"}case"Shift+Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(n>0){const e=t[n-1];return e.focus(),`Shift+Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Shift+Tab: no previous focusable element"}case"Enter":if(e instanceof HTMLButtonElement||"button"===e.getAttribute("role"))return e.click(),"Enter: clicked button";if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.closest("form");if(t){const e=t.querySelector('button[type="submit"], input[type="submit"]');return e?(e.click(),"Enter: clicked form submit button"):(t.requestSubmit(),"Enter: submitted form")}}return e instanceof HTMLAnchorElement?(e.click(),"Enter: clicked link"):"Enter: dispatched event";case"Escape":return e.blur(),document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0,cancelable:!0})),"Escape: blurred element and dispatched to document";case" ":case"Space":return e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?(e.click(),`Space: toggled ${e.type}`):e instanceof HTMLButtonElement||"button"===e.getAttribute("role")?(e.click(),"Space: clicked button"):"Space: dispatched event";case"ArrowDown":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t<e.options.length-1?(e.selectedIndex=t+1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowDown: selected "${e.options[e.selectedIndex].text}"`):"ArrowDown: already at last option"}return"ArrowDown: dispatched event";case"ArrowUp":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t>0?(e.selectedIndex=t-1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowUp: selected "${e.options[e.selectedIndex].text}"`):"ArrowUp: already at first option"}return"ArrowUp: dispatched event";case"Home":return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?(e.setSelectionRange(0,0),"Home: moved cursor to start"):"Home: dispatched event";case"End":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value.length;return e.setSelectionRange(t,t),"End: moved cursor to end"}return"End: dispatched event";case"Backspace":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value;if(!t||0===t.length)return"Backspace: input is empty, nothing to delete";let n,r,o=e.selectionStart??t.length,i=e.selectionEnd??t.length;if(0===o&&0===i&&(o=t.length,i=t.length),o===i&&o>0)n=t.slice(0,o-1)+t.slice(i),r=o-1;else{if(o===i)return"Backspace: cursor at start, nothing to delete";n=t.slice(0,o)+t.slice(i),r=o}const a=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return a?a.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(r,r),`Backspace: deleted character, value is now "${n}"`}return"Backspace: dispatched event";case"Delete":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.selectionStart||0,n=e.selectionEnd||0,r=e.value;let o;if(t===n&&t<r.length)o=r.slice(0,t)+r.slice(n+1);else{if(t===n)return"Delete: cursor at end, nothing to delete";o=r.slice(0,t)+r.slice(n)}const i=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return i?i.call(e,o):e.value=o,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${o}"`}return"Delete: dispatched event";default:return null}}uploadFile(e){return{success:!1,data:{text:""},error:"File upload not supported via script"}}closeTab(){return window.close(),{success:!0,data:{text:"Attempted close"}}}switchTab(e){return e.tab_id?{success:!1,data:{text:""},error:"Tab switching not supported"}:{success:!1,data:{text:""},error:"tab_id is required"}}done(e){return void 0===e.success?{success:!1,data:{text:""},error:"success parameter is required"}:{success:!0,data:{text:e.message||(e.success?"Task completed":"Task failed")}}}getHtml(){try{return{success:!0,data:{text:Va.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Va.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Ja();if(!e)return{success:!1,data:{text:""},error:"Failed to get stream"};const t=document.createElement("video");t.srcObject=e,t.autoplay=!0,t.style.display="none",document.body.appendChild(t),await new Promise(e=>{t.onloadeddata=()=>e()});const n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d")?.drawImage(t,0,0);const r=n.toDataURL("image/jpeg",.75);return t.remove(),{success:!0,data:{text:r}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}}.getInstance(),Qa=e=>({state:e,effects:[]});function es(e,t,n,r,o,i,a){const s=function(e){return za[e]?za[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Sa({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Ea.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=Ia(e),o=r.parts||[],i=[...o],a=o.findIndex(e=>"progress"===e.type&&e.toolName===t&&"in_progress"===e.status),s=!Ca.has(t),c="default",l=Ta(n);return a>=0?i[a]={...i[a],content:l,hideIcon:s,textStyle:c}:i.push({type:"progress",content:l,status:"in_progress",toolName:t,hideIcon:s,textStyle:c}),{...r,parts:i}}(l,s,o||s)),t&&p&&(l=Ma(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=Ia(e),r=n.parts||[],o=[...r];let i=-1;if(t)i=r.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);else for(let a=r.length-1;a>=0;a--)if("progress"===r[a].type&&"in_progress"===r[a].status){i=a;break}return i>=0&&(o[i]={...o[i],status:"completed"}),{...n,parts:o}}(l)),t&&p&&(l=Ma(l,t,n,!1))):(l=function(e,t,n){const r=Ia(e),o=r.parts||[],i=n.toLowerCase().includes("cancelled by cleanup"),a=[...o];let s=o.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);if(-1===s)for(let c=o.length-1;c>=0;c--)if("progress"===o[c].type&&"in_progress"===o[c].status){s=c;break}if(s>=0)if(i){const e=Ta(a[s].content);a[s]={...a[s],status:"completed",content:e}}else{const e=Ta(n),t=Ta(a[s].content);a[s]={...a[s],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:a}}(l,s,a||""),t&&p&&(l=Ma(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function ts(e,t,n,r,o,i){return{...e,messages:es(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ns=n(void 0),rs={activeTaskId:null,isTaskRunning:!1},os=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:a})=>{const[c,l]=p(()=>({messages:o??[],task:a??rs})),h=u(c);h.current=c;const m=u(n);m.current=n;const g=u(0),y=u(/* @__PURE__ */new Set),b=u({}),w=i(e=>{l(t=>{const n=e(t);return n===t||n.messages===t.messages&&n.task===t.task?t:(h.current=n,n)})},[]),v=i(e=>{w(t=>({...t,messages:[...t.messages,e]}))},[w]),x=i((e,t)=>{w(n=>({...n,messages:n.messages.map(n=>n.id===e?{...n,...t}:n)}))},[w]),k=i(e=>{w(t=>({...t,messages:t.messages.filter(t=>t.id!==e)}))},[w]),_=i(e=>{w(t=>({...t,messages:e}))},[w]),S=i(()=>{w(e=>({...e,messages:[]}))},[w]),I=i(e=>{w(t=>({...t,task:{activeTaskId:e.activeTaskId,isTaskRunning:e.isTaskRunning}}))},[w]),C=i(async(e,n,o,i,a)=>{const s=n??m.current;if(t)return a||v(La(e,s)),void v($a("This is a preview. In production, I'll respond to your messages here."));let c=Ha.getConfig();if(c||(c=Ha.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void v($a("Configuration error: Missing API credentials. Please check your widget settings."));a||v(La(e,s));const l=`temp-${globalThis.crypto.randomUUID()}`;v({id:l,content:ka(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:s,isPlaceholder:!0,placeholderState:"thinking",parts:[]}),r.setLoading(!0);const d=new Wa(c);try{o&&d.updateConfig({mtxApp:o});const t=d.getChatId();if(t){const e=Ba.getInstance();if(!e.isConnected()){const n=Ha.getConfig();try{await e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0)}catch(u){}}}await d.sendMessage({message:e,mode:s,question:i,requestId:l})}catch(p){w(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.",n=e.messages.map(e=>{if(e.id!==l)return e;const n=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:n,content:t}});return{...e,messages:n}})}finally{r.setLoading(!1)}},[t,v,w,r]),E=i(e=>{if(y.current.add(e),y.current.size>1e3){const e=Array.from(y.current);y.current=new Set(e.slice(-500))}},[]),T=i(()=>{const e=b.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;b.current={},w(e=>({...e,task:{isTaskRunning:!0,activeTaskId:t}}))}},[w]);s(()=>{if(t)return;const e=Ba.getInstance(),n=async t=>{const{callId:n,tool:r,args:o,mode:i,explanation:a}=t,s=await Xa.executeTool(r,o,i,a);if(s.success)try{g.current++,e.send({type:"tool/response",call_id:n,success:!0,data:"string"==typeof s.data?s.data:JSON.stringify(s.data),state_version:g.current}).catch(e=>{}),w(e=>ts(e,r,a,"completed",m.current)),"done"===r&&(b.current={},w(e=>function(e,t){const n=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];if(n){const e=(n.message.parts??[]).filter(e=>!("progress"===e.type&&"done"===e.toolName));r[n.index]={...n.message,taskStatus:"done",parts:e}}return{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,m.current)))}catch(c){w(e=>ts(e,r,a,"failed",m.current,"Connection error"))}else w(e=>ts(e,r,a,"failed",m.current,s.error||"Tool execution failed")),g.current++,e.send({type:"tool/response",call_id:n,success:!1,data:"string"==typeof s.data?s.data:JSON.stringify(s.data),error:s.error??void 0,state_version:g.current}).catch(e=>{})},o={onStatusChange:e=>{r.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const n=t.call_id;if(y.current.has(n))return;if(E(n),!va.map(e=>e.id).includes(t.tool))return void e.send({type:"tool/response",call_id:n,success:!1,error:`Unknown tool: ${t.tool}`,state_version:g.current}).catch(e=>{});h.current.task.isTaskRunning,void 0!==t.state_version&&t.state_version>g.current&&(g.current=t.state_version)}else if("task/status"!==t.type||"completed"!==t.status&&"failed"!==t.status&&"stopped"!==t.status){if("task/status"===t.type&&"has_question"===t.status)b.current={};else if("task/status"===t.type&&"running"===t.status)return b.current={...b.current,agentRunning:!0,apiTaskId:b.current.apiTaskId||t.task_id||void 0},void T()}else y.current.clear(),b.current={};let o=[];w(e=>{const n=function(e,t,n){switch(t.type){case"tool/call":{const r=e.task.isTaskRunning?e.task:{...e.task,isTaskRunning:!0},o=r.isTaskRunning,i=t.mode||n||"do",a=t.explanation||"";return{state:{messages:es(e.messages,o,n,t.tool,a,"in_progress"),task:r},effects:[{type:"executeTool",callId:t.call_id,tool:t.tool,args:t.args,mode:i,explanation:a}]}}case"task/status":{const r=t.message||"";if("running"===t.status)return Qa(e);if("has_question"===t.status){const t=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=Ma(t.message,!1,n);o[t.index]={...e,placeholderState:"waiting-for-user",...r&&{content:r}}}return{state:{messages:o,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}const o=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),i=[...e.messages];if(o){let e="done";"failed"===t.status?e="failed":"stopped"===t.status&&(e="stopped"),i[o.index]={...o.message,taskStatus:e,...r&&{content:r}}}return{state:{messages:i,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}case"chat/response":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=[...e.parts??[],{type:"text",content:t.text}];return{...e,content:t.text,isPlaceholder:!1,placeholderState:void 0,parts:n,...t.task_id&&{taskId:t.task_id}}}),r=[{type:"setLoading",value:!1}];return t.task_id&&r.push({type:"activateApiTask",taskId:t.task_id}),{state:{...e,messages:n},effects:r}}case"chat/error":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=`Error: ${t.error}`,r=[...e.parts??[],{type:"text",content:n}];return{...e,content:n,isPlaceholder:!1,placeholderState:void 0,parts:r}});return{state:{...e,messages:n},effects:[{type:"setLoading",value:!1}]}}default:return Qa(e)}}(e,t,m.current);return o=n.effects,n.state}),(e=>{for(const t of e)"setLoading"===t.type?r.setLoading(t.value):"activateApiTask"===t.type&&(b.current={...b.current,apiTaskId:t.taskId},T())})(o);const i=o.find(e=>"executeTool"===e.type);"executeTool"===i?.type&&await n(i)},onError:e=>{r.setError(e.message)}};return e.addCallbacks(o),()=>{e.removeCallbacks(o)}},[t,w,T,E,r]);const M=i(async()=>{const e=h.current.task.activeTaskId??void 0;w(e=>function(e,t){const n=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];return n&&(r[n.index]={...n.message,taskStatus:"stopped"}),{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,m.current)),t||Ba.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,w]),z=d(()=>({addMessage:v,updateMessage:x,removeMessage:k,setMessages:_,clearMessages:S,sendMessage:C}),[v,x,k,_,S,C]),A=d(()=>({setTaskState:I,stopTask:M}),[I,M]),O=d(()=>({messages:c.messages}),[c.messages]);/* @__PURE__ */
|
|
2
|
+
return Yr(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */Yr(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */Yr(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */Yr(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Ro=/*@__PURE__*/je("ZodString",(e,t)=>{Tn.init(e,t),No.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ct(t)})}(Do,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(Fo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(ti,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(Uo,t)),e.guid=t=>e.check(Br(Po,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(jo,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ct(t)})}(jo,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ct(t)})}(jo,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ct(t)})}(jo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(Bo,t)),e.guid=t=>e.check(Br(Po,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(Wo,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(Ho,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(Zo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(Xo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(Qo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(qo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(Vo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(Go,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(Jo,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(Ko,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(Yo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(ei,t)),e.datetime=t=>e.check(co(t)),e.date=t=>e.check(uo(t)),e.time=t=>e.check(ho(t)),e.duration=t=>e.check(fo(t))});function Lo(e){return function(e,t){return new e({type:"string",...ct(t)})}(Ro,e)}var $o=/*@__PURE__*/je("ZodStringFormat",(e,t)=>{Mn.init(e,t),No.init(e,t)}),Do=/*@__PURE__*/je("ZodEmail",(e,t)=>{On.init(e,t),$o.init(e,t)}),Po=/*@__PURE__*/je("ZodGUID",(e,t)=>{zn.init(e,t),$o.init(e,t)}),jo=/*@__PURE__*/je("ZodUUID",(e,t)=>{An.init(e,t),$o.init(e,t)}),Fo=/*@__PURE__*/je("ZodURL",(e,t)=>{Nn.init(e,t),$o.init(e,t)}),Uo=/*@__PURE__*/je("ZodEmoji",(e,t)=>{Rn.init(e,t),$o.init(e,t)}),Bo=/*@__PURE__*/je("ZodNanoID",(e,t)=>{Ln.init(e,t),$o.init(e,t)}),Wo=/*@__PURE__*/je("ZodCUID",(e,t)=>{$n.init(e,t),$o.init(e,t)}),Ho=/*@__PURE__*/je("ZodCUID2",(e,t)=>{Dn.init(e,t),$o.init(e,t)}),Zo=/*@__PURE__*/je("ZodULID",(e,t)=>{Pn.init(e,t),$o.init(e,t)}),qo=/*@__PURE__*/je("ZodXID",(e,t)=>{jn.init(e,t),$o.init(e,t)}),Vo=/*@__PURE__*/je("ZodKSUID",(e,t)=>{Fn.init(e,t),$o.init(e,t)}),Go=/*@__PURE__*/je("ZodIPv4",(e,t)=>{Zn.init(e,t),$o.init(e,t)}),Jo=/*@__PURE__*/je("ZodIPv6",(e,t)=>{qn.init(e,t),$o.init(e,t)}),Ko=/*@__PURE__*/je("ZodCIDRv4",(e,t)=>{Vn.init(e,t),$o.init(e,t)}),Yo=/*@__PURE__*/je("ZodCIDRv6",(e,t)=>{Gn.init(e,t),$o.init(e,t)}),Xo=/*@__PURE__*/je("ZodBase64",(e,t)=>{Kn.init(e,t),$o.init(e,t)}),Qo=/*@__PURE__*/je("ZodBase64URL",(e,t)=>{Yn.init(e,t),$o.init(e,t)}),ei=/*@__PURE__*/je("ZodE164",(e,t)=>{Xn.init(e,t),$o.init(e,t)}),ti=/*@__PURE__*/je("ZodJWT",(e,t)=>{Qn.init(e,t),$o.init(e,t)}),ni=/*@__PURE__*/je("ZodNumber",(e,t)=>{er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:i,format:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l}=e._zod.bag;"string"==typeof a&&a.includes("int")?r.type="integer":r.type="number";const d="number"==typeof l&&l>=(o??Number.NEGATIVE_INFINITY),u="number"==typeof c&&c<=(i??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof o&&(r.minimum=o),u?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof i&&(r.maximum=i),"number"==typeof s&&(r.multipleOf=s)})(e,t,n),Ao(e,"ZodNumber",{gt(e,t){return this.check(Zr(e,t))},gte(e,t){return this.check(qr(e,t))},min(e,t){return this.check(qr(e,t))},lt(e,t){return this.check(Wr(e,t))},lte(e,t){return this.check(Hr(e,t))},max(e,t){return this.check(Hr(e,t))},int(e){return this.check(ii(e))},safe(e){return this.check(ii(e))},positive(e){return this.check(Zr(0,e))},nonnegative(e){return this.check(qr(0,e))},negative(e){return this.check(Wr(0,e))},nonpositive(e){return this.check(Hr(0,e))},multipleOf(e,t){return this.check(Vr(e,t))},step(e,t){return this.check(Vr(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ri(e){return function(e,t){return new e({type:"number",checks:[],...ct(t)})}(ni,e)}var oi=/*@__PURE__*/je("ZodNumberFormat",(e,t)=>{tr.init(e,t),ni.init(e,t)});function ii(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(oi,e)}var ai=/*@__PURE__*/je("ZodBoolean",(e,t)=>{nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function si(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(ai,e)}var ci=/*@__PURE__*/je("ZodNull",(e,t)=>{rr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{"openapi-3.0"===t.target?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"})(0,e,t)});var li=/*@__PURE__*/je("ZodUnknown",(e,t)=>{or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function di(){return new li({type:"unknown"})}var ui=/*@__PURE__*/je("ZodNever",(e,t)=>{ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function pi(e){return function(e,t){return new e({type:"never",...ct(t)})}(ui,e)}var hi=/*@__PURE__*/je("ZodDate",(e,t)=>{ar.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,n)=>e.check(qr(t,n)),e.max=(t,n)=>e.check(Hr(t,n));const n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null}),mi=/*@__PURE__*/je("ZodArray",(e,t)=>{cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(o.minItems=a),"number"==typeof s&&(o.maxItems=s),o.type="array",o.items=eo(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Ao(e,"ZodArray",{min(e,t){return this.check(Jr(e,t))},nonempty(e){return this.check(Jr(1,e))},max(e,t){return this.check(Gr(e,t))},length(e,t){return this.check(Kr(e,t))},unwrap(){return this.element}})});function fi(e,t){return function(e,t,n){return new e({type:"array",element:t,...ct(n)})}(mi,e,t)}var gi=/*@__PURE__*/je("ZodObject",(e,t)=>{hr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const l in a)o.properties[l]=eo(a[l],t,{...r,path:[...r.path,"properties",l]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=eo(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),Ke(e,"shape",()=>t.shape),Ao(e,"ZodObject",{keyof(){return Si(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:di()})},loose(){return this.clone({...this._zod.def,catchall:di()})},strict(){return this.clone({...this._zod.def,catchall:pi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!rt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Ye(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!rt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Ye(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Ye(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return st(e,Xe(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ye(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return st(e,Xe(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ye(this,"shape",r),r},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return st(t,Xe(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Ye(this,"shape",o),o},checks:[]}))}(Ei,this,e[0])},required(...e){return t=Ri,n=this,r=e[0],st(n,Xe(n._zod.def,{get shape(){const e=n._zod.def.shape,o={...e};if(r)for(const n in r){if(!(n in o))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(o[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)o[n]=new t({type:"nonoptional",innerType:e[n]});return Ye(this,"shape",o),o}}));var t,n,r}})});function yi(e,t){return new gi({type:"object",shape:e??{},...ct(t)})}var bi=/*@__PURE__*/je("ZodUnion",(e,t)=>{fr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,a=o.options.map((e,n)=>eo(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=a:n.anyOf=a})(e,t,n,r),e.options=t.options});function wi(e,t){return new bi({type:"union",options:e,...ct(t)})}var vi=/*@__PURE__*/je("ZodIntersection",(e,t)=>{gr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=eo(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=eo(o.right,t,{...r,path:[...r.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]})(e,t,n,r)});var xi=/*@__PURE__*/je("ZodRecord",(e,t)=>{wr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,s=a._zod.bag?.patterns;if("loose"===i.mode&&s&&s.size>0){const e=eo(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of s)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=eo(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=eo(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=a._zod.values;if(c){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(o.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ki(e,t,n){return t&&t._zod?new xi({type:"record",keyType:e,valueType:t,...ct(n)}):new xi({type:"record",keyType:Lo(),valueType:e,...ct(t)})}var _i=/*@__PURE__*/je("ZodEnum",(e,t)=>{vr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=He(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new _i({...t,checks:[],...ct(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new _i({...t,checks:[],...ct(r),entries:o})}});function Si(e,t){return new _i({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ct(t)})}var Ii=/*@__PURE__*/je("ZodLiteral",(e,t)=>{xr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,o=[];for(const i of r.values)if(void 0===i){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof i){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(i))}else o.push(i);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});var Ci=/*@__PURE__*/je("ZodTransform",(e,t)=>{kr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ue(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(gt(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(gt(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});var Ei=/*@__PURE__*/je("ZodOptional",(e,t)=>{Sr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ti(e){return new Ei({type:"optional",innerType:e})}var Mi=/*@__PURE__*/je("ZodExactOptional",(e,t)=>{Ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var zi=/*@__PURE__*/je("ZodNullable",(e,t)=>{Cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=eo(o.innerType,t,r),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ai(e){return new zi({type:"nullable",innerType:e})}var Oi=/*@__PURE__*/je("ZodDefault",(e,t)=>{Er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Ni=/*@__PURE__*/je("ZodPrefault",(e,t)=>{Mr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Ri=/*@__PURE__*/je("ZodNonOptional",(e,t)=>{zr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Li=/*@__PURE__*/je("ZodCatch",(e,t)=>{Or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var $i=/*@__PURE__*/je("ZodPipe",(e,t)=>{Nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a="input"===t.io?i?o.out:o.in:o.out;eo(a,t,r),t.seen.get(e).ref=a})(e,t,0,r),e.in=t.in,e.out=t.out});function Di(e,t){return new $i({type:"pipe",in:e,out:t})}var Pi=/*@__PURE__*/je("ZodReadonly",(e,t)=>{Lr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var ji=/*@__PURE__*/je("ZodCustom",(e,t)=>{Pr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Fi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...ct(t)})}(ni,e)}function Ui(e){return function(e,t){return new e({type:"date",coerce:!0,...ct(t)})}(hi,e)}var Bi,Wi,Hi=Si(["created","active","suspended","pending_approval"]),Zi=yi({id:ri().optional(),created_at:Ui().optional(),updated_at:Ui().optional()}),qi=(yi({id:Fi()}),yi({slug:Lo()}),yi({widget_id:Fi()}),yi({simulation_id:Fi()}),yi({application_id:Fi()}),yi({user_id:Fi()}),yi({limit:Fi().optional().default(50),offset:Fi().optional().default(0)}),wi([Lo(),ri(),si(),fi(Lo()),function(e,t){return new e({type:"null",...ct(t)})}(ci,Bi)]),yi({type:Si(["doc","sim","session"]),id:Lo(),label:Lo()}),yi({success:function(e,t){return new Ii({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}(!0)})),Vi=(qi.extend({message:Lo()}),yi({name:Lo().min(1),params:ki(Lo(),di()).default({}),result:ki(Lo(),di()).default({})}),Lo().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),yi({start:Lo(),end:Lo(),action:Lo()}).passthrough()),Gi=yi({id:Lo(),label:Lo(),purpose:Lo(),elements:fi(ki(Lo(),di())).default([]),bbox:ki(Lo(),di()).default({}),screenshot:Lo().default(""),embedding:fi(ri()).nullish()}).passthrough(),Ji=yi({id:Lo(),title:Lo(),url:Lo(),summary:Lo().default(""),screenshot:Lo().default(""),sections:fi(Gi).default([]),sequence_ids:fi(ri()).default([]),embedding:fi(ri()).nullish()}).passthrough(),Ki=(yi({nodes:fi(Ji),edges:fi(Vi)}),yi({skill_id:ri().int(),params:ki(Lo(),Lo())}),Si(["free","startup","growth","enterprise"])),Yi=Si(["document","video"]),Xi=Si(["user","research"]),Qi=(Si(["pending","processing","waiting_review","completed","failed"]),Si(["queued","running","creating_knowledge","has_question","completed","failed","stopped"])),ea=Si(["pending","generating","completed","failed"]),ta=Si(["app","website"]),na=Si(["widget"]),ra=(Si(["tell","show","do"]),Si(["password","oauth"])),oa=(Zi.extend({is_super:si(),status:Hi,email:Lo().email(),external_id:Lo().nullish(),first_name:Lo().nullish(),last_name:Lo().nullish(),password:Lo().nullish(),image_url:Lo().nullish(),prompt_limit:ri().nullish(),last_login_at:Ui().nullish(),auth_method:ra.nullish()}).partial().extend({email:Lo().email(),password:Lo()}),Zi.extend({name:Lo(),slug:Lo(),status:Hi,package:Ki,ending_date:Ui().nullish(),external_workspace_id:Lo().nullish(),slack_webhook_configured:si().optional(),notify_all_members_on_question:si().optional()}),Zi.extend({workspace_id:ri(),application_id:ri().optional(),file_name:Lo().min(1),file_size:Fi(),file_type:Yi,file_url:Lo(),source_url:Lo().nullish(),source:Xi.default("user").optional()}),Si(["passed","needs_healing","failed"]),yi({ultimate_goal:Lo(),test_cases:fi(yi({test_title:Lo(),test_objective:Lo(),test_steps:fi(Lo()),expected_outcome:Lo(),priority:Si(["Low","Medium","High"])})),summary:yi({total_tests:ri(),high_priority:ri(),medium_priority:ri(),low_priority:ri(),estimated_time_minutes:ri()})}),yi({task_id:Lo(),condition:Si(["pass"]).optional()})),ia=yi({task_id:Lo(),title:Lo(),instructions:Lo(),status:Si(["pending","running","has_question","passed","failed","skipped","stopped"]),error_message:Lo().nullish(),started_at:Lo().nullish(),completed_at:Lo().nullish(),order_index:ri().int().nonnegative().default(0),tab_id:Lo().nullish(),step_count:ri().int().nonnegative().default(0),blocked_by:fi(oa).default([])}),aa=(Zi.extend({application_id:ri(),job_id:Lo(),browser_session_id:Lo().nullish(),status:Qi,status_message:Lo().nullish(),path:Lo().nullish(),instructions:Lo().nullish(),pinned:si().optional(),source:Si(["direct","qa"]).optional(),graph_id:Lo().nullish(),source_metadata:ki(Lo(),di()).nullish(),tasks:fi(ia).optional(),graph_status:ea.optional(),graph_steps_processed:ri().int().nonnegative().optional(),graph_steps_total:ri().int().nonnegative().optional(),graph_error:Lo().nullish(),created_by_user_id:ri().nullish(),persona_id:ri().nullish(),has_question:si().optional()}),Zi.extend({workspace_id:ri(),name:Lo(),slug:Lo(),type:ta,url:Lo().nullish(),username:Lo().nullish(),password:Lo().nullish(),allowed_domains:fi(Lo()).nullish().default([])}).omit({password:!0}),yi({chip_mode:Si(["show","tell","do"]),chip_text:Lo()})),sa=yi({widget_enabled:si(),widget_appearance:Si(["default","compact","full"]),widget_position:Si(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Si(["desktop","mobile","desktop_mobile"]),widget_header:Lo(),widget_body:Lo(),widget_greeting:Lo(),widget_feature_tell:si(),widget_feature_show:si(),widget_feature_do:si(),widget_feature_human:si(),widget_background_color:Lo(),widget_text_color:Lo(),widget_border_color:Lo(),widget_accent_color:Lo(),widget_secondary_color:Lo(),widget_border_radius:Lo(),widget_font_size:Lo(),widget_width:Lo(),widget_height:Lo(),widget_shadow:Lo(),widget_animation_duration:Lo(),widget_fade_duration:Lo(),widget_bounce_effect:si(),widget_chips:fi(aa)}),ca=(Zi.extend({application_id:ri(),type:na,settings:sa,status:Hi,marketrix_id:Lo(),marketrix_key:Lo(),snippet:Lo().nullish()}),Zi.extend({widget_id:ri(),url_pattern:Lo(),message:fi(Lo()),description:Lo().optional()}),Si(["pending","running","completed","failed","stopped"]),Si(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_application","update_application","delete_application","create_widget","update_widget","delete_widget","create_knowledge","update_knowledge","delete_knowledge","approve_user","deny_user","request_workspace","widget_question","qa_run_started","start_simulation","create_automation","update_automation","delete_automation","toggle_automation","slack_command"])),la=yi({details:Lo().optional(),id:ri().optional(),type:Lo().optional(),name:Lo().optional(),target_user_id:ri().optional(),target_user_email:Lo().optional(),reason:Lo().optional(),assigned_role:Lo().optional(),new_role:Lo().optional(),previous_role:Lo().optional(),workspace_name:Lo().optional(),workspace_slug:Lo().optional(),ip_address:Lo().optional(),user_agent:Lo().optional(),widget_type:Lo().optional(),created_by:ri().optional()}).passthrough(),da=(Zi.extend({workspace_id:ri(),user_id:ri(),type:ca,metadata:la.optional()}).partial().extend({type:ca}),yi({user_id:ri(),limit:ri(),used:ri(),remaining:ri()}),yi({description:Lo(),selected:si(),simulation_id:ri().nullable().optional(),task_id:Lo().nullable().optional(),status:Qi.nullable().optional()}),null),ua="";function pa(e){return ge(new Pe({url:e,headers:()=>{const e={};return da&&(e.Authorization=`Bearer ${da}`),e}}))}Wi=pa("");var ha=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ua&&(ua=e,Wi=pa(e))},ma={setAuthToken:e=>{da=e},clearAuthToken:()=>{da=null},getAuthToken:()=>da,configure:ha},fa=new Proxy({},{get:(e,t)=>t in ma?ma[t]:Wi[t]}),ga="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",ya={debug:0,info:1,warn:2,error:3};function ba(e){return ya[e]>=ya[ga]}function wa(e){return{debug:(e,...t)=>{ba("debug")},info:(e,...t)=>{ba("info")},warn:(e,...t)=>{ba("warn")},error:(e,...t)=>{ba("error")}}}var va=[{id:"navigate",name:"Navigate",description:"Navigate to a URL",displayAction:"Navigating",category:"navigation",actionType:"navigate"},{id:"search",name:"Search",description:"Search the web using a search engine",displayAction:"Searching",category:"navigation",actionType:"search"},{id:"click_element",name:"Click Element",description:"Click on an element by index or coordinates",displayAction:"Clicking element",category:"interaction",actionType:"click_element"},{id:"type_text",name:"Type Text",description:"Type text into an input field",displayAction:"Typing text",category:"interaction",actionType:"type_text"},{id:"scroll",name:"Scroll",description:"Scroll the page up or down",displayAction:"Scrolling",category:"interaction",actionType:"scroll"},{id:"scroll_to_text",name:"Scroll to Text",description:"Scroll until text is visible",displayAction:"Scrolling to text",category:"interaction",actionType:"scroll_to_text"},{id:"send_keys",name:"Send Keys",description:"Send keyboard keys or shortcuts",displayAction:"Pressing key",category:"interaction",actionType:"send_keys"},{id:"extract",name:"Extract",description:"Extract content from the page",displayAction:"Extracting content",category:"extraction",actionType:"extract"},{id:"get_dropdown_options",name:"Get Dropdown Options",description:"Get available options from a dropdown",displayAction:"Reading dropdown options",category:"extraction",actionType:"get_dropdown_options"},{id:"select_dropdown_option",name:"Select Dropdown Option",description:"Select an option from a dropdown",displayAction:"Selecting option",category:"interaction",actionType:"select_dropdown_option"},{id:"upload_file",name:"Upload File",description:"Upload a file to an input field",displayAction:"Uploading file",category:"interaction",actionType:"upload_file"},{id:"go_back",name:"Go Back",description:"Browser back button",displayAction:"Going back",category:"navigation",actionType:"go_back"},{id:"wait",name:"Wait",description:"Wait for a specified duration",displayAction:"Waiting",category:"utility",actionType:"wait"},{id:"switch_tab",name:"Switch Tab",description:"Switch to a different browser tab",displayAction:"Switching tab",category:"utility",actionType:"switch_tab"},{id:"close_tab",name:"Close Tab",description:"Close the current browser tab",displayAction:"Closing tab",category:"utility",actionType:"close_tab"},{id:"done",name:"Done",description:"Mark task as complete",displayAction:"Done",category:"utility",actionType:"done"},{id:"get_html",name:"Get HTML",description:"Get full page HTML with data-id attributes",displayAction:"Viewed your screen",category:"extraction",actionType:"get_html"},{id:"get_interactable_elements",name:"Get Interactable Elements",description:"Get list of interactable elements",displayAction:"Scanning elements",category:"extraction",actionType:"get_interactable_elements"},{id:"get_screenshot",name:"Get Screenshot",description:"Capture a screenshot of the page",displayAction:"Taking screenshot",category:"extraction",actionType:"get_screenshot"}];function xa(e){return e.includes("__THINKING__")}function ka(e){return xa(e)?e:`${e}\n\n__THINKING__`}function _a(e,t,n,r,o){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(o&&t&&("show"===n||"do"===n))if(e.isPlaceholder){if(void 0!==e.mode&&e.mode!==n)return!1}else if(e.mode!==n)return!1;if(r){const t=e.content.trim().length>0,n=e.parts&&e.parts.length>0;if(!t&&!n)return!1}return!0}function Sa(e){const{messages:t,isTaskRunning:n,currentMode:r,requireContent:o}=e;let i=-1;if(n&&("show"===r||"do"===r)){const e=!0;for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder,d=!o||s.content.trim().length>0||s.parts&&s.parts.length>0;if(c&&l&&d){i=a;break}}if(i<0&&!o)for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder;if(c&&l){i=a;break}}if(i<0)for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder;if(c&&!l){i=a;break}}}if(i<0){for(let e=t.length-1;e>=0;e--){const n=t[e],r="agent"===n.sender,a=n.isPlaceholder,s=!n.isSystemMessage,c=!n.isScreenAccessRequest,l=!o||n.content.trim().length>0||n.parts&&n.parts.length>0;if(r&&a&&s&&c&&l){i=e;break}}if(i<0&&!o)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&n.isPlaceholder&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}if(i<0&&(i=function(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest&&!n.isPlaceholder)return t}return-1}(t)),i<0)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}}return i>=0?{index:i,message:t[i]}:null}function Ia(e){const t={...e};if(!t.parts){t.parts=[];const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts.push({type:"text",content:e})}return t}var Ca=new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Ea=new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function Ta(e){return e?e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\(cancelled by cleanup\)/gi,"").replace(/Cancelled by cleanup/gi,"").replace(/\s+/g," ").trim():e}function Ma(e,t,n,r=!1){const o=Ia(e);if(!t||"show"!==n&&"do"!==n)return xa(o.content)?{...o,content:o.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:o;const i=r?"waiting-for-user":"thinking";return xa(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:ka(o.content),placeholderState:i}}var za=Object.fromEntries(va.map(e=>[e.id,e.displayAction]));var Aa="marketrix_chat_context",Oa={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Na=class e{static instance;context=null;constructor(){this.loadContext()}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadContext(){if("undefined"==typeof window)return this.context={...Oa},this.context;try{const e=localStorage.getItem(Aa);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Oa},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Oa},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Aa,JSON.stringify(this.context))}catch(e){}}getContext(){return this.context?this.context:this.loadContext()}updateContext(e){this.context||this.loadContext();const t=this.context;this.context={...t,...e},this.saveContext()}isValidChatId(e){return"string"==typeof e&&""!==e.trim()}getChatId(){if("undefined"!=typeof window&&this.isValidChatId(window.name)){const e=window.name;return e!==this.getContext().chat_id&&this.updateContext({chat_id:e}),e}return this.getContext().chat_id}setChatId(e){this.updateContext({chat_id:e}),"undefined"!=typeof window&&e&&(window.name=e,window.dispatchEvent(new CustomEvent("marketrix:chatid",{detail:{chatId:e}})))}getMessages(){return this.getContext().messages}setMessages(e){this.updateContext({messages:e})}getChatState(){const e=this.getContext();return{isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading}}setChatState(e){this.updateContext(e)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}clear(){this.context={...Oa},"undefined"!=typeof window&&localStorage.removeItem(Aa)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Ra=class e{static instance;chatId=null;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e}createInitialContext(e){try{if(Na.hasValidContext())return;Na.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}restore(){const e=Na.getContext();return{messages:e.chat_id?e.messages.map(e=>{if(e.id.startsWith("screenshare-"))return{...e,content:"Screenshare ended",videoStream:void 0,isSystemMessage:!0,timestamp:new Date(e.timestamp),parts:[{type:"text",content:"Screenshare ended"}]};const t={...e,timestamp:new Date(e.timestamp),videoStream:void 0,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts||[]};if(0===t.parts?.length&&t.content){const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts&&t.parts.push({type:"text",content:e})}return t}):[],isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading??!1}}persist(e){if(this.chatId)try{const t=e.messages.filter(e=>!e.isPlaceholder||("thinking"===e.placeholderState||"waiting-for-user"===e.placeholderState||(e.parts||[]).length>0)).filter(e=>!(e.isSystemMessage&&"Chat context changed"===e.content)).map(e=>{return{id:e.id,content:(t=e.content,t.replace(/__THINKING__/g,"")),sender:e.sender,timestamp:e.timestamp.toISOString(),mode:e.mode,isScreenAccessRequest:e.isScreenAccessRequest,screenShareStatus:e.screenShareStatus,isSystemMessage:e.isSystemMessage,isPlaceholder:e.isPlaceholder,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts};var t});Na.updateContext({chat_id:this.chatId,messages:t,isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading})}catch(t){}}}.getInstance();function La(e,t,n="user-message"){const r=[],o=e.trim();return o&&r.push({type:"text",content:o}),{id:`${n}-${Date.now()}`,content:o,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:r}}function $a(e,t,n,r="agent-message"){const o=[],i=e.trim();return i&&o.push({type:"text",content:i}),{id:n||`${r}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:o}}function Da(e,t,n="agent",r="system-message"){const o=[];return e&&o.push({type:"text",content:e}),{id:`${r}-${Date.now()}`,content:e,sender:n,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:o}}function Pa(e="show"){const t="Started screenshare";return{id:`started-screenshare-${Date.now()}`,content:t,sender:"user",timestamp:/* @__PURE__ */new Date,mode:e,isSystemMessage:!0,parts:[{type:"text",content:t}]}}function ja(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Fa=wa(),Ua=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Fa.debug("Loaded existing chat ID from storage:",this.chatId))}static getInstance(){return"undefined"==typeof window||"undefined"==typeof document?(e.instance||(e.instance=Object.create(e.prototype),e.instance.chatId=null,e.instance.initializationPromise=null),e.instance):(e.instance||(e.instance=new e),e.instance)}getChatId(){return this.chatId}async getOrCreateChatId(){if(this.chatId)return Fa.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Fa.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Fa.debug("Found chat ID in storage:",this.chatId),this.chatId;this.initializationPromise=this.createChatId();try{return await this.initializationPromise}finally{this.initializationPromise=null}}async createChatId(){try{Fa.info("Creating new chat ID...");const e=await fa.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Fa.info("Created and stored new chat ID:",this.chatId),Ra.createInitialContext(e),e}catch(e){throw Fa.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Na.getChatId()}storeChatId(e){Na.setChatId(e)}}.getInstance(),Ba=class e{static instance=null;abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;isIntentionallyDisconnected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;config;connectionId=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}getStatus(){return this.status}isConnected(){return"registered"===this.status}async connect(e,t){if(this.isIntentionallyDisconnected&&(this.isIntentionallyDisconnected=!1),this.chatId===e&&("connecting"===this.status||"connected"===this.status||"registered"===this.status))return;this.abortController&&(this.abortController.abort(),this.abortController=null),this.chatId=e,t&&(this.config=t),this.setStatus("connecting");const n=++this.connectionId;this.abortController=new AbortController;const r=this.abortController.signal;try{const t={chat_id:e};this.config?.mtxId&&this.config?.mtxKey?(t.marketrix_id=this.config.mtxId,t.marketrix_key=this.config.mtxKey):this.config?.mtxApp&&(t.application_id=this.config.mtxApp);const o=await fa.widgetStream(t,{signal:r});this.setStatus("connected"),this.consumeEvents(o,n)}catch(o){r.aborted||(this.setStatus("error"),this.notifyError(/* @__PURE__ */new Error("Stream connection failed")),this.scheduleReconnect())}}async consumeEvents(e,t){let n=!1;try{for await(const r of e){if(this.connectionId!==t){n=!0;break}this.handleMessage(r)}}catch(r){this.connectionId!==t?n=!0:this.isIntentionallyDisconnected||this.setStatus("error")}finally{n||this.connectionId!==t||this.isIntentionallyDisconnected||(this.setStatus("disconnected"),this.scheduleReconnect())}}disconnect(){this.isIntentionallyDisconnected=!0,this.clearReconnectTimer(),this.abortController&&(this.abortController.abort(),this.abortController=null),this.setStatus("disconnected"),this.chatId=null}send(e){return this.chatId?fa.widgetMessage({chat_id:this.chatId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${String(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(t=>t.onStatusChange?.(e)))}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}handleMessage(e){this.isIntentionallyDisconnected||"heartbeat"!==e.type&&("registered"===e.type&&e.chat_id===this.chatId&&(this.setStatus("registered"),this.reconnectAttempts=0,this.reconnectDelay=1e3,this.callbacks.forEach(t=>t.onRegistered?.(e.application_id))),"chat/error"===e.type&&"auth"===e.request_id&&(this.isIntentionallyDisconnected=!0),this.callbacks.forEach(t=>t.onMessage?.(e)))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.notifyError(/* @__PURE__ */new Error("Max reconnect attempts reached"));this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.isIntentionallyDisconnected&&this.chatId&&this.connect(this.chatId,this.config).catch(console.error)},e)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}},Wa=class{config;constructor(e){this.config=e}getChatId(){return Ua.getChatId()}getUserId(){if(this.config.userId&&"number"==typeof this.config.userId)return this.config.userId;try{const e=localStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}try{const e=sessionStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}return null}async logWidgetQuestion(e,t){try{const n=this.getUserId(),r={question:e,mode:t,chat_id:this.getChatId(),timestamp:/* @__PURE__ */(new Date).toISOString()};null!==n&&(r.user_id=n),this.config.mtxApp&&(r.application_id=this.config.mtxApp),this.config.mtxId&&this.config.mtxKey&&(r.marketrix_id=this.config.mtxId,r.marketrix_key=this.config.mtxKey),fa.activityLogCreate({type:"widget_question",metadata:r}).catch(e=>{})}catch(n){}}async sendMessage(e){if(!(await Ua.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const t=e.mode||"tell";if(e.message&&await this.logWidgetQuestion(e.message,t),!(this.config.mtxId&&this.config.mtxKey||this.config.mtxApp))throw new Error("Either mtxId + mtxKey or mtxApp is required");const n=e.requestId||`req_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,r={type:`chat/${t}`,request_id:n,content:e.message||""};return Ba.getInstance().send(r),{messageId:n,response:"",mode:t,timestamp:/* @__PURE__ */new Date}}updateConfig(e){this.config={...this.config,...e}}},Ha=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Na.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Na.setConfig(e),this.config=e}updateConfig(e){this.config||(this.config={}),this.config={...this.config,...e},this.saveConfig(this.config)}getConfig(){return this.config}shouldShowWidget(){return!!this.config&&(this.config.widget_enabled??!1)}}.getInstance();function Za(e,t={}){return{...t,...e}}function qa(e){if(!(e&&e instanceof Element))return!1;try{const n=e.tagName.toLowerCase(),r="button"===n;if(!(r||"input"===n||"textarea"===n||"select"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||"textbox"===e.getAttribute("role")||"checkbox"===e.getAttribute("role")||"radio"===e.getAttribute("role")||"switch"===e.getAttribute("role")||"tab"===e.getAttribute("role")||"menuitem"===e.getAttribute("role")||"true"===e.getAttribute("contenteditable")||e.hasAttribute("onclick")||e.hasAttribute("tabindex")&&parseInt(e.getAttribute("tabindex")||"-1",10)>=0))return!1;const o=(t,n)=>{if(r){e.tagName,e.id,e.className}};if(!0===e.disabled)return o("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return o("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return o("inert","ancestor is inert"),!1;const e=t instanceof Element?t.getRootNode():null;t=t instanceof Element?t.parentElement||(e instanceof ShadowRoot?e.host:null):null}}catch(t){}const i=e.hasAttribute("onclick");if(r&&i)return!0;let a,s;try{a=window.getComputedStyle(e)}catch(t){return o("computed-style","failed to get computed style"),!1}if("none"===a.display)return o("display","display is none"),!1;if("none"===a.pointerEvents)return o("pointer-events","pointer-events is none"),!1;try{s=e.getBoundingClientRect()}catch(t){return o("bounding-rect","failed to get bounding rect"),!1}if(s.width<=0||s.height<=0)return o("dimensions",`width=${s.width}, height=${s.height}`),!1;try{let t=e;for(;t&&t!==document.body;){const e=t.getRootNode(),n=t.parentElement||(e instanceof ShadowRoot?e.host:null);if(!n)break;let i,a;try{i=window.getComputedStyle(n),a=n.getBoundingClientRect()}catch{t=n;continue}if("hidden"===i.overflow||"clip"===i.overflow){const e=s.right<a.left||s.left>a.right||s.bottom<a.top||s.top>a.bottom;if(r){if(e)return o("overflow-clipping","completely outside parent bounds"),!1}else if(e)return!1}t=n}}catch(t){}try{let t=e.getRootNode();for(;t instanceof ShadowRoot;){const e=t.host;let n;try{n=e.getBoundingClientRect()}catch{break}if(n.width<=0||n.height<=0)return!1;t=e.getRootNode()}}catch(t){}return!0}catch(t){return!1}}var Va=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;indexingInProgress=!1;indexVersion=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}generateSelector(e){if(e.id&&1===document.querySelectorAll(`#${CSS.escape(e.id)}`).length)return`#${CSS.escape(e.id)}`;const t=[];let n=e;for(;n&&n!==document.body&&n.parentElement;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${CSS.escape(n.id)}`,t.unshift(e);break}{const t=n.parentElement;if(!t)break;const r=n.tagName,o=Array.from(t.children).filter(e=>e.tagName===r);if(o.length>1){e+=`:nth-of-type(${o.indexOf(n)+1})`}}t.unshift(e),n=n.parentElement}return t.join(" > ")}generateFingerprint(e,t){return{tagName:e.tagName,id:e.id||null,textContent:((e,t=100)=>{if(!e)return null;const n=e.trim().replace(/\s+/g," ");return n.length>t?n.slice(0,t):n})(e.textContent),type:e.getAttribute("type"),role:e.getAttribute("role"),ariaLabel:e.getAttribute("aria-label"),name:e.getAttribute("name"),href:e.getAttribute("href"),selector:t,indexVersion:this.indexVersion}}matchesFingerprint(e,t){return e.tagName===t.tagName&&(!(!t.id||e.id!==t.id)||(!t.type||e.getAttribute("type")===t.type)&&((!t.ariaLabel||e.getAttribute("aria-label")===t.ariaLabel)&&((!t.role||e.getAttribute("role")===t.role)&&((!t.href||"A"!==t.tagName||e.getAttribute("href")===t.href)&&(!t.name||e.getAttribute("name")===t.name)))))}validateElementAtIndex(e){const t=this.fingerprintMap.get(e);if(!t)return{isValid:!0};const n=this.elementMap.get(e);return n&&document.contains(n)?n instanceof HTMLElement&&!this.matchesFingerprint(n,t)?{isValid:!1,mismatchReason:"element_changed"}:{isValid:!0}:{isValid:!1,mismatchReason:"element_removed"}}indexInteractableElements(){if(this.indexingInProgress)return[];try{this.indexingInProgress=!0,this.clearIndex();const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e instanceof HTMLElement&&null===e.offsetParent&&"BODY"!==e.tagName){const t=window.getComputedStyle(e),n="fixed"===t.position||"sticky"===t.position;if("none"===t.display)return NodeFilter.FILTER_REJECT;if(!n){let t=e.parentElement,n=!1;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if("fixed"===e.position||"sticky"===e.position){n=!0;break}t=t.parentElement}if(!n)return NodeFilter.FILTER_REJECT}}return NodeFilter.FILTER_ACCEPT}});let t=e.nextNode(),n=0;const r=[];for(;t;){if(t instanceof HTMLElement){const e=t.matches('a[href], button, input, textarea, select, [role="button"]'),o=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),i="onclick"in t&&"function"==typeof t.onclick;if(e||o||i||qa(t)){this.elementMap.set(n,t),this.elementToSequence.set(t,n);const e=this.generateSelector(t);this.selectorMap.set(n,e);const o=this.generateFingerprint(t,e);this.fingerprintMap.set(n,o),r.push([n,t]),n++}}t=e.nextNode()}return this.indexVersion++,r}finally{this.indexingInProgress=!1}}getElementCoordinates(e){const t=e.getBoundingClientRect(),n=this.calculateGlobalZOrder(e);return{x:Math.round(t.left),y:Math.round(t.top),w:Math.round(t.width),h:Math.round(t.height),z:n}}isStackingContext(e){const t=window.getComputedStyle(e),n=t.position;if(("fixed"===n||"absolute"===n||"relative"===n||"sticky"===n)&&"auto"!==t.zIndex)return!0;if("auto"!==t.zIndex&&e.parentElement){const t=window.getComputedStyle(e.parentElement).display;if("flex"===t||"inline-flex"===t||"grid"===t||"inline-grid"===t)return!0}const r=parseFloat(t.opacity);if(!isNaN(r)&&r<1)return!0;if(t.transform&&"none"!==t.transform)return!0;if(t.filter&&"none"!==t.filter)return!0;const o=t.willChange;if(o&&(o.includes("transform")||o.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const i=t.contain;return!(!i||!(i.includes("layout")||i.includes("style")||i.includes("paint")))}calculateGlobalZOrder(e){let t=e;const n=[];for(;t&&t!==document.body&&t.parentElement;){const e=window.getComputedStyle(t);if(this.isStackingContext(t)){let r=0;if("auto"!==e.zIndex){const t=parseInt(e.zIndex,10);isNaN(t)||(r=t)}let o=0;t.parentElement&&(o=Array.from(t.parentElement.children).indexOf(t)),n.push({element:t,zIndex:r,domOrder:o})}t=t.parentElement}let r=1e6;for(let o=n.length-1;o>=0;o--){const e=n[o];r+=1e4*e.zIndex+e.domOrder}if(e.parentElement){r+=Array.from(e.parentElement.children).indexOf(e)}return r}getSnapshotHtml(){this.indexInteractableElements();const e=document.documentElement.cloneNode(!0);for(const[n,r]of this.elementMap.entries())if(r instanceof HTMLElement){const o=this.selectorMap.get(n);if(o)try{const t=(e.querySelector("body")||e).querySelector(o);if(t)if(t.setAttribute("data-id",n.toString()),"none"===window.getComputedStyle(r).display)t.setAttribute("data-x","0"),t.setAttribute("data-y","0"),t.setAttribute("data-w","0"),t.setAttribute("data-h","0"),t.setAttribute("data-z","0");else{const e=this.getElementCoordinates(r);t.setAttribute("data-x",e.x.toString()),t.setAttribute("data-y",e.y.toString()),t.setAttribute("data-w",e.w.toString()),t.setAttribute("data-h",e.h.toString()),t.setAttribute("data-z",e.z.toString())}}catch(t){}}return e.outerHTML}getInteractableElements(){this.indexInteractableElements();const e=[];for(const[t,n]of this.elementMap.entries())if(n instanceof HTMLElement){const r=this.fingerprintMap.get(t);r&&e.push({index:t,fingerprint:r,coords:this.getElementCoordinates(n),cssClasses:Array.from(n.classList)})}return e}getSequenceForElement(e){return this.elementToSequence.get(e)}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear()}checkInteractability(e,t){if(!document.body.contains(e))return`ELEMENT_NOT_INTERACTABLE: Element ${t} is not in the DOM`;const n=window.getComputedStyle(e);if("none"===n.display)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has display:none`;if("hidden"===n.visibility)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has visibility:hidden`;if(0===parseFloat(n.opacity))return`ELEMENT_NOT_INTERACTABLE: Element ${t} has opacity:0`;const r=e.getBoundingClientRect();if(0===r.width||0===r.height)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has zero dimensions`;if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth)return`ELEMENT_NOT_INTERACTABLE: Element ${t} is off-screen`;const o=r.left+r.width/2,i=r.top+r.height/2,a=document.elementFromPoint(o,i);if(a&&a!==e&&!e.contains(a)&&!(a.closest("#marketrix-show-highlight")||a.closest("#marketrix-show-popup")||a.closest("[data-marketrix-widget]"))){const e=a.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${a.className?`${e}.${a.className.split(" ")[0]}`:e}. The obscuring element may be a modal or overlay that needs to be dismissed first.`}return null}checkElementInteractable(e,t){return this.checkInteractability(e,t)}getElementByIndex(e){let t=null;if(this.elementMap.has(e)){const n=this.elementMap.get(e);n&&n instanceof HTMLElement&&(t=n)}if(!t&&this.selectorMap.has(e)){const n=this.selectorMap.get(e);if(n)try{const e=document.querySelector(n);e&&e instanceof HTMLElement&&(t=e)}catch(r){}}if(!t)return{element:null,error:`Element ${e} not found`};const n=this.checkInteractability(t,e);return n?{element:null,error:n}:{element:t}}getValidatedElement(e){const t=this.validateElementAtIndex(e);if(!t.isValid)return{element:null,validation:t,error:`DOM_CHANGED: Element at index ${e} ${"element_removed"===t.mismatchReason?"no longer exists":"has changed"}. Call get_html to get updated indices.`};const n=this.elementMap.get(e);if(!n)return{element:null,validation:t,error:`Element ${e} not found`};const r=this.checkInteractability(n,e);return r?{element:null,validation:t,error:r}:{element:n,validation:t}}}.getInstance(),Ga=null;async function Ja(){if(Ga?.active){const e=Ga.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Ga}const e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!e||0===e.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return Ga=e,e.getVideoTracks()[0].addEventListener("ended",()=>{Ga=null}),e}function Ka(){return null!==function(){if(Ga?.active){const e=Ga.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Ga}return Ga=null,null}()}var Ya=class e{static instance;currentPopup=null;currentHighlight=null;currentElement=null;currentOptions=null;currentPromise=null;resolvePromise=null;rejectPromise=null;clickHandler=null;scrollHandler=null;updateHighlightPosition=null;rafId=null;mutationObserver=null;visibilityCheckInterval=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async showToolAction(e){const{element:t,explanation:n,isClickAction:r=!1,toolName:o}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===n&&this.currentOptions.toolName===o&&this.currentPromise||(this.cleanup(),this.currentOptions=e,this.currentElement=t,t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),this.createHighlight(t),this.createPopup(n,r),this.setupPositionUpdates(),this.setupElementMonitoring(),this.setupVisibilityMonitoring(),r&&this.setupClickHandler(),this.currentPromise=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t}).finally(()=>{this.cleanup()})),this.currentPromise}cleanup(){this.rejectPromise&&(this.rejectPromise("Cancelled by cleanup"),this.rejectPromise=null),this.resolvePromise=null,this.clickHandler&&(document.removeEventListener("click",this.clickHandler,{capture:!0}),this.clickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:!0}),window.removeEventListener("resize",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("wheel",this.scrollHandler),this.scrollHandler=null),null!==this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.visibilityCheckInterval&&(clearInterval(this.visibilityCheckInterval),this.visibilityCheckInterval=null),this.updateHighlightPosition=null,this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentHighlight&&(this.currentHighlight.remove(),this.currentHighlight=null);const e=document.getElementById("marketrix-show-popup");e&&e.remove();const t=document.getElementById("marketrix-show-highlight");t&&t.remove(),this.currentElement=null,this.currentOptions=null,this.currentPromise=null,this.resolvePromise=null,this.rejectPromise=null}createHighlight(e){const t=e.getBoundingClientRect(),n=document.createElement("div");n.id="marketrix-show-highlight",n.style.cssText=`\n position: fixed;\n top: ${t.top}px;\n left: ${t.left}px;\n width: ${t.width}px;\n height: ${t.height}px;\n border: 3px solid #3b82f6;\n border-radius: 4px;\n box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.4);\n z-index: 2147483645;\n pointer-events: none;\n transition: none;\n `,document.body.appendChild(n),this.currentHighlight=n}createPopup(e,t){const n=document.createElement("div");n.id="marketrix-show-popup",n.innerHTML=t?`<div style="font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>`:`<div style="margin-bottom: 12px; font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>\n <div style="display: flex; gap: 8px; justify-content: flex-end;">\n <button id="marketrix-show-continue" style="\n background: #3b82f6; color: white; border: none; border-radius: 6px;\n padding: 8px 16px; font-size: 12px; font-weight: 500; cursor: pointer;\n ">Continue</button>\n </div>`,document.body.appendChild(n),this.currentPopup=n,t||this.setupContinueButton(n),this.updatePopupPosition()}setupPositionUpdates(){this.updateHighlightPosition=()=>{if(!this.currentElement||!this.currentHighlight)return;const e=this.currentElement.getBoundingClientRect();this.currentHighlight.style.top=`${e.top}px`,this.currentHighlight.style.left=`${e.left}px`,this.currentHighlight.style.width=`${e.width}px`,this.currentHighlight.style.height=`${e.height}px`,this.updatePopupPosition()},this.scrollHandler=()=>{null!==this.rafId&&window.cancelAnimationFrame(this.rafId),this.updateHighlightPosition?.()},window.addEventListener("scroll",this.scrollHandler,{capture:!0,passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("wheel",this.scrollHandler,{passive:!0})}updatePopupPosition(){if(!this.currentPopup||!this.currentElement)return;const e=this.currentElement.getBoundingClientRect(),t=320,n=120,r=10,o=e.left+e.width/2,i=e.top+e.height/2,a=[{left:e.right+20,top:i-60},{left:e.left-t-20,top:i-60},{left:o-160,top:e.top-n-20},{left:o-160,top:e.bottom+20}];let s=a[0];for(const d of a)if(d.left>=r&&d.left+t<=window.innerWidth-r&&d.top>=r&&d.top+n<=window.innerHeight-r){s=d;break}const c=Math.max(r,Math.min(s.left,window.innerWidth-t-r)),l=Math.max(r,Math.min(s.top,window.innerHeight-n-r));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${l}px;\n left: ${c}px;\n width: 320px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n z-index: 2147483646;\n padding: 16px;\n `}setupClickHandler(){this.clickHandler=e=>{if(this.currentElement&&this.resolvePromise&&e.composedPath().includes(this.currentElement)){e.preventDefault(),e.stopPropagation();const t=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,t(!0)}},document.addEventListener("click",this.clickHandler,{capture:!0})}setupContinueButton(e){window.requestAnimationFrame(()=>{const t=e.querySelector("#marketrix-show-continue");t&&t.addEventListener("click",e=>{if(e.stopPropagation(),this.resolvePromise){const e=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,e(!0)}})})}setupElementMonitoring(){this.currentElement&&(this.mutationObserver=new MutationObserver(()=>{this.currentElement&&!document.body.contains(this.currentElement)&&this.failWithElementGone("Element was removed from DOM")}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}setupVisibilityMonitoring(){this.visibilityCheckInterval=setInterval(()=>{if(!this.currentElement)return;const e=Va.getSequenceForElement(this.currentElement)??-1,t=Va.checkElementInteractable(this.currentElement,e);t&&this.failWithElementGone(t)},200)}failWithElementGone(e){if(this.rejectPromise){const t=this.rejectPromise;this.rejectPromise=null,this.resolvePromise=null,t(/* @__PURE__ */new Error(`ELEMENT_GONE: ${e}`))}this.cleanup()}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}}.getInstance(),Xa=class e{static instance;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async executeTool(e,t,n="do",r=""){try{if("show"===n&&this.requiresHighlight(e)){const n=t.index;if(void 0!==n){const{element:t,error:o}=Va.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await Ya.showToolAction({element:t,explanation:r||`Execute ${e}`,toolName:e,isClickAction:"click_element"===e})))return{success:!1,data:{text:""},error:"User cancelled action"}}}switch(e){case"navigate":return this.navigate(t);case"search":return this.search(t);case"click_element":return await this.clickElement(t);case"type_text":return this.typeText(t);case"scroll":return this.scroll(t);case"scroll_to_text":return this.scrollToText(t);case"extract":return this.extract(t);case"go_back":return this.goBack();case"wait":return await this.wait(t);case"select_dropdown_option":return this.selectDropdownOption(t);case"get_dropdown_options":return this.getDropdownOptions(t);case"send_keys":return this.sendKeys(t);case"upload_file":return this.uploadFile(t);case"close_tab":return this.closeTab();case"switch_tab":return this.switchTab(t);case"done":return this.done(t);case"get_html":return this.getHtml();case"get_interactable_elements":return this.getInteractableElements();case"get_screenshot":return await this.getScreenshot();default:return{success:!1,data:{text:""},error:`Unknown tool: ${e}`}}}catch(o){return Ya.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Ea.has(e)}navigate(e){return e.url?e.new_tab?(window.open(e.url,"_blank"),{success:!0,data:{text:`Opened ${e.url} in new tab`}}):(window.location.href=e.url,{success:!0,data:{text:`Navigating to ${e.url}`}}):{success:!1,data:{text:""},error:"URL is required"}}search(e){if(!e.query)return{success:!1,data:{text:""},error:"Query is required"};const t=e.engine||"duckduckgo",n=encodeURIComponent(e.query);let r=`https://duckduckgo.com/?q=${n}`;return"google"===t&&(r=`https://www.google.com/search?q=${n}`),"bing"===t&&(r=`https://www.bing.com/search?q=${n}`),window.location.href=r,{success:!0,data:{text:`Searching for "${e.query}" on ${t}`}}}async clickElement(e){if(void 0===e.index)return{success:!1,data:{text:""},error:"Index required"};const{element:t,error:n}=Va.getValidatedElement(e.index);return t?(t.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(e=>setTimeout(e,100)),setTimeout(()=>{try{t.click()}catch(e){try{t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}catch(n){}}},50),{success:!0,data:{text:`Clicked element ${e.index}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}typeText(e){if(void 0===e.index||void 0===e.text)return{success:!1,data:{text:""},error:"Index and text required"};const t=!1!==e.clear,{element:n,error:r}=Va.getValidatedElement(e.index);if(!n)return{success:!1,data:{text:""},error:r||`Element ${e.index} not found`};if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n.isContentEditable){const r=n;try{r.focus()}catch(o){}const i=t?e.text:r.value+e.text;let a=!1,s=null;if(!a)try{const e="TEXTAREA"===r.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(r,i),a=!0)}catch(o){s=o}if(!a)try{r.value=i,a=!0}catch(o){s=o}if(!a)try{r.focus(),t&&r.select(),document.execCommand("insertText",!1,e.text)&&(a=!0)}catch(o){s=o}if(!a)try{r.focus(),t&&(r.value="");for(const t of e.text)r.dispatchEvent(new KeyboardEvent("keydown",{key:t,bubbles:!0,cancelable:!0})),r.value+=t,r.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),r.dispatchEvent(new KeyboardEvent("keyup",{key:t,bubbles:!0,cancelable:!0}));a=!0}catch(o){s=o}if(!a)return{success:!1,data:{text:""},error:`Failed to set value: ${s instanceof Error?s.message:String(s)}`};try{const t=new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:e.text});r.dispatchEvent(t),r.dispatchEvent(new Event("change",{bubbles:!0})),r.dispatchEvent(new Event("blur",{bubbles:!0}))}catch(o){}}else if("value"in n)try{n.value=e.text,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set value on element: ${o instanceof Error?o.message:String(o)}`}}else try{n.textContent=e.text,n.dispatchEvent(new Event("input",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set textContent: ${o instanceof Error?o.message:String(o)}`}}return{success:!0,data:{text:`Typed text into element ${e.index}`}}}scroll(e){const t=.8*window.innerHeight;switch(e.direction){case"down":window.scrollBy({top:t,behavior:"smooth"});break;case"up":window.scrollBy({top:-t,behavior:"smooth"});break;case"left":window.scrollBy({left:-t,behavior:"smooth"});break;case"right":window.scrollBy({left:t,behavior:"smooth"});break;default:return{success:!1,data:{text:""},error:"Invalid direction"}}return{success:!0,data:{text:`Scrolled ${e.direction}`}}}scrollToText(e){if(!e.text)return{success:!1,data:{text:""},error:"Text required"};const t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT);let n;for(;n=t.nextNode();)if(n.textContent?.includes(e.text)&&n.parentElement)return n.parentElement.scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,data:{text:`Scrolled to "${e.text}"`}};return{success:!1,data:{text:""},error:`Text "${e.text}" not found`}}extract(e){const t=e.start_from_char??0,n=!1!==e.extract_links,r=document.body.innerText;return{success:!0,data:{title:document.title,url:window.location.href,text:r.slice(t,t+1e4),links:n?Array.from(document.querySelectorAll("a[href]")).slice(0,100).map(e=>({text:e.textContent?.trim()||"",href:e.getAttribute("href")})):[]}}}goBack(){return window.history.length>1?(window.history.back(),{success:!0,data:{text:"Navigated back"}}):{success:!1,data:{text:""},error:"No history"}}async wait(e){return void 0===e.seconds?{success:!1,data:{text:""},error:"Seconds required"}:(await new Promise(t=>setTimeout(t,1e3*e.seconds)),{success:!0,data:{text:`Waited ${e.seconds}s`}})}selectDropdownOption(e){if(void 0===e.index||!e.option)return{success:!1,data:{text:""},error:"Index/Option required"};const{element:t,error:n}=Va.getValidatedElement(e.index);if(!t)return{success:!1,data:{text:""},error:n||`Select ${e.index} not found`};if(!(t instanceof HTMLSelectElement))return{success:!1,data:{text:""},error:`Element ${e.index} is not a select element`};const r=Array.from(t.options).find(t=>t.value===e.option||t.text===e.option);return r?(t.value=r.value,t.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,data:{text:`Selected ${e.option}`}}):{success:!1,data:{text:""},error:`Option ${e.option} not found`}}getDropdownOptions(e){const t=e.index,{element:n,error:r}=Va.getValidatedElement(t);return n?n instanceof HTMLSelectElement?{success:!0,data:{options:Array.from(n.options).map(e=>({value:e.value,text:e.text}))}}:{success:!1,data:{options:[]},error:`Element ${t} is not a select element`}:{success:!1,data:{options:[]},error:r||`Select ${t} not found`}}sendKeys(e){if(void 0===e.index||!e.keys)return{success:!1,data:{text:""},error:"Index/Keys required"};const{element:t,error:n}=Va.getValidatedElement(e.index);return t?(t.focus(),t.dispatchEvent(new KeyboardEvent("keydown",{key:e.keys,bubbles:!0,cancelable:!0})),t.dispatchEvent(new KeyboardEvent("keyup",{key:e.keys,bubbles:!0,cancelable:!0})),{success:!0,data:{text:this.simulateKeyAction(t,e.keys)||`Sent keys ${e.keys}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}simulateKeyAction(e,t){switch(t){case"Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(-1!==n&&n<t.length-1){const e=t[n+1];return e.focus(),`Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Tab: no next focusable element"}case"Shift+Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(n>0){const e=t[n-1];return e.focus(),`Shift+Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Shift+Tab: no previous focusable element"}case"Enter":if(e instanceof HTMLButtonElement||"button"===e.getAttribute("role"))return e.click(),"Enter: clicked button";if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.closest("form");if(t){const e=t.querySelector('button[type="submit"], input[type="submit"]');return e?(e.click(),"Enter: clicked form submit button"):(t.requestSubmit(),"Enter: submitted form")}}return e instanceof HTMLAnchorElement?(e.click(),"Enter: clicked link"):"Enter: dispatched event";case"Escape":return e.blur(),document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0,cancelable:!0})),"Escape: blurred element and dispatched to document";case" ":case"Space":return e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?(e.click(),`Space: toggled ${e.type}`):e instanceof HTMLButtonElement||"button"===e.getAttribute("role")?(e.click(),"Space: clicked button"):"Space: dispatched event";case"ArrowDown":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t<e.options.length-1?(e.selectedIndex=t+1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowDown: selected "${e.options[e.selectedIndex].text}"`):"ArrowDown: already at last option"}return"ArrowDown: dispatched event";case"ArrowUp":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t>0?(e.selectedIndex=t-1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowUp: selected "${e.options[e.selectedIndex].text}"`):"ArrowUp: already at first option"}return"ArrowUp: dispatched event";case"Home":return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?(e.setSelectionRange(0,0),"Home: moved cursor to start"):"Home: dispatched event";case"End":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value.length;return e.setSelectionRange(t,t),"End: moved cursor to end"}return"End: dispatched event";case"Backspace":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value;if(!t||0===t.length)return"Backspace: input is empty, nothing to delete";let n,r,o=e.selectionStart??t.length,i=e.selectionEnd??t.length;if(0===o&&0===i&&(o=t.length,i=t.length),o===i&&o>0)n=t.slice(0,o-1)+t.slice(i),r=o-1;else{if(o===i)return"Backspace: cursor at start, nothing to delete";n=t.slice(0,o)+t.slice(i),r=o}const a=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return a?a.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(r,r),`Backspace: deleted character, value is now "${n}"`}return"Backspace: dispatched event";case"Delete":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.selectionStart||0,n=e.selectionEnd||0,r=e.value;let o;if(t===n&&t<r.length)o=r.slice(0,t)+r.slice(n+1);else{if(t===n)return"Delete: cursor at end, nothing to delete";o=r.slice(0,t)+r.slice(n)}const i=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return i?i.call(e,o):e.value=o,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${o}"`}return"Delete: dispatched event";default:return null}}uploadFile(e){return{success:!1,data:{text:""},error:"File upload not supported via script"}}closeTab(){return window.close(),{success:!0,data:{text:"Attempted close"}}}switchTab(e){return e.tab_id?{success:!1,data:{text:""},error:"Tab switching not supported"}:{success:!1,data:{text:""},error:"tab_id is required"}}done(e){return void 0===e.success?{success:!1,data:{text:""},error:"success parameter is required"}:{success:!0,data:{text:e.message||(e.success?"Task completed":"Task failed")}}}getHtml(){try{return{success:!0,data:{text:Va.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Va.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Ja();if(!e)return{success:!1,data:{text:""},error:"Failed to get stream"};const t=document.createElement("video");t.srcObject=e,t.autoplay=!0,t.style.display="none",document.body.appendChild(t),await new Promise(e=>{t.onloadeddata=()=>e()});const n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d")?.drawImage(t,0,0);const r=n.toDataURL("image/jpeg",.75);return t.remove(),{success:!0,data:{text:r}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}}.getInstance(),Qa=e=>({state:e,effects:[]});function es(e,t,n,r,o,i,a){const s=function(e){return za[e]?za[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Sa({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Ea.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=Ia(e),o=r.parts||[],i=[...o],a=o.findIndex(e=>"progress"===e.type&&e.toolName===t&&"in_progress"===e.status),s=!Ca.has(t),c="default",l=Ta(n);return a>=0?i[a]={...i[a],content:l,hideIcon:s,textStyle:c}:i.push({type:"progress",content:l,status:"in_progress",toolName:t,hideIcon:s,textStyle:c}),{...r,parts:i}}(l,s,o||s)),t&&p&&(l=Ma(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=Ia(e),r=n.parts||[],o=[...r];let i=-1;if(t)i=r.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);else for(let a=r.length-1;a>=0;a--)if("progress"===r[a].type&&"in_progress"===r[a].status){i=a;break}return i>=0&&(o[i]={...o[i],status:"completed"}),{...n,parts:o}}(l)),t&&p&&(l=Ma(l,t,n,!1))):(l=function(e,t,n){const r=Ia(e),o=r.parts||[],i=n.toLowerCase().includes("cancelled by cleanup"),a=[...o];let s=o.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);if(-1===s)for(let c=o.length-1;c>=0;c--)if("progress"===o[c].type&&"in_progress"===o[c].status){s=c;break}if(s>=0)if(i){const e=Ta(a[s].content);a[s]={...a[s],status:"completed",content:e}}else{const e=Ta(n),t=Ta(a[s].content);a[s]={...a[s],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:a}}(l,s,a||""),t&&p&&(l=Ma(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function ts(e,t,n,r,o,i){return{...e,messages:es(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ns=n(void 0),rs={activeTaskId:null,isTaskRunning:!1},os=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:a})=>{const[c,l]=p(()=>({messages:o??[],task:a??rs})),h=u(c);h.current=c;const m=u(n);m.current=n;const g=u(0),y=u(/* @__PURE__ */new Set),b=u({}),w=i(e=>{l(t=>{const n=e(t);return n===t||n.messages===t.messages&&n.task===t.task?t:(h.current=n,n)})},[]),v=i(e=>{w(t=>({...t,messages:[...t.messages,e]}))},[w]),x=i((e,t)=>{w(n=>({...n,messages:n.messages.map(n=>n.id===e?{...n,...t}:n)}))},[w]),k=i(e=>{w(t=>({...t,messages:t.messages.filter(t=>t.id!==e)}))},[w]),_=i(e=>{w(t=>({...t,messages:e}))},[w]),S=i(()=>{w(e=>({...e,messages:[]}))},[w]),I=i(e=>{w(t=>({...t,task:{activeTaskId:e.activeTaskId,isTaskRunning:e.isTaskRunning}}))},[w]),C=i(async(e,n,o,i,a)=>{const s=n??m.current;if(t)return a||v(La(e,s)),void v($a("This is a preview. In production, I'll respond to your messages here."));let c=Ha.getConfig();if(c||(c=Ha.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void v($a("Configuration error: Missing API credentials. Please check your widget settings."));a||v(La(e,s));const l=`temp-${globalThis.crypto.randomUUID()}`;v({id:l,content:ka(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:s,isPlaceholder:!0,placeholderState:"thinking",parts:[]}),r.setLoading(!0);const d=new Wa(c);try{o&&d.updateConfig({mtxApp:o});const t=d.getChatId();if(t){const e=Ba.getInstance();if(!e.isConnected()){const n=Ha.getConfig();try{await e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0)}catch(u){}}}await d.sendMessage({message:e,mode:s,question:i,requestId:l})}catch(p){w(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.",n=e.messages.map(e=>{if(e.id!==l)return e;const n=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:n,content:t}});return{...e,messages:n}})}finally{r.setLoading(!1)}},[t,v,w,r]),E=i(e=>{if(y.current.add(e),y.current.size>1e3){const e=Array.from(y.current);y.current=new Set(e.slice(-500))}},[]),T=i(()=>{const e=b.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;b.current={},w(e=>({...e,task:{isTaskRunning:!0,activeTaskId:t}}))}},[w]);s(()=>{if(t)return;const e=Ba.getInstance(),n=async t=>{const{callId:n,tool:r,args:o,mode:i,explanation:a}=t,s=await Xa.executeTool(r,o,i,a);if(s.success)try{g.current++,e.send({type:"tool/response",call_id:n,success:!0,data:"string"==typeof s.data?s.data:JSON.stringify(s.data),state_version:g.current}).catch(e=>{}),w(e=>ts(e,r,a,"completed",m.current)),"done"===r&&(b.current={},w(e=>function(e,t){const n=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];if(n){const e=(n.message.parts??[]).filter(e=>!("progress"===e.type&&"done"===e.toolName));r[n.index]={...n.message,taskStatus:"done",parts:e}}return{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,m.current)))}catch(c){w(e=>ts(e,r,a,"failed",m.current,"Connection error"))}else w(e=>ts(e,r,a,"failed",m.current,s.error||"Tool execution failed")),g.current++,e.send({type:"tool/response",call_id:n,success:!1,data:"string"==typeof s.data?s.data:JSON.stringify(s.data),error:s.error??void 0,state_version:g.current}).catch(e=>{})},o={onStatusChange:e=>{r.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const n=t.call_id;if(y.current.has(n))return;if(E(n),!va.map(e=>e.id).includes(t.tool))return void e.send({type:"tool/response",call_id:n,success:!1,error:`Unknown tool: ${t.tool}`,state_version:g.current}).catch(e=>{});h.current.task.isTaskRunning,void 0!==t.state_version&&t.state_version>g.current&&(g.current=t.state_version)}else if("task/status"!==t.type||"completed"!==t.status&&"failed"!==t.status&&"stopped"!==t.status){if("task/status"===t.type&&"has_question"===t.status)b.current={};else if("task/status"===t.type&&"running"===t.status)return b.current={...b.current,agentRunning:!0,apiTaskId:b.current.apiTaskId||t.task_id||void 0},void T()}else y.current.clear(),b.current={};let o=[];w(e=>{const n=function(e,t,n){switch(t.type){case"tool/call":{const r=e.task.isTaskRunning?e.task:{...e.task,isTaskRunning:!0},o=r.isTaskRunning,i=t.mode||n||"do",a=t.explanation||"";return{state:{messages:es(e.messages,o,n,t.tool,a,"in_progress"),task:r},effects:[{type:"executeTool",callId:t.call_id,tool:t.tool,args:t.args,mode:i,explanation:a}]}}case"task/status":{const r=t.message||"";if("running"===t.status)return Qa(e);if("has_question"===t.status){const t=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=Ma(t.message,!1,n);o[t.index]={...e,placeholderState:"waiting-for-user",...r&&{content:r}}}return{state:{messages:o,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}const o=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),i=[...e.messages];if(o){let e="done";"failed"===t.status?e="failed":"stopped"===t.status&&(e="stopped"),i[o.index]={...o.message,taskStatus:e,...r&&{content:r}}}return{state:{messages:i,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}case"chat/response":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=[...e.parts??[],{type:"text",content:t.text}];return{...e,content:t.text,isPlaceholder:!1,placeholderState:void 0,parts:n,...t.task_id&&{taskId:t.task_id}}}),r=[{type:"setLoading",value:!1}];return t.task_id&&r.push({type:"activateApiTask",taskId:t.task_id}),{state:{...e,messages:n},effects:r}}case"chat/error":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=`Error: ${t.error}`,r=[...e.parts??[],{type:"text",content:n}];return{...e,content:n,isPlaceholder:!1,placeholderState:void 0,parts:r}});return{state:{...e,messages:n},effects:[{type:"setLoading",value:!1}]}}default:return Qa(e)}}(e,t,m.current);return o=n.effects,n.state}),(e=>{for(const t of e)"setLoading"===t.type?r.setLoading(t.value):"activateApiTask"===t.type&&(b.current={...b.current,apiTaskId:t.taskId},T())})(o);const i=o.find(e=>"executeTool"===e.type);"executeTool"===i?.type&&await n(i)},onError:e=>{r.setError(e.message)}};return e.addCallbacks(o),()=>{e.removeCallbacks(o)}},[t,w,T,E,r]);const M=i(async()=>{const e=h.current.task.activeTaskId??void 0;w(e=>function(e,t){const n=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];return n&&(r[n.index]={...n.message,taskStatus:"stopped"}),{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,m.current)),t||Ba.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,w]),z=d(()=>({addMessage:v,updateMessage:x,removeMessage:k,setMessages:_,clearMessages:S,sendMessage:C}),[v,x,k,_,S,C]),A=d(()=>({setTaskState:I,stopTask:M}),[I,M]),O=d(()=>({messages:c.messages}),[c.messages]);/* @__PURE__ */
|
|
3
3
|
return f(ns.Provider,{value:{chatState:O,chatActions:z,taskState:c.task,taskActions:A},children:e})},is=()=>{const e=a(ns);if(!e)throw new Error("useConversationContext must be used within ConversationProvider");return e},as=n(void 0),ss=({children:e,initialMode:t="tell",initialIsOpen:n=!1,initialIsMinimized:r=!1})=>{const[o,i]=p({isOpen:n,isMinimized:r,activeView:"home",currentMode:t,agentAvailable:!1,isLoading:!1}),a=d(()=>({setActiveView:e=>i(t=>({...t,activeView:e})),toggleWidget:()=>i(e=>({...e,isOpen:!e.isOpen,isMinimized:!!e.isOpen})),closeWidget:()=>i(e=>({...e,isOpen:!1,isMinimized:!0})),setMode:e=>i(t=>({...t,currentMode:e})),setLoading:e=>i(t=>({...t,isLoading:e})),setAgentAvailable:e=>i(t=>({...t,agentAvailable:e})),setError:e=>i(t=>({...t,error:e})),clearError:()=>i(e=>({...e,error:void 0})),applyState:e=>i(t=>({...t,...e}))}),[]);/* @__PURE__ */
|
|
4
4
|
return f(as.Provider,{value:{uiState:o,uiActions:a},children:e})},cs=()=>{const e=a(as);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var ls=({config:e}={})=>{const{uiState:t,uiActions:n}=cs(),{chatState:r,chatActions:o,taskState:a,taskActions:c}=is(),l=d(()=>({isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading,currentMode:t.currentMode,agentAvailable:t.agentAvailable,error:t.error,activeView:t.activeView,messages:r.messages,activeTaskId:a.activeTaskId,isTaskRunning:a.isTaskRunning}),[t,r,a]),u=i(()=>{o.clearMessages(),c.setTaskState({activeTaskId:null,isTaskRunning:!1}),n.setError(void 0)},[o,c,n]),p=d(()=>({setActiveView:n.setActiveView,toggleWidget:n.toggleWidget,closeWidget:n.closeWidget,setMode:n.setMode,setLoading:n.setLoading,setAgentAvailable:n.setAgentAvailable,setError:n.setError,clearError:n.clearError,setTaskState:c.setTaskState,stopTask:c.stopTask,addMessage:o.addMessage,updateMessage:o.updateMessage,removeMessage:o.removeMessage,setMessages:o.setMessages,sendMessage:o.sendMessage,clearChatHistory:u}),[n,c,o,u]),h=d(()=>e||Ha.getConfig()||{},[e]),m=function(e){return Object.keys(sa.shape).every(t=>void 0!==e[t])}(h);s(()=>{m&&Ha.saveConfig(h)},[h,m]);const f=h.isPreviewMode??!1;return{state:l,actions:p,config:h,shouldShow:m&&!0===h.widget_enabled,isPreviewMode:f,configValid:m}},ds=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),us="-",ps=[],hs=e=>{const t=gs(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return fs(e);const n=e.split(us);return ms(n,""===n[0]&&n.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=r[e],o=n[e];return t?o?((e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n})(o,t):t:o||ps}return n[e]||ps}}},ms=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],o=n.nextPart.get(r);if(o){const n=ms(e,t+1,o);if(n)return n}const i=n.validators;if(null===i)return;const a=0===t?e.join(us):e.slice(t).join(us),s=i.length;for(let c=0;c<s;c++){const e=i[c];if(e.validator(a))return e.classGroupId}},fs=e=>-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?"arbitrary.."+r:void 0})(),gs=e=>{const{theme:t,classGroups:n}=e;return ys(n,t)},ys=(e,t)=>{const n=ds();for(const r in e){const o=e[r];bs(o,n,r,t)}return n},bs=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const o=e[i];ws(o,t,n,r)}},ws=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?ks(e,t,n,r):xs(e,t,n,r):vs(e,t,n)},vs=(e,t,n)=>{(""===e?t:_s(t,e)).classGroupId=n},xs=(e,t,n,r)=>{Ss(e)?bs(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},ks=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[e,i]=o[a];bs(i,_s(t,e),n,r)}},_s=(e,t)=>{let n=e;const r=t.split(us),o=r.length;for(let i=0;i<o;i++){const e=r[i];let t=n.nextPart.get(e);t||(t=ds(),n.nextPart.set(e,t)),n=t}return n},Ss=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Is=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(o,i)=>{n[o]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];return void 0!==t?t:void 0!==(t=r[e])?(o(e,t),t):void 0},set(e,t){e in n?n[e]=t:o(e,t)}}},Cs=[],Es=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Ts=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=e=>{const t=[];let n,r=0,o=0,i=0;const a=e.length;for(let d=0;d<a;d++){const a=e[d];if(0===r&&0===o){if(":"===a){t.push(e.slice(i,d)),i=d+1;continue}if("/"===a){n=d;continue}}"["===a?r++:"]"===a?r--:"("===a?o++:")"===a&&o--}const s=0===t.length?e:e.slice(i);let c=s,l=!1;s.endsWith("!")?(c=s.slice(0,-1),l=!0):s.startsWith("!")&&(c=s.slice(1),l=!0);return Es(t,l,c,n&&n>i?n-i:void 0)};if(t){const e=t+":",n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Es(Cs,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},Ms=e=>{const t=/* @__PURE__ */new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{const n=[];let r=[];for(let o=0;o<e.length;o++){const i=e[o],a="["===i[0],s=t.has(i);a||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(i)):r.push(i)}return r.length>0&&(r.sort(),n.push(...r)),n}},zs=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},As=/\s+/,Os=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Os(e[r]))&&(n&&(n+=" "),n+=t);return n},Ns=(e,...t)=>{let n,r,o,i;const a=e=>{const t=r(e);if(t)return t;const i=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i,postfixLookupClassGroupIds:a}=t,s=[],c=e.trim().split(As);let l="";for(let d=c.length-1;d>=0;d-=1){const e=c[d],{isExternal:t,modifiers:u,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:m}=n(e);if(t){l=e+(l.length>0?" "+l:l);continue}let f,g=!!m;if(g){f=r(h.substring(0,m));const e=f&&a[f]?r(h):void 0;e&&e!==f&&(f=e,g=!1)}else f=r(h);if(!f){if(!g){l=e+(l.length>0?" "+l:l);continue}if(f=r(h),!f){l=e+(l.length>0?" "+l:l);continue}g=!1}const y=0===u.length?"":1===u.length?u[0]:i(u).join(":"),b=p?y+"!":y,w=b+f;if(s.indexOf(w)>-1)continue;s.push(w);const v=o(f,g);for(let n=0;n<v.length;++n){const e=v[n];s.push(b+e)}l=e+(l.length>0?" "+l:l)}return l})(e,n);return o(e,i),i};return i=s=>(n=(e=>({cache:Is(e.cacheSize),parseClassName:Ts(e),sortModifiers:Ms(e),postfixLookupClassGroupIds:zs(e),...hs(e)}))(t.reduce((e,t)=>t(e),e())),r=n.cache.get,o=n.cache.set,i=a,a(s)),(...e)=>i(((...e)=>{let t,n,r=0,o="";for(;r<e.length;)(t=e[r++])&&(n=Os(t))&&(o&&(o+=" "),o+=n);return o})(...e))},Rs=[],Ls=e=>{const t=t=>t[e]||Rs;return t.isThemeGetter=!0,t},$s=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ds=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ps=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,js=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fs=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Us=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Bs=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ws=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Hs=e=>Ps.test(e),Zs=e=>!!e&&!Number.isNaN(Number(e)),qs=e=>!!e&&Number.isInteger(Number(e)),Vs=e=>e.endsWith("%")&&Zs(e.slice(0,-1)),Gs=e=>js.test(e),Js=()=>!0,Ks=e=>Fs.test(e)&&!Us.test(e),Ys=()=>!1,Xs=e=>Bs.test(e),Qs=e=>Ws.test(e),ec=e=>!rc(e)&&!uc(e),tc=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),nc=e=>wc(e,_c,Ys),rc=e=>$s.test(e),oc=e=>wc(e,Sc,Ks),ic=e=>wc(e,Ic,Zs),ac=e=>wc(e,Ec,Js),sc=e=>wc(e,Cc,Ys),cc=e=>wc(e,xc,Ys),lc=e=>wc(e,kc,Qs),dc=e=>wc(e,Tc,Xs),uc=e=>Ds.test(e),pc=e=>vc(e,Sc),hc=e=>vc(e,Cc),mc=e=>vc(e,xc),fc=e=>vc(e,_c),gc=e=>vc(e,kc),yc=e=>vc(e,Tc,!0),bc=e=>vc(e,Ec,!0),wc=(e,t,n)=>{const r=$s.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},vc=(e,t,n=!1)=>{const r=Ds.exec(e);return!!r&&(r[1]?t(r[1]):n)},xc=e=>"position"===e||"percentage"===e,kc=e=>"image"===e||"url"===e,_c=e=>"length"===e||"size"===e||"bg-size"===e,Sc=e=>"length"===e,Ic=e=>"number"===e,Cc=e=>"family-name"===e,Ec=e=>"number"===e||"weight"===e,Tc=e=>"shadow"===e,Mc=/*#__PURE__*/Ns(()=>{const e=Ls("color"),t=Ls("font"),n=Ls("text"),r=Ls("font-weight"),o=Ls("tracking"),i=Ls("leading"),a=Ls("breakpoint"),s=Ls("container"),c=Ls("spacing"),l=Ls("radius"),d=Ls("shadow"),u=Ls("inset-shadow"),p=Ls("text-shadow"),h=Ls("drop-shadow"),m=Ls("blur"),f=Ls("perspective"),g=Ls("aspect"),y=Ls("ease"),b=Ls("animate"),w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",uc,rc],v=()=>[uc,rc,c],x=()=>[Hs,"full","auto",...v()],k=()=>[qs,"none","subgrid",uc,rc],_=()=>["auto",{span:["full",qs,uc,rc]},qs,uc,rc],S=()=>[qs,"auto",uc,rc],I=()=>["auto","min","max","fr",uc,rc],C=()=>["auto",...v()],E=()=>[Hs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],T=()=>[Hs,"screen","full","dvw","lvw","svw","min","max","fit",...v()],M=()=>[Hs,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],z=()=>[e,uc,rc],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",mc,cc,{position:[uc,rc]}],O=()=>["auto","cover","contain",fc,nc,{size:[uc,rc]}],N=()=>[Vs,pc,oc],R=()=>["","none","full",l,uc,rc],L=()=>["",Zs,pc,oc],$=()=>[Zs,Vs,mc,cc],D=()=>["","none",m,uc,rc],P=()=>["none",Zs,uc,rc],j=()=>["none",Zs,uc,rc],F=()=>[Zs,uc,rc],U=()=>[Hs,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Gs],breakpoint:[Gs],color:[Js],container:[Gs],"drop-shadow":[Gs],ease:["in","out","in-out"],font:[ec],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Gs],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Gs],shadow:[Gs],spacing:["px",Zs],text:[Gs],"text-shadow":[Gs],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Hs,rc,uc,g]}],container:["container"],"container-type":[{"@container":["","normal","size",uc,rc]}],"container-named":[tc],columns:[{columns:[Zs,rc,uc,s]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:w()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:x()}],"inset-x":[{"inset-x":x()}],"inset-y":[{"inset-y":x()}],start:[{"inset-s":x(),start:x()}],end:[{"inset-e":x(),end:x()}],"inset-bs":[{"inset-bs":x()}],"inset-be":[{"inset-be":x()}],top:[{top:x()}],right:[{right:x()}],bottom:[{bottom:x()}],left:[{left:x()}],visibility:["visible","invisible","collapse"],z:[{z:[qs,"auto",uc,rc]}],basis:[{basis:[Hs,"full","auto",s,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Zs,Hs,"auto","initial","none",rc]}],grow:[{grow:["",Zs,uc,rc]}],shrink:[{shrink:["",Zs,uc,rc]}],order:[{order:[qs,"first","last","none",uc,rc]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:_()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:_()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:E()}],"inline-size":[{inline:["auto",...T()]}],"min-inline-size":[{"min-inline":["auto",...T()]}],"max-inline-size":[{"max-inline":["none",...T()]}],"block-size":[{block:["auto",...M()]}],"min-block-size":[{"min-block":["auto",...M()]}],"max-block-size":[{"max-block":["none",...M()]}],w:[{w:[s,"screen",...E()]}],"min-w":[{"min-w":[s,"screen","none",...E()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[a]},...E()]}],h:[{h:["screen","lh",...E()]}],"min-h":[{"min-h":["screen","lh","none",...E()]}],"max-h":[{"max-h":["screen","lh",...E()]}],"font-size":[{text:["base",n,pc,oc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,bc,ac]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Vs,rc]}],"font-family":[{font:[hc,sc,t]}],"font-features":[{"font-features":[rc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,uc,rc]}],"line-clamp":[{"line-clamp":[Zs,"none",uc,ic]}],leading:[{leading:[i,...v()]}],"list-image":[{"list-image":["none",uc,rc]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",uc,rc]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[Zs,"from-font","auto",uc,oc]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[Zs,"auto",uc,rc]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[qs,uc,rc]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",uc,rc]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",uc,rc]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:A()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:O()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qs,uc,rc],radial:["",uc,rc],conic:[qs,uc,rc]},gc,lc]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":L()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-bs":[{"border-bs":z()}],"border-color-be":[{"border-be":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Zs,uc,rc]}],"outline-w":[{outline:["",Zs,pc,oc]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",d,yc,dc]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",u,yc,dc]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[Zs,oc]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",p,yc,dc]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[Zs,uc,rc]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Zs]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[uc,rc]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[Zs]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:A()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",uc,rc]}],filter:[{filter:["","none",uc,rc]}],blur:[{blur:D()}],brightness:[{brightness:[Zs,uc,rc]}],contrast:[{contrast:[Zs,uc,rc]}],"drop-shadow":[{"drop-shadow":["","none",h,yc,dc]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",Zs,uc,rc]}],"hue-rotate":[{"hue-rotate":[Zs,uc,rc]}],invert:[{invert:["",Zs,uc,rc]}],saturate:[{saturate:[Zs,uc,rc]}],sepia:[{sepia:["",Zs,uc,rc]}],"backdrop-filter":[{"backdrop-filter":["","none",uc,rc]}],"backdrop-blur":[{"backdrop-blur":D()}],"backdrop-brightness":[{"backdrop-brightness":[Zs,uc,rc]}],"backdrop-contrast":[{"backdrop-contrast":[Zs,uc,rc]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Zs,uc,rc]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Zs,uc,rc]}],"backdrop-invert":[{"backdrop-invert":["",Zs,uc,rc]}],"backdrop-opacity":[{"backdrop-opacity":[Zs,uc,rc]}],"backdrop-saturate":[{"backdrop-saturate":[Zs,uc,rc]}],"backdrop-sepia":[{"backdrop-sepia":["",Zs,uc,rc]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",uc,rc]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Zs,"initial",uc,rc]}],ease:[{ease:["linear","initial",y,uc,rc]}],delay:[{delay:[Zs,uc,rc]}],animate:[{animate:["none",b,uc,rc]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,uc,rc]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:P()}],"rotate-x":[{"rotate-x":P()}],"rotate-y":[{"rotate-y":P()}],"rotate-z":[{"rotate-z":P()}],scale:[{scale:j()}],"scale-x":[{"scale-x":j()}],"scale-y":[{"scale-y":j()}],"scale-z":[{"scale-z":j()}],"scale-3d":["scale-3d"],skew:[{skew:F()}],"skew-x":[{"skew-x":F()}],"skew-y":[{"skew-y":F()}],transform:[{transform:[uc,rc,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:U()}],"translate-x":[{"translate-x":U()}],"translate-y":[{"translate-y":U()}],"translate-z":[{"translate-z":U()}],"translate-none":["translate-none"],zoom:[{zoom:[qs,uc,rc]}],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",uc,rc]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":z()}],"scrollbar-track-color":[{"scrollbar-track":z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",uc,rc]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[Zs,pc,oc,ic]}],stroke:[{stroke:["none",...z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function zc(...e){return Mc(e.filter(Boolean).join(" "))}var Ac={none:"none",card:"0 1px 4px rgba(0,0,0,0.1)",section:"0 2px 8px rgba(0,0,0,0.06)",panel:"0 12px 40px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.08)",fab:"0 2px 8px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04)",button:"0 4px 6px -1px rgba(0,0,0,0.1)"},Oc={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",theme:"rounded-[var(--radius)]",pill:"rounded-full",circle:"rounded-full"},Nc={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Rc={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Lc={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},$c={info:{background:"#f0f9ff",border:"1px solid #bae6fd",titleColor:"#0c4a6e",bodyColor:"#0369a1",closeColor:"#7dd3fc",closeHoverColor:"#38bdf8",actionBackground:"#e0f2fe"},error:{background:"#fef2f2",border:"1px solid #fecaca",titleColor:"#b91c1c",bodyColor:"#b91c1c",closeColor:"#f87171",closeHoverColor:"#ef4444",actionBackground:"#fee2e2"}};function Dc(e){if(e&&"none"!==e)return{boxShadow:Ac[e]}}var Pc={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},jc=new Set(["padding","paddingX","paddingY","paddingTop","paddingBottom","margin","marginX","marginY","marginTop","marginBottom","gap","align","justify","wrap","grow","shrink","position","inset","overflow","overflowY","width","height","minWidth","minHeight","border","rounded","shadow","cursor","opacity","animate","hidden","as","style"]);function Fc(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Pc[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Pc[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Pc[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Pc[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Pc[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Pc[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Pc[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Pc[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Pc[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Pc[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Pc[e.gap]}`),void 0!==e.align&&t.push(`items-${e.align}`),void 0!==e.justify&&t.push(`justify-${e.justify}`),!0===e.wrap&&t.push("flex-wrap"),!0===e.grow&&t.push("flex-1"),!1===e.shrink&&t.push("flex-shrink-0"),void 0!==e.position&&t.push(e.position),void 0!==e.inset&&t.push("0"===e.inset?"inset-0":`inset-${Pc[e.inset]}`),void 0!==e.overflow&&t.push(`overflow-${e.overflow}`),void 0!==e.overflowY&&t.push(`overflow-y-${e.overflowY}`),void 0!==e.width&&t.push(`w-${e.width}`),void 0!==e.height&&t.push(`h-${e.height}`),"0"===e.minWidth&&t.push("min-w-0"),"0"===e.minHeight&&t.push("min-h-0"),void 0!==e.border&&!1!==e.border)if(!0===e.border)t.push("border","border-border");else{const n={top:"t",bottom:"b",left:"l",right:"r"}[e.border];t.push(`border-${n}`,"border-border")}if(void 0!==e.rounded&&!1!==e.rounded)if(!0===e.rounded)t.push(Oc.theme);else if("full"===e.rounded)t.push(Oc.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Oc[n])}return!0!==e.shadow&&"theme"!==e.shadow||t.push("shadow-[var(--shadow)]"),void 0!==e.cursor&&t.push(`cursor-${e.cursor}`),void 0!==e.opacity&&t.push(`opacity-${e.opacity}`),void 0!==e.animate&&"none"!==e.animate&&t.push({spin:"animate-spin",ping:"animate-ping",pulse:"animate-pulse",fadeIn:"animate-fade-in"}[e.animate]),!0===e.hidden&&t.push("hidden"),t.join(" ")}function Uc(e){const t={};for(const n in e)jc.has(n)||(t[n]=e[n]);return t}var Bc={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Wc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Hc=o(function(e,t){const{as:n="div",background:r="default",className:o,elevation:i,paddingPreset:a="none",radius:s,style:c,...l}=e,d=Fc(e);/* @__PURE__ */
|
|
5
5
|
return f(n,{...Uc(l),ref:t,className:zc(Bc[r],Wc[a],s&&Fc({rounded:s}),d,o),style:{...Dc(i),...c}})}),Zc="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",qc={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"},Vc=o(function({src:e,alt:t,elevation:n,fit:r="contain",size:o="md",rounded:i,className:a,style:s,...c},l){const d="string"==typeof o,u=d?qc[o]:void 0,p=d?s:{width:o,height:o,...s};/* @__PURE__ */
|