@marketrix.ai/widget 3.3.226 → 3.3.235

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/widget.mjs CHANGED
@@ -1,68 +1,68 @@
1
- import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as i,useCallback as o,useContext as s,useEffect as a,useId as l,useLayoutEffect as c,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,w=2147483001,b=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,i]=[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*i}(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 i=Math.round(n.r*r),o=Math.round(n.g*r),s=Math.round(n.b*r),`#${[i,o,s].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var i,o,s}var S=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),C=e=>{switch(e){case"show":return"Show";case"tell":return"Tell";case"do":return"Do";default:return e}},I={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(I);function T(e){return Array.isArray(e)?e:null==e?[]:[e]}var A="orpc",M=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function z(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.3/otel/config__"]}function R(e,t={},n){return(O()?.tracer)?.startSpan(e,t,n)}function P(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 N({name:e,context:t,...n},r){const i=O()?.tracer;if(!i)return r();const o=async e=>{try{return await r(e)}catch(t){throw P(e,t,n),t}finally{e.end()}};return t?i.startActiveSpan(e,n,t,o):i.startActiveSpan(e,n,o)}async function L(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 $=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[$](){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??=R(e);try{const e=await L(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(i){throw P(r,i,t),i}},async e=>{try{"next"!==e&&await L(r,()=>n.return?.())}catch(i){throw P(r,i,t),i}finally{r?.end()}})}function U(e,t,n){const r=(t,i)=>{const o=e[i];return o?o({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function B(e){if(e)return JSON.parse(e)}function G(e){return JSON.stringify(e)}function W(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function H(e){return!!e&&("object"==typeof e||"function"==typeof e)}function Z(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)&&q.test(t.toString()));var t}))return Reflect.apply(t,n,r);let i=!0;r[0].call(n,V(new Proxy(e,{get:(e,t,n)=>{if(!i||"then"!==t)return Reflect.get(e,t,n);i=!1}})))}})}})}var q=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var Y={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 J=Symbol.for("__@orpc/client@1.14.3/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[J]??=/* @__PURE__ */new WeakSet;var K=globalThis[J],Q=class extends Error{defined;code;status;data;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||Y[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??Y[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(K.has(this)){const t=function(e){return H(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&K.has(t))return!0}return super[Symbol.hasInstance](e)}};function X(e){return e<200||e>=400}function ee(e){if(!W(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 te(e,t={}){return new Q(e.code,{...t,...e})}K.add(Q);var ne=class extends TypeError{},re=class extends TypeError{},ie=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),i=-1===e?"":r.slice(e+1).replace(/^\s/,"");if(0===e)n.comments.push(i);else if("data"===t)n.data??="",n.data+=`${i}\n`;else if("event"===t)n.event=i;else if("id"===t)n.id=i;else if("retry"===t){const e=Number.parseInt(i);Number.isInteger(e)&&e>=0&&e.toString()===i&&(n.retry=e)}}return n.data=n.data?.replace(/\n$/,""),n}var se=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 re("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new se({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function le(e){if(e.includes("\n"))throw new ne("Event's id must not contain a newline character")}function ce(e){if(!Number.isInteger(e)||e<0)throw new ne("Event's retry must be a integer and >= 0")}function de(e){if(e.includes("\n"))throw new ne("Event's comment must not contain a newline character")}function ue(e){let t="";return t+=function(e){let t="";for(const n of e??[])de(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new ne("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&&(le(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 pe=Symbol("ORPC_EVENT_SOURCE_META");function he(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&le(t.id),void 0!==t.retry&&ce(t.retry),void 0!==t.comments)for(const n of t.comments)de(n);return new Proxy(e,{get:(e,n,r)=>n===pe?t:Reflect.get(e,n,r)})}function me(e){return H(e)?Reflect.get(e,pe):void 0}function fe(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 ge(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=me(e);t&&H(n)&&(n=he(n,t))}return n};return new j(async()=>{const{done:r,value:i}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let o=await t.value(i,r);if(o!==i){const e=me(i);e&&H(o)&&(o=he(o,e))}return{done:r,value:o}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function ye(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,i)=>"string"!=typeof i?Reflect.get(r,i):ye(e,{...t,path:[...n,i]})}))}function we(e,t={}){return N({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=fe(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,i=!1;return new j(async()=>{r??=R("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await L(r,()=>n.read());if(e){if(i)throw new M("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=B(t.data);return H(e)&&(e=he(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new ie({data:B(t.data)});throw e=he(e,t),r?.addEvent("error"),e}case"done":{let e=B(t.data);return H(e)&&(e=he(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof ie||P(r,e,t),e}},async e=>{try{"next"!==e&&(i=!0,r?.addEvent("cancelled")),await L(r,()=>n?.cancel())}catch(o){throw P(r,o,t),o}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const i=await e.blob();return new File([i],"blob",{type:i.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,i=t.eventIteratorKeepAliveComment??"",o=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,l,c=!1;return new ReadableStream({start(e){l=R("stream_event_iterator"),o&&e.enqueue(ue({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ue({comments:[i]})),l?.addEvent("keepalive")},r));const o=await L(l,()=>e.next());if(clearInterval(a),c)return;const s=me(o.value);if(!o.done||void 0!==o.value||void 0!==s){const e=o.done?"done":"message";t.enqueue(ue({...s,event:e,data:G(o.value)})),l?.addEvent(e)}o.done&&(t.close(),l?.end())}catch(o){if(clearInterval(a),c)return;o instanceof ie?(t.enqueue(ue({...me(o),event:"error",data:G(o.data)})),l?.addEvent("error"),t.close()):(P(l,o),t.error(o)),l?.end()}},async cancel(){try{c=!0,clearInterval(a),l?.addEvent("cancelled"),await L(l,()=>e.return?.())}catch(t){throw P(l,t),t}finally{l?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),G(e)):void 0}function ve(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 xe(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 ke=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)}},_e=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new ke(n.plugins).init(n),this.interceptors=T(n.interceptors),this.clientInterceptors=T(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return N({name:`${A}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",A),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 i=O();let o;const s=i?.trace.getActiveSpan()??r;s&&i&&(o=i?.trace.setSpan(i.context.active(),s));const a=await N({name:"encode_request",context:o},()=>this.codec.encode(e,t,n)),l=await U(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>N({name:"send_request",signal:r.signal,context:o},()=>this.sender.call(n,r,t,e))),c=await N({name:"decode_response",context:o},()=>this.codec.decode(l,n,e,t));return D(c)?F({name:"consume_event_iterator_output",signal:n.signal},c):c})))}},Se=0,Ce=1,Ie=2,Ee=3,Te=4,Ae=5,Me=6,ze=7,Oe=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=[],i=[]){for(const o of this.customSerializers)if(o.condition(e)){const s=this.serialize(o.serialize(e),t,n,r,i);return n.push([o.type,...t]),s}if(e instanceof Blob)return r.push(t),i.push(e),[e,n,r,i];if("bigint"==typeof e)return n.push([Se,...t]),[e.toString(),n,r,i];if(e instanceof Date)return n.push([Ce,...t]),Number.isNaN(e.getTime())?[null,n,r,i]:[e.toISOString(),n,r,i];if(Number.isNaN(e))return n.push([Ie,...t]),[null,n,r,i];if(e instanceof URL)return n.push([Te,...t]),[e.toString(),n,r,i];if(e instanceof RegExp)return n.push([Ae,...t]),[e.toString(),n,r,i];if(e instanceof Set){const o=this.serialize(Array.from(e),t,n,r,i);return n.push([Me,...t]),o}if(e instanceof Map){const o=this.serialize(Array.from(e.entries()),t,n,r,i);return n.push([ze,...t]),o}if(Array.isArray(e))return[e.map((e,o)=>void 0===e?(n.push([Ee,...t,o]),null):this.serialize(e,[...t,o],n,r,i)[0]),n,r,i];if(W(e)){const o={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(o[s]=this.serialize(e[s],[...t,s],n,r,i)[0]);return[o,n,r,i]}return[e,n,r,i]}deserialize(e,t,n,r){const i={data:e};n&&r&&n.forEach((e,t)=>{let n=i,o="data";e.forEach(e=>{if(n=n[o],o=e,!Object.hasOwn(n,o))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${o}`)}),n[o]=r(t)});for(const o of t){const e=o[0];let t=i,n="data";for(let r=1;r<o.length;r++)if(t=t[n],n=o[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 Se:t[n]=BigInt(t[n]);break;case Ce:t[n]=new Date(t[n]??"Invalid Date");break;case Ie:t[n]=NaN;break;case Ee:t[n]=void 0;break;case Te:t[n]=new URL(t[n]);break;case Ae:{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 i.data}};var Re,Pe=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?ve(e):e}(await Z(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 i=await Z(this.expectedMethod,n,e,t),o=await Z(this.baseUrl,n,e,t),s=new URL(o);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==i||a instanceof FormData||D(a))){const o=await Z(this.maxUrlLength,n,e,t),l=new URL(s);if(l.searchParams.append("data",G(a)),l.toString().length<=o)return{body:void 0,method:i,headers:r,url:l,signal:n.signal}}return{url:s,method:"GET"===i?this.fallbackMethod:i,headers:r,body:a,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(ee(n))throw te(n);throw new Q((r=e.status,Object.entries(Y).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},Ne=class{constructor(e){this.jsonSerializer=e}serialize(e){return D(e)?ge(e,{value:async e=>this.#i(e,!1),error:async e=>{return new ie({data:this.#i((t=e,t instanceof Q?t:new Q("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#i(e,!0)}#i(e,t){const[n,r,i,o]=this.jsonSerializer.serialize(e),s=0===r.length?void 0:r;if(!t||0===o.length)return{json:n,meta:s};const a=new FormData;return a.set("data",G({json:n,meta:s,maps:i})),o.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return D(e)?ge(e,{value:async e=>this.#o(e),error:async e=>{if(!(e instanceof ie))return e;const t=this.#o(e.data);return ee(t)?te(t,{cause:e}):new ie({data:t,cause:e})}}):this.#o(e)}#o(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 _e{constructor(e,t){super(new Pe(new Ne(new Oe(t)),t),e,t)}},De=class extends ke{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},$e=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new De(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 i=xe(e,this.toFetchRequestOptions);return function(e,t={}){return{body:z(()=>we(e,t)),status:e.status,get headers(){const t=ve(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:i,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...i})=>this.fetch(e,r,i,t,n)),{signal:i.signal})}},je=class extends Le{constructor(e){super(new $e(e),e)}};function Fe(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const i=s.prototype,o=Object.keys(i);for(let e=0;e<o.length;e++){const t=o[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class o extends i{}function s(e){var t;const i=n?.Parent?new o:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Ue=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Be=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Re=globalThis).__zod_globalConfig??(Re.__zod_globalConfig={});var Ge=globalThis.__zod_globalConfig;function We(e){return e&&Object.assign(Ge,e),Ge}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 Ve(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qe(e){return null==e}function Ye(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 Qe(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 et(e){return JSON.stringify(e)}var tt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var rt=/* @__PURE__ */Ve(()=>{if(Ge.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function it(e){if(!1===nt(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!==nt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function ot(e){return it(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var st=/* @__PURE__ */new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(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 dt={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 ut(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 pt(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 ht(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function mt(e){return"string"==typeof e?e:e?.message}function ft(e,t,n){const r=e.message?e.message:mt(e.inst?._zod.def?.error?.(e))??mt(t?.error?.(e))??mt(n.customError?.(e))??mt(n.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function gt(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function yt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function wt(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var bt=(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})},vt=Fe("$ZodError",bt),xt=Fe("$ZodError",bt,{Parent:Error});var kt=e=>(t,n,r,i)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Ue;if(s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>ft(e,o,We())));throw tt(t,i?.callee),t}return s.value},_t=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>ft(e,o,We())));throw tt(t,i?.callee),t}return s.value},St=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Ue;return o.issues.length?{success:!1,error:new(e??vt)(o.issues.map(e=>ft(e,i,We())))}:{success:!0,data:o.value}},Ct=/* @__PURE__ */St(xt),It=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>ft(e,i,We())))}:{success:!0,data:o.value}},Et=/* @__PURE__ */It(xt),Tt=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return kt(e)(t,n,i)},At=e=>(t,n,r)=>kt(e)(t,n,r),Mt=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return _t(e)(t,n,i)},zt=e=>async(t,n,r)=>_t(e)(t,n,r),Ot=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return St(e)(t,n,i)},Rt=e=>(t,n,r)=>St(e)(t,n,r),Pt=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return It(e)(t,n,i)},Nt=e=>async(t,n,r)=>It(e)(t,n,r),Lt=/^[cC][0-9a-z]{6,}$/,Dt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jt=/^[0-9a-vA-V]{20}$/,Ft=/^[A-Za-z0-9]{27}$/,Ut=/^[a-zA-Z0-9_-]{21}$/,Bt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gt=/^([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})$/,Wt=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)$/,Ht=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Zt=/^(?:(?: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])$/,Vt=/^(([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])$/,Yt=/^(([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])$/,Jt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kt=/^[A-Za-z0-9_-]*$/,Qt=/^https?$/,Xt=/^\+[1-9]\d{6,14}$/,en="(?:(?:\\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])))",tn=/* @__PURE__ */new RegExp(`^${en}$`);function nn(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 rn=/^-?\d+$/,on=/^-?\d+(?:\.\d+)?$/,sn=/^(?:true|false)$/i,an=/^null$/i,ln=/^[^A-Z]*$/,cn=/^[^a-z]*$/,dn=/* @__PURE__ */Fe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),un={number:"number",bigint:"bigint",object:"date"},pn=/* @__PURE__ */Fe("$ZodCheckLessThan",(e,t)=>{dn.init(e,t);const n=un[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})}}),hn=/* @__PURE__ */Fe("$ZodCheckGreaterThan",(e,t)=>{dn.init(e,t);const n=un[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})}}),mn=/* @__PURE__ */Fe("$ZodCheckMultipleOf",(e,t)=>{dn.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),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?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})}}),fn=/* @__PURE__ */Fe("$ZodCheckNumberFormat",(e,t)=>{dn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=dt[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=o,n&&(r.pattern=rn)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,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}):s.issues.push({input:a,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}))}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),gn=/* @__PURE__ */Fe("$ZodCheckMaxSize",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(t)&&void 0!==t.size}),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;r.size<=t.maximum||n.issues.push({origin:gt(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yn=/* @__PURE__ */Fe("$ZodCheckMinSize",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(t)&&void 0!==t.size}),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;r.size>=t.minimum||n.issues.push({origin:gt(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wn=/* @__PURE__ */Fe("$ZodCheckMaxLength",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(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 i=yt(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bn=/* @__PURE__ */Fe("$ZodCheckMinLength",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(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 i=yt(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vn=/* @__PURE__ */Fe("$ZodCheckLengthEquals",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(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,i=r.length;if(i===t.length)return;const o=yt(r),s=i>t.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xn=/* @__PURE__ */Fe("$ZodCheckStringFormat",(e,t)=>{var n,r;dn.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=()=>{})}),kn=/* @__PURE__ */Fe("$ZodCheckRegex",(e,t)=>{xn.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})}}),_n=/* @__PURE__ */Fe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ln),xn.init(e,t)}),Sn=/* @__PURE__ */Fe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cn),xn.init(e,t)}),Cn=/* @__PURE__ */Fe("$ZodCheckIncludes",(e,t)=>{dn.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})}}),In=/* @__PURE__ */Fe("$ZodCheckStartsWith",(e,t)=>{dn.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})}}),En=/* @__PURE__ */Fe("$ZodCheckEndsWith",(e,t)=>{dn.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})}}),Tn=/* @__PURE__ */Fe("$ZodCheckMimeType",(e,t)=>{dn.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),An=/* @__PURE__ */Fe("$ZodCheckOverwrite",(e,t)=>{dn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Mn=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 i of r)this.content.push(i)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(e=>` ${e}`)];return new e(...t,n.join("\n"))}},zn={major:4,minor:4,patch:3},On=/* @__PURE__ */Fe("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zn;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const i of r)for(const t of i._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,i=ut(e);for(const o of t){if(o._zod.def.when){if(pt(e))continue;if(!o._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new Ue;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(i||(i=ut(e,t)))});else{if(e.issues.length===t)continue;i||(i=ut(e,t))}}return r?r.then(()=>e):e},n=(n,i,o)=>{if(ut(n))return n.aborted=!0,n;const s=t(i,r,o);if(s instanceof Promise){if(!1===o.async)throw new Ue;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(i,o)=>{if(o.skipChecks)return e._zod.parse(i,o);if("backward"===o.direction){const t=e._zod.parse({value:i.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,o)):n(t,i,o)}const s=e._zod.parse(i,o);if(s instanceof Promise){if(!1===o.async)throw new Ue;return s.then(e=>t(e,r,o))}return t(s,r,o)}}Ke(e,"~standard",()=>({validate:t=>{try{const n=Ct(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Et(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Rn=/* @__PURE__ */Fe("$ZodString",(e,t)=>{var n;On.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}}),Pn=/* @__PURE__ */Fe("$ZodStringFormat",(e,t)=>{xn.init(e,t),Rn.init(e,t)}),Nn=/* @__PURE__ */Fe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gt),Pn.init(e,t)}),Ln=/* @__PURE__ */Fe("$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=Wt(e))}else t.pattern??(t.pattern=Wt());Pn.init(e,t)}),Dn=/* @__PURE__ */Fe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ht),Pn.init(e,t)}),$n=/* @__PURE__ */Fe("$ZodURL",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Qt.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 i=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),jn=/* @__PURE__ */Fe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pn.init(e,t)}),Fn=/* @__PURE__ */Fe("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ut),Pn.init(e,t)}),Un=/* @__PURE__ */Fe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Lt),Pn.init(e,t)}),Bn=/* @__PURE__ */Fe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dt),Pn.init(e,t)}),Gn=/* @__PURE__ */Fe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$t),Pn.init(e,t)}),Wn=/* @__PURE__ */Fe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=jt),Pn.init(e,t)}),Hn=/* @__PURE__ */Fe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ft),Pn.init(e,t)}),Zn=/* @__PURE__ */Fe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=nn({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(`^${en}T(?:${r})$`)}(t)),Pn.init(e,t)}),Vn=/* @__PURE__ */Fe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=tn),Pn.init(e,t)}),qn=/* @__PURE__ */Fe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${nn(t)}$`)),Pn.init(e,t)}),Yn=/* @__PURE__ */Fe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bt),Pn.init(e,t)}),Jn=/* @__PURE__ */Fe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Zt),Pn.init(e,t),e._zod.bag.format="ipv4"}),Kn=/* @__PURE__ */Fe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vt),Pn.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})}}}),Qn=/* @__PURE__ */Fe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qt),Pn.init(e,t)}),Xn=/* @__PURE__ */Fe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Yt),Pn.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 er(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 tr=/* @__PURE__ */Fe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Jt),Pn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{er(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var nr=/* @__PURE__ */Fe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Kt),Pn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Kt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return er(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})}}),rr=/* @__PURE__ */Fe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xt),Pn.init(e,t)});var ir=/* @__PURE__ */Fe("$ZodJWT",(e,t)=>{Pn.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 i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.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})}}),or=/* @__PURE__ */Fe("$ZodNumber",(e,t)=>{On.init(e,t),e._zod.pattern=e._zod.bag.pattern??on,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),sr=/* @__PURE__ */Fe("$ZodNumberFormat",(e,t)=>{fn.init(e,t),or.init(e,t)}),ar=/* @__PURE__ */Fe("$ZodBoolean",(e,t)=>{On.init(e,t),e._zod.pattern=sn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(o){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),lr=/* @__PURE__ */Fe("$ZodNull",(e,t)=>{On.init(e,t),e._zod.pattern=an,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}}),cr=/* @__PURE__ */Fe("$ZodUnknown",(e,t)=>{On.init(e,t),e._zod.parse=e=>e}),dr=/* @__PURE__ */Fe("$ZodNever",(e,t)=>{On.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ur=/* @__PURE__ */Fe("$ZodDate",(e,t)=>{On.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(s){}const i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function pr(e,t,n){e.issues.length&&t.issues.push(...ht(n,e.issues)),t.value[n]=e.value}var hr=/* @__PURE__ */Fe("$ZodArray",(e,t)=>{On.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let e=0;e<i.length;e++){const s=i[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?o.push(a.then(t=>pr(t,n,e))):pr(a,n,e)}return o.length?Promise.all(o).then(()=>n):n}});function mr(e,t,n,r,i,o){const s=n in r;if(e.issues.length){if(i&&o&&!s)return;t.issues.push(...ht(n,e.issues))}s||i?void 0===e.value?s&&(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 fr(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": 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 gr(e,t,n,r,i,o){const s=[],a=i.keySet,l=i.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(const p in t){if("__proto__"===p)continue;if(a.has(p))continue;if("never"===c){s.push(p);continue}const i=l.run({value:t[p],issues:[]},r);i instanceof Promise?e.push(i.then(e=>mr(e,n,p,t,d,u))):mr(i,n,p,t,d,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}var yr=/* @__PURE__ */Fe("$ZodObject",(e,t)=>{if(On.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=Ve(()=>fr(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=nt,i=t.catchall;let o;e._zod.parse=(t,s)=>{o??(o=n.value);const a=t.value;if(!r(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const l=[],c=o.shape;for(const e of o.keys){const n=c[e],r="optional"===n._zod.optin,i="optional"===n._zod.optout,o=n._zod.run({value:a[e],issues:[]},s);o instanceof Promise?l.push(o.then(n=>mr(n,t,e,a,r,i))):mr(o,t,e,a,r,i)}return i?gr(l,a,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),wr=/* @__PURE__ */Fe("$ZodObjectJIT",(e,t)=>{yr.init(e,t);const n=e._zod.parse,r=Ve(()=>fr(t));let i;const o=nt,s=!Ge.jitless,a=s&&rt.value,l=t.catchall;let c;e._zod.parse=(d,u)=>{c??(c=r.value);const p=d.value;return o(p)?s&&a&&!1===u?.async&&!0!==u.jitless?(i||(i=(e=>{const t=new Mn(["shape","payload","ctx"]),n=r.value,i=e=>{const t=et(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const o=Object.create(null);let s=0;for(const r of n.keys)o[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=o[r],s=et(r),a=e[r],l="optional"===a?._zod?.optin,c="optional"===a?._zod?.optout;t.write(`const ${n} = ${i(r)};`),l&&c?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):l?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\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: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),d=i(d,u),l?gr([],p,d,u,c,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function br(e,t,n,r){for(const o of e)if(0===o.issues.length)return t.value=o.value,t;const i=e.filter(e=>!ut(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ft(e,r,We())))}),t)}var vr=/* @__PURE__ */Fe("$ZodUnion",(e,t)=>{On.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=>Ye(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>br(t,r,e,i)):br(s,r,e,i)}}),xr=/* @__PURE__ */Fe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,vr.init(e,t);const n=e._zod.parse;Ke(e._zod,"propValues",()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */new Set);for(const r of n)e[t].add(r)}}return e});const r=Ve(()=>{const e=t.options,n=/* @__PURE__ */new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,o)=>{const s=i.value;if(!nt(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback||"backward"===o.direction?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:s,path:[t.discriminator],inst:e}),i)}}),kr=/* @__PURE__ */Fe("$ZodIntersection",(e,t)=>{On.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>Sr(e,t,n)):Sr(e,i,o)}});function _r(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(it(e)&&it(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const o of r){const n=_r(e[o],t[o]);if(!n.valid)return{valid:!1,mergeErrorPath:[o,...n.mergeErrorPath]};i[o]=n.data}return{valid:!0,data:i}}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 i=_r(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Sr(e,t,n){const r=/* @__PURE__ */new Map;let i;for(const a of t.issues)if("unrecognized_keys"===a.code){i??(i=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const o=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(o.length&&i&&e.issues.push({...i,keys:o}),ut(e))return e;const s=_r(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Cr=/* @__PURE__ */Fe("$ZodRecord",(e,t)=>{On.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!it(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],s=t.keyType._zod.values;if(s){n.value={};const a=/* @__PURE__ */new Set;for(const c of s)if("string"==typeof c||"number"==typeof c||"symbol"==typeof c){a.add("number"==typeof c?c.toString():c);const s=t.keyType._zod.run({value:c,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>ft(e,r,We())),input:c,path:[c],inst:e});continue}const l=s.value,d=t.valueType._zod.run({value:i[c],issues:[]},r);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&n.issues.push(...ht(c,e.issues)),n.value[l]=e.value})):(d.issues.length&&n.issues.push(...ht(c,d.issues)),n.value[l]=d.value)}let l;for(const e in i)a.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const s of Reflect.ownKeys(i)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(i,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&on.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>ft(e,r,We())),input:s,path:[s],inst:e});continue}const l=t.valueType._zod.run({value:i[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...ht(s,e.issues)),n.value[a.value]=e.value})):(l.issues.length&&n.issues.push(...ht(s,l.issues)),n.value[a.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Ir=/* @__PURE__ */Fe("$ZodEnum",(e,t)=>{On.init(e,t);const n=He(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>st.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const o=t.value;return r.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),Er=/* @__PURE__ */Fe("$ZodLiteral",(e,t)=>{if(On.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,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Tr=/* @__PURE__ */Fe("$ZodFile",(e,t)=>{On.init(e,t),e._zod.parse=(t,n)=>{const r=t.value;return r instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),t}}),Ar=/* @__PURE__ */Fe("$ZodTransform",(e,t)=>{On.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Be(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Ue;return n.value=i,n.fallback=!0,n}});function Mr(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var zr=/* @__PURE__ */Fe("$ZodOptional",(e,t)=>{On.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(`^(${Ye(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Mr(e,r)):Mr(i,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Or=/* @__PURE__ */Fe("$ZodExactOptional",(e,t)=>{zr.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)}),Rr=/* @__PURE__ */Fe("$ZodNullable",(e,t)=>{On.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(`^(${Ye(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)}),Pr=/* @__PURE__ */Fe("$ZodDefault",(e,t)=>{On.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=>Nr(e,t)):Nr(r,t)}});function Nr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Lr=/* @__PURE__ */Fe("$ZodPrefault",(e,t)=>{On.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))}),Dr=/* @__PURE__ */Fe("$ZodNonOptional",(e,t)=>{On.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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>$r(t,e)):$r(i,e)}});function $r(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 jr=/* @__PURE__ */Fe("$ZodCatch",(e,t)=>{On.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=>ft(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=>ft(e,n,We()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Fr=/* @__PURE__ */Fe("$ZodPipe",(e,t)=>{On.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=>Ur(e,t.in,n)):Ur(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ur(e,t.out,n)):Ur(r,t.out,n)}});function Ur(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 Br=/* @__PURE__ */Fe("$ZodPreprocess",(e,t)=>{Fr.init(e,t)}),Gr=/* @__PURE__ */Fe("$ZodReadonly",(e,t)=>{On.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(Wr):Wr(r)}});function Wr(e){return e.value=Object.freeze(e.value),e}var Hr,Zr=/* @__PURE__ */Fe("$ZodCustom",(e,t)=>{dn.init(e,t),On.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Vr(t,n,r,e));Vr(i,n,r,e)}});function Vr(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(wt(e))}}var qr=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)}};(Hr=globalThis).__zod_globalRegistry??(Hr.__zod_globalRegistry=new qr);var Yr=globalThis.__zod_globalRegistry;function Jr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}function Kr(e,t){return new pn({check:"less_than",...ct(t),value:e,inclusive:!1})}function Qr(e,t){return new pn({check:"less_than",...ct(t),value:e,inclusive:!0})}function Xr(e,t){return new hn({check:"greater_than",...ct(t),value:e,inclusive:!1})}function ei(e,t){return new hn({check:"greater_than",...ct(t),value:e,inclusive:!0})}function ti(e,t){return new mn({check:"multiple_of",...ct(t),value:e})}function ni(e,t){return new wn({check:"max_length",...ct(t),maximum:e})}function ri(e,t){return new bn({check:"min_length",...ct(t),minimum:e})}function ii(e,t){return new vn({check:"length_equals",...ct(t),length:e})}function oi(e){return new An({check:"overwrite",tx:e})}function si(e,t){const n=new dn({check:"custom",...ct(t)});return n._zod.check=e,n}function ai(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??Yr,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 li(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,o=t.processors[i.type];if(!o)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,n,r)}const o=e._zod.parent;o&&(s.ref||(s.ref=o),li(o,t,r),t.seen.get(o).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),"input"===t.io&&ui(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function ci(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 o of e.seen.entries()){const t=e.metadataRegistry.get(o[0])?.id;if(t){const e=r.get(t);if(e&&e!==o[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,o[0])}}const i=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:i,defId:o}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const o=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${r}/${o}`}}if(t[1]===n)return{ref:"#"};const i=`#/${r}/`,o=t[1].schema.id??"__schema"+e.counter++;return{defId:o,ref:i+o}})(t);r.def={...r.schema},o&&(r.defId=o);const s=r.schema;for(const e in s)delete s[e];s.$ref=i};if("throw"===e.cycles)for(const o of e.seen.entries()){const e=o[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 o of e.seen.entries()){const n=o[1];if(t!==o[0]){if(e.external){const n=e.external.registry.get(o[0])?.id;if(t!==o[0]&&n){i(o);continue}}(e.metadataRegistry.get(o[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(o)}else i(o)}}function di(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 i=n.def??n.schema,o={...i},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,o),t._zod.parent===s)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())r(l[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$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");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;void 0!==o&&i.id===o&&delete i.id;const s=e.external?.defs??{};for(const l of e.seen.entries()){const e=l[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?i.$defs=s:i.definitions=s);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:pi(t,"input",e.processors),output:pi(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function ui(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 ui(r.element,n);if("set"===r.type)return ui(r.valueType,n);if("lazy"===r.type)return ui(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 ui(r.innerType,n);if("intersection"===r.type)return ui(r.left,n)||ui(r.right,n);if("record"===r.type||"map"===r.type)return ui(r.keyType,n)||ui(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(ui(r.in,n)||ui(r.out,n));if("object"===r.type){for(const e in r.shape)if(ui(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(ui(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(ui(e,n))return!0;return!(!r.rest||!ui(r.rest,n))}return!1}var pi=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=ai({...i??{},target:o,io:t,processors:n});return li(e,s),ci(s,e),di(s,e)},hi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mi=(e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r);t.seen.get(e).ref=i.innerType},fi=/* @__PURE__ */Fe("ZodISODateTime",(e,t)=>{Zn.init(e,t),Gi.init(e,t)});function gi(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}(fi,e)}var yi=/* @__PURE__ */Fe("ZodISODate",(e,t)=>{Vn.init(e,t),Gi.init(e,t)});function wi(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}(yi,e)}var bi=/* @__PURE__ */Fe("ZodISOTime",(e,t)=>{qn.init(e,t),Gi.init(e,t)});function vi(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}(bi,e)}var xi=/* @__PURE__ */Fe("ZodISODuration",(e,t)=>{Yn.init(e,t),Gi.init(e,t)});function ki(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}(xi,e)}var _i=(e,t)=>{vt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,i=[])=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e},[...i,...o.path]));else if("invalid_key"===o.code)r({issues:o.issues},[...i,...o.path]);else if("invalid_element"===o.code)r({issues:o.issues},[...i,...o.path]);else{const e=[...i,...o.path];if(0===e.length)n._errors.push(t(o));else{let r=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(o))),r=r[n],i++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));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}})},Si=/* @__PURE__ */Fe("ZodError",_i,{Parent:Error}),Ci=/* @__PURE__ */kt(Si),Ii=/* @__PURE__ */_t(Si),Ei=/* @__PURE__ */St(Si),Ti=/* @__PURE__ */It(Si),Ai=/* @__PURE__ */Tt(Si),Mi=/* @__PURE__ */At(Si),zi=/* @__PURE__ */Mt(Si),Oi=/* @__PURE__ */zt(Si),Ri=/* @__PURE__ */Ot(Si),Pi=/* @__PURE__ */Rt(Si),Ni=/* @__PURE__ */Pt(Si),Li=/* @__PURE__ */Nt(Si),Di=/* @__PURE__ */new WeakMap;function $i(e,t,n){const r=Object.getPrototypeOf(e);let i=Di.get(r);if(i||(i=/* @__PURE__ */new Set,Di.set(r,i)),!i.has(t)){i.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 ji=/* @__PURE__ */Fe("ZodType",(e,t)=>(On.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:pi(e,"input"),output:pi(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=ai({...n,processors:t});return li(e,r),ci(r,e),di(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ci(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ei(e,t,n),e.parseAsync=async(t,n)=>Ii(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ti(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ai(e,t,n),e.decode=(t,n)=>Mi(e,t,n),e.encodeAsync=async(t,n)=>zi(e,t,n),e.decodeAsync=async(t,n)=>Oi(e,t,n),e.safeEncode=(t,n)=>Ri(e,t,n),e.safeDecode=(t,n)=>Pi(e,t,n),e.safeEncodeAsync=async(t,n)=>Ni(e,t,n),e.safeDecodeAsync=async(t,n)=>Li(e,t,n),$i(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 lt(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)})}(Xo,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */si(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(wt(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(wt(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(oi(e))},optional(){return Uo(this)},exactOptional(){return new Bo({type:"optional",innerType:this})},nullable(){return Wo(this)},nullish(){return Uo(Wo(this))},nonoptional(e){return function(e,t){return new Vo({type:"nonoptional",innerType:e,...ct(t)})}(this,e)},array(){return _o(this)},or(e){return Eo([this,e])},and(e){return new Mo({type:"intersection",left:this,right:e})},transform(e){return Jo(this,jo(e))},default(e){return t=e,new Ho({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},prefault(e){return t=e,new Zo({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},catch(e){return new qo({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Jo(this,e)},readonly(){return new Qo({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(0===e.length)return Yr.get(this);const t=this.clone();return Yr.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:()=>Yr.get(e)?.description,configurable:!0}),e)),Fi=/* @__PURE__ */Fe("_ZodString",(e,t)=>{Rn.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:i,maximum:o,format:s,patterns:a,contentEncoding:l}=e._zod.bag;if("number"==typeof i&&(r.minLength=i),"number"==typeof o&&(r.maxLength=o),s&&(r.format=hi[s]??s,""===r.format&&delete r.format,"time"===s&&delete r.format),l&&(r.contentEncoding=l),a&&a.size>0){const e=[...a];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,$i(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new kn({check:"string_format",format:"regex",...ct(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Cn({check:"string_format",format:"includes",...ct(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new In({check:"string_format",format:"starts_with",...ct(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new En({check:"string_format",format:"ends_with",...ct(t),suffix:e})}(...e))},min(...e){return this.check(ri(...e))},max(...e){return this.check(ni(...e))},length(...e){return this.check(ii(...e))},nonempty(...e){return this.check(ri(1,...e))},lowercase(e){return this.check(function(e){return new _n({check:"string_format",format:"lowercase",...ct(e)})}(e))},uppercase(e){return this.check(function(e){return new Sn({check:"string_format",format:"uppercase",...ct(e)})}(e))},trim(){return this.check(/* @__PURE__ */oi(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
- return oi(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */oi(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */oi(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */oi(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Ui=/* @__PURE__ */Fe("ZodString",(e,t)=>{Rn.init(e,t),Fi.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)})}(Wi,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(Vi,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(lo,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(qi,t)),e.guid=t=>e.check(Jr(Hi,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(Zi,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)})}(Zi,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)})}(Zi,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)})}(Zi,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(Yi,t)),e.guid=t=>e.check(Jr(Hi,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(Ji,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(Ki,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(Qi,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(oo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(so,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(Xi,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(eo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(to,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(no,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(ro,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(io,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(ao,t)),e.datetime=t=>e.check(gi(t)),e.date=t=>e.check(wi(t)),e.time=t=>e.check(vi(t)),e.duration=t=>e.check(ki(t))});function Bi(e){return function(e,t){return new e({type:"string",...ct(t)})}(Ui,e)}var Gi=/* @__PURE__ */Fe("ZodStringFormat",(e,t)=>{Pn.init(e,t),Fi.init(e,t)}),Wi=/* @__PURE__ */Fe("ZodEmail",(e,t)=>{Dn.init(e,t),Gi.init(e,t)}),Hi=/* @__PURE__ */Fe("ZodGUID",(e,t)=>{Nn.init(e,t),Gi.init(e,t)}),Zi=/* @__PURE__ */Fe("ZodUUID",(e,t)=>{Ln.init(e,t),Gi.init(e,t)}),Vi=/* @__PURE__ */Fe("ZodURL",(e,t)=>{$n.init(e,t),Gi.init(e,t)}),qi=/* @__PURE__ */Fe("ZodEmoji",(e,t)=>{jn.init(e,t),Gi.init(e,t)}),Yi=/* @__PURE__ */Fe("ZodNanoID",(e,t)=>{Fn.init(e,t),Gi.init(e,t)}),Ji=/* @__PURE__ */Fe("ZodCUID",(e,t)=>{Un.init(e,t),Gi.init(e,t)}),Ki=/* @__PURE__ */Fe("ZodCUID2",(e,t)=>{Bn.init(e,t),Gi.init(e,t)}),Qi=/* @__PURE__ */Fe("ZodULID",(e,t)=>{Gn.init(e,t),Gi.init(e,t)}),Xi=/* @__PURE__ */Fe("ZodXID",(e,t)=>{Wn.init(e,t),Gi.init(e,t)}),eo=/* @__PURE__ */Fe("ZodKSUID",(e,t)=>{Hn.init(e,t),Gi.init(e,t)}),to=/* @__PURE__ */Fe("ZodIPv4",(e,t)=>{Jn.init(e,t),Gi.init(e,t)}),no=/* @__PURE__ */Fe("ZodIPv6",(e,t)=>{Kn.init(e,t),Gi.init(e,t)}),ro=/* @__PURE__ */Fe("ZodCIDRv4",(e,t)=>{Qn.init(e,t),Gi.init(e,t)}),io=/* @__PURE__ */Fe("ZodCIDRv6",(e,t)=>{Xn.init(e,t),Gi.init(e,t)}),oo=/* @__PURE__ */Fe("ZodBase64",(e,t)=>{tr.init(e,t),Gi.init(e,t)}),so=/* @__PURE__ */Fe("ZodBase64URL",(e,t)=>{nr.init(e,t),Gi.init(e,t)}),ao=/* @__PURE__ */Fe("ZodE164",(e,t)=>{rr.init(e,t),Gi.init(e,t)}),lo=/* @__PURE__ */Fe("ZodJWT",(e,t)=>{ir.init(e,t),Gi.init(e,t)}),co=/* @__PURE__ */Fe("ZodNumber",(e,t)=>{or.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:i,maximum:o,format:s,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:c}=e._zod.bag;"string"==typeof s&&s.includes("int")?r.type="integer":r.type="number";const d="number"==typeof c&&c>=(i??Number.NEGATIVE_INFINITY),u="number"==typeof l&&l<=(o??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof i&&(r.minimum=i),u?p?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l:"number"==typeof o&&(r.maximum=o),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),$i(e,"ZodNumber",{gt(e,t){return this.check(Xr(e,t))},gte(e,t){return this.check(ei(e,t))},min(e,t){return this.check(ei(e,t))},lt(e,t){return this.check(Kr(e,t))},lte(e,t){return this.check(Qr(e,t))},max(e,t){return this.check(Qr(e,t))},int(e){return this.check(ho(e))},safe(e){return this.check(ho(e))},positive(e){return this.check(Xr(0,e))},nonnegative(e){return this.check(ei(0,e))},negative(e){return this.check(Kr(0,e))},nonpositive(e){return this.check(Qr(0,e))},multipleOf(e,t){return this.check(ti(e,t))},step(e,t){return this.check(ti(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 uo(e){return function(e,t){return new e({type:"number",checks:[],...ct(t)})}(co,e)}var po=/* @__PURE__ */Fe("ZodNumberFormat",(e,t)=>{sr.init(e,t),co.init(e,t)});function ho(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(po,e)}var mo=/* @__PURE__ */Fe("ZodBoolean",(e,t)=>{ar.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function fo(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(mo,e)}var go=/* @__PURE__ */Fe("ZodNull",(e,t)=>{lr.init(e,t),ji.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 yo=/* @__PURE__ */Fe("ZodUnknown",(e,t)=>{cr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function wo(){return new yo({type:"unknown"})}var bo=/* @__PURE__ */Fe("ZodNever",(e,t)=>{dr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function vo(e){return function(e,t){return new e({type:"never",...ct(t)})}(bo,e)}var xo=/* @__PURE__ */Fe("ZodDate",(e,t)=>{ur.init(e,t),ji.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(ei(t,n)),e.max=(t,n)=>e.check(Qr(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}),ko=/* @__PURE__ */Fe("ZodArray",(e,t)=>{hr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(i.minItems=s),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=li(o.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,$i(e,"ZodArray",{min(e,t){return this.check(ri(e,t))},nonempty(e){return this.check(ri(1,e))},max(e,t){return this.check(ni(e,t))},length(e,t){return this.check(ii(e,t))},unwrap(){return this.element}})});function _o(e,t){return function(e,t,n){return new e({type:"array",element:t,...ct(n)})}(ko,e,t)}var So=/* @__PURE__ */Fe("ZodObject",(e,t)=>{wr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object",i.properties={};const s=o.shape;for(const c in s)i.properties[c]=li(s[c],t,{...r,path:[...r.path,"properties",c]});const a=new Set(Object.keys(s)),l=new Set([...a].filter(e=>{const n=o.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(i.required=Array.from(l)),"never"===o.catchall?._zod.def.type?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=li(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),Ke(e,"shape",()=>t.shape),$i(e,"ZodObject",{keyof(){return Po(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:wo()})},loose(){return this.clone({...this._zod.def,catchall:wo()})},strict(){return this.clone({...this._zod.def,catchall:vo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!it(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 lt(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Qe(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!it(t))throw new Error("Invalid input to safeExtend: expected a plain object");return lt(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Qe(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 lt(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Qe(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 lt(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 Qe(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 lt(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 Qe(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 lt(t,Xe(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Qe(this,"shape",i),i},checks:[]}))}(Fo,this,e[0])},required(...e){return t=Vo,n=this,r=e[0],lt(n,Xe(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(r)for(const n in r){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return Qe(this,"shape",i),i}}));var t,n,r}})});function Co(e,t){return new So({type:"object",shape:e??{},...ct(t)})}var Io=/* @__PURE__ */Fe("ZodUnion",(e,t)=>{vr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=!1===i.inclusive,s=i.options.map((e,n)=>li(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options});function Eo(e,t){return new Io({type:"union",options:e,...ct(t)})}var To=/* @__PURE__ */Fe("ZodDiscriminatedUnion",(e,t)=>{Io.init(e,t),xr.init(e,t)});function Ao(e,t,n){return new To({type:"union",options:t,discriminator:e,...ct(n)})}var Mo=/* @__PURE__ */Fe("ZodIntersection",(e,t)=>{kr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=li(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=li(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]]})(e,t,n,r)});var zo=/* @__PURE__ */Fe("ZodRecord",(e,t)=>{Cr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=s._zod.bag?.patterns;if("loose"===o.mode&&a&&a.size>0){const e=li(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const t of a)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=li(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=li(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const l=s._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Oo(e,t,n){return t&&t._zod?new zo({type:"record",keyType:e,valueType:t,...ct(n)}):new zo({type:"record",keyType:Bi(),valueType:e,...ct(t)})}var Ro=/* @__PURE__ */Fe("ZodEnum",(e,t)=>{Ir.init(e,t),ji.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 i={};for(const o of e){if(!n.has(o))throw new Error(`Key ${o} not found in enum`);i[o]=t.entries[o]}return new Ro({...t,checks:[],...ct(r),entries:i})},e.exclude=(e,r)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Ro({...t,checks:[],...ct(r),entries:i})}});function Po(e,t){return new Ro({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ct(t)})}var No=/* @__PURE__ */Fe("ZodLiteral",(e,t)=>{Er.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,i=[];for(const o of r.values)if(void 0===o){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof o){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(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]}})});function Lo(e,t){return new No({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}var Do=/* @__PURE__ */Fe("ZodFile",(e,t)=>{Tr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:a}=e._zod.bag;void 0!==o&&(i.minLength=o),void 0!==s&&(i.maxLength=s),a?1===a.length?(i.contentMediaType=a[0],Object.assign(r,i)):(Object.assign(r,i),r.anyOf=a.map(e=>({contentMediaType:e}))):Object.assign(r,i)})(e,0,n),e.min=(t,n)=>e.check(function(e,t){return new yn({check:"min_size",...ct(t),minimum:e})}(t,n)),e.max=(t,n)=>e.check(function(e,t){return new gn({check:"max_size",...ct(t),maximum:e})}(t,n)),e.mime=(t,n)=>e.check(function(e,t){return new Tn({check:"mime_type",mime:e,...ct(t)})}(Array.isArray(t)?t:[t],n))});var $o=/* @__PURE__ */Fe("ZodTransform",(e,t)=>{Ar.init(e,t),ji.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 Be(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(wt(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(wt(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function jo(e){return new $o({type:"transform",transform:e})}var Fo=/* @__PURE__ */Fe("ZodOptional",(e,t)=>{zr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Uo(e){return new Fo({type:"optional",innerType:e})}var Bo=/* @__PURE__ */Fe("ZodExactOptional",(e,t)=>{Or.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Go=/* @__PURE__ */Fe("ZodNullable",(e,t)=>{Rr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=li(i.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wo(e){return new Go({type:"nullable",innerType:e})}var Ho=/* @__PURE__ */Fe("ZodDefault",(e,t)=>{Pr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Zo=/* @__PURE__ */Fe("ZodPrefault",(e,t)=>{Lr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Vo=/* @__PURE__ */Fe("ZodNonOptional",(e,t)=>{Dr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var qo=/* @__PURE__ */Fe("ZodCatch",(e,t)=>{jr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;let o;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Yo=/* @__PURE__ */Fe("ZodPipe",(e,t)=>{Fr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s="input"===t.io?o?i.out:i.in:i.out;li(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Jo(e,t){return new Yo({type:"pipe",in:e,out:t})}var Ko=/* @__PURE__ */Fe("ZodPreprocess",(e,t)=>{Yo.init(e,t),Br.init(e,t)}),Qo=/* @__PURE__ */Fe("ZodReadonly",(e,t)=>{Gr.init(e,t),ji.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Xo=/* @__PURE__ */Fe("ZodCustom",(e,t)=>{Zr.init(e,t),ji.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 es(e,t={}){const n=new Xo({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...ct(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:"invalid_type",expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function ts(e,t){return new Ko({type:"pipe",in:jo(e),out:t})}function ns(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...ct(t)})}(co,e)}function rs(e){return function(e,t){return new e({type:"boolean",coerce:!0,...ct(t)})}(mo,e)}function is(e){return function(e,t){return new e({type:"date",coerce:!0,...ct(t)})}(xo,e)}Po(["free","startup","growth","enterprise"]);var os,ss=Po(["created","active","suspended","pending_approval"]),as=Po(["free","startup","growth","enterprise"]),ls=Po(["human","ai"]),cs=Po(["male","female"]),ds=Po(["active","learning","error"]),us=Co({vector_index_created:fo().nullable(),graph_index_created:fo().nullable()}),ps=Po(["document","video"]),hs=Po(["user","research"]),ms=Po(["pending","processing","waiting_review","completed","failed"]),fs=(Po(["user","agent"]),Po(["widget","app"])),gs=(Po(["tell","show","do"]),Po(["app","website"])),ys=Po(["widget"]),ws=Po(["timer","github","slack","teams","jira","mcp"]),bs=Po(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_agent","update_agent","delete_agent","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"]),vs=Co({id:uo().optional(),created_at:is().optional(),updated_at:is().optional()}),xs=Co({file:es(File),application_id:ns().optional()}),ks=Co({id:ns()}),_s=Co({slug:Bi()}),Ss=Co({agent_id:ns()}),Cs=Co({widget_id:ns()}),Is=Co({simulation_id:ns()}),Es=Co({application_id:ns()}),Ts=Co({user_id:ns()}),As=Co({success:Lo(!0)}),Ms=As.extend({message:Bi()}),zs=(Co({workspace_id:ns().optional()}),Co({application_id:ns().optional()}),Co({limit:ns().optional().default(50),offset:ns().optional().default(0)})),Os=e=>Co({items:_o(e),total:uo(),limit:uo(),offset:uo()}),Rs=e=>Co({items:_o(e),count:uo()}),Ps=Co({status:Bi(),timestamp:Bi(),service:Bi(),version:Bi(),build:Bi()}),Ns=Co({name:Bi(),version:Bi(),build:Bi(),status:Bi(),timestamp:Bi()}),Ls=Po(["password","oauth"]),Ds=vs.extend({is_super:fo(),status:ss,email:Bi().email(),external_id:Bi().nullish(),first_name:Bi().nullish(),last_name:Bi().nullish(),password:Bi().nullish(),image_url:Bi().nullish(),prompt_limit:uo().nullish(),last_login_at:is().nullish(),auth_method:Ls.nullish()}),$s=Ds.partial().extend({email:Bi().email(),password:Bi()}),js=Ds.partial(),Fs=Co({users:_o($s)}),Us=Co({users:_o(Ds.partial())}),Bs=(Co({token:Bi()}),vs.extend({name:Bi(),slug:Bi(),status:ss,package:as,ending_date:is().nullish(),external_workspace_id:Bi().nullish(),slack_webhook_configured:fo().optional(),notify_all_members_on_question:fo().optional()})),Gs=Bs.partial().extend({name:Bi().min(1)}),Ws=Bi().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),Hs=Bs.omit({slack_webhook_configured:!0}).partial().extend({slack_webhook_url:Ws.nullable().optional()}),Zs=Po(["active","past_due","canceled","unpaid","trialing","incomplete","incomplete_expired","paused"]),Vs=vs.extend({workspace_id:uo(),package:as,ending_date:is(),stripe_subscription_id:Bi().nullable(),stripe_price_id:Bi().nullable(),status:Zs.default("active").optional()}),qs=(Vs.partial().extend({workspace_id:uo(),package:as}),Vs.partial(),Po(["owner","member"])),Ys=vs.extend({workspace_id:uo(),user_id:uo(),role:qs}),Js=Co({id:uo(),agent_name:Bi(),image_url:Bi().nullish()}),Ks=vs.extend({workspace_id:uo(),application_id:uo().optional(),file_name:Bi().min(1),file_size:ns(),file_type:ps,file_url:Bi(),source_url:Bi().nullish(),source:hs.default("user").optional(),agents:_o(Js).optional()}),Qs=Po(["chromium","firefox","webkit"]),Xs=Co({browsers:_o(Qs).default(["chromium"]),parallel:fo().default(!1),fail_fast:fo().default(!1),timeout_per_browser:uo().int().min(60).max(3600).optional()}),ea=vs.extend({workspace_id:uo(),user_id:uo(),application_id:uo(),file_name:Bi().min(1),file_size:ns(),file_type:Bi(),file_url:Bi(),file_path:Bi().nullable(),text_content:Bi().nullish(),additional_instructions:Bi().max(1e3).nullish(),status:ms,processing_step:Bi().nullish(),processing_started_at:is().nullish(),ultimate_goal:Bi().nullish(),browser_config:Xs.nullish(),persona_ids:_o(ns()).optional().default([]),pinned:fo().optional().default(!1)}),ta=Co({application_id:ns(),file:es(File).optional(),text_content:Bi().optional(),file_name:Bi().optional(),additional_instructions:Bi().max(1e3).optional(),persona_ids:_o(ns()).optional()}),na=vs.extend({qa_flow_id:uo(),workspace_id:uo(),triggered_by:uo(),browser_type:Qs,browser_config:Xs.nullish(),simulation_id:uo(),source:Po(["manual","automation","github_pr","slack_command"]).nullish(),source_metadata:Oo(Bi(),wo()).nullish(),auto_heal:fo().default(!1),auto_accept:fo().default(!1),has_question:fo().optional()}),ra=Co({version:uo().int().positive(),test_title:Bi(),test_objective:Bi(),test_steps:_o(Bi()),expected_outcome:Bi(),priority:Po(["Low","Medium","High"]),change_type:Po(["created","modified","self_healed","refined","deleted"]),change_reason:Bi().nullish(),changed_by:uo().nullish(),created_at:Bi(),accepted:fo().optional()}),ia=Co({failure_type:Po(["locator","assertion","timeout","flow_change","environment"]),failure_message:Bi().nullish(),failure_context:Oo(Bi(),wo()).nullish(),repair_strategy:Bi().nullish(),repair_details:Oo(Bi(),wo()).nullish(),confidence_score:uo().min(0).max(1).nullish(),validation_status:Po(["pending","validated","failed","rejected"]),simulation_id:uo().nullish(),validation_simulation_id:uo().nullish(),healed_version:uo().nullish(),created_at:Bi()}),oa=(Po(["passed","needs_healing","failed"]),Co({outcome_reached:fo(),steps_aligned:fo(),healing_recommended:fo(),is_actual_bug:fo(),confidence:uo().min(0).max(1),reasoning:Bi(),evaluated_at:Bi(),screenshot_url:Bi().nullish()})),sa=Po(["queued","running","passed","failed","needs_healing","stopped"]),aa=Co({qa_run_id:uo(),qa_test_case_id:uo(),simulation_task_id:Bi().nullable().optional(),status:sa,verdict:Bi().nullable().optional(),proposed_steps:_o(Bi()).default([]),executed_steps:_o(Bi()).nullable().optional(),evaluation:oa.nullable().optional(),started_at:is().nullable().optional(),ended_at:is().nullable().optional(),created_at:is().optional(),updated_at:is().optional()}),la=vs.extend({qa_flow_id:uo(),workspace_id:uo(),order_index:uo().int().nonnegative(),test_title:Bi(),test_objective:Bi(),test_steps:_o(Bi()),expected_outcome:Bi(),priority:Po(["Low","Medium","High"]),is_active:ts(e=>"number"==typeof e?0!==e:e,fo()),current_version:uo().int().positive(),version_history:_o(ra).nullable(),healing_attempts:_o(ia).nullable(),healing_metadata:Oo(Bi(),wo()).nullish(),last_healed_at:is().nullish(),blocked_by:_o(Co({index:uo().int().nonnegative(),condition:Po(["pass"]).optional()})).default([])}),ca=(Co({qa_flow_id:uo(),test_title:Bi(),test_objective:Bi(),test_steps:_o(Bi()),expected_outcome:Bi(),priority:Po(["Low","Medium","High"]).optional()}),Co({ultimateGoal:Bi(),document:ea,testCases:_o(Co({id:uo(),title:Bi(),prompt:Bi(),objective:Bi(),steps:_o(Bi()),expectedOutcome:Bi(),priority:Po(["Low","Medium","High"])})),summary:Co({total:uo(),estimatedTime:Bi(),complexity:Po(["Low","Medium","High"])})})),da=Co({ultimate_goal:Bi(),test_cases:_o(Co({test_title:Bi(),test_objective:Bi(),test_steps:_o(Bi()),expected_outcome:Bi(),priority:Po(["Low","Medium","High"])})),summary:Co({total_tests:uo(),high_priority:uo(),medium_priority:uo(),low_priority:uo(),estimated_time_minutes:uo()})}),ua=(Ao("event",[Co({event:Lo("response.created"),data:Co({message:Bi()})}),Co({event:Lo("response.progress"),data:Co({message:Bi()})}),Co({event:Lo("response.clear"),data:Co({}).optional()}),Co({event:Lo("response.completed"),data:da}),Co({event:Lo("error"),data:Co({detail:Bi()})})]),Eo([Bi(),uo(),fo(),_o(Bi()),function(e,t){return new e({type:"null",...ct(t)})}(go,os)])),pa=(Po(["created","modified","self_healed","refined","deleted"]),Po(["locator","assertion","timeout","flow_change","environment"])),ha=(Po(["pending","validated","failed","rejected"]),Co({healing_enabled:fo().default(!0),auto_apply:fo().default(!1),min_confidence_threshold:uo().min(0).max(1).default(.85),max_healing_attempts:uo().int().min(1).max(5).default(2),last_healing_attempt:Bi().datetime().nullable(),total_healing_attempts:uo().int().default(0),successful_heals:uo().int().default(0)}),Co({failure_type:pa,is_healable:fo(),is_actual_bug:fo(),failure_message:Bi(),failure_context:Oo(Bi(),wo()),suggested_repair:Co({type:Po(["update_locator","update_assertion","update_steps","skip_test"]),confidence:uo().min(0).max(1),details:Oo(Bi(),wo())}).nullable()})),ma=(Co({go_to_url:Co({url:Bi(),new_tab:fo()})}),Co({click_element_by_index:Co({index:uo().int().min(1)})}),Co({input_text:Co({index:uo(),text:Bi(),clear_existing:fo()})}),Co({write_file:Co({file_name:Bi(),content:Bi(),append:fo(),trailing_newline:fo(),leading_newline:fo()})}),Co({get_otp:Co({question:Bi()})}),Co({done:Co({success:fo(),message:Bi().optional()})}),Co({wait:Co({seconds:uo()})}),Co({reload_page:Co({})}),Co({open_new_tab:Co({url:Bi()})}),Co({navigate_to_url:Co({url:Bi()})}),Oo(Bi(),wo())),fa=Co({evaluation_previous_goal:Bi().optional().nullable(),memory:Bi().optional().nullable(),next_goal:Bi().optional().nullable(),action:_o(ma).optional().nullable(),thinking:Bi().optional().nullable()}).passthrough(),ga=Co({is_done:fo(),success:fo().optional().nullable(),long_term_memory:Bi().optional().nullable(),extracted_content:Bi().optional().nullable(),include_extracted_content_only_once:fo().optional().nullable(),include_in_memory:fo().optional().nullable(),error:Bi().optional().nullable(),metadata:Co({click_x:uo().optional(),click_y:uo().optional(),new_tab_opened:fo().optional(),input_x:uo().optional(),input_y:uo().optional()}).passthrough().optional().nullable()}).passthrough(),ya=Co({url:Bi(),title:Bi(),tab_id:Bi().optional(),parent_tab_id:Bi().optional().nullable()}).passthrough(),wa=Co({node_id:uo().optional(),backend_node_id:uo().optional(),frame_id:Bi().optional().nullable(),node_type:uo().optional(),node_value:Bi().optional(),node_name:Bi().optional(),attributes:Oo(Bi(),Bi()).optional().nullable(),x_path:Bi().optional(),element_hash:uo().optional(),bounds:Co({x:uo(),y:uo(),width:uo(),height:uo()}).passthrough().optional().nullable(),stable_hash:uo().optional(),ax_name:Bi().optional().nullable()}).passthrough(),ba=Co({tabs:_o(ya),screenshot_path:Bi().nullable(),interacted_element:_o(wa.nullable()),url:Bi(),title:Bi()}).passthrough(),va=Co({step_start_time:uo().optional().nullable(),step_end_time:uo().optional().nullable(),step_number:uo().optional().nullable(),step_interval:uo().optional().nullable()}).passthrough(),xa=Co({model_output:fa.nullable(),result:_o(ga),state:ba,metadata:va.nullable(),state_message:Bi().optional().nullable()}).passthrough(),ka=Co({step_number:uo().int().positive(),topic:Bi(),screenshot_url:Bi().nullable(),title:Bi().optional().nullable(),url:Bi().optional().nullable()}),_a=(Co({status:Bi(),status_message:Bi().nullable(),task_id:Bi().nullish(),created_at:is()}),Co({task_id:Bi(),condition:Po(["pass"]).optional()})),Sa=Co({task_id:Bi(),title:Bi(),instructions:Bi(),status:Po(["pending","running","has_question","passed","failed","skipped","stopped"]),error_message:Bi().nullish(),started_at:Bi().nullish(),completed_at:Bi().nullish(),order_index:uo().int().nonnegative().default(0),tab_id:Bi().nullish(),step_count:uo().int().nonnegative().default(0),blocked_by:_o(_a).default([])}),Ca=vs.extend({application_id:uo(),agent_id:uo(),job_id:Bi(),browser_session_id:Bi().nullish(),status:Bi(),status_message:Bi().nullish(),path:Bi().nullish(),instructions:Bi().nullish(),pinned:fo().optional(),source:Po(["direct","qa"]).optional(),agent_name:Bi().nullish(),graph_index_id:Bi().nullish(),source_metadata:Oo(Bi(),wo()).nullish(),tasks:_o(Sa).optional(),agents:_o(Js).optional(),mindmap_status:Bi().optional(),mindmap_steps_processed:uo().int().nonnegative().optional(),mindmap_steps_total:uo().int().nonnegative().optional(),mindmap_error:Bi().nullish(),created_by_user_id:uo().nullish(),has_question:fo().optional()}),Ia=Ca.omit({tasks:!0,source_metadata:!0}),Ea=(Co({user_id:uo(),email:Bi(),first_name:Bi().optional().nullable(),last_name:Bi().optional().nullable(),last_simulation_at:Bi().optional()}),Ca.omit({tasks:!0}).partial().extend({application_id:uo(),agent_id:uo(),instructions:Bi(),max_steps:uo().int().positive().max(1e3).optional(),timeout:uo().positive().max(360).optional()})),Ta=Co({job_id:Bi().optional(),status:Bi().optional(),status_message:Bi().optional(),pinned:fo().optional(),graph_index_id:Bi().optional()}),Aa=Co({answer:Bi().min(1)}),Ma=vs.extend({session_id:Bi(),chat_id:Bi(),application_id:ns(),blob_url:Bi().nullable(),event_count:ns().int().nonnegative(),started_at:is(),ended_at:is().nullable(),is_active:ts(e=>"number"==typeof e?0!==e:e,fo()),metadata:Co({userAgent:Bi().optional(),url:Bi().optional(),viewport:Co({width:uo(),height:uo()}).optional()}).nullable(),last_batch_index:ns().int().nullable(),last_event_timestamp:ns().int().nullable(),last_upload_time:is().nullable()}),za=Co({session_id:Bi().min(1),chat_id:Bi().min(1),application_id:uo().int().nullish(),blob_url:Bi().nullish(),event_count:uo().int().nonnegative().optional(),started_at:is().optional(),ended_at:is().nullish(),is_active:ts(e=>"number"==typeof e?0!==e:e,fo()).optional(),metadata:Co({userAgent:Bi().optional(),url:Bi().optional(),viewport:Co({width:uo(),height:uo()}).optional()}).nullable().optional(),last_batch_index:uo().int().nonnegative().nullish(),last_event_timestamp:uo().int().nullish(),last_upload_time:is().nullish()}),Oa=Co({id:uo(),simulation_id:uo(),status:Bi(),status_message:Bi().nullable(),created_at:is()}),Ra=Co({start:Bi(),end:Bi(),action:Bi()}).passthrough(),Pa=Co({id:Bi(),label:Bi(),purpose:Bi(),elements:_o(Oo(Bi(),wo())).default([]),bbox:Oo(Bi(),wo()).default({}),screenshot:Bi().default(""),embedding:_o(uo()).nullish()}).passthrough(),Na=Co({id:Bi(),title:Bi(),url:Bi(),summary:Bi().default(""),screenshot:Bi().default(""),sections:_o(Pa).default([]),sequence_ids:_o(uo()).default([]),embedding:_o(uo()).nullish()}).passthrough(),La=Co({nodes:_o(Na),edges:_o(Ra)}),Da=vs.extend({workspace_id:uo(),user_id:uo().nullish(),application_id:uo(),agent_name:Bi(),agent_type:ls,agent_voice:cs,agent_description:Bi().nullish(),instructions:Bi().nullish(),image_url:Bi().nullish(),graph_index_id:Bi().nullish(),vector_store_id:Bi().nullish(),status:ds,status_message:Bi().nullish(),learning_progress:us.nullish(),learning_started_at:is().nullish(),workspace:Bs.optional(),user:Ds.optional(),knowledge:_o(Ks).optional(),simulations:_o(Ca).optional(),simulation_count:uo().int().nonnegative().optional(),knowledge_count:uo().int().nonnegative().optional()}),$a=e=>{if(Array.isArray(e))return e.map(e=>Number(e));if("string"==typeof e){const t=JSON.parse(e);return Array.isArray(t)?t.map(e=>Number(e)):[]}return[]},ja=Eo([_o(uo()),Bi()]).transform($a),Fa=Eo([_o(uo()),Bi()]).transform($a),Ua=Da.partial().extend({application_id:ns(),agent_name:Bi(),agent_type:ls,agent_voice:cs,agent_description:Bi(),instructions:Bi(),file:es(File).optional(),image_url:Bi().optional(),knowledge_ids:ja,simulation_ids:Fa}),Ba=Da.partial().extend({file:es(File).optional(),knowledge_ids:ja,simulation_ids:Fa}),Ga=(Co({text:Bi(),task_id:Bi().optional()}),Co({status:Bi(),message:Bi().optional()}),Co({task_id:Bi().optional(),status:Bi().optional(),current_step:Bi().optional(),error:Bi().optional(),message:Bi().optional()}),Co({workflow_id:Bi(),workflow_type:Bi(),status:Bi(),current_step:Bi(),error:Bi().nullable(),created_at:Bi(),updated_at:Bi()}),Co({browser_session_id:Bi().optional(),live_view_url:Bi().nullish(),status:Bi().optional(),message:Bi().nullish(),success:fo().optional()}),Co({contentType:Po(["document","video","automation_log","screenshot","all"]).optional(),context:Bi().optional(),previousActions:_o(Bi()).optional(),top:ns().min(1).max(100).optional(),minConfidence:ns().min(0).max(1).optional(),entities:_o(Bi()).optional(),useVectorSearch:fo().optional(),vectorThreshold:ns().min(0).max(1).optional()}),Co({id:Bi(),content:Bi(),contentType:Po(["document","video","automation_log","screenshot"]),sourceFile:Bi(),sourceType:Bi(),metadata:Bi(),confidence:uo(),keyPhrases:_o(Bi()),entities:_o(Bi()),sentiment:Bi(),vectorContent:_o(uo())})),Wa=(Co({document:Ga,score:uo(),highlights:Oo(Bi(),_o(Bi())).optional()}),Co({simulation_id:ns().positive("Simulation ID must be a positive number")})),Ha=Co({agent:Da,simulation_id:uo(),knowledge_id:uo(),message:Bi()}),Za=vs.extend({workspace_id:uo(),name:Bi(),slug:Bi(),type:gs,url:Bi().nullish(),username:Bi().nullish(),password:Bi().nullish(),allowed_domains:_o(Bi()).nullish().default([])}),Va=Za.omit({password:!0}),qa=Za.partial().extend({type:gs,name:Bi().min(1),url:Bi(),allowed_domains:_o(Bi()).optional().default([])}),Ya=Za.partial().omit({workspace_id:!0,slug:!0}),Ja=Co({chip_mode:Po(["show","tell","do"]),chip_text:Bi()}),Ka=Co({widget_enabled:fo(),widget_appearance:Po(["default","compact","full"]),widget_position:Po(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Po(["desktop","mobile","desktop_mobile"]),widget_header:Bi(),widget_body:Bi(),widget_greeting:Bi(),widget_feature_tell:fo(),widget_feature_show:fo(),widget_feature_do:fo(),widget_feature_human:fo(),widget_background_color:Bi(),widget_text_color:Bi(),widget_border_color:Bi(),widget_accent_color:Bi(),widget_secondary_color:Bi(),widget_border_radius:Bi(),widget_font_size:Bi(),widget_width:Bi(),widget_height:Bi(),widget_shadow:Bi(),widget_animation_duration:Bi(),widget_fade_duration:Bi(),widget_bounce_effect:fo(),widget_chips:_o(Ja)}),Qa=vs.extend({application_id:uo(),agent_id:uo(),type:ys,settings:Ka,status:ss,marketrix_id:Bi(),marketrix_key:Bi(),snippet:Bi().nullish()}),Xa=(Qa.extend({application:Va.partial(),workspace:Bs.partial(),user:Ds.partial(),agent:Da.partial()}),Qa.extend({agent:Da.partial().optional()})),el=(Va.extend({widgets:_o(Qa).optional(),agents:_o(Da).optional()}),Qa.partial().extend({application_id:uo().positive(),agent_id:uo().positive(),type:ys,settings:Ka.optional()})),tl=Qa.partial(),nl=vs.extend({widget_id:uo(),url_pattern:Bi(),message:_o(Bi()),description:Bi().optional()}),rl=nl.partial().extend({widget_id:uo().positive(),url_pattern:Bi().min(1),message:_o(Bi().min(1)).min(1)}),il=nl.partial(),ol=(Co({marketrix_id:Bi().optional(),marketrix_key:Bi().optional(),agent_id:uo().positive().optional(),application_id:uo().positive().optional(),chat_id:Bi().optional(),content:Bi()}).refine(e=>(e.marketrix_id&&e.marketrix_key)??(e.agent_id&&e.application_id),{message:"Either marketrix_id + marketrix_key or both agent_id + application_id must be provided"}),Co({text:Bi(),task_id:Bi().optional()}),Ao("type",[Co({type:Lo("registered"),chat_id:Bi(),application_id:uo().optional()}),Co({type:Lo("pong")}),Co({type:Lo("heartbeat")}),Co({type:Lo("chat/response"),request_id:Bi(),text:Bi(),task_id:Bi().optional()}),Co({type:Lo("chat/error"),request_id:Bi(),error:Bi()}),Co({type:Lo("task/status"),status:Po(["running","completed","failed","stopped","has_question"]),message:Bi().optional(),task_id:Bi().optional(),timestamp:uo().optional()}),Co({type:Lo("tool/call"),call_id:Bi(),tool:Bi(),args:Oo(Bi(),wo()),mode:Po(["show","do"]).optional(),explanation:Bi().optional(),state_version:uo().optional()})])),sl=Ao("type",[Co({type:Lo("chat/tell"),request_id:Bi(),content:Bi()}),Co({type:Lo("chat/show"),request_id:Bi(),content:Bi()}),Co({type:Lo("chat/do"),request_id:Bi(),content:Bi()}),Co({type:Lo("chat/stop"),task_id:Bi().optional()}),Co({type:Lo("tool/response"),call_id:Bi(),success:fo(),data:Bi().optional(),error:Bi().optional(),state_version:uo().optional()}),Co({type:Lo("ping")}),Co({type:Lo("rrweb/metadata"),session_id:Bi(),chat_id:Bi(),application_id:uo(),url:Bi().optional(),user_agent:Bi().optional(),timestamp:uo().optional(),viewport:Co({width:uo(),height:uo()}).optional()}),Co({type:Lo("rrweb/events"),session_id:Bi(),events:_o(wo())})]),al=Po(["simulations","agents","qa","user","jobs","triggers","automations","notifications"]),ll=Po(["queued","running","creating_knowledge","completed","failed","stopped"]),cl=Po(["pending","running","completed","failed","stopped"]),dl=Ao("type",[Co({type:Lo("simulation/updated"),simulation_id:uo(),application_id:uo(),status:ll,has_question:fo().optional(),step_label:Bi().optional(),step_pending:fo().optional(),task_id:Bi().nullish()}),Co({type:Lo("simulation/created"),simulation_id:uo(),application_id:uo()}),Co({type:Lo("simulation/deleted"),simulation_id:uo(),application_id:uo()}),Co({type:Lo("simulation/queued"),simulation_id:uo(),job_id:Bi()}),Co({type:Lo("simulation/started"),simulation_id:uo(),job_id:Bi()}),Co({type:Lo("simulation/step"),simulation_id:uo(),job_id:Bi(),step_count:uo().optional(),message:Bi().optional()}),Co({type:Lo("simulation/question"),simulation_id:uo(),job_id:Bi(),question:Bi().optional()}),Co({type:Lo("simulation/completed"),simulation_id:uo(),job_id:Bi(),step_count:uo().optional()}),Co({type:Lo("simulation/failed"),simulation_id:uo(),job_id:Bi(),error:Bi().optional()}),Co({type:Lo("simulation/stopped"),simulation_id:uo(),job_id:Bi()}),Co({type:Lo("simulation/mindmap-updated"),simulation_id:uo(),application_id:uo(),mindmap_status:Bi(),steps_processed:uo(),steps_total:uo()}),Co({type:Lo("qa-run/completed"),run_id:uo(),status:Bi()}),Co({type:Lo("agent/updated"),agent_id:uo().optional(),context_id:Bi().optional(),task_id:Bi().optional(),application_id:uo().optional(),status:Bi(),error:Bi().optional()}),Co({type:Lo("agent/created"),agent_id:uo(),application_id:uo()}),Co({type:Lo("agent/deleted"),agent_id:uo(),application_id:uo()}),Co({type:Lo("qa-document/updated"),document_id:uo(),application_id:uo(),status:Bi(),step_label:Bi().optional()}),Co({type:Lo("qa-run/updated"),run_id:uo(),document_id:uo(),application_id:uo(),status:cl,has_question:fo().optional(),simulation_id:uo().optional()}),Co({type:Lo("qa-test/updated"),test_id:uo(),run_id:uo(),document_id:uo(),application_id:uo(),status:Bi()}),Co({type:Lo("user/updated"),user_id:uo(),workspace_id:uo(),status:Bi()}),Co({type:Lo("job/progress"),job_id:Bi(),application_id:uo(),status:Bi(),message:Bi().optional(),phase:Po(["research","segments","personas"]).optional()}),Co({type:Lo("job/completed"),job_id:Bi(),application_id:uo(),result:wo().optional()}),Co({type:Lo("job/failed"),job_id:Bi(),application_id:uo(),error:Bi()}),Co({type:Lo("trigger/fired"),trigger_id:uo(),workspace_id:uo(),provider:Bi(),name:Bi(),payload:wo().optional(),timestamp:Bi()}),Co({type:Lo("automation-run/completed"),automation_id:uo(),run_id:uo(),status:Lo("completed")}),Co({type:Lo("automation-run/failed"),automation_id:uo(),run_id:uo(),status:Lo("failed"),error:Bi().optional()}),Co({type:Lo("reaction/completed"),reaction_id:uo(),run_id:uo(),application_id:uo()}),Co({type:Lo("reaction/failed"),reaction_id:uo(),run_id:uo(),application_id:uo(),error:Bi().optional()}),Co({type:Lo("reaction/progress"),reaction_id:uo(),run_id:uo(),application_id:uo(),result_id:uo(),persona_id:uo().nullable(),completed_personas:uo(),total_personas:uo(),failed_personas:uo()}),Co({type:Lo("notification/created"),notification_id:uo(),workspace_id:uo(),recipient_user_id:uo(),simulation_id:uo(),application_id:uo(),task_id:Bi().nullable(),url:Bi(),summary:Bi(),question_text:Bi().nullable()}),Co({type:Lo("notification/resolved"),notification_id:uo(),workspace_id:uo(),simulation_id:uo(),application_id:uo(),reason:Po(["answered","dismissed","cancelled"])})]),ul=Po(["simulation_question"]),pl=Po(["answered","dismissed","cancelled"]),hl=Co({id:uo(),workspace_id:uo(),recipient_user_id:uo(),type:ul,simulation_id:uo().nullable(),task_id:Bi().nullable(),question_text:Bi().nullable(),url:Bi().nullable(),summary:Bi(),email_sent_at:is().nullable(),read_at:is().nullable(),resolved_at:is().nullable(),resolved_reason:pl.nullable(),resolved_by_user_id:uo().nullable(),created_at:is()}),ml=Co({push:Co({enabled:fo()}),email:Co({enabled:fo(),delay_minutes:ns().int().min(1).max(120)}),slack:Co({enabled:fo()})}),fl=Co({endpoint:Bi().url(),p256dh:Bi().min(1),auth:Bi().min(1),user_agent:Bi().optional()}),gl=Co({endpoint:Bi().url()}),yl=Co({webhook_url:Ws}),wl=Co({public_key:Bi().nullable()}),bl=Co({details:Bi().optional(),id:uo().optional(),type:Bi().optional(),name:Bi().optional(),target_user_id:uo().optional(),target_user_email:Bi().optional(),reason:Bi().optional(),assigned_role:Bi().optional(),new_role:Bi().optional(),previous_role:Bi().optional(),workspace_name:Bi().optional(),workspace_slug:Bi().optional(),ip_address:Bi().optional(),user_agent:Bi().optional(),widget_type:Bi().optional(),created_by:uo().optional()}).passthrough(),vl=vs.extend({workspace_id:uo(),user_id:uo(),type:bs,metadata:bl.optional()}),xl=vl.partial().extend({type:bs}),kl=Po(["widget_chat","app_chat","guide_preview","slack"]),_l=Po(["user","assistant","system","tool"]),Sl=(vs.extend({context_id:Bi(),workspace_id:uo(),application_id:uo().nullish(),agent_id:uo().nullish(),user_id:uo().nullish(),simulation_id:uo().nullish(),session_id:uo().nullish(),persona_id:uo().nullish(),type:kl,channel_id:Bi().nullish(),preview_video_url:Bi().nullish(),metadata:Oo(Bi(),wo()).nullish()}),vs.extend({conversation_id:uo(),role:_l,content:Bi(),tool_call_id:Bi().nullish()}),vs.extend({workspace_id:uo(),application_id:uo().nullish(),provider:ws,name:Bi().min(1).max(120),identifier:Bi().max(120).nullish(),api_endpoint:Bi().url().nullish(),api_token:Bi().nullish(),metadata:Oo(Bi(),wo()).nullish(),is_active:fo().default(!0),status:ss.default("active")})),Cl=Co({id:ns().optional(),application_id:uo().nullish(),provider:ws,name:Bi().min(1).max(120),identifier:Bi().max(120).nullish(),api_endpoint:Bi().url().nullish(),api_token:Bi().nullish(),metadata:Oo(Bi(),wo()).nullish(),is_active:fo().optional(),status:ss.optional()}),Il=Co({application_id:uo().nullish(),provider:ws.optional(),status:ss.optional(),is_active:rs().optional(),limit:ns().int().positive().max(100).optional(),offset:ns().int().nonnegative().optional()}),El=Co({id:uo(),application_id:uo(),identifier:Bi(),api_token:Bi(),is_active:fo(),created_at:is().optional()}),Tl=Co({name:Bi(),category:Bi(),description:Bi(),inputSchema:Oo(Bi(),wo()),enabled:fo()}),Al=Co({id:uo(),full_name:Bi(),name:Bi(),private:fo(),html_url:Bi(),default_branch:Bi().optional()}),Ml=Co({id:uo(),name:Bi(),status:Bi(),conclusion:Bi().nullable(),created_at:Bi(),updated_at:Bi(),html_url:Bi(),head_branch:Bi(),run_attempt:uo()}),zl=Po(["pending","running","completed","failed","stopped"]),Ol=(Po(["connector","condition"]),Ao("kind",[Co({kind:Lo("connector"),connector_type:Bi().min(1),connector_id:uo().nullable().optional(),trigger_id:uo().nullable().optional(),action_id:uo().nullable().optional(),capability:Bi().min(1),role:Po(["trigger","callback"]),config:Oo(Bi(),wo()).default({})}),Co({kind:Lo("condition"),config:Co({field:Bi().min(1),operator:Po(["equals","not_equals","contains","gt","lt"]),value:wo()})})])),Rl=Co({from:Bi().min(1),to:Bi().min(1),when:Po(["true","false"]).optional()}),Pl=Co({nodes:Oo(Bi(),Ol),edges:_o(Rl)}),Nl=Po(["skip","queue","replace"]).default("skip"),Ll=vs.extend({workspace_id:uo(),created_by_user_id:uo().nullable(),name:Bi(),graph:Pl,concurrency:Nl,enabled:fo(),last_run_at:is().nullable(),next_run_at:is().nullable()}),Dl=Co({name:Bi().min(1).max(255),graph:Pl,concurrency:Nl.optional(),enabled:fo().optional()}),$l=Co({id:ns(),name:Bi().min(1).max(255).optional(),graph:Pl.optional(),enabled:fo().optional()}),jl=Co({enabled:rs().optional(),limit:ns().int().positive().max(100).optional(),offset:ns().int().nonnegative().optional()}),Fl=Co({status:Po(["in_progress","completed","failed","skipped","stopped"]),output:Oo(Bi(),wo()).nullable().optional(),error:Bi().nullable().optional(),duration_ms:uo().optional()}),Ul=Co({id:uo().optional(),automation_id:uo(),status:zl,trigger_node_id:Bi(),trigger_data:Oo(Bi(),wo()).nullable(),node_results:Oo(Bi(),Fl),started_at:is(),completed_at:is().nullable()}),Bl=Co({status:zl.optional(),limit:ns().int().positive().max(100).optional(),offset:ns().int().nonnegative().optional()}),Gl=Co({connector_type:Bi(),built_in:fo(),triggers:_o(Co({capability:Bi(),description:Bi(),config_schema:Oo(Bi(),wo())})),callbacks:_o(Co({capability:Bi(),description:Bi(),config_schema:Oo(Bi(),wo())}))}),Wl=Co({filename:Bi(),status:Bi(),additions:uo(),deletions:uo(),patch:Bi().optional()}),Hl=(Co({event:Bi(),action:Bi(),pull_request:Co({number:uo(),title:Bi(),html_url:Bi(),head:Co({sha:Bi(),ref:Bi()}),base:Co({ref:Bi()})}),repository:Co({full_name:Bi(),name:Bi(),owner:Co({login:Bi()})}),sender:Co({login:Bi()}),files:_o(Wl).optional()}),Co({name:Bi(),head_sha:Bi(),status:Po(["queued","in_progress","completed"]).optional(),conclusion:Po(["success","failure","neutral","cancelled","timed_out","action_required"]).optional(),started_at:Bi().optional(),completed_at:Bi().optional(),output:Co({title:Bi(),summary:Bi(),text:Bi().optional()}).optional()}),Co({url:Bi()})),Zl=(Co({user_id:uo(),file:es(File)}),Co({user_id:uo(),application_id:uo(),source:fs,prompt:Bi(),status:Bi()}),Co({user_id:uo(),limit:uo(),used:uo(),remaining:uo()})),Vl=(Co({user_id:uo(),workspace_id:uo(),chat_count:uo(),prompt_text:Bi(),metadata:Oo(Bi(),Bi()).optional()}),Co({to:Bi(),subject:Bi(),template:Bi(),context:Oo(Bi(),Bi())}),Co({id:Bi(),object:Lo("event"),api_version:Bi().nullish(),created:uo(),data:Co({object:Oo(Bi(),wo()),previous_attributes:Oo(Bi(),wo()).optional()}),livemode:fo(),pending_webhooks:uo(),request:Co({id:Bi().nullable(),idempotency_key:Bi().nullable()}).nullable().optional(),type:Bi()}),Co({priceId:Bi().min(1,"Price ID is required"),successUrl:Bi().url("Success URL must be a valid URL"),cancelUrl:Bi().url("Cancel URL must be a valid URL")})),ql=Co({returnUrl:Bi().url("Return URL must be a valid URL")}),Yl=Co({plan:Po(["startup","growth"]).default("startup"),interval:Po(["month","year"]).default("month")}),Jl=Co({subscriptionId:Bi().min(1,"Subscription ID is required"),priceId:Bi().min(1,"Price ID is required")}),Kl=Co({success:fo(),message:Bi()}),Ql=Co({subscriptionId:Bi().nullable(),customerId:Bi().nullable(),status:Po(["active","past_due","canceled","unpaid","trialing","incomplete","incomplete_expired","paused"]).nullable(),planTier:Po(["free","startup","growth","enterprise"]).nullable(),billingInterval:Po(["month","year"]).nullable(),priceId:Bi().nullable(),trialEndDate:is().nullable(),currentPeriodStart:is().nullable(),currentPeriodEnd:is().nullable(),cancelAtPeriodEnd:fo(),isTrialing:fo(),daysRemainingInTrial:uo().nullable(),trial_provisioned:fo()}),Xl=Co({sessionId:Bi(),url:Bi().url()}),ec=Co({url:Bi().url()}),tc=Co({subscriptionId:Bi(),customerId:Bi(),status:Lo("trialing"),trialStartDate:is(),trialEndDate:is(),planTier:Po(["startup","growth"]),daysRemainingInTrial:uo()}),nc=Co({used:uo().int().min(0),limit:uo().int()}),rc=Co({applications:nc,simulationsPerMonth:nc,userPrompts:nc}),ic=Co({amount:uo().int().min(0),currency:Bi().default("usd"),formatted:Bi()}),oc=Co({planId:Po(["free","startup","growth","enterprise"]),monthly:ic.nullable(),annual:ic.nullable(),priceIds:Co({monthly:Bi().nullable(),annual:Bi().nullable()})}),sc=Co({plans:_o(oc),lastUpdated:Bi().datetime()}),ac=Co({id:Po(["free","startup","growth","enterprise"]),name:Bi(),description:Bi(),features:_o(Bi()),cta:Bi(),isPopular:fo(),customPriceDisplay:Bi().optional(),priceSubtext:Bi().optional(),borderColor:Bi(),buttonColor:Bi(),outlineColor:Bi(),checkColor:Bi()}),lc=Co({plans:_o(ac)}),cc=Co({publishableKey:Bi(),priceIds:Co({startup:Co({monthly:Bi().nullable(),annual:Bi().nullable()}),growth:Co({monthly:Bi().nullable(),annual:Bi().nullable()})}),trialDays:uo().int().min(0),calendlyUrl:Bi()}),dc=Co({widgetKey:Bi(),widgetId:Bi(),widgetUrl:Bi()}),uc=Co({date:Bi().describe("YYYY-MM-DD"),sessions:uo().int().nonnegative(),events:uo().int().nonnegative()}),pc=Co({items:_o(uc)}),hc=Co({role:Po(["user","assistant","system"]),content:Bi(),timestamp:Bi().optional()}),mc=vs.extend({workspace_id:uo(),application_id:uo().nullish(),agent_id:uo().nullish(),simulation_id:uo().nullish(),chat_id:Bi(),chat_content:Bi().nullish(),chat_history:_o(hc).nullish(),chat_output:Bi().nullish(),preview_video_url:Bi().nullish(),metadata:Oo(Bi(),wo()).nullish()}),fc=Co({application_id:uo().nullish(),agent_id:uo().nullish(),simulation_id:uo().nullish(),chat_id:Bi(),chat_content:Bi().nullish(),chat_history:_o(hc).nullish(),chat_output:Bi().nullish(),preview_video_url:Bi().nullish(),metadata:Oo(Bi(),wo()).nullish()}),gc=Co({chat_id:Bi().optional(),agent_id:uo().optional(),simulation_id:uo().optional(),limit:uo().optional(),offset:uo().optional()}),yc=Po(["github","slack","teams","jira"]),wc=Po(["github","slack","teams","jira","timer","mcp"]),bc=Po(["github","slack","teams","jira","internal"]),vc=Po(["connected","disconnected"]),xc=Co({workspace_id:uo(),provider:yc,status:vc.default("disconnected"),credentials:Oo(Bi(),wo()).nullish(),provider_data:Oo(Bi(),wo()).nullish(),connected_at:is().nullish(),created_at:is().optional(),updated_at:is().optional()}),kc=vs.extend({workspace_id:uo(),connector_id:uo().nullish(),provider:wc,name:Bi().min(1).max(255),source_config:Oo(Bi(),wo()).default({}),webhook_id:Bi(),webhook_secret:Bi(),enabled:fo().default(!0),last_triggered_at:is().nullish()}),_c=Co({connector_id:uo().nullish(),provider:wc,name:Bi().min(1).max(255),source_config:Oo(Bi(),wo()).default({})}),Sc=Co({trigger_id:ns(),name:Bi().min(1).max(255).optional(),source_config:Oo(Bi(),wo()).optional(),enabled:fo().optional()}),Cc=Co({provider:wc.optional(),connector_id:ns().optional()}).extend(zs.shape),Ic=vs.extend({workspace_id:uo(),provider:bc,name:Bi().min(1).max(255),type:Bi().min(1).max(60),target_config:Oo(Bi(),wo()).default({}),is_default:fo().default(!1),enabled:fo().default(!0),last_executed_at:is().nullish()}),Ec=Co({provider:bc,name:Bi().min(1).max(255),type:Bi().min(1).max(60),target_config:Oo(Bi(),wo()).default({})}),Tc=Co({action_id:ns(),name:Bi().min(1).max(255).optional(),target_config:Oo(Bi(),wo()).optional(),enabled:fo().optional()}),Ac=Co({provider:bc.optional(),type:Bi().optional()}).extend(zs.shape),Mc=Po(["connected","not_connected"]),zc=Co({key:Bi(),label:Bi(),color:Bi(),status:Mc,session_count:uo().nullable()}),Oc=Co({id:uo(),application_id:uo(),name:Bi(),percentage:uo(),description:Bi(),avg_sessions_per_week:uo(),mobile_percentage:uo(),created_at:is().optional(),updated_at:is().optional()}),Rc=Co({id:uo(),application_id:uo(),segment_id:uo().nullable(),segment_name:Bi().optional(),is_selected:fo().default(!1),is_top:fo().default(!1),name:Bi(),initials:Bi(),description:Bi(),traits:_o(Bi()),tags:_o(Bi()).optional().default([]),source:Po(["generated","domain","manual"]).optional().default("generated"),age_range:Bi().optional().default(""),goals:Bi().optional().default(""),behavior:Bi().optional().default(""),pain_points:Bi().optional().default(""),triggers:Bi().optional().default(""),openness:uo().nullable().optional(),conscientiousness:uo().nullable().optional(),extraversion:uo().nullable().optional(),agreeableness:uo().nullable().optional(),neuroticism:uo().nullable().optional(),mbti_type:Bi().optional().default(""),mbti_rationale:Bi().optional().default(""),key_features:_o(Bi()).optional().default([]),bhvr_proficiency:uo().nullable().optional(),bhvr_preciseness:uo().nullable().optional(),bhvr_sensitivity:uo().nullable().optional(),bhvr_efficiency:uo().nullable().optional(),created_at:is().optional(),updated_at:is().optional()}),Pc=Co({connectors:_o(zc),segments:_o(Oc),personas:_o(Rc)}),Nc=Co({name:Bi(),initials:Bi(),description:Bi(),traits:_o(Bi()),tags:_o(Bi()).optional().default([]),is_top:fo().default(!1)}),Lc=Co({personas:_o(Nc.extend({is_selected:fo()}))}),Dc=Co({id:ns(),name:Bi().optional(),description:Bi().optional(),age_range:Bi().optional(),goals:Bi().optional(),behavior:Bi().optional(),pain_points:Bi().optional(),triggers:Bi().optional(),tags:_o(Bi()).optional(),traits:_o(Bi()).optional(),key_features:_o(Bi()).optional()}),$c=Co({label:Bi(),industry:Bi(),personas:_o(Nc)}).nullable(),jc=Po(["clicks","scroll","attention"]),Fc=Po(["desktop","tablet","mobile"]),Uc=Co({x:uo(),y:uo(),radius:uo(),intensity:uo()}),Bc=Co({total_interactions:uo(),unique_users:uo(),hottest_zone:Bi(),dead_zones:uo()}),Gc=Co({selector:Bi(),count:uo(),dead_clicks:uo(),rage_clicks:uo()}),Wc=Co({id:uo(),application_id:uo(),path:Bi(),session_count:uo(),variation_count:uo(),variations:_o(Fc).default([]),visitor_count:uo().optional(),last_aggregated_at:is().nullable().optional(),representative_session_id:Bi().nullable().optional()}),Hc=Co({id:uo(),heatmap_page_id:uo(),variation:Fc,type:jc,spots:_o(Uc),stats:Bc,page_width:uo().nullable().optional(),page_height:uo().nullable().optional(),element_counts:_o(Gc).optional(),representative_session_override:Bi().nullable().optional()}),Zc=Co({job_id:Bi().nullable(),status:Po(["idle","queued","active","completed","failed"]),last_aggregated_at:is().nullable()}),Vc=Co({session_id:Bi(),width:uo(),height:uo(),event_count:uo(),started_at:is(),has_full_snapshot:fo()}),qc=Co({score:uo().min(1).max(10),justification:Bi()}),Yc=Co({type:Po(["doc","sim","session"]),id:Bi(),label:Bi()}),Jc=Co({simulations:_o(Co({simulation_id:uo(),task_id:Bi().nullable().optional(),step_count:uo(),summary:Bi()})).default([]),moments:_o(Co({sim_index:uo(),step_index:uo(),label:Bi()})).max(6).default([]),context_refs:_o(Yc).default([])}),Kc=Co({name:Bi(),initials:Bi().optional(),segment_name:Bi().optional(),traits:_o(Bi()).optional(),age_range:Bi().optional()}),Qc=Co({id:uo(),run_id:uo(),persona_id:uo().nullable(),persona_name:Bi().optional(),persona_initials:Bi().optional(),ad_hoc_persona:Co({name:Bi(),description:Bi(),traits:_o(Bi())}).nullable().optional(),overall_reactions:Oo(Bi(),qc),dimension_scores:Oo(Bi(),qc),simulation_id:uo().nullable().optional(),task_id:Bi().nullable().optional(),status:Po(["pending","completed","failed"]).optional(),replay_evidence:Jc.nullable().optional(),error:Bi().nullable().optional(),persona_snapshot:Kc.nullable().optional(),created_at:is().optional()}),Xc=Co({description:Bi(),selected:fo(),simulation_id:uo().nullable().optional(),task_id:Bi().nullable().optional(),status:Bi().nullable().optional()}),ed=Co({id:uo(),reaction_id:uo(),run_number:uo().optional(),context_refs:_o(Yc),simulations:_o(Xc),persona_ids:_o(uo()).optional(),results:_o(Qc).optional(),status:Po(["running","completed","failed"]).nullable().optional(),processing_started_at:is().nullable().optional(),completed_at:is().nullable().optional(),failed_at:is().nullable().optional(),error:Bi().nullable().optional(),created_at:is().optional()}),td=Co({id:uo(),application_id:uo(),question:Bi(),run_count:uo().optional(),last_run_at:is().optional(),runs:_o(ed).optional(),created_at:is().optional()}),nd=Co({contextRefs:_o(Yc),suggestedSimulations:_o(Xc)}),rd=Po(["received","classifying","dispatched","completed","failed"]),id=Co({id:uo(),workspace_id:uo(),slack_user_id:Bi(),slack_channel_id:Bi().nullable(),raw_text:Bi(),detected_intent:Bi(),extracted_params:Oo(Bi(),wo()),status:rd,response_text:Bi().nullable(),error_message:Bi().nullable(),duration_ms:uo().nullable(),created_at:is().optional(),updated_at:is().optional()}),od=Co({intent:Bi().optional(),limit:ns().optional().default(20),offset:ns().optional().default(0)}),sd=Co({intent:Bi(),name:Bi(),description:Bi(),example:Bi(),execution_count:uo(),last_used:Bi().nullable()}),ad=class extends Error{issues;data;constructor(e){super(e.message,e),this.issues=e.issues,this.data=e.data}};function ld(e,t){return{...e,...t}}var cd=class{"~orpc";constructor(e){if(e.route?.successStatus&&X(e.route.successStatus))throw new Error("[ContractProcedure] Invalid successStatus.");if(Object.values(e.errorMap).some(e=>e&&e.status&&!X(e.status)))throw new Error("[ContractProcedure] Invalid error status code.");this["~orpc"]=e}};function dd(e,t){let n=e;return t.prefix&&(n=function(e,t){return e.path?{...e,path:`${t}${e.path}`}:e}(n,t.prefix)),t.tags?.length&&(n=function(e,t){return{...e,tags:[...t,...e.tags??[]]}}(n,t.tags)),n}function ud(e,t){if((n=e)instanceof cd||("object"==typeof n||"function"==typeof n)&&null!==n&&"~orpc"in n&&"object"==typeof n["~orpc"]&&null!==n["~orpc"]&&"errorMap"in n["~orpc"]&&"route"in n["~orpc"]&&"meta"in n["~orpc"])return new cd({...e["~orpc"],errorMap:ld(t.errorMap,e["~orpc"].errorMap),route:dd(e["~orpc"].route,t)});var n;if("object"!=typeof e||null===e)return e;const r={};for(const i in e)r[i]=ud(e[i],t);return r}var pd=new class e extends cd{constructor(e){super(e),this["~orpc"].prefix=e.prefix,this["~orpc"].tags=e.tags}$meta(t){return new e({...this["~orpc"],meta:t})}$route(t){return new e({...this["~orpc"],route:t})}$input(t){return new e({...this["~orpc"],inputSchema:t})}errors(t){return new e({...this["~orpc"],errorMap:ld(this["~orpc"].errorMap,t)})}meta(t){return new e({...this["~orpc"],meta:(n=this["~orpc"].meta,r=t,{...n,...r})});var n,r}route(t){return new e({...this["~orpc"],route:(n=this["~orpc"].route,r=t,{...n,...r})});var n,r}input(t){return new e({...this["~orpc"],inputSchema:t})}output(t){return new e({...this["~orpc"],outputSchema:t})}prefix(t){return new e({...this["~orpc"],prefix:(n=this["~orpc"].prefix,r=t,n?`${n}${r}`:r)});var n,r}tag(...t){return new e({...this["~orpc"],tags:(n=this["~orpc"].tags,r=t,n?[...n,...r]:r)});var n,r}router(e){return ud(e,this["~orpc"])}}({errorMap:{},route:{},meta:{}}),hd=Symbol("ORPC_EVENT_ITERATOR_DETAILS");function md(e,t){return{"~standard":{[hd]:{yields:e,returns:t},vendor:"orpc",version:1,validate:n=>D(n)?{value:ge(n,{async value(n,r){const i=r?t:e;if(!i)return n;const o=await i["~standard"].validate(n);if(o.issues)throw new Q("EVENT_ITERATOR_VALIDATION_FAILED",{message:"Event iterator validation failed",cause:new ad({issues:o.issues,message:"Event iterator validation failed",data:n})});return o.value},error:async e=>e})}:{issues:[{message:"Expect event iterator",path:[]}]}}}}pd.route({method:"GET",tags:["Root"],path:"/",summary:"Get API index information and basic system details",description:"Returns general API information, version, and available endpoints"}).output(Ns),pd.route({method:"GET",tags:["Internal"],path:"/health",summary:"Health check endpoint for monitoring system status",description:"Returns current system health, database connectivity, and service status"}).output(Ps),pd.route({method:"GET",tags:["Root"],path:"/validate-url",summary:"Validate URL accessibility and DNS resolution",description:"Validates a URL for format, DNS resolution, and HTTP accessibility"}).input(Co({url:Bi().url(),skip_network:Bi().optional()})).output(Co({valid:fo(),accessible:fo(),dnsResolves:fo(),error:Bi().optional().describe("Error message if URL validation failed"),warnings:_o(Bi()).optional().describe("Non-fatal issues found during URL validation")})),pd.route({method:"GET",tags:["Root"],path:"/config/public",summary:"Get public client configuration",description:"Returns widget key and widget ID. No auth. Values are stored in backend env only."}).output(dc),pd.route({method:"GET",tags:["Auth"],path:"/auth/me",summary:"Get current authenticated user and workspace information",description:"Returns user profile and workspace data based on session cookie"}).output(Co({user:Ds,workspace:Bs.nullable(),workspaces:_o(Co({id:uo(),name:Bi(),slug:Bi(),role:Po(["owner","member"])}))})),pd.route({method:"GET",tags:["Auth"],path:"/email-action/{token}",summary:"Process email approval/rejection action",description:"Handles approve/reject links from admin emails. Token-in-URL authentication (no session required). Returns an HTML page, not JSON."}).input(Co({token:Bi().min(1)})).output(Co({result:Bi().describe("HTML response page")})),pd.route({method:"POST",tags:["Onboarding"],path:"/onboard",summary:"Complete user onboarding in one atomic operation",description:"Creates workspace, updates user status, and invites team members"}).input(Co({name:Bi().min(1).max(45),slug:Bi().min(1).max(45).optional(),domain:Bi().min(1).max(200),team_emails:_o(Bi().email()).optional().default([]),app_url:Bi().optional(),app_username:Bi().optional(),app_password:Bi().optional()})).output(Co({workspace:Bs})),pd.route({method:"POST",tags:["Workspace"],path:"/workspaces",summary:"Create a new workspace",description:"Creates new workspace with specified settings and returns workspace entity"}).input(Gs).output(Bs),pd.route({method:"GET",tags:["Workspace"],path:"/workspaces",summary:"Search and filter workspaces by various criteria",description:"Returns list of workspaces matching search parameters (name, domain, email, etc.)"}).input(Co({name:Bi().optional(),domain:Bi().optional(),email:Bi().email().optional(),application_id:ns().optional(),workspace_id:ns().optional(),user_id:ns().optional()}).extend(zs.shape)).output(Os(Bs)),pd.route({method:"GET",tags:["Workspace"],path:"/workspaces/lookup/{slug}",summary:"Look up workspace by slug for onboarding",description:"Returns workspace name and slug for join-workspace flow. Requires onboarding-level auth."}).input(_s).output(Co({name:Bi(),slug:Bi()}).nullable()),pd.route({method:"GET",tags:["Workspace"],path:"/workspaces/{slug}",summary:"Get specific workspace details by slug",description:"Returns complete workspace information including settings and configuration"}).input(_s).output(Bs),pd.route({method:"POST",tags:["Workspace"],path:"/workspaces/{slug}/select",summary:"Select the active workspace for the current session",description:"Updates the server-side session workspace context to match the selected workspace slug."}).input(_s).output(Bs),pd.route({method:"PUT",tags:["Workspace"],path:"/workspaces/{slug}",summary:"Update workspace settings and configuration",description:"Modifies workspace properties like name, domain, or feature settings"}).input(Hs.extend({slug:Bi()})).output(Bs),pd.route({method:"DELETE",tags:["Workspace"],path:"/workspaces/{slug}",summary:"Delete workspace and all associated data",description:"Permanently deletes a workspace and cleans up all related resources. This action cannot be undone."}).input(_s).output(As),pd.route({method:"GET",tags:["Workspace"],path:"/workspaces/{slug}/members",summary:"List workspace members",description:"Returns all members of the workspace with their user profile details and roles."}).input(_s).output(Rs(Ys.extend({user:Ds.pick({id:!0,email:!0,first_name:!0,last_name:!0,image_url:!0})}))),pd.route({method:"POST",tags:["Workspace"],path:"/workspaces/{slug}/members",summary:"Add member to workspace",description:"Invites a user by email to join the workspace with the specified role. Defaults to member role."}).input(_s.extend({email:Bi().email(),role:qs.default("member")})).output(Ys),pd.route({method:"DELETE",tags:["Workspace"],path:"/workspaces/{slug}/members/{user_id}",summary:"Remove member from workspace",description:"Removes a user from the workspace by user_id. The user loses access immediately."}).input(_s.extend({user_id:uo()})).output(As),pd.route({method:"PATCH",tags:["Workspace"],path:"/workspaces/{slug}/members/{user_id}",summary:"Update member role",description:"Changes the role of a workspace member. Valid roles: owner, member."}).input(_s.extend({user_id:uo(),role:qs})).output(Ys),pd.route({method:"GET",tags:["Workspace"],path:"/users/me/workspaces",summary:"List workspaces for current user",description:"Returns all workspaces the authenticated user belongs to, including their role in each."}).output(Rs(Bs.extend({role:qs}))),pd.route({method:"POST",path:"/admin/reconcile",tags:["Internal"],summary:"Reconcile Stripe customers and WorkOS users",description:"Backfills missing Stripe customer IDs for workspaces and real WorkOS user IDs for users. Idempotent and safe to run repeatedly. Requires super user role."}).output(Co({workspaces_stripe_created:uo(),users_workos_created:uo(),workspace_plans_synced:uo(),trials_provisioned:uo(),stripe_plans_refreshed:uo(),workos_profiles_synced:uo(),errors:_o(Co({type:Bi(),id:uo(),error:Bi()}))})),pd.route({method:"POST",path:"/admin/maintenance",tags:["Internal"],summary:"Run periodic maintenance cleanup tasks",description:"Cleans up orphaned CosmosDB containers, QA simulations not linked to existing runs, and orphaned blob storage files. Idempotent and safe to run repeatedly. Requires super user role."}).output(Co({cosmos_containers_deleted:uo(),orphaned_qa_simulations_deleted:uo(),orphaned_blob_dirs_deleted:uo(),errors:_o(Co({type:Bi(),detail:Bi()}))})),pd.route({method:"POST",path:"/admin/rebuild",tags:["Internal"],summary:"Rebuild all agent indexes after cleanup",description:"Removes stale knowledge (missing files), stale simulations (0 steps or missing blobs), then deletes and recreates vector stores and knowledge graphs for every agent. Index creation is async. Requires super user role."}).output(Co({knowledge_removed:uo(),simulations_removed:uo(),agents_rebuilt:uo(),errors:_o(Co({type:Bi(),detail:Bi()}))})),pd.route({method:"POST",tags:["Application"],path:"/applications",summary:"Create a new application",description:"Creates a new application for the authenticated workspace and returns the created entity."}).input(qa).output(Va),pd.route({method:"GET",tags:["Application"],path:"/applications",summary:"Search applications for workspace",description:"Returns applications for the authenticated workspace, optionally filtered by type, always includes widgets"}).input(Co({type:gs.optional(),include:_o(Po(["widgets"])).optional()}).extend(zs.shape)).output(Os(Va.extend({widgets:_o(Qa).optional()}))),pd.route({method:"GET",tags:["Application"],path:"/applications/{application_id}",summary:"Get application by ID",description:"Returns specific application details by ID, always includes widgets"}).input(Es).output(Va.extend({widgets:_o(Qa)})),pd.route({method:"PUT",tags:["Application"],path:"/applications/{application_id}",summary:"Update application",description:"Updates application details and configuration"}).input(Ya.extend({application_id:ns()})).output(Va),pd.route({method:"DELETE",tags:["Application"],path:"/applications/{application_id}",summary:"Delete application",description:"Permanently deletes an application and all associated widgets. This action cannot be undone."}).input(Es).output(As),pd.route({method:"POST",tags:["Widget"],path:"/widgets",summary:"Create a new widget",description:"Creates a new widget for an application and returns the created entity. Requires an application_id."}).input(el).output(Qa),pd.route({method:"GET",tags:["Widget"],path:"/widgets",summary:"Search widgets for workspace",description:"Search widgets by type, application, marketrix_id, or marketrix_key"}).input(Co({type:ys.optional(),application_id:ns().optional(),marketrix_id:Bi().optional(),marketrix_key:Bi().optional(),include:_o(Po(["agent"])).optional()}).extend(zs.shape)).output(Os(Xa)),pd.route({method:"GET",tags:["Widget"],path:"/widgets/defaults/{type}",summary:"Get default settings for widget type",description:"Returns default settings for the specified widget type"}).input(Co({type:ys})).output(Ka),pd.route({method:"GET",tags:["Widget"],path:"/widgets/{widget_id}",summary:"Get widget by ID",description:"Returns specific widget details by widget ID including snippet code"}).input(Cs).output(Qa),pd.route({method:"PUT",tags:["Widget"],path:"/widgets/{widget_id}",summary:"Update widget",description:"Updates widget settings and configuration"}).input(tl.extend({widget_id:ns()})).output(Qa),pd.route({method:"DELETE",tags:["Widget"],path:"/widgets/{widget_id}",summary:"Delete widget",description:"Permanently deletes a widget from an application. This action cannot be undone."}).input(Cs).output(As),pd.route({method:"POST",tags:["Chat"],path:"/chat",summary:"Create a new chat thread",description:"Initializes new chat thread and returns session ID"}).output(Bi()),pd.route({method:"GET",tags:["Chat"],path:"/chat",summary:"Search chats by user",description:"Returns chat list and quota for the specified user"}).input(Co({user_id:ns().optional(),chat_id:ns().optional()})).output(Zl),pd.route({method:"POST",tags:["Chat"],path:"/preview-video-chat",summary:"Create or update preview video chat record",description:"Persists guide preview chat content, history, output, and related simulation metadata"}).input(fc).output(mc),pd.route({method:"GET",tags:["Chat"],path:"/preview-video-chat",summary:"Search preview video chat records",description:"Returns preview chat records filtered by chat_id, agent_id, or simulation_id for current workspace"}).input(gc).output(Rs(mc)),pd.route({method:"GET",tags:["Chat"],path:"/preview-video-chat/{id}",summary:"Get preview video chat record by ID",description:"Returns a single preview chat record for current workspace"}).input(ks).output(mc.nullable()),pd.route({method:"POST",tags:["Connector"],path:"/connector",summary:"Create or update connector",description:"Stores provider credentials and API endpoint details for workspace connectors"}).input(Cl).output(Sl),pd.route({method:"GET",tags:["Connector"],path:"/connector",summary:"Search connectors",description:"Returns workspace connectors filtered by provider/status"}).input(Il).output(Os(Sl)),pd.route({method:"GET",tags:["Connector"],path:"/connector/{id}",summary:"Get connector by ID",description:"Returns a single workspace connector"}).input(ks).output(Sl.nullable()),pd.route({method:"DELETE",tags:["Connector"],path:"/connector/{id}",summary:"Delete connector",description:"Permanently deletes a connector for current workspace. This action cannot be undone."}).input(ks).output(As),pd.route({method:"GET",tags:["Connector"],path:"/connector/{id}/github/repos",summary:"List GitHub repositories for a GitHub connector",description:"Uses the stored GitHub PAT from the connector to call GitHub /user/repos."}).input(Co({id:ns(),per_page:ns().int().min(1).max(100).optional(),page:ns().int().min(1).optional()})).output(_o(Al)),pd.route({method:"GET",tags:["Connector"],path:"/connector/{id}/github/repos/{owner}/{repo}/actions/runs",summary:"List GitHub Actions workflow runs",description:"Lists workflow runs for a repository (pass/fail status)."}).input(Co({id:ns(),owner:Bi().min(1),repo:Bi().min(1),per_page:ns().int().min(1).max(100).optional(),page:ns().int().min(1).optional()})).output(_o(Ml)),pd.route({method:"POST",tags:["MCP"],path:"/mcp/activate",summary:"Activate MCP for an application",description:"Creates or reactivates an MCP connector with auto-generated credentials."}).input(Co({application_id:ns()})).output(El),pd.route({method:"POST",tags:["MCP"],path:"/mcp/deactivate",summary:"Deactivate MCP for an application",description:"Deactivates the MCP connector. Credentials are preserved but access is revoked."}).input(Co({application_id:ns()})).output(El),pd.route({method:"POST",tags:["MCP"],path:"/mcp/regenerate",summary:"Regenerate MCP API key",description:"Generates a new API key for the MCP connector. Existing integrations will break."}).input(Co({application_id:ns()})).output(El),pd.route({method:"GET",tags:["MCP"],path:"/mcp/status/{application_id}",summary:"Get MCP activation status",description:"Returns the MCP connector status for an application, or null if not activated."}).input(Co({application_id:ns()})).output(El.nullable()),pd.route({method:"GET",tags:["MCP"],path:"/mcp/tools/{application_id}",summary:"List MCP platform tools",description:"Returns all platform tools with their enabled/disabled state."}).input(Co({application_id:ns()})).output(_o(Tl)),pd.route({method:"PATCH",tags:["MCP"],path:"/mcp/tools/toggle",summary:"Toggle a platform tool",description:"Enable or disable a specific platform tool for the MCP server."}).input(Co({application_id:ns(),tool_name:Bi(),enabled:fo()})).output(_o(Tl)),pd.route({method:"POST",tags:["Automation"],path:"/automation",summary:"Create automation",description:"Creates a DAG-based automation workflow"}).input(Dl).output(Ll),pd.route({method:"GET",tags:["Automation"],path:"/automation",summary:"List automations",description:"Returns automations for the current workspace"}).input(jl).output(Os(Ll)),pd.route({method:"GET",tags:["Automation"],path:"/automation/{id}",summary:"Get automation",description:"Returns a single automation with its graph"}).input(ks).output(Ll.nullable()),pd.route({method:"PUT",tags:["Automation"],path:"/automation/{id}",summary:"Update automation",description:"Updates automation graph and settings"}).input($l).output(Ll),pd.route({method:"DELETE",tags:["Automation"],path:"/automation/{id}",summary:"Delete automation",description:"Permanently deletes an automation and deregisters its triggers"}).input(ks).output(As),pd.route({method:"PATCH",tags:["Automation"],path:"/automation/{id}/toggle",summary:"Toggle automation",description:"Enable or disable an automation"}).input(Co({id:ns(),enabled:fo()})).output(Ll),pd.route({method:"POST",tags:["Automation"],path:"/automation/{id}/run",summary:"Trigger automation run",description:"Manually triggers an automation run"}).input(ks).output(Ul.nullable()),pd.route({method:"GET",tags:["Automation"],path:"/automation/{id}/runs",summary:"List automation runs",description:"Returns execution history for an automation"}).input(Co({id:ns()}).extend(Bl.shape)).output(Os(Ul)),pd.route({method:"GET",tags:["Automation"],path:"/automation/{id}/runs/{run_id}",summary:"Get automation run",description:"Returns a single run with per-node results"}).input(Co({id:ns(),run_id:ns()})).output(Ul.nullable()),pd.route({method:"GET",tags:["Provider"],path:"/provider/{provider}",summary:"Get provider record for a workspace"}).input(Co({provider:yc})).output(xc.nullable()),pd.route({method:"DELETE",tags:["Provider"],path:"/provider/{provider}",summary:"Disconnect a provider"}).input(Co({provider:yc})).output(As),pd.route({method:"POST",tags:["Provider"],path:"/provider/{provider}/refresh",summary:"Re-fetch provider data using stored credentials"}).input(Co({provider:yc})).output(xc),pd.route({method:"POST",tags:["Trigger"],path:"/trigger",summary:"Create a new trigger"}).input(_c).output(kc),pd.route({method:"GET",tags:["Trigger"],path:"/trigger/{trigger_id}",summary:"Get a single trigger"}).input(Co({trigger_id:ns()})).output(kc),pd.route({method:"GET",tags:["Trigger"],path:"/trigger",summary:"List triggers"}).input(Cc).output(Os(kc)),pd.route({method:"PUT",tags:["Trigger"],path:"/trigger/{trigger_id}",summary:"Update trigger"}).input(Sc).output(kc),pd.route({method:"DELETE",tags:["Trigger"],path:"/trigger/{trigger_id}",summary:"Delete a trigger"}).input(Co({trigger_id:ns()})).output(As),pd.route({method:"PATCH",tags:["Trigger"],path:"/trigger/{trigger_id}/toggle",summary:"Toggle trigger enabled state"}).input(Co({trigger_id:ns()})).output(kc),pd.route({method:"POST",tags:["Trigger"],path:"/trigger/{trigger_id}/install",summary:"Auto-install trigger configuration on the provider"}).input(Co({trigger_id:ns()})).output(Co({success:fo(),message:Bi()})),pd.route({method:"GET",tags:["Slack"],path:"/slack/command-log",summary:"Search slash command logs"}).input(od).output(Os(id)),pd.route({method:"GET",tags:["Slack"],path:"/slack/capabilities",summary:"Get Slack capability stats"}).output(_o(sd)),pd.route({method:"POST",tags:["Action"],path:"/action",summary:"Create a custom action"}).input(Ec).output(Ic),pd.route({method:"GET",tags:["Action"],path:"/action/{action_id}",summary:"Get a single action"}).input(Co({action_id:ns()})).output(Ic),pd.route({method:"GET",tags:["Action"],path:"/action",summary:"List actions"}).input(Ac).output(Os(Ic)),pd.route({method:"PUT",tags:["Action"],path:"/action/{action_id}",summary:"Update action"}).input(Tc).output(Ic),pd.route({method:"DELETE",tags:["Action"],path:"/action/{action_id}",summary:"Delete an action"}).input(Co({action_id:ns()})).output(As),pd.route({method:"PATCH",tags:["Action"],path:"/action/{action_id}/toggle",summary:"Toggle action enabled state"}).input(Co({action_id:ns()})).output(Ic),pd.route({method:"GET",tags:["Connector"],path:"/connector-capabilities",summary:"List connector capabilities",description:"Returns available triggers and callbacks per connector type"}).input(Co({})).output(_o(Gl)),pd.route({method:"GET",tags:["User"],path:"/user",summary:"Search and filter users by workspace",description:"Returns list of users associated with specified workspace"}).input(Co({workspace_id:ns().optional(),status:ss.optional()}).extend(zs.shape)).output(Os(Ds)),pd.route({method:"POST",tags:["User"],path:"/user/batch",summary:"Create multiple users in batch operation",description:"Processes bulk user creation and returns results for each user"}).input(Fs).output(_o(Us)),pd.route({method:"GET",tags:["User"],path:"/user/{user_id}",summary:"Get specific user details by ID",description:"Returns complete user information including profile and settings"}).input(Ts).output(Ds),pd.route({method:"PUT",tags:["User"],path:"/user/{user_id}",summary:"Update user profile and settings",description:"Modifies user properties like name, email, or preferences"}).input(js.extend({user_id:ns()})).output(Ds),pd.route({method:"PUT",tags:["User"],path:"/user/{user_id}/image",summary:"Upload and update user profile image",description:"Handles file upload for user avatar and returns upload response"}).input(xs.extend({user_id:ns()})).output(Hl),pd.route({method:"DELETE",tags:["User"],path:"/user/{user_id}",summary:"Delete user account and all associated data",description:"Permanently deletes a user account and cleans up all related resources. This action cannot be undone."}).input(Ts).output(As),pd.route({method:"POST",tags:["User"],path:"/user/{user_id}/deactivate",summary:"Deactivate user account without deletion",description:"Deactivates user access while preserving data for potential reactivation"}).input(Ts.extend({reason:Bi().optional()})).output(As),pd.route({method:"POST",tags:["Agent"],path:"/agent",summary:"Create new AI agent with configuration",description:"Creates agent with specified settings, prompts, and returns agent entity"}).input(Ua).output(Da),pd.route({method:"GET",tags:["Agent"],path:"/agent",summary:"Search and filter agents by workspace or user",description:"Returns list of agents matching search parameters. Supports filtering by workspace_id, user_id, and application_id."}).input(Co({workspace_id:ns().optional(),user_id:ns().optional(),application_id:ns().optional(),include:_o(Po(["knowledge","simulations"])).optional()}).extend(zs.shape)).output(Os(Da)),pd.route({method:"GET",tags:["Agent"],path:"/agent/{agent_id}",summary:"Get specific agent details by ID",description:"Returns complete agent information including configuration and settings"}).input(Ss.extend({include:_o(Po(["knowledge","simulations"])).optional()})).output(Da),pd.route({method:"GET",tags:["Agent"],path:"/agent/{agent_id}/mindmap",summary:"Get agent mindmap by ID",description:"Returns the mindmap knowledge graph for the specified agent"}).input(Ss).output(La),pd.route({method:"PUT",tags:["Agent"],path:"/agent/{agent_id}",summary:"Update agent configuration and settings",description:"Updates agent details. For JSON requests, handled by oRPC. Also accepts multipart/form-data for logo file uploads (handled by raw Express route)."}).input(Ba.extend({agent_id:ns(),force_reset_learning:rs().optional()})).output(Da),pd.route({method:"DELETE",tags:["Agent"],path:"/agent/{agent_id}",summary:"Delete agent and all associated data",description:"Permanently deletes an agent and cleans up all related resources. This action cannot be undone."}).input(Ss).output(As),pd.route({method:"POST",tags:["Agent"],path:"/agent/{agent_id}/index",summary:"Index simulation document into agent knowledge base",description:"Adds a simulation document to an agent's knowledge base and refreshes the search index"}).input(Wa.extend({agent_id:ns()})).output(Ha),pd.route({method:"POST",tags:["Agent"],path:"/agent/{agent_id}/reset-learning",summary:"Force reset agent from stuck learning state",description:"Resets an agent that is stuck in learning state, setting it to error status with a message explaining the reset"}).input(Ss).output(Da),pd.route({method:"POST",tags:["Activity Log"],path:"/log",summary:"Create new activity log entry",description:"Records user or system action for auditing and tracking purposes"}).input(xl).output(vl),pd.route({method:"GET",tags:["Activity Log"],path:"/log",summary:"Search and filter activity logs",description:"Returns list of activity logs matching search parameters (workspace, type)"}).input(Co({workspace_id:ns().optional(),type:bs.optional(),application_id:ns().optional()}).extend(zs.shape)).output(Os(vl)),pd.route({method:"GET",tags:["State Trigger"],path:"/state-trigger",summary:"Search state triggers by widget",description:"Returns list of state triggers for specified widget"}).input(Cs.extend(zs.shape)).output(Os(nl)),pd.route({method:"POST",tags:["State Trigger"],path:"/state-trigger",summary:"Create new state trigger",description:"Creates state trigger with pattern and message"}).input(rl).output(nl),pd.route({method:"GET",tags:["State Trigger"],path:"/state-trigger/{id}",summary:"Get state trigger by ID",description:"Returns state trigger details"}).input(ks).output(nl),pd.route({method:"PUT",tags:["State Trigger"],path:"/state-trigger/{id}",summary:"Update state trigger",description:"Updates state trigger properties"}).input(il.extend({id:ns()})).output(nl),pd.route({method:"DELETE",tags:["State Trigger"],path:"/state-trigger/{id}",summary:"Delete state trigger",description:"Permanently deletes a state trigger. This action cannot be undone."}).input(ks).output(As),pd.route({method:"GET",tags:["State Trigger"],path:"/state-trigger/match",summary:"Find matching state trigger for current URL",description:"Returns matching state trigger for a given URL pattern"}).input(Co({widget_id:ns(),url:Bi()})).output(nl.nullable()),pd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}",summary:"Get a single simulation by ID"}).input(Co({simulation_id:ns()})).output(Ca),pd.route({method:"GET",tags:["Simulation"],path:"/simulation",summary:"Search and filter simulations by workspace",description:"Returns list of simulations associated with specified workspace. Use application_id, agent_id, or pinned to filter."}).input(Co({workspace_id:ns().optional(),application_id:ns().optional(),agent_id:ns().optional(),pinned:Eo([fo(),Bi()]).optional().transform(e=>void 0===e?void 0:"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0),source:Po(["direct","qa"]).optional(),include:_o(Po(["agent","application"])).optional()}).extend(zs.shape)).output(Os(Ia)),pd.route({method:"POST",tags:["Simulation"],path:"/simulation/start",summary:"Start new application simulation",description:"Creates and initializes simulation with specified parameters"}).input(Ea).output(Ca),pd.route({method:"PUT",tags:["Simulation"],path:"/simulation/{simulation_id}",summary:"Update simulation configuration and status",description:"Modifies simulation parameters and updates execution state"}).input(Ta.extend({simulation_id:ns()})).output(Ca),pd.route({method:"PUT",tags:["Simulation"],path:"/simulation/{simulation_id}/agents",summary:"Assign agents to a simulation",description:"Sets which agents use this simulation for their knowledge. Triggers learning on affected agents."}).input(Is.extend({agent_ids:_o(uo())})).output(Ca),pd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/progress",summary:"Get simulation progress history as chat transcript",description:"Returns all progress updates for a simulation ordered chronologically"}).input(Is.extend({task_id:Bi().optional()})).output(Rs(Oa)),pd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/task/{task_id}/live-view",summary:"Get per-task live view URL",description:"Returns Browserbase per-tab live view URL for a specific task within a simulation."}).input(Co({simulation_id:ns().int().positive(),task_id:Bi()})).output(Co({live_view_url:Bi(),status:Bi()})),pd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/history",summary:"Get simulation history by ID",description:"Returns the history array for the specified simulation"}).input(Is.extend({task_id:Bi()})).output(Rs(xa)),pd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/steps",summary:"Get all simulation steps with topic and screenshot link as JSON",description:"Returns each step with step_number, topic, screenshot_url, and optional title/url for the simulation"}).input(Is).output(Rs(ka)),pd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/mindmap",summary:"Get simulation mindmap by ID",description:"Returns the mindmap knowledge graph for the specified simulation"}).input(Is).output(La),pd.route({method:"POST",tags:["Simulation"],path:"/simulation/{simulation_id}/stop",summary:"Stop running simulation",description:"Terminates a running simulation and closes its browser session."}).input(Is).output(Ms),pd.route({method:"POST",tags:["Simulation"],path:"/simulation/{simulation_id}/answer",summary:"Submit answer to simulation question",description:"Submits an answer to a pending question from the simulation agent"}).input(Aa.extend({simulation_id:ns()})).output(Ms),pd.route({method:"POST",tags:["Simulation"],path:"/simulation/{simulation_id}/retry-mindmap",summary:"Retry mindmap generation",description:"Restarts mindmap generation from stored history for a simulation."}).input(Co({simulation_id:ns()})).output(Ms),pd.route({method:"DELETE",tags:["Simulation"],path:"/simulation/{simulation_id}",summary:"Delete simulation",description:"Permanently deletes a simulation and all associated data. Only works on simulations in terminal state."}).input(Is).output(Ms),pd.route({method:"GET",tags:["Notification"],path:"/notification/pending",summary:"List pending notifications for the current user"}).output(Rs(hl)),pd.route({method:"POST",tags:["Notification"],path:"/notification/{id}/read",summary:"Mark a notification as read"}).input(Co({id:ns()})).output(As),pd.route({method:"POST",tags:["Notification"],path:"/notification/{id}/dismiss",summary:"Dismiss a pending notification"}).input(Co({id:ns()})).output(As),pd.route({method:"GET",tags:["Notification"],path:"/notification/preferences",summary:"Get notification preferences for the current (user, workspace)"}).output(ml),pd.route({method:"PUT",tags:["Notification"],path:"/notification/preferences",summary:"Update notification preferences for the current (user, workspace)"}).input(ml).output(ml),pd.route({method:"GET",tags:["Notification"],path:"/notification/vapid-public-key",summary:"Public VAPID key for browser pushManager.subscribe"}).output(wl),pd.route({method:"POST",tags:["Notification"],path:"/notification/push-subscription",summary:"Register a Web Push subscription for the current user"}).input(fl).output(As),pd.route({method:"DELETE",tags:["Notification"],path:"/notification/push-subscription",summary:"Unregister a Web Push subscription for the current user"}).input(gl).output(As),pd.route({method:"POST",tags:["Notification"],path:"/notification/slack-test",summary:"Send a test message to a Slack incoming-webhook URL"}).input(yl).output(Ms),pd.route({method:"POST",tags:["Session"],path:"/sessions",summary:"Create or update session",description:"Creates a new session or updates an existing one"}).input(za).output(Ma),pd.route({method:"GET",tags:["Session"],path:"/sessions/{session_id}",summary:"Get session by session ID",description:"Retrieves a session by its session_id"}).input(Co({session_id:Bi().min(1)})).output(Ma.nullable()),pd.route({method:"GET",tags:["Session"],path:"/sessions/chat/{chat_id}",summary:"Get sessions by chat ID",description:"Retrieves all sessions for a given chat_id"}).input(Co({chat_id:Bi().min(1)})).output(Rs(Ma)),pd.route({method:"GET",tags:["Session"],path:"/sessions",summary:"Get all sessions",description:"Retrieves all sessions ordered by creation date, optionally filtered by application and date range"}).input(Co({application_id:ns().optional(),start_date:Bi().optional(),end_date:Bi().optional()}).extend(zs.shape)).output(Os(Ma)),pd.route({method:"GET",tags:["Session"],path:"/sessions/stats",summary:"Get session activity stats",description:"Returns daily aggregated session metrics for charting. Each entry is one calendar day with session count and total event count."}).input(Co({application_id:ns(),start_date:Bi().describe("YYYY-MM-DD"),end_date:Bi().describe("YYYY-MM-DD")})).output(pc),pd.route({method:"GET",tags:["Session"],path:"/sessions/{session_id}/events",summary:"Get session events (paginated by batch)",description:"Fetches batches from storage in pages. Use batch_offset/batch_limit to paginate."}).input(Co({session_id:Bi().min(1),batch_offset:ns().int().nonnegative().default(0),batch_limit:ns().int().positive().max(50).default(20)})).output(Co({items:_o(Co({type:uo(),timestamp:uo(),data:wo().describe("rrweb event payload — shape defined by rrweb library")})),count:uo(),total_batches:uo(),batch_offset:uo(),batch_limit:uo()})),pd.route({method:"POST",tags:["Browser Session"],path:"/browser-session/create",summary:"Create browser session for application",description:"Creates a browser session and navigates to the application URL"}).input(Co({application_id:uo(),agent_id:uo(),url:Bi().nullish()})).output(Co({browser_session_id:Bi(),live_view_url:Bi()})),pd.route({method:"POST",tags:["Browser Session"],path:"/browser-session/{browser_session_id}/stop",summary:"Stop browser session",description:"Stops all running tasks and closes the browser session. Set stop_tasks=false to skip task cleanup."}).input(Co({browser_session_id:Bi(),stop_tasks:fo().optional().default(!0)})).output(Ms),pd.route({method:"GET",tags:["Knowledge"],path:"/knowledge",summary:"Search and filter knowledge base documents",description:"Returns list of knowledge documents matching search parameters. Supports filtering by workspace_id, type, and application_id."}).input(Co({workspace_id:ns().optional(),type:ps.optional(),application_id:ns().optional(),include:_o(Po(["agents","application"])).optional()}).extend(zs.shape)).output(Os(Ks)),pd.route({method:"POST",tags:["Knowledge"],path:"/knowledge",summary:"Upload new knowledge base document",description:"Upload a file, document URL, or video URL to create a knowledge entry for AI training"}).input(Co({file:function(e){return function(e,t){return new e({type:"file",...ct(t)})}(Do,e)}().optional(),application_id:ns(),document_url:Bi().url().optional(),document_name:Bi().optional(),video_url:Bi().url().optional(),video_name:Bi().optional()})).output(Ks),pd.route({method:"GET",tags:["Knowledge"],path:"/knowledge/{id}",summary:"Get specific knowledge document by ID",description:"Returns complete knowledge document information and content"}).input(ks).output(Ks),pd.route({method:"DELETE",tags:["Knowledge"],path:"/knowledge/{id}",summary:"Delete knowledge document",description:"Permanently deletes a knowledge document from the database. This action cannot be undone."}).input(ks).output(As),pd.route({method:"POST",tags:["Knowledge"],path:"/knowledge/{id}/refresh",summary:"Refresh knowledge document",description:"Re-fetches HTML content from source URL and updates the document"}).input(ks).output(Ks),pd.route({method:"PUT",tags:["Knowledge"],path:"/knowledge/{knowledge_id}/agents",summary:"Assign agents to a knowledge item",description:"Sets which agents use this knowledge item. Triggers learning on affected agents."}).input(Co({knowledge_id:ns(),agent_ids:_o(uo())})).output(Ks),pd.route({method:"POST",tags:["QA"],path:"/qa/document",summary:"Upload QA flow (file or text)",description:"Uploads a PDF/text file or text content for QA test generation. Also accepts multipart/form-data for file uploads (handled by raw Express route)."}).input(ta).output(ea),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/process",summary:"Process QA flow and generate test cases",description:"Starts async processing (returns 202). Poll GET /qa/document/:id for status and processing_step until completed/failed."}).input(ks).output(Co({document:ea})),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/refine",summary:"Refine existing QA test cases",description:"Refines existing test cases with a refinement prompt via AI agent API"}).input(ks.extend({refinementPrompt:Bi().min(5).max(2e3)})).output(ca),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/process/stream",summary:"Process QA flow with SSE streaming",description:"Streams processing events as Server-Sent Events. Events: response.created, response.progress, response.clear, response.completed, error."}).input(ks).output(md(Co({event:Bi().describe("SSE event type: response.created | response.progress | response.clear | response.completed | error"),data:wo().describe("Event payload object — shape varies by event type")}))),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/refine/stream",summary:"Refine QA flow test cases with SSE streaming",description:"Streams refinement events as Server-Sent Events. Requires a refinement prompt (min 5 chars)."}).input(ks.extend({refinementPrompt:Bi().min(5)})).output(md(Co({event:Bi().describe("SSE event type: response.created | response.progress | response.clear | response.completed | error"),data:wo().describe("Event payload object — shape varies by event type")}))),pd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}",summary:"Get QA flow by ID",description:"Retrieves a QA flow by its ID"}).input(ks).output(ea),pd.route({method:"GET",tags:["QA"],path:"/qa/document",summary:"List QA flows",description:"Returns all QA flows with aggregated metrics (run_count, pass_rate, total_failed) and the last run summary. Supports filtering by application_id."}).input(Co({application_id:ns().optional()}).extend(zs.shape)).output(Os(ea.extend({run_count:uo(),display_title:Bi(),total_failed:uo(),pass_rate:uo().nullable(),last_run:Co({id:uo(),status:Bi(),total_tests:uo(),passed_tests:uo(),failed_tests:uo(),created_at:is().nullable()}).nullable()})).extend({metrics:Co({total_flows:uo(),total_runs:uo(),avg_pass_rate:uo().nullable(),total_failed:uo(),total_passed:uo()})})),pd.route({method:"DELETE",tags:["QA"],path:"/qa/document/{id}",summary:"Delete QA flow",description:"Permanently deletes a QA flow and all its runs and test cases. This action cannot be undone."}).input(ks).output(As),pd.route({method:"PUT",tags:["QA"],path:"/qa/document/{id}",summary:"Update QA flow",description:"Updates status and/or pinned state of a QA flow"}).input(ks.extend({status:ms.optional(),pinned:fo().optional()})).output(ea),pd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}/runs",summary:"List runs for a QA flow",description:"Returns all runs for a document with total/passed/failed counts"}).input(ks.extend(zs.shape)).output(Os(na.extend({status:Bi(),total_tests:uo(),passed:uo(),failed:uo()}))),pd.route({method:"GET",tags:["QA"],path:"/qa/run/{id}",summary:"Get a QA run by ID",description:"Returns run details with test cases"}).input(ks).output(na.extend({test_cases:_o(la)})),pd.route({method:"GET",tags:["QA"],path:"/qa/run/{run_id}/verdicts",summary:"Get evaluator verdicts for a QA run",description:"Returns all qa_run_task rows for a run, keyed by test case"}).input(Co({run_id:ns()})).output(_o(aa)),pd.route({method:"DELETE",tags:["QA"],path:"/qa/run/{id}",summary:"Delete a QA run",description:"Permanently deletes a QA run and all its test case results. This action cannot be undone."}).input(ks).output(As),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/run",summary:"Create and start a new QA run",description:"Creates a new run and starts execution. Returns 202; poll test-cases for execution status."}).input(ks.extend({auto_heal:fo().default(!1),auto_accept:fo().default(!1)})).output(Co({run:na})),pd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}/test-cases",summary:"Get test cases for a QA flow",description:"Retrieves test cases; optional run_id scopes to that run"}).input(ks.extend({run_id:ns().optional()})).output(Rs(la)),pd.route({method:"PUT",tags:["QA"],path:"/qa/test-case/{id}",summary:"Update test case definition fields",description:"Updates a test case definition (title, objective, steps, etc.)"}).input(ks.extend({test_title:Bi().optional(),test_objective:Bi().optional(),test_steps:_o(Bi()).optional(),expected_outcome:Bi().optional(),priority:Po(["Low","Medium","High"]).optional(),is_active:fo().optional()})).output(la),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/execute",summary:"Create a run and execute all pending tests for a QA flow as simulations",description:"Creates a new QA run, then starts a simulation for every active test case. Returns the run and simulation entities."}).input(ks).output(Co({run:na,simulations:_o(Ca)})),pd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/execute",summary:"Execute a single test case as a simulation",description:"Starts a simulation for the specified test case and returns the simulation entity."}).input(ks).output(Co({simulation:Ca})),pd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/simulation",summary:"Get the simulation linked to a test case",description:"Returns the simulation entity associated with the test case for a specific run, or null if no simulation exists."}).input(ks.extend({run_id:ns().int().positive().optional()})).output(Co({simulation:Ca.nullable()})),pd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/versions",summary:"Get version history for a test case",description:"Returns all version entries from the test case version_history JSON"}).input(ks).output(Rs(ra)),pd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}",summary:"Get specific test case version",description:"Returns a specific version entry from the test case version_history JSON"}).input(ks.extend({version:ns()})).output(ra),pd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}/rollback",summary:"Rollback to specific version",description:"Restores test case to a previous version and appends new version entry"}).input(ks.extend({version:ns()})).output(ra),pd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/versions/compare",summary:"Compare two versions",description:"Returns differences between two test case versions"}).input(ks.extend({version1:ns(),version2:ns()})).output(Co({version1:ra,version2:ra,diff:_o(Co({field:Bi(),oldValue:ua,newValue:ua}))})),pd.route({method:"DELETE",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}",summary:"Delete a specific version",description:"Removes a version from history and reverts test case to previous version if it was the latest"}).input(ks.extend({version:ns()})).output(As.extend({current_version:uo()})),pd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}/accept",summary:"Accept a specific version",description:"Marks a version as accepted by the user"}).input(ks.extend({version:ns()})).output(As),pd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/healing-attempts",summary:"Get healing attempts for a test case",description:"Returns all healing attempt entries from the test case healing_attempts JSON"}).input(ks).output(Rs(ia)),pd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/healing-attempts/{attemptIndex}/approve",summary:"Approve a healing attempt",description:"Applies the repair from a validated healing attempt by array index"}).input(ks.extend({attemptIndex:ns()})).output(As),pd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/healing-attempts/{attemptIndex}/reject",summary:"Reject a healing attempt",description:"Marks a healing attempt as rejected by array index"}).input(ks.extend({attemptIndex:ns()})).output(As),pd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/heal",summary:"Trigger self-healing for a failed test case",description:"Initiates the self-healing workflow for a test case"}).input(ks.extend({simulation_id:uo(),config:Co({enabled:fo().optional(),autoApply:fo().optional(),minConfidenceThreshold:uo().min(0).max(1).optional(),maxHealingAttempts:uo().int().min(1).max(5).optional()}).optional()})).output(Co({healed:fo(),attemptIndex:uo().nullable(),analysis:ha.nullable(),confidence:uo().nullable()})),pd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/run-cross-browser",summary:"Execute cross-browser tests",description:"Runs tests across multiple browsers (chromium, firefox, webkit)"}).input(Xs.extend({id:ns()})).output(Co({runs:_o(Co({browserType:Qs,runId:uo(),status:Po(["completed","failed","skipped"]),passedTests:uo(),failedTests:uo(),totalTests:uo()})),summary:Co({totalRuns:uo(),completedRuns:uo(),failedRuns:uo(),overallPassed:uo(),overallFailed:uo()})})),pd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}/cross-browser-comparison",summary:"Get cross-browser comparison",description:"Returns test cases comparison across different browsers"}).input(ks).output(Co({byTest:Oo(Bi(),Oo(Bi(),Co({status:Bi(),runId:uo()}))),byBrowser:Oo(Bi(),Co({passed:uo(),failed:uo(),total:uo()}))})),pd.route({method:"PUT",tags:["QA"],path:"/qa/document/{id}/browser-config",summary:"Update browser configuration",description:"Updates the default browser configuration for a QA flow"}).input(Xs.extend({id:ns()})).output(As),pd.route({method:"POST",tags:["Stripe"],path:"/stripe/trial",summary:"Create a trial subscription",description:"Creates a trial subscription for the authenticated workspace. The trial period is 30 days by default."}).input(Yl).output(tc),pd.route({method:"POST",tags:["Stripe"],path:"/stripe/checkout",summary:"Create a checkout session for subscription purchase",description:"Creates a Stripe checkout session for purchasing a subscription. Returns a session URL for redirect."}).input(Vl).output(Xl),pd.route({method:"POST",tags:["Stripe"],path:"/stripe/portal",summary:"Create a customer portal session",description:"Creates a Stripe billing portal session for managing subscription, payment methods, and invoices."}).input(ql).output(ec),pd.route({method:"POST",tags:["Stripe"],path:"/stripe/downgrade",summary:"Confirm and process a subscription downgrade",description:"Processes a confirmed subscription downgrade to a lower tier plan. No payment required."}).input(Jl).output(Kl),pd.route({method:"POST",tags:["Stripe"],path:"/stripe/cancel",summary:"Cancel subscription at period end",description:"Cancels the subscription at the end of the current billing period."}).input(Co({subscriptionId:Bi().min(1)})).output(Co({subscriptionId:Bi(),cancelAtPeriodEnd:fo()})),pd.route({method:"GET",tags:["Stripe"],path:"/stripe/catalog",summary:"Get public Stripe catalog (pricing, plans, config)",description:"Returns pricing from Stripe, plan catalog metadata, and Stripe frontend configuration in a single call."}).output(Co({pricing:sc,plans:lc,config:cc})),pd.route({method:"GET",tags:["Stripe"],path:"/stripe/subscription",summary:"Get current subscription plan and usage",description:"Returns current subscription plan information and actual usage statistics for the authenticated workspace."}).output(Co({plan:Ql,usage:rc})),pd.route({method:"POST",tags:["Stripe"],path:"/stripe/sync",summary:"Reconcile workspace plan with Stripe",description:"Force-syncs the workspace_plan row with live Stripe subscription state. Called by the app after checkout success to recover from delayed or missed webhooks."}).output(Co({plan:Ql})),pd.route({method:"GET",tags:["Widget"],path:"/widget/stream",summary:"SSE stream for real-time widget events",description:"Typed event stream delivering tool calls, task status updates, chat responses, and registration confirmation."}).input(Co({chat_id:Bi(),tab_id:Bi().optional(),marketrix_id:Bi().optional(),marketrix_key:Bi().optional(),agent_id:ns().optional(),application_id:ns().optional()})).output(md(ol)),pd.route({method:"POST",tags:["Widget"],path:"/widget/message",summary:"Send a typed command from widget to server",description:"Receives chat commands, tool responses, and keepalive pings from the widget."}).input(Co({chat_id:Bi(),command:sl})).output(Co({ok:fo()})),pd.route({method:"GET",tags:["App"],path:"/app/events",summary:"SSE stream for real-time app dashboard events",description:"Typed event stream delivering simulation, agent, QA, and user updates filtered by scope and application."}).input(Co({scopes:_o(al).min(1),application_id:ns().optional()})).output(md(dl)),pd.route({method:"POST",tags:["Internal"],path:"/workos/webhook",summary:"WorkOS webhook receiver",description:"Receives webhook events from WorkOS (user management, SSO). Verified via workos-signature header. Not for external use."}).input(Co({event:Bi(),data:Oo(Bi(),wo())})).output(Co({received:fo()})),pd.route({method:"POST",tags:["Internal"],path:"/stripe/webhook",summary:"Stripe webhook receiver",description:"Receives webhook events from Stripe (payments, subscriptions). Verified via stripe-signature header. Not for external use."}).input(Co({id:Bi(),object:Bi(),type:Bi(),data:Oo(Bi(),wo())}).passthrough().describe("Stripe event payload")).output(Co({received:fo()})),pd.route({method:"GET",tags:["Insight"],path:"/insights/personas",summary:"Get personas overview (connectors + segments + personas)"}).input(Es).output(Pc),pd.route({method:"POST",tags:["Insight"],path:"/insights/segments/generate",summary:"Generate segments from session data (mocked)"}).input(Es).output(Co({items:_o(Oc)})),pd.route({method:"DELETE",tags:["Insight"],path:"/insights/segments/{id}",summary:"Delete a segment"}).input(Co({id:ns()})).output(As),pd.route({method:"POST",tags:["Insight"],path:"/insights/personas/generate",summary:"Generate personas from segments (mocked)"}).input(Es).output(Co({items:_o(Rc)})),pd.route({method:"DELETE",tags:["Insight"],path:"/insights/personas/{id}",summary:"Delete a persona"}).input(Co({id:ns()})).output(As),pd.route({method:"GET",tags:["Insight"],path:"/insights/personas/domain-suggest",summary:"Get domain-specific persona suggestions (accessible during onboarding)"}).input(Co({domain:Bi()})).output($c),pd.route({method:"POST",tags:["Insight"],path:"/insights/personas/save-domain",summary:"Save domain-suggested personas to the workspace (accessible during onboarding)"}).input(Lc).output(Co({saved:uo()})),pd.route({method:"PATCH",tags:["Insight"],path:"/insights/personas/{id}",summary:"Update persona content (name, description, profile fields, tags, traits)"}).input(Dc).output(As),pd.route({method:"PATCH",tags:["Insight"],path:"/insights/personas/{id}/selection",summary:"Toggle the is_selected state of a persona"}).input(Co({id:ns(),is_selected:fo()})).output(As),pd.route({method:"POST",tags:["Insight"],path:"/insights/personas/regenerate",summary:"Start segment + persona regeneration for an application (fire-and-forget)"}).input(Co({application_id:uo()})).output(Co({job_id:Bi()})),pd.route({method:"POST",tags:["Insight"],path:"/insights/personas/{id}/key-features",summary:"Generate AI key product feature insights for a specific persona"}).input(Co({id:ns()})).output(Co({features:_o(Bi())})),pd.route({method:"POST",tags:["Insight"],path:"/insights/{application_id}/research/run",summary:"Kick off Background Research for an application",description:"Fire-and-forget: dispatches Background Research to the agent, returns a job_id the client can subscribe to via appEvents. On completion, research output is persisted as knowledge rows with source='research' and a knowledge_embed is dispatched per row."}).input(Co({application_id:ns()})).output(Co({job_id:Bi()})),pd.route({method:"GET",tags:["Insight"],path:"/insights/{application_id}/research/status",summary:"Check whether Background Research is currently running",description:'Returns the current Background Research dispatch state for an application. Used by the client to restore the "Researching…" banner across page refreshes — if `status="in_progress"`, the client subscribes to appEvents and waits for `job/completed`. Per-pod tracking; not persistent across api restarts.'}).input(Co({application_id:ns()})).output(Co({status:Po(["idle","in_progress"])})),pd.route({method:"GET",tags:["Insight"],path:"/insights/heatmaps/pages",summary:"Get all tracked heatmap pages"}).input(Es).output(Co({items:_o(Wc)})),pd.route({method:"GET",tags:["Insight"],path:"/insights/heatmaps/snapshot",summary:"Get heatmap snapshot for a page/variation/type"}).input(Co({page_id:ns(),variation:Fc,type:jc})).output(Hc.nullable()),pd.route({method:"POST",tags:["Insight"],path:"/insights/heatmaps/generate",summary:"Enqueue a heatmap aggregation job over RRWeb session batches"}).input(Es).output(Co({job_id:Bi(),status:Po(["queued","active"])})),pd.route({method:"GET",tags:["Insight"],path:"/insights/heatmaps/status",summary:"Get the current heatmap aggregation job status for an application"}).input(Es).output(Zc),pd.route({method:"POST",tags:["Insight"],path:"/insights/heatmaps/candidates",summary:"Live-scan contributing sessions for a (page, variation) snapshot"}).input(Co({page_id:uo(),variation:Fc,limit:uo().int().min(1).max(50).default(15),offset:uo().int().min(0).default(0)})).output(Co({candidates:_o(Vc),total:uo()})),pd.route({method:"POST",tags:["Insight"],path:"/insights/heatmaps/backdrop",summary:"Pin a session as the backdrop override for a (page, variation) snapshot, or clear it with null"}).input(Co({page_id:uo(),variation:Fc,session_id:Bi().nullable()})).output(Co({success:Lo(!0)})),pd.route({method:"GET",tags:["Insight"],path:"/insights/reactions",summary:"Get all reactions with runs and results"}).input(Es).output(Co({reactions:_o(td),personas:_o(Rc)})),pd.route({method:"POST",tags:["Insight"],path:"/insights/reactions",summary:"Create a new reaction (question)"}).input(Co({application_id:ns(),question:Bi()})).output(td),pd.route({method:"DELETE",tags:["Insight"],path:"/insights/reactions/{id}",summary:"Delete a reaction and all its runs"}).input(Co({id:ns()})).output(As),pd.route({method:"POST",tags:["Insight"],path:"/insights/reactions/context",summary:"Get context for a reaction question"}).input(Co({application_id:ns(),question:Bi()})).output(nd),pd.route({method:"POST",tags:["Insight"],path:"/insights/reactions/{reaction_id}/run",summary:"Run reaction scoring for selected personas"}).input(Co({reaction_id:ns(),persona_ids:_o(ns()),context_refs:_o(Yc),simulations:_o(Xc.pick({description:!0,selected:!0}))})).output(ed);var fd,gd=null,yd="";function wd(e){return ye(new je({url:e,headers:()=>{const e={};return gd&&(e.Authorization=`Bearer ${gd}`),e}}))}fd=wd("");var bd=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==yd&&(yd=e,fd=wd(e))},vd={setAuthToken:e=>{gd=e},clearAuthToken:()=>{gd=null},getAuthToken:()=>gd,configure:bd},xd=new Proxy({},{get:(e,t)=>t in vd?vd[t]:fd[t]}),kd="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",_d={debug:0,info:1,warn:2,error:3};function Sd(e){return _d[e]>=_d[kd]}function Cd(e){return{debug:(e,...t)=>{Sd("debug")},info:(e,...t)=>{Sd("info")},warn:(e,...t)=>{Sd("warn")},error:(e,...t)=>{Sd("error")}}}var Id=[{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 Ed(e){return e.includes("__THINKING__")}function Td(e){return Ed(e)?e:`${e}\n\n__THINKING__`}function Ad(e,t,n,r,i){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(i&&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 Md(e){const{messages:t,isTaskRunning:n,currentMode:r,requireContent:i}=e;let o=-1;if(n&&("show"===r||"do"===r)){const e=!0;for(let s=t.length-1;s>=0;s--){const a=t[s],l=Ad(a,n,r,i,e),c=a.isPlaceholder,d=!i||a.content.trim().length>0||a.parts&&a.parts.length>0;if(l&&c&&d){o=s;break}}if(o<0&&!i)for(let s=t.length-1;s>=0;s--){const a=t[s],l=Ad(a,n,r,i,e),c=a.isPlaceholder;if(l&&c){o=s;break}}if(o<0)for(let s=t.length-1;s>=0;s--){const a=t[s],l=Ad(a,n,r,i,e),c=a.isPlaceholder;if(l&&!c){o=s;break}}}if(o<0){for(let e=t.length-1;e>=0;e--){const n=t[e],r="agent"===n.sender,s=n.isPlaceholder,a=!n.isSystemMessage,l=!n.isScreenAccessRequest,c=!i||n.content.trim().length>0||n.parts&&n.parts.length>0;if(r&&s&&a&&l&&c){o=e;break}}if(o<0&&!i)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&n.isPlaceholder&&!n.isSystemMessage&&!n.isScreenAccessRequest){o=e;break}}if(o<0&&(o=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)),o<0)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest){o=e;break}}}return o>=0?{index:o,message:t[o]}:null}function zd(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 Od=new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]);function Rd(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 Pd(e,t,n,r=!1){const i=zd(e);if(!t||"show"!==n&&"do"!==n)return Ed(i.content)?{...i,content:i.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:i;const o=r?"waiting-for-user":"thinking";return Ed(i.content)?i.placeholderState!==o?{...i,placeholderState:o}:i:{...i,content:Td(i.content),placeholderState:o}}var Nd=Object.fromEntries(Id.map(e=>[e.id,e.displayAction]));var Ld="marketrix_chat_context",Dd={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},$d=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={...Dd},this.context;try{const e=localStorage.getItem(Ld);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Dd},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Dd},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Ld,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,taskProgress:e.taskProgress,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={...Dd},"undefined"!=typeof window&&localStorage.removeItem(Ld)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),jd=class e{static instance;messages=[];chatId=null;isTaskRunning=!1;activeTaskId=null;taskProgress=[];currentMode="tell";isOpen=!1;isMinimized=!1;isLoading=!1;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e,this.restoreState()}createInitialContext(e){try{if($d.hasValidContext())return;$d.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}getMessages(){return this.messages}getIsLoading(){return this.isLoading}getIsTaskRunning(){return this.isTaskRunning}getActiveTaskId(){return this.activeTaskId}getTaskProgress(){return this.taskProgress}getCurrentMode(){return this.currentMode}getIsOpen(){return this.isOpen}getIsMinimized(){return this.isMinimized}addMessage(e){this.messages=[...this.messages,e],this.persistState()}updateMessage(e,t){this.messages=this.messages.map(n=>n.id===e?{...n,...t}:n),this.persistState()}removeMessage(e){this.messages=this.messages.filter(t=>t.id!==e),this.persistState()}setMessages(e){this.messages=e,this.persistState()}clearMessages(){this.messages=[],this.persistState()}setTaskState(e,t,n){this.isTaskRunning=e,this.activeTaskId=t,this.taskProgress=n,this.persistState()}setMode(e){this.currentMode=e,this.persistState()}setWidgetState(e,t){this.isOpen=e,this.isMinimized=t,this.persistState()}setIsLoading(e){this.isLoading=e,this.persistState()}restoreState(){try{const e=$d.getContext();if(!e.chat_id)return;this.chatId&&(e.chat_id,this.chatId),this.messages=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}),this.isTaskRunning=e.isTaskRunning,this.activeTaskId=e.activeTaskId,this.taskProgress=e.taskProgress,this.currentMode=e.currentMode,this.isOpen=e.isOpen,this.isMinimized=e.isMinimized,this.isLoading=e.isLoading??!1}catch(e){}}persistState(){if(this.chatId)try{const e=this.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});$d.updateContext({chat_id:this.chatId,messages:e,isTaskRunning:this.isTaskRunning,activeTaskId:this.activeTaskId,taskProgress:this.taskProgress,currentMode:this.currentMode,isOpen:this.isOpen,isMinimized:this.isMinimized,isLoading:this.isLoading})}catch(e){}}}.getInstance();function Fd(e,t,n="user-message"){const r=[],i=e.trim();return i&&r.push({type:"text",content:i}),{id:`${n}-${Date.now()}`,content:i,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:r}}function Ud(e,t,n,r="agent-message"){const i=[],o=e.trim();return o&&i.push({type:"text",content:o}),{id:n||`${r}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:i}}function Bd(e,t,n="agent",r="system-message"){const i=[];return e&&i.push({type:"text",content:e}),{id:`${r}-${Date.now()}`,content:e,sender:n,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:i}}function Gd(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 Wd(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Hd=Cd(),Zd=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Hd.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 Hd.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Hd.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Hd.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{Hd.info("Creating new chat ID...");const e=await xd.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Hd.info("Created and stored new chat ID:",this.chatId),jd.createInitialContext(e),e}catch(e){throw Hd.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return $d.getChatId()}storeChatId(e){$d.setChatId(e)}}.getInstance(),Vd=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?.mtxAgent&&this.config?.mtxApp&&(t.agent_id=this.config.mtxAgent,t.application_id=this.config.mtxApp);const i=await xd.widgetStream(t,{signal:r});this.setStatus("connected"),this.reconnectAttempts=0,this.reconnectDelay=1e3,this.consumeEvents(i,n)}catch(i){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?xd.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)}},qd=class{config;constructor(e){this.config=e}getChatId(){return Zd.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),xd.activityLogCreate({type:"widget_question",metadata:r}).catch(e=>{})}catch(n){}}async sendMessage(e){if(!(await Zd.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&&this.config.mtxAgent))throw new Error("Either mtxId + mtxKey or both mtxApp + mtxAgent are 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 Vd.getInstance().send(r),{messageId:n,response:"",mode:t,timestamp:/* @__PURE__ */new Date}}updateConfig(e){this.config={...this.config,...e}}},Yd=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=$d.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){$d.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 Jd(e,t={}){return{...t,...e}}var Kd=n(void 0),Qd=({children:e,previewMode:t=!1,uiActions:n,currentMode:r})=>{const[i,s]=p({messages:[]}),a=u(r);a.current=r;const l=o(e=>{s(t=>(jd.addMessage(e),{messages:[...t.messages,e]}))},[]),c=o((e,t)=>{s(n=>(jd.updateMessage(e,t),{messages:n.messages.map(n=>n.id===e?{...n,...t}:n)}))},[]),h=o(e=>{s(t=>(jd.removeMessage(e),{messages:t.messages.filter(t=>t.id!==e)}))},[]),m=o(e=>{s(()=>(jd.setMessages(e),{messages:e}))},[]),g=o(()=>{jd.clearMessages(),s({messages:[]})},[]),y=o(async(e,r,i,o,c)=>{const d=r??a.current;if(t)return c||l(Fd(e,d)),void l(Ud("This is a preview. In production, I'll respond to your messages here."));let u=Yd.getConfig();if(u||(u=Yd.loadConfig()),!u||!u.mtxId&&!u.mtxKey&&!u.mtxAgent)return void l(Ud("Configuration error: Missing API credentials. Please check your widget settings."));c||l(Fd(e,d));const p=`temp-${globalThis.crypto.randomUUID()}`;l({id:p,content:Td(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:d,isPlaceholder:!0,placeholderState:"thinking",parts:[]}),n.setLoading(!0);const h=new qd(u);try{i&&h.updateConfig({mtxApp:i});const t=h.getChatId();if(t){const e=Vd.getInstance();if(!e.isConnected()){const n=Yd.getConfig();try{await e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxAgent:n.mtxAgent,mtxApp:n.mtxApp}:void 0)}catch(m){}}}await h.sendMessage({message:e,mode:d,question:o,requestId:p})}catch(f){s(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.",n=e.messages.map(e=>{if(e.id!==p)return e;const n=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:n,content:t}});return jd.setMessages(n),{messages:n}})}finally{n.setLoading(!1)}},[t,l,n]),w=d(()=>({addMessage:l,updateMessage:c,removeMessage:h,setMessages:m,clearMessages:g,sendMessage:y}),[l,c,h,m,g,y]);/* @__PURE__ */
3
- return f(Kd.Provider,{value:{chatState:i,chatActions:w,_setMessages:s},children:e})};function Xd(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 i=(t,n)=>{if(r){e.tagName,e.id,e.className}};if(!0===e.disabled)return i("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return i("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return i("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 o=e.hasAttribute("onclick");if(r&&o)return!0;let s,a;try{s=window.getComputedStyle(e)}catch(t){return i("computed-style","failed to get computed style"),!1}if("none"===s.display)return i("display","display is none"),!1;if("none"===s.pointerEvents)return i("pointer-events","pointer-events is none"),!1;try{a=e.getBoundingClientRect()}catch(t){return i("bounding-rect","failed to get bounding rect"),!1}if(a.width<=0||a.height<=0)return i("dimensions",`width=${a.width}, height=${a.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 o,s;try{o=window.getComputedStyle(n),s=n.getBoundingClientRect()}catch{t=n;continue}if("hidden"===o.overflow||"clip"===o.overflow){const e=a.right<s.left||a.left>s.right||a.bottom<s.top||a.top>s.bottom;if(r){if(e)return i("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 eu=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;isIndexed=!1;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,i=Array.from(t.children).filter(e=>e.tagName===r);if(i.length>1){e+=`:nth-of-type(${i.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"}}exportState(){return{selectors:Array.from(this.selectorMap.entries()),fingerprints:Array.from(this.fingerprintMap.entries())}}importState(e){if(e)try{e.selectors&&(this.selectorMap=new Map(e.selectors)),e.fingerprints&&(this.fingerprintMap=new Map(e.fingerprints)),(this.selectorMap.size>0||this.fingerprintMap.size>0)&&(this.isIndexed=!0)}catch(t){}}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"]'),i=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),o="onclick"in t&&"function"==typeof t.onclick;if(e||i||o||Xd(t)){this.elementMap.set(n,t),this.elementToSequence.set(t,n);const e=this.generateSelector(t);this.selectorMap.set(n,e);const i=this.generateFingerprint(t,e);this.fingerprintMap.set(n,i),r.push([n,t]),n++}}t=e.nextNode()}return this.isIndexed=!0,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 i=t.willChange;if(i&&(i.includes("transform")||i.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const o=t.contain;return!(!o||!(o.includes("layout")||o.includes("style")||o.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 i=0;t.parentElement&&(i=Array.from(t.parentElement.children).indexOf(t)),n.push({element:t,zIndex:r,domOrder:i})}t=t.parentElement}let r=1e6;for(let i=n.length-1;i>=0;i--){const e=n[i];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 i=this.selectorMap.get(n);if(i)try{const t=(e.querySelector("body")||e).querySelector(i);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}getElementByDataId(e){return this.elementMap.get(e)}getSequenceForElement(e){return this.elementToSequence.get(e)}isIndexActive(){return this.isIndexed}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear(),this.isIndexed=!1}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 i=r.left+r.width/2,o=r.top+r.height/2,s=document.elementFromPoint(i,o);if(s&&s!==e&&!e.contains(s)&&!(s.closest("#marketrix-show-highlight")||s.closest("#marketrix-show-popup")||s.closest("[data-marketrix-widget]"))){const e=s.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${s.className?`${e}.${s.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}}getFingerprint(e){return this.fingerprintMap.get(e)}getAllFingerprints(){return Array.from(this.fingerprintMap.entries())}getIndexVersion(){return this.indexVersion}}.getInstance(),tu=null;async function nu(){if(tu?.active){const e=tu.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return tu}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 tu=e,e.getVideoTracks()[0].addEventListener("ended",()=>{tu=null}),e}function ru(){return null!==function(){if(tu?.active){const e=tu.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return tu}return tu=null,null}()}var iu=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:i}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===n&&this.currentOptions.toolName===i&&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,i=e.left+e.width/2,o=e.top+e.height/2,s=[{left:e.right+20,top:o-60},{left:e.left-t-20,top:o-60},{left:i-160,top:e.top-n-20},{left:i-160,top:e.bottom+20}];let a=s[0];for(const d of s)if(d.left>=r&&d.left+t<=window.innerWidth-r&&d.top>=r&&d.top+n<=window.innerHeight-r){a=d;break}const l=Math.max(r,Math.min(a.left,window.innerWidth-t-r)),c=Math.max(r,Math.min(a.top,window.innerHeight-n-r));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${c}px;\n left: ${l}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=eu.getSequenceForElement(this.currentElement)??-1,t=eu.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(),ou=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:i}=eu.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:i||`Element ${n} not found`};if(!(await iu.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(i){return iu.cleanup(),{success:!1,data:{text:""},error:i instanceof Error?i.message:String(i)}}}requiresHighlight(e){return["click_element","type_text","select_dropdown_option","send_keys","upload_file"].includes(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}=eu.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}=eu.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(i){}const o=t?e.text:r.value+e.text;let s=!1,a=null;if(!s)try{const e="TEXTAREA"===r.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(r,o),s=!0)}catch(i){a=i}if(!s)try{r.value=o,s=!0}catch(i){a=i}if(!s)try{r.focus(),t&&r.select(),document.execCommand("insertText",!1,e.text)&&(s=!0)}catch(i){a=i}if(!s)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}));s=!0}catch(i){a=i}if(!s)return{success:!1,data:{text:""},error:`Failed to set value: ${a instanceof Error?a.message:String(a)}`};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(i){}}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(i){return{success:!1,data:{text:""},error:`Failed to set value on element: ${i instanceof Error?i.message:String(i)}`}}else try{n.textContent=e.text,n.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){return{success:!1,data:{text:""},error:`Failed to set textContent: ${i instanceof Error?i.message:String(i)}`}}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}=eu.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}=eu.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}=eu.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,i=e.selectionStart??t.length,o=e.selectionEnd??t.length;if(0===i&&0===o&&(i=t.length,o=t.length),i===o&&i>0)n=t.slice(0,i-1)+t.slice(o),r=i-1;else{if(i===o)return"Backspace: cursor at start, nothing to delete";n=t.slice(0,i)+t.slice(o),r=i}const s=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return s?s.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 i;if(t===n&&t<r.length)i=r.slice(0,t)+r.slice(n+1);else{if(t===n)return"Delete: cursor at end, nothing to delete";i=r.slice(0,t)+r.slice(n)}const o=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return o?o.call(e,i):e.value=i,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${i}"`}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:eu.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:eu.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await nu();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(),su=n(void 0),au=({children:e,previewMode:t=!1,currentMode:n,setMessages:r,uiActions:i,activeTaskIdRef:s})=>{const[l,c]=p({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),h=u(!1),m=u(0),g=u(/* @__PURE__ */new Set),y=u({}),w=u(n);w.current=n,a(()=>{s.current=l.activeTaskId},[l.activeTaskId,s]);const b=o(e=>{if(g.current.add(e),g.current.size>1e3){const e=Array.from(g.current);g.current=new Set(e.slice(-500))}},[]),v=o((e,t,n,i)=>{r(r=>{const o=function(e){return Nd[e]?Nd[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(e),s=Md({messages:r.messages,isTaskRunning:h.current,currentMode:w.current,requireContent:"failed"===n});if(!s)return r;let a=s.message;const l=["click_element","type_text","select_dropdown_option","send_keys","upload_file"].includes(e),c=h.current&&"show"===w.current&&l,d="done"===e;"in_progress"===n?(d||(a=function(e,t,n){const r=zd(e),i=r.parts||[],o=[...i],s=i.findIndex(e=>"progress"===e.type&&e.toolName===t&&"in_progress"===e.status),a=!Od.has(t),l="default",c=Rd(n);return s>=0?o[s]={...o[s],content:c,hideIcon:a,textStyle:l}:o.push({type:"progress",content:c,status:"in_progress",toolName:t,hideIcon:a,textStyle:l}),{...r,parts:o}}(a,o,t||o)),!h.current||"show"!==w.current&&"do"!==w.current||(a=Pd(a,h.current,w.current,c))):"completed"===n?(d||(a=function(e,t){const n=zd(e),r=n.parts||[],i=[...r];let o=-1;if(t)o=r.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);else for(let s=r.length-1;s>=0;s--)if("progress"===r[s].type&&"in_progress"===r[s].status){o=s;break}return o>=0&&(i[o]={...i[o],status:"completed"}),{...n,parts:i}}(a)),!h.current||"show"!==w.current&&"do"!==w.current||(a=Pd(a,h.current,w.current,!1))):(a=function(e,t,n){const r=zd(e),i=r.parts||[],o=n.toLowerCase().includes("cancelled by cleanup"),s=[...i];let a=i.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);if(-1===a)for(let l=i.length-1;l>=0;l--)if("progress"===i[l].type&&"in_progress"===i[l].status){a=l;break}if(a>=0)if(o){const e=Rd(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=Rd(n),t=Rd(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(a,o,i||""),!h.current||"show"!==w.current&&"do"!==w.current||(a=Pd(a,h.current,w.current,!1)));const u=[...r.messages];return u[s.index]=a,jd.setMessages(u),{messages:u}})},[]),x=o(()=>{const e=y.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;y.current={},c(e=>(jd.setTaskState(!0,t,[]),h.current=!0,{...e,isTaskRunning:!0,activeTaskId:t,taskProgress:[]}))}},[]);a(()=>{if(t)return;const e=Vd.getInstance(),n={onStatusChange:e=>{i.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const i=t.call_id;if(g.current.has(i))return;if(b(i),!Id.map(e=>e.id).includes(t.tool))return void e.send({type:"tool/response",call_id:i,success:!1,error:`Unknown tool: ${t.tool}`,state_version:m.current}).catch(e=>{});h.current||(h.current=!0,c(e=>({...e,isTaskRunning:!0})));const o=t.tool,s=t.args,a=t.mode||w.current||"do",l=t.explanation||"",d=t.state_version;void 0!==d&&d>m.current&&(m.current=d),v(o,l,"in_progress");const u=await ou.executeTool(o,s,a,l);if(u.success)try{m.current++,e.send({type:"tool/response",call_id:i,success:!0,data:"string"==typeof u.data?u.data:JSON.stringify(u.data),state_version:m.current}).catch(e=>{}),v(o,l,"completed"),"done"===o&&(y.current={},c(e=>(jd.setTaskState(!1,null,[]),h.current=!1,r(t=>{const n=Md({messages:t.messages,isTaskRunning:e.isTaskRunning,currentMode:w.current,requireContent:!1}),r=[...t.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},jd.setMessages(r)}return{messages:r}}),{...e,isTaskRunning:!1,activeTaskId:null,taskProgress:[]})))}catch(n){v(o,l,"failed","Connection error")}else v(o,l,"failed",u.error||"Tool execution failed"),m.current++,e.send({type:"tool/response",call_id:i,success:!1,data:"string"==typeof u.data?u.data:JSON.stringify(u.data),error:u.error??void 0,state_version:m.current}).catch(e=>{})}else if("task/status"===t.type){const e=t.status,n=t.message||"";"running"===e?(y.current={...y.current,agentRunning:!0,apiTaskId:y.current.apiTaskId||t.task_id||void 0},x()):"completed"!==e&&"failed"!==e&&"stopped"!==e||(g.current.clear(),y.current={},c(t=>(jd.setTaskState(!1,null,[]),r(r=>{const i=Md({messages:r.messages,isTaskRunning:t.isTaskRunning,currentMode:w.current,requireContent:!1}),o=[...r.messages];if(i){let t="done";"failed"===e?t="failed":"stopped"===e&&(t="stopped"),o[i.index]={...i.message,taskStatus:t,...n&&{content:n}},jd.setMessages(o)}return{messages:o}}),h.current=!1,{...t,isTaskRunning:!1,activeTaskId:null,taskProgress:[]})))}else"chat/response"===t.type?(r(e=>{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}}});return jd.setMessages(n),t.task_id&&(y.current={...y.current,apiTaskId:t.task_id},x()),{messages:n}}),i.setLoading(!1)):"chat/error"===t.type&&(r(e=>{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 jd.setMessages(n),{messages:n}}),i.setLoading(!1))},onError:e=>{i.setError(e.message)}};return e.addCallbacks(n),()=>{e.removeCallbacks(n)}},[t,v,x,b,r,i]);const k=o(e=>{c(t=>(jd.setTaskState(e.isTaskRunning,e.activeTaskId,e.taskProgress??[]),{...t,...e}))},[]),_=o(async()=>{const e=s.current??void 0;c(e=>(r(n=>{const r=Md({messages:n.messages,isTaskRunning:e.isTaskRunning,currentMode:w.current,requireContent:!1}),i=[...n.messages];return r&&(i[r.index]={...r.message,taskStatus:"stopped"},t||jd.setMessages(i)),{messages:i}}),t||jd.setTaskState(!1,null,[]),h.current=!1,{...e,isTaskRunning:!1,activeTaskId:null,taskProgress:[]})),t||Vd.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,r,s]),S=d(()=>({setTaskState:k,stopTask:_}),[k,_]);/* @__PURE__ */
4
- return f(su.Provider,{value:{taskState:l,taskActions:S},children:e})},lu=n(void 0),cu=({children:e,initialMode:t="tell",initialIsOpen:n=!1,initialIsMinimized:r=!1})=>{const[i,o]=p({isOpen:n,isMinimized:r,activeView:"home",currentMode:t,agentAvailable:!1,isLoading:!1}),s=d(()=>({setActiveView:e=>o(t=>({...t,activeView:e})),toggleWidget:()=>o(e=>{const t={...e,isOpen:!e.isOpen,isMinimized:!!e.isOpen};return jd.setWidgetState(t.isOpen,t.isMinimized),t}),closeWidget:()=>o(e=>{const t={...e,isOpen:!1,isMinimized:!0};return jd.setWidgetState(t.isOpen,t.isMinimized),t}),setMode:e=>o(t=>(jd.setMode(e),{...t,currentMode:e})),setLoading:e=>{jd.setIsLoading(e),o(t=>({...t,isLoading:e}))},setAgentAvailable:e=>o(t=>({...t,agentAvailable:e})),setError:e=>o(t=>({...t,error:e})),clearError:()=>o(e=>({...e,error:void 0})),applyState:e=>o(t=>({...t,...e}))}),[]);/* @__PURE__ */
5
- return f(lu.Provider,{value:{uiState:i,uiActions:s},children:e})},du=()=>{const e=s(lu);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var uu=({config:e}={})=>{const{uiState:t,uiActions:n}=du(),{chatState:r,chatActions:i}=(()=>{const e=s(Kd);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e})(),{taskState:l,taskActions:c}=(()=>{const e=s(su);if(!e)throw new Error("useTaskContext must be used within TaskProvider");return e})(),u=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:l.activeTaskId,isTaskRunning:l.isTaskRunning,taskProgress:l.taskProgress}),[t,r,l]),p=o(e=>{n.applyState({...void 0!==e.isOpen&&{isOpen:e.isOpen},...void 0!==e.isMinimized&&{isMinimized:e.isMinimized},...void 0!==e.isLoading&&{isLoading:e.isLoading},...void 0!==e.currentMode&&{currentMode:e.currentMode},...void 0!==e.agentAvailable&&{agentAvailable:e.agentAvailable},...void 0!==e.error&&{error:e.error},...void 0!==e.activeView&&{activeView:e.activeView}}),void 0!==e.messages&&i.setMessages(e.messages),void 0===e.activeTaskId&&void 0===e.isTaskRunning&&void 0===e.taskProgress||c.setTaskState({activeTaskId:e.activeTaskId??l.activeTaskId,isTaskRunning:e.isTaskRunning??l.isTaskRunning,taskProgress:e.taskProgress??l.taskProgress})},[n,i,c,l]),h=o(()=>{i.clearMessages(),c.setTaskState({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),n.setError(void 0)},[i,c,n]),m=d(()=>({setState:p,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:i.addMessage,updateMessage:i.updateMessage,removeMessage:i.removeMessage,setMessages:i.setMessages,sendMessage:i.sendMessage,resetState:h,clearChatHistory:h}),[p,n,c,i,h]),f=d(()=>e||Yd.getConfig()||{},[e]),g=function(e){return Object.keys(Ka.shape).every(t=>void 0!==e[t])}(f);a(()=>{g&&Yd.saveConfig(f)},[f,g]);const y=f.isPreviewMode??!1;return{state:u,actions:m,config:f,shouldShow:g&&!0===f.widget_enabled,isPreviewMode:y,configValid:g}},pu=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),hu="-",mu=[],fu=e=>{const t=wu(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return yu(e);const n=e.split(hu);return gu(n,""===n[0]&&n.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=r[e],i=n[e];return t?i?((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})(i,t):t:i||mu}return n[e]||mu}}},gu=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],i=n.nextPart.get(r);if(i){const n=gu(e,t+1,i);if(n)return n}const o=n.validators;if(null===o)return;const s=0===t?e.join(hu):e.slice(t).join(hu),a=o.length;for(let l=0;l<a;l++){const e=o[l];if(e.validator(s))return e.classGroupId}},yu=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})(),wu=e=>{const{theme:t,classGroups:n}=e;return bu(n,t)},bu=(e,t)=>{const n=pu();for(const r in e){const i=e[r];vu(i,n,r,t)}return n},vu=(e,t,n,r)=>{const i=e.length;for(let o=0;o<i;o++){const i=e[o];xu(i,t,n,r)}},xu=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?Su(e,t,n,r):_u(e,t,n,r):ku(e,t,n)},ku=(e,t,n)=>{(""===e?t:Cu(t,e)).classGroupId=n},_u=(e,t,n,r)=>{Iu(e)?vu(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},Su=(e,t,n,r)=>{const i=Object.entries(e),o=i.length;for(let s=0;s<o;s++){const[e,o]=i[s];vu(o,Cu(t,e),n,r)}},Cu=(e,t)=>{let n=e;const r=t.split(hu),i=r.length;for(let o=0;o<i;o++){const e=r[o];let t=n.nextPart.get(e);t||(t=pu(),n.nextPart.set(e,t)),n=t}return n},Iu=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Eu=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(i,o)=>{n[i]=o,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])?(i(e,t),t):void 0},set(e,t){e in n?n[e]=t:i(e,t)}}},Tu=[],Au=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Mu=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=e=>{const t=[];let n,r=0,i=0,o=0;const s=e.length;for(let d=0;d<s;d++){const s=e[d];if(0===r&&0===i){if(":"===s){t.push(e.slice(o,d)),o=d+1;continue}if("/"===s){n=d;continue}}"["===s?r++:"]"===s?r--:"("===s?i++:")"===s&&i--}const a=0===t.length?e:e.slice(o);let l=a,c=!1;a.endsWith("!")?(l=a.slice(0,-1),c=!0):a.startsWith("!")&&(l=a.slice(1),c=!0);return Au(t,c,l,n&&n>o?n-o:void 0)};if(t){const e=t+":",n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Au(Tu,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},zu=e=>{const t=/* @__PURE__ */new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{const n=[];let r=[];for(let i=0;i<e.length;i++){const o=e[i],s="["===o[0],a=t.has(o);s||a?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(o)):r.push(o)}return r.length>0&&(r.sort(),n.push(...r)),n}},Ou=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},Ru=/\s+/,Pu=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Pu(e[r]))&&(n&&(n+=" "),n+=t);return n},Nu=(e,...t)=>{let n,r,i,o;const s=e=>{const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:s}=t,a=[],l=e.trim().split(Ru);let c="";for(let d=l.length-1;d>=0;d-=1){const e=l[d],{isExternal:t,modifiers:u,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:m}=n(e);if(t){c=e+(c.length>0?" "+c:c);continue}let f,g=!!m;if(g){f=r(h.substring(0,m));const e=f&&s[f]?r(h):void 0;e&&e!==f&&(f=e,g=!1)}else f=r(h);if(!f){if(!g){c=e+(c.length>0?" "+c:c);continue}if(f=r(h),!f){c=e+(c.length>0?" "+c:c);continue}g=!1}const y=0===u.length?"":1===u.length?u[0]:o(u).join(":"),w=p?y+"!":y,b=w+f;if(a.indexOf(b)>-1)continue;a.push(b);const v=i(f,g);for(let n=0;n<v.length;++n){const e=v[n];a.push(w+e)}c=e+(c.length>0?" "+c:c)}return c})(e,n);return i(e,o),o};return o=a=>(n=(e=>({cache:Eu(e.cacheSize),parseClassName:Mu(e),sortModifiers:zu(e),postfixLookupClassGroupIds:Ou(e),...fu(e)}))(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,o=s,s(a)),(...e)=>o(((...e)=>{let t,n,r=0,i="";for(;r<e.length;)(t=e[r++])&&(n=Pu(t))&&(i&&(i+=" "),i+=n);return i})(...e))},Lu=[],Du=e=>{const t=t=>t[e]||Lu;return t.isThemeGetter=!0,t},$u=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ju=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Fu=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Uu=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Bu=/\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$/,Gu=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Wu=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Hu=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Zu=e=>Fu.test(e),Vu=e=>!!e&&!Number.isNaN(Number(e)),qu=e=>!!e&&Number.isInteger(Number(e)),Yu=e=>e.endsWith("%")&&Vu(e.slice(0,-1)),Ju=e=>Uu.test(e),Ku=()=>!0,Qu=e=>Bu.test(e)&&!Gu.test(e),Xu=()=>!1,ep=e=>Wu.test(e),tp=e=>Hu.test(e),np=e=>!op(e)&&!hp(e),rp=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)),ip=e=>xp(e,Cp,Xu),op=e=>$u.test(e),sp=e=>xp(e,Ip,Qu),ap=e=>xp(e,Ep,Vu),lp=e=>xp(e,Ap,Ku),cp=e=>xp(e,Tp,Xu),dp=e=>xp(e,_p,Xu),up=e=>xp(e,Sp,tp),pp=e=>xp(e,Mp,ep),hp=e=>ju.test(e),mp=e=>kp(e,Ip),fp=e=>kp(e,Tp),gp=e=>kp(e,_p),yp=e=>kp(e,Cp),wp=e=>kp(e,Sp),bp=e=>kp(e,Mp,!0),vp=e=>kp(e,Ap,!0),xp=(e,t,n)=>{const r=$u.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},kp=(e,t,n=!1)=>{const r=ju.exec(e);return!!r&&(r[1]?t(r[1]):n)},_p=e=>"position"===e||"percentage"===e,Sp=e=>"image"===e||"url"===e,Cp=e=>"length"===e||"size"===e||"bg-size"===e,Ip=e=>"length"===e,Ep=e=>"number"===e,Tp=e=>"family-name"===e,Ap=e=>"number"===e||"weight"===e,Mp=e=>"shadow"===e,zp=/* @__PURE__ */Nu(()=>{const e=Du("color"),t=Du("font"),n=Du("text"),r=Du("font-weight"),i=Du("tracking"),o=Du("leading"),s=Du("breakpoint"),a=Du("container"),l=Du("spacing"),c=Du("radius"),d=Du("shadow"),u=Du("inset-shadow"),p=Du("text-shadow"),h=Du("drop-shadow"),m=Du("blur"),f=Du("perspective"),g=Du("aspect"),y=Du("ease"),w=Du("animate"),b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",hp,op],v=()=>[hp,op,l],x=()=>[Zu,"full","auto",...v()],k=()=>[qu,"none","subgrid",hp,op],_=()=>["auto",{span:["full",qu,hp,op]},qu,hp,op],S=()=>[qu,"auto",hp,op],C=()=>["auto","min","max","fr",hp,op],I=()=>["auto",...v()],E=()=>[Zu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],T=()=>[Zu,"screen","full","dvw","lvw","svw","min","max","fit",...v()],A=()=>[Zu,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],M=()=>[e,hp,op],z=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",gp,dp,{position:[hp,op]}],O=()=>["auto","cover","contain",yp,ip,{size:[hp,op]}],R=()=>[Yu,mp,sp],P=()=>["","none","full",c,hp,op],N=()=>["",Vu,mp,sp],L=()=>[Vu,Yu,gp,dp],D=()=>["","none",m,hp,op],$=()=>["none",Vu,hp,op],j=()=>["none",Vu,hp,op],F=()=>[Vu,hp,op],U=()=>[Zu,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ju],breakpoint:[Ju],color:[Ku],container:[Ju],"drop-shadow":[Ju],ease:["in","out","in-out"],font:[np],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ju],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ju],shadow:[Ju],spacing:["px",Vu],text:[Ju],"text-shadow":[Ju],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Zu,op,hp,g]}],container:["container"],"container-type":[{"@container":["","normal","size",hp,op]}],"container-named":[rp],columns:[{columns:[Vu,op,hp,a]}],"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:b()}],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:[qu,"auto",hp,op]}],basis:[{basis:[Zu,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Vu,Zu,"auto","initial","none",op]}],grow:[{grow:["",Vu,hp,op]}],shrink:[{shrink:["",Vu,hp,op]}],order:[{order:[qu,"first","last","none",hp,op]}],"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":C()}],"auto-rows":[{"auto-rows":C()}],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:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mbs:[{mbs:I()}],mbe:[{mbe:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"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",...A()]}],"min-block-size":[{"min-block":["auto",...A()]}],"max-block-size":[{"max-block":["none",...A()]}],w:[{w:[a,"screen",...E()]}],"min-w":[{"min-w":[a,"screen","none",...E()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...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,mp,sp]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vp,lp]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yu,op]}],"font-family":[{font:[fp,cp,t]}],"font-features":[{"font-features":[op]}],"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:[i,hp,op]}],"line-clamp":[{"line-clamp":[Vu,"none",hp,ap]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",hp,op]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",hp,op]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[Vu,"from-font","auto",hp,sp]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[Vu,"auto",hp,op]}],"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:[qu,hp,op]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",hp,op]}],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",hp,op]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"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"]},qu,hp,op],radial:["",hp,op],conic:[qu,hp,op]},wp,up]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:N()}],"border-w-x":[{"border-x":N()}],"border-w-y":[{"border-y":N()}],"border-w-s":[{"border-s":N()}],"border-w-e":[{"border-e":N()}],"border-w-bs":[{"border-bs":N()}],"border-w-be":[{"border-be":N()}],"border-w-t":[{"border-t":N()}],"border-w-r":[{"border-r":N()}],"border-w-b":[{"border-b":N()}],"border-w-l":[{"border-l":N()}],"divide-x":[{"divide-x":N()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":N()}],"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:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Vu,hp,op]}],"outline-w":[{outline:["",Vu,mp,sp]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",d,bp,pp]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",u,bp,pp]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:N()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[Vu,sp]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":N()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",p,bp,pp]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[Vu,hp,op]}],"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":[Vu]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[hp,op]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"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":[Vu]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",hp,op]}],filter:[{filter:["","none",hp,op]}],blur:[{blur:D()}],brightness:[{brightness:[Vu,hp,op]}],contrast:[{contrast:[Vu,hp,op]}],"drop-shadow":[{"drop-shadow":["","none",h,bp,pp]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",Vu,hp,op]}],"hue-rotate":[{"hue-rotate":[Vu,hp,op]}],invert:[{invert:["",Vu,hp,op]}],saturate:[{saturate:[Vu,hp,op]}],sepia:[{sepia:["",Vu,hp,op]}],"backdrop-filter":[{"backdrop-filter":["","none",hp,op]}],"backdrop-blur":[{"backdrop-blur":D()}],"backdrop-brightness":[{"backdrop-brightness":[Vu,hp,op]}],"backdrop-contrast":[{"backdrop-contrast":[Vu,hp,op]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Vu,hp,op]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Vu,hp,op]}],"backdrop-invert":[{"backdrop-invert":["",Vu,hp,op]}],"backdrop-opacity":[{"backdrop-opacity":[Vu,hp,op]}],"backdrop-saturate":[{"backdrop-saturate":[Vu,hp,op]}],"backdrop-sepia":[{"backdrop-sepia":["",Vu,hp,op]}],"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",hp,op]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Vu,"initial",hp,op]}],ease:[{ease:["linear","initial",y,hp,op]}],delay:[{delay:[Vu,hp,op]}],animate:[{animate:["none",w,hp,op]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,hp,op]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:$()}],"rotate-x":[{"rotate-x":$()}],"rotate-y":[{"rotate-y":$()}],"rotate-z":[{"rotate-z":$()}],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:[hp,op,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"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:[qu,hp,op]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"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",hp,op]}],"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":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"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",hp,op]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[Vu,mp,sp,ap]}],stroke:[{stroke:["none",...M()]}],"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 Op(...e){return zp(e.filter(Boolean).join(" "))}var Rp={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)"},Pp={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"},Np={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Lp={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Dp={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},$p={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 jp(e){if(e&&"none"!==e)return{boxShadow:Rp[e]}}var Fp={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Up=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 Bp(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Fp[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Fp[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Fp[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Fp[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Fp[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Fp[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Fp[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Fp[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Fp[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Fp[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Fp[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-${Fp[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(Pp.theme);else if("full"===e.rounded)t.push(Pp.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Pp[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 Gp(e){const t={};for(const n in e)Up.has(n)||(t[n]=e[n]);return t}var Wp={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Hp={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Zp=i(function(e,t){const{as:n="div",background:r="default",className:i,elevation:o,paddingPreset:s="none",radius:a,style:l,...c}=e,d=Bp(e);/* @__PURE__ */
6
- return f(n,{...Gp(c),ref:t,className:Op(Wp[r],Hp[s],a&&Bp({rounded:a}),d,i),style:{...jp(o),...l}})}),Vp="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",qp={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"},Yp=i(function({src:e,alt:t,elevation:n,fit:r="contain",size:i="md",rounded:o,className:s,style:a,...l},c){const d="string"==typeof i,u=d?qp[i]:void 0,p=d?a:{width:i,height:i,...a};/* @__PURE__ */
7
- return f("img",{...l,ref:c,alt:t,className:Op("flex-shrink-0","contain"===r?"object-contain":"object-cover",u,!0===o||"theme"===o?Pp.theme:"full"===o?Pp.pill:o?Pp[o]:void 0,s),src:e,style:{...jp(n),...p}})});function Jp(e){return"undefined"!=typeof window&&(e instanceof HTMLElement||e instanceof function(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}(e).HTMLElement)}var Kp={};function Qp(t,n){const r=e.useRef(Kp);return r.current===Kp&&(r.current=t(n)),r}var Xp=e[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],eh=Xp&&Xp!==e.useLayoutEffect?Xp:e=>e();function th(e){const t=Qp(nh).current;return t.next=e,eh(t.effect),t.trampoline}function nh(){const e={next:void 0,callback:rh,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function rh(){}var ih="undefined"!=typeof document?e.useLayoutEffect:()=>{};function oh(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var sh={};function ah(e,t,n,r,i){if(!(n||r||i||e))return lh(t);let o=lh(e);return t&&(o=ch(o,t)),n&&(o=ch(o,n)),r&&(o=ch(o,r)),i&&(o=ch(o,i)),o}function lh(e){return uh(e)?{...ph(e,sh)}:function(e){const t={...e};for(const n in t){const e=t[n];dh(n,e)&&(t[n]=mh(e))}return t}(e)}function ch(e,t){return uh(t)?ph(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=oh(e.style,r);break;case"className":e[n]=gh(e.className,r);break;default:dh(n,r)?e[n]=hh(e[n],r):e[n]=r}}return e}(e,t)}function dh(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return 111===n&&110===r&&i>=65&&i<=90&&("function"==typeof t||void 0===t)}function uh(e){return"function"==typeof e}function ph(e,t){return uh(e)?e(t):e??sh}function hh(e,t){return t?e?(...n)=>{const r=n[0];if(yh(r)){const i=r;fh(i);const o=t(...n);return i.baseUIHandlerPrevented||e?.(...n),o}const i=t(...n);return e?.(...n),i}:mh(t):e}function mh(e){return e?(...t)=>{const n=t[0];return yh(n)&&fh(n),e(...t)}:e}function fh(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function gh(e,t){return t?e?t+" "+e:t:e}function yh(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}var wh,bh,vh=(wh="https://base-ui.com/production-error",bh="Base UI",function(e,...t){const n=new URL(wh);return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`${bh} error #${e}; visit ${n} for the full message.`}),xh=/* @__PURE__ */e.createContext(void 0);function kh(t={}){const{disabled:n=!1,focusableWhenDisabled:r,tabIndex:i=0,native:o=!0,composite:s}=t,a=e.useRef(null),l=function(t=!1){const n=e.useContext(xh);if(void 0===n&&!t)throw new Error(vh(16));return n}(!0),c=s??void 0!==l,{props:d}=function(t){const{focusableWhenDisabled:n,disabled:r,composite:i=!1,tabIndex:o=0,isNativeButton:s}=t,a=i&&!1!==n,l=i&&!1===n;return{props:e.useMemo(()=>{const e={onKeyDown(e){r&&n&&"Tab"!==e.key&&e.preventDefault()}};return i||(e.tabIndex=o,!s&&r&&(e.tabIndex=n?o:-1)),(s&&(n||a)||!s&&r)&&(e["aria-disabled"]=r),!s||n&&!l||(e.disabled=r),e},[i,r,n,a,l,s,o])}}({focusableWhenDisabled:r,disabled:n,composite:c,tabIndex:i,isNativeButton:o}),u=e.useCallback(()=>{const e=a.current;_h(e)&&c&&n&&void 0===d.disabled&&e.disabled&&(e.disabled=!1)},[n,d.disabled,c]);return ih(u,[u]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:r,onKeyUp:i,onKeyDown:s,onPointerDown:a,...l}=e;return ah({type:o?"button":void 0,onClick(e){n?e.preventDefault():t?.(e)},onMouseDown(e){n||r?.(e)},onKeyDown(e){if(n)return;if(fh(e),s?.(e),e.baseUIHandlerPrevented)return;const r=e.target===e.currentTarget,i=e.currentTarget,a=_h(i),l=!o&&(d=i,Boolean("A"===d?.tagName&&d?.href));var d;const u=r&&(o?a:!l),p="Enter"===e.key,h=" "===e.key,m=i.getAttribute("role"),f=m?.startsWith("menuitem")||"option"===m||"gridcell"===m;if(r&&c&&h){if(e.defaultPrevented&&f)return;return e.preventDefault(),void(l||o&&a?(i.click(),e.preventBaseUIHandler()):u&&(t?.(e),e.preventBaseUIHandler()))}u&&(o||!h&&!p||e.preventDefault(),!o&&p&&t?.(e))},onKeyUp(e){n||(fh(e),i?.(e),e.target===e.currentTarget&&o&&c&&_h(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||o||c||" "!==e.key||t?.(e))},onPointerDown(e){n?e.preventDefault():a?.(e)}},o?void 0:{role:"button"},d,l)},[n,d,c,o]),buttonRef:th(e=>{a.current=e,u()})}}function _h(e){return Jp(e)&&"BUTTON"===e.tagName}function Sh(e,t,n,r){const i=Qp(Ch).current;return function(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}(i,e,t,n,r)&&Ih(i,[e,t,n,r]),i.callback}function Ch(){return{callback:null,cleanup:null,refs:[]}}function Ih(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=n){const r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const i=t[e];if(null!=i)switch(typeof i){case"function":{const t=i(n);"function"==typeof t&&(r[e]=t);break}case"object":i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const n=t[e];if(null!=n)switch(typeof n){case"function":{const t=r[e];"function"==typeof t?t():n(null);break}case"object":n.current=null}}}}}}var Eh=parseInt(e.version,10);function Th(t){if(!/* @__PURE__ */e.isValidElement(t))return null;const n=t,r=n.props;return(Eh>=19?r?.ref:n.ref)??null}Object.freeze([]);var Ah=Object.freeze({});function Mh(t,n,i={}){const o=n.render,s=function(e,t={}){const{className:n,style:r,render:i}=e,{state:o=Ah,ref:s,props:a,stateAttributesMapping:l,enabled:c=!0}=t,d=c?function(e,t){return"function"==typeof e?e(t):e}(n,o):void 0,u=c?function(e,t){return"function"==typeof e?e(t):e}(r,o):void 0,p=c?function(e,t){const n={};for(const r in e){const i=e[r];if(t?.hasOwnProperty(r)){const e=t[r](i);null!=e&&Object.assign(n,e);continue}!0===i?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}(o,l):Ah,h=c&&a?function(e){return Array.isArray(e)?function(e){if(0===e.length)return sh;if(1===e.length)return lh(e[0]);let t=lh(e[0]);for(let n=1;n<e.length;n+=1)t=ch(t,e[n]);return t}(e):ah(void 0,e)}(a):void 0,m=c?oh(p,h)??{}:Ah;"undefined"!=typeof document&&(c?Array.isArray(s)?m.ref=function(e){const t=Qp(Ch).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&Ih(t,e),t.callback}([m.ref,Th(i),...s]):m.ref=Sh(m.ref,Th(i),s):Sh(null,null));if(!c)return Ah;void 0!==d&&(m.className=gh(m.className,d));void 0!==u&&(m.style=oh(m.style,u));return m}(n,i);return!1===i.enabled?null:function(t,n,i,o){if(n){if("function"==typeof n)return n(i,o);const t=ah(i,n.props);t.ref=i.ref;let r=n;return r?.$$typeof===zh&&(r=e.Children.toArray(n)[0]),/* @__PURE__ */e.cloneElement(r,t)}if(t&&"string"==typeof t)return function(t,n){return"button"===t?/* @__PURE__ */r("button",{type:"button",...n,key:n.key}):"img"===t?/* @__PURE__ */r("img",{alt:"",...n,key:n.key}):/* @__PURE__ */e.createElement(t,n)}(t,i);throw new Error(vh(8))}(t,o,s,i.state??Ah)}var zh=Symbol.for("react.lazy");var Oh=/* @__PURE__ */e.forwardRef(function(e,t){const{render:n,className:r,disabled:i=!1,focusableWhenDisabled:o=!1,nativeButton:s=!0,style:a,...l}=e,{getButtonProps:c,buttonRef:d}=kh({disabled:i,focusableWhenDisabled:o,native:s});return Mh("button",e,{state:{disabled:i},ref:[t,d],props:[l,c]})}),Rh={primary:"bg-primary text-primary-foreground border-transparent hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border-transparent hover:bg-secondary/80",ghost:"bg-transparent text-foreground border-border hover:bg-muted",bare:"bg-transparent text-inherit border-transparent hover:bg-transparent p-0 min-h-0",chip:"bg-secondary-bg text-foreground border-transparent hover:bg-primary hover:text-primary-foreground hover:border-primary",tab:"bg-transparent text-foreground-muted border-transparent hover:text-foreground hover:bg-transparent p-0 min-h-0",inline:"bg-transparent text-primary border-transparent hover:bg-transparent hover:text-primary p-0 min-h-0",toolbar:"bg-transparent text-foreground border-transparent opacity-60 hover:opacity-100"},Ph={sm:"px-2 py-1 text-xs min-h-7",md:"px-4 py-2 text-sm min-h-9"},Nh={default:"rounded-lg",theme:Pp.theme,pill:Pp.pill},Lh=i(function({active:e=!1,className:t,disabled:n,elevation:r,full:i,loading:o=!1,shape:s="default",size:a="md",stacked:l=!1,type:c="button",variant:d="primary",style:u,...p},h){const m=!["bare","inline","tab","toolbar"].includes(d),g=n||o;/* @__PURE__ */
8
- return f(Oh,{...p,ref:h,className:Op("inline-flex items-center justify-center gap-2 font-medium cursor-pointer transition-all focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2",m&&"border",Nh[s],Rh[d],"bare"!==d&&"inline"!==d&&"tab"!==d&&Ph[a],l&&"flex-col gap-0.5","tab"===d&&"h-full min-w-0 flex-1",e&&"tab"===d&&"text-primary font-semibold",g&&"opacity-50 cursor-not-allowed pointer-events-none",o&&"opacity-70 cursor-wait pointer-events-none",i&&"w-full",t),"aria-busy":o?"true":void 0,"data-disabled":n?"true":"false","data-loading":o?"true":"false","data-size":a,"data-variant":d,disabled:g,style:{...jp(r),...u},type:c})}),Dh=i(function(e,t){const{className:n,direction:r,...i}=e;/* @__PURE__ */
9
- return f(Zp,{...i,ref:t,className:Op("flex","column"===r&&"flex-col",n)})}),$h={spinner:{viewBox:"0 0 512 512",paths:[{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z",fill:"currentColor"}]},checkCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z",fill:"currentColor"}]},circle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z",fill:"currentColor"}]},exclamationCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z",fill:"currentColor"}]},timesCircle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z",fill:"currentColor"}]},ban:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z",fill:"currentColor"}]},arrowUp:{viewBox:"0 0 448 512",paths:[{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z",fill:"currentColor"}]},arrowDown:{viewBox:"0 0 448 512",paths:[{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z",fill:"currentColor"}]},info:{viewBox:"0 0 24 24",paths:[{d:"M 12 2 A 10 10 0 1 1 11.9999 2 Z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 16L12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 8L12.01 8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},trash:{viewBox:"0 0 24 24",paths:[{d:"M3 6L5 6L21 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M10 11L10 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M14 11L14 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},x:{viewBox:"0 0 24 24",paths:[{d:"M18 6L6 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chatBubble:{viewBox:"0 0 512 512",paths:[{d:"M87.48 380c1.2-4.38-1.43-10.47-3.94-14.86a42.63 42.63 0 0 0-2.54-3.8 199.81 199.81 0 0 1-33-110C47.64 139.09 140.72 48 255.82 48 356.2 48 440 117.54 459.57 209.85a199 199 0 0 1 4.43 41.64c0 112.41-89.49 204.93-204.59 204.93-18.31 0-43-4.6-56.47-8.37s-26.92-8.77-30.39-10.11a31.14 31.14 0 0 0-11.13-2.07 30.7 30.7 0 0 0-12.08 2.43L81.5 462.78a15.92 15.92 0 0 1-4.66 1.22 9.61 9.61 0 0 1-9.58-9.74 15.85 15.85 0 0 1 .6-3.29z",fill:"none",stroke:"currentColor",strokeWidth:32,strokeLinecap:"round"},{d:"M160 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M256 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M352 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"}]},stop:{viewBox:"0 0 512 512",paths:[{d:"M392 432H120a40 40 0 0 1-40-40V120a40 40 0 0 1 40-40h272a40 40 0 0 1 40 40v272a40 40 0 0 1-40 40z",fill:"currentColor"}]},mousePointerClick:{viewBox:"0 0 24 24",paths:[{d:"M14 4.1 12 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m5.1 8-2.9-.8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m6 12-1.9 2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M7.2 2.2 8 5.1",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},scroll:{viewBox:"0 0 24 24",paths:[{d:"M19 17V5a2 2 0 0 0-2-2H4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},ticktick:{viewBox:"0 0 24 24",paths:[{d:"M12 0C5.383 0 0 5.383 0 12s5.383 12 12 12 12-5.383 12-12h-2.7c0 5.128-4.172 9.3-9.3 9.3-5.128 0-9.3-4.172-9.3-9.3 0-5.128 4.172-9.3 9.3-9.3V0Zm7.4 2.583-7.505 9.371L8.388 9.08l-2.002 2.436 4.741 3.888a1.573 1.573 0 0 0 2.231-.233l8.504-10.617L19.4 2.583Z",fill:"currentColor"}]},arrowRight:{viewBox:"0 0 24 24",paths:[{d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},documentText:{viewBox:"0 0 24 24",paths:[{d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},globe:{viewBox:"0 0 24 24",paths:[{d:"M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},magnifyingGlass:{viewBox:"0 0 24 24",paths:[{d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},xMark:{viewBox:"0 0 24 24",paths:[{d:"M6 18 18 6M6 6l12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},keyboard:{viewBox:"0 0 24 24",paths:[{d:"M20 7v10H4V7h16m0-2H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z",fill:"currentColor"}]},selectAll:{viewBox:"0 0 24 24",paths:[{d:"M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z",fill:"currentColor"}]},tablerArrowDown:{viewBox:"0 0 24 24",paths:[{d:"M12 5l0 14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M18 13l-6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 13l6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},fileUpload:{viewBox:"0 0 24 24",paths:[{d:"M14 3v4a1 1 0 0 0 1 1h4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 11v6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.5 13.5l2.5 -2.5l2.5 2.5",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},home:{viewBox:"0 0 24 24",paths:[{d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chat:{viewBox:"0 0 24 24",paths:[{d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},help:{viewBox:"0 0 24 24",paths:[{d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},send:{viewBox:"0 0 24 24",paths:[{d:"M5 12h14m-7-7l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},closeSmall:{viewBox:"0 0 12 12",paths:[{d:"M9 3L3 9M3 3l6 6",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},close:{viewBox:"0 0 20 20",paths:[{d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}]},chevronDown:{viewBox:"0 0 24 24",paths:[{d:"M19 9l-7 7-7-7",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round"}]},screenShare:{viewBox:"0 0 24 24",paths:[{d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},moreVertical:{viewBox:"0 0 20 20",paths:[{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z",fill:"currentColor"}]},chevronRight:{viewBox:"0 0 24 24",paths:[{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},alertCircle:{viewBox:"0 0 24 24",paths:[{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]}},jh=i(function({name:e,size:t=16,className:n,...r},i){const o=$h[e];return o?/* @__PURE__ */f("svg",{...r,ref:i,"aria-hidden":"true",className:Op("inline-block flex-shrink-0",n),fill:"none",height:t,viewBox:o.viewBox,width:t,xmlns:"http://www.w3.org/2000/svg",children:o.paths.map((e,t)=>/* @__PURE__ */f("path",{clipRule:e.clipRule,d:e.d,fill:e.fill??(e.stroke?"none":"currentColor"),fillRule:e.fillRule,stroke:e.stroke,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,strokeMiterlimit:e.strokeMiterlimit,strokeWidth:e.strokeWidth},t))}):null}),Fh={primary:"bg-primary text-primary-foreground hover:bg-primary-hover",secondary:"bg-secondary-bg text-foreground hover:bg-secondary-hover",ghost:"bg-transparent text-foreground opacity-60 hover:opacity-100",toolbar:"bg-transparent text-foreground opacity-60 hover:opacity-100"},Uh={xs:"w-5 h-5 min-w-5",sm:"w-7 h-7 min-w-7"},Bh={circle:Pp.circle,theme:Pp.theme},Gh=i(function({variant:e="ghost",size:t="sm",shape:n="circle",tone:r,label:i,disabled:o,elevation:s,className:a,children:l,style:c,...d},u){/* @__PURE__ */
10
- return f("button",{...d,ref:u,type:"button",disabled:o,"aria-label":i,className:Op("inline-flex items-center justify-center flex-shrink-0 border-none cursor-pointer transition-all",Bh[n],Fh[e],r&&Np[r],Uh[t],o&&"opacity-50 cursor-not-allowed pointer-events-none",a),style:{...jp(s),...c},children:l})}),Wh=i(function(e,t){const{background:n="default",className:r,elevation:i,paddingPreset:o="none",radius:s,style:a,...l}=e,c=Bp(e);/* @__PURE__ */
11
- return f("div",{...Gp(l),ref:t,className:Op("flex flex-col",Wp[n],Hp[o],s&&Bp({rounded:s}),c,r),style:{...jp(i),...a}})}),Hh={xxs:"text-[10px]",xs:"text-xs",sm:"text-sm",base:"text-base",lg:"text-lg"},Zh={normal:"font-normal",medium:"font-medium",semibold:"font-semibold"},Vh={center:"text-center",right:"text-right"},qh=i(function({as:e="span",block:t=!1,clamp:n,code:r=!1,inheritColor:i=!1,italic:o=!1,leading:s,tone:a,variant:l="default",size:c,weight:d,truncate:u,align:p,className:h,style:m,...g},y){/* @__PURE__ */
12
- return f(e,{...g,ref:y,className:Op(Np[i?"inherit":a??{default:"default",muted:"muted",faint:"faint"}[l]],c&&Hh[c],d&&Zh[d],p&&Vh[p],s&&Lp[s],t&&"block",r&&"font-mono",o&&"italic",u&&"truncate",h),style:n?{...m,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:n,overflow:"hidden"}:m})});function Yh(e){return"above-fab"===e?{bottom:"90px",left:"50%",transform:"translateX(-50%)"}:{bottom:"20px",left:"50%",transform:"translateX(-50%)"}}var Jh=({tone:e,title:t,body:n,onDismiss:r,onRetry:i,position:s="bottom-center"})=>{const[l,c]=p(!1),d=o(()=>{c(!0),setTimeout(r,300)},[r]);a(()=>{if("info"!==e)return;const t=setTimeout(d,8e3);return()=>clearTimeout(t)},[e,d]);const u=$p[e];/* @__PURE__ */
13
- return f(Zp,{position:"fixed",style:{zIndex:b,maxWidth:"420px",opacity:l?0:1,transition:"opacity 0.3s ease-out",animation:l?"none":"fadeIn 0.3s ease-out",...Yh(s)},children:/* @__PURE__ */g(Dh,{align:"center",gap:"md",rounded:"pill",paddingPreset:"toast",elevation:"panel",style:{backgroundColor:u.background,border:u.border},children:[
14
- /* @__PURE__ */f(Yp,{src:Vp,alt:"",size:28,rounded:"full"}),
15
- /* @__PURE__ */g(Wh,{grow:!0,minWidth:"0",children:[/* @__PURE__ */f(qh,{as:"span",block:!0,inheritColor:!0,weight:"medium",style:{fontSize:"13px",color:u.titleColor,whiteSpace:i?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),n&&/* @__PURE__ */f(qh,{as:"span",block:!0,inheritColor:!0,style:{fontSize:"12px",color:u.bodyColor,opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]}),i&&/* @__PURE__ */f(Lh,{type:"button",variant:"ghost",shape:"pill",size:"sm",onClick:()=>{i(),d()},style:{color:u.titleColor,backgroundColor:u.actionBackground,border:u.border},"aria-label":"Retry",children:"Retry"}),
16
- /* @__PURE__ */f(Gh,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},shape:"circle",size:"xs",tone:"inherit",style:{color:u.closeColor,padding:"2px"},children:/* @__PURE__ */f(jh,{name:"closeSmall",size:12})})]})})},Kh=20,Qh=(e,t,n,r,i)=>{switch(e){case"top_left":return{x:Kh,y:Kh};case"top_right":return{x:t-Kh-r,y:Kh};case"bottom_left":return{x:Kh,y:n-Kh-i};default:return{x:t-Kh-r,y:n-Kh-i}}},Xh=(e,t,n,r,i,o)=>{const s=Qh(e,n,r,i,o),a=s.x+i/2,l=s.y+o/2;let c,d;switch(t){case"top_left":c=Kh+i/2,d=Kh+o/2;break;case"top_right":c=n-Kh-i/2,d=Kh+o/2;break;case"bottom_left":c=Kh+i/2,d=r-Kh-o/2;break;default:c=n-Kh-i/2,d=r-Kh-o/2}return{dx:c-a,dy:d-l}},em="cubic-bezier(0.16, 1, 0.3, 1)";function tm({position:e,onDrag:n,isPreviewMode:r=!1,wrapperRef:i}){const[s,a]=p(!1),[l,d]=p({w:56,h:56}),[,h]=p(0),m=u(null),f=u(null),g=u(null),y=u(0),w=u([]),b=u(0);t.useEffect(()=>()=>{null!==g.current&&window.cancelAnimationFrame(g.current)},[]),t.useEffect(()=>{if(r)return;const e=()=>h(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const v=o(()=>{if(!i.current||"undefined"==typeof window)return;const e=i.current.getBoundingClientRect();d(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[i]);c(()=>{v();const e="undefined"!=typeof window&&i.current?new ResizeObserver(v):null;return e&&i.current&&e.observe(i.current),()=>e?.disconnect()},[v,e,i]);const x="undefined"!=typeof window?window.innerWidth:0,k="undefined"!=typeof window?window.innerHeight:0,_=Qh(e,x,k,l.w,l.h),S=!r&&x>0&&k>0?{left:_.x,top:_.y}:void 0,C=(e,t=.999)=>e/1e3*t/(1-t),I=()=>{null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null),i.current&&(i.current.style.transform="",i.current.style.willChange="",i.current.style.transition="")},E=o((e,t)=>{if(m.current)return;let r=!1;const o=()=>{r||(r=!0,m.current=null,t.style.transition="none",t.style.willChange="",n(e),a(!1),requestAnimationFrame(()=>{i.current&&(i.current.style.transition="")}))};m.current=o;const s=window.setTimeout(o,650);t.addEventListener("transitionend",function e(n){n.target===t&&"left"===n.propertyName&&(window.clearTimeout(s),t.removeEventListener("transitionend",e),o())})},[n,i]),T=o((t,r,o)=>{if(!i.current||!S)return I(),n(t),void a(!1);null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null);const s=i.current,c=Qh(e,x,k,l.w,l.h),d=Qh(t,x,k,l.w,l.h);s.style.transition="none",s.style.transform="none",s.style.willChange="left, top",s.style.left=`${c.x+r}px`,s.style.top=`${c.y+o}px`,requestAnimationFrame(()=>{s.style.transition=`left 600ms ${em}, top 600ms ${em}`,s.style.left=`${d.x}px`,s.style.top=`${d.y}px`}),E(t,s)},[E,n,S,e,x,k,l.w,l.h,i]);return{isDragging:s,pixelPositionStyle:S,onPointerDown:e=>{f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,dragging:!1,lastX:0,lastY:0},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{const t=f.current;if(t?.pointerId!==e.pointerId)return;const n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.dragging&&Math.hypot(n,r)>5&&(t.dragging=!0,a(!0),w.current=[],b.current=0,i.current&&(i.current.style.willChange="transform",i.current.style.transition="none")),!t.dragging)return;t.lastX=n,t.lastY=r;const o=Date.now();o-b.current>=10&&(b.current=o,w.current=[...w.current.slice(-5),{x:e.clientX,y:e.clientY,t:o}]),null===g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null;const e=f.current,t=i.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:t=>{const n=f.current;if(n?.pointerId===t.pointerId){if(n.dragging){const r=(()=>{const e=w.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),o=C(r.x),s=C(r.y),a={dx:n.lastX+o,dy:n.lastY+s};let l;if("undefined"!=typeof window&&i.current){const t=i.current.getBoundingClientRect();l=((e,t,n,r,i,o)=>{const s=["top_left","top_right","bottom_left","bottom_right"];let a=t,l=1/0;for(const c of s){const s=Xh(t,c,n,r,i,o),d=Math.hypot(e.dx-s.dx,e.dy-s.dy);d<l&&(l=d,a=c)}return a})(a,e,window.innerWidth,window.innerHeight,t.width,t.height)}else l=e;return T(l,n.lastX,n.lastY),y.current=Date.now()+600,f.current=null,void t.currentTarget.releasePointerCapture(t.pointerId)}I(),f.current=null,a(!1),t.currentTarget.releasePointerCapture(t.pointerId)}},onPointerCancel:e=>{f.current?.pointerId===e.pointerId&&(I(),f.current=null,a(!1),e.currentTarget.releasePointerCapture(e.pointerId))},suppressUntilRef:y}}var nm=({open:e,processing:t=!1,error:n=!1,taskRunning:r=!1,onClick:i,onStop:o,accentColor:s,backgroundColor:a,borderRadius:l="12px",tooltipBgColor:c,tooltipTextColor:d,zIndex:p=50,position:h,onDrag:m,isPreviewMode:y=!1})=>{const w=!e&&(t||r),b=!e&&r&&null!=o,v=n?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",x=n?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",k=Math.max(6,Math.min(22,Number.parseFloat(l)||12)),_=u(null),{isDragging:S,pixelPositionStyle:C,onPointerDown:I,onPointerMove:E,onPointerUp:T,onPointerCancel:A,suppressUntilRef:M}=tm({position:h,onDrag:m,isPreviewMode:y,wrapperRef:_}),z=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(h),O=y?"absolute":"fixed",R=y?h.includes("top")?{top:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{};/* @__PURE__ */
17
- return g(Zp,{ref:_,className:`${O} ${C?"":z} ${S?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:p,pointerEvents:e?"none":"auto",...R,...C},children:[/* @__PURE__ */g(Zp,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[w&&/* @__PURE__ */f(Zp,{className:v,"aria-hidden":!0}),b&&!S&&/* @__PURE__ */f(Lh,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(h.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop running task",children:"Stop"}),
18
- /* @__PURE__ */f(Lh,{type:"button",variant:"bare",onClick:()=>{Date.now()<M.current||i()},onDragStart:e=>e.preventDefault(),onPointerDown:I,onPointerMove:E,onPointerUp:T,onPointerCancel:A,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:S?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */f(Dh,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */g(Zp,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:l,backgroundColor:e?a:s,boxShadow:Rp.fab},children:[w&&/* @__PURE__ */f("svg",{className:x,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */f("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:k+1,ry:k+1})}),
19
- /* @__PURE__ */f(Dh,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(30deg) scale(0)":"rotate(0deg) scale(1)",opacity:e?0:1,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":e,children:/* @__PURE__ */f(Yp,{src:Vp,alt:"",className:"relative z-10 w-full h-full object-contain",draggable:!1,onDragStart:e=>e.preventDefault(),style:{borderRadius:l,border:"none",outline:"none",backgroundColor:"transparent",pointerEvents:"none",userSelect:"none"}})}),
20
- /* @__PURE__ */f(Dh,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */f(jh,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(Zp,{className:`absolute bottom-16 ${h.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:c,color:d},children:[/* @__PURE__ */f(qh,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */f(Zp,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:c}})]})]})},rm="3.3.226";function im(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function om(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function sm(e,t,n){return Math.min(Math.max(e,t),n)}function am(e,t,n,r,i){const o={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:i-n,cursor:o[e]};case"bottom-left":return{dx:t-r,dy:i-n,cursor:o[e]};case"top-right":return{dx:r-t,dy:n-i,cursor:o[e]};case"top-left":return{dx:t-r,dy:n-i,cursor:o[e]}}}var lm={count:"inline-flex items-center rounded-full bg-muted px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground",live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},cm={default:"bg-muted text-muted-foreground",muted:"bg-muted text-muted-foreground",primary:"bg-chart-1/15 text-chart-1",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning"},dm=i(function({variant:e,color:t,tone:n="default",className:r,style:i,children:o,...s},a){/* @__PURE__ */
21
- return g("span",{...s,ref:a,className:Op(lm[e],"status"===e&&cm[n],r),"data-variant":e,style:{color:t,...i},children:["live"===e&&/* @__PURE__ */g("span",{className:"relative flex h-1.5 w-1.5",children:[/* @__PURE__ */f("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */f("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),o]})}),um=i(function({background:e="card",border:t=!0,children:n,className:r,elevation:i="card",paddingPreset:o="card",radius:s="xl",style:a,...l},c){/* @__PURE__ */
22
- return f(Zp,{...l,ref:c,as:"div",background:e,border:t,className:r,elevation:i,paddingPreset:o,radius:s,style:a,children:n})});var pm=n(null);function hm(e){const t=s(pm);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function mm({children:e,defaultOpen:t,onOpenChange:n,open:r}){const{isOpen:i,setIsOpen:s}=function({defaultOpen:e=!1,onOpenChange:t,open:n}){const[r,i]=p(e),s=void 0!==n;return{isOpen:s?n:r,setIsOpen:o(e=>{s||i(e),t?.(e)},[s,t])}}({defaultOpen:t,onOpenChange:n,open:r}),a=l(),c=l(),u=l(),h=d(()=>({contentId:a,descriptionId:u,open:i,setOpen:s,titleId:c}),[a,u,i,s,c]);/* @__PURE__ */
23
- return f(pm.Provider,{value:h,children:e})}function fm({children:e,className:t,onKeyDown:n,...r}){const i=hm("DialogContent"),{variant:o="default",style:s,...l}=r;return a(()=>{if(!i.open)return;const e=e=>{"Escape"===e.key&&i.setOpen(!1)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[i]),i.open?/* @__PURE__ */f("div",{...l,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"aria-modal":"true",className:Op("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[calc(var(--layer-dialog)+1)] flex flex-col w-full max-h-[85vh] overflow-auto bg-card animate-dialog-content-in","default"===o&&"max-w-[500px] rounded-lg p-6","confirm"===o&&"max-w-sm rounded-lg p-4","info"===o&&"w-64 rounded-md border border-border p-0",t),"data-state":"open",id:i.contentId,onKeyDown:e=>{n?.(e),e.defaultPrevented||"Escape"!==e.key||i.setOpen(!1)},role:"dialog",style:{...jp("info"===o?"section":"panel"),...s},tabIndex:-1,children:e}):null}function gm({className:e,variant:t="default",...n}){const r=hm("DialogTitle");/* @__PURE__ */
24
- return f("h2",{...n,className:Op("default"===t&&"text-lg font-semibold text-card-foreground mb-2","confirm"===t&&"text-base font-semibold text-foreground mb-1","info"===t&&"text-xs font-semibold text-foreground flex-1 text-center mb-0",e),id:r.titleId})}function ym({className:e,variant:t="default",...n}){const r=hm("DialogDescription");/* @__PURE__ */
25
- return f("p",{...n,className:Op("default"===t&&"text-sm text-muted-foreground mb-4","confirm"===t&&"text-sm text-muted-foreground mb-4 leading-relaxed",e),id:r.descriptionId})}function wm({children:e,className:t,onClick:n,variant:r="default",...i}){const o=hm("DialogClose");/* @__PURE__ */
26
- return f("button",{...i,className:Op("default"===r&&"absolute top-4 right-4 flex items-center justify-center w-8 h-8 p-0 bg-transparent border-none rounded-lg text-muted-foreground cursor-pointer transition-colors hover:bg-muted","info"===r&&"static -mr-1 flex h-5 w-5 items-center justify-center rounded-full border-none bg-transparent p-0 text-muted-foreground transition-colors hover:text-foreground",t),onClick:e=>{n?.(e),e.defaultPrevented||o.setOpen(!1)},type:"button",children:e})}var bm=()=>/* @__PURE__ */f("span",{className:"block h-0.5 w-full rounded-full bg-primary"}),vm=(n(null),{sm:"px-2 py-0.5 text-[11px] gap-0.5"}),xm=i(function({active:e=!1,variant:t="primary",size:n="sm",children:r,...i},o){/* @__PURE__ */
27
- return f("button",{...i,ref:o,type:"button",className:Op("inline-flex items-center font-medium border-none cursor-pointer transition-all duration-200",Pp.pill,vm[n],e&&"primary"===t&&"bg-primary text-primary-foreground shadow-sm",!e&&"bg-secondary-bg text-foreground-muted"),children:r})}),km={sm:"h-3.5 w-3.5 border-[1.5px]",md:"h-5 w-5 border-2",lg:"h-6 w-6 border-2"},_m=i(function({label:e,size:t="md",className:n,style:r},i){/* @__PURE__ */
28
- return g("div",{ref:i,className:Op("inline-flex items-center gap-1.5",n),"data-size":t,role:"status",style:r,children:[
29
- /* @__PURE__ */f("div",{"aria-hidden":"true",className:Op("animate-spin rounded-full border-current border-t-transparent flex-shrink-0",km[t])}),null!=e&&/* @__PURE__ */f("span",{children:e}),
30
- /* @__PURE__ */f("span",{className:"sr-only",children:"Loading"})]})}),Sm={default:"block w-full px-3 py-2 text-sm leading-normal text-foreground bg-background border border-input rounded-lg transition-colors min-h-20 resize-y hover:border-muted-foreground focus:outline-none focus:border-ring focus:ring-3 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-muted",chat:"block w-full px-3 text-sm text-foreground placeholder:text-foreground-faint bg-transparent border-none rounded-none transition-colors min-h-0 resize-none focus:outline-none focus:ring-0 disabled:opacity-50 disabled:cursor-not-allowed"},Cm=i(function({className:e,errorMessage:t,id:n,validationState:r="default",variant:i="default",...o},s){const a="invalid"===r&&t?`${n??o["aria-label"]??"textarea"}-error`:void 0;/* @__PURE__ */
31
- return g(m,{children:[/* @__PURE__ */f("textarea",{...o,"aria-describedby":a,"aria-invalid":"invalid"===r?"true":void 0,className:Op(Sm[i],e),"data-validation-state":r,id:n,ref:s}),null!=a&&/* @__PURE__ */f("span",{id:a,children:t})]})}),Im=i(function({className:e,...t},n){/* @__PURE__ */
32
- return f("video",{...t,ref:n,className:Op(e)})}),Em=({title:e,subtitle:t,minimized:n=!1,onClose:r,controls:i})=>/* @__PURE__ */g(Dh,n?{align:"center",justify:"between",paddingX:"lg",border:"bottom",shrink:!1,style:Dp.header,children:[/* @__PURE__ */f(qh,{size:"sm",weight:"medium",children:e}),/* @__PURE__ */f(Gh,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */f(jh,{name:"close",size:16})})]}:{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */g(Dh,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */f(Yp,{src:Vp,alt:"",size:"md",rounded:"theme",elevation:"card"}),/* @__PURE__ */g(Wh,{minWidth:"0",children:[/* @__PURE__ */f(qh,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */f(qh,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */g(Dh,{align:"center",gap:"xs",shrink:!1,children:[i,/* @__PURE__ */f(Gh,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */f(jh,{name:"close",size:16})})]})]}),Tm={green:"success",blue:"primary",yellow:"warning",gray:"muted"},Am=({variant:e,open:t,onClose:n,title:r,description:i,onConfirm:o,confirmLabel:s="Confirm",cancelLabel:a="Cancel",rows:l=[],status:c})=>/* @__PURE__ */f(mm,{open:t,onOpenChange:e=>{e||n()},children:/* @__PURE__ */g(fm,"confirm"===e?{variant:"confirm",children:[
33
- /* @__PURE__ */f(gm,{variant:"confirm",children:r}),null!=i&&/* @__PURE__ */f(ym,{variant:"confirm",children:i}),
34
- /* @__PURE__ */g(Dh,{gap:"md",justify:"end",children:[/* @__PURE__ */f(Lh,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:a}),/* @__PURE__ */f(Lh,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:s})]})]}:{variant:"info",children:[/* @__PURE__ */g(Dh,{align:"center",justify:"between",paddingX:"lg",paddingY:"sm",border:"bottom",children:[/* @__PURE__ */f(gm,{variant:"info",children:r}),/* @__PURE__ */f(wm,{variant:"info","aria-label":"Close",children:/* @__PURE__ */f(jh,{name:"x",size:12})})]}),/* @__PURE__ */g(Wh,{paddingX:"lg",paddingY:"sm",children:[l.map(e=>/* @__PURE__ */g(Dh,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */f(qh,{as:"span",size:"xs",variant:"muted",children:e.label}),/* @__PURE__ */g(Dh,{align:"center",gap:"2xs",children:[/* @__PURE__ */f(qh,{as:"code",code:!0,size:"xs",variant:"muted",truncate:!0,style:{maxWidth:"120px"},children:e.value||"N/A"}),!0===e.copyable&&e.value&&/* @__PURE__ */f(Lh,{type:"button",variant:"inline",size:"sm",onClick:()=>{return t=e.value,void navigator.clipboard.writeText(t);var t},children:"Copy"})]})]},e.label)),null!=c&&/* @__PURE__ */g(Dh,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */f(qh,{as:"span",size:"xs",variant:"muted",children:"Status"}),/* @__PURE__ */f(dm,{variant:"status",tone:Tm[c.color],children:c.label})]})]})]})});function Mm(e){return"registered"===e?"green":"connected"===e?"blue":"connecting"===e?"yellow":"gray"}var zm=({isOpen:e,onClose:t,diagnosticData:n})=>{const r=[{label:"Chat ID",value:n.chatId??"N/A",copyable:!!n.chatId},{label:"Stream Endpoint",value:n.streamEndpoint??"N/A",copyable:!!n.streamEndpoint},{label:"Application ID",value:n.applicationId?.toString()??"N/A",copyable:!!n.applicationId},{label:"Agent ID",value:n.agentId?.toString()??"N/A",copyable:!!n.agentId}],i={label:n.connectionStatus,color:Mm(n.connectionStatus)},o="dev"===n.build?"dev":n.build.slice(0,7);/* @__PURE__ */
35
- return f(Am,{variant:"info",open:e,onClose:t,title:`Widget v${n.version} (${o})`,rows:r,status:i})};function Om({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:n,onAddMessage:r,onUpdateMessage:i,onRemoveMessage:o,onSendMessage:s,pendingMessage:l,setPendingMessage:c}){const[d,h]=p(!1),[m,f]=p(null),[g,y]=p(null),[w,b]=p(null),[v,x]=p(!1),k=u(d),_=u(g),S=u(r),C=u(o),I=u(e);a(()=>{k.current=d},[d]),a(()=>{_.current=g},[g]),a(()=>{S.current=r},[r]),a(()=>{C.current=o},[o]),a(()=>{I.current=e},[e]),a(()=>{const e=()=>{const e=ru(),t=k.current,n=_.current;if(e!==t&&(k.current=e,h(e),I.current?.(e)),t&&!e&&n){C.current?.(n);const e=Bd("Stopped screenshare","show","user","stopped-sharing");S.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const E=()=>{x(!0)},T=()=>{tu&&(tu.getTracks().forEach(e=>e.stop()),tu=null),h(!1),f(null),e?.(!1),g&&o&&o(g),r(Bd("Stopped screenshare","show","user","stopped-sharing")),y(null)};return a(()=>(t&&(t.current=E),n&&(n.current=T),()=>{t&&(t.current=null),n&&(n.current=null)})),{isScreenSharing:d,screenStream:m,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await nu();h(!0),f(t),e?.(!0),r(Gd("show"));const n=Wd(t,"show");y(n.id),r(n)}catch(t){h(!1),f(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await nu();h(!0),f(t),e?.(!0),w&&(i(w,{screenShareStatus:"allowed"}),b(null)),r(Gd("show"));const n=Wd(t,"show");if(y(n.id),r(n),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(h(!1),f(null),e?.(!1),w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(w)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);b(t.id),r(t)}}}function Rm(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var Pm=t.forwardRef(function({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:i,onModeChange:s,disabled:l=!1,taskRunning:c=!1,onStop:d,placeholder:p="Ask anything"},h){const m=u(null);a(()=>{const e=m.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,66);e.style.height=`${n}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=o(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,66);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>66?"auto":"hidden"},[t]),w=o(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),b=Boolean(e.trim())&&!l;/* @__PURE__ */
36
- return g(Wh,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"focus-within:border-foreground-faint transition-colors",children:[/* @__PURE__ */f(Cm,{ref:Rm(m,h),value:e,onChange:y,onKeyDown:w,placeholder:p,disabled:l,rows:1,variant:"chat",style:{lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */g(Dh,{align:"center",justify:"between",paddingX:"sm",paddingTop:"2xs",paddingBottom:"sm",children:[/* @__PURE__ */f(Dh,{align:"center",gap:"2xs",children:r.map(e=>/* @__PURE__ */g(xm,{active:i===e.id,size:"sm",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */f(jh,{name:e.icon,size:12}),/* @__PURE__ */f(qh,{as:"span",inheritColor:!0,children:e.label})]},e.id))}),/* @__PURE__ */f(Gh,{variant:c?"secondary":"primary",size:"sm",disabled:!c&&!b,label:c?"Stop task":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),c&&d?d():n()},children:/* @__PURE__ */f(jh,c?{name:"stop",size:14}:{name:"send",size:16})})]})]})}),Nm=({variant:e,message:t})=>{const n="error"===e,r="loading"===e;/* @__PURE__ */
37
- return g(Wh,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:r?"status":void 0,"aria-live":n?"assertive":"polite",style:n?{color:"var(--color-red-600, #dc2626)"}:void 0,children:[r&&/* @__PURE__ */f(_m,{size:"lg"}),/* @__PURE__ */f(qh,{as:"p",size:"sm",align:"center",children:t})]})},Lm=({content:e,status:t,hideIcon:n=!1,textStyle:r="default"})=>{const{config:i}=uu(),o=i.widget_accent_color;/* @__PURE__ */
38
- return g(Dh,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return f(jh,{name:"checkCircle",style:{color:o,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return f(jh,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"stopped":/* @__PURE__ */return f(jh,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});default:/* @__PURE__ */return f(_m,{size:"sm",style:{color:o,marginTop:"2px"}})}})(),/* @__PURE__ */f(qh,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===r?.5:1},children:e})]})},Dm=({isWaitingForUser:e})=>/* @__PURE__ */g(Dh,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */f(_m,{size:"sm"}),/* @__PURE__ */f(qh,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),$m=({message:e,isLastMessage:t})=>{const{state:n}=uu(),r="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */g(Wh,{gap:"sm",children:[e.parts.map((t,n)=>{if("text"===t.type){let e=(r=t.content,r.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */f(qh,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${n}`):null}return"progress"===t.type?"done"===t.toolName&&"done"===e.taskStatus?null:/* @__PURE__ */f(Lm,{content:t.content,status:t.status||"in_progress",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */f(Dm,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */f(Dm,{isWaitingForUser:r}):e.content?/* @__PURE__ */f(qh,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */f(Zp,{})},jm=({status:e})=>{const{config:t}=uu(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return f(jh,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return f(jh,{name:"exclamationCircle",style:{color:k(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return f(jh,{name:"circle",style:{color:k(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return f(_m,{size:"sm",style:{color:n}})}},Fm="8px 8px 0 0",Um="#111827",Bm="rgba(255,255,255,0.7)",Gm=({stream:e})=>{const t=u(null),n=u(null),[r,i]=p(!1),[o,s]=p(!1);return a(()=>{if(t.current&&e){const r=t.current;i(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const o=()=>{i(!0)},a=()=>{s(!0),i(!1)};r.addEventListener("loadedmetadata",o),r.addEventListener("error",a);const l=r.play();return n.current=l,l.then(()=>{i(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",o),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),i(!1),s(!1)}},[e]),e?/* @__PURE__ */g(Zp,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:Fm,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!r&&!o&&/* @__PURE__ */f(Dh,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Um,borderRadius:Fm,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(Dh,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */f(_m,{size:"lg",style:{color:"white"}}),/* @__PURE__ */f(qh,{as:"span",size:"xs",weight:"medium",style:{color:Bm},children:"Loading stream..."})]})}),o&&/* @__PURE__ */f(Dh,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Um,borderRadius:Fm,zIndex:10},children:/* @__PURE__ */g(Dh,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */f(jh,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */f(qh,{as:"span",size:"xs",weight:"medium",style:{color:Bm},children:"Failed to load stream"})]})}),
39
- /* @__PURE__ */f(Im,{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:Fm,transition:"opacity 500ms",opacity:r?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),r&&!o&&/* @__PURE__ */g(Dh,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */g(Dh,{position:"relative",align:"center",justify:"center",children:[/* @__PURE__ */f(Zp,{position:"absolute",rounded:"full",animate:"ping",style:{width:"8px",height:"8px",backgroundColor:"white",opacity:.75}}),/* @__PURE__ */f(Zp,{position:"relative",rounded:"full",style:{width:"6px",height:"6px",backgroundColor:"white"}})]}),/* @__PURE__ */f(qh,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
40
- /* @__PURE__ */f(Dh,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:Fm,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */f(Zp,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */f(qh,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]}):null},Wm=({message:e,index:t,isLastMessage:n,onScreenAccessAllow:r,onScreenAccessDeny:i})=>{if(e.isSystemMessage)/* @__PURE__ */return f(Dh,{justify:"center",align:"center",children:/* @__PURE__ */f(qh,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})},`message-${e.id}-${t}`);const o="user"===e.sender;/* @__PURE__ */
41
- return g(Wh,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":o?"You said…":"Agent says…",animate:n?"fadeIn":void 0,children:[/* @__PURE__ */g(Dh,{align:"start",gap:"sm",width:"full",children:[
42
- /* @__PURE__ */f(Dh,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!o&&/* @__PURE__ */f(Yp,{src:"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",alt:"Marketrix AI",size:20,fit:"cover",rounded:"theme",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
43
- /* @__PURE__ */g(Wh,{grow:!0,position:"relative",rounded:"theme",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:o?"var(--primary)":void 0,color:o?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */f(Gm,{stream:e.videoStream}),!e.videoStream&&/* @__PURE__ */f($m,{message:e,isLastMessage:n}),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */g(Dh,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */f(Lh,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */f(Lh,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>i?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */f(qh,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"Check HTML Instead"}),!o&&e.taskStatus&&/* @__PURE__ */f(Dh,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */f(jm,{status:e.taskStatus})})]}),
44
- /* @__PURE__ */f(Dh,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */f(qh,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:S(e.timestamp)})]},`message-${e.id}-${t}`)},Hm={boxShadow:Rp.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Zm=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:i,onClearChat:o})=>{const{config:s,state:l,isPreviewMode:c}=uu({config:n}),[h,m]=p(!1),[y,w]=p(!1),b=u(null),v=d(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=d(()=>[v,...e],[v,e]),_=()=>{if(b.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=b.current;m(e>200),w(!(Math.abs(t-e-n)<50)&&t>n)}};return a(()=>{window.requestAnimationFrame(()=>{t.current&&(!c&&t.current.scrollIntoView({behavior:"auto"}),!c&&_())})},[e.length,c]),/* @__PURE__ */g(Zp,{position:"relative",height:"full",children:[
45
- /* @__PURE__ */g(Zp,{ref:b,onScroll:_,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:s.widget_background_color.includes("gradient")?"transparent":s.widget_background_color,backgroundImage:s.widget_background_color.includes("gradient")?s.widget_background_color:`linear-gradient(135deg, ${s.widget_background_color} 0%, ${s.widget_background_color} 100%)`,scrollbarColor:`${k(s.widget_border_color,.3)} ${k(s.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&l.isLoading&&/* @__PURE__ */f(Nm,{variant:"loading",message:"Connecting…"}),x.map((e,t)=>/* @__PURE__ */f(Wm,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:r,onScreenAccessDeny:i},`message-${e.id}-${t}`)),e.length>0&&o&&/* @__PURE__ */f(Dh,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */f(Lh,{type:"button",variant:"bare",onClick:()=>{const e=o();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */f(qh,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
46
- /* @__PURE__ */f(Zp,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */f(Dh,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(Gh,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{b.current?.scrollTo({top:0,behavior:"smooth"})},style:Hm,children:/* @__PURE__ */f(jh,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */f(Dh,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(Gh,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!c&&t.current.scrollIntoView({behavior:"smooth"})},style:Hm,children:/* @__PURE__ */f(jh,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},Vm=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */f(qh,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},qm={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Ym=["tell","show","do"];var Jm=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,taskProgress:i=[],onSendMessage:o,onSetMode:s,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onStopTask:d,onClearChat:h,onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,messageInputRef:b})=>{const[v,x]=p(""),_=u(null),[S,I]=p(null),{isScreenSharing:E,showScreenAccessDialog:T,handleScreenAccessDialogAllow:A,handleScreenAccessDialogDeny:M,handleScreenAccessAllow:z,handleScreenAccessDeny:O,requestScreenAccess:R}=Om({onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onSendMessage:o,pendingMessage:S,setPendingMessage:I}),P=e;/* @__PURE__ */
47
- return g(Wh,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[T&&/* @__PURE__ */f(Am,{variant:"confirm",open:T,onClose:M,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:A,confirmLabel:"Yes",cancelLabel:"No"}),
48
- /* @__PURE__ */f(Zp,{grow:!0,overflow:"hidden",paddingY:"xs",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */f(Vm,{children:/* @__PURE__ */f(Zm,{messages:t,messagesEndRef:_,config:e,onScreenAccessAllow:z,onScreenAccessDeny:O,onClearChat:h})})}),
49
- /* @__PURE__ */g(um,{style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:[r&&i.length>0&&/* @__PURE__ */g(Zp,{rounded:!0,overflowY:"auto",style:{margin:"0 8px 8px",padding:"8px",maxHeight:"128px",backgroundColor:k(e.widget_background_color??"#fff",.8),borderColor:e.widget_border_color,borderWidth:"1px",borderStyle:"solid"},children:[/* @__PURE__ */g(qh,{as:"div",weight:"semibold",style:{marginBottom:"4px",color:e.widget_text_color},children:["Task Progress (",i.length," steps)"]}),/* @__PURE__ */f(Wh,{gap:"xs",children:i.map((t,n)=>/* @__PURE__ */g(Dh,{align:"start",gap:"sm",style:{fontSize:"12px",opacity:.8,color:e.widget_text_color},children:[
50
- /* @__PURE__ */g(qh,{as:"span",weight:"medium",children:["Step ",t.step,":"]})," ",t.tool_name,t.tool_params&&Object.keys(t.tool_params).length>0&&/* @__PURE__ */g(qh,{as:"span",style:{opacity:.7,marginLeft:"4px"},children:["(",Object.keys(t.tool_params).join(", "),")"]})]},n))})]}),/* @__PURE__ */f(Pm,{ref:b,value:v,onChange:x,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(v.trim()&&!r){const t=v.trim();x(""),a(Fd(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||E?o(t,n,void 0,void 0,!0):(I({content:t,mode:n,alreadyAdded:!0}),R(n))}},modes:Ym.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(P).includes(e)).map(e=>({id:e,icon:qm[e],label:C(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(a(Bd(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),s(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{iu.cleanup(),d?.()}})]})]})},Km=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */f(jh,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */f(jh,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */f(jh,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */f(jh,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */f(jh,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Qm(e){switch(e){case"do":/* @__PURE__ */return f(jh,{name:"ticktick",size:12});case"show":/* @__PURE__ */return f(jh,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return f(jh,{name:"chatBubble",size:12})}}var Xm=({actions:e,onActionClick:t})=>{const{config:n}=uu();return 0===e.length?null:/* @__PURE__ */f(Wh,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */f(Lh,{elevation:"card",shape:"theme",size:"sm",variant:"chip",full:!0,onClick:n=>t(e,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */f(qh,{as:"span",weight:"normal",leading:"tight",children:"show"===e.type?/* @__PURE__ */g(m,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(m,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},ef=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const i=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text,i=t.chip_mode,o=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let s=o,a=0;for(;e.has(s);)a++,s=`${o}-${a}`;return e.add(s),{id:s,text:r,icon:Qm(i),type:i,isShow:"show"===i}})}return Km}(e);/* @__PURE__ */
51
- return g(Wh,{height:"full",overflow:"hidden",id:"view-home",role:"tabpanel","aria-labelledby":"tab-home",children:[/* @__PURE__ */g(Wh,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */g(Zp,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */f(qh,{as:"h2",size:"lg",weight:"semibold",children:e.widget_greeting??"Hey There!"}),/* @__PURE__ */f(qh,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:e.widget_body??"How can I help you today?"})]}),/* @__PURE__ */g(Wh,{gap:"sm",children:[/* @__PURE__ */g(Lh,{type:"button",variant:"primary",full:!0,onClick:n,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */f(jh,{name:"chat",size:16}),"Ask a question"]}),/* @__PURE__ */f(Xm,{actions:i,onActionClick:async(e,t)=>{t.preventDefault(),t.stopPropagation(),n(),r(e)}})]})]}),t.length>0&&/* @__PURE__ */g(um,{style:{margin:"0 12px 12px 12px"},children:[
52
- /* @__PURE__ */f(qh,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
53
- /* @__PURE__ */f(qh,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t[t.length-1].content||"Message"}),
54
- /* @__PURE__ */f(qh,{as:"p",size:"xs",variant:"muted",onClick:n,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},tf=["top-left","top-right","bottom-left","bottom-right"];function nf(e){const t=e.startsWith("top"),n=e.endsWith("left");return{position:"absolute",width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:t?"flex-start":"flex-end",justifyContent:n?"flex-start":"flex-end",cursor:t&&n||!t&&!n?"nwse-resize":"nesw-resize",top:t?0:void 0,bottom:t?void 0:0,left:n?0:void 0,right:n?void 0:0}}var rf,of=({onResizeStart:e})=>/* @__PURE__ */f(m,{children:tf.map(t=>/* @__PURE__ */f("div",{role:"separator","aria-label":`Resize widget from ${t.replace("-"," ")}`,title:"Drag to resize",style:nf(t),onMouseDown:e(t)},t))}),sf=({tabs:e,active:t,onChange:n})=>/* @__PURE__ */f(Dh,{role:"tablist",align:"center",justify:"around",shrink:!1,border:"top",style:Dp.tabBar,children:e.map(e=>{const r=t===e.id;/* @__PURE__ */
55
- return g(Lh,{role:"tab","aria-selected":r,"aria-controls":`view-${e.id}`,id:`tab-${e.id}`,onClick:()=>n(e.id),active:r,stacked:!0,variant:"tab",children:[r&&/* @__PURE__ */f(qh,{as:"span",inheritColor:!0,style:{position:"absolute",top:0,left:"25%",right:"25%"},children:/* @__PURE__ */f(bm,{variant:"bar",color:"accent"})}),
56
- /* @__PURE__ */f(qh,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */f(jh,{name:e.icon,size:20})}),
57
- /* @__PURE__ */f(qh,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id)})}),af=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"},{id:"help",icon:"help",label:"Help"}],lf=({activeView:e,onChange:t})=>/* @__PURE__ */f(sf,{tabs:af,active:e,onChange:e=>t(e)}),cf=({children:e,direction:t})=>/* @__PURE__ */f(Zp,{"data-view-transition":!0,"data-direction":t,style:{width:"100%",height:"100%"},children:e}),df=({config:e,isOpen:t,isMinimized:n,messages:r,currentMode:i,isTaskRunning:s=!1,taskProgress:l=[],activeView:c,onClose:h,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:S,setActiveView:C})=>{const{config:I,isPreviewMode:E}=uu({config:e}),T=d(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:A,heightPx:M,onResizeStart:z,containerRef:O}=function(e,t,n,r,i){const s=d(()=>`marketrix_widget_size_${n}`,[n]),a=u({width:360,height:450}),l=u(null),[c,h]=p(()=>{if("undefined"==typeof localStorage)return{width:om(e),height:om(t)};const n=localStorage.getItem(s);if(n)try{const e=JSON.parse(n);if("number"==typeof e.width&&"number"==typeof e.height){const t=sm(e.width,280,600),n=sm(e.height,320,Math.floor(.85*window.innerHeight));return a.current={width:t,height:n},{width:t,height:n}}}catch{}const r=om(e),i=om(t);return a.current={width:r,height:i},{width:r,height:i}});a.current=c;const m=o(e=>t=>{if(t.preventDefault(),t.stopPropagation(),r||i)return;const n=t.clientX,o=t.clientY,c=a.current.width,d=a.current.height,{cursor:u}=am(e,n,o,n,o);l.current&&(l.current.dataset.resizing="true");const p=t=>{const{dx:r,dy:i}=am(e,n,o,t.clientX,t.clientY),s=Math.floor(.85*window.innerHeight),u={width:sm(c+r,280,600),height:sm(d+i,320,s)};a.current=u,l.current&&(l.current.style.width=`${u.width}px`,l.current.style.height=`${u.height}px`)},m=()=>{if(document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",l.current&&delete l.current.dataset.resizing,h({...a.current}),!i&&"undefined"!=typeof localStorage){const{width:e,height:t}=a.current;localStorage.setItem(s,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[r,i,s]);return{width:c.width,height:c.height,widthPx:`${c.width}px`,heightPx:`${c.height}px`,onResizeStart:m,containerRef:l}}(I.widget_width,I.widget_height,T,n,E),R=u(null),[P,N]=p("forward"),L=u(c);a(()=>{L.current!==c&&(N("chat"===c?"forward":"back"),L.current=c)},[c]),function(e,t,n){const r=u(!1),i=u(null),s=o(()=>{const t=e.current;if(!t)return;const r=n?.focusTargetRef?.current;if(r)return void r.focus({preventScroll:!0});const i=im(t);i[0]&&i[0].focus({preventScroll:!0})},[e,n?.focusTargetRef]);a(()=>{if(!t)return r.current&&(i.current?.focus({preventScroll:!0}),i.current=null),void(r.current=!1);r.current||(i.current=document.activeElement||null),r.current=!0;const o=e.current;if(!o)return;s();const a=e=>{if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const t=im(o);if(0===t.length)return;const r=document.activeElement,i=t.indexOf(r);-1!==i&&(e.shiftKey?0===i&&(e.preventDefault(),t[t.length-1].focus()):i===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t,e,s,n?.onEscape])}(O,t,{onEscape:h,focusTargetRef:"chat"===c?R:void 0});const D=I.widget_position,$=I.widget_position_z_index??40,j=(e=>{const t="20px",n="20px";switch(e){case"bottom_right":default:return{bottom:t,right:n};case"bottom_left":return{bottom:t,left:n};case"top_right":return{top:t,right:n};case"top_left":return{top:t,left:n}}})(D),[F,U]=p(!1),[B,G]=p(!1),W=u(null),H=u(null),Z=o(e=>{G(e),S?.(e)},[S]);if(!t)return null;const V=I.widget_background_color.includes("gradient")?I.widget_background_color:`linear-gradient(135deg, ${I.widget_background_color} 0%, ${I.widget_background_color} 100%)`,q={width:A,height:n?"48px":M,fontSize:I.widget_font_size,backgroundImage:V,zIndex:$},Y=E?"absolute":"fixed",J=E?D.includes("top")?{top:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{},K=`${D.includes("top")?"top":"bottom"} ${D.includes("right")?"right":"left"}`,Q="chat"===c&&!1!==e.use_screenshare?()=>{B?H.current?.():W.current?.()}:void 0;/* @__PURE__ */
58
- return g(Wh,{ref:O,position:Y,rounded:"theme",border:!0,overflow:"hidden",style:{zIndex:$,backgroundImage:V,transformOrigin:K,...q,...E?J:j,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:Rp.panel},children:[
59
- /* @__PURE__ */f(Em,{title:e.agent_name??"AI Agent",subtitle:n?void 0:e.agent_description??"How can I help?",minimized:n,onClose:h,controls:Q&&/* @__PURE__ */g(Gh,{variant:"ghost",size:"sm",label:B?"Stop screen sharing":"Start screen sharing",onClick:Q,children:[B&&/* @__PURE__ */f(dm,{variant:"live",style:{position:"absolute",top:"2px",right:"2px"}}),/* @__PURE__ */f(jh,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */g(m,{children:[/* @__PURE__ */f(Zp,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(cf,{direction:P,children:["home"===c&&/* @__PURE__ */f(ef,{config:e,messages:r,onNavigateToChat:()=>{N("forward"),C("chat")},onChipClick:e=>{b(Fd(e.text,e.type,"chip-message")),w(e.type),y(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */f(Jm,{config:e,messages:r,currentMode:i,isTaskRunning:s,taskProgress:l,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:Z,onStartScreenShareRef:W,onStopScreenShareRef:H,messageInputRef:R}),"help"===c&&/* @__PURE__ */g(Wh,{id:"view-help",role:"tabpanel","aria-labelledby":"tab-help",height:"full",padding:"lg",children:[/* @__PURE__ */g(Wh,{grow:!0,align:"center",justify:"center",gap:"sm",children:[/* @__PURE__ */f(qh,{as:"span",variant:"faint",children:/* @__PURE__ */f(jh,{name:"help",size:32})}),/* @__PURE__ */f(qh,{size:"sm",variant:"muted",children:"Help – coming soon"})]}),/* @__PURE__ */g(um,{style:{margin:"0 12px 12px 12px"},children:[/* @__PURE__ */g(qh,{size:"xs",variant:"faint",style:{display:"block"},children:["Widget v",rm]}),/* @__PURE__ */g(qh,{size:"xs",variant:"faint",style:{display:"block"},children:["API"," ",(()=>{try{return"connected"===Vd.getInstance().getStatus()?"connected":"disconnected"}catch{return"—"}})()]})]})]}),"news"===c&&/* @__PURE__ */g(Wh,{id:"view-news",role:"tabpanel","aria-labelledby":"tab-news",height:"full",align:"center",justify:"center",gap:"sm",padding:"lg",children:[/* @__PURE__ */f(qh,{as:"span",variant:"faint",children:/* @__PURE__ */f(jh,{name:"info",size:32})}),/* @__PURE__ */f(qh,{size:"sm",variant:"muted",children:"News – coming soon"})]})]},c)}),/* @__PURE__ */f(lf,{activeView:c,onChange:C})]}),!n&&!E&&/* @__PURE__ */f(of,{onResizeStart:z}),
60
- /* @__PURE__ */f(zm,{isOpen:F,onClose:()=>U(!1),diagnosticData:{chatId:Zd.getChatId(),streamEndpoint:(()=>{const t=Yd.getConfig()?.mtxApiHost||e.mtxApiHost;return t?`${t.replace(/\/$/,"")}/widget/stream`:null})(),connectionStatus:(()=>{try{return Vd.getInstance().getStatus()}catch{return"disconnected"}})(),applicationId:Yd.getConfig()?.mtxApp,agentId:Yd.getConfig()?.mtxAgent,version:rm,build:"dev"}})]})},uf=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},pf=({config:e})=>{const[t,n]=p(!1),{state:r,actions:i,config:o,shouldShow:s,isPreviewMode:l,configValid:c}=uu({config:e});var u;u=r.isOpen,a(()=>{if(!u)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[u]);const[h,m]=p(e.widget_position??"bottom_right"),b=d(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);a(()=>{m(o.widget_position??"bottom_right")},[o.widget_position]),a(()=>{if(l||"undefined"==typeof localStorage)return;const e=o.widget_position??"bottom_right",t=localStorage.getItem(b);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(b,e),m(e)):m(t)},[l,b,o.widget_position]),a(()=>{if(r.isOpen||l||"default"!==o.widget_appearance)return void n(!1);const e=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(e)},[r.isOpen,l,o.widget_appearance]);if(!c)return null;if(!(l?e.widget_enabled??o.widget_enabled:s&&o.widget_enabled&&!1!==e.show_widget))return null;const v=(S=function(e={}){return E({...I,widget_background_color:e.widget_background_color??I.widget_background_color,widget_text_color:e.widget_text_color??I.widget_text_color,widget_border_color:e.widget_border_color??I.widget_border_color,widget_accent_color:e.widget_accent_color??I.widget_accent_color,widget_secondary_color:e.widget_secondary_color??I.widget_secondary_color,widget_border_radius:e.widget_border_radius??I.widget_border_radius,widget_font_size:e.widget_font_size??I.widget_font_size,widget_width:e.widget_width??I.widget_width,widget_height:e.widget_height??I.widget_height,widget_shadow:e.widget_shadow??I.widget_shadow,widget_animation_duration:e.widget_animation_duration??I.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??I.widget_fade_duration})}(o),{"--background":S.color.background,"--foreground":S.color.foreground,"--card":S.color.background,"--card-foreground":S.color.foreground,"--popover":S.color.background,"--popover-foreground":S.color.foreground,"--primary":S.color.primary,"--foreground-muted":S.color.foregroundMuted,"--foreground-faint":S.color.foregroundFaint,"--border-muted":S.color.borderMuted,"--primary-foreground":S.color.primaryForeground,"--primary-hover":S.color.primaryHover,"--primary-muted":S.color.primaryMuted,"--secondary":S.color.secondary,"--secondary-foreground":S.color.secondaryForeground,"--secondary-bg":S.color.secondaryBg,"--secondary-hover":S.color.secondaryHover,"--muted":S.color.border,"--muted-foreground":S.color.secondary,"--accent":S.color.background,"--accent-foreground":S.color.foreground,"--border":S.color.border,"--input":S.color.border,"--ring":S.color.primary,"--radius":S.radius,"--shadow":S.shadow,"--duration-animation":S.motion.durationAnimation,"--duration-fade":S.motion.durationFade,"--widget-width":S.size.widgetWidth,"--widget-height":S.size.widgetHeight});var S;const C=Math.max(o.widget_position_z_index??0,y),T={...o,widget_position:h,widget_position_z_index:C,show_widget:e.show_widget,use_screenshare:e.use_screenshare},A=r.isLoading||r.isTaskRunning;/* @__PURE__ */
61
- return g(Zp,{"data-marketrix-widget":!0,position:"relative",style:{...v,"--widget-z-index":C,...l&&{width:"100%",height:"100%"}},"data-widget-mode":o?.widget_feature_human?"hybrid":"ai",children:[A&&/* @__PURE__ */f(Zp,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${k(o.widget_accent_color,.72)}, inset 0 0 46px 10px ${k(o.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
62
- /* @__PURE__ */f(uf,{children:/* @__PURE__ */f(df,{config:T,isOpen:r.isOpen,isMinimized:r.isMinimized,messages:r.messages,currentMode:r.currentMode,isTaskRunning:r.isTaskRunning,taskProgress:r.taskProgress,activeView:r.activeView,onClose:i.closeWidget,onSendMessage:i.sendMessage,onSetMode:i.setMode,onAddMessage:i.addMessage,onUpdateMessage:i.updateMessage,onRemoveMessage:i.removeMessage,onStopTask:i.stopTask,onClearChat:i.clearChatHistory,setActiveView:i.setActiveView})}),
63
- /* @__PURE__ */f(nm,{open:r.isOpen,processing:r.isLoading,error:!!r.error,taskRunning:r.isTaskRunning,onClick:i.toggleWidget,onStop:i.stopTask,accentColor:T.widget_accent_color,backgroundColor:T.widget_background_color,borderRadius:T.widget_border_radius,tooltipBgColor:_(T.widget_accent_color,.3),tooltipTextColor:x(_(T.widget_accent_color,.3)),zIndex:T.widget_position_z_index??50,position:h,onDrag:e=>{m(e),l||"undefined"==typeof localStorage||localStorage.setItem(b,e)},isPreviewMode:l}),r.error&&/* @__PURE__ */f(Jh,{tone:"error",title:r.error,onDismiss:()=>i.clearError(),onRetry:()=>i.clearError(),position:h.includes("top")?"bottom-center":"above-fab"}),t&&!r.error&&o.widget_greeting&&/* @__PURE__ */f(Jh,{tone:"info",title:o.widget_greeting,body:o.widget_body,onDismiss:()=>n(!1),position:"bottom-center"})]})},hf=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=du(),{_setMessages:i}=(()=>{const e=s(Kd);if(!e)throw new Error("useChatContextInternal must be used within ChatProvider");return e})(),o=u(null);return a(()=>{if(t)return;(async()=>{const e=await Zd.getOrCreateChatId();jd.createInitialContext(e),jd.getInitError()&&r.setError("Widget failed to initialise — please refresh the page."),jd.initialize(e);const t=jd.getIsTaskRunning(),n=jd.getActiveTaskId();if(r.applyState({isLoading:jd.getIsLoading(),currentMode:jd.getCurrentMode(),isOpen:jd.getIsOpen(),isMinimized:jd.getIsMinimized()}),i({messages:jd.getMessages()}),o.current=t?n:null,e){const t=Vd.getInstance(),n=Yd.getConfig();t.connect(e,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxAgent:n.mtxAgent,mtxApp:n.mtxApp}:void 0).catch(e=>{})}})()},[]),/* @__PURE__ */f(au,{previewMode:t,currentMode:n.currentMode,setMessages:i,uiActions:r,activeTaskIdRef:o,children:e})},mf=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=du();/* @__PURE__ */
64
- return f(Qd,{previewMode:t,uiActions:r,currentMode:n.currentMode,children:/* @__PURE__ */f(hf,{previewMode:t,children:e})})},ff=({children:e,previewMode:t=!1})=>/* @__PURE__ */f(cu,{children:/* @__PURE__ */f(mf,{previewMode:t,children:e})}),gf=Object.defineProperty,yf=(e,t,n)=>((e,t,n)=>t in e?gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),wf=Object.defineProperty,bf=(e,t,n)=>((e,t,n)=>t in e?wf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),vf=/* @__PURE__ */(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(vf||{}),xf={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},kf={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},_f={};function Sf(e){if(_f[e])return _f[e];const t=globalThis[e],n=t.prototype,r=e in xf?xf[e]:void 0,i=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),o=e in kf?kf[e]:void 0,s=Boolean(o&&o.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return _f[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");document.body.appendChild(r);const i=r.contentWindow;if(!i)return t.prototype;const o=i[e].prototype;return document.body.removeChild(r),o?_f[e]=o:n}catch{return n}}var Cf={};function If(e,t,n){var r;const i=`${e}.${String(n)}`;if(Cf[i])return Cf[i].call(t);const o=Sf(e),s=null==(r=Object.getOwnPropertyDescriptor(o,n))?void 0:r.get;return s?(Cf[i]=s,s.call(t)):t[n]}var Ef={};function Tf(e,t,n){const r=`${e}.${String(n)}`;if(Ef[r])return Ef[r].bind(t);const i=Sf(e)[n];return"function"!=typeof i?t[n]:(Ef[r]=i,i.bind(t))}var Af={ownerDocument:function(e){return If("Node",e,"ownerDocument")},childNodes:function(e){return If("Node",e,"childNodes")},parentNode:function(e){return If("Node",e,"parentNode")},parentElement:function(e){return If("Node",e,"parentElement")},textContent:function(e){return If("Node",e,"textContent")},contains:function(e,t){return Tf("Node",e,"contains")(t)},getRootNode:function(e){return Tf("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?If("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?If("Element",e,"shadowRoot"):null},querySelector:function(e,t){return If("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return If("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return Sf("MutationObserver").constructor},patch:function(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}};function Mf(e){return e.nodeType===e.ELEMENT_NODE}function zf(e){const t=e&&"host"in e&&"mode"in e&&Af.host(e)||null;return Boolean(t&&"shadowRoot"in t&&Af.shadowRoot(t)===e)}function Of(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function Rf(e){try{const n=e.rules||e.cssRules;if(!n)return null;let r=e.href;return!r&&e.ownerNode&&(r=e.ownerNode.baseURI),(t=Array.from(n,e=>Pf(e,r)).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),t}catch(n){return null}var t}function Pf(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=Rf(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(n){t=e.cssText}return e.styleSheet.href?Hf(t,e.styleSheet.href):t}{let n=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(n=n.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")),t?Hf(n,t):n}}var Nf=class{constructor(){bf(this,"idNodeMap",/* @__PURE__ */new Map),bf(this,"nodeMetaMap",/* @__PURE__ */new WeakMap)}getId(e){var t;return e?(null==(t=this.getMeta(e))?void 0:t.id)??-1:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=/* @__PURE__ */new Map,this.nodeMetaMap=/* @__PURE__ */new WeakMap}};function Lf({element:e,maskInputOptions:t,tagName:n,type:r,value:i,maskInputFn:o}){let s=i||"";const a=r&&Df(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=o?o(s,e):"*".repeat(s.length)),s}function Df(e){return e.toLowerCase()}var $f="__rrweb_original__";function jf(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Df(t):null}function Ff(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(i){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}var Uf=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Bf=/^(?:[a-z+]+:)?\/\//i,Gf=/^www\..*/i,Wf=/^(data:)([^,]*),(.*)/i;function Hf(e,t){return(e||"").replace(Uf,(e,n,r,i,o,s)=>{const a=r||o||s,l=n||i||"";if(!a)return e;if(Bf.test(a)||Gf.test(a))return`url(${l}${a}${l})`;if(Wf.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),d=a.split("/");c.pop();for(const t of d){if("."===t)continue;".."===t?c.pop():c.push(t)}return`url(${l}${c.join("/")}${l})`})}function Zf(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function Vf(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),i=[];let o=0;if(r.length>1&&e&&"string"==typeof e){let t=Zf(e,n);const s=t.length/e.length;for(let a=1;a<r.length;a++)if(r[a].textContent&&"string"==typeof r[a].textContent){const l=Zf(r[a].textContent,n),c=100;let d=3;for(;d<l.length&&(l[d].match(/[a-zA-Z0-9]/)||-1!==l.indexOf(l.substring(0,d),1));d++);for(;d<l.length;d++){let u=l.substring(0,d),p=t.split(u),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[a-1].textContent)h=t.indexOf(u,1);else if(1===p.length){if(u=u.substring(0,u.length-1),p=t.split(u),p.length<=1)return i.push(e),i;d=c+1}else d===l.length-1&&(h=t.indexOf(u));if(p.length>=2&&d>c){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=Zf(e).length;h=t.indexOf(u,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/s);for(;a>0&&a<e.length;){if(o+=1,o>50*r.length)return i.push(e),i;const l=Zf(e.substring(0,a),n);if(l.length===h){i.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}l.length<h?a+=Math.max(1,Math.floor((h-l.length)/s)):a-=Math.max(1,Math.floor((l.length-h)*s))}break}}}}return i.push(e),i}(e,t).join("/* rr_split */")}var qf,Yf,Jf=1,Kf=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function Qf(){return Jf++}var Xf=/^[^ \t\n\r\u000c]+/,eg=/^[, \t\n\r\u000c]+/;var tg=/* @__PURE__ */new WeakMap;function ng(e,t){return t&&""!==t.trim()?ig(e,t):t}function rg(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function ig(e,t){let n=tg.get(e);if(n||(n=e.createElement("a"),tg.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function og(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]||"background"===n&&["table","td","th"].includes(t)?ng(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const i=e.exec(t.substring(n));return i?(r=i[0],n+=r.length,r):""}const i=[];for(;r(eg),!(n>=t.length);){let o=r(Xf);if(","===o.slice(-1))o=ng(e,o.substring(0,o.length-1)),i.push(o);else{let r="";o=ng(e,o);let s=!1;for(;;){const e=t.charAt(n);if(""===e){i.push((o+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,i.push((o+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return i.join(", ")}(e,r):"style"===n?Hf(r,ig(e)):"object"===t&&"data"===n?ng(e,r):r:r}function sg(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function ag(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ag(Af.parentNode(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&ag(Af.parentNode(e),t,n)}function lg(e,t,n,r){let i;if(Mf(e)){if(i=e,!Af.childNodes(i).length)return!1}else{if(null===Af.parentElement(e))return!1;i=Af.parentElement(e)}try{if("string"==typeof t){if(r){if(i.closest(`.${t}`))return!0}else if(i.classList.contains(t))return!0}else if(ag(i,t,r))return!0;if(n)if(r){if(i.closest(n))return!0}else if(i.matches(n))return!0}catch(o){}return!1}function cg(e,t){const{doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:s,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:d,dataURLOptions:u={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:m,newlyAddedElement:f=!1,cssCaptured:g=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:vf.Document,childNodes:[],compatMode:e.compatMode}:{type:vf.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:vf.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:i,inlineStylesheet:o,maskInputOptions:s={},maskInputFn:a,dataURLOptions:l={},inlineImages:c,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:p=!1,rootId:h}=t,m=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(r){}return!1}(e,r,i),f=function(e){if(e instanceof HTMLFormElement)return"form";const t=Df(e.tagName);return Kf.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let v=0;v<y;v++){const t=e.attributes[v];sg(f,t.name,t.value)||(g[t.name]=og(n,f,Df(t.name),t.value))}if("link"===f&&o){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=Rf(t)),r&&(delete g.rel,delete g.href,g._cssText=r)}if("style"===f&&e.sheet){let t=Rf(e.sheet);t&&(e.childNodes.length>1&&(t=Vf(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(f)){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Lf({element:e,type:jf(e),tagName:f,value:t,maskInputOptions:s,maskInputFn:a}):n&&(g.checked=n)}"option"===f&&(e.selected&&!s.select?g.selected=!0:delete g.selected);"dialog"===f&&e.open&&(g.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===f&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const i=t.getImageData,o=$f in i?i[$f]:i;if(new Uint32Array(o.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(g.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){const t=e.toDataURL(l.type,l.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height,t!==r.toDataURL(l.type,l.quality)&&(g.rr_dataURL=t)}if("img"===f&&c){qf||(qf=n.createElement("canvas"),Yf=qf.getContext("2d"));const t=e,r=(t.currentSrc||t.getAttribute("src"),t.crossOrigin),i=()=>{t.removeEventListener("load",i);try{qf.width=t.naturalWidth,qf.height=t.naturalHeight,Yf.drawImage(t,0,0),g.rr_dataURL=qf.toDataURL(l.type,l.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i))}"anonymous"===t.crossOrigin&&(r?g.crossOrigin=r:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i)}if(["audio","video"].includes(f)){const t=g;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(m){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==f||u(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);let w;try{customElements.get(f)&&(w=!0)}catch(b){}return{type:vf.Element,tagName:f,attributes:g,childNodes:[],isSVG:rg(e)||void 0,needBlock:m,rootId:h,isCustom:w}}(e,{doc:n,blockClass:i,blockSelector:o,inlineStylesheet:a,maskInputOptions:l,maskInputFn:d,dataURLOptions:u,inlineImages:p,recordCanvas:h,keepIframeSrcFn:m,newlyAddedElement:f,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:i,cssCaptured:o}=t,s=Af.parentNode(e),a=s&&s.tagName;let l="";const c="STYLE"===a||void 0,d="SCRIPT"===a||void 0;d?l="SCRIPT_PLACEHOLDER":o||(l=Af.textContent(e),c&&l&&(l=Hf(l,ig(t.doc))));!c&&!d&&l&&n&&(l=r?r(l,Af.parentElement(e)):l.replace(/[\S]/g,"*"));return{type:vf.Text,textContent:l||"",rootId:i}}(e,{doc:n,needsMask:s,maskTextFn:c,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:vf.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:vf.Comment,textContent:Af.textContent(e)||"",rootId:y};default:return!1}}function dg(e){return null==e?"":e.toLowerCase()}function ug(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:e||{}}function pg(e,t){const{doc:n,mirror:r,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m={},inlineImages:f=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b=5e3,onStylesheetLoad:v,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:_=!1,cssCaptured:S=!1}=t;let{needsMask:C}=t,{preserveWhiteSpace:I=!0}=t;C||(C=lg(e,s,a,void 0===C));const E=cg(e,{doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:C,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,dataURLOptions:m,inlineImages:f,recordCanvas:g,keepIframeSrcFn:k,newlyAddedElement:_,cssCaptured:S});if(!E)return null;let T;T=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===vf.Comment)return!0;if(e.type===vf.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===Ff(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(dg(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===dg(e.attributes.name)||"icon"===dg(e.attributes.rel)||"apple-touch-icon"===dg(e.attributes.rel)||"shortcut icon"===dg(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&dg(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(dg(e.attributes.property).match(/^(og|twitter|fb):/)||dg(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===dg(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===dg(e.attributes.name)||"googlebot"===dg(e.attributes.name)||"bingbot"===dg(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===dg(e.attributes.name)||"generator"===dg(e.attributes.name)||"framework"===dg(e.attributes.name)||"publisher"===dg(e.attributes.name)||"progid"===dg(e.attributes.name)||dg(e.attributes.property).match(/^article:/)||dg(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===dg(e.attributes.name)||"yandex-verification"===dg(e.attributes.name)||"csrf-token"===dg(e.attributes.name)||"p:domain_verify"===dg(e.attributes.name)||"verify-v1"===dg(e.attributes.name)||"verification"===dg(e.attributes.name)||"shopify-checkout-api-token"===dg(e.attributes.name)))return!0}}return!1}(E,h)||!I&&E.type===vf.Text&&!E.textContent.replace(/^\s+|\s+$/gm,"").length?-2:Qf();const A=Object.assign(E,{id:T});if(r.add(e,A),-2===T)return null;y&&y(e);let M=!l;if(A.type===vf.Element){M=M&&!A.needBlock,delete A.needBlock;const t=Af.shadowRoot(e);t&&Of(t)&&(A.isShadowHost=!0)}if((A.type===vf.Document||A.type===vf.Element)&&M){h.headWhitespace&&A.type===vf.Element&&"head"===A.tagName&&(I=!1);const t={doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:C,maskTextClass:s,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:f,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(A.type===vf.Element&&"textarea"===A.tagName&&void 0!==A.attributes.value);else{A.type===vf.Element&&void 0!==A.attributes._cssText&&"string"==typeof A.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(Af.childNodes(e))){const e=pg(n,t);e&&A.childNodes.push(e)}}let _=null;if(Mf(e)&&(_=Af.shadowRoot(e)))for(const e of Array.from(Af.childNodes(_))){const n=pg(e,t);n&&(Of(_)&&(n.isShadow=!0),A.childNodes.push(n))}}const z=Af.parentNode(e);return z&&zf(z)&&Of(z)&&(A.isShadow=!0),A.type===vf.Element&&"iframe"===A.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let i,o=!1;try{i=r.document.readyState}catch(a){return}if("complete"!==i){const r=setTimeout(()=>{o||(t(),o=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),o=!0,t()})}const s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&w){const n=pg(t,{doc:t,mirror:r,blockClass:i,blockSelector:o,needsMask:C,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:f,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});n&&w(e,n)}},b),A.type===vf.Element&&"link"===A.tagName&&"string"==typeof A.attributes.rel&&("stylesheet"===A.attributes.rel||"preload"===A.attributes.rel&&"string"==typeof A.attributes.href&&"css"===Ff(A.attributes.href))&&function(e,t,n){let r,i=!1;try{r=e.sheet}catch(s){return}if(r)return;const o=setTimeout(()=>{i||(t(),i=!0)},n);e.addEventListener("load",()=>{clearTimeout(o),i=!0,t()})}(e,()=>{if(v){const t=pg(e,{doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:C,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:f,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&v(e,t)}},x),A}function hg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function mg(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var fg={exports:{}},gg=String,yg=function(){return{isColorSupported:!1,reset:gg,bold:gg,dim:gg,italic:gg,underline:gg,inverse:gg,hidden:gg,strikethrough:gg,black:gg,red:gg,green:gg,yellow:gg,blue:gg,magenta:gg,cyan:gg,white:gg,gray:gg,bgBlack:gg,bgRed:gg,bgGreen:gg,bgYellow:gg,bgBlue:gg,bgMagenta:gg,bgCyan:gg,bgWhite:gg}};fg.exports=yg(),fg.exports.createColors=yg;var wg=fg.exports,bg=/* @__PURE__ */mg(/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),vg=wg,xg=bg,kg=class e extends Error{constructor(t,n,r,i,o,s){super(t),this.name="CssSyntaxError",this.reason=t,o&&(this.file=o),i&&(this.source=i),s&&(this.plugin=s),void 0!==n&&void 0!==r&&("number"==typeof n?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;null==e&&(e=vg.isColorSupported),xg&&e&&(t=xg(t));let n,r,i=t.split(/\r?\n/),o=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length;if(e){let{bold:e,gray:t,red:i}=vg.createColors(!0);n=t=>e(i(t)),r=e=>t(e)}else n=r=e=>e;return i.slice(o,s).map((e,t)=>{let i=o+1+t,s=" "+(" "+i).slice(-a)+" | ";if(i===this.line){let t=r(s.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return n(">")+r(s)+e+"\n "+t+n("^")}return" "+r(s)+e}).join("\n")}toString(){let e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},_g=kg;kg.default=kg;var Sg={};Sg.isClean=Symbol("isClean"),Sg.my=Symbol("my");var Cg={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var Ig=class{constructor(e){this.builder=e}atrule(e,t){let n="@"+e.name,r=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?n+=e.raws.afterName:r&&(n+=" "),e.nodes)this.block(e,n+r);else{let i=(e.raws.between||"")+(t?";":"");this.builder(n+r+i,e)}}beforeAfter(e,t){let n;n="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let r=e.parent,i=0;for(;r&&"root"!==r.type;)i+=1,r=r.parent;if(n.includes("\n")){let t=this.raw(e,null,"indent");if(t.length)for(let e=0;e<i;e++)n+=t}return n}block(e,t){let n,r=this.raw(e,"between","beforeOpen");this.builder(t+r+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),this.builder("}",e,"end")}body(e){let t=e.nodes.length-1;for(;t>0&&"comment"===e.nodes[t].type;)t-=1;let n=this.raw(e,"semicolon");for(let r=0;r<e.nodes.length;r++){let i=e.nodes[r],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==r||n)}}comment(e){let t=this.raw(e,"left","commentLeft"),n=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+n+"*/",e)}decl(e,t){let n=this.raw(e,"between","colon"),r=e.prop+n+this.rawValue(e,"value");e.important&&(r+=e.raws.important||" !important"),t&&(r+=";"),this.builder(r,e)}document(e){this.body(e)}raw(e,t,n){let r;if(n||(n=t),t&&(r=e.raws[t],void 0!==r))return r;let i=e.parent;if("before"===n){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return Cg[n];let o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[n])return o.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);{let i="raw"+((s=n)[0].toUpperCase()+s.slice(1));this[i]?r=this[i](o,e):o.walk(e=>{if(r=e.raws[t],void 0!==r)return!1})}var s;return void 0===r&&(r=Cg[n]),o.rawCache[n]=r,r}rawBeforeClose(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return t=e.raws.after,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){let n;return e.walkComments(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(e,t){let n;return e.walkDecls(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(e){let t;return e.walk(e=>{if("decl"!==e.type&&(t=e.raws.between,void 0!==t))return!1}),t}rawBeforeRule(e){let t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&void 0!==n.raws.before)return t=n.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){let t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(t=e.raws.after,void 0!==t))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(n=>{let r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&void 0!==n.raws.before){let e=n.raws.before.split("\n");return t=e[e.length-1],t=t.replace(/\S/g,""),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(t=e.raws.semicolon,void 0!==t))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},Eg=Ig;Ig.default=Ig;var Tg=Eg;function Ag(e,t){new Tg(t).stringify(e)}var Mg=Ag;Ag.default=Ag;var{isClean:zg,my:Og}=Sg,Rg=_g,Pg=Eg,Ng=Mg;function Lg(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;if("proxyCache"===r)continue;let i=e[r],o=typeof i;"parent"===r&&"object"===o?t&&(n[r]=t):"source"===r?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>Lg(e,n)):("object"===o&&null!==i&&(i=Lg(i)),n[r]=i)}return n}var Dg=class{constructor(e={}){this.raws={},this[zg]=!1,this[Og]=!0;for(let t in e)if("nodes"===t){this.nodes=[];for(let n of e[t])"function"==typeof n.clone?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=Lg(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new Rg(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[zg]){this[zg]=!1;let e=this;for(;e=e.parent;)e[zg]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e,t){let n=this.source.start;if(e.index)n=this.positionInside(e.index,t);else if(e.word){let r=(t=this.toString()).indexOf(e.word);-1!==r&&(n=this.positionInside(r,t))}return n}positionInside(e,t){let n=t||this.toString(),r=this.source.start.column,i=this.source.start.line;for(let o=0;o<e;o++)"\n"===n[o]?(r=1,i+=1):r+=1;return{column:r,line:i}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e){let t={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){let r=this.toString(),i=r.indexOf(e.word);-1!==i&&(t=this.positionInside(i,r),n=this.positionInside(i+e.word.length,r))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?n={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?n=this.positionInside(e.endIndex):e.index&&(n=this.positionInside(e.index+1));return(n.line<t.line||n.line===t.line&&n.column<=t.column)&&(n={column:t.column+1,line:t.line}),{end:n,start:t}}raw(e,t){return(new Pg).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){let n={},r=null==t;t=t||/* @__PURE__ */new Map;let i=0;for(let o in this){if(!Object.prototype.hasOwnProperty.call(this,o))continue;if("parent"===o||"proxyCache"===o)continue;let e=this[o];if(Array.isArray(e))n[o]=e.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof e&&e.toJSON)n[o]=e.toJSON(null,t);else if("source"===o){let r=t.get(e.input);null==r&&(r=i,t.set(e.input,i),i++),n[o]={end:e.end,inputId:r,start:e.start}}else n[o]=e}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=Ng){e.stringify&&(e=e.stringify);let t="";return e(this,e=>{t+=e}),t}warn(e,t,n){let r={node:this};for(let i in n)r[i]=n[i];return e.warn(t,r)}get proxyOf(){return this}},$g=Dg;Dg.default=Dg;var jg=$g,Fg=class extends jg{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e={...e,value:String(e.value)}),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Ug=Fg;Fg.default=Fg;var Bg={nanoid:(e=21)=>{let t="",n=e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(n=t)=>{let r="",i=n;for(;i--;)r+=e[Math.random()*e.length|0];return r}},{SourceMapConsumer:Gg,SourceMapGenerator:Wg}=bg,{existsSync:Hg,readFileSync:Zg}=bg,{dirname:Vg,join:qg}=bg;var Yg=class{constructor(e,t){if(!1===t.map)return;this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");let n=t.map?t.map.prev:void 0,r=this.loadMap(t.from,n);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Vg(this.mapFile)),r&&(this.text=r)}consumer(){return this.consumerCache||(this.consumerCache=new Gg(this.text)),this.consumerCache}decodeInline(e){if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var t;let n=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+n)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){let t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(!t)return;let n=e.lastIndexOf(t.pop()),r=e.indexOf("*/",n);n>-1&&r>-1&&(this.annotation=this.getAnnotationURL(e.substring(n,r)))}loadFile(e){if(this.root=Vg(e),Hg(e))return this.mapFile=e,Zg(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof Gg)return Wg.fromSourceMap(t).toString();if(t instanceof Wg)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}{let n=t(e);if(n){let e=this.loadFile(n);if(!e)throw new Error("Unable to load previous source map: "+n.toString());return e}}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let t=this.annotation;return e&&(t=qg(Vg(e),t)),this.loadFile(t)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Jg=Yg;Yg.default=Yg;var{SourceMapConsumer:Kg,SourceMapGenerator:Qg}=bg,{fileURLToPath:Xg,pathToFileURL:ey}=bg,{isAbsolute:ty,resolve:ny}=bg,{nanoid:ry}=Bg,iy=bg,oy=_g,sy=Jg,ay=Symbol("fromOffsetCache"),ly=Boolean(Kg&&Qg),cy=Boolean(ny&&ty),dy=class{constructor(e,t={}){if(null==e||"object"==typeof e&&!e.toString)throw new Error(`PostCSS received ${e} instead of CSS string`);if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!cy||/^\w+:\/\//.test(t.from)||ty(t.from)?this.file=t.from:this.file=ny(t.from)),cy&&ly){let e=new sy(this.css,t);if(e.text){this.map=e;let t=e.consumer().file;!this.file&&t&&(this.file=this.mapResolve(t))}}this.file||(this.id="<input css "+ry(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,n,r={}){let i,o,s;if(t&&"object"==typeof t){let e=t,r=n;if("number"==typeof e.offset){let r=this.fromOffset(e.offset);t=r.line,n=r.col}else t=e.line,n=e.column;if("number"==typeof r.offset){let e=this.fromOffset(r.offset);o=e.line,s=e.col}else o=r.line,s=r.column}else if(!n){let e=this.fromOffset(t);t=e.line,n=e.col}let a=this.origin(t,n,o,s);return i=a?new oy(e,void 0===a.endLine?a.line:{column:a.column,line:a.line},void 0===a.endLine?a.column:{column:a.endColumn,line:a.endLine},a.source,a.file,r.plugin):new oy(e,void 0===o?t:{column:n,line:t},void 0===o?n:{column:s,line:o},this.css,this.file,r.plugin),i.input={column:n,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(ey&&(i.input.url=ey(this.file).toString()),i.input.file=this.file),i}fromOffset(e){let t,n;if(this[ay])n=this[ay];else{let e=this.css.split("\n");n=new Array(e.length);let t=0;for(let r=0,i=e.length;r<i;r++)n[r]=t,t+=e[r].length+1;this[ay]=n}t=n[n.length-1];let r=0;if(e>=t)r=n.length-1;else{let t,i=n.length-2;for(;r<i;)if(t=r+(i-r>>1),e<n[t])i=t-1;else{if(!(e>=n[t+1])){r=t;break}r=t+1}}return{col:e-n[r]+1,line:r+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:ny(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,n,r){if(!this.map)return!1;let i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof n&&(i=s.originalPositionFor({column:r,line:n})),o=ty(a.source)?ey(a.source):new URL(a.source,this.map.consumer().sourceRoot||ey(this.map.mapFile));let l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!Xg)throw new Error("file: protocol is not available in this PostCSS build");l.file=Xg(o)}let c=s.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){let e={};for(let t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map={...this.map},e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},uy=dy;dy.default=dy,iy&&iy.registerInput&&iy.registerInput(dy);var{SourceMapConsumer:py,SourceMapGenerator:hy}=bg,{dirname:my,relative:fy,resolve:gy,sep:yy}=bg,{pathToFileURL:wy}=bg,by=uy,vy=Boolean(py&&hy),xy=Boolean(my&&gy&&fy&&yy),ky=class{constructor(e,t,n,r){this.stringify=e,this.mapOpts=n.map||{},this.root=t,this.opts=n,this.css=r,this.originalCSS=r,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=/* @__PURE__ */new Map,this.memoizedPaths=/* @__PURE__ */new Map,this.memoizedURLs=/* @__PURE__ */new Map}addAnnotation(){let e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";let t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let t,n=this.toUrl(this.path(e.file)),r=e.root||my(e.file);!1===this.mapOpts.sourcesContent?(t=new py(e.text),t.sourcesContent&&(t.sourcesContent=null)):t=e.consumer(),this.map.applySourceMap(t,n,this.toUrl(this.path(r)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root){let e;for(let t=this.root.nodes.length-1;t>=0;t--)e=this.root.nodes[t],"comment"===e.type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),xy&&vy&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=hy.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new hy({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new hy({file:this.outputFile(),ignoreInvalidMapping:!0});let e,t,n=1,r=1,i="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(s,a,l)=>{if(this.css+=s,a&&"end"!==l&&(o.generated.line=n,o.generated.column=r-1,a.source&&a.source.start?(o.source=this.sourcePath(a),o.original.line=a.source.start.line,o.original.column=a.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),e=s.match(/\n/g),e?(n+=e.length,t=s.lastIndexOf("\n"),r=s.length-t):r+=s.length,a&&"start"!==l){let e=a.parent||{raws:{}};("decl"!==a.type&&("atrule"!==a.type||a.nodes)||a!==e.last||e.raws.semicolon)&&(a.source&&a.source.end?(o.source=this.sourcePath(a),o.original.line=a.source.end.line,o.original.column=a.source.end.column-1,o.generated.line=n,o.generated.column=r-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=n,o.generated.column=r-1,this.map.addMapping(o)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;let e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let n=this.opts.to?my(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(n=my(gy(n,this.mapOpts.annotation)));let r=fy(n,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new by(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let n=t.source.input.from;if(n&&!e[n]){e[n]=!0;let r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(wy){let t=wy(e).toString();return this.memoizedFileURLs.set(e,t),t}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;"\\"===yy&&(e=e.replace(/\\/g,"/"));let n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}},_y=$g,Sy=class extends _y{constructor(e){super(e),this.type="comment"}},Cy=Sy;Sy.default=Sy;var Iy,Ey,Ty,Ay,{isClean:My,my:zy}=Sg,Oy=Ug,Ry=Cy,Py=$g;function Ny(e){return e.map(e=>(e.nodes&&(e.nodes=Ny(e.nodes)),delete e.source,e))}function Ly(e){if(e[My]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)Ly(t)}var Dy=class e extends Py{append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t,n,r=this.getIterator();for(;this.indexes[r]<this.proxyOf.nodes.length&&(t=this.indexes[r],n=e(this.proxyOf.nodes[t],t),!1!==n);)this.indexes[r]+=1;return delete this.indexes[r],n}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?(...n)=>e[t](...n.map(e=>"function"==typeof e?(t,n)=>e(t.toProxy(),n):e)):"every"===t||"some"===t?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n,r=this.index(e),i=this.normalize(t,this.proxyOf.nodes[r]).reverse();r=this.index(e);for(let o of i)this.proxyOf.nodes.splice(r+1,0,o);for(let o in this.indexes)n=this.indexes[o],r<n&&(this.indexes[o]=n+i.length);return this.markDirty(),this}insertBefore(e,t){let n,r=this.index(e),i=0===r&&"prepend",o=this.normalize(t,this.proxyOf.nodes[r],i).reverse();r=this.index(e);for(let s of o)this.proxyOf.nodes.splice(r,0,s);for(let s in this.indexes)n=this.indexes[s],r<=n&&(this.indexes[s]=n+o.length);return this.markDirty(),this}normalize(t,n){if("string"==typeof t)t=Ny(Iy(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if("root"===t.type&&"document"!==this.type){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new Oy(t)]}else if(t.selector)t=[new Ey(t)];else if(t.name)t=[new Ty(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new Ry(t)]}return t.map(t=>(t[zy]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[My]&&Ly(t),void 0===t.raws.before&&n&&void 0!==n.raws.before&&(t.raws.before=n.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,"prepend").reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){let t;e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(i){throw t.addToError(i)}return!1!==r&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("atrule"===n.type&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if("atrule"===n.type&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("atrule"===e.type)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if("comment"===t.type)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("decl"===n.type&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if("decl"===n.type&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("decl"===e.type)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("rule"===n.type&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if("rule"===n.type&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("rule"===e.type)return t(e,n)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};Dy.registerParse=e=>{Iy=e},Dy.registerRule=e=>{Ey=e},Dy.registerAtRule=e=>{Ty=e},Dy.registerRoot=e=>{Ay=e};var $y=Dy;Dy.default=Dy,Dy.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,Ty.prototype):"rule"===e.type?Object.setPrototypeOf(e,Ey.prototype):"decl"===e.type?Object.setPrototypeOf(e,Oy.prototype):"comment"===e.type?Object.setPrototypeOf(e,Ry.prototype):"root"===e.type&&Object.setPrototypeOf(e,Ay.prototype),e[zy]=!0,e.nodes&&e.nodes.forEach(e=>{Dy.rebuild(e)})};var jy,Fy,Uy=$y,By=class extends Uy{constructor(e){super({type:"document",...e}),this.nodes||(this.nodes=[])}toResult(e={}){return new jy(new Fy,this,e).stringify()}};By.registerLazyResult=e=>{jy=e},By.registerProcessor=e=>{Fy=e};var Gy=By;By.default=By;var Wy=class{constructor(e,t={}){if(this.type="warning",this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let n in t)this[n]=t[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},Hy=Wy;Wy.default=Wy;var Zy=Hy,Vy=class{constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let n=new Zy(e,t);return this.messages.push(n),n}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},qy=Vy;Vy.default=Vy;var Yy="'".charCodeAt(0),Jy='"'.charCodeAt(0),Ky="\\".charCodeAt(0),Qy="/".charCodeAt(0),Xy="\n".charCodeAt(0),ew=" ".charCodeAt(0),tw="\f".charCodeAt(0),nw="\t".charCodeAt(0),rw="\r".charCodeAt(0),iw="[".charCodeAt(0),ow="]".charCodeAt(0),sw="(".charCodeAt(0),aw=")".charCodeAt(0),lw="{".charCodeAt(0),cw="}".charCodeAt(0),dw=";".charCodeAt(0),uw="*".charCodeAt(0),pw=":".charCodeAt(0),hw="@".charCodeAt(0),mw=/[\t\n\f\r "#'()/;[\\\]{}]/g,fw=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,gw=/.[\r\n"'(/\\]/,yw=/[\da-f]/i,ww=$y,bw=class extends ww{constructor(e){super(e),this.type="atrule"}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}},vw=bw;bw.default=bw,ww.registerAtRule(bw);var xw,kw,_w=$y,Sw=class extends _w{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,n){let r=super.normalize(e);if(t)if("prepend"===n)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let i of r)i.raws.before=t.raws.before;return r}removeChild(e,t){let n=this.index(e);return!t&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new xw(new kw,this,e).stringify()}};Sw.registerLazyResult=e=>{xw=e},Sw.registerProcessor=e=>{kw=e};var Cw=Sw;Sw.default=Sw,_w.registerRoot(Sw);var Iw={comma:e=>Iw.split(e,[","],!0),space:e=>Iw.split(e,[" ","\n","\t"]),split(e,t,n){let r=[],i="",o=!1,s=0,a=!1,l="",c=!1;for(let d of e)c?c=!1:"\\"===d?c=!0:a?d===l&&(a=!1):'"'===d||"'"===d?(a=!0,l=d):"("===d?s+=1:")"===d?s>0&&(s-=1):0===s&&t.includes(d)&&(o=!0),o?(""!==i&&r.push(i.trim()),i="",o=!1):i+=d;return(n||""!==i)&&r.push(i.trim()),r}},Ew=Iw;Iw.default=Iw;var Tw=$y,Aw=Ew,Mw=class extends Tw{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return Aw.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(n)}},zw=Mw;Mw.default=Mw,Tw.registerRule(Mw);var Ow=Ug,Rw=function(e,t={}){let n,r,i,o,s,a,l,c,d,u,p=e.css.valueOf(),h=t.ignoreErrors,m=p.length,f=0,g=[],y=[];function w(t){throw e.error("Unclosed "+t,f)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&f>=m},nextToken:function(e){if(y.length)return y.pop();if(f>=m)return;let t=!!e&&e.ignoreUnclosed;switch(n=p.charCodeAt(f),n){case Xy:case ew:case nw:case rw:case tw:r=f;do{r+=1,n=p.charCodeAt(r)}while(n===ew||n===Xy||n===nw||n===rw||n===tw);u=["space",p.slice(f,r)],f=r-1;break;case iw:case ow:case lw:case cw:case pw:case dw:case aw:{let e=String.fromCharCode(n);u=[e,e,f];break}case sw:if(c=g.length?g.pop()[1]:"",d=p.charCodeAt(f+1),"url"===c&&d!==Yy&&d!==Jy&&d!==ew&&d!==Xy&&d!==nw&&d!==tw&&d!==rw){r=f;do{if(a=!1,r=p.indexOf(")",r+1),-1===r){if(h||t){r=f;break}w("bracket")}for(l=r;p.charCodeAt(l-1)===Ky;)l-=1,a=!a}while(a);u=["brackets",p.slice(f,r+1),f,r],f=r}else r=p.indexOf(")",f+1),o=p.slice(f,r+1),-1===r||gw.test(o)?u=["(","(",f]:(u=["brackets",o,f,r],f=r);break;case Yy:case Jy:i=n===Yy?"'":'"',r=f;do{if(a=!1,r=p.indexOf(i,r+1),-1===r){if(h||t){r=f+1;break}w("string")}for(l=r;p.charCodeAt(l-1)===Ky;)l-=1,a=!a}while(a);u=["string",p.slice(f,r+1),f,r],f=r;break;case hw:mw.lastIndex=f+1,mw.test(p),r=0===mw.lastIndex?p.length-1:mw.lastIndex-2,u=["at-word",p.slice(f,r+1),f,r],f=r;break;case Ky:for(r=f,s=!0;p.charCodeAt(r+1)===Ky;)r+=1,s=!s;if(n=p.charCodeAt(r+1),s&&n!==Qy&&n!==ew&&n!==Xy&&n!==nw&&n!==rw&&n!==tw&&(r+=1,yw.test(p.charAt(r)))){for(;yw.test(p.charAt(r+1));)r+=1;p.charCodeAt(r+1)===ew&&(r+=1)}u=["word",p.slice(f,r+1),f,r],f=r;break;default:n===Qy&&p.charCodeAt(f+1)===uw?(r=p.indexOf("*/",f+2)+1,0===r&&(h||t?r=p.length:w("comment")),u=["comment",p.slice(f,r+1),f,r],f=r):(fw.lastIndex=f+1,fw.test(p),r=0===fw.lastIndex?p.length-1:fw.lastIndex-2,u=["word",p.slice(f,r+1),f,r],g.push(u),f=r)}return f++,u},position:function(){return f}}},Pw=Cy,Nw=vw,Lw=Cw,Dw=zw,$w={empty:!0,space:!0};var jw=$y,Fw=class{constructor(e){this.input=e,this.root=new Lw,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t,n,r,i=new Nw;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);let o=!1,s=!1,a=[],l=[];for(;!this.tokenizer.endOfFile();){if(t=(e=this.tokenizer.nextToken())[0],"("===t||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(r=a.length-1,n=a[r];n&&"space"===n[0];)n=a[--r];n&&(i.source.end=this.getPosition(n[3]||n[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){let t=this.colon(e);if(!1===t)return;let n,r=0;for(let i=t-1;i>=0&&(n=e[i],"space"===n[0]||(r+=1,2!==r));i--);throw this.input.error("Missed semicolon","word"===n[0]?n[3]+1:n[2])}colon(e){let t,n,r,i=0;for(let[o,s]of e.entries()){if(t=s,n=t[0],"("===n&&(i+=1),")"===n&&(i-=1),0===i&&":"===n){if(r){if("word"===r[0]&&"progid"===r[1])continue;return o}this.doubleColon(t)}r=t}return!1}comment(e){let t=new Pw;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(/^\s*$/.test(n))t.text="",t.raws.left=n,t.raws.right="";else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=Rw(this.input)}decl(e,t){let n=new Ow;this.init(n,e[0][2]);let r,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(i[3]||i[2]||function(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}(e)),n.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;n.prop+=e.shift()[1]}for(n.raws.between="";e.length;){if(r=e.shift(),":"===r[0]){n.raws.between+=r[1];break}"word"===r[0]&&/\w/.test(r[1])&&this.unknownWord([r]),n.raws.between+=r[1]}"_"!==n.prop[0]&&"*"!==n.prop[0]||(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let o,s=[];for(;e.length&&(o=e[0][0],"space"===o||"comment"===o);)s.push(e.shift());this.precheckMissedSemicolon(e);for(let a=e.length-1;a>=0;a--){if(r=e[a],"!important"===r[1].toLowerCase()){n.important=!0;let t=this.stringFrom(e,a);t=this.spacesFromEnd(e)+t," !important"!==t&&(n.raws.important=t);break}if("important"===r[1].toLowerCase()){let t=e.slice(0),r="";for(let e=a;e>0;e--){let n=t[e][0];if(0===r.trim().indexOf("!")&&"space"!==n)break;r=t.pop()[1]+r}0===r.trim().indexOf("!")&&(n.important=!0,n.raws.important=r,e=t)}if("space"!==r[0]&&"comment"!==r[0])break}e.some(e=>"space"!==e[0]&&"comment"!==e[0])&&(n.raws.between+=s.map(e=>e[1]).join(""),s=[]),this.raw(n,"value",s.concat(e),t),n.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new Dw;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],l=e;for(;l;){if(n=l[0],a.push(l),"("===n||"["===n)i||(i=l),o.push("("===n?")":"]");else if(s&&r&&"{"===n)i||(i=l),o.push("}");else if(0===o.length){if(";"===n){if(r)return void this.decl(a,s);break}if("{"===n)return void this.rule(a);if("}"===n){this.tokenizer.back(a.pop()),t=!0;break}":"===n&&(r=!0)}else n===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&r){if(!s)for(;a.length&&(l=a[a.length-1][0],"space"===l||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,o,s,a,l=n.length,c="",d=!0;for(let u=0;u<l;u+=1)i=n[u],o=i[0],"space"!==o||u!==l-1||r?"comment"===o?(a=n[u-1]?n[u-1][0]:"empty",s=n[u+1]?n[u+1][0]:"empty",$w[a]||$w[s]||","===c.slice(-1)?d=!1:c+=i[1]):c+=i[1]:d=!1;if(!d){let r=n.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:r,value:c}}e[t]=c}rule(e){e.pop();let t=new Dw;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t||"comment"===t);)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n="";for(;e.length&&(t=e[0][0],"space"===t||"comment"===t);)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n="";for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Uw=uy;function Bw(e,t){let n=new Fw(new Uw(e,t));try{n.parse()}catch(r){throw r}return n.root}var Gw=Bw;Bw.default=Bw,jw.registerParse(Bw);var{isClean:Ww,my:Hw}=Sg,Zw=ky,Vw=Mg,qw=$y,Yw=Gy,Jw=qy,Kw=Gw,Qw=Cw,Xw={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},eb={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},tb={Once:!0,postcssPlugin:!0,prepare:!0};function nb(e){return"object"==typeof e&&"function"==typeof e.then}function rb(e){let t=!1,n=Xw[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[n,n+"-"+t,0,n+"Exit",n+"Exit-"+t]:t?[n,n+"-"+t,n+"Exit",n+"Exit-"+t]:e.append?[n,0,n+"Exit"]:[n,n+"Exit"]}function ib(e){let t;return t="document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:rb(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function ob(e){return e[Ww]=!1,e.nodes&&e.nodes.forEach(e=>ob(e)),e}var sb={},ab=class e{constructor(t,n,r){let i;if(this.stringified=!1,this.processed=!1,"object"!=typeof n||null===n||"root"!==n.type&&"document"!==n.type)if(n instanceof e||n instanceof Jw)i=ob(n.root),n.map&&(void 0===r.map&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=n.map);else{let e=Kw;r.syntax&&(e=r.syntax.parse),r.parser&&(e=r.parser),e.parse&&(e=e.parse);try{i=e(n,r)}catch(o){this.processed=!0,this.error=o}i&&!i[Hw]&&qw.rebuild(i)}else i=ob(n);this.result=new Jw(t,i,r),this.helpers={...sb,postcss:sb,result:this.result},this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let n=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin?n.postcssVersion:(e.plugin=n.postcssPlugin,e.setMessage())}catch(r){console&&console.error}return e}prepareVisitors(){this.listeners={};let e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(let t of this.plugins)if("object"==typeof t)for(let n in t){if(!eb[n]&&/^[A-Z]/.test(n))throw new Error(`Unknown event ${n} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!tb[n])if("object"==typeof t[n])for(let r in t[n])e(t,"*"===r?n:n+"-"+r.toLowerCase(),t[n][r]);else"function"==typeof t[n]&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let n=0;n<this.plugins.length;n++){let t=this.plugins[n],r=this.runOnRoot(t);if(nb(r))try{await r}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Ww];){e[Ww]=!0;let n=[ib(e)];for(;n.length>0;){let e=this.visitTick(n);if(nb(e))try{await e}catch(t){let e=n[n.length-1].node;throw this.handleError(t,e)}}}if(this.listeners.OnceExit)for(let[n,r]of this.listeners.OnceExit){this.result.lastPlugin=n;try{if("document"===e.type){let t=e.nodes.map(e=>r(e,this.helpers));await Promise.all(t)}else await r(e,this.helpers)}catch(t){throw this.handleError(t)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return nb(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=Vw;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let n=new Zw(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(nb(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Ww];)e[Ww]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[r,i]of e){let e;this.result.lastPlugin=r;try{e=i(t,this.helpers)}catch(n){throw this.handleError(n,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(nb(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:n,visitors:r}=t;if("root"!==n.type&&"document"!==n.type&&!n.parent)return void e.pop();if(r.length>0&&t.visitorIndex<r.length){let[e,i]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(n.toProxy(),this.helpers)}catch(o){throw this.handleError(o,n)}}if(0!==t.iterator){let r,i=t.iterator;for(;r=n.nodes[n.indexes[i]];)if(n.indexes[i]+=1,!r[Ww])return r[Ww]=!0,void e.push(ib(r));t.iterator=0,delete n.indexes[i]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,0===e)return void(n.nodes&&n.nodes.length&&(n[Ww]=!0,t.iterator=n.getIterator()));if(this.listeners[e])return void(t.visitors=this.listeners[e])}e.pop()}walkSync(e){e[Ww]=!0;let t=rb(e);for(let n of t)if(0===n)e.nodes&&e.each(e=>{e[Ww]||this.walkSync(e)});else{let t=this.listeners[n];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};ab.registerPostcss=e=>{sb=e};var lb=ab;ab.default=ab,Qw.registerLazyResult(ab),Yw.registerLazyResult(ab);var cb=ky,db=Mg,ub=Gw,pb=qy,hb=class{constructor(e,t,n){let r;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=n,this._map=void 0;let i=db;this.result=new pb(this._processor,r,this._opts),this.result.css=t;let o=this;Object.defineProperty(this.result,"root",{get:()=>o.root});let s=new cb(i,r,this._opts,t);if(s.isMap()){let[e,t]=s.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=ub;try{e=t(this._css,this._opts)}catch(n){this.error=n}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},mb=hb;hb.default=hb;var fb=mb,gb=lb,yb=Gy,wb=Cw,bb=class{constructor(e=[]){this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){let t=[];for(let n of e)if(!0===n.postcss?n=n():n.postcss&&(n=n.postcss),"object"==typeof n&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if("object"==typeof n&&n.postcssPlugin)t.push(n);else if("function"==typeof n)t.push(n);else if("object"!=typeof n||!n.parse&&!n.stringify)throw new Error(n+" is not a PostCSS plugin");return t}process(e,t={}){return this.plugins.length||t.parser||t.stringifier||t.syntax?new gb(this,e,t):new fb(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},vb=bb;bb.default=bb,wb.registerProcessor(bb),yb.registerProcessor(bb);var xb=Ug,kb=Jg,_b=Cy,Sb=vw,Cb=uy,Ib=Cw,Eb=zw;function Tb(e,t){if(Array.isArray(e))return e.map(e=>Tb(e));let{inputs:n,...r}=e;if(n){t=[];for(let e of n){let n={...e,__proto__:Cb.prototype};n.map&&(n.map={...n.map,__proto__:kb.prototype}),t.push(n)}}if(r.nodes&&(r.nodes=e.nodes.map(e=>Tb(e,t))),r.source){let{inputId:e,...n}=r.source;r.source=n,null!=e&&(r.source.input=t[e])}if("root"===r.type)return new Ib(r);if("decl"===r.type)return new xb(r);if("rule"===r.type)return new Eb(r);if("comment"===r.type)return new _b(r);if("atrule"===r.type)return new Sb(r);throw new Error("Unknown node type: "+e.type)}var Ab=Tb;Tb.default=Tb;var Mb=_g,zb=Ug,Ob=lb,Rb=$y,Pb=vb,Nb=Mg,Lb=Ab,Db=Gy,$b=Hy,jb=Cy,Fb=vw,Ub=qy,Bb=uy,Gb=Gw,Wb=Ew,Hb=zw,Zb=Cw,Vb=$g;function qb(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new Pb(e)}qb.plugin=function(e,t){let n,r=!1;function i(...n){console&&console.warn&&!r&&(r=!0,{}.LANG&&{}.LANG.startsWith("cn"));let i=t(...n);return i.postcssPlugin=e,i.postcssVersion=(new Pb).version,i}return Object.defineProperty(i,"postcss",{get:()=>(n||(n=i()),n)}),i.process=function(e,t,n){return qb([i(n)]).process(e,t)},i},qb.stringify=Nb,qb.parse=Gb,qb.fromJSON=Lb,qb.list=Wb,qb.comment=e=>new jb(e),qb.atRule=e=>new Fb(e),qb.decl=e=>new zb(e),qb.rule=e=>new Hb(e),qb.root=e=>new Zb(e),qb.document=e=>new Db(e),qb.CssSyntaxError=Mb,qb.Declaration=zb,qb.Container=Rb,qb.Processor=Pb,qb.Document=Db,qb.Comment=jb,qb.Warning=$b,qb.AtRule=Fb,qb.Result=Ub,qb.Input=Bb,qb.Rule=Hb,qb.Root=Zb,qb.Node=Vb,Ob.registerPostcss(qb);var Yb=qb;qb.default=qb;var Jb=/* @__PURE__ */hg(Yb);Jb.stringify,Jb.fromJSON,Jb.plugin,Jb.parse,Jb.list,Jb.document,Jb.comment,Jb.atRule,Jb.rule,Jb.decl,Jb.root,Jb.CssSyntaxError,Jb.Declaration,Jb.Container,Jb.Processor,Jb.Document,Jb.Comment,Jb.Warning,Jb.AtRule,Jb.Result,Jb.Input,Jb.Rule,Jb.Root,Jb.Node;var Kb=Object.defineProperty,Qb=(e,t,n)=>((e,t,n)=>t in e?Kb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);function Xb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ev(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var tv={exports:{}},nv=String,rv=function(){return{isColorSupported:!1,reset:nv,bold:nv,dim:nv,italic:nv,underline:nv,inverse:nv,hidden:nv,strikethrough:nv,black:nv,red:nv,green:nv,yellow:nv,blue:nv,magenta:nv,cyan:nv,white:nv,gray:nv,bgBlack:nv,bgRed:nv,bgGreen:nv,bgYellow:nv,bgBlue:nv,bgMagenta:nv,bgCyan:nv,bgWhite:nv}};tv.exports=rv(),tv.exports.createColors=rv;var iv=tv.exports,ov=/* @__PURE__ */ev(/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),sv=iv,av=ov,lv=class e extends Error{constructor(t,n,r,i,o,s){super(t),this.name="CssSyntaxError",this.reason=t,o&&(this.file=o),i&&(this.source=i),s&&(this.plugin=s),void 0!==n&&void 0!==r&&("number"==typeof n?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;null==e&&(e=sv.isColorSupported),av&&e&&(t=av(t));let n,r,i=t.split(/\r?\n/),o=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length;if(e){let{bold:e,gray:t,red:i}=sv.createColors(!0);n=t=>e(i(t)),r=e=>t(e)}else n=r=e=>e;return i.slice(o,s).map((e,t)=>{let i=o+1+t,s=" "+(" "+i).slice(-a)+" | ";if(i===this.line){let t=r(s.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return n(">")+r(s)+e+"\n "+t+n("^")}return" "+r(s)+e}).join("\n")}toString(){let e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},cv=lv;lv.default=lv;var dv={};dv.isClean=Symbol("isClean"),dv.my=Symbol("my");var uv={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var pv=class{constructor(e){this.builder=e}atrule(e,t){let n="@"+e.name,r=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?n+=e.raws.afterName:r&&(n+=" "),e.nodes)this.block(e,n+r);else{let i=(e.raws.between||"")+(t?";":"");this.builder(n+r+i,e)}}beforeAfter(e,t){let n;n="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let r=e.parent,i=0;for(;r&&"root"!==r.type;)i+=1,r=r.parent;if(n.includes("\n")){let t=this.raw(e,null,"indent");if(t.length)for(let e=0;e<i;e++)n+=t}return n}block(e,t){let n,r=this.raw(e,"between","beforeOpen");this.builder(t+r+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),this.builder("}",e,"end")}body(e){let t=e.nodes.length-1;for(;t>0&&"comment"===e.nodes[t].type;)t-=1;let n=this.raw(e,"semicolon");for(let r=0;r<e.nodes.length;r++){let i=e.nodes[r],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==r||n)}}comment(e){let t=this.raw(e,"left","commentLeft"),n=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+n+"*/",e)}decl(e,t){let n=this.raw(e,"between","colon"),r=e.prop+n+this.rawValue(e,"value");e.important&&(r+=e.raws.important||" !important"),t&&(r+=";"),this.builder(r,e)}document(e){this.body(e)}raw(e,t,n){let r;if(n||(n=t),t&&(r=e.raws[t],void 0!==r))return r;let i=e.parent;if("before"===n){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return uv[n];let o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[n])return o.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);{let i="raw"+((s=n)[0].toUpperCase()+s.slice(1));this[i]?r=this[i](o,e):o.walk(e=>{if(r=e.raws[t],void 0!==r)return!1})}var s;return void 0===r&&(r=uv[n]),o.rawCache[n]=r,r}rawBeforeClose(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return t=e.raws.after,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){let n;return e.walkComments(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(e,t){let n;return e.walkDecls(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(e){let t;return e.walk(e=>{if("decl"!==e.type&&(t=e.raws.between,void 0!==t))return!1}),t}rawBeforeRule(e){let t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&void 0!==n.raws.before)return t=n.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){let t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(t=e.raws.after,void 0!==t))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(n=>{let r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&void 0!==n.raws.before){let e=n.raws.before.split("\n");return t=e[e.length-1],t=t.replace(/\S/g,""),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(t=e.raws.semicolon,void 0!==t))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},hv=pv;pv.default=pv;var mv=hv;function fv(e,t){new mv(t).stringify(e)}var gv=fv;fv.default=fv;var{isClean:yv,my:wv}=dv,bv=cv,vv=hv,xv=gv;function kv(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;if("proxyCache"===r)continue;let i=e[r],o=typeof i;"parent"===r&&"object"===o?t&&(n[r]=t):"source"===r?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>kv(e,n)):("object"===o&&null!==i&&(i=kv(i)),n[r]=i)}return n}var _v=class{constructor(e={}){this.raws={},this[yv]=!1,this[wv]=!0;for(let t in e)if("nodes"===t){this.nodes=[];for(let n of e[t])"function"==typeof n.clone?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=kv(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new bv(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[yv]){this[yv]=!1;let e=this;for(;e=e.parent;)e[yv]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e,t){let n=this.source.start;if(e.index)n=this.positionInside(e.index,t);else if(e.word){let r=(t=this.toString()).indexOf(e.word);-1!==r&&(n=this.positionInside(r,t))}return n}positionInside(e,t){let n=t||this.toString(),r=this.source.start.column,i=this.source.start.line;for(let o=0;o<e;o++)"\n"===n[o]?(r=1,i+=1):r+=1;return{column:r,line:i}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e){let t={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){let r=this.toString(),i=r.indexOf(e.word);-1!==i&&(t=this.positionInside(i,r),n=this.positionInside(i+e.word.length,r))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?n={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?n=this.positionInside(e.endIndex):e.index&&(n=this.positionInside(e.index+1));return(n.line<t.line||n.line===t.line&&n.column<=t.column)&&(n={column:t.column+1,line:t.line}),{end:n,start:t}}raw(e,t){return(new vv).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){let n={},r=null==t;t=t||/* @__PURE__ */new Map;let i=0;for(let o in this){if(!Object.prototype.hasOwnProperty.call(this,o))continue;if("parent"===o||"proxyCache"===o)continue;let e=this[o];if(Array.isArray(e))n[o]=e.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof e&&e.toJSON)n[o]=e.toJSON(null,t);else if("source"===o){let r=t.get(e.input);null==r&&(r=i,t.set(e.input,i),i++),n[o]={end:e.end,inputId:r,start:e.start}}else n[o]=e}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=xv){e.stringify&&(e=e.stringify);let t="";return e(this,e=>{t+=e}),t}warn(e,t,n){let r={node:this};for(let i in n)r[i]=n[i];return e.warn(t,r)}get proxyOf(){return this}},Sv=_v;_v.default=_v;var Cv=Sv,Iv=class extends Cv{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e={...e,value:String(e.value)}),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Ev=Iv;Iv.default=Iv;var Tv={nanoid:(e=21)=>{let t="",n=e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(n=t)=>{let r="",i=n;for(;i--;)r+=e[Math.random()*e.length|0];return r}},{SourceMapConsumer:Av,SourceMapGenerator:Mv}=ov,{existsSync:zv,readFileSync:Ov}=ov,{dirname:Rv,join:Pv}=ov;var Nv=class{constructor(e,t){if(!1===t.map)return;this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");let n=t.map?t.map.prev:void 0,r=this.loadMap(t.from,n);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Rv(this.mapFile)),r&&(this.text=r)}consumer(){return this.consumerCache||(this.consumerCache=new Av(this.text)),this.consumerCache}decodeInline(e){if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var t;let n=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+n)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){let t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(!t)return;let n=e.lastIndexOf(t.pop()),r=e.indexOf("*/",n);n>-1&&r>-1&&(this.annotation=this.getAnnotationURL(e.substring(n,r)))}loadFile(e){if(this.root=Rv(e),zv(e))return this.mapFile=e,Ov(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof Av)return Mv.fromSourceMap(t).toString();if(t instanceof Mv)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}{let n=t(e);if(n){let e=this.loadFile(n);if(!e)throw new Error("Unable to load previous source map: "+n.toString());return e}}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let t=this.annotation;return e&&(t=Pv(Rv(e),t)),this.loadFile(t)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Lv=Nv;Nv.default=Nv;var{SourceMapConsumer:Dv,SourceMapGenerator:$v}=ov,{fileURLToPath:jv,pathToFileURL:Fv}=ov,{isAbsolute:Uv,resolve:Bv}=ov,{nanoid:Gv}=Tv,Wv=ov,Hv=cv,Zv=Lv,Vv=Symbol("fromOffsetCache"),qv=Boolean(Dv&&$v),Yv=Boolean(Bv&&Uv),Jv=class{constructor(e,t={}){if(null==e||"object"==typeof e&&!e.toString)throw new Error(`PostCSS received ${e} instead of CSS string`);if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!Yv||/^\w+:\/\//.test(t.from)||Uv(t.from)?this.file=t.from:this.file=Bv(t.from)),Yv&&qv){let e=new Zv(this.css,t);if(e.text){this.map=e;let t=e.consumer().file;!this.file&&t&&(this.file=this.mapResolve(t))}}this.file||(this.id="<input css "+Gv(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,n,r={}){let i,o,s;if(t&&"object"==typeof t){let e=t,r=n;if("number"==typeof e.offset){let r=this.fromOffset(e.offset);t=r.line,n=r.col}else t=e.line,n=e.column;if("number"==typeof r.offset){let e=this.fromOffset(r.offset);o=e.line,s=e.col}else o=r.line,s=r.column}else if(!n){let e=this.fromOffset(t);t=e.line,n=e.col}let a=this.origin(t,n,o,s);return i=a?new Hv(e,void 0===a.endLine?a.line:{column:a.column,line:a.line},void 0===a.endLine?a.column:{column:a.endColumn,line:a.endLine},a.source,a.file,r.plugin):new Hv(e,void 0===o?t:{column:n,line:t},void 0===o?n:{column:s,line:o},this.css,this.file,r.plugin),i.input={column:n,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(Fv&&(i.input.url=Fv(this.file).toString()),i.input.file=this.file),i}fromOffset(e){let t,n;if(this[Vv])n=this[Vv];else{let e=this.css.split("\n");n=new Array(e.length);let t=0;for(let r=0,i=e.length;r<i;r++)n[r]=t,t+=e[r].length+1;this[Vv]=n}t=n[n.length-1];let r=0;if(e>=t)r=n.length-1;else{let t,i=n.length-2;for(;r<i;)if(t=r+(i-r>>1),e<n[t])i=t-1;else{if(!(e>=n[t+1])){r=t;break}r=t+1}}return{col:e-n[r]+1,line:r+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:Bv(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,n,r){if(!this.map)return!1;let i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof n&&(i=s.originalPositionFor({column:r,line:n})),o=Uv(a.source)?Fv(a.source):new URL(a.source,this.map.consumer().sourceRoot||Fv(this.map.mapFile));let l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!jv)throw new Error("file: protocol is not available in this PostCSS build");l.file=jv(o)}let c=s.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){let e={};for(let t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map={...this.map},e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},Kv=Jv;Jv.default=Jv,Wv&&Wv.registerInput&&Wv.registerInput(Jv);var{SourceMapConsumer:Qv,SourceMapGenerator:Xv}=ov,{dirname:ex,relative:tx,resolve:nx,sep:rx}=ov,{pathToFileURL:ix}=ov,ox=Kv,sx=Boolean(Qv&&Xv),ax=Boolean(ex&&nx&&tx&&rx),lx=class{constructor(e,t,n,r){this.stringify=e,this.mapOpts=n.map||{},this.root=t,this.opts=n,this.css=r,this.originalCSS=r,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=/* @__PURE__ */new Map,this.memoizedPaths=/* @__PURE__ */new Map,this.memoizedURLs=/* @__PURE__ */new Map}addAnnotation(){let e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";let t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let t,n=this.toUrl(this.path(e.file)),r=e.root||ex(e.file);!1===this.mapOpts.sourcesContent?(t=new Qv(e.text),t.sourcesContent&&(t.sourcesContent=null)):t=e.consumer(),this.map.applySourceMap(t,n,this.toUrl(this.path(r)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root){let e;for(let t=this.root.nodes.length-1;t>=0;t--)e=this.root.nodes[t],"comment"===e.type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),ax&&sx&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=Xv.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new Xv({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new Xv({file:this.outputFile(),ignoreInvalidMapping:!0});let e,t,n=1,r=1,i="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(s,a,l)=>{if(this.css+=s,a&&"end"!==l&&(o.generated.line=n,o.generated.column=r-1,a.source&&a.source.start?(o.source=this.sourcePath(a),o.original.line=a.source.start.line,o.original.column=a.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),e=s.match(/\n/g),e?(n+=e.length,t=s.lastIndexOf("\n"),r=s.length-t):r+=s.length,a&&"start"!==l){let e=a.parent||{raws:{}};("decl"!==a.type&&("atrule"!==a.type||a.nodes)||a!==e.last||e.raws.semicolon)&&(a.source&&a.source.end?(o.source=this.sourcePath(a),o.original.line=a.source.end.line,o.original.column=a.source.end.column-1,o.generated.line=n,o.generated.column=r-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=n,o.generated.column=r-1,this.map.addMapping(o)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;let e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let n=this.opts.to?ex(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(n=ex(nx(n,this.mapOpts.annotation)));let r=tx(n,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new ox(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let n=t.source.input.from;if(n&&!e[n]){e[n]=!0;let r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(ix){let t=ix(e).toString();return this.memoizedFileURLs.set(e,t),t}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;"\\"===rx&&(e=e.replace(/\\/g,"/"));let n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}},cx=Sv,dx=class extends cx{constructor(e){super(e),this.type="comment"}},ux=dx;dx.default=dx;var px,hx,mx,fx,{isClean:gx,my:yx}=dv,wx=Ev,bx=ux,vx=Sv;function xx(e){return e.map(e=>(e.nodes&&(e.nodes=xx(e.nodes)),delete e.source,e))}function kx(e){if(e[gx]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)kx(t)}var _x=class e extends vx{append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t,n,r=this.getIterator();for(;this.indexes[r]<this.proxyOf.nodes.length&&(t=this.indexes[r],n=e(this.proxyOf.nodes[t],t),!1!==n);)this.indexes[r]+=1;return delete this.indexes[r],n}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?(...n)=>e[t](...n.map(e=>"function"==typeof e?(t,n)=>e(t.toProxy(),n):e)):"every"===t||"some"===t?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n,r=this.index(e),i=this.normalize(t,this.proxyOf.nodes[r]).reverse();r=this.index(e);for(let o of i)this.proxyOf.nodes.splice(r+1,0,o);for(let o in this.indexes)n=this.indexes[o],r<n&&(this.indexes[o]=n+i.length);return this.markDirty(),this}insertBefore(e,t){let n,r=this.index(e),i=0===r&&"prepend",o=this.normalize(t,this.proxyOf.nodes[r],i).reverse();r=this.index(e);for(let s of o)this.proxyOf.nodes.splice(r,0,s);for(let s in this.indexes)n=this.indexes[s],r<=n&&(this.indexes[s]=n+o.length);return this.markDirty(),this}normalize(t,n){if("string"==typeof t)t=xx(px(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if("root"===t.type&&"document"!==this.type){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new wx(t)]}else if(t.selector)t=[new hx(t)];else if(t.name)t=[new mx(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new bx(t)]}return t.map(t=>(t[yx]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[gx]&&kx(t),void 0===t.raws.before&&n&&void 0!==n.raws.before&&(t.raws.before=n.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,"prepend").reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){let t;e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(i){throw t.addToError(i)}return!1!==r&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("atrule"===n.type&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if("atrule"===n.type&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("atrule"===e.type)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if("comment"===t.type)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("decl"===n.type&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if("decl"===n.type&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("decl"===e.type)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("rule"===n.type&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if("rule"===n.type&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("rule"===e.type)return t(e,n)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};_x.registerParse=e=>{px=e},_x.registerRule=e=>{hx=e},_x.registerAtRule=e=>{mx=e},_x.registerRoot=e=>{fx=e};var Sx=_x;_x.default=_x,_x.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,mx.prototype):"rule"===e.type?Object.setPrototypeOf(e,hx.prototype):"decl"===e.type?Object.setPrototypeOf(e,wx.prototype):"comment"===e.type?Object.setPrototypeOf(e,bx.prototype):"root"===e.type&&Object.setPrototypeOf(e,fx.prototype),e[yx]=!0,e.nodes&&e.nodes.forEach(e=>{_x.rebuild(e)})};var Cx,Ix,Ex=Sx,Tx=class extends Ex{constructor(e){super({type:"document",...e}),this.nodes||(this.nodes=[])}toResult(e={}){return new Cx(new Ix,this,e).stringify()}};Tx.registerLazyResult=e=>{Cx=e},Tx.registerProcessor=e=>{Ix=e};var Ax=Tx;Tx.default=Tx;var Mx=class{constructor(e,t={}){if(this.type="warning",this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let n in t)this[n]=t[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},zx=Mx;Mx.default=Mx;var Ox=zx,Rx=class{constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let n=new Ox(e,t);return this.messages.push(n),n}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},Px=Rx;Rx.default=Rx;var Nx="'".charCodeAt(0),Lx='"'.charCodeAt(0),Dx="\\".charCodeAt(0),$x="/".charCodeAt(0),jx="\n".charCodeAt(0),Fx=" ".charCodeAt(0),Ux="\f".charCodeAt(0),Bx="\t".charCodeAt(0),Gx="\r".charCodeAt(0),Wx="[".charCodeAt(0),Hx="]".charCodeAt(0),Zx="(".charCodeAt(0),Vx=")".charCodeAt(0),qx="{".charCodeAt(0),Yx="}".charCodeAt(0),Jx=";".charCodeAt(0),Kx="*".charCodeAt(0),Qx=":".charCodeAt(0),Xx="@".charCodeAt(0),ek=/[\t\n\f\r "#'()/;[\\\]{}]/g,tk=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,nk=/.[\r\n"'(/\\]/,rk=/[\da-f]/i,ik=Sx,ok=class extends ik{constructor(e){super(e),this.type="atrule"}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}},sk=ok;ok.default=ok,ik.registerAtRule(ok);var ak,lk,ck=Sx,dk=class extends ck{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,n){let r=super.normalize(e);if(t)if("prepend"===n)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let i of r)i.raws.before=t.raws.before;return r}removeChild(e,t){let n=this.index(e);return!t&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new ak(new lk,this,e).stringify()}};dk.registerLazyResult=e=>{ak=e},dk.registerProcessor=e=>{lk=e};var uk=dk;dk.default=dk,ck.registerRoot(dk);var pk={comma:e=>pk.split(e,[","],!0),space:e=>pk.split(e,[" ","\n","\t"]),split(e,t,n){let r=[],i="",o=!1,s=0,a=!1,l="",c=!1;for(let d of e)c?c=!1:"\\"===d?c=!0:a?d===l&&(a=!1):'"'===d||"'"===d?(a=!0,l=d):"("===d?s+=1:")"===d?s>0&&(s-=1):0===s&&t.includes(d)&&(o=!0),o?(""!==i&&r.push(i.trim()),i="",o=!1):i+=d;return(n||""!==i)&&r.push(i.trim()),r}},hk=pk;pk.default=pk;var mk=Sx,fk=hk,gk=class extends mk{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return fk.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(n)}},yk=gk;gk.default=gk,mk.registerRule(gk);var wk=Ev,bk=function(e,t={}){let n,r,i,o,s,a,l,c,d,u,p=e.css.valueOf(),h=t.ignoreErrors,m=p.length,f=0,g=[],y=[];function w(t){throw e.error("Unclosed "+t,f)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&f>=m},nextToken:function(e){if(y.length)return y.pop();if(f>=m)return;let t=!!e&&e.ignoreUnclosed;switch(n=p.charCodeAt(f),n){case jx:case Fx:case Bx:case Gx:case Ux:r=f;do{r+=1,n=p.charCodeAt(r)}while(n===Fx||n===jx||n===Bx||n===Gx||n===Ux);u=["space",p.slice(f,r)],f=r-1;break;case Wx:case Hx:case qx:case Yx:case Qx:case Jx:case Vx:{let e=String.fromCharCode(n);u=[e,e,f];break}case Zx:if(c=g.length?g.pop()[1]:"",d=p.charCodeAt(f+1),"url"===c&&d!==Nx&&d!==Lx&&d!==Fx&&d!==jx&&d!==Bx&&d!==Ux&&d!==Gx){r=f;do{if(a=!1,r=p.indexOf(")",r+1),-1===r){if(h||t){r=f;break}w("bracket")}for(l=r;p.charCodeAt(l-1)===Dx;)l-=1,a=!a}while(a);u=["brackets",p.slice(f,r+1),f,r],f=r}else r=p.indexOf(")",f+1),o=p.slice(f,r+1),-1===r||nk.test(o)?u=["(","(",f]:(u=["brackets",o,f,r],f=r);break;case Nx:case Lx:i=n===Nx?"'":'"',r=f;do{if(a=!1,r=p.indexOf(i,r+1),-1===r){if(h||t){r=f+1;break}w("string")}for(l=r;p.charCodeAt(l-1)===Dx;)l-=1,a=!a}while(a);u=["string",p.slice(f,r+1),f,r],f=r;break;case Xx:ek.lastIndex=f+1,ek.test(p),r=0===ek.lastIndex?p.length-1:ek.lastIndex-2,u=["at-word",p.slice(f,r+1),f,r],f=r;break;case Dx:for(r=f,s=!0;p.charCodeAt(r+1)===Dx;)r+=1,s=!s;if(n=p.charCodeAt(r+1),s&&n!==$x&&n!==Fx&&n!==jx&&n!==Bx&&n!==Gx&&n!==Ux&&(r+=1,rk.test(p.charAt(r)))){for(;rk.test(p.charAt(r+1));)r+=1;p.charCodeAt(r+1)===Fx&&(r+=1)}u=["word",p.slice(f,r+1),f,r],f=r;break;default:n===$x&&p.charCodeAt(f+1)===Kx?(r=p.indexOf("*/",f+2)+1,0===r&&(h||t?r=p.length:w("comment")),u=["comment",p.slice(f,r+1),f,r],f=r):(tk.lastIndex=f+1,tk.test(p),r=0===tk.lastIndex?p.length-1:tk.lastIndex-2,u=["word",p.slice(f,r+1),f,r],g.push(u),f=r)}return f++,u},position:function(){return f}}},vk=ux,xk=sk,kk=uk,_k=yk,Sk={empty:!0,space:!0};var Ck=Sx,Ik=class{constructor(e){this.input=e,this.root=new kk,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t,n,r,i=new xk;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);let o=!1,s=!1,a=[],l=[];for(;!this.tokenizer.endOfFile();){if(t=(e=this.tokenizer.nextToken())[0],"("===t||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(r=a.length-1,n=a[r];n&&"space"===n[0];)n=a[--r];n&&(i.source.end=this.getPosition(n[3]||n[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){let t=this.colon(e);if(!1===t)return;let n,r=0;for(let i=t-1;i>=0&&(n=e[i],"space"===n[0]||(r+=1,2!==r));i--);throw this.input.error("Missed semicolon","word"===n[0]?n[3]+1:n[2])}colon(e){let t,n,r,i=0;for(let[o,s]of e.entries()){if(t=s,n=t[0],"("===n&&(i+=1),")"===n&&(i-=1),0===i&&":"===n){if(r){if("word"===r[0]&&"progid"===r[1])continue;return o}this.doubleColon(t)}r=t}return!1}comment(e){let t=new vk;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(/^\s*$/.test(n))t.text="",t.raws.left=n,t.raws.right="";else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=bk(this.input)}decl(e,t){let n=new wk;this.init(n,e[0][2]);let r,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(i[3]||i[2]||function(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}(e)),n.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;n.prop+=e.shift()[1]}for(n.raws.between="";e.length;){if(r=e.shift(),":"===r[0]){n.raws.between+=r[1];break}"word"===r[0]&&/\w/.test(r[1])&&this.unknownWord([r]),n.raws.between+=r[1]}"_"!==n.prop[0]&&"*"!==n.prop[0]||(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let o,s=[];for(;e.length&&(o=e[0][0],"space"===o||"comment"===o);)s.push(e.shift());this.precheckMissedSemicolon(e);for(let a=e.length-1;a>=0;a--){if(r=e[a],"!important"===r[1].toLowerCase()){n.important=!0;let t=this.stringFrom(e,a);t=this.spacesFromEnd(e)+t," !important"!==t&&(n.raws.important=t);break}if("important"===r[1].toLowerCase()){let t=e.slice(0),r="";for(let e=a;e>0;e--){let n=t[e][0];if(0===r.trim().indexOf("!")&&"space"!==n)break;r=t.pop()[1]+r}0===r.trim().indexOf("!")&&(n.important=!0,n.raws.important=r,e=t)}if("space"!==r[0]&&"comment"!==r[0])break}e.some(e=>"space"!==e[0]&&"comment"!==e[0])&&(n.raws.between+=s.map(e=>e[1]).join(""),s=[]),this.raw(n,"value",s.concat(e),t),n.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new _k;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],l=e;for(;l;){if(n=l[0],a.push(l),"("===n||"["===n)i||(i=l),o.push("("===n?")":"]");else if(s&&r&&"{"===n)i||(i=l),o.push("}");else if(0===o.length){if(";"===n){if(r)return void this.decl(a,s);break}if("{"===n)return void this.rule(a);if("}"===n){this.tokenizer.back(a.pop()),t=!0;break}":"===n&&(r=!0)}else n===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&r){if(!s)for(;a.length&&(l=a[a.length-1][0],"space"===l||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,o,s,a,l=n.length,c="",d=!0;for(let u=0;u<l;u+=1)i=n[u],o=i[0],"space"!==o||u!==l-1||r?"comment"===o?(a=n[u-1]?n[u-1][0]:"empty",s=n[u+1]?n[u+1][0]:"empty",Sk[a]||Sk[s]||","===c.slice(-1)?d=!1:c+=i[1]):c+=i[1]:d=!1;if(!d){let r=n.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:r,value:c}}e[t]=c}rule(e){e.pop();let t=new _k;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t||"comment"===t);)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n="";for(;e.length&&(t=e[0][0],"space"===t||"comment"===t);)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n="";for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Ek=Kv;function Tk(e,t){let n=new Ik(new Ek(e,t));try{n.parse()}catch(r){throw r}return n.root}var Ak=Tk;Tk.default=Tk,Ck.registerParse(Tk);var{isClean:Mk,my:zk}=dv,Ok=lx,Rk=gv,Pk=Sx,Nk=Ax,Lk=Px,Dk=Ak,$k=uk,jk={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Fk={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Uk={Once:!0,postcssPlugin:!0,prepare:!0};function Bk(e){return"object"==typeof e&&"function"==typeof e.then}function Gk(e){let t=!1,n=jk[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[n,n+"-"+t,0,n+"Exit",n+"Exit-"+t]:t?[n,n+"-"+t,n+"Exit",n+"Exit-"+t]:e.append?[n,0,n+"Exit"]:[n,n+"Exit"]}function Wk(e){let t;return t="document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:Gk(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function Hk(e){return e[Mk]=!1,e.nodes&&e.nodes.forEach(e=>Hk(e)),e}var Zk={},Vk=class e{constructor(t,n,r){let i;if(this.stringified=!1,this.processed=!1,"object"!=typeof n||null===n||"root"!==n.type&&"document"!==n.type)if(n instanceof e||n instanceof Lk)i=Hk(n.root),n.map&&(void 0===r.map&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=n.map);else{let e=Dk;r.syntax&&(e=r.syntax.parse),r.parser&&(e=r.parser),e.parse&&(e=e.parse);try{i=e(n,r)}catch(o){this.processed=!0,this.error=o}i&&!i[zk]&&Pk.rebuild(i)}else i=Hk(n);this.result=new Lk(t,i,r),this.helpers={...Zk,postcss:Zk,result:this.result},this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let n=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin?n.postcssVersion:(e.plugin=n.postcssPlugin,e.setMessage())}catch(r){console&&console.error}return e}prepareVisitors(){this.listeners={};let e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(let t of this.plugins)if("object"==typeof t)for(let n in t){if(!Fk[n]&&/^[A-Z]/.test(n))throw new Error(`Unknown event ${n} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Uk[n])if("object"==typeof t[n])for(let r in t[n])e(t,"*"===r?n:n+"-"+r.toLowerCase(),t[n][r]);else"function"==typeof t[n]&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let n=0;n<this.plugins.length;n++){let t=this.plugins[n],r=this.runOnRoot(t);if(Bk(r))try{await r}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Mk];){e[Mk]=!0;let n=[Wk(e)];for(;n.length>0;){let e=this.visitTick(n);if(Bk(e))try{await e}catch(t){let e=n[n.length-1].node;throw this.handleError(t,e)}}}if(this.listeners.OnceExit)for(let[n,r]of this.listeners.OnceExit){this.result.lastPlugin=n;try{if("document"===e.type){let t=e.nodes.map(e=>r(e,this.helpers));await Promise.all(t)}else await r(e,this.helpers)}catch(t){throw this.handleError(t)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return Bk(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=Rk;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let n=new Ok(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(Bk(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Mk];)e[Mk]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[r,i]of e){let e;this.result.lastPlugin=r;try{e=i(t,this.helpers)}catch(n){throw this.handleError(n,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(Bk(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:n,visitors:r}=t;if("root"!==n.type&&"document"!==n.type&&!n.parent)return void e.pop();if(r.length>0&&t.visitorIndex<r.length){let[e,i]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(n.toProxy(),this.helpers)}catch(o){throw this.handleError(o,n)}}if(0!==t.iterator){let r,i=t.iterator;for(;r=n.nodes[n.indexes[i]];)if(n.indexes[i]+=1,!r[Mk])return r[Mk]=!0,void e.push(Wk(r));t.iterator=0,delete n.indexes[i]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,0===e)return void(n.nodes&&n.nodes.length&&(n[Mk]=!0,t.iterator=n.getIterator()));if(this.listeners[e])return void(t.visitors=this.listeners[e])}e.pop()}walkSync(e){e[Mk]=!0;let t=Gk(e);for(let n of t)if(0===n)e.nodes&&e.each(e=>{e[Mk]||this.walkSync(e)});else{let t=this.listeners[n];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};Vk.registerPostcss=e=>{Zk=e};var qk=Vk;Vk.default=Vk,$k.registerLazyResult(Vk),Nk.registerLazyResult(Vk);var Yk=lx,Jk=gv,Kk=Ak,Qk=Px,Xk=class{constructor(e,t,n){let r;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=n,this._map=void 0;let i=Jk;this.result=new Qk(this._processor,r,this._opts),this.result.css=t;let o=this;Object.defineProperty(this.result,"root",{get:()=>o.root});let s=new Yk(i,r,this._opts,t);if(s.isMap()){let[e,t]=s.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=Kk;try{e=t(this._css,this._opts)}catch(n){this.error=n}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},e_=Xk;Xk.default=Xk;var t_=e_,n_=qk,r_=Ax,i_=uk,o_=class{constructor(e=[]){this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){let t=[];for(let n of e)if(!0===n.postcss?n=n():n.postcss&&(n=n.postcss),"object"==typeof n&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if("object"==typeof n&&n.postcssPlugin)t.push(n);else if("function"==typeof n)t.push(n);else if("object"!=typeof n||!n.parse&&!n.stringify)throw new Error(n+" is not a PostCSS plugin");return t}process(e,t={}){return this.plugins.length||t.parser||t.stringifier||t.syntax?new n_(this,e,t):new t_(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},s_=o_;o_.default=o_,i_.registerProcessor(o_),r_.registerProcessor(o_);var a_=Ev,l_=Lv,c_=ux,d_=sk,u_=Kv,p_=uk,h_=yk;function m_(e,t){if(Array.isArray(e))return e.map(e=>m_(e));let{inputs:n,...r}=e;if(n){t=[];for(let e of n){let n={...e,__proto__:u_.prototype};n.map&&(n.map={...n.map,__proto__:l_.prototype}),t.push(n)}}if(r.nodes&&(r.nodes=e.nodes.map(e=>m_(e,t))),r.source){let{inputId:e,...n}=r.source;r.source=n,null!=e&&(r.source.input=t[e])}if("root"===r.type)return new p_(r);if("decl"===r.type)return new a_(r);if("rule"===r.type)return new h_(r);if("comment"===r.type)return new c_(r);if("atrule"===r.type)return new d_(r);throw new Error("Unknown node type: "+e.type)}var f_=m_;m_.default=m_;var g_=cv,y_=Ev,w_=qk,b_=Sx,v_=s_,x_=gv,k_=f_,__=Ax,S_=zx,C_=ux,I_=sk,E_=Px,T_=Kv,A_=Ak,M_=hk,z_=yk,O_=uk,R_=Sv;function P_(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new v_(e)}P_.plugin=function(e,t){let n,r=!1;function i(...n){console&&console.warn&&!r&&(r=!0,{}.LANG&&{}.LANG.startsWith("cn"));let i=t(...n);return i.postcssPlugin=e,i.postcssVersion=(new v_).version,i}return Object.defineProperty(i,"postcss",{get:()=>(n||(n=i()),n)}),i.process=function(e,t,n){return P_([i(n)]).process(e,t)},i},P_.stringify=x_,P_.parse=A_,P_.fromJSON=k_,P_.list=M_,P_.comment=e=>new C_(e),P_.atRule=e=>new I_(e),P_.decl=e=>new y_(e),P_.rule=e=>new z_(e),P_.root=e=>new O_(e),P_.document=e=>new __(e),P_.CssSyntaxError=g_,P_.Declaration=y_,P_.Container=b_,P_.Processor=v_,P_.Document=__,P_.Comment=C_,P_.Warning=S_,P_.AtRule=I_,P_.Result=E_,P_.Input=T_,P_.Rule=z_,P_.Root=O_,P_.Node=R_,w_.registerPostcss(P_);var N_=P_;P_.default=P_;var L_=/* @__PURE__ */Xb(N_);L_.stringify,L_.fromJSON,L_.plugin,L_.parse,L_.list,L_.document,L_.comment,L_.atRule,L_.rule,L_.decl,L_.root,L_.CssSyntaxError,L_.Declaration,L_.Container,L_.Processor,L_.Document,L_.Comment,L_.Warning,L_.AtRule,L_.Result,L_.Input,L_.Rule,L_.Root,L_.Node;var D_=class e{constructor(...e){Qb(this,"parentElement",null),Qb(this,"parentNode",null),Qb(this,"ownerDocument"),Qb(this,"firstChild",null),Qb(this,"lastChild",null),Qb(this,"previousSibling",null),Qb(this,"nextSibling",null),Qb(this,"ELEMENT_NODE",1),Qb(this,"TEXT_NODE",3),Qb(this,"nodeType"),Qb(this,"nodeName"),Qb(this,"RRNodeType")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}},$_={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},j_={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},F_={};function U_(e){if(F_[e])return F_[e];const t=globalThis[e],n=t.prototype,r=e in $_?$_[e]:void 0,i=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),o=e in j_?j_[e]:void 0,s=Boolean(o&&o.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return F_[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");document.body.appendChild(r);const i=r.contentWindow;if(!i)return t.prototype;const o=i[e].prototype;return document.body.removeChild(r),o?F_[e]=o:n}catch{return n}}var B_={};function G_(e,t,n){var r;const i=`${e}.${String(n)}`;if(B_[i])return B_[i].call(t);const o=U_(e),s=null==(r=Object.getOwnPropertyDescriptor(o,n))?void 0:r.get;return s?(B_[i]=s,s.call(t)):t[n]}var W_={};function H_(e,t,n){const r=`${e}.${String(n)}`;if(W_[r])return W_[r].bind(t);const i=U_(e)[n];return"function"!=typeof i?t[n]:(W_[r]=i,i.bind(t))}function Z_(){return U_("MutationObserver").constructor}function V_(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var q_={ownerDocument:function(e){return G_("Node",e,"ownerDocument")},childNodes:function(e){return G_("Node",e,"childNodes")},parentNode:function(e){return G_("Node",e,"parentNode")},parentElement:function(e){return G_("Node",e,"parentElement")},textContent:function(e){return G_("Node",e,"textContent")},contains:function(e,t){return H_("Node",e,"contains")(t)},getRootNode:function(e){return H_("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?G_("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?G_("Element",e,"shadowRoot"):null},querySelector:function(e,t){return G_("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return G_("Element",e,"querySelectorAll")(t)},mutationObserver:Z_,patch:V_};function Y_(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var J_={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function K_(e,t,n={}){let r=null,i=0;return function(...o){const s=Date.now();i||!1!==n.leading||(i=s);const a=t-(s-i),l=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),i=s,e.apply(l,o)):r||!1===n.trailing||(r=setTimeout(()=>{i=!1===n.leading?0:Date.now(),r=null,e.apply(l,o)},a))}}function Q_(e,t,n,r,i=window){const o=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),o&&o.set&&o.set.call(this,e)}}),()=>Q_(e,t,o||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(J_=new Proxy(J_,{get:(e,t,n)=>Reflect.get(e,t,n)}));var X_=Date.now;function eS(e){var t,n,r,i;const o=e.document;return{left:o.scrollingElement?o.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:o.documentElement.scrollLeft||(null==o?void 0:o.body)&&(null==(t=q_.parentElement(o.body))?void 0:t.scrollLeft)||(null==(n=null==o?void 0:o.body)?void 0:n.scrollLeft)||0,top:o.scrollingElement?o.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==o?void 0:o.documentElement.scrollTop)||(null==o?void 0:o.body)&&(null==(r=q_.parentElement(o.body))?void 0:r.scrollTop)||(null==(i=null==o?void 0:o.body)?void 0:i.scrollTop)||0}}function tS(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function nS(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function rS(e){return e?e.nodeType===e.ELEMENT_NODE?e:q_.parentElement(e):null}function iS(e,t,n,r){if(!e)return!1;const i=rS(e);if(!i)return!1;try{if("string"==typeof t){if(i.classList.contains(t))return!0;if(r&&null!==i.closest("."+t))return!0}else if(ag(i,t,r))return!0}catch(o){}if(n){if(i.matches(n))return!0;if(r&&null!==i.closest(n))return!0}return!1}function oS(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function sS(e,t){if(zf(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=q_.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||sS(r,t))}function aS(e){return Boolean(e.changedTouches)}function lS(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function cS(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function dS(e){return!!e&&(e instanceof D_&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(q_.shadowRoot(e)))}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(X_=()=>/* @__PURE__ */(new Date).getTime());var uS=class{constructor(){yf(this,"id",1),yf(this,"styleIDMap",/* @__PURE__ */new WeakMap),yf(this,"idStyleMap",/* @__PURE__ */new Map)}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=/* @__PURE__ */new WeakMap,this.idStyleMap=/* @__PURE__ */new Map,this.id=1}generateId(){return this.id++}};function pS(e){var t;let n=null;return"getRootNode"in e&&(null==(t=q_.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&q_.host(q_.getRootNode(e))&&(n=q_.host(q_.getRootNode(e))),n}function hS(e){const t=q_.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=pS(n);)n=t;return n}(e);return q_.contains(t,n)}function mS(e){const t=q_.ownerDocument(e);return!!t&&(q_.contains(t,e)||hS(e))}var fS=/* @__PURE__ */(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(fS||{}),gS=/* @__PURE__ */(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(gS||{}),yS=/* @__PURE__ */(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(yS||{}),wS=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(wS||{}),bS=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(bS||{}),vS=/* @__PURE__ */(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(vS||{}),xS=/* @__PURE__ */(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(xS||{});function kS(e){return"__ln"in e}var _S,SS=class{constructor(){yf(this,"length",0),yf(this,"head",null),yf(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&kS(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&kS(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},CS=(e,t)=>`${e}@${t}`,IS=class{constructor(){yf(this,"frozen",!1),yf(this,"locked",!1),yf(this,"texts",[]),yf(this,"attributes",[]),yf(this,"attributeMap",/* @__PURE__ */new WeakMap),yf(this,"removes",[]),yf(this,"mapRemoves",[]),yf(this,"movedMap",{}),yf(this,"addedSet",/* @__PURE__ */new Set),yf(this,"movedSet",/* @__PURE__ */new Set),yf(this,"droppedSet",/* @__PURE__ */new Set),yf(this,"removesSubTreeCache",/* @__PURE__ */new Set),yf(this,"mutationCb"),yf(this,"blockClass"),yf(this,"blockSelector"),yf(this,"maskTextClass"),yf(this,"maskTextSelector"),yf(this,"inlineStylesheet"),yf(this,"maskInputOptions"),yf(this,"maskTextFn"),yf(this,"maskInputFn"),yf(this,"keepIframeSrcFn"),yf(this,"recordCanvas"),yf(this,"inlineImages"),yf(this,"slimDOMOptions"),yf(this,"dataURLOptions"),yf(this,"doc"),yf(this,"mirror"),yf(this,"iframeManager"),yf(this,"stylesheetManager"),yf(this,"shadowDomManager"),yf(this,"canvasManager"),yf(this,"processedNodeManager"),yf(this,"unattachedDoc"),yf(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),yf(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new SS,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},i=i=>{const o=q_.parentNode(i);if(!o||!mS(i))return;let s=!1;if(i.nodeType===Node.TEXT_NODE){const e=o.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(o)&&(s=!0)}const a=zf(o)?this.mirror.getId(pS(i)):this.mirror.getId(o),l=r(i);if(-1===a||-1===l)return n.addNode(i);const c=pg(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{lS(e,this.mirror)&&this.iframeManager.addIframe(e),cS(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),dS(i)&&this.shadowDomManager.addShadowRoot(q_.shadowRoot(i),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});c&&(e.push({parentId:a,nextId:l,node:c}),t.add(c.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)TS(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(q_.parentNode(a))||i(a);for(const a of this.addedSet)AS(this.droppedSet,a)||TS(this.removesSubTreeCache,a,this.mirror)?AS(this.movedSet,a)?i(a):this.droppedSet.add(a):i(a);let o=null;for(;n.length;){let e=null;if(o){const t=this.mirror.getId(q_.parentNode(o.value)),n=r(o.value);-1!==t&&-1!==n&&(e=o)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(q_.parentNode(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=q_.parentNode(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=q_.host(r);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}o=e.previous,n.removeNode(e.value),i(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=q_.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=/* @__PURE__ */new WeakMap,this.removes=[],this.addedSet=/* @__PURE__ */new Set,this.movedSet=/* @__PURE__ */new Set,this.droppedSet=/* @__PURE__ */new Set,this.removesSubTreeCache=/* @__PURE__ */new Set,this.movedMap={},this.mutationCb(s))}),yf(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const n=Array.from(q_.childNodes(e),e=>q_.textContent(e)||"").join("");t.attributes.value=Lf({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:jf(e),value:n,maskInputFn:this.maskInputFn})}),yf(this,"processMutation",e=>{if(!oS(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=q_.textContent(e.target);iS(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:lg(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,rS(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const n=e.target;let r=e.attributeName,i=e.target.getAttribute(r);if("value"===r){const e=jf(n);i=Lf({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:i,maskInputFn:this.maskInputFn})}if(iS(e.target,this.blockClass,this.blockSelector,!1)||i===e.oldValue)return;let o=this.attributeMap.get(e.target);if("IFRAME"===n.tagName&&"src"===r&&!this.keepIframeSrcFn(i)){if(n.contentDocument)return;r="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===r&&"INPUT"===n.tagName&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!sg(n.tagName,r))if(o.attributes[r]=og(this.doc,Df(n.tagName),Df(r),i),"style"===r){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(t){this.unattachedDoc=this.doc}const r=this.unattachedDoc.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(n.style)){const t=n.style.getPropertyValue(e),i=n.style.getPropertyPriority(e);t!==r.style.getPropertyValue(e)||i!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===i?t:[t,i]:o._unchangedStyles[e]=[t,i]}for(const e of Array.from(r.style))""===n.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}else"open"===r&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?o.attributes.rr_open_mode="modal":o.attributes.rr_open_mode="non-modal");break}case"childList":if(iS(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),r=zf(e.target)?this.mirror.getId(q_.host(e.target)):this.mirror.getId(e.target);iS(e.target,this.blockClass,this.blockSelector,!1)||oS(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(ES(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||sS(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[CS(n,r)]?ES(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!zf(e.target)||!Of(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),q_.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),yf(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(oS(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[CS(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);iS(e,this.blockClass,this.blockSelector,!1)||(q_.childNodes(e).forEach(e=>this.genAdds(e)),dS(e)&&q_.childNodes(q_.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function ES(e,t){e.delete(t),q_.childNodes(t).forEach(t=>ES(e,t))}function TS(e,t,n){return 0!==e.size&&function(e,t){const n=q_.parentNode(t);return!!n&&e.has(n)}(e,t)}function AS(e,t){return 0!==e.size&&MS(e,t)}function MS(e,t){const n=q_.parentNode(t);return!!n&&(!!e.has(n)||MS(e,n))}var zS=e=>{if(!_S)return e;return(...t)=>{try{return e(...t)}catch(n){if(_S&&!0===_S(n))return;throw n}}},OS=[];function RS(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function PS(e,t){const n=new IS;OS.push(n),n.init(e);const r=new(Z_())(zS(n.processMutations.bind(n)));return r.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),r}function NS({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){if(!1===o.mouseInteraction)return()=>{};const s=!0===o.mouseInteraction||void 0===o.mouseInteraction?{}:o.mouseInteraction,a=[];let l=null;return Object.keys(yS).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(o=>{let s=Df(o);const c=(t=>o=>{const s=RS(o);if(iS(s,r,i,!0))return;let a=null,c=t;if("pointerType"in o){switch(o.pointerType){case"mouse":a=wS.Mouse;break;case"touch":a=wS.Touch;break;case"pen":a=wS.Pen}a===wS.Touch?yS[t]===yS.MouseDown?c="TouchStart":yS[t]===yS.MouseUp&&(c="TouchEnd"):wS.Pen}else aS(o)&&(a=wS.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===wS.Touch||c.startsWith("Mouse")&&a===wS.Mouse)&&(a=null)):yS[t]===yS.Click&&(a=l,l=null);const d=aS(o)?o.changedTouches[0]:o;if(!d)return;const u=n.getId(s),{clientX:p,clientY:h}=d;zS(e)({type:yS[c],id:u,x:p,y:h,...null!==a&&{pointerType:a}})})(o);if(window.PointerEvent)switch(yS[o]){case yS.MouseDown:case yS.MouseUp:s=s.replace("mouse","pointer");break;case yS.TouchStart:case yS.TouchEnd:return}a.push(Y_(s,c,t))}),zS(()=>{a.forEach(e=>e())})}function LS({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){return Y_("scroll",zS(K_(zS(o=>{const s=RS(o);if(!s||iS(s,r,i,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=eS(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),o.scroll||100)),t)}var DS=["INPUT","TEXTAREA","SELECT"],$S=/* @__PURE__ */new WeakMap;function jS(e){return function(e,t){if(GS("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||GS("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||GS("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||GS("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function FS(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function US({mirror:e,stylesheetManager:t},n){var r,i,o;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(q_.host(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(o=null==(i=n.ownerDocument)?void 0:i.defaultView)?void 0:o.ShadowRoot,l=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null==(e=l.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=l.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(i){}return r}}),zS(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function BS(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:o,viewportResizeCb:s,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),i(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),o(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}(e,t),e.recordDOM&&(r=PS(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const i="number"==typeof t.mousemove?t.mousemove:50,o="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const l=K_(zS(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),o),c=zS(K_(zS(e=>{const t=RS(e),{clientX:n,clientY:i}=aS(e)?e.changedTouches[0]:e;s||(s=X_()),a.push({x:n,y:i,id:r.getId(t),timeOffset:X_()-s}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?gS.Drag:e instanceof MouseEvent?gS.MouseMove:gS.TouchMove)}),i,{trailing:!1})),d=[Y_("mousemove",c,n),Y_("touchmove",c,n),Y_("drag",c,n)];return zS(()=>{d.forEach(e=>e())})}(e),o=NS(e),s=LS(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Y_("resize",zS(K_(zS(()=>{const t=tS(),i=nS();n===t&&r===i||(e({width:Number(i),height:Number(t)}),n=t,r=i)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:o,ignoreSelector:s,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(e){let n=RS(e);const c=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=q_.parentElement(n)),!n||!u||DS.indexOf(u)<0||iS(n,r,i,!0))return;if(n.classList.contains(o)||s&&n.matches(s))return;let h=n.value,m=!1;const f=jf(n)||"";"radio"===f||"checkbox"===f?m=n.checked:(a[u.toLowerCase()]||a[f])&&(h=Lf({element:n,maskInputOptions:a,tagName:u,type:f,value:h,maskInputFn:l})),p(n,d?{text:h,isChecked:m,userTriggered:c}:{text:h,isChecked:m});const g=n.name;"radio"===f&&g&&m&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,d?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function p(t,r){const i=$S.get(t);if(!i||i.text!==r.text||i.isChecked!==r.isChecked){$S.set(t,r);const i=n.getId(t);zS(e)({...r,id:i})}}const h=("last"===c.input?["change"]:["input","change"]).map(e=>Y_(e,zS(u),t)),m=t.defaultView;if(!m)return()=>{h.forEach(e=>e())};const f=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),g=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return f&&f.set&&h.push(...g.map(e=>Q_(e[0],e[1],{set(){zS(u)({target:this,isTrusted:!1})}},!1,m))),zS(()=>{h.forEach(e=>e())})}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i,doc:o}){const s=zS(o=>K_(zS(i=>{const s=RS(i);if(!s||iS(s,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d,loop:u}=s;e({type:o,id:r.getId(s),currentTime:a,volume:l,muted:c,playbackRate:d,loop:u})}),i.media||500)),a=[Y_("play",s(vS.Play),o),Y_("pause",s(vS.Pause),o),Y_("seeked",s(vS.Seeked),o),Y_("volumechange",s(vS.VolumeChange),o),Y_("ratechange",s(vS.RateChange),o)];return zS(()=>{a.forEach(e=>e())})}(e);let d=()=>{},u=()=>{},p=()=>{},h=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:zS((r,i,o)=>{const[s,a]=o,{id:l,styleId:c}=FS(i,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:a}]}),r.apply(i,o)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const i=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[i,n])};const o=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:zS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=FS(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:s}]}),r.apply(i,o)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:zS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=FS(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:s}),r.apply(i,o)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:zS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=FS(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:s}),r.apply(i,o)})}));const l={};WS("CSSGroupingRule")?l.CSSGroupingRule=r.CSSGroupingRule:(WS("CSSMediaRule")&&(l.CSSMediaRule=r.CSSMediaRule),WS("CSSConditionRule")&&(l.CSSConditionRule=r.CSSConditionRule),WS("CSSSupportsRule")&&(l.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(l).forEach(([r,i])=>{c[r]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=new Proxy(c[r].insertRule,{apply:zS((r,i,o)=>{const[s,a]=o,{id:l,styleId:c}=FS(i.parentStyleSheet,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:[...jS(i),a||0]}]}),r.apply(i,o)})}),i.prototype.deleteRule=new Proxy(c[r].deleteRule,{apply:zS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=FS(i.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...jS(i),s]}]}),r.apply(i,o)})})}),zS(()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=o,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})})}(e,{win:n}),u=US(e,e.doc),p=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){const o=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:zS((i,s,a)=>{var l;const[c,d,u]=a;if(n.has(c))return o.apply(s,[c,d,u]);const{id:p,styleId:h}=FS(null==(l=s.parentRule)?void 0:l.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:c,value:d,priority:u},index:jS(s.parentRule)}),i.apply(s,a)})});const s=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:zS((i,o,a)=>{var l;const[c]=a;if(n.has(c))return s.apply(o,[c]);const{id:d,styleId:u}=FS(null==(l=o.parentRule)?void 0:l.parentStyleSheet,t,r.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:c},index:jS(o.parentRule)}),i.apply(o,a)})}),zS(()=>{i.CSSStyleDeclaration.prototype.setProperty=o,i.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(h=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],i=/* @__PURE__ */new WeakMap,o=n.FontFace;n.FontFace=function(e,t,n){const r=new o(e,t,n);return i.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=V_(t.fonts,"add",function(t){return function(n){return setTimeout(zS(()=>{const t=i.get(n);t&&(e(t),i.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=o}),r.push(s),zS(()=>{r.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:o}=e;let s=!0;const a=zS(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const{startContainer:o,startOffset:s,endContainer:l,endOffset:c}=e.getRangeAt(t);iS(o,r,i,!0)||iS(l,r,i,!0)||a.push({start:n.getId(o),startOffset:s,end:n.getId(l),endOffset:c})}o({ranges:a})});return a(),Y_("selectionchange",a)}(e),f=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?V_(n.customElements,"define",function(e){return function(n,r,i){try{t({define:{name:n}})}catch(o){}return e.apply(this,[n,r,i])}}):()=>{}}(e),g=[];for(const y of e.plugins)g.push(y.observer(y.callback,n,y.options));return zS(()=>{OS.forEach(e=>e.reset()),r?.disconnect(),i(),o(),s(),a(),l(),c(),d(),u(),p(),h(),m(),f(),g.forEach(e=>e())})}function GS(e){return void 0!==window[e]}function WS(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var HS=class{constructor(e){yf(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),yf(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const i=n||this.getIdToRemoteIdMap(e),o=r||this.getRemoteIdToIdMap(e);let s=i.get(t);return s||(s=this.generateIdFn(),i.set(t,s),o.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const i=r.get(t);return i||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=/* @__PURE__ */new WeakMap,void(this.iframeRemoteIdToIdMap=/* @__PURE__ */new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}},ZS=class{constructor(e){yf(this,"iframes",/* @__PURE__ */new WeakMap),yf(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),yf(this,"crossOriginIframeMirror",new HS(Qf)),yf(this,"crossOriginIframeStyleMirror"),yf(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),yf(this,"mirror"),yf(this,"mutationCb"),yf(this,"wrappedEmit"),yf(this,"loadListener"),yf(this,"stylesheetManager"),yf(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new HS(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,r;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(n=e.contentWindow)||n.addEventListener("message",this.handleMessage.bind(this))),null==(r=this.loadListener)||r.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case fS.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:fS.IncrementalSnapshot,data:{source:gS.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case fS.Meta:case fS.Load:case fS.DomContentLoaded:return!1;case fS.Plugin:return t;case fS.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case fS.IncrementalSnapshot:switch(t.data.source){case gS.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case gS.Drag:case gS.TouchMove:case gS.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case gS.ViewportResize:return!1;case gS.MediaInteraction:case gS.MouseInteraction:case gS.Scroll:case gS.CanvasMutation:case gS.Input:return this.replaceIds(t.data,e,["id"]),t;case gS.StyleSheetRule:case gS.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case gS.Font:return t;case gS.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case gS.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(n=t.data.styles)||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,r){for(const i of r)(Array.isArray(t[i])||"number"==typeof t[i])&&(Array.isArray(t[i])?t[i]=e.getIds(n,t[i]):t[i]=e.getId(n,t[i]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===xS.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},VS=class{constructor(e){yf(this,"shadowDoms",/* @__PURE__ */new WeakSet),yf(this,"mutationCb"),yf(this,"scrollCb"),yf(this,"bypassOptions"),yf(this,"mirror"),yf(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!Of(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=PS({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(LS({...this.bypassOptions,scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(q_.host(e))),this.restoreHandlers.push(US({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(V_(e.prototype,"attachShadow",function(e){return function(r){const i=e.call(this,r),o=q_.shadowRoot(this);return o&&mS(this)&&n.addShadowRoot(o,t),i}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},qS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",YS="undefined"==typeof Uint8Array?[]:new Uint8Array(256),JS=0;JS<64;JS++)YS[qS.charCodeAt(JS)]=JS;var KS=function(e){var t,n=new Uint8Array(e),r=n.length,i="";for(t=0;t<r;t+=3)i+=qS[n[t]>>2],i+=qS[(3&n[t])<<4|n[t+1]>>4],i+=qS[(15&n[t+1])<<2|n[t+2]>>6],i+=qS[63&n[t+2]];return r%3==2?i=i.substring(0,i.length-1)+"=":r%3==1&&(i=i.substring(0,i.length-2)+"=="),i},QS=/* @__PURE__ */new Map;var XS=(e,t,n)=>{if(!e||!nC(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=QS.get(e);return n||(n=/* @__PURE__ */new Map,QS.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let i=r.indexOf(e);return-1===i&&(i=r.length,r.push(e)),i};function eC(e,t,n){if(e instanceof Array)return e.map(e=>eC(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:KS(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[eC(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[eC(e.data,t,n),e.width,e.height]}:nC(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:XS(e,t,n)}:e}var tC=(e,t,n)=>e.map(e=>eC(e,t,n)),nC=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function rC(e,t,n,r){const i=[];try{const o=V_(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(i,...o){if(!iS(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(i);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(o[0]&&"object"==typeof o[0]){const e=o[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else o.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[i,...o])}});i.push(o)}catch{}return()=>{i.forEach(e=>e())}}function iC(e,t,n,r,i,o){const s=[],a=Object.getOwnPropertyNames(e);for(const l of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if("function"!=typeof e[l])continue;const a=V_(e,l,function(e){return function(...s){const a=e.apply(this,s);if(XS(a,o,this),"tagName"in this.canvas&&!iS(this.canvas,r,i,!0)){const e={type:t,property:l,args:tC(s,o,this)};n(this.canvas,e)}return a}});s.push(a)}catch{const r=Q_(e,l,{set(e){n(this.canvas,{type:t,property:l,args:[e],setter:!0})}});s.push(r)}return s}var oC="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",sC="undefined"!=typeof window&&window.Blob&&new Blob([(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0)))(oC)],{type:"text/javascript;charset=utf-8"});function aC(e){let t;try{if(t=sC&&(window.URL||window.webkitURL).createObjectURL(sC),!t)throw"";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),n}catch(n){return new Worker("data:text/javascript;base64,"+oC,{name:null==e?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}var lC,cC,dC,uC=class{constructor(e){yf(this,"pendingCanvasMutations",/* @__PURE__ */new Map),yf(this,"rafStamps",{latestId:0,invokeId:null}),yf(this,"mirror"),yf(this,"mutationCb"),yf(this,"resetObservers"),yf(this,"frozen",!1),yf(this,"locked",!1),yf(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:n,blockClass:r,blockSelector:i,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,i),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,i,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){const o=rC(t,n,r,!0),s=/* @__PURE__ */new Map,a=new aC;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:i,height:o}=e.data;this.mutationCb({id:t,type:bS["2D"],commands:[{property:"clearRect",args:[0,0,i,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{iS(t,n,r,!0)||e.push(t)}),e})().forEach(async e=>{var t;const n=this.mirror.getId(e);if(s.get(n))return;if(0===e.width||0===e.height)return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null==(t=null==n?void 0:n.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=await createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[r])})),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{o(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=rC(e,t,n,!1),i=function(e,t,n,r){const i=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const o=V_(t.CanvasRenderingContext2D.prototype,s,function(i){return function(...o){return iS(this.canvas,n,r,!0)||setTimeout(()=>{const n=tC(o,t,this);e(this.canvas,{type:bS["2D"],property:s,args:n})},0),i.apply(this,o)}});i.push(o)}catch{const n=Q_(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:bS["2D"],property:s,args:[t],setter:!0})}});i.push(n)}return()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const i=[];return i.push(...iC(t.WebGLRenderingContext.prototype,bS.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&i.push(...iC(t.WebGL2RenderingContext.prototype,bS.WebGL2,e,n,r,t)),()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},pC=class{constructor(e){yf(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),yf(this,"mutationCb"),yf(this,"adoptedStyleSheetCb"),yf(this,"styleMirror",new uS),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const i of e){let e;this.styleMirror.has(i)?e=this.styleMirror.getId(i):(e=this.styleMirror.add(i),r.push({styleId:e,rules:Array.from(i.rules||CSSRule,(e,t)=>({rule:Pf(e,i.href),index:t}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=/* @__PURE__ */new WeakSet}trackStylesheetInLinkElement(e){}},hC=class{constructor(){yf(this,"nodeMap",/* @__PURE__ */new WeakMap),yf(this,"active",!1)}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=/* @__PURE__ */new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||/* @__PURE__ */new Set).add(t))}destroy(){}},mC=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(rf=e.contentWindow)?void 0:rf.Array.from)||Array.from,document.body.removeChild(e)}}catch(vI){}var fC,gC,yC=new Nf;function wC(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:p,slimDOMOptions:h,maskInputFn:m,maskTextFn:f,hooks:g,packFn:y,sampling:w={},dataURLOptions:b={},mousemoveWait:v,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:_=!1,recordAfter:S=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:C=!1,collectFonts:I=!1,inlineImages:E=!1,plugins:T,keepIframeSrcFn:A=()=>!1,ignoreCSSAttributes:M=/* @__PURE__ */new Set([]),errorHandler:z}=e;_S=z;const O=!_||window.parent===window;let R=!1;if(!O)try{window.parent.document&&(R=!1)}catch(Z){R=!0}if(O&&!t)throw new Error("emit function is required");if(!O&&!R)return()=>{};void 0!==v&&void 0===w.mousemove&&(w.mousemove=v),yC.reset();const P=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==p?p:{password:!0},N=ug(h);let L;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();let D=0;const $=e=>{for(const t of T||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!R&&(e=y(e)),e};lC=(e,i)=>{var o;const s=e;if(s.timestamp=X_(),!(null==(o=OS[0])?void 0:o.isFrozen())||s.type===fS.FullSnapshot||s.type===fS.IncrementalSnapshot&&s.data.source===gS.Mutation||OS.forEach(e=>e.unfreeze()),O)t?.($(s),i);else if(R){const e={type:"rrweb",event:$(s),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,"*")}if(s.type===fS.FullSnapshot)L=s,D=0;else if(s.type===fS.IncrementalSnapshot){if(s.data.source===gS.Mutation&&s.data.isAttachIframe)return;D++;const e=r&&D>=r,t=n&&s.timestamp-L.timestamp>n;(e||t)&&cC(!0)}};const j=e=>{lC({type:fS.IncrementalSnapshot,data:{source:gS.Mutation,...e}})},F=e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.Scroll,...e}}),U=e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.CanvasMutation,...e}}),B=new pC({mutationCb:j,adoptedStyleSheetCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.AdoptedStyleSheet,...e}})}),G=new ZS({mirror:yC,mutationCb:j,stylesheetManager:B,recordCrossOriginIframes:_,wrappedEmit:lC});for(const q of T||[])q.getMirror&&q.getMirror({nodeMirror:yC,crossOriginIframeMirror:G.crossOriginIframeMirror,crossOriginIframeStyleMirror:G.crossOriginIframeStyleMirror});const W=new hC;dC=new uC({recordCanvas:k,mutationCb:U,win:window,blockClass:i,blockSelector:o,mirror:yC,sampling:w.canvas,dataURLOptions:b});const H=new VS({mutationCb:j,scrollCb:F,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:P,dataURLOptions:b,maskTextFn:f,maskInputFn:m,recordCanvas:k,inlineImages:E,sampling:w,slimDOMOptions:N,iframeManager:G,stylesheetManager:B,canvasManager:dC,keepIframeSrcFn:A,processedNodeManager:W},mirror:yC});cC=(e=!1)=>{if(!x)return;lC({type:fS.Meta,data:{href:window.location.href,width:nS(),height:tS()}},e),B.reset(),H.init(),OS.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new Nf,blockClass:r="rr-block",blockSelector:i=null,maskTextClass:o="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:p,slimDOM:h=!1,dataURLOptions:m,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x=()=>!1}=t||{};return pg(e,{doc:e,mirror:n,blockClass:r,blockSelector:i,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:ug(h),dataURLOptions:m,inlineImages:l,recordCanvas:c,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:yC,blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:P,maskTextFn:f,maskInputFn:m,slimDOM:N,dataURLOptions:b,recordCanvas:k,inlineImages:E,onSerialize:e=>{lS(e,yC)&&G.addIframe(e),cS(e,yC)&&B.trackLinkElement(e),dS(e)&&H.addShadowRoot(q_.shadowRoot(e),document)},onIframeLoad:(e,t)=>{G.attachIframe(e,t),H.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{B.attachLinkElement(e,t)},keepIframeSrcFn:A});t&&(lC({type:fS.FullSnapshot,data:{node:t,initialOffset:eS(window)}},e),OS.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&B.adoptStyleSheets(document.adoptedStyleSheets,yC.getId(document)))};try{const e=[],t=e=>{var t;return zS(BS)({mutationCb:j,mousemoveCb:(e,t)=>lC({type:fS.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.MouseInteraction,...e}}),scrollCb:F,viewportResizeCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.ViewportResize,...e}}),inputCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.Input,...e}}),mediaInteractionCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.MediaInteraction,...e}}),styleSheetRuleCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.StyleSheetRule,...e}}),styleDeclarationCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.StyleDeclaration,...e}}),canvasMutationCb:U,fontCb:e=>lC({type:fS.IncrementalSnapshot,data:{source:gS.Font,...e}}),selectionCb:e=>{lC({type:fS.IncrementalSnapshot,data:{source:gS.Selection,...e}})},customElementCb:e=>{lC({type:fS.IncrementalSnapshot,data:{source:gS.CustomElement,...e}})},blockClass:i,ignoreClass:s,ignoreSelector:a,maskTextClass:l,maskTextSelector:c,maskInputOptions:P,inlineStylesheet:d,sampling:w,recordDOM:x,recordCanvas:k,inlineImages:E,userTriggeredOnInput:C,collectFonts:I,doc:e,maskInputFn:m,maskTextFn:f,keepIframeSrcFn:A,blockSelector:o,slimDOMOptions:N,dataURLOptions:b,mirror:yC,iframeManager:G,stylesheetManager:B,shadowDomManager:H,processedNodeManager:W,canvasManager:dC,ignoreCSSAttributes:M,plugins:(null==(t=null==T?void 0:T.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>lC({type:fS.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};G.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){}});const n=()=>{cC(),e.push(t(document)),mC=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(Y_("DOMContentLoaded",()=>{lC({type:fS.DomContentLoaded,data:{}}),"DOMContentLoaded"===S&&n()})),e.push(Y_("load",()=>{lC({type:fS.Load,data:{}}),"load"===S&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")}}),W.destroy(),mC=!1,_S=void 0}}catch(V){}}wC.addCustomEvent=(e,t)=>{if(!mC)throw new Error("please add custom event after start recording");lC({type:fS.Custom,data:{tag:e,payload:t}})},wC.freezePage=()=>{OS.forEach(e=>e.freeze())},wC.takeFullSnapshot=e=>{if(!mC)throw new Error("please take full snapshot after start recording");cC(e)},wC.mirror=yC,(gC=fC||(fC={}))[gC.NotStarted=0]="NotStarted",gC[gC.Running=1]="Running",gC[gC.Stopped=2]="Stopped";var bC=Cd(),vC=500,xC=5e5,kC=class{eventQueue=[];estimatedQueueBytes=0;sessionId;stopRecording=null;isRecording=!1;chatId;applicationId;metadataSent=!1;startPromise=null;stopRequested=!1;flushTimer=null;consecutiveFailures=0;isFlushing=!1;constructor(e,t){if(!e||""===e.trim())throw new Error("chatId is required for SessionRecorder");if(!t||t<=0)throw new Error("applicationId (mtxApp) is required for SessionRecorder");bC.info("Constructor called with chatId:",e,"applicationId:",t),this.chatId=e,this.applicationId=t,this.sessionId=e,bC.info("Initialized with sessionId:",this.sessionId)}async sendMetadata(){this.metadataSent?bC.warn("Metadata already sent, skipping"):(bC.info("Sending rrweb/metadata via POST"),await xd.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/metadata",session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,user_agent:navigator.userAgent,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.metadataSent=!0,bC.info("✅ rrweb/metadata sent successfully"))}bufferEvent(e){if(this.eventQueue.push(e),this.estimatedQueueBytes+=new Blob([JSON.stringify(e)]).size,this.eventQueue.length>vC){const e=this.eventQueue.length-vC,t=this.eventQueue.splice(0,e);for(const n of t)this.estimatedQueueBytes-=JSON.stringify(n).length;bC.warn(`⚠️ Event queue exceeded 500, dropped ${e} oldest events`)}this.estimatedQueueBytes>=5e4?this.flush():this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},500))}flush(){if(this.isFlushing)return;if(this.isFlushing=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),0===this.eventQueue.length)return void(this.isFlushing=!1);let e,t;if(this.estimatedQueueBytes<=xC)e=this.eventQueue,t=this.estimatedQueueBytes,this.eventQueue=[],this.estimatedQueueBytes=0;else{for(e=[],t=0;this.eventQueue.length>0;){const n=this.eventQueue[0];if(void 0===n)break;const r=JSON.stringify(n).length;if(t+r>xC&&e.length>0)break;const i=this.eventQueue.shift();void 0!==i&&e.push(i),t+=r,this.estimatedQueueBytes-=r}this.eventQueue.length>0&&!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},0))}bC.debug(`Flushing ${e.length} events (~${t} bytes)`),xd.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/events",session_id:this.sessionId,events:e}}).then(()=>{this.consecutiveFailures=0}).catch(n=>{const r=null!=n&&"object"==typeof n&&"status"in n?n.status:null;if("number"==typeof r&&r>=400&&r<500)return bC.error(`Dropping ${e.length} events after permanent ${String(r)} error:`,n),void(this.consecutiveFailures=0);if(this.consecutiveFailures++,this.consecutiveFailures>5)return bC.error(`Dropping ${e.length} events after 5 consecutive failures:`,n),void(this.consecutiveFailures=0);if(bC.error(`Failed to flush events (attempt ${this.consecutiveFailures}/5), re-queuing:`,n),this.eventQueue=e.concat(this.eventQueue),this.estimatedQueueBytes+=t,this.eventQueue.length>vC){const e=this.eventQueue.length-vC,t=this.eventQueue.splice(0,e);for(const n of t)this.estimatedQueueBytes-=JSON.stringify(n).length;bC.warn(`⚠️ Event queue exceeded 500 after re-queue, dropped ${e} oldest events`)}}).finally(()=>{this.isFlushing=!1})}async start(){if(this.isRecording)bC.warn("Recording already started");else{if(this.startPromise)return this.startPromise;this.startPromise=this.doStart();try{await this.startPromise}finally{this.startPromise=null}}}async doStart(){this.stopRequested=!1;try{if(bC.info("🚀 start() called"),await this.sendMetadata(),this.stopRequested)throw new Error("Recording stopped during startup");const e={emit:e=>{this.bufferEvent(e)},recordCanvas:!1,recordCrossOriginIframes:!1,maskAllInputs:!1,collectFonts:!1,inlineStylesheet:!0,blockClass:"rr-block",ignoreClass:"rr-ignore"};this.stopRecording=wC(e),this.isRecording=!0,bC.info("Recording started with chatId:",this.sessionId)}catch(e){throw bC.error("Failed to start recording:",e),e}}stop(){this.stopRequested=!0,this.stopRecording&&(this.stopRecording(),this.stopRecording=null),(this.isRecording||this.eventQueue.length>0)&&this.flush(),this.isRecording=!1,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.metadataSent=!1,bC.info("Recording stopped")}getSessionId(){return this.sessionId}isActive(){return this.isRecording}},_C=e=>e?.mtxApiHost?e.mtxApiHost:"";function SC(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function CC(e,t="Operation",n){const r=SC(e);return function(e){const t=e instanceof Error?e.message:String(e);return t.includes("Failed to fetch")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("NetworkError")||t.includes("Network request failed")}(e)?{isValid:!1,error:`Cannot connect to API server. Please ensure the API server is running at ${_C(n)||"configured API server"}. Error: ${r}`}:{isValid:!1,error:`${t} failed: ${r}`}}var IC=class{config;async validateConfig(e){return this.config=e,e.mtxId&&e.mtxKey?this.validateByMarketrixId(e.mtxId,e.mtxKey):e.mtxApp&&e.mtxAgent?this.validateByAgentAndApplication(e.mtxApp,e.mtxAgent):{isValid:!1,error:"Please provide either (mtxId + mtxKey) OR (mtxApp + mtxAgent)"}}async validateByMarketrixId(e,t){try{const{items:r}=await xd.widgetSearch({marketrix_id:e,marketrix_key:t});if(!r||0===r.length)return{isValid:!1,error:"Widget not found or invalid credentials"};const i=r.find(e=>"widget"===e.type&&"active"===e.status);if(!i){const e=r.filter(e=>"widget"===e.type);return e.length>0?{isValid:!1,error:`Found widget(s) but none are active. Current status(es): ${e.map(e=>e.status).join(", ")}. Please activate the widget in the dashboard.`}:0===r.length?{isValid:!1,error:"No widgets found for the provided marketrix_id and marketrix_key. Please verify your credentials."}:{isValid:!1,error:`No widget found. Found widget type(s): ${r.map(e=>e.type).join(", ")}. Please create a widget.`}}if(!i.agent_id)return{isValid:!1,error:"Widget missing agent_id",widget:i};try{const e=await xd.agentGet({agent_id:i.agent_id});if(!i.application_id)return{isValid:!1,error:"Widget missing application_id",widget:i,agent:e};return{isValid:!0,widget:i,agent:e,application:await xd.applicationGet({application_id:i.application_id})}}catch(n){return{isValid:!1,error:`Failed to validate agent: ${SC(n)}`,widget:i}}}catch(r){return CC(r,"Widget validation",this.config)}}async validateByAgentAndApplication(e,t){try{const n=await xd.applicationGet({application_id:e}),r=await xd.agentGet({agent_id:t});return r.application_id!==e?{isValid:!1,error:`Agent ID ${t} belongs to application ID ${r.application_id}, but provided application ID is ${e}. Please verify the application ID matches the agent's application_id.`,application:n,agent:r}:{isValid:!0,application:n,agent:r}}catch(n){return CC(n,"Agent and application validation",this.config)}}};function EC(e,t){return"object"==typeof e&&null!==e&&t in e}function TC(e){return null!==e&&e instanceof HTMLElement}function AC(e){return null!==e&&e instanceof HTMLScriptElement}var MC=null,zC=class{mtxId;mtxKey;mtxApp;constructor(e,t,n){this.mtxId=e,this.mtxKey=t,this.mtxApp=n}async fetchWidgetSettings(){if(!this.mtxId&&!this.mtxKey&&!this.mtxApp)return null;try{MC||(MC=await xd.widgetGetDefaults({type:"widget"}));const e=MC;if(!e){throw new Error("Failed to fetch default widget settings from API. The API must return widget settings.")}let t=null;if(this.mtxId&&this.mtxKey)t=(await xd.widgetSearch({type:"widget",marketrix_id:this.mtxId,marketrix_key:this.mtxKey})).items;else{if(!this.mtxApp)return null;t=(await xd.widgetSearch({type:"widget",application_id:this.mtxApp})).items}const n=t?.find(e=>"active"===e.status&&"widget"===e.type)||null;if(n?.settings){const t=this.getWidgetSettings(n);if(t){const r={...e,...t};return{...n,settings:r}}}const r=/* @__PURE__ */new Date;return{id:0,application_id:this.mtxApp||0,agent_id:0,type:"widget",settings:e,status:"active",marketrix_id:this.mtxId||"",marketrix_key:this.mtxKey||"",created_at:r,updated_at:r}}catch(e){const t=e instanceof Error?e.message:"Unknown error",n=/* @__PURE__ */new Error(`Failed to fetch widget settings from API: ${t}`);throw n.cause=e,n}}getWidgetSettings(e){if(!e?.settings)return null;const t=e.settings;return function(e){return"object"==typeof e&&null!==e}(n=t)&&EC(n,"widget_enabled")&&"boolean"==typeof n.widget_enabled&&EC(n,"widget_appearance")&&"string"==typeof n.widget_appearance&&EC(n,"widget_position")&&"string"==typeof n.widget_position?t:null;var n}},OC="#6b7280",RC="#1f2937",PC="rgba(255, 255, 255, 0.95)",NC="rgba(255, 255, 255, 0.2)",LC="rgba(0, 0, 0, 0.15)",DC=({message:e="Loading widget settings..."})=>{const[t,n]=p(!1),r=e?.includes("marketrix_id")||e?.includes("marketrix_key");return t?null:/* @__PURE__ */g(Zp,{position:"fixed",style:{bottom:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"420px",backgroundColor:PC,borderRadius:r?"18px":"999px",boxShadow:`0 2px 12px ${LC}`,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"8px",padding:"10px 12px",border:`1px solid ${NC}`,zIndex:9999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[/* @__PURE__ */g(Dh,{align:"center",style:{gap:"10px"},children:[
65
- /* @__PURE__ */f(Yp,{src:Vp,alt:"",size:28,style:{borderRadius:"50%",overflow:"hidden",flexShrink:0}}),
66
- /* @__PURE__ */f(qh,{as:"span",style:{fontSize:"13px",color:RC,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:e}),
67
- /* @__PURE__ */f(Gh,{label:"Dismiss",onClick:()=>n(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:OC,borderRadius:"50%",width:"20px",height:"20px",minWidth:"unset"},children:/* @__PURE__ */f(jh,{name:"closeSmall",size:12})})]}),r?/* @__PURE__ */f(qh,{as:"p",style:{fontSize:"12px",color:OC,textAlign:"left",margin:0},children:"Please configure marketrix_id and marketrix_key"}):null]})},$C='/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-900:oklch(21% .034 264.665);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-2{inset:calc(var(--spacing) * 2)}.inset-3{inset:calc(var(--spacing) * 3)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing) * 4)}.top-5{top:calc(var(--spacing) * 5)}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-4{right:calc(var(--spacing) * 4)}.right-5{right:calc(var(--spacing) * 5)}.right-full{right:100%}.bottom-5{bottom:calc(var(--spacing) * 5)}.bottom-16{bottom:calc(var(--spacing) * 16)}.left-0{left:calc(var(--spacing) * 0)}.left-1\\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.left-full{left:100%}.isolate{isolation:isolate}.z-10{z-index:10}.z-20{z-index:20}.z-\\[calc\\(var\\(--layer-dialog\\)\\+1\\)\\]{z-index:calc(var(--layer-dialog) + 1)}.z-\\[var\\(--layer-popover\\)\\]{z-index:var(--layer-popover)}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.m-2{margin:calc(var(--spacing) * 2)}.m-32{margin:calc(var(--spacing) * 32)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-0\\.5{margin-block:calc(var(--spacing) * .5)}.mt-0\\.5{margin-top:calc(var(--spacing) * .5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-0{margin-bottom:calc(var(--spacing) * 0)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.h-0{height:calc(var(--spacing) * 0)}.h-0\\.5{height:calc(var(--spacing) * .5)}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-3\\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[85vh\\]{max-height:85vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-20{min-height:calc(var(--spacing) * 20)}.w-0{width:calc(var(--spacing) * 0)}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-3\\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-full{width:100%}.max-w-\\[500px\\]{max-width:500px}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-14{min-width:calc(var(--spacing) * 14)}.min-w-\\[180px\\]{min-width:180px}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-dialog-content-in{animation:dialog-content-in var(--duration-animation) ease-out}.animate-fade-in{animation:.5s ease-out fade-in}.animate-menu-in{animation:menu-in var(--duration-fade) ease-out}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-\\[var\\(--radius\\)\\]{border-radius:var(--radius)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-4{border-top-style:var(--tw-border-style);border-top-width:4px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-4{border-right-style:var(--tw-border-style);border-right-width:4px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--border)}.border-current{border-color:currentColor}.border-input{border-color:var(--input)}.border-transparent{border-color:#0000}.border-white\\/25{border-color:#ffffff40}@supports (color:color-mix(in lab, red, red)){.border-white\\/25{border-color:color-mix(in oklab, var(--color-white) 25%, transparent)}}.border-t-transparent{border-top-color:#0000}.bg-background{background-color:var(--background)}.bg-card{background-color:var(--card)}.bg-chart-1\\/15{background-color:var(--chart-1)}@supports (color:color-mix(in lab, red, red)){.bg-chart-1\\/15{background-color:color-mix(in oklab, var(--chart-1) 15%, transparent)}}.bg-current{background-color:currentColor}.bg-gray-900{background-color:var(--color-gray-900)}.bg-muted{background-color:var(--muted)}.bg-popover{background-color:var(--popover)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-secondary-bg{background-color:var(--secondary-bg)}.bg-success\\/15{background-color:var(--success)}@supports (color:color-mix(in lab, red, red)){.bg-success\\/15{background-color:color-mix(in oklab, var(--success) 15%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning\\/15{background-color:var(--warning)}@supports (color:color-mix(in lab, red, red)){.bg-warning\\/15{background-color:color-mix(in oklab, var(--warning) 15%, transparent)}}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing) * 0)}.p-0\\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-1\\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-blue-500{color:var(--color-blue-500)}.text-card-foreground{color:var(--card-foreground)}.text-chart-1{color:var(--chart-1)}.text-foreground{color:var(--foreground)}.text-foreground-faint{color:var(--foreground-faint)}.text-foreground-muted{color:var(--foreground-muted)}.text-inherit{color:inherit}.text-muted-foreground{color:var(--muted-foreground)}.text-popover-foreground{color:var(--popover-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-500{color:var(--color-red-500)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-success{color:var(--success)}.text-warning{color:var(--warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow,.shadow-\\[var\\(--shadow\\)\\]{--tw-shadow:var(--shadow);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\,background-color\\]{transition-property:transform,opacity,background-color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-\\[160ms\\]{--tw-duration:.16s;transition-duration:.16s}.duration-\\[167ms\\]{--tw-duration:.167s;transition-duration:.167s}.ease-\\[cubic-bezier\\(0\\.33\\,0\\,0\\,1\\)\\]{--tw-ease:cubic-bezier(.33,0,0,1);transition-timing-function:cubic-bezier(.33,0,0,1)}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.group-focus-within\\:pointer-events-auto:is(:where(.group):focus-within *){pointer-events:auto}.group-focus-within\\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media (hover:hover){.group-hover\\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\\:text-foreground-faint::placeholder{color:var(--foreground-faint)}.focus-within\\:border-foreground-faint:focus-within{border-color:var(--foreground-faint)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\\:border-muted-foreground:hover{border-color:var(--muted-foreground)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-accent:hover{background-color:var(--accent)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary:hover{background-color:var(--primary)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab, var(--primary) 90%, transparent)}}.hover\\:bg-secondary-hover:hover{background-color:var(--secondary-hover)}.hover\\:bg-secondary\\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-secondary\\/80:hover{background-color:color-mix(in oklab, var(--secondary) 80%, transparent)}}.hover\\:bg-transparent:hover{background-color:#0000}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\\:opacity-100:hover{opacity:1}.hover\\:duration-\\[250ms\\]:hover{--tw-duration:.25s;transition-duration:.25s}}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-3:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-ring:focus{--tw-ring-color:var(--ring)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:var(--ring)}.active\\:scale-\\[0\\.85\\]:active{scale:.85}.active\\:duration-\\[134ms\\]:active{--tw-duration:.134s;transition-duration:.134s}.active\\:ease-\\[cubic-bezier\\(0\\.45\\,0\\,0\\.2\\,1\\)\\]:active{--tw-ease:cubic-bezier(.45,0,.2,1);transition-timing-function:cubic-bezier(.45,0,.2,1)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:bg-muted:disabled{background-color:var(--muted)}.disabled\\:opacity-50:disabled{opacity:.5}}:root,:host{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--destructive-foreground:oklch(100% 0 0);--success:oklch(60% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(75% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--border-muted:#e5e7eb4d;--primary-hover:#3b82f6d9;--primary-muted:#3b82f64d;--secondary-bg:#6b728033;--secondary-hover:#6b72804d;--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040;--tracking-normal:0em;--spacing:.25rem;--duration-animation:.3s;--duration-fade:.2s;--widget-width:400px;--widget-height:520px;--layer-tooltip:1000;--layer-popover:1050;--layer-dialog:1100;--layer-toast:1200}.dark,:host(.dark){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(26.9% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(37.1% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(70.4% .191 22.216);--destructive-foreground:oklch(98.5% 0 0);--success:oklch(55% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(70% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(27.5% 0 0);--input:oklch(32.5% 0 0);--ring:oklch(55.6% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(27.5% 0 0);--sidebar-ring:oklch(43.9% 0 0);--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040}@media (prefers-reduced-motion:reduce){:root{--duration-animation:0s;--duration-fade:0s}}@keyframes dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes menu-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes popover-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes tooltip-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes toast-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(-30px)}to{opacity:1;transform:translate(0)}}@keyframes slide-in-right{0%{opacity:0;transform:translate(30px)}to{opacity:1;transform:translate(0)}}.marketrix-widget,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.marketrix-widget-container{z-index:var(--widget-z-index,1210);pointer-events:auto;position:fixed}.marketrix-widget,.marketrix-widget *,[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;box-sizing:border-box;transition:color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,opacity .2s ease-in-out,box-shadow .2s ease-in-out,transform .2s ease-in-out}.marketrix-widget button,.marketrix-widget input,.marketrix-widget textarea,.marketrix-widget select,[data-marketrix-widget] button,[data-marketrix-widget] input,[data-marketrix-widget] textarea,[data-marketrix-widget] select{font:inherit}[data-resizing=true],[data-resizing=true] *{transition:none!important}.gradient-border{border:2px solid;border-image:linear-gradient(to right, var(--foreground), var(--foreground)) 1}.marketrix-widget ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget * ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget * ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget{scrollbar-color:var(--muted) var(--muted-foreground);scrollbar-width:thin}.marketrix-widget ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget * ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget * ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button{background:0 0!important;border:none!important;width:0!important;height:0!important;display:none!important}@keyframes glow-border-pulse{0%,to{border-color:#fff9;box-shadow:0 0 #ffffff4d,0 0 #1f293766}50%{border-color:#fff;box-shadow:0 0 0 2px #fff9,0 0 0 4px #1f29374d}}@keyframes marketrix-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}.marketrix-screen-edge-glow,[data-screen-edge-glow]{animation:1.6s ease-in-out infinite marketrix-screen-edge-pulse}.marketrix-widget-button-processing-glow,.marketrix-widget-button-error-glow{pointer-events:none;filter:blur(14px);will-change:transform, opacity;border-radius:50%;width:140%;height:140%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}@keyframes widget-activity-dash-travel{0%{stroke-dashoffset:0;opacity:.5}18%{stroke-dashoffset:-112px;opacity:1}35%{stroke-dashoffset:-160px;opacity:.65}60%{stroke-dashoffset:-160px;opacity:.45}82%{stroke-dashoffset:-272px;opacity:1}to{stroke-dashoffset:-320px;opacity:.6}}.marketrix-widget-button-processing-activity-ring,.marketrix-widget-button-error-activity-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.marketrix-widget-button-processing-activity-ring rect,.marketrix-widget-button-error-activity-ring rect{fill:none;stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:40 120;animation:1.9s cubic-bezier(.4,0,.2,1) infinite widget-activity-dash-travel}.marketrix-widget-button-processing-activity-ring rect{stroke:#31d06d;filter:drop-shadow(0 0 3px #31d06db3)}.marketrix-widget-button-error-activity-ring rect{stroke:#d0342c;filter:drop-shadow(0 0 3px #d0342cb3)}@keyframes widget-glow-green{0%,to{opacity:.72;background:radial-gradient(circle,#31d06d00 38%,#31d06d61 58%,#31d06d3d 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle,#31d06d00 34%,#31d06d8c 56%,#31d06d54 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-processing-glow{animation:2s ease-in-out infinite widget-glow-green}@keyframes widget-glow-red{0%,to{opacity:.65;background:radial-gradient(circle,#d0342c00 38%,#d0342c57 58%,#d0342c38 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle,#d0342c00 34%,#d0342c80 56%,#d0342c4d 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-error-glow{animation:1.5s ease-in-out infinite widget-glow-red}@keyframes launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.animate-launcher-entrance{animation:.25s ease-out forwards launcher-entrance}@keyframes messenger-entrance{0%{opacity:0;transform:scale(0)}40%{opacity:1}to{transform:scale(1)}}@keyframes messenger-exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)translateY(8px)}}.animate-messenger-entrance{animation:.3s cubic-bezier(0,1.2,1,1) messenger-entrance}.animate-messenger-exit{animation:.2s cubic-bezier(.4,0,.2,1) forwards messenger-exit}@keyframes message-enter{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.animate-message-enter{animation:.2s ease-out message-enter}.view-slide-enter.forward{opacity:0;transform:translate(20px)}.view-slide-enter.back{opacity:0;transform:translate(-20px)}.view-slide-enter-active{opacity:1;transition:transform .15s .15s,opacity .15s .15s;transform:translate(0)}.view-slide-enter-active.forward,.view-slide-enter-active.back{opacity:1;transform:translate(0)}.view-slide-exit-active.forward{opacity:0;transition:transform .15s,opacity .15s;transform:translate(-20px)}.view-slide-exit-active.back{opacity:0;transition:transform .15s,opacity .15s;transform:translate(20px)}[data-view-transition][data-direction=forward]{animation:.3s both viewSlideForward}[data-view-transition][data-direction=back]{animation:.3s both viewSlideBack}@keyframes viewSlideForward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes viewSlideBack{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media print{.marketrix-widget{display:none!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}',jC=null,FC=null,UC=null,BC=!1,GC=!1,WC=0,HC=(e,t)=>{const n=t||"marketrix-widget-container-"+ ++WC;let r;if(e){if(e.querySelector(`#${n}`))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.overflow="visible",e.appendChild(r)}else{if(document.getElementById(n))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",document.body.appendChild(r)}if(r.style.pointerEvents="auto",!TC(r))throw new Error("Container is not an HTMLElement");if(r.shadowRoot)throw new Error("Container already has a shadow root");const i=r.attachShadow({mode:"closed"}),o=document.createElement("style");if(o.textContent=$C,i.appendChild(o),i.querySelector("#marketrix-widget-root"))throw new Error("Mount element already exists in shadow root");const s=document.createElement("div");return s.id="marketrix-widget-root",s.style.pointerEvents="auto",s.style.width="100%",s.style.height="100%",s.style.position="relative",i.appendChild(s),{container:r,shadowRoot:i,mountEl:s}},ZC=(e,n,r=!1)=>{const i=h(e);return i.render(/* @__PURE__ */f(t.StrictMode,{children:/* @__PURE__ */f(ff,{previewMode:r,children:/* @__PURE__ */f(pf,{config:n})})})),i},VC=e=>{if(!e)throw new Error("Container is required");e.remove()},qC=()=>FC,YC=()=>null!==jC,JC=e=>{BC=e},KC=()=>BC,QC=()=>GC,XC=e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(UC){const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove(),UC.unmount(),UC=null}if(document.getElementById("marketrix-widget-loader-container"))throw new Error("Widget loader container already exists");const n=document.createElement("div");n.id="marketrix-widget-loader-container",n.className="marketrix-widget-loader-container",document.body.appendChild(n);const r=n.attachShadow({mode:"closed"}),i=document.createElement("style");i.textContent=$C,r.appendChild(i);const o=document.createElement("div");o.id="marketrix-widget-loader-root",r.appendChild(o);const s=h(o);UC=s,s.render(/* @__PURE__ */f(t.StrictMode,{children:/* @__PURE__ */f(DC,{message:e})}))},eI=()=>{if(UC){UC.unmount(),UC=null;const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove()}},tI=null,nI=(e=0)=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;const t=[0,100,500,1e3,2e3];if(!tI)return;const n=document.querySelectorAll("script[mtx-id], script[mtx-app]"),r=(void 0!==document.currentScript&&null!=document.currentScript&&AC(document.currentScript)&&(document.currentScript.hasAttribute("mtx-id")||document.currentScript.hasAttribute("mtx-app"))?document.currentScript:null)??n[n.length-1];if(!r||!AC(r)){if(0===n.length)return void(YC()||KC());if(e<5){return void setTimeout(()=>nI(e+1),t[e]||2e3)}if(YC()||KC())return;return void XC("Please configure mtx-id and mtx-key, or mtx-app and mtx-agent")}const i=r,o=i.getAttribute("mtx-id"),s=i.getAttribute("mtx-key"),a=i.getAttribute("mtx-api-host"),l=i.getAttribute("mtx-app"),c=i.getAttribute("mtx-agent"),d=i.getAttribute("mtx-use-screenshare");if(o&&s){const e={mtxId:o,mtxKey:s};a&&(e.mtxApiHost=a),"false"===d&&(e.use_screenshare=!1),tI(e).catch(e=>{})}else if(l&&c){const e=Number.parseInt(l),t=Number.parseInt(c);if(isNaN(e)||isNaN(t))return void XC("Invalid mtx-app or mtx-agent values");const n={mtxApp:e,mtxAgent:t};a&&(n.mtxApiHost=a),"false"===d&&(n.use_screenshare=!1),tI(n).catch(e=>{})}else{if(YC()||KC())return;XC("Please configure mtx-id and mtx-key, or mtx-app and mtx-agent")}},rI=null,iI=!1,oI=!1,sI=null,aI=null,lI=null;async function cI(e,t){if(JC(!0),YC())return void JC(!1);if(QC())return void JC(!1);window.__mtx={state:"initializing"},e.mtxApiHost&&bd(e.mtxApiHost),XC("Validating widget configuration...");const n=await(new IC).validateConfig(e);if(!n.isValid)return XC(n.error||"Widget validation failed. Please check your configuration."),JC(!1),void(window.__mtx=void 0);let r;try{r=await async function(e,t){if(!t.isValid)throw new Error(t.error||"Widget validation failed");XC("Loading widget settings...");try{const t=new zC(e.mtxId,e.mtxKey,e.mtxApp),n=await t.fetchWidgetSettings(),r=n?t.getWidgetSettings(n):null;if(!r)throw new Error("WidgetService did not return widget settings");const i=["widget_enabled","widget_appearance","widget_position","widget_device","widget_header","widget_body","widget_greeting","widget_feature_tell","widget_feature_show","widget_feature_do","widget_feature_human","widget_background_color","widget_text_color","widget_border_color","widget_accent_color","widget_secondary_color","widget_border_radius","widget_font_size","widget_width","widget_height","widget_shadow","widget_animation_duration","widget_fade_duration","widget_bounce_effect","widget_chips"].filter(e=>void 0===r[e]);if(i.length>0)throw new Error(`Widget settings are incomplete. Missing required fields: ${i.join(", ")}. The API must return all widget settings.`);return Jd(r,e)}catch(vI){throw vI}finally{eI()}}(e,n)}catch(s){return XC(s instanceof Error?s.message:"Failed to initialize widget"),JC(!1),void(window.__mtx=void 0)}(e=>{FC=e})(r);const{mountEl:i}=HC(t,`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);var o;o=ZC(i,r),jC=o,GC=!0,JC(!1),window.__mtx={state:"active"};try{if(rI&&iI)return;rI&&(rI.stop(),rI=null,iI=!1),lI=new AbortController;const t=(e,t)=>{if(!(rI&&iI||oI)){oI=!0;try{rI=new kC(t,e),iI=!0;const n=rI;sI=n.start().catch(e=>{rI===n&&(iI=!1)}).finally(()=>{oI=!1,rI===n&&(sI=null)})}catch{oI=!1}}},n=e=>{const n=$d.getChatId();n?t(e,n):window.addEventListener("marketrix:chatid",()=>{const n=$d.getChatId();n&&t(e,n)},{once:!0,signal:lI?.signal})},i=r.mtxApp??e.mtxApp;if(i)n(i);else{const e=Vd.getInstance(),t={onRegistered:r=>{r&&n(r),e.removeCallbacks(t)}};e.addCallbacks(t)}}catch(s){iI=!1}}var dI=!1,uI=async(e,t)=>{if(!window.__mtx?.state){if(aI)return aI;if(dI)return Promise.resolve();if(!YC()&&!QC()){aI=cI(e,t),dI=!0;try{await aI}finally{aI=null,dI=!1}}}},pI=()=>{if(jC){jC.unmount(),jC=null,FC=null,GC=!1;const e=document.querySelector(".marketrix-widget-container");e&&VC(e)}lI?.abort(),lI=null,rI&&(rI.stop(),rI=null,iI=!1,oI=!1,sI=null),aI=null,window.__mtx=void 0,eI()},hI=()=>{rI&&rI.stop()},mI=async()=>{if(!rI)throw new Error("Session recording not available. Ensure the widget is initialized with mtxApiHost and mtxApp.");if(sI&&(await sI.catch(()=>{}),rI?.isActive()))return;if(rI.isActive())return;const e=rI.start();sI=e;try{await e}finally{sI===e&&(sI=null)}},fI=()=>rI?.isActive()??!1,gI=async e=>{if(YC()){const t=qC();if(!t)throw new Error("Widget not initialized");const n={...t,...e};pI(),await uI(n)}},yI=({settings:e,container:t,mtxId:n,mtxKey:r,mtxApiHost:i})=>{const o=u(null),s=u(null),l=u(null),c=u(null);return a(()=>{const a=t??o?.current?.parentElement??document.body;if(!a||!TC(a))return;c.current||(c.current=`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);const{container:d,mountEl:u}=HC(a,c.current);l.current=d;const p={...Jd(e,{mtxId:n,mtxKey:r,mtxApiHost:i}),isPreviewMode:!0,widget_enabled:e.widget_enabled??!0};s.current&&(s.current.unmount(),s.current=null);const m=h(u);return s.current=m,m.render(/* @__PURE__ */f(ff,{previewMode:!0,children:/* @__PURE__ */f(pf,{config:p})})),()=>{s.current&&(s.current.unmount(),s.current=null),l.current&&(VC(l.current),l.current=null,c.current=null)}},[e,t]),t?null:/* @__PURE__ */f("div",{ref:o,style:{width:"100%",height:"100%",position:"relative"}})},wI=async e=>{JC(!0);const t=e.container;if("settings"in e&&void 0!==e.settings){const{settings:n,container:r,...i}=e,o={...Jd(n,i),isPreviewMode:!0},{mountEl:s}=HC(t,`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);ZC(s,o,!0),JC(!1)}else if("mtxId"in e&&void 0!==e.mtxId&&void 0!==e.mtxKey){const{mtxId:n,mtxKey:r,container:i,...o}=e;await uI({mtxId:n,mtxKey:r,...o},t)}else{if(!("mtxApp"in e)||void 0===e.mtxApp||void 0===e.mtxAgent)throw JC(!1),new Error("Invalid configuration: provide either settings (preview), mtxId+mtxKey (production), or mtxApp+mtxAgent (dev)");{const{mtxApp:n,mtxAgent:r,container:i,...o}=e;await uI({mtxApp:n,mtxAgent:r,...o},t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{"function"==typeof e&&(tI=e,nI())})(uI)}catch(e){}},0);var bI={MarketrixWidget:yI,mountWidget:wI,initWidget:uI,unmountWidget:pI,updateMarketrixConfig:gI,getCurrentConfig:qC,startRecording:mI,stopRecording:hI,getRecordingState:fI};export{yI as MarketrixWidget,bI as default,qC as getCurrentConfig,fI as getRecordingState,uI as initWidget,wI as mountWidget,mI as startRecording,hI as stopRecording,pI as unmountWidget,gI as updateMarketrixConfig};
1
+ import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as i,useCallback as o,useContext as s,useEffect as a,useId as l,useLayoutEffect as c,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 g,jsxs as f}from"react/jsx-runtime";var y=2147483002,w=2147483001,b=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,i]=[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*i}(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 i=Math.round(n.r*r),o=Math.round(n.g*r),s=Math.round(n.b*r),`#${[i,o,s].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var i,o,s}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 A(e){return Array.isArray(e)?e:null==e?[]:[e]}var T="orpc",M=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function z(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.3/otel/config__"]}function R(e,t={},n){return(O()?.tracer)?.startSpan(e,t,n)}function P(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 N({name:e,context:t,...n},r){const i=O()?.tracer;if(!i)return r();const o=async e=>{try{return await r(e)}catch(t){throw P(e,t,n),t}finally{e.end()}};return t?i.startActiveSpan(e,n,t,o):i.startActiveSpan(e,n,o)}async function L(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 j=Symbol.asyncDispose??Symbol.for("asyncDispose"),$=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[j](){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 $(async()=>{r??=R(e);try{const e=await L(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(i){throw P(r,i,t),i}},async e=>{try{"next"!==e&&await L(r,()=>n.return?.())}catch(i){throw P(r,i,t),i}finally{r?.end()}})}function B(e,t,n){const r=(t,i)=>{const o=e[i];return o?o({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function U(e){if(e)return JSON.parse(e)}function G(e){return JSON.stringify(e)}function W(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 V(e,...t){return"function"==typeof e?e(...t):e}function H(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)&&Y.test(t.toString()));var t}))return Reflect.apply(t,n,r);let i=!0;r[0].call(n,H(new Proxy(e,{get:(e,t,n)=>{if(!i||"then"!==t)return Reflect.get(e,t,n);i=!1}})))}})}})}var Y=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var q={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 J=Symbol.for("__@orpc/client@1.14.3/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[J]??=/* @__PURE__ */new WeakSet;var K=globalThis[J],X=class extends Error{defined;code;status;data;constructor(e,...t){const n=function(e){return e[0]??{}}(t);if(void 0!==n.status&&!Q(n.status))throw new Error("[ORPCError] Invalid error status code.");const r=function(e,t){return t||q[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??q[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(K.has(this)){const t=function(e){return Z(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&K.has(t))return!0}return super[Symbol.hasInstance](e)}};function Q(e){return e<200||e>=400}function ee(e){if(!W(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&&Q(e.status)&&"message"in e&&"string"==typeof e.message)}function te(e,t={}){return new X(e.code,{...t,...e})}K.add(X);var ne=class extends TypeError{},re=class extends TypeError{},ie=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),i=-1===e?"":r.slice(e+1).replace(/^\s/,"");if(0===e)n.comments.push(i);else if("data"===t)n.data??="",n.data+=`${i}\n`;else if("event"===t)n.event=i;else if("id"===t)n.id=i;else if("retry"===t){const e=Number.parseInt(i);Number.isInteger(e)&&e>=0&&e.toString()===i&&(n.retry=e)}}return n.data=n.data?.replace(/\n$/,""),n}var se=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 re("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new se({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function le(e){if(e.includes("\n"))throw new ne("Event's id must not contain a newline character")}function ce(e){if(!Number.isInteger(e)||e<0)throw new ne("Event's retry must be a integer and >= 0")}function de(e){if(e.includes("\n"))throw new ne("Event's comment must not contain a newline character")}function ue(e){let t="";return t+=function(e){let t="";for(const n of e??[])de(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new ne("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&&(le(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 pe=Symbol("ORPC_EVENT_SOURCE_META");function he(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&le(t.id),void 0!==t.retry&&ce(t.retry),void 0!==t.comments)for(const n of t.comments)de(n);return new Proxy(e,{get:(e,n,r)=>n===pe?t:Reflect.get(e,n,r)})}function me(e){return Z(e)?Reflect.get(e,pe):void 0}function ge(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=me(e);t&&Z(n)&&(n=he(n,t))}return n};return new $(async()=>{const{done:r,value:i}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let o=await t.value(i,r);if(o!==i){const e=me(i);e&&Z(o)&&(o=he(o,e))}return{done:r,value:o}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function ye(e,t={}){const n=t.path??[];return H(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,i)=>"string"!=typeof i?Reflect.get(r,i):ye(e,{...t,path:[...n,i]})}))}function we(e,t={}){return N({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=ge(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 U(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,i=!1;return new $(async()=>{r??=R("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await L(r,()=>n.read());if(e){if(i)throw new M("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=U(t.data);return Z(e)&&(e=he(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new ie({data:U(t.data)});throw e=he(e,t),r?.addEvent("error"),e}case"done":{let e=U(t.data);return Z(e)&&(e=he(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof ie||P(r,e,t),e}},async e=>{try{"next"!==e&&(i=!0,r?.addEvent("cancelled")),await L(r,()=>n?.cancel())}catch(o){throw P(r,o,t),o}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const i=await e.blob();return new File([i],"blob",{type:i.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,i=t.eventIteratorKeepAliveComment??"",o=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,l,c=!1;return new ReadableStream({start(e){l=R("stream_event_iterator"),o&&e.enqueue(ue({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ue({comments:[i]})),l?.addEvent("keepalive")},r));const o=await L(l,()=>e.next());if(clearInterval(a),c)return;const s=me(o.value);if(!o.done||void 0!==o.value||void 0!==s){const e=o.done?"done":"message";t.enqueue(ue({...s,event:e,data:G(o.value)})),l?.addEvent(e)}o.done&&(t.close(),l?.end())}catch(o){if(clearInterval(a),c)return;o instanceof ie?(t.enqueue(ue({...me(o),event:"error",data:G(o.data)})),l?.addEvent("error"),t.close()):(P(l,o),t.error(o)),l?.end()}},async cancel(){try{c=!0,clearInterval(a),l?.addEvent("cancelled"),await L(l,()=>e.return?.())}catch(t){throw P(l,t),t}finally{l?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),G(e)):void 0}function ve(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 xe(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 ke=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)}},_e=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new ke(n.plugins).init(n),this.interceptors=A(n.interceptors),this.clientInterceptors=A(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return N({name:`${T}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",T),r?.setAttribute("rpc.method",e.join(".")),D(t)&&(t=F({name:"consume_event_iterator_input",signal:n.signal},t)),B(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const i=O();let o;const s=i?.trace.getActiveSpan()??r;s&&i&&(o=i?.trace.setSpan(i.context.active(),s));const a=await N({name:"encode_request",context:o},()=>this.codec.encode(e,t,n)),l=await B(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>N({name:"send_request",signal:r.signal,context:o},()=>this.sender.call(n,r,t,e))),c=await N({name:"decode_response",context:o},()=>this.codec.decode(l,n,e,t));return D(c)?F({name:"consume_event_iterator_output",signal:n.signal},c):c})))}},Se=0,Ie=1,Ce=2,Ee=3,Ae=4,Te=5,Me=6,ze=7,Oe=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=[],i=[]){for(const o of this.customSerializers)if(o.condition(e)){const s=this.serialize(o.serialize(e),t,n,r,i);return n.push([o.type,...t]),s}if(e instanceof Blob)return r.push(t),i.push(e),[e,n,r,i];if("bigint"==typeof e)return n.push([Se,...t]),[e.toString(),n,r,i];if(e instanceof Date)return n.push([Ie,...t]),Number.isNaN(e.getTime())?[null,n,r,i]:[e.toISOString(),n,r,i];if(Number.isNaN(e))return n.push([Ce,...t]),[null,n,r,i];if(e instanceof URL)return n.push([Ae,...t]),[e.toString(),n,r,i];if(e instanceof RegExp)return n.push([Te,...t]),[e.toString(),n,r,i];if(e instanceof Set){const o=this.serialize(Array.from(e),t,n,r,i);return n.push([Me,...t]),o}if(e instanceof Map){const o=this.serialize(Array.from(e.entries()),t,n,r,i);return n.push([ze,...t]),o}if(Array.isArray(e))return[e.map((e,o)=>void 0===e?(n.push([Ee,...t,o]),null):this.serialize(e,[...t,o],n,r,i)[0]),n,r,i];if(W(e)){const o={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(o[s]=this.serialize(e[s],[...t,s],n,r,i)[0]);return[o,n,r,i]}return[e,n,r,i]}deserialize(e,t,n,r){const i={data:e};n&&r&&n.forEach((e,t)=>{let n=i,o="data";e.forEach(e=>{if(n=n[o],o=e,!Object.hasOwn(n,o))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${o}`)}),n[o]=r(t)});for(const o of t){const e=o[0];let t=i,n="data";for(let r=1;r<o.length;r++)if(t=t[n],n=o[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 Se:t[n]=BigInt(t[n]);break;case Ie:t[n]=new Date(t[n]??"Invalid Date");break;case Ce:t[n]=NaN;break;case Ee:t[n]=void 0;break;case Ae: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 i.data}};var Re,Pe=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?ve(e):e}(await V(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]=[...A(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 i=await V(this.expectedMethod,n,e,t),o=await V(this.baseUrl,n,e,t),s=new URL(o);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==i||a instanceof FormData||D(a))){const o=await V(this.maxUrlLength,n,e,t),l=new URL(s);if(l.searchParams.append("data",G(a)),l.toString().length<=o)return{body:void 0,method:i,headers:r,url:l,signal:n.signal}}return{url:s,method:"GET"===i?this.fallbackMethod:i,headers:r,body:a,signal:n.signal}}async decode(e){const t=!Q(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(ee(n))throw te(n);throw new X((r=e.status,Object.entries(q).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},Ne=class{constructor(e){this.jsonSerializer=e}serialize(e){return D(e)?fe(e,{value:async e=>this.#i(e,!1),error:async e=>{return new ie({data:this.#i((t=e,t instanceof X?t:new X("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#i(e,!0)}#i(e,t){const[n,r,i,o]=this.jsonSerializer.serialize(e),s=0===r.length?void 0:r;if(!t||0===o.length)return{json:n,meta:s};const a=new FormData;return a.set("data",G({json:n,meta:s,maps:i})),o.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return D(e)?fe(e,{value:async e=>this.#o(e),error:async e=>{if(!(e instanceof ie))return e;const t=this.#o(e.data);return ee(t)?te(t,{cause:e}):new ie({data:t,cause:e})}}):this.#o(e)}#o(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 _e{constructor(e,t){super(new Pe(new Ne(new Oe(t)),t),e,t)}},De=class extends ke{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},je=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new De(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=A(e.adapterInterceptors)}async call(e,t,n,r){const i=xe(e,this.toFetchRequestOptions);return function(e,t={}){return{body:z(()=>we(e,t)),status:e.status,get headers(){const t=ve(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await B(this.adapterInterceptors,{...t,request:i,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...i})=>this.fetch(e,r,i,t,n)),{signal:i.signal})}},$e=class extends Le{constructor(e){super(new je(e),e)}};function Fe(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const i=s.prototype,o=Object.keys(i);for(let e=0;e<o.length;e++){const t=o[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class o extends i{}function s(e){var t;const i=n?.Parent?new o:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Be=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"}};(Re=globalThis).__zod_globalConfig??(Re.__zod_globalConfig={});var Ge=globalThis.__zod_globalConfig;function We(e){return e&&Object.assign(Ge,e),Ge}function Ze(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 Ve(e,t){return"bigint"==typeof t?t.toString():t}function He(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ye(e){return null==e}function qe(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 Xe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qe(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function et(e){return JSON.stringify(e)}var tt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var rt=/* @__PURE__ */He(()=>{if(Ge.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function it(e){if(!1===nt(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!==nt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function ot(e){return it(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var st=/* @__PURE__ */new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(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 dt={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 ut(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 pt(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 ht(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function mt(e){return"string"==typeof e?e:e?.message}function gt(e,t,n){const r=e.message?e.message:mt(e.inst?._zod.def?.error?.(e))??mt(t?.error?.(e))??mt(n.customError?.(e))??mt(n.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function ft(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function yt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function wt(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var bt=(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,Ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vt=Fe("$ZodError",bt),xt=Fe("$ZodError",bt,{Parent:Error});var kt=e=>(t,n,r,i)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Be;if(s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>gt(e,o,We())));throw tt(t,i?.callee),t}return s.value},_t=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>gt(e,o,We())));throw tt(t,i?.callee),t}return s.value},St=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Be;return o.issues.length?{success:!1,error:new(e??vt)(o.issues.map(e=>gt(e,i,We())))}:{success:!0,data:o.value}},It=/* @__PURE__ */St(xt),Ct=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>gt(e,i,We())))}:{success:!0,data:o.value}},Et=/* @__PURE__ */Ct(xt),At=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return kt(e)(t,n,i)},Tt=e=>(t,n,r)=>kt(e)(t,n,r),Mt=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return _t(e)(t,n,i)},zt=e=>async(t,n,r)=>_t(e)(t,n,r),Ot=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return St(e)(t,n,i)},Rt=e=>(t,n,r)=>St(e)(t,n,r),Pt=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Ct(e)(t,n,i)},Nt=e=>async(t,n,r)=>Ct(e)(t,n,r),Lt=/^[cC][0-9a-z]{6,}$/,Dt=/^[0-9a-z]+$/,jt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$t=/^[0-9a-vA-V]{20}$/,Ft=/^[A-Za-z0-9]{27}$/,Bt=/^[a-zA-Z0-9_-]{21}$/,Ut=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gt=/^([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})$/,Wt=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)$/,Zt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Vt=/^(?:(?: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])$/,Ht=/^(([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}|:))$/,Yt=/^((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])$/,qt=/^(([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])$/,Jt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kt=/^[A-Za-z0-9_-]*$/,Xt=/^https?$/,Qt=/^\+[1-9]\d{6,14}$/,en="(?:(?:\\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])))",tn=/* @__PURE__ */new RegExp(`^${en}$`);function nn(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 rn=/^-?\d+$/,on=/^-?\d+(?:\.\d+)?$/,sn=/^(?:true|false)$/i,an=/^null$/i,ln=/^[^A-Z]*$/,cn=/^[^a-z]*$/,dn=/* @__PURE__ */Fe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),un={number:"number",bigint:"bigint",object:"date"},pn=/* @__PURE__ */Fe("$ZodCheckLessThan",(e,t)=>{dn.init(e,t);const n=un[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})}}),hn=/* @__PURE__ */Fe("$ZodCheckGreaterThan",(e,t)=>{dn.init(e,t);const n=un[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})}}),mn=/* @__PURE__ */Fe("$ZodCheckMultipleOf",(e,t)=>{dn.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),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?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})}}),gn=/* @__PURE__ */Fe("$ZodCheckNumberFormat",(e,t)=>{dn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=dt[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=o,n&&(r.pattern=rn)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,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}):s.issues.push({input:a,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}))}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),fn=/* @__PURE__ */Fe("$ZodCheckMaxSize",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ye(t)&&void 0!==t.size}),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;r.size<=t.maximum||n.issues.push({origin:ft(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yn=/* @__PURE__ */Fe("$ZodCheckMinSize",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ye(t)&&void 0!==t.size}),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;r.size>=t.minimum||n.issues.push({origin:ft(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wn=/* @__PURE__ */Fe("$ZodCheckMaxLength",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ye(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 i=yt(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bn=/* @__PURE__ */Fe("$ZodCheckMinLength",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ye(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 i=yt(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vn=/* @__PURE__ */Fe("$ZodCheckLengthEquals",(e,t)=>{var n;dn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ye(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,i=r.length;if(i===t.length)return;const o=yt(r),s=i>t.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xn=/* @__PURE__ */Fe("$ZodCheckStringFormat",(e,t)=>{var n,r;dn.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=()=>{})}),kn=/* @__PURE__ */Fe("$ZodCheckRegex",(e,t)=>{xn.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})}}),_n=/* @__PURE__ */Fe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ln),xn.init(e,t)}),Sn=/* @__PURE__ */Fe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cn),xn.init(e,t)}),In=/* @__PURE__ */Fe("$ZodCheckIncludes",(e,t)=>{dn.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})}}),Cn=/* @__PURE__ */Fe("$ZodCheckStartsWith",(e,t)=>{dn.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})}}),En=/* @__PURE__ */Fe("$ZodCheckEndsWith",(e,t)=>{dn.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})}}),An=/* @__PURE__ */Fe("$ZodCheckMimeType",(e,t)=>{dn.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),Tn=/* @__PURE__ */Fe("$ZodCheckOverwrite",(e,t)=>{dn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Mn=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 i of r)this.content.push(i)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(e=>` ${e}`)];return new e(...t,n.join("\n"))}},zn={major:4,minor:4,patch:3},On=/* @__PURE__ */Fe("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zn;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const i of r)for(const t of i._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,i=ut(e);for(const o of t){if(o._zod.def.when){if(pt(e))continue;if(!o._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new Be;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(i||(i=ut(e,t)))});else{if(e.issues.length===t)continue;i||(i=ut(e,t))}}return r?r.then(()=>e):e},n=(n,i,o)=>{if(ut(n))return n.aborted=!0,n;const s=t(i,r,o);if(s instanceof Promise){if(!1===o.async)throw new Be;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(i,o)=>{if(o.skipChecks)return e._zod.parse(i,o);if("backward"===o.direction){const t=e._zod.parse({value:i.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,o)):n(t,i,o)}const s=e._zod.parse(i,o);if(s instanceof Promise){if(!1===o.async)throw new Be;return s.then(e=>t(e,r,o))}return t(s,r,o)}}Ke(e,"~standard",()=>({validate:t=>{try{const n=It(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Et(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Rn=/* @__PURE__ */Fe("$ZodString",(e,t)=>{var n;On.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}}),Pn=/* @__PURE__ */Fe("$ZodStringFormat",(e,t)=>{xn.init(e,t),Rn.init(e,t)}),Nn=/* @__PURE__ */Fe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gt),Pn.init(e,t)}),Ln=/* @__PURE__ */Fe("$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=Wt(e))}else t.pattern??(t.pattern=Wt());Pn.init(e,t)}),Dn=/* @__PURE__ */Fe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Zt),Pn.init(e,t)}),jn=/* @__PURE__ */Fe("$ZodURL",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Xt.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 i=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$n=/* @__PURE__ */Fe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pn.init(e,t)}),Fn=/* @__PURE__ */Fe("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Bt),Pn.init(e,t)}),Bn=/* @__PURE__ */Fe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Lt),Pn.init(e,t)}),Un=/* @__PURE__ */Fe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dt),Pn.init(e,t)}),Gn=/* @__PURE__ */Fe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=jt),Pn.init(e,t)}),Wn=/* @__PURE__ */Fe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=$t),Pn.init(e,t)}),Zn=/* @__PURE__ */Fe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ft),Pn.init(e,t)}),Vn=/* @__PURE__ */Fe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=nn({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(`^${en}T(?:${r})$`)}(t)),Pn.init(e,t)}),Hn=/* @__PURE__ */Fe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=tn),Pn.init(e,t)}),Yn=/* @__PURE__ */Fe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${nn(t)}$`)),Pn.init(e,t)}),qn=/* @__PURE__ */Fe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ut),Pn.init(e,t)}),Jn=/* @__PURE__ */Fe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vt),Pn.init(e,t),e._zod.bag.format="ipv4"}),Kn=/* @__PURE__ */Fe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ht),Pn.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})}}}),Xn=/* @__PURE__ */Fe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Yt),Pn.init(e,t)}),Qn=/* @__PURE__ */Fe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=qt),Pn.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 er(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 tr=/* @__PURE__ */Fe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Jt),Pn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{er(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var nr=/* @__PURE__ */Fe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Kt),Pn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Kt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return er(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})}}),rr=/* @__PURE__ */Fe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Qt),Pn.init(e,t)});var ir=/* @__PURE__ */Fe("$ZodJWT",(e,t)=>{Pn.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 i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.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})}}),or=/* @__PURE__ */Fe("$ZodNumber",(e,t)=>{On.init(e,t),e._zod.pattern=e._zod.bag.pattern??on,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),sr=/* @__PURE__ */Fe("$ZodNumberFormat",(e,t)=>{gn.init(e,t),or.init(e,t)}),ar=/* @__PURE__ */Fe("$ZodBoolean",(e,t)=>{On.init(e,t),e._zod.pattern=sn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(o){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),lr=/* @__PURE__ */Fe("$ZodNull",(e,t)=>{On.init(e,t),e._zod.pattern=an,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}}),cr=/* @__PURE__ */Fe("$ZodUnknown",(e,t)=>{On.init(e,t),e._zod.parse=e=>e}),dr=/* @__PURE__ */Fe("$ZodNever",(e,t)=>{On.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ur=/* @__PURE__ */Fe("$ZodDate",(e,t)=>{On.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(s){}const i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function pr(e,t,n){e.issues.length&&t.issues.push(...ht(n,e.issues)),t.value[n]=e.value}var hr=/* @__PURE__ */Fe("$ZodArray",(e,t)=>{On.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let e=0;e<i.length;e++){const s=i[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?o.push(a.then(t=>pr(t,n,e))):pr(a,n,e)}return o.length?Promise.all(o).then(()=>n):n}});function mr(e,t,n,r,i,o){const s=n in r;if(e.issues.length){if(i&&o&&!s)return;t.issues.push(...ht(n,e.issues))}s||i?void 0===e.value?s&&(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 gr(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": 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 fr(e,t,n,r,i,o){const s=[],a=i.keySet,l=i.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(const p in t){if("__proto__"===p)continue;if(a.has(p))continue;if("never"===c){s.push(p);continue}const i=l.run({value:t[p],issues:[]},r);i instanceof Promise?e.push(i.then(e=>mr(e,n,p,t,d,u))):mr(i,n,p,t,d,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}var yr=/* @__PURE__ */Fe("$ZodObject",(e,t)=>{if(On.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=He(()=>gr(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=nt,i=t.catchall;let o;e._zod.parse=(t,s)=>{o??(o=n.value);const a=t.value;if(!r(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const l=[],c=o.shape;for(const e of o.keys){const n=c[e],r="optional"===n._zod.optin,i="optional"===n._zod.optout,o=n._zod.run({value:a[e],issues:[]},s);o instanceof Promise?l.push(o.then(n=>mr(n,t,e,a,r,i))):mr(o,t,e,a,r,i)}return i?fr(l,a,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),wr=/* @__PURE__ */Fe("$ZodObjectJIT",(e,t)=>{yr.init(e,t);const n=e._zod.parse,r=He(()=>gr(t));let i;const o=nt,s=!Ge.jitless,a=s&&rt.value,l=t.catchall;let c;e._zod.parse=(d,u)=>{c??(c=r.value);const p=d.value;return o(p)?s&&a&&!1===u?.async&&!0!==u.jitless?(i||(i=(e=>{const t=new Mn(["shape","payload","ctx"]),n=r.value,i=e=>{const t=et(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const o=Object.create(null);let s=0;for(const r of n.keys)o[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=o[r],s=et(r),a=e[r],l="optional"===a?._zod?.optin,c="optional"===a?._zod?.optout;t.write(`const ${n} = ${i(r)};`),l&&c?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):l?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\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: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),d=i(d,u),l?fr([],p,d,u,c,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function br(e,t,n,r){for(const o of e)if(0===o.issues.length)return t.value=o.value,t;const i=e.filter(e=>!ut(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>gt(e,r,We())))}),t)}var vr=/* @__PURE__ */Fe("$ZodUnion",(e,t)=>{On.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=>qe(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>br(t,r,e,i)):br(s,r,e,i)}}),xr=/* @__PURE__ */Fe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,vr.init(e,t);const n=e._zod.parse;Ke(e._zod,"propValues",()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */new Set);for(const r of n)e[t].add(r)}}return e});const r=He(()=>{const e=t.options,n=/* @__PURE__ */new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,o)=>{const s=i.value;if(!nt(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback||"backward"===o.direction?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:s,path:[t.discriminator],inst:e}),i)}}),kr=/* @__PURE__ */Fe("$ZodIntersection",(e,t)=>{On.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>Sr(e,t,n)):Sr(e,i,o)}});function _r(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(it(e)&&it(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const o of r){const n=_r(e[o],t[o]);if(!n.valid)return{valid:!1,mergeErrorPath:[o,...n.mergeErrorPath]};i[o]=n.data}return{valid:!0,data:i}}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 i=_r(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Sr(e,t,n){const r=/* @__PURE__ */new Map;let i;for(const a of t.issues)if("unrecognized_keys"===a.code){i??(i=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const o=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(o.length&&i&&e.issues.push({...i,keys:o}),ut(e))return e;const s=_r(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Ir=/* @__PURE__ */Fe("$ZodRecord",(e,t)=>{On.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!it(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],s=t.keyType._zod.values;if(s){n.value={};const a=/* @__PURE__ */new Set;for(const c of s)if("string"==typeof c||"number"==typeof c||"symbol"==typeof c){a.add("number"==typeof c?c.toString():c);const s=t.keyType._zod.run({value:c,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>gt(e,r,We())),input:c,path:[c],inst:e});continue}const l=s.value,d=t.valueType._zod.run({value:i[c],issues:[]},r);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&n.issues.push(...ht(c,e.issues)),n.value[l]=e.value})):(d.issues.length&&n.issues.push(...ht(c,d.issues)),n.value[l]=d.value)}let l;for(const e in i)a.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const s of Reflect.ownKeys(i)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(i,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&on.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>gt(e,r,We())),input:s,path:[s],inst:e});continue}const l=t.valueType._zod.run({value:i[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...ht(s,e.issues)),n.value[a.value]=e.value})):(l.issues.length&&n.issues.push(...ht(s,l.issues)),n.value[a.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Cr=/* @__PURE__ */Fe("$ZodEnum",(e,t)=>{On.init(e,t);const n=Ze(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>st.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const o=t.value;return r.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),Er=/* @__PURE__ */Fe("$ZodLiteral",(e,t)=>{if(On.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,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Ar=/* @__PURE__ */Fe("$ZodFile",(e,t)=>{On.init(e,t),e._zod.parse=(t,n)=>{const r=t.value;return r instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),t}}),Tr=/* @__PURE__ */Fe("$ZodTransform",(e,t)=>{On.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ue(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Be;return n.value=i,n.fallback=!0,n}});function Mr(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var zr=/* @__PURE__ */Fe("$ZodOptional",(e,t)=>{On.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(`^(${qe(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Mr(e,r)):Mr(i,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Or=/* @__PURE__ */Fe("$ZodExactOptional",(e,t)=>{zr.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)}),Rr=/* @__PURE__ */Fe("$ZodNullable",(e,t)=>{On.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(`^(${qe(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)}),Pr=/* @__PURE__ */Fe("$ZodDefault",(e,t)=>{On.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=>Nr(e,t)):Nr(r,t)}});function Nr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Lr=/* @__PURE__ */Fe("$ZodPrefault",(e,t)=>{On.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))}),Dr=/* @__PURE__ */Fe("$ZodNonOptional",(e,t)=>{On.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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>jr(t,e)):jr(i,e)}});function jr(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 $r=/* @__PURE__ */Fe("$ZodCatch",(e,t)=>{On.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=>gt(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=>gt(e,n,We()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Fr=/* @__PURE__ */Fe("$ZodPipe",(e,t)=>{On.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=>Br(e,t.in,n)):Br(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Br(e,t.out,n)):Br(r,t.out,n)}});function Br(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 Ur=/* @__PURE__ */Fe("$ZodPreprocess",(e,t)=>{Fr.init(e,t)}),Gr=/* @__PURE__ */Fe("$ZodReadonly",(e,t)=>{On.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(Wr):Wr(r)}});function Wr(e){return e.value=Object.freeze(e.value),e}var Zr,Vr=/* @__PURE__ */Fe("$ZodCustom",(e,t)=>{dn.init(e,t),On.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Hr(t,n,r,e));Hr(i,n,r,e)}});function Hr(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(wt(e))}}var Yr=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)}};(Zr=globalThis).__zod_globalRegistry??(Zr.__zod_globalRegistry=new Yr);var qr=globalThis.__zod_globalRegistry;function Jr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}function Kr(e,t){return new pn({check:"less_than",...ct(t),value:e,inclusive:!1})}function Xr(e,t){return new pn({check:"less_than",...ct(t),value:e,inclusive:!0})}function Qr(e,t){return new hn({check:"greater_than",...ct(t),value:e,inclusive:!1})}function ei(e,t){return new hn({check:"greater_than",...ct(t),value:e,inclusive:!0})}function ti(e,t){return new mn({check:"multiple_of",...ct(t),value:e})}function ni(e,t){return new wn({check:"max_length",...ct(t),maximum:e})}function ri(e,t){return new bn({check:"min_length",...ct(t),minimum:e})}function ii(e,t){return new vn({check:"length_equals",...ct(t),length:e})}function oi(e){return new Tn({check:"overwrite",tx:e})}function si(e,t){const n=new dn({check:"custom",...ct(t)});return n._zod.check=e,n}function ai(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??qr,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 li(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,o=t.processors[i.type];if(!o)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,n,r)}const o=e._zod.parent;o&&(s.ref||(s.ref=o),li(o,t,r),t.seen.get(o).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),"input"===t.io&&ui(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function ci(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 o of e.seen.entries()){const t=e.metadataRegistry.get(o[0])?.id;if(t){const e=r.get(t);if(e&&e!==o[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,o[0])}}const i=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:i,defId:o}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const o=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${r}/${o}`}}if(t[1]===n)return{ref:"#"};const i=`#/${r}/`,o=t[1].schema.id??"__schema"+e.counter++;return{defId:o,ref:i+o}})(t);r.def={...r.schema},o&&(r.defId=o);const s=r.schema;for(const e in s)delete s[e];s.$ref=i};if("throw"===e.cycles)for(const o of e.seen.entries()){const e=o[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 o of e.seen.entries()){const n=o[1];if(t!==o[0]){if(e.external){const n=e.external.registry.get(o[0])?.id;if(t!==o[0]&&n){i(o);continue}}(e.metadataRegistry.get(o[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(o)}else i(o)}}function di(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 i=n.def??n.schema,o={...i},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,o),t._zod.parent===s)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())r(l[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$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");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;void 0!==o&&i.id===o&&delete i.id;const s=e.external?.defs??{};for(const l of e.seen.entries()){const e=l[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?i.$defs=s:i.definitions=s);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:pi(t,"input",e.processors),output:pi(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function ui(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 ui(r.element,n);if("set"===r.type)return ui(r.valueType,n);if("lazy"===r.type)return ui(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 ui(r.innerType,n);if("intersection"===r.type)return ui(r.left,n)||ui(r.right,n);if("record"===r.type||"map"===r.type)return ui(r.keyType,n)||ui(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(ui(r.in,n)||ui(r.out,n));if("object"===r.type){for(const e in r.shape)if(ui(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(ui(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(ui(e,n))return!0;return!(!r.rest||!ui(r.rest,n))}return!1}var pi=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=ai({...i??{},target:o,io:t,processors:n});return li(e,s),ci(s,e),di(s,e)},hi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mi=(e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r);t.seen.get(e).ref=i.innerType},gi=/* @__PURE__ */Fe("ZodISODateTime",(e,t)=>{Vn.init(e,t),Gi.init(e,t)});function fi(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}(gi,e)}var yi=/* @__PURE__ */Fe("ZodISODate",(e,t)=>{Hn.init(e,t),Gi.init(e,t)});function wi(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}(yi,e)}var bi=/* @__PURE__ */Fe("ZodISOTime",(e,t)=>{Yn.init(e,t),Gi.init(e,t)});function vi(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}(bi,e)}var xi=/* @__PURE__ */Fe("ZodISODuration",(e,t)=>{qn.init(e,t),Gi.init(e,t)});function ki(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}(xi,e)}var _i=(e,t)=>{vt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,i=[])=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e},[...i,...o.path]));else if("invalid_key"===o.code)r({issues:o.issues},[...i,...o.path]);else if("invalid_element"===o.code)r({issues:o.issues},[...i,...o.path]);else{const e=[...i,...o.path];if(0===e.length)n._errors.push(t(o));else{let r=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(o))),r=r[n],i++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ve,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ve,2)}},isEmpty:{get:()=>0===e.issues.length}})},Si=/* @__PURE__ */Fe("ZodError",_i,{Parent:Error}),Ii=/* @__PURE__ */kt(Si),Ci=/* @__PURE__ */_t(Si),Ei=/* @__PURE__ */St(Si),Ai=/* @__PURE__ */Ct(Si),Ti=/* @__PURE__ */At(Si),Mi=/* @__PURE__ */Tt(Si),zi=/* @__PURE__ */Mt(Si),Oi=/* @__PURE__ */zt(Si),Ri=/* @__PURE__ */Ot(Si),Pi=/* @__PURE__ */Rt(Si),Ni=/* @__PURE__ */Pt(Si),Li=/* @__PURE__ */Nt(Si),Di=/* @__PURE__ */new WeakMap;function ji(e,t,n){const r=Object.getPrototypeOf(e);let i=Di.get(r);if(i||(i=/* @__PURE__ */new Set,Di.set(r,i)),!i.has(t)){i.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 $i=/* @__PURE__ */Fe("ZodType",(e,t)=>(On.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:pi(e,"input"),output:pi(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=ai({...n,processors:t});return li(e,r),ci(r,e),di(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ii(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ei(e,t,n),e.parseAsync=async(t,n)=>Ci(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ai(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ti(e,t,n),e.decode=(t,n)=>Mi(e,t,n),e.encodeAsync=async(t,n)=>zi(e,t,n),e.decodeAsync=async(t,n)=>Oi(e,t,n),e.safeEncode=(t,n)=>Ri(e,t,n),e.safeDecode=(t,n)=>Pi(e,t,n),e.safeEncodeAsync=async(t,n)=>Ni(e,t,n),e.safeDecodeAsync=async(t,n)=>Li(e,t,n),ji(e,"ZodType",{check(...e){const t=this.def;return this.clone(Qe(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 lt(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)})}(Qo,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */si(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(wt(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(wt(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(oi(e))},optional(){return Bo(this)},exactOptional(){return new Uo({type:"optional",innerType:this})},nullable(){return Wo(this)},nullish(){return Bo(Wo(this))},nonoptional(e){return function(e,t){return new Ho({type:"nonoptional",innerType:e,...ct(t)})}(this,e)},array(){return _o(this)},or(e){return Eo([this,e])},and(e){return new Mo({type:"intersection",left:this,right:e})},transform(e){return Jo(this,$o(e))},default(e){return t=e,new Zo({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},prefault(e){return t=e,new Vo({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},catch(e){return new Yo({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Jo(this,e)},readonly(){return new Xo({type:"readonly",innerType:this})},describe(e){const t=this.clone();return qr.add(t,{description:e}),t},meta(...e){if(0===e.length)return qr.get(this);const t=this.clone();return qr.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:()=>qr.get(e)?.description,configurable:!0}),e)),Fi=/* @__PURE__ */Fe("_ZodString",(e,t)=>{Rn.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:i,maximum:o,format:s,patterns:a,contentEncoding:l}=e._zod.bag;if("number"==typeof i&&(r.minLength=i),"number"==typeof o&&(r.maxLength=o),s&&(r.format=hi[s]??s,""===r.format&&delete r.format,"time"===s&&delete r.format),l&&(r.contentEncoding=l),a&&a.size>0){const e=[...a];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,ji(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new kn({check:"string_format",format:"regex",...ct(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new In({check:"string_format",format:"includes",...ct(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Cn({check:"string_format",format:"starts_with",...ct(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new En({check:"string_format",format:"ends_with",...ct(t),suffix:e})}(...e))},min(...e){return this.check(ri(...e))},max(...e){return this.check(ni(...e))},length(...e){return this.check(ii(...e))},nonempty(...e){return this.check(ri(1,...e))},lowercase(e){return this.check(function(e){return new _n({check:"string_format",format:"lowercase",...ct(e)})}(e))},uppercase(e){return this.check(function(e){return new Sn({check:"string_format",format:"uppercase",...ct(e)})}(e))},trim(){return this.check(/* @__PURE__ */oi(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
+ return oi(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */oi(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */oi(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */oi(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Bi=/* @__PURE__ */Fe("ZodString",(e,t)=>{Rn.init(e,t),Fi.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)})}(Wi,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(Hi,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(lo,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(Yi,t)),e.guid=t=>e.check(Jr(Zi,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(Vi,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)})}(Vi,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)})}(Vi,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)})}(Vi,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(qi,t)),e.guid=t=>e.check(Jr(Zi,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(Ji,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(Ki,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(Xi,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(oo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(so,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(Qi,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(eo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(to,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(no,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(ro,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(io,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(ao,t)),e.datetime=t=>e.check(fi(t)),e.date=t=>e.check(wi(t)),e.time=t=>e.check(vi(t)),e.duration=t=>e.check(ki(t))});function Ui(e){return function(e,t){return new e({type:"string",...ct(t)})}(Bi,e)}var Gi=/* @__PURE__ */Fe("ZodStringFormat",(e,t)=>{Pn.init(e,t),Fi.init(e,t)}),Wi=/* @__PURE__ */Fe("ZodEmail",(e,t)=>{Dn.init(e,t),Gi.init(e,t)}),Zi=/* @__PURE__ */Fe("ZodGUID",(e,t)=>{Nn.init(e,t),Gi.init(e,t)}),Vi=/* @__PURE__ */Fe("ZodUUID",(e,t)=>{Ln.init(e,t),Gi.init(e,t)}),Hi=/* @__PURE__ */Fe("ZodURL",(e,t)=>{jn.init(e,t),Gi.init(e,t)}),Yi=/* @__PURE__ */Fe("ZodEmoji",(e,t)=>{$n.init(e,t),Gi.init(e,t)}),qi=/* @__PURE__ */Fe("ZodNanoID",(e,t)=>{Fn.init(e,t),Gi.init(e,t)}),Ji=/* @__PURE__ */Fe("ZodCUID",(e,t)=>{Bn.init(e,t),Gi.init(e,t)}),Ki=/* @__PURE__ */Fe("ZodCUID2",(e,t)=>{Un.init(e,t),Gi.init(e,t)}),Xi=/* @__PURE__ */Fe("ZodULID",(e,t)=>{Gn.init(e,t),Gi.init(e,t)}),Qi=/* @__PURE__ */Fe("ZodXID",(e,t)=>{Wn.init(e,t),Gi.init(e,t)}),eo=/* @__PURE__ */Fe("ZodKSUID",(e,t)=>{Zn.init(e,t),Gi.init(e,t)}),to=/* @__PURE__ */Fe("ZodIPv4",(e,t)=>{Jn.init(e,t),Gi.init(e,t)}),no=/* @__PURE__ */Fe("ZodIPv6",(e,t)=>{Kn.init(e,t),Gi.init(e,t)}),ro=/* @__PURE__ */Fe("ZodCIDRv4",(e,t)=>{Xn.init(e,t),Gi.init(e,t)}),io=/* @__PURE__ */Fe("ZodCIDRv6",(e,t)=>{Qn.init(e,t),Gi.init(e,t)}),oo=/* @__PURE__ */Fe("ZodBase64",(e,t)=>{tr.init(e,t),Gi.init(e,t)}),so=/* @__PURE__ */Fe("ZodBase64URL",(e,t)=>{nr.init(e,t),Gi.init(e,t)}),ao=/* @__PURE__ */Fe("ZodE164",(e,t)=>{rr.init(e,t),Gi.init(e,t)}),lo=/* @__PURE__ */Fe("ZodJWT",(e,t)=>{ir.init(e,t),Gi.init(e,t)}),co=/* @__PURE__ */Fe("ZodNumber",(e,t)=>{or.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:i,maximum:o,format:s,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:c}=e._zod.bag;"string"==typeof s&&s.includes("int")?r.type="integer":r.type="number";const d="number"==typeof c&&c>=(i??Number.NEGATIVE_INFINITY),u="number"==typeof l&&l<=(o??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof i&&(r.minimum=i),u?p?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l:"number"==typeof o&&(r.maximum=o),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),ji(e,"ZodNumber",{gt(e,t){return this.check(Qr(e,t))},gte(e,t){return this.check(ei(e,t))},min(e,t){return this.check(ei(e,t))},lt(e,t){return this.check(Kr(e,t))},lte(e,t){return this.check(Xr(e,t))},max(e,t){return this.check(Xr(e,t))},int(e){return this.check(ho(e))},safe(e){return this.check(ho(e))},positive(e){return this.check(Qr(0,e))},nonnegative(e){return this.check(ei(0,e))},negative(e){return this.check(Kr(0,e))},nonpositive(e){return this.check(Xr(0,e))},multipleOf(e,t){return this.check(ti(e,t))},step(e,t){return this.check(ti(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 uo(e){return function(e,t){return new e({type:"number",checks:[],...ct(t)})}(co,e)}var po=/* @__PURE__ */Fe("ZodNumberFormat",(e,t)=>{sr.init(e,t),co.init(e,t)});function ho(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(po,e)}var mo=/* @__PURE__ */Fe("ZodBoolean",(e,t)=>{ar.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function go(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(mo,e)}var fo=/* @__PURE__ */Fe("ZodNull",(e,t)=>{lr.init(e,t),$i.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 yo=/* @__PURE__ */Fe("ZodUnknown",(e,t)=>{cr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function wo(){return new yo({type:"unknown"})}var bo=/* @__PURE__ */Fe("ZodNever",(e,t)=>{dr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function vo(e){return function(e,t){return new e({type:"never",...ct(t)})}(bo,e)}var xo=/* @__PURE__ */Fe("ZodDate",(e,t)=>{ur.init(e,t),$i.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(ei(t,n)),e.max=(t,n)=>e.check(Xr(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}),ko=/* @__PURE__ */Fe("ZodArray",(e,t)=>{hr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(i.minItems=s),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=li(o.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,ji(e,"ZodArray",{min(e,t){return this.check(ri(e,t))},nonempty(e){return this.check(ri(1,e))},max(e,t){return this.check(ni(e,t))},length(e,t){return this.check(ii(e,t))},unwrap(){return this.element}})});function _o(e,t){return function(e,t,n){return new e({type:"array",element:t,...ct(n)})}(ko,e,t)}var So=/* @__PURE__ */Fe("ZodObject",(e,t)=>{wr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object",i.properties={};const s=o.shape;for(const c in s)i.properties[c]=li(s[c],t,{...r,path:[...r.path,"properties",c]});const a=new Set(Object.keys(s)),l=new Set([...a].filter(e=>{const n=o.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(i.required=Array.from(l)),"never"===o.catchall?._zod.def.type?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=li(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),Ke(e,"shape",()=>t.shape),ji(e,"ZodObject",{keyof(){return Po(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:wo()})},loose(){return this.clone({...this._zod.def,catchall:wo()})},strict(){return this.clone({...this._zod.def,catchall:vo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!it(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 lt(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Xe(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!it(t))throw new Error("Invalid input to safeExtend: expected a plain object");return lt(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Xe(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 lt(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Xe(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 lt(e,Qe(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 Xe(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 lt(e,Qe(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 Xe(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 lt(t,Qe(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Xe(this,"shape",i),i},checks:[]}))}(Fo,this,e[0])},required(...e){return t=Ho,n=this,r=e[0],lt(n,Qe(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(r)for(const n in r){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return Xe(this,"shape",i),i}}));var t,n,r}})});function Io(e,t){return new So({type:"object",shape:e??{},...ct(t)})}var Co=/* @__PURE__ */Fe("ZodUnion",(e,t)=>{vr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=!1===i.inclusive,s=i.options.map((e,n)=>li(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options});function Eo(e,t){return new Co({type:"union",options:e,...ct(t)})}var Ao=/* @__PURE__ */Fe("ZodDiscriminatedUnion",(e,t)=>{Co.init(e,t),xr.init(e,t)});function To(e,t,n){return new Ao({type:"union",options:t,discriminator:e,...ct(n)})}var Mo=/* @__PURE__ */Fe("ZodIntersection",(e,t)=>{kr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=li(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=li(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]]})(e,t,n,r)});var zo=/* @__PURE__ */Fe("ZodRecord",(e,t)=>{Ir.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=s._zod.bag?.patterns;if("loose"===o.mode&&a&&a.size>0){const e=li(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const t of a)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=li(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=li(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const l=s._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Oo(e,t,n){return t&&t._zod?new zo({type:"record",keyType:e,valueType:t,...ct(n)}):new zo({type:"record",keyType:Ui(),valueType:e,...ct(t)})}var Ro=/* @__PURE__ */Fe("ZodEnum",(e,t)=>{Cr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Ze(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 i={};for(const o of e){if(!n.has(o))throw new Error(`Key ${o} not found in enum`);i[o]=t.entries[o]}return new Ro({...t,checks:[],...ct(r),entries:i})},e.exclude=(e,r)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Ro({...t,checks:[],...ct(r),entries:i})}});function Po(e,t){return new Ro({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ct(t)})}var No=/* @__PURE__ */Fe("ZodLiteral",(e,t)=>{Er.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,i=[];for(const o of r.values)if(void 0===o){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof o){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(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]}})});function Lo(e,t){return new No({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}var Do=/* @__PURE__ */Fe("ZodFile",(e,t)=>{Ar.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:a}=e._zod.bag;void 0!==o&&(i.minLength=o),void 0!==s&&(i.maxLength=s),a?1===a.length?(i.contentMediaType=a[0],Object.assign(r,i)):(Object.assign(r,i),r.anyOf=a.map(e=>({contentMediaType:e}))):Object.assign(r,i)})(e,0,n),e.min=(t,n)=>e.check(function(e,t){return new yn({check:"min_size",...ct(t),minimum:e})}(t,n)),e.max=(t,n)=>e.check(function(e,t){return new fn({check:"max_size",...ct(t),maximum:e})}(t,n)),e.mime=(t,n)=>e.check(function(e,t){return new An({check:"mime_type",mime:e,...ct(t)})}(Array.isArray(t)?t:[t],n))});var jo=/* @__PURE__ */Fe("ZodTransform",(e,t)=>{Tr.init(e,t),$i.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(wt(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(wt(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function $o(e){return new jo({type:"transform",transform:e})}var Fo=/* @__PURE__ */Fe("ZodOptional",(e,t)=>{zr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Bo(e){return new Fo({type:"optional",innerType:e})}var Uo=/* @__PURE__ */Fe("ZodExactOptional",(e,t)=>{Or.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Go=/* @__PURE__ */Fe("ZodNullable",(e,t)=>{Rr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=li(i.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wo(e){return new Go({type:"nullable",innerType:e})}var Zo=/* @__PURE__ */Fe("ZodDefault",(e,t)=>{Pr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Vo=/* @__PURE__ */Fe("ZodPrefault",(e,t)=>{Lr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Ho=/* @__PURE__ */Fe("ZodNonOptional",(e,t)=>{Dr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Yo=/* @__PURE__ */Fe("ZodCatch",(e,t)=>{$r.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;let o;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var qo=/* @__PURE__ */Fe("ZodPipe",(e,t)=>{Fr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s="input"===t.io?o?i.out:i.in:i.out;li(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Jo(e,t){return new qo({type:"pipe",in:e,out:t})}var Ko=/* @__PURE__ */Fe("ZodPreprocess",(e,t)=>{qo.init(e,t),Ur.init(e,t)}),Xo=/* @__PURE__ */Fe("ZodReadonly",(e,t)=>{Gr.init(e,t),$i.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;li(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Qo=/* @__PURE__ */Fe("ZodCustom",(e,t)=>{Vr.init(e,t),$i.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 es(e,t={}){const n=new Qo({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...ct(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:"invalid_type",expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function ts(e,t){return new Ko({type:"pipe",in:$o(e),out:t})}function ns(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...ct(t)})}(co,e)}function rs(e){return function(e,t){return new e({type:"boolean",coerce:!0,...ct(t)})}(mo,e)}function is(e){return function(e,t){return new e({type:"date",coerce:!0,...ct(t)})}(xo,e)}Po(["free","startup","growth","enterprise"]);var os,ss=Po(["created","active","suspended","pending_approval"]),as=Po(["free","startup","growth","enterprise"]),ls=Po(["human","ai"]),cs=Po(["male","female"]),ds=Po(["active","learning","error"]),us=Io({vector_index_created:go().nullable(),graph_index_created:go().nullable()}),ps=Po(["document","video"]),hs=Po(["user","research"]),ms=Po(["pending","processing","waiting_review","completed","failed"]),gs=(Po(["user","agent"]),Po(["widget","app"])),fs=(Po(["tell","show","do"]),Po(["app","website"])),ys=Po(["widget"]),ws=Po(["timer","github","slack","teams","jira","mcp"]),bs=Po(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_agent","update_agent","delete_agent","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"]),vs=Io({id:uo().optional(),created_at:is().optional(),updated_at:is().optional()}),xs=Io({file:es(File),application_id:ns().optional()}),ks=Io({id:ns()}),_s=Io({slug:Ui()}),Ss=Io({agent_id:ns()}),Is=Io({widget_id:ns()}),Cs=Io({simulation_id:ns()}),Es=Io({application_id:ns()}),As=Io({user_id:ns()}),Ts=Io({success:Lo(!0)}),Ms=Ts.extend({message:Ui()}),zs=(Io({workspace_id:ns().optional()}),Io({application_id:ns().optional()}),Io({limit:ns().optional().default(50),offset:ns().optional().default(0)})),Os=e=>Io({items:_o(e),total:uo(),limit:uo(),offset:uo()}),Rs=e=>Io({items:_o(e),count:uo()}),Ps=Io({status:Ui(),timestamp:Ui(),service:Ui(),version:Ui(),build:Ui()}),Ns=Io({name:Ui(),version:Ui(),build:Ui(),status:Ui(),timestamp:Ui()}),Ls=Po(["password","oauth"]),Ds=vs.extend({is_super:go(),status:ss,email:Ui().email(),external_id:Ui().nullish(),first_name:Ui().nullish(),last_name:Ui().nullish(),password:Ui().nullish(),image_url:Ui().nullish(),prompt_limit:uo().nullish(),last_login_at:is().nullish(),auth_method:Ls.nullish()}),js=Ds.partial().extend({email:Ui().email(),password:Ui()}),$s=Ds.partial(),Fs=Io({users:_o(js)}),Bs=Io({users:_o(Ds.partial())}),Us=(Io({token:Ui()}),vs.extend({name:Ui(),slug:Ui(),status:ss,package:as,ending_date:is().nullish(),external_workspace_id:Ui().nullish(),slack_webhook_configured:go().optional(),notify_all_members_on_question:go().optional()})),Gs=Us.partial().extend({name:Ui().min(1)}),Ws=Ui().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),Zs=Us.omit({slack_webhook_configured:!0}).partial().extend({slack_webhook_url:Ws.nullable().optional()}),Vs=Po(["active","past_due","canceled","unpaid","trialing","incomplete","incomplete_expired","paused"]),Hs=vs.extend({workspace_id:uo(),package:as,ending_date:is(),stripe_subscription_id:Ui().nullable(),stripe_price_id:Ui().nullable(),status:Vs.default("active").optional()}),Ys=(Hs.partial().extend({workspace_id:uo(),package:as}),Hs.partial(),Po(["owner","member"])),qs=vs.extend({workspace_id:uo(),user_id:uo(),role:Ys}),Js=Io({id:uo(),agent_name:Ui(),image_url:Ui().nullish()}),Ks=vs.extend({workspace_id:uo(),application_id:uo().optional(),file_name:Ui().min(1),file_size:ns(),file_type:ps,file_url:Ui(),source_url:Ui().nullish(),source:hs.default("user").optional(),agents:_o(Js).optional()}),Xs=Po(["chromium","firefox","webkit"]),Qs=Io({browsers:_o(Xs).default(["chromium"]),parallel:go().default(!1),fail_fast:go().default(!1),timeout_per_browser:uo().int().min(60).max(3600).optional()}),ea=vs.extend({workspace_id:uo(),user_id:uo(),application_id:uo(),file_name:Ui().min(1),file_size:ns(),file_type:Ui(),file_url:Ui(),file_path:Ui().nullable(),text_content:Ui().nullish(),additional_instructions:Ui().max(1e3).nullish(),status:ms,processing_step:Ui().nullish(),processing_started_at:is().nullish(),ultimate_goal:Ui().nullish(),browser_config:Qs.nullish(),persona_ids:_o(ns()).optional().default([]),pinned:go().optional().default(!1)}),ta=Io({application_id:ns(),file:es(File).optional(),text_content:Ui().optional(),file_name:Ui().optional(),additional_instructions:Ui().max(1e3).optional(),persona_ids:_o(ns()).optional()}),na=vs.extend({qa_flow_id:uo(),workspace_id:uo(),triggered_by:uo(),browser_type:Xs,browser_config:Qs.nullish(),simulation_id:uo(),source:Po(["manual","automation","github_pr","slack_command"]).nullish(),source_metadata:Oo(Ui(),wo()).nullish(),auto_heal:go().default(!1),auto_accept:go().default(!1),has_question:go().optional()}),ra=Io({version:uo().int().positive(),test_title:Ui(),test_objective:Ui(),test_steps:_o(Ui()),expected_outcome:Ui(),priority:Po(["Low","Medium","High"]),change_type:Po(["created","modified","self_healed","refined","deleted"]),change_reason:Ui().nullish(),changed_by:uo().nullish(),created_at:Ui(),accepted:go().optional()}),ia=Io({failure_type:Po(["locator","assertion","timeout","flow_change","environment"]),failure_message:Ui().nullish(),failure_context:Oo(Ui(),wo()).nullish(),repair_strategy:Ui().nullish(),repair_details:Oo(Ui(),wo()).nullish(),confidence_score:uo().min(0).max(1).nullish(),validation_status:Po(["pending","validated","failed","rejected"]),simulation_id:uo().nullish(),validation_simulation_id:uo().nullish(),healed_version:uo().nullish(),created_at:Ui()}),oa=(Po(["passed","needs_healing","failed"]),Io({outcome_reached:go(),steps_aligned:go(),healing_recommended:go(),is_actual_bug:go(),confidence:uo().min(0).max(1),reasoning:Ui(),evaluated_at:Ui(),screenshot_url:Ui().nullish()})),sa=Po(["queued","running","passed","failed","needs_healing","stopped"]),aa=Io({qa_run_id:uo(),qa_test_case_id:uo(),simulation_task_id:Ui().nullable().optional(),status:sa,verdict:Ui().nullable().optional(),proposed_steps:_o(Ui()).default([]),executed_steps:_o(Ui()).nullable().optional(),evaluation:oa.nullable().optional(),started_at:is().nullable().optional(),ended_at:is().nullable().optional(),created_at:is().optional(),updated_at:is().optional()}),la=vs.extend({qa_flow_id:uo(),workspace_id:uo(),order_index:uo().int().nonnegative(),test_title:Ui(),test_objective:Ui(),test_steps:_o(Ui()),expected_outcome:Ui(),priority:Po(["Low","Medium","High"]),is_active:ts(e=>"number"==typeof e?0!==e:e,go()),current_version:uo().int().positive(),version_history:_o(ra).nullable(),healing_attempts:_o(ia).nullable(),healing_metadata:Oo(Ui(),wo()).nullish(),last_healed_at:is().nullish(),blocked_by:_o(Io({index:uo().int().nonnegative(),condition:Po(["pass"]).optional()})).default([])}),ca=(Io({qa_flow_id:uo(),test_title:Ui(),test_objective:Ui(),test_steps:_o(Ui()),expected_outcome:Ui(),priority:Po(["Low","Medium","High"]).optional()}),Io({ultimateGoal:Ui(),document:ea,testCases:_o(Io({id:uo(),title:Ui(),prompt:Ui(),objective:Ui(),steps:_o(Ui()),expectedOutcome:Ui(),priority:Po(["Low","Medium","High"])})),summary:Io({total:uo(),estimatedTime:Ui(),complexity:Po(["Low","Medium","High"])})})),da=Io({ultimate_goal:Ui(),test_cases:_o(Io({test_title:Ui(),test_objective:Ui(),test_steps:_o(Ui()),expected_outcome:Ui(),priority:Po(["Low","Medium","High"])})),summary:Io({total_tests:uo(),high_priority:uo(),medium_priority:uo(),low_priority:uo(),estimated_time_minutes:uo()})}),ua=(To("event",[Io({event:Lo("response.created"),data:Io({message:Ui()})}),Io({event:Lo("response.progress"),data:Io({message:Ui()})}),Io({event:Lo("response.clear"),data:Io({}).optional()}),Io({event:Lo("response.completed"),data:da}),Io({event:Lo("error"),data:Io({detail:Ui()})})]),Eo([Ui(),uo(),go(),_o(Ui()),function(e,t){return new e({type:"null",...ct(t)})}(fo,os)])),pa=(Po(["created","modified","self_healed","refined","deleted"]),Po(["locator","assertion","timeout","flow_change","environment"])),ha=(Po(["pending","validated","failed","rejected"]),Io({healing_enabled:go().default(!0),auto_apply:go().default(!1),min_confidence_threshold:uo().min(0).max(1).default(.85),max_healing_attempts:uo().int().min(1).max(5).default(2),last_healing_attempt:Ui().datetime().nullable(),total_healing_attempts:uo().int().default(0),successful_heals:uo().int().default(0)}),Io({failure_type:pa,is_healable:go(),is_actual_bug:go(),failure_message:Ui(),failure_context:Oo(Ui(),wo()),suggested_repair:Io({type:Po(["update_locator","update_assertion","update_steps","skip_test"]),confidence:uo().min(0).max(1),details:Oo(Ui(),wo())}).nullable()})),ma=(Io({go_to_url:Io({url:Ui(),new_tab:go()})}),Io({click_element_by_index:Io({index:uo().int().min(1)})}),Io({input_text:Io({index:uo(),text:Ui(),clear_existing:go()})}),Io({write_file:Io({file_name:Ui(),content:Ui(),append:go(),trailing_newline:go(),leading_newline:go()})}),Io({get_otp:Io({question:Ui()})}),Io({done:Io({success:go(),message:Ui().optional()})}),Io({wait:Io({seconds:uo()})}),Io({reload_page:Io({})}),Io({open_new_tab:Io({url:Ui()})}),Io({navigate_to_url:Io({url:Ui()})}),Io({name:Ui().min(1),params:Oo(Ui(),wo()).default({}),result:Oo(Ui(),wo()).default({})})),ga=Io({action_text:Ui().min(1),tool_calls:_o(ma).default([]),skill_used:Ui().nullable().default(null),screenshot_path:Ui().nullable().default(null),status:Po(["running","completed","failed","has_question"]).default("completed"),started_at:Ui(),ended_at:Ui(),error_message:Ui().nullable().default(null),url:Ui().nullable().default(null),title:Ui().nullable().default(null)}).passthrough(),fa=Io({step_number:uo().int().positive(),topic:Ui(),screenshot_url:Ui().nullable(),title:Ui().optional().nullable(),url:Ui().optional().nullable()}),ya=(Io({status:Ui(),status_message:Ui().nullable(),task_id:Ui().nullish(),created_at:is()}),Io({task_id:Ui(),condition:Po(["pass"]).optional()})),wa=Io({task_id:Ui(),title:Ui(),instructions:Ui(),status:Po(["pending","running","has_question","passed","failed","skipped","stopped"]),error_message:Ui().nullish(),started_at:Ui().nullish(),completed_at:Ui().nullish(),order_index:uo().int().nonnegative().default(0),tab_id:Ui().nullish(),step_count:uo().int().nonnegative().default(0),blocked_by:_o(ya).default([])}),ba=vs.extend({application_id:uo(),agent_id:uo(),job_id:Ui(),browser_session_id:Ui().nullish(),status:Ui(),status_message:Ui().nullish(),path:Ui().nullish(),instructions:Ui().nullish(),pinned:go().optional(),source:Po(["direct","qa"]).optional(),agent_name:Ui().nullish(),graph_index_id:Ui().nullish(),source_metadata:Oo(Ui(),wo()).nullish(),tasks:_o(wa).optional(),agents:_o(Js).optional(),mindmap_status:Ui().optional(),mindmap_steps_processed:uo().int().nonnegative().optional(),mindmap_steps_total:uo().int().nonnegative().optional(),mindmap_error:Ui().nullish(),created_by_user_id:uo().nullish(),has_question:go().optional()}),va=ba.omit({tasks:!0,source_metadata:!0}),xa=(Io({user_id:uo(),email:Ui(),first_name:Ui().optional().nullable(),last_name:Ui().optional().nullable(),last_simulation_at:Ui().optional()}),ba.omit({tasks:!0}).partial().extend({application_id:uo(),agent_id:uo(),instructions:Ui(),max_steps:uo().int().positive().max(1e3).optional(),timeout:uo().positive().max(360).optional()})),ka=Io({job_id:Ui().optional(),status:Ui().optional(),status_message:Ui().optional(),pinned:go().optional(),graph_index_id:Ui().optional()}),_a=Io({answer:Ui().min(1)}),Sa=vs.extend({session_id:Ui(),chat_id:Ui(),application_id:ns(),blob_url:Ui().nullable(),event_count:ns().int().nonnegative(),started_at:is(),ended_at:is().nullable(),is_active:ts(e=>"number"==typeof e?0!==e:e,go()),metadata:Io({userAgent:Ui().optional(),url:Ui().optional(),viewport:Io({width:uo(),height:uo()}).optional()}).nullable(),last_batch_index:ns().int().nullable(),last_event_timestamp:ns().int().nullable(),last_upload_time:is().nullable()}),Ia=Io({session_id:Ui().min(1),chat_id:Ui().min(1),application_id:uo().int().nullish(),blob_url:Ui().nullish(),event_count:uo().int().nonnegative().optional(),started_at:is().optional(),ended_at:is().nullish(),is_active:ts(e=>"number"==typeof e?0!==e:e,go()).optional(),metadata:Io({userAgent:Ui().optional(),url:Ui().optional(),viewport:Io({width:uo(),height:uo()}).optional()}).nullable().optional(),last_batch_index:uo().int().nonnegative().nullish(),last_event_timestamp:uo().int().nullish(),last_upload_time:is().nullish()}),Ca=Io({id:uo(),simulation_id:uo(),status:Ui(),status_message:Ui().nullable(),created_at:is()}),Ea=Io({start:Ui(),end:Ui(),action:Ui()}).passthrough(),Aa=Io({id:Ui(),label:Ui(),purpose:Ui(),elements:_o(Oo(Ui(),wo())).default([]),bbox:Oo(Ui(),wo()).default({}),screenshot:Ui().default(""),embedding:_o(uo()).nullish()}).passthrough(),Ta=Io({id:Ui(),title:Ui(),url:Ui(),summary:Ui().default(""),screenshot:Ui().default(""),sections:_o(Aa).default([]),sequence_ids:_o(uo()).default([]),embedding:_o(uo()).nullish()}).passthrough(),Ma=Io({nodes:_o(Ta),edges:_o(Ea)}),za=vs.extend({workspace_id:uo(),user_id:uo().nullish(),application_id:uo(),agent_name:Ui(),agent_type:ls,agent_voice:cs,agent_description:Ui().nullish(),instructions:Ui().nullish(),image_url:Ui().nullish(),graph_index_id:Ui().nullish(),vector_store_id:Ui().nullish(),status:ds,status_message:Ui().nullish(),learning_progress:us.nullish(),learning_started_at:is().nullish(),workspace:Us.optional(),user:Ds.optional(),knowledge:_o(Ks).optional(),simulations:_o(ba).optional(),simulation_count:uo().int().nonnegative().optional(),knowledge_count:uo().int().nonnegative().optional()}),Oa=e=>{if(Array.isArray(e))return e.map(e=>Number(e));if("string"==typeof e){const t=JSON.parse(e);return Array.isArray(t)?t.map(e=>Number(e)):[]}return[]},Ra=Eo([_o(uo()),Ui()]).transform(Oa),Pa=Eo([_o(uo()),Ui()]).transform(Oa),Na=za.partial().extend({application_id:ns(),agent_name:Ui(),agent_type:ls,agent_voice:cs,agent_description:Ui(),instructions:Ui(),file:es(File).optional(),image_url:Ui().optional(),knowledge_ids:Ra,simulation_ids:Pa}),La=za.partial().extend({file:es(File).optional(),knowledge_ids:Ra,simulation_ids:Pa}),Da=(Io({text:Ui(),task_id:Ui().optional()}),Io({status:Ui(),message:Ui().optional()}),Io({task_id:Ui().optional(),status:Ui().optional(),current_step:Ui().optional(),error:Ui().optional(),message:Ui().optional()}),Io({workflow_id:Ui(),workflow_type:Ui(),status:Ui(),current_step:Ui(),error:Ui().nullable(),created_at:Ui(),updated_at:Ui()}),Io({browser_session_id:Ui().optional(),live_view_url:Ui().nullish(),status:Ui().optional(),message:Ui().nullish(),success:go().optional()}),Io({contentType:Po(["document","video","automation_log","screenshot","all"]).optional(),context:Ui().optional(),previousActions:_o(Ui()).optional(),top:ns().min(1).max(100).optional(),minConfidence:ns().min(0).max(1).optional(),entities:_o(Ui()).optional(),useVectorSearch:go().optional(),vectorThreshold:ns().min(0).max(1).optional()}),Io({id:Ui(),content:Ui(),contentType:Po(["document","video","automation_log","screenshot"]),sourceFile:Ui(),sourceType:Ui(),metadata:Ui(),confidence:uo(),keyPhrases:_o(Ui()),entities:_o(Ui()),sentiment:Ui(),vectorContent:_o(uo())})),ja=(Io({document:Da,score:uo(),highlights:Oo(Ui(),_o(Ui())).optional()}),Io({simulation_id:ns().positive("Simulation ID must be a positive number")})),$a=Io({agent:za,simulation_id:uo(),knowledge_id:uo(),message:Ui()}),Fa=vs.extend({workspace_id:uo(),name:Ui(),slug:Ui(),type:fs,url:Ui().nullish(),username:Ui().nullish(),password:Ui().nullish(),allowed_domains:_o(Ui()).nullish().default([])}),Ba=Fa.omit({password:!0}),Ua=Fa.partial().extend({type:fs,name:Ui().min(1),url:Ui(),allowed_domains:_o(Ui()).optional().default([])}),Ga=Fa.partial().omit({workspace_id:!0,slug:!0}),Wa=Io({chip_mode:Po(["show","tell","do"]),chip_text:Ui()}),Za=Io({widget_enabled:go(),widget_appearance:Po(["default","compact","full"]),widget_position:Po(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Po(["desktop","mobile","desktop_mobile"]),widget_header:Ui(),widget_body:Ui(),widget_greeting:Ui(),widget_feature_tell:go(),widget_feature_show:go(),widget_feature_do:go(),widget_feature_human:go(),widget_background_color:Ui(),widget_text_color:Ui(),widget_border_color:Ui(),widget_accent_color:Ui(),widget_secondary_color:Ui(),widget_border_radius:Ui(),widget_font_size:Ui(),widget_width:Ui(),widget_height:Ui(),widget_shadow:Ui(),widget_animation_duration:Ui(),widget_fade_duration:Ui(),widget_bounce_effect:go(),widget_chips:_o(Wa)}),Va=vs.extend({application_id:uo(),agent_id:uo(),type:ys,settings:Za,status:ss,marketrix_id:Ui(),marketrix_key:Ui(),snippet:Ui().nullish()}),Ha=(Va.extend({application:Ba.partial(),workspace:Us.partial(),user:Ds.partial(),agent:za.partial()}),Va.extend({agent:za.partial().optional()})),Ya=(Ba.extend({widgets:_o(Va).optional(),agents:_o(za).optional()}),Va.partial().extend({application_id:uo().positive(),agent_id:uo().positive(),type:ys,settings:Za.optional()})),qa=Va.partial(),Ja=vs.extend({widget_id:uo(),url_pattern:Ui(),message:_o(Ui()),description:Ui().optional()}),Ka=Ja.partial().extend({widget_id:uo().positive(),url_pattern:Ui().min(1),message:_o(Ui().min(1)).min(1)}),Xa=Ja.partial(),Qa=(Io({marketrix_id:Ui().optional(),marketrix_key:Ui().optional(),agent_id:uo().positive().optional(),application_id:uo().positive().optional(),chat_id:Ui().optional(),content:Ui()}).refine(e=>(e.marketrix_id&&e.marketrix_key)??(e.agent_id&&e.application_id),{message:"Either marketrix_id + marketrix_key or both agent_id + application_id must be provided"}),Io({text:Ui(),task_id:Ui().optional()}),To("type",[Io({type:Lo("registered"),chat_id:Ui(),application_id:uo().optional()}),Io({type:Lo("pong")}),Io({type:Lo("heartbeat")}),Io({type:Lo("chat/response"),request_id:Ui(),text:Ui(),task_id:Ui().optional()}),Io({type:Lo("chat/error"),request_id:Ui(),error:Ui()}),Io({type:Lo("task/status"),status:Po(["running","completed","failed","stopped","has_question"]),message:Ui().optional(),task_id:Ui().optional(),timestamp:uo().optional()}),Io({type:Lo("tool/call"),call_id:Ui(),tool:Ui(),args:Oo(Ui(),wo()),mode:Po(["show","do"]).optional(),explanation:Ui().optional(),state_version:uo().optional()})])),el=To("type",[Io({type:Lo("chat/tell"),request_id:Ui(),content:Ui()}),Io({type:Lo("chat/show"),request_id:Ui(),content:Ui()}),Io({type:Lo("chat/do"),request_id:Ui(),content:Ui()}),Io({type:Lo("chat/stop"),task_id:Ui().optional()}),Io({type:Lo("tool/response"),call_id:Ui(),success:go(),data:Ui().optional(),error:Ui().optional(),state_version:uo().optional()}),Io({type:Lo("ping")}),Io({type:Lo("rrweb/metadata"),session_id:Ui(),chat_id:Ui(),application_id:uo(),url:Ui().optional(),user_agent:Ui().optional(),timestamp:uo().optional(),viewport:Io({width:uo(),height:uo()}).optional()}),Io({type:Lo("rrweb/events"),session_id:Ui(),events:_o(wo())})]),tl=Po(["simulations","agents","qa","user","jobs","triggers","automations","notifications"]),nl=Po(["queued","running","creating_knowledge","completed","failed","stopped"]),rl=Po(["pending","running","completed","failed","stopped"]),il=To("type",[Io({type:Lo("simulation/updated"),simulation_id:uo(),application_id:uo(),status:nl,has_question:go().optional(),step_label:Ui().optional(),step_pending:go().optional(),task_id:Ui().nullish()}),Io({type:Lo("simulation/created"),simulation_id:uo(),application_id:uo()}),Io({type:Lo("simulation/deleted"),simulation_id:uo(),application_id:uo()}),Io({type:Lo("simulation/queued"),simulation_id:uo(),job_id:Ui()}),Io({type:Lo("simulation/started"),simulation_id:uo(),job_id:Ui()}),Io({type:Lo("simulation/step"),simulation_id:uo(),job_id:Ui(),step_count:uo().optional(),message:Ui().optional()}),Io({type:Lo("simulation/question"),simulation_id:uo(),job_id:Ui(),question:Ui().optional()}),Io({type:Lo("simulation/completed"),simulation_id:uo(),job_id:Ui(),step_count:uo().optional()}),Io({type:Lo("simulation/failed"),simulation_id:uo(),job_id:Ui(),error:Ui().optional()}),Io({type:Lo("simulation/stopped"),simulation_id:uo(),job_id:Ui()}),Io({type:Lo("simulation/mindmap-updated"),simulation_id:uo(),application_id:uo(),mindmap_status:Ui(),steps_processed:uo(),steps_total:uo()}),Io({type:Lo("qa-run/completed"),run_id:uo(),status:Ui()}),Io({type:Lo("agent/updated"),agent_id:uo().optional(),context_id:Ui().optional(),task_id:Ui().optional(),application_id:uo().optional(),status:Ui(),error:Ui().optional()}),Io({type:Lo("agent/created"),agent_id:uo(),application_id:uo()}),Io({type:Lo("agent/deleted"),agent_id:uo(),application_id:uo()}),Io({type:Lo("qa-document/updated"),document_id:uo(),application_id:uo(),status:Ui(),step_label:Ui().optional()}),Io({type:Lo("qa-run/updated"),run_id:uo(),document_id:uo(),application_id:uo(),status:rl,has_question:go().optional(),simulation_id:uo().optional()}),Io({type:Lo("qa-test/updated"),test_id:uo(),run_id:uo(),document_id:uo(),application_id:uo(),status:Ui()}),Io({type:Lo("user/updated"),user_id:uo(),workspace_id:uo(),status:Ui()}),Io({type:Lo("job/progress"),job_id:Ui(),application_id:uo(),status:Ui(),message:Ui().optional(),phase:Po(["research","segments","personas"]).optional()}),Io({type:Lo("job/completed"),job_id:Ui(),application_id:uo(),result:wo().optional()}),Io({type:Lo("job/failed"),job_id:Ui(),application_id:uo(),error:Ui()}),Io({type:Lo("trigger/fired"),trigger_id:uo(),workspace_id:uo(),provider:Ui(),name:Ui(),payload:wo().optional(),timestamp:Ui()}),Io({type:Lo("automation-run/completed"),automation_id:uo(),run_id:uo(),status:Lo("completed")}),Io({type:Lo("automation-run/failed"),automation_id:uo(),run_id:uo(),status:Lo("failed"),error:Ui().optional()}),Io({type:Lo("reaction/completed"),reaction_id:uo(),run_id:uo(),application_id:uo()}),Io({type:Lo("reaction/failed"),reaction_id:uo(),run_id:uo(),application_id:uo(),error:Ui().optional()}),Io({type:Lo("reaction/progress"),reaction_id:uo(),run_id:uo(),application_id:uo(),result_id:uo(),persona_id:uo().nullable(),completed_personas:uo(),total_personas:uo(),failed_personas:uo()}),Io({type:Lo("notification/created"),notification_id:uo(),workspace_id:uo(),recipient_user_id:uo(),simulation_id:uo(),application_id:uo(),task_id:Ui().nullable(),url:Ui(),summary:Ui(),question_text:Ui().nullable()}),Io({type:Lo("notification/resolved"),notification_id:uo(),workspace_id:uo(),simulation_id:uo(),application_id:uo(),reason:Po(["answered","dismissed","cancelled"])})]),ol=Po(["simulation_question"]),sl=Po(["answered","dismissed","cancelled"]),al=Io({id:uo(),workspace_id:uo(),recipient_user_id:uo(),type:ol,simulation_id:uo().nullable(),task_id:Ui().nullable(),question_text:Ui().nullable(),url:Ui().nullable(),summary:Ui(),email_sent_at:is().nullable(),read_at:is().nullable(),resolved_at:is().nullable(),resolved_reason:sl.nullable(),resolved_by_user_id:uo().nullable(),created_at:is()}),ll=Io({push:Io({enabled:go()}),email:Io({enabled:go(),delay_minutes:ns().int().min(1).max(120)}),slack:Io({enabled:go()})}),cl=Io({endpoint:Ui().url(),p256dh:Ui().min(1),auth:Ui().min(1),user_agent:Ui().optional()}),dl=Io({endpoint:Ui().url()}),ul=Io({webhook_url:Ws}),pl=Io({public_key:Ui().nullable()}),hl=Io({details:Ui().optional(),id:uo().optional(),type:Ui().optional(),name:Ui().optional(),target_user_id:uo().optional(),target_user_email:Ui().optional(),reason:Ui().optional(),assigned_role:Ui().optional(),new_role:Ui().optional(),previous_role:Ui().optional(),workspace_name:Ui().optional(),workspace_slug:Ui().optional(),ip_address:Ui().optional(),user_agent:Ui().optional(),widget_type:Ui().optional(),created_by:uo().optional()}).passthrough(),ml=vs.extend({workspace_id:uo(),user_id:uo(),type:bs,metadata:hl.optional()}),gl=ml.partial().extend({type:bs}),fl=Po(["widget_chat","app_chat","guide_preview","slack"]),yl=Po(["user","assistant","system","tool"]),wl=(vs.extend({context_id:Ui(),workspace_id:uo(),application_id:uo().nullish(),agent_id:uo().nullish(),user_id:uo().nullish(),simulation_id:uo().nullish(),session_id:uo().nullish(),persona_id:uo().nullish(),type:fl,channel_id:Ui().nullish(),preview_video_url:Ui().nullish(),metadata:Oo(Ui(),wo()).nullish()}),vs.extend({conversation_id:uo(),role:yl,content:Ui(),tool_call_id:Ui().nullish()}),vs.extend({workspace_id:uo(),application_id:uo().nullish(),provider:ws,name:Ui().min(1).max(120),identifier:Ui().max(120).nullish(),api_endpoint:Ui().url().nullish(),api_token:Ui().nullish(),metadata:Oo(Ui(),wo()).nullish(),is_active:go().default(!0),status:ss.default("active")})),bl=Io({id:ns().optional(),application_id:uo().nullish(),provider:ws,name:Ui().min(1).max(120),identifier:Ui().max(120).nullish(),api_endpoint:Ui().url().nullish(),api_token:Ui().nullish(),metadata:Oo(Ui(),wo()).nullish(),is_active:go().optional(),status:ss.optional()}),vl=Io({application_id:uo().nullish(),provider:ws.optional(),status:ss.optional(),is_active:rs().optional(),limit:ns().int().positive().max(100).optional(),offset:ns().int().nonnegative().optional()}),xl=Io({id:uo(),application_id:uo(),identifier:Ui(),api_token:Ui(),is_active:go(),created_at:is().optional()}),kl=Io({name:Ui(),category:Ui(),description:Ui(),inputSchema:Oo(Ui(),wo()),enabled:go()}),_l=Io({id:uo(),full_name:Ui(),name:Ui(),private:go(),html_url:Ui(),default_branch:Ui().optional()}),Sl=Io({id:uo(),name:Ui(),status:Ui(),conclusion:Ui().nullable(),created_at:Ui(),updated_at:Ui(),html_url:Ui(),head_branch:Ui(),run_attempt:uo()}),Il=Po(["pending","running","completed","failed","stopped"]),Cl=(Po(["connector","condition"]),To("kind",[Io({kind:Lo("connector"),connector_type:Ui().min(1),connector_id:uo().nullable().optional(),trigger_id:uo().nullable().optional(),action_id:uo().nullable().optional(),capability:Ui().min(1),role:Po(["trigger","callback"]),config:Oo(Ui(),wo()).default({})}),Io({kind:Lo("condition"),config:Io({field:Ui().min(1),operator:Po(["equals","not_equals","contains","gt","lt"]),value:wo()})})])),El=Io({from:Ui().min(1),to:Ui().min(1),when:Po(["true","false"]).optional()}),Al=Io({nodes:Oo(Ui(),Cl),edges:_o(El)}),Tl=Po(["skip","queue","replace"]).default("skip"),Ml=vs.extend({workspace_id:uo(),created_by_user_id:uo().nullable(),name:Ui(),graph:Al,concurrency:Tl,enabled:go(),last_run_at:is().nullable(),next_run_at:is().nullable()}),zl=Io({name:Ui().min(1).max(255),graph:Al,concurrency:Tl.optional(),enabled:go().optional()}),Ol=Io({id:ns(),name:Ui().min(1).max(255).optional(),graph:Al.optional(),enabled:go().optional()}),Rl=Io({enabled:rs().optional(),limit:ns().int().positive().max(100).optional(),offset:ns().int().nonnegative().optional()}),Pl=Io({status:Po(["in_progress","completed","failed","skipped","stopped"]),output:Oo(Ui(),wo()).nullable().optional(),error:Ui().nullable().optional(),duration_ms:uo().optional()}),Nl=Io({id:uo().optional(),automation_id:uo(),status:Il,trigger_node_id:Ui(),trigger_data:Oo(Ui(),wo()).nullable(),node_results:Oo(Ui(),Pl),started_at:is(),completed_at:is().nullable()}),Ll=Io({status:Il.optional(),limit:ns().int().positive().max(100).optional(),offset:ns().int().nonnegative().optional()}),Dl=Io({connector_type:Ui(),built_in:go(),triggers:_o(Io({capability:Ui(),description:Ui(),config_schema:Oo(Ui(),wo())})),callbacks:_o(Io({capability:Ui(),description:Ui(),config_schema:Oo(Ui(),wo())}))}),jl=Io({filename:Ui(),status:Ui(),additions:uo(),deletions:uo(),patch:Ui().optional()}),$l=(Io({event:Ui(),action:Ui(),pull_request:Io({number:uo(),title:Ui(),html_url:Ui(),head:Io({sha:Ui(),ref:Ui()}),base:Io({ref:Ui()})}),repository:Io({full_name:Ui(),name:Ui(),owner:Io({login:Ui()})}),sender:Io({login:Ui()}),files:_o(jl).optional()}),Io({name:Ui(),head_sha:Ui(),status:Po(["queued","in_progress","completed"]).optional(),conclusion:Po(["success","failure","neutral","cancelled","timed_out","action_required"]).optional(),started_at:Ui().optional(),completed_at:Ui().optional(),output:Io({title:Ui(),summary:Ui(),text:Ui().optional()}).optional()}),Io({url:Ui()})),Fl=(Io({user_id:uo(),file:es(File)}),Io({user_id:uo(),application_id:uo(),source:gs,prompt:Ui(),status:Ui()}),Io({user_id:uo(),limit:uo(),used:uo(),remaining:uo()})),Bl=(Io({user_id:uo(),workspace_id:uo(),chat_count:uo(),prompt_text:Ui(),metadata:Oo(Ui(),Ui()).optional()}),Io({to:Ui(),subject:Ui(),template:Ui(),context:Oo(Ui(),Ui())}),Io({id:Ui(),object:Lo("event"),api_version:Ui().nullish(),created:uo(),data:Io({object:Oo(Ui(),wo()),previous_attributes:Oo(Ui(),wo()).optional()}),livemode:go(),pending_webhooks:uo(),request:Io({id:Ui().nullable(),idempotency_key:Ui().nullable()}).nullable().optional(),type:Ui()}),Io({priceId:Ui().min(1,"Price ID is required"),successUrl:Ui().url("Success URL must be a valid URL"),cancelUrl:Ui().url("Cancel URL must be a valid URL")})),Ul=Io({returnUrl:Ui().url("Return URL must be a valid URL")}),Gl=Io({plan:Po(["startup","growth"]).default("startup"),interval:Po(["month","year"]).default("month")}),Wl=Io({subscriptionId:Ui().min(1,"Subscription ID is required"),priceId:Ui().min(1,"Price ID is required")}),Zl=Io({success:go(),message:Ui()}),Vl=Io({subscriptionId:Ui().nullable(),customerId:Ui().nullable(),status:Po(["active","past_due","canceled","unpaid","trialing","incomplete","incomplete_expired","paused"]).nullable(),planTier:Po(["free","startup","growth","enterprise"]).nullable(),billingInterval:Po(["month","year"]).nullable(),priceId:Ui().nullable(),trialEndDate:is().nullable(),currentPeriodStart:is().nullable(),currentPeriodEnd:is().nullable(),cancelAtPeriodEnd:go(),isTrialing:go(),daysRemainingInTrial:uo().nullable(),trial_provisioned:go()}),Hl=Io({sessionId:Ui(),url:Ui().url()}),Yl=Io({url:Ui().url()}),ql=Io({subscriptionId:Ui(),customerId:Ui(),status:Lo("trialing"),trialStartDate:is(),trialEndDate:is(),planTier:Po(["startup","growth"]),daysRemainingInTrial:uo()}),Jl=Io({used:uo().int().min(0),limit:uo().int()}),Kl=Io({applications:Jl,simulationsPerMonth:Jl,userPrompts:Jl}),Xl=Io({amount:uo().int().min(0),currency:Ui().default("usd"),formatted:Ui()}),Ql=Io({planId:Po(["free","startup","growth","enterprise"]),monthly:Xl.nullable(),annual:Xl.nullable(),priceIds:Io({monthly:Ui().nullable(),annual:Ui().nullable()})}),ec=Io({plans:_o(Ql),lastUpdated:Ui().datetime()}),tc=Io({id:Po(["free","startup","growth","enterprise"]),name:Ui(),description:Ui(),features:_o(Ui()),cta:Ui(),isPopular:go(),customPriceDisplay:Ui().optional(),priceSubtext:Ui().optional(),borderColor:Ui(),buttonColor:Ui(),outlineColor:Ui(),checkColor:Ui()}),nc=Io({plans:_o(tc)}),rc=Io({publishableKey:Ui(),priceIds:Io({startup:Io({monthly:Ui().nullable(),annual:Ui().nullable()}),growth:Io({monthly:Ui().nullable(),annual:Ui().nullable()})}),trialDays:uo().int().min(0),calendlyUrl:Ui()}),ic=Io({widgetKey:Ui(),widgetId:Ui(),widgetUrl:Ui()}),oc=Io({date:Ui().describe("YYYY-MM-DD"),sessions:uo().int().nonnegative(),events:uo().int().nonnegative()}),sc=Io({items:_o(oc)}),ac=Io({role:Po(["user","assistant","system"]),content:Ui(),timestamp:Ui().optional()}),lc=vs.extend({workspace_id:uo(),application_id:uo().nullish(),agent_id:uo().nullish(),simulation_id:uo().nullish(),chat_id:Ui(),chat_content:Ui().nullish(),chat_history:_o(ac).nullish(),chat_output:Ui().nullish(),preview_video_url:Ui().nullish(),metadata:Oo(Ui(),wo()).nullish()}),cc=Io({application_id:uo().nullish(),agent_id:uo().nullish(),simulation_id:uo().nullish(),chat_id:Ui(),chat_content:Ui().nullish(),chat_history:_o(ac).nullish(),chat_output:Ui().nullish(),preview_video_url:Ui().nullish(),metadata:Oo(Ui(),wo()).nullish()}),dc=Io({chat_id:Ui().optional(),agent_id:uo().optional(),simulation_id:uo().optional(),limit:uo().optional(),offset:uo().optional()}),uc=Po(["github","slack","teams","jira"]),pc=Po(["github","slack","teams","jira","timer","mcp"]),hc=Po(["github","slack","teams","jira","internal"]),mc=Po(["connected","disconnected"]),gc=Io({workspace_id:uo(),provider:uc,status:mc.default("disconnected"),credentials:Oo(Ui(),wo()).nullish(),provider_data:Oo(Ui(),wo()).nullish(),connected_at:is().nullish(),created_at:is().optional(),updated_at:is().optional()}),fc=vs.extend({workspace_id:uo(),connector_id:uo().nullish(),provider:pc,name:Ui().min(1).max(255),source_config:Oo(Ui(),wo()).default({}),webhook_id:Ui(),webhook_secret:Ui(),enabled:go().default(!0),last_triggered_at:is().nullish()}),yc=Io({connector_id:uo().nullish(),provider:pc,name:Ui().min(1).max(255),source_config:Oo(Ui(),wo()).default({})}),wc=Io({trigger_id:ns(),name:Ui().min(1).max(255).optional(),source_config:Oo(Ui(),wo()).optional(),enabled:go().optional()}),bc=Io({provider:pc.optional(),connector_id:ns().optional()}).extend(zs.shape),vc=vs.extend({workspace_id:uo(),provider:hc,name:Ui().min(1).max(255),type:Ui().min(1).max(60),target_config:Oo(Ui(),wo()).default({}),is_default:go().default(!1),enabled:go().default(!0),last_executed_at:is().nullish()}),xc=Io({provider:hc,name:Ui().min(1).max(255),type:Ui().min(1).max(60),target_config:Oo(Ui(),wo()).default({})}),kc=Io({action_id:ns(),name:Ui().min(1).max(255).optional(),target_config:Oo(Ui(),wo()).optional(),enabled:go().optional()}),_c=Io({provider:hc.optional(),type:Ui().optional()}).extend(zs.shape),Sc=Po(["connected","not_connected"]),Ic=Io({key:Ui(),label:Ui(),color:Ui(),status:Sc,session_count:uo().nullable()}),Cc=Io({id:uo(),application_id:uo(),name:Ui(),percentage:uo(),description:Ui(),avg_sessions_per_week:uo(),mobile_percentage:uo(),created_at:is().optional(),updated_at:is().optional()}),Ec=Io({id:uo(),application_id:uo(),segment_id:uo().nullable(),segment_name:Ui().optional(),is_selected:go().default(!1),is_top:go().default(!1),name:Ui(),initials:Ui(),description:Ui(),traits:_o(Ui()),tags:_o(Ui()).optional().default([]),source:Po(["generated","domain","manual"]).optional().default("generated"),age_range:Ui().optional().default(""),goals:Ui().optional().default(""),behavior:Ui().optional().default(""),pain_points:Ui().optional().default(""),triggers:Ui().optional().default(""),openness:uo().nullable().optional(),conscientiousness:uo().nullable().optional(),extraversion:uo().nullable().optional(),agreeableness:uo().nullable().optional(),neuroticism:uo().nullable().optional(),mbti_type:Ui().optional().default(""),mbti_rationale:Ui().optional().default(""),key_features:_o(Ui()).optional().default([]),bhvr_proficiency:uo().nullable().optional(),bhvr_preciseness:uo().nullable().optional(),bhvr_sensitivity:uo().nullable().optional(),bhvr_efficiency:uo().nullable().optional(),created_at:is().optional(),updated_at:is().optional()}),Ac=Io({connectors:_o(Ic),segments:_o(Cc),personas:_o(Ec)}),Tc=Io({name:Ui(),initials:Ui(),description:Ui(),traits:_o(Ui()),tags:_o(Ui()).optional().default([]),is_top:go().default(!1)}),Mc=Io({personas:_o(Tc.extend({is_selected:go()}))}),zc=Io({id:ns(),name:Ui().optional(),description:Ui().optional(),age_range:Ui().optional(),goals:Ui().optional(),behavior:Ui().optional(),pain_points:Ui().optional(),triggers:Ui().optional(),tags:_o(Ui()).optional(),traits:_o(Ui()).optional(),key_features:_o(Ui()).optional()}),Oc=Io({label:Ui(),industry:Ui(),personas:_o(Tc)}).nullable(),Rc=Po(["clicks","scroll","attention"]),Pc=Po(["desktop","tablet","mobile"]),Nc=Io({x:uo(),y:uo(),radius:uo(),intensity:uo()}),Lc=Io({total_interactions:uo(),unique_users:uo(),hottest_zone:Ui(),dead_zones:uo()}),Dc=Io({selector:Ui(),count:uo(),dead_clicks:uo(),rage_clicks:uo()}),jc=Io({id:uo(),application_id:uo(),path:Ui(),session_count:uo(),variation_count:uo(),variations:_o(Pc).default([]),visitor_count:uo().optional(),last_aggregated_at:is().nullable().optional(),representative_session_id:Ui().nullable().optional()}),$c=Io({id:uo(),heatmap_page_id:uo(),variation:Pc,type:Rc,spots:_o(Nc),stats:Lc,page_width:uo().nullable().optional(),page_height:uo().nullable().optional(),element_counts:_o(Dc).optional(),representative_session_override:Ui().nullable().optional()}),Fc=Io({job_id:Ui().nullable(),status:Po(["idle","queued","active","completed","failed"]),last_aggregated_at:is().nullable()}),Bc=Io({session_id:Ui(),width:uo(),height:uo(),event_count:uo(),started_at:is(),has_full_snapshot:go()}),Uc=Io({score:uo().min(1).max(10),justification:Ui()}),Gc=Io({type:Po(["doc","sim","session"]),id:Ui(),label:Ui()}),Wc=Io({simulations:_o(Io({simulation_id:uo(),task_id:Ui().nullable().optional(),step_count:uo(),summary:Ui()})).default([]),moments:_o(Io({sim_index:uo(),step_index:uo(),label:Ui()})).max(6).default([]),context_refs:_o(Gc).default([])}),Zc=Io({name:Ui(),initials:Ui().optional(),segment_name:Ui().optional(),traits:_o(Ui()).optional(),age_range:Ui().optional()}),Vc=Io({id:uo(),run_id:uo(),persona_id:uo().nullable(),persona_name:Ui().optional(),persona_initials:Ui().optional(),ad_hoc_persona:Io({name:Ui(),description:Ui(),traits:_o(Ui())}).nullable().optional(),overall_reactions:Oo(Ui(),Uc),dimension_scores:Oo(Ui(),Uc),simulation_id:uo().nullable().optional(),task_id:Ui().nullable().optional(),status:Po(["pending","completed","failed"]).optional(),replay_evidence:Wc.nullable().optional(),error:Ui().nullable().optional(),persona_snapshot:Zc.nullable().optional(),created_at:is().optional()}),Hc=Io({description:Ui(),selected:go(),simulation_id:uo().nullable().optional(),task_id:Ui().nullable().optional(),status:Ui().nullable().optional()}),Yc=Io({id:uo(),reaction_id:uo(),run_number:uo().optional(),context_refs:_o(Gc),simulations:_o(Hc),persona_ids:_o(uo()).optional(),results:_o(Vc).optional(),status:Po(["running","completed","failed"]).nullable().optional(),processing_started_at:is().nullable().optional(),completed_at:is().nullable().optional(),failed_at:is().nullable().optional(),error:Ui().nullable().optional(),created_at:is().optional()}),qc=Io({id:uo(),application_id:uo(),question:Ui(),run_count:uo().optional(),last_run_at:is().optional(),runs:_o(Yc).optional(),created_at:is().optional()}),Jc=Io({contextRefs:_o(Gc),suggestedSimulations:_o(Hc)}),Kc=Po(["received","classifying","dispatched","completed","failed"]),Xc=Io({id:uo(),workspace_id:uo(),slack_user_id:Ui(),slack_channel_id:Ui().nullable(),raw_text:Ui(),detected_intent:Ui(),extracted_params:Oo(Ui(),wo()),status:Kc,response_text:Ui().nullable(),error_message:Ui().nullable(),duration_ms:uo().nullable(),created_at:is().optional(),updated_at:is().optional()}),Qc=Io({intent:Ui().optional(),limit:ns().optional().default(20),offset:ns().optional().default(0)}),ed=Io({intent:Ui(),name:Ui(),description:Ui(),example:Ui(),execution_count:uo(),last_used:Ui().nullable()}),td=class extends Error{issues;data;constructor(e){super(e.message,e),this.issues=e.issues,this.data=e.data}};function nd(e,t){return{...e,...t}}var rd=class{"~orpc";constructor(e){if(e.route?.successStatus&&Q(e.route.successStatus))throw new Error("[ContractProcedure] Invalid successStatus.");if(Object.values(e.errorMap).some(e=>e&&e.status&&!Q(e.status)))throw new Error("[ContractProcedure] Invalid error status code.");this["~orpc"]=e}};function id(e,t){let n=e;return t.prefix&&(n=function(e,t){return e.path?{...e,path:`${t}${e.path}`}:e}(n,t.prefix)),t.tags?.length&&(n=function(e,t){return{...e,tags:[...t,...e.tags??[]]}}(n,t.tags)),n}function od(e,t){if((n=e)instanceof rd||("object"==typeof n||"function"==typeof n)&&null!==n&&"~orpc"in n&&"object"==typeof n["~orpc"]&&null!==n["~orpc"]&&"errorMap"in n["~orpc"]&&"route"in n["~orpc"]&&"meta"in n["~orpc"])return new rd({...e["~orpc"],errorMap:nd(t.errorMap,e["~orpc"].errorMap),route:id(e["~orpc"].route,t)});var n;if("object"!=typeof e||null===e)return e;const r={};for(const i in e)r[i]=od(e[i],t);return r}var sd=new class e extends rd{constructor(e){super(e),this["~orpc"].prefix=e.prefix,this["~orpc"].tags=e.tags}$meta(t){return new e({...this["~orpc"],meta:t})}$route(t){return new e({...this["~orpc"],route:t})}$input(t){return new e({...this["~orpc"],inputSchema:t})}errors(t){return new e({...this["~orpc"],errorMap:nd(this["~orpc"].errorMap,t)})}meta(t){return new e({...this["~orpc"],meta:(n=this["~orpc"].meta,r=t,{...n,...r})});var n,r}route(t){return new e({...this["~orpc"],route:(n=this["~orpc"].route,r=t,{...n,...r})});var n,r}input(t){return new e({...this["~orpc"],inputSchema:t})}output(t){return new e({...this["~orpc"],outputSchema:t})}prefix(t){return new e({...this["~orpc"],prefix:(n=this["~orpc"].prefix,r=t,n?`${n}${r}`:r)});var n,r}tag(...t){return new e({...this["~orpc"],tags:(n=this["~orpc"].tags,r=t,n?[...n,...r]:r)});var n,r}router(e){return od(e,this["~orpc"])}}({errorMap:{},route:{},meta:{}}),ad=Symbol("ORPC_EVENT_ITERATOR_DETAILS");function ld(e,t){return{"~standard":{[ad]:{yields:e,returns:t},vendor:"orpc",version:1,validate:n=>D(n)?{value:fe(n,{async value(n,r){const i=r?t:e;if(!i)return n;const o=await i["~standard"].validate(n);if(o.issues)throw new X("EVENT_ITERATOR_VALIDATION_FAILED",{message:"Event iterator validation failed",cause:new td({issues:o.issues,message:"Event iterator validation failed",data:n})});return o.value},error:async e=>e})}:{issues:[{message:"Expect event iterator",path:[]}]}}}}sd.route({method:"GET",tags:["Root"],path:"/",summary:"Get API index information and basic system details",description:"Returns general API information, version, and available endpoints"}).output(Ns),sd.route({method:"GET",tags:["Internal"],path:"/health",summary:"Health check endpoint for monitoring system status",description:"Returns current system health, database connectivity, and service status"}).output(Ps),sd.route({method:"GET",tags:["Root"],path:"/validate-url",summary:"Validate URL accessibility and DNS resolution",description:"Validates a URL for format, DNS resolution, and HTTP accessibility"}).input(Io({url:Ui().url(),skip_network:Ui().optional()})).output(Io({valid:go(),accessible:go(),dnsResolves:go(),error:Ui().optional().describe("Error message if URL validation failed"),warnings:_o(Ui()).optional().describe("Non-fatal issues found during URL validation")})),sd.route({method:"GET",tags:["Root"],path:"/config/public",summary:"Get public client configuration",description:"Returns widget key and widget ID. No auth. Values are stored in backend env only."}).output(ic),sd.route({method:"GET",tags:["Auth"],path:"/auth/me",summary:"Get current authenticated user and workspace information",description:"Returns user profile and workspace data based on session cookie"}).output(Io({user:Ds,workspace:Us.nullable(),workspaces:_o(Io({id:uo(),name:Ui(),slug:Ui(),role:Po(["owner","member"])}))})),sd.route({method:"GET",tags:["Auth"],path:"/email-action/{token}",summary:"Process email approval/rejection action",description:"Handles approve/reject links from admin emails. Token-in-URL authentication (no session required). Returns an HTML page, not JSON."}).input(Io({token:Ui().min(1)})).output(Io({result:Ui().describe("HTML response page")})),sd.route({method:"POST",tags:["Onboarding"],path:"/onboard",summary:"Complete user onboarding in one atomic operation",description:"Creates workspace, updates user status, and invites team members"}).input(Io({name:Ui().min(1).max(45),slug:Ui().min(1).max(45).optional(),domain:Ui().min(1).max(200),team_emails:_o(Ui().email()).optional().default([]),app_url:Ui().optional(),app_username:Ui().optional(),app_password:Ui().optional()})).output(Io({workspace:Us})),sd.route({method:"POST",tags:["Workspace"],path:"/workspaces",summary:"Create a new workspace",description:"Creates new workspace with specified settings and returns workspace entity"}).input(Gs).output(Us),sd.route({method:"GET",tags:["Workspace"],path:"/workspaces",summary:"Search and filter workspaces by various criteria",description:"Returns list of workspaces matching search parameters (name, domain, email, etc.)"}).input(Io({name:Ui().optional(),domain:Ui().optional(),email:Ui().email().optional(),application_id:ns().optional(),workspace_id:ns().optional(),user_id:ns().optional()}).extend(zs.shape)).output(Os(Us)),sd.route({method:"GET",tags:["Workspace"],path:"/workspaces/lookup/{slug}",summary:"Look up workspace by slug for onboarding",description:"Returns workspace name and slug for join-workspace flow. Requires onboarding-level auth."}).input(_s).output(Io({name:Ui(),slug:Ui()}).nullable()),sd.route({method:"GET",tags:["Workspace"],path:"/workspaces/{slug}",summary:"Get specific workspace details by slug",description:"Returns complete workspace information including settings and configuration"}).input(_s).output(Us),sd.route({method:"POST",tags:["Workspace"],path:"/workspaces/{slug}/select",summary:"Select the active workspace for the current session",description:"Updates the server-side session workspace context to match the selected workspace slug."}).input(_s).output(Us),sd.route({method:"PUT",tags:["Workspace"],path:"/workspaces/{slug}",summary:"Update workspace settings and configuration",description:"Modifies workspace properties like name, domain, or feature settings"}).input(Zs.extend({slug:Ui()})).output(Us),sd.route({method:"DELETE",tags:["Workspace"],path:"/workspaces/{slug}",summary:"Delete workspace and all associated data",description:"Permanently deletes a workspace and cleans up all related resources. This action cannot be undone."}).input(_s).output(Ts),sd.route({method:"GET",tags:["Workspace"],path:"/workspaces/{slug}/members",summary:"List workspace members",description:"Returns all members of the workspace with their user profile details and roles."}).input(_s).output(Rs(qs.extend({user:Ds.pick({id:!0,email:!0,first_name:!0,last_name:!0,image_url:!0})}))),sd.route({method:"POST",tags:["Workspace"],path:"/workspaces/{slug}/members",summary:"Add member to workspace",description:"Invites a user by email to join the workspace with the specified role. Defaults to member role."}).input(_s.extend({email:Ui().email(),role:Ys.default("member")})).output(qs),sd.route({method:"DELETE",tags:["Workspace"],path:"/workspaces/{slug}/members/{user_id}",summary:"Remove member from workspace",description:"Removes a user from the workspace by user_id. The user loses access immediately."}).input(_s.extend({user_id:uo()})).output(Ts),sd.route({method:"PATCH",tags:["Workspace"],path:"/workspaces/{slug}/members/{user_id}",summary:"Update member role",description:"Changes the role of a workspace member. Valid roles: owner, member."}).input(_s.extend({user_id:uo(),role:Ys})).output(qs),sd.route({method:"GET",tags:["Workspace"],path:"/users/me/workspaces",summary:"List workspaces for current user",description:"Returns all workspaces the authenticated user belongs to, including their role in each."}).output(Rs(Us.extend({role:Ys}))),sd.route({method:"POST",path:"/admin/reconcile",tags:["Internal"],summary:"Reconcile Stripe customers and WorkOS users",description:"Backfills missing Stripe customer IDs for workspaces and real WorkOS user IDs for users. Idempotent and safe to run repeatedly. Requires super user role."}).output(Io({workspaces_stripe_created:uo(),users_workos_created:uo(),workspace_plans_synced:uo(),trials_provisioned:uo(),stripe_plans_refreshed:uo(),workos_profiles_synced:uo(),errors:_o(Io({type:Ui(),id:uo(),error:Ui()}))})),sd.route({method:"POST",path:"/admin/maintenance",tags:["Internal"],summary:"Run periodic maintenance cleanup tasks",description:"Cleans up orphaned CosmosDB containers, QA simulations not linked to existing runs, and orphaned blob storage files. Idempotent and safe to run repeatedly. Requires super user role."}).output(Io({cosmos_containers_deleted:uo(),orphaned_qa_simulations_deleted:uo(),orphaned_blob_dirs_deleted:uo(),errors:_o(Io({type:Ui(),detail:Ui()}))})),sd.route({method:"POST",path:"/admin/rebuild",tags:["Internal"],summary:"Rebuild all agent indexes after cleanup",description:"Removes stale knowledge (missing files), stale simulations (0 steps or missing blobs), then deletes and recreates vector stores and knowledge graphs for every agent. Index creation is async. Requires super user role."}).output(Io({knowledge_removed:uo(),simulations_removed:uo(),agents_rebuilt:uo(),errors:_o(Io({type:Ui(),detail:Ui()}))})),sd.route({method:"POST",tags:["Application"],path:"/applications",summary:"Create a new application",description:"Creates a new application for the authenticated workspace and returns the created entity."}).input(Ua).output(Ba),sd.route({method:"GET",tags:["Application"],path:"/applications",summary:"Search applications for workspace",description:"Returns applications for the authenticated workspace, optionally filtered by type, always includes widgets"}).input(Io({type:fs.optional(),include:_o(Po(["widgets"])).optional()}).extend(zs.shape)).output(Os(Ba.extend({widgets:_o(Va).optional()}))),sd.route({method:"GET",tags:["Application"],path:"/applications/{application_id}",summary:"Get application by ID",description:"Returns specific application details by ID, always includes widgets"}).input(Es).output(Ba.extend({widgets:_o(Va)})),sd.route({method:"PUT",tags:["Application"],path:"/applications/{application_id}",summary:"Update application",description:"Updates application details and configuration"}).input(Ga.extend({application_id:ns()})).output(Ba),sd.route({method:"DELETE",tags:["Application"],path:"/applications/{application_id}",summary:"Delete application",description:"Permanently deletes an application and all associated widgets. This action cannot be undone."}).input(Es).output(Ts),sd.route({method:"POST",tags:["Widget"],path:"/widgets",summary:"Create a new widget",description:"Creates a new widget for an application and returns the created entity. Requires an application_id."}).input(Ya).output(Va),sd.route({method:"GET",tags:["Widget"],path:"/widgets",summary:"Search widgets for workspace",description:"Search widgets by type, application, marketrix_id, or marketrix_key"}).input(Io({type:ys.optional(),application_id:ns().optional(),marketrix_id:Ui().optional(),marketrix_key:Ui().optional(),include:_o(Po(["agent"])).optional()}).extend(zs.shape)).output(Os(Ha)),sd.route({method:"GET",tags:["Widget"],path:"/widgets/defaults/{type}",summary:"Get default settings for widget type",description:"Returns default settings for the specified widget type"}).input(Io({type:ys})).output(Za),sd.route({method:"GET",tags:["Widget"],path:"/widgets/{widget_id}",summary:"Get widget by ID",description:"Returns specific widget details by widget ID including snippet code"}).input(Is).output(Va),sd.route({method:"PUT",tags:["Widget"],path:"/widgets/{widget_id}",summary:"Update widget",description:"Updates widget settings and configuration"}).input(qa.extend({widget_id:ns()})).output(Va),sd.route({method:"DELETE",tags:["Widget"],path:"/widgets/{widget_id}",summary:"Delete widget",description:"Permanently deletes a widget from an application. This action cannot be undone."}).input(Is).output(Ts),sd.route({method:"POST",tags:["Chat"],path:"/chat",summary:"Create a new chat thread",description:"Initializes new chat thread and returns session ID"}).output(Ui()),sd.route({method:"GET",tags:["Chat"],path:"/chat",summary:"Search chats by user",description:"Returns chat list and quota for the specified user"}).input(Io({user_id:ns().optional(),chat_id:ns().optional()})).output(Fl),sd.route({method:"POST",tags:["Chat"],path:"/preview-video-chat",summary:"Create or update preview video chat record",description:"Persists guide preview chat content, history, output, and related simulation metadata"}).input(cc).output(lc),sd.route({method:"GET",tags:["Chat"],path:"/preview-video-chat",summary:"Search preview video chat records",description:"Returns preview chat records filtered by chat_id, agent_id, or simulation_id for current workspace"}).input(dc).output(Rs(lc)),sd.route({method:"GET",tags:["Chat"],path:"/preview-video-chat/{id}",summary:"Get preview video chat record by ID",description:"Returns a single preview chat record for current workspace"}).input(ks).output(lc.nullable()),sd.route({method:"POST",tags:["Connector"],path:"/connector",summary:"Create or update connector",description:"Stores provider credentials and API endpoint details for workspace connectors"}).input(bl).output(wl),sd.route({method:"GET",tags:["Connector"],path:"/connector",summary:"Search connectors",description:"Returns workspace connectors filtered by provider/status"}).input(vl).output(Os(wl)),sd.route({method:"GET",tags:["Connector"],path:"/connector/{id}",summary:"Get connector by ID",description:"Returns a single workspace connector"}).input(ks).output(wl.nullable()),sd.route({method:"DELETE",tags:["Connector"],path:"/connector/{id}",summary:"Delete connector",description:"Permanently deletes a connector for current workspace. This action cannot be undone."}).input(ks).output(Ts),sd.route({method:"GET",tags:["Connector"],path:"/connector/{id}/github/repos",summary:"List GitHub repositories for a GitHub connector",description:"Uses the stored GitHub PAT from the connector to call GitHub /user/repos."}).input(Io({id:ns(),per_page:ns().int().min(1).max(100).optional(),page:ns().int().min(1).optional()})).output(_o(_l)),sd.route({method:"GET",tags:["Connector"],path:"/connector/{id}/github/repos/{owner}/{repo}/actions/runs",summary:"List GitHub Actions workflow runs",description:"Lists workflow runs for a repository (pass/fail status)."}).input(Io({id:ns(),owner:Ui().min(1),repo:Ui().min(1),per_page:ns().int().min(1).max(100).optional(),page:ns().int().min(1).optional()})).output(_o(Sl)),sd.route({method:"POST",tags:["MCP"],path:"/mcp/activate",summary:"Activate MCP for an application",description:"Creates or reactivates an MCP connector with auto-generated credentials."}).input(Io({application_id:ns()})).output(xl),sd.route({method:"POST",tags:["MCP"],path:"/mcp/deactivate",summary:"Deactivate MCP for an application",description:"Deactivates the MCP connector. Credentials are preserved but access is revoked."}).input(Io({application_id:ns()})).output(xl),sd.route({method:"POST",tags:["MCP"],path:"/mcp/regenerate",summary:"Regenerate MCP API key",description:"Generates a new API key for the MCP connector. Existing integrations will break."}).input(Io({application_id:ns()})).output(xl),sd.route({method:"GET",tags:["MCP"],path:"/mcp/status/{application_id}",summary:"Get MCP activation status",description:"Returns the MCP connector status for an application, or null if not activated."}).input(Io({application_id:ns()})).output(xl.nullable()),sd.route({method:"GET",tags:["MCP"],path:"/mcp/tools/{application_id}",summary:"List MCP platform tools",description:"Returns all platform tools with their enabled/disabled state."}).input(Io({application_id:ns()})).output(_o(kl)),sd.route({method:"PATCH",tags:["MCP"],path:"/mcp/tools/toggle",summary:"Toggle a platform tool",description:"Enable or disable a specific platform tool for the MCP server."}).input(Io({application_id:ns(),tool_name:Ui(),enabled:go()})).output(_o(kl)),sd.route({method:"POST",tags:["Automation"],path:"/automation",summary:"Create automation",description:"Creates a DAG-based automation workflow"}).input(zl).output(Ml),sd.route({method:"GET",tags:["Automation"],path:"/automation",summary:"List automations",description:"Returns automations for the current workspace"}).input(Rl).output(Os(Ml)),sd.route({method:"GET",tags:["Automation"],path:"/automation/{id}",summary:"Get automation",description:"Returns a single automation with its graph"}).input(ks).output(Ml.nullable()),sd.route({method:"PUT",tags:["Automation"],path:"/automation/{id}",summary:"Update automation",description:"Updates automation graph and settings"}).input(Ol).output(Ml),sd.route({method:"DELETE",tags:["Automation"],path:"/automation/{id}",summary:"Delete automation",description:"Permanently deletes an automation and deregisters its triggers"}).input(ks).output(Ts),sd.route({method:"PATCH",tags:["Automation"],path:"/automation/{id}/toggle",summary:"Toggle automation",description:"Enable or disable an automation"}).input(Io({id:ns(),enabled:go()})).output(Ml),sd.route({method:"POST",tags:["Automation"],path:"/automation/{id}/run",summary:"Trigger automation run",description:"Manually triggers an automation run"}).input(ks).output(Nl.nullable()),sd.route({method:"GET",tags:["Automation"],path:"/automation/{id}/runs",summary:"List automation runs",description:"Returns execution history for an automation"}).input(Io({id:ns()}).extend(Ll.shape)).output(Os(Nl)),sd.route({method:"GET",tags:["Automation"],path:"/automation/{id}/runs/{run_id}",summary:"Get automation run",description:"Returns a single run with per-node results"}).input(Io({id:ns(),run_id:ns()})).output(Nl.nullable()),sd.route({method:"GET",tags:["Provider"],path:"/provider/{provider}",summary:"Get provider record for a workspace"}).input(Io({provider:uc})).output(gc.nullable()),sd.route({method:"DELETE",tags:["Provider"],path:"/provider/{provider}",summary:"Disconnect a provider"}).input(Io({provider:uc})).output(Ts),sd.route({method:"POST",tags:["Provider"],path:"/provider/{provider}/refresh",summary:"Re-fetch provider data using stored credentials"}).input(Io({provider:uc})).output(gc),sd.route({method:"POST",tags:["Trigger"],path:"/trigger",summary:"Create a new trigger"}).input(yc).output(fc),sd.route({method:"GET",tags:["Trigger"],path:"/trigger/{trigger_id}",summary:"Get a single trigger"}).input(Io({trigger_id:ns()})).output(fc),sd.route({method:"GET",tags:["Trigger"],path:"/trigger",summary:"List triggers"}).input(bc).output(Os(fc)),sd.route({method:"PUT",tags:["Trigger"],path:"/trigger/{trigger_id}",summary:"Update trigger"}).input(wc).output(fc),sd.route({method:"DELETE",tags:["Trigger"],path:"/trigger/{trigger_id}",summary:"Delete a trigger"}).input(Io({trigger_id:ns()})).output(Ts),sd.route({method:"PATCH",tags:["Trigger"],path:"/trigger/{trigger_id}/toggle",summary:"Toggle trigger enabled state"}).input(Io({trigger_id:ns()})).output(fc),sd.route({method:"POST",tags:["Trigger"],path:"/trigger/{trigger_id}/install",summary:"Auto-install trigger configuration on the provider"}).input(Io({trigger_id:ns()})).output(Io({success:go(),message:Ui()})),sd.route({method:"GET",tags:["Slack"],path:"/slack/command-log",summary:"Search slash command logs"}).input(Qc).output(Os(Xc)),sd.route({method:"GET",tags:["Slack"],path:"/slack/capabilities",summary:"Get Slack capability stats"}).output(_o(ed)),sd.route({method:"POST",tags:["Action"],path:"/action",summary:"Create a custom action"}).input(xc).output(vc),sd.route({method:"GET",tags:["Action"],path:"/action/{action_id}",summary:"Get a single action"}).input(Io({action_id:ns()})).output(vc),sd.route({method:"GET",tags:["Action"],path:"/action",summary:"List actions"}).input(_c).output(Os(vc)),sd.route({method:"PUT",tags:["Action"],path:"/action/{action_id}",summary:"Update action"}).input(kc).output(vc),sd.route({method:"DELETE",tags:["Action"],path:"/action/{action_id}",summary:"Delete an action"}).input(Io({action_id:ns()})).output(Ts),sd.route({method:"PATCH",tags:["Action"],path:"/action/{action_id}/toggle",summary:"Toggle action enabled state"}).input(Io({action_id:ns()})).output(vc),sd.route({method:"GET",tags:["Connector"],path:"/connector-capabilities",summary:"List connector capabilities",description:"Returns available triggers and callbacks per connector type"}).input(Io({})).output(_o(Dl)),sd.route({method:"GET",tags:["User"],path:"/user",summary:"Search and filter users by workspace",description:"Returns list of users associated with specified workspace"}).input(Io({workspace_id:ns().optional(),status:ss.optional()}).extend(zs.shape)).output(Os(Ds)),sd.route({method:"POST",tags:["User"],path:"/user/batch",summary:"Create multiple users in batch operation",description:"Processes bulk user creation and returns results for each user"}).input(Fs).output(_o(Bs)),sd.route({method:"GET",tags:["User"],path:"/user/{user_id}",summary:"Get specific user details by ID",description:"Returns complete user information including profile and settings"}).input(As).output(Ds),sd.route({method:"PUT",tags:["User"],path:"/user/{user_id}",summary:"Update user profile and settings",description:"Modifies user properties like name, email, or preferences"}).input($s.extend({user_id:ns()})).output(Ds),sd.route({method:"PUT",tags:["User"],path:"/user/{user_id}/image",summary:"Upload and update user profile image",description:"Handles file upload for user avatar and returns upload response"}).input(xs.extend({user_id:ns()})).output($l),sd.route({method:"DELETE",tags:["User"],path:"/user/{user_id}",summary:"Delete user account and all associated data",description:"Permanently deletes a user account and cleans up all related resources. This action cannot be undone."}).input(As).output(Ts),sd.route({method:"POST",tags:["User"],path:"/user/{user_id}/deactivate",summary:"Deactivate user account without deletion",description:"Deactivates user access while preserving data for potential reactivation"}).input(As.extend({reason:Ui().optional()})).output(Ts),sd.route({method:"POST",tags:["Agent"],path:"/agent",summary:"Create new AI agent with configuration",description:"Creates agent with specified settings, prompts, and returns agent entity"}).input(Na).output(za),sd.route({method:"GET",tags:["Agent"],path:"/agent",summary:"Search and filter agents by workspace or user",description:"Returns list of agents matching search parameters. Supports filtering by workspace_id, user_id, and application_id."}).input(Io({workspace_id:ns().optional(),user_id:ns().optional(),application_id:ns().optional(),include:_o(Po(["knowledge","simulations"])).optional()}).extend(zs.shape)).output(Os(za)),sd.route({method:"GET",tags:["Agent"],path:"/agent/{agent_id}",summary:"Get specific agent details by ID",description:"Returns complete agent information including configuration and settings"}).input(Ss.extend({include:_o(Po(["knowledge","simulations"])).optional()})).output(za),sd.route({method:"GET",tags:["Agent"],path:"/agent/{agent_id}/mindmap",summary:"Get agent mindmap by ID",description:"Returns the mindmap knowledge graph for the specified agent"}).input(Ss).output(Ma),sd.route({method:"PUT",tags:["Agent"],path:"/agent/{agent_id}",summary:"Update agent configuration and settings",description:"Updates agent details. For JSON requests, handled by oRPC. Also accepts multipart/form-data for logo file uploads (handled by raw Express route)."}).input(La.extend({agent_id:ns(),force_reset_learning:rs().optional()})).output(za),sd.route({method:"DELETE",tags:["Agent"],path:"/agent/{agent_id}",summary:"Delete agent and all associated data",description:"Permanently deletes an agent and cleans up all related resources. This action cannot be undone."}).input(Ss).output(Ts),sd.route({method:"POST",tags:["Agent"],path:"/agent/{agent_id}/index",summary:"Index simulation document into agent knowledge base",description:"Adds a simulation document to an agent's knowledge base and refreshes the search index"}).input(ja.extend({agent_id:ns()})).output($a),sd.route({method:"POST",tags:["Agent"],path:"/agent/{agent_id}/reset-learning",summary:"Force reset agent from stuck learning state",description:"Resets an agent that is stuck in learning state, setting it to error status with a message explaining the reset"}).input(Ss).output(za),sd.route({method:"POST",tags:["Activity Log"],path:"/log",summary:"Create new activity log entry",description:"Records user or system action for auditing and tracking purposes"}).input(gl).output(ml),sd.route({method:"GET",tags:["Activity Log"],path:"/log",summary:"Search and filter activity logs",description:"Returns list of activity logs matching search parameters (workspace, type)"}).input(Io({workspace_id:ns().optional(),type:bs.optional(),application_id:ns().optional()}).extend(zs.shape)).output(Os(ml)),sd.route({method:"GET",tags:["State Trigger"],path:"/state-trigger",summary:"Search state triggers by widget",description:"Returns list of state triggers for specified widget"}).input(Is.extend(zs.shape)).output(Os(Ja)),sd.route({method:"POST",tags:["State Trigger"],path:"/state-trigger",summary:"Create new state trigger",description:"Creates state trigger with pattern and message"}).input(Ka).output(Ja),sd.route({method:"GET",tags:["State Trigger"],path:"/state-trigger/{id}",summary:"Get state trigger by ID",description:"Returns state trigger details"}).input(ks).output(Ja),sd.route({method:"PUT",tags:["State Trigger"],path:"/state-trigger/{id}",summary:"Update state trigger",description:"Updates state trigger properties"}).input(Xa.extend({id:ns()})).output(Ja),sd.route({method:"DELETE",tags:["State Trigger"],path:"/state-trigger/{id}",summary:"Delete state trigger",description:"Permanently deletes a state trigger. This action cannot be undone."}).input(ks).output(Ts),sd.route({method:"GET",tags:["State Trigger"],path:"/state-trigger/match",summary:"Find matching state trigger for current URL",description:"Returns matching state trigger for a given URL pattern"}).input(Io({widget_id:ns(),url:Ui()})).output(Ja.nullable()),sd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}",summary:"Get a single simulation by ID"}).input(Io({simulation_id:ns()})).output(ba),sd.route({method:"GET",tags:["Simulation"],path:"/simulation",summary:"Search and filter simulations by workspace",description:"Returns list of simulations associated with specified workspace. Use application_id, agent_id, or pinned to filter."}).input(Io({workspace_id:ns().optional(),application_id:ns().optional(),agent_id:ns().optional(),pinned:Eo([go(),Ui()]).optional().transform(e=>void 0===e?void 0:"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0),source:Po(["direct","qa"]).optional(),include:_o(Po(["agent","application"])).optional()}).extend(zs.shape)).output(Os(va)),sd.route({method:"POST",tags:["Simulation"],path:"/simulation/start",summary:"Start new application simulation",description:"Creates and initializes simulation with specified parameters"}).input(xa).output(ba),sd.route({method:"PUT",tags:["Simulation"],path:"/simulation/{simulation_id}",summary:"Update simulation configuration and status",description:"Modifies simulation parameters and updates execution state"}).input(ka.extend({simulation_id:ns()})).output(ba),sd.route({method:"PUT",tags:["Simulation"],path:"/simulation/{simulation_id}/agents",summary:"Assign agents to a simulation",description:"Sets which agents use this simulation for their knowledge. Triggers learning on affected agents."}).input(Cs.extend({agent_ids:_o(uo())})).output(ba),sd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/progress",summary:"Get simulation progress history as chat transcript",description:"Returns all progress updates for a simulation ordered chronologically"}).input(Cs.extend({task_id:Ui().optional()})).output(Rs(Ca)),sd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/task/{task_id}/live-view",summary:"Get per-task live view URL",description:"Returns Browserbase per-tab live view URL for a specific task within a simulation."}).input(Io({simulation_id:ns().int().positive(),task_id:Ui()})).output(Io({live_view_url:Ui(),status:Ui()})),sd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/history",summary:"Get simulation history by ID",description:"Returns the history array for the specified simulation"}).input(Cs.extend({task_id:Ui()})).output(Rs(ga)),sd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/steps",summary:"Get all simulation steps with topic and screenshot link as JSON",description:"Returns each step with step_number, topic, screenshot_url, and optional title/url for the simulation"}).input(Cs).output(Rs(fa)),sd.route({method:"GET",tags:["Simulation"],path:"/simulation/{simulation_id}/mindmap",summary:"Get simulation mindmap by ID",description:"Returns the mindmap knowledge graph for the specified simulation"}).input(Cs).output(Ma),sd.route({method:"POST",tags:["Simulation"],path:"/simulation/{simulation_id}/stop",summary:"Stop running simulation",description:"Terminates a running simulation and closes its browser session."}).input(Cs).output(Ms),sd.route({method:"POST",tags:["Simulation"],path:"/simulation/{simulation_id}/answer",summary:"Submit answer to simulation question",description:"Submits an answer to a pending question from the simulation agent"}).input(_a.extend({simulation_id:ns()})).output(Ms),sd.route({method:"POST",tags:["Simulation"],path:"/simulation/{simulation_id}/retry-mindmap",summary:"Retry mindmap generation",description:"Restarts mindmap generation from stored history for a simulation."}).input(Io({simulation_id:ns()})).output(Ms),sd.route({method:"DELETE",tags:["Simulation"],path:"/simulation/{simulation_id}",summary:"Delete simulation",description:"Permanently deletes a simulation and all associated data. Only works on simulations in terminal state."}).input(Cs).output(Ms),sd.route({method:"GET",tags:["Notification"],path:"/notification/pending",summary:"List pending notifications for the current user"}).output(Rs(al)),sd.route({method:"POST",tags:["Notification"],path:"/notification/{id}/read",summary:"Mark a notification as read"}).input(Io({id:ns()})).output(Ts),sd.route({method:"POST",tags:["Notification"],path:"/notification/{id}/dismiss",summary:"Dismiss a pending notification"}).input(Io({id:ns()})).output(Ts),sd.route({method:"GET",tags:["Notification"],path:"/notification/preferences",summary:"Get notification preferences for the current (user, workspace)"}).output(ll),sd.route({method:"PUT",tags:["Notification"],path:"/notification/preferences",summary:"Update notification preferences for the current (user, workspace)"}).input(ll).output(ll),sd.route({method:"GET",tags:["Notification"],path:"/notification/vapid-public-key",summary:"Public VAPID key for browser pushManager.subscribe"}).output(pl),sd.route({method:"POST",tags:["Notification"],path:"/notification/push-subscription",summary:"Register a Web Push subscription for the current user"}).input(cl).output(Ts),sd.route({method:"DELETE",tags:["Notification"],path:"/notification/push-subscription",summary:"Unregister a Web Push subscription for the current user"}).input(dl).output(Ts),sd.route({method:"POST",tags:["Notification"],path:"/notification/slack-test",summary:"Send a test message to a Slack incoming-webhook URL"}).input(ul).output(Ms),sd.route({method:"POST",tags:["Session"],path:"/sessions",summary:"Create or update session",description:"Creates a new session or updates an existing one"}).input(Ia).output(Sa),sd.route({method:"GET",tags:["Session"],path:"/sessions/{session_id}",summary:"Get session by session ID",description:"Retrieves a session by its session_id"}).input(Io({session_id:Ui().min(1)})).output(Sa.nullable()),sd.route({method:"GET",tags:["Session"],path:"/sessions/chat/{chat_id}",summary:"Get sessions by chat ID",description:"Retrieves all sessions for a given chat_id"}).input(Io({chat_id:Ui().min(1)})).output(Rs(Sa)),sd.route({method:"GET",tags:["Session"],path:"/sessions",summary:"Get all sessions",description:"Retrieves all sessions ordered by creation date, optionally filtered by application and date range"}).input(Io({application_id:ns().optional(),start_date:Ui().optional(),end_date:Ui().optional()}).extend(zs.shape)).output(Os(Sa)),sd.route({method:"GET",tags:["Session"],path:"/sessions/stats",summary:"Get session activity stats",description:"Returns daily aggregated session metrics for charting. Each entry is one calendar day with session count and total event count."}).input(Io({application_id:ns(),start_date:Ui().describe("YYYY-MM-DD"),end_date:Ui().describe("YYYY-MM-DD")})).output(sc),sd.route({method:"GET",tags:["Session"],path:"/sessions/{session_id}/events",summary:"Get session events (paginated by batch)",description:"Fetches batches from storage in pages. Use batch_offset/batch_limit to paginate."}).input(Io({session_id:Ui().min(1),batch_offset:ns().int().nonnegative().default(0),batch_limit:ns().int().positive().max(50).default(20)})).output(Io({items:_o(Io({type:uo(),timestamp:uo(),data:wo().describe("rrweb event payload — shape defined by rrweb library")})),count:uo(),total_batches:uo(),batch_offset:uo(),batch_limit:uo()})),sd.route({method:"POST",tags:["Browser Session"],path:"/browser-session/create",summary:"Create browser session for application",description:"Creates a browser session and navigates to the application URL"}).input(Io({application_id:uo(),agent_id:uo(),url:Ui().nullish()})).output(Io({browser_session_id:Ui(),live_view_url:Ui()})),sd.route({method:"POST",tags:["Browser Session"],path:"/browser-session/{browser_session_id}/stop",summary:"Stop browser session",description:"Stops all running tasks and closes the browser session. Set stop_tasks=false to skip task cleanup."}).input(Io({browser_session_id:Ui(),stop_tasks:go().optional().default(!0)})).output(Ms),sd.route({method:"GET",tags:["Knowledge"],path:"/knowledge",summary:"Search and filter knowledge base documents",description:"Returns list of knowledge documents matching search parameters. Supports filtering by workspace_id, type, and application_id."}).input(Io({workspace_id:ns().optional(),type:ps.optional(),application_id:ns().optional(),include:_o(Po(["agents","application"])).optional()}).extend(zs.shape)).output(Os(Ks)),sd.route({method:"POST",tags:["Knowledge"],path:"/knowledge",summary:"Upload new knowledge base document",description:"Upload a file, document URL, or video URL to create a knowledge entry for AI training"}).input(Io({file:function(e){return function(e,t){return new e({type:"file",...ct(t)})}(Do,e)}().optional(),application_id:ns(),document_url:Ui().url().optional(),document_name:Ui().optional(),video_url:Ui().url().optional(),video_name:Ui().optional()})).output(Ks),sd.route({method:"GET",tags:["Knowledge"],path:"/knowledge/{id}",summary:"Get specific knowledge document by ID",description:"Returns complete knowledge document information and content"}).input(ks).output(Ks),sd.route({method:"DELETE",tags:["Knowledge"],path:"/knowledge/{id}",summary:"Delete knowledge document",description:"Permanently deletes a knowledge document from the database. This action cannot be undone."}).input(ks).output(Ts),sd.route({method:"POST",tags:["Knowledge"],path:"/knowledge/{id}/refresh",summary:"Refresh knowledge document",description:"Re-fetches HTML content from source URL and updates the document"}).input(ks).output(Ks),sd.route({method:"PUT",tags:["Knowledge"],path:"/knowledge/{knowledge_id}/agents",summary:"Assign agents to a knowledge item",description:"Sets which agents use this knowledge item. Triggers learning on affected agents."}).input(Io({knowledge_id:ns(),agent_ids:_o(uo())})).output(Ks),sd.route({method:"POST",tags:["QA"],path:"/qa/document",summary:"Upload QA flow (file or text)",description:"Uploads a PDF/text file or text content for QA test generation. Also accepts multipart/form-data for file uploads (handled by raw Express route)."}).input(ta).output(ea),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/process",summary:"Process QA flow and generate test cases",description:"Starts async processing (returns 202). Poll GET /qa/document/:id for status and processing_step until completed/failed."}).input(ks).output(Io({document:ea})),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/refine",summary:"Refine existing QA test cases",description:"Refines existing test cases with a refinement prompt via AI agent API"}).input(ks.extend({refinementPrompt:Ui().min(5).max(2e3)})).output(ca),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/process/stream",summary:"Process QA flow with SSE streaming",description:"Streams processing events as Server-Sent Events. Events: response.created, response.progress, response.clear, response.completed, error."}).input(ks).output(ld(Io({event:Ui().describe("SSE event type: response.created | response.progress | response.clear | response.completed | error"),data:wo().describe("Event payload object — shape varies by event type")}))),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/refine/stream",summary:"Refine QA flow test cases with SSE streaming",description:"Streams refinement events as Server-Sent Events. Requires a refinement prompt (min 5 chars)."}).input(ks.extend({refinementPrompt:Ui().min(5)})).output(ld(Io({event:Ui().describe("SSE event type: response.created | response.progress | response.clear | response.completed | error"),data:wo().describe("Event payload object — shape varies by event type")}))),sd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}",summary:"Get QA flow by ID",description:"Retrieves a QA flow by its ID"}).input(ks).output(ea),sd.route({method:"GET",tags:["QA"],path:"/qa/document",summary:"List QA flows",description:"Returns all QA flows with aggregated metrics (run_count, pass_rate, total_failed) and the last run summary. Supports filtering by application_id."}).input(Io({application_id:ns().optional()}).extend(zs.shape)).output(Os(ea.extend({run_count:uo(),display_title:Ui(),total_failed:uo(),pass_rate:uo().nullable(),last_run:Io({id:uo(),status:Ui(),total_tests:uo(),passed_tests:uo(),failed_tests:uo(),created_at:is().nullable()}).nullable()})).extend({metrics:Io({total_flows:uo(),total_runs:uo(),avg_pass_rate:uo().nullable(),total_failed:uo(),total_passed:uo()})})),sd.route({method:"DELETE",tags:["QA"],path:"/qa/document/{id}",summary:"Delete QA flow",description:"Permanently deletes a QA flow and all its runs and test cases. This action cannot be undone."}).input(ks).output(Ts),sd.route({method:"PUT",tags:["QA"],path:"/qa/document/{id}",summary:"Update QA flow",description:"Updates status and/or pinned state of a QA flow"}).input(ks.extend({status:ms.optional(),pinned:go().optional()})).output(ea),sd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}/runs",summary:"List runs for a QA flow",description:"Returns all runs for a document with total/passed/failed counts"}).input(ks.extend(zs.shape)).output(Os(na.extend({status:Ui(),total_tests:uo(),passed:uo(),failed:uo()}))),sd.route({method:"GET",tags:["QA"],path:"/qa/run/{id}",summary:"Get a QA run by ID",description:"Returns run details with test cases"}).input(ks).output(na.extend({test_cases:_o(la)})),sd.route({method:"GET",tags:["QA"],path:"/qa/run/{run_id}/verdicts",summary:"Get evaluator verdicts for a QA run",description:"Returns all qa_run_task rows for a run, keyed by test case"}).input(Io({run_id:ns()})).output(_o(aa)),sd.route({method:"DELETE",tags:["QA"],path:"/qa/run/{id}",summary:"Delete a QA run",description:"Permanently deletes a QA run and all its test case results. This action cannot be undone."}).input(ks).output(Ts),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/run",summary:"Create and start a new QA run",description:"Creates a new run and starts execution. Returns 202; poll test-cases for execution status."}).input(ks.extend({auto_heal:go().default(!1),auto_accept:go().default(!1)})).output(Io({run:na})),sd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}/test-cases",summary:"Get test cases for a QA flow",description:"Retrieves test cases; optional run_id scopes to that run"}).input(ks.extend({run_id:ns().optional()})).output(Rs(la)),sd.route({method:"PUT",tags:["QA"],path:"/qa/test-case/{id}",summary:"Update test case definition fields",description:"Updates a test case definition (title, objective, steps, etc.)"}).input(ks.extend({test_title:Ui().optional(),test_objective:Ui().optional(),test_steps:_o(Ui()).optional(),expected_outcome:Ui().optional(),priority:Po(["Low","Medium","High"]).optional(),is_active:go().optional()})).output(la),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/execute",summary:"Create a run and execute all pending tests for a QA flow as simulations",description:"Creates a new QA run, then starts a simulation for every active test case. Returns the run and simulation entities."}).input(ks).output(Io({run:na,simulations:_o(ba)})),sd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/execute",summary:"Execute a single test case as a simulation",description:"Starts a simulation for the specified test case and returns the simulation entity."}).input(ks).output(Io({simulation:ba})),sd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/simulation",summary:"Get the simulation linked to a test case",description:"Returns the simulation entity associated with the test case for a specific run, or null if no simulation exists."}).input(ks.extend({run_id:ns().int().positive().optional()})).output(Io({simulation:ba.nullable()})),sd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/versions",summary:"Get version history for a test case",description:"Returns all version entries from the test case version_history JSON"}).input(ks).output(Rs(ra)),sd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}",summary:"Get specific test case version",description:"Returns a specific version entry from the test case version_history JSON"}).input(ks.extend({version:ns()})).output(ra),sd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}/rollback",summary:"Rollback to specific version",description:"Restores test case to a previous version and appends new version entry"}).input(ks.extend({version:ns()})).output(ra),sd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/versions/compare",summary:"Compare two versions",description:"Returns differences between two test case versions"}).input(ks.extend({version1:ns(),version2:ns()})).output(Io({version1:ra,version2:ra,diff:_o(Io({field:Ui(),oldValue:ua,newValue:ua}))})),sd.route({method:"DELETE",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}",summary:"Delete a specific version",description:"Removes a version from history and reverts test case to previous version if it was the latest"}).input(ks.extend({version:ns()})).output(Ts.extend({current_version:uo()})),sd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/versions/{version}/accept",summary:"Accept a specific version",description:"Marks a version as accepted by the user"}).input(ks.extend({version:ns()})).output(Ts),sd.route({method:"GET",tags:["QA"],path:"/qa/test-case/{id}/healing-attempts",summary:"Get healing attempts for a test case",description:"Returns all healing attempt entries from the test case healing_attempts JSON"}).input(ks).output(Rs(ia)),sd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/healing-attempts/{attemptIndex}/approve",summary:"Approve a healing attempt",description:"Applies the repair from a validated healing attempt by array index"}).input(ks.extend({attemptIndex:ns()})).output(Ts),sd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/healing-attempts/{attemptIndex}/reject",summary:"Reject a healing attempt",description:"Marks a healing attempt as rejected by array index"}).input(ks.extend({attemptIndex:ns()})).output(Ts),sd.route({method:"POST",tags:["QA"],path:"/qa/test-case/{id}/heal",summary:"Trigger self-healing for a failed test case",description:"Initiates the self-healing workflow for a test case"}).input(ks.extend({simulation_id:uo(),config:Io({enabled:go().optional(),autoApply:go().optional(),minConfidenceThreshold:uo().min(0).max(1).optional(),maxHealingAttempts:uo().int().min(1).max(5).optional()}).optional()})).output(Io({healed:go(),attemptIndex:uo().nullable(),analysis:ha.nullable(),confidence:uo().nullable()})),sd.route({method:"POST",tags:["QA"],path:"/qa/document/{id}/run-cross-browser",summary:"Execute cross-browser tests",description:"Runs tests across multiple browsers (chromium, firefox, webkit)"}).input(Qs.extend({id:ns()})).output(Io({runs:_o(Io({browserType:Xs,runId:uo(),status:Po(["completed","failed","skipped"]),passedTests:uo(),failedTests:uo(),totalTests:uo()})),summary:Io({totalRuns:uo(),completedRuns:uo(),failedRuns:uo(),overallPassed:uo(),overallFailed:uo()})})),sd.route({method:"GET",tags:["QA"],path:"/qa/document/{id}/cross-browser-comparison",summary:"Get cross-browser comparison",description:"Returns test cases comparison across different browsers"}).input(ks).output(Io({byTest:Oo(Ui(),Oo(Ui(),Io({status:Ui(),runId:uo()}))),byBrowser:Oo(Ui(),Io({passed:uo(),failed:uo(),total:uo()}))})),sd.route({method:"PUT",tags:["QA"],path:"/qa/document/{id}/browser-config",summary:"Update browser configuration",description:"Updates the default browser configuration for a QA flow"}).input(Qs.extend({id:ns()})).output(Ts),sd.route({method:"POST",tags:["Stripe"],path:"/stripe/trial",summary:"Create a trial subscription",description:"Creates a trial subscription for the authenticated workspace. The trial period is 30 days by default."}).input(Gl).output(ql),sd.route({method:"POST",tags:["Stripe"],path:"/stripe/checkout",summary:"Create a checkout session for subscription purchase",description:"Creates a Stripe checkout session for purchasing a subscription. Returns a session URL for redirect."}).input(Bl).output(Hl),sd.route({method:"POST",tags:["Stripe"],path:"/stripe/portal",summary:"Create a customer portal session",description:"Creates a Stripe billing portal session for managing subscription, payment methods, and invoices."}).input(Ul).output(Yl),sd.route({method:"POST",tags:["Stripe"],path:"/stripe/downgrade",summary:"Confirm and process a subscription downgrade",description:"Processes a confirmed subscription downgrade to a lower tier plan. No payment required."}).input(Wl).output(Zl),sd.route({method:"POST",tags:["Stripe"],path:"/stripe/cancel",summary:"Cancel subscription at period end",description:"Cancels the subscription at the end of the current billing period."}).input(Io({subscriptionId:Ui().min(1)})).output(Io({subscriptionId:Ui(),cancelAtPeriodEnd:go()})),sd.route({method:"GET",tags:["Stripe"],path:"/stripe/catalog",summary:"Get public Stripe catalog (pricing, plans, config)",description:"Returns pricing from Stripe, plan catalog metadata, and Stripe frontend configuration in a single call."}).output(Io({pricing:ec,plans:nc,config:rc})),sd.route({method:"GET",tags:["Stripe"],path:"/stripe/subscription",summary:"Get current subscription plan and usage",description:"Returns current subscription plan information and actual usage statistics for the authenticated workspace."}).output(Io({plan:Vl,usage:Kl})),sd.route({method:"POST",tags:["Stripe"],path:"/stripe/sync",summary:"Reconcile workspace plan with Stripe",description:"Force-syncs the workspace_plan row with live Stripe subscription state. Called by the app after checkout success to recover from delayed or missed webhooks."}).output(Io({plan:Vl})),sd.route({method:"GET",tags:["Widget"],path:"/widget/stream",summary:"SSE stream for real-time widget events",description:"Typed event stream delivering tool calls, task status updates, chat responses, and registration confirmation."}).input(Io({chat_id:Ui(),tab_id:Ui().optional(),marketrix_id:Ui().optional(),marketrix_key:Ui().optional(),agent_id:ns().optional(),application_id:ns().optional()})).output(ld(Qa)),sd.route({method:"POST",tags:["Widget"],path:"/widget/message",summary:"Send a typed command from widget to server",description:"Receives chat commands, tool responses, and keepalive pings from the widget."}).input(Io({chat_id:Ui(),command:el})).output(Io({ok:go()})),sd.route({method:"GET",tags:["App"],path:"/app/events",summary:"SSE stream for real-time app dashboard events",description:"Typed event stream delivering simulation, agent, QA, and user updates filtered by scope and application."}).input(Io({scopes:_o(tl).min(1),application_id:ns().optional()})).output(ld(il)),sd.route({method:"POST",tags:["Internal"],path:"/workos/webhook",summary:"WorkOS webhook receiver",description:"Receives webhook events from WorkOS (user management, SSO). Verified via workos-signature header. Not for external use."}).input(Io({event:Ui(),data:Oo(Ui(),wo())})).output(Io({received:go()})),sd.route({method:"POST",tags:["Internal"],path:"/stripe/webhook",summary:"Stripe webhook receiver",description:"Receives webhook events from Stripe (payments, subscriptions). Verified via stripe-signature header. Not for external use."}).input(Io({id:Ui(),object:Ui(),type:Ui(),data:Oo(Ui(),wo())}).passthrough().describe("Stripe event payload")).output(Io({received:go()})),sd.route({method:"GET",tags:["Insight"],path:"/insights/personas",summary:"Get personas overview (connectors + segments + personas)"}).input(Es).output(Ac),sd.route({method:"POST",tags:["Insight"],path:"/insights/segments/generate",summary:"Generate segments from session data (mocked)"}).input(Es).output(Io({items:_o(Cc)})),sd.route({method:"DELETE",tags:["Insight"],path:"/insights/segments/{id}",summary:"Delete a segment"}).input(Io({id:ns()})).output(Ts),sd.route({method:"POST",tags:["Insight"],path:"/insights/personas/generate",summary:"Generate personas from segments (mocked)"}).input(Es).output(Io({items:_o(Ec)})),sd.route({method:"DELETE",tags:["Insight"],path:"/insights/personas/{id}",summary:"Delete a persona"}).input(Io({id:ns()})).output(Ts),sd.route({method:"GET",tags:["Insight"],path:"/insights/personas/domain-suggest",summary:"Get domain-specific persona suggestions (accessible during onboarding)"}).input(Io({domain:Ui()})).output(Oc),sd.route({method:"POST",tags:["Insight"],path:"/insights/personas/save-domain",summary:"Save domain-suggested personas to the workspace (accessible during onboarding)"}).input(Mc).output(Io({saved:uo()})),sd.route({method:"PATCH",tags:["Insight"],path:"/insights/personas/{id}",summary:"Update persona content (name, description, profile fields, tags, traits)"}).input(zc).output(Ts),sd.route({method:"PATCH",tags:["Insight"],path:"/insights/personas/{id}/selection",summary:"Toggle the is_selected state of a persona"}).input(Io({id:ns(),is_selected:go()})).output(Ts),sd.route({method:"POST",tags:["Insight"],path:"/insights/personas/regenerate",summary:"Start segment + persona regeneration for an application (fire-and-forget)"}).input(Io({application_id:uo()})).output(Io({job_id:Ui()})),sd.route({method:"POST",tags:["Insight"],path:"/insights/personas/{id}/key-features",summary:"Generate AI key product feature insights for a specific persona"}).input(Io({id:ns()})).output(Io({features:_o(Ui())})),sd.route({method:"POST",tags:["Insight"],path:"/insights/{application_id}/research/run",summary:"Kick off Background Research for an application",description:"Fire-and-forget: dispatches Background Research to the agent, returns a job_id the client can subscribe to via appEvents. On completion, research output is persisted as knowledge rows with source='research' and a knowledge_embed is dispatched per row."}).input(Io({application_id:ns()})).output(Io({job_id:Ui()})),sd.route({method:"GET",tags:["Insight"],path:"/insights/{application_id}/research/status",summary:"Check whether Background Research is currently running",description:'Returns the current Background Research dispatch state for an application. Used by the client to restore the "Researching…" banner across page refreshes — if `status="in_progress"`, the client subscribes to appEvents and waits for `job/completed`. Per-pod tracking; not persistent across api restarts.'}).input(Io({application_id:ns()})).output(Io({status:Po(["idle","in_progress"])})),sd.route({method:"GET",tags:["Insight"],path:"/insights/heatmaps/pages",summary:"Get all tracked heatmap pages"}).input(Es).output(Io({items:_o(jc)})),sd.route({method:"GET",tags:["Insight"],path:"/insights/heatmaps/snapshot",summary:"Get heatmap snapshot for a page/variation/type"}).input(Io({page_id:ns(),variation:Pc,type:Rc})).output($c.nullable()),sd.route({method:"POST",tags:["Insight"],path:"/insights/heatmaps/generate",summary:"Enqueue a heatmap aggregation job over RRWeb session batches"}).input(Es).output(Io({job_id:Ui(),status:Po(["queued","active"])})),sd.route({method:"GET",tags:["Insight"],path:"/insights/heatmaps/status",summary:"Get the current heatmap aggregation job status for an application"}).input(Es).output(Fc),sd.route({method:"POST",tags:["Insight"],path:"/insights/heatmaps/candidates",summary:"Live-scan contributing sessions for a (page, variation) snapshot"}).input(Io({page_id:uo(),variation:Pc,limit:uo().int().min(1).max(50).default(15),offset:uo().int().min(0).default(0)})).output(Io({candidates:_o(Bc),total:uo()})),sd.route({method:"POST",tags:["Insight"],path:"/insights/heatmaps/backdrop",summary:"Pin a session as the backdrop override for a (page, variation) snapshot, or clear it with null"}).input(Io({page_id:uo(),variation:Pc,session_id:Ui().nullable()})).output(Io({success:Lo(!0)})),sd.route({method:"GET",tags:["Insight"],path:"/insights/reactions",summary:"Get all reactions with runs and results"}).input(Es).output(Io({reactions:_o(qc),personas:_o(Ec)})),sd.route({method:"POST",tags:["Insight"],path:"/insights/reactions",summary:"Create a new reaction (question)"}).input(Io({application_id:ns(),question:Ui()})).output(qc),sd.route({method:"DELETE",tags:["Insight"],path:"/insights/reactions/{id}",summary:"Delete a reaction and all its runs"}).input(Io({id:ns()})).output(Ts),sd.route({method:"POST",tags:["Insight"],path:"/insights/reactions/context",summary:"Get context for a reaction question"}).input(Io({application_id:ns(),question:Ui()})).output(Jc),sd.route({method:"POST",tags:["Insight"],path:"/insights/reactions/{reaction_id}/run",summary:"Run reaction scoring for selected personas"}).input(Io({reaction_id:ns(),persona_ids:_o(ns()),context_refs:_o(Gc),simulations:_o(Hc.pick({description:!0,selected:!0}))})).output(Yc);var cd,dd=null,ud="";function pd(e){return ye(new $e({url:e,headers:()=>{const e={};return dd&&(e.Authorization=`Bearer ${dd}`),e}}))}cd=pd("");var hd=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ud&&(ud=e,cd=pd(e))},md={setAuthToken:e=>{dd=e},clearAuthToken:()=>{dd=null},getAuthToken:()=>dd,configure:hd},gd=new Proxy({},{get:(e,t)=>t in md?md[t]:cd[t]}),fd="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",yd={debug:0,info:1,warn:2,error:3};function wd(e){return yd[e]>=yd[fd]}function bd(e){return{debug:(e,...t)=>{wd("debug")},info:(e,...t)=>{wd("info")},warn:(e,...t)=>{wd("warn")},error:(e,...t)=>{wd("error")}}}var vd=[{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 xd(e){return e.includes("__THINKING__")}function kd(e){return xd(e)?e:`${e}\n\n__THINKING__`}function _d(e,t,n,r,i){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(i&&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 Sd(e){const{messages:t,isTaskRunning:n,currentMode:r,requireContent:i}=e;let o=-1;if(n&&("show"===r||"do"===r)){const e=!0;for(let s=t.length-1;s>=0;s--){const a=t[s],l=_d(a,n,r,i,e),c=a.isPlaceholder,d=!i||a.content.trim().length>0||a.parts&&a.parts.length>0;if(l&&c&&d){o=s;break}}if(o<0&&!i)for(let s=t.length-1;s>=0;s--){const a=t[s],l=_d(a,n,r,i,e),c=a.isPlaceholder;if(l&&c){o=s;break}}if(o<0)for(let s=t.length-1;s>=0;s--){const a=t[s],l=_d(a,n,r,i,e),c=a.isPlaceholder;if(l&&!c){o=s;break}}}if(o<0){for(let e=t.length-1;e>=0;e--){const n=t[e],r="agent"===n.sender,s=n.isPlaceholder,a=!n.isSystemMessage,l=!n.isScreenAccessRequest,c=!i||n.content.trim().length>0||n.parts&&n.parts.length>0;if(r&&s&&a&&l&&c){o=e;break}}if(o<0&&!i)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&n.isPlaceholder&&!n.isSystemMessage&&!n.isScreenAccessRequest){o=e;break}}if(o<0&&(o=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)),o<0)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest){o=e;break}}}return o>=0?{index:o,message:t[o]}:null}function Id(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 Cd=new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]);function Ed(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 Ad(e,t,n,r=!1){const i=Id(e);if(!t||"show"!==n&&"do"!==n)return xd(i.content)?{...i,content:i.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:i;const o=r?"waiting-for-user":"thinking";return xd(i.content)?i.placeholderState!==o?{...i,placeholderState:o}:i:{...i,content:kd(i.content),placeholderState:o}}var Td=Object.fromEntries(vd.map(e=>[e.id,e.displayAction]));var Md="marketrix_chat_context",zd={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Od=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={...zd},this.context;try{const e=localStorage.getItem(Md);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...zd},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...zd},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Md,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,taskProgress:e.taskProgress,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={...zd},"undefined"!=typeof window&&localStorage.removeItem(Md)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Rd=class e{static instance;messages=[];chatId=null;isTaskRunning=!1;activeTaskId=null;taskProgress=[];currentMode="tell";isOpen=!1;isMinimized=!1;isLoading=!1;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e,this.restoreState()}createInitialContext(e){try{if(Od.hasValidContext())return;Od.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}getMessages(){return this.messages}getIsLoading(){return this.isLoading}getIsTaskRunning(){return this.isTaskRunning}getActiveTaskId(){return this.activeTaskId}getTaskProgress(){return this.taskProgress}getCurrentMode(){return this.currentMode}getIsOpen(){return this.isOpen}getIsMinimized(){return this.isMinimized}addMessage(e){this.messages=[...this.messages,e],this.persistState()}updateMessage(e,t){this.messages=this.messages.map(n=>n.id===e?{...n,...t}:n),this.persistState()}removeMessage(e){this.messages=this.messages.filter(t=>t.id!==e),this.persistState()}setMessages(e){this.messages=e,this.persistState()}clearMessages(){this.messages=[],this.persistState()}setTaskState(e,t,n){this.isTaskRunning=e,this.activeTaskId=t,this.taskProgress=n,this.persistState()}setMode(e){this.currentMode=e,this.persistState()}setWidgetState(e,t){this.isOpen=e,this.isMinimized=t,this.persistState()}setIsLoading(e){this.isLoading=e,this.persistState()}restoreState(){try{const e=Od.getContext();if(!e.chat_id)return;this.chatId&&(e.chat_id,this.chatId),this.messages=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}),this.isTaskRunning=e.isTaskRunning,this.activeTaskId=e.activeTaskId,this.taskProgress=e.taskProgress,this.currentMode=e.currentMode,this.isOpen=e.isOpen,this.isMinimized=e.isMinimized,this.isLoading=e.isLoading??!1}catch(e){}}persistState(){if(this.chatId)try{const e=this.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});Od.updateContext({chat_id:this.chatId,messages:e,isTaskRunning:this.isTaskRunning,activeTaskId:this.activeTaskId,taskProgress:this.taskProgress,currentMode:this.currentMode,isOpen:this.isOpen,isMinimized:this.isMinimized,isLoading:this.isLoading})}catch(e){}}}.getInstance();function Pd(e,t,n="user-message"){const r=[],i=e.trim();return i&&r.push({type:"text",content:i}),{id:`${n}-${Date.now()}`,content:i,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:r}}function Nd(e,t,n,r="agent-message"){const i=[],o=e.trim();return o&&i.push({type:"text",content:o}),{id:n||`${r}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:i}}function Ld(e,t,n="agent",r="system-message"){const i=[];return e&&i.push({type:"text",content:e}),{id:`${r}-${Date.now()}`,content:e,sender:n,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:i}}function Dd(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 jd(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var $d=bd(),Fd=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&$d.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 $d.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return $d.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,$d.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{$d.info("Creating new chat ID...");const e=await gd.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),$d.info("Created and stored new chat ID:",this.chatId),Rd.createInitialContext(e),e}catch(e){throw $d.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Od.getChatId()}storeChatId(e){Od.setChatId(e)}}.getInstance(),Bd=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?.mtxAgent&&this.config?.mtxApp&&(t.agent_id=this.config.mtxAgent,t.application_id=this.config.mtxApp);const i=await gd.widgetStream(t,{signal:r});this.setStatus("connected"),this.reconnectAttempts=0,this.reconnectDelay=1e3,this.consumeEvents(i,n)}catch(i){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?gd.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)}},Ud=class{config;constructor(e){this.config=e}getChatId(){return Fd.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),gd.activityLogCreate({type:"widget_question",metadata:r}).catch(e=>{})}catch(n){}}async sendMessage(e){if(!(await Fd.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&&this.config.mtxAgent))throw new Error("Either mtxId + mtxKey or both mtxApp + mtxAgent are 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 Bd.getInstance().send(r),{messageId:n,response:"",mode:t,timestamp:/* @__PURE__ */new Date}}updateConfig(e){this.config={...this.config,...e}}},Gd=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Od.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Od.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 Wd(e,t={}){return{...t,...e}}var Zd=n(void 0),Vd=({children:e,previewMode:t=!1,uiActions:n,currentMode:r})=>{const[i,s]=p({messages:[]}),a=u(r);a.current=r;const l=o(e=>{s(t=>(Rd.addMessage(e),{messages:[...t.messages,e]}))},[]),c=o((e,t)=>{s(n=>(Rd.updateMessage(e,t),{messages:n.messages.map(n=>n.id===e?{...n,...t}:n)}))},[]),h=o(e=>{s(t=>(Rd.removeMessage(e),{messages:t.messages.filter(t=>t.id!==e)}))},[]),m=o(e=>{s(()=>(Rd.setMessages(e),{messages:e}))},[]),f=o(()=>{Rd.clearMessages(),s({messages:[]})},[]),y=o(async(e,r,i,o,c)=>{const d=r??a.current;if(t)return c||l(Pd(e,d)),void l(Nd("This is a preview. In production, I'll respond to your messages here."));let u=Gd.getConfig();if(u||(u=Gd.loadConfig()),!u||!u.mtxId&&!u.mtxKey&&!u.mtxAgent)return void l(Nd("Configuration error: Missing API credentials. Please check your widget settings."));c||l(Pd(e,d));const p=`temp-${globalThis.crypto.randomUUID()}`;l({id:p,content:kd(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:d,isPlaceholder:!0,placeholderState:"thinking",parts:[]}),n.setLoading(!0);const h=new Ud(u);try{i&&h.updateConfig({mtxApp:i});const t=h.getChatId();if(t){const e=Bd.getInstance();if(!e.isConnected()){const n=Gd.getConfig();try{await e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxAgent:n.mtxAgent,mtxApp:n.mtxApp}:void 0)}catch(m){}}}await h.sendMessage({message:e,mode:d,question:o,requestId:p})}catch(g){s(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.",n=e.messages.map(e=>{if(e.id!==p)return e;const n=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:n,content:t}});return Rd.setMessages(n),{messages:n}})}finally{n.setLoading(!1)}},[t,l,n]),w=d(()=>({addMessage:l,updateMessage:c,removeMessage:h,setMessages:m,clearMessages:f,sendMessage:y}),[l,c,h,m,f,y]);/* @__PURE__ */
3
+ return g(Zd.Provider,{value:{chatState:i,chatActions:w,_setMessages:s},children:e})};function Hd(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 i=(t,n)=>{if(r){e.tagName,e.id,e.className}};if(!0===e.disabled)return i("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return i("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return i("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 o=e.hasAttribute("onclick");if(r&&o)return!0;let s,a;try{s=window.getComputedStyle(e)}catch(t){return i("computed-style","failed to get computed style"),!1}if("none"===s.display)return i("display","display is none"),!1;if("none"===s.pointerEvents)return i("pointer-events","pointer-events is none"),!1;try{a=e.getBoundingClientRect()}catch(t){return i("bounding-rect","failed to get bounding rect"),!1}if(a.width<=0||a.height<=0)return i("dimensions",`width=${a.width}, height=${a.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 o,s;try{o=window.getComputedStyle(n),s=n.getBoundingClientRect()}catch{t=n;continue}if("hidden"===o.overflow||"clip"===o.overflow){const e=a.right<s.left||a.left>s.right||a.bottom<s.top||a.top>s.bottom;if(r){if(e)return i("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 Yd=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;isIndexed=!1;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,i=Array.from(t.children).filter(e=>e.tagName===r);if(i.length>1){e+=`:nth-of-type(${i.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"}}exportState(){return{selectors:Array.from(this.selectorMap.entries()),fingerprints:Array.from(this.fingerprintMap.entries())}}importState(e){if(e)try{e.selectors&&(this.selectorMap=new Map(e.selectors)),e.fingerprints&&(this.fingerprintMap=new Map(e.fingerprints)),(this.selectorMap.size>0||this.fingerprintMap.size>0)&&(this.isIndexed=!0)}catch(t){}}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"]'),i=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),o="onclick"in t&&"function"==typeof t.onclick;if(e||i||o||Hd(t)){this.elementMap.set(n,t),this.elementToSequence.set(t,n);const e=this.generateSelector(t);this.selectorMap.set(n,e);const i=this.generateFingerprint(t,e);this.fingerprintMap.set(n,i),r.push([n,t]),n++}}t=e.nextNode()}return this.isIndexed=!0,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 i=t.willChange;if(i&&(i.includes("transform")||i.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const o=t.contain;return!(!o||!(o.includes("layout")||o.includes("style")||o.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 i=0;t.parentElement&&(i=Array.from(t.parentElement.children).indexOf(t)),n.push({element:t,zIndex:r,domOrder:i})}t=t.parentElement}let r=1e6;for(let i=n.length-1;i>=0;i--){const e=n[i];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 i=this.selectorMap.get(n);if(i)try{const t=(e.querySelector("body")||e).querySelector(i);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}getElementByDataId(e){return this.elementMap.get(e)}getSequenceForElement(e){return this.elementToSequence.get(e)}isIndexActive(){return this.isIndexed}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear(),this.isIndexed=!1}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 i=r.left+r.width/2,o=r.top+r.height/2,s=document.elementFromPoint(i,o);if(s&&s!==e&&!e.contains(s)&&!(s.closest("#marketrix-show-highlight")||s.closest("#marketrix-show-popup")||s.closest("[data-marketrix-widget]"))){const e=s.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${s.className?`${e}.${s.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}}getFingerprint(e){return this.fingerprintMap.get(e)}getAllFingerprints(){return Array.from(this.fingerprintMap.entries())}getIndexVersion(){return this.indexVersion}}.getInstance(),qd=null;async function Jd(){if(qd?.active){const e=qd.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return qd}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 qd=e,e.getVideoTracks()[0].addEventListener("ended",()=>{qd=null}),e}function Kd(){return null!==function(){if(qd?.active){const e=qd.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return qd}return qd=null,null}()}var Xd=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:i}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===n&&this.currentOptions.toolName===i&&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,i=e.left+e.width/2,o=e.top+e.height/2,s=[{left:e.right+20,top:o-60},{left:e.left-t-20,top:o-60},{left:i-160,top:e.top-n-20},{left:i-160,top:e.bottom+20}];let a=s[0];for(const d of s)if(d.left>=r&&d.left+t<=window.innerWidth-r&&d.top>=r&&d.top+n<=window.innerHeight-r){a=d;break}const l=Math.max(r,Math.min(a.left,window.innerWidth-t-r)),c=Math.max(r,Math.min(a.top,window.innerHeight-n-r));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${c}px;\n left: ${l}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=Yd.getSequenceForElement(this.currentElement)??-1,t=Yd.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(),Qd=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:i}=Yd.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:i||`Element ${n} not found`};if(!(await Xd.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(i){return Xd.cleanup(),{success:!1,data:{text:""},error:i instanceof Error?i.message:String(i)}}}requiresHighlight(e){return["click_element","type_text","select_dropdown_option","send_keys","upload_file"].includes(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}=Yd.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}=Yd.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(i){}const o=t?e.text:r.value+e.text;let s=!1,a=null;if(!s)try{const e="TEXTAREA"===r.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(r,o),s=!0)}catch(i){a=i}if(!s)try{r.value=o,s=!0}catch(i){a=i}if(!s)try{r.focus(),t&&r.select(),document.execCommand("insertText",!1,e.text)&&(s=!0)}catch(i){a=i}if(!s)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}));s=!0}catch(i){a=i}if(!s)return{success:!1,data:{text:""},error:`Failed to set value: ${a instanceof Error?a.message:String(a)}`};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(i){}}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(i){return{success:!1,data:{text:""},error:`Failed to set value on element: ${i instanceof Error?i.message:String(i)}`}}else try{n.textContent=e.text,n.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){return{success:!1,data:{text:""},error:`Failed to set textContent: ${i instanceof Error?i.message:String(i)}`}}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}=Yd.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}=Yd.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}=Yd.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,i=e.selectionStart??t.length,o=e.selectionEnd??t.length;if(0===i&&0===o&&(i=t.length,o=t.length),i===o&&i>0)n=t.slice(0,i-1)+t.slice(o),r=i-1;else{if(i===o)return"Backspace: cursor at start, nothing to delete";n=t.slice(0,i)+t.slice(o),r=i}const s=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return s?s.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 i;if(t===n&&t<r.length)i=r.slice(0,t)+r.slice(n+1);else{if(t===n)return"Delete: cursor at end, nothing to delete";i=r.slice(0,t)+r.slice(n)}const o=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return o?o.call(e,i):e.value=i,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${i}"`}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:Yd.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Yd.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Jd();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(),eu=n(void 0),tu=({children:e,previewMode:t=!1,currentMode:n,setMessages:r,uiActions:i,activeTaskIdRef:s})=>{const[l,c]=p({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),h=u(!1),m=u(0),f=u(/* @__PURE__ */new Set),y=u({}),w=u(n);w.current=n,a(()=>{s.current=l.activeTaskId},[l.activeTaskId,s]);const b=o(e=>{if(f.current.add(e),f.current.size>1e3){const e=Array.from(f.current);f.current=new Set(e.slice(-500))}},[]),v=o((e,t,n,i)=>{r(r=>{const o=function(e){return Td[e]?Td[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(e),s=Sd({messages:r.messages,isTaskRunning:h.current,currentMode:w.current,requireContent:"failed"===n});if(!s)return r;let a=s.message;const l=["click_element","type_text","select_dropdown_option","send_keys","upload_file"].includes(e),c=h.current&&"show"===w.current&&l,d="done"===e;"in_progress"===n?(d||(a=function(e,t,n){const r=Id(e),i=r.parts||[],o=[...i],s=i.findIndex(e=>"progress"===e.type&&e.toolName===t&&"in_progress"===e.status),a=!Cd.has(t),l="default",c=Ed(n);return s>=0?o[s]={...o[s],content:c,hideIcon:a,textStyle:l}:o.push({type:"progress",content:c,status:"in_progress",toolName:t,hideIcon:a,textStyle:l}),{...r,parts:o}}(a,o,t||o)),!h.current||"show"!==w.current&&"do"!==w.current||(a=Ad(a,h.current,w.current,c))):"completed"===n?(d||(a=function(e,t){const n=Id(e),r=n.parts||[],i=[...r];let o=-1;if(t)o=r.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);else for(let s=r.length-1;s>=0;s--)if("progress"===r[s].type&&"in_progress"===r[s].status){o=s;break}return o>=0&&(i[o]={...i[o],status:"completed"}),{...n,parts:i}}(a)),!h.current||"show"!==w.current&&"do"!==w.current||(a=Ad(a,h.current,w.current,!1))):(a=function(e,t,n){const r=Id(e),i=r.parts||[],o=n.toLowerCase().includes("cancelled by cleanup"),s=[...i];let a=i.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);if(-1===a)for(let l=i.length-1;l>=0;l--)if("progress"===i[l].type&&"in_progress"===i[l].status){a=l;break}if(a>=0)if(o){const e=Ed(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=Ed(n),t=Ed(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(a,o,i||""),!h.current||"show"!==w.current&&"do"!==w.current||(a=Ad(a,h.current,w.current,!1)));const u=[...r.messages];return u[s.index]=a,Rd.setMessages(u),{messages:u}})},[]),x=o(()=>{const e=y.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;y.current={},c(e=>(Rd.setTaskState(!0,t,[]),h.current=!0,{...e,isTaskRunning:!0,activeTaskId:t,taskProgress:[]}))}},[]);a(()=>{if(t)return;const e=Bd.getInstance(),n={onStatusChange:e=>{i.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const i=t.call_id;if(f.current.has(i))return;if(b(i),!vd.map(e=>e.id).includes(t.tool))return void e.send({type:"tool/response",call_id:i,success:!1,error:`Unknown tool: ${t.tool}`,state_version:m.current}).catch(e=>{});h.current||(h.current=!0,c(e=>({...e,isTaskRunning:!0})));const o=t.tool,s=t.args,a=t.mode||w.current||"do",l=t.explanation||"",d=t.state_version;void 0!==d&&d>m.current&&(m.current=d),v(o,l,"in_progress");const u=await Qd.executeTool(o,s,a,l);if(u.success)try{m.current++,e.send({type:"tool/response",call_id:i,success:!0,data:"string"==typeof u.data?u.data:JSON.stringify(u.data),state_version:m.current}).catch(e=>{}),v(o,l,"completed"),"done"===o&&(y.current={},c(e=>(Rd.setTaskState(!1,null,[]),h.current=!1,r(t=>{const n=Sd({messages:t.messages,isTaskRunning:e.isTaskRunning,currentMode:w.current,requireContent:!1}),r=[...t.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},Rd.setMessages(r)}return{messages:r}}),{...e,isTaskRunning:!1,activeTaskId:null,taskProgress:[]})))}catch(n){v(o,l,"failed","Connection error")}else v(o,l,"failed",u.error||"Tool execution failed"),m.current++,e.send({type:"tool/response",call_id:i,success:!1,data:"string"==typeof u.data?u.data:JSON.stringify(u.data),error:u.error??void 0,state_version:m.current}).catch(e=>{})}else if("task/status"===t.type){const e=t.status,n=t.message||"";"running"===e?(y.current={...y.current,agentRunning:!0,apiTaskId:y.current.apiTaskId||t.task_id||void 0},x()):"completed"!==e&&"failed"!==e&&"stopped"!==e||(f.current.clear(),y.current={},c(t=>(Rd.setTaskState(!1,null,[]),r(r=>{const i=Sd({messages:r.messages,isTaskRunning:t.isTaskRunning,currentMode:w.current,requireContent:!1}),o=[...r.messages];if(i){let t="done";"failed"===e?t="failed":"stopped"===e&&(t="stopped"),o[i.index]={...i.message,taskStatus:t,...n&&{content:n}},Rd.setMessages(o)}return{messages:o}}),h.current=!1,{...t,isTaskRunning:!1,activeTaskId:null,taskProgress:[]})))}else"chat/response"===t.type?(r(e=>{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}}});return Rd.setMessages(n),t.task_id&&(y.current={...y.current,apiTaskId:t.task_id},x()),{messages:n}}),i.setLoading(!1)):"chat/error"===t.type&&(r(e=>{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 Rd.setMessages(n),{messages:n}}),i.setLoading(!1))},onError:e=>{i.setError(e.message)}};return e.addCallbacks(n),()=>{e.removeCallbacks(n)}},[t,v,x,b,r,i]);const k=o(e=>{c(t=>(Rd.setTaskState(e.isTaskRunning,e.activeTaskId,e.taskProgress??[]),{...t,...e}))},[]),_=o(async()=>{const e=s.current??void 0;c(e=>(r(n=>{const r=Sd({messages:n.messages,isTaskRunning:e.isTaskRunning,currentMode:w.current,requireContent:!1}),i=[...n.messages];return r&&(i[r.index]={...r.message,taskStatus:"stopped"},t||Rd.setMessages(i)),{messages:i}}),t||Rd.setTaskState(!1,null,[]),h.current=!1,{...e,isTaskRunning:!1,activeTaskId:null,taskProgress:[]})),t||Bd.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,r,s]),S=d(()=>({setTaskState:k,stopTask:_}),[k,_]);/* @__PURE__ */
4
+ return g(eu.Provider,{value:{taskState:l,taskActions:S},children:e})},nu=n(void 0),ru=({children:e,initialMode:t="tell",initialIsOpen:n=!1,initialIsMinimized:r=!1})=>{const[i,o]=p({isOpen:n,isMinimized:r,activeView:"home",currentMode:t,agentAvailable:!1,isLoading:!1}),s=d(()=>({setActiveView:e=>o(t=>({...t,activeView:e})),toggleWidget:()=>o(e=>{const t={...e,isOpen:!e.isOpen,isMinimized:!!e.isOpen};return Rd.setWidgetState(t.isOpen,t.isMinimized),t}),closeWidget:()=>o(e=>{const t={...e,isOpen:!1,isMinimized:!0};return Rd.setWidgetState(t.isOpen,t.isMinimized),t}),setMode:e=>o(t=>(Rd.setMode(e),{...t,currentMode:e})),setLoading:e=>{Rd.setIsLoading(e),o(t=>({...t,isLoading:e}))},setAgentAvailable:e=>o(t=>({...t,agentAvailable:e})),setError:e=>o(t=>({...t,error:e})),clearError:()=>o(e=>({...e,error:void 0})),applyState:e=>o(t=>({...t,...e}))}),[]);/* @__PURE__ */
5
+ return g(nu.Provider,{value:{uiState:i,uiActions:s},children:e})},iu=()=>{const e=s(nu);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var ou=({config:e}={})=>{const{uiState:t,uiActions:n}=iu(),{chatState:r,chatActions:i}=(()=>{const e=s(Zd);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e})(),{taskState:l,taskActions:c}=(()=>{const e=s(eu);if(!e)throw new Error("useTaskContext must be used within TaskProvider");return e})(),u=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:l.activeTaskId,isTaskRunning:l.isTaskRunning,taskProgress:l.taskProgress}),[t,r,l]),p=o(e=>{n.applyState({...void 0!==e.isOpen&&{isOpen:e.isOpen},...void 0!==e.isMinimized&&{isMinimized:e.isMinimized},...void 0!==e.isLoading&&{isLoading:e.isLoading},...void 0!==e.currentMode&&{currentMode:e.currentMode},...void 0!==e.agentAvailable&&{agentAvailable:e.agentAvailable},...void 0!==e.error&&{error:e.error},...void 0!==e.activeView&&{activeView:e.activeView}}),void 0!==e.messages&&i.setMessages(e.messages),void 0===e.activeTaskId&&void 0===e.isTaskRunning&&void 0===e.taskProgress||c.setTaskState({activeTaskId:e.activeTaskId??l.activeTaskId,isTaskRunning:e.isTaskRunning??l.isTaskRunning,taskProgress:e.taskProgress??l.taskProgress})},[n,i,c,l]),h=o(()=>{i.clearMessages(),c.setTaskState({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),n.setError(void 0)},[i,c,n]),m=d(()=>({setState:p,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:i.addMessage,updateMessage:i.updateMessage,removeMessage:i.removeMessage,setMessages:i.setMessages,sendMessage:i.sendMessage,resetState:h,clearChatHistory:h}),[p,n,c,i,h]),g=d(()=>e||Gd.getConfig()||{},[e]),f=function(e){return Object.keys(Za.shape).every(t=>void 0!==e[t])}(g);a(()=>{f&&Gd.saveConfig(g)},[g,f]);const y=g.isPreviewMode??!1;return{state:u,actions:m,config:g,shouldShow:f&&!0===g.widget_enabled,isPreviewMode:y,configValid:f}},su=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),au="-",lu=[],cu=e=>{const t=pu(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return uu(e);const n=e.split(au);return du(n,""===n[0]&&n.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=r[e],i=n[e];return t?i?((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})(i,t):t:i||lu}return n[e]||lu}}},du=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],i=n.nextPart.get(r);if(i){const n=du(e,t+1,i);if(n)return n}const o=n.validators;if(null===o)return;const s=0===t?e.join(au):e.slice(t).join(au),a=o.length;for(let l=0;l<a;l++){const e=o[l];if(e.validator(s))return e.classGroupId}},uu=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})(),pu=e=>{const{theme:t,classGroups:n}=e;return hu(n,t)},hu=(e,t)=>{const n=su();for(const r in e){const i=e[r];mu(i,n,r,t)}return n},mu=(e,t,n,r)=>{const i=e.length;for(let o=0;o<i;o++){const i=e[o];gu(i,t,n,r)}},gu=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?wu(e,t,n,r):yu(e,t,n,r):fu(e,t,n)},fu=(e,t,n)=>{(""===e?t:bu(t,e)).classGroupId=n},yu=(e,t,n,r)=>{vu(e)?mu(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},wu=(e,t,n,r)=>{const i=Object.entries(e),o=i.length;for(let s=0;s<o;s++){const[e,o]=i[s];mu(o,bu(t,e),n,r)}},bu=(e,t)=>{let n=e;const r=t.split(au),i=r.length;for(let o=0;o<i;o++){const e=r[o];let t=n.nextPart.get(e);t||(t=su(),n.nextPart.set(e,t)),n=t}return n},vu=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,xu=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(i,o)=>{n[i]=o,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])?(i(e,t),t):void 0},set(e,t){e in n?n[e]=t:i(e,t)}}},ku=[],_u=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Su=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=e=>{const t=[];let n,r=0,i=0,o=0;const s=e.length;for(let d=0;d<s;d++){const s=e[d];if(0===r&&0===i){if(":"===s){t.push(e.slice(o,d)),o=d+1;continue}if("/"===s){n=d;continue}}"["===s?r++:"]"===s?r--:"("===s?i++:")"===s&&i--}const a=0===t.length?e:e.slice(o);let l=a,c=!1;a.endsWith("!")?(l=a.slice(0,-1),c=!0):a.startsWith("!")&&(l=a.slice(1),c=!0);return _u(t,c,l,n&&n>o?n-o:void 0)};if(t){const e=t+":",n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):_u(ku,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},Iu=e=>{const t=/* @__PURE__ */new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{const n=[];let r=[];for(let i=0;i<e.length;i++){const o=e[i],s="["===o[0],a=t.has(o);s||a?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(o)):r.push(o)}return r.length>0&&(r.sort(),n.push(...r)),n}},Cu=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},Eu=/\s+/,Au=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Au(e[r]))&&(n&&(n+=" "),n+=t);return n},Tu=(e,...t)=>{let n,r,i,o;const s=e=>{const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:s}=t,a=[],l=e.trim().split(Eu);let c="";for(let d=l.length-1;d>=0;d-=1){const e=l[d],{isExternal:t,modifiers:u,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:m}=n(e);if(t){c=e+(c.length>0?" "+c:c);continue}let g,f=!!m;if(f){g=r(h.substring(0,m));const e=g&&s[g]?r(h):void 0;e&&e!==g&&(g=e,f=!1)}else g=r(h);if(!g){if(!f){c=e+(c.length>0?" "+c:c);continue}if(g=r(h),!g){c=e+(c.length>0?" "+c:c);continue}f=!1}const y=0===u.length?"":1===u.length?u[0]:o(u).join(":"),w=p?y+"!":y,b=w+g;if(a.indexOf(b)>-1)continue;a.push(b);const v=i(g,f);for(let n=0;n<v.length;++n){const e=v[n];a.push(w+e)}c=e+(c.length>0?" "+c:c)}return c})(e,n);return i(e,o),o};return o=a=>(n=(e=>({cache:xu(e.cacheSize),parseClassName:Su(e),sortModifiers:Iu(e),postfixLookupClassGroupIds:Cu(e),...cu(e)}))(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,o=s,s(a)),(...e)=>o(((...e)=>{let t,n,r=0,i="";for(;r<e.length;)(t=e[r++])&&(n=Au(t))&&(i&&(i+=" "),i+=n);return i})(...e))},Mu=[],zu=e=>{const t=t=>t[e]||Mu;return t.isThemeGetter=!0,t},Ou=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ru=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Pu=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Nu=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Lu=/\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$/,Du=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ju=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$u=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Fu=e=>Pu.test(e),Bu=e=>!!e&&!Number.isNaN(Number(e)),Uu=e=>!!e&&Number.isInteger(Number(e)),Gu=e=>e.endsWith("%")&&Bu(e.slice(0,-1)),Wu=e=>Nu.test(e),Zu=()=>!0,Vu=e=>Lu.test(e)&&!Du.test(e),Hu=()=>!1,Yu=e=>ju.test(e),qu=e=>$u.test(e),Ju=e=>!Qu(e)&&!ap(e),Ku=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)),Xu=e=>gp(e,bp,Hu),Qu=e=>Ou.test(e),ep=e=>gp(e,vp,Vu),tp=e=>gp(e,xp,Bu),np=e=>gp(e,_p,Zu),rp=e=>gp(e,kp,Hu),ip=e=>gp(e,yp,Hu),op=e=>gp(e,wp,qu),sp=e=>gp(e,Sp,Yu),ap=e=>Ru.test(e),lp=e=>fp(e,vp),cp=e=>fp(e,kp),dp=e=>fp(e,yp),up=e=>fp(e,bp),pp=e=>fp(e,wp),hp=e=>fp(e,Sp,!0),mp=e=>fp(e,_p,!0),gp=(e,t,n)=>{const r=Ou.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},fp=(e,t,n=!1)=>{const r=Ru.exec(e);return!!r&&(r[1]?t(r[1]):n)},yp=e=>"position"===e||"percentage"===e,wp=e=>"image"===e||"url"===e,bp=e=>"length"===e||"size"===e||"bg-size"===e,vp=e=>"length"===e,xp=e=>"number"===e,kp=e=>"family-name"===e,_p=e=>"number"===e||"weight"===e,Sp=e=>"shadow"===e,Ip=/* @__PURE__ */Tu(()=>{const e=zu("color"),t=zu("font"),n=zu("text"),r=zu("font-weight"),i=zu("tracking"),o=zu("leading"),s=zu("breakpoint"),a=zu("container"),l=zu("spacing"),c=zu("radius"),d=zu("shadow"),u=zu("inset-shadow"),p=zu("text-shadow"),h=zu("drop-shadow"),m=zu("blur"),g=zu("perspective"),f=zu("aspect"),y=zu("ease"),w=zu("animate"),b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",ap,Qu],v=()=>[ap,Qu,l],x=()=>[Fu,"full","auto",...v()],k=()=>[Uu,"none","subgrid",ap,Qu],_=()=>["auto",{span:["full",Uu,ap,Qu]},Uu,ap,Qu],S=()=>[Uu,"auto",ap,Qu],I=()=>["auto","min","max","fr",ap,Qu],C=()=>["auto",...v()],E=()=>[Fu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],A=()=>[Fu,"screen","full","dvw","lvw","svw","min","max","fit",...v()],T=()=>[Fu,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],M=()=>[e,ap,Qu],z=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",dp,ip,{position:[ap,Qu]}],O=()=>["auto","cover","contain",up,Xu,{size:[ap,Qu]}],R=()=>[Gu,lp,ep],P=()=>["","none","full",c,ap,Qu],N=()=>["",Bu,lp,ep],L=()=>[Bu,Gu,dp,ip],D=()=>["","none",m,ap,Qu],j=()=>["none",Bu,ap,Qu],$=()=>["none",Bu,ap,Qu],F=()=>[Bu,ap,Qu],B=()=>[Fu,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Wu],breakpoint:[Wu],color:[Zu],container:[Wu],"drop-shadow":[Wu],ease:["in","out","in-out"],font:[Ju],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Wu],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Wu],shadow:[Wu],spacing:["px",Bu],text:[Wu],"text-shadow":[Wu],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Fu,Qu,ap,f]}],container:["container"],"container-type":[{"@container":["","normal","size",ap,Qu]}],"container-named":[Ku],columns:[{columns:[Bu,Qu,ap,a]}],"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:b()}],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:[Uu,"auto",ap,Qu]}],basis:[{basis:[Fu,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Bu,Fu,"auto","initial","none",Qu]}],grow:[{grow:["",Bu,ap,Qu]}],shrink:[{shrink:["",Bu,ap,Qu]}],order:[{order:[Uu,"first","last","none",ap,Qu]}],"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",...A()]}],"min-inline-size":[{"min-inline":["auto",...A()]}],"max-inline-size":[{"max-inline":["none",...A()]}],"block-size":[{block:["auto",...T()]}],"min-block-size":[{"min-block":["auto",...T()]}],"max-block-size":[{"max-block":["none",...T()]}],w:[{w:[a,"screen",...E()]}],"min-w":[{"min-w":[a,"screen","none",...E()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...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,lp,ep]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,mp,np]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Gu,Qu]}],"font-family":[{font:[cp,rp,t]}],"font-features":[{"font-features":[Qu]}],"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:[i,ap,Qu]}],"line-clamp":[{"line-clamp":[Bu,"none",ap,tp]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",ap,Qu]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ap,Qu]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[Bu,"from-font","auto",ap,ep]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[Bu,"auto",ap,Qu]}],"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:[Uu,ap,Qu]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ap,Qu]}],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",ap,Qu]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"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"]},Uu,ap,Qu],radial:["",ap,Qu],conic:[Uu,ap,Qu]},pp,op]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:N()}],"border-w-x":[{"border-x":N()}],"border-w-y":[{"border-y":N()}],"border-w-s":[{"border-s":N()}],"border-w-e":[{"border-e":N()}],"border-w-bs":[{"border-bs":N()}],"border-w-be":[{"border-be":N()}],"border-w-t":[{"border-t":N()}],"border-w-r":[{"border-r":N()}],"border-w-b":[{"border-b":N()}],"border-w-l":[{"border-l":N()}],"divide-x":[{"divide-x":N()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":N()}],"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:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Bu,ap,Qu]}],"outline-w":[{outline:["",Bu,lp,ep]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",d,hp,sp]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",u,hp,sp]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:N()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[Bu,ep]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":N()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",p,hp,sp]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[Bu,ap,Qu]}],"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":[Bu]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[ap,Qu]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"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":[Bu]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ap,Qu]}],filter:[{filter:["","none",ap,Qu]}],blur:[{blur:D()}],brightness:[{brightness:[Bu,ap,Qu]}],contrast:[{contrast:[Bu,ap,Qu]}],"drop-shadow":[{"drop-shadow":["","none",h,hp,sp]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",Bu,ap,Qu]}],"hue-rotate":[{"hue-rotate":[Bu,ap,Qu]}],invert:[{invert:["",Bu,ap,Qu]}],saturate:[{saturate:[Bu,ap,Qu]}],sepia:[{sepia:["",Bu,ap,Qu]}],"backdrop-filter":[{"backdrop-filter":["","none",ap,Qu]}],"backdrop-blur":[{"backdrop-blur":D()}],"backdrop-brightness":[{"backdrop-brightness":[Bu,ap,Qu]}],"backdrop-contrast":[{"backdrop-contrast":[Bu,ap,Qu]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Bu,ap,Qu]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Bu,ap,Qu]}],"backdrop-invert":[{"backdrop-invert":["",Bu,ap,Qu]}],"backdrop-opacity":[{"backdrop-opacity":[Bu,ap,Qu]}],"backdrop-saturate":[{"backdrop-saturate":[Bu,ap,Qu]}],"backdrop-sepia":[{"backdrop-sepia":["",Bu,ap,Qu]}],"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",ap,Qu]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Bu,"initial",ap,Qu]}],ease:[{ease:["linear","initial",y,ap,Qu]}],delay:[{delay:[Bu,ap,Qu]}],animate:[{animate:["none",w,ap,Qu]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ap,Qu]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:j()}],"rotate-x":[{"rotate-x":j()}],"rotate-y":[{"rotate-y":j()}],"rotate-z":[{"rotate-z":j()}],scale:[{scale:$()}],"scale-x":[{"scale-x":$()}],"scale-y":[{"scale-y":$()}],"scale-z":[{"scale-z":$()}],"scale-3d":["scale-3d"],skew:[{skew:F()}],"skew-x":[{"skew-x":F()}],"skew-y":[{"skew-y":F()}],transform:[{transform:[ap,Qu,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:B()}],"translate-x":[{"translate-x":B()}],"translate-y":[{"translate-y":B()}],"translate-z":[{"translate-z":B()}],"translate-none":["translate-none"],zoom:[{zoom:[Uu,ap,Qu]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"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",ap,Qu]}],"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":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"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",ap,Qu]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[Bu,lp,ep,tp]}],stroke:[{stroke:["none",...M()]}],"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 Cp(...e){return Ip(e.filter(Boolean).join(" "))}var Ep={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)"},Ap={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"},Tp={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Mp={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},zp={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},Op={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 Rp(e){if(e&&"none"!==e)return{boxShadow:Ep[e]}}var Pp={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Np=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 Lp(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Pp[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Pp[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Pp[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Pp[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Pp[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Pp[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Pp[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Pp[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Pp[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Pp[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Pp[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-${Pp[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(Ap.theme);else if("full"===e.rounded)t.push(Ap.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Ap[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 Dp(e){const t={};for(const n in e)Np.has(n)||(t[n]=e[n]);return t}var jp={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},$p={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Fp=i(function(e,t){const{as:n="div",background:r="default",className:i,elevation:o,paddingPreset:s="none",radius:a,style:l,...c}=e,d=Lp(e);/* @__PURE__ */
6
+ return g(n,{...Dp(c),ref:t,className:Cp(jp[r],$p[s],a&&Lp({rounded:a}),d,i),style:{...Rp(o),...l}})}),Bp="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",Up={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"},Gp=i(function({src:e,alt:t,elevation:n,fit:r="contain",size:i="md",rounded:o,className:s,style:a,...l},c){const d="string"==typeof i,u=d?Up[i]:void 0,p=d?a:{width:i,height:i,...a};/* @__PURE__ */
7
+ return g("img",{...l,ref:c,alt:t,className:Cp("flex-shrink-0","contain"===r?"object-contain":"object-cover",u,!0===o||"theme"===o?Ap.theme:"full"===o?Ap.pill:o?Ap[o]:void 0,s),src:e,style:{...Rp(n),...p}})});function Wp(e){return"undefined"!=typeof window&&(e instanceof HTMLElement||e instanceof function(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}(e).HTMLElement)}var Zp={...e},Vp={};function Hp(t,n){const r=e.useRef(Vp);return r.current===Vp&&(r.current=t(n)),r}var Yp=Zp.useInsertionEffect,qp=Yp&&Yp!==Zp.useLayoutEffect?Yp:e=>e();function Jp(e){const t=Hp(Kp).current;return t.next=e,qp(t.effect),t.trampoline}function Kp(){const e={next:void 0,callback:Xp,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Xp(){}var Qp="undefined"!=typeof document?e.useLayoutEffect:()=>{};function eh(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var th={};function nh(e,t,n,r,i){if(!(n||r||i||e))return rh(t);let o=rh(e);return t&&(o=ih(o,t)),n&&(o=ih(o,n)),r&&(o=ih(o,r)),i&&(o=ih(o,i)),o}function rh(e){return sh(e)?{...ah(e,th)}:function(e){const t={...e};for(const n in t){const e=t[n];oh(n,e)&&(t[n]=ch(e))}return t}(e)}function ih(e,t){return sh(t)?ah(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=eh(e.style,r);break;case"className":e[n]=uh(e.className,r);break;default:oh(n,r)?e[n]=lh(e[n],r):e[n]=r}}return e}(e,t)}function oh(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return 111===n&&110===r&&i>=65&&i<=90&&("function"==typeof t||void 0===t)}function sh(e){return"function"==typeof e}function ah(e,t){return sh(e)?e(t):e??th}function lh(e,t){return t?e?(...n)=>{const r=n[0];if(ph(r)){const i=r;dh(i);const o=t(...n);return i.baseUIHandlerPrevented||e?.(...n),o}const i=t(...n);return e?.(...n),i}:ch(t):e}function ch(e){return e?(...t)=>{const n=t[0];return ph(n)&&dh(n),e(...t)}:e}function dh(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function uh(e,t){return t?e?t+" "+e:t:e}function ph(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}var hh,mh,gh=(hh="https://base-ui.com/production-error",mh="Base UI",function(e,...t){const n=new URL(hh);return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`${mh} error #${e}; visit ${n} for the full message.`}),fh=/* @__PURE__ */e.createContext(void 0);function yh(t={}){const{disabled:n=!1,focusableWhenDisabled:r,tabIndex:i=0,native:o=!0,composite:s}=t,a=e.useRef(null),l=function(t=!1){const n=e.useContext(fh);if(void 0===n&&!t)throw new Error(gh(16));return n}(!0),c=s??void 0!==l,{props:d}=function(t){const{focusableWhenDisabled:n,disabled:r,composite:i=!1,tabIndex:o=0,isNativeButton:s}=t,a=i&&!1!==n,l=i&&!1===n;return{props:e.useMemo(()=>{const e={onKeyDown(e){r&&n&&"Tab"!==e.key&&e.preventDefault()}};return i||(e.tabIndex=o,!s&&r&&(e.tabIndex=n?o:-1)),(s&&(n||a)||!s&&r)&&(e["aria-disabled"]=r),!s||n&&!l||(e.disabled=r),e},[i,r,n,a,l,s,o])}}({focusableWhenDisabled:r,disabled:n,composite:c,tabIndex:i,isNativeButton:o}),u=e.useCallback(()=>{const e=a.current;wh(e)&&c&&n&&void 0===d.disabled&&e.disabled&&(e.disabled=!1)},[n,d.disabled,c]);return Qp(u,[u]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:r,onKeyUp:i,onKeyDown:s,onPointerDown:a,...l}=e;return nh({onClick(e){n?e.preventDefault():t?.(e)},onMouseDown(e){n||r?.(e)},onKeyDown(e){if(n)return;if(dh(e),s?.(e),e.baseUIHandlerPrevented)return;const r=e.target===e.currentTarget,i=e.currentTarget,a=wh(i),l=!o&&(d=i,Boolean("A"===d?.tagName&&d?.href));var d;const u=r&&(o?a:!l),p="Enter"===e.key,h=" "===e.key,m=i.getAttribute("role"),g=m?.startsWith("menuitem")||"option"===m||"gridcell"===m;if(r&&c&&h){if(e.defaultPrevented&&g)return;return e.preventDefault(),void(l||o&&a?(i.click(),e.preventBaseUIHandler()):u&&(t?.(e),e.preventBaseUIHandler()))}u&&(o||!h&&!p||e.preventDefault(),!o&&p&&t?.(e))},onKeyUp(e){n||(dh(e),i?.(e),e.target===e.currentTarget&&o&&c&&wh(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||o||c||" "!==e.key||t?.(e))},onPointerDown(e){n?e.preventDefault():a?.(e)}},o?{type:"button"}:{role:"button"},d,l)},[n,d,c,o]),buttonRef:Jp(e=>{a.current=e,u()})}}function wh(e){return Wp(e)&&"BUTTON"===e.tagName}function bh(e,t,n,r){const i=Hp(vh).current;return function(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}(i,e,t,n,r)&&xh(i,[e,t,n,r]),i.callback}function vh(){return{callback:null,cleanup:null,refs:[]}}function xh(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=n){const r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const i=t[e];if(null!=i)switch(typeof i){case"function":{const t=i(n);"function"==typeof t&&(r[e]=t);break}case"object":i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const n=t[e];if(null!=n)switch(typeof n){case"function":{const t=r[e];"function"==typeof t?t():n(null);break}case"object":n.current=null}}}}}}var kh=parseInt(e.version,10);function _h(t){if(!/* @__PURE__ */e.isValidElement(t))return null;const n=t,r=n.props;return(kh>=19?r?.ref:n.ref)??null}Object.freeze([]);var Sh=Object.freeze({});function Ih(t,n,i={}){const o=n.render,s=function(e,t={}){const{className:n,style:r,render:i}=e,{state:o=Sh,ref:s,props:a,stateAttributesMapping:l,enabled:c=!0}=t,d=c?function(e,t){return"function"==typeof e?e(t):e}(n,o):void 0,u=c?function(e,t){return"function"==typeof e?e(t):e}(r,o):void 0,p=c?function(e,t){const n={};for(const r in e){const i=e[r];if(t?.hasOwnProperty(r)){const e=t[r](i);null!=e&&Object.assign(n,e);continue}!0===i?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}(o,l):Sh,h=c&&a?function(e){return Array.isArray(e)?function(e){if(0===e.length)return th;if(1===e.length)return rh(e[0]);let t=rh(e[0]);for(let n=1;n<e.length;n+=1)t=ih(t,e[n]);return t}(e):nh(void 0,e)}(a):void 0,m=c?eh(p,h)??{}:Sh;"undefined"!=typeof document&&(c?Array.isArray(s)?m.ref=function(e){const t=Hp(vh).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&xh(t,e),t.callback}([m.ref,_h(i),...s]):m.ref=bh(m.ref,_h(i),s):bh(null,null));if(!c)return Sh;void 0!==d&&(m.className=uh(m.className,d));void 0!==u&&(m.style=eh(m.style,u));return m}(n,i);return!1===i.enabled?null:function(t,n,i,o){if(n){if("function"==typeof n)return n(i,o);const t=nh(i,n.props);t.ref=i.ref;let r=n;return r?.$$typeof===Ch&&(r=e.Children.toArray(n)[0]),/* @__PURE__ */e.cloneElement(r,t)}if(t&&"string"==typeof t)return function(t,n){return"button"===t?/* @__PURE__ */r("button",{type:"button",...n,key:n.key}):"img"===t?/* @__PURE__ */r("img",{alt:"",...n,key:n.key}):/* @__PURE__ */e.createElement(t,n)}(t,i);throw new Error(gh(8))}(t,o,s,i.state??Sh)}var Ch=Symbol.for("react.lazy");var Eh=/* @__PURE__ */e.forwardRef(function(e,t){const{render:n,className:r,disabled:i=!1,focusableWhenDisabled:o=!1,nativeButton:s=!0,style:a,...l}=e,{getButtonProps:c,buttonRef:d}=yh({disabled:i,focusableWhenDisabled:o,native:s});return Ih("button",e,{state:{disabled:i},ref:[t,d],props:[l,c]})}),Ah={primary:"bg-primary text-primary-foreground border-transparent hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border-transparent hover:bg-secondary/80",ghost:"bg-transparent text-foreground border-border hover:bg-muted",bare:"bg-transparent text-inherit border-transparent hover:bg-transparent p-0 min-h-0",chip:"bg-secondary-bg text-foreground border-transparent hover:bg-primary hover:text-primary-foreground hover:border-primary",tab:"bg-transparent text-foreground-muted border-transparent hover:text-foreground hover:bg-transparent p-0 min-h-0",inline:"bg-transparent text-primary border-transparent hover:bg-transparent hover:text-primary p-0 min-h-0",toolbar:"bg-transparent text-foreground border-transparent opacity-60 hover:opacity-100"},Th={sm:"px-2 py-1 text-xs min-h-7",md:"px-4 py-2 text-sm min-h-9"},Mh={default:"rounded-lg",theme:Ap.theme,pill:Ap.pill},zh=i(function({active:e=!1,className:t,disabled:n,elevation:r,full:i,loading:o=!1,shape:s="default",size:a="md",stacked:l=!1,type:c="button",variant:d="primary",style:u,...p},h){const m=!["bare","inline","tab","toolbar"].includes(d),f=n||o;/* @__PURE__ */
8
+ return g(Eh,{...p,ref:h,className:Cp("inline-flex items-center justify-center gap-2 font-medium cursor-pointer transition-all focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2",m&&"border",Mh[s],Ah[d],"bare"!==d&&"inline"!==d&&"tab"!==d&&Th[a],l&&"flex-col gap-0.5","tab"===d&&"h-full min-w-0 flex-1",e&&"tab"===d&&"text-primary font-semibold",f&&"opacity-50 cursor-not-allowed pointer-events-none",o&&"opacity-70 cursor-wait pointer-events-none",i&&"w-full",t),"aria-busy":o?"true":void 0,"data-disabled":n?"true":"false","data-loading":o?"true":"false","data-size":a,"data-variant":d,disabled:f,style:{...Rp(r),...u},type:c})}),Oh=i(function(e,t){const{className:n,direction:r,...i}=e;/* @__PURE__ */
9
+ return g(Fp,{...i,ref:t,className:Cp("flex","column"===r&&"flex-col",n)})}),Rh={spinner:{viewBox:"0 0 512 512",paths:[{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z",fill:"currentColor"}]},checkCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z",fill:"currentColor"}]},circle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z",fill:"currentColor"}]},exclamationCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z",fill:"currentColor"}]},timesCircle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z",fill:"currentColor"}]},ban:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z",fill:"currentColor"}]},arrowUp:{viewBox:"0 0 448 512",paths:[{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z",fill:"currentColor"}]},arrowDown:{viewBox:"0 0 448 512",paths:[{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z",fill:"currentColor"}]},info:{viewBox:"0 0 24 24",paths:[{d:"M 12 2 A 10 10 0 1 1 11.9999 2 Z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 16L12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 8L12.01 8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},trash:{viewBox:"0 0 24 24",paths:[{d:"M3 6L5 6L21 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M10 11L10 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M14 11L14 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},x:{viewBox:"0 0 24 24",paths:[{d:"M18 6L6 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chatBubble:{viewBox:"0 0 512 512",paths:[{d:"M87.48 380c1.2-4.38-1.43-10.47-3.94-14.86a42.63 42.63 0 0 0-2.54-3.8 199.81 199.81 0 0 1-33-110C47.64 139.09 140.72 48 255.82 48 356.2 48 440 117.54 459.57 209.85a199 199 0 0 1 4.43 41.64c0 112.41-89.49 204.93-204.59 204.93-18.31 0-43-4.6-56.47-8.37s-26.92-8.77-30.39-10.11a31.14 31.14 0 0 0-11.13-2.07 30.7 30.7 0 0 0-12.08 2.43L81.5 462.78a15.92 15.92 0 0 1-4.66 1.22 9.61 9.61 0 0 1-9.58-9.74 15.85 15.85 0 0 1 .6-3.29z",fill:"none",stroke:"currentColor",strokeWidth:32,strokeLinecap:"round"},{d:"M160 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M256 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M352 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"}]},stop:{viewBox:"0 0 512 512",paths:[{d:"M392 432H120a40 40 0 0 1-40-40V120a40 40 0 0 1 40-40h272a40 40 0 0 1 40 40v272a40 40 0 0 1-40 40z",fill:"currentColor"}]},mousePointerClick:{viewBox:"0 0 24 24",paths:[{d:"M14 4.1 12 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m5.1 8-2.9-.8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m6 12-1.9 2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M7.2 2.2 8 5.1",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},scroll:{viewBox:"0 0 24 24",paths:[{d:"M19 17V5a2 2 0 0 0-2-2H4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},ticktick:{viewBox:"0 0 24 24",paths:[{d:"M12 0C5.383 0 0 5.383 0 12s5.383 12 12 12 12-5.383 12-12h-2.7c0 5.128-4.172 9.3-9.3 9.3-5.128 0-9.3-4.172-9.3-9.3 0-5.128 4.172-9.3 9.3-9.3V0Zm7.4 2.583-7.505 9.371L8.388 9.08l-2.002 2.436 4.741 3.888a1.573 1.573 0 0 0 2.231-.233l8.504-10.617L19.4 2.583Z",fill:"currentColor"}]},arrowRight:{viewBox:"0 0 24 24",paths:[{d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},documentText:{viewBox:"0 0 24 24",paths:[{d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},globe:{viewBox:"0 0 24 24",paths:[{d:"M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},magnifyingGlass:{viewBox:"0 0 24 24",paths:[{d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},xMark:{viewBox:"0 0 24 24",paths:[{d:"M6 18 18 6M6 6l12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},keyboard:{viewBox:"0 0 24 24",paths:[{d:"M20 7v10H4V7h16m0-2H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z",fill:"currentColor"}]},selectAll:{viewBox:"0 0 24 24",paths:[{d:"M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z",fill:"currentColor"}]},tablerArrowDown:{viewBox:"0 0 24 24",paths:[{d:"M12 5l0 14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M18 13l-6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 13l6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},fileUpload:{viewBox:"0 0 24 24",paths:[{d:"M14 3v4a1 1 0 0 0 1 1h4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 11v6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.5 13.5l2.5 -2.5l2.5 2.5",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},home:{viewBox:"0 0 24 24",paths:[{d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chat:{viewBox:"0 0 24 24",paths:[{d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},help:{viewBox:"0 0 24 24",paths:[{d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},send:{viewBox:"0 0 24 24",paths:[{d:"M5 12h14m-7-7l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},closeSmall:{viewBox:"0 0 12 12",paths:[{d:"M9 3L3 9M3 3l6 6",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},close:{viewBox:"0 0 20 20",paths:[{d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}]},chevronDown:{viewBox:"0 0 24 24",paths:[{d:"M19 9l-7 7-7-7",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round"}]},screenShare:{viewBox:"0 0 24 24",paths:[{d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},moreVertical:{viewBox:"0 0 20 20",paths:[{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z",fill:"currentColor"}]},chevronRight:{viewBox:"0 0 24 24",paths:[{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},alertCircle:{viewBox:"0 0 24 24",paths:[{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]}},Ph=i(function({name:e,size:t=16,className:n,...r},i){const o=Rh[e];return o?/* @__PURE__ */g("svg",{...r,ref:i,"aria-hidden":"true",className:Cp("inline-block flex-shrink-0",n),fill:"none",height:t,viewBox:o.viewBox,width:t,xmlns:"http://www.w3.org/2000/svg",children:o.paths.map((e,t)=>/* @__PURE__ */g("path",{clipRule:e.clipRule,d:e.d,fill:e.fill??(e.stroke?"none":"currentColor"),fillRule:e.fillRule,stroke:e.stroke,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,strokeMiterlimit:e.strokeMiterlimit,strokeWidth:e.strokeWidth},t))}):null}),Nh={primary:"bg-primary text-primary-foreground hover:bg-primary-hover",secondary:"bg-secondary-bg text-foreground hover:bg-secondary-hover",ghost:"bg-transparent text-foreground opacity-60 hover:opacity-100",toolbar:"bg-transparent text-foreground opacity-60 hover:opacity-100"},Lh={xs:"w-5 h-5 min-w-5",sm:"w-7 h-7 min-w-7"},Dh={circle:Ap.circle,theme:Ap.theme},jh=i(function({variant:e="ghost",size:t="sm",shape:n="circle",tone:r,label:i,disabled:o,elevation:s,className:a,children:l,style:c,...d},u){/* @__PURE__ */
10
+ return g("button",{...d,ref:u,type:"button",disabled:o,"aria-label":i,className:Cp("inline-flex items-center justify-center flex-shrink-0 border-none cursor-pointer transition-all",Dh[n],Nh[e],r&&Tp[r],Lh[t],o&&"opacity-50 cursor-not-allowed pointer-events-none",a),style:{...Rp(s),...c},children:l})}),$h=i(function(e,t){const{background:n="default",className:r,elevation:i,paddingPreset:o="none",radius:s,style:a,...l}=e,c=Lp(e);/* @__PURE__ */
11
+ return g("div",{...Dp(l),ref:t,className:Cp("flex flex-col",jp[n],$p[o],s&&Lp({rounded:s}),c,r),style:{...Rp(i),...a}})}),Fh={xxs:"text-[10px]",xs:"text-xs",sm:"text-sm",base:"text-base",lg:"text-lg"},Bh={normal:"font-normal",medium:"font-medium",semibold:"font-semibold"},Uh={center:"text-center",right:"text-right"},Gh=i(function({as:e="span",block:t=!1,clamp:n,code:r=!1,inheritColor:i=!1,italic:o=!1,leading:s,tone:a,variant:l="default",size:c,weight:d,truncate:u,align:p,className:h,style:m,...f},y){/* @__PURE__ */
12
+ return g(e,{...f,ref:y,className:Cp(Tp[i?"inherit":a??{default:"default",muted:"muted",faint:"faint"}[l]],c&&Fh[c],d&&Bh[d],p&&Uh[p],s&&Mp[s],t&&"block",r&&"font-mono",o&&"italic",u&&"truncate",h),style:n?{...m,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:n,overflow:"hidden"}:m})});function Wh(e){return"above-fab"===e?{bottom:"90px",left:"50%",transform:"translateX(-50%)"}:{bottom:"20px",left:"50%",transform:"translateX(-50%)"}}var Zh=({tone:e,title:t,body:n,onDismiss:r,onRetry:i,position:s="bottom-center"})=>{const[l,c]=p(!1),d=o(()=>{c(!0),setTimeout(r,300)},[r]);a(()=>{if("info"!==e)return;const t=setTimeout(d,8e3);return()=>clearTimeout(t)},[e,d]);const u=Op[e];/* @__PURE__ */
13
+ return g(Fp,{position:"fixed",style:{zIndex:b,maxWidth:"420px",opacity:l?0:1,transition:"opacity 0.3s ease-out",animation:l?"none":"fadeIn 0.3s ease-out",...Wh(s)},children:/* @__PURE__ */f(Oh,{align:"center",gap:"md",rounded:"pill",paddingPreset:"toast",elevation:"panel",style:{backgroundColor:u.background,border:u.border},children:[
14
+ /* @__PURE__ */g(Gp,{src:Bp,alt:"",size:28,rounded:"full"}),
15
+ /* @__PURE__ */f($h,{grow:!0,minWidth:"0",children:[/* @__PURE__ */g(Gh,{as:"span",block:!0,inheritColor:!0,weight:"medium",style:{fontSize:"13px",color:u.titleColor,whiteSpace:i?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),n&&/* @__PURE__ */g(Gh,{as:"span",block:!0,inheritColor:!0,style:{fontSize:"12px",color:u.bodyColor,opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]}),i&&/* @__PURE__ */g(zh,{type:"button",variant:"ghost",shape:"pill",size:"sm",onClick:()=>{i(),d()},style:{color:u.titleColor,backgroundColor:u.actionBackground,border:u.border},"aria-label":"Retry",children:"Retry"}),
16
+ /* @__PURE__ */g(jh,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},shape:"circle",size:"xs",tone:"inherit",style:{color:u.closeColor,padding:"2px"},children:/* @__PURE__ */g(Ph,{name:"closeSmall",size:12})})]})})},Vh=20,Hh=(e,t,n,r,i)=>{switch(e){case"top_left":return{x:Vh,y:Vh};case"top_right":return{x:t-Vh-r,y:Vh};case"bottom_left":return{x:Vh,y:n-Vh-i};default:return{x:t-Vh-r,y:n-Vh-i}}},Yh=(e,t,n,r,i,o)=>{const s=Hh(e,n,r,i,o),a=s.x+i/2,l=s.y+o/2;let c,d;switch(t){case"top_left":c=Vh+i/2,d=Vh+o/2;break;case"top_right":c=n-Vh-i/2,d=Vh+o/2;break;case"bottom_left":c=Vh+i/2,d=r-Vh-o/2;break;default:c=n-Vh-i/2,d=r-Vh-o/2}return{dx:c-a,dy:d-l}},qh="cubic-bezier(0.16, 1, 0.3, 1)";function Jh({position:e,onDrag:n,isPreviewMode:r=!1,wrapperRef:i}){const[s,a]=p(!1),[l,d]=p({w:56,h:56}),[,h]=p(0),m=u(null),g=u(null),f=u(null),y=u(0),w=u([]),b=u(0);t.useEffect(()=>()=>{null!==f.current&&window.cancelAnimationFrame(f.current)},[]),t.useEffect(()=>{if(r)return;const e=()=>h(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const v=o(()=>{if(!i.current||"undefined"==typeof window)return;const e=i.current.getBoundingClientRect();d(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[i]);c(()=>{v();const e="undefined"!=typeof window&&i.current?new ResizeObserver(v):null;return e&&i.current&&e.observe(i.current),()=>e?.disconnect()},[v,e,i]);const x="undefined"!=typeof window?window.innerWidth:0,k="undefined"!=typeof window?window.innerHeight:0,_=Hh(e,x,k,l.w,l.h),S=!r&&x>0&&k>0?{left:_.x,top:_.y}:void 0,I=(e,t=.999)=>e/1e3*t/(1-t),C=()=>{null!==f.current&&(window.cancelAnimationFrame(f.current),f.current=null),i.current&&(i.current.style.transform="",i.current.style.willChange="",i.current.style.transition="")},E=o((e,t)=>{if(m.current)return;let r=!1;const o=()=>{r||(r=!0,m.current=null,t.style.transition="none",t.style.willChange="",n(e),a(!1),requestAnimationFrame(()=>{i.current&&(i.current.style.transition="")}))};m.current=o;const s=window.setTimeout(o,650);t.addEventListener("transitionend",function e(n){n.target===t&&"left"===n.propertyName&&(window.clearTimeout(s),t.removeEventListener("transitionend",e),o())})},[n,i]),A=o((t,r,o)=>{if(!i.current||!S)return C(),n(t),void a(!1);null!==f.current&&(window.cancelAnimationFrame(f.current),f.current=null);const s=i.current,c=Hh(e,x,k,l.w,l.h),d=Hh(t,x,k,l.w,l.h);s.style.transition="none",s.style.transform="none",s.style.willChange="left, top",s.style.left=`${c.x+r}px`,s.style.top=`${c.y+o}px`,requestAnimationFrame(()=>{s.style.transition=`left 600ms ${qh}, top 600ms ${qh}`,s.style.left=`${d.x}px`,s.style.top=`${d.y}px`}),E(t,s)},[E,n,S,e,x,k,l.w,l.h,i]);return{isDragging:s,pixelPositionStyle:S,onPointerDown:e=>{g.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,dragging:!1,lastX:0,lastY:0},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{const t=g.current;if(t?.pointerId!==e.pointerId)return;const n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.dragging&&Math.hypot(n,r)>5&&(t.dragging=!0,a(!0),w.current=[],b.current=0,i.current&&(i.current.style.willChange="transform",i.current.style.transition="none")),!t.dragging)return;t.lastX=n,t.lastY=r;const o=Date.now();o-b.current>=10&&(b.current=o,w.current=[...w.current.slice(-5),{x:e.clientX,y:e.clientY,t:o}]),null===f.current&&(f.current=window.requestAnimationFrame(()=>{f.current=null;const e=g.current,t=i.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:t=>{const n=g.current;if(n?.pointerId===t.pointerId){if(n.dragging){const r=(()=>{const e=w.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),o=I(r.x),s=I(r.y),a={dx:n.lastX+o,dy:n.lastY+s};let l;if("undefined"!=typeof window&&i.current){const t=i.current.getBoundingClientRect();l=((e,t,n,r,i,o)=>{const s=["top_left","top_right","bottom_left","bottom_right"];let a=t,l=1/0;for(const c of s){const s=Yh(t,c,n,r,i,o),d=Math.hypot(e.dx-s.dx,e.dy-s.dy);d<l&&(l=d,a=c)}return a})(a,e,window.innerWidth,window.innerHeight,t.width,t.height)}else l=e;return A(l,n.lastX,n.lastY),y.current=Date.now()+600,g.current=null,void t.currentTarget.releasePointerCapture(t.pointerId)}C(),g.current=null,a(!1),t.currentTarget.releasePointerCapture(t.pointerId)}},onPointerCancel:e=>{g.current?.pointerId===e.pointerId&&(C(),g.current=null,a(!1),e.currentTarget.releasePointerCapture(e.pointerId))},suppressUntilRef:y}}var Kh=({open:e,processing:t=!1,error:n=!1,taskRunning:r=!1,onClick:i,onStop:o,accentColor:s,backgroundColor:a,borderRadius:l="12px",tooltipBgColor:c,tooltipTextColor:d,zIndex:p=50,position:h,onDrag:m,isPreviewMode:y=!1})=>{const w=!e&&(t||r),b=!e&&r&&null!=o,v=n?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",x=n?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",k=Math.max(6,Math.min(22,Number.parseFloat(l)||12)),_=u(null),{isDragging:S,pixelPositionStyle:I,onPointerDown:C,onPointerMove:E,onPointerUp:A,onPointerCancel:T,suppressUntilRef:M}=Jh({position:h,onDrag:m,isPreviewMode:y,wrapperRef:_}),z=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(h),O=y?"absolute":"fixed",R=y?h.includes("top")?{top:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{};/* @__PURE__ */
17
+ return f(Fp,{ref:_,className:`${O} ${I?"":z} ${S?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:p,pointerEvents:e?"none":"auto",...R,...I},children:[/* @__PURE__ */f(Fp,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[w&&/* @__PURE__ */g(Fp,{className:v,"aria-hidden":!0}),b&&!S&&/* @__PURE__ */g(zh,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(h.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop running task",children:"Stop"}),
18
+ /* @__PURE__ */g(zh,{type:"button",variant:"bare",onClick:()=>{Date.now()<M.current||i()},onDragStart:e=>e.preventDefault(),onPointerDown:C,onPointerMove:E,onPointerUp:A,onPointerCancel:T,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:S?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */g(Oh,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */f(Fp,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:l,backgroundColor:e?a:s,boxShadow:Ep.fab},children:[w&&/* @__PURE__ */g("svg",{className:x,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */g("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:k+1,ry:k+1})}),
19
+ /* @__PURE__ */g(Oh,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(30deg) scale(0)":"rotate(0deg) scale(1)",opacity:e?0:1,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":e,children:/* @__PURE__ */g(Gp,{src:Bp,alt:"",className:"relative z-10 w-full h-full object-contain",draggable:!1,onDragStart:e=>e.preventDefault(),style:{borderRadius:l,border:"none",outline:"none",backgroundColor:"transparent",pointerEvents:"none",userSelect:"none"}})}),
20
+ /* @__PURE__ */g(Oh,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */g(Ph,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */f(Fp,{className:`absolute bottom-16 ${h.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:c,color:d},children:[/* @__PURE__ */g(Gh,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */g(Fp,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:c}})]})]})},Xh="3.3.235";function Qh(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function em(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function tm(e,t,n){return Math.min(Math.max(e,t),n)}function nm(e,t,n,r,i){const o={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:i-n,cursor:o[e]};case"bottom-left":return{dx:t-r,dy:i-n,cursor:o[e]};case"top-right":return{dx:r-t,dy:n-i,cursor:o[e]};case"top-left":return{dx:t-r,dy:n-i,cursor:o[e]}}}var rm={count:"inline-flex items-center rounded-full bg-muted px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground",live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},im={default:"bg-muted text-muted-foreground",muted:"bg-muted text-muted-foreground",primary:"bg-chart-1/15 text-chart-1",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning"},om=i(function({variant:e,color:t,tone:n="default",className:r,style:i,children:o,...s},a){/* @__PURE__ */
21
+ return f("span",{...s,ref:a,className:Cp(rm[e],"status"===e&&im[n],r),"data-variant":e,style:{color:t,...i},children:["live"===e&&/* @__PURE__ */f("span",{className:"relative flex h-1.5 w-1.5",children:[/* @__PURE__ */g("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */g("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),o]})}),sm=i(function({background:e="card",border:t=!0,children:n,className:r,elevation:i="card",paddingPreset:o="card",radius:s="xl",style:a,...l},c){/* @__PURE__ */
22
+ return g(Fp,{...l,ref:c,as:"div",background:e,border:t,className:r,elevation:i,paddingPreset:o,radius:s,style:a,children:n})});var am=n(null);function lm(e){const t=s(am);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function cm({children:e,defaultOpen:t,onOpenChange:n,open:r}){const{isOpen:i,setIsOpen:s}=function({defaultOpen:e=!1,onOpenChange:t,open:n}){const[r,i]=p(e),s=void 0!==n;return{isOpen:s?n:r,setIsOpen:o(e=>{s||i(e),t?.(e)},[s,t])}}({defaultOpen:t,onOpenChange:n,open:r}),a=l(),c=l(),u=l(),h=d(()=>({contentId:a,descriptionId:u,open:i,setOpen:s,titleId:c}),[a,u,i,s,c]);/* @__PURE__ */
23
+ return g(am.Provider,{value:h,children:e})}function dm({children:e,className:t,onKeyDown:n,...r}){const i=lm("DialogContent"),{variant:o="default",style:s,...l}=r;return a(()=>{if(!i.open)return;const e=e=>{"Escape"===e.key&&i.setOpen(!1)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[i]),i.open?/* @__PURE__ */g("div",{...l,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"aria-modal":"true",className:Cp("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[calc(var(--layer-dialog)+1)] flex flex-col w-full max-h-[85vh] overflow-auto bg-card animate-dialog-content-in","default"===o&&"max-w-[500px] rounded-lg p-6","confirm"===o&&"max-w-sm rounded-lg p-4","info"===o&&"w-64 rounded-md border border-border p-0",t),"data-state":"open",id:i.contentId,onKeyDown:e=>{n?.(e),e.defaultPrevented||"Escape"!==e.key||i.setOpen(!1)},role:"dialog",style:{...Rp("info"===o?"section":"panel"),...s},tabIndex:-1,children:e}):null}function um({className:e,variant:t="default",...n}){const r=lm("DialogTitle");/* @__PURE__ */
24
+ return g("h2",{...n,className:Cp("default"===t&&"text-lg font-semibold text-card-foreground mb-2","confirm"===t&&"text-base font-semibold text-foreground mb-1","info"===t&&"text-xs font-semibold text-foreground flex-1 text-center mb-0",e),id:r.titleId})}function pm({className:e,variant:t="default",...n}){const r=lm("DialogDescription");/* @__PURE__ */
25
+ return g("p",{...n,className:Cp("default"===t&&"text-sm text-muted-foreground mb-4","confirm"===t&&"text-sm text-muted-foreground mb-4 leading-relaxed",e),id:r.descriptionId})}function hm({children:e,className:t,onClick:n,variant:r="default",...i}){const o=lm("DialogClose");/* @__PURE__ */
26
+ return g("button",{...i,className:Cp("default"===r&&"absolute top-4 right-4 flex items-center justify-center w-8 h-8 p-0 bg-transparent border-none rounded-lg text-muted-foreground cursor-pointer transition-colors hover:bg-muted","info"===r&&"static -mr-1 flex h-5 w-5 items-center justify-center rounded-full border-none bg-transparent p-0 text-muted-foreground transition-colors hover:text-foreground",t),onClick:e=>{n?.(e),e.defaultPrevented||o.setOpen(!1)},type:"button",children:e})}var mm=()=>/* @__PURE__ */g("span",{className:"block h-0.5 w-full rounded-full bg-primary"}),gm=(n(null),{sm:"px-2 py-0.5 text-[11px] gap-0.5"}),fm=i(function({active:e=!1,variant:t="primary",size:n="sm",children:r,...i},o){/* @__PURE__ */
27
+ return g("button",{...i,ref:o,type:"button",className:Cp("inline-flex items-center font-medium border-none cursor-pointer transition-all duration-200",Ap.pill,gm[n],e&&"primary"===t&&"bg-primary text-primary-foreground shadow-sm",!e&&"bg-secondary-bg text-foreground-muted"),children:r})}),ym={sm:"h-3.5 w-3.5 border-[1.5px]",md:"h-5 w-5 border-2",lg:"h-6 w-6 border-2"},wm=i(function({label:e,size:t="md",className:n,style:r},i){/* @__PURE__ */
28
+ return f("div",{ref:i,className:Cp("inline-flex items-center gap-1.5",n),"data-size":t,role:"status",style:r,children:[
29
+ /* @__PURE__ */g("div",{"aria-hidden":"true",className:Cp("animate-spin rounded-full border-current border-t-transparent flex-shrink-0",ym[t])}),null!=e&&/* @__PURE__ */g("span",{children:e}),
30
+ /* @__PURE__ */g("span",{className:"sr-only",children:"Loading"})]})}),bm={default:"block w-full px-3 py-2 text-sm leading-normal text-foreground bg-background border border-input rounded-lg transition-colors min-h-20 resize-y hover:border-muted-foreground focus:outline-none focus:border-ring focus:ring-3 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-muted",chat:"block w-full px-3 text-sm text-foreground placeholder:text-foreground-faint bg-transparent border-none rounded-none transition-colors min-h-0 resize-none focus:outline-none focus:ring-0 disabled:opacity-50 disabled:cursor-not-allowed"},vm=i(function({className:e,errorMessage:t,id:n,validationState:r="default",variant:i="default",...o},s){const a="invalid"===r&&t?`${n??o["aria-label"]??"textarea"}-error`:void 0;/* @__PURE__ */
31
+ return f(m,{children:[/* @__PURE__ */g("textarea",{...o,"aria-describedby":a,"aria-invalid":"invalid"===r?"true":void 0,className:Cp(bm[i],e),"data-validation-state":r,id:n,ref:s}),null!=a&&/* @__PURE__ */g("span",{id:a,children:t})]})}),xm=i(function({className:e,...t},n){/* @__PURE__ */
32
+ return g("video",{...t,ref:n,className:Cp(e)})}),km=({title:e,subtitle:t,minimized:n=!1,onClose:r,controls:i})=>/* @__PURE__ */f(Oh,n?{align:"center",justify:"between",paddingX:"lg",border:"bottom",shrink:!1,style:zp.header,children:[/* @__PURE__ */g(Gh,{size:"sm",weight:"medium",children:e}),/* @__PURE__ */g(jh,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */g(Ph,{name:"close",size:16})})]}:{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */f(Oh,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */g(Gp,{src:Bp,alt:"",size:"md",rounded:"theme",elevation:"card"}),/* @__PURE__ */f($h,{minWidth:"0",children:[/* @__PURE__ */g(Gh,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */g(Gh,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */f(Oh,{align:"center",gap:"xs",shrink:!1,children:[i,/* @__PURE__ */g(jh,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */g(Ph,{name:"close",size:16})})]})]}),_m={green:"success",blue:"primary",yellow:"warning",gray:"muted"},Sm=({variant:e,open:t,onClose:n,title:r,description:i,onConfirm:o,confirmLabel:s="Confirm",cancelLabel:a="Cancel",rows:l=[],status:c})=>/* @__PURE__ */g(cm,{open:t,onOpenChange:e=>{e||n()},children:/* @__PURE__ */f(dm,"confirm"===e?{variant:"confirm",children:[
33
+ /* @__PURE__ */g(um,{variant:"confirm",children:r}),null!=i&&/* @__PURE__ */g(pm,{variant:"confirm",children:i}),
34
+ /* @__PURE__ */f(Oh,{gap:"md",justify:"end",children:[/* @__PURE__ */g(zh,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:a}),/* @__PURE__ */g(zh,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:s})]})]}:{variant:"info",children:[/* @__PURE__ */f(Oh,{align:"center",justify:"between",paddingX:"lg",paddingY:"sm",border:"bottom",children:[/* @__PURE__ */g(um,{variant:"info",children:r}),/* @__PURE__ */g(hm,{variant:"info","aria-label":"Close",children:/* @__PURE__ */g(Ph,{name:"x",size:12})})]}),/* @__PURE__ */f($h,{paddingX:"lg",paddingY:"sm",children:[l.map(e=>/* @__PURE__ */f(Oh,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */g(Gh,{as:"span",size:"xs",variant:"muted",children:e.label}),/* @__PURE__ */f(Oh,{align:"center",gap:"2xs",children:[/* @__PURE__ */g(Gh,{as:"code",code:!0,size:"xs",variant:"muted",truncate:!0,style:{maxWidth:"120px"},children:e.value||"N/A"}),!0===e.copyable&&e.value&&/* @__PURE__ */g(zh,{type:"button",variant:"inline",size:"sm",onClick:()=>{return t=e.value,void navigator.clipboard.writeText(t);var t},children:"Copy"})]})]},e.label)),null!=c&&/* @__PURE__ */f(Oh,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */g(Gh,{as:"span",size:"xs",variant:"muted",children:"Status"}),/* @__PURE__ */g(om,{variant:"status",tone:_m[c.color],children:c.label})]})]})]})});function Im(e){return"registered"===e?"green":"connected"===e?"blue":"connecting"===e?"yellow":"gray"}var Cm=({isOpen:e,onClose:t,diagnosticData:n})=>{const r=[{label:"Chat ID",value:n.chatId??"N/A",copyable:!!n.chatId},{label:"Stream Endpoint",value:n.streamEndpoint??"N/A",copyable:!!n.streamEndpoint},{label:"Application ID",value:n.applicationId?.toString()??"N/A",copyable:!!n.applicationId},{label:"Agent ID",value:n.agentId?.toString()??"N/A",copyable:!!n.agentId}],i={label:n.connectionStatus,color:Im(n.connectionStatus)},o="dev"===n.build?"dev":n.build.slice(0,7);/* @__PURE__ */
35
+ return g(Sm,{variant:"info",open:e,onClose:t,title:`Widget v${n.version} (${o})`,rows:r,status:i})};function Em({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:n,onAddMessage:r,onUpdateMessage:i,onRemoveMessage:o,onSendMessage:s,pendingMessage:l,setPendingMessage:c}){const[d,h]=p(!1),[m,g]=p(null),[f,y]=p(null),[w,b]=p(null),[v,x]=p(!1),k=u(d),_=u(f),S=u(r),I=u(o),C=u(e);a(()=>{k.current=d},[d]),a(()=>{_.current=f},[f]),a(()=>{S.current=r},[r]),a(()=>{I.current=o},[o]),a(()=>{C.current=e},[e]),a(()=>{const e=()=>{const e=Kd(),t=k.current,n=_.current;if(e!==t&&(k.current=e,h(e),C.current?.(e)),t&&!e&&n){I.current?.(n);const e=Ld("Stopped screenshare","show","user","stopped-sharing");S.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const E=()=>{x(!0)},A=()=>{qd&&(qd.getTracks().forEach(e=>e.stop()),qd=null),h(!1),g(null),e?.(!1),f&&o&&o(f),r(Ld("Stopped screenshare","show","user","stopped-sharing")),y(null)};return a(()=>(t&&(t.current=E),n&&(n.current=A),()=>{t&&(t.current=null),n&&(n.current=null)})),{isScreenSharing:d,screenStream:m,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await Jd();h(!0),g(t),e?.(!0),r(Dd("show"));const n=jd(t,"show");y(n.id),r(n)}catch(t){h(!1),g(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await Jd();h(!0),g(t),e?.(!0),w&&(i(w,{screenShareStatus:"allowed"}),b(null)),r(Dd("show"));const n=jd(t,"show");if(y(n.id),r(n),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(h(!1),g(null),e?.(!1),w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(w)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);b(t.id),r(t)}}}function Am(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var Tm=t.forwardRef(function({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:i,onModeChange:s,disabled:l=!1,taskRunning:c=!1,onStop:d,placeholder:p="Ask anything"},h){const m=u(null);a(()=>{const e=m.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,66);e.style.height=`${n}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=o(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,66);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>66?"auto":"hidden"},[t]),w=o(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),b=Boolean(e.trim())&&!l;/* @__PURE__ */
36
+ return f($h,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"focus-within:border-foreground-faint transition-colors",children:[/* @__PURE__ */g(vm,{ref:Am(m,h),value:e,onChange:y,onKeyDown:w,placeholder:p,disabled:l,rows:1,variant:"chat",style:{lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */f(Oh,{align:"center",justify:"between",paddingX:"sm",paddingTop:"2xs",paddingBottom:"sm",children:[/* @__PURE__ */g(Oh,{align:"center",gap:"2xs",children:r.map(e=>/* @__PURE__ */f(fm,{active:i===e.id,size:"sm",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */g(Ph,{name:e.icon,size:12}),/* @__PURE__ */g(Gh,{as:"span",inheritColor:!0,children:e.label})]},e.id))}),/* @__PURE__ */g(jh,{variant:c?"secondary":"primary",size:"sm",disabled:!c&&!b,label:c?"Stop task":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),c&&d?d():n()},children:/* @__PURE__ */g(Ph,c?{name:"stop",size:14}:{name:"send",size:16})})]})]})}),Mm=({variant:e,message:t})=>{const n="error"===e,r="loading"===e;/* @__PURE__ */
37
+ return f($h,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:r?"status":void 0,"aria-live":n?"assertive":"polite",style:n?{color:"var(--color-red-600, #dc2626)"}:void 0,children:[r&&/* @__PURE__ */g(wm,{size:"lg"}),/* @__PURE__ */g(Gh,{as:"p",size:"sm",align:"center",children:t})]})},zm=({content:e,status:t,hideIcon:n=!1,textStyle:r="default"})=>{const{config:i}=ou(),o=i.widget_accent_color;/* @__PURE__ */
38
+ return f(Oh,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return g(Ph,{name:"checkCircle",style:{color:o,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return g(Ph,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"stopped":/* @__PURE__ */return g(Ph,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});default:/* @__PURE__ */return g(wm,{size:"sm",style:{color:o,marginTop:"2px"}})}})(),/* @__PURE__ */g(Gh,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===r?.5:1},children:e})]})},Om=({isWaitingForUser:e})=>/* @__PURE__ */f(Oh,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */g(wm,{size:"sm"}),/* @__PURE__ */g(Gh,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Rm=({message:e,isLastMessage:t})=>{const{state:n}=ou(),r="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */f($h,{gap:"sm",children:[e.parts.map((t,n)=>{if("text"===t.type){let e=(r=t.content,r.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */g(Gh,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${n}`):null}return"progress"===t.type?"done"===t.toolName&&"done"===e.taskStatus?null:/* @__PURE__ */g(zm,{content:t.content,status:t.status||"in_progress",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */g(Om,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */g(Om,{isWaitingForUser:r}):e.content?/* @__PURE__ */g(Gh,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */g(Fp,{})},Pm=({status:e})=>{const{config:t}=ou(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return g(Ph,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return g(Ph,{name:"exclamationCircle",style:{color:k(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return g(Ph,{name:"circle",style:{color:k(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return g(wm,{size:"sm",style:{color:n}})}},Nm="8px 8px 0 0",Lm="#111827",Dm="rgba(255,255,255,0.7)",jm=({stream:e})=>{const t=u(null),n=u(null),[r,i]=p(!1),[o,s]=p(!1);return a(()=>{if(t.current&&e){const r=t.current;i(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const o=()=>{i(!0)},a=()=>{s(!0),i(!1)};r.addEventListener("loadedmetadata",o),r.addEventListener("error",a);const l=r.play();return n.current=l,l.then(()=>{i(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",o),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),i(!1),s(!1)}},[e]),e?/* @__PURE__ */f(Fp,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:Nm,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!r&&!o&&/* @__PURE__ */g(Oh,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Lm,borderRadius:Nm,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */f(Oh,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */g(wm,{size:"lg",style:{color:"white"}}),/* @__PURE__ */g(Gh,{as:"span",size:"xs",weight:"medium",style:{color:Dm},children:"Loading stream..."})]})}),o&&/* @__PURE__ */g(Oh,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Lm,borderRadius:Nm,zIndex:10},children:/* @__PURE__ */f(Oh,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */g(Ph,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */g(Gh,{as:"span",size:"xs",weight:"medium",style:{color:Dm},children:"Failed to load stream"})]})}),
39
+ /* @__PURE__ */g(xm,{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:Nm,transition:"opacity 500ms",opacity:r?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),r&&!o&&/* @__PURE__ */f(Oh,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */f(Oh,{position:"relative",align:"center",justify:"center",children:[/* @__PURE__ */g(Fp,{position:"absolute",rounded:"full",animate:"ping",style:{width:"8px",height:"8px",backgroundColor:"white",opacity:.75}}),/* @__PURE__ */g(Fp,{position:"relative",rounded:"full",style:{width:"6px",height:"6px",backgroundColor:"white"}})]}),/* @__PURE__ */g(Gh,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
40
+ /* @__PURE__ */g(Oh,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:Nm,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */g(Fp,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */g(Gh,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]}):null},$m=({message:e,index:t,isLastMessage:n,onScreenAccessAllow:r,onScreenAccessDeny:i})=>{if(e.isSystemMessage)/* @__PURE__ */return g(Oh,{justify:"center",align:"center",children:/* @__PURE__ */g(Gh,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})},`message-${e.id}-${t}`);const o="user"===e.sender;/* @__PURE__ */
41
+ return f($h,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":o?"You said…":"Agent says…",animate:n?"fadeIn":void 0,children:[/* @__PURE__ */f(Oh,{align:"start",gap:"sm",width:"full",children:[
42
+ /* @__PURE__ */g(Oh,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!o&&/* @__PURE__ */g(Gp,{src:"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",alt:"Marketrix AI",size:20,fit:"cover",rounded:"theme",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
43
+ /* @__PURE__ */f($h,{grow:!0,position:"relative",rounded:"theme",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:o?"var(--primary)":void 0,color:o?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */g(jm,{stream:e.videoStream}),!e.videoStream&&/* @__PURE__ */g(Rm,{message:e,isLastMessage:n}),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */f(Oh,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */g(zh,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */g(zh,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>i?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */g(Gh,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"Check HTML Instead"}),!o&&e.taskStatus&&/* @__PURE__ */g(Oh,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */g(Pm,{status:e.taskStatus})})]}),
44
+ /* @__PURE__ */g(Oh,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */g(Gh,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:S(e.timestamp)})]},`message-${e.id}-${t}`)},Fm={boxShadow:Ep.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Bm=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:i,onClearChat:o})=>{const{config:s,state:l,isPreviewMode:c}=ou({config:n}),[h,m]=p(!1),[y,w]=p(!1),b=u(null),v=d(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=d(()=>[v,...e],[v,e]),_=()=>{if(b.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=b.current;m(e>200),w(!(Math.abs(t-e-n)<50)&&t>n)}};return a(()=>{window.requestAnimationFrame(()=>{t.current&&(!c&&t.current.scrollIntoView({behavior:"auto"}),!c&&_())})},[e.length,c]),/* @__PURE__ */f(Fp,{position:"relative",height:"full",children:[
45
+ /* @__PURE__ */f(Fp,{ref:b,onScroll:_,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:s.widget_background_color.includes("gradient")?"transparent":s.widget_background_color,backgroundImage:s.widget_background_color.includes("gradient")?s.widget_background_color:`linear-gradient(135deg, ${s.widget_background_color} 0%, ${s.widget_background_color} 100%)`,scrollbarColor:`${k(s.widget_border_color,.3)} ${k(s.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&l.isLoading&&/* @__PURE__ */g(Mm,{variant:"loading",message:"Connecting…"}),x.map((e,t)=>/* @__PURE__ */g($m,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:r,onScreenAccessDeny:i},`message-${e.id}-${t}`)),e.length>0&&o&&/* @__PURE__ */g(Oh,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */g(zh,{type:"button",variant:"bare",onClick:()=>{const e=o();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */g(Gh,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
46
+ /* @__PURE__ */g(Fp,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */g(Oh,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */g(jh,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{b.current?.scrollTo({top:0,behavior:"smooth"})},style:Fm,children:/* @__PURE__ */g(Ph,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */g(Oh,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */g(jh,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!c&&t.current.scrollIntoView({behavior:"smooth"})},style:Fm,children:/* @__PURE__ */g(Ph,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},Um=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */g(Gh,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},Gm={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Wm=["tell","show","do"];var Zm=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,taskProgress:i=[],onSendMessage:o,onSetMode:s,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onStopTask:d,onClearChat:h,onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,messageInputRef:b})=>{const[v,x]=p(""),_=u(null),[S,C]=p(null),{isScreenSharing:E,showScreenAccessDialog:A,handleScreenAccessDialogAllow:T,handleScreenAccessDialogDeny:M,handleScreenAccessAllow:z,handleScreenAccessDeny:O,requestScreenAccess:R}=Em({onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onSendMessage:o,pendingMessage:S,setPendingMessage:C}),P=e;/* @__PURE__ */
47
+ return f($h,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[A&&/* @__PURE__ */g(Sm,{variant:"confirm",open:A,onClose:M,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:T,confirmLabel:"Yes",cancelLabel:"No"}),
48
+ /* @__PURE__ */g(Fp,{grow:!0,overflow:"hidden",paddingY:"xs",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(Um,{children:/* @__PURE__ */g(Bm,{messages:t,messagesEndRef:_,config:e,onScreenAccessAllow:z,onScreenAccessDeny:O,onClearChat:h})})}),
49
+ /* @__PURE__ */f(sm,{style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:[r&&i.length>0&&/* @__PURE__ */f(Fp,{rounded:!0,overflowY:"auto",style:{margin:"0 8px 8px",padding:"8px",maxHeight:"128px",backgroundColor:k(e.widget_background_color??"#fff",.8),borderColor:e.widget_border_color,borderWidth:"1px",borderStyle:"solid"},children:[/* @__PURE__ */f(Gh,{as:"div",weight:"semibold",style:{marginBottom:"4px",color:e.widget_text_color},children:["Task Progress (",i.length," steps)"]}),/* @__PURE__ */g($h,{gap:"xs",children:i.map((t,n)=>/* @__PURE__ */f(Oh,{align:"start",gap:"sm",style:{fontSize:"12px",opacity:.8,color:e.widget_text_color},children:[
50
+ /* @__PURE__ */f(Gh,{as:"span",weight:"medium",children:["Step ",t.step,":"]})," ",t.tool_name,t.tool_params&&Object.keys(t.tool_params).length>0&&/* @__PURE__ */f(Gh,{as:"span",style:{opacity:.7,marginLeft:"4px"},children:["(",Object.keys(t.tool_params).join(", "),")"]})]},n))})]}),/* @__PURE__ */g(Tm,{ref:b,value:v,onChange:x,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(v.trim()&&!r){const t=v.trim();x(""),a(Pd(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||E?o(t,n,void 0,void 0,!0):(C({content:t,mode:n,alreadyAdded:!0}),R(n))}},modes:Wm.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(P).includes(e)).map(e=>({id:e,icon:Gm[e],label:I(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(a(Ld(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),s(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{Xd.cleanup(),d?.()}})]})]})},Vm=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */g(Ph,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */g(Ph,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */g(Ph,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */g(Ph,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */g(Ph,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Hm(e){switch(e){case"do":/* @__PURE__ */return g(Ph,{name:"ticktick",size:12});case"show":/* @__PURE__ */return g(Ph,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return g(Ph,{name:"chatBubble",size:12})}}var Ym=({actions:e,onActionClick:t})=>{const{config:n}=ou();return 0===e.length?null:/* @__PURE__ */g($h,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */g(zh,{elevation:"card",shape:"theme",size:"sm",variant:"chip",full:!0,onClick:n=>t(e,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */g(Gh,{as:"span",weight:"normal",leading:"tight",children:"show"===e.type?/* @__PURE__ */f(m,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */f(m,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},qm=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const i=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text,i=t.chip_mode,o=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let s=o,a=0;for(;e.has(s);)a++,s=`${o}-${a}`;return e.add(s),{id:s,text:r,icon:Hm(i),type:i,isShow:"show"===i}})}return Vm}(e);/* @__PURE__ */
51
+ return f($h,{height:"full",overflow:"hidden",id:"view-home",role:"tabpanel","aria-labelledby":"tab-home",children:[/* @__PURE__ */f($h,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */f(Fp,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */g(Gh,{as:"h2",size:"lg",weight:"semibold",children:e.widget_greeting??"Hey There!"}),/* @__PURE__ */g(Gh,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:e.widget_body??"How can I help you today?"})]}),/* @__PURE__ */f($h,{gap:"sm",children:[/* @__PURE__ */f(zh,{type:"button",variant:"primary",full:!0,onClick:n,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */g(Ph,{name:"chat",size:16}),"Ask a question"]}),/* @__PURE__ */g(Ym,{actions:i,onActionClick:async(e,t)=>{t.preventDefault(),t.stopPropagation(),n(),r(e)}})]})]}),t.length>0&&/* @__PURE__ */f(sm,{style:{margin:"0 12px 12px 12px"},children:[
52
+ /* @__PURE__ */g(Gh,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
53
+ /* @__PURE__ */g(Gh,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t[t.length-1].content||"Message"}),
54
+ /* @__PURE__ */g(Gh,{as:"p",size:"xs",variant:"muted",onClick:n,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},Jm=["top-left","top-right","bottom-left","bottom-right"];function Km(e){const t=e.startsWith("top"),n=e.endsWith("left");return{position:"absolute",width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:t?"flex-start":"flex-end",justifyContent:n?"flex-start":"flex-end",cursor:t&&n||!t&&!n?"nwse-resize":"nesw-resize",top:t?0:void 0,bottom:t?void 0:0,left:n?0:void 0,right:n?void 0:0}}var Xm,Qm=({onResizeStart:e})=>/* @__PURE__ */g(m,{children:Jm.map(t=>/* @__PURE__ */g("div",{role:"separator","aria-label":`Resize widget from ${t.replace("-"," ")}`,title:"Drag to resize",style:Km(t),onMouseDown:e(t)},t))}),eg=({tabs:e,active:t,onChange:n})=>/* @__PURE__ */g(Oh,{role:"tablist",align:"center",justify:"around",shrink:!1,border:"top",style:zp.tabBar,children:e.map(e=>{const r=t===e.id;/* @__PURE__ */
55
+ return f(zh,{role:"tab","aria-selected":r,"aria-controls":`view-${e.id}`,id:`tab-${e.id}`,onClick:()=>n(e.id),active:r,stacked:!0,variant:"tab",children:[r&&/* @__PURE__ */g(Gh,{as:"span",inheritColor:!0,style:{position:"absolute",top:0,left:"25%",right:"25%"},children:/* @__PURE__ */g(mm,{variant:"bar",color:"accent"})}),
56
+ /* @__PURE__ */g(Gh,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */g(Ph,{name:e.icon,size:20})}),
57
+ /* @__PURE__ */g(Gh,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id)})}),tg=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"},{id:"help",icon:"help",label:"Help"}],ng=({activeView:e,onChange:t})=>/* @__PURE__ */g(eg,{tabs:tg,active:e,onChange:e=>t(e)}),rg=({children:e,direction:t})=>/* @__PURE__ */g(Fp,{"data-view-transition":!0,"data-direction":t,style:{width:"100%",height:"100%"},children:e}),ig=({config:e,isOpen:t,isMinimized:n,messages:r,currentMode:i,isTaskRunning:s=!1,taskProgress:l=[],activeView:c,onClose:h,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:S,setActiveView:I})=>{const{config:C,isPreviewMode:E}=ou({config:e}),A=d(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:T,heightPx:M,onResizeStart:z,containerRef:O}=function(e,t,n,r,i){const s=d(()=>`marketrix_widget_size_${n}`,[n]),a=u({width:360,height:450}),l=u(null),[c,h]=p(()=>{if("undefined"==typeof localStorage)return{width:em(e),height:em(t)};const n=localStorage.getItem(s);if(n)try{const e=JSON.parse(n);if("number"==typeof e.width&&"number"==typeof e.height){const t=tm(e.width,280,600),n=tm(e.height,320,Math.floor(.85*window.innerHeight));return a.current={width:t,height:n},{width:t,height:n}}}catch{}const r=em(e),i=em(t);return a.current={width:r,height:i},{width:r,height:i}});a.current=c;const m=o(e=>t=>{if(t.preventDefault(),t.stopPropagation(),r||i)return;const n=t.clientX,o=t.clientY,c=a.current.width,d=a.current.height,{cursor:u}=nm(e,n,o,n,o);l.current&&(l.current.dataset.resizing="true");const p=t=>{const{dx:r,dy:i}=nm(e,n,o,t.clientX,t.clientY),s=Math.floor(.85*window.innerHeight),u={width:tm(c+r,280,600),height:tm(d+i,320,s)};a.current=u,l.current&&(l.current.style.width=`${u.width}px`,l.current.style.height=`${u.height}px`)},m=()=>{if(document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",l.current&&delete l.current.dataset.resizing,h({...a.current}),!i&&"undefined"!=typeof localStorage){const{width:e,height:t}=a.current;localStorage.setItem(s,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[r,i,s]);return{width:c.width,height:c.height,widthPx:`${c.width}px`,heightPx:`${c.height}px`,onResizeStart:m,containerRef:l}}(C.widget_width,C.widget_height,A,n,E),R=u(null),[P,N]=p("forward"),L=u(c);a(()=>{L.current!==c&&(N("chat"===c?"forward":"back"),L.current=c)},[c]),function(e,t,n){const r=u(!1),i=u(null),s=o(()=>{const t=e.current;if(!t)return;const r=n?.focusTargetRef?.current;if(r)return void r.focus({preventScroll:!0});const i=Qh(t);i[0]&&i[0].focus({preventScroll:!0})},[e,n?.focusTargetRef]);a(()=>{if(!t)return r.current&&(i.current?.focus({preventScroll:!0}),i.current=null),void(r.current=!1);r.current||(i.current=document.activeElement||null),r.current=!0;const o=e.current;if(!o)return;s();const a=e=>{if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const t=Qh(o);if(0===t.length)return;const r=document.activeElement,i=t.indexOf(r);-1!==i&&(e.shiftKey?0===i&&(e.preventDefault(),t[t.length-1].focus()):i===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t,e,s,n?.onEscape])}(O,t,{onEscape:h,focusTargetRef:"chat"===c?R:void 0});const D=C.widget_position,j=C.widget_position_z_index??40,$=(e=>{const t="20px",n="20px";switch(e){case"bottom_right":default:return{bottom:t,right:n};case"bottom_left":return{bottom:t,left:n};case"top_right":return{top:t,right:n};case"top_left":return{top:t,left:n}}})(D),[F,B]=p(!1),[U,G]=p(!1),W=u(null),Z=u(null),V=o(e=>{G(e),S?.(e)},[S]);if(!t)return null;const H=C.widget_background_color.includes("gradient")?C.widget_background_color:`linear-gradient(135deg, ${C.widget_background_color} 0%, ${C.widget_background_color} 100%)`,Y={width:T,height:n?"48px":M,fontSize:C.widget_font_size,backgroundImage:H,zIndex:j},q=E?"absolute":"fixed",J=E?D.includes("top")?{top:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{},K=`${D.includes("top")?"top":"bottom"} ${D.includes("right")?"right":"left"}`,X="chat"===c&&!1!==e.use_screenshare?()=>{U?Z.current?.():W.current?.()}:void 0;/* @__PURE__ */
58
+ return f($h,{ref:O,position:q,rounded:"theme",border:!0,overflow:"hidden",style:{zIndex:j,backgroundImage:H,transformOrigin:K,...Y,...E?J:$,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:Ep.panel},children:[
59
+ /* @__PURE__ */g(km,{title:e.agent_name??"AI Agent",subtitle:n?void 0:e.agent_description??"How can I help?",minimized:n,onClose:h,controls:X&&/* @__PURE__ */f(jh,{variant:"ghost",size:"sm",label:U?"Stop screen sharing":"Start screen sharing",onClick:X,children:[U&&/* @__PURE__ */g(om,{variant:"live",style:{position:"absolute",top:"2px",right:"2px"}}),/* @__PURE__ */g(Ph,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */f(m,{children:[/* @__PURE__ */g(Fp,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */f(rg,{direction:P,children:["home"===c&&/* @__PURE__ */g(qm,{config:e,messages:r,onNavigateToChat:()=>{N("forward"),I("chat")},onChipClick:e=>{b(Pd(e.text,e.type,"chip-message")),w(e.type),y(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */g(Zm,{config:e,messages:r,currentMode:i,isTaskRunning:s,taskProgress:l,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:V,onStartScreenShareRef:W,onStopScreenShareRef:Z,messageInputRef:R}),"help"===c&&/* @__PURE__ */f($h,{id:"view-help",role:"tabpanel","aria-labelledby":"tab-help",height:"full",padding:"lg",children:[/* @__PURE__ */f($h,{grow:!0,align:"center",justify:"center",gap:"sm",children:[/* @__PURE__ */g(Gh,{as:"span",variant:"faint",children:/* @__PURE__ */g(Ph,{name:"help",size:32})}),/* @__PURE__ */g(Gh,{size:"sm",variant:"muted",children:"Help – coming soon"})]}),/* @__PURE__ */f(sm,{style:{margin:"0 12px 12px 12px"},children:[/* @__PURE__ */f(Gh,{size:"xs",variant:"faint",style:{display:"block"},children:["Widget v",Xh]}),/* @__PURE__ */f(Gh,{size:"xs",variant:"faint",style:{display:"block"},children:["API"," ",(()=>{try{return"connected"===Bd.getInstance().getStatus()?"connected":"disconnected"}catch{return"—"}})()]})]})]}),"news"===c&&/* @__PURE__ */f($h,{id:"view-news",role:"tabpanel","aria-labelledby":"tab-news",height:"full",align:"center",justify:"center",gap:"sm",padding:"lg",children:[/* @__PURE__ */g(Gh,{as:"span",variant:"faint",children:/* @__PURE__ */g(Ph,{name:"info",size:32})}),/* @__PURE__ */g(Gh,{size:"sm",variant:"muted",children:"News – coming soon"})]})]},c)}),/* @__PURE__ */g(ng,{activeView:c,onChange:I})]}),!n&&!E&&/* @__PURE__ */g(Qm,{onResizeStart:z}),
60
+ /* @__PURE__ */g(Cm,{isOpen:F,onClose:()=>B(!1),diagnosticData:{chatId:Fd.getChatId(),streamEndpoint:(()=>{const t=Gd.getConfig()?.mtxApiHost||e.mtxApiHost;return t?`${t.replace(/\/$/,"")}/widget/stream`:null})(),connectionStatus:(()=>{try{return Bd.getInstance().getStatus()}catch{return"disconnected"}})(),applicationId:Gd.getConfig()?.mtxApp,agentId:Gd.getConfig()?.mtxAgent,version:Xh,build:"dev"}})]})},og=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},sg=({config:e})=>{const[t,n]=p(!1),{state:r,actions:i,config:o,shouldShow:s,isPreviewMode:l,configValid:c}=ou({config:e});var u;u=r.isOpen,a(()=>{if(!u)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[u]);const[h,m]=p(e.widget_position??"bottom_right"),b=d(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);a(()=>{m(o.widget_position??"bottom_right")},[o.widget_position]),a(()=>{if(l||"undefined"==typeof localStorage)return;const e=o.widget_position??"bottom_right",t=localStorage.getItem(b);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(b,e),m(e)):m(t)},[l,b,o.widget_position]),a(()=>{if(r.isOpen||l||"default"!==o.widget_appearance)return void n(!1);const e=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(e)},[r.isOpen,l,o.widget_appearance]);if(!c)return null;if(!(l?e.widget_enabled??o.widget_enabled:s&&o.widget_enabled&&!1!==e.show_widget))return null;const v=(S=function(e={}){return E({...C,widget_background_color:e.widget_background_color??C.widget_background_color,widget_text_color:e.widget_text_color??C.widget_text_color,widget_border_color:e.widget_border_color??C.widget_border_color,widget_accent_color:e.widget_accent_color??C.widget_accent_color,widget_secondary_color:e.widget_secondary_color??C.widget_secondary_color,widget_border_radius:e.widget_border_radius??C.widget_border_radius,widget_font_size:e.widget_font_size??C.widget_font_size,widget_width:e.widget_width??C.widget_width,widget_height:e.widget_height??C.widget_height,widget_shadow:e.widget_shadow??C.widget_shadow,widget_animation_duration:e.widget_animation_duration??C.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??C.widget_fade_duration})}(o),{"--background":S.color.background,"--foreground":S.color.foreground,"--card":S.color.background,"--card-foreground":S.color.foreground,"--popover":S.color.background,"--popover-foreground":S.color.foreground,"--primary":S.color.primary,"--foreground-muted":S.color.foregroundMuted,"--foreground-faint":S.color.foregroundFaint,"--border-muted":S.color.borderMuted,"--primary-foreground":S.color.primaryForeground,"--primary-hover":S.color.primaryHover,"--primary-muted":S.color.primaryMuted,"--secondary":S.color.secondary,"--secondary-foreground":S.color.secondaryForeground,"--secondary-bg":S.color.secondaryBg,"--secondary-hover":S.color.secondaryHover,"--muted":S.color.border,"--muted-foreground":S.color.secondary,"--accent":S.color.background,"--accent-foreground":S.color.foreground,"--border":S.color.border,"--input":S.color.border,"--ring":S.color.primary,"--radius":S.radius,"--shadow":S.shadow,"--duration-animation":S.motion.durationAnimation,"--duration-fade":S.motion.durationFade,"--widget-width":S.size.widgetWidth,"--widget-height":S.size.widgetHeight});var S;const I=Math.max(o.widget_position_z_index??0,y),A={...o,widget_position:h,widget_position_z_index:I,show_widget:e.show_widget,use_screenshare:e.use_screenshare},T=r.isLoading||r.isTaskRunning;/* @__PURE__ */
61
+ return f(Fp,{"data-marketrix-widget":!0,position:"relative",style:{...v,"--widget-z-index":I,...l&&{width:"100%",height:"100%"}},"data-widget-mode":o?.widget_feature_human?"hybrid":"ai",children:[T&&/* @__PURE__ */g(Fp,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${k(o.widget_accent_color,.72)}, inset 0 0 46px 10px ${k(o.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
62
+ /* @__PURE__ */g(og,{children:/* @__PURE__ */g(ig,{config:A,isOpen:r.isOpen,isMinimized:r.isMinimized,messages:r.messages,currentMode:r.currentMode,isTaskRunning:r.isTaskRunning,taskProgress:r.taskProgress,activeView:r.activeView,onClose:i.closeWidget,onSendMessage:i.sendMessage,onSetMode:i.setMode,onAddMessage:i.addMessage,onUpdateMessage:i.updateMessage,onRemoveMessage:i.removeMessage,onStopTask:i.stopTask,onClearChat:i.clearChatHistory,setActiveView:i.setActiveView})}),
63
+ /* @__PURE__ */g(Kh,{open:r.isOpen,processing:r.isLoading,error:!!r.error,taskRunning:r.isTaskRunning,onClick:i.toggleWidget,onStop:i.stopTask,accentColor:A.widget_accent_color,backgroundColor:A.widget_background_color,borderRadius:A.widget_border_radius,tooltipBgColor:_(A.widget_accent_color,.3),tooltipTextColor:x(_(A.widget_accent_color,.3)),zIndex:A.widget_position_z_index??50,position:h,onDrag:e=>{m(e),l||"undefined"==typeof localStorage||localStorage.setItem(b,e)},isPreviewMode:l}),r.error&&/* @__PURE__ */g(Zh,{tone:"error",title:r.error,onDismiss:()=>i.clearError(),onRetry:()=>i.clearError(),position:h.includes("top")?"bottom-center":"above-fab"}),t&&!r.error&&o.widget_greeting&&/* @__PURE__ */g(Zh,{tone:"info",title:o.widget_greeting,body:o.widget_body,onDismiss:()=>n(!1),position:"bottom-center"})]})},ag=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=iu(),{_setMessages:i}=(()=>{const e=s(Zd);if(!e)throw new Error("useChatContextInternal must be used within ChatProvider");return e})(),o=u(null);return a(()=>{if(t)return;(async()=>{const e=await Fd.getOrCreateChatId();Rd.createInitialContext(e),Rd.getInitError()&&r.setError("Widget failed to initialise — please refresh the page."),Rd.initialize(e);const t=Rd.getIsTaskRunning(),n=Rd.getActiveTaskId();if(r.applyState({isLoading:Rd.getIsLoading(),currentMode:Rd.getCurrentMode(),isOpen:Rd.getIsOpen(),isMinimized:Rd.getIsMinimized()}),i({messages:Rd.getMessages()}),o.current=t?n:null,e){const t=Bd.getInstance(),n=Gd.getConfig();t.connect(e,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxAgent:n.mtxAgent,mtxApp:n.mtxApp}:void 0).catch(e=>{})}})()},[]),/* @__PURE__ */g(tu,{previewMode:t,currentMode:n.currentMode,setMessages:i,uiActions:r,activeTaskIdRef:o,children:e})},lg=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=iu();/* @__PURE__ */
64
+ return g(Vd,{previewMode:t,uiActions:r,currentMode:n.currentMode,children:/* @__PURE__ */g(ag,{previewMode:t,children:e})})},cg=({children:e,previewMode:t=!1})=>/* @__PURE__ */g(ru,{children:/* @__PURE__ */g(lg,{previewMode:t,children:e})}),dg=Object.defineProperty,ug=(e,t,n)=>((e,t,n)=>t in e?dg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),pg=Object.defineProperty,hg=(e,t,n)=>((e,t,n)=>t in e?pg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),mg=/* @__PURE__ */(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(mg||{}),gg={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},fg={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},yg={};function wg(e){if(yg[e])return yg[e];const t=globalThis[e],n=t.prototype,r=e in gg?gg[e]:void 0,i=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),o=e in fg?fg[e]:void 0,s=Boolean(o&&o.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return yg[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");document.body.appendChild(r);const i=r.contentWindow;if(!i)return t.prototype;const o=i[e].prototype;return document.body.removeChild(r),o?yg[e]=o:n}catch{return n}}var bg={};function vg(e,t,n){var r;const i=`${e}.${String(n)}`;if(bg[i])return bg[i].call(t);const o=wg(e),s=null==(r=Object.getOwnPropertyDescriptor(o,n))?void 0:r.get;return s?(bg[i]=s,s.call(t)):t[n]}var xg={};function kg(e,t,n){const r=`${e}.${String(n)}`;if(xg[r])return xg[r].bind(t);const i=wg(e)[n];return"function"!=typeof i?t[n]:(xg[r]=i,i.bind(t))}var _g={ownerDocument:function(e){return vg("Node",e,"ownerDocument")},childNodes:function(e){return vg("Node",e,"childNodes")},parentNode:function(e){return vg("Node",e,"parentNode")},parentElement:function(e){return vg("Node",e,"parentElement")},textContent:function(e){return vg("Node",e,"textContent")},contains:function(e,t){return kg("Node",e,"contains")(t)},getRootNode:function(e){return kg("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?vg("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?vg("Element",e,"shadowRoot"):null},querySelector:function(e,t){return vg("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return vg("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return wg("MutationObserver").constructor},patch:function(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}};function Sg(e){return e.nodeType===e.ELEMENT_NODE}function Ig(e){const t=e&&"host"in e&&"mode"in e&&_g.host(e)||null;return Boolean(t&&"shadowRoot"in t&&_g.shadowRoot(t)===e)}function Cg(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function Eg(e){try{const n=e.rules||e.cssRules;if(!n)return null;let r=e.href;return!r&&e.ownerNode&&(r=e.ownerNode.baseURI),(t=Array.from(n,e=>Ag(e,r)).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),t}catch(n){return null}var t}function Ag(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=Eg(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(n){t=e.cssText}return e.styleSheet.href?$g(t,e.styleSheet.href):t}{let n=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(n=n.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")),t?$g(n,t):n}}var Tg=class{constructor(){hg(this,"idNodeMap",/* @__PURE__ */new Map),hg(this,"nodeMetaMap",/* @__PURE__ */new WeakMap)}getId(e){var t;return e?(null==(t=this.getMeta(e))?void 0:t.id)??-1:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=/* @__PURE__ */new Map,this.nodeMetaMap=/* @__PURE__ */new WeakMap}};function Mg({element:e,maskInputOptions:t,tagName:n,type:r,value:i,maskInputFn:o}){let s=i||"";const a=r&&zg(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=o?o(s,e):"*".repeat(s.length)),s}function zg(e){return e.toLowerCase()}var Og="__rrweb_original__";function Rg(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?zg(t):null}function Pg(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(i){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}var Ng=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Lg=/^(?:[a-z+]+:)?\/\//i,Dg=/^www\..*/i,jg=/^(data:)([^,]*),(.*)/i;function $g(e,t){return(e||"").replace(Ng,(e,n,r,i,o,s)=>{const a=r||o||s,l=n||i||"";if(!a)return e;if(Lg.test(a)||Dg.test(a))return`url(${l}${a}${l})`;if(jg.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),d=a.split("/");c.pop();for(const t of d){if("."===t)continue;".."===t?c.pop():c.push(t)}return`url(${l}${c.join("/")}${l})`})}function Fg(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function Bg(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),i=[];let o=0;if(r.length>1&&e&&"string"==typeof e){let t=Fg(e,n);const s=t.length/e.length;for(let a=1;a<r.length;a++)if(r[a].textContent&&"string"==typeof r[a].textContent){const l=Fg(r[a].textContent,n),c=100;let d=3;for(;d<l.length&&(l[d].match(/[a-zA-Z0-9]/)||-1!==l.indexOf(l.substring(0,d),1));d++);for(;d<l.length;d++){let u=l.substring(0,d),p=t.split(u),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[a-1].textContent)h=t.indexOf(u,1);else if(1===p.length){if(u=u.substring(0,u.length-1),p=t.split(u),p.length<=1)return i.push(e),i;d=101}else d===l.length-1&&(h=t.indexOf(u));if(p.length>=2&&d>c){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=Fg(e).length;h=t.indexOf(u,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/s);for(;a>0&&a<e.length;){if(o+=1,o>50*r.length)return i.push(e),i;const l=Fg(e.substring(0,a),n);if(l.length===h){i.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}l.length<h?a+=Math.max(1,Math.floor((h-l.length)/s)):a-=Math.max(1,Math.floor((l.length-h)*s))}break}}}}return i.push(e),i}(e,t).join("/* rr_split */")}var Ug,Gg,Wg=1,Zg=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function Vg(){return Wg++}var Hg=/^[^ \t\n\r\u000c]+/,Yg=/^[, \t\n\r\u000c]+/;var qg=/* @__PURE__ */new WeakMap;function Jg(e,t){return t&&""!==t.trim()?Xg(e,t):t}function Kg(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function Xg(e,t){let n=qg.get(e);if(n||(n=e.createElement("a"),qg.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function Qg(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]||"background"===n&&["table","td","th"].includes(t)?Jg(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const i=e.exec(t.substring(n));return i?(r=i[0],n+=r.length,r):""}const i=[];for(;r(Yg),!(n>=t.length);){let o=r(Hg);if(","===o.slice(-1))o=Jg(e,o.substring(0,o.length-1)),i.push(o);else{let r="";o=Jg(e,o);let s=!1;for(;;){const e=t.charAt(n);if(""===e){i.push((o+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,i.push((o+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return i.join(", ")}(e,r):"style"===n?$g(r,Xg(e)):"object"===t&&"data"===n?Jg(e,r):r:r}function ef(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function tf(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&tf(_g.parentNode(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&tf(_g.parentNode(e),t,n)}function nf(e,t,n,r){let i;if(Sg(e)){if(i=e,!_g.childNodes(i).length)return!1}else{if(null===_g.parentElement(e))return!1;i=_g.parentElement(e)}try{if("string"==typeof t){if(r){if(i.closest(`.${t}`))return!0}else if(i.classList.contains(t))return!0}else if(tf(i,t,r))return!0;if(n)if(r){if(i.closest(n))return!0}else if(i.matches(n))return!0}catch(o){}return!1}function rf(e,t){const{doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:s,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:d,dataURLOptions:u={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:m,newlyAddedElement:g=!1,cssCaptured:f=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:mg.Document,childNodes:[],compatMode:e.compatMode}:{type:mg.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:mg.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:i,inlineStylesheet:o,maskInputOptions:s={},maskInputFn:a,dataURLOptions:l={},inlineImages:c,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:p=!1,rootId:h}=t,m=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(r){}return!1}(e,r,i),g=function(e){if(e instanceof HTMLFormElement)return"form";const t=zg(e.tagName);return Zg.test(t)?"div":t}(e);let f={};const y=e.attributes.length;for(let v=0;v<y;v++){const t=e.attributes[v];ef(g,t.name,t.value)||(f[t.name]=Qg(n,g,zg(t.name),t.value))}if("link"===g&&o){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=Eg(t)),r&&(delete f.rel,delete f.href,f._cssText=r)}if("style"===g&&e.sheet){let t=Eg(e.sheet);t&&(e.childNodes.length>1&&(t=Bg(t,e)),f._cssText=t)}if(["input","textarea","select"].includes(g)){const t=e.value,n=e.checked;"radio"!==f.type&&"checkbox"!==f.type&&"submit"!==f.type&&"button"!==f.type&&t?f.value=Mg({element:e,type:Rg(e),tagName:g,value:t,maskInputOptions:s,maskInputFn:a}):n&&(f.checked=n)}"option"===g&&(e.selected&&!s.select?f.selected=!0:delete f.selected);"dialog"===g&&e.open&&(f.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===g&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const i=t.getImageData,o=Og in i?i[Og]:i;if(new Uint32Array(o.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(f.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){const t=e.toDataURL(l.type,l.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height,t!==r.toDataURL(l.type,l.quality)&&(f.rr_dataURL=t)}if("img"===g&&c){Ug||(Ug=n.createElement("canvas"),Gg=Ug.getContext("2d"));const t=e,r=(t.currentSrc||t.getAttribute("src"),t.crossOrigin),i=()=>{t.removeEventListener("load",i);try{Ug.width=t.naturalWidth,Ug.height=t.naturalHeight,Gg.drawImage(t,0,0),f.rr_dataURL=Ug.toDataURL(l.type,l.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i))}"anonymous"===t.crossOrigin&&(r?f.crossOrigin=r:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i)}if(["audio","video"].includes(g)){const t=f;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(f.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(f.rr_scrollTop=e.scrollTop));if(m){const{width:t,height:n}=e.getBoundingClientRect();f={class:f.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==g||u(f.src)||(e.contentDocument||(f.rr_src=f.src),delete f.src);let w;try{customElements.get(g)&&(w=!0)}catch(b){}return{type:mg.Element,tagName:g,attributes:f,childNodes:[],isSVG:Kg(e)||void 0,needBlock:m,rootId:h,isCustom:w}}(e,{doc:n,blockClass:i,blockSelector:o,inlineStylesheet:a,maskInputOptions:l,maskInputFn:d,dataURLOptions:u,inlineImages:p,recordCanvas:h,keepIframeSrcFn:m,newlyAddedElement:g,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:i,cssCaptured:o}=t,s=_g.parentNode(e),a=s&&s.tagName;let l="";const c="STYLE"===a||void 0,d="SCRIPT"===a||void 0;d?l="SCRIPT_PLACEHOLDER":o||(l=_g.textContent(e),c&&l&&(l=$g(l,Xg(t.doc))));!c&&!d&&l&&n&&(l=r?r(l,_g.parentElement(e)):l.replace(/[\S]/g,"*"));return{type:mg.Text,textContent:l||"",rootId:i}}(e,{doc:n,needsMask:s,maskTextFn:c,rootId:y,cssCaptured:f});case e.CDATA_SECTION_NODE:return{type:mg.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:mg.Comment,textContent:_g.textContent(e)||"",rootId:y};default:return!1}}function of(e){return null==e?"":e.toLowerCase()}function sf(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:e||{}}function af(e,t){const{doc:n,mirror:r,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m={},inlineImages:g=!1,recordCanvas:f=!1,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b=5e3,onStylesheetLoad:v,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:_=!1,cssCaptured:S=!1}=t;let{needsMask:I}=t,{preserveWhiteSpace:C=!0}=t;I||(I=nf(e,s,a,void 0===I));const E=rf(e,{doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:I,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,dataURLOptions:m,inlineImages:g,recordCanvas:f,keepIframeSrcFn:k,newlyAddedElement:_,cssCaptured:S});if(!E)return null;let A;A=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===mg.Comment)return!0;if(e.type===mg.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===Pg(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(of(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===of(e.attributes.name)||"icon"===of(e.attributes.rel)||"apple-touch-icon"===of(e.attributes.rel)||"shortcut icon"===of(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&of(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(of(e.attributes.property).match(/^(og|twitter|fb):/)||of(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===of(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===of(e.attributes.name)||"googlebot"===of(e.attributes.name)||"bingbot"===of(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===of(e.attributes.name)||"generator"===of(e.attributes.name)||"framework"===of(e.attributes.name)||"publisher"===of(e.attributes.name)||"progid"===of(e.attributes.name)||of(e.attributes.property).match(/^article:/)||of(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===of(e.attributes.name)||"yandex-verification"===of(e.attributes.name)||"csrf-token"===of(e.attributes.name)||"p:domain_verify"===of(e.attributes.name)||"verify-v1"===of(e.attributes.name)||"verification"===of(e.attributes.name)||"shopify-checkout-api-token"===of(e.attributes.name)))return!0}}return!1}(E,h)||!C&&E.type===mg.Text&&!E.textContent.replace(/^\s+|\s+$/gm,"").length?-2:Vg();const T=Object.assign(E,{id:A});if(r.add(e,T),-2===A)return null;y&&y(e);let M=!l;if(T.type===mg.Element){M=M&&!T.needBlock,delete T.needBlock;const t=_g.shadowRoot(e);t&&Cg(t)&&(T.isShadowHost=!0)}if((T.type===mg.Document||T.type===mg.Element)&&M){h.headWhitespace&&T.type===mg.Element&&"head"===T.tagName&&(C=!1);const t={doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:g,recordCanvas:f,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(T.type===mg.Element&&"textarea"===T.tagName&&void 0!==T.attributes.value);else{T.type===mg.Element&&void 0!==T.attributes._cssText&&"string"==typeof T.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(_g.childNodes(e))){const e=af(n,t);e&&T.childNodes.push(e)}}let _=null;if(Sg(e)&&(_=_g.shadowRoot(e)))for(const e of Array.from(_g.childNodes(_))){const n=af(e,t);n&&(Cg(_)&&(n.isShadow=!0),T.childNodes.push(n))}}const z=_g.parentNode(e);return z&&Ig(z)&&Cg(z)&&(T.isShadow=!0),T.type===mg.Element&&"iframe"===T.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let i,o=!1;try{i=r.document.readyState}catch(a){return}if("complete"!==i){const r=setTimeout(()=>{o||(t(),o=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),o=!0,t()})}const s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&w){const n=af(t,{doc:t,mirror:r,blockClass:i,blockSelector:o,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:g,recordCanvas:f,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});n&&w(e,n)}},b),T.type===mg.Element&&"link"===T.tagName&&"string"==typeof T.attributes.rel&&("stylesheet"===T.attributes.rel||"preload"===T.attributes.rel&&"string"==typeof T.attributes.href&&"css"===Pg(T.attributes.href))&&function(e,t,n){let r,i=!1;try{r=e.sheet}catch(s){return}if(r)return;const o=setTimeout(()=>{i||(t(),i=!0)},n);e.addEventListener("load",()=>{clearTimeout(o),i=!0,t()})}(e,()=>{if(v){const t=af(e,{doc:n,mirror:r,blockClass:i,blockSelector:o,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:g,recordCanvas:f,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&v(e,t)}},x),T}function lf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function cf(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var df={exports:{}},uf=String,pf=function(){return{isColorSupported:!1,reset:uf,bold:uf,dim:uf,italic:uf,underline:uf,inverse:uf,hidden:uf,strikethrough:uf,black:uf,red:uf,green:uf,yellow:uf,blue:uf,magenta:uf,cyan:uf,white:uf,gray:uf,bgBlack:uf,bgRed:uf,bgGreen:uf,bgYellow:uf,bgBlue:uf,bgMagenta:uf,bgCyan:uf,bgWhite:uf}};df.exports=pf(),df.exports.createColors=pf;var hf=df.exports,mf=/* @__PURE__ */cf(/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),gf=hf,ff=mf,yf=class e extends Error{constructor(t,n,r,i,o,s){super(t),this.name="CssSyntaxError",this.reason=t,o&&(this.file=o),i&&(this.source=i),s&&(this.plugin=s),void 0!==n&&void 0!==r&&("number"==typeof n?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;null==e&&(e=gf.isColorSupported),ff&&e&&(t=ff(t));let n,r,i=t.split(/\r?\n/),o=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length;if(e){let{bold:e,gray:t,red:i}=gf.createColors(!0);n=t=>e(i(t)),r=e=>t(e)}else n=r=e=>e;return i.slice(o,s).map((e,t)=>{let i=o+1+t,s=" "+(" "+i).slice(-a)+" | ";if(i===this.line){let t=r(s.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return n(">")+r(s)+e+"\n "+t+n("^")}return" "+r(s)+e}).join("\n")}toString(){let e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},wf=yf;yf.default=yf;var bf={};bf.isClean=Symbol("isClean"),bf.my=Symbol("my");var vf={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var xf=class{constructor(e){this.builder=e}atrule(e,t){let n="@"+e.name,r=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?n+=e.raws.afterName:r&&(n+=" "),e.nodes)this.block(e,n+r);else{let i=(e.raws.between||"")+(t?";":"");this.builder(n+r+i,e)}}beforeAfter(e,t){let n;n="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let r=e.parent,i=0;for(;r&&"root"!==r.type;)i+=1,r=r.parent;if(n.includes("\n")){let t=this.raw(e,null,"indent");if(t.length)for(let e=0;e<i;e++)n+=t}return n}block(e,t){let n,r=this.raw(e,"between","beforeOpen");this.builder(t+r+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),this.builder("}",e,"end")}body(e){let t=e.nodes.length-1;for(;t>0&&"comment"===e.nodes[t].type;)t-=1;let n=this.raw(e,"semicolon");for(let r=0;r<e.nodes.length;r++){let i=e.nodes[r],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==r||n)}}comment(e){let t=this.raw(e,"left","commentLeft"),n=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+n+"*/",e)}decl(e,t){let n=this.raw(e,"between","colon"),r=e.prop+n+this.rawValue(e,"value");e.important&&(r+=e.raws.important||" !important"),t&&(r+=";"),this.builder(r,e)}document(e){this.body(e)}raw(e,t,n){let r;if(n||(n=t),t&&(r=e.raws[t],void 0!==r))return r;let i=e.parent;if("before"===n){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return vf[n];let o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[n])return o.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);{let i="raw"+((s=n)[0].toUpperCase()+s.slice(1));this[i]?r=this[i](o,e):o.walk(e=>{if(r=e.raws[t],void 0!==r)return!1})}var s;return void 0===r&&(r=vf[n]),o.rawCache[n]=r,r}rawBeforeClose(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return t=e.raws.after,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){let n;return e.walkComments(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(e,t){let n;return e.walkDecls(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(e){let t;return e.walk(e=>{if("decl"!==e.type&&(t=e.raws.between,void 0!==t))return!1}),t}rawBeforeRule(e){let t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&void 0!==n.raws.before)return t=n.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){let t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(t=e.raws.after,void 0!==t))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(n=>{let r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&void 0!==n.raws.before){let e=n.raws.before.split("\n");return t=e[e.length-1],t=t.replace(/\S/g,""),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(t=e.raws.semicolon,void 0!==t))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},kf=xf;xf.default=xf;var _f=kf;function Sf(e,t){new _f(t).stringify(e)}var If=Sf;Sf.default=Sf;var{isClean:Cf,my:Ef}=bf,Af=wf,Tf=kf,Mf=If;function zf(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;if("proxyCache"===r)continue;let i=e[r],o=typeof i;"parent"===r&&"object"===o?t&&(n[r]=t):"source"===r?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>zf(e,n)):("object"===o&&null!==i&&(i=zf(i)),n[r]=i)}return n}var Of=class{constructor(e={}){this.raws={},this[Cf]=!1,this[Ef]=!0;for(let t in e)if("nodes"===t){this.nodes=[];for(let n of e[t])"function"==typeof n.clone?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=zf(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new Af(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[Cf]){this[Cf]=!1;let e=this;for(;e=e.parent;)e[Cf]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e,t){let n=this.source.start;if(e.index)n=this.positionInside(e.index,t);else if(e.word){let r=(t=this.toString()).indexOf(e.word);-1!==r&&(n=this.positionInside(r,t))}return n}positionInside(e,t){let n=t||this.toString(),r=this.source.start.column,i=this.source.start.line;for(let o=0;o<e;o++)"\n"===n[o]?(r=1,i+=1):r+=1;return{column:r,line:i}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e){let t={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){let r=this.toString(),i=r.indexOf(e.word);-1!==i&&(t=this.positionInside(i,r),n=this.positionInside(i+e.word.length,r))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?n={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?n=this.positionInside(e.endIndex):e.index&&(n=this.positionInside(e.index+1));return(n.line<t.line||n.line===t.line&&n.column<=t.column)&&(n={column:t.column+1,line:t.line}),{end:n,start:t}}raw(e,t){return(new Tf).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){let n={},r=null==t;t=t||/* @__PURE__ */new Map;let i=0;for(let o in this){if(!Object.prototype.hasOwnProperty.call(this,o))continue;if("parent"===o||"proxyCache"===o)continue;let e=this[o];if(Array.isArray(e))n[o]=e.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof e&&e.toJSON)n[o]=e.toJSON(null,t);else if("source"===o){let r=t.get(e.input);null==r&&(r=i,t.set(e.input,i),i++),n[o]={end:e.end,inputId:r,start:e.start}}else n[o]=e}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=Mf){e.stringify&&(e=e.stringify);let t="";return e(this,e=>{t+=e}),t}warn(e,t,n){let r={node:this};for(let i in n)r[i]=n[i];return e.warn(t,r)}get proxyOf(){return this}},Rf=Of;Of.default=Of;var Pf=Rf,Nf=class extends Pf{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e={...e,value:String(e.value)}),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Lf=Nf;Nf.default=Nf;var Df={nanoid:(e=21)=>{let t="",n=e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(n=t)=>{let r="",i=n;for(;i--;)r+=e[Math.random()*e.length|0];return r}},{SourceMapConsumer:jf,SourceMapGenerator:$f}=mf,{existsSync:Ff,readFileSync:Bf}=mf,{dirname:Uf,join:Gf}=mf;var Wf=class{constructor(e,t){if(!1===t.map)return;this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");let n=t.map?t.map.prev:void 0,r=this.loadMap(t.from,n);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Uf(this.mapFile)),r&&(this.text=r)}consumer(){return this.consumerCache||(this.consumerCache=new jf(this.text)),this.consumerCache}decodeInline(e){if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var t;let n=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+n)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){let t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(!t)return;let n=e.lastIndexOf(t.pop()),r=e.indexOf("*/",n);n>-1&&r>-1&&(this.annotation=this.getAnnotationURL(e.substring(n,r)))}loadFile(e){if(this.root=Uf(e),Ff(e))return this.mapFile=e,Bf(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof jf)return $f.fromSourceMap(t).toString();if(t instanceof $f)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}{let n=t(e);if(n){let e=this.loadFile(n);if(!e)throw new Error("Unable to load previous source map: "+n.toString());return e}}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let t=this.annotation;return e&&(t=Gf(Uf(e),t)),this.loadFile(t)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Zf=Wf;Wf.default=Wf;var{SourceMapConsumer:Vf,SourceMapGenerator:Hf}=mf,{fileURLToPath:Yf,pathToFileURL:qf}=mf,{isAbsolute:Jf,resolve:Kf}=mf,{nanoid:Xf}=Df,Qf=mf,ey=wf,ty=Zf,ny=Symbol("fromOffsetCache"),ry=Boolean(Vf&&Hf),iy=Boolean(Kf&&Jf),oy=class{constructor(e,t={}){if(null==e||"object"==typeof e&&!e.toString)throw new Error(`PostCSS received ${e} instead of CSS string`);if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!iy||/^\w+:\/\//.test(t.from)||Jf(t.from)?this.file=t.from:this.file=Kf(t.from)),iy&&ry){let e=new ty(this.css,t);if(e.text){this.map=e;let t=e.consumer().file;!this.file&&t&&(this.file=this.mapResolve(t))}}this.file||(this.id="<input css "+Xf(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,n,r={}){let i,o,s;if(t&&"object"==typeof t){let e=t,r=n;if("number"==typeof e.offset){let r=this.fromOffset(e.offset);t=r.line,n=r.col}else t=e.line,n=e.column;if("number"==typeof r.offset){let e=this.fromOffset(r.offset);o=e.line,s=e.col}else o=r.line,s=r.column}else if(!n){let e=this.fromOffset(t);t=e.line,n=e.col}let a=this.origin(t,n,o,s);return i=a?new ey(e,void 0===a.endLine?a.line:{column:a.column,line:a.line},void 0===a.endLine?a.column:{column:a.endColumn,line:a.endLine},a.source,a.file,r.plugin):new ey(e,void 0===o?t:{column:n,line:t},void 0===o?n:{column:s,line:o},this.css,this.file,r.plugin),i.input={column:n,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(qf&&(i.input.url=qf(this.file).toString()),i.input.file=this.file),i}fromOffset(e){let t,n;if(this[ny])n=this[ny];else{let e=this.css.split("\n");n=new Array(e.length);let t=0;for(let r=0,i=e.length;r<i;r++)n[r]=t,t+=e[r].length+1;this[ny]=n}t=n[n.length-1];let r=0;if(e>=t)r=n.length-1;else{let t,i=n.length-2;for(;r<i;)if(t=r+(i-r>>1),e<n[t])i=t-1;else{if(!(e>=n[t+1])){r=t;break}r=t+1}}return{col:e-n[r]+1,line:r+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:Kf(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,n,r){if(!this.map)return!1;let i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof n&&(i=s.originalPositionFor({column:r,line:n})),o=Jf(a.source)?qf(a.source):new URL(a.source,this.map.consumer().sourceRoot||qf(this.map.mapFile));let l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!Yf)throw new Error("file: protocol is not available in this PostCSS build");l.file=Yf(o)}let c=s.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){let e={};for(let t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map={...this.map},e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},sy=oy;oy.default=oy,Qf&&Qf.registerInput&&Qf.registerInput(oy);var{SourceMapConsumer:ay,SourceMapGenerator:ly}=mf,{dirname:cy,relative:dy,resolve:uy,sep:py}=mf,{pathToFileURL:hy}=mf,my=sy,gy=Boolean(ay&&ly),fy=Boolean(cy&&uy&&dy&&py),yy=class{constructor(e,t,n,r){this.stringify=e,this.mapOpts=n.map||{},this.root=t,this.opts=n,this.css=r,this.originalCSS=r,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=/* @__PURE__ */new Map,this.memoizedPaths=/* @__PURE__ */new Map,this.memoizedURLs=/* @__PURE__ */new Map}addAnnotation(){let e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";let t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let t,n=this.toUrl(this.path(e.file)),r=e.root||cy(e.file);!1===this.mapOpts.sourcesContent?(t=new ay(e.text),t.sourcesContent&&(t.sourcesContent=null)):t=e.consumer(),this.map.applySourceMap(t,n,this.toUrl(this.path(r)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root){let e;for(let t=this.root.nodes.length-1;t>=0;t--)e=this.root.nodes[t],"comment"===e.type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),fy&&gy&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=ly.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new ly({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new ly({file:this.outputFile(),ignoreInvalidMapping:!0});let e,t,n=1,r=1,i="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(s,a,l)=>{if(this.css+=s,a&&"end"!==l&&(o.generated.line=n,o.generated.column=r-1,a.source&&a.source.start?(o.source=this.sourcePath(a),o.original.line=a.source.start.line,o.original.column=a.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),e=s.match(/\n/g),e?(n+=e.length,t=s.lastIndexOf("\n"),r=s.length-t):r+=s.length,a&&"start"!==l){let e=a.parent||{raws:{}};("decl"!==a.type&&("atrule"!==a.type||a.nodes)||a!==e.last||e.raws.semicolon)&&(a.source&&a.source.end?(o.source=this.sourcePath(a),o.original.line=a.source.end.line,o.original.column=a.source.end.column-1,o.generated.line=n,o.generated.column=r-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=n,o.generated.column=r-1,this.map.addMapping(o)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;let e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let n=this.opts.to?cy(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(n=cy(uy(n,this.mapOpts.annotation)));let r=dy(n,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new my(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let n=t.source.input.from;if(n&&!e[n]){e[n]=!0;let r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(hy){let t=hy(e).toString();return this.memoizedFileURLs.set(e,t),t}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;"\\"===py&&(e=e.replace(/\\/g,"/"));let n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}},wy=Rf,by=class extends wy{constructor(e){super(e),this.type="comment"}},vy=by;by.default=by;var xy,ky,_y,Sy,{isClean:Iy,my:Cy}=bf,Ey=Lf,Ay=vy,Ty=Rf;function My(e){return e.map(e=>(e.nodes&&(e.nodes=My(e.nodes)),delete e.source,e))}function zy(e){if(e[Iy]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)zy(t)}var Oy=class e extends Ty{append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t,n,r=this.getIterator();for(;this.indexes[r]<this.proxyOf.nodes.length&&(t=this.indexes[r],n=e(this.proxyOf.nodes[t],t),!1!==n);)this.indexes[r]+=1;return delete this.indexes[r],n}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?(...n)=>e[t](...n.map(e=>"function"==typeof e?(t,n)=>e(t.toProxy(),n):e)):"every"===t||"some"===t?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n,r=this.index(e),i=this.normalize(t,this.proxyOf.nodes[r]).reverse();r=this.index(e);for(let o of i)this.proxyOf.nodes.splice(r+1,0,o);for(let o in this.indexes)n=this.indexes[o],r<n&&(this.indexes[o]=n+i.length);return this.markDirty(),this}insertBefore(e,t){let n,r=this.index(e),i=0===r&&"prepend",o=this.normalize(t,this.proxyOf.nodes[r],i).reverse();r=this.index(e);for(let s of o)this.proxyOf.nodes.splice(r,0,s);for(let s in this.indexes)n=this.indexes[s],r<=n&&(this.indexes[s]=n+o.length);return this.markDirty(),this}normalize(t,n){if("string"==typeof t)t=My(xy(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if("root"===t.type&&"document"!==this.type){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new Ey(t)]}else if(t.selector)t=[new ky(t)];else if(t.name)t=[new _y(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new Ay(t)]}return t.map(t=>(t[Cy]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[Iy]&&zy(t),void 0===t.raws.before&&n&&void 0!==n.raws.before&&(t.raws.before=n.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,"prepend").reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){let t;e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(i){throw t.addToError(i)}return!1!==r&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("atrule"===n.type&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if("atrule"===n.type&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("atrule"===e.type)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if("comment"===t.type)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("decl"===n.type&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if("decl"===n.type&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("decl"===e.type)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("rule"===n.type&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if("rule"===n.type&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("rule"===e.type)return t(e,n)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};Oy.registerParse=e=>{xy=e},Oy.registerRule=e=>{ky=e},Oy.registerAtRule=e=>{_y=e},Oy.registerRoot=e=>{Sy=e};var Ry=Oy;Oy.default=Oy,Oy.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,_y.prototype):"rule"===e.type?Object.setPrototypeOf(e,ky.prototype):"decl"===e.type?Object.setPrototypeOf(e,Ey.prototype):"comment"===e.type?Object.setPrototypeOf(e,Ay.prototype):"root"===e.type&&Object.setPrototypeOf(e,Sy.prototype),e[Cy]=!0,e.nodes&&e.nodes.forEach(e=>{Oy.rebuild(e)})};var Py,Ny,Ly=Ry,Dy=class extends Ly{constructor(e){super({type:"document",...e}),this.nodes||(this.nodes=[])}toResult(e={}){return new Py(new Ny,this,e).stringify()}};Dy.registerLazyResult=e=>{Py=e},Dy.registerProcessor=e=>{Ny=e};var jy=Dy;Dy.default=Dy;var $y=class{constructor(e,t={}){if(this.type="warning",this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let n in t)this[n]=t[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},Fy=$y;$y.default=$y;var By=Fy,Uy=class{constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let n=new By(e,t);return this.messages.push(n),n}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},Gy=Uy;Uy.default=Uy;var Wy="'".charCodeAt(0),Zy='"'.charCodeAt(0),Vy="\\".charCodeAt(0),Hy="/".charCodeAt(0),Yy="\n".charCodeAt(0),qy=" ".charCodeAt(0),Jy="\f".charCodeAt(0),Ky="\t".charCodeAt(0),Xy="\r".charCodeAt(0),Qy="[".charCodeAt(0),ew="]".charCodeAt(0),tw="(".charCodeAt(0),nw=")".charCodeAt(0),rw="{".charCodeAt(0),iw="}".charCodeAt(0),ow=";".charCodeAt(0),sw="*".charCodeAt(0),aw=":".charCodeAt(0),lw="@".charCodeAt(0),cw=/[\t\n\f\r "#'()/;[\\\]{}]/g,dw=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,uw=/.[\r\n"'(/\\]/,pw=/[\da-f]/i,hw=Ry,mw=class extends hw{constructor(e){super(e),this.type="atrule"}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}},gw=mw;mw.default=mw,hw.registerAtRule(mw);var fw,yw,ww=Ry,bw=class extends ww{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,n){let r=super.normalize(e);if(t)if("prepend"===n)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let i of r)i.raws.before=t.raws.before;return r}removeChild(e,t){let n=this.index(e);return!t&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new fw(new yw,this,e).stringify()}};bw.registerLazyResult=e=>{fw=e},bw.registerProcessor=e=>{yw=e};var vw=bw;bw.default=bw,ww.registerRoot(bw);var xw={comma:e=>xw.split(e,[","],!0),space:e=>xw.split(e,[" ","\n","\t"]),split(e,t,n){let r=[],i="",o=!1,s=0,a=!1,l="",c=!1;for(let d of e)c?c=!1:"\\"===d?c=!0:a?d===l&&(a=!1):'"'===d||"'"===d?(a=!0,l=d):"("===d?s+=1:")"===d?s>0&&(s-=1):0===s&&t.includes(d)&&(o=!0),o?(""!==i&&r.push(i.trim()),i="",o=!1):i+=d;return(n||""!==i)&&r.push(i.trim()),r}},kw=xw;xw.default=xw;var _w=Ry,Sw=kw,Iw=class extends _w{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return Sw.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(n)}},Cw=Iw;Iw.default=Iw,_w.registerRule(Iw);var Ew=Lf,Aw=function(e,t={}){let n,r,i,o,s,a,l,c,d,u,p=e.css.valueOf(),h=t.ignoreErrors,m=p.length,g=0,f=[],y=[];function w(t){throw e.error("Unclosed "+t,g)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&g>=m},nextToken:function(e){if(y.length)return y.pop();if(g>=m)return;let t=!!e&&e.ignoreUnclosed;switch(n=p.charCodeAt(g),n){case Yy:case qy:case Ky:case Xy:case Jy:r=g;do{r+=1,n=p.charCodeAt(r)}while(n===qy||n===Yy||n===Ky||n===Xy||n===Jy);u=["space",p.slice(g,r)],g=r-1;break;case Qy:case ew:case rw:case iw:case aw:case ow:case nw:{let e=String.fromCharCode(n);u=[e,e,g];break}case tw:if(c=f.length?f.pop()[1]:"",d=p.charCodeAt(g+1),"url"===c&&d!==Wy&&d!==Zy&&d!==qy&&d!==Yy&&d!==Ky&&d!==Jy&&d!==Xy){r=g;do{if(a=!1,r=p.indexOf(")",r+1),-1===r){if(h||t){r=g;break}w("bracket")}for(l=r;p.charCodeAt(l-1)===Vy;)l-=1,a=!a}while(a);u=["brackets",p.slice(g,r+1),g,r],g=r}else r=p.indexOf(")",g+1),o=p.slice(g,r+1),-1===r||uw.test(o)?u=["(","(",g]:(u=["brackets",o,g,r],g=r);break;case Wy:case Zy:i=n===Wy?"'":'"',r=g;do{if(a=!1,r=p.indexOf(i,r+1),-1===r){if(h||t){r=g+1;break}w("string")}for(l=r;p.charCodeAt(l-1)===Vy;)l-=1,a=!a}while(a);u=["string",p.slice(g,r+1),g,r],g=r;break;case lw:cw.lastIndex=g+1,cw.test(p),r=0===cw.lastIndex?p.length-1:cw.lastIndex-2,u=["at-word",p.slice(g,r+1),g,r],g=r;break;case Vy:for(r=g,s=!0;p.charCodeAt(r+1)===Vy;)r+=1,s=!s;if(n=p.charCodeAt(r+1),s&&n!==Hy&&n!==qy&&n!==Yy&&n!==Ky&&n!==Xy&&n!==Jy&&(r+=1,pw.test(p.charAt(r)))){for(;pw.test(p.charAt(r+1));)r+=1;p.charCodeAt(r+1)===qy&&(r+=1)}u=["word",p.slice(g,r+1),g,r],g=r;break;default:n===Hy&&p.charCodeAt(g+1)===sw?(r=p.indexOf("*/",g+2)+1,0===r&&(h||t?r=p.length:w("comment")),u=["comment",p.slice(g,r+1),g,r],g=r):(dw.lastIndex=g+1,dw.test(p),r=0===dw.lastIndex?p.length-1:dw.lastIndex-2,u=["word",p.slice(g,r+1),g,r],f.push(u),g=r)}return g++,u},position:function(){return g}}},Tw=vy,Mw=gw,zw=vw,Ow=Cw,Rw={empty:!0,space:!0};var Pw=Ry,Nw=class{constructor(e){this.input=e,this.root=new zw,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t,n,r,i=new Mw;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);let o=!1,s=!1,a=[],l=[];for(;!this.tokenizer.endOfFile();){if(t=(e=this.tokenizer.nextToken())[0],"("===t||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(r=a.length-1,n=a[r];n&&"space"===n[0];)n=a[--r];n&&(i.source.end=this.getPosition(n[3]||n[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){let t=this.colon(e);if(!1===t)return;let n,r=0;for(let i=t-1;i>=0&&(n=e[i],"space"===n[0]||(r+=1,2!==r));i--);throw this.input.error("Missed semicolon","word"===n[0]?n[3]+1:n[2])}colon(e){let t,n,r,i=0;for(let[o,s]of e.entries()){if(t=s,n=t[0],"("===n&&(i+=1),")"===n&&(i-=1),0===i&&":"===n){if(r){if("word"===r[0]&&"progid"===r[1])continue;return o}this.doubleColon(t)}r=t}return!1}comment(e){let t=new Tw;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(/^\s*$/.test(n))t.text="",t.raws.left=n,t.raws.right="";else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=Aw(this.input)}decl(e,t){let n=new Ew;this.init(n,e[0][2]);let r,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(i[3]||i[2]||function(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}(e)),n.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;n.prop+=e.shift()[1]}for(n.raws.between="";e.length;){if(r=e.shift(),":"===r[0]){n.raws.between+=r[1];break}"word"===r[0]&&/\w/.test(r[1])&&this.unknownWord([r]),n.raws.between+=r[1]}"_"!==n.prop[0]&&"*"!==n.prop[0]||(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let o,s=[];for(;e.length&&(o=e[0][0],"space"===o||"comment"===o);)s.push(e.shift());this.precheckMissedSemicolon(e);for(let a=e.length-1;a>=0;a--){if(r=e[a],"!important"===r[1].toLowerCase()){n.important=!0;let t=this.stringFrom(e,a);t=this.spacesFromEnd(e)+t," !important"!==t&&(n.raws.important=t);break}if("important"===r[1].toLowerCase()){let t=e.slice(0),r="";for(let e=a;e>0;e--){let n=t[e][0];if(0===r.trim().indexOf("!")&&"space"!==n)break;r=t.pop()[1]+r}0===r.trim().indexOf("!")&&(n.important=!0,n.raws.important=r,e=t)}if("space"!==r[0]&&"comment"!==r[0])break}e.some(e=>"space"!==e[0]&&"comment"!==e[0])&&(n.raws.between+=s.map(e=>e[1]).join(""),s=[]),this.raw(n,"value",s.concat(e),t),n.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new Ow;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],l=e;for(;l;){if(n=l[0],a.push(l),"("===n||"["===n)i||(i=l),o.push("("===n?")":"]");else if(s&&r&&"{"===n)i||(i=l),o.push("}");else if(0===o.length){if(";"===n){if(r)return void this.decl(a,s);break}if("{"===n)return void this.rule(a);if("}"===n){this.tokenizer.back(a.pop()),t=!0;break}":"===n&&(r=!0)}else n===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&r){if(!s)for(;a.length&&(l=a[a.length-1][0],"space"===l||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,o,s,a,l=n.length,c="",d=!0;for(let u=0;u<l;u+=1)i=n[u],o=i[0],"space"!==o||u!==l-1||r?"comment"===o?(a=n[u-1]?n[u-1][0]:"empty",s=n[u+1]?n[u+1][0]:"empty",Rw[a]||Rw[s]||","===c.slice(-1)?d=!1:c+=i[1]):c+=i[1]:d=!1;if(!d){let r=n.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:r,value:c}}e[t]=c}rule(e){e.pop();let t=new Ow;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t||"comment"===t);)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n="";for(;e.length&&(t=e[0][0],"space"===t||"comment"===t);)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n="";for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Lw=sy;function Dw(e,t){let n=new Nw(new Lw(e,t));try{n.parse()}catch(r){throw r}return n.root}var jw=Dw;Dw.default=Dw,Pw.registerParse(Dw);var{isClean:$w,my:Fw}=bf,Bw=yy,Uw=If,Gw=Ry,Ww=jy,Zw=Gy,Vw=jw,Hw=vw,Yw={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},qw={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Jw={Once:!0,postcssPlugin:!0,prepare:!0};function Kw(e){return"object"==typeof e&&"function"==typeof e.then}function Xw(e){let t=!1,n=Yw[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[n,n+"-"+t,0,n+"Exit",n+"Exit-"+t]:t?[n,n+"-"+t,n+"Exit",n+"Exit-"+t]:e.append?[n,0,n+"Exit"]:[n,n+"Exit"]}function Qw(e){let t;return t="document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:Xw(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function eb(e){return e[$w]=!1,e.nodes&&e.nodes.forEach(e=>eb(e)),e}var tb={},nb=class e{constructor(t,n,r){let i;if(this.stringified=!1,this.processed=!1,"object"!=typeof n||null===n||"root"!==n.type&&"document"!==n.type)if(n instanceof e||n instanceof Zw)i=eb(n.root),n.map&&(void 0===r.map&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=n.map);else{let e=Vw;r.syntax&&(e=r.syntax.parse),r.parser&&(e=r.parser),e.parse&&(e=e.parse);try{i=e(n,r)}catch(o){this.processed=!0,this.error=o}i&&!i[Fw]&&Gw.rebuild(i)}else i=eb(n);this.result=new Zw(t,i,r),this.helpers={...tb,postcss:tb,result:this.result},this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let n=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin?n.postcssVersion:(e.plugin=n.postcssPlugin,e.setMessage())}catch(r){console&&console.error}return e}prepareVisitors(){this.listeners={};let e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(let t of this.plugins)if("object"==typeof t)for(let n in t){if(!qw[n]&&/^[A-Z]/.test(n))throw new Error(`Unknown event ${n} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Jw[n])if("object"==typeof t[n])for(let r in t[n])e(t,"*"===r?n:n+"-"+r.toLowerCase(),t[n][r]);else"function"==typeof t[n]&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let n=0;n<this.plugins.length;n++){let t=this.plugins[n],r=this.runOnRoot(t);if(Kw(r))try{await r}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[$w];){e[$w]=!0;let n=[Qw(e)];for(;n.length>0;){let e=this.visitTick(n);if(Kw(e))try{await e}catch(t){let e=n[n.length-1].node;throw this.handleError(t,e)}}}if(this.listeners.OnceExit)for(let[n,r]of this.listeners.OnceExit){this.result.lastPlugin=n;try{if("document"===e.type){let t=e.nodes.map(e=>r(e,this.helpers));await Promise.all(t)}else await r(e,this.helpers)}catch(t){throw this.handleError(t)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return Kw(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=Uw;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let n=new Bw(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(Kw(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[$w];)e[$w]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[r,i]of e){let e;this.result.lastPlugin=r;try{e=i(t,this.helpers)}catch(n){throw this.handleError(n,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(Kw(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:n,visitors:r}=t;if("root"!==n.type&&"document"!==n.type&&!n.parent)return void e.pop();if(r.length>0&&t.visitorIndex<r.length){let[e,i]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(n.toProxy(),this.helpers)}catch(o){throw this.handleError(o,n)}}if(0!==t.iterator){let r,i=t.iterator;for(;r=n.nodes[n.indexes[i]];)if(n.indexes[i]+=1,!r[$w])return r[$w]=!0,void e.push(Qw(r));t.iterator=0,delete n.indexes[i]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,0===e)return void(n.nodes&&n.nodes.length&&(n[$w]=!0,t.iterator=n.getIterator()));if(this.listeners[e])return void(t.visitors=this.listeners[e])}e.pop()}walkSync(e){e[$w]=!0;let t=Xw(e);for(let n of t)if(0===n)e.nodes&&e.each(e=>{e[$w]||this.walkSync(e)});else{let t=this.listeners[n];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};nb.registerPostcss=e=>{tb=e};var rb=nb;nb.default=nb,Hw.registerLazyResult(nb),Ww.registerLazyResult(nb);var ib=yy,ob=If,sb=jw,ab=Gy,lb=class{constructor(e,t,n){let r;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=n,this._map=void 0;let i=ob;this.result=new ab(this._processor,r,this._opts),this.result.css=t;let o=this;Object.defineProperty(this.result,"root",{get:()=>o.root});let s=new ib(i,r,this._opts,t);if(s.isMap()){let[e,t]=s.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=sb;try{e=t(this._css,this._opts)}catch(n){this.error=n}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},cb=lb;lb.default=lb;var db=cb,ub=rb,pb=jy,hb=vw,mb=class{constructor(e=[]){this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){let t=[];for(let n of e)if(!0===n.postcss?n=n():n.postcss&&(n=n.postcss),"object"==typeof n&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if("object"==typeof n&&n.postcssPlugin)t.push(n);else if("function"==typeof n)t.push(n);else if("object"!=typeof n||!n.parse&&!n.stringify)throw new Error(n+" is not a PostCSS plugin");return t}process(e,t={}){return this.plugins.length||t.parser||t.stringifier||t.syntax?new ub(this,e,t):new db(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},gb=mb;mb.default=mb,hb.registerProcessor(mb),pb.registerProcessor(mb);var fb=Lf,yb=Zf,wb=vy,bb=gw,vb=sy,xb=vw,kb=Cw;function _b(e,t){if(Array.isArray(e))return e.map(e=>_b(e));let{inputs:n,...r}=e;if(n){t=[];for(let e of n){let n={...e,__proto__:vb.prototype};n.map&&(n.map={...n.map,__proto__:yb.prototype}),t.push(n)}}if(r.nodes&&(r.nodes=e.nodes.map(e=>_b(e,t))),r.source){let{inputId:e,...n}=r.source;r.source=n,null!=e&&(r.source.input=t[e])}if("root"===r.type)return new xb(r);if("decl"===r.type)return new fb(r);if("rule"===r.type)return new kb(r);if("comment"===r.type)return new wb(r);if("atrule"===r.type)return new bb(r);throw new Error("Unknown node type: "+e.type)}var Sb=_b;_b.default=_b;var Ib=wf,Cb=Lf,Eb=rb,Ab=Ry,Tb=gb,Mb=If,zb=Sb,Ob=jy,Rb=Fy,Pb=vy,Nb=gw,Lb=Gy,Db=sy,jb=jw,$b=kw,Fb=Cw,Bb=vw,Ub=Rf;function Gb(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new Tb(e)}Gb.plugin=function(e,t){let n,r=!1;function i(...n){console&&console.warn&&!r&&(r=!0,{}.LANG&&{}.LANG.startsWith("cn"));let i=t(...n);return i.postcssPlugin=e,i.postcssVersion=(new Tb).version,i}return Object.defineProperty(i,"postcss",{get:()=>(n||(n=i()),n)}),i.process=function(e,t,n){return Gb([i(n)]).process(e,t)},i},Gb.stringify=Mb,Gb.parse=jb,Gb.fromJSON=zb,Gb.list=$b,Gb.comment=e=>new Pb(e),Gb.atRule=e=>new Nb(e),Gb.decl=e=>new Cb(e),Gb.rule=e=>new Fb(e),Gb.root=e=>new Bb(e),Gb.document=e=>new Ob(e),Gb.CssSyntaxError=Ib,Gb.Declaration=Cb,Gb.Container=Ab,Gb.Processor=Tb,Gb.Document=Ob,Gb.Comment=Pb,Gb.Warning=Rb,Gb.AtRule=Nb,Gb.Result=Lb,Gb.Input=Db,Gb.Rule=Fb,Gb.Root=Bb,Gb.Node=Ub,Eb.registerPostcss(Gb);var Wb=Gb;Gb.default=Gb;var Zb=/* @__PURE__ */lf(Wb);Zb.stringify,Zb.fromJSON,Zb.plugin,Zb.parse,Zb.list,Zb.document,Zb.comment,Zb.atRule,Zb.rule,Zb.decl,Zb.root,Zb.CssSyntaxError,Zb.Declaration,Zb.Container,Zb.Processor,Zb.Document,Zb.Comment,Zb.Warning,Zb.AtRule,Zb.Result,Zb.Input,Zb.Rule,Zb.Root,Zb.Node;var Vb=Object.defineProperty,Hb=(e,t,n)=>((e,t,n)=>t in e?Vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);function Yb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function qb(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var Jb={exports:{}},Kb=String,Xb=function(){return{isColorSupported:!1,reset:Kb,bold:Kb,dim:Kb,italic:Kb,underline:Kb,inverse:Kb,hidden:Kb,strikethrough:Kb,black:Kb,red:Kb,green:Kb,yellow:Kb,blue:Kb,magenta:Kb,cyan:Kb,white:Kb,gray:Kb,bgBlack:Kb,bgRed:Kb,bgGreen:Kb,bgYellow:Kb,bgBlue:Kb,bgMagenta:Kb,bgCyan:Kb,bgWhite:Kb}};Jb.exports=Xb(),Jb.exports.createColors=Xb;var Qb=Jb.exports,ev=/* @__PURE__ */qb(/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),tv=Qb,nv=ev,rv=class e extends Error{constructor(t,n,r,i,o,s){super(t),this.name="CssSyntaxError",this.reason=t,o&&(this.file=o),i&&(this.source=i),s&&(this.plugin=s),void 0!==n&&void 0!==r&&("number"==typeof n?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;null==e&&(e=tv.isColorSupported),nv&&e&&(t=nv(t));let n,r,i=t.split(/\r?\n/),o=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length;if(e){let{bold:e,gray:t,red:i}=tv.createColors(!0);n=t=>e(i(t)),r=e=>t(e)}else n=r=e=>e;return i.slice(o,s).map((e,t)=>{let i=o+1+t,s=" "+(" "+i).slice(-a)+" | ";if(i===this.line){let t=r(s.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return n(">")+r(s)+e+"\n "+t+n("^")}return" "+r(s)+e}).join("\n")}toString(){let e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},iv=rv;rv.default=rv;var ov={};ov.isClean=Symbol("isClean"),ov.my=Symbol("my");var sv={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var av=class{constructor(e){this.builder=e}atrule(e,t){let n="@"+e.name,r=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?n+=e.raws.afterName:r&&(n+=" "),e.nodes)this.block(e,n+r);else{let i=(e.raws.between||"")+(t?";":"");this.builder(n+r+i,e)}}beforeAfter(e,t){let n;n="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let r=e.parent,i=0;for(;r&&"root"!==r.type;)i+=1,r=r.parent;if(n.includes("\n")){let t=this.raw(e,null,"indent");if(t.length)for(let e=0;e<i;e++)n+=t}return n}block(e,t){let n,r=this.raw(e,"between","beforeOpen");this.builder(t+r+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),this.builder("}",e,"end")}body(e){let t=e.nodes.length-1;for(;t>0&&"comment"===e.nodes[t].type;)t-=1;let n=this.raw(e,"semicolon");for(let r=0;r<e.nodes.length;r++){let i=e.nodes[r],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==r||n)}}comment(e){let t=this.raw(e,"left","commentLeft"),n=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+n+"*/",e)}decl(e,t){let n=this.raw(e,"between","colon"),r=e.prop+n+this.rawValue(e,"value");e.important&&(r+=e.raws.important||" !important"),t&&(r+=";"),this.builder(r,e)}document(e){this.body(e)}raw(e,t,n){let r;if(n||(n=t),t&&(r=e.raws[t],void 0!==r))return r;let i=e.parent;if("before"===n){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return sv[n];let o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[n])return o.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);{let i="raw"+((s=n)[0].toUpperCase()+s.slice(1));this[i]?r=this[i](o,e):o.walk(e=>{if(r=e.raws[t],void 0!==r)return!1})}var s;return void 0===r&&(r=sv[n]),o.rawCache[n]=r,r}rawBeforeClose(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return t=e.raws.after,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){let n;return e.walkComments(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(e,t){let n;return e.walkDecls(e=>{if(void 0!==e.raws.before)return n=e.raws.before,n.includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(e){let t;return e.walk(e=>{if("decl"!==e.type&&(t=e.raws.between,void 0!==t))return!1}),t}rawBeforeRule(e){let t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&void 0!==n.raws.before)return t=n.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){let t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(t=e.raws.after,void 0!==t))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(n=>{let r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&void 0!==n.raws.before){let e=n.raws.before.split("\n");return t=e[e.length-1],t=t.replace(/\S/g,""),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(t=e.raws.semicolon,void 0!==t))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},lv=av;av.default=av;var cv=lv;function dv(e,t){new cv(t).stringify(e)}var uv=dv;dv.default=dv;var{isClean:pv,my:hv}=ov,mv=iv,gv=lv,fv=uv;function yv(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;if("proxyCache"===r)continue;let i=e[r],o=typeof i;"parent"===r&&"object"===o?t&&(n[r]=t):"source"===r?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>yv(e,n)):("object"===o&&null!==i&&(i=yv(i)),n[r]=i)}return n}var wv=class{constructor(e={}){this.raws={},this[pv]=!1,this[hv]=!0;for(let t in e)if("nodes"===t){this.nodes=[];for(let n of e[t])"function"==typeof n.clone?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=yv(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new mv(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[pv]){this[pv]=!1;let e=this;for(;e=e.parent;)e[pv]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e,t){let n=this.source.start;if(e.index)n=this.positionInside(e.index,t);else if(e.word){let r=(t=this.toString()).indexOf(e.word);-1!==r&&(n=this.positionInside(r,t))}return n}positionInside(e,t){let n=t||this.toString(),r=this.source.start.column,i=this.source.start.line;for(let o=0;o<e;o++)"\n"===n[o]?(r=1,i+=1):r+=1;return{column:r,line:i}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e){let t={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){let r=this.toString(),i=r.indexOf(e.word);-1!==i&&(t=this.positionInside(i,r),n=this.positionInside(i+e.word.length,r))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?n={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?n=this.positionInside(e.endIndex):e.index&&(n=this.positionInside(e.index+1));return(n.line<t.line||n.line===t.line&&n.column<=t.column)&&(n={column:t.column+1,line:t.line}),{end:n,start:t}}raw(e,t){return(new gv).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){let n={},r=null==t;t=t||/* @__PURE__ */new Map;let i=0;for(let o in this){if(!Object.prototype.hasOwnProperty.call(this,o))continue;if("parent"===o||"proxyCache"===o)continue;let e=this[o];if(Array.isArray(e))n[o]=e.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof e&&e.toJSON)n[o]=e.toJSON(null,t);else if("source"===o){let r=t.get(e.input);null==r&&(r=i,t.set(e.input,i),i++),n[o]={end:e.end,inputId:r,start:e.start}}else n[o]=e}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=fv){e.stringify&&(e=e.stringify);let t="";return e(this,e=>{t+=e}),t}warn(e,t,n){let r={node:this};for(let i in n)r[i]=n[i];return e.warn(t,r)}get proxyOf(){return this}},bv=wv;wv.default=wv;var vv=bv,xv=class extends vv{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e={...e,value:String(e.value)}),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},kv=xv;xv.default=xv;var _v={nanoid:(e=21)=>{let t="",n=e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(n=t)=>{let r="",i=n;for(;i--;)r+=e[Math.random()*e.length|0];return r}},{SourceMapConsumer:Sv,SourceMapGenerator:Iv}=ev,{existsSync:Cv,readFileSync:Ev}=ev,{dirname:Av,join:Tv}=ev;var Mv=class{constructor(e,t){if(!1===t.map)return;this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");let n=t.map?t.map.prev:void 0,r=this.loadMap(t.from,n);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Av(this.mapFile)),r&&(this.text=r)}consumer(){return this.consumerCache||(this.consumerCache=new Sv(this.text)),this.consumerCache}decodeInline(e){if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var t;let n=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+n)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){let t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(!t)return;let n=e.lastIndexOf(t.pop()),r=e.indexOf("*/",n);n>-1&&r>-1&&(this.annotation=this.getAnnotationURL(e.substring(n,r)))}loadFile(e){if(this.root=Av(e),Cv(e))return this.mapFile=e,Ev(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof Sv)return Iv.fromSourceMap(t).toString();if(t instanceof Iv)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}{let n=t(e);if(n){let e=this.loadFile(n);if(!e)throw new Error("Unable to load previous source map: "+n.toString());return e}}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let t=this.annotation;return e&&(t=Tv(Av(e),t)),this.loadFile(t)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},zv=Mv;Mv.default=Mv;var{SourceMapConsumer:Ov,SourceMapGenerator:Rv}=ev,{fileURLToPath:Pv,pathToFileURL:Nv}=ev,{isAbsolute:Lv,resolve:Dv}=ev,{nanoid:jv}=_v,$v=ev,Fv=iv,Bv=zv,Uv=Symbol("fromOffsetCache"),Gv=Boolean(Ov&&Rv),Wv=Boolean(Dv&&Lv),Zv=class{constructor(e,t={}){if(null==e||"object"==typeof e&&!e.toString)throw new Error(`PostCSS received ${e} instead of CSS string`);if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!Wv||/^\w+:\/\//.test(t.from)||Lv(t.from)?this.file=t.from:this.file=Dv(t.from)),Wv&&Gv){let e=new Bv(this.css,t);if(e.text){this.map=e;let t=e.consumer().file;!this.file&&t&&(this.file=this.mapResolve(t))}}this.file||(this.id="<input css "+jv(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,n,r={}){let i,o,s;if(t&&"object"==typeof t){let e=t,r=n;if("number"==typeof e.offset){let r=this.fromOffset(e.offset);t=r.line,n=r.col}else t=e.line,n=e.column;if("number"==typeof r.offset){let e=this.fromOffset(r.offset);o=e.line,s=e.col}else o=r.line,s=r.column}else if(!n){let e=this.fromOffset(t);t=e.line,n=e.col}let a=this.origin(t,n,o,s);return i=a?new Fv(e,void 0===a.endLine?a.line:{column:a.column,line:a.line},void 0===a.endLine?a.column:{column:a.endColumn,line:a.endLine},a.source,a.file,r.plugin):new Fv(e,void 0===o?t:{column:n,line:t},void 0===o?n:{column:s,line:o},this.css,this.file,r.plugin),i.input={column:n,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(Nv&&(i.input.url=Nv(this.file).toString()),i.input.file=this.file),i}fromOffset(e){let t,n;if(this[Uv])n=this[Uv];else{let e=this.css.split("\n");n=new Array(e.length);let t=0;for(let r=0,i=e.length;r<i;r++)n[r]=t,t+=e[r].length+1;this[Uv]=n}t=n[n.length-1];let r=0;if(e>=t)r=n.length-1;else{let t,i=n.length-2;for(;r<i;)if(t=r+(i-r>>1),e<n[t])i=t-1;else{if(!(e>=n[t+1])){r=t;break}r=t+1}}return{col:e-n[r]+1,line:r+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:Dv(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,n,r){if(!this.map)return!1;let i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof n&&(i=s.originalPositionFor({column:r,line:n})),o=Lv(a.source)?Nv(a.source):new URL(a.source,this.map.consumer().sourceRoot||Nv(this.map.mapFile));let l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!Pv)throw new Error("file: protocol is not available in this PostCSS build");l.file=Pv(o)}let c=s.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){let e={};for(let t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map={...this.map},e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},Vv=Zv;Zv.default=Zv,$v&&$v.registerInput&&$v.registerInput(Zv);var{SourceMapConsumer:Hv,SourceMapGenerator:Yv}=ev,{dirname:qv,relative:Jv,resolve:Kv,sep:Xv}=ev,{pathToFileURL:Qv}=ev,ex=Vv,tx=Boolean(Hv&&Yv),nx=Boolean(qv&&Kv&&Jv&&Xv),rx=class{constructor(e,t,n,r){this.stringify=e,this.mapOpts=n.map||{},this.root=t,this.opts=n,this.css=r,this.originalCSS=r,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=/* @__PURE__ */new Map,this.memoizedPaths=/* @__PURE__ */new Map,this.memoizedURLs=/* @__PURE__ */new Map}addAnnotation(){let e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";let t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let t,n=this.toUrl(this.path(e.file)),r=e.root||qv(e.file);!1===this.mapOpts.sourcesContent?(t=new Hv(e.text),t.sourcesContent&&(t.sourcesContent=null)):t=e.consumer(),this.map.applySourceMap(t,n,this.toUrl(this.path(r)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root){let e;for(let t=this.root.nodes.length-1;t>=0;t--)e=this.root.nodes[t],"comment"===e.type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),nx&&tx&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=Yv.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new Yv({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new Yv({file:this.outputFile(),ignoreInvalidMapping:!0});let e,t,n=1,r=1,i="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(s,a,l)=>{if(this.css+=s,a&&"end"!==l&&(o.generated.line=n,o.generated.column=r-1,a.source&&a.source.start?(o.source=this.sourcePath(a),o.original.line=a.source.start.line,o.original.column=a.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),e=s.match(/\n/g),e?(n+=e.length,t=s.lastIndexOf("\n"),r=s.length-t):r+=s.length,a&&"start"!==l){let e=a.parent||{raws:{}};("decl"!==a.type&&("atrule"!==a.type||a.nodes)||a!==e.last||e.raws.semicolon)&&(a.source&&a.source.end?(o.source=this.sourcePath(a),o.original.line=a.source.end.line,o.original.column=a.source.end.column-1,o.generated.line=n,o.generated.column=r-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=n,o.generated.column=r-1,this.map.addMapping(o)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;let e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let n=this.opts.to?qv(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(n=qv(Kv(n,this.mapOpts.annotation)));let r=Jv(n,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new ex(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let n=t.source.input.from;if(n&&!e[n]){e[n]=!0;let r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(Qv){let t=Qv(e).toString();return this.memoizedFileURLs.set(e,t),t}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;"\\"===Xv&&(e=e.replace(/\\/g,"/"));let n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}},ix=bv,ox=class extends ix{constructor(e){super(e),this.type="comment"}},sx=ox;ox.default=ox;var ax,lx,cx,dx,{isClean:ux,my:px}=ov,hx=kv,mx=sx,gx=bv;function fx(e){return e.map(e=>(e.nodes&&(e.nodes=fx(e.nodes)),delete e.source,e))}function yx(e){if(e[ux]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)yx(t)}var wx=class e extends gx{append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t,n,r=this.getIterator();for(;this.indexes[r]<this.proxyOf.nodes.length&&(t=this.indexes[r],n=e(this.proxyOf.nodes[t],t),!1!==n);)this.indexes[r]+=1;return delete this.indexes[r],n}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?(...n)=>e[t](...n.map(e=>"function"==typeof e?(t,n)=>e(t.toProxy(),n):e)):"every"===t||"some"===t?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n,r=this.index(e),i=this.normalize(t,this.proxyOf.nodes[r]).reverse();r=this.index(e);for(let o of i)this.proxyOf.nodes.splice(r+1,0,o);for(let o in this.indexes)n=this.indexes[o],r<n&&(this.indexes[o]=n+i.length);return this.markDirty(),this}insertBefore(e,t){let n,r=this.index(e),i=0===r&&"prepend",o=this.normalize(t,this.proxyOf.nodes[r],i).reverse();r=this.index(e);for(let s of o)this.proxyOf.nodes.splice(r,0,s);for(let s in this.indexes)n=this.indexes[s],r<=n&&(this.indexes[s]=n+o.length);return this.markDirty(),this}normalize(t,n){if("string"==typeof t)t=fx(ax(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if("root"===t.type&&"document"!==this.type){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new hx(t)]}else if(t.selector)t=[new lx(t)];else if(t.name)t=[new cx(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new mx(t)]}return t.map(t=>(t[px]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[ux]&&yx(t),void 0===t.raws.before&&n&&void 0!==n.raws.before&&(t.raws.before=n.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,"prepend").reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){let t;e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(i){throw t.addToError(i)}return!1!==r&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("atrule"===n.type&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if("atrule"===n.type&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("atrule"===e.type)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if("comment"===t.type)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("decl"===n.type&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if("decl"===n.type&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("decl"===e.type)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("rule"===n.type&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if("rule"===n.type&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("rule"===e.type)return t(e,n)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};wx.registerParse=e=>{ax=e},wx.registerRule=e=>{lx=e},wx.registerAtRule=e=>{cx=e},wx.registerRoot=e=>{dx=e};var bx=wx;wx.default=wx,wx.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,cx.prototype):"rule"===e.type?Object.setPrototypeOf(e,lx.prototype):"decl"===e.type?Object.setPrototypeOf(e,hx.prototype):"comment"===e.type?Object.setPrototypeOf(e,mx.prototype):"root"===e.type&&Object.setPrototypeOf(e,dx.prototype),e[px]=!0,e.nodes&&e.nodes.forEach(e=>{wx.rebuild(e)})};var vx,xx,kx=bx,_x=class extends kx{constructor(e){super({type:"document",...e}),this.nodes||(this.nodes=[])}toResult(e={}){return new vx(new xx,this,e).stringify()}};_x.registerLazyResult=e=>{vx=e},_x.registerProcessor=e=>{xx=e};var Sx=_x;_x.default=_x;var Ix=class{constructor(e,t={}){if(this.type="warning",this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let n in t)this[n]=t[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},Cx=Ix;Ix.default=Ix;var Ex=Cx,Ax=class{constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let n=new Ex(e,t);return this.messages.push(n),n}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},Tx=Ax;Ax.default=Ax;var Mx="'".charCodeAt(0),zx='"'.charCodeAt(0),Ox="\\".charCodeAt(0),Rx="/".charCodeAt(0),Px="\n".charCodeAt(0),Nx=" ".charCodeAt(0),Lx="\f".charCodeAt(0),Dx="\t".charCodeAt(0),jx="\r".charCodeAt(0),$x="[".charCodeAt(0),Fx="]".charCodeAt(0),Bx="(".charCodeAt(0),Ux=")".charCodeAt(0),Gx="{".charCodeAt(0),Wx="}".charCodeAt(0),Zx=";".charCodeAt(0),Vx="*".charCodeAt(0),Hx=":".charCodeAt(0),Yx="@".charCodeAt(0),qx=/[\t\n\f\r "#'()/;[\\\]{}]/g,Jx=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,Kx=/.[\r\n"'(/\\]/,Xx=/[\da-f]/i,Qx=bx,ek=class extends Qx{constructor(e){super(e),this.type="atrule"}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}},tk=ek;ek.default=ek,Qx.registerAtRule(ek);var nk,rk,ik=bx,ok=class extends ik{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,n){let r=super.normalize(e);if(t)if("prepend"===n)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let i of r)i.raws.before=t.raws.before;return r}removeChild(e,t){let n=this.index(e);return!t&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new nk(new rk,this,e).stringify()}};ok.registerLazyResult=e=>{nk=e},ok.registerProcessor=e=>{rk=e};var sk=ok;ok.default=ok,ik.registerRoot(ok);var ak={comma:e=>ak.split(e,[","],!0),space:e=>ak.split(e,[" ","\n","\t"]),split(e,t,n){let r=[],i="",o=!1,s=0,a=!1,l="",c=!1;for(let d of e)c?c=!1:"\\"===d?c=!0:a?d===l&&(a=!1):'"'===d||"'"===d?(a=!0,l=d):"("===d?s+=1:")"===d?s>0&&(s-=1):0===s&&t.includes(d)&&(o=!0),o?(""!==i&&r.push(i.trim()),i="",o=!1):i+=d;return(n||""!==i)&&r.push(i.trim()),r}},lk=ak;ak.default=ak;var ck=bx,dk=lk,uk=class extends ck{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return dk.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(n)}},pk=uk;uk.default=uk,ck.registerRule(uk);var hk=kv,mk=function(e,t={}){let n,r,i,o,s,a,l,c,d,u,p=e.css.valueOf(),h=t.ignoreErrors,m=p.length,g=0,f=[],y=[];function w(t){throw e.error("Unclosed "+t,g)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&g>=m},nextToken:function(e){if(y.length)return y.pop();if(g>=m)return;let t=!!e&&e.ignoreUnclosed;switch(n=p.charCodeAt(g),n){case Px:case Nx:case Dx:case jx:case Lx:r=g;do{r+=1,n=p.charCodeAt(r)}while(n===Nx||n===Px||n===Dx||n===jx||n===Lx);u=["space",p.slice(g,r)],g=r-1;break;case $x:case Fx:case Gx:case Wx:case Hx:case Zx:case Ux:{let e=String.fromCharCode(n);u=[e,e,g];break}case Bx:if(c=f.length?f.pop()[1]:"",d=p.charCodeAt(g+1),"url"===c&&d!==Mx&&d!==zx&&d!==Nx&&d!==Px&&d!==Dx&&d!==Lx&&d!==jx){r=g;do{if(a=!1,r=p.indexOf(")",r+1),-1===r){if(h||t){r=g;break}w("bracket")}for(l=r;p.charCodeAt(l-1)===Ox;)l-=1,a=!a}while(a);u=["brackets",p.slice(g,r+1),g,r],g=r}else r=p.indexOf(")",g+1),o=p.slice(g,r+1),-1===r||Kx.test(o)?u=["(","(",g]:(u=["brackets",o,g,r],g=r);break;case Mx:case zx:i=n===Mx?"'":'"',r=g;do{if(a=!1,r=p.indexOf(i,r+1),-1===r){if(h||t){r=g+1;break}w("string")}for(l=r;p.charCodeAt(l-1)===Ox;)l-=1,a=!a}while(a);u=["string",p.slice(g,r+1),g,r],g=r;break;case Yx:qx.lastIndex=g+1,qx.test(p),r=0===qx.lastIndex?p.length-1:qx.lastIndex-2,u=["at-word",p.slice(g,r+1),g,r],g=r;break;case Ox:for(r=g,s=!0;p.charCodeAt(r+1)===Ox;)r+=1,s=!s;if(n=p.charCodeAt(r+1),s&&n!==Rx&&n!==Nx&&n!==Px&&n!==Dx&&n!==jx&&n!==Lx&&(r+=1,Xx.test(p.charAt(r)))){for(;Xx.test(p.charAt(r+1));)r+=1;p.charCodeAt(r+1)===Nx&&(r+=1)}u=["word",p.slice(g,r+1),g,r],g=r;break;default:n===Rx&&p.charCodeAt(g+1)===Vx?(r=p.indexOf("*/",g+2)+1,0===r&&(h||t?r=p.length:w("comment")),u=["comment",p.slice(g,r+1),g,r],g=r):(Jx.lastIndex=g+1,Jx.test(p),r=0===Jx.lastIndex?p.length-1:Jx.lastIndex-2,u=["word",p.slice(g,r+1),g,r],f.push(u),g=r)}return g++,u},position:function(){return g}}},gk=sx,fk=tk,yk=sk,wk=pk,bk={empty:!0,space:!0};var vk=bx,xk=class{constructor(e){this.input=e,this.root=new yk,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t,n,r,i=new fk;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);let o=!1,s=!1,a=[],l=[];for(;!this.tokenizer.endOfFile();){if(t=(e=this.tokenizer.nextToken())[0],"("===t||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(r=a.length-1,n=a[r];n&&"space"===n[0];)n=a[--r];n&&(i.source.end=this.getPosition(n[3]||n[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){let t=this.colon(e);if(!1===t)return;let n,r=0;for(let i=t-1;i>=0&&(n=e[i],"space"===n[0]||(r+=1,2!==r));i--);throw this.input.error("Missed semicolon","word"===n[0]?n[3]+1:n[2])}colon(e){let t,n,r,i=0;for(let[o,s]of e.entries()){if(t=s,n=t[0],"("===n&&(i+=1),")"===n&&(i-=1),0===i&&":"===n){if(r){if("word"===r[0]&&"progid"===r[1])continue;return o}this.doubleColon(t)}r=t}return!1}comment(e){let t=new gk;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(/^\s*$/.test(n))t.text="",t.raws.left=n,t.raws.right="";else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=mk(this.input)}decl(e,t){let n=new hk;this.init(n,e[0][2]);let r,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(i[3]||i[2]||function(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}(e)),n.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;n.prop+=e.shift()[1]}for(n.raws.between="";e.length;){if(r=e.shift(),":"===r[0]){n.raws.between+=r[1];break}"word"===r[0]&&/\w/.test(r[1])&&this.unknownWord([r]),n.raws.between+=r[1]}"_"!==n.prop[0]&&"*"!==n.prop[0]||(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let o,s=[];for(;e.length&&(o=e[0][0],"space"===o||"comment"===o);)s.push(e.shift());this.precheckMissedSemicolon(e);for(let a=e.length-1;a>=0;a--){if(r=e[a],"!important"===r[1].toLowerCase()){n.important=!0;let t=this.stringFrom(e,a);t=this.spacesFromEnd(e)+t," !important"!==t&&(n.raws.important=t);break}if("important"===r[1].toLowerCase()){let t=e.slice(0),r="";for(let e=a;e>0;e--){let n=t[e][0];if(0===r.trim().indexOf("!")&&"space"!==n)break;r=t.pop()[1]+r}0===r.trim().indexOf("!")&&(n.important=!0,n.raws.important=r,e=t)}if("space"!==r[0]&&"comment"!==r[0])break}e.some(e=>"space"!==e[0]&&"comment"!==e[0])&&(n.raws.between+=s.map(e=>e[1]).join(""),s=[]),this.raw(n,"value",s.concat(e),t),n.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new wk;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],l=e;for(;l;){if(n=l[0],a.push(l),"("===n||"["===n)i||(i=l),o.push("("===n?")":"]");else if(s&&r&&"{"===n)i||(i=l),o.push("}");else if(0===o.length){if(";"===n){if(r)return void this.decl(a,s);break}if("{"===n)return void this.rule(a);if("}"===n){this.tokenizer.back(a.pop()),t=!0;break}":"===n&&(r=!0)}else n===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&r){if(!s)for(;a.length&&(l=a[a.length-1][0],"space"===l||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,o,s,a,l=n.length,c="",d=!0;for(let u=0;u<l;u+=1)i=n[u],o=i[0],"space"!==o||u!==l-1||r?"comment"===o?(a=n[u-1]?n[u-1][0]:"empty",s=n[u+1]?n[u+1][0]:"empty",bk[a]||bk[s]||","===c.slice(-1)?d=!1:c+=i[1]):c+=i[1]:d=!1;if(!d){let r=n.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:r,value:c}}e[t]=c}rule(e){e.pop();let t=new wk;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t||"comment"===t);)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n="";for(;e.length&&(t=e[0][0],"space"===t||"comment"===t);)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n="";for(;e.length&&(t=e[e.length-1][0],"space"===t);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n="";for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},kk=Vv;function _k(e,t){let n=new xk(new kk(e,t));try{n.parse()}catch(r){throw r}return n.root}var Sk=_k;_k.default=_k,vk.registerParse(_k);var{isClean:Ik,my:Ck}=ov,Ek=rx,Ak=uv,Tk=bx,Mk=Sx,zk=Tx,Ok=Sk,Rk=sk,Pk={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Nk={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Lk={Once:!0,postcssPlugin:!0,prepare:!0};function Dk(e){return"object"==typeof e&&"function"==typeof e.then}function jk(e){let t=!1,n=Pk[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[n,n+"-"+t,0,n+"Exit",n+"Exit-"+t]:t?[n,n+"-"+t,n+"Exit",n+"Exit-"+t]:e.append?[n,0,n+"Exit"]:[n,n+"Exit"]}function $k(e){let t;return t="document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:jk(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function Fk(e){return e[Ik]=!1,e.nodes&&e.nodes.forEach(e=>Fk(e)),e}var Bk={},Uk=class e{constructor(t,n,r){let i;if(this.stringified=!1,this.processed=!1,"object"!=typeof n||null===n||"root"!==n.type&&"document"!==n.type)if(n instanceof e||n instanceof zk)i=Fk(n.root),n.map&&(void 0===r.map&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=n.map);else{let e=Ok;r.syntax&&(e=r.syntax.parse),r.parser&&(e=r.parser),e.parse&&(e=e.parse);try{i=e(n,r)}catch(o){this.processed=!0,this.error=o}i&&!i[Ck]&&Tk.rebuild(i)}else i=Fk(n);this.result=new zk(t,i,r),this.helpers={...Bk,postcss:Bk,result:this.result},this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let n=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin?n.postcssVersion:(e.plugin=n.postcssPlugin,e.setMessage())}catch(r){console&&console.error}return e}prepareVisitors(){this.listeners={};let e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(let t of this.plugins)if("object"==typeof t)for(let n in t){if(!Nk[n]&&/^[A-Z]/.test(n))throw new Error(`Unknown event ${n} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Lk[n])if("object"==typeof t[n])for(let r in t[n])e(t,"*"===r?n:n+"-"+r.toLowerCase(),t[n][r]);else"function"==typeof t[n]&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let n=0;n<this.plugins.length;n++){let t=this.plugins[n],r=this.runOnRoot(t);if(Dk(r))try{await r}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Ik];){e[Ik]=!0;let n=[$k(e)];for(;n.length>0;){let e=this.visitTick(n);if(Dk(e))try{await e}catch(t){let e=n[n.length-1].node;throw this.handleError(t,e)}}}if(this.listeners.OnceExit)for(let[n,r]of this.listeners.OnceExit){this.result.lastPlugin=n;try{if("document"===e.type){let t=e.nodes.map(e=>r(e,this.helpers));await Promise.all(t)}else await r(e,this.helpers)}catch(t){throw this.handleError(t)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return Dk(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=Ak;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let n=new Ek(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(Dk(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Ik];)e[Ik]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[r,i]of e){let e;this.result.lastPlugin=r;try{e=i(t,this.helpers)}catch(n){throw this.handleError(n,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(Dk(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:n,visitors:r}=t;if("root"!==n.type&&"document"!==n.type&&!n.parent)return void e.pop();if(r.length>0&&t.visitorIndex<r.length){let[e,i]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(n.toProxy(),this.helpers)}catch(o){throw this.handleError(o,n)}}if(0!==t.iterator){let r,i=t.iterator;for(;r=n.nodes[n.indexes[i]];)if(n.indexes[i]+=1,!r[Ik])return r[Ik]=!0,void e.push($k(r));t.iterator=0,delete n.indexes[i]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,0===e)return void(n.nodes&&n.nodes.length&&(n[Ik]=!0,t.iterator=n.getIterator()));if(this.listeners[e])return void(t.visitors=this.listeners[e])}e.pop()}walkSync(e){e[Ik]=!0;let t=jk(e);for(let n of t)if(0===n)e.nodes&&e.each(e=>{e[Ik]||this.walkSync(e)});else{let t=this.listeners[n];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};Uk.registerPostcss=e=>{Bk=e};var Gk=Uk;Uk.default=Uk,Rk.registerLazyResult(Uk),Mk.registerLazyResult(Uk);var Wk=rx,Zk=uv,Vk=Sk,Hk=Tx,Yk=class{constructor(e,t,n){let r;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=n,this._map=void 0;let i=Zk;this.result=new Hk(this._processor,r,this._opts),this.result.css=t;let o=this;Object.defineProperty(this.result,"root",{get:()=>o.root});let s=new Wk(i,r,this._opts,t);if(s.isMap()){let[e,t]=s.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=Vk;try{e=t(this._css,this._opts)}catch(n){this.error=n}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},qk=Yk;Yk.default=Yk;var Jk=qk,Kk=Gk,Xk=Sx,Qk=sk,e_=class{constructor(e=[]){this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){let t=[];for(let n of e)if(!0===n.postcss?n=n():n.postcss&&(n=n.postcss),"object"==typeof n&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if("object"==typeof n&&n.postcssPlugin)t.push(n);else if("function"==typeof n)t.push(n);else if("object"!=typeof n||!n.parse&&!n.stringify)throw new Error(n+" is not a PostCSS plugin");return t}process(e,t={}){return this.plugins.length||t.parser||t.stringifier||t.syntax?new Kk(this,e,t):new Jk(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},t_=e_;e_.default=e_,Qk.registerProcessor(e_),Xk.registerProcessor(e_);var n_=kv,r_=zv,i_=sx,o_=tk,s_=Vv,a_=sk,l_=pk;function c_(e,t){if(Array.isArray(e))return e.map(e=>c_(e));let{inputs:n,...r}=e;if(n){t=[];for(let e of n){let n={...e,__proto__:s_.prototype};n.map&&(n.map={...n.map,__proto__:r_.prototype}),t.push(n)}}if(r.nodes&&(r.nodes=e.nodes.map(e=>c_(e,t))),r.source){let{inputId:e,...n}=r.source;r.source=n,null!=e&&(r.source.input=t[e])}if("root"===r.type)return new a_(r);if("decl"===r.type)return new n_(r);if("rule"===r.type)return new l_(r);if("comment"===r.type)return new i_(r);if("atrule"===r.type)return new o_(r);throw new Error("Unknown node type: "+e.type)}var d_=c_;c_.default=c_;var u_=iv,p_=kv,h_=Gk,m_=bx,g_=t_,f_=uv,y_=d_,w_=Sx,b_=Cx,v_=sx,x_=tk,k_=Tx,__=Vv,S_=Sk,I_=lk,C_=pk,E_=sk,A_=bv;function T_(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new g_(e)}T_.plugin=function(e,t){let n,r=!1;function i(...n){console&&console.warn&&!r&&(r=!0,{}.LANG&&{}.LANG.startsWith("cn"));let i=t(...n);return i.postcssPlugin=e,i.postcssVersion=(new g_).version,i}return Object.defineProperty(i,"postcss",{get:()=>(n||(n=i()),n)}),i.process=function(e,t,n){return T_([i(n)]).process(e,t)},i},T_.stringify=f_,T_.parse=S_,T_.fromJSON=y_,T_.list=I_,T_.comment=e=>new v_(e),T_.atRule=e=>new x_(e),T_.decl=e=>new p_(e),T_.rule=e=>new C_(e),T_.root=e=>new E_(e),T_.document=e=>new w_(e),T_.CssSyntaxError=u_,T_.Declaration=p_,T_.Container=m_,T_.Processor=g_,T_.Document=w_,T_.Comment=v_,T_.Warning=b_,T_.AtRule=x_,T_.Result=k_,T_.Input=__,T_.Rule=C_,T_.Root=E_,T_.Node=A_,h_.registerPostcss(T_);var M_=T_;T_.default=T_;var z_=/* @__PURE__ */Yb(M_);z_.stringify,z_.fromJSON,z_.plugin,z_.parse,z_.list,z_.document,z_.comment,z_.atRule,z_.rule,z_.decl,z_.root,z_.CssSyntaxError,z_.Declaration,z_.Container,z_.Processor,z_.Document,z_.Comment,z_.Warning,z_.AtRule,z_.Result,z_.Input,z_.Rule,z_.Root,z_.Node;var O_=class e{constructor(...e){Hb(this,"parentElement",null),Hb(this,"parentNode",null),Hb(this,"ownerDocument"),Hb(this,"firstChild",null),Hb(this,"lastChild",null),Hb(this,"previousSibling",null),Hb(this,"nextSibling",null),Hb(this,"ELEMENT_NODE",1),Hb(this,"TEXT_NODE",3),Hb(this,"nodeType"),Hb(this,"nodeName"),Hb(this,"RRNodeType")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}},R_={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},P_={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},N_={};function L_(e){if(N_[e])return N_[e];const t=globalThis[e],n=t.prototype,r=e in R_?R_[e]:void 0,i=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),o=e in P_?P_[e]:void 0,s=Boolean(o&&o.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return N_[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");document.body.appendChild(r);const i=r.contentWindow;if(!i)return t.prototype;const o=i[e].prototype;return document.body.removeChild(r),o?N_[e]=o:n}catch{return n}}var D_={};function j_(e,t,n){var r;const i=`${e}.${String(n)}`;if(D_[i])return D_[i].call(t);const o=L_(e),s=null==(r=Object.getOwnPropertyDescriptor(o,n))?void 0:r.get;return s?(D_[i]=s,s.call(t)):t[n]}var $_={};function F_(e,t,n){const r=`${e}.${String(n)}`;if($_[r])return $_[r].bind(t);const i=L_(e)[n];return"function"!=typeof i?t[n]:($_[r]=i,i.bind(t))}function B_(){return L_("MutationObserver").constructor}function U_(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var G_={ownerDocument:function(e){return j_("Node",e,"ownerDocument")},childNodes:function(e){return j_("Node",e,"childNodes")},parentNode:function(e){return j_("Node",e,"parentNode")},parentElement:function(e){return j_("Node",e,"parentElement")},textContent:function(e){return j_("Node",e,"textContent")},contains:function(e,t){return F_("Node",e,"contains")(t)},getRootNode:function(e){return F_("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?j_("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?j_("Element",e,"shadowRoot"):null},querySelector:function(e,t){return j_("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return j_("Element",e,"querySelectorAll")(t)},mutationObserver:B_,patch:U_};function W_(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var Z_={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function V_(e,t,n={}){let r=null,i=0;return function(...o){const s=Date.now();i||!1!==n.leading||(i=s);const a=t-(s-i),l=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),i=s,e.apply(l,o)):r||!1===n.trailing||(r=setTimeout(()=>{i=!1===n.leading?0:Date.now(),r=null,e.apply(l,o)},a))}}function H_(e,t,n,r,i=window){const o=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),o&&o.set&&o.set.call(this,e)}}),()=>H_(e,t,o||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Z_=new Proxy(Z_,{get:(e,t,n)=>Reflect.get(e,t,n)}));var Y_=Date.now;function q_(e){var t,n,r,i;const o=e.document;return{left:o.scrollingElement?o.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:o.documentElement.scrollLeft||(null==o?void 0:o.body)&&(null==(t=G_.parentElement(o.body))?void 0:t.scrollLeft)||(null==(n=null==o?void 0:o.body)?void 0:n.scrollLeft)||0,top:o.scrollingElement?o.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==o?void 0:o.documentElement.scrollTop)||(null==o?void 0:o.body)&&(null==(r=G_.parentElement(o.body))?void 0:r.scrollTop)||(null==(i=null==o?void 0:o.body)?void 0:i.scrollTop)||0}}function J_(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function K_(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function X_(e){return e?e.nodeType===e.ELEMENT_NODE?e:G_.parentElement(e):null}function Q_(e,t,n,r){if(!e)return!1;const i=X_(e);if(!i)return!1;try{if("string"==typeof t){if(i.classList.contains(t))return!0;if(r&&null!==i.closest("."+t))return!0}else if(tf(i,t,r))return!0}catch(o){}if(n){if(i.matches(n))return!0;if(r&&null!==i.closest(n))return!0}return!1}function eS(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function tS(e,t){if(Ig(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=G_.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||tS(r,t))}function nS(e){return Boolean(e.changedTouches)}function rS(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function iS(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function oS(e){return!!e&&(e instanceof O_&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(G_.shadowRoot(e)))}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(Y_=()=>/* @__PURE__ */(new Date).getTime());var sS=class{constructor(){ug(this,"id",1),ug(this,"styleIDMap",/* @__PURE__ */new WeakMap),ug(this,"idStyleMap",/* @__PURE__ */new Map)}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=/* @__PURE__ */new WeakMap,this.idStyleMap=/* @__PURE__ */new Map,this.id=1}generateId(){return this.id++}};function aS(e){var t;let n=null;return"getRootNode"in e&&(null==(t=G_.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&G_.host(G_.getRootNode(e))&&(n=G_.host(G_.getRootNode(e))),n}function lS(e){const t=G_.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=aS(n);)n=t;return n}(e);return G_.contains(t,n)}function cS(e){const t=G_.ownerDocument(e);return!!t&&(G_.contains(t,e)||lS(e))}var dS=/* @__PURE__ */(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(dS||{}),uS=/* @__PURE__ */(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(uS||{}),pS=/* @__PURE__ */(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(pS||{}),hS=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(hS||{}),mS=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(mS||{}),gS=/* @__PURE__ */(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(gS||{}),fS=/* @__PURE__ */(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(fS||{});function yS(e){return"__ln"in e}var wS,bS=class{constructor(){ug(this,"length",0),ug(this,"head",null),ug(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&yS(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&yS(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},vS=(e,t)=>`${e}@${t}`,xS=class{constructor(){ug(this,"frozen",!1),ug(this,"locked",!1),ug(this,"texts",[]),ug(this,"attributes",[]),ug(this,"attributeMap",/* @__PURE__ */new WeakMap),ug(this,"removes",[]),ug(this,"mapRemoves",[]),ug(this,"movedMap",{}),ug(this,"addedSet",/* @__PURE__ */new Set),ug(this,"movedSet",/* @__PURE__ */new Set),ug(this,"droppedSet",/* @__PURE__ */new Set),ug(this,"removesSubTreeCache",/* @__PURE__ */new Set),ug(this,"mutationCb"),ug(this,"blockClass"),ug(this,"blockSelector"),ug(this,"maskTextClass"),ug(this,"maskTextSelector"),ug(this,"inlineStylesheet"),ug(this,"maskInputOptions"),ug(this,"maskTextFn"),ug(this,"maskInputFn"),ug(this,"keepIframeSrcFn"),ug(this,"recordCanvas"),ug(this,"inlineImages"),ug(this,"slimDOMOptions"),ug(this,"dataURLOptions"),ug(this,"doc"),ug(this,"mirror"),ug(this,"iframeManager"),ug(this,"stylesheetManager"),ug(this,"shadowDomManager"),ug(this,"canvasManager"),ug(this,"processedNodeManager"),ug(this,"unattachedDoc"),ug(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),ug(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new bS,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},i=i=>{const o=G_.parentNode(i);if(!o||!cS(i))return;let s=!1;if(i.nodeType===Node.TEXT_NODE){const e=o.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(o)&&(s=!0)}const a=Ig(o)?this.mirror.getId(aS(i)):this.mirror.getId(o),l=r(i);if(-1===a||-1===l)return n.addNode(i);const c=af(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{rS(e,this.mirror)&&this.iframeManager.addIframe(e),iS(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),oS(i)&&this.shadowDomManager.addShadowRoot(G_.shadowRoot(i),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});c&&(e.push({parentId:a,nextId:l,node:c}),t.add(c.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)_S(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(G_.parentNode(a))||i(a);for(const a of this.addedSet)SS(this.droppedSet,a)||_S(this.removesSubTreeCache,a,this.mirror)?SS(this.movedSet,a)?i(a):this.droppedSet.add(a):i(a);let o=null;for(;n.length;){let e=null;if(o){const t=this.mirror.getId(G_.parentNode(o.value)),n=r(o.value);-1!==t&&-1!==n&&(e=o)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(G_.parentNode(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=G_.parentNode(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=G_.host(r);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}o=e.previous,n.removeNode(e.value),i(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=G_.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=/* @__PURE__ */new WeakMap,this.removes=[],this.addedSet=/* @__PURE__ */new Set,this.movedSet=/* @__PURE__ */new Set,this.droppedSet=/* @__PURE__ */new Set,this.removesSubTreeCache=/* @__PURE__ */new Set,this.movedMap={},this.mutationCb(s))}),ug(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const n=Array.from(G_.childNodes(e),e=>G_.textContent(e)||"").join("");t.attributes.value=Mg({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Rg(e),value:n,maskInputFn:this.maskInputFn})}),ug(this,"processMutation",e=>{if(!eS(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=G_.textContent(e.target);Q_(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:nf(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,X_(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const n=e.target;let r=e.attributeName,i=e.target.getAttribute(r);if("value"===r){const e=Rg(n);i=Mg({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:i,maskInputFn:this.maskInputFn})}if(Q_(e.target,this.blockClass,this.blockSelector,!1)||i===e.oldValue)return;let o=this.attributeMap.get(e.target);if("IFRAME"===n.tagName&&"src"===r&&!this.keepIframeSrcFn(i)){if(n.contentDocument)return;r="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===r&&"INPUT"===n.tagName&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!ef(n.tagName,r))if(o.attributes[r]=Qg(this.doc,zg(n.tagName),zg(r),i),"style"===r){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(t){this.unattachedDoc=this.doc}const r=this.unattachedDoc.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(n.style)){const t=n.style.getPropertyValue(e),i=n.style.getPropertyPriority(e);t!==r.style.getPropertyValue(e)||i!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===i?t:[t,i]:o._unchangedStyles[e]=[t,i]}for(const e of Array.from(r.style))""===n.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}else"open"===r&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?o.attributes.rr_open_mode="modal":o.attributes.rr_open_mode="non-modal");break}case"childList":if(Q_(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),r=Ig(e.target)?this.mirror.getId(G_.host(e.target)):this.mirror.getId(e.target);Q_(e.target,this.blockClass,this.blockSelector,!1)||eS(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(kS(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||tS(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[vS(n,r)]?kS(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!Ig(e.target)||!Cg(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),G_.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),ug(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(eS(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[vS(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Q_(e,this.blockClass,this.blockSelector,!1)||(G_.childNodes(e).forEach(e=>this.genAdds(e)),oS(e)&&G_.childNodes(G_.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function kS(e,t){e.delete(t),G_.childNodes(t).forEach(t=>kS(e,t))}function _S(e,t,n){return 0!==e.size&&function(e,t){const n=G_.parentNode(t);return!!n&&e.has(n)}(e,t)}function SS(e,t){return 0!==e.size&&IS(e,t)}function IS(e,t){const n=G_.parentNode(t);return!!n&&(!!e.has(n)||IS(e,n))}var CS=e=>{if(!wS)return e;return(...t)=>{try{return e(...t)}catch(n){if(wS&&!0===wS(n))return;throw n}}},ES=[];function AS(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function TS(e,t){const n=new xS;ES.push(n),n.init(e);const r=new(B_())(CS(n.processMutations.bind(n)));return r.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),r}function MS({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){if(!1===o.mouseInteraction)return()=>{};const s=!0===o.mouseInteraction||void 0===o.mouseInteraction?{}:o.mouseInteraction,a=[];let l=null;return Object.keys(pS).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(o=>{let s=zg(o);const c=(t=>o=>{const s=AS(o);if(Q_(s,r,i,!0))return;let a=null,c=t;if("pointerType"in o){switch(o.pointerType){case"mouse":a=hS.Mouse;break;case"touch":a=hS.Touch;break;case"pen":a=hS.Pen}a===hS.Touch?pS[t]===pS.MouseDown?c="TouchStart":pS[t]===pS.MouseUp&&(c="TouchEnd"):hS.Pen}else nS(o)&&(a=hS.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===hS.Touch||c.startsWith("Mouse")&&a===hS.Mouse)&&(a=null)):pS[t]===pS.Click&&(a=l,l=null);const d=nS(o)?o.changedTouches[0]:o;if(!d)return;const u=n.getId(s),{clientX:p,clientY:h}=d;CS(e)({type:pS[c],id:u,x:p,y:h,...null!==a&&{pointerType:a}})})(o);if(window.PointerEvent)switch(pS[o]){case pS.MouseDown:case pS.MouseUp:s=s.replace("mouse","pointer");break;case pS.TouchStart:case pS.TouchEnd:return}a.push(W_(s,c,t))}),CS(()=>{a.forEach(e=>e())})}function zS({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){return W_("scroll",CS(V_(CS(o=>{const s=AS(o);if(!s||Q_(s,r,i,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=q_(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),o.scroll||100)),t)}var OS=["INPUT","TEXTAREA","SELECT"],RS=/* @__PURE__ */new WeakMap;function PS(e){return function(e,t){if(jS("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||jS("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||jS("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||jS("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function NS(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function LS({mirror:e,stylesheetManager:t},n){var r,i,o;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(G_.host(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(o=null==(i=n.ownerDocument)?void 0:i.defaultView)?void 0:o.ShadowRoot,l=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null==(e=l.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=l.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(i){}return r}}),CS(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function DS(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:o,viewportResizeCb:s,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),i(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),o(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}(e,t),e.recordDOM&&(r=TS(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const i="number"==typeof t.mousemove?t.mousemove:50,o="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const l=V_(CS(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),o),c=CS(V_(CS(e=>{const t=AS(e),{clientX:n,clientY:i}=nS(e)?e.changedTouches[0]:e;s||(s=Y_()),a.push({x:n,y:i,id:r.getId(t),timeOffset:Y_()-s}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?uS.Drag:e instanceof MouseEvent?uS.MouseMove:uS.TouchMove)}),i,{trailing:!1})),d=[W_("mousemove",c,n),W_("touchmove",c,n),W_("drag",c,n)];return CS(()=>{d.forEach(e=>e())})}(e),o=MS(e),s=zS(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return W_("resize",CS(V_(CS(()=>{const t=J_(),i=K_();n===t&&r===i||(e({width:Number(i),height:Number(t)}),n=t,r=i)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:o,ignoreSelector:s,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(e){let n=AS(e);const c=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=G_.parentElement(n)),!n||!u||OS.indexOf(u)<0||Q_(n,r,i,!0))return;if(n.classList.contains(o)||s&&n.matches(s))return;let h=n.value,m=!1;const g=Rg(n)||"";"radio"===g||"checkbox"===g?m=n.checked:(a[u.toLowerCase()]||a[g])&&(h=Mg({element:n,maskInputOptions:a,tagName:u,type:g,value:h,maskInputFn:l})),p(n,d?{text:h,isChecked:m,userTriggered:c}:{text:h,isChecked:m});const f=n.name;"radio"===g&&f&&m&&t.querySelectorAll(`input[type="radio"][name="${f}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,d?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function p(t,r){const i=RS.get(t);if(!i||i.text!==r.text||i.isChecked!==r.isChecked){RS.set(t,r);const i=n.getId(t);CS(e)({...r,id:i})}}const h=("last"===c.input?["change"]:["input","change"]).map(e=>W_(e,CS(u),t)),m=t.defaultView;if(!m)return()=>{h.forEach(e=>e())};const g=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),f=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&h.push(...f.map(e=>H_(e[0],e[1],{set(){CS(u)({target:this,isTrusted:!1})}},!1,m))),CS(()=>{h.forEach(e=>e())})}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i,doc:o}){const s=CS(o=>V_(CS(i=>{const s=AS(i);if(!s||Q_(s,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d,loop:u}=s;e({type:o,id:r.getId(s),currentTime:a,volume:l,muted:c,playbackRate:d,loop:u})}),i.media||500)),a=[W_("play",s(gS.Play),o),W_("pause",s(gS.Pause),o),W_("seeked",s(gS.Seeked),o),W_("volumechange",s(gS.VolumeChange),o),W_("ratechange",s(gS.RateChange),o)];return CS(()=>{a.forEach(e=>e())})}(e);let d=()=>{},u=()=>{},p=()=>{},h=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:CS((r,i,o)=>{const[s,a]=o,{id:l,styleId:c}=NS(i,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:a}]}),r.apply(i,o)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const i=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[i,n])};const o=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:CS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=NS(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:s}]}),r.apply(i,o)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:CS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=NS(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:s}),r.apply(i,o)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:CS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=NS(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:s}),r.apply(i,o)})}));const l={};$S("CSSGroupingRule")?l.CSSGroupingRule=r.CSSGroupingRule:($S("CSSMediaRule")&&(l.CSSMediaRule=r.CSSMediaRule),$S("CSSConditionRule")&&(l.CSSConditionRule=r.CSSConditionRule),$S("CSSSupportsRule")&&(l.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(l).forEach(([r,i])=>{c[r]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=new Proxy(c[r].insertRule,{apply:CS((r,i,o)=>{const[s,a]=o,{id:l,styleId:c}=NS(i.parentStyleSheet,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:[...PS(i),a||0]}]}),r.apply(i,o)})}),i.prototype.deleteRule=new Proxy(c[r].deleteRule,{apply:CS((r,i,o)=>{const[s]=o,{id:a,styleId:l}=NS(i.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...PS(i),s]}]}),r.apply(i,o)})})}),CS(()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=o,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})})}(e,{win:n}),u=LS(e,e.doc),p=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){const o=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:CS((i,s,a)=>{var l;const[c,d,u]=a;if(n.has(c))return o.apply(s,[c,d,u]);const{id:p,styleId:h}=NS(null==(l=s.parentRule)?void 0:l.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:c,value:d,priority:u},index:PS(s.parentRule)}),i.apply(s,a)})});const s=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:CS((i,o,a)=>{var l;const[c]=a;if(n.has(c))return s.apply(o,[c]);const{id:d,styleId:u}=NS(null==(l=o.parentRule)?void 0:l.parentStyleSheet,t,r.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:c},index:PS(o.parentRule)}),i.apply(o,a)})}),CS(()=>{i.CSSStyleDeclaration.prototype.setProperty=o,i.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(h=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],i=/* @__PURE__ */new WeakMap,o=n.FontFace;n.FontFace=function(e,t,n){const r=new o(e,t,n);return i.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=U_(t.fonts,"add",function(t){return function(n){return setTimeout(CS(()=>{const t=i.get(n);t&&(e(t),i.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=o}),r.push(s),CS(()=>{r.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:o}=e;let s=!0;const a=CS(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const{startContainer:o,startOffset:s,endContainer:l,endOffset:c}=e.getRangeAt(t);Q_(o,r,i,!0)||Q_(l,r,i,!0)||a.push({start:n.getId(o),startOffset:s,end:n.getId(l),endOffset:c})}o({ranges:a})});return a(),W_("selectionchange",a)}(e),g=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?U_(n.customElements,"define",function(e){return function(n,r,i){try{t({define:{name:n}})}catch(o){}return e.apply(this,[n,r,i])}}):()=>{}}(e),f=[];for(const y of e.plugins)f.push(y.observer(y.callback,n,y.options));return CS(()=>{ES.forEach(e=>e.reset()),r?.disconnect(),i(),o(),s(),a(),l(),c(),d(),u(),p(),h(),m(),g(),f.forEach(e=>e())})}function jS(e){return void 0!==window[e]}function $S(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var FS=class{constructor(e){ug(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),ug(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const i=n||this.getIdToRemoteIdMap(e),o=r||this.getRemoteIdToIdMap(e);let s=i.get(t);return s||(s=this.generateIdFn(),i.set(t,s),o.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const i=r.get(t);return i||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=/* @__PURE__ */new WeakMap,void(this.iframeRemoteIdToIdMap=/* @__PURE__ */new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}},BS=class{constructor(e){ug(this,"iframes",/* @__PURE__ */new WeakMap),ug(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),ug(this,"crossOriginIframeMirror",new FS(Vg)),ug(this,"crossOriginIframeStyleMirror"),ug(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),ug(this,"mirror"),ug(this,"mutationCb"),ug(this,"wrappedEmit"),ug(this,"loadListener"),ug(this,"stylesheetManager"),ug(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new FS(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,r;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(n=e.contentWindow)||n.addEventListener("message",this.handleMessage.bind(this))),null==(r=this.loadListener)||r.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case dS.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:dS.IncrementalSnapshot,data:{source:uS.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case dS.Meta:case dS.Load:case dS.DomContentLoaded:return!1;case dS.Plugin:return t;case dS.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case dS.IncrementalSnapshot:switch(t.data.source){case uS.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case uS.Drag:case uS.TouchMove:case uS.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case uS.ViewportResize:return!1;case uS.MediaInteraction:case uS.MouseInteraction:case uS.Scroll:case uS.CanvasMutation:case uS.Input:return this.replaceIds(t.data,e,["id"]),t;case uS.StyleSheetRule:case uS.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case uS.Font:return t;case uS.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case uS.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(n=t.data.styles)||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,r){for(const i of r)(Array.isArray(t[i])||"number"==typeof t[i])&&(Array.isArray(t[i])?t[i]=e.getIds(n,t[i]):t[i]=e.getId(n,t[i]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===fS.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},US=class{constructor(e){ug(this,"shadowDoms",/* @__PURE__ */new WeakSet),ug(this,"mutationCb"),ug(this,"scrollCb"),ug(this,"bypassOptions"),ug(this,"mirror"),ug(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!Cg(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=TS({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(zS({...this.bypassOptions,scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(G_.host(e))),this.restoreHandlers.push(LS({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(U_(e.prototype,"attachShadow",function(e){return function(r){const i=e.call(this,r),o=G_.shadowRoot(this);return o&&cS(this)&&n.addShadowRoot(o,t),i}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},GS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",WS="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ZS=0;ZS<64;ZS++)WS[GS.charCodeAt(ZS)]=ZS;var VS=function(e){var t,n=new Uint8Array(e),r=n.length,i="";for(t=0;t<r;t+=3)i+=GS[n[t]>>2],i+=GS[(3&n[t])<<4|n[t+1]>>4],i+=GS[(15&n[t+1])<<2|n[t+2]>>6],i+=GS[63&n[t+2]];return r%3==2?i=i.substring(0,i.length-1)+"=":r%3==1&&(i=i.substring(0,i.length-2)+"=="),i},HS=/* @__PURE__ */new Map;var YS=(e,t,n)=>{if(!e||!KS(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=HS.get(e);return n||(n=/* @__PURE__ */new Map,HS.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let i=r.indexOf(e);return-1===i&&(i=r.length,r.push(e)),i};function qS(e,t,n){if(e instanceof Array)return e.map(e=>qS(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:VS(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[qS(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[qS(e.data,t,n),e.width,e.height]}:KS(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:YS(e,t,n)}:e}var JS=(e,t,n)=>e.map(e=>qS(e,t,n)),KS=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function XS(e,t,n,r){const i=[];try{const o=U_(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(i,...o){if(!Q_(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(i);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(o[0]&&"object"==typeof o[0]){const e=o[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else o.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[i,...o])}});i.push(o)}catch{}return()=>{i.forEach(e=>e())}}function QS(e,t,n,r,i,o){const s=[],a=Object.getOwnPropertyNames(e);for(const l of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if("function"!=typeof e[l])continue;const a=U_(e,l,function(e){return function(...s){const a=e.apply(this,s);if(YS(a,o,this),"tagName"in this.canvas&&!Q_(this.canvas,r,i,!0)){const e={type:t,property:l,args:JS(s,o,this)};n(this.canvas,e)}return a}});s.push(a)}catch{const r=H_(e,l,{set(e){n(this.canvas,{type:t,property:l,args:[e],setter:!0})}});s.push(r)}return s}var eI="undefined"!=typeof window&&window.Blob&&new Blob([(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0)))("KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=")],{type:"text/javascript;charset=utf-8"});function tI(e){let t;try{if(t=eI&&(window.URL||window.webkitURL).createObjectURL(eI),!t)throw"";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),n}catch(n){return new Worker("data:text/javascript;base64,KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",{name:null==e?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}var nI,rI,iI,oI=class{constructor(e){ug(this,"pendingCanvasMutations",/* @__PURE__ */new Map),ug(this,"rafStamps",{latestId:0,invokeId:null}),ug(this,"mirror"),ug(this,"mutationCb"),ug(this,"resetObservers"),ug(this,"frozen",!1),ug(this,"locked",!1),ug(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:n,blockClass:r,blockSelector:i,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,i),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,i,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){const o=XS(t,n,r,!0),s=/* @__PURE__ */new Map,a=new tI;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:i,height:o}=e.data;this.mutationCb({id:t,type:mS["2D"],commands:[{property:"clearRect",args:[0,0,i,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{Q_(t,n,r,!0)||e.push(t)}),e})().forEach(async e=>{var t;const n=this.mirror.getId(e);if(s.get(n))return;if(0===e.width||0===e.height)return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null==(t=null==n?void 0:n.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=await createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[r])})),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{o(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=XS(e,t,n,!1),i=function(e,t,n,r){const i=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const o=U_(t.CanvasRenderingContext2D.prototype,s,function(i){return function(...o){return Q_(this.canvas,n,r,!0)||setTimeout(()=>{const n=JS(o,t,this);e(this.canvas,{type:mS["2D"],property:s,args:n})},0),i.apply(this,o)}});i.push(o)}catch{const n=H_(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:mS["2D"],property:s,args:[t],setter:!0})}});i.push(n)}return()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const i=[];return i.push(...QS(t.WebGLRenderingContext.prototype,mS.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&i.push(...QS(t.WebGL2RenderingContext.prototype,mS.WebGL2,e,n,r,t)),()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},sI=class{constructor(e){ug(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),ug(this,"mutationCb"),ug(this,"adoptedStyleSheetCb"),ug(this,"styleMirror",new sS),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const i of e){let e;this.styleMirror.has(i)?e=this.styleMirror.getId(i):(e=this.styleMirror.add(i),r.push({styleId:e,rules:Array.from(i.rules||CSSRule,(e,t)=>({rule:Ag(e,i.href),index:t}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=/* @__PURE__ */new WeakSet}trackStylesheetInLinkElement(e){}},aI=class{constructor(){ug(this,"nodeMap",/* @__PURE__ */new WeakMap),ug(this,"active",!1)}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=/* @__PURE__ */new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||/* @__PURE__ */new Set).add(t))}destroy(){}},lI=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(Xm=e.contentWindow)?void 0:Xm.Array.from)||Array.from,document.body.removeChild(e)}}catch(mC){}var cI,dI,uI=new Tg;function pI(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:p,slimDOMOptions:h,maskInputFn:m,maskTextFn:g,hooks:f,packFn:y,sampling:w={},dataURLOptions:b={},mousemoveWait:v,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:_=!1,recordAfter:S=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:C=!1,inlineImages:E=!1,plugins:A,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:M=/* @__PURE__ */new Set([]),errorHandler:z}=e;wS=z;const O=!_||window.parent===window;let R=!1;if(!O)try{window.parent.document&&(R=!1)}catch(V){R=!0}if(O&&!t)throw new Error("emit function is required");if(!O&&!R)return()=>{};void 0!==v&&void 0===w.mousemove&&(w.mousemove=v),uI.reset();const P=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==p?p:{password:!0},N=sf(h);let L;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();let D=0;const j=e=>{for(const t of A||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!R&&(e=y(e)),e};nI=(e,i)=>{var o;const s=e;if(s.timestamp=Y_(),!(null==(o=ES[0])?void 0:o.isFrozen())||s.type===dS.FullSnapshot||s.type===dS.IncrementalSnapshot&&s.data.source===uS.Mutation||ES.forEach(e=>e.unfreeze()),O)t?.(j(s),i);else if(R){const e={type:"rrweb",event:j(s),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,"*")}if(s.type===dS.FullSnapshot)L=s,D=0;else if(s.type===dS.IncrementalSnapshot){if(s.data.source===uS.Mutation&&s.data.isAttachIframe)return;D++;const e=r&&D>=r,t=n&&s.timestamp-L.timestamp>n;(e||t)&&rI(!0)}};const $=e=>{nI({type:dS.IncrementalSnapshot,data:{source:uS.Mutation,...e}})},F=e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.Scroll,...e}}),B=e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.CanvasMutation,...e}}),U=new sI({mutationCb:$,adoptedStyleSheetCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.AdoptedStyleSheet,...e}})}),G=new BS({mirror:uI,mutationCb:$,stylesheetManager:U,recordCrossOriginIframes:_,wrappedEmit:nI});for(const Y of A||[])Y.getMirror&&Y.getMirror({nodeMirror:uI,crossOriginIframeMirror:G.crossOriginIframeMirror,crossOriginIframeStyleMirror:G.crossOriginIframeStyleMirror});const W=new aI;iI=new oI({recordCanvas:k,mutationCb:B,win:window,blockClass:i,blockSelector:o,mirror:uI,sampling:w.canvas,dataURLOptions:b});const Z=new US({mutationCb:$,scrollCb:F,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:P,dataURLOptions:b,maskTextFn:g,maskInputFn:m,recordCanvas:k,inlineImages:E,sampling:w,slimDOMOptions:N,iframeManager:G,stylesheetManager:U,canvasManager:iI,keepIframeSrcFn:T,processedNodeManager:W},mirror:uI});rI=(e=!1)=>{if(!x)return;nI({type:dS.Meta,data:{href:window.location.href,width:K_(),height:J_()}},e),U.reset(),Z.init(),ES.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new Tg,blockClass:r="rr-block",blockSelector:i=null,maskTextClass:o="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:p,slimDOM:h=!1,dataURLOptions:m,preserveWhiteSpace:g,onSerialize:f,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x=()=>!1}=t||{};return af(e,{doc:e,mirror:n,blockClass:r,blockSelector:i,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:sf(h),dataURLOptions:m,inlineImages:l,recordCanvas:c,preserveWhiteSpace:g,onSerialize:f,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:uI,blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:P,maskTextFn:g,maskInputFn:m,slimDOM:N,dataURLOptions:b,recordCanvas:k,inlineImages:E,onSerialize:e=>{rS(e,uI)&&G.addIframe(e),iS(e,uI)&&U.trackLinkElement(e),oS(e)&&Z.addShadowRoot(G_.shadowRoot(e),document)},onIframeLoad:(e,t)=>{G.attachIframe(e,t),Z.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{U.attachLinkElement(e,t)},keepIframeSrcFn:T});t&&(nI({type:dS.FullSnapshot,data:{node:t,initialOffset:q_(window)}},e),ES.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&U.adoptStyleSheets(document.adoptedStyleSheets,uI.getId(document)))};try{const e=[],t=e=>{var t;return CS(DS)({mutationCb:$,mousemoveCb:(e,t)=>nI({type:dS.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.MouseInteraction,...e}}),scrollCb:F,viewportResizeCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.ViewportResize,...e}}),inputCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.Input,...e}}),mediaInteractionCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.MediaInteraction,...e}}),styleSheetRuleCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.StyleSheetRule,...e}}),styleDeclarationCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.StyleDeclaration,...e}}),canvasMutationCb:B,fontCb:e=>nI({type:dS.IncrementalSnapshot,data:{source:uS.Font,...e}}),selectionCb:e=>{nI({type:dS.IncrementalSnapshot,data:{source:uS.Selection,...e}})},customElementCb:e=>{nI({type:dS.IncrementalSnapshot,data:{source:uS.CustomElement,...e}})},blockClass:i,ignoreClass:s,ignoreSelector:a,maskTextClass:l,maskTextSelector:c,maskInputOptions:P,inlineStylesheet:d,sampling:w,recordDOM:x,recordCanvas:k,inlineImages:E,userTriggeredOnInput:I,collectFonts:C,doc:e,maskInputFn:m,maskTextFn:g,keepIframeSrcFn:T,blockSelector:o,slimDOMOptions:N,dataURLOptions:b,mirror:uI,iframeManager:G,stylesheetManager:U,shadowDomManager:Z,processedNodeManager:W,canvasManager:iI,ignoreCSSAttributes:M,plugins:(null==(t=null==A?void 0:A.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>nI({type:dS.Plugin,data:{plugin:e.name,payload:t}})})))||[]},f)};G.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){}});const n=()=>{rI(),e.push(t(document)),lI=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(W_("DOMContentLoaded",()=>{nI({type:dS.DomContentLoaded,data:{}}),"DOMContentLoaded"===S&&n()})),e.push(W_("load",()=>{nI({type:dS.Load,data:{}}),"load"===S&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")}}),W.destroy(),lI=!1,wS=void 0}}catch(H){}}pI.addCustomEvent=(e,t)=>{if(!lI)throw new Error("please add custom event after start recording");nI({type:dS.Custom,data:{tag:e,payload:t}})},pI.freezePage=()=>{ES.forEach(e=>e.freeze())},pI.takeFullSnapshot=e=>{if(!lI)throw new Error("please take full snapshot after start recording");rI(e)},pI.mirror=uI,(dI=cI||(cI={}))[dI.NotStarted=0]="NotStarted",dI[dI.Running=1]="Running",dI[dI.Stopped=2]="Stopped";var hI=bd(),mI=500,gI=5e5,fI=class{eventQueue=[];estimatedQueueBytes=0;sessionId;stopRecording=null;isRecording=!1;chatId;applicationId;metadataSent=!1;startPromise=null;stopRequested=!1;flushTimer=null;consecutiveFailures=0;isFlushing=!1;constructor(e,t){if(!e||""===e.trim())throw new Error("chatId is required for SessionRecorder");if(!t||t<=0)throw new Error("applicationId (mtxApp) is required for SessionRecorder");hI.info("Constructor called with chatId:",e,"applicationId:",t),this.chatId=e,this.applicationId=t,this.sessionId=e,hI.info("Initialized with sessionId:",this.sessionId)}async sendMetadata(){this.metadataSent?hI.warn("Metadata already sent, skipping"):(hI.info("Sending rrweb/metadata via POST"),await gd.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/metadata",session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,user_agent:navigator.userAgent,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.metadataSent=!0,hI.info("✅ rrweb/metadata sent successfully"))}bufferEvent(e){if(this.eventQueue.push(e),this.estimatedQueueBytes+=new Blob([JSON.stringify(e)]).size,this.eventQueue.length>mI){const e=this.eventQueue.length-mI,t=this.eventQueue.splice(0,e);for(const n of t)this.estimatedQueueBytes-=JSON.stringify(n).length;hI.warn(`⚠️ Event queue exceeded 500, dropped ${e} oldest events`)}this.estimatedQueueBytes>=5e4?this.flush():this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},500))}flush(){if(this.isFlushing)return;if(this.isFlushing=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),0===this.eventQueue.length)return void(this.isFlushing=!1);let e,t;if(this.estimatedQueueBytes<=gI)e=this.eventQueue,t=this.estimatedQueueBytes,this.eventQueue=[],this.estimatedQueueBytes=0;else{for(e=[],t=0;this.eventQueue.length>0;){const n=this.eventQueue[0];if(void 0===n)break;const r=JSON.stringify(n).length;if(t+r>gI&&e.length>0)break;const i=this.eventQueue.shift();void 0!==i&&e.push(i),t+=r,this.estimatedQueueBytes-=r}this.eventQueue.length>0&&!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},0))}hI.debug(`Flushing ${e.length} events (~${t} bytes)`),gd.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/events",session_id:this.sessionId,events:e}}).then(()=>{this.consecutiveFailures=0}).catch(n=>{const r=null!=n&&"object"==typeof n&&"status"in n?n.status:null;if("number"==typeof r&&r>=400&&r<500)return hI.error(`Dropping ${e.length} events after permanent ${String(r)} error:`,n),void(this.consecutiveFailures=0);if(this.consecutiveFailures++,this.consecutiveFailures>5)return hI.error(`Dropping ${e.length} events after 5 consecutive failures:`,n),void(this.consecutiveFailures=0);if(hI.error(`Failed to flush events (attempt ${this.consecutiveFailures}/5), re-queuing:`,n),this.eventQueue=e.concat(this.eventQueue),this.estimatedQueueBytes+=t,this.eventQueue.length>mI){const e=this.eventQueue.length-mI,t=this.eventQueue.splice(0,e);for(const n of t)this.estimatedQueueBytes-=JSON.stringify(n).length;hI.warn(`⚠️ Event queue exceeded 500 after re-queue, dropped ${e} oldest events`)}}).finally(()=>{this.isFlushing=!1})}async start(){if(this.isRecording)hI.warn("Recording already started");else{if(this.startPromise)return this.startPromise;this.startPromise=this.doStart();try{await this.startPromise}finally{this.startPromise=null}}}async doStart(){this.stopRequested=!1;try{if(hI.info("🚀 start() called"),await this.sendMetadata(),this.stopRequested)throw new Error("Recording stopped during startup");const e={emit:e=>{this.bufferEvent(e)},recordCanvas:!1,recordCrossOriginIframes:!1,maskAllInputs:!1,collectFonts:!1,inlineStylesheet:!0,blockClass:"rr-block",ignoreClass:"rr-ignore"};this.stopRecording=pI(e),this.isRecording=!0,hI.info("Recording started with chatId:",this.sessionId)}catch(e){throw hI.error("Failed to start recording:",e),e}}stop(){this.stopRequested=!0,this.stopRecording&&(this.stopRecording(),this.stopRecording=null),(this.isRecording||this.eventQueue.length>0)&&this.flush(),this.isRecording=!1,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.metadataSent=!1,hI.info("Recording stopped")}getSessionId(){return this.sessionId}isActive(){return this.isRecording}},yI=e=>e?.mtxApiHost?e.mtxApiHost:"";function wI(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function bI(e,t="Operation",n){const r=wI(e);return function(e){const t=e instanceof Error?e.message:String(e);return t.includes("Failed to fetch")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("NetworkError")||t.includes("Network request failed")}(e)?{isValid:!1,error:`Cannot connect to API server. Please ensure the API server is running at ${yI(n)||"configured API server"}. Error: ${r}`}:{isValid:!1,error:`${t} failed: ${r}`}}var vI=class{config;async validateConfig(e){return this.config=e,e.mtxId&&e.mtxKey?this.validateByMarketrixId(e.mtxId,e.mtxKey):e.mtxApp&&e.mtxAgent?this.validateByAgentAndApplication(e.mtxApp,e.mtxAgent):{isValid:!1,error:"Please provide either (mtxId + mtxKey) OR (mtxApp + mtxAgent)"}}async validateByMarketrixId(e,t){try{const{items:r}=await gd.widgetSearch({marketrix_id:e,marketrix_key:t});if(!r||0===r.length)return{isValid:!1,error:"Widget not found or invalid credentials"};const i=r.find(e=>"widget"===e.type&&"active"===e.status);if(!i){const e=r.filter(e=>"widget"===e.type);return e.length>0?{isValid:!1,error:`Found widget(s) but none are active. Current status(es): ${e.map(e=>e.status).join(", ")}. Please activate the widget in the dashboard.`}:0===r.length?{isValid:!1,error:"No widgets found for the provided marketrix_id and marketrix_key. Please verify your credentials."}:{isValid:!1,error:`No widget found. Found widget type(s): ${r.map(e=>e.type).join(", ")}. Please create a widget.`}}if(!i.agent_id)return{isValid:!1,error:"Widget missing agent_id",widget:i};try{const e=await gd.agentGet({agent_id:i.agent_id});if(!i.application_id)return{isValid:!1,error:"Widget missing application_id",widget:i,agent:e};return{isValid:!0,widget:i,agent:e,application:await gd.applicationGet({application_id:i.application_id})}}catch(n){return{isValid:!1,error:`Failed to validate agent: ${wI(n)}`,widget:i}}}catch(r){return bI(r,"Widget validation",this.config)}}async validateByAgentAndApplication(e,t){try{const n=await gd.applicationGet({application_id:e}),r=await gd.agentGet({agent_id:t});return r.application_id!==e?{isValid:!1,error:`Agent ID ${t} belongs to application ID ${r.application_id}, but provided application ID is ${e}. Please verify the application ID matches the agent's application_id.`,application:n,agent:r}:{isValid:!0,application:n,agent:r}}catch(n){return bI(n,"Agent and application validation",this.config)}}};function xI(e,t){return"object"==typeof e&&null!==e&&t in e}function kI(e){return null!==e&&e instanceof HTMLElement}function _I(e){return null!==e&&e instanceof HTMLScriptElement}var SI=null,II=class{mtxId;mtxKey;mtxApp;constructor(e,t,n){this.mtxId=e,this.mtxKey=t,this.mtxApp=n}async fetchWidgetSettings(){if(!this.mtxId&&!this.mtxKey&&!this.mtxApp)return null;try{SI||(SI=await gd.widgetGetDefaults({type:"widget"}));const e=SI;if(!e){throw new Error("Failed to fetch default widget settings from API. The API must return widget settings.")}let t=null;if(this.mtxId&&this.mtxKey)t=(await gd.widgetSearch({type:"widget",marketrix_id:this.mtxId,marketrix_key:this.mtxKey})).items;else{if(!this.mtxApp)return null;t=(await gd.widgetSearch({type:"widget",application_id:this.mtxApp})).items}const n=t?.find(e=>"active"===e.status&&"widget"===e.type)||null;if(n?.settings){const t=this.getWidgetSettings(n);if(t){const r={...e,...t};return{...n,settings:r}}}const r=/* @__PURE__ */new Date;return{id:0,application_id:this.mtxApp||0,agent_id:0,type:"widget",settings:e,status:"active",marketrix_id:this.mtxId||"",marketrix_key:this.mtxKey||"",created_at:r,updated_at:r}}catch(e){const t=e instanceof Error?e.message:"Unknown error",n=/* @__PURE__ */new Error(`Failed to fetch widget settings from API: ${t}`);throw n.cause=e,n}}getWidgetSettings(e){if(!e?.settings)return null;const t=e.settings;return function(e){return"object"==typeof e&&null!==e}(n=t)&&xI(n,"widget_enabled")&&"boolean"==typeof n.widget_enabled&&xI(n,"widget_appearance")&&"string"==typeof n.widget_appearance&&xI(n,"widget_position")&&"string"==typeof n.widget_position?t:null;var n}},CI="#6b7280",EI="#1f2937",AI="rgba(255, 255, 255, 0.95)",TI="rgba(255, 255, 255, 0.2)",MI="rgba(0, 0, 0, 0.15)",zI=({message:e="Loading widget settings..."})=>{const[t,n]=p(!1),r=e?.includes("marketrix_id")||e?.includes("marketrix_key");return t?null:/* @__PURE__ */f(Fp,{position:"fixed",style:{bottom:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"420px",backgroundColor:AI,borderRadius:r?"18px":"999px",boxShadow:`0 2px 12px ${MI}`,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"8px",padding:"10px 12px",border:`1px solid ${TI}`,zIndex:9999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[/* @__PURE__ */f(Oh,{align:"center",style:{gap:"10px"},children:[
65
+ /* @__PURE__ */g(Gp,{src:Bp,alt:"",size:28,style:{borderRadius:"50%",overflow:"hidden",flexShrink:0}}),
66
+ /* @__PURE__ */g(Gh,{as:"span",style:{fontSize:"13px",color:EI,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:e}),
67
+ /* @__PURE__ */g(jh,{label:"Dismiss",onClick:()=>n(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:CI,borderRadius:"50%",width:"20px",height:"20px",minWidth:"unset"},children:/* @__PURE__ */g(Ph,{name:"closeSmall",size:12})})]}),r?/* @__PURE__ */g(Gh,{as:"p",style:{fontSize:"12px",color:CI,textAlign:"left",margin:0},children:"Please configure marketrix_id and marketrix_key"}):null]})},OI='/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-900:oklch(21% .034 264.665);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-2{inset:calc(var(--spacing) * 2)}.inset-3{inset:calc(var(--spacing) * 3)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing) * 4)}.top-5{top:calc(var(--spacing) * 5)}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-4{right:calc(var(--spacing) * 4)}.right-5{right:calc(var(--spacing) * 5)}.right-full{right:100%}.bottom-5{bottom:calc(var(--spacing) * 5)}.bottom-16{bottom:calc(var(--spacing) * 16)}.left-0{left:calc(var(--spacing) * 0)}.left-1\\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.left-full{left:100%}.isolate{isolation:isolate}.z-10{z-index:10}.z-20{z-index:20}.z-\\[calc\\(var\\(--layer-dialog\\)\\+1\\)\\]{z-index:calc(var(--layer-dialog) + 1)}.z-\\[var\\(--layer-popover\\)\\]{z-index:var(--layer-popover)}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.m-2{margin:calc(var(--spacing) * 2)}.m-32{margin:calc(var(--spacing) * 32)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-0\\.5{margin-block:calc(var(--spacing) * .5)}.mt-0\\.5{margin-top:calc(var(--spacing) * .5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-0{margin-bottom:calc(var(--spacing) * 0)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.h-0{height:calc(var(--spacing) * 0)}.h-0\\.5{height:calc(var(--spacing) * .5)}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-3\\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[85vh\\]{max-height:85vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-20{min-height:calc(var(--spacing) * 20)}.w-0{width:calc(var(--spacing) * 0)}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-3\\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-full{width:100%}.max-w-\\[500px\\]{max-width:500px}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-14{min-width:calc(var(--spacing) * 14)}.min-w-\\[180px\\]{min-width:180px}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-dialog-content-in{animation:dialog-content-in var(--duration-animation) ease-out}.animate-fade-in{animation:.5s ease-out fade-in}.animate-menu-in{animation:menu-in var(--duration-fade) ease-out}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-\\[var\\(--radius\\)\\]{border-radius:var(--radius)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-4{border-top-style:var(--tw-border-style);border-top-width:4px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-4{border-right-style:var(--tw-border-style);border-right-width:4px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--border)}.border-current{border-color:currentColor}.border-input{border-color:var(--input)}.border-transparent{border-color:#0000}.border-white\\/25{border-color:#ffffff40}@supports (color:color-mix(in lab, red, red)){.border-white\\/25{border-color:color-mix(in oklab, var(--color-white) 25%, transparent)}}.border-t-transparent{border-top-color:#0000}.bg-background{background-color:var(--background)}.bg-card{background-color:var(--card)}.bg-chart-1\\/15{background-color:var(--chart-1)}@supports (color:color-mix(in lab, red, red)){.bg-chart-1\\/15{background-color:color-mix(in oklab, var(--chart-1) 15%, transparent)}}.bg-current{background-color:currentColor}.bg-gray-900{background-color:var(--color-gray-900)}.bg-muted{background-color:var(--muted)}.bg-popover{background-color:var(--popover)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-secondary-bg{background-color:var(--secondary-bg)}.bg-success\\/15{background-color:var(--success)}@supports (color:color-mix(in lab, red, red)){.bg-success\\/15{background-color:color-mix(in oklab, var(--success) 15%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning\\/15{background-color:var(--warning)}@supports (color:color-mix(in lab, red, red)){.bg-warning\\/15{background-color:color-mix(in oklab, var(--warning) 15%, transparent)}}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing) * 0)}.p-0\\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-1\\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-blue-500{color:var(--color-blue-500)}.text-card-foreground{color:var(--card-foreground)}.text-chart-1{color:var(--chart-1)}.text-foreground{color:var(--foreground)}.text-foreground-faint{color:var(--foreground-faint)}.text-foreground-muted{color:var(--foreground-muted)}.text-inherit{color:inherit}.text-muted-foreground{color:var(--muted-foreground)}.text-popover-foreground{color:var(--popover-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-500{color:var(--color-red-500)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-success{color:var(--success)}.text-warning{color:var(--warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow,.shadow-\\[var\\(--shadow\\)\\]{--tw-shadow:var(--shadow);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\,background-color\\]{transition-property:transform,opacity,background-color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-\\[160ms\\]{--tw-duration:.16s;transition-duration:.16s}.duration-\\[167ms\\]{--tw-duration:.167s;transition-duration:.167s}.ease-\\[cubic-bezier\\(0\\.33\\,0\\,0\\,1\\)\\]{--tw-ease:cubic-bezier(.33,0,0,1);transition-timing-function:cubic-bezier(.33,0,0,1)}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.group-focus-within\\:pointer-events-auto:is(:where(.group):focus-within *){pointer-events:auto}.group-focus-within\\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media (hover:hover){.group-hover\\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\\:text-foreground-faint::placeholder{color:var(--foreground-faint)}.focus-within\\:border-foreground-faint:focus-within{border-color:var(--foreground-faint)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\\:border-muted-foreground:hover{border-color:var(--muted-foreground)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-accent:hover{background-color:var(--accent)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary:hover{background-color:var(--primary)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab, var(--primary) 90%, transparent)}}.hover\\:bg-secondary-hover:hover{background-color:var(--secondary-hover)}.hover\\:bg-secondary\\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-secondary\\/80:hover{background-color:color-mix(in oklab, var(--secondary) 80%, transparent)}}.hover\\:bg-transparent:hover{background-color:#0000}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\\:opacity-100:hover{opacity:1}.hover\\:duration-\\[250ms\\]:hover{--tw-duration:.25s;transition-duration:.25s}}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-3:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-ring:focus{--tw-ring-color:var(--ring)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:var(--ring)}.active\\:scale-\\[0\\.85\\]:active{scale:.85}.active\\:duration-\\[134ms\\]:active{--tw-duration:.134s;transition-duration:.134s}.active\\:ease-\\[cubic-bezier\\(0\\.45\\,0\\,0\\.2\\,1\\)\\]:active{--tw-ease:cubic-bezier(.45,0,.2,1);transition-timing-function:cubic-bezier(.45,0,.2,1)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:bg-muted:disabled{background-color:var(--muted)}.disabled\\:opacity-50:disabled{opacity:.5}}:root,:host{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--destructive-foreground:oklch(100% 0 0);--success:oklch(60% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(75% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--border-muted:#e5e7eb4d;--primary-hover:#3b82f6d9;--primary-muted:#3b82f64d;--secondary-bg:#6b728033;--secondary-hover:#6b72804d;--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040;--tracking-normal:0em;--spacing:.25rem;--duration-animation:.3s;--duration-fade:.2s;--widget-width:400px;--widget-height:520px;--layer-tooltip:1000;--layer-popover:1050;--layer-dialog:1100;--layer-toast:1200}.dark,:host(.dark){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(26.9% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(37.1% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(70.4% .191 22.216);--destructive-foreground:oklch(98.5% 0 0);--success:oklch(55% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(70% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(27.5% 0 0);--input:oklch(32.5% 0 0);--ring:oklch(55.6% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(27.5% 0 0);--sidebar-ring:oklch(43.9% 0 0);--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040}@media (prefers-reduced-motion:reduce){:root{--duration-animation:0s;--duration-fade:0s}}@keyframes dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes menu-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes popover-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes tooltip-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes toast-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(-30px)}to{opacity:1;transform:translate(0)}}@keyframes slide-in-right{0%{opacity:0;transform:translate(30px)}to{opacity:1;transform:translate(0)}}.marketrix-widget,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.marketrix-widget-container{z-index:var(--widget-z-index,1210);pointer-events:auto;position:fixed}.marketrix-widget,.marketrix-widget *,[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;box-sizing:border-box;transition:color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,opacity .2s ease-in-out,box-shadow .2s ease-in-out,transform .2s ease-in-out}.marketrix-widget button,.marketrix-widget input,.marketrix-widget textarea,.marketrix-widget select,[data-marketrix-widget] button,[data-marketrix-widget] input,[data-marketrix-widget] textarea,[data-marketrix-widget] select{font:inherit}[data-resizing=true],[data-resizing=true] *{transition:none!important}.gradient-border{border:2px solid;border-image:linear-gradient(to right, var(--foreground), var(--foreground)) 1}.marketrix-widget ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget * ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget * ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget{scrollbar-color:var(--muted) var(--muted-foreground);scrollbar-width:thin}.marketrix-widget ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget * ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget * ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button{background:0 0!important;border:none!important;width:0!important;height:0!important;display:none!important}@keyframes glow-border-pulse{0%,to{border-color:#fff9;box-shadow:0 0 #ffffff4d,0 0 #1f293766}50%{border-color:#fff;box-shadow:0 0 0 2px #fff9,0 0 0 4px #1f29374d}}@keyframes marketrix-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}.marketrix-screen-edge-glow,[data-screen-edge-glow]{animation:1.6s ease-in-out infinite marketrix-screen-edge-pulse}.marketrix-widget-button-processing-glow,.marketrix-widget-button-error-glow{pointer-events:none;filter:blur(14px);will-change:transform, opacity;border-radius:50%;width:140%;height:140%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}@keyframes widget-activity-dash-travel{0%{stroke-dashoffset:0;opacity:.5}18%{stroke-dashoffset:-112px;opacity:1}35%{stroke-dashoffset:-160px;opacity:.65}60%{stroke-dashoffset:-160px;opacity:.45}82%{stroke-dashoffset:-272px;opacity:1}to{stroke-dashoffset:-320px;opacity:.6}}.marketrix-widget-button-processing-activity-ring,.marketrix-widget-button-error-activity-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.marketrix-widget-button-processing-activity-ring rect,.marketrix-widget-button-error-activity-ring rect{fill:none;stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:40 120;animation:1.9s cubic-bezier(.4,0,.2,1) infinite widget-activity-dash-travel}.marketrix-widget-button-processing-activity-ring rect{stroke:#31d06d;filter:drop-shadow(0 0 3px #31d06db3)}.marketrix-widget-button-error-activity-ring rect{stroke:#d0342c;filter:drop-shadow(0 0 3px #d0342cb3)}@keyframes widget-glow-green{0%,to{opacity:.72;background:radial-gradient(circle,#31d06d00 38%,#31d06d61 58%,#31d06d3d 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle,#31d06d00 34%,#31d06d8c 56%,#31d06d54 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-processing-glow{animation:2s ease-in-out infinite widget-glow-green}@keyframes widget-glow-red{0%,to{opacity:.65;background:radial-gradient(circle,#d0342c00 38%,#d0342c57 58%,#d0342c38 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle,#d0342c00 34%,#d0342c80 56%,#d0342c4d 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-error-glow{animation:1.5s ease-in-out infinite widget-glow-red}@keyframes launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.animate-launcher-entrance{animation:.25s ease-out forwards launcher-entrance}@keyframes messenger-entrance{0%{opacity:0;transform:scale(0)}40%{opacity:1}to{transform:scale(1)}}@keyframes messenger-exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)translateY(8px)}}.animate-messenger-entrance{animation:.3s cubic-bezier(0,1.2,1,1) messenger-entrance}.animate-messenger-exit{animation:.2s cubic-bezier(.4,0,.2,1) forwards messenger-exit}@keyframes message-enter{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.animate-message-enter{animation:.2s ease-out message-enter}.view-slide-enter.forward{opacity:0;transform:translate(20px)}.view-slide-enter.back{opacity:0;transform:translate(-20px)}.view-slide-enter-active{opacity:1;transition:transform .15s .15s,opacity .15s .15s;transform:translate(0)}.view-slide-enter-active.forward,.view-slide-enter-active.back{opacity:1;transform:translate(0)}.view-slide-exit-active.forward{opacity:0;transition:transform .15s,opacity .15s;transform:translate(-20px)}.view-slide-exit-active.back{opacity:0;transition:transform .15s,opacity .15s;transform:translate(20px)}[data-view-transition][data-direction=forward]{animation:.3s both viewSlideForward}[data-view-transition][data-direction=back]{animation:.3s both viewSlideBack}@keyframes viewSlideForward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes viewSlideBack{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media print{.marketrix-widget{display:none!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}',RI=null,PI=null,NI=null,LI=!1,DI=!1,jI=0,$I=(e,t)=>{const n=t||"marketrix-widget-container-"+ ++jI;let r;if(e){if(e.querySelector(`#${n}`))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.overflow="visible",e.appendChild(r)}else{if(document.getElementById(n))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",document.body.appendChild(r)}if(r.style.pointerEvents="auto",!kI(r))throw new Error("Container is not an HTMLElement");if(r.shadowRoot)throw new Error("Container already has a shadow root");const i=r.attachShadow({mode:"closed"}),o=document.createElement("style");if(o.textContent=OI,i.appendChild(o),i.querySelector("#marketrix-widget-root"))throw new Error("Mount element already exists in shadow root");const s=document.createElement("div");return s.id="marketrix-widget-root",s.style.pointerEvents="auto",s.style.width="100%",s.style.height="100%",s.style.position="relative",i.appendChild(s),{container:r,shadowRoot:i,mountEl:s}},FI=(e,n,r=!1)=>{const i=h(e);return i.render(/* @__PURE__ */g(t.StrictMode,{children:/* @__PURE__ */g(cg,{previewMode:r,children:/* @__PURE__ */g(sg,{config:n})})})),i},BI=e=>{if(!e)throw new Error("Container is required");e.remove()},UI=()=>PI,GI=()=>null!==RI,WI=e=>{LI=e},ZI=()=>LI,VI=()=>DI,HI=e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(NI){const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove(),NI.unmount(),NI=null}if(document.getElementById("marketrix-widget-loader-container"))throw new Error("Widget loader container already exists");const n=document.createElement("div");n.id="marketrix-widget-loader-container",n.className="marketrix-widget-loader-container",document.body.appendChild(n);const r=n.attachShadow({mode:"closed"}),i=document.createElement("style");i.textContent=OI,r.appendChild(i);const o=document.createElement("div");o.id="marketrix-widget-loader-root",r.appendChild(o);const s=h(o);NI=s,s.render(/* @__PURE__ */g(t.StrictMode,{children:/* @__PURE__ */g(zI,{message:e})}))},YI=()=>{if(NI){NI.unmount(),NI=null;const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove()}},qI=null,JI=(e=0)=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;const t=[0,100,500,1e3,2e3];if(!qI)return;const n=document.querySelectorAll("script[mtx-id], script[mtx-app]"),r=(void 0!==document.currentScript&&null!=document.currentScript&&_I(document.currentScript)&&(document.currentScript.hasAttribute("mtx-id")||document.currentScript.hasAttribute("mtx-app"))?document.currentScript:null)??n[n.length-1];if(!r||!_I(r)){if(0===n.length)return void(GI()||ZI());if(e<5){return void setTimeout(()=>JI(e+1),t[e]||2e3)}if(GI()||ZI())return;return void HI("Please configure mtx-id and mtx-key, or mtx-app and mtx-agent")}const i=r,o=i.getAttribute("mtx-id"),s=i.getAttribute("mtx-key"),a=i.getAttribute("mtx-api-host"),l=i.getAttribute("mtx-app"),c=i.getAttribute("mtx-agent"),d=i.getAttribute("mtx-use-screenshare");if(o&&s){const e={mtxId:o,mtxKey:s};a&&(e.mtxApiHost=a),"false"===d&&(e.use_screenshare=!1),qI(e).catch(e=>{})}else if(l&&c){const e=Number.parseInt(l),t=Number.parseInt(c);if(isNaN(e)||isNaN(t))return void HI("Invalid mtx-app or mtx-agent values");const n={mtxApp:e,mtxAgent:t};a&&(n.mtxApiHost=a),"false"===d&&(n.use_screenshare=!1),qI(n).catch(e=>{})}else{if(GI()||ZI())return;HI("Please configure mtx-id and mtx-key, or mtx-app and mtx-agent")}},KI=null,XI=!1,QI=!1,eC=null,tC=null,nC=null;async function rC(e,t){if(WI(!0),GI())return void WI(!1);if(VI())return void WI(!1);window.__mtx={state:"initializing"},e.mtxApiHost&&hd(e.mtxApiHost),HI("Validating widget configuration...");const n=await(new vI).validateConfig(e);if(!n.isValid)return HI(n.error||"Widget validation failed. Please check your configuration."),WI(!1),void(window.__mtx=void 0);let r;try{r=await async function(e,t){if(!t.isValid)throw new Error(t.error||"Widget validation failed");HI("Loading widget settings...");try{const t=new II(e.mtxId,e.mtxKey,e.mtxApp),n=await t.fetchWidgetSettings(),r=n?t.getWidgetSettings(n):null;if(!r)throw new Error("WidgetService did not return widget settings");const i=["widget_enabled","widget_appearance","widget_position","widget_device","widget_header","widget_body","widget_greeting","widget_feature_tell","widget_feature_show","widget_feature_do","widget_feature_human","widget_background_color","widget_text_color","widget_border_color","widget_accent_color","widget_secondary_color","widget_border_radius","widget_font_size","widget_width","widget_height","widget_shadow","widget_animation_duration","widget_fade_duration","widget_bounce_effect","widget_chips"].filter(e=>void 0===r[e]);if(i.length>0)throw new Error(`Widget settings are incomplete. Missing required fields: ${i.join(", ")}. The API must return all widget settings.`);return Wd(r,e)}catch(mC){throw mC}finally{YI()}}(e,n)}catch(s){return HI(s instanceof Error?s.message:"Failed to initialize widget"),WI(!1),void(window.__mtx=void 0)}(e=>{PI=e})(r);const{mountEl:i}=$I(t,`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);var o;o=FI(i,r),RI=o,DI=!0,WI(!1),window.__mtx={state:"active"};try{if(KI&&XI)return;KI&&(KI.stop(),KI=null,XI=!1),nC=new AbortController;const t=(e,t)=>{if(!(KI&&XI||QI)){QI=!0;try{KI=new fI(t,e),XI=!0;const n=KI;eC=n.start().catch(e=>{KI===n&&(XI=!1)}).finally(()=>{QI=!1,KI===n&&(eC=null)})}catch{QI=!1}}},n=e=>{const n=Od.getChatId();n?t(e,n):window.addEventListener("marketrix:chatid",()=>{const n=Od.getChatId();n&&t(e,n)},{once:!0,signal:nC?.signal})},i=r.mtxApp??e.mtxApp;if(i)n(i);else{const e=Bd.getInstance(),t={onRegistered:r=>{r&&n(r),e.removeCallbacks(t)}};e.addCallbacks(t)}}catch(s){XI=!1}}var iC=!1,oC=async(e,t)=>{if(!window.__mtx?.state){if(tC)return tC;if(iC)return Promise.resolve();if(!GI()&&!VI()){tC=rC(e,t),iC=!0;try{await tC}finally{tC=null,iC=!1}}}},sC=()=>{if(RI){RI.unmount(),RI=null,PI=null,DI=!1;const e=document.querySelector(".marketrix-widget-container");e&&BI(e)}nC?.abort(),nC=null,KI&&(KI.stop(),KI=null,XI=!1,QI=!1,eC=null),tC=null,window.__mtx=void 0,YI()},aC=()=>{KI&&KI.stop()},lC=async()=>{if(!KI)throw new Error("Session recording not available. Ensure the widget is initialized with mtxApiHost and mtxApp.");if(eC&&(await eC.catch(()=>{}),KI?.isActive()))return;if(KI.isActive())return;const e=KI.start();eC=e;try{await e}finally{eC===e&&(eC=null)}},cC=()=>KI?.isActive()??!1,dC=async e=>{if(GI()){const t=UI();if(!t)throw new Error("Widget not initialized");const n={...t,...e};sC(),await oC(n)}},uC=({settings:e,container:t,mtxId:n,mtxKey:r,mtxApiHost:i})=>{const o=u(null),s=u(null),l=u(null),c=u(null);return a(()=>{const a=t??o?.current?.parentElement??document.body;if(!a||!kI(a))return;c.current||(c.current=`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);const{container:d,mountEl:u}=$I(a,c.current);l.current=d;const p={...Wd(e,{mtxId:n,mtxKey:r,mtxApiHost:i}),isPreviewMode:!0,widget_enabled:e.widget_enabled??!0};s.current&&(s.current.unmount(),s.current=null);const m=h(u);return s.current=m,m.render(/* @__PURE__ */g(cg,{previewMode:!0,children:/* @__PURE__ */g(sg,{config:p})})),()=>{s.current&&(s.current.unmount(),s.current=null),l.current&&(BI(l.current),l.current=null,c.current=null)}},[e,t]),t?null:/* @__PURE__ */g("div",{ref:o,style:{width:"100%",height:"100%",position:"relative"}})},pC=async e=>{WI(!0);const t=e.container;if("settings"in e&&void 0!==e.settings){const{settings:n,container:r,...i}=e,o={...Wd(n,i),isPreviewMode:!0},{mountEl:s}=$I(t,`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);FI(s,o,!0),WI(!1)}else if("mtxId"in e&&void 0!==e.mtxId&&void 0!==e.mtxKey){const{mtxId:n,mtxKey:r,container:i,...o}=e;await oC({mtxId:n,mtxKey:r,...o},t)}else{if(!("mtxApp"in e)||void 0===e.mtxApp||void 0===e.mtxAgent)throw WI(!1),new Error("Invalid configuration: provide either settings (preview), mtxId+mtxKey (production), or mtxApp+mtxAgent (dev)");{const{mtxApp:n,mtxAgent:r,container:i,...o}=e;await oC({mtxApp:n,mtxAgent:r,...o},t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{"function"==typeof e&&(qI=e,JI())})(oC)}catch(e){}},0);var hC={MarketrixWidget:uC,mountWidget:pC,initWidget:oC,unmountWidget:sC,updateMarketrixConfig:dC,getCurrentConfig:UI,startRecording:lC,stopRecording:aC,getRecordingState:cC};export{uC as MarketrixWidget,hC as default,UI as getCurrentConfig,cC as getRecordingState,oC as initWidget,pC as mountWidget,lC as startRecording,aC as stopRecording,sC as unmountWidget,dC as updateMarketrixConfig};
68
68
  //# sourceMappingURL=widget.mjs.map