@marketrix.ai/widget 4.0.116 → 4.0.118

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.
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { CSSProperties } from 'react';
17
17
  export type RadiusToken = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'pill';
18
- export type TextTone = 'default' | 'muted' | 'faint' | 'primary' | 'inherit';
18
+ export type TextTone = 'default' | 'muted' | 'faint' | 'inherit';
19
19
  export type TextLeading = 'tight' | 'snug' | 'normal' | 'relaxed';
20
20
  export type NotificationTone = 'info' | 'error' | 'neutral';
21
21
  export declare const RADIUS: Record<RadiusToken, string>;
@@ -1,2 +1 @@
1
1
  export declare function logWarn(message: string, cause?: unknown): void;
2
- export declare function logError(message: string, cause?: unknown): void;
package/dist/widget.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as s,useEffect as a,useImperativeHandle as c,useLayoutEffect as l,useMemo as u,useRef as d,useState as p,useSyncExternalStore as h,useSyncExternalStore as f}from"react";import{createRoot as m}from"react-dom/client";import*as g from"react-dom";import{Fragment as y,jsx as b,jsxs as v}from"react/jsx-runtime";function w(e){return Array.isArray(e)?e:null==e?[]:[e]}var x="orpc",S=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function k(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function C(){return globalThis["__@orpc/shared@1.15.0/otel/config__"]}function E(e,t={},n){return(C()?.tracer)?.startSpan(e,t,n)}function I(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 M({name:e,context:t,...n},r){const o=C()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw I(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function T(e,t){const n=C();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function R(e){return!(!e||"object"!=typeof e)&&"next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator]}var O=Symbol.asyncDispose??Symbol.for("asyncDispose"),A=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[O](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function _({name:e,...t},n){let r;return new A(async()=>{r??=E(e);try{const e=await T(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw I(r,o,t),o}},async e=>{try{"next"!==e&&await T(r,()=>n.return?.())}catch(o){throw I(r,o,t),o}finally{r?.end()}})}function D(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function P(e){if(e)return JSON.parse(e)}function N(e){return JSON.stringify(e)}function L(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function F(e){return!!e&&("object"==typeof e||"function"==typeof e)}function z(e,...t){return"function"==typeof e?e(...t):e}function $(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)&&W.test(t.toString()));var t}))return Reflect.apply(t,n,r);let o=!0;r[0].call(n,$(new Proxy(e,{get:(e,t,n)=>{if(!o||"then"!==t)return Reflect.get(e,t,n);o=!1}})))}})}})}var B,W=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/,U=/* @__PURE__ */new Set(["bind","valueOf","toString","toJSON"]),H={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"}},j=class e extends Error{defined;code;status;data;static{const t=Symbol.for("__@orpc/client@1.15.0/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(B=globalThis[t]).add(e)}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||H[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??H[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(B.has(this)){const t=function(e){return F(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&B.has(t))return!0}return super[Symbol.hasInstance](e)}};function q(e){return e<200||e>=400}function V(e){if(!L(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 Y(e,t={}){return new j(e.code,{...t,...e})}var K=class extends TypeError{},X=class extends TypeError{},G=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}},J=/\r\n|\r(?!\n)|\n/,Z=/(?:\r\n|\r(?!\n)|\n){2}/,Q=/(?:\r\n|\r(?!\n)|\n){2}/g;function ee(e){const t={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const n of e.split(J)){if(""===n)continue;const e=n.indexOf(":"),r=-1===e?"":n.slice(32===n.charCodeAt(e+1)?e+2:e+1);if(0!==e)switch(-1===e?n:n.slice(0,e)){case"data":t.data=void 0===t.data?r:`${t.data}\n${r}`;break;case"event":t.event=r;break;case"id":t.id=r;break;case"retry":{const e=Number.parseInt(r,10);e>=0&&e.toString()===r&&(t.retry=e);break}}else t.comments.push(r)}return t}var te=class{constructor(e={}){this.options=e}pending=[];tail="";discardLeadingLF=!1;feed(e){if(""===e)return;if(this.discardLeadingLF&&(this.discardLeadingLF=!1,10===e.charCodeAt(0)&&""===(e=e.slice(1))))return;const t=this.tail+e;if(!Z.test(t))return this.pending.push(e),void(this.tail=t.slice(-3));this.pending.push(e);const n=1===this.pending.length?e:this.pending.join(""),r=n.length-t.length,o=[];let i=0;for(const a of t.matchAll(Q))o.push(n.slice(i,r+a.index)),i=r+a.index+a[0].length;const s=n.slice(i);this.pending.length=0,this.tail=s.slice(-3),""===s?this.discardLeadingLF=13===e.charCodeAt(e.length-1):this.pending.push(s);for(const a of o){const e=ee(a);this.options.onEvent&&this.options.onEvent(e)}}end(){if(0!==this.pending.length)throw new X("Event Iterator ended before complete")}},ne=class extends TransformStream{constructor(){let e;super({start(t){e=new te({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}},re=/\r\n|[\n\r]/,oe=/\r\n|[\n\r]/g;function ie(e){return re.test(e)}function se(e){if(ie(e))throw new K("Event's id must not contain a carriage return or newline character")}function ae(e){if(!Number.isInteger(e)||e<0)throw new K("Event's retry must be a integer and >= 0")}function ce(e){if(ie(e))throw new K("Event's comment must not contain a carriage return or newline character")}function le(e){let t="";var n;return t+=function(e){let t="";for(const n of e??[])ce(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(function(e){if(ie(e))throw new K("Event's event must not contain a carriage return or newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(ae(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(se(e.id),t+=`id: ${e.id}\n`),t+=void 0===(n=e.data)?"":`data: ${n.replace(oe,"\ndata: ")}\n`,t+="\n",t}var ue=Symbol("ORPC_EVENT_SOURCE_META");function de(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&se(t.id),void 0!==t.retry&&ae(t.retry),void 0!==t.comments)for(const n of t.comments)ce(n);return new Proxy(e,{get:(e,n,r)=>n===ue?t:Reflect.get(e,n,r)})}function pe(e){return F(e)?Reflect.get(e,ue):void 0}function he(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=pe(e);t&&F(n)&&(n=de(n,t))}return n};return new A(async()=>{const{done:r,value:o}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let i=await t.value(o,r);if(i!==o){const e=pe(o);e&&F(i)&&(i=de(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function fe(e,t={}){const n=t.path??[];return $(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,o)=>"string"!=typeof o||U.has(o)?Reflect.get(r,o):fe(e,{...t,path:[...n,o]})}))}function me(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}var ge=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)}},ye=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new ge(n.plugins).init(n),this.interceptors=w(n.interceptors),this.clientInterceptors=w(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return M({name:`${x}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",x),r?.setAttribute("rpc.method",e.join(".")),R(t)&&(t=_({name:"consume_event_iterator_input",signal:n.signal},t)),D(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=C();let i;const s=o?.trace.getActiveSpan()??r;s&&o&&(i=o?.trace.setSpan(o.context.active(),s));const a=await M({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await D(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>M({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await M({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return R(l)?_({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},be=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],n=[],r=[],o=[]){for(const i of this.customSerializers)if(i.condition(e)){const s=this.serialize(i.serialize(e),t,n,r,o);return n.push([i.type,...t]),s}if(e instanceof Blob)return r.push(t),o.push(e),[e,n,r,o];if("bigint"==typeof e)return n.push([0,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([1,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([2,...t]),[null,n,r,o];if(e instanceof URL)return n.push([4,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([5,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([6,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([7,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([3,...t,i]),null):this.serialize(e,[...t,i],n,r,o)[0]),n,r,o];if(L(e)){const i={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(i[s]=this.serialize(e[s],[...t,s],n,r,o)[0]);return[i,n,r,o]}return[e,n,r,o]}deserialize(e,t,n,r){const o={data:e};n&&r&&n.forEach((e,t)=>{let n=o,i="data";e.forEach(e=>{if(n=n[i],i=e,!Object.hasOwn(n,i))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${i}`)}),n[i]=r(t)});for(const i of t){const e=i[0];let t=o,n="data";for(let r=1;r<i.length;r++)if(t=t[n],n=i[r],!Object.hasOwn(t,n))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${n}`);for(const r of this.customSerializers)if(r.type===e){t[n]=r.deserialize(t[n]);break}switch(e){case 0:t[n]=BigInt(t[n]);break;case 1:t[n]=new Date(t[n]??"Invalid Date");break;case 2:t[n]=NaN;break;case 3:t[n]=void 0;break;case 4:t[n]=new URL(t[n]);break;case 5:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case 6:t[n]=new Set(t[n]);break;case 7:t[n]=new Map(t[n])}}return o.data}},ve=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?me(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]=[...w(n[r]),...t[r]]:void 0!==t[r]&&(Array.isArray(n[r])?n[r]=[...n[r],t[r]]:void 0!==n[r]?n[r]=[n[r],t[r]]:n[r]=t[r]);return n}(r,{"last-event-id":n.lastEventId}));const o=await z(this.expectedMethod,n,e,t),i=await z(this.baseUrl,n,e,t),s=new URL(i);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==o||a instanceof FormData||R(a))){const i=await z(this.maxUrlLength,n,e,t),c=new URL(s);if(c.searchParams.append("data",N(a)),c.toString().length<=i)return{body:void 0,method:o,headers:r,url:c,signal:n.signal}}return{url:s,method:"GET"===o?this.fallbackMethod:o,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(V(n))throw Y(n);throw new j((r=e.status,Object.entries(H).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},we=class{constructor(e){this.jsonSerializer=e}serialize(e){return R(e)?he(e,{value:async e=>this.#o(e,!1),error:async e=>{return new G({data:this.#o((t=e,t instanceof j?t:new j("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#o(e,!0)}#o(e,t){const[n,r,o,i]=this.jsonSerializer.serialize(e),s=0===r.length?void 0:r;if(!t||0===i.length)return{json:n,meta:s};const a=new FormData;return a.set("data",N({json:n,meta:s,maps:o})),i.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return R(e)?he(e,{value:async e=>this.#i(e),error:async e=>{if(!(e instanceof G))return e;const t=this.#i(e.data);return V(t)?Y(t,{cause:e}):new G({data:t,cause:e})}}):this.#i(e)}#i(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},xe=class extends ye{constructor(e,t){const n=new be(t),r=new we(n);super(new ve(r,t),e,t)}},Se=class extends ge{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},ke=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new Se(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=w(e.adapterInterceptors)}async call(e,t,n,r){const o=function(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=function(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:R(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,c,l=!1;return new ReadableStream({start(e){c=E("stream_event_iterator"),i&&e.enqueue(le({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(le({comments:[o]})),c?.addEvent("keepalive")},r));const i=await T(c,()=>e.next());if(clearInterval(a),l)return;const s=pe(i.value);if(!i.done||void 0!==i.value||void 0!==s){const e=i.done?"done":"message";t.enqueue(le({...s,event:e,data:N(i.value)})),c?.addEvent(e)}i.done&&(t.close(),c?.end())}catch(i){if(clearInterval(a),l)return;i instanceof G?(t.enqueue(le({...pe(i),event:"error",data:N(i.data)})),c?.addEvent("error"),t.close()):(I(c,i),t.error(i)),c?.end()}},async cancel(){try{l=!0,clearInterval(a),c?.addEvent("cancelled"),await T(c,()=>e.return?.())}catch(t){throw I(c,t),t}finally{c?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),N(e)):void 0}(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}(e,this.toFetchRequestOptions);return function(e,t={}){return{body:k(()=>function(e,t={}){return M({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=function(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}(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 P(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 ne))?.getReader();let r,o=!1;return new A(async()=>{r??=E("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await T(r,()=>n.read());if(e){if(o)throw new S("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=P(t.data);return F(e)&&(e=de(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new G({data:P(t.data)});throw e=de(e,t),r?.addEvent("error"),e}case"done":{let e=P(t.data);return F(e)&&(e=de(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof G||I(r,e,t),e}},async e=>{try{"next"!==e&&(o=!0,r?.addEvent("cancelled")),await T(r,()=>n?.cancel())}catch(i){throw I(r,i,t),i}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const o=await e.blob();return new File([o],"blob",{type:o.type})})}(e,t)),status:e.status,get headers(){const t=me(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await D(this.adapterInterceptors,{...t,request:o,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...o})=>this.fetch(e,r,o,t,n)),{signal:o.signal})}},Ce=class extends xe{constructor(e){super(new ke(e),e)}};function Ee(e){return fe(new Ce({url:e}))}var Ie="",Me=Ee(""),Te=new Proxy({},{get:(e,t)=>Me[t]});function Re(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function Oe(e,t){console.warn(void 0===t?e:`${e} ${Re(t)}`)}var Ae="marketrix_chat_context";function _e(e,t){return`${e}_${function(e){return e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}(t)}`}var De={chat_id:null,messages:[],currentMode:"tell",isOpen:!1,config:null,timestamp:0};function Pe(e){try{return"undefined"==typeof localStorage?null:localStorage.getItem(e)}catch(t){return Oe("[StorageService] localStorage is unreadable:",t),null}}function Ne(e,t){try{"undefined"!=typeof localStorage&&localStorage.setItem(e,t)}catch(n){Oe("[StorageService] localStorage is unwritable:",n)}}function Le(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.content&&("user"===t.sender||"agent"===t.sender)&&"string"==typeof t.timestamp&&Array.isArray(t.parts)}function Fe(e){const t=Pe(e);if(!t)return{...De};try{const e=function(e){if("object"!=typeof e||null===e)return{...De};const t=e,n=t.chat_id,r=t.currentMode,o=t.config,i=t.timestamp;return{chat_id:"string"==typeof n||null===n?n:De.chat_id,messages:Array.isArray(t.messages)?t.messages.filter(Le):De.messages,currentMode:"tell"===r||"show"===r||"do"===r?r:De.currentMode,isOpen:"boolean"==typeof t.isOpen?t.isOpen:De.isOpen,config:"object"==typeof o?o:De.config,timestamp:"number"==typeof i?i:De.timestamp}}(JSON.parse(t));if(Date.now()-e.timestamp<=6048e5)return e}catch(n){Oe("[StorageService] Failed to parse the stored context:",n)}return{...De}}var ze,$e=new class{key=Ae;context=Fe(this.key);getContext(){return this.context}updateContext(e){this.context={...this.context,...e,timestamp:Date.now()},Ne(this.key,JSON.stringify(this.context))}getChatId(){return this.context.chat_id}setChatId(e){this.updateContext({chat_id:e})}getCredentialedConfig(){const{config:e}=this.context;return e?.mtxId&&e.mtxKey?e:null}setConfig(e){this.key=_e(Ae,e),this.context=Fe(this.key),this.updateContext({config:e})}},Be=new class{creation=null;async getOrCreateChatId(){return $e.getChatId()||(this.creation??=(async()=>{const e=await Te.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return $e.setChatId(e),e})().finally(()=>{this.creation=null}),this.creation)}},We=Object.defineProperty,Ue=(e,t,n)=>((e,t,n)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),He=/* @__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[e.Asset=7]="Asset",e))(He||{}),je=/* @__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))(je||{}),qe=/* @__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))(qe||{}),Ve=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ve||{}),Ye=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ye||{}),Ke=/* @__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))(Ke||{}),Xe=/* @__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))(Xe||{}),Ge={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Je={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ze={},Qe={};function et(e){if(Ze[e])return Ze[e];const t=globalThis[e],n=t.prototype,r=e in Ge?Ge[e]:void 0,o=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]"))})),i=e in Je?Je[e]:void 0,s=Boolean(i&&i.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(o&&s&&!globalThis.Zone)return Ze[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");r.style.display="none",document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;if(!i)return r.remove(),n;const s=navigator.userAgent;return s.includes("Safari")&&!s.includes("Chrome")?(r.classList.add("rr-block"),r.setAttribute("__rrwebUntaintedMutationObserver",""),Qe[e]=()=>r.remove()):r.remove(),Ze[e]=i}catch{return n}}var tt={};function nt(e,t,n){var r;const o=`${e}.${String(n)}`;if(tt[o])return tt[o].call(t);const i=et(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(tt[o]=s,s.call(t)):t[n]}var rt={};function ot(e,t,n){const r=`${e}.${String(n)}`;if(rt[r])return rt[r].bind(t);const o=et(e)[n];return"function"!=typeof o?t[n]:(rt[r]=o,o.bind(t))}var it=Date.now;function st(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(it=()=>/* @__PURE__ */(new Date).getTime());var at=function(e){return nt("Node",e,"ownerDocument")},ct=function(e){return nt("Node",e,"childNodes")},lt=function(e){return nt("Node",e,"parentNode")},ut=function(e){return nt("Node",e,"parentElement")},dt=function(e){return nt("Node",e,"textContent")},pt=function(e,t){return ot("Node",e,"contains")(t)},ht=function(e){return ot("Node",e,"getRootNode")()},ft=function(e){return e&&"host"in e?nt("ShadowRoot",e,"host"):null},mt=function(e){return e&&"shadowRoot"in e?nt("Element",e,"shadowRoot"):null};function gt(e){return e.nodeType===e.ELEMENT_NODE}function yt(e){const t=e&&"host"in e&&"mode"in e&&ft(e)||null;return Boolean(t&&"shadowRoot"in t&&mt(t)===e)}function bt(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function vt(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=>wt(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 wt(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=vt(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?At(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?At(n,t):n}}var xt=class{constructor(){Ue(this,"idNodeMap",/* @__PURE__ */new Map),Ue(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 St({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:i}){let s=o||"";const a=r&&kt(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=i?i(s,e):"*".repeat(s.length)),s}function kt(e){return e.toLowerCase()}var Ct="__rrweb_original__";function Et(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?kt(t):null}function It(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(o){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}var Mt=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Tt=/^(?:[a-z+]+:)?\/\//i,Rt=/^www\..*/i,Ot=/^(data:)([^,]*),(.*)/i;function At(e,t){return(e||"").replace(Mt,(e,n,r,o,i,s)=>{const a=r||i||s,c=n||o||"";if(!a)return e;if(Tt.test(a)||Rt.test(a))return`url(${c}${a}${c})`;if(Ot.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${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}${c})`;const l=a.split("#")[0],u=a.substring(l.length),d=t.split("#")[0].split("/"),p=l.split("/");d.pop();for(const t of p)"."!==t&&(".."===t?d.pop():d.push(t));return`url(${c}${d.join("/")}${u}${c})`})}function _t(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}var Dt,Pt,Nt=1,Lt=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function Ft(){return Nt++}var zt=/^[^ \t\n\r\u000c]+/,$t=/^[, \t\n\r\u000c]+/,Bt=/* @__PURE__ */new WeakMap;function Wt(e,t){return t&&""!==t.trim()?Ut(e,t):t}function Ut(e,t){let n=Bt.get(e);if(n||(n=e.createElement("a"),Bt.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function Ht(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)?Wt(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r($t),!(n>=t.length);){let i=r(zt);if(","===i.slice(-1))i=Wt(e,i.substring(0,i.length-1)),o.push(i);else{let r="";i=Wt(e,i);let s=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((i+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,o.push((i+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?At(r,Ut(e)):"object"===t&&"data"===n?Wt(e,r):r:r}function jt(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function qt(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&qt(lt(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&qt(lt(e),t,n)}function Vt(e,t,n,r){let o;if(gt(e)){if(o=e,!ct(o).length)return!1}else{if(null===ut(e))return!1;o=ut(e)}try{if("string"==typeof t){if(r){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(qt(o,t,r))return!0;if(n)if(r){if(o.closest(n))return!0}else if(o.matches(n))return!0}catch(i){}return!1}function Yt(e){return null==e?"":e.toLowerCase()}function Kt(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 Xt(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,maskTextClass:s,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f={},inlineImages:m=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:S=()=>!1,newlyAddedElement:k=!1,cssCaptured:C=!1}=t;let{needsMask:E}=t,{preserveWhiteSpace:I=!0}=t;E||(E=Vt(e,s,a,void 0===E));const M=function(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:s,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:l,maskInputFn:u,dataURLOptions:d={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m=!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:Xe.Document,childNodes:[],compatMode:e.compatMode}:{type:Xe.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:Xe.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:o,inlineStylesheet:i,maskInputOptions:s={},maskInputFn:a,dataURLOptions:c={},inlineImages:l,recordCanvas:u,keepIframeSrcFn:d,newlyAddedElement:p=!1,rootId:h}=t,f=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,o),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=kt(e.tagName);return Lt.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let x=0;x<y;x++){const t=e.attributes[x];jt(m,t.name,t.value)||(g[t.name]=Ht(n,m,kt(t.name),t.value))}if("link"===m&&i){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=vt(t)),r&&(delete g.rel,delete g.href,g._cssText=r)}if("style"===m&&e.sheet){let t=vt(e.sheet);t&&(e.childNodes.length>1&&(t=function(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),o=[];let i=0;if(r.length>1&&e&&"string"==typeof e){let t=_t(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 c=_t(r[a].textContent,n),l=100;let u=3;for(;u<c.length&&(c[u].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,u),1));u++);for(;u<c.length;u++){let d=c.substring(0,u),p=t.split(d),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[a-1].textContent)h=t.indexOf(d,1);else if(1===p.length){if(d=d.substring(0,d.length-1),p=t.split(d),p.length<=1)return o.push(e),o;u=101}else u===c.length-1&&(h=t.indexOf(d));if(p.length>=2&&u>l){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=_t(e).length;h=t.indexOf(d,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/s);for(;a>0&&a<e.length;){if(i+=1,i>50*r.length)return o.push(e),o;const c=_t(e.substring(0,a),n);if(c.length===h){o.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}c.length<h?a+=Math.max(1,Math.floor((h-c.length)/s)):a-=Math.max(1,Math.floor((c.length-h)*s))}break}}}}return o.push(e),o}(e,t).join("/* rr_split */")}(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(m)){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=St({element:e,type:Et(e),tagName:m,value:t,maskInputOptions:s,maskInputFn:a}):n&&(g.checked=n)}if("option"===m&&(e.selected&&!s.select?g.selected=!0:delete g.selected),"dialog"===m&&e.open&&(g.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"),"canvas"===m&&u)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 o=t.getImageData,i=Ct in o?o[Ct]:o;if(new Uint32Array(i.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(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height,t!==r.toDataURL(c.type,c.quality)&&(g.rr_dataURL=t)}if("img"===m&&l){Dt||(Dt=n.createElement("canvas"),Pt=Dt.getContext("2d"));const t=e,r=t.currentSrc||t.getAttribute("src")||"<unknown-src>",o=t.crossOrigin,i=()=>{t.removeEventListener("load",i);try{Dt.width=t.naturalWidth,Dt.height=t.naturalHeight,Pt.drawImage(t,0,0),g.rr_dataURL=Dt.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i));console.warn(`Cannot inline img src=${r}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(o?g.crossOrigin=o:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i)}if(["audio","video"].includes(m)){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}if(p||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop)),f){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}let b;"iframe"!==m||d(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);try{customElements.get(m)&&(b=!0)}catch(w){}return{type:Xe.Element,tagName:m,attributes:g,childNodes:[],isSVG:(v=e,Boolean("svg"===v.tagName||v.ownerSVGElement)||void 0),needBlock:f,rootId:h,isCustom:b};var v}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:a,maskInputOptions:c,maskInputFn:u,dataURLOptions:d,inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:o,cssCaptured:i}=t,s=lt(e),a=s&&s.tagName;let c="";const l="STYLE"===a||void 0,u="SCRIPT"===a||void 0;return u?c="SCRIPT_PLACEHOLDER":i||(c=dt(e),l&&c&&(c=At(c,Ut(t.doc)))),!l&&!u&&c&&n&&(c=r?r(c,ut(e)):c.replace(/[\S]/g,"*")),{type:Xe.Text,textContent:c||"",rootId:o}}(e,{doc:n,needsMask:s,maskTextFn:l,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:Xe.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:Xe.Comment,textContent:dt(e)||"",rootId:y};default:return!1}}(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:E,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,keepIframeSrcFn:S,newlyAddedElement:k,cssCaptured:C});if(!M)return console.warn(e,"not serialized"),null;let T;T=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===Xe.Comment)return!0;if(e.type===Xe.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"===It(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Yt(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Yt(e.attributes.name)||"icon"===Yt(e.attributes.rel)||"apple-touch-icon"===Yt(e.attributes.rel)||"shortcut icon"===Yt(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Yt(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Yt(e.attributes.property).match(/^(og|twitter|fb):/)||Yt(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Yt(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===Yt(e.attributes.name)||"googlebot"===Yt(e.attributes.name)||"bingbot"===Yt(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===Yt(e.attributes.name)||"generator"===Yt(e.attributes.name)||"framework"===Yt(e.attributes.name)||"publisher"===Yt(e.attributes.name)||"progid"===Yt(e.attributes.name)||Yt(e.attributes.property).match(/^article:/)||Yt(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===Yt(e.attributes.name)||"yandex-verification"===Yt(e.attributes.name)||"csrf-token"===Yt(e.attributes.name)||"p:domain_verify"===Yt(e.attributes.name)||"verify-v1"===Yt(e.attributes.name)||"verification"===Yt(e.attributes.name)||"shopify-checkout-api-token"===Yt(e.attributes.name)))return!0}}return!1}(M,h)||!I&&M.type===Xe.Text&&!M.textContent.replace(/^\s+|\s+$/gm,"").length?-2:Ft();const R=Object.assign(M,{id:T});if(r.add(e,R),-2===T)return null;y&&y(e);let O=!c;if(R.type===Xe.Element){O=O&&!R.needBlock,delete R.needBlock;const t=mt(e);t&&bt(t)&&(R.isShadowHost=!0)}if((R.type===Xe.Document||R.type===Xe.Element)&&O){h.headWhitespace&&R.type===Xe.Element&&"head"===R.tagName&&(I=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:E,maskTextClass:s,maskTextSelector:a,skipChild:c,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:S,cssCaptured:!1};if(R.type===Xe.Element&&"textarea"===R.tagName&&void 0!==R.attributes.value);else{R.type===Xe.Element&&void 0!==R.attributes._cssText&&"string"==typeof R.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(ct(e))){const e=Xt(n,t);e&&R.childNodes.push(e)}}let k=null;if(gt(e)&&(k=mt(e)))for(const e of Array.from(ct(k))){const n=Xt(e,t);n&&(bt(k)&&(n.isShadow=!0),R.childNodes.push(n))}}const A=lt(e);return A&&yt(A)&&bt(A)&&(R.isShadow=!0),R.type===Xe.Element&&"iframe"===R.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,i=!1;try{o=r.document.readyState}catch(a){return}if("complete"!==o){const r=setTimeout(()=>{i||(t(),i=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),i=!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&&b){const n=Xt(t,{doc:t,mirror:r,blockClass:o,blockSelector:i,needsMask:E,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:S});n&&b(e,n)}},v),R.type===Xe.Element&&"link"===R.tagName&&"string"==typeof R.attributes.rel&&("stylesheet"===R.attributes.rel||"preload"===R.attributes.rel&&"string"==typeof R.attributes.href&&"css"===It(R.attributes.href))&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(s){return}if(r)return;const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()})}(e,()=>{if(w){const t=Xt(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:E,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:S});t&&w(e,t)}},x),R}var Gt=class e{constructor(...e){Ue(this,"parentElement",null),Ue(this,"parentNode",null),Ue(this,"ownerDocument"),Ue(this,"firstChild",null),Ue(this,"lastChild",null),Ue(this,"previousSibling",null),Ue(this,"nextSibling",null),Ue(this,"ELEMENT_NODE",1),Ue(this,"TEXT_NODE",3),Ue(this,"nodeType"),Ue(this,"nodeName"),Ue(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"}};function Jt(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var Zt="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",Qt={map:{},getId:()=>(console.error(Zt),-1),getNode:()=>(console.error(Zt),null),removeNodeFromMap(){console.error(Zt)},has:()=>(console.error(Zt),!1),reset(){console.error(Zt)}};function en(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},a))}}function tn(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>tn(e,t,i||{},!0)}function nn(e){var t,n,r,o;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null==(t=ut(i.body))?void 0:t.scrollLeft)||(null==(n=null==i?void 0:i.body)?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null==(r=ut(i.body))?void 0:r.scrollTop)||(null==(o=null==i?void 0:i.body)?void 0:o.scrollTop)||0}}function rn(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function on(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function sn(e){return e?e.nodeType===e.ELEMENT_NODE?e:ut(e):null}function an(e,t,n,r){if(!e)return!1;const o=sn(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(qt(o,t,r))return!0}catch(i){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function cn(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function ln(e,t){if(yt(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=lt(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||ln(r,t))}function un(e){return Boolean(e.changedTouches)}function dn(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function pn(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function hn(e){return!!e&&(e instanceof Gt&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(mt(e)))}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Qt=new Proxy(Qt,{get:(e,t,n)=>("map"===t&&console.error(Zt),Reflect.get(e,t,n))}));var fn=class{constructor(){Ue(this,"id",1),Ue(this,"styleIDMap",/* @__PURE__ */new WeakMap),Ue(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 mn(e){var t;let n=null;return"getRootNode"in e&&(null==(t=ht(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&ft(ht(e))&&(n=ft(ht(e))),n}function gn(e){const t=at(e);return!!t&&(pt(t,e)||function(e){const t=at(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=mn(n);)n=t;return n}(e);return pt(t,n)}(e))}function yn(e){return"__ln"in e}var bn,vn=class{constructor(){Ue(this,"length",0),Ue(this,"head",null),Ue(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&&yn(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&&yn(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--)}},wn=(e,t)=>`${e}@${t}`,xn=class{constructor(){Ue(this,"frozen",!1),Ue(this,"locked",!1),Ue(this,"texts",[]),Ue(this,"attributes",[]),Ue(this,"attributeMap",/* @__PURE__ */new WeakMap),Ue(this,"removes",[]),Ue(this,"mapRemoves",[]),Ue(this,"movedMap",{}),Ue(this,"addedSet",/* @__PURE__ */new Set),Ue(this,"movedSet",/* @__PURE__ */new Set),Ue(this,"droppedSet",/* @__PURE__ */new Set),Ue(this,"removesSubTreeCache",/* @__PURE__ */new Set),Ue(this,"mutationCb"),Ue(this,"blockClass"),Ue(this,"blockSelector"),Ue(this,"maskTextClass"),Ue(this,"maskTextSelector"),Ue(this,"inlineStylesheet"),Ue(this,"maskInputOptions"),Ue(this,"maskTextFn"),Ue(this,"maskInputFn"),Ue(this,"keepIframeSrcFn"),Ue(this,"recordCanvas"),Ue(this,"inlineImages"),Ue(this,"slimDOMOptions"),Ue(this,"dataURLOptions"),Ue(this,"doc"),Ue(this,"mirror"),Ue(this,"iframeManager"),Ue(this,"stylesheetManager"),Ue(this,"shadowDomManager"),Ue(this,"canvasManager"),Ue(this,"processedNodeManager"),Ue(this,"unattachedDoc"),Ue(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),Ue(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new vn,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{const i=lt(o);if(!i||!gn(o))return;let s=!1;if(o.nodeType===Node.TEXT_NODE){const e=i.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(i)&&(s=!0)}const a=yt(i)?this.mirror.getId(mn(o)):this.mirror.getId(i),c=r(o);if(-1===a||-1===c)return n.addNode(o);const l=Xt(o,{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=>{dn(e,this.mirror)&&this.iframeManager.addIframe(e),pn(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),hn(o)&&this.shadowDomManager.addShadowRoot(mt(o),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});l&&(e.push({parentId:a,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)kn(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(lt(a))||o(a);for(const a of this.addedSet)Cn(this.droppedSet,a)||kn(this.removesSubTreeCache,a,this.mirror)?Cn(this.movedSet,a)?o(a):this.droppedSet.add(a):o(a);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(lt(i.value)),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(lt(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=lt(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=ft(r);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=lt(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))}),Ue(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(ct(e),e=>dt(e)||"").join("");t.attributes.value=St({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Et(e),value:n,maskInputFn:this.maskInputFn})}),Ue(this,"processMutation",e=>{if(!cn(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=dt(e.target);an(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Vt(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,sn(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const n=e.target;let r=e.attributeName,o=e.target.getAttribute(r);if("value"===r){const e=Et(n);o=St({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:o,maskInputFn:this.maskInputFn})}if(an(e.target,this.blockClass,this.blockSelector,!1)||o===e.oldValue)return;let i=this.attributeMap.get(e.target);if("IFRAME"===n.tagName&&"src"===r&&!this.keepIframeSrcFn(o)){if(n.contentDocument)return;r="rr_src"}if(i||(i={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(e.target,i)),"type"===r&&"INPUT"===n.tagName&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!jt(n.tagName,r))if(i.attributes[r]=Ht(this.doc,kt(n.tagName),kt(r),o),"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),o=n.style.getPropertyPriority(e);t!==r.style.getPropertyValue(e)||o!==r.style.getPropertyPriority(e)?i.styleDiff[e]=""===o?t:[t,o]:i._unchangedStyles[e]=[t,o]}for(const e of Array.from(r.style))""===n.style.getPropertyValue(e)&&(i.styleDiff[e]=!1)}else"open"===r&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(an(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=yt(e.target)?this.mirror.getId(ft(e.target)):this.mirror.getId(e.target);an(e.target,this.blockClass,this.blockSelector,!1)||cn(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Sn(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ln(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[wn(n,r)]?Sn(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!yt(e.target)||!bt(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),ct(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),Ue(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(cn(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[wn(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);an(e,this.blockClass,this.blockSelector,!1)||(ct(e).forEach(e=>this.genAdds(e)),hn(e)&&ct(mt(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 Sn(e,t){e.delete(t),ct(t).forEach(t=>Sn(e,t))}function kn(e,t,n){return 0!==e.size&&function(e,t){const n=lt(t);return!!n&&e.has(n)}(e,t)}function Cn(e,t){return 0!==e.size&&En(e,t)}function En(e,t){const n=lt(t);return!!n&&(!!e.has(n)||En(e,n))}var In=e=>bn?(...t)=>{try{return e(...t)}catch(n){if(bn&&!0===bn(n))return;throw n}}:e,Mn=[];function Tn(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 Rn(e,t){const n=new xn;Mn.push(n),n.init(e);const[r,o]=[et("MutationObserver").constructor,Qe.MutationObserver??(()=>{})],i=new r(In(n.processMutations.bind(n)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[i,o]}function On({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return Jt("scroll",In(en(In(i=>{const s=Tn(i);if(!s||an(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=nn(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),i.scroll||100)),t)}var An=["INPUT","TEXTAREA","SELECT"],_n=/* @__PURE__ */new WeakMap;function Dn(e){return function e(t,n){if(Fn("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Fn("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Fn("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Fn("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const r=Array.from(t.parentRule.cssRules).indexOf(t);return n.unshift(r),e(t.parentRule,n)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);n.unshift(e)}return n}(e,[])}function Pn(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Nn({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(ft(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(i=null==(o=n.ownerDocument)?void 0:o.defaultView)?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null==(e=c.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=c.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(o){}return r}}),In(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function Ln(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:p,selectionCb:h,customElementCb:f}=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),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...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),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...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),f(...e)}}(e,t);let o=()=>{};e.recordDOM&&([r,o]=Rn(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=en(In(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),i),l=In(en(In(e=>{const t=Tn(e),{clientX:n,clientY:o}=un(e)?e.changedTouches[0]:e;s||(s=it()),a.push({x:n,y:o,id:r.getId(t),timeOffset:it()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?je.Drag:e instanceof MouseEvent?je.MouseMove:je.TouchMove)}),o,{trailing:!1})),u=[Jt("mousemove",l,n),Jt("touchmove",l,n),Jt("drag",l,n)];return In(()=>{u.forEach(e=>e())})}(e),s=function({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];let c=null;return Object.keys(qe).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{let s=kt(i);const l=(t=>i=>{const s=Tn(i);if(an(s,r,o,!0))return;let a=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":a=Ve.Mouse;break;case"touch":a=Ve.Touch;break;case"pen":a=Ve.Pen}a===Ve.Touch?qe[t]===qe.MouseDown?l="TouchStart":qe[t]===qe.MouseUp&&(l="TouchEnd"):Ve.Pen}else un(i)&&(a=Ve.Touch);null!==a?(c=a,(l.startsWith("Touch")&&a===Ve.Touch||l.startsWith("Mouse")&&a===Ve.Mouse)&&(a=null)):qe[t]===qe.Click&&(a=c,c=null);const u=un(i)?i.changedTouches[0]:i;if(!u)return;const d=n.getId(s),{clientX:p,clientY:h}=u;In(e)({type:qe[l],id:d,x:p,y:h,...null!==a&&{pointerType:a}})})(i);if(window.PointerEvent)switch(qe[i]){case qe.MouseDown:case qe.MouseUp:s=s.replace("mouse","pointer");break;case qe.TouchStart:case qe.TouchEnd:return}a.push(Jt(s,l,t))}),In(()=>{a.forEach(e=>e())})}(e),a=On(e),c=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Jt("resize",In(en(In(()=>{const t=rn(),o=on();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:u}){function d(e){let n=Tn(e);const l=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=ut(n)),!n||!d||An.indexOf(d)<0||an(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let h=n.value,f=!1;const m=Et(n)||"";"radio"===m||"checkbox"===m?f=n.checked:(a[d.toLowerCase()]||a[m])&&(h=St({element:n,maskInputOptions:a,tagName:d,type:m,value:h,maskInputFn:c})),p(n,u?{text:h,isChecked:f,userTriggered:l}:{text:h,isChecked:f});const g=n.name;"radio"===m&&g&&f&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,u?{text:t,isChecked:!f,userTriggered:!1}:{text:t,isChecked:!f})}})}function p(t,r){const o=_n.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){_n.set(t,r);const o=n.getId(t);In(e)({...r,id:o})}}const h=("last"===l.input?["change"]:["input","change"]).map(e=>Jt(e,In(d),t)),f=t.defaultView;if(!f)return()=>{h.forEach(e=>e())};const m=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value"),g=[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...g.map(e=>tn(e[0],e[1],{set(){In(d)({target:this,isTrusted:!1})}},!1,f))),In(()=>{h.forEach(e=>e())})}(e),u=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=In(i=>en(In(o=>{const s=Tn(o);if(!s||an(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:u,loop:d}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:u,loop:d})}),o.media||500)),a=[Jt("play",s(Ke.Play),i),Jt("pause",s(Ke.Pause),i),Jt("seeked",s(Ke.Seeked),i),Jt("volumechange",s(Ke.VolumeChange),i),Jt("ratechange",s(Ke.RateChange),i)];return In(()=>{a.forEach(e=>e())})}(e);let d=()=>{},p=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:In((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Pn(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const o=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[o,n])};const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),r.apply(o,i)})}),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:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)})}));const c={};zn("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(zn("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),zn("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),zn("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:In((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Pn(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...Dn(o),a||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...Dn(o),s]}]}),r.apply(o,i)})})}),In(()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}(e,{win:n}),p=Nn(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:In((o,s,a)=>{var c;const[l,u,d]=a;if(n.has(l))return i.apply(s,[l,u,d]);const{id:p,styleId:h}=Pn(null==(c=s.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:l,value:u,priority:d},index:Dn(s.parentRule)}),o.apply(s,a)})});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:In((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.apply(i,[l]);const{id:u,styleId:d}=Pn(null==(c=i.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(u&&-1!==u||d&&-1!==d)&&e({id:u,styleId:d,remove:{property:l},index:Dn(i.parentRule)}),o.apply(i,a)})}),In(()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(f=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=/* @__PURE__ */new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.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=st(t.fonts,"add",function(t){return function(n){return setTimeout(In(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=i}),r.push(s),In(()=>{r.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=In(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const{startContainer:i,startOffset:s,endContainer:c,endOffset:l}=e.getRangeAt(t);an(i,r,o,!0)||an(c,r,o,!0)||a.push({start:n.getId(i),startOffset:s,end:n.getId(c),endOffset:l})}i({ranges:a})});return a(),Jt("selectionchange",a)}(e),g=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?st(n.customElements,"define",function(e){return function(n,r,o){try{t({define:{name:n}})}catch(i){console.warn(`Custom element callback failed for ${n}`)}return e.apply(this,[n,r,o])}}):()=>{}}(e),y=[];for(const b of e.plugins)y.push(b.observer(b.callback,n,b.options));return In(()=>{Mn.forEach(e=>e.reset()),r?.disconnect(),o(),i(),s(),a(),c(),l(),u(),d(),p(),h(),f(),m(),g(),y.forEach(e=>e())})}function Fn(e){return void 0!==window[e]}function zn(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var $n=class{constructor(e){Ue(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),Ue(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.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);return"number"!=typeof t?t:r.get(t)||-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}},Bn=class{constructor(e){Ue(this,"iframes",/* @__PURE__ */new WeakMap),Ue(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),Ue(this,"crossOriginIframeMirror",new $n(Ft)),Ue(this,"crossOriginIframeStyleMirror"),Ue(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),Ue(this,"mirror"),Ue(this,"mutationCb"),Ue(this,"wrappedEmit"),Ue(this,"loadListener"),Ue(this,"stylesheetManager"),Ue(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new $n(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 He.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:He.IncrementalSnapshot,data:{source:je.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case He.Meta:case He.Load:case He.DomContentLoaded:return!1;case He.Plugin:return t;case He.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case He.IncrementalSnapshot:switch(t.data.source){case je.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 je.Drag:case je.TouchMove:case je.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case je.ViewportResize:return!1;case je.MediaInteraction:case je.MouseInteraction:case je.Scroll:case je.CanvasMutation:case je.Input:return this.replaceIds(t.data,e,["id"]),t;case je.StyleSheetRule:case je.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case je.Font:return t;case je.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case je.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 o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));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===Xe.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},Wn=class{constructor(e){Ue(this,"shadowDoms",/* @__PURE__ */new WeakSet),Ue(this,"mutationCb"),Ue(this,"scrollCb"),Ue(this,"bypassOptions"),Ue(this,"mirror"),Ue(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(!bt(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const[n]=Rn({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(On({...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(ft(e))),this.restoreHandlers.push(Nn({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(st(e.prototype,"attachShadow",function(e){return function(r){const o=e.call(this,r),i=mt(this);return i&&gn(this)&&n.addShadowRoot(i,t),o}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},Un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hn="undefined"==typeof Uint8Array?[]:/* @__PURE__ */new Uint8Array(256),jn=0;jn<64;jn++)Hn[Un.charCodeAt(jn)]=jn;var qn=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Un[n[t]>>2],o+=Un[(3&n[t])<<4|n[t+1]>>4],o+=Un[(15&n[t+1])<<2|n[t+2]>>6],o+=Un[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o},Vn=/* @__PURE__ */new Map,Yn=(e,t,n)=>{if(!e||!Gn(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Vn.get(e);return n||(n=/* @__PURE__ */new Map,Vn.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Kn(e,t,n){if(e instanceof Array)return e.map(e=>Kn(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:qn(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Kn(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:[Kn(e.data,t,n),e.width,e.height]}:Gn(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Yn(e,t,n)}:e}var Xn=(e,t,n)=>e.map(e=>Kn(e,t,n)),Gn=(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 Jn(e,t,n,r){const o=[];try{const i=st(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){if(!an(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(i[0]&&"object"==typeof i[0]){const e=i[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...i])}});o.push(i)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(e=>e())}}function Zn(e,t,n,r,o,i){const s=[],a=Object.getOwnPropertyNames(e);for(const c of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const a=st(e,c,function(e){return function(...s){const a=e.apply(this,s);if(Yn(a,i,this),"tagName"in this.canvas&&!an(this.canvas,r,o,!0)){const e=Xn(s,i,this),r={type:t,property:c,args:e};n(this.canvas,r)}return a}});s.push(a)}catch{const r=tn(e,c,{set(e){n(this.canvas,{type:t,property:c,args:[e],setter:!0})}});s.push(r)}return s}var Qn='(function() {\n "use strict";\n var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);\n for (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n var encode = function(arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";\n for (i2 = 0; i2 < len; i2 += 3) {\n base64 += chars[bytes[i2] >> 2];\n base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];\n base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];\n base64 += chars[bytes[i2 + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + "=";\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + "==";\n }\n return base64;\n };\n const lastBlobMap = /* @__PURE__ */ new Map();\n const transparentBlobMap = /* @__PURE__ */ new Map();\n async function getTransparentBlobFor(width, height, dataURLOptions) {\n const id = `${width}-${height}`;\n if ("OffscreenCanvas" in globalThis) {\n if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);\n const offscreen = new OffscreenCanvas(width, height);\n offscreen.getContext("2d");\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n transparentBlobMap.set(id, base64);\n return base64;\n } else {\n return "";\n }\n }\n const worker = self;\n worker.onmessage = async function(e) {\n if ("OffscreenCanvas" in globalThis) {\n const { id, bitmap, width, height, dataURLOptions } = e.data;\n const transparentBase64 = getTransparentBlobFor(\n width,\n height,\n dataURLOptions\n );\n const offscreen = new OffscreenCanvas(width, height);\n const ctx = offscreen.getContext("2d");\n ctx.drawImage(bitmap, 0, 0);\n bitmap.close();\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const type = blob.type;\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n if (!lastBlobMap.has(id) && await transparentBase64 === base64) {\n lastBlobMap.set(id, base64);\n return worker.postMessage({ id });\n }\n if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });\n worker.postMessage({\n id,\n type,\n base64,\n width,\n height\n });\n lastBlobMap.set(id, base64);\n } else {\n return worker.postMessage({ id: e.data.id });\n }\n };\n})();\n//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map\n',er="undefined"!=typeof self&&self.Blob&&new Blob([Qn],{type:"text/javascript;charset=utf-8"});function tr(e){let t;try{if(t=er&&(self.URL||self.webkitURL).createObjectURL(er),!t)throw"";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(n){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Qn),{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var nr,rr,or,ir=class{constructor(e){Ue(this,"pendingCanvasMutations",/* @__PURE__ */new Map),Ue(this,"rafStamps",{latestId:0,invokeId:null}),Ue(this,"mirror"),Ue(this,"mutationCb"),Ue(this,"resetObservers"),Ue(this,"frozen",!1),Ue(this,"locked",!1),Ue(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:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{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,o){const i=Jn(t,n,r,!0),s=/* @__PURE__ */new Map,a=new tr;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:Ye["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,u=0;const d=e=>{u&&e-u<c||(u=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{an(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:o.dataURLOptions},[r])})),l=requestAnimationFrame(d)};l=requestAnimationFrame(d),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Jn(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=st(t.CanvasRenderingContext2D.prototype,s,function(o){return function(...i){return an(this.canvas,n,r,!0)||setTimeout(()=>{const n=Xn(i,t,this);e(this.canvas,{type:Ye["2D"],property:s,args:n})},0),o.apply(this,i)}});o.push(i)}catch{const n=tn(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:Ye["2D"],property:s,args:[t],setter:!0})}});o.push(n)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const o=[];return void 0!==t.WebGLRenderingContext&&o.push(...Zn(t.WebGLRenderingContext.prototype,Ye.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&o.push(...Zn(t.WebGL2RenderingContext.prototype,Ye.WebGL2,e,n,r,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),o(),i()}}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:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}},sr=class{constructor(e){Ue(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),Ue(this,"mutationCb"),Ue(this,"adoptedStyleSheetCb"),Ue(this,"styleMirror",new fn),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 o of e){let e;this.styleMirror.has(o)?e=this.styleMirror.getId(o):(e=this.styleMirror.add(o),r.push({styleId:e,rules:Array.from(o.rules||CSSRule,(e,t)=>({rule:wt(e,o.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){}},ar=class{constructor(){Ue(this,"nodeMap",/* @__PURE__ */new WeakMap),Ue(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(){}},cr=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(ze=e.contentWindow)?void 0:ze.Array.from)||Array.from,document.body.removeChild(e)}}catch(Ad){}var lr=new xt;function ur(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:p,slimDOMOptions:h,maskInputFn:f,maskTextFn:m,hooks:g,packFn:y,sampling:b={},dataURLOptions:v={},mousemoveWait:w,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:k=!1,recordAfter:C=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:E=!1,collectFonts:I=!1,inlineImages:M=!1,plugins:T,keepIframeSrcFn:R=()=>!1,ignoreCSSAttributes:O=/* @__PURE__ */new Set([]),errorHandler:A}=e;bn=A;const _=!k||window.parent===window;let D=!1;if(!_)try{window.parent.document&&(D=!1)}catch(V){D=!0}if(_&&!t)throw new Error("emit function is required");if(!_&&!D)return()=>{};void 0!==w&&void 0===b.mousemove&&(b.mousemove=w),lr.reset();const P=!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}:void 0!==p?p:{password:!0},N=Kt(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 F=0;const z=e=>{for(const t of T||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!D&&(e=y(e)),e};nr=(e,o)=>{var i;const s=e;if(s.timestamp=it(),!(null==(i=Mn[0])?void 0:i.isFrozen())||s.type===He.FullSnapshot||s.type===He.IncrementalSnapshot&&s.data.source===je.Mutation||Mn.forEach(e=>e.unfreeze()),_)t?.(z(s),o);else if(D){const e={type:"rrweb",event:z(s),origin:window.location.origin,isCheckout:o};window.parent.postMessage(e,"*")}if(s.type===He.FullSnapshot)L=s,F=0;else if(s.type===He.IncrementalSnapshot){if(s.data.source===je.Mutation&&s.data.isAttachIframe)return;F++;const e=r&&F>=r,t=n&&s.timestamp-L.timestamp>n;(e||t)&&rr(!0)}};const $=e=>{nr({type:He.IncrementalSnapshot,data:{source:je.Mutation,...e}})},B=e=>nr({type:He.IncrementalSnapshot,data:{source:je.Scroll,...e}}),W=e=>nr({type:He.IncrementalSnapshot,data:{source:je.CanvasMutation,...e}}),U=new sr({mutationCb:$,adoptedStyleSheetCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.AdoptedStyleSheet,...e}})}),H=new Bn({mirror:lr,mutationCb:$,stylesheetManager:U,recordCrossOriginIframes:k,wrappedEmit:nr});for(const K of T||[])K.getMirror&&K.getMirror({nodeMirror:lr,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});const j=new ar;or=new ir({recordCanvas:S,mutationCb:W,win:window,blockClass:o,blockSelector:i,mirror:lr,sampling:b.canvas,dataURLOptions:v});const q=new Wn({mutationCb:$,scrollCb:B,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:P,dataURLOptions:v,maskTextFn:m,maskInputFn:f,recordCanvas:S,inlineImages:M,sampling:b,slimDOMOptions:N,iframeManager:H,stylesheetManager:U,canvasManager:or,keepIframeSrcFn:R,processedNodeManager:j},mirror:lr});rr=(e=!1)=>{if(!x)return;nr({type:He.Meta,data:{href:window.location.href,width:on(),height:rn()}},e),U.reset(),q.init(),Mn.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new xt,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:i="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:p,slimDOM:h=!1,dataURLOptions:f,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:x=()=>!1}=t;return Xt(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:i,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!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}:!1===u?{password:!0}:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:Kt(h),dataURLOptions:f,inlineImages:c,recordCanvas:l,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:lr,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:P,maskTextFn:m,maskInputFn:f,slimDOM:N,dataURLOptions:v,recordCanvas:S,inlineImages:M,onSerialize:e=>{dn(e,lr)&&H.addIframe(e),pn(e,lr)&&U.trackLinkElement(e),hn(e)&&q.addShadowRoot(mt(e),document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),q.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{U.attachLinkElement(e,t)},keepIframeSrcFn:R});if(!t)return console.warn("Failed to snapshot the document");nr({type:He.FullSnapshot,data:{node:t,initialOffset:nn(window)}},e),Mn.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&U.adoptStyleSheets(document.adoptedStyleSheets,lr.getId(document))};try{const e=[],t=e=>{var t;return In(Ln)({mutationCb:$,mousemoveCb:(e,t)=>nr({type:He.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.MouseInteraction,...e}}),scrollCb:B,viewportResizeCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.ViewportResize,...e}}),inputCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.Input,...e}}),mediaInteractionCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.MediaInteraction,...e}}),styleSheetRuleCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.StyleSheetRule,...e}}),styleDeclarationCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.StyleDeclaration,...e}}),canvasMutationCb:W,fontCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.Font,...e}}),selectionCb:e=>{nr({type:He.IncrementalSnapshot,data:{source:je.Selection,...e}})},customElementCb:e=>{nr({type:He.IncrementalSnapshot,data:{source:je.CustomElement,...e}})},blockClass:o,ignoreClass:s,ignoreSelector:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:P,inlineStylesheet:u,sampling:b,recordDOM:x,recordCanvas:S,inlineImages:M,userTriggeredOnInput:E,collectFonts:I,doc:e,maskInputFn:f,maskTextFn:m,keepIframeSrcFn:R,blockSelector:i,slimDOMOptions:N,dataURLOptions:v,mirror:lr,iframeManager:H,stylesheetManager:U,shadowDomManager:q,processedNodeManager:j,canvasManager:or,ignoreCSSAttributes:O,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=>nr({type:He.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};H.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){console.warn(r)}});const n=()=>{rr(),e.push(t(document)),cr=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(Jt("DOMContentLoaded",()=>{nr({type:He.DomContentLoaded,data:{}}),"DOMContentLoaded"===C&&n()})),e.push(Jt("load",()=>{nr({type:He.Load,data:{}}),"load"===C&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")||console.warn(t)}}),j.destroy(),cr=!1,bn=void 0}}catch(Y){console.warn(Y)}}ur.addCustomEvent=(e,t)=>{if(!cr)throw new Error("please add custom event after start recording");nr({type:He.Custom,data:{tag:e,payload:t}})},ur.freezePage=()=>{Mn.forEach(e=>e.freeze())},ur.takeFullSnapshot=e=>{if(!cr)throw new Error("please take full snapshot after start recording");rr(e)},ur.mirror=lr;var dr="Chat is unavailable — the widget credentials were rejected.",pr=class extends Error{},hr=new class{abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;tornDown=!1;credentialRejected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;connectionId=0;tabId=globalThis.crypto.randomUUID();registrationWaiters=/* @__PURE__ */new Set;addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}isConnected(){return"registered"===this.status}reconnectSuppressed(){return this.tornDown||this.credentialRejected}canReconnect(){return null!==this.chatId&&!this.reconnectSuppressed()&&!this.isConnected()}reconnectNow(){this.canReconnect()&&null!==this.chatId&&(this.clearReconnectTimer(),this.resetBackoff(),this.abortConnection(),this.connect(this.chatId))}async ready(e){await this.connect(e),await this.waitUntilRegistered()}async waitUntilRegistered(){if(!this.isConnected()){if(this.credentialRejected)throw new pr(dr);await new Promise((e,t)=>this.registrationWaiters.add({resolve:e,reject:t}))}}async connect(e){if(this.credentialRejected)return;if(this.tornDown=!1,this.chatId===e&&("connecting"===this.status||"open"===this.status||"registered"===this.status))return;this.abortConnection(),this.chatId=e,this.status="connecting";const t=++this.connectionId;this.abortController=new AbortController;const n=this.abortController.signal;try{const r=$e.getCredentialedConfig(),o=await Te.widgetStream({chat_id:e,tab_id:this.tabId,...r&&{marketrix_id:r.mtxId,marketrix_key:r.mtxKey,...r.userId?{user_id:r.userId}:{}}},{signal:n});this.status="open",this.consumeEvents(o,t)}catch(r){n.aborted||(Oe("[StreamClient] Connection failed, will retry:",r),this.status="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.reconnectSuppressed()||(Oe("[StreamClient] Stream error:",r),this.status="error")}finally{n||this.connectionId!==t||this.reconnectSuppressed()||(this.status="disconnected",this.scheduleReconnect())}}disconnect(){this.tornDown=!0,this.credentialRejected=!1,this.clearReconnectTimer(),this.abortConnection(),this.chatId=null,this.settleWaiters(/* @__PURE__ */new Error("Stream disconnected before registration"))}send(e){return this.chatId?Te.widgetMessagePost({chat_id:this.chatId,tab_id:this.tabId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${Re(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}resetBackoff(){this.reconnectAttempts=0,this.reconnectDelay=1e3}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}settleWaiters(e){for(const t of this.registrationWaiters)e?t.reject(e):t.resolve();this.registrationWaiters.clear()}giveUp(e){const t=new pr(e);this.notifyError(t),this.settleWaiters(t)}handleMessage(e){this.reconnectSuppressed()||"heartbeat"!==e.type&&("registered"===e.type&&e.chat_id===this.chatId&&(this.status="registered",this.resetBackoff(),this.settleWaiters()),"chat/error"===e.type&&"auth"===e.request_id&&(console.error("[StreamClient] Authentication failed — will not reconnect"),this.credentialRejected=!0,this.giveUp(dr)),this.callbacks.forEach(t=>t.onMessage?.(e)))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.giveUp("Could not reconnect to the assistant. Try again.");this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.reconnectSuppressed()&&this.chatId&&this.connect(this.chatId)},e)}abortConnection(){this.abortController?.abort(),this.abortController=null,this.status="disconnected"}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}},fr=class{chatId;applicationId;events=[];sessionId=globalThis.crypto.randomUUID();stopRecording=null;flushTimer=null;flushPromise=Promise.resolve();stopped=!1;constructor(e,t){this.chatId=e,this.applicationId=t}async start(){this.stopRecording||this.stopped||(await hr.ready(this.chatId),this.stopped||(await Te.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/metadata",rrweb_session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.stopped||(this.stopRecording=ur({emit:e=>{this.events.push(e),this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flush()},500))},maskAllInputs:!0,maskTextClass:/^(rr-mask|mtx-mask)$/,blockClass:/^(rr-block|mtx-block)$/}))))}stop(){this.stopped=!0,this.stopRecording?.(),this.stopRecording=null,this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null,this.flush()}flush(){return this.flushPromise=this.flushPromise.then(async()=>{this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null;const e=this.events.splice(0);if(e.length)try{await Te.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/events",rrweb_session_id:this.sessionId,events:e}})}catch(t){this.events=e.concat(this.events).slice(0,2e4),console.error("Failed to record session events:",t)}}),this.flushPromise}},mr=null;function gr(){return mr?.active&&"live"===mr.getVideoTracks()[0]?.readyState?mr:(mr=null,null)}function yr(){mr&&(mr.getTracks().forEach(e=>e.stop()),mr=null)}var br=e=>"string"==typeof e,vr=e=>"boolean"==typeof e,wr=(...e)=>t=>"string"==typeof t&&e.includes(t),xr={widget_enabled:vr,widget_appearance:wr("default","hidden"),widget_position:wr("bottom_left","bottom_right","top_left","top_right"),widget_header:br,widget_body:br,widget_greeting:br,widget_greeting_toast:vr,widget_recording:vr,widget_feature_tell:vr,widget_feature_show:vr,widget_feature_do:vr,widget_background_color:br,widget_text_color:br,widget_border_color:br,widget_accent_color:br,widget_secondary_color:br,widget_border_radius:br,widget_font_size:br,widget_width:br,widget_height:br,widget_animation_duration:br,widget_fade_duration:br,widget_chips:e=>Array.isArray(e)&&e.every(e=>"object"==typeof e&&null!==e&&wr("tell","show","do")(e.chip_mode)&&br(e.chip_text))},Sr=Object.keys(xr),kr=/* @__PURE__ */new Set(["widget_border_radius","widget_font_size","widget_animation_duration","widget_fade_duration"]);function Cr(e){if("object"!=typeof e||null===e)return{invalidFields:["settings"]};const t=e,n=Sr.filter(e=>!xr[e](t[e]));if(n.length>0)return{invalidFields:n};const r={};for(const o of Sr)kr.has(o)||(r[o]=t[o]);return{settings:r}}var Er=e=>`Widget settings are invalid: ${e.join(", ")}`;function Ir(e,t={}){return{...t,...e}}function Mr(){}var Tr=Object.freeze([]),Rr=Object.freeze({});function Or(t){e.useEffect(t,Tr)}var Ar={};function _r(t,n){const r=e.useRef(Ar);return r.current===Ar&&(r.current=t(n)),r}var Dr="undefined"!=typeof document?e.useLayoutEffect:()=>{},Pr=function(e,...t){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`Base UI error #${e}; visit ${n} for the full message.`},Nr=/*#__PURE__*/e.createContext(void 0);function Lr(){const t=e.useContext(Nr);if(!t)throw new Error(Pr(73));return t}var Fr=parseInt(e.version,10);function zr(e){return Fr>=e}var $r=[],Br=void 0;function Wr(){return{didInitialize:!1}}var Ur,Hr=zr(19)?function(t,n,r,o,i){const s=Br;if(!s)return function(t,n,r,o,i){const s=e.useCallback(()=>n(t.getSnapshot(),r,o,i),[t,n,r,o,i]);return f(t.subscribe,s,s)}(t,n,r,o,i);const a=s.syncIndex;let c;return s.syncIndex+=1,s.didInitialize?(c=s.syncHooks[a],c.store===t&&c.selector===n&&Object.is(c.a1,r)&&Object.is(c.a2,o)&&Object.is(c.a3,i)||(c.store!==t&&(s.didChangeStore=!0),c.store=t,c.selector=n,c.a1=r,c.a2=o,c.a3=i,c.value=n(t.getSnapshot(),r,o,i))):(c={store:t,selector:n,a1:r,a2:o,a3:i,value:n(t.getSnapshot(),r,o,i)},s.syncHooks.push(c)),c.value}:function(e,t,n,r,o){return function(e,t,n,r){const o=d(null),i=e=>{const t=o.current;if(t&&Object.is(t.snapshot,e))return t.selection;const n=r(e);return o.current={snapshot:e,selection:n},n};return h(e,()=>i(t()),n&&(()=>i(n())))}(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,o))};function jr(e,t,n,r,o){return Hr(e,t,n,r,o)}Ur={before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=/* @__PURE__ */new Set;for(const o of e.syncHooks)n.add(o.store);const r=[];for(const e of n)r.push(e.subscribe(t));return()=>{for(const e of r)e()}}),f(e.subscribe,e.getSnapshot,e.getSnapshot))}},$r.push(Ur);var qr=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=/* @__PURE__ */new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;const t=this.updateTick;for(const n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(const t in e)if(!Object.is(this.state[t],e[t]))return void this.setState({...this.state,...e})}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){const e={...this.state};this.setState(e)}use(e,t,n,r){return jr(this,e,t,n,r)}},Vr={...e},Yr=Vr.useInsertionEffect,Kr=Yr&&Yr!==Vr.useLayoutEffect?Yr:e=>e();function Xr(e){const t=_r(Gr).current;return t.next=e,Kr(t.effect),t.trampoline}function Gr(){const e={next:void 0,callback:Jr,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Jr(){}var Zr=class extends qr{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(t,n){e.useDebugValue(t);const r=this;Dr(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(e,t){const n=this;Dr(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){const t=this,n=Object.values(e);Dr(()=>{t.update(e)},[t,...n])}useControlledProp(t,n){e.useDebugValue(t);const r=this,o=void 0!==n;Dr(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o])}select(e,t,n,r){return(0,this.selectors[e])(this.state,t,n,r)}useState(t,n,r,o){return e.useDebugValue(t),jr(this,this.selectors[t],n,r,o)}useContextCallback(t,n){e.useDebugValue(t);const r=Xr(n??Mr);this.context[t]=r}useStateSetter(t){const n=e.useRef(void 0);return void 0===n.current&&(n.current=e=>{this.set(t,e)}),n.current}observe(e,t){let n;n="function"==typeof e?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{const o=n(e);if(!Object.is(r,o)){const e=r;r=o,t(o,e,this)}})}};function Qr(){return"undefined"!=typeof window}function eo(e){return no(e)?(e.nodeName||"").toLowerCase():"#document"}function to(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function no(e){return!!Qr()&&(e instanceof Node||e instanceof to(e).Node)}function ro(e){return!!Qr()&&(e instanceof Element||e instanceof to(e).Element)}function oo(e){return!!Qr()&&(e instanceof HTMLElement||e instanceof to(e).HTMLElement)}function io(e){return!(!Qr()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof to(e).ShadowRoot)}function so(e){return/^(html|body|#document)$/.test(eo(e))}function ao(e){return to(e).getComputedStyle(e)}function co(e){if("html"===eo(e))return e;const t=e.assignedSlot||e.parentNode||io(e)&&e.host||function(e){var t;return null==(t=(no(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}(e);return io(t)?t.host:t}function lo(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}function uo(e){return e?.ownerDocument||document}function po(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}var ho=null;globalThis.requestAnimationFrame;var fo=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;const t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let r=0;r<t.length;r+=1)t[r]?.(e)};request(e){const t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){const t=e-this.startId;t<0||t>=this.callbacks.length||null!==this.callbacks[t]&&(this.callbacks[t]=null,this.callbacksCount-=1)}},mo=class e{static create(){return new e}static request(e){return fo.request(e)}static cancel(e){return fo.cancel(e)}currentId=ho;request(e){this.cancel(),this.currentId=fo.request(()=>{this.currentId=ho,e()})}cancel=()=>{this.currentId!==ho&&(fo.cancel(this.currentId),this.currentId=ho)};disposeEffect=()=>this.cancel};function go(){const e=_r(mo.create).current;return Or(e.disposeEffect),e}var yo=class e{static create(){return new e}currentId=0;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return 0!==this.currentId}clear=()=>{0!==this.currentId&&(clearTimeout(this.currentId),this.currentId=0)};disposeEffect=()=>this.clear};function bo(){const e=_r(yo.create).current;return Or(e.disposeEffect),e}var vo=0;function wo(e,t){if("string"==typeof e)return{description:e};if("function"==typeof e){const n=e(t);return"string"==typeof n?{description:n}:n}return e}var{userAgent:xo,platform:So,maxTouchPoints:ko}="undefined"==typeof navigator?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0},Co=xo.toLowerCase(),Eo=So.toLowerCase(),Io=/^i(os$|p)/.test(Eo)||"macintel"===Eo&&ko>1,Mo="android",To=Eo===Mo||Co.includes(Mo),Ro=!Io&&Eo.startsWith("mac"),Oo=(Eo.startsWith("win"),!To&&/^(linux|chrome os)/.test(Eo),Ro||Io),Ao="undefined"!=typeof CSS&&!!CSS.supports?.("-webkit-backdrop-filter:none"),_o=(!Ao&&Co.includes("firefox"),!Ao&&Co.includes("chrom"),Oo),Do=/jsdom|happydom/.test(Co);function Po(e){let t=e.activeElement;for(;null!=t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function No(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&io(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Lo(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}var Fo="data-base-ui-focusable",zo="data-starting-style",$o="data-ending-style",Bo={[zo]:""},Wo={[$o]:""},Uo={transitionStatus:e=>"starting"===e?Bo:"ending"===e?Wo:null},Ho="data-open",jo="data-closed",qo="data-anchor-hidden",Vo={[Ho]:""},Yo={[jo]:""},Ko={[qo]:""},Xo={open:e=>e?Vo:Yo,anchorHidden:e=>e?Ko:null},Go={...Xo,...Uo};function Jo(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function Zo(e){return oo(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function Qo(e){return!!e&&"combobox"===e.getAttribute("role")&&Zo(e)}function ei(e){if(!e||Do)return!0;try{return e.matches(":focus-visible")}catch(t){return!0}}function ti(e){return e?e.hasAttribute("data-base-ui-focusable")?e:e.querySelector("[data-base-ui-focusable]")||e:null}function ni(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ni(e,t.id,n)])}function ri(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){const t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function oi(e){return!(""!==e.pointerType||!e.isTrusted)||(To&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function ii(e,t){return t<0||t>=e.length}function si(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:o=1}={}){let i=t;do{i+=n?-o:o}while(i>=0&&i<=e.length-1&&ai(e,i,r));return i}function ai(e,t,n){if("function"==typeof n?n(t):n?.includes(t))return!0;const r=e[t];return!!r&&(!ci(r)||!!r.matches(":disabled")||!n&&(r.hasAttribute("disabled")||"true"===r.getAttribute("aria-disabled")))}function ci(e,t=(e?ao(e):null)){return!(!(e&&e.isConnected&&t)||function(e){return"hidden"===e.visibility||"collapse"===e.visibility}(t))&&("function"==typeof e.checkVisibility?e.checkVisibility():"none"!==t.display&&"contents"!==t.display)}function li(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return io(n)?n.host:null}function ui(e){for(const t of Array.from(e.children))if("summary"===eo(t))return t;return null}function di(e,t){const n=ui(t);return!!n&&(e===n||No(n,e))}function pi(e){const t=e?eo(e):"";return null!=e&&e.matches('a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]')&&("summary"!==t||null!=e.parentElement&&"details"===eo(e.parentElement)&&ui(e.parentElement)===e)&&("details"!==t||null==ui(e))&&("input"!==t||"hidden"!==e.type)}function hi(e){if(!pi(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=li(t)){const n=t!==e,r="slot"===eo(t);if(t.hasAttribute("inert"))return!1;if(n&&"details"===eo(t)&&!t.open&&!di(e,t)||t.hasAttribute("hidden")||!r&&!fi(t,n))return!1}return!0}function fi(e,t){const n=ao(e);return t?"none"!==n.display:ci(e,n)}function mi(e){const t=e.tabIndex;if(t<0){const t=eo(e);if("details"===t||"audio"===t||"video"===t||oo(e)&&e.isContentEditable)return 0}return t}function gi(e){if("input"!==eo(e))return null;const t=e;return"radio"===t.type&&""!==t.name?t:null}function yi(e){if(oo(e)&&"slot"===eo(e)){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return oo(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function bi(e,t){yi(e).forEach(e=>{pi(e)&&t.push(e),bi(e,t)})}function vi(e,t,n){yi(e).forEach(e=>{oo(e)&&e.matches(t)&&n.push(e),vi(e,t,n)})}function wi(e){return hi(e)&&mi(e)>=0}function xi(e){const t=[];return bi(e,t),t.filter(hi)}function Si(e){const t=xi(e);return t.filter(e=>mi(e)>=0&&function(e,t){const n=gi(e);if(!n)return!0;const r=t.find(e=>{const t=gi(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{const t=gi(e);return t?.name===n.name&&t.form===n.form})===n}(e,t))}function ki(e,t){const n=Si(e),r=n.length;if(0===r)return;const o=Po(uo(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Ci(e){return ki(uo(e).body,1)||e}function Ei(e){return ki(uo(e).body,-1)||e}function Ii(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!No(n,r)}function Mi(e){const t=[];vi(e,"[data-tabindex]",t),t.forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}function Ti(e){const t=/* @__PURE__ */new Map;let n=0,r=0;return e.forEach((e,o)=>{const i="ending"===e.transitionStatus;t.set(e.id,{value:e,domIndex:o,visibleIndex:i?-1:n,offsetY:r}),r+=e.height||0,i||(n+=1)}),t}function Ri(e,t){let n=0;return e.map(e=>{if("ending"===e.transitionStatus)return e;const r=n>=t;return n+=1,e.limited===r?e:{...e,limited:r}})}var Oi={toasts:e=>e.toasts,isEmpty:e=>0===e.toasts.length,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement},Ai=class extends Zr{timers=/* @__PURE__ */new Map;areTimersPaused=!1;constructor(e){super({...e,toastMetadata:Ti(e.toasts)},{},Oi)}setViewport=e=>{this.set("viewport",e)};syncProviderProps(e,t){const n=this.state.limit!==t;if(this.state.timeout===e&&!n)return;const r={timeout:e,limit:t};if(n){const e=Ri(this.state.toasts,t);r.toasts=e,r.toastMetadata=Ti(e)}this.update(r)}disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e,t=!1){const n=Oi.toastIndex(this.state,e);if(-1===n)return;const r=this.state.toasts[n];t||r?.onRemove?.();const o=[...this.state.toasts];o.splice(n,1),this.setToasts(o)}addToast=e=>{const{timeout:t,limit:n}=this.state,r=e.id||(vo+=1,`toast-${Math.random().toString(36).slice(2,6)}-${vo}`);if(e.id){const t=Oi.toast(this.state,e.id);if(t){if("ending"!==t.transitionStatus){const{id:t,transitionStatus:n,...r}=e;return this.updateToastInternal(e.id,r,!0,!0),e.id}this.removeToast(e.id,!0)}}const o={...e,id:r,updateKey:0,transitionStatus:"starting"},i=[o,...this.state.toasts];this.setToasts(Ri(i,n));const s=o.timeout??t;return"loading"!==o.type&&s>0&&this.scheduleTimer(r,s,()=>this.closeToast(r)),Oi.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),r};updateToast=(e,t)=>{const n=Oi.toast(this.state,e);n&&"ending"!==n.transitionStatus&&this.updateToastInternal(e,"function"==typeof t?t(n):t,!1,!0)};updateToastInternal=(e,t,n=!1,r=!1)=>{const{timeout:o,toasts:i}=this.state,s=Oi.toast(this.state,e);if(!s)return;if("ending"===s.transitionStatus)return;const a={...s,...t,...r&&{updateKey:s.updateKey+1}};this.setToasts(i.map(t=>t.id===e?a:t));const c=a.timeout??o,l=s.timeout??o,u=Object.hasOwn(t,"timeout"),d="ending"!==a.transitionStatus&&"loading"!==a.type&&c>0,p=this.timers.has(e),h=l!==c,f="loading"===s.type;d||!p?d&&(!p||h||u||f||n)&&(this.clearTimer(e),this.scheduleTimer(e,c,()=>this.closeToast(e)),Oi.expandedOrOutOfFocus(this.state)&&this.pauseTimers()):this.clearTimer(e)};closeToast=e=>{const t=void 0===e,{limit:n,toasts:r}=this.state;let o;if(t)o=r,this.clearTimers();else{const t=Oi.toast(this.state,e);if(!t)return;o=[t],this.clearTimer(e)}const i=Ri(r.map(n=>t||n.id===e?{...n,transitionStatus:"ending",height:0}:n),n);this.setToasts(i,!i.some(e=>"ending"!==e.transitionStatus)),o.forEach(e=>{"ending"!==e.transitionStatus&&e.onClose?.()}),this.handleFocusManagement(e)};promiseToast=(e,t)=>{const n=wo(t.loading),r=this.addToast({...n,type:"loading"}),o=e.then(e=>{const n=wo(t.success,e);return this.updateToast(r,{...n,type:"success",timeout:n.timeout}),e}).catch(e=>{const n=wo(t.error,e);return this.updateToast(r,{...n,type:"error",timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,"setPromise")&&t.setPromise(o),o};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{e.timeout&&(e.timeout.clear(),e.remaining=Math.max(e.remaining-(Date.now()-e.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=yo.create(),e.timeout.start(e.remaining,()=>{this.handleTimerFired(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if("touch"!==e.pointerType)return;const t=Lo(e);No(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){const r=Date.now(),o=Oi.expandedOrOutOfFocus(this.state)?void 0:yo.create();o?.start(t,()=>{this.handleTimerFired(e),n()}),this.timers.set(e,{timeout:o,start:r,delay:t,remaining:t,callback:n})}clearTimers(){this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(e){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(e){this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){0===this.timers.size&&(this.areTimersPaused=!1)}setToasts(e,t=0===e.length){const n={toasts:e,toastMetadata:Ti(e)};t&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(e){const t=Po(uo(this.state.viewport));if(!this.state.viewport||!No(this.state.viewport,t)||!ei(t))return;if(void 0===e)return void this.restoreFocusToPrevElement();const n=Oi.toasts(this.state),r=Oi.toastIndex(this.state,e),o=(e,t)=>{for(let r=e;r>=0&&r<n.length;r+=t)if("ending"!==n[r].transitionStatus)return n[r];return null},i=o(r+1,1)??o(r-1,-1);i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},_i=function(t){const{children:n,timeout:r=5e3,limit:o=3,toastManager:i}=t,s=_r(()=>new Ai({timeout:r,limit:o,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Or(s.disposeEffect),e.useEffect(function(){if(i)return i[" subscribe"](({action:e,options:t})=>{const n=t.id;"promise"===e&&t.promise?s.promiseToast(t.promise,t):"update"===e&&n?s.updateToast(n,t.updates):"close"===e?s.closeToast(n):s.addToast(t)})},[s,i]),/*#__PURE__*/v(Nr.Provider,{value:s,children:[/*#__PURE__*/b(Di,{store:s,timeout:r,limit:o}),n]})};function Di(e){const{store:t,timeout:n,limit:r}=e;return Dr(()=>{t.syncProviderProps(n,r)},[t,n,r]),null}var Pi={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1,position:"fixed",top:0,left:0},Ni=/*#__PURE__*/e.forwardRef(function(t,n){const[r,o]=e.useState();return Dr(()=>{_o&&Ao&&o("button")},[]),/*#__PURE__*/b("span",{...t,ref:n,style:Pi,"aria-hidden":!r||void 0,tabIndex:0,role:r,"data-base-ui-focus-guard":""})});function Li(e,t,n,r){const o=_r(Fi).current;return function(e,t,n,r,o){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==o}(o,e,t,n,r)&&zi(o,[e,t,n,r]),o.callback}function Fi(){return{callback:null,cleanup:null,refs:[]}}function zi(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 o=t[e];if(null!=o)switch(typeof o){case"function":{const t=o(n);"function"==typeof t&&(r[e]=t);break}case"object":o.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}}}}}}function $i(t){if(!/*#__PURE__*/e.isValidElement(t))return null;const n=t,r=n.props;return(zr(19)?r?.ref:n.ref)??null}function Bi(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var Wi={};function Ui(e,t,n,r,o){if(!(n||r||o||e))return Hi(t);let i=Hi(e);return t&&(i=ji(i,t)),n&&(i=ji(i,n)),r&&(i=ji(i,r)),o&&(i=ji(i,o)),i}function Hi(e){return Vi(e)?{...Yi(e,Wi)}:function(e){const t={...e};for(const n in t){const e=t[n];qi(n,e)&&(t[n]=Xi(e))}return t}(e)}function ji(e,t){return Vi(t)?Yi(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=Bi(e.style,r);break;case"className":e[n]=Ji(e.className,r);break;default:qi(n,r)?e[n]=Ki(e[n],r):e[n]=r}}return e}(e,t)}function qi(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),o=e.charCodeAt(2);return 111===n&&110===r&&o>=65&&o<=90&&("function"==typeof t||void 0===t)}function Vi(e){return"function"==typeof e}function Yi(e,t){return Vi(e)?e(t):e??Wi}function Ki(e,t){return t?e?(...n)=>{const r=n[0];if(Zi(r)){const o=r;Gi(o);const i=t(...n);return o.baseUIHandlerPrevented||e?.(...n),i}const o=t(...n);return e?.(...n),o}:Xi(t):e}function Xi(e){return e?(...t)=>{const n=t[0];return Zi(n)&&Gi(n),e(...t)}:e}function Gi(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Ji(e,t){return t?e?t+" "+e:t:e}function Zi(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}function Qi(t,n,o={}){let i=n.render;!1!==o.enabled&&(i=function(t){if(t?.$$typeof!==es)return t;const n=e.Children.toArray(t)[0];/*#__PURE__*/
1
+ import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as s,useEffect as a,useImperativeHandle as c,useLayoutEffect as l,useMemo as u,useRef as d,useState as p,useSyncExternalStore as h,useSyncExternalStore as f}from"react";import{createRoot as m}from"react-dom/client";import*as g from"react-dom";import{Fragment as y,jsx as b,jsxs as v}from"react/jsx-runtime";function w(e){return Array.isArray(e)?e:null==e?[]:[e]}var x="orpc",S=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function k(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function C(){return globalThis["__@orpc/shared@1.15.1/otel/config__"]}function E(e,t={},n){return(C()?.tracer)?.startSpan(e,t,n)}function I(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 M({name:e,context:t,...n},r){const o=C()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw I(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function T(e,t){const n=C();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function R(e){return!(!e||"object"!=typeof e)&&"next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator]}var O=Symbol.asyncDispose??Symbol.for("asyncDispose"),A=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[O](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function _({name:e,...t},n){let r;return new A(async()=>{r??=E(e);try{const e=await T(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw I(r,o,t),o}},async e=>{try{"next"!==e&&await T(r,()=>n.return?.())}catch(o){throw I(r,o,t),o}finally{r?.end()}})}function D(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function P(e){if(e)return JSON.parse(e)}function N(e){return JSON.stringify(e)}function L(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function F(e){return!!e&&("object"==typeof e||"function"==typeof e)}function z(e,...t){return"function"==typeof e?e(...t):e}function $(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)&&W.test(t.toString()));var t}))return Reflect.apply(t,n,r);let o=!0;r[0].call(n,$(new Proxy(e,{get:(e,t,n)=>{if(!o||"then"!==t)return Reflect.get(e,t,n);o=!1}})))}})}})}var B,W=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/,U=/* @__PURE__ */new Set(["bind","valueOf","toString","toJSON"]),H={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"}},j=class e extends Error{defined;code;status;data;static{const t=Symbol.for("__@orpc/client@1.15.1/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(B=globalThis[t]).add(e)}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||H[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??H[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(B.has(this)){const t=function(e){return F(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&B.has(t))return!0}return super[Symbol.hasInstance](e)}};function q(e){return e<200||e>=400}function V(e){if(!L(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 Y(e,t={}){return new j(e.code,{...t,...e})}var K=class extends TypeError{},X=class extends TypeError{},G=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}},J=/\r\n|\r(?!\n)|\n/,Z=/(?:\r\n|\r(?!\n)|\n){2}/,Q=/(?:\r\n|\r(?!\n)|\n){2}/g;function ee(e){const t={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const n of e.split(J)){if(""===n)continue;const e=n.indexOf(":"),r=-1===e?"":n.slice(32===n.charCodeAt(e+1)?e+2:e+1);if(0!==e)switch(-1===e?n:n.slice(0,e)){case"data":t.data=void 0===t.data?r:`${t.data}\n${r}`;break;case"event":t.event=r;break;case"id":t.id=r;break;case"retry":{const e=Number.parseInt(r,10);e>=0&&e.toString()===r&&(t.retry=e);break}}else t.comments.push(r)}return t}var te=class{constructor(e={}){this.options=e}pending=[];tail="";discardLeadingLF=!1;feed(e){if(""===e)return;if(this.discardLeadingLF&&(this.discardLeadingLF=!1,10===e.charCodeAt(0)&&""===(e=e.slice(1))))return;const t=this.tail+e;if(!Z.test(t))return this.pending.push(e),void(this.tail=t.slice(-3));this.pending.push(e);const n=1===this.pending.length?e:this.pending.join(""),r=n.length-t.length,o=[];let i=0;for(const a of t.matchAll(Q))o.push(n.slice(i,r+a.index)),i=r+a.index+a[0].length;const s=n.slice(i);this.pending.length=0,this.tail=s.slice(-3),""===s?this.discardLeadingLF=13===e.charCodeAt(e.length-1):this.pending.push(s);for(const a of o){const e=ee(a);this.options.onEvent&&this.options.onEvent(e)}}end(){if(0!==this.pending.length)throw new X("Event Iterator ended before complete")}},ne=class extends TransformStream{constructor(){let e;super({start(t){e=new te({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}},re=/\r\n|[\n\r]/,oe=/\r\n|[\n\r]/g;function ie(e){return re.test(e)}function se(e){if(ie(e))throw new K("Event's id must not contain a carriage return or newline character")}function ae(e){if(!Number.isInteger(e)||e<0)throw new K("Event's retry must be a integer and >= 0")}function ce(e){if(ie(e))throw new K("Event's comment must not contain a carriage return or newline character")}function le(e){let t="";var n;return t+=function(e){let t="";for(const n of e??[])ce(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(function(e){if(ie(e))throw new K("Event's event must not contain a carriage return or newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(ae(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(se(e.id),t+=`id: ${e.id}\n`),t+=void 0===(n=e.data)?"":`data: ${n.replace(oe,"\ndata: ")}\n`,t+="\n",t}var ue=Symbol("ORPC_EVENT_SOURCE_META");function de(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&se(t.id),void 0!==t.retry&&ae(t.retry),void 0!==t.comments)for(const n of t.comments)ce(n);return new Proxy(e,{get:(e,n,r)=>n===ue?t:Reflect.get(e,n,r)})}function pe(e){return F(e)?Reflect.get(e,ue):void 0}function he(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=pe(e);t&&F(n)&&(n=de(n,t))}return n};return new A(async()=>{const{done:r,value:o}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let i=await t.value(o,r);if(i!==o){const e=pe(o);e&&F(i)&&(i=de(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function fe(e,t={}){const n=t.path??[];return $(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,o)=>"string"!=typeof o||U.has(o)?Reflect.get(r,o):fe(e,{...t,path:[...n,o]})}))}function me(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}var ge=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)}},ye=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new ge(n.plugins).init(n),this.interceptors=w(n.interceptors),this.clientInterceptors=w(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return M({name:`${x}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",x),r?.setAttribute("rpc.method",e.join(".")),R(t)&&(t=_({name:"consume_event_iterator_input",signal:n.signal},t)),D(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=C();let i;const s=o?.trace.getActiveSpan()??r;s&&o&&(i=o?.trace.setSpan(o.context.active(),s));const a=await M({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await D(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>M({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await M({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return R(l)?_({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},be=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],n=[],r=[],o=[]){for(const i of this.customSerializers)if(i.condition(e)){const s=this.serialize(i.serialize(e),t,n,r,o);return n.push([i.type,...t]),s}if(e instanceof Blob)return r.push(t),o.push(e),[e,n,r,o];if("bigint"==typeof e)return n.push([0,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([1,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([2,...t]),[null,n,r,o];if(e instanceof URL)return n.push([4,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([5,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([6,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([7,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([3,...t,i]),null):this.serialize(e,[...t,i],n,r,o)[0]),n,r,o];if(L(e)){const i={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(i[s]=this.serialize(e[s],[...t,s],n,r,o)[0]);return[i,n,r,o]}return[e,n,r,o]}deserialize(e,t,n,r){const o={data:e};n&&r&&n.forEach((e,t)=>{let n=o,i="data";e.forEach(e=>{if(n=n[i],i=e,!Object.hasOwn(n,i))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${i}`)}),n[i]=r(t)});for(const i of t){const e=i[0];let t=o,n="data";for(let r=1;r<i.length;r++)if(t=t[n],n=i[r],!Object.hasOwn(t,n))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${n}`);for(const r of this.customSerializers)if(r.type===e){t[n]=r.deserialize(t[n]);break}switch(e){case 0:t[n]=BigInt(t[n]);break;case 1:t[n]=new Date(t[n]??"Invalid Date");break;case 2:t[n]=NaN;break;case 3:t[n]=void 0;break;case 4:t[n]=new URL(t[n]);break;case 5:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case 6:t[n]=new Set(t[n]);break;case 7:t[n]=new Map(t[n])}}return o.data}},ve=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?me(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]=[...w(n[r]),...t[r]]:void 0!==t[r]&&(Array.isArray(n[r])?n[r]=[...n[r],t[r]]:void 0!==n[r]?n[r]=[n[r],t[r]]:n[r]=t[r]);return n}(r,{"last-event-id":n.lastEventId}));const o=await z(this.expectedMethod,n,e,t),i=await z(this.baseUrl,n,e,t),s=new URL(i);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==o||a instanceof FormData||R(a))){const i=await z(this.maxUrlLength,n,e,t),c=new URL(s);if(c.searchParams.append("data",N(a)),c.toString().length<=i)return{body:void 0,method:o,headers:r,url:c,signal:n.signal}}return{url:s,method:"GET"===o?this.fallbackMethod:o,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(V(n))throw Y(n);throw new j((r=e.status,Object.entries(H).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},we=class{constructor(e){this.jsonSerializer=e}serialize(e){return R(e)?he(e,{value:async e=>this.#o(e,!1),error:async e=>{return new G({data:this.#o((t=e,t instanceof j?t:new j("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#o(e,!0)}#o(e,t){const[n,r,o,i]=this.jsonSerializer.serialize(e),s=0===r.length?void 0:r;if(!t||0===i.length)return{json:n,meta:s};const a=new FormData;return a.set("data",N({json:n,meta:s,maps:o})),i.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return R(e)?he(e,{value:async e=>this.#i(e),error:async e=>{if(!(e instanceof G))return e;const t=this.#i(e.data);return V(t)?Y(t,{cause:e}):new G({data:t,cause:e})}}):this.#i(e)}#i(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},xe=class extends ye{constructor(e,t){const n=new be(t),r=new we(n);super(new ve(r,t),e,t)}},Se=class extends ge{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},ke=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new Se(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=w(e.adapterInterceptors)}async call(e,t,n,r){const o=function(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=function(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:R(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,c,l=!1;return new ReadableStream({start(e){c=E("stream_event_iterator"),i&&e.enqueue(le({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(le({comments:[o]})),c?.addEvent("keepalive")},r));const i=await T(c,()=>e.next());if(clearInterval(a),l)return;const s=pe(i.value);if(!i.done||void 0!==i.value||void 0!==s){const e=i.done?"done":"message";t.enqueue(le({...s,event:e,data:N(i.value)})),c?.addEvent(e)}i.done&&(t.close(),c?.end())}catch(i){if(clearInterval(a),l)return;i instanceof G?(t.enqueue(le({...pe(i),event:"error",data:N(i.data)})),c?.addEvent("error"),t.close()):(I(c,i),t.error(i)),c?.end()}},async cancel(){try{l=!0,clearInterval(a),c?.addEvent("cancelled"),await T(c,()=>e.return?.())}catch(t){throw I(c,t),t}finally{c?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),N(e)):void 0}(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}(e,this.toFetchRequestOptions);return function(e,t={}){return{body:k(()=>function(e,t={}){return M({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=function(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}(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 P(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 ne))?.getReader();let r,o=!1;return new A(async()=>{r??=E("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await T(r,()=>n.read());if(e){if(o)throw new S("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=P(t.data);return F(e)&&(e=de(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new G({data:P(t.data)});throw e=de(e,t),r?.addEvent("error"),e}case"done":{let e=P(t.data);return F(e)&&(e=de(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof G||I(r,e,t),e}},async e=>{try{"next"!==e&&(o=!0,r?.addEvent("cancelled")),await T(r,()=>n?.cancel())}catch(i){throw I(r,i,t),i}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const o=await e.blob();return new File([o],"blob",{type:o.type})})}(e,t)),status:e.status,get headers(){const t=me(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await D(this.adapterInterceptors,{...t,request:o,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...o})=>this.fetch(e,r,o,t,n)),{signal:o.signal})}},Ce=class extends xe{constructor(e){super(new ke(e),e)}};function Ee(e){return fe(new Ce({url:e}))}var Ie="",Me=Ee(""),Te=new Proxy({},{get:(e,t)=>Me[t]});function Re(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function Oe(e,t){console.warn(void 0===t?e:`${e} ${Re(t)}`)}var Ae="marketrix_chat_context";function _e(e,t){return`${e}_${function(e){return e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}(t)}`}var De={chat_id:null,messages:[],currentMode:"tell",isOpen:!1,config:null,timestamp:0};function Pe(e){try{return"undefined"==typeof localStorage?null:localStorage.getItem(e)}catch(t){return Oe("[StorageService] localStorage is unreadable:",t),null}}function Ne(e,t){try{"undefined"!=typeof localStorage&&localStorage.setItem(e,t)}catch(n){Oe("[StorageService] localStorage is unwritable:",n)}}function Le(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.content&&("user"===t.sender||"agent"===t.sender)&&"string"==typeof t.timestamp&&Array.isArray(t.parts)}function Fe(e){const t=Pe(e);if(!t)return{...De};try{const e=function(e){if("object"!=typeof e||null===e)return{...De};const t=e,n=t.chat_id,r=t.currentMode,o=t.config,i=t.timestamp;return{chat_id:"string"==typeof n||null===n?n:De.chat_id,messages:Array.isArray(t.messages)?t.messages.filter(Le):De.messages,currentMode:"tell"===r||"show"===r||"do"===r?r:De.currentMode,isOpen:"boolean"==typeof t.isOpen?t.isOpen:De.isOpen,config:"object"==typeof o?o:De.config,timestamp:"number"==typeof i?i:De.timestamp}}(JSON.parse(t));if(Date.now()-e.timestamp<=6048e5)return e}catch(n){Oe("[StorageService] Failed to parse the stored context:",n)}return{...De}}var ze,$e=new class{key=Ae;context=Fe(this.key);getContext(){return this.context}updateContext(e){this.context={...this.context,...e,timestamp:Date.now()},Ne(this.key,JSON.stringify(this.context))}getChatId(){return this.context.chat_id}setChatId(e){this.updateContext({chat_id:e})}getCredentialedConfig(){const{config:e}=this.context;return e?.mtxId&&e.mtxKey?e:null}setConfig(e){this.key=_e(Ae,e),this.context=Fe(this.key),this.updateContext({config:e})}},Be=new class{creation=null;async getOrCreateChatId(){return $e.getChatId()||(this.creation??=(async()=>{const e=await Te.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return $e.setChatId(e),e})().finally(()=>{this.creation=null}),this.creation)}},We=Object.defineProperty,Ue=(e,t,n)=>((e,t,n)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),He=/* @__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[e.Asset=7]="Asset",e))(He||{}),je=/* @__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))(je||{}),qe=/* @__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))(qe||{}),Ve=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ve||{}),Ye=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ye||{}),Ke=/* @__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))(Ke||{}),Xe=/* @__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))(Xe||{}),Ge={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Je={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ze={},Qe={};function et(e){if(Ze[e])return Ze[e];const t=globalThis[e],n=t.prototype,r=e in Ge?Ge[e]:void 0,o=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]"))})),i=e in Je?Je[e]:void 0,s=Boolean(i&&i.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(o&&s&&!globalThis.Zone)return Ze[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");r.style.display="none",document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;if(!i)return r.remove(),n;const s=navigator.userAgent;return s.includes("Safari")&&!s.includes("Chrome")?(r.classList.add("rr-block"),r.setAttribute("__rrwebUntaintedMutationObserver",""),Qe[e]=()=>r.remove()):r.remove(),Ze[e]=i}catch{return n}}var tt={};function nt(e,t,n){var r;const o=`${e}.${String(n)}`;if(tt[o])return tt[o].call(t);const i=et(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(tt[o]=s,s.call(t)):t[n]}var rt={};function ot(e,t,n){const r=`${e}.${String(n)}`;if(rt[r])return rt[r].bind(t);const o=et(e)[n];return"function"!=typeof o?t[n]:(rt[r]=o,o.bind(t))}var it=Date.now;function st(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(it=()=>/* @__PURE__ */(new Date).getTime());var at=function(e){return nt("Node",e,"ownerDocument")},ct=function(e){return nt("Node",e,"childNodes")},lt=function(e){return nt("Node",e,"parentNode")},ut=function(e){return nt("Node",e,"parentElement")},dt=function(e){return nt("Node",e,"textContent")},pt=function(e,t){return ot("Node",e,"contains")(t)},ht=function(e){return ot("Node",e,"getRootNode")()},ft=function(e){return e&&"host"in e?nt("ShadowRoot",e,"host"):null},mt=function(e){return e&&"shadowRoot"in e?nt("Element",e,"shadowRoot"):null};function gt(e){return e.nodeType===e.ELEMENT_NODE}function yt(e){const t=e&&"host"in e&&"mode"in e&&ft(e)||null;return Boolean(t&&"shadowRoot"in t&&mt(t)===e)}function bt(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function vt(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=>wt(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 wt(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=vt(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?At(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?At(n,t):n}}var xt=class{constructor(){Ue(this,"idNodeMap",/* @__PURE__ */new Map),Ue(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 St({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:i}){let s=o||"";const a=r&&kt(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=i?i(s,e):"*".repeat(s.length)),s}function kt(e){return e.toLowerCase()}var Ct="__rrweb_original__";function Et(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?kt(t):null}function It(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(o){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}var Mt=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Tt=/^(?:[a-z+]+:)?\/\//i,Rt=/^www\..*/i,Ot=/^(data:)([^,]*),(.*)/i;function At(e,t){return(e||"").replace(Mt,(e,n,r,o,i,s)=>{const a=r||i||s,c=n||o||"";if(!a)return e;if(Tt.test(a)||Rt.test(a))return`url(${c}${a}${c})`;if(Ot.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${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}${c})`;const l=a.split("#")[0],u=a.substring(l.length),d=t.split("#")[0].split("/"),p=l.split("/");d.pop();for(const t of p)"."!==t&&(".."===t?d.pop():d.push(t));return`url(${c}${d.join("/")}${u}${c})`})}function _t(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}var Dt,Pt,Nt=1,Lt=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function Ft(){return Nt++}var zt=/^[^ \t\n\r\u000c]+/,$t=/^[, \t\n\r\u000c]+/,Bt=/* @__PURE__ */new WeakMap;function Wt(e,t){return t&&""!==t.trim()?Ut(e,t):t}function Ut(e,t){let n=Bt.get(e);if(n||(n=e.createElement("a"),Bt.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function Ht(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)?Wt(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r($t),!(n>=t.length);){let i=r(zt);if(","===i.slice(-1))i=Wt(e,i.substring(0,i.length-1)),o.push(i);else{let r="";i=Wt(e,i);let s=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((i+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,o.push((i+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?At(r,Ut(e)):"object"===t&&"data"===n?Wt(e,r):r:r}function jt(e,t,n){return["video","audio"].includes(e)&&"autoplay"===kt(t)}function qt(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&qt(lt(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&qt(lt(e),t,n)}function Vt(e,t,n,r){let o;if(gt(e)){if(o=e,!ct(o).length)return!1}else{if(null===ut(e))return!1;o=ut(e)}try{if("string"==typeof t){if(r){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(qt(o,t,r))return!0;if(n)if(r){if(o.closest(n))return!0}else if(o.matches(n))return!0}catch(i){}return!1}function Yt(e){return null==e?"":e.toLowerCase()}function Kt(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 Xt(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,maskTextClass:s,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f={},inlineImages:m=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:S=()=>!1,newlyAddedElement:k=!1,cssCaptured:C=!1}=t;let{needsMask:E}=t,{preserveWhiteSpace:I=!0}=t;E||(E=Vt(e,s,a,void 0===E));const M=function(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:s,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:l,maskInputFn:u,dataURLOptions:d={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m=!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:Xe.Document,childNodes:[],compatMode:e.compatMode}:{type:Xe.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:Xe.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:o,inlineStylesheet:i,maskInputOptions:s={},maskInputFn:a,dataURLOptions:c={},inlineImages:l,recordCanvas:u,keepIframeSrcFn:d,newlyAddedElement:p=!1,rootId:h}=t,f=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,o),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=kt(e.tagName);return Lt.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let x=0;x<y;x++){const t=e.attributes[x];jt(m,t.name,t.value)||(g[t.name]=Ht(n,m,kt(t.name),t.value))}if("link"===m&&i){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=vt(t)),r&&(delete g.rel,delete g.href,g._cssText=r)}if("style"===m&&e.sheet){let t=vt(e.sheet);t&&(e.childNodes.length>1&&(t=function(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),o=[];let i=0;if(r.length>1&&e&&"string"==typeof e){let t=_t(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 c=_t(r[a].textContent,n),l=100;let u=3;for(;u<c.length&&(c[u].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,u),1));u++);for(;u<c.length;u++){let d=c.substring(0,u),p=t.split(d),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[a-1].textContent)h=t.indexOf(d,1);else if(1===p.length){if(d=d.substring(0,d.length-1),p=t.split(d),p.length<=1)return o.push(e),o;u=101}else u===c.length-1&&(h=t.indexOf(d));if(p.length>=2&&u>l){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=_t(e).length;h=t.indexOf(d,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/s);for(;a>0&&a<e.length;){if(i+=1,i>50*r.length)return o.push(e),o;const c=_t(e.substring(0,a),n);if(c.length===h){o.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}c.length<h?a+=Math.max(1,Math.floor((h-c.length)/s)):a-=Math.max(1,Math.floor((c.length-h)*s))}break}}}}return o.push(e),o}(e,t).join("/* rr_split */")}(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(m)){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=St({element:e,type:Et(e),tagName:m,value:t,maskInputOptions:s,maskInputFn:a}):n&&(g.checked=n)}if("option"===m&&(e.selected&&!s.select?g.selected=!0:delete g.selected),"dialog"===m&&e.open&&(g.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"),"canvas"===m&&u)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 o=t.getImageData,i=Ct in o?o[Ct]:o;if(new Uint32Array(i.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(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height,t!==r.toDataURL(c.type,c.quality)&&(g.rr_dataURL=t)}if("img"===m&&l){Dt||(Dt=n.createElement("canvas"),Pt=Dt.getContext("2d"));const t=e,r=t.currentSrc||t.getAttribute("src")||"<unknown-src>",o=t.crossOrigin,i=()=>{t.removeEventListener("load",i);try{Dt.width=t.naturalWidth,Dt.height=t.naturalHeight,Pt.drawImage(t,0,0),g.rr_dataURL=Dt.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i));console.warn(`Cannot inline img src=${r}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(o?g.crossOrigin=o:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i)}if(["audio","video"].includes(m)){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}if(p||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop)),f){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}let b;"iframe"!==m||d(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);try{customElements.get(m)&&(b=!0)}catch(w){}return{type:Xe.Element,tagName:m,attributes:g,childNodes:[],isSVG:(v=e,Boolean("svg"===v.tagName||v.ownerSVGElement)||void 0),needBlock:f,rootId:h,isCustom:b};var v}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:a,maskInputOptions:c,maskInputFn:u,dataURLOptions:d,inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:o,cssCaptured:i}=t,s=lt(e),a=s&&s.tagName;let c="";const l="STYLE"===a||void 0,u="SCRIPT"===a||void 0;return u?c="SCRIPT_PLACEHOLDER":i||(c=dt(e),l&&c&&(c=At(c,Ut(t.doc)))),!l&&!u&&c&&n&&(c=r?r(c,ut(e)):c.replace(/[\S]/g,"*")),{type:Xe.Text,textContent:c||"",rootId:o}}(e,{doc:n,needsMask:s,maskTextFn:l,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:Xe.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:Xe.Comment,textContent:dt(e)||"",rootId:y};default:return!1}}(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:E,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,keepIframeSrcFn:S,newlyAddedElement:k,cssCaptured:C});if(!M)return console.warn(e,"not serialized"),null;let T;T=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===Xe.Comment)return!0;if(e.type===Xe.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"===It(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Yt(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Yt(e.attributes.name)||"icon"===Yt(e.attributes.rel)||"apple-touch-icon"===Yt(e.attributes.rel)||"shortcut icon"===Yt(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Yt(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Yt(e.attributes.property).match(/^(og|twitter|fb):/)||Yt(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Yt(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===Yt(e.attributes.name)||"googlebot"===Yt(e.attributes.name)||"bingbot"===Yt(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===Yt(e.attributes.name)||"generator"===Yt(e.attributes.name)||"framework"===Yt(e.attributes.name)||"publisher"===Yt(e.attributes.name)||"progid"===Yt(e.attributes.name)||Yt(e.attributes.property).match(/^article:/)||Yt(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===Yt(e.attributes.name)||"yandex-verification"===Yt(e.attributes.name)||"csrf-token"===Yt(e.attributes.name)||"p:domain_verify"===Yt(e.attributes.name)||"verify-v1"===Yt(e.attributes.name)||"verification"===Yt(e.attributes.name)||"shopify-checkout-api-token"===Yt(e.attributes.name)))return!0}}return!1}(M,h)||!I&&M.type===Xe.Text&&!M.textContent.replace(/^\s+|\s+$/gm,"").length?-2:Ft();const R=Object.assign(M,{id:T});if(r.add(e,R),-2===T)return null;y&&y(e);let O=!c;if(R.type===Xe.Element){O=O&&!R.needBlock,delete R.needBlock;const t=mt(e);t&&bt(t)&&(R.isShadowHost=!0)}if((R.type===Xe.Document||R.type===Xe.Element)&&O){h.headWhitespace&&R.type===Xe.Element&&"head"===R.tagName&&(I=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:E,maskTextClass:s,maskTextSelector:a,skipChild:c,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:S,cssCaptured:!1};if(R.type===Xe.Element&&"textarea"===R.tagName&&void 0!==R.attributes.value);else{R.type===Xe.Element&&void 0!==R.attributes._cssText&&"string"==typeof R.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(ct(e))){const e=Xt(n,t);e&&R.childNodes.push(e)}}let k=null;if(gt(e)&&(k=mt(e)))for(const e of Array.from(ct(k))){const n=Xt(e,t);n&&(bt(k)&&(n.isShadow=!0),R.childNodes.push(n))}}const A=lt(e);return A&&yt(A)&&bt(A)&&(R.isShadow=!0),R.type===Xe.Element&&"iframe"===R.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,i=!1;try{o=r.document.readyState}catch(a){return}if("complete"!==o){const r=setTimeout(()=>{i||(t(),i=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),i=!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&&b){const n=Xt(t,{doc:t,mirror:r,blockClass:o,blockSelector:i,needsMask:E,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:S});n&&b(e,n)}},v),R.type===Xe.Element&&"link"===R.tagName&&"string"==typeof R.attributes.rel&&("stylesheet"===R.attributes.rel||"preload"===R.attributes.rel&&"string"==typeof R.attributes.href&&"css"===It(R.attributes.href))&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(s){return}if(r)return;const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()})}(e,()=>{if(w){const t=Xt(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:E,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:I,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:S});t&&w(e,t)}},x),R}var Gt=class e{constructor(...e){Ue(this,"parentElement",null),Ue(this,"parentNode",null),Ue(this,"ownerDocument"),Ue(this,"firstChild",null),Ue(this,"lastChild",null),Ue(this,"previousSibling",null),Ue(this,"nextSibling",null),Ue(this,"ELEMENT_NODE",1),Ue(this,"TEXT_NODE",3),Ue(this,"nodeType"),Ue(this,"nodeName"),Ue(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"}};function Jt(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var Zt="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",Qt={map:{},getId:()=>(console.error(Zt),-1),getNode:()=>(console.error(Zt),null),removeNodeFromMap(){console.error(Zt)},has:()=>(console.error(Zt),!1),reset(){console.error(Zt)}};function en(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},a))}}function tn(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>tn(e,t,i||{},!0)}function nn(e){var t,n,r,o;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null==(t=ut(i.body))?void 0:t.scrollLeft)||(null==(n=null==i?void 0:i.body)?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null==(r=ut(i.body))?void 0:r.scrollTop)||(null==(o=null==i?void 0:i.body)?void 0:o.scrollTop)||0}}function rn(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function on(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function sn(e){return e?e.nodeType===e.ELEMENT_NODE?e:ut(e):null}function an(e,t,n,r){if(!e)return!1;const o=sn(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(qt(o,t,r))return!0}catch(i){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function cn(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function ln(e,t){if(yt(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=lt(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||ln(r,t))}function un(e){return Boolean(e.changedTouches)}function dn(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function pn(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function hn(e){return!!e&&(e instanceof Gt&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(mt(e)))}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Qt=new Proxy(Qt,{get:(e,t,n)=>("map"===t&&console.error(Zt),Reflect.get(e,t,n))}));var fn=class{constructor(){Ue(this,"id",1),Ue(this,"styleIDMap",/* @__PURE__ */new WeakMap),Ue(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 mn(e){var t;let n=null;return"getRootNode"in e&&(null==(t=ht(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&ft(ht(e))&&(n=ft(ht(e))),n}function gn(e){const t=at(e);return!!t&&(pt(t,e)||function(e){const t=at(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=mn(n);)n=t;return n}(e);return pt(t,n)}(e))}function yn(e){return"__ln"in e}var bn,vn=class{constructor(){Ue(this,"length",0),Ue(this,"head",null),Ue(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&&yn(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&&yn(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--)}},wn=(e,t)=>`${e}@${t}`,xn=class{constructor(){Ue(this,"frozen",!1),Ue(this,"locked",!1),Ue(this,"texts",[]),Ue(this,"attributes",[]),Ue(this,"attributeMap",/* @__PURE__ */new WeakMap),Ue(this,"removes",[]),Ue(this,"mapRemoves",[]),Ue(this,"movedMap",{}),Ue(this,"addedSet",/* @__PURE__ */new Set),Ue(this,"movedSet",/* @__PURE__ */new Set),Ue(this,"droppedSet",/* @__PURE__ */new Set),Ue(this,"removesSubTreeCache",/* @__PURE__ */new Set),Ue(this,"mutationCb"),Ue(this,"blockClass"),Ue(this,"blockSelector"),Ue(this,"maskTextClass"),Ue(this,"maskTextSelector"),Ue(this,"inlineStylesheet"),Ue(this,"maskInputOptions"),Ue(this,"maskTextFn"),Ue(this,"maskInputFn"),Ue(this,"keepIframeSrcFn"),Ue(this,"recordCanvas"),Ue(this,"inlineImages"),Ue(this,"slimDOMOptions"),Ue(this,"dataURLOptions"),Ue(this,"doc"),Ue(this,"mirror"),Ue(this,"iframeManager"),Ue(this,"stylesheetManager"),Ue(this,"shadowDomManager"),Ue(this,"canvasManager"),Ue(this,"processedNodeManager"),Ue(this,"unattachedDoc"),Ue(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),Ue(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new vn,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{const i=lt(o);if(!i||!gn(o))return;let s=!1;if(o.nodeType===Node.TEXT_NODE){const e=i.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(i)&&(s=!0)}const a=yt(i)?this.mirror.getId(mn(o)):this.mirror.getId(i),c=r(o);if(-1===a||-1===c)return n.addNode(o);const l=Xt(o,{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=>{dn(e,this.mirror)&&this.iframeManager.addIframe(e),pn(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),hn(o)&&this.shadowDomManager.addShadowRoot(mt(o),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});l&&(e.push({parentId:a,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)kn(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(lt(a))||o(a);for(const a of this.addedSet)Cn(this.droppedSet,a)||kn(this.removesSubTreeCache,a,this.mirror)?Cn(this.movedSet,a)?o(a):this.droppedSet.add(a):o(a);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(lt(i.value)),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(lt(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=lt(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=ft(r);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=lt(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))}),Ue(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(ct(e),e=>dt(e)||"").join("");t.attributes.value=St({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Et(e),value:n,maskInputFn:this.maskInputFn})}),Ue(this,"processMutation",e=>{if(!cn(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=dt(e.target);an(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Vt(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,sn(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const n=e.target,r=kt(n.tagName);let o=e.attributeName,i=e.target.getAttribute(o);if("value"===o){const e=Et(n);i=St({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:i,maskInputFn:this.maskInputFn})}if(an(e.target,this.blockClass,this.blockSelector,!1)||i===e.oldValue)return;let s=this.attributeMap.get(e.target);if("iframe"===r&&"src"===o&&!this.keepIframeSrcFn(i)){if(n.contentDocument)return;o="rr_src"}if(s||(s={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(s),this.attributeMap.set(e.target,s)),"type"===o&&"input"===r&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!jt(r,o))if(s.attributes[o]=Ht(this.doc,r,kt(o),i),"style"===o){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),o=n.style.getPropertyPriority(e);t!==r.style.getPropertyValue(e)||o!==r.style.getPropertyPriority(e)?s.styleDiff[e]=""===o?t:[t,o]:s._unchangedStyles[e]=[t,o]}for(const e of Array.from(r.style))""===n.style.getPropertyValue(e)&&(s.styleDiff[e]=!1)}else"open"===o&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?s.attributes.rr_open_mode="modal":s.attributes.rr_open_mode="non-modal");break}case"childList":if(an(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=yt(e.target)?this.mirror.getId(ft(e.target)):this.mirror.getId(e.target);an(e.target,this.blockClass,this.blockSelector,!1)||cn(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Sn(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ln(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[wn(n,r)]?Sn(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!yt(e.target)||!bt(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),ct(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),Ue(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(cn(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[wn(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);an(e,this.blockClass,this.blockSelector,!1)||(ct(e).forEach(e=>this.genAdds(e)),hn(e)&&ct(mt(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 Sn(e,t){e.delete(t),ct(t).forEach(t=>Sn(e,t))}function kn(e,t,n){return 0!==e.size&&function(e,t){const n=lt(t);return!!n&&e.has(n)}(e,t)}function Cn(e,t){return 0!==e.size&&En(e,t)}function En(e,t){const n=lt(t);return!!n&&(!!e.has(n)||En(e,n))}var In=e=>bn?(...t)=>{try{return e(...t)}catch(n){if(bn&&!0===bn(n))return;throw n}}:e,Mn=[];function Tn(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 Rn(e,t){const n=new xn;Mn.push(n),n.init(e);const[r,o]=[et("MutationObserver").constructor,Qe.MutationObserver??(()=>{})],i=new r(In(n.processMutations.bind(n)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[i,o]}function On({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return Jt("scroll",In(en(In(i=>{const s=Tn(i);if(!s||an(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=nn(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),i.scroll||100)),t)}var An=["INPUT","TEXTAREA","SELECT"],_n=/* @__PURE__ */new WeakMap;function Dn(e){return function e(t,n){if(Fn("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Fn("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Fn("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Fn("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const r=Array.from(t.parentRule.cssRules).indexOf(t);return n.unshift(r),e(t.parentRule,n)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);n.unshift(e)}return n}(e,[])}function Pn(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Nn({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(ft(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(i=null==(o=n.ownerDocument)?void 0:o.defaultView)?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null==(e=c.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=c.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(o){}return r}}),In(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function Ln(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:p,selectionCb:h,customElementCb:f}=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),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...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),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...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),f(...e)}}(e,t);let o=()=>{};e.recordDOM&&([r,o]=Rn(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=en(In(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),i),l=In(en(In(e=>{const t=Tn(e),{clientX:n,clientY:o}=un(e)?e.changedTouches[0]:e;s||(s=it()),a.push({x:n,y:o,id:r.getId(t),timeOffset:it()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?je.Drag:e instanceof MouseEvent?je.MouseMove:je.TouchMove)}),o,{trailing:!1})),u=[Jt("mousemove",l,n),Jt("touchmove",l,n),Jt("drag",l,n)];return In(()=>{u.forEach(e=>e())})}(e),s=function({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];let c=null;return Object.keys(qe).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{let s=kt(i);const l=(t=>i=>{const s=Tn(i);if(an(s,r,o,!0))return;let a=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":a=Ve.Mouse;break;case"touch":a=Ve.Touch;break;case"pen":a=Ve.Pen}a===Ve.Touch?qe[t]===qe.MouseDown?l="TouchStart":qe[t]===qe.MouseUp&&(l="TouchEnd"):Ve.Pen}else un(i)&&(a=Ve.Touch);null!==a?(c=a,(l.startsWith("Touch")&&a===Ve.Touch||l.startsWith("Mouse")&&a===Ve.Mouse)&&(a=null)):qe[t]===qe.Click&&(a=c,c=null);const u=un(i)?i.changedTouches[0]:i;if(!u)return;const d=n.getId(s),{clientX:p,clientY:h}=u;In(e)({type:qe[l],id:d,x:p,y:h,...null!==a&&{pointerType:a}})})(i);if(window.PointerEvent)switch(qe[i]){case qe.MouseDown:case qe.MouseUp:s=s.replace("mouse","pointer");break;case qe.TouchStart:case qe.TouchEnd:return}a.push(Jt(s,l,t))}),In(()=>{a.forEach(e=>e())})}(e),a=On(e),c=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Jt("resize",In(en(In(()=>{const t=rn(),o=on();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:u}){function d(e){let n=Tn(e);const l=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=ut(n)),!n||!d||An.indexOf(d)<0||an(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let h=n.value,f=!1;const m=Et(n)||"";"radio"===m||"checkbox"===m?f=n.checked:(a[d.toLowerCase()]||a[m])&&(h=St({element:n,maskInputOptions:a,tagName:d,type:m,value:h,maskInputFn:c})),p(n,u?{text:h,isChecked:f,userTriggered:l}:{text:h,isChecked:f});const g=n.name;"radio"===m&&g&&f&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,u?{text:t,isChecked:!f,userTriggered:!1}:{text:t,isChecked:!f})}})}function p(t,r){const o=_n.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){_n.set(t,r);const o=n.getId(t);In(e)({...r,id:o})}}const h=("last"===l.input?["change"]:["input","change"]).map(e=>Jt(e,In(d),t)),f=t.defaultView;if(!f)return()=>{h.forEach(e=>e())};const m=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value"),g=[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...g.map(e=>tn(e[0],e[1],{set(){In(d)({target:this,isTrusted:!1})}},!1,f))),In(()=>{h.forEach(e=>e())})}(e),u=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=In(i=>en(In(o=>{const s=Tn(o);if(!s||an(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:u,loop:d}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:u,loop:d})}),o.media||500)),a=[Jt("play",s(Ke.Play),i),Jt("pause",s(Ke.Pause),i),Jt("seeked",s(Ke.Seeked),i),Jt("volumechange",s(Ke.VolumeChange),i),Jt("ratechange",s(Ke.RateChange),i)];return In(()=>{a.forEach(e=>e())})}(e);let d=()=>{},p=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:In((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Pn(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const o=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[o,n])};const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),r.apply(o,i)})}),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:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)})}));const c={};zn("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(zn("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),zn("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),zn("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:In((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Pn(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...Dn(o),a||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:In((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Pn(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...Dn(o),s]}]}),r.apply(o,i)})})}),In(()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}(e,{win:n}),p=Nn(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:In((o,s,a)=>{var c;const[l,u,d]=a;if(n.has(l))return i.apply(s,[l,u,d]);const{id:p,styleId:h}=Pn(null==(c=s.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:l,value:u,priority:d},index:Dn(s.parentRule)}),o.apply(s,a)})});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:In((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.apply(i,[l]);const{id:u,styleId:d}=Pn(null==(c=i.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(u&&-1!==u||d&&-1!==d)&&e({id:u,styleId:d,remove:{property:l},index:Dn(i.parentRule)}),o.apply(i,a)})}),In(()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(f=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=/* @__PURE__ */new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.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=st(t.fonts,"add",function(t){return function(n){return setTimeout(In(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=i}),r.push(s),In(()=>{r.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=In(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const{startContainer:i,startOffset:s,endContainer:c,endOffset:l}=e.getRangeAt(t);an(i,r,o,!0)||an(c,r,o,!0)||a.push({start:n.getId(i),startOffset:s,end:n.getId(c),endOffset:l})}i({ranges:a})});return a(),Jt("selectionchange",a)}(e),g=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?st(n.customElements,"define",function(e){return function(n,r,o){try{t({define:{name:n}})}catch(i){console.warn(`Custom element callback failed for ${n}`)}return e.apply(this,[n,r,o])}}):()=>{}}(e),y=[];for(const b of e.plugins)y.push(b.observer(b.callback,n,b.options));return In(()=>{Mn.forEach(e=>e.reset()),r?.disconnect(),o(),i(),s(),a(),c(),l(),u(),d(),p(),h(),f(),m(),g(),y.forEach(e=>e())})}function Fn(e){return void 0!==window[e]}function zn(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var $n=class{constructor(e){Ue(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),Ue(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.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);return"number"!=typeof t?t:r.get(t)||-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}},Bn=class{constructor(e){Ue(this,"iframes",/* @__PURE__ */new WeakMap),Ue(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),Ue(this,"crossOriginIframeMirror",new $n(Ft)),Ue(this,"crossOriginIframeStyleMirror"),Ue(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),Ue(this,"mirror"),Ue(this,"mutationCb"),Ue(this,"wrappedEmit"),Ue(this,"loadListener"),Ue(this,"stylesheetManager"),Ue(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new $n(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 He.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:He.IncrementalSnapshot,data:{source:je.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case He.Meta:case He.Load:case He.DomContentLoaded:return!1;case He.Plugin:return t;case He.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case He.IncrementalSnapshot:switch(t.data.source){case je.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 je.Drag:case je.TouchMove:case je.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case je.ViewportResize:return!1;case je.MediaInteraction:case je.MouseInteraction:case je.Scroll:case je.CanvasMutation:case je.Input:return this.replaceIds(t.data,e,["id"]),t;case je.StyleSheetRule:case je.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case je.Font:return t;case je.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case je.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 o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));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===Xe.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},Wn=class{constructor(e){Ue(this,"shadowDoms",/* @__PURE__ */new WeakSet),Ue(this,"mutationCb"),Ue(this,"scrollCb"),Ue(this,"bypassOptions"),Ue(this,"mirror"),Ue(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(!bt(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const[n]=Rn({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(On({...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(ft(e))),this.restoreHandlers.push(Nn({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(st(e.prototype,"attachShadow",function(e){return function(r){const o=e.call(this,r),i=mt(this);return i&&gn(this)&&n.addShadowRoot(i,t),o}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},Un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hn="undefined"==typeof Uint8Array?[]:/* @__PURE__ */new Uint8Array(256),jn=0;jn<64;jn++)Hn[Un.charCodeAt(jn)]=jn;var qn=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Un[n[t]>>2],o+=Un[(3&n[t])<<4|n[t+1]>>4],o+=Un[(15&n[t+1])<<2|n[t+2]>>6],o+=Un[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o},Vn=/* @__PURE__ */new Map,Yn=(e,t,n)=>{if(!e||!Gn(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Vn.get(e);return n||(n=/* @__PURE__ */new Map,Vn.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Kn(e,t,n){if(e instanceof Array)return e.map(e=>Kn(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:qn(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Kn(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:[Kn(e.data,t,n),e.width,e.height]}:Gn(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Yn(e,t,n)}:e}var Xn=(e,t,n)=>e.map(e=>Kn(e,t,n)),Gn=(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 Jn(e,t,n,r){const o=[];try{const i=st(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){if(!an(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(i[0]&&"object"==typeof i[0]){const e=i[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...i])}});o.push(i)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(e=>e())}}function Zn(e,t,n,r,o,i){const s=[],a=Object.getOwnPropertyNames(e);for(const c of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const a=st(e,c,function(e){return function(...s){const a=e.apply(this,s);if(Yn(a,i,this),"tagName"in this.canvas&&!an(this.canvas,r,o,!0)){const e=Xn(s,i,this),r={type:t,property:c,args:e};n(this.canvas,r)}return a}});s.push(a)}catch{const r=tn(e,c,{set(e){n(this.canvas,{type:t,property:c,args:[e],setter:!0})}});s.push(r)}return s}var Qn='(function() {\n "use strict";\n var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);\n for (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n var encode = function(arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";\n for (i2 = 0; i2 < len; i2 += 3) {\n base64 += chars[bytes[i2] >> 2];\n base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];\n base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];\n base64 += chars[bytes[i2 + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + "=";\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + "==";\n }\n return base64;\n };\n const lastBlobMap = /* @__PURE__ */ new Map();\n const transparentBlobMap = /* @__PURE__ */ new Map();\n async function getTransparentBlobFor(width, height, dataURLOptions) {\n const id = `${width}-${height}`;\n if ("OffscreenCanvas" in globalThis) {\n if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);\n const offscreen = new OffscreenCanvas(width, height);\n offscreen.getContext("2d");\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n transparentBlobMap.set(id, base64);\n return base64;\n } else {\n return "";\n }\n }\n const worker = self;\n worker.onmessage = async function(e) {\n if ("OffscreenCanvas" in globalThis) {\n const { id, bitmap, width, height, dataURLOptions } = e.data;\n const transparentBase64 = getTransparentBlobFor(\n width,\n height,\n dataURLOptions\n );\n const offscreen = new OffscreenCanvas(width, height);\n const ctx = offscreen.getContext("2d");\n ctx.drawImage(bitmap, 0, 0);\n bitmap.close();\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const type = blob.type;\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n if (!lastBlobMap.has(id) && await transparentBase64 === base64) {\n lastBlobMap.set(id, base64);\n return worker.postMessage({ id });\n }\n if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });\n worker.postMessage({\n id,\n type,\n base64,\n width,\n height\n });\n lastBlobMap.set(id, base64);\n } else {\n return worker.postMessage({ id: e.data.id });\n }\n };\n})();\n//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map\n',er="undefined"!=typeof self&&self.Blob&&new Blob([Qn],{type:"text/javascript;charset=utf-8"});function tr(e){let t;try{if(t=er&&(self.URL||self.webkitURL).createObjectURL(er),!t)throw"";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(n){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Qn),{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var nr,rr,or,ir=class{constructor(e){Ue(this,"pendingCanvasMutations",/* @__PURE__ */new Map),Ue(this,"rafStamps",{latestId:0,invokeId:null}),Ue(this,"mirror"),Ue(this,"mutationCb"),Ue(this,"resetObservers"),Ue(this,"frozen",!1),Ue(this,"locked",!1),Ue(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:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{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,o){const i=Jn(t,n,r,!0),s=/* @__PURE__ */new Map,a=new tr;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:Ye["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,u=0;const d=e=>{u&&e-u<c||(u=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{an(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:o.dataURLOptions},[r])})),l=requestAnimationFrame(d)};l=requestAnimationFrame(d),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Jn(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=st(t.CanvasRenderingContext2D.prototype,s,function(o){return function(...i){return an(this.canvas,n,r,!0)||setTimeout(()=>{const n=Xn(i,t,this);e(this.canvas,{type:Ye["2D"],property:s,args:n})},0),o.apply(this,i)}});o.push(i)}catch{const n=tn(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:Ye["2D"],property:s,args:[t],setter:!0})}});o.push(n)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const o=[];return void 0!==t.WebGLRenderingContext&&o.push(...Zn(t.WebGLRenderingContext.prototype,Ye.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&o.push(...Zn(t.WebGL2RenderingContext.prototype,Ye.WebGL2,e,n,r,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),o(),i()}}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:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}},sr=class{constructor(e){Ue(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),Ue(this,"mutationCb"),Ue(this,"adoptedStyleSheetCb"),Ue(this,"styleMirror",new fn),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 o of e){let e;this.styleMirror.has(o)?e=this.styleMirror.getId(o):(e=this.styleMirror.add(o),r.push({styleId:e,rules:Array.from(o.rules||CSSRule,(e,t)=>({rule:wt(e,o.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){}},ar=class{constructor(){Ue(this,"nodeMap",/* @__PURE__ */new WeakMap),Ue(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(){}},cr=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(ze=e.contentWindow)?void 0:ze.Array.from)||Array.from,document.body.removeChild(e)}}catch(_d){}var lr=new xt;function ur(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:p,slimDOMOptions:h,maskInputFn:f,maskTextFn:m,hooks:g,packFn:y,sampling:b={},dataURLOptions:v={},mousemoveWait:w,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:k=!1,recordAfter:C=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:E=!1,collectFonts:I=!1,inlineImages:M=!1,plugins:T,keepIframeSrcFn:R=()=>!1,ignoreCSSAttributes:O=/* @__PURE__ */new Set([]),errorHandler:A}=e;bn=A;const _=!k||window.parent===window;let D=!1;if(!_)try{window.parent.document&&(D=!1)}catch(V){D=!0}if(_&&!t)throw new Error("emit function is required");if(!_&&!D)return()=>{};void 0!==w&&void 0===b.mousemove&&(b.mousemove=w),lr.reset();const P=!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}:void 0!==p?p:{password:!0},N=Kt(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 F=0;const z=e=>{for(const t of T||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!D&&(e=y(e)),e};nr=(e,o)=>{var i;const s=e;if(s.timestamp=it(),!(null==(i=Mn[0])?void 0:i.isFrozen())||s.type===He.FullSnapshot||s.type===He.IncrementalSnapshot&&s.data.source===je.Mutation||Mn.forEach(e=>e.unfreeze()),_)t?.(z(s),o);else if(D){const e={type:"rrweb",event:z(s),origin:window.location.origin,isCheckout:o};window.parent.postMessage(e,"*")}if(s.type===He.FullSnapshot)L=s,F=0;else if(s.type===He.IncrementalSnapshot){if(s.data.source===je.Mutation&&s.data.isAttachIframe)return;F++;const e=r&&F>=r,t=n&&s.timestamp-L.timestamp>n;(e||t)&&rr(!0)}};const $=e=>{nr({type:He.IncrementalSnapshot,data:{source:je.Mutation,...e}})},B=e=>nr({type:He.IncrementalSnapshot,data:{source:je.Scroll,...e}}),W=e=>nr({type:He.IncrementalSnapshot,data:{source:je.CanvasMutation,...e}}),U=new sr({mutationCb:$,adoptedStyleSheetCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.AdoptedStyleSheet,...e}})}),H=new Bn({mirror:lr,mutationCb:$,stylesheetManager:U,recordCrossOriginIframes:k,wrappedEmit:nr});for(const K of T||[])K.getMirror&&K.getMirror({nodeMirror:lr,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});const j=new ar;or=new ir({recordCanvas:S,mutationCb:W,win:window,blockClass:o,blockSelector:i,mirror:lr,sampling:b.canvas,dataURLOptions:v});const q=new Wn({mutationCb:$,scrollCb:B,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:P,dataURLOptions:v,maskTextFn:m,maskInputFn:f,recordCanvas:S,inlineImages:M,sampling:b,slimDOMOptions:N,iframeManager:H,stylesheetManager:U,canvasManager:or,keepIframeSrcFn:R,processedNodeManager:j},mirror:lr});rr=(e=!1)=>{if(!x)return;nr({type:He.Meta,data:{href:window.location.href,width:on(),height:rn()}},e),U.reset(),q.init(),Mn.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new xt,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:i="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:p,slimDOM:h=!1,dataURLOptions:f,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:x=()=>!1}=t;return Xt(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:i,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!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}:!1===u?{password:!0}:u,maskTextFn:d,maskInputFn:p,slimDOMOptions:Kt(h),dataURLOptions:f,inlineImages:c,recordCanvas:l,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:lr,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:P,maskTextFn:m,maskInputFn:f,slimDOM:N,dataURLOptions:v,recordCanvas:S,inlineImages:M,onSerialize:e=>{dn(e,lr)&&H.addIframe(e),pn(e,lr)&&U.trackLinkElement(e),hn(e)&&q.addShadowRoot(mt(e),document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),q.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{U.attachLinkElement(e,t)},keepIframeSrcFn:R});if(!t)return console.warn("Failed to snapshot the document");nr({type:He.FullSnapshot,data:{node:t,initialOffset:nn(window)}},e),Mn.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&U.adoptStyleSheets(document.adoptedStyleSheets,lr.getId(document))};try{const e=[],t=e=>{var t;return In(Ln)({mutationCb:$,mousemoveCb:(e,t)=>nr({type:He.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.MouseInteraction,...e}}),scrollCb:B,viewportResizeCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.ViewportResize,...e}}),inputCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.Input,...e}}),mediaInteractionCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.MediaInteraction,...e}}),styleSheetRuleCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.StyleSheetRule,...e}}),styleDeclarationCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.StyleDeclaration,...e}}),canvasMutationCb:W,fontCb:e=>nr({type:He.IncrementalSnapshot,data:{source:je.Font,...e}}),selectionCb:e=>{nr({type:He.IncrementalSnapshot,data:{source:je.Selection,...e}})},customElementCb:e=>{nr({type:He.IncrementalSnapshot,data:{source:je.CustomElement,...e}})},blockClass:o,ignoreClass:s,ignoreSelector:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:P,inlineStylesheet:u,sampling:b,recordDOM:x,recordCanvas:S,inlineImages:M,userTriggeredOnInput:E,collectFonts:I,doc:e,maskInputFn:f,maskTextFn:m,keepIframeSrcFn:R,blockSelector:i,slimDOMOptions:N,dataURLOptions:v,mirror:lr,iframeManager:H,stylesheetManager:U,shadowDomManager:q,processedNodeManager:j,canvasManager:or,ignoreCSSAttributes:O,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=>nr({type:He.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};H.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){console.warn(r)}});const n=()=>{rr(),e.push(t(document)),cr=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(Jt("DOMContentLoaded",()=>{nr({type:He.DomContentLoaded,data:{}}),"DOMContentLoaded"===C&&n()})),e.push(Jt("load",()=>{nr({type:He.Load,data:{}}),"load"===C&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")||console.warn(t)}}),j.destroy(),cr=!1,bn=void 0}}catch(Y){console.warn(Y)}}ur.addCustomEvent=(e,t)=>{if(!cr)throw new Error("please add custom event after start recording");nr({type:He.Custom,data:{tag:e,payload:t}})},ur.freezePage=()=>{Mn.forEach(e=>e.freeze())},ur.takeFullSnapshot=e=>{if(!cr)throw new Error("please take full snapshot after start recording");rr(e)},ur.mirror=lr;var dr="Chat is unavailable — the widget credentials were rejected.",pr=class extends Error{},hr=new class{abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;tornDown=!1;credentialRejected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;connectionId=0;tabId=globalThis.crypto.randomUUID();registrationWaiters=/* @__PURE__ */new Set;addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}isConnected(){return"registered"===this.status}reconnectSuppressed(){return this.tornDown||this.credentialRejected}canReconnect(){return null!==this.chatId&&!this.reconnectSuppressed()&&!this.isConnected()}reconnectNow(){this.canReconnect()&&null!==this.chatId&&(this.clearReconnectTimer(),this.resetBackoff(),this.abortConnection(),this.connect(this.chatId))}async ready(e){await this.connect(e),await this.waitUntilRegistered()}async waitUntilRegistered(){if(!this.isConnected()){if(this.credentialRejected)throw new pr(dr);await new Promise((e,t)=>this.registrationWaiters.add({resolve:e,reject:t}))}}async connect(e){if(this.credentialRejected)return;if(this.tornDown=!1,this.chatId===e&&("connecting"===this.status||"open"===this.status||"registered"===this.status))return;this.abortConnection(),this.chatId=e,this.status="connecting";const t=++this.connectionId;this.abortController=new AbortController;const n=this.abortController.signal;try{const r=$e.getCredentialedConfig(),o=await Te.widgetStream({chat_id:e,tab_id:this.tabId,...r&&{marketrix_id:r.mtxId,marketrix_key:r.mtxKey,...r.userId?{user_id:r.userId}:{}}},{signal:n});this.status="open",this.consumeEvents(o,t)}catch(r){n.aborted||(Oe("[StreamClient] Connection failed, will retry:",r),this.status="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.reconnectSuppressed()||(Oe("[StreamClient] Stream error:",r),this.status="error")}finally{n||this.connectionId!==t||this.reconnectSuppressed()||(this.status="disconnected",this.scheduleReconnect())}}disconnect(){this.tornDown=!0,this.credentialRejected=!1,this.clearReconnectTimer(),this.abortConnection(),this.chatId=null,this.settleWaiters(/* @__PURE__ */new Error("Stream disconnected before registration"))}send(e){return this.chatId?Te.widgetMessagePost({chat_id:this.chatId,tab_id:this.tabId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${Re(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}resetBackoff(){this.reconnectAttempts=0,this.reconnectDelay=1e3}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}settleWaiters(e){for(const t of this.registrationWaiters)e?t.reject(e):t.resolve();this.registrationWaiters.clear()}giveUp(e){const t=new pr(e);this.notifyError(t),this.settleWaiters(t)}handleMessage(e){this.reconnectSuppressed()||"heartbeat"!==e.type&&("registered"===e.type&&e.chat_id===this.chatId&&(this.status="registered",this.resetBackoff(),this.settleWaiters()),"chat/error"===e.type&&"auth"===e.request_id&&(console.error("[StreamClient] Authentication failed — will not reconnect"),this.credentialRejected=!0,this.giveUp(dr)),this.callbacks.forEach(t=>t.onMessage?.(e)))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.giveUp("Could not reconnect to the assistant. Try again.");this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.reconnectSuppressed()&&this.chatId&&this.connect(this.chatId)},e)}abortConnection(){this.abortController?.abort(),this.abortController=null,this.status="disconnected"}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}},fr=class{chatId;applicationId;events=[];sessionId=globalThis.crypto.randomUUID();stopRecording=null;flushTimer=null;flushPromise=Promise.resolve();stopped=!1;constructor(e,t){this.chatId=e,this.applicationId=t}async start(){this.stopRecording||this.stopped||(await hr.ready(this.chatId),this.stopped||(await Te.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/metadata",rrweb_session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.stopped||(this.stopRecording=ur({emit:e=>{this.events.push(e),this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flush()},500))},maskAllInputs:!0,maskTextClass:/^(rr-mask|mtx-mask)$/,blockClass:/^(rr-block|mtx-block)$/}))))}stop(){this.stopped=!0,this.stopRecording?.(),this.stopRecording=null,this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null,this.flush()}flush(){return this.flushPromise=this.flushPromise.then(async()=>{this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null;const e=this.events.splice(0);if(e.length)try{await Te.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/events",rrweb_session_id:this.sessionId,events:e}})}catch(t){this.events=e.concat(this.events).slice(0,2e4),console.error("Failed to record session events:",t)}}),this.flushPromise}},mr=null;function gr(){return mr?.active&&"live"===mr.getVideoTracks()[0]?.readyState?mr:(mr=null,null)}function yr(){mr&&(mr.getTracks().forEach(e=>e.stop()),mr=null)}var br=e=>"string"==typeof e,vr=e=>"boolean"==typeof e,wr=(...e)=>t=>"string"==typeof t&&e.includes(t),xr={widget_enabled:vr,widget_appearance:wr("default","hidden"),widget_position:wr("bottom_left","bottom_right","top_left","top_right"),widget_header:br,widget_body:br,widget_greeting:br,widget_greeting_toast:vr,widget_recording:vr,widget_feature_tell:vr,widget_feature_show:vr,widget_feature_do:vr,widget_background_color:br,widget_text_color:br,widget_border_color:br,widget_accent_color:br,widget_secondary_color:br,widget_border_radius:br,widget_font_size:br,widget_width:br,widget_height:br,widget_animation_duration:br,widget_fade_duration:br,widget_chips:e=>Array.isArray(e)&&e.every(e=>"object"==typeof e&&null!==e&&wr("tell","show","do")(e.chip_mode)&&br(e.chip_text))},Sr=Object.keys(xr),kr=/* @__PURE__ */new Set(["widget_border_radius","widget_font_size","widget_animation_duration","widget_fade_duration"]);function Cr(e){if("object"!=typeof e||null===e)return{invalidFields:["settings"]};const t=e,n=Sr.filter(e=>!xr[e](t[e]));if(n.length>0)return{invalidFields:n};const r={};for(const o of Sr)kr.has(o)||(r[o]=t[o]);return{settings:r}}var Er=e=>`Widget settings are invalid: ${e.join(", ")}`;function Ir(e,t={}){return{...t,...e}}function Mr(){}var Tr=Object.freeze([]),Rr=Object.freeze({});function Or(t){e.useEffect(t,Tr)}var Ar={};function _r(t,n){const r=e.useRef(Ar);return r.current===Ar&&(r.current=t(n)),r}var Dr="undefined"!=typeof document?e.useLayoutEffect:()=>{},Pr=function(e,...t){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`Base UI error #${e}; visit ${n} for the full message.`},Nr=/*#__PURE__*/e.createContext(void 0);function Lr(){const t=e.useContext(Nr);if(!t)throw new Error(Pr(73));return t}var Fr=parseInt(e.version,10);function zr(e){return Fr>=e}var $r=[],Br=void 0;function Wr(){return{didInitialize:!1}}var Ur,Hr=zr(19)?function(t,n,r,o,i){const s=Br;if(!s)return function(t,n,r,o,i){const s=e.useCallback(()=>n(t.getSnapshot(),r,o,i),[t,n,r,o,i]);return f(t.subscribe,s,s)}(t,n,r,o,i);const a=s.syncIndex;let c;return s.syncIndex+=1,s.didInitialize?(c=s.syncHooks[a],c.store===t&&c.selector===n&&Object.is(c.a1,r)&&Object.is(c.a2,o)&&Object.is(c.a3,i)||(c.store!==t&&(s.didChangeStore=!0),c.store=t,c.selector=n,c.a1=r,c.a2=o,c.a3=i,c.value=n(t.getSnapshot(),r,o,i))):(c={store:t,selector:n,a1:r,a2:o,a3:i,value:n(t.getSnapshot(),r,o,i)},s.syncHooks.push(c)),c.value}:function(e,t,n,r,o){return function(e,t,n,r){const o=d(null),i=e=>{const t=o.current;if(t&&Object.is(t.snapshot,e))return t.selection;const n=r(e);return o.current={snapshot:e,selection:n},n};return h(e,()=>i(t()),n&&(()=>i(n())))}(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,o))};function jr(e,t,n,r,o){return Hr(e,t,n,r,o)}Ur={before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=/* @__PURE__ */new Set;for(const o of e.syncHooks)n.add(o.store);const r=[];for(const e of n)r.push(e.subscribe(t));return()=>{for(const e of r)e()}}),f(e.subscribe,e.getSnapshot,e.getSnapshot))}},$r.push(Ur);var qr=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=/* @__PURE__ */new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;const t=this.updateTick;for(const n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(const t in e)if(!Object.is(this.state[t],e[t]))return void this.setState({...this.state,...e})}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){const e={...this.state};this.setState(e)}use(e,t,n,r){return jr(this,e,t,n,r)}},Vr={...e},Yr=Vr.useInsertionEffect,Kr=Yr&&Yr!==Vr.useLayoutEffect?Yr:e=>e();function Xr(e){const t=_r(Gr).current;return t.next=e,Kr(t.effect),t.trampoline}function Gr(){const e={next:void 0,callback:Jr,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Jr(){}var Zr=class extends qr{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(t,n){e.useDebugValue(t);const r=this;Dr(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(e,t){const n=this;Dr(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){const t=this,n=Object.values(e);Dr(()=>{t.update(e)},[t,...n])}useControlledProp(t,n){e.useDebugValue(t);const r=this,o=void 0!==n;Dr(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o])}select(e,t,n,r){return(0,this.selectors[e])(this.state,t,n,r)}useState(t,n,r,o){return e.useDebugValue(t),jr(this,this.selectors[t],n,r,o)}useContextCallback(t,n){e.useDebugValue(t);const r=Xr(n??Mr);this.context[t]=r}useStateSetter(t){const n=e.useRef(void 0);return void 0===n.current&&(n.current=e=>{this.set(t,e)}),n.current}observe(e,t){let n;n="function"==typeof e?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{const o=n(e);if(!Object.is(r,o)){const e=r;r=o,t(o,e,this)}})}};function Qr(){return"undefined"!=typeof window}function eo(e){return no(e)?(e.nodeName||"").toLowerCase():"#document"}function to(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function no(e){return!!Qr()&&(e instanceof Node||e instanceof to(e).Node)}function ro(e){return!!Qr()&&(e instanceof Element||e instanceof to(e).Element)}function oo(e){return!!Qr()&&(e instanceof HTMLElement||e instanceof to(e).HTMLElement)}function io(e){return!(!Qr()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof to(e).ShadowRoot)}function so(e){return/^(html|body|#document)$/.test(eo(e))}function ao(e){return to(e).getComputedStyle(e)}function co(e){if("html"===eo(e))return e;const t=e.assignedSlot||e.parentNode||io(e)&&e.host||function(e){var t;return null==(t=(no(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}(e);return io(t)?t.host:t}function lo(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}function uo(e){return e?.ownerDocument||document}function po(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}var ho=null;globalThis.requestAnimationFrame;var fo=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;const t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let r=0;r<t.length;r+=1)t[r]?.(e)};request(e){const t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){const t=e-this.startId;t<0||t>=this.callbacks.length||null!==this.callbacks[t]&&(this.callbacks[t]=null,this.callbacksCount-=1)}},mo=class e{static create(){return new e}static request(e){return fo.request(e)}static cancel(e){return fo.cancel(e)}currentId=ho;request(e){this.cancel(),this.currentId=fo.request(()=>{this.currentId=ho,e()})}cancel=()=>{this.currentId!==ho&&(fo.cancel(this.currentId),this.currentId=ho)};disposeEffect=()=>this.cancel};function go(){const e=_r(mo.create).current;return Or(e.disposeEffect),e}var yo=class e{static create(){return new e}currentId=0;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return 0!==this.currentId}clear=()=>{0!==this.currentId&&(clearTimeout(this.currentId),this.currentId=0)};disposeEffect=()=>this.clear};function bo(){const e=_r(yo.create).current;return Or(e.disposeEffect),e}var vo=0;function wo(e,t){if("string"==typeof e)return{description:e};if("function"==typeof e){const n=e(t);return"string"==typeof n?{description:n}:n}return e}var{userAgent:xo,platform:So,maxTouchPoints:ko}="undefined"==typeof navigator?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0},Co=xo.toLowerCase(),Eo=So.toLowerCase(),Io=/^i(os$|p)/.test(Eo)||"macintel"===Eo&&ko>1,Mo="android",To=Eo===Mo||Co.includes(Mo),Ro=!Io&&Eo.startsWith("mac"),Oo=(Eo.startsWith("win"),!To&&/^(linux|chrome os)/.test(Eo),Ro||Io),Ao="undefined"!=typeof CSS&&!!CSS.supports?.("-webkit-backdrop-filter:none"),_o=(!Ao&&Co.includes("firefox"),!Ao&&Co.includes("chrom"),Oo),Do=/jsdom|happydom/.test(Co);function Po(e){let t=e.activeElement;for(;null!=t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function No(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&io(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Lo(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}var Fo="data-base-ui-focusable",zo="data-starting-style",$o="data-ending-style",Bo={[zo]:""},Wo={[$o]:""},Uo={transitionStatus:e=>"starting"===e?Bo:"ending"===e?Wo:null},Ho="data-open",jo="data-closed",qo="data-anchor-hidden",Vo={[Ho]:""},Yo={[jo]:""},Ko={[qo]:""},Xo={open:e=>e?Vo:Yo,anchorHidden:e=>e?Ko:null},Go={...Xo,...Uo};function Jo(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function Zo(e){return oo(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function Qo(e){return!!e&&"combobox"===e.getAttribute("role")&&Zo(e)}function ei(e){if(!e||Do)return!0;try{return e.matches(":focus-visible")}catch(t){return!0}}function ti(e){return e?e.hasAttribute("data-base-ui-focusable")?e:e.querySelector("[data-base-ui-focusable]")||e:null}function ni(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ni(e,t.id,n)])}function ri(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){const t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function oi(e){return!(""!==e.pointerType||!e.isTrusted)||(To&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function ii(e,t){return t<0||t>=e.length}function si(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:o=1}={}){let i=t;do{i+=n?-o:o}while(i>=0&&i<=e.length-1&&ai(e,i,r));return i}function ai(e,t,n){if("function"==typeof n?n(t):n?.includes(t))return!0;const r=e[t];return!!r&&(!ci(r)||!!r.matches(":disabled")||!n&&(r.hasAttribute("disabled")||"true"===r.getAttribute("aria-disabled")))}function ci(e,t=(e?ao(e):null)){return!(!(e&&e.isConnected&&t)||function(e){return"hidden"===e.visibility||"collapse"===e.visibility}(t))&&("function"==typeof e.checkVisibility?e.checkVisibility():"none"!==t.display&&"contents"!==t.display)}function li(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return io(n)?n.host:null}function ui(e){for(const t of Array.from(e.children))if("summary"===eo(t))return t;return null}function di(e,t){const n=ui(t);return!!n&&(e===n||No(n,e))}function pi(e){const t=e?eo(e):"";return null!=e&&e.matches('a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]')&&("summary"!==t||null!=e.parentElement&&"details"===eo(e.parentElement)&&ui(e.parentElement)===e)&&("details"!==t||null==ui(e))&&("input"!==t||"hidden"!==e.type)}function hi(e){if(!pi(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=li(t)){const n=t!==e,r="slot"===eo(t);if(t.hasAttribute("inert"))return!1;if(n&&"details"===eo(t)&&!t.open&&!di(e,t)||t.hasAttribute("hidden")||!r&&!fi(t,n))return!1}return!0}function fi(e,t){const n=ao(e);return t?"none"!==n.display:ci(e,n)}function mi(e){const t=e.tabIndex;if(t<0){const t=eo(e);if("details"===t||"audio"===t||"video"===t||oo(e)&&e.isContentEditable)return 0}return t}function gi(e){if("input"!==eo(e))return null;const t=e;return"radio"===t.type&&""!==t.name?t:null}function yi(e){if(oo(e)&&"slot"===eo(e)){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return oo(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function bi(e,t){yi(e).forEach(e=>{pi(e)&&t.push(e),bi(e,t)})}function vi(e,t,n){yi(e).forEach(e=>{oo(e)&&e.matches(t)&&n.push(e),vi(e,t,n)})}function wi(e){return hi(e)&&mi(e)>=0}function xi(e){const t=[];return bi(e,t),t.filter(hi)}function Si(e){const t=xi(e);return t.filter(e=>mi(e)>=0&&function(e,t){const n=gi(e);if(!n)return!0;const r=t.find(e=>{const t=gi(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{const t=gi(e);return t?.name===n.name&&t.form===n.form})===n}(e,t))}function ki(e,t){const n=Si(e),r=n.length;if(0===r)return;const o=Po(uo(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Ci(e){return ki(uo(e).body,1)||e}function Ei(e){return ki(uo(e).body,-1)||e}function Ii(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!No(n,r)}function Mi(e){const t=[];vi(e,"[data-tabindex]",t),t.forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}function Ti(e){const t=/* @__PURE__ */new Map;let n=0,r=0;return e.forEach((e,o)=>{const i="ending"===e.transitionStatus;t.set(e.id,{value:e,domIndex:o,visibleIndex:i?-1:n,offsetY:r}),r+=e.height||0,i||(n+=1)}),t}function Ri(e,t){let n=0;return e.map(e=>{if("ending"===e.transitionStatus)return e;const r=n>=t;return n+=1,e.limited===r?e:{...e,limited:r}})}var Oi={toasts:e=>e.toasts,isEmpty:e=>0===e.toasts.length,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement},Ai=class extends Zr{timers=/* @__PURE__ */new Map;areTimersPaused=!1;constructor(e){super({...e,toastMetadata:Ti(e.toasts)},{},Oi)}setViewport=e=>{this.set("viewport",e)};syncProviderProps(e,t){const n=this.state.limit!==t;if(this.state.timeout===e&&!n)return;const r={timeout:e,limit:t};if(n){const e=Ri(this.state.toasts,t);r.toasts=e,r.toastMetadata=Ti(e)}this.update(r)}disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e,t=!1){const n=Oi.toastIndex(this.state,e);if(-1===n)return;const r=this.state.toasts[n];t||r?.onRemove?.();const o=[...this.state.toasts];o.splice(n,1),this.setToasts(o)}addToast=e=>{const{timeout:t,limit:n}=this.state,r=e.id||(vo+=1,`toast-${Math.random().toString(36).slice(2,6)}-${vo}`);if(e.id){const t=Oi.toast(this.state,e.id);if(t){if("ending"!==t.transitionStatus){const{id:t,transitionStatus:n,...r}=e;return this.updateToastInternal(e.id,r,!0,!0),e.id}this.removeToast(e.id,!0)}}const o={...e,id:r,updateKey:0,transitionStatus:"starting"},i=[o,...this.state.toasts];this.setToasts(Ri(i,n));const s=o.timeout??t;return"loading"!==o.type&&s>0&&this.scheduleTimer(r,s,()=>this.closeToast(r)),Oi.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),r};updateToast=(e,t)=>{const n=Oi.toast(this.state,e);n&&"ending"!==n.transitionStatus&&this.updateToastInternal(e,"function"==typeof t?t(n):t,!1,!0)};updateToastInternal=(e,t,n=!1,r=!1)=>{const{timeout:o,toasts:i}=this.state,s=Oi.toast(this.state,e);if(!s)return;if("ending"===s.transitionStatus)return;const a={...s,...t,...r&&{updateKey:s.updateKey+1}};this.setToasts(i.map(t=>t.id===e?a:t));const c=a.timeout??o,l=s.timeout??o,u=Object.hasOwn(t,"timeout"),d="ending"!==a.transitionStatus&&"loading"!==a.type&&c>0,p=this.timers.has(e),h=l!==c,f="loading"===s.type;d||!p?d&&(!p||h||u||f||n)&&(this.clearTimer(e),this.scheduleTimer(e,c,()=>this.closeToast(e)),Oi.expandedOrOutOfFocus(this.state)&&this.pauseTimers()):this.clearTimer(e)};closeToast=e=>{const t=void 0===e,{limit:n,toasts:r}=this.state;let o;if(t)o=r,this.clearTimers();else{const t=Oi.toast(this.state,e);if(!t)return;o=[t],this.clearTimer(e)}const i=Ri(r.map(n=>t||n.id===e?{...n,transitionStatus:"ending",height:0}:n),n);this.setToasts(i,!i.some(e=>"ending"!==e.transitionStatus)),o.forEach(e=>{"ending"!==e.transitionStatus&&e.onClose?.()}),this.handleFocusManagement(e)};promiseToast=(e,t)=>{const n=wo(t.loading),r=this.addToast({...n,type:"loading"}),o=e.then(e=>{const n=wo(t.success,e);return this.updateToast(r,{...n,type:"success",timeout:n.timeout}),e}).catch(e=>{const n=wo(t.error,e);return this.updateToast(r,{...n,type:"error",timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,"setPromise")&&t.setPromise(o),o};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{e.timeout&&(e.timeout.clear(),e.remaining=Math.max(e.remaining-(Date.now()-e.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=yo.create(),e.timeout.start(e.remaining,()=>{this.handleTimerFired(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if("touch"!==e.pointerType)return;const t=Lo(e);No(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){const r=Date.now(),o=Oi.expandedOrOutOfFocus(this.state)?void 0:yo.create();o?.start(t,()=>{this.handleTimerFired(e),n()}),this.timers.set(e,{timeout:o,start:r,delay:t,remaining:t,callback:n})}clearTimers(){this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(e){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(e){this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){0===this.timers.size&&(this.areTimersPaused=!1)}setToasts(e,t=0===e.length){const n={toasts:e,toastMetadata:Ti(e)};t&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(e){const t=Po(uo(this.state.viewport));if(!this.state.viewport||!No(this.state.viewport,t)||!ei(t))return;if(void 0===e)return void this.restoreFocusToPrevElement();const n=Oi.toasts(this.state),r=Oi.toastIndex(this.state,e),o=(e,t)=>{for(let r=e;r>=0&&r<n.length;r+=t)if("ending"!==n[r].transitionStatus)return n[r];return null},i=o(r+1,1)??o(r-1,-1);i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},_i=function(t){const{children:n,timeout:r=5e3,limit:o=3,toastManager:i}=t,s=_r(()=>new Ai({timeout:r,limit:o,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Or(s.disposeEffect),e.useEffect(function(){if(i)return i[" subscribe"](({action:e,options:t})=>{const n=t.id;"promise"===e&&t.promise?s.promiseToast(t.promise,t):"update"===e&&n?s.updateToast(n,t.updates):"close"===e?s.closeToast(n):s.addToast(t)})},[s,i]),/*#__PURE__*/v(Nr.Provider,{value:s,children:[/*#__PURE__*/b(Di,{store:s,timeout:r,limit:o}),n]})};function Di(e){const{store:t,timeout:n,limit:r}=e;return Dr(()=>{t.syncProviderProps(n,r)},[t,n,r]),null}var Pi={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1,position:"fixed",top:0,left:0},Ni=/*#__PURE__*/e.forwardRef(function(t,n){const[r,o]=e.useState();return Dr(()=>{_o&&Ao&&o("button")},[]),/*#__PURE__*/b("span",{...t,ref:n,style:Pi,"aria-hidden":!r||void 0,tabIndex:0,role:r,"data-base-ui-focus-guard":""})});function Li(e,t,n,r){const o=_r(Fi).current;return function(e,t,n,r,o){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==o}(o,e,t,n,r)&&zi(o,[e,t,n,r]),o.callback}function Fi(){return{callback:null,cleanup:null,refs:[]}}function zi(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 o=t[e];if(null!=o)switch(typeof o){case"function":{const t=o(n);"function"==typeof t&&(r[e]=t);break}case"object":o.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}}}}}}function $i(t){if(!/*#__PURE__*/e.isValidElement(t))return null;const n=t,r=n.props;return(zr(19)?r?.ref:n.ref)??null}function Bi(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var Wi={};function Ui(e,t,n,r,o){if(!(n||r||o||e))return Hi(t);let i=Hi(e);return t&&(i=ji(i,t)),n&&(i=ji(i,n)),r&&(i=ji(i,r)),o&&(i=ji(i,o)),i}function Hi(e){return Vi(e)?{...Yi(e,Wi)}:function(e){const t={...e};for(const n in t){const e=t[n];qi(n,e)&&(t[n]=Xi(e))}return t}(e)}function ji(e,t){return Vi(t)?Yi(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=Bi(e.style,r);break;case"className":e[n]=Ji(e.className,r);break;default:qi(n,r)?e[n]=Ki(e[n],r):e[n]=r}}return e}(e,t)}function qi(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),o=e.charCodeAt(2);return 111===n&&110===r&&o>=65&&o<=90&&("function"==typeof t||void 0===t)}function Vi(e){return"function"==typeof e}function Yi(e,t){return Vi(e)?e(t):e??Wi}function Ki(e,t){return t?e?(...n)=>{const r=n[0];if(Zi(r)){const o=r;Gi(o);const i=t(...n);return o.baseUIHandlerPrevented||e?.(...n),i}const o=t(...n);return e?.(...n),o}:Xi(t):e}function Xi(e){return e?(...t)=>{const n=t[0];return Zi(n)&&Gi(n),e(...t)}:e}function Gi(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Ji(e,t){return t?e?t+" "+e:t:e}function Zi(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}function Qi(t,n,o={}){let i=n.render;!1!==o.enabled&&(i=function(t){if(t?.$$typeof!==es)return t;const n=e.Children.toArray(t)[0];/*#__PURE__*/
2
2
  return e.isValidElement(n)?n:t}(i));const s=function(e,t,n){const{className:r,style:o}=e,{state:i=Rr,ref:s,props:a,stateAttributesMapping:c,enabled:l=!0}=t,u=l?function(e,t){return"function"==typeof e?e(t):e}(r,i):void 0,d=l?function(e,t){return"function"==typeof e?e(t):e}(o,i):void 0,p=l?function(e,t){const n={};for(const r in e){const o=e[r];if(t?.hasOwnProperty(r)){const e=t[r](o);null!=e&&Object.assign(n,e);continue}!0===o?n[`data-${r.toLowerCase()}`]="":o&&(n[`data-${r.toLowerCase()}`]=o.toString())}return n}(i,c):Rr,h=l&&a?function(e){return Array.isArray(e)?function(e){if(0===e.length)return Wi;if(1===e.length)return Hi(e[0]);let t=Hi(e[0]);for(let n=1;n<e.length;n+=1)t=ji(t,e[n]);return t}(e):Ui(void 0,e)}(a):void 0,f=l?Bi(p,h)??{}:Rr;return"undefined"!=typeof document&&(l?Array.isArray(s)?f.ref=function(e){const t=_r(Fi).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&zi(t,e),t.callback}([f.ref,$i(n),...s]):f.ref=Li(f.ref,$i(n),s):Li(null,null)),l?(void 0!==u&&(f.className=Ji(f.className,u)),void 0!==d&&(f.style=Bi(f.style,d)),f):Rr}(n,o,i);return!1===o.enabled?null:function(t,n,o,i){if(n){if("function"==typeof n)return n(o,i);const t=Ui(o,n.props);return t.ref=o.ref,/*#__PURE__*/e.cloneElement(n,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,o);throw new Error(Pr(8))}(t,i,s,o.state??Rr)}var es=Symbol.for("react.lazy"),ts="--toast-frontmost-height",ns=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,children:s,...a}=t,c=Lr(),l=bo(),u=e.useRef(!1),d=e.useRef(!1),p=e.useRef(!1),h=c.useState("isEmpty"),f=c.useState("toasts"),m=c.useState("focused"),g=c.useState("expanded"),y=c.useState("prevFocusElement"),w=f[0]?.height,x=f.some(e=>"ending"===e.transitionStatus),S=f.filter(e=>"high"===e.priority);function k(){c.state.toasts.some(e=>"ending"===e.transitionStatus)||p.current||!d.current||(c.state.isWindowFocused&&c.resumeTimers(),c.set("hovering",!1),d.current=!1)}function C(){c.pauseTimers(),c.set("hovering",!0),d.current=!1}function E(e){"touch"===e.pointerType&&(p.current=!1,k())}function I(){u.current?u.current=!1:m||ei(Po(uo(c.state.viewport)))&&(c.set("focused",!0),c.pauseTimers())}e.useEffect(()=>{const e=c.state.viewport;if(!e||h)return;const t=to(e),n=uo(e);return lo(po(t,"keydown",function(t){"F6"===t.key&&Lo(t)!==e&&(t.preventDefault(),c.set("prevFocusElement",Po(n)),e?.focus({preventScroll:!0}),c.pauseTimers(),c.set("focused",!0))}),po(t,"blur",function(e){Lo(e)===t&&(c.set("isWindowFocused",!1),c.pauseTimers())},!0),po(t,"focus",function(n){if(n.relatedTarget)return;const r=Lo(n),o=Po(uo(e));r!==t&&No(e,r)&&ei(o)||c.resumeTimers(),l.start(0,()=>c.set("isWindowFocused",!0))},!0),po(n,"pointerdown",c.handleDocumentPointerDown,!0))},[c,l,h]),e.useEffect(k,[x,c]);const M={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:C,onMouseMove:C,onMouseLeave:function(){d.current=!0,k()},onFocus:I,onBlur:function(e){m&&!No(c.state.viewport,e.relatedTarget)&&(c.set("focused",!1),c.state.isWindowFocused&&c.resumeTimers())},onKeyDown:function(e){"Tab"===e.key&&e.shiftKey&&Lo(e.nativeEvent)===c.state.viewport&&(e.preventDefault(),c.restoreFocusToPrevElement())},onClick:I,onPointerDown:function(e){"touch"===e.pointerType&&(p.current=!0)},onPointerUp:E,onPointerCancel:E,style:{[ts]:w?`${w}px`:void 0}},T={expanded:g},R=!h&&y&&/*#__PURE__*/b(Ni,{onFocus:function(e){u.current=!0;const t=e.relatedTarget===c.state.viewport?f.find(e=>"ending"!==e.transitionStatus&&!e.limited):void 0;t?t.ref?.current?.focus():c.restoreFocusToPrevElement()}}),O=Qi("div",t,{ref:[n,c.setViewport],state:T,props:[M,a,{children:/*#__PURE__*/v(e.Fragment,{children:[R,s,R]})}]});/*#__PURE__*/
3
3
  return v(e.Fragment,{children:[R,O,!m&&S.length>0&&/*#__PURE__*/b("div",{style:Pi,children:S.map(e=>/*#__PURE__*/v("div",{role:"alert","aria-atomic":!0,children:[/*#__PURE__*/b("div",{children:e.title}),/*#__PURE__*/b("div",{children:e.description})]},e.id))})]})});function rs(e){return zr(19)?e:e?"true":void 0}var os=/*#__PURE__*/e.createContext(void 0);function is(){const t=e.useContext(os);if(!t)throw new Error(Pr(66));return t}function ss(e){return null==e?e:"current"in e?e.current:e}var as=null;function cs(t){const{enabled:n=!0,open:r,ref:o,batch:i=!1,onComplete:s}=t,a=Xr(s),c=function(e,t=!1,n=!1){const r=go();return Xr((o,i=null)=>{r.cancel();const s=ss(e);if(null==s)return;const a=s,c=()=>{n?function(){if(!as){const e=[];as=e,queueMicrotask(()=>{as=null,g.flushSync(()=>{for(const t of e)t()})})}as.push(()=>{i?.aborted||o()})}():g.flushSync(o)};if("function"!=typeof a.getAnimations||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{if(t){const e=zo;if(!a.hasAttribute(e))return void r.request(l);const t=new MutationObserver(()=>{a.hasAttribute(e)||(t.disconnect(),l())});return t.observe(a,{attributes:!0,attributeFilter:[e]}),void i?.addEventListener("abort",()=>t.disconnect(),{once:!0})}r.request(l)}function l(){Promise.all(a.getAnimations().map(e=>e.finished)).then(()=>{i?.aborted||c()},()=>{i?.aborted||(a.getAnimations().some(e=>e.pending||"finished"!==e.playState)?l():c())})}})}(o,r,i);e.useEffect(()=>{if(!n)return;const e=new AbortController;return c(a,e.signal),()=>{e.abort()}},[n,r,a,c])}var ls={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function us(e,t,n){switch(e){case"up":return-n;case"down":return n;case"left":return-t;case"right":return t;default:return 0}}var ds="--toast-index",ps="--toast-offset-y",hs="--toast-height",fs="--toast-swipe-movement-x",ms="--toast-swipe-movement-y",gs="data-swipe-direction",ys={...Uo,swipeDirection:e=>e?{[gs]:e}:null},bs=/*#__PURE__*/e.forwardRef(function(t,n){const{toast:r,render:o,className:i,swipeDirection:s=["down","right"],style:a,...c}=t,l=void 0!==r.positionerProps?.anchor;let u=[];l||(u=Array.isArray(s)?s:[s]);const d=u.length>0,p=Lr(),[h,f]=e.useState(void 0),[m,y]=e.useState(!1),[v,w]=e.useState(!1),[x,S]=e.useState({x:0,y:0}),[k,C]=e.useState({x:0,y:0,scale:1}),[E,I]=e.useState(),[M,T]=e.useState(),[R,O]=e.useState(null),A=e.useRef(null),_=e.useRef(void 0),D=e.useRef({x:0,y:0}),P=e.useRef({x:0,y:0,scale:1}),N=e.useRef(void 0),L=e.useRef(0),F=e.useRef(!1),z=e.useRef({x:0,y:0}),$=e.useRef(!1),B=e.useRef({x:0,y:0}),W=e.useRef(null),U=e.useRef(null),H=p.useState("toastIndex",r.id),j=p.useState("toastVisibleIndex",r.id),q=p.useState("toastOffsetY",r.id),V=p.useState("focused"),Y=p.useState("expanded");cs({open:"ending"!==r.transitionStatus,ref:A,onComplete(){"ending"===r.transitionStatus&&p.removeToast(r.id)}});const K=Xr((e=!1)=>{const t=A.current;if(!t)return;const n=t.style.height;t.style.height="auto";const o=t.offsetHeight;function i(){p.updateToastInternal(r.id,{ref:A,height:o,transitionStatus:void 0})}t.style.height=n,e?g.flushSync(i):i()});function X(e){B.current=e,S(e)}Dr(()=>{const e=_.current;"starting"!==r.transitionStatus&&e===r.id||(void 0!==e&&(f(void 0),C({x:0,y:0,scale:1}),X({x:0,y:0})),_.current=r.id,K())},[K,r.id,r.transitionStatus]),Dr(()=>()=>{U.current?.abort()},[]);const G=Xr(e=>{if(e.pointerId!==W.current)return;W.current=null,U.current?.abort(),U.current=null,y(!1),w(!1),O(null);const t=P.current;if("pointercancel"===e.type||F.current)return X({x:t.x,y:t.y}),void f(void 0);const n=B.current,o=n.x-t.x,i=n.y-t.y;let s;for(const r of u)if(us(r,o,i)>40){s=r;break}s?(f(s),p.closeToast(r.id)):(X({x:t.x,y:t.y}),f(void 0))});e.useEffect(()=>{const e=A.current;if(d&&e)return po(e,"touchmove",function(t){null!==W.current&&No(e,Lo(t))&&t.preventDefault()},{passive:!1})},[d]);const J="high"===r.priority,Z={role:J?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":E,"aria-describedby":M,"aria-hidden":!(!J||V)||void 0,onPointerDown:d?function(e){if(0!==e.button)return;if("touch"===e.pointerType&&p.pauseTimers(),Lo(e.nativeEvent)?.closest('button,a,input,textarea,[role="button"],[data-base-ui-swipe-ignore],[data-swipe-ignore]'))return;F.current=!1,N.current=void 0,L.current=0,W.current=e.pointerId,D.current={x:e.clientX,y:e.clientY},z.current=D.current;const t=e.currentTarget,n=function(e){const t=to(e).getComputedStyle(e).transform;let n=0,r=0,o=1;if(t&&"none"!==t){const e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){const t=e[1].split(", ").map(parseFloat);6===t.length?(n=t[4],r=t[5],o=Math.sqrt(t[0]*t[0]+t[1]*t[1])):16===t.length&&(n=t[12],r=t[13],o=t[0])}}return{x:n,y:r,scale:o}}(t);P.current=n,C(n),X({x:n.x,y:n.y}),p.set("hovering",!0),y(!0),w(!1),O(null),$.current=!0,U.current?.abort();const r=new AbortController;U.current=r;const o=uo(t);o.addEventListener("pointerup",G,{signal:r.signal}),o.addEventListener("pointercancel",G,{signal:r.signal}),t.setPointerCapture?.(e.pointerId)}:void 0,onPointerMove:d?function(e){if(e.pointerId!==W.current)return;e.preventDefault(),$.current&&(D.current={x:e.clientX,y:e.clientY},$.current=!1);const{clientY:t,clientX:n,movementX:r,movementY:o}=e;(o<0&&t>z.current.y||o>0&&t<z.current.y)&&(z.current={x:z.current.x,y:t}),(r<0&&n>z.current.x||r>0&&n<z.current.x)&&(z.current={x:n,y:z.current.y});const i=n-D.current.x,s=t-D.current.y,a=t-z.current.y,c=n-z.current.x;let l,d=R;if(!v&&Math.sqrt(i*i+s*s)>=1){w(!0);const e=u.includes("left")||u.includes("right"),t=u.includes("up")||u.includes("down");e&&t&&(d=Math.abs(i)>Math.abs(s)?"horizontal":"vertical",O(d))}if(N.current){const e=N.current,t=us(e,c,a);t>40?(F.current=!1,f(e)):u.includes("left")&&u.includes("right")||u.includes("up")&&u.includes("down")||!(L.current-t>=10)||(F.current=!0)}else"vertical"===d?s>0?l="down":s<0&&(l="up"):"horizontal"===d?i>0?l="right":i<0&&(l="left"):l=Math.abs(i)>=Math.abs(s)?i>0?"right":"left":s>0?"down":"up",l&&u.includes(l)&&(N.current=l,L.current=us(l,i,s),f(l));const p=function(e,t){const n=e=>e>0?e**.5:-(Math.abs(e)**.5),r=e>0&&!u.includes("right")||e<0&&!u.includes("left"),o=t>0&&!u.includes("down")||t<0&&!u.includes("up");return{x:r?n(e):e,y:o?n(t):t}}(i,s);let h=P.current.x,m=P.current.y;const g=u.includes("left")||u.includes("right"),y=u.includes("up")||u.includes("down");"vertical"!==d&&g&&(h+=p.x),"horizontal"!==d&&y&&(m+=p.y),X({x:h,y:m})}:void 0,onPointerUp:d?G:void 0,onPointerCancel:d?G:void 0,onKeyDown:function(e){if("Escape"===e.key){if(!A.current||!No(A.current,Po(uo(A.current))))return;p.closeToast(r.id)}},inert:rs(r.limited),style:{...function(){const e=x.x-k.x,t=x.y-k.y;return{transition:m?"none":void 0,transform:m?`translateX(${x.x}px) translateY(${x.y}px) scale(${k.scale})`:void 0,[fs]:`${e}px`,[ms]:`${t}px`}}(),[ds]:"ending"===r.transitionStatus?H:j,[ps]:`${q}px`,[hs]:r.height?`${r.height}px`:void 0}},Q=e.useMemo(()=>({toast:r,setTitleId:I,setDescriptionId:T,recalculateHeight:K,visibleIndex:j,expanded:Y}),[r,I,T,K,j,Y]),ee={transitionStatus:r.transitionStatus,expanded:Y,limited:r.limited||!1,type:r.type,swiping:m,swipeDirection:h},te=Qi("div",t,{ref:[n,A],state:ee,stateAttributesMapping:ys,props:[Z,c]});/*#__PURE__*/
4
4
  return b(os.Provider,{value:Q,children:te})}),vs=0,ws=Vr.useId;function xs(t,n){if(void 0!==ws){const e=ws();return t??(n?`${n}-${e}`:e)}return function(t,n="mui"){const[r,o]=e.useState(t),i=t||r;return e.useEffect(()=>{null==r&&o(`${n}-${vs+=1}`)},[r,n]),i}(t,n)}function Ss(e){return null!=e&&"boolean"!=typeof e&&""!==e&&(!Array.isArray(e)||e.some(Ss))}function ks(t){/*#__PURE__*/
5
5
  return e.isValidElement(t)&&Ss(t.props.children)}function Cs(e,t,n){const{toast:r,setTitleId:o,setDescriptionId:i}=is(),s="title"===n?o:i,a=t??("title"===n?r.title:r.description);return{id:xs(e),children:a,type:r.type,setId:s}}function Es(e,t,n){const r=ks(e);return Dr(()=>{if(r)return n(t),()=>{n(e=>e===t?void 0:e)}},[r,t,n]),r?e:null}var Is=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,children:s,...a}=e,{id:c,children:l,type:u,setId:d}=Cs(i,s,"description");return Es(Qi("p",e,{ref:t,state:{type:u},props:{...a,id:c,children:l}}),c,d)}),Ms=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,children:s,...a}=e,{id:c,children:l,type:u,setId:d}=Cs(i,s,"title");return Es(Qi("h2",e,{ref:t,state:{type:u},props:{...a,id:c,children:l}}),c,d)}),Ts=/*#__PURE__*/e.createContext(void 0);function Rs(t=!1){const n=e.useContext(Ts);if(void 0===n&&!t)throw new Error(Pr(16));return n}function Os(e,t,{detail:n=0}={}){e.dispatchEvent(new(to(e).PointerEvent)("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function As(t={}){const{disabled:n=!1,focusableWhenDisabled:r,tabIndex:o=0,native:i=!0,composite:s}=t,a=e.useRef(null),c=Rs(!0),l=s??void 0!==c,{props:u}=function(t){const{focusableWhenDisabled:n,disabled:r,composite:o=!1,tabIndex:i=0,isNativeButton:s}=t,a=o&&!1!==n,c=o&&!1===n;return{props:e.useMemo(()=>{const e={onKeyDown(e){r&&n&&"Tab"!==e.key&&e.preventDefault()}};return o||(e.tabIndex=i,!s&&r&&(e.tabIndex=n?i:-1)),(s&&(n||a)||!s&&r)&&(e["aria-disabled"]=r),!s||n&&!c||(e.disabled=r),e},[o,r,n,a,c,s,i])}}({focusableWhenDisabled:r,disabled:n,composite:l,tabIndex:o,isNativeButton:i}),d=e.useCallback(()=>{const e=a.current;_s(e)&&l&&n&&void 0===u.disabled&&e.disabled&&(e.disabled=!1)},[n,u.disabled,l]);return Dr(d,[d]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:r,onKeyUp:o,onKeyDown:s,onPointerDown:a,...c}=e;return Ui({onClick(e){n?e.preventDefault():t?.(e)},onMouseDown(e){n||r?.(e)},onKeyDown(e){if(n)return;if(Gi(e),s?.(e),e.baseUIHandlerPrevented)return;const t=e.target===e.currentTarget,r=e.currentTarget,o=_s(r),a=!i&&oo(c=r)&&"A"===c.tagName&&Boolean(c.href);var c;const u=t&&(i?o:!a),d="Enter"===e.key,p=" "===e.key,h=r.getAttribute("role"),f=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(t&&l&&p){if(e.defaultPrevented&&f)return;return e.preventDefault(),void(i&&!o||(e.preventBaseUIHandler(),Os(r,e)))}u&&!i&&(p||d)?e.defaultPrevented||(e.preventDefault(),d&&(e.preventBaseUIHandler(),Os(r,e))):t&&a&&p&&e.preventDefault()},onKeyUp(e){n||(Gi(e),o?.(e),e.target===e.currentTarget&&i&&l&&_s(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||l||e.defaultPrevented||" "!==e.key||(e.preventBaseUIHandler(),Os(e.currentTarget,e)))},onPointerDown(e){n?e.preventDefault():a?.(e)}},i?{type:"button"}:{role:"button"},u,c)},[n,u,l,i]),buttonRef:Xr(e=>{a.current=e,d()})}}function _s(e){return oo(e)&&"BUTTON"===e.tagName}var Ds=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,disabled:s,nativeButton:a=!0,...c}=t,l=Lr(),{toast:u,expanded:d}=is(),[p,h]=e.useState(!1),{getButtonProps:f,buttonRef:m}=As({disabled:s,native:a});return Qi("button",t,{ref:[n,m],state:{type:u.type},props:[{"aria-hidden":!d&&!p,onClick(){l.closeToast(u.id)},onFocus(){h(!0)},onBlur(){h(!1)}},c,f]})}),Ps=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,disabled:i,nativeButton:s=!0,...a}=e,{toast:c}=is(),l=c.actionProps?.children??a.children,{getButtonProps:u,buttonRef:d}=As({disabled:i,native:s}),p=Qi("button",e,{ref:[t,d],state:{type:c.type},props:[a,c.actionProps,u,{children:l}]});return ks(p)?p:null}),Ns="none",Ls="missing",Fs="initial";function zs(e,t,n,r){let o=!1,i=!1;const s=r??Rr;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){i=!0},get isCanceled(){return o},get isPropagationAllowed(){return i},trigger:n,...s}}function $s(e){return`data-base-ui-${e}`}var Bs=/*#__PURE__*/e.createContext(null),Ws=()=>e.useContext(Bs),Us=$s("portal");function Hs(t={}){const{ref:n,container:r,componentProps:o=Rr,elementProps:i}=t,s=xs(),a=Ws()?.portalNode,[c,l]=e.useState(null),[u,d]=e.useState(null),p=Xr(e=>{null!==e&&d(e)}),h=e.useRef(null);Dr(()=>{if(null===r)return void(h.current&&(h.current=null,d(null),l(null)));const e=(r&&(no(r)?r:r.current))??a??document.body;null!=e?h.current!==e&&(h.current=e,d(null),l(e)):h.current&&(h.current=null,d(null),l(null))},[r,a]);const f=Qi("div",o,{ref:[n,p],props:[{id:s,[Us]:""},i]}),m=c&&f?/*#__PURE__*/g.createPortal(f,c):null;return{node:u,nodeId:/*#__PURE__*/e.isValidElement(f)?f.props.id:void 0,subtree:m}}var js=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,children:s,container:a,portalOwnerRole:c,...l}=t,{node:u,nodeId:d,subtree:p}=Hs({container:a,ref:n,componentProps:t,elementProps:l}),h=e.useRef(null),f=e.useRef(null),m=e.useRef(null),y=e.useRef(null),[w,x]=e.useState(null),S=e.useRef(!1),k=w?.modal,C=w?.open,E=!!w&&!w.modal&&w.open&&!!u;e.useEffect(()=>{if(u&&!k)return lo(po(u,"focusin",e,!0),po(u,"focusout",e,!0));function e(e){u&&e.relatedTarget&&Ii(e)&&("focusin"===e.type?S.current&&(Mi(u),S.current=!1):(function(e){Si(e).forEach(e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")})}(u),S.current=!0))}},[u,k]),Dr(()=>{u&&!0===C&&S.current&&(Mi(u),S.current=!1)},[C,u]);const I=e.useMemo(()=>({beforeOutsideRef:h,afterOutsideRef:f,beforeInsideRef:m,afterInsideRef:y,portalNode:u,setFocusManagerState:x}),[u]);/*#__PURE__*/
6
6
  return v(e.Fragment,{children:[p,/*#__PURE__*/v(Bs.Provider,{value:I,children:[E&&u&&/*#__PURE__*/b(Ni,{"data-type":"outside",ref:h,onFocus:e=>{if(Ii(e,u))m.current?.focus();else{const e=w?w.domReference:null;Ei(e)?.focus()}}}),E&&u&&/*#__PURE__*/b("span",{role:c,"aria-owns":d,style:ls}),u&&/*#__PURE__*/g.createPortal(s,u),E&&u&&/*#__PURE__*/b(Ni,{"data-type":"outside",ref:f,onFocus:e=>{if(Ii(e,u))y.current?.focus();else{const t=w?w.domReference:null;Ci(t)?.focus(),w?.closeOnFocusOut&&w?.onOpenChange(!1,zs("focus-out",e.nativeEvent))}}})]})]})}),qs=/*#__PURE__*/e.forwardRef(function(t,n){const{children:r,container:o,className:i,render:s,style:a,...c}=t,{node:l,subtree:u}=Hs({container:o,ref:n,componentProps:t,elementProps:c});return u||l?/*#__PURE__*/v(e.Fragment,{children:[u,l&&/*#__PURE__*/g.createPortal(r,l)]}):null}),Vs=/*#__PURE__*/e.forwardRef(function(e,t){/*#__PURE__*/
7
7
  return b(qs,{ref:t,...e})});function Ys(e){const t=_r(Ks,e).current;return t.next=e,Dr(t.effect),t}function Ks(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Xs=0;function Gs(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:o}=t;function i(){o&&!o()||e?.focus({preventScroll:n})}if(cancelAnimationFrame(Xs),r)return i(),Mr;const s=requestAnimationFrame(i);return Xs=s,()=>{Xs===s&&(cancelAnimationFrame(s),Xs=0)}}var Js={inert:/* @__PURE__ */new WeakMap,"aria-hidden":/* @__PURE__ */new WeakMap},Zs="data-base-ui-inert",Qs={inert:/* @__PURE__ */new WeakSet,"aria-hidden":/* @__PURE__ */new WeakSet},ea=/* @__PURE__ */new WeakMap,ta=0;function na(e){return e?io(e)?e.host:na(e.parentNode):null}var ra=(e,t)=>t.map(t=>{if(e.contains(t))return t;const n=na(t);return e.contains(n)?n:null}).filter(e=>null!=e),oa=e=>{const t=/* @__PURE__ */new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},ia=(e,t,n)=>{const r=[],o=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{"script"!==eo(e)&&(t.has(e)?o(e):r.push(e))})};return o(e),r};function sa(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:o=!0}=t;return function(e,t,n,r,{mark:o=!0}){let i=null;r?i="inert":n&&(i="aria-hidden");let s=null,a=null;const c=ra(t,e),l=o?ia(t,oa(c),new Set(c)):[],u=[],d=[];if(i){const e=Js[i],n=function(e){return Qs[e]}(i);a=n,s=e;const r=ra(t,Array.from(t.querySelectorAll("[aria-live]"))),o=c.concat(r);ia(t,oa(o),new Set(o)).forEach(t=>{const r=t.getAttribute(i),o=null!==r&&"false"!==r,s=(e.get(t)||0)+1;e.set(t,s),u.push(t),1===s&&o&&n.add(t),o||t.setAttribute(i,"inert"===i?"":"true")})}return o&&l.forEach(e=>{const t=(ea.get(e)||0)+1;ea.set(e,t),d.push(e),1===t&&e.setAttribute(Zs,"")}),ta+=1,()=>{s&&u.forEach(e=>{const t=(s.get(e)||0)-1;s.set(e,t),t||(!a?.has(e)&&i&&e.removeAttribute(i),a?.delete(e))}),o&&d.forEach(e=>{const t=(ea.get(e)||0)-1;ea.set(e,t),t||e.removeAttribute(Zs)}),(ta-=1)||(Js.inert=/* @__PURE__ */new WeakMap,Js["aria-hidden"]=/* @__PURE__ */new WeakMap,Qs.inert=/* @__PURE__ */new WeakSet,Qs["aria-hidden"]=/* @__PURE__ */new WeakSet,ea=/* @__PURE__ */new WeakMap)}}(e,uo(e[0]).body,n,r,{mark:o})}function aa(){const e=/* @__PURE__ */new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var ca=/*#__PURE__*/e.createContext(null),la=/*#__PURE__*/e.createContext(null),ua=t=>{const n=e.useContext(la);return t??n},da=[];function pa(){da=da.filter(e=>e.deref()?.isConnected)}function ha(e){pa(),e&&"body"!==eo(e)&&(da.push(new WeakRef(e)),da.length>20&&(da=da.slice(-20)))}function fa(){return pa(),da[da.length-1]?.deref()}function ma(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex"))return;if(!e.getAttribute("role")?.includes("dialog"))return;const t=xi(e).filter(e=>{const t=e.getAttribute("data-tabindex")||"";return wi(e)||e.hasAttribute("data-tabindex")&&!t.startsWith("-")}),n=e.getAttribute("tabindex");0===t.length?"0"!==n&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):("-1"!==n||e.hasAttribute("data-tabindex")&&"-1"!==e.getAttribute("data-tabindex"))&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function ga(t){const{context:n,children:r,disabled:o=!1,initialFocus:i=!0,returnFocus:s=!0,restoreFocus:a=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u="",nextFocusableElement:d,previousFocusableElement:p,beforeContentFocusGuardRef:h,externalTree:f,getInsideElements:m}=t,g="rootStore"in n?n.rootStore:n,y=g.useState("open"),w=g.useState("domReferenceElement"),x=g.useState("floatingElement"),{events:S,dataRef:k}=g.context,C=Xr(()=>k.current.floatingContext?.nodeId),E=!1===i,I=Qo(w)&&E,M=Ys(i),T=Ys(s),R=Ys(u),O=Ys(y),A=ua(f),_=Ws(),D=e.useRef(!1),P=e.useRef(!1),N=e.useRef(!1),L=e.useRef(null),F=e.useRef(""),z=e.useRef(""),$=e.useRef(null),B=e.useRef(null),W=Li($,h,_?.beforeInsideRef),U=Li(B,_?.afterInsideRef),H=bo(),j=bo(),q=go(),V=null!=_,Y=ti(x),K=Xr((e=Y)=>e?Si(e):[]),X=Xr(()=>m?.().filter(e=>null!=e)??[]);e.useEffect(()=>{if(!o&&c)return po(uo(Y),"keydown",function(e){"Tab"===e.key&&No(Y,Po(uo(Y)))&&0===K().length&&!I&&function(e){e.preventDefault(),e.stopPropagation()}(e)})},[o,Y,c,I,K]),e.useEffect(()=>{if(o||!y)return;const e=uo(Y);function t(){N.current=!1}return lo(po(e,"pointerdown",function(e){const t=Lo(e),n=X(),r=No(x,t)||No(w,t)||No(_?.portalNode,t)||n.some(e=>e===t||No(e,t));N.current=!r,z.current=e.pointerType||"keyboard",t?.closest("[data-base-ui-click-trigger]")&&(P.current=!0,j.start(0,()=>{P.current=!1}))},!0),po(e,"pointerup",t,!0),po(e,"pointercancel",t,!0),po(e,"keydown",function(){z.current="keyboard"},!0),t)},[o,x,w,Y,y,_,j,X]),e.useEffect(()=>{if(o||!l)return;const e=uo(Y);function t(t){const n=t.relatedTarget,r=t.currentTarget,o=Lo(t);c&&null==n&&null!=o&&No(x,o)&&ha(o),queueMicrotask(()=>{const i=C(),s=g.context.triggerElements,l=X(),u=n?.hasAttribute($s("focus-guard"))&&[$.current,B.current,_?.beforeInsideRef.current,_?.afterInsideRef.current,_?.beforeOutsideRef.current,_?.afterOutsideRef.current,ss(p),ss(d)].includes(n),h=!(No(w,n)||No(x,n)||No(n,x)||No(_?.portalNode,n)||l.some(e=>e===n||No(e,n))||s.hasMatchingElement(e=>No(e,n))||u||A&&(ni(A.nodesRef.current,i).find(e=>No(e.context?.elements.floating,n)||No(e.context?.elements.domReference,n))||ri(A.nodesRef.current,i).find(e=>[e.context?.elements.floating,ti(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===w&&Y&&ma(Y),a&&r!==w&&!ci(o)&&Po(e)===e.body){if(oo(Y)&&(Y.focus(),"popup"===a))return void q.request(()=>{Y.focus()});const e=K(),t=L.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||Y;oo(n)&&n.focus()}k.current.insideReactTree?k.current.insideReactTree=!1:!I&&c||!n||!h||P.current||!I&&n===fa()||(D.current=!0,g.setOpen(!1,zs("focus-out",t)))})}const n=oo(w)?w:null;return x||n?lo(n&&po(n,"focusout",t),n&&po(n,"pointerdown",function(){P.current=!0,j.start(0,()=>{P.current=!1})}),x&&po(x,"focusin",function(e){const t=Lo(e);wi(t)&&(L.current=t)}),x&&po(x,"focusout",t),x&&_&&po(x,"focusout",function(){N.current||(k.current.insideReactTree=!0,H.start(0,()=>{k.current.insideReactTree=!1}))},!0)):void 0},[o,w,x,Y,c,A,_,g,l,a,K,I,C,k,H,j,q,d,p,X]),e.useEffect(()=>{if(o||!x||!y)return;const e=Array.from(_?.portalNode?.querySelectorAll(`[${$s("portal")}]`)||[]),t=(A?ri(A.nodesRef.current,C()):[]).find(e=>Qo(e.context?.elements.domReference||null))?.context?.elements.domReference,n=sa([x,...e,$.current,B.current,_?.beforeOutsideRef.current,_?.afterOutsideRef.current,...X(),t,ss(p),ss(d),I?w:null].filter(e=>null!=e),{ariaHidden:c||I,mark:!1}),r=sa([x,...e].filter(e=>null!=e));return()=>{r(),n()}},[y,o,w,x,c,_,I,A,C,d,p,X]),Dr(()=>{if(!y||o||!oo(Y))return;F.current="",z.current="";const e=uo(Y),t=Po(e);queueMicrotask(()=>{const n=M.current,r="function"==typeof n?n(R.current||""):n;if(void 0===r||!1===r)return;if(No(Y,t))return;let o=null;const i=()=>(null==o&&(o=K(Y)),o[0]||Y);let s;s=!0===r||null===r?i():ss(r),s=s||i();const a=No(Y,Po(e));Gs(s,{preventScroll:s===Y,shouldFocus(){if(!O.current)return!1;if(a)return!0;const t=Po(e);return!(t!==s&&No(Y,t))}})})},[o,y,Y,K,M,R,O]),Dr(()=>{if(o||!Y)return;const e=uo(Y),t=Po(e),n=null==R.current;function r(e){var t;if(e.open||(F.current=function(e,t){const n=to(Lo(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(0===e.detail?"keyboard":"mouse"):""}(e.nativeEvent,z.current)),"trigger-hover"===e.reason&&"mouseleave"===e.nativeEvent.type&&(D.current=!0),"outside-press"===e.reason)if(e.nested)D.current=!1;else if(oi(e.nativeEvent)||(t=e.nativeEvent,!Do&&(!To&&0===t.width&&0===t.height||To&&1===t.width&&1===t.height&&0===t.pressure&&0===t.detail&&"mouse"===t.pointerType||t.width<1&&t.height<1&&0===t.pressure&&0===t.detail&&"touch"===t.pointerType)))D.current=!1;else{let e=!1;uo(Y).createElement("div").focus({get preventScroll(){return e=!0,!1}}),D.current=!e}}return ha(t),S.on("openchange",r),()=>{S.off("openchange",r);const o=Po(e),i=X(),s=No(x,o)||i.some(e=>e===o||No(e,o))||A&&ni(A.nodesRef.current,C(),!1).some(e=>No(e.context?.elements.floating,o)),a=T.current,c=F.current,l=function(e){const r=T.current;let o="function"==typeof r?r(e):r;if(void 0===o||!1===o)return null;null===o&&(o=!0);const i=w?.isConnected?w:null,s=t?.isConnected&&"body"!==eo(t)?t:null;let a=n?s||i:i||s;return a||(a=fa()||null),"boolean"==typeof o?a:ss(o)||a||null}(c);queueMicrotask(()=>{const t=(n=l)?wi(n)?n:Si(n)[0]||n:null;var n;const r="boolean"!=typeof a;if(a&&!D.current&&oo(t)&&(r||t===o||o===e.body||s)){const e={preventScroll:!0};"keyboard"===c&&(e.focusVisible=!0),t.focus(e)}D.current=!1})}},[o,x,Y,T,R,S,A,w,C,X]),Dr(()=>{if(!Ao||y||!x)return;const e=Po(uo(x));oo(e)&&Zo(e)&&No(x,e)&&e.blur()},[y,x]),Dr(()=>{if(!o&&_)return _.setFocusManagerState({modal:c,closeOnFocusOut:l,open:y,onOpenChange:g.setOpen,domReference:w}),()=>{_.setFocusManagerState(null)}},[o,_,c,y,g,l,w]),Dr(()=>{if(!o&&Y)return ma(Y),()=>{queueMicrotask(pa)}},[o,Y]);const G=!o&&(!c||!I)&&(V||c);/*#__PURE__*/
8
- return v(e.Fragment,{children:[G&&/*#__PURE__*/b(Ni,{"data-type":"inside",ref:W,onFocus:e=>{if(c){const e=K();Gs(e[e.length-1])}else _?.portalNode&&(D.current=!1,Ii(e,_.portalNode)?Ci(w)?.focus():ss(p??_.beforeOutsideRef)?.focus())}}),r,G&&/*#__PURE__*/b(Ni,{"data-type":"inside",ref:U,onFocus:e=>{c?Gs(K()[0]):_?.portalNode&&(l&&(D.current=!0),Ii(e,_.portalNode)?Ei(w)?.focus():ss(d??_.afterOutsideRef)?.focus())}})]})}function ya(){return!1}var ba={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},va=class extends Zr{constructor(e){const{syncOnly:t,nested:n,onOpenChange:r,triggerElements:o,...i}=e;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:aa(),nested:n,triggerElements:o},ba),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||null!=t&&function(e){const t=e.type;return"click"===t||"mousedown"===t||"keydown"===t||"keyup"===t}(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);const n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit("openchange",n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function wa(t,n=!1,r=!1,o=!1){const[i,s]=e.useState(t&&n?"idle":void 0),[a,c]=e.useState(t&&!o);return t&&!a&&(c(!0),s("starting")),t||!a||"ending"===i||r||s("ending"),t||a||"ending"!==i||s(void 0),Dr(()=>{if(!t&&a&&"ending"!==i&&r){const e=mo.request(()=>{s("ending")});return()=>{mo.cancel(e)}}},[t,a,i,r]),Dr(()=>{if(!t||n)return;const e=mo.request(()=>{s(void 0)});return()=>{mo.cancel(e)}},[n,t]),Dr(()=>{if(!t||!n)return;t&&a&&"idle"!==i&&s("starting");const e=mo.request(()=>{s("idle")});return()=>{mo.cancel(e)}},[n,t,a,i]),{mounted:a,setMounted:c,transitionStatus:i}}var xa={tabIndex:-1,[Fo]:""};function Sa({handle:e,store:t}){return Dr(()=>e.attachStore(t),[e,t]),null}var ka=class{constructor(){this.idMap=/* @__PURE__ */new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(const t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(const t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Ca(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new va({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Rr,inactiveTriggerProps:Rr,popupProps:Rr}}var Ea=e=>e.triggerIdProp??e.activeTriggerId,Ia=e=>e.openProp??e.open,Ma=e=>(e.popupElement?.id??e.floatingId)||void 0;function Ta(e,t){return void 0!==t&&Ia(e)&&Ea(e)===t}var Ra={open:Ia,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Ea,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Ma,isTriggerActive:(e,t)=>void 0!==t&&Ea(e)===t,isOpenedByTrigger:(e,t)=>Ta(e,t),isMountedByTrigger:(e,t)=>void 0!==t&&Ea(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>function(e,t){return!!Ta(e,t)||void 0!==t&&Ia(e)&&null==Ea(e)&&1===e.triggerCount}(e,t)?Ma(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},Oa=/*#__PURE__*/e.createContext(void 0);function Aa(){const t=Lr(),n=t.useState("toasts");return e.useMemo(()=>({toasts:n,add:t.addToast,close:t.closeToast,update:t.updateToast,promise:t.promiseToast}),[n,t])}var _a="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%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",Da={none:"0",sm:"calc(var(--radius) - 4px)",md:"calc(var(--radius) - 2px)",lg:"var(--radius)",xl:"calc(var(--radius) + 4px)",pill:"var(--radius-pill)"},Pa={default:"var(--foreground)",muted:"var(--foreground-muted)",faint:"var(--foreground-faint)",primary:"var(--primary)",inherit:"inherit"},Na={tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625"},La={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)"},Fa=2147483003,za={info:{background:"#f0f9ff",border:"1px solid #bae6fd",titleColor:"#0c4a6e",bodyColor:"#0369a1",closeColor:"#7dd3fc",actionBackground:"#e0f2fe"},error:{background:"#fef2f2",border:"1px solid #fecaca",titleColor:"#b91c1c",bodyColor:"#b91c1c",closeColor:"#f87171",actionBackground:"#fee2e2"},neutral:{background:"rgba(255, 255, 255, 0.95)",border:"1px solid rgba(255, 255, 255, 0.2)",titleColor:"#1f2937",bodyColor:"#1f2937",closeColor:"#6b7280",actionBackground:"transparent"}};function $a(e){if(e&&"none"!==e)return{boxShadow:La[e]}}var Ba={none:"0","2xs":"2px",xs:"4px",sm:"6px",md:"8px",lg:"12px",xl:"16px","2xl":"24px"},Wa={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},Ua={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around"},Ha={spin:"mtx-spin 1s linear infinite",ping:"mtx-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",pulse:"mtx-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",fadeIn:"mtx-fade-in 0.5s ease-out"},ja={top:"borderTopWidth",bottom:"borderBottomWidth",left:"borderLeftWidth",right:"borderRightWidth"},qa=/* @__PURE__ */new Set(["padding","paddingX","paddingY","paddingTop","paddingBottom","gap","align","justify","grow","shrink","position","inset","overflow","overflowY","width","height","minWidth","minHeight","border","rounded","animate","hidden","as","style"]);function Va(e){const t={};return void 0!==e.padding&&(t.padding=Ba[e.padding]),void 0!==e.paddingX&&(t.paddingLeft=Ba[e.paddingX],t.paddingRight=Ba[e.paddingX]),void 0!==e.paddingY&&(t.paddingTop=Ba[e.paddingY],t.paddingBottom=Ba[e.paddingY]),void 0!==e.paddingTop&&(t.paddingTop=Ba[e.paddingTop]),void 0!==e.paddingBottom&&(t.paddingBottom=Ba[e.paddingBottom]),void 0!==e.gap&&(t.gap=Ba[e.gap]),void 0!==e.align&&(t.alignItems=Wa[e.align]),void 0!==e.justify&&(t.justifyContent=Ua[e.justify]),!0===e.grow&&(t.flex="1 1 0%"),!1===e.shrink&&(t.flexShrink=0),void 0!==e.position&&(t.position=e.position),void 0!==e.inset&&(t.inset="0"===e.inset?"0":Ba[e.inset]),void 0!==e.overflow&&(t.overflow=e.overflow),void 0!==e.overflowY&&(t.overflowY=e.overflowY),void 0!==e.width&&(t.width="full"===e.width?"100%":"auto"),void 0!==e.height&&(t.height="full"===e.height?"100%":"auto"),"0"===e.minWidth&&(t.minWidth=0),"0"===e.minHeight&&(t.minHeight=0),void 0!==e.border&&!1!==e.border&&(t.borderColor="var(--border)",t.borderStyle="solid",!0===e.border?t.borderWidth="1px":t[ja[e.border]]="1px"),void 0!==e.rounded&&!1!==e.rounded&&(!0===e.rounded?t.borderRadius=Da.lg:t.borderRadius=Da[e.rounded]),void 0!==e.animate&&"none"!==e.animate&&(t.animation=Ha[e.animate]),!0===e.hidden&&(t.display="none"),t}var Ya=(e,t)=>t?`${e} ${t}`:e,Ka={sm:20,md:32,lg:48};function Xa(e){const{src:t,alt:n,elevation:r,fit:o="contain",size:i="md",rounded:s,className:a,style:c,ref:l,...u}=e,d="string"==typeof i?Ka[i]:i;/* @__PURE__ */
8
+ return v(e.Fragment,{children:[G&&/*#__PURE__*/b(Ni,{"data-type":"inside",ref:W,onFocus:e=>{if(c){const e=K();Gs(e[e.length-1])}else _?.portalNode&&(D.current=!1,Ii(e,_.portalNode)?Ci(w)?.focus():ss(p??_.beforeOutsideRef)?.focus())}}),r,G&&/*#__PURE__*/b(Ni,{"data-type":"inside",ref:U,onFocus:e=>{c?Gs(K()[0]):_?.portalNode&&(l&&(D.current=!0),Ii(e,_.portalNode)?Ei(w)?.focus():ss(d??_.afterOutsideRef)?.focus())}})]})}function ya(){return!1}var ba={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},va=class extends Zr{constructor(e){const{syncOnly:t,nested:n,onOpenChange:r,triggerElements:o,...i}=e;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:aa(),nested:n,triggerElements:o},ba),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||null!=t&&function(e){const t=e.type;return"click"===t||"mousedown"===t||"keydown"===t||"keyup"===t}(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);const n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit("openchange",n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function wa(t,n=!1,r=!1,o=!1){const[i,s]=e.useState(t&&n?"idle":void 0),[a,c]=e.useState(t&&!o);return t&&!a&&(c(!0),s("starting")),t||!a||"ending"===i||r||s("ending"),t||a||"ending"!==i||s(void 0),Dr(()=>{if(!t&&a&&"ending"!==i&&r){const e=mo.request(()=>{s("ending")});return()=>{mo.cancel(e)}}},[t,a,i,r]),Dr(()=>{if(!t||n)return;const e=mo.request(()=>{s(void 0)});return()=>{mo.cancel(e)}},[n,t]),Dr(()=>{if(!t||!n)return;t&&a&&"idle"!==i&&s("starting");const e=mo.request(()=>{s("idle")});return()=>{mo.cancel(e)}},[n,t,a,i]),{mounted:a,setMounted:c,transitionStatus:i}}var xa={tabIndex:-1,[Fo]:""};function Sa({handle:e,store:t}){return Dr(()=>e.attachStore(t),[e,t]),null}var ka=class{constructor(){this.idMap=/* @__PURE__ */new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(const t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(const t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Ca(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new va({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Rr,inactiveTriggerProps:Rr,popupProps:Rr}}var Ea=e=>e.triggerIdProp??e.activeTriggerId,Ia=e=>e.openProp??e.open,Ma=e=>(e.popupElement?.id??e.floatingId)||void 0;function Ta(e,t){return void 0!==t&&Ia(e)&&Ea(e)===t}var Ra={open:Ia,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Ea,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Ma,isTriggerActive:(e,t)=>void 0!==t&&Ea(e)===t,isOpenedByTrigger:(e,t)=>Ta(e,t),isMountedByTrigger:(e,t)=>void 0!==t&&Ea(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>function(e,t){return!!Ta(e,t)||void 0!==t&&Ia(e)&&null==Ea(e)&&1===e.triggerCount}(e,t)?Ma(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},Oa=/*#__PURE__*/e.createContext(void 0);function Aa(){const t=Lr(),n=t.useState("toasts");return e.useMemo(()=>({toasts:n,add:t.addToast,close:t.closeToast,update:t.updateToast,promise:t.promiseToast}),[n,t])}var _a="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%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",Da={none:"0",sm:"calc(var(--radius) - 4px)",md:"calc(var(--radius) - 2px)",lg:"var(--radius)",xl:"calc(var(--radius) + 4px)",pill:"var(--radius-pill)"},Pa={default:"var(--foreground)",muted:"var(--foreground-muted)",faint:"var(--foreground-faint)",inherit:"inherit"},Na={tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625"},La={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)"},Fa=2147483003,za={info:{background:"#f0f9ff",border:"1px solid #bae6fd",titleColor:"#0c4a6e",bodyColor:"#0369a1",closeColor:"#7dd3fc",actionBackground:"#e0f2fe"},error:{background:"#fef2f2",border:"1px solid #fecaca",titleColor:"#b91c1c",bodyColor:"#b91c1c",closeColor:"#f87171",actionBackground:"#fee2e2"},neutral:{background:"rgba(255, 255, 255, 0.95)",border:"1px solid rgba(255, 255, 255, 0.2)",titleColor:"#1f2937",bodyColor:"#1f2937",closeColor:"#6b7280",actionBackground:"transparent"}};function $a(e){if(e&&"none"!==e)return{boxShadow:La[e]}}var Ba={none:"0","2xs":"2px",xs:"4px",sm:"6px",md:"8px",lg:"12px",xl:"16px","2xl":"24px"},Wa={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},Ua={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around"},Ha={spin:"mtx-spin 1s linear infinite",ping:"mtx-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",pulse:"mtx-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",fadeIn:"mtx-fade-in 0.5s ease-out"},ja={top:"borderTopWidth",bottom:"borderBottomWidth",left:"borderLeftWidth",right:"borderRightWidth"},qa=/* @__PURE__ */new Set(["padding","paddingX","paddingY","paddingTop","paddingBottom","gap","align","justify","grow","shrink","position","inset","overflow","overflowY","width","height","minWidth","minHeight","border","rounded","animate","hidden","as","style"]);function Va(e){const t={};return void 0!==e.padding&&(t.padding=Ba[e.padding]),void 0!==e.paddingX&&(t.paddingLeft=Ba[e.paddingX],t.paddingRight=Ba[e.paddingX]),void 0!==e.paddingY&&(t.paddingTop=Ba[e.paddingY],t.paddingBottom=Ba[e.paddingY]),void 0!==e.paddingTop&&(t.paddingTop=Ba[e.paddingTop]),void 0!==e.paddingBottom&&(t.paddingBottom=Ba[e.paddingBottom]),void 0!==e.gap&&(t.gap=Ba[e.gap]),void 0!==e.align&&(t.alignItems=Wa[e.align]),void 0!==e.justify&&(t.justifyContent=Ua[e.justify]),!0===e.grow&&(t.flex="1 1 0%"),!1===e.shrink&&(t.flexShrink=0),void 0!==e.position&&(t.position=e.position),void 0!==e.inset&&(t.inset="0"===e.inset?"0":Ba[e.inset]),void 0!==e.overflow&&(t.overflow=e.overflow),void 0!==e.overflowY&&(t.overflowY=e.overflowY),void 0!==e.width&&(t.width="full"===e.width?"100%":"auto"),void 0!==e.height&&(t.height="full"===e.height?"100%":"auto"),"0"===e.minWidth&&(t.minWidth=0),"0"===e.minHeight&&(t.minHeight=0),void 0!==e.border&&!1!==e.border&&(t.borderColor="var(--border)",t.borderStyle="solid",!0===e.border?t.borderWidth="1px":t[ja[e.border]]="1px"),void 0!==e.rounded&&!1!==e.rounded&&(!0===e.rounded?t.borderRadius=Da.lg:t.borderRadius=Da[e.rounded]),void 0!==e.animate&&"none"!==e.animate&&(t.animation=Ha[e.animate]),!0===e.hidden&&(t.display="none"),t}var Ya=(e,t)=>t?`${e} ${t}`:e,Ka={sm:20,md:32,lg:48};function Xa(e){const{src:t,alt:n,elevation:r,fit:o="contain",size:i="md",rounded:s,className:a,style:c,ref:l,...u}=e,d="string"==typeof i?Ka[i]:i;/* @__PURE__ */
9
9
  return b("img",{...u,ref:l,alt:n,className:Ya("mtx-avatar",a),src:t,style:{objectFit:o,width:d,height:d,...Va({rounded:s}),...$a(r),...c}})}var Ga=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,disabled:o=!1,focusableWhenDisabled:i=!1,nativeButton:s=!0,style:a,...c}=e,{getButtonProps:l,buttonRef:u}=As({disabled:o,focusableWhenDisabled:i,native:s});return Qi("button",e,{state:{disabled:o},ref:[t,u],props:[c,l]})}),Ja={default:Da.lg,pill:Da.pill};function Za({className:e,disabled:t,elevation:n,full:r,shape:o="default",size:i="md",stacked:s=!1,type:a="button",variant:c="primary",style:l,ref:u,...d}){/* @__PURE__ */
10
10
  return b(Ga,{...d,ref:u,className:Ya("mtx-button",e),"data-disabled":t?"true":"false","data-full":r?"true":"false","data-size":i,"data-stacked":s?"true":"false","data-variant":c,disabled:t,style:{borderRadius:Ja[o],...$a(n),...l},type:a})}var Qa={default:{},card:{backgroundColor:"var(--card)",color:"var(--card-foreground)"}},ec={none:{},card:{padding:"8px 12px"},toast:{padding:"8px 12px 8px 8px"}},tc={floatingCard:{background:"card",border:!0,elevation:"card",paddingPreset:"card",rounded:"xl"}},nc={floatingCard:{margin:"0 12px 12px 12px"}},rc=o(function(e,t){const{as:n="div",className:r,style:o,variant:i,...s}=e,a=i?{...tc[i],...s}:s,{background:c="default",elevation:l,paddingPreset:u="none",...d}=a,p=function(e){const t={};for(const n in e)qa.has(n)||(t[n]=e[n]);return t}(d);/* @__PURE__ */
11
11
  return b(n,{...p,ref:t,className:r,style:{...Qa[c],...ec[u],...$a(l),...Va(a),...i&&nc[i],...o}})}),oc=o(function(e,t){const{direction:n,hidden:r,style:o,...i}=e;/* @__PURE__ */
@@ -38,28 +38,28 @@ return v(vu.Provider,{value:k,children:[d&&/*#__PURE__*/b(Sa,{handle:d,store:k})
38
38
  return b($u,{open:e,onOpenChange:(e,n)=>{e||"none"===n.reason||t()},children:/* @__PURE__ */v(Ru,{container:l,children:[/* @__PURE__ */b(xu,{className:"mtx-dialog-backdrop",style:{zIndex:Fa}}),/* @__PURE__ */v(Mu,{className:"mtx-dialog-popup",finalFocus:c,style:{...$a("panel"),zIndex:Fa},children:[
39
39
  /* @__PURE__ */b(Bu,{className:"mtx-dialog-title",children:n}),null!=r&&/* @__PURE__ */b(Su,{className:"mtx-dialog-description",children:r}),
40
40
  /* @__PURE__ */b(oc,{gap:"md",justify:"end",children:[["secondary",a,t],["primary",i,()=>o?.()]].map(([e,t,n])=>/* @__PURE__ */b(Za,{type:"button",variant:e,size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:t},e))})]})]})})},Uu={sm:{width:"14px",height:"14px",borderWidth:"1.5px"},md:{width:"20px",height:"20px",borderWidth:"2px"},lg:{width:"24px",height:"24px",borderWidth:"2px"}};function Hu({size:e="md",style:t,ref:n}){/* @__PURE__ */
41
- return v("div",{ref:n,"data-size":e,role:"status",style:{display:"inline-flex",alignItems:"center",gap:"6px",...t},children:[/* @__PURE__ */b("div",{"aria-hidden":"true",className:"mtx-spinner-ring",style:Uu[e]}),/* @__PURE__ */b("span",{className:"mtx-visually-hidden",children:"Loading"})]})}var ju="8px 8px 0 0",qu=({label:e,children:t})=>/* @__PURE__ */b(oc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:"var(--overlay-dark)",borderRadius:ju,zIndex:10},children:/* @__PURE__ */v(oc,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",padding:"0 16px"},children:[t,/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"medium",style:{color:"rgba(255,255,255,0.7)"},children:e})]})}),Vu=({stream:e})=>{const t=d(null),[n,r]=p(!1),[o,i]=p(!1);return a(()=>{const n=t.current;if(!n)return;r(!1),i(!1),n.srcObject=e;const o=()=>{r(!0)},s=()=>{i(!0),r(!1)};return n.addEventListener("loadedmetadata",o),n.addEventListener("error",s),n.play().catch(e=>{e instanceof Error&&"AbortError"!==e.name&&(console.error("Error playing video stream:",e),i(!0))}),()=>{n.removeEventListener("loadedmetadata",o),n.removeEventListener("error",s),n.srcObject=null}},[e]),/* @__PURE__ */v(rc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:ju,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!n&&!o&&/* @__PURE__ */b(qu,{label:"Loading stream...",children:/* @__PURE__ */b(Hu,{size:"lg",style:{color:"white"}})}),o&&/* @__PURE__ */b(qu,{label:"Failed to load stream",children:/* @__PURE__ */b(cc,{name:"alertCircle",size:32,style:{color:"#9ca3af"}})}),
42
- /* @__PURE__ */b("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:ju,transition:"opacity 500ms",opacity:n?1:0,minHeight:"120px",background:"linear-gradient(135deg, var(--overlay-dark) 0%, #374151 100%)"}}),n&&!o&&/* @__PURE__ */v(oc,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"var(--radius-pill)",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px var(--foreground-faint)"},children:[/* @__PURE__ */b(mu,{style:{color:"white"}}),/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
43
- /* @__PURE__ */b(oc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:ju,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */b(rc,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */b(hc,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]})},Yu={done:{name:"checkCircle",opacity:1},failed:{name:"exclamationCircle",opacity:.75},stopped:{name:"circle",opacity:.5}},Ku=({isWaitingForUser:e})=>/* @__PURE__ */v(oc,{align:"center",gap:"sm",paddingY:"2xs",children:[/* @__PURE__ */b(Hu,{size:"sm"}),/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Xu=({message:e,isLastMessage:t,isTaskRunning:n})=>{const r="waiting-for-user"===e.placeholderState,o=n&&t&&("show"===e.mode||"do"===e.mode);return 0===e.parts.length?e.isPlaceholder||o?/* @__PURE__ */b(Ku,{isWaitingForUser:r}):/* @__PURE__ */b(rc,{}):/* @__PURE__ */v(ic,{gap:"sm",children:[e.parts.map((e,t)=>"text"===e.type?e.content?/* @__PURE__ */b(hc,{as:"div",size:"sm",weight:"medium",style:{wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e.content},`part-${t}`):null:"progress"===e.type?/* @__PURE__ */b(oc,{align:"start",gap:"md",children:/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap"},children:e.content})},`part-${t}`):null),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||o)&&/* @__PURE__ */b(Ku,{isWaitingForUser:r})]})},Gu=t.memo(({message:e,isLastMessage:t,isTaskRunning:n,onScreenAccessAllow:r,onScreenAccessDeny:o})=>{const i=El().widget_accent_color;if(e.isSystemMessage)/* @__PURE__ */return b(oc,{justify:"center",align:"center",children:/* @__PURE__ */b(hc,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})});const s="user"===e.sender,a=s?"show"===e.mode||"do"===e.mode?"mousePointerClick":void 0:e.isScreenAccessRequest||"waiting-for-user"===e.placeholderState?"checkCircle":void 0,c=!s&&e.taskStatus?Yu[e.taskStatus]:void 0;/* @__PURE__ */
41
+ return v("div",{ref:n,"data-size":e,role:"status",style:{display:"inline-flex",alignItems:"center",gap:"6px",...t},children:[/* @__PURE__ */b("div",{"aria-hidden":"true",className:"mtx-spinner-ring",style:Uu[e]}),/* @__PURE__ */b("span",{className:"mtx-visually-hidden",children:"Loading"})]})}var ju="8px 8px 0 0",qu="#ffffff",Vu=({label:e,children:t})=>/* @__PURE__ */b(oc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:"var(--overlay-dark)",borderRadius:ju,zIndex:10},children:/* @__PURE__ */v(oc,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",padding:"0 16px"},children:[t,/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"medium",style:{color:"rgba(255,255,255,0.7)"},children:e})]})}),Yu=({stream:e})=>{const t=d(null),[n,r]=p(!1),[o,i]=p(!1);return a(()=>{const n=t.current;if(!n)return;r(!1),i(!1),n.srcObject=e;const o=()=>{r(!0)},s=()=>{i(!0),r(!1)};return n.addEventListener("loadedmetadata",o),n.addEventListener("error",s),n.play().catch(e=>{e instanceof Error&&"AbortError"!==e.name&&(console.error("Error playing video stream:",e),i(!0))}),()=>{n.removeEventListener("loadedmetadata",o),n.removeEventListener("error",s),n.srcObject=null}},[e]),/* @__PURE__ */v(rc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:ju,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!n&&!o&&/* @__PURE__ */b(Vu,{label:"Loading stream...",children:/* @__PURE__ */b(Hu,{size:"lg",style:{color:qu}})}),o&&/* @__PURE__ */b(Vu,{label:"Failed to load stream",children:/* @__PURE__ */b(cc,{name:"alertCircle",size:32,style:{color:"#9ca3af"}})}),
42
+ /* @__PURE__ */b("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:ju,transition:"opacity 500ms",opacity:n?1:0,minHeight:"120px",background:"linear-gradient(135deg, var(--overlay-dark) 0%, #374151 100%)"}}),n&&!o&&/* @__PURE__ */v(oc,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"var(--radius-pill)",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px var(--foreground-faint)"},children:[/* @__PURE__ */b(mu,{style:{color:qu}}),/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"semibold",style:{color:qu,textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
43
+ /* @__PURE__ */b(oc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:ju,backgroundColor:"transparent",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */b(rc,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */b(hc,{as:"div",size:"xs",weight:"medium",style:{color:qu},children:"Screen Sharing Active"})})})]})},Ku={done:{name:"checkCircle",opacity:1},failed:{name:"exclamationCircle",opacity:.75},stopped:{name:"circle",opacity:.5}},Xu=({isWaitingForUser:e})=>/* @__PURE__ */v(oc,{align:"center",gap:"sm",paddingY:"2xs",children:[/* @__PURE__ */b(Hu,{size:"sm"}),/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Gu=({message:e,isLastMessage:t,isTaskRunning:n})=>{const r="waiting-for-user"===e.placeholderState,o=n&&t&&("show"===e.mode||"do"===e.mode);return 0===e.parts.length?e.isPlaceholder||o?/* @__PURE__ */b(Xu,{isWaitingForUser:r}):/* @__PURE__ */b(rc,{}):/* @__PURE__ */v(ic,{gap:"sm",children:[e.parts.map((e,t)=>"text"===e.type?e.content?/* @__PURE__ */b(hc,{as:"div",size:"sm",weight:"medium",style:{wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e.content},`part-${t}`):null:"progress"===e.type?/* @__PURE__ */b(oc,{align:"start",gap:"md",children:/* @__PURE__ */b(hc,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap"},children:e.content})},`part-${t}`):null),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||o)&&/* @__PURE__ */b(Xu,{isWaitingForUser:r})]})},Ju=t.memo(({message:e,isLastMessage:t,isTaskRunning:n,onScreenAccessAllow:r,onScreenAccessDeny:o})=>{const i=El().widget_accent_color;if(e.isSystemMessage)/* @__PURE__ */return b(oc,{justify:"center",align:"center",children:/* @__PURE__ */b(hc,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})});const s="user"===e.sender,a=s?"show"===e.mode||"do"===e.mode?"mousePointerClick":void 0:e.isScreenAccessRequest||"waiting-for-user"===e.placeholderState?"checkCircle":void 0,c=!s&&e.taskStatus?Ku[e.taskStatus]:void 0;/* @__PURE__ */
44
44
  return v(ic,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":s?"You said…":"Assistant says…",animate:t?"fadeIn":void 0,children:[/* @__PURE__ */v(oc,{align:"start",gap:"sm",width:"full",children:[
45
45
  /* @__PURE__ */b(oc,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!s&&/* @__PURE__ */b(Xa,{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%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:"lg",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
46
- /* @__PURE__ */v(ic,{grow:!0,position:"relative",rounded:"lg",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:s?"var(--primary)":void 0,color:s?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */b(Vu,{stream:e.videoStream}),!e.videoStream&&(a?/* @__PURE__ */v(oc,{align:"start",gap:"sm",children:[/* @__PURE__ */b(oc,{shrink:!1,style:{marginTop:"3px"},children:/* @__PURE__ */b(cc,{name:a,size:13})}),/* @__PURE__ */b(ic,{grow:!0,children:/* @__PURE__ */b(Xu,{message:e,isLastMessage:t,isTaskRunning:n})})]}):/* @__PURE__ */b(Xu,{message:e,isLastMessage:t,isTaskRunning:n})),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */v(oc,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */b(Za,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */b(Za,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>o?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */b(hc,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"No"}),c&&/* @__PURE__ */b(oc,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */b(cc,{name:c.name,size:14,style:{color:xl(i,c.opacity),flexShrink:0}})})]}),
47
- /* @__PURE__ */b(oc,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */b(hc,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:(l=e.timestamp,(l??/* @__PURE__ */new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}))})]});var l}),Ju={boxShadow:La.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Zu=({messagesEndRef:e,onScreenAccessAllow:t,onScreenAccessDeny:n})=>{const r=El(),{state:o,actions:i}=Il(),{messages:s,isTaskRunning:c}=o,{isPreviewMode:l}=r,[h,f]=p(!1),[m,g]=p(!1),y=d(null),w=u(()=>Yc(r.widget_body),[r.widget_body]),x=u(()=>[w,...s],[w,s]),S=()=>{if(y.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=y.current;f(e>200);const r=Math.abs(t-e-n)<50;g(!r&&t>n)}};a(()=>{window.requestAnimationFrame(()=>{e.current&&(!l&&e.current.scrollIntoView({behavior:"auto"}),!l&&S())})},[s.length,l,e]);const k=s[s.length-1]?.content?.length??0;return a(()=>{const t=y.current;t&&!l&&t.scrollHeight-t.scrollTop-t.clientHeight<120&&window.requestAnimationFrame(()=>e.current?.scrollIntoView({behavior:"auto"}))},[k,l,e]),/* @__PURE__ */v(rc,{position:"relative",height:"full",children:[/* @__PURE__ */v(rc,{ref:y,onScroll:S,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:r.widget_background_color.includes("gradient")?"transparent":r.widget_background_color,backgroundImage:Sl(r.widget_background_color),scrollbarColor:`${xl(r.widget_border_color,.3)} ${xl(r.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[x.map((e,r)=>/* @__PURE__ */b(Gu,{message:e,isLastMessage:r===x.length-1,isTaskRunning:c,onScreenAccessAllow:t,onScreenAccessDeny:n},e.id)),s.length>0&&/* @__PURE__ */b(oc,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */b(Za,{type:"button",variant:"bare",onClick:i.clearChatHistory,children:/* @__PURE__ */b(hc,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
48
- /* @__PURE__ */b(rc,{ref:e},"scroll-anchor")]},"message-list-container"),[{show:h,edge:{top:"8px"},label:"Scroll to top",icon:"arrowUp",onClick:()=>y.current?.scrollTo({top:0,behavior:"smooth"})},{show:m,edge:{bottom:"8px"},label:"Scroll to bottom",icon:"arrowDown",onClick:()=>!l&&e.current?.scrollIntoView({behavior:"smooth"})}].map(({show:e,edge:t,label:n,icon:o,onClick:i})=>e&&/* @__PURE__ */b(oc,{position:"absolute",justify:"center",style:{...t,left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */b(lc,{variant:"secondary",size:"sm",label:n,onClick:i,style:Ju,children:/* @__PURE__ */b(cc,{name:o,size:10,style:{color:r.widget_accent_color}})})},n))]})},Qu=[{id:"tell",icon:"chatBubble",flag:"widget_feature_tell"},{id:"show",icon:"mousePointerClick",flag:"widget_feature_show"},{id:"do",icon:"ticktick",flag:"widget_feature_do"}];function ed(e){const t=d(e);return t.current=e,t}var td=({onScreenSharingChange:e,toggleScreenShareRef:t,messageInputRef:n})=>{const r=El(),{state:o,actions:s}=Il(),{currentMode:l,isTaskRunning:u,isAwaitingReply:h}=o,[f,m]=p(""),g=d(null),{isScreenSharing:y,isAwaitingScreenAccess:w,showScreenAccessDialog:x,handleScreenAccessDialogAllow:S,handleScreenAccessDialogDismiss:k,handleScreenAccessRequestAllow:C,handleScreenAccessRequestDeny:E,requestScreenAccess:I}=function({onScreenSharingChange:e,toggleScreenShareRef:t,onAddMessage:n,onUpdateMessage:r,onRemoveMessage:o,onSendMessage:s,messages:l}){const[u,d]=p(!1),[h,f]=p(null),[m,g]=p(!1),y=ed(u),b=ed(h),v=ed(e),w=t=>{d(t),e?.(t)},x=e=>{e&&o?.(e),n(Kc("Screen sharing stopped","stopped-sharing")),f(null)},S=ed(x);a(()=>{const e=()=>{const e=null!==gr(),t=y.current,n=b.current;e!==t&&(y.current=e,d(e),v.current?.(e)),t&&!e&&n&&S.current(n)};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[S,v,b,y]);const k=l[Bc(l,e=>!!e.isScreenAccessRequest&&!e.screenShareStatus)]??null,C=()=>{k?.pendingContent&&s(k.pendingContent,k.mode,!0)},E=e=>{k&&r(k.id,{screenShareStatus:e})},I=async()=>{try{const e=await async function(){if(!1===$e.getContext().config?.use_screenshare)throw new Error("Screen sharing is disabled for this widget");const e=gr();if(e)return e;const t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!t||0===t.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return mr=t,t.getVideoTracks()[0]?.addEventListener("ended",()=>{mr=null}),t}();w(!0),E("allowed"),n(Kc("Screen sharing started","started-screenshare"));const t=((e,t="show")=>qc("screenshare","user","",{mode:t,videoStream:e}))(e,"show");f(t.id),n(t)}catch(e){console.error("Failed to start screen sharing:",e),w(!1),E("denied")}C()},M=ed(I),T=i(()=>M.current(),[M]),R=ed(()=>{E("denied"),C()}),O=i(()=>R.current(),[R]);return c(t,()=>()=>{u?(yr(),w(!1),x(h)):g(!0)}),{isScreenSharing:u,isAwaitingScreenAccess:null!==k,showScreenAccessDialog:m,handleScreenAccessDialogAllow:async()=>{g(!1),await I()},handleScreenAccessDialogDismiss:()=>{g(!1)},handleScreenAccessRequestAllow:T,handleScreenAccessRequestDeny:O,requestScreenAccess:(e,t)=>{k||n(((e,t)=>qc("screen-access-request","agent","Can I take a look at your screen?",{mode:e,isScreenAccessRequest:!0,pendingContent:t}))(e,t))}}}({onScreenSharingChange:e,toggleScreenShareRef:t,onAddMessage:s.addMessage,onUpdateMessage:s.updateMessage,onRemoveMessage:s.removeMessage,onSendMessage:s.messageDispatch,messages:o.messages}),M=w||h;/* @__PURE__ */
46
+ /* @__PURE__ */v(ic,{grow:!0,position:"relative",rounded:"lg",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:s?"var(--primary)":void 0,color:s?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */b(Yu,{stream:e.videoStream}),!e.videoStream&&(a?/* @__PURE__ */v(oc,{align:"start",gap:"sm",children:[/* @__PURE__ */b(oc,{shrink:!1,style:{marginTop:"3px"},children:/* @__PURE__ */b(cc,{name:a,size:13})}),/* @__PURE__ */b(ic,{grow:!0,children:/* @__PURE__ */b(Gu,{message:e,isLastMessage:t,isTaskRunning:n})})]}):/* @__PURE__ */b(Gu,{message:e,isLastMessage:t,isTaskRunning:n})),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */v(oc,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */b(Za,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */b(Za,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>o?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */b(hc,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"No"}),c&&/* @__PURE__ */b(oc,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */b(cc,{name:c.name,size:14,style:{color:xl(i,c.opacity),flexShrink:0}})})]}),
47
+ /* @__PURE__ */b(oc,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */b(hc,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:(l=e.timestamp,(l??/* @__PURE__ */new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}))})]});var l}),Zu={boxShadow:La.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Qu=({messagesEndRef:e,onScreenAccessAllow:t,onScreenAccessDeny:n})=>{const r=El(),{state:o,actions:i}=Il(),{messages:s,isTaskRunning:c}=o,{isPreviewMode:l}=r,[h,f]=p(!1),[m,g]=p(!1),y=d(null),w=u(()=>Yc(r.widget_body),[r.widget_body]),x=u(()=>[w,...s],[w,s]),S=()=>{if(y.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=y.current;f(e>200);const r=Math.abs(t-e-n)<50;g(!r&&t>n)}};a(()=>{window.requestAnimationFrame(()=>{e.current&&(!l&&e.current.scrollIntoView({behavior:"auto"}),!l&&S())})},[s.length,l,e]);const k=s[s.length-1]?.content?.length??0;return a(()=>{const t=y.current;t&&!l&&t.scrollHeight-t.scrollTop-t.clientHeight<120&&window.requestAnimationFrame(()=>e.current?.scrollIntoView({behavior:"auto"}))},[k,l,e]),/* @__PURE__ */v(rc,{position:"relative",height:"full",children:[/* @__PURE__ */v(rc,{ref:y,onScroll:S,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:r.widget_background_color.includes("gradient")?"transparent":r.widget_background_color,backgroundImage:Sl(r.widget_background_color),scrollbarColor:`${xl(r.widget_border_color,.3)} ${xl(r.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[x.map((e,r)=>/* @__PURE__ */b(Ju,{message:e,isLastMessage:r===x.length-1,isTaskRunning:c,onScreenAccessAllow:t,onScreenAccessDeny:n},e.id)),s.length>0&&/* @__PURE__ */b(oc,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */b(Za,{type:"button",variant:"bare",onClick:i.clearChatHistory,children:/* @__PURE__ */b(hc,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
48
+ /* @__PURE__ */b(rc,{ref:e},"scroll-anchor")]},"message-list-container"),[{show:h,edge:{top:"8px"},label:"Scroll to top",icon:"arrowUp",onClick:()=>y.current?.scrollTo({top:0,behavior:"smooth"})},{show:m,edge:{bottom:"8px"},label:"Scroll to bottom",icon:"arrowDown",onClick:()=>!l&&e.current?.scrollIntoView({behavior:"smooth"})}].map(({show:e,edge:t,label:n,icon:o,onClick:i})=>e&&/* @__PURE__ */b(oc,{position:"absolute",justify:"center",style:{...t,left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */b(lc,{variant:"secondary",size:"sm",label:n,onClick:i,style:Zu,children:/* @__PURE__ */b(cc,{name:o,size:10,style:{color:r.widget_accent_color}})})},n))]})},ed=[{id:"tell",icon:"chatBubble",flag:"widget_feature_tell"},{id:"show",icon:"mousePointerClick",flag:"widget_feature_show"},{id:"do",icon:"ticktick",flag:"widget_feature_do"}];function td(e){const t=d(e);return t.current=e,t}var nd=({onScreenSharingChange:e,toggleScreenShareRef:t,messageInputRef:n})=>{const r=El(),{state:o,actions:s}=Il(),{currentMode:l,isTaskRunning:u,isAwaitingReply:h}=o,[f,m]=p(""),g=d(null),{isScreenSharing:y,isAwaitingScreenAccess:w,showScreenAccessDialog:x,handleScreenAccessDialogAllow:S,handleScreenAccessDialogDismiss:k,handleScreenAccessRequestAllow:C,handleScreenAccessRequestDeny:E,requestScreenAccess:I}=function({onScreenSharingChange:e,toggleScreenShareRef:t,onAddMessage:n,onUpdateMessage:r,onRemoveMessage:o,onSendMessage:s,messages:l}){const[u,d]=p(!1),[h,f]=p(null),[m,g]=p(!1),y=td(u),b=td(h),v=td(e),w=t=>{d(t),e?.(t)},x=e=>{e&&o?.(e),n(Kc("Screen sharing stopped","stopped-sharing")),f(null)},S=td(x);a(()=>{const e=()=>{const e=null!==gr(),t=y.current,n=b.current;e!==t&&(y.current=e,d(e),v.current?.(e)),t&&!e&&n&&S.current(n)};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[S,v,b,y]);const k=l[Bc(l,e=>!!e.isScreenAccessRequest&&!e.screenShareStatus)]??null,C=()=>{k?.pendingContent&&s(k.pendingContent,k.mode,!0)},E=e=>{k&&r(k.id,{screenShareStatus:e})},I=async()=>{try{const e=await async function(){if(!1===$e.getContext().config?.use_screenshare)throw new Error("Screen sharing is disabled for this widget");const e=gr();if(e)return e;const t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!t||0===t.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return mr=t,t.getVideoTracks()[0]?.addEventListener("ended",()=>{mr=null}),t}();w(!0),E("allowed"),n(Kc("Screen sharing started","started-screenshare"));const t=((e,t="show")=>qc("screenshare","user","",{mode:t,videoStream:e}))(e,"show");f(t.id),n(t)}catch(e){console.error("Failed to start screen sharing:",e),w(!1),E("denied")}C()},M=td(I),T=i(()=>M.current(),[M]),R=td(()=>{E("denied"),C()}),O=i(()=>R.current(),[R]);return c(t,()=>()=>{u?(yr(),w(!1),x(h)):g(!0)}),{isScreenSharing:u,isAwaitingScreenAccess:null!==k,showScreenAccessDialog:m,handleScreenAccessDialogAllow:async()=>{g(!1),await I()},handleScreenAccessDialogDismiss:()=>{g(!1)},handleScreenAccessRequestAllow:T,handleScreenAccessRequestDeny:O,requestScreenAccess:(e,t)=>{k||n(((e,t)=>qc("screen-access-request","agent","Can I take a look at your screen?",{mode:e,isScreenAccessRequest:!0,pendingContent:t}))(e,t))}}}({onScreenSharingChange:e,toggleScreenShareRef:t,onAddMessage:s.addMessage,onUpdateMessage:s.updateMessage,onRemoveMessage:s.removeMessage,onSendMessage:s.messageDispatch,messages:o.messages}),M=w||h;/* @__PURE__ */
49
49
  return v(ic,{height:"full",children:[x&&/* @__PURE__ */b(Wu,{open:x,onClose:k,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:S,confirmLabel:"Yes",cancelLabel:"No",finalFocusRef:n}),
50
- /* @__PURE__ */b(ic,{grow:!0,overflow:"hidden",paddingY:"2xs",minHeight:"0",children:/* @__PURE__ */b(Dl,{label:"Chat",fallback:/* @__PURE__ */b(hc,{as:"div",size:"xs",align:"center",variant:"muted",style:{padding:"16px"},children:"Something went wrong displaying messages. Please refresh."}),children:/* @__PURE__ */b(Zu,{messagesEndRef:g,onScreenAccessAllow:C,onScreenAccessDeny:E})})}),
51
- /* @__PURE__ */b(rc,{variant:"floatingCard",style:{marginTop:"auto"},children:/* @__PURE__ */b(bu,{ref:n,value:f,onChange:m,onSubmit:()=>{if(!f.trim()||M)return;const e=f.trim();m(""),s.addMessage(Vc(e,l)),!1===r.use_screenshare||"show"!==l&&"do"!==l||y?s.messageDispatch(e,l,!0):I(l,e)},modes:Qu.filter(({flag:e})=>r[e]).map(({id:e,icon:t})=>({id:e,icon:t,label:$c(e)})),activeMode:l,onModeChange:e=>{e!==l&&(s.addMessage(Kc(`Switched to ${$c(e)} mode`,"mode-change")),s.setMode(e))},disabled:M,taskRunning:u,onStop:()=>{Ac.cleanup(),s.stopTask()}})})]})},nd=[{id:"show-add-product",text:"Show me how to add a new product",type:"show"},{id:"show-login",text:"Show me how to login",type:"show"},{id:"do-login",text:"Do the login process for me",type:"do"},{id:"show-revenue",text:"Show me the revenue metrics",type:"show"},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",type:"tell"}],rd=({onNavigateToChat:e,onChipClick:t})=>{const n=El(),{messages:r}=Il().state,o=function(e){const t=e.widget_chips;return t?.length?t.map((e,t)=>({id:`chip-${e.chip_text.replace(/\s+/g,"-").toLowerCase()}-${t}`,text:"show"===e.chip_mode?`Show me ${e.chip_text.replace(/^Show me\s+/i,"")}`:"do"===e.chip_mode?`Do ${e.chip_text.replace(/^Do\s+/i,"")}`:e.chip_text,type:e.chip_mode})):nd}(n);/* @__PURE__ */
50
+ /* @__PURE__ */b(ic,{grow:!0,overflow:"hidden",paddingY:"2xs",minHeight:"0",children:/* @__PURE__ */b(Dl,{label:"Chat",fallback:/* @__PURE__ */b(hc,{as:"div",size:"xs",align:"center",variant:"muted",style:{padding:"16px"},children:"Something went wrong displaying messages. Please refresh."}),children:/* @__PURE__ */b(Qu,{messagesEndRef:g,onScreenAccessAllow:C,onScreenAccessDeny:E})})}),
51
+ /* @__PURE__ */b(rc,{variant:"floatingCard",style:{marginTop:"auto"},children:/* @__PURE__ */b(bu,{ref:n,value:f,onChange:m,onSubmit:()=>{if(!f.trim()||M)return;const e=f.trim();m(""),s.addMessage(Vc(e,l)),!1===r.use_screenshare||"show"!==l&&"do"!==l||y?s.messageDispatch(e,l,!0):I(l,e)},modes:ed.filter(({flag:e})=>r[e]).map(({id:e,icon:t})=>({id:e,icon:t,label:$c(e)})),activeMode:l,onModeChange:e=>{e!==l&&(s.addMessage(Kc(`Switched to ${$c(e)} mode`,"mode-change")),s.setMode(e))},disabled:M,taskRunning:u,onStop:()=>{Ac.cleanup(),s.stopTask()}})})]})},rd=[{id:"show-add-product",text:"Show me how to add a new product",type:"show"},{id:"show-login",text:"Show me how to login",type:"show"},{id:"do-login",text:"Do the login process for me",type:"do"},{id:"show-revenue",text:"Show me the revenue metrics",type:"show"},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",type:"tell"}],od=({onNavigateToChat:e,onChipClick:t})=>{const n=El(),{messages:r}=Il().state,o=function(e){const t=e.widget_chips;return t?.length?t.map((e,t)=>({id:`chip-${e.chip_text.replace(/\s+/g,"-").toLowerCase()}-${t}`,text:"show"===e.chip_mode?`Show me ${e.chip_text.replace(/^Show me\s+/i,"")}`:"do"===e.chip_mode?`Do ${e.chip_text.replace(/^Do\s+/i,"")}`:e.chip_text,type:e.chip_mode})):rd}(n);/* @__PURE__ */
52
52
  return v(ic,{height:"full",overflow:"hidden",children:[/* @__PURE__ */v(ic,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */v(rc,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */b(hc,{as:"h2",size:"lg",weight:"semibold",children:n.widget_greeting}),/* @__PURE__ */b(hc,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:n.widget_body})]}),/* @__PURE__ */v(ic,{gap:"sm",children:[/* @__PURE__ */v(Za,{type:"button",variant:"primary",full:!0,onClick:e,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */b(cc,{name:"chat",size:16}),"Ask a question"]}),o.map(r=>/* @__PURE__ */b(Za,{elevation:"card",size:"sm",variant:"chip",full:!0,onClick:n=>(async(n,r)=>{r.preventDefault(),r.stopPropagation(),e(),t(n)})(r,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */b(hc,{as:"span",weight:"normal",leading:"tight",children:r.text})},r.id))]})]}),r.length>0&&/* @__PURE__ */v(rc,{variant:"floatingCard",children:[
53
53
  /* @__PURE__ */b(hc,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
54
54
  /* @__PURE__ */b(hc,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r[r.length-1]?.content||"Message"}),
55
- /* @__PURE__ */b(hc,{as:"p",size:"xs",variant:"muted",onClick:e,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},od=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"}],id=()=>/* @__PURE__ */b(fu,{render:/* @__PURE__ */b(oc,{align:"center",justify:"around",shrink:!1,border:"top"}),style:{height:48},children:od.map(e=>/* @__PURE__ */v(Ql,{value:e.id,render:/* @__PURE__ */b(Za,{stacked:!0,variant:"tab"}),children:[
55
+ /* @__PURE__ */b(Za,{type:"button",variant:"bare",onClick:e,style:{marginTop:"4px"},children:/* @__PURE__ */b(hc,{as:"span",size:"xs",variant:"muted",children:"Continue conversation →"})})]})]})},id=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"}],sd=()=>/* @__PURE__ */b(fu,{render:/* @__PURE__ */b(oc,{align:"center",justify:"around",shrink:!1,border:"top"}),style:{height:48},children:id.map(e=>/* @__PURE__ */v(Ql,{value:e.id,render:/* @__PURE__ */b(Za,{stacked:!0,variant:"tab"}),children:[
56
56
  /* @__PURE__ */b("span",{className:"mtx-tab-underline"}),
57
57
  /* @__PURE__ */b(hc,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */b(cc,{name:e.icon,size:20})}),
58
- /* @__PURE__ */b(hc,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id))});function sd(e){const t=e.getRootNode();return(t instanceof ShadowRoot?t.activeElement:document.activeElement)??null}function ad({width:e,height:t}){return{width:Math.min(Math.max(e,280),600),height:Math.min(Math.max(t,320),Math.floor(.85*window.innerHeight))}}function cd(e,t){const n=/^\s*(\d+(?:\.\d+)?)px\s*$/.exec(e??"");return n?Number(n[1]):t}var ld=()=>{const e=El(),{state:t,actions:n}=Il(),{isOpen:r,activeView:o}=t,{isPreviewMode:s}=e,{widthPx:c,heightPx:l,grip:h,onResizeStart:f,containerRef:m}=function(e,t,n,r,o){const s=_e("marketrix_widget_size",r),a=d(null),c=u(()=>(e=>{const t=Rl(e),n=Al[t.vertical],r=Al[t.horizontal];return{vertical:n,horizontal:r,growX:"left"===r?-1:1,growY:"top"===n?-1:1,cursor:"top"===n==("left"===r)?"nwse-resize":"nesw-resize"}})(n),[n]),[l,h]=p(()=>function(e){try{const t=JSON.parse(Pe(e)??"null");return function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.width&&"number"==typeof e.height}(t)?ad(t):null}catch(t){return Oe("[useResize] Ignoring an unparseable stored size:",t),null}}(s)??ad({width:cd(e,360),height:cd(t,450)})),f=d(l);f.current=l;const m=i(e=>{if(e.preventDefault(),e.stopPropagation(),o)return;const t=e.clientX,n=e.clientY,r=f.current.width,i=f.current.height,{growX:l,growY:u,cursor:d}=c;a.current&&(a.current.dataset.resizing="true");const p=e=>{const o=ad({width:r+(e.clientX-t)*l,height:i+(e.clientY-n)*u});f.current=o,a.current&&(a.current.style.width=`${o.width}px`,a.current.style.height=`${o.height}px`)},m=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",a.current&&delete a.current.dataset.resizing,h({...f.current}),Ne(s,JSON.stringify(f.current))};document.body.style.cursor=d,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[o,s,c]);return{widthPx:`${l.width}px`,heightPx:`${l.height}px`,grip:c,onResizeStart:m,containerRef:a}}(e.widget_width,e.widget_height,e.widget_position,e,s),g=d(null),y="chat"===o?"forward":"back";!function(e,t,n){const r=d(!1),o=d(null);a(()=>{if(!t)return r.current&&(o.current?.focus({preventScroll:!0}),o.current=null),void(r.current=!1);const i=e.current;if(!i)return;r.current||(o.current=sd(i)),r.current=!0,(n?.focusTargetRef?.current??bc(i)[0])?.focus({preventScroll:!0});const s=e=>{const t=sd(i);if(!t||!i.contains(t))return;if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const r=bc(i);if(0===r.length)return;const o=r.indexOf(t);-1!==o&&(e.shiftKey?0===o&&(e.preventDefault(),r[r.length-1]?.focus()):o===r.length-1&&(e.preventDefault(),r[0]?.focus()))};return document.addEventListener("keydown",s,!0),()=>document.removeEventListener("keydown",s,!0)},[t,e,n?.focusTargetRef,n?.onEscape])}(m,r,{onEscape:n.closeWidget,focusTargetRef:"chat"===o?g:void 0});const w=Ol(e.widget_position),[x,S]=p(!1),k=d(null);if(!r)return null;const C=Sl(e.widget_background_color),{vertical:E,horizontal:I}=Rl(e.widget_position),M="chat"===o&&!1!==e.use_screenshare?()=>k.current?.():void 0;/* @__PURE__ */
58
+ /* @__PURE__ */b(hc,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id))});function ad(e){const t=e.getRootNode();return(t instanceof ShadowRoot?t.activeElement:document.activeElement)??null}function cd({width:e,height:t}){return{width:Math.min(Math.max(e,280),600),height:Math.min(Math.max(t,320),Math.floor(.85*window.innerHeight))}}function ld(e,t){const n=/^\s*(\d+(?:\.\d+)?)px\s*$/.exec(e??"");return n?Number(n[1]):t}var ud=()=>{const e=El(),{state:t,actions:n}=Il(),{isOpen:r,activeView:o}=t,{isPreviewMode:s}=e,{widthPx:c,heightPx:l,grip:h,onResizeStart:f,containerRef:m}=function(e,t,n,r,o){const s=_e("marketrix_widget_size",r),a=d(null),c=u(()=>(e=>{const t=Rl(e),n=Al[t.vertical],r=Al[t.horizontal];return{vertical:n,horizontal:r,growX:"left"===r?-1:1,growY:"top"===n?-1:1,cursor:"top"===n==("left"===r)?"nwse-resize":"nesw-resize"}})(n),[n]),[l,h]=p(()=>function(e){try{const t=JSON.parse(Pe(e)??"null");return function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.width&&"number"==typeof e.height}(t)?cd(t):null}catch(t){return Oe("[useResize] Ignoring an unparseable stored size:",t),null}}(s)??cd({width:ld(e,360),height:ld(t,450)})),f=d(l);f.current=l;const m=i(e=>{if(e.preventDefault(),e.stopPropagation(),o)return;const t=e.clientX,n=e.clientY,r=f.current.width,i=f.current.height,{growX:l,growY:u,cursor:d}=c;a.current&&(a.current.dataset.resizing="true");const p=e=>{const o=cd({width:r+(e.clientX-t)*l,height:i+(e.clientY-n)*u});f.current=o,a.current&&(a.current.style.width=`${o.width}px`,a.current.style.height=`${o.height}px`)},m=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",a.current&&delete a.current.dataset.resizing,h({...f.current}),Ne(s,JSON.stringify(f.current))};document.body.style.cursor=d,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[o,s,c]);return{widthPx:`${l.width}px`,heightPx:`${l.height}px`,grip:c,onResizeStart:m,containerRef:a}}(e.widget_width,e.widget_height,e.widget_position,e,s),g=d(null),y="chat"===o?"forward":"back";!function(e,t,n){const r=d(!1),o=d(null);a(()=>{if(!t)return r.current&&(o.current?.focus({preventScroll:!0}),o.current=null),void(r.current=!1);const i=e.current;if(!i)return;r.current||(o.current=ad(i)),r.current=!0,(n?.focusTargetRef?.current??bc(i)[0])?.focus({preventScroll:!0});const s=e=>{const t=ad(i);if(!t||!i.contains(t))return;if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const r=bc(i);if(0===r.length)return;const o=r.indexOf(t);-1!==o&&(e.shiftKey?0===o&&(e.preventDefault(),r[r.length-1]?.focus()):o===r.length-1&&(e.preventDefault(),r[0]?.focus()))};return document.addEventListener("keydown",s,!0),()=>document.removeEventListener("keydown",s,!0)},[t,e,n?.focusTargetRef,n?.onEscape])}(m,r,{onEscape:n.closeWidget,focusTargetRef:"chat"===o?g:void 0});const w=Ol(e.widget_position),[x,S]=p(!1),k=d(null);if(!r)return null;const C=Sl(e.widget_background_color),{vertical:E,horizontal:I}=Rl(e.widget_position),M="chat"===o&&!1!==e.use_screenshare?()=>k.current?.():void 0;/* @__PURE__ */
59
59
  return v(ic,{ref:m,position:s?"absolute":"fixed",rounded:"lg",border:!0,overflow:"hidden",style:{zIndex:e.widget_position_z_index,backgroundImage:C,transformOrigin:`${E} ${I}`,width:c,height:l,fontSize:"14px",...w,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:La.panel},children:[
60
60
  /* @__PURE__ */b(gu,{title:e.widget_header,subtitle:e.widget_body,onClose:n.closeWidget,controls:M&&/* @__PURE__ */v(lc,{variant:"ghost",size:"sm",label:x?"Stop screen sharing":"Start screen sharing",onClick:M,children:[x&&/* @__PURE__ */b(mu,{style:{position:"absolute",top:"2px",right:"2px"}}),/* @__PURE__ */b(cc,{name:"screenShare",size:16})]})}),
61
- /* @__PURE__ */v(Vl,{value:o,onValueChange:e=>n.setActiveView(e),render:/* @__PURE__ */b(ic,{grow:!0,minHeight:"0"}),children:[/* @__PURE__ */v(ic,{grow:!0,overflow:"hidden",minHeight:"0",children:[/* @__PURE__ */b(nu,{value:"home","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(rd,{onNavigateToChat:()=>n.setActiveView("chat"),onChipClick:e=>{n.addMessage(Vc(e.text,e.type,"chip-message")),n.setMode(e.type),n.messageDispatch(e.text,e.type,!0)}})}),/* @__PURE__ */b(nu,{value:"chat","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(td,{onScreenSharingChange:S,toggleScreenShareRef:k,messageInputRef:g})})]}),/* @__PURE__ */b(id,{})]}),!s&&/* @__PURE__ */b("div",{role:"separator","aria-label":`Resize widget from ${h.vertical} ${h.horizontal}`,title:"Drag to resize",style:{position:"absolute",[h.vertical]:0,[h.horizontal]:0,width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:"top"===h.vertical?"flex-start":"flex-end",justifyContent:"left"===h.horizontal?"flex-start":"flex-end",cursor:h.cursor},onMouseDown:f})]})},ud=({config:e})=>{const[t,n]=p(!1),[r,o]=p(null),{state:i,actions:s}=Il(),c=e.isPreviewMode??!1;var l;l=i.isOpen,a(()=>{if(!l)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}},[l]);const[u,d]=p(e.widget_position??"bottom_right"),h=_e("marketrix_widget_position",e);a(()=>{const t=c?null:Pe(h);(e=>Tl.includes(e))(t)?d(t):d(e.widget_position??"bottom_right")},[c,h,e.widget_position]),a(()=>{if(i.isOpen||c||!e.widget_greeting_toast)return void n(!1);const t=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(t)},[i.isOpen,c,e.widget_greeting_toast]);const f=!1===e.show_widget||"hidden"===e.widget_appearance;if(!c&&f)return null;const m=Math.max(e.widget_position_z_index??0,2147483002),g={...e,widget_position:u,widget_position_z_index:m,isPreviewMode:c},y=i.isAwaitingReply||i.isTaskRunning,w=(x=function(e={}){const t=Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e)),n={...kl,...t};return{color:{background:n.widget_background_color,foreground:n.widget_text_color,foregroundMuted:xl(n.widget_text_color,.6),foregroundFaint:xl(n.widget_text_color,.4),border:n.widget_border_color,primary:n.widget_accent_color,primaryForeground:wl(n.widget_accent_color),primaryHover:xl(n.widget_accent_color,.85),secondary:n.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:xl(n.widget_secondary_color,.2),secondaryHover:xl(n.widget_secondary_color,.3)},radius:"12px",motion:{durationAnimation:"300ms",durationFade:"200ms"}}}(e),{"--foreground":x.color.foreground,"--card":x.color.background,"--card-foreground":x.color.foreground,"--primary":x.color.primary,"--foreground-muted":x.color.foregroundMuted,"--foreground-faint":x.color.foregroundFaint,"--primary-foreground":x.color.primaryForeground,"--primary-hover":x.color.primaryHover,"--secondary":x.color.secondary,"--secondary-foreground":x.color.secondaryForeground,"--secondary-bg":x.color.secondaryBg,"--secondary-hover":x.color.secondaryHover,"--border":x.color.border,"--ring":x.color.primary,"--radius":x.radius,"--duration-animation":x.motion.durationAnimation,"--duration-fade":x.motion.durationFade});var x;/* @__PURE__ */
61
+ /* @__PURE__ */v(Vl,{value:o,onValueChange:e=>n.setActiveView(e),render:/* @__PURE__ */b(ic,{grow:!0,minHeight:"0"}),children:[/* @__PURE__ */v(ic,{grow:!0,overflow:"hidden",minHeight:"0",children:[/* @__PURE__ */b(nu,{value:"home","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(od,{onNavigateToChat:()=>n.setActiveView("chat"),onChipClick:e=>{n.addMessage(Vc(e.text,e.type,"chip-message")),n.setMode(e.type),n.messageDispatch(e.text,e.type,!0)}})}),/* @__PURE__ */b(nu,{value:"chat","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(nd,{onScreenSharingChange:S,toggleScreenShareRef:k,messageInputRef:g})})]}),/* @__PURE__ */b(sd,{})]}),!s&&/* @__PURE__ */b("div",{role:"separator","aria-label":`Resize widget from ${h.vertical} ${h.horizontal}`,title:"Drag to resize",style:{position:"absolute",[h.vertical]:0,[h.horizontal]:0,width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:"top"===h.vertical?"flex-start":"flex-end",justifyContent:"left"===h.horizontal?"flex-start":"flex-end",cursor:h.cursor},onMouseDown:f})]})},dd=({config:e})=>{const[t,n]=p(!1),[r,o]=p(null),{state:i,actions:s}=Il(),c=e.isPreviewMode??!1;var l;l=i.isOpen,a(()=>{if(!l)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}},[l]);const[u,d]=p(e.widget_position??"bottom_right"),h=_e("marketrix_widget_position",e);a(()=>{const t=c?null:Pe(h);(e=>Tl.includes(e))(t)?d(t):d(e.widget_position??"bottom_right")},[c,h,e.widget_position]),a(()=>{if(i.isOpen||c||!e.widget_greeting_toast)return void n(!1);const t=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(t)},[i.isOpen,c,e.widget_greeting_toast]);const f=!1===e.show_widget||"hidden"===e.widget_appearance;if(!c&&f)return null;const m=Math.max(e.widget_position_z_index??0,2147483002),g={...e,widget_position:u,widget_position_z_index:m,isPreviewMode:c},y=i.isAwaitingReply||i.isTaskRunning,w=(x=function(e={}){const t=Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e)),n={...kl,...t};return{color:{background:n.widget_background_color,foreground:n.widget_text_color,foregroundMuted:xl(n.widget_text_color,.6),foregroundFaint:xl(n.widget_text_color,.4),border:n.widget_border_color,primary:n.widget_accent_color,primaryForeground:wl(n.widget_accent_color),primaryHover:xl(n.widget_accent_color,.85),secondary:n.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:xl(n.widget_secondary_color,.2),secondaryHover:xl(n.widget_secondary_color,.3)},radius:"12px",motion:{durationAnimation:"300ms",durationFade:"200ms"}}}(e),{"--foreground":x.color.foreground,"--card":x.color.background,"--card-foreground":x.color.foreground,"--primary":x.color.primary,"--foreground-muted":x.color.foregroundMuted,"--foreground-faint":x.color.foregroundFaint,"--primary-foreground":x.color.primaryForeground,"--primary-hover":x.color.primaryHover,"--secondary":x.color.secondary,"--secondary-foreground":x.color.secondaryForeground,"--secondary-bg":x.color.secondaryBg,"--secondary-hover":x.color.secondaryHover,"--border":x.color.border,"--ring":x.color.primary,"--radius":x.radius,"--duration-animation":x.motion.durationAnimation,"--duration-fade":x.motion.durationFade});var x;/* @__PURE__ */
62
62
  return b(Cl,{value:g,children:/* @__PURE__ */b(rc,{ref:o,"data-marketrix-widget":!0,position:"relative",style:{...w,...c&&{width:"100%",height:"100%"}},children:/* @__PURE__ */b(hl,{value:r,children:/* @__PURE__ */v(mc,{container:r,offsetBottom:"top"===Rl(u).vertical?20:90,children:[y&&/* @__PURE__ */b(rc,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${xl(g.widget_accent_color,.72)}, inset 0 0 46px 10px ${xl(g.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:2147483001}}),
63
- /* @__PURE__ */b(Dl,{label:"Widget",children:/* @__PURE__ */b(ld,{})}),
63
+ /* @__PURE__ */b(Dl,{label:"Widget",children:/* @__PURE__ */b(ud,{})}),
64
64
  /* @__PURE__ */b(Nl,{onPositionCommit:e=>{d(e),c||Ne(h,e)}}),
65
- /* @__PURE__ */b(gc,{error:i.error,onClearError:()=>s.setError(void 0),...hr.canReconnect()&&{onRetry:()=>{s.setError(void 0),hr.reconnectNow()}},greeting:t&&!i.error?e.widget_greeting:void 0,greetingBody:e.widget_body,onGreetingDismiss:()=>n(!1)})]})})})})},dd={mount:null},pd=null,hd=(e,t)=>{const n=e.attachShadow({mode:"closed"}),r=document.createElement("style");r.textContent=':root,:host{--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-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);--border:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--primary-hover:#3b82f6d9;--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";--radius:.625rem;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--duration-animation:.3s;--duration-fade:.2s;--radius-pill:9999px;--status-processing-rgb:49, 208, 109;--status-error-rgb:208, 52, 44;--overlay-dark:#111827}*,:before,:after{box-sizing:border-box;border:0 solid var(--border);margin:0;padding:0}:host,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1.5}:where([data-marketrix-widget]) :where(h1,h2,h3){font-size:inherit;font-weight:inherit}:where([data-marketrix-widget]) :where(img,svg,video,canvas){vertical-align:middle;display:block}:where([data-marketrix-widget]) :where(img,video){max-width:100%;height:auto}:where([data-marketrix-widget]) :where(button,input,textarea){font:inherit;color:inherit;background:0 0;border-radius:0}:where([data-marketrix-widget]) :where(button){appearance:button}:where([data-marketrix-widget]) :where(textarea){resize:vertical}[data-marketrix-widget] [hidden]{display:none!important}[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;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}[data-resizing=true],[data-resizing=true] *{transition:none!important}@media (prefers-reduced-motion:reduce){[data-marketrix-widget]{--duration-animation:0s!important;--duration-fade:0s!important}}.mtx-button,.mtx-icon-button{cursor:pointer;justify-content:center;align-items:center;transition:all .2s ease-in-out;display:inline-flex}.mtx-button{border:1px solid #0000;gap:8px;font-weight:500}.mtx-button:focus-visible{outline:2px solid var(--ring);outline-offset:2px}.mtx-button[data-size=sm]{min-height:28px;padding:4px 8px;font-size:.75rem}.mtx-button[data-size=md]{min-height:36px;padding:8px 16px;font-size:.875rem}.mtx-button[data-variant=primary]{background:var(--primary);color:var(--primary-foreground)}.mtx-button[data-variant=primary]:hover{background:color-mix(in oklab, var(--primary) 90%, transparent)}.mtx-button[data-variant=secondary]{background:var(--secondary);color:var(--secondary-foreground)}.mtx-button[data-variant=secondary]:hover{background:color-mix(in oklab, var(--secondary) 80%, transparent)}.mtx-button[data-variant=ghost]{color:var(--foreground);border-color:var(--border);background:0 0}.mtx-button[data-variant=ghost]:hover{background:var(--border)}.mtx-button[data-variant=chip]{background:var(--secondary-bg);color:var(--foreground)}.mtx-button[data-variant=chip]:hover{background:var(--primary);color:var(--primary-foreground);border-color:var(--primary)}.mtx-button[data-variant=bare],.mtx-button[data-variant=tab]{background:0 0;border-color:#0000;min-height:0;padding:0}.mtx-button[data-variant=bare]{color:inherit}.mtx-button[data-variant=tab]{color:var(--foreground-muted);flex:1;min-width:0;height:100%;position:relative}.mtx-button[data-variant=tab]:hover{color:var(--foreground)}.mtx-button[data-variant=tab][aria-selected=true]{color:var(--primary);font-weight:600}.mtx-button[data-stacked=true]{flex-direction:column;gap:2px}.mtx-button[data-full=true]{width:100%}.mtx-icon-button{border-radius:var(--radius-pill);border:none;flex-shrink:0}.mtx-icon-button[data-size=xs]{width:20px;min-width:20px;height:20px}.mtx-icon-button[data-size=sm]{width:28px;min-width:28px;height:28px}.mtx-icon-button[data-variant=primary]{background:var(--primary);color:var(--primary-foreground)}.mtx-icon-button[data-variant=primary]:hover{background:var(--primary-hover)}.mtx-icon-button[data-variant=secondary]{background:var(--secondary-bg);color:var(--foreground)}.mtx-icon-button[data-variant=secondary]:hover{background:var(--secondary-hover)}.mtx-icon-button[data-variant=ghost]{color:var(--foreground);opacity:.6;background:0 0}.mtx-icon-button[data-variant=ghost]:hover{opacity:1}.mtx-button[data-disabled=true],.mtx-icon-button[data-disabled=true]{opacity:.5;cursor:not-allowed;pointer-events:none}.mtx-icon{flex-shrink:0;display:inline-block}.mtx-avatar{flex-shrink:0}.mtx-spinner-ring{border-radius:var(--radius-pill);border-style:solid;border-color:#0000 currentColor currentColor;flex-shrink:0;animation:1s linear infinite mtx-spin}.mtx-visually-hidden{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.mtx-composer:focus-within{border-color:var(--foreground-faint)}.mtx-composer-input{resize:none;width:100%;min-height:0;color:var(--foreground);background:0 0;border:none;padding-left:12px;padding-right:12px;font-size:.875rem;display:block}.mtx-composer-input::placeholder{color:var(--foreground-faint)}.mtx-composer-input:focus{outline:none}.mtx-composer-input:disabled{cursor:not-allowed;opacity:.5}.mtx-mode-chip{border-radius:var(--radius-pill);cursor:pointer;background:var(--secondary-bg);color:var(--foreground-muted);border:none;align-items:center;gap:2px;padding:2px 8px;font-size:11px;font-weight:500;transition:all .2s ease-in-out;display:inline-flex}.mtx-mode-chip[data-active=true]{background:var(--primary);color:var(--primary-foreground);box-shadow:var(--shadow-sm)}.mtx-toast-viewport{flex-direction:column;gap:8px;max-width:420px;display:flex;position:fixed;left:50%;transform:translate(-50%)}.mtx-toast{animation:mtx-fade-in var(--duration-animation) ease-out}.mtx-toast[data-ending-style]{opacity:0;transition:opacity var(--duration-animation) ease-out}.mtx-dialog-backdrop{animation:mtx-dialog-overlay-in var(--duration-fade) ease-out;background:#0003;position:fixed;inset:0}.mtx-dialog-popup{border-radius:var(--radius);background:var(--card);width:100%;max-width:24rem;max-height:85vh;animation:mtx-dialog-content-in var(--duration-animation) ease-out;flex-direction:column;padding:16px;display:flex;position:fixed;top:50%;left:50%;overflow:auto;transform:translate(-50%,-50%)}.mtx-dialog-title{color:var(--foreground);margin-bottom:4px;font-size:1rem;font-weight:600}.mtx-dialog-description{color:var(--foreground-muted);margin-bottom:16px;font-size:.875rem;line-height:1.625}.mtx-fab-anchor{position:fixed}.mtx-fab-anchor[data-preview=true]{position:absolute}.mtx-fab-anchor[data-animated=true]{transition:transform var(--duration-animation) ease-in-out}.mtx-fab{width:56px;height:56px;transition:all var(--duration-animation) ease-in-out;position:relative;overflow:visible}.mtx-fab[data-open=false]:hover{transform:scale(1.1)}.mtx-fab[data-open=true]{opacity:0;pointer-events:none;transform:scale(0)}.mtx-fab-trigger{z-index:10;width:56px;min-width:56px;height:56px;position:relative}.mtx-fab-center{justify-content:center;align-items:center;width:100%;height:100%;position:relative}.mtx-fab-badge{width:48px;height:48px;transition:transform .167s cubic-bezier(.33,0,0,1),opacity .167s cubic-bezier(.33,0,0,1),background-color .167s cubic-bezier(.33,0,0,1);animation:.25s ease-out forwards mtx-launcher-entrance;position:relative;overflow:hidden}.mtx-fab-badge:hover{transition-duration:.25s;transform:scale(1.1)}.mtx-fab-badge:active{transition-duration:.134s;transition-timing-function:cubic-bezier(.45,0,.2,1);transform:scale(.85)}.mtx-fab-icon-layer{justify-content:center;align-items:center;transition-property:transform,opacity;transition-duration:.16s,80ms;transition-timing-function:linear;position:absolute;inset:0}.mtx-fab-avatar{z-index:10;object-fit:contain;width:100%;height:100%;position:relative}.mtx-fab-chevron{z-index:10;color:var(--foreground);pointer-events:none;position:relative}.mtx-fab-stop{z-index:20;border-radius:var(--radius-pill);background:var(--overlay-dark);text-transform:uppercase;letter-spacing:.025em;color:#fff;box-shadow:var(--shadow-lg);opacity:0;pointer-events:none;border:1px solid #ffffff40;padding:4px 10px;font-size:11px;font-weight:600;transition:opacity .15s ease-in-out;position:absolute;top:50%;transform:translateY(-50%)}.mtx-fab-stop[data-side=left]{margin-left:8px;left:100%}.mtx-fab-stop[data-side=right]{margin-right:8px;right:100%}.mtx-fab:hover .mtx-fab-stop,.mtx-fab:focus-within .mtx-fab-stop{opacity:1;pointer-events:auto}.mtx-tab-underline{border-radius:var(--radius-pill);background:var(--primary);opacity:0;height:2px;position:absolute;top:0;left:25%;right:25%}[aria-selected=true]>.mtx-tab-underline{opacity:1}.mtx-live-dot{width:6px;height:6px;display:inline-flex;position:relative}.mtx-live-dot-ping{border-radius:var(--radius-pill);opacity:.75;background:currentColor;width:100%;height:100%;animation:1s cubic-bezier(0,0,.2,1) infinite mtx-ping;display:inline-flex;position:absolute}.mtx-live-dot-core{border-radius:var(--radius-pill);background:currentColor;width:6px;height:6px;display:inline-flex;position:relative}.mtx-fab-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%)}.mtx-fab-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.mtx-fab-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 mtx-fab-ring-travel}.mtx-fab-ring[data-tone=processing] rect{stroke:rgb(var(--status-processing-rgb));filter:drop-shadow(0 0 3px rgba(var(--status-processing-rgb), .7))}.mtx-fab-ring[data-tone=error] rect{stroke:rgb(var(--status-error-rgb));filter:drop-shadow(0 0 3px rgba(var(--status-error-rgb), .7))}.mtx-fab-glow[data-tone=processing]{animation:2s ease-in-out infinite mtx-fab-glow-processing}.mtx-fab-glow[data-tone=error]{animation:1.5s ease-in-out infinite mtx-fab-glow-error}[data-screen-edge-glow]{animation:1.6s ease-in-out infinite mtx-screen-edge-pulse}[data-view-transition][data-direction=forward]{animation:.3s both mtx-view-slide-forward}[data-view-transition][data-direction=back]{animation:.3s both mtx-view-slide-back}@keyframes mtx-spin{to{transform:rotate(360deg)}}@keyframes mtx-ping{75%,to{opacity:0;transform:scale(2)}}@keyframes mtx-pulse{50%{opacity:.5}}@keyframes mtx-dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes mtx-dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes mtx-fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes mtx-launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}@keyframes mtx-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}@keyframes mtx-fab-ring-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}}@keyframes mtx-fab-glow-processing{0%,to{opacity:.72;background:radial-gradient(circle, rgba(var(--status-processing-rgb), 0) 38%, rgba(var(--status-processing-rgb), .38) 58%, rgba(var(--status-processing-rgb), .24) 68%, transparent 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle, rgba(var(--status-processing-rgb), 0) 34%, rgba(var(--status-processing-rgb), .55) 56%, rgba(var(--status-processing-rgb), .33) 68%, transparent 80%);transform:translate(-50%,-50%)scale(1.1)}}@keyframes mtx-fab-glow-error{0%,to{opacity:.65;background:radial-gradient(circle, rgba(var(--status-error-rgb), 0) 38%, rgba(var(--status-error-rgb), .34) 58%, rgba(var(--status-error-rgb), .22) 68%, transparent 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle, rgba(var(--status-error-rgb), 0) 34%, rgba(var(--status-error-rgb), .5) 56%, rgba(var(--status-error-rgb), .3) 68%, transparent 80%);transform:translate(-50%,-50%)scale(1.1)}}@keyframes mtx-view-slide-forward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes mtx-view-slide-back{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}',n.appendChild(r);const o=document.createElement("div");return o.id=t,n.appendChild(o),{shadowRoot:n,mountEl:o}},fd=e=>{const t=e??document.body,n=document.createElement("div");n.className="marketrix-widget-container",n.style.pointerEvents="auto",e&&Object.assign(n.style,{width:"100%",height:"100%",position:"relative",overflow:"visible"}),t.appendChild(n);const{shadowRoot:r,mountEl:o}=hd(n,"marketrix-widget-root");return Object.assign(o.style,{pointerEvents:"auto",width:"100%",height:"100%",position:"relative"}),{container:n,shadowRoot:r,mountEl:o}},md=(e,n,r=!1)=>{const o=m(e);return o.render(/* @__PURE__ */b(t.StrictMode,{children:/* @__PURE__ */b(gl,{previewMode:r,children:/* @__PURE__ */b(ud,{config:n})})})),o},gd=()=>null!==dd.mount,yd=()=>dd.mount?.config??null,bd=(e,n="neutral")=>{if("undefined"==typeof window||"undefined"==typeof document)return;vd();const r=document.createElement("div");r.id="marketrix-widget-notice-container",r.className="marketrix-widget-notice-container",document.body.appendChild(r);const{mountEl:o}=hd(r,"marketrix-widget-notice-root");(pd=m(o)).render(/* @__PURE__ */b(t.StrictMode,{children:/* @__PURE__ */b(mc,{container:o,children:/* @__PURE__ */b(gc,{error:"error"===n?e:void 0,onClearError:vd,greeting:"error"===n?void 0:e,onGreetingDismiss:vd})})}))},vd=()=>{pd?.unmount(),pd=null,document.getElementById("marketrix-widget-notice-container")?.remove()},wd=null,xd=0,Sd=null;function kd(e,t={}){const n=Cr(e);return n.invalidFields?(console.error(`Marketrix Widget: ${Er(n.invalidFields)}`),null):{...Ir(n.settings,t),isPreviewMode:!0}}function Cd(e,t,n=!1){const{container:r,mountEl:o}=fd(t),i=md(o,e,n);dd.mount={instance:i,config:e,container:r,host:t,previewMode:n}}var Ed=(e,t)=>{if(wd)return wd;if(window.__mtx?.state)return Promise.resolve();if(gd())return Oe("Marketrix Widget: already initialized"),Promise.resolve();const n=async function(e,t,n){let r;window.__mtx={state:"initializing"},bd("Loading widget settings...");try{(e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==Ie&&(Ie=e,Me=Ee(e))})(e.mtxApiHost??""),r=await async function(e){const{mtxId:t,mtxKey:n}=e;if(!t||!n)throw new Error("Please provide mtxId + mtxKey");let r;try{({items:r}=await Te.widgetPublicSearch({marketrix_id:t,marketrix_key:n}))}catch(s){const t=Re(s);throw function(e,t){return Object.assign(new Error(e),{cause:t})}(["Failed to fetch","ERR_CONNECTION_REFUSED","NetworkError","Network request failed"].some(e=>t.includes(e))?`Cannot connect to API server. Please ensure the API server is running at ${e.mtxApiHost||"configured API server"}. Error: ${t}`:`Widget validation failed: ${t}`,s)}if(!r.length)throw new Error("Widget not found or invalid credentials");const o=r.find(e=>"active"===e.status);if(!o){const e=r.map(e=>e.status).join(", ");throw new Error(`Found widget(s) but none are active. Current status(es): ${e}. Please activate the widget in the dashboard.`)}if(!o.application_id)throw new Error("Widget missing application_id");const i=Cr(o.settings);if(i.invalidFields)throw new Error(Er(i.invalidFields));return{...Ir(i.settings,e),mtxId:t,mtxKey:n,mtxApp:o.application_id,isPreviewMode:!1}}(e)}catch(o){if(n!==xd)return;return console.error("Marketrix Widget initialization failed:",o),bd(Re(o,"Failed to initialize widget"),"error"),void(window.__mtx=void 0)}n===xd&&(vd(),r.widget_enabled?($e.setConfig(r),Cd(r,t),window.__mtx={state:"active"},r.widget_recording&&r.mtxApp&&(async()=>{try{const e=await Be.getOrCreateChatId();if(n!==xd)return;const t=new fr(e,r.mtxApp);Sd=t,await t.start(),n!==xd&&(t.stop(),Sd===t&&(Sd=null))}catch(o){n===xd&&console.error("Failed to start session recording:",o)}})()):window.__mtx=void 0)}(e,t,++xd);return wd=n,n.then(()=>{wd===n&&(wd=null)},()=>{wd===n&&(wd=null)}),n},Id=()=>{xd++,hr.disconnect(),Sd?.stop(),Sd=null,yr();const e=dd.mount;dd.mount=null,e&&(e.instance.unmount(),e.container.remove()),wd=null,window.__mtx=void 0,vd()},Md=async e=>{const t=dd.mount;if(!t)return;const{config:n,host:r,previewMode:o}=t,i={...n,...e};Id(),o?Cd(i,r,!0):await Ed(i,r)},Td=({settings:e,container:t})=>{const n=d(null),r=d(null),o=d(null);return a(()=>{const i=t??n.current??document.body;if(!(i&&(s=i,s instanceof HTMLElement)))return void console.error("MarketrixWidgetPreview: Invalid container");var s;const a=kd(e);if(!a)return;const{container:c,mountEl:l}=fd(i);return o.current=c,r.current=md(l,a,!0),()=>{r.current&&(r.current.unmount(),r.current=null),o.current&&(o.current.remove(),o.current=null)}},[e,t]),t?null:/* @__PURE__ */b("div",{ref:n,style:{width:"100%",height:"100%",position:"relative"}})},Rd=async e=>{const t=e.container;if(void 0!==e.settings){const{settings:n,container:r,...o}=e,i=kd(e.settings,o);if(!i)return;Id(),Cd(i,t,!0)}else{if(void 0===e.mtxId||void 0===e.mtxKey)throw new Error("Invalid configuration: provide either settings (preview) or mtxId+mtxKey (production)");{const{container:n,...r}=e;await Ed(r,t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;const t=document.querySelectorAll("script[mtx-id]"),n=t[t.length-1];if(!(n&&(r=n,r instanceof HTMLScriptElement)))return;var r;const o=n.getAttribute("mtx-id"),i=n.getAttribute("mtx-key"),s=n.getAttribute("mtx-api-host");if(!o||!i||!s){if(gd())return;return console.error("[AutoInit] Missing required attributes:",{hasMtxId:!!o,hasMtxKey:!!i,hasMtxApiHost:!!s}),void bd("Please configure mtx-id, mtx-key and mtx-api-host","error")}const a={mtxId:o,mtxKey:i,mtxApiHost:s};"false"===n.getAttribute("mtx-use-screenshare")&&(a.use_screenshare=!1),e(a).catch(e=>console.error("[AutoInit] Failed to initialize widget:",e))})(Ed)}catch(e){console.error("Marketrix Widget: Auto-init registration failed",e)}},0);var Od={MarketrixWidgetPreview:Td,mountWidget:Rd,initWidget:Ed,unmountWidget:Id,updateMarketrixConfig:Md,getCurrentConfig:yd};export{Td as MarketrixWidgetPreview,Od as default,yd as getCurrentConfig,Ed as initWidget,Rd as mountWidget,Id as unmountWidget,Md as updateMarketrixConfig};
65
+ /* @__PURE__ */b(gc,{error:i.error,onClearError:()=>s.setError(void 0),...hr.canReconnect()&&{onRetry:()=>{s.setError(void 0),hr.reconnectNow()}},greeting:t&&!i.error?e.widget_greeting:void 0,greetingBody:e.widget_body,onGreetingDismiss:()=>n(!1)})]})})})})},pd={mount:null},hd=null,fd=(e,t)=>{const n=e.attachShadow({mode:"closed"}),r=document.createElement("style");r.textContent=':root,:host{--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-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);--border:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--primary-hover:#3b82f6d9;--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";--radius:.625rem;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--duration-animation:.3s;--duration-fade:.2s;--radius-pill:9999px;--status-processing-rgb:49, 208, 109;--status-error-rgb:208, 52, 44;--overlay-dark:#111827}*,:before,:after{box-sizing:border-box;border:0 solid var(--border);margin:0;padding:0}:host,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1.5}:where([data-marketrix-widget]) :where(h1,h2,h3){font-size:inherit;font-weight:inherit}:where([data-marketrix-widget]) :where(img,svg,video,canvas){vertical-align:middle;display:block}:where([data-marketrix-widget]) :where(img,video){max-width:100%;height:auto}:where([data-marketrix-widget]) :where(button,input,textarea){font:inherit;color:inherit;background:0 0;border-radius:0}:where([data-marketrix-widget]) :where(button){appearance:button}:where([data-marketrix-widget]) :where(textarea){resize:vertical}[data-marketrix-widget] [hidden]{display:none!important}[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;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}[data-resizing=true],[data-resizing=true] *{transition:none!important}@media (prefers-reduced-motion:reduce){[data-marketrix-widget]{--duration-animation:0s!important;--duration-fade:0s!important}}.mtx-button,.mtx-icon-button{cursor:pointer;justify-content:center;align-items:center;transition:all .2s ease-in-out;display:inline-flex}.mtx-button{border:1px solid #0000;gap:8px;font-weight:500}.mtx-button:focus-visible{outline:2px solid var(--ring);outline-offset:2px}.mtx-button[data-size=sm]{min-height:28px;padding:4px 8px;font-size:.75rem}.mtx-button[data-size=md]{min-height:36px;padding:8px 16px;font-size:.875rem}.mtx-button[data-variant=primary]{background:var(--primary);color:var(--primary-foreground)}.mtx-button[data-variant=primary]:hover{background:color-mix(in oklab, var(--primary) 90%, transparent)}.mtx-button[data-variant=secondary]{background:var(--secondary);color:var(--secondary-foreground)}.mtx-button[data-variant=secondary]:hover{background:color-mix(in oklab, var(--secondary) 80%, transparent)}.mtx-button[data-variant=ghost]{color:var(--foreground);border-color:var(--border);background:0 0}.mtx-button[data-variant=ghost]:hover{background:var(--border)}.mtx-button[data-variant=chip]{background:var(--secondary-bg);color:var(--foreground)}.mtx-button[data-variant=chip]:hover{background:var(--primary);color:var(--primary-foreground);border-color:var(--primary)}.mtx-button[data-variant=bare],.mtx-button[data-variant=tab]{background:0 0;border-color:#0000;min-height:0;padding:0}.mtx-button[data-variant=bare]{color:inherit}.mtx-button[data-variant=tab]{color:var(--foreground-muted);flex:1;min-width:0;height:100%;position:relative}.mtx-button[data-variant=tab]:hover{color:var(--foreground)}.mtx-button[data-variant=tab][aria-selected=true]{color:var(--primary);font-weight:600}.mtx-button[data-stacked=true]{flex-direction:column;gap:2px}.mtx-button[data-full=true]{width:100%}.mtx-icon-button{border-radius:var(--radius-pill);border:none;flex-shrink:0}.mtx-icon-button[data-size=xs]{width:20px;min-width:20px;height:20px}.mtx-icon-button[data-size=sm]{width:28px;min-width:28px;height:28px}.mtx-icon-button[data-variant=primary]{background:var(--primary);color:var(--primary-foreground)}.mtx-icon-button[data-variant=primary]:hover{background:var(--primary-hover)}.mtx-icon-button[data-variant=secondary]{background:var(--secondary-bg);color:var(--foreground)}.mtx-icon-button[data-variant=secondary]:hover{background:var(--secondary-hover)}.mtx-icon-button[data-variant=ghost]{color:var(--foreground);opacity:.6;background:0 0}.mtx-icon-button[data-variant=ghost]:hover{opacity:1}.mtx-button[data-disabled=true],.mtx-icon-button[data-disabled=true]{opacity:.5;cursor:not-allowed;pointer-events:none}.mtx-icon{flex-shrink:0;display:inline-block}.mtx-avatar{flex-shrink:0}.mtx-spinner-ring{border-radius:var(--radius-pill);border-style:solid;border-color:#0000 currentColor currentColor;flex-shrink:0;animation:1s linear infinite mtx-spin}.mtx-visually-hidden{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.mtx-composer:focus-within{border-color:var(--foreground-faint)}.mtx-composer-input{resize:none;width:100%;min-height:0;color:var(--foreground);background:0 0;border:none;padding-left:12px;padding-right:12px;font-size:.875rem;display:block}.mtx-composer-input::placeholder{color:var(--foreground-faint)}.mtx-composer-input:focus{outline:none}.mtx-composer-input:disabled{cursor:not-allowed;opacity:.5}.mtx-mode-chip{border-radius:var(--radius-pill);cursor:pointer;background:var(--secondary-bg);color:var(--foreground-muted);border:none;align-items:center;gap:2px;padding:2px 8px;font-size:11px;font-weight:500;transition:all .2s ease-in-out;display:inline-flex}.mtx-mode-chip[data-active=true]{background:var(--primary);color:var(--primary-foreground);box-shadow:var(--shadow-sm)}.mtx-toast-viewport{flex-direction:column;gap:8px;max-width:420px;display:flex;position:fixed;left:50%;transform:translate(-50%)}.mtx-toast{animation:mtx-fade-in var(--duration-animation) ease-out}.mtx-toast[data-ending-style]{opacity:0;transition:opacity var(--duration-animation) ease-out}.mtx-dialog-backdrop{animation:mtx-dialog-overlay-in var(--duration-fade) ease-out;background:#0003;position:fixed;inset:0}.mtx-dialog-popup{border-radius:var(--radius);background:var(--card);width:100%;max-width:24rem;max-height:85vh;animation:mtx-dialog-content-in var(--duration-animation) ease-out;flex-direction:column;padding:16px;display:flex;position:fixed;top:50%;left:50%;overflow:auto;transform:translate(-50%,-50%)}.mtx-dialog-title{color:var(--foreground);margin-bottom:4px;font-size:1rem;font-weight:600}.mtx-dialog-description{color:var(--foreground-muted);margin-bottom:16px;font-size:.875rem;line-height:1.625}.mtx-fab-anchor{position:fixed}.mtx-fab-anchor[data-preview=true]{position:absolute}.mtx-fab-anchor[data-animated=true]{transition:transform var(--duration-animation) ease-in-out}.mtx-fab{width:56px;height:56px;transition:all var(--duration-animation) ease-in-out;position:relative;overflow:visible}.mtx-fab[data-open=false]:hover{transform:scale(1.1)}.mtx-fab[data-open=true]{opacity:0;pointer-events:none;transform:scale(0)}.mtx-fab-trigger{z-index:10;width:56px;min-width:56px;height:56px;position:relative}.mtx-fab-center{justify-content:center;align-items:center;width:100%;height:100%;position:relative}.mtx-fab-badge{width:48px;height:48px;transition:transform .167s cubic-bezier(.33,0,0,1),opacity .167s cubic-bezier(.33,0,0,1),background-color .167s cubic-bezier(.33,0,0,1);animation:.25s ease-out forwards mtx-launcher-entrance;position:relative;overflow:hidden}.mtx-fab-badge:hover{transition-duration:.25s;transform:scale(1.1)}.mtx-fab-badge:active{transition-duration:.134s;transition-timing-function:cubic-bezier(.45,0,.2,1);transform:scale(.85)}.mtx-fab-icon-layer{justify-content:center;align-items:center;transition-property:transform,opacity;transition-duration:.16s,80ms;transition-timing-function:linear;position:absolute;inset:0}.mtx-fab-avatar{z-index:10;object-fit:contain;width:100%;height:100%;position:relative}.mtx-fab-chevron{z-index:10;color:var(--foreground);pointer-events:none;position:relative}.mtx-fab-stop{z-index:20;border-radius:var(--radius-pill);background:var(--overlay-dark);text-transform:uppercase;letter-spacing:.025em;color:#fff;box-shadow:var(--shadow-lg);opacity:0;pointer-events:none;border:1px solid #ffffff40;padding:4px 10px;font-size:11px;font-weight:600;transition:opacity .15s ease-in-out;position:absolute;top:50%;transform:translateY(-50%)}.mtx-fab-stop[data-side=left]{margin-left:8px;left:100%}.mtx-fab-stop[data-side=right]{margin-right:8px;right:100%}.mtx-fab:hover .mtx-fab-stop,.mtx-fab:focus-within .mtx-fab-stop{opacity:1;pointer-events:auto}.mtx-tab-underline{border-radius:var(--radius-pill);background:var(--primary);opacity:0;height:2px;position:absolute;top:0;left:25%;right:25%}[aria-selected=true]>.mtx-tab-underline{opacity:1}.mtx-live-dot{width:6px;height:6px;display:inline-flex;position:relative}.mtx-live-dot-ping{border-radius:var(--radius-pill);opacity:.75;background:currentColor;width:100%;height:100%;animation:1s cubic-bezier(0,0,.2,1) infinite mtx-ping;display:inline-flex;position:absolute}.mtx-live-dot-core{border-radius:var(--radius-pill);background:currentColor;width:6px;height:6px;display:inline-flex;position:relative}.mtx-fab-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%)}.mtx-fab-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.mtx-fab-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 mtx-fab-ring-travel}.mtx-fab-ring[data-tone=processing] rect{stroke:rgb(var(--status-processing-rgb));filter:drop-shadow(0 0 3px rgba(var(--status-processing-rgb), .7))}.mtx-fab-ring[data-tone=error] rect{stroke:rgb(var(--status-error-rgb));filter:drop-shadow(0 0 3px rgba(var(--status-error-rgb), .7))}.mtx-fab-glow[data-tone=processing]{animation:2s ease-in-out infinite mtx-fab-glow-processing}.mtx-fab-glow[data-tone=error]{animation:1.5s ease-in-out infinite mtx-fab-glow-error}[data-screen-edge-glow]{animation:1.6s ease-in-out infinite mtx-screen-edge-pulse}[data-view-transition][data-direction=forward]{animation:.3s both mtx-view-slide-forward}[data-view-transition][data-direction=back]{animation:.3s both mtx-view-slide-back}@keyframes mtx-spin{to{transform:rotate(360deg)}}@keyframes mtx-ping{75%,to{opacity:0;transform:scale(2)}}@keyframes mtx-pulse{50%{opacity:.5}}@keyframes mtx-dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes mtx-dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes mtx-fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes mtx-launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}@keyframes mtx-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}@keyframes mtx-fab-ring-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}}@keyframes mtx-fab-glow-processing{0%,to{opacity:.72;background:radial-gradient(circle, rgba(var(--status-processing-rgb), 0) 38%, rgba(var(--status-processing-rgb), .38) 58%, rgba(var(--status-processing-rgb), .24) 68%, transparent 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle, rgba(var(--status-processing-rgb), 0) 34%, rgba(var(--status-processing-rgb), .55) 56%, rgba(var(--status-processing-rgb), .33) 68%, transparent 80%);transform:translate(-50%,-50%)scale(1.1)}}@keyframes mtx-fab-glow-error{0%,to{opacity:.65;background:radial-gradient(circle, rgba(var(--status-error-rgb), 0) 38%, rgba(var(--status-error-rgb), .34) 58%, rgba(var(--status-error-rgb), .22) 68%, transparent 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle, rgba(var(--status-error-rgb), 0) 34%, rgba(var(--status-error-rgb), .5) 56%, rgba(var(--status-error-rgb), .3) 68%, transparent 80%);transform:translate(-50%,-50%)scale(1.1)}}@keyframes mtx-view-slide-forward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes mtx-view-slide-back{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}',n.appendChild(r);const o=document.createElement("div");return o.id=t,n.appendChild(o),{shadowRoot:n,mountEl:o}},md=e=>{const t=e??document.body,n=document.createElement("div");n.className="marketrix-widget-container",n.style.pointerEvents="auto",e&&Object.assign(n.style,{width:"100%",height:"100%",position:"relative",overflow:"visible"}),t.appendChild(n);const{shadowRoot:r,mountEl:o}=fd(n,"marketrix-widget-root");return Object.assign(o.style,{pointerEvents:"auto",width:"100%",height:"100%",position:"relative"}),{container:n,shadowRoot:r,mountEl:o}},gd=(e,n,r=!1)=>{const o=m(e);return o.render(/* @__PURE__ */b(t.StrictMode,{children:/* @__PURE__ */b(gl,{previewMode:r,children:/* @__PURE__ */b(dd,{config:n})})})),o},yd=()=>null!==pd.mount,bd=()=>pd.mount?.config??null,vd=(e,n="neutral")=>{if("undefined"==typeof window||"undefined"==typeof document)return;wd();const r=document.createElement("div");r.id="marketrix-widget-notice-container",r.className="marketrix-widget-notice-container",document.body.appendChild(r);const{mountEl:o}=fd(r,"marketrix-widget-notice-root");(hd=m(o)).render(/* @__PURE__ */b(t.StrictMode,{children:/* @__PURE__ */b(mc,{container:o,children:/* @__PURE__ */b(gc,{error:"error"===n?e:void 0,onClearError:wd,greeting:"error"===n?void 0:e,onGreetingDismiss:wd})})}))},wd=()=>{hd?.unmount(),hd=null,document.getElementById("marketrix-widget-notice-container")?.remove()},xd=null,Sd=0,kd=null;function Cd(e,t={}){const n=Cr(e);return n.invalidFields?(console.error(`Marketrix Widget: ${Er(n.invalidFields)}`),null):{...Ir(n.settings,t),isPreviewMode:!0}}function Ed(e,t,n=!1){const{container:r,mountEl:o}=md(t),i=gd(o,e,n);pd.mount={instance:i,config:e,container:r,host:t,previewMode:n}}var Id=(e,t)=>{if(xd)return xd;if(window.__mtx?.state)return Promise.resolve();if(yd())return Oe("Marketrix Widget: already initialized"),Promise.resolve();const n=async function(e,t,n){let r;window.__mtx={state:"initializing"},vd("Loading widget settings...");try{(e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==Ie&&(Ie=e,Me=Ee(e))})(e.mtxApiHost??""),r=await async function(e){const{mtxId:t,mtxKey:n}=e;if(!t||!n)throw new Error("Please provide mtxId + mtxKey");let r;try{({items:r}=await Te.widgetPublicSearch({marketrix_id:t,marketrix_key:n}))}catch(s){const t=Re(s);throw function(e,t){return Object.assign(new Error(e),{cause:t})}(["Failed to fetch","ERR_CONNECTION_REFUSED","NetworkError","Network request failed"].some(e=>t.includes(e))?`Cannot connect to API server. Please ensure the API server is running at ${e.mtxApiHost||"configured API server"}. Error: ${t}`:`Widget validation failed: ${t}`,s)}if(!r.length)throw new Error("Widget not found or invalid credentials");const o=r.find(e=>"active"===e.status);if(!o){const e=r.map(e=>e.status).join(", ");throw new Error(`Found widget(s) but none are active. Current status(es): ${e}. Please activate the widget in the dashboard.`)}if(!o.application_id)throw new Error("Widget missing application_id");const i=Cr(o.settings);if(i.invalidFields)throw new Error(Er(i.invalidFields));return{...Ir(i.settings,e),mtxId:t,mtxKey:n,mtxApp:o.application_id,isPreviewMode:!1}}(e)}catch(o){if(n!==Sd)return;return console.error("Marketrix Widget initialization failed:",o),vd(Re(o,"Failed to initialize widget"),"error"),void(window.__mtx=void 0)}n===Sd&&(wd(),r.widget_enabled?($e.setConfig(r),Ed(r,t),window.__mtx={state:"active"},r.widget_recording&&r.mtxApp&&(async()=>{try{const e=await Be.getOrCreateChatId();if(n!==Sd)return;const t=new fr(e,r.mtxApp);kd=t,await t.start(),n!==Sd&&(t.stop(),kd===t&&(kd=null))}catch(o){n===Sd&&console.error("Failed to start session recording:",o)}})()):window.__mtx=void 0)}(e,t,++Sd);return xd=n,n.then(()=>{xd===n&&(xd=null)},()=>{xd===n&&(xd=null)}),n},Md=()=>{Sd++,hr.disconnect(),kd?.stop(),kd=null,yr();const e=pd.mount;pd.mount=null,e&&(e.instance.unmount(),e.container.remove()),xd=null,window.__mtx=void 0,wd()},Td=async e=>{const t=pd.mount;if(!t)return;const{config:n,host:r,previewMode:o}=t,i={...n,...e};Md(),o?Ed(i,r,!0):await Id(i,r)},Rd=({settings:e,container:t})=>{const n=d(null),r=d(null),o=d(null);return a(()=>{const i=t??n.current??document.body;if(!(i&&(s=i,s instanceof HTMLElement)))return void console.error("MarketrixWidgetPreview: Invalid container");var s;const a=Cd(e);if(!a)return;const{container:c,mountEl:l}=md(i);return o.current=c,r.current=gd(l,a,!0),()=>{r.current&&(r.current.unmount(),r.current=null),o.current&&(o.current.remove(),o.current=null)}},[e,t]),t?null:/* @__PURE__ */b("div",{ref:n,style:{width:"100%",height:"100%",position:"relative"}})},Od=async e=>{const t=e.container;if(void 0!==e.settings){const{settings:n,container:r,...o}=e,i=Cd(e.settings,o);if(!i)return;Md(),Ed(i,t,!0)}else{if(void 0===e.mtxId||void 0===e.mtxKey)throw new Error("Invalid configuration: provide either settings (preview) or mtxId+mtxKey (production)");{const{container:n,...r}=e;await Id(r,t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;const t=document.querySelectorAll("script[mtx-id]"),n=t[t.length-1];if(!(n&&(r=n,r instanceof HTMLScriptElement)))return;var r;const o=n.getAttribute("mtx-id"),i=n.getAttribute("mtx-key"),s=n.getAttribute("mtx-api-host");if(!o||!i||!s){if(yd())return;return console.error("[AutoInit] Missing required attributes:",{hasMtxId:!!o,hasMtxKey:!!i,hasMtxApiHost:!!s}),void vd("Please configure mtx-id, mtx-key and mtx-api-host","error")}const a={mtxId:o,mtxKey:i,mtxApiHost:s};"false"===n.getAttribute("mtx-use-screenshare")&&(a.use_screenshare=!1),e(a).catch(e=>console.error("[AutoInit] Failed to initialize widget:",e))})(Id)}catch(e){console.error("Marketrix Widget: Auto-init registration failed",e)}},0);var Ad={MarketrixWidgetPreview:Rd,mountWidget:Od,initWidget:Id,unmountWidget:Md,updateMarketrixConfig:Td,getCurrentConfig:bd};export{Rd as MarketrixWidgetPreview,Ad as default,bd as getCurrentConfig,Id as initWidget,Od as mountWidget,Md as unmountWidget,Td as updateMarketrixConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marketrix.ai/widget",
3
- "version": "4.0.116",
3
+ "version": "4.0.118",
4
4
  "type": "module",
5
5
  "packageManager": "bun@1.4.2",
6
6
  "sideEffects": false,
@@ -23,7 +23,7 @@
23
23
  "tag": "bash scripts/release.sh",
24
24
  "start": "vite",
25
25
  "build": "vite build",
26
- "ci": "bun run code:check && bun run test && bun run build && bun run bundle:check",
26
+ "ci": "bun run code:check && bun run build && bun run test && bun run bundle:check",
27
27
  "lint": "eslint . --max-warnings 0 --fix",
28
28
  "type-check": "tsc --noEmit",
29
29
  "test": "bun test --isolate",
@@ -35,10 +35,10 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@base-ui/react": "^1.8.0",
38
- "@orpc/client": "^1.15.0",
39
- "@orpc/contract": "^1.15.0",
40
- "@rrweb/record": "^2.1.1",
41
- "zod": "~4.5.4"
38
+ "@orpc/client": "^1.15.1",
39
+ "@orpc/contract": "^1.15.1",
40
+ "@rrweb/record": "^2.1.4",
41
+ "zod": "~4.6.5"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": "^19.2.3",
@@ -46,15 +46,15 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@eslint/js": "^10.0.1",
49
- "@rrweb/types": "^2.0.0-alpha.20",
49
+ "@rrweb/types": "^2.1.4",
50
50
  "@testing-library/jest-dom": "^7.0.1",
51
51
  "@testing-library/react": "^16.3.3",
52
52
  "@types/jsdom": "^30.0.0",
53
- "@types/node": "^26.4.1",
54
- "@types/react": "^19.2.18",
55
- "@types/react-dom": "^19.2.7",
56
- "@typescript-eslint/eslint-plugin": "^8.69.0",
57
- "@typescript-eslint/parser": "^8.59.0",
53
+ "@types/node": "^26.6.1",
54
+ "@types/react": "^19.3.0",
55
+ "@types/react-dom": "^19.3.0",
56
+ "@typescript-eslint/eslint-plugin": "^8.70.0",
57
+ "@typescript-eslint/parser": "^8.70.0",
58
58
  "@vitejs/plugin-react": "^6.1.1",
59
59
  "axe-core": "^4.13.0",
60
60
  "bun-types": "1.4.2",
@@ -64,12 +64,12 @@
64
64
  "eslint-plugin-simple-import-sort": "^14.0.0",
65
65
  "eslint-plugin-unused-imports": "^4.4.1",
66
66
  "jsdom": "^30.0.1",
67
- "lefthook": "^2.1.12",
68
- "prettier": "^3.9.6",
69
- "react": "^19.2.8",
70
- "react-dom": "^19.2.8",
67
+ "lefthook": "^2.1.14",
68
+ "prettier": "^3.9.7",
69
+ "react": "^19.3.0",
70
+ "react-dom": "^19.3.0",
71
71
  "terser": "^5.51.2",
72
72
  "typescript": "^6.0.3",
73
- "vite": "^8.2.2"
73
+ "vite": "^8.3.0"
74
74
  }
75
75
  }