@marketrix.ai/widget 3.8.9 → 3.8.40

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.
Files changed (215) hide show
  1. package/README.md +159 -161
  2. package/dist/src/components/MarketrixWidget.d.ts +0 -1
  3. package/dist/src/components/base/Avatar.d.ts +0 -1
  4. package/dist/src/components/base/Badge.d.ts +0 -1
  5. package/dist/src/components/base/Button.d.ts +0 -1
  6. package/dist/src/components/base/Card.d.ts +0 -1
  7. package/dist/src/components/base/Dialog.d.ts +6 -7
  8. package/dist/src/components/base/Flex.d.ts +0 -1
  9. package/dist/src/components/base/Icon.d.ts +0 -1
  10. package/dist/src/components/base/IconButton.d.ts +0 -1
  11. package/dist/src/components/base/Indicator.d.ts +0 -1
  12. package/dist/src/components/base/Menu.d.ts +4 -5
  13. package/dist/src/components/base/Pill.d.ts +0 -1
  14. package/dist/src/components/base/Spinner.d.ts +0 -1
  15. package/dist/src/components/base/Stack.d.ts +0 -1
  16. package/dist/src/components/base/Surface.d.ts +0 -1
  17. package/dist/src/components/base/Text.d.ts +0 -1
  18. package/dist/src/components/base/Textarea.d.ts +0 -1
  19. package/dist/src/components/base/Video.d.ts +0 -1
  20. package/dist/src/components/base/icons.d.ts +0 -1
  21. package/dist/src/components/base/layoutProps.d.ts +0 -1
  22. package/dist/src/components/base/tokens.d.ts +0 -1
  23. package/dist/src/components/base/useDisclosure.d.ts +0 -1
  24. package/dist/src/components/blocks/ChatInput.d.ts +0 -1
  25. package/dist/src/components/blocks/HeaderBar.d.ts +0 -1
  26. package/dist/src/components/blocks/NotificationToast.d.ts +0 -1
  27. package/dist/src/components/blocks/TabBar.d.ts +1 -2
  28. package/dist/src/components/blocks/WidgetDialog.d.ts +0 -1
  29. package/dist/src/components/blocks/WidgetFab.d.ts +0 -1
  30. package/dist/src/components/chat/MessageContent.d.ts +0 -1
  31. package/dist/src/components/chat/MessageItem.d.ts +0 -1
  32. package/dist/src/components/chat/MessageList.d.ts +1 -2
  33. package/dist/src/components/chat/ProgressLine.d.ts +0 -1
  34. package/dist/src/components/chat/SuggestedActions.d.ts +0 -1
  35. package/dist/src/components/chat/TaskStatusIcon.d.ts +0 -1
  36. package/dist/src/components/chat/ThinkingIndicator.d.ts +0 -1
  37. package/dist/src/components/chat/VideoStreamDisplay.d.ts +0 -1
  38. package/dist/src/components/navigation/MessengerShell.d.ts +0 -1
  39. package/dist/src/components/navigation/ResizeHandles.d.ts +0 -1
  40. package/dist/src/components/navigation/ShellTabBar.d.ts +0 -1
  41. package/dist/src/components/navigation/ViewTransition.d.ts +0 -1
  42. package/dist/src/components/ui/StateMessage.d.ts +0 -1
  43. package/dist/src/components/ui/WidgetSettingsLoader.d.ts +1 -2
  44. package/dist/src/components/views/ChatView.d.ts +0 -1
  45. package/dist/src/components/views/HomeView.d.ts +0 -1
  46. package/dist/src/constants/config.d.ts +0 -1
  47. package/dist/src/constants/theme.d.ts +0 -1
  48. package/dist/src/context/ChatContext.d.ts +0 -1
  49. package/dist/src/context/TaskContext.d.ts +0 -1
  50. package/dist/src/context/UIStateContext.d.ts +0 -1
  51. package/dist/src/context/WidgetProviders.d.ts +0 -1
  52. package/dist/src/context/sseReducer.d.ts +0 -1
  53. package/dist/src/design-system/component-tokens.d.ts +0 -1
  54. package/dist/src/design-system/layers.d.ts +0 -1
  55. package/dist/src/design-system/semantic-tokens.d.ts +0 -1
  56. package/dist/src/design-system/shadows.d.ts +0 -1
  57. package/dist/src/design-system/token-adapter.d.ts +0 -1
  58. package/dist/src/hooks/useDragSnap.d.ts +0 -1
  59. package/dist/src/hooks/useFocusTrap.d.ts +0 -1
  60. package/dist/src/hooks/useResize.d.ts +0 -1
  61. package/dist/src/hooks/useScreenShare.d.ts +0 -1
  62. package/dist/src/hooks/useScrollLock.d.ts +0 -1
  63. package/dist/src/hooks/useWidget.d.ts +0 -1
  64. package/dist/src/index.d.ts +0 -1
  65. package/dist/src/lib/utils.d.ts +0 -1
  66. package/dist/src/sdk/contract.d.ts +0 -371
  67. package/dist/src/sdk/contracts/activityLog.d.ts +0 -25
  68. package/dist/src/sdk/contracts/application.d.ts +54 -5
  69. package/dist/src/sdk/contracts/chat.d.ts +0 -1
  70. package/dist/src/sdk/contracts/common.d.ts +10 -14
  71. package/dist/src/sdk/contracts/entities.d.ts +12 -271
  72. package/dist/src/sdk/contracts/widget.d.ts +0 -973
  73. package/dist/src/sdk/index.d.ts +1 -372
  74. package/dist/src/services/ApiService.d.ts +1 -3
  75. package/dist/src/services/ChatService.d.ts +2 -4
  76. package/dist/src/services/ConfigManager.d.ts +0 -1
  77. package/dist/src/services/DomService.d.ts +3 -4
  78. package/dist/src/services/ScreenShareService.d.ts +0 -6
  79. package/dist/src/services/SessionManager.d.ts +0 -1
  80. package/dist/src/services/SessionRecorder.d.ts +0 -1
  81. package/dist/src/services/ShowModeService.d.ts +0 -1
  82. package/dist/src/services/StorageService.d.ts +0 -1
  83. package/dist/src/services/StreamClient.d.ts +0 -2
  84. package/dist/src/services/ToolService.d.ts +3 -4
  85. package/dist/src/services/ValidationService.d.ts +9 -12
  86. package/dist/src/services/WidgetService.d.ts +0 -2
  87. package/dist/src/test/a11y-utils.d.ts +0 -1
  88. package/dist/src/test/fixtures.d.ts +0 -1
  89. package/dist/src/test/setup.d.ts +0 -1
  90. package/dist/src/types/browserTools.d.ts +0 -7
  91. package/dist/src/types/index.d.ts +3 -10
  92. package/dist/src/utils/apiUtils.d.ts +0 -1
  93. package/dist/src/utils/bootstrap.d.ts +0 -1
  94. package/dist/src/utils/chat.d.ts +0 -11
  95. package/dist/src/utils/common.d.ts +0 -1
  96. package/dist/src/utils/dom.d.ts +0 -6
  97. package/dist/src/utils/format.d.ts +0 -1
  98. package/dist/src/utils/suggestedActions.d.ts +0 -1
  99. package/dist/src/utils/validation.d.ts +0 -5
  100. package/dist/src/utils/widgetPositioning.d.ts +0 -1
  101. package/dist/widget.mjs +65 -65
  102. package/dist/widget.mjs.map +1 -1
  103. package/package.json +12 -12
  104. package/dist/index.html +0 -1697
  105. package/dist/src/components/MarketrixWidget.d.ts.map +0 -1
  106. package/dist/src/components/base/Avatar.d.ts.map +0 -1
  107. package/dist/src/components/base/Badge.d.ts.map +0 -1
  108. package/dist/src/components/base/Button.d.ts.map +0 -1
  109. package/dist/src/components/base/Card.d.ts.map +0 -1
  110. package/dist/src/components/base/Dialog.d.ts.map +0 -1
  111. package/dist/src/components/base/Flex.d.ts.map +0 -1
  112. package/dist/src/components/base/Icon.d.ts.map +0 -1
  113. package/dist/src/components/base/IconButton.d.ts.map +0 -1
  114. package/dist/src/components/base/Indicator.d.ts.map +0 -1
  115. package/dist/src/components/base/Menu.d.ts.map +0 -1
  116. package/dist/src/components/base/Pill.d.ts.map +0 -1
  117. package/dist/src/components/base/Spinner.d.ts.map +0 -1
  118. package/dist/src/components/base/Stack.d.ts.map +0 -1
  119. package/dist/src/components/base/Surface.d.ts.map +0 -1
  120. package/dist/src/components/base/Text.d.ts.map +0 -1
  121. package/dist/src/components/base/Textarea.d.ts.map +0 -1
  122. package/dist/src/components/base/Video.d.ts.map +0 -1
  123. package/dist/src/components/base/icons.d.ts.map +0 -1
  124. package/dist/src/components/base/index.d.ts +0 -22
  125. package/dist/src/components/base/index.d.ts.map +0 -1
  126. package/dist/src/components/base/layoutProps.d.ts.map +0 -1
  127. package/dist/src/components/base/tokens.d.ts.map +0 -1
  128. package/dist/src/components/base/useDisclosure.d.ts.map +0 -1
  129. package/dist/src/components/blocks/ChatInput.d.ts.map +0 -1
  130. package/dist/src/components/blocks/HeaderBar.d.ts.map +0 -1
  131. package/dist/src/components/blocks/NotificationToast.d.ts.map +0 -1
  132. package/dist/src/components/blocks/TabBar.d.ts.map +0 -1
  133. package/dist/src/components/blocks/WidgetDialog.d.ts.map +0 -1
  134. package/dist/src/components/blocks/WidgetFab.d.ts.map +0 -1
  135. package/dist/src/components/blocks/index.d.ts +0 -7
  136. package/dist/src/components/blocks/index.d.ts.map +0 -1
  137. package/dist/src/components/chat/MessageContent.d.ts.map +0 -1
  138. package/dist/src/components/chat/MessageItem.d.ts.map +0 -1
  139. package/dist/src/components/chat/MessageList.d.ts.map +0 -1
  140. package/dist/src/components/chat/ProgressLine.d.ts.map +0 -1
  141. package/dist/src/components/chat/SuggestedActions.d.ts.map +0 -1
  142. package/dist/src/components/chat/TaskStatusIcon.d.ts.map +0 -1
  143. package/dist/src/components/chat/ThinkingIndicator.d.ts.map +0 -1
  144. package/dist/src/components/chat/VideoStreamDisplay.d.ts.map +0 -1
  145. package/dist/src/components/navigation/MessengerShell.d.ts.map +0 -1
  146. package/dist/src/components/navigation/ResizeHandles.d.ts.map +0 -1
  147. package/dist/src/components/navigation/ShellTabBar.d.ts.map +0 -1
  148. package/dist/src/components/navigation/ViewTransition.d.ts.map +0 -1
  149. package/dist/src/components/ui/StateMessage.d.ts.map +0 -1
  150. package/dist/src/components/ui/WidgetSettingsLoader.d.ts.map +0 -1
  151. package/dist/src/components/views/ChatView.d.ts.map +0 -1
  152. package/dist/src/components/views/HomeView.d.ts.map +0 -1
  153. package/dist/src/constants/config.d.ts.map +0 -1
  154. package/dist/src/constants/theme.d.ts.map +0 -1
  155. package/dist/src/context/ChatContext.d.ts.map +0 -1
  156. package/dist/src/context/TaskContext.d.ts.map +0 -1
  157. package/dist/src/context/UIStateContext.d.ts.map +0 -1
  158. package/dist/src/context/WidgetProviders.d.ts.map +0 -1
  159. package/dist/src/context/sseReducer.d.ts.map +0 -1
  160. package/dist/src/design-system/component-tokens.d.ts.map +0 -1
  161. package/dist/src/design-system/layers.d.ts.map +0 -1
  162. package/dist/src/design-system/semantic-tokens.d.ts.map +0 -1
  163. package/dist/src/design-system/shadows.d.ts.map +0 -1
  164. package/dist/src/design-system/themes/default.d.ts +0 -7
  165. package/dist/src/design-system/themes/default.d.ts.map +0 -1
  166. package/dist/src/design-system/themes/high-contrast.d.ts +0 -4
  167. package/dist/src/design-system/themes/high-contrast.d.ts.map +0 -1
  168. package/dist/src/design-system/themes/index.d.ts +0 -3
  169. package/dist/src/design-system/themes/index.d.ts.map +0 -1
  170. package/dist/src/design-system/token-adapter.d.ts.map +0 -1
  171. package/dist/src/hooks/useDragSnap.d.ts.map +0 -1
  172. package/dist/src/hooks/useFocusTrap.d.ts.map +0 -1
  173. package/dist/src/hooks/useResize.d.ts.map +0 -1
  174. package/dist/src/hooks/useScreenShare.d.ts.map +0 -1
  175. package/dist/src/hooks/useScrollLock.d.ts.map +0 -1
  176. package/dist/src/hooks/useWidget.d.ts.map +0 -1
  177. package/dist/src/index.d.ts.map +0 -1
  178. package/dist/src/lib/utils.d.ts.map +0 -1
  179. package/dist/src/sdk/contract.d.ts.map +0 -1
  180. package/dist/src/sdk/contracts/activityLog.d.ts.map +0 -1
  181. package/dist/src/sdk/contracts/agent.d.ts +0 -3243
  182. package/dist/src/sdk/contracts/agent.d.ts.map +0 -1
  183. package/dist/src/sdk/contracts/application.d.ts.map +0 -1
  184. package/dist/src/sdk/contracts/chat.d.ts.map +0 -1
  185. package/dist/src/sdk/contracts/common.d.ts.map +0 -1
  186. package/dist/src/sdk/contracts/entities.d.ts.map +0 -1
  187. package/dist/src/sdk/contracts/widget.d.ts.map +0 -1
  188. package/dist/src/sdk/index.d.ts.map +0 -1
  189. package/dist/src/services/ApiService.d.ts.map +0 -1
  190. package/dist/src/services/ChatService.d.ts.map +0 -1
  191. package/dist/src/services/ConfigManager.d.ts.map +0 -1
  192. package/dist/src/services/DomService.d.ts.map +0 -1
  193. package/dist/src/services/ScreenShareService.d.ts.map +0 -1
  194. package/dist/src/services/SessionManager.d.ts.map +0 -1
  195. package/dist/src/services/SessionRecorder.d.ts.map +0 -1
  196. package/dist/src/services/ShowModeService.d.ts.map +0 -1
  197. package/dist/src/services/StorageService.d.ts.map +0 -1
  198. package/dist/src/services/StreamClient.d.ts.map +0 -1
  199. package/dist/src/services/ToolService.d.ts.map +0 -1
  200. package/dist/src/services/ValidationService.d.ts.map +0 -1
  201. package/dist/src/services/WidgetService.d.ts.map +0 -1
  202. package/dist/src/test/a11y-utils.d.ts.map +0 -1
  203. package/dist/src/test/fixtures.d.ts.map +0 -1
  204. package/dist/src/test/setup.d.ts.map +0 -1
  205. package/dist/src/types/browserTools.d.ts.map +0 -1
  206. package/dist/src/types/index.d.ts.map +0 -1
  207. package/dist/src/utils/apiUtils.d.ts.map +0 -1
  208. package/dist/src/utils/bootstrap.d.ts.map +0 -1
  209. package/dist/src/utils/chat.d.ts.map +0 -1
  210. package/dist/src/utils/common.d.ts.map +0 -1
  211. package/dist/src/utils/dom.d.ts.map +0 -1
  212. package/dist/src/utils/format.d.ts.map +0 -1
  213. package/dist/src/utils/suggestedActions.d.ts.map +0 -1
  214. package/dist/src/utils/validation.d.ts.map +0 -1
  215. package/dist/src/utils/widgetPositioning.d.ts.map +0 -1
package/dist/widget.mjs CHANGED
@@ -1,66 +1,66 @@
1
- import*as e from"react";import t,{createContext as r,createElement as n,forwardRef as i,useCallback as o,useContext as s,useEffect as a,useId as l,useLayoutEffect as c,useMemo as d,useRef as u,useState as h}from"react";import{createRoot as p}from"react-dom/client";import{Fragment as f,jsx as m,jsxs as g}from"react/jsx-runtime";var y=2147483002,w=2147483001,b=2147483005;function v(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function x(e){return function(e){const t=v(e);if(!t)return.5;const[r,n,i]=[t.r/255,t.g/255,t.b/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*r+.7152*n+.0722*i}(e)>.5?"#000000":"#ffffff"}function k(e,t){if(e.startsWith("rgba")||e.startsWith("rgb")){const r=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(r)return`rgba(${r[1]}, ${r[2]}, ${r[3]}, ${t})`}const r=v(e);return r?`rgba(${r.r}, ${r.g}, ${r.b}, ${t})`:(e.includes("gradient")||e.includes("linear-gradient"),e)}function S(e,t){const r=v(e);if(!r)return e;const n=1-t;return i=Math.round(r.r*n),o=Math.round(r.g*n),s=Math.round(r.b*n),`#${[i,o,s].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var i,o,s}var C=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),I=e=>{switch(e){case"show":return"Show";case"tell":return"Tell";case"do":return"Do";default:return e}},_={widget_background_color:"#ffffff",widget_text_color:"#1f2937",widget_border_color:"#e5e7eb",widget_accent_color:"#3b82f6",widget_secondary_color:"#6b7280",widget_border_radius:"20px",widget_font_size:"14px",widget_width:"400px",widget_height:"600px",widget_shadow:"0 5px 40px 0 rgba(0, 0, 0, 0.3)",widget_animation_duration:"300ms",widget_fade_duration:"200ms"};function A(e){return{color:{background:e.widget_background_color,foreground:e.widget_text_color,foregroundMuted:k(e.widget_text_color,.6),foregroundFaint:k(e.widget_text_color,.4),border:e.widget_border_color,borderMuted:k(e.widget_border_color,.3),primary:e.widget_accent_color,primaryForeground:x(e.widget_accent_color),primaryHover:k(e.widget_accent_color,.85),primaryMuted:k(e.widget_accent_color,.3),secondary:e.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:k(e.widget_secondary_color,.2),secondaryHover:k(e.widget_secondary_color,.3)},radius:e.widget_border_radius,shadow:e.widget_shadow,typography:{fontSizeBase:e.widget_font_size},motion:{durationAnimation:e.widget_animation_duration,durationFade:e.widget_fade_duration},size:{widgetWidth:e.widget_width,widgetHeight:e.widget_height}}}A(_);function E(e){return Array.isArray(e)?e:null==e?[]:[e]}var z="orpc",M=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function T(e){let t;return()=>{if(t)return t.result;const r=e();return t={result:r},r}}function O(){return globalThis["__@orpc/shared@1.14.4/otel/config__"]}function R(e,t={},r){return(O()?.tracer)?.startSpan(e,t,r)}function N(e,t,r={}){if(!e)return;const n=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(n),r.signal?.aborted&&r.signal.reason===t||e.setStatus({code:2,message:n.message})}async function P({name:e,context:t,...r},n){const i=O()?.tracer;if(!i)return n();const o=async e=>{try{return await n(e)}catch(t){throw N(e,t,r),t}finally{e.end()}};return t?i.startActiveSpan(e,r,t,o):i.startActiveSpan(e,r,o)}async function L(e,t){const r=O();if(!e||!r)return t();const n=r.trace.setSpan(r.context.active(),e);return r.context.with(n,t)}function D(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var $=Symbol.asyncDispose??Symbol.for("asyncDispose"),F=class{#e=!1;#t=!1;#r;#n;constructor(e,t){this.#r=t,this.#n=function(e){let t=Promise.resolve();return(...r)=>t=t.catch(()=>{}).then(()=>e(...r))}(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.#r("next"))}})}next(){return this.#n()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#r("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#r("throw")),e}async[$](){this.#e=!0,this.#t||(this.#t=!0,await this.#r("dispose"))}[Symbol.asyncIterator](){return this}};function j({name:e,...t},r){let n;return new F(async()=>{n??=R(e);try{const e=await L(n,()=>r.next());return n?.addEvent(e.done?"completed":"yielded"),e}catch(i){throw N(n,i,t),i}},async e=>{try{"next"!==e&&await L(n,()=>r.return?.())}catch(i){throw N(n,i,t),i}finally{n?.end()}})}function B(e,t,r){const n=(t,i)=>{const o=e[i];return o?o({...t,next:(e=t)=>n(e,i+1)}):r(t)};return n(t,0)}function Z(e){if(e)return JSON.parse(e)}function W(e){return JSON.stringify(e)}function U(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function V(e){return!!e&&("object"==typeof e||"function"==typeof e)}function H(e,...t){return"function"==typeof e?e(...t):e}function G(e){return new Proxy(e,{get(e,t,r){const n=Reflect.get(e,t,r);return"then"!==t||"function"!=typeof n?n:new Proxy(n,{apply(t,r,n){if(2!==n.length||n.some(e=>{return!("function"==typeof(t=e)&&Y.test(t.toString()));var t}))return Reflect.apply(t,r,n);let i=!0;n[0].call(r,G(new Proxy(e,{get:(e,t,r)=>{if(!i||"then"!==t)return Reflect.get(e,t,r);i=!1}})))}})}})}var Y=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var J={BAD_REQUEST:{status:400,message:"Bad Request"},UNAUTHORIZED:{status:401,message:"Unauthorized"},FORBIDDEN:{status:403,message:"Forbidden"},NOT_FOUND:{status:404,message:"Not Found"},METHOD_NOT_SUPPORTED:{status:405,message:"Method Not Supported"},NOT_ACCEPTABLE:{status:406,message:"Not Acceptable"},TIMEOUT:{status:408,message:"Request Timeout"},CONFLICT:{status:409,message:"Conflict"},PRECONDITION_FAILED:{status:412,message:"Precondition Failed"},PAYLOAD_TOO_LARGE:{status:413,message:"Payload Too Large"},UNSUPPORTED_MEDIA_TYPE:{status:415,message:"Unsupported Media Type"},UNPROCESSABLE_CONTENT:{status:422,message:"Unprocessable Content"},TOO_MANY_REQUESTS:{status:429,message:"Too Many Requests"},CLIENT_CLOSED_REQUEST:{status:499,message:"Client Closed Request"},INTERNAL_SERVER_ERROR:{status:500,message:"Internal Server Error"},NOT_IMPLEMENTED:{status:501,message:"Not Implemented"},BAD_GATEWAY:{status:502,message:"Bad Gateway"},SERVICE_UNAVAILABLE:{status:503,message:"Service Unavailable"},GATEWAY_TIMEOUT:{status:504,message:"Gateway Timeout"}};var K=Symbol.for("__@orpc/client@1.14.4/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[K]??=/* @__PURE__ */new WeakSet;var X=globalThis[K],q=class extends Error{defined;code;status;data;constructor(e,...t){const r=function(e){return e[0]??{}}(t);if(void 0!==r.status&&!Q(r.status))throw new Error("[ORPCError] Invalid error status code.");const n=function(e,t){return t||J[e]?.message||e}(e,r.message);super(n,r),this.code=e,this.status=function(e,t){return t??J[e]?.status??500}(e,r.status),this.defined=r.defined??!1,this.data=r.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(X.has(this)){const t=function(e){return V(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&X.has(t))return!0}return super[Symbol.hasInstance](e)}};function Q(e){return e<200||e>=400}function ee(e){if(!U(e))return!1;const t=["defined","code","status","message","data"];return!Object.keys(e).some(e=>!t.includes(e))&&("defined"in e&&"boolean"==typeof e.defined&&"code"in e&&"string"==typeof e.code&&"status"in e&&"number"==typeof e.status&&Q(e.status)&&"message"in e&&"string"==typeof e.message)}function te(e,t={}){return new q(e.code,{...t,...e})}X.add(q);var re=class extends TypeError{},ne=class extends TypeError{},ie=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}};function oe(e){const t=e.replace(/\n+$/,"").split(/\n/),r={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const n of t){const e=n.indexOf(":"),t=-1===e?n:n.slice(0,e),i=-1===e?"":n.slice(e+1).replace(/^\s/,"");if(0===e)r.comments.push(i);else if("data"===t)r.data??="",r.data+=`${i}\n`;else if("event"===t)r.event=i;else if("id"===t)r.id=i;else if("retry"===t){const e=Number.parseInt(i);Number.isInteger(e)&&e>=0&&e.toString()===i&&(r.retry=e)}}return r.data=r.data?.replace(/\n$/,""),r}var se=class{constructor(e={}){this.options=e}incomplete="";feed(e){this.incomplete+=e;const t=this.incomplete.lastIndexOf("\n\n");if(-1===t)return;const r=this.incomplete.slice(0,t).split(/\n\n/);this.incomplete=this.incomplete.slice(t+2);for(const n of r){const e=oe(`${n}\n\n`);this.options.onEvent&&this.options.onEvent(e)}}end(){if(this.incomplete)throw new ne("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new se({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function le(e){if(e.includes("\n"))throw new re("Event's id must not contain a newline character")}function ce(e){if(!Number.isInteger(e)||e<0)throw new re("Event's retry must be a integer and >= 0")}function de(e){if(e.includes("\n"))throw new re("Event's comment must not contain a newline character")}function ue(e){let t="";return t+=function(e){let t="";for(const r of e??[])de(r),t+=`: ${r}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new re("Event's event must not contain a newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(ce(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(le(e.id),t+=`id: ${e.id}\n`),t+=function(e){const t=e?.split(/\n/)??[];let r="";for(const n of t)r+=`data: ${n}\n`;return r}(e.data),t+="\n",t}var he=Symbol("ORPC_EVENT_SOURCE_META");function pe(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&le(t.id),void 0!==t.retry&&ce(t.retry),void 0!==t.comments)for(const r of t.comments)de(r);return new Proxy(e,{get:(e,r,n)=>r===he?t:Reflect.get(e,r,n)})}function fe(e){return V(e)?Reflect.get(e,he):void 0}function me(e){const t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&"string"==typeof t[2])return function(e){try{return decodeURIComponent(e)}catch{return e}}(t[2]);const r=e.match(/filename="((?:\\"|[^"])*)"/i);return r&&"string"==typeof r[1]?r[1].replace(/\\"/g,'"'):void 0}function ge(e,t){const r=async e=>{let r=await t.error(e);if(r!==e){const t=fe(e);t&&V(r)&&(r=pe(r,t))}return r};return new F(async()=>{const{done:n,value:i}=await(async()=>{try{return await e.next()}catch(t){throw await r(t)}})();let o=await t.value(i,n);if(o!==i){const e=fe(i);e&&V(o)&&(o=pe(o,e))}return{done:n,value:o}},async()=>{try{await(e.return?.())}catch(t){throw await r(t)}})}function ye(e,t={}){const r=t.path??[];return G(new Proxy(async(...[t,n={}])=>await e.call(r,t,function(e){return{...e,context:e.context??{}}}(n)),{get:(n,i)=>"string"!=typeof i?Reflect.get(n,i):ye(e,{...t,path:[...r,i]})}))}function we(e,t={}){return P({name:"parse_standard_body",signal:t.signal},async()=>{const r=e.headers.get("content-disposition");if("string"==typeof r){const t=me(r)??"blob",n=await e.blob();return new File([n],t,{type:n.type})}const n=e.headers.get("content-type");if(!n||n.startsWith("application/json"))return Z(await e.text());if(n.startsWith("multipart/form-data"))return await e.formData();if(n.startsWith("application/x-www-form-urlencoded")){const t=await e.text();return new URLSearchParams(t)}if(n.startsWith("text/event-stream"))return function(e,t={}){const r=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new ae))?.getReader();let n,i=!1;return new F(async()=>{n??=R("consume_event_iterator_stream");try{for(;;){if(void 0===r)return{done:!0,value:void 0};const{done:e,value:t}=await L(n,()=>r.read());if(e){if(i)throw new M("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=Z(t.data);return V(e)&&(e=pe(e,t)),n?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new ie({data:Z(t.data)});throw e=pe(e,t),n?.addEvent("error"),e}case"done":{let e=Z(t.data);return V(e)&&(e=pe(e,t)),n?.addEvent("done"),{done:!0,value:e}}default:n?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof ie||N(n,e,t),e}},async e=>{try{"next"!==e&&(i=!0,n?.addEvent("cancelled")),await L(n,()=>r?.cancel())}catch(o){throw N(n,o,t),o}finally{n?.end()}})}(e.body,t);if(n.startsWith("text/plain"))return await e.text();const i=await e.blob();return new File([i],"blob",{type:i.type})})}function be(e,t,r={}){if(e instanceof ReadableStream)return e;const n=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",n??function(e,t="inline"){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}(e instanceof File?e.name:"blob")),e):e instanceof FormData||e instanceof URLSearchParams?e:D(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const r=t.eventIteratorKeepAliveEnabled??!0,n=t.eventIteratorKeepAliveInterval??5e3,i=t.eventIteratorKeepAliveComment??"",o=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,l,c=!1;return new ReadableStream({start(e){l=R("stream_event_iterator"),o&&e.enqueue(ue({comments:[s]}))},async pull(t){try{r&&(a=setInterval(()=>{t.enqueue(ue({comments:[i]})),l?.addEvent("keepalive")},n));const o=await L(l,()=>e.next());if(clearInterval(a),c)return;const s=fe(o.value);if(!o.done||void 0!==o.value||void 0!==s){const e=o.done?"done":"message";t.enqueue(ue({...s,event:e,data:W(o.value)})),l?.addEvent(e)}o.done&&(t.close(),l?.end())}catch(o){if(clearInterval(a),c)return;o instanceof ie?(t.enqueue(ue({...fe(o),event:"error",data:W(o.data)})),l?.addEvent("error"),t.close()):(N(l,o),t.error(o)),l?.end()}},async cancel(){try{c=!0,clearInterval(a),l?.addEvent("cancelled"),await L(l,()=>e.return?.())}catch(t){throw N(l,t),t}finally{l?.end()}}}).pipeThrough(new TextEncoderStream)}(e,r)):(t.set("content-type","application/json"),W(e)):void 0}function ve(e,t={}){return e.forEach((e,r)=>{Array.isArray(t[r])?t[r].push(e):void 0!==t[r]?t[r]=[t[r],e]:t[r]=e}),t}function xe(e,t={}){const r=function(e,t=new Headers){for(const[r,n]of Object.entries(e))if(Array.isArray(n))for(const e of n)t.append(r,e);else void 0!==n&&t.append(r,n);return t}(e.headers),n=be(e.body,r,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:r,body:n})}var ke=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(const t of this.plugins)t.init?.(e)}},Se=class{constructor(e,t,r={}){this.codec=e,this.sender=t,new ke(r.plugins).init(r),this.interceptors=E(r.interceptors),this.clientInterceptors=E(r.clientInterceptors)}interceptors;clientInterceptors;call(e,t,r){return P({name:`${z}.${e.join("/")}`,signal:r.signal},n=>(n?.setAttribute("rpc.system",z),n?.setAttribute("rpc.method",e.join(".")),D(t)&&(t=j({name:"consume_event_iterator_input",signal:r.signal},t)),B(this.interceptors,{...r,path:e,input:t},async({path:e,input:t,...r})=>{const i=O();let o;const s=i?.trace.getActiveSpan()??n;s&&i&&(o=i?.trace.setSpan(i.context.active(),s));const a=await P({name:"encode_request",context:o},()=>this.codec.encode(e,t,r)),l=await B(this.clientInterceptors,{...r,input:t,path:e,request:a},({input:e,path:t,request:r,...n})=>P({name:"send_request",signal:n.signal,context:o},()=>this.sender.call(r,n,t,e))),c=await P({name:"decode_response",context:o},()=>this.codec.decode(l,r,e,t));return D(c)?j({name:"consume_event_iterator_output",signal:r.signal},c):c})))}},Ce=0,Ie=1,_e=2,Ae=3,Ee=4,ze=5,Me=6,Te=7,Oe=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],r=[],n=[],i=[]){for(const o of this.customSerializers)if(o.condition(e)){const s=this.serialize(o.serialize(e),t,r,n,i);return r.push([o.type,...t]),s}if(e instanceof Blob)return n.push(t),i.push(e),[e,r,n,i];if("bigint"==typeof e)return r.push([Ce,...t]),[e.toString(),r,n,i];if(e instanceof Date)return r.push([Ie,...t]),Number.isNaN(e.getTime())?[null,r,n,i]:[e.toISOString(),r,n,i];if(Number.isNaN(e))return r.push([_e,...t]),[null,r,n,i];if(e instanceof URL)return r.push([Ee,...t]),[e.toString(),r,n,i];if(e instanceof RegExp)return r.push([ze,...t]),[e.toString(),r,n,i];if(e instanceof Set){const o=this.serialize(Array.from(e),t,r,n,i);return r.push([Me,...t]),o}if(e instanceof Map){const o=this.serialize(Array.from(e.entries()),t,r,n,i);return r.push([Te,...t]),o}if(Array.isArray(e))return[e.map((e,o)=>void 0===e?(r.push([Ae,...t,o]),null):this.serialize(e,[...t,o],r,n,i)[0]),r,n,i];if(U(e)){const o={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(o[s]=this.serialize(e[s],[...t,s],r,n,i)[0]);return[o,r,n,i]}return[e,r,n,i]}deserialize(e,t,r,n){const i={data:e};r&&n&&r.forEach((e,t)=>{let r=i,o="data";e.forEach(e=>{if(r=r[o],o=e,!Object.hasOwn(r,o))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${o}`)}),r[o]=n(t)});for(const o of t){const e=o[0];let t=i,r="data";for(let n=1;n<o.length;n++)if(t=t[r],r=o[n],!Object.hasOwn(t,r))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${r}`);for(const n of this.customSerializers)if(n.type===e){t[r]=n.deserialize(t[r]);break}switch(e){case Ce:t[r]=BigInt(t[r]);break;case Ie:t[r]=new Date(t[r]??"Invalid Date");break;case _e:t[r]=NaN;break;case Ae:t[r]=void 0;break;case Ee:t[r]=new URL(t[r]);break;case ze:{const[,e,n]=t[r].match(/^\/(.*)\/([a-z]*)$/);t[r]=new RegExp(e,n);break}case Me:t[r]=new Set(t[r]);break;case Te:t[r]=new Map(t[r])}}return i.data}};var Re,Ne=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??"POST",this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,r){let n=function(e){return"function"==typeof e.forEach?ve(e):e}(await H(this.headers,r,e,t));void 0!==r.lastEventId&&(n=function(e,t){const r={...e};for(const n in t)Array.isArray(t[n])?r[n]=[...E(r[n]),...t[n]]:void 0!==t[n]&&(Array.isArray(r[n])?r[n]=[...r[n],t[n]]:void 0!==r[n]?r[n]=[r[n],t[n]]:r[n]=t[n]);return r}(n,{"last-event-id":r.lastEventId}));const i=await H(this.expectedMethod,r,e,t),o=await H(this.baseUrl,r,e,t),s=new URL(o);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==i||a instanceof FormData||D(a))){const o=await H(this.maxUrlLength,r,e,t),l=new URL(s);if(l.searchParams.append("data",W(a)),l.toString().length<=o)return{body:void 0,method:i,headers:n,url:l,signal:r.signal}}return{url:s,method:"GET"===i?this.fallbackMethod:i,headers:n,body:a,signal:r.signal}}async decode(e){const t=!Q(e.status),r=await(async()=>{let t=!1;try{const r=await e.body();return t=!0,this.serializer.deserialize(r)}catch(r){if(!t)throw new Error("Cannot parse response body, please check the response body and content-type.",{cause:r});throw new Error("Invalid RPC response format.",{cause:r})}})();if(!t){if(ee(r))throw te(r);throw new q((n=e.status,Object.entries(J).find(([,e])=>e.status===n)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:r}})}var n;return r}},Pe=class{constructor(e){this.jsonSerializer=e}serialize(e){return D(e)?ge(e,{value:async e=>this.#i(e,!1),error:async e=>{return new ie({data:this.#i((t=e,t instanceof q?t:new q("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#i(e,!0)}#i(e,t){const[r,n,i,o]=this.jsonSerializer.serialize(e),s=0===n.length?void 0:n;if(!t||0===o.length)return{json:r,meta:s};const a=new FormData;return a.set("data",W({json:r,meta:s,maps:i})),o.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return D(e)?ge(e,{value:async e=>this.#o(e),error:async e=>{if(!(e instanceof ie))return e;const t=this.#o(e.data);return ee(t)?te(t,{cause:e}):new ie({data:t,cause:e})}}):this.#o(e)}#o(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},Le=class extends Se{constructor(e,t){super(new Ne(new Pe(new Oe(t)),t),e,t)}},De=class extends ke{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},$e=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new De(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=E(e.adapterInterceptors)}async call(e,t,r,n){const i=xe(e,this.toFetchRequestOptions);return function(e,t={}){return{body:T(()=>we(e,t)),status:e.status,get headers(){const t=ve(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await B(this.adapterInterceptors,{...t,request:i,path:r,input:n,init:{redirect:"manual"}},({request:e,path:t,input:r,init:n,...i})=>this.fetch(e,n,i,t,r)),{signal:i.signal})}},Fe=class extends Le{constructor(e){super(new $e(e),e)}};function je(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:s,traits:/* @__PURE__ */new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);const i=s.prototype,o=Object.keys(i);for(let e=0;e<o.length;e++){const t=o[e];t in r||(r[t]=i[t].bind(r))}}const i=r?.Parent??Object;class o extends i{}function s(e){var t;const i=r?.Parent?new o:this;n(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const r of i._zod.deferred)r();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Be=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ze=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Re=globalThis).__zod_globalConfig??(Re.__zod_globalConfig={});var We=globalThis.__zod_globalConfig;function Ue(e){return e&&Object.assign(We,e),We}function Ve(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function He(e,t){return"bigint"==typeof t?t.toString():t}function Ge(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ye(e){return null==e}function Je(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Ke=/* @__PURE__ */Symbol("evaluating");function Xe(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ke)return void 0===n&&(n=Ke,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function qe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Qe(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function et(e){return JSON.stringify(e)}var tt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var nt=/* @__PURE__ */Ge(()=>{if(We.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function it(e){if(!1===rt(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const r=t.prototype;return!1!==rt(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ot(e){return it(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var st=/* @__PURE__ */new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function ct(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}var dt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ut(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function ht(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(!1===e.issues[r]?.continue)return!0;return!1}function pt(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function ft(e){return"string"==typeof e?e:e?.message}function mt(e,t,r){const n=e.message?e.message:ft(e.inst?._zod.def?.error?.(e))??ft(t?.error?.(e))??ft(r.customError?.(e))??ft(r.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function gt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function yt(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}var wt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,He,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bt=je("$ZodError",wt),vt=je("$ZodError",wt,{Parent:Error});var xt=e=>(t,r,n,i)=>{const o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Be;if(s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>mt(e,o,Ue())));throw tt(t,i?.callee),t}return s.value},kt=e=>async(t,r,n,i)=>{const o=n?{...n,async:!0}:{async:!0};let s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>mt(e,o,Ue())));throw tt(t,i?.callee),t}return s.value},St=e=>(t,r,n)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Be;return o.issues.length?{success:!1,error:new(e??bt)(o.issues.map(e=>mt(e,i,Ue())))}:{success:!0,data:o.value}},Ct=/* @__PURE__ */St(vt),It=e=>async(t,r,n)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>mt(e,i,Ue())))}:{success:!0,data:o.value}},_t=/* @__PURE__ */It(vt),At=e=>(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return xt(e)(t,r,i)},Et=e=>(t,r,n)=>xt(e)(t,r,n),zt=e=>async(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return kt(e)(t,r,i)},Mt=e=>async(t,r,n)=>kt(e)(t,r,n),Tt=e=>(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return St(e)(t,r,i)},Ot=e=>(t,r,n)=>St(e)(t,r,n),Rt=e=>async(t,r,n)=>{const i=n?{...n,direction:"backward"}:{direction:"backward"};return It(e)(t,r,i)},Nt=e=>async(t,r,n)=>It(e)(t,r,n),Pt=/^[cC][0-9a-z]{6,}$/,Lt=/^[0-9a-z]+$/,Dt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$t=/^[0-9a-vA-V]{20}$/,Ft=/^[A-Za-z0-9]{27}$/,jt=/^[a-zA-Z0-9_-]{21}$/,Bt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Wt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ut=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Vt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Gt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Yt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Jt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kt=/^[A-Za-z0-9_-]*$/,Xt=/^https?$/,qt=/^\+[1-9]\d{6,14}$/,Qt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",er=/* @__PURE__ */new RegExp(`^${Qt}$`);function tr(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}var rr=/^-?\d+$/,nr=/^-?\d+(?:\.\d+)?$/,ir=/^(?:true|false)$/i,or=/^null$/i,sr=/^[^A-Z]*$/,ar=/^[^a-z]*$/,lr=/* @__PURE__ */je("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),cr={number:"number",bigint:"bigint",object:"date"},dr=/* @__PURE__ */je("$ZodCheckLessThan",(e,t)=>{lr.init(e,t);const r=cr[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ur=/* @__PURE__ */je("$ZodCheckGreaterThan",(e,t)=>{lr.init(e,t);const r=cr[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hr=/* @__PURE__ */je("$ZodCheckMultipleOf",(e,t)=>{lr.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value!==BigInt(0):0!==function(e,t){const r=e/t,n=Math.round(r),i=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}(r.value,t.value))&&r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),pr=/* @__PURE__ */je("$ZodCheckNumberFormat",(e,t)=>{lr.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[i,o]=dt[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=i,n.maximum=o,r&&(n.pattern=rr)}),e._zod.check=s=>{const a=s.value;if(r){if(!Number.isInteger(a))return void s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}))}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),fr=/* @__PURE__ */je("$ZodCheckMaxLength",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Ye(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const n=r.value;if(n.length<=t.maximum)return;const i=gt(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),mr=/* @__PURE__ */je("$ZodCheckMinLength",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Ye(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const i=gt(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),gr=/* @__PURE__ */je("$ZodCheckLengthEquals",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Ye(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{const n=r.value,i=n.length;if(i===t.length)return;const o=gt(n),s=i>t.length;r.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),yr=/* @__PURE__ */je("$ZodCheckStringFormat",(e,t)=>{var r,n;lr.init(e,t),e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=/* @__PURE__ */new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),wr=/* @__PURE__ */je("$ZodCheckRegex",(e,t)=>{yr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),br=/* @__PURE__ */je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sr),yr.init(e,t)}),vr=/* @__PURE__ */je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ar),yr.init(e,t)}),xr=/* @__PURE__ */je("$ZodCheckIncludes",(e,t)=>{lr.init(e,t);const r=at(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),kr=/* @__PURE__ */je("$ZodCheckStartsWith",(e,t)=>{lr.init(e,t);const r=new RegExp(`^${at(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Sr=/* @__PURE__ */je("$ZodCheckEndsWith",(e,t)=>{lr.init(e,t);const r=new RegExp(`.*${at(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Cr=/* @__PURE__ */je("$ZodCheckOverwrite",(e,t)=>{lr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Ir=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e);for(const i of n)this.content.push(i)}compile(){const e=Function,t=this?.args,r=[...(this?.content??[""]).map(e=>` ${e}`)];return new e(...t,r.join("\n"))}},_r={major:4,minor:4,patch:3},Ar=/* @__PURE__ */je("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_r;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const i of n)for(const t of i._zod.onattach)t(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,i=ut(e);for(const o of t){if(o._zod.def.when){if(ht(e))continue;if(!o._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&!1===r?.async)throw new Be;if(n||s instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(i||(i=ut(e,t)))});else{if(e.issues.length===t)continue;i||(i=ut(e,t))}}return n?n.then(()=>e):e},r=(r,i,o)=>{if(ut(r))return r.aborted=!0,r;const s=t(i,n,o);if(s instanceof Promise){if(!1===o.async)throw new Be;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(i,o)=>{if(o.skipChecks)return e._zod.parse(i,o);if("backward"===o.direction){const t=e._zod.parse({value:i.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,o)):r(t,i,o)}const s=e._zod.parse(i,o);if(s instanceof Promise){if(!1===o.async)throw new Be;return s.then(e=>t(e,n,o))}return t(s,n,o)}}Xe(e,"~standard",()=>({validate:t=>{try{const r=Ct(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return _t(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Er=/* @__PURE__ */je("$ZodString",(e,t)=>{var r;Ar.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),zr=/* @__PURE__ */je("$ZodStringFormat",(e,t)=>{yr.init(e,t),Er.init(e,t)}),Mr=/* @__PURE__ */je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Zt),zr.init(e,t)}),Tr=/* @__PURE__ */je("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wt(e))}else t.pattern??(t.pattern=Wt());zr.init(e,t)}),Or=/* @__PURE__ */je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ut),zr.init(e,t)}),Rr=/* @__PURE__ */je("$ZodURL",(e,t)=>{zr.init(e,t),e._zod.check=r=>{try{const n=r.value.trim();if(!t.normalize&&t.protocol?.source===Xt.source&&!/^https?:\/\//i.test(n))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});const i=new URL(n);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(t.normalize?r.value=i.href:r.value=n)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Nr=/* @__PURE__ */je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),zr.init(e,t)}),Pr=/* @__PURE__ */je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jt),zr.init(e,t)}),Lr=/* @__PURE__ */je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Pt),zr.init(e,t)}),Dr=/* @__PURE__ */je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),zr.init(e,t)}),$r=/* @__PURE__ */je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Dt),zr.init(e,t)}),Fr=/* @__PURE__ */je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=$t),zr.init(e,t)}),jr=/* @__PURE__ */je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ft),zr.init(e,t)}),Br=/* @__PURE__ */je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=tr({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Qt}T(?:${n})$`)}(t)),zr.init(e,t)}),Zr=/* @__PURE__ */je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=er),zr.init(e,t)}),Wr=/* @__PURE__ */je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${tr(t)}$`)),zr.init(e,t)}),Ur=/* @__PURE__ */je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bt),zr.init(e,t)}),Vr=/* @__PURE__ */je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vt),zr.init(e,t),e._zod.bag.format="ipv4"}),Hr=/* @__PURE__ */je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ht),zr.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Gr=/* @__PURE__ */je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Gt),zr.init(e,t)}),Yr=/* @__PURE__ */je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Yt),zr.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(2!==n.length)throw new Error;const[e,t]=n;if(!t)throw new Error;const r=Number(t);if(`${r}`!==t)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Jr(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Kr=/* @__PURE__ */je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Jt),zr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Jr(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});var Xr=/* @__PURE__ */je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Kt),zr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{(function(e){if(!Kt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Jr(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),qr=/* @__PURE__ */je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qt),zr.init(e,t)});var Qr=/* @__PURE__ */je("$ZodJWT",(e,t)=>{zr.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),en=/* @__PURE__ */je("$ZodNumber",(e,t)=>{Ar.init(e,t),e._zod.pattern=e._zod.bag.pattern??nr,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}const i=r.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return r;const o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),tn=/* @__PURE__ */je("$ZodNumberFormat",(e,t)=>{pr.init(e,t),en.init(e,t)}),rn=/* @__PURE__ */je("$ZodBoolean",(e,t)=>{Ar.init(e,t),e._zod.pattern=ir,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(o){}const i=r.value;return"boolean"==typeof i||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),nn=/* @__PURE__ */je("$ZodNull",(e,t)=>{Ar.init(e,t),e._zod.pattern=or,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),on=/* @__PURE__ */je("$ZodUnknown",(e,t)=>{Ar.init(e,t),e._zod.parse=e=>e}),sn=/* @__PURE__ */je("$ZodNever",(e,t)=>{Ar.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),an=/* @__PURE__ */je("$ZodDate",(e,t)=>{Ar.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(s){}const i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),r}});function ln(e,t,r){e.issues.length&&t.issues.push(...pt(r,e.issues)),t.value[r]=e.value}var cn=/* @__PURE__ */je("$ZodArray",(e,t)=>{Ar.init(e,t),e._zod.parse=(r,n)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);const o=[];for(let e=0;e<i.length;e++){const s=i[e],a=t.element._zod.run({value:s,issues:[]},n);a instanceof Promise?o.push(a.then(t=>ln(t,r,e))):ln(a,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function dn(e,t,r,n,i,o){const s=r in n;if(e.issues.length){if(i&&o&&!s)return;t.issues.push(...pt(r,e.issues))}s||i?void 0===e.value?s&&(t.value[r]=void 0):t.value[r]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]})}function un(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const r=(n=e.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function hn(e,t,r,n,i,o){const s=[],a=i.keySet,l=i.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(const h in t){if("__proto__"===h)continue;if(a.has(h))continue;if("never"===c){s.push(h);continue}const i=l.run({value:t[h],issues:[]},n);i instanceof Promise?e.push(i.then(e=>dn(e,r,h,t,d,u))):dn(i,r,h,t,d,u)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var pn=/* @__PURE__ */je("$ZodObject",(e,t)=>{if(Ar.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}const r=Ge(()=>un(t));Xe(e._zod,"propValues",()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=/* @__PURE__ */new Set);for(const e of n.values)r[t].add(e)}}return r});const n=rt,i=t.catchall;let o;e._zod.parse=(t,s)=>{o??(o=r.value);const a=t.value;if(!n(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const l=[],c=o.shape;for(const e of o.keys){const r=c[e],n="optional"===r._zod.optin,i="optional"===r._zod.optout,o=r._zod.run({value:a[e],issues:[]},s);o instanceof Promise?l.push(o.then(r=>dn(r,t,e,a,n,i))):dn(o,t,e,a,n,i)}return i?hn(l,a,t,s,r.value,e):l.length?Promise.all(l).then(()=>t):t}}),fn=/* @__PURE__ */je("$ZodObjectJIT",(e,t)=>{pn.init(e,t);const r=e._zod.parse,n=Ge(()=>un(t));let i;const o=rt,s=!We.jitless,a=s&&nt.value,l=t.catchall;let c;e._zod.parse=(d,u)=>{c??(c=n.value);const h=d.value;return o(h)?s&&a&&!1===u?.async&&!0!==u.jitless?(i||(i=(e=>{const t=new Ir(["shape","payload","ctx"]),r=n.value,i=e=>{const t=et(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const o=Object.create(null);let s=0;for(const n of r.keys)o[n]="key_"+s++;t.write("const newResult = {};");for(const n of r.keys){const r=o[n],s=et(n),a=e[n],l="optional"===a?._zod?.optin,c="optional"===a?._zod?.optout;t.write(`const ${r} = ${i(n)};`),l&&c?t.write(`\n if (${r}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${r}.value;\n }\n \n `):l?t.write(`\n if (${r}.issues.length) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${r}.value;\n }\n \n `):t.write(`\n const ${r}_present = ${s} in input;\n if (${r}.issues.length) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${r}_present && !${r}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${r}_present) {\n if (${r}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${r}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,r)=>a(e,t,r)})(t.shape)),d=i(d,u),l?hn([],h,d,u,c,e):d):r(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),d)}});function mn(e,t,r,n){for(const o of e)if(0===o.issues.length)return t.value=o.value,t;const i=e.filter(e=>!ut(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>mt(e,n,Ue())))}),t)}var gn=/* @__PURE__ */je("$ZodUnion",(e,t)=>{Ar.init(e,t),Xe(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Xe(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Xe(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Xe(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Je(e.source)).join("|")})$`)}});const r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:n.value,issues:[]},i);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>mn(t,n,e,i)):mn(s,n,e,i)}}),yn=/* @__PURE__ */je("$ZodIntersection",(e,t)=>{Ar.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,i=t.left._zod.run({value:n,issues:[]},r),o=t.right._zod.run({value:n,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,r])=>bn(e,t,r)):bn(e,i,o)}});function wn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(it(e)&&it(t)){const r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),i={...e,...t};for(const o of n){const r=wn(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};i[o]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const i=wn(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function bn(e,t,r){const n=/* @__PURE__ */new Map;let i;for(const a of t.issues)if("unrecognized_keys"===a.code){i??(i=a);for(const e of a.keys)n.has(e)||n.set(e,{}),n.get(e).l=!0}else e.issues.push(a);for(const a of r.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)n.has(e)||n.set(e,{}),n.get(e).r=!0;else e.issues.push(a);const o=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(o.length&&i&&e.issues.push({...i,keys:o}),ut(e))return e;const s=wn(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var vn=/* @__PURE__ */je("$ZodRecord",(e,t)=>{Ar.init(e,t),e._zod.parse=(r,n)=>{const i=r.value;if(!it(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;const o=[],s=t.keyType._zod.values;if(s){r.value={};const a=/* @__PURE__ */new Set;for(const c of s)if("string"==typeof c||"number"==typeof c||"symbol"==typeof c){a.add("number"==typeof c?c.toString():c);const s=t.keyType._zod.run({value:c,issues:[]},n);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>mt(e,n,Ue())),input:c,path:[c],inst:e});continue}const l=s.value,d=t.valueType._zod.run({value:i[c],issues:[]},n);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...pt(c,e.issues)),r.value[l]=e.value})):(d.issues.length&&r.issues.push(...pt(c,d.issues)),r.value[l]=d.value)}let l;for(const e in i)a.has(e)||(l=l??[],l.push(e));l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{r.value={};for(const s of Reflect.ownKeys(i)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(i,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&nr.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},n);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?r.value[s]=i[s]:r.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>mt(e,n,Ue())),input:s,path:[s],inst:e});continue}const l=t.valueType._zod.run({value:i[s],issues:[]},n);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&r.issues.push(...pt(s,e.issues)),r.value[a.value]=e.value})):(l.issues.length&&r.issues.push(...pt(s,l.issues)),r.value[a.value]=l.value)}}return o.length?Promise.all(o).then(()=>r):r}}),xn=/* @__PURE__ */je("$ZodEnum",(e,t)=>{Ar.init(e,t);const r=Ve(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(e=>st.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const o=t.value;return n.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),kn=/* @__PURE__ */je("$ZodLiteral",(e,t)=>{if(Ar.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?at(e):e?at(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,i)=>{const o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),Sn=/* @__PURE__ */je("$ZodTransform",(e,t)=>{Ar.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Ze(e.constructor.name);const i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(r.value=e,r.fallback=!0,r));if(i instanceof Promise)throw new Be;return r.value=i,r.fallback=!0,r}});function Cn(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var In=/* @__PURE__ */je("$ZodOptional",(e,t)=>{Ar.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Xe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Xe(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Je(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){const n=e.value,i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(e=>Cn(e,n)):Cn(i,n)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),_n=/* @__PURE__ */je("$ZodExactOptional",(e,t)=>{In.init(e,t),Xe(e._zod,"values",()=>t.innerType._zod.values),Xe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),An=/* @__PURE__ */je("$ZodNullable",(e,t)=>{Ar.init(e,t),Xe(e._zod,"optin",()=>t.innerType._zod.optin),Xe(e._zod,"optout",()=>t.innerType._zod.optout),Xe(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Je(e.source)}|null)$`):void 0}),Xe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),En=/* @__PURE__ */je("$ZodDefault",(e,t)=>{Ar.init(e,t),e._zod.optin="optional",Xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>zn(e,t)):zn(n,t)}});function zn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Mn=/* @__PURE__ */je("$ZodPrefault",(e,t)=>{Ar.init(e,t),e._zod.optin="optional",Xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),Tn=/* @__PURE__ */je("$ZodNonOptional",(e,t)=>{Ar.init(e,t),Xe(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(t=>On(t,e)):On(i,e)}});function On(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Rn=/* @__PURE__ */je("$ZodCatch",(e,t)=>{Ar.init(e,t),e._zod.optin="optional",Xe(e._zod,"optout",()=>t.innerType._zod.optout),Xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>mt(e,r,Ue()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>mt(e,r,Ue()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Nn=/* @__PURE__ */je("$ZodPipe",(e,t)=>{Ar.init(e,t),Xe(e._zod,"values",()=>t.in._zod.values),Xe(e._zod,"optin",()=>t.in._zod.optin),Xe(e._zod,"optout",()=>t.out._zod.optout),Xe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){const n=t.out._zod.run(e,r);return n instanceof Promise?n.then(e=>Pn(e,t.in,r)):Pn(n,t.in,r)}const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>Pn(e,t.out,r)):Pn(n,t.out,r)}});function Pn(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var Ln=/* @__PURE__ */je("$ZodReadonly",(e,t)=>{Ar.init(e,t),Xe(e._zod,"propValues",()=>t.innerType._zod.propValues),Xe(e._zod,"values",()=>t.innerType._zod.values),Xe(e._zod,"optin",()=>t.innerType?._zod?.optin),Xe(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(Dn):Dn(n)}});function Dn(e){return e.value=Object.freeze(e.value),e}var $n,Fn=/* @__PURE__ */je("$ZodCustom",(e,t)=>{lr.init(e,t),Ar.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(t=>jn(t,r,n,e));jn(i,r,n,e)}});function jn(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(yt(e))}}var Bn=class{constructor(){this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};($n=globalThis).__zod_globalRegistry??($n.__zod_globalRegistry=new Bn);var Zn=globalThis.__zod_globalRegistry;function Wn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}function Un(e,t){return new dr({check:"less_than",...ct(t),value:e,inclusive:!1})}function Vn(e,t){return new dr({check:"less_than",...ct(t),value:e,inclusive:!0})}function Hn(e,t){return new ur({check:"greater_than",...ct(t),value:e,inclusive:!1})}function Gn(e,t){return new ur({check:"greater_than",...ct(t),value:e,inclusive:!0})}function Yn(e,t){return new hr({check:"multiple_of",...ct(t),value:e})}function Jn(e,t){return new fr({check:"max_length",...ct(t),maximum:e})}function Kn(e,t){return new mr({check:"min_length",...ct(t),minimum:e})}function Xn(e,t){return new gr({check:"length_equals",...ct(t),length:e})}function qn(e){return new Cr({check:"overwrite",tx:e})}function Qn(e,t){const r=new lr({check:"custom",...ct(t)});return r._zod.check=e,r}function ei(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Zn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:/* @__PURE__ */new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function ti(e,t,r={path:[],schemaPath:[]}){var n;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,n);else{const r=s.schema,o=t.processors[i.type];if(!o)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,r,n)}const o=e._zod.parent;o&&(s.ref||(s.ref=o),ti(o,t,n),t.seen.get(o).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),"input"===t.io&&ii(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function ri(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=/* @__PURE__ */new Map;for(const o of e.seen.entries()){const t=e.metadataRegistry.get(o[0])?.id;if(t){const e=n.get(t);if(e&&e!==o[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(t,o[0])}}const i=t=>{if(t[1].schema.$ref)return;const n=t[1],{ref:i,defId:o}=(t=>{const n="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const r=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(r)return{ref:i(r)};const o=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${n}/${o}`}}if(t[1]===r)return{ref:"#"};const i=`#/${n}/`,o=t[1].schema.id??"__schema"+e.counter++;return{defId:o,ref:i+o}})(t);n.def={...n.schema},o&&(n.defId=o);const s=n.schema;for(const e in s)delete s[e];s.$ref=i};if("throw"===e.cycles)for(const o of e.seen.entries()){const e=o[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of e.seen.entries()){const r=o[1];if(t!==o[0]){if(e.external){const r=e.external.registry.get(o[0])?.id;if(t!==o[0]&&r){i(o);continue}}(e.metadataRegistry.get(o[0])?.id||r.cycle||r.count>1&&"ref"===e.reused)&&i(o)}else i(o)}}function ni(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=t=>{const r=e.seen.get(t);if(null===r.ref)return;const i=r.def??r.schema,o={...i},s=r.ref;if(r.ref=null,s){n(s);const r=e.seen.get(s),a=r.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,o),t._zod.parent===s)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(a.$ref&&r.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(i[e])===JSON.stringify(r.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==s){n(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:r.path??[]})};for(const l of[...e.seen.entries()].reverse())n(l[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(r)}Object.assign(i,r.def??r.schema);const o=e.metadataRegistry.get(t)?.id;void 0!==o&&i.id===o&&delete i.id;const s=e.external?.defs??{};for(const l of e.seen.entries()){const e=l[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?i.$defs=s:i.definitions=s);try{const r=JSON.parse(JSON.stringify(i));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:oi(t,"input",e.processors),output:oi(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(a){throw new Error("Error converting schema to JSON.")}}function ii(e,t){const r=t??{seen:/* @__PURE__ */new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return ii(n.element,r);if("set"===n.type)return ii(n.valueType,r);if("lazy"===n.type)return ii(n.getter(),r);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type)return ii(n.innerType,r);if("intersection"===n.type)return ii(n.left,r)||ii(n.right,r);if("record"===n.type||"map"===n.type)return ii(n.keyType,r)||ii(n.valueType,r);if("pipe"===n.type)return!!e._zod.traits.has("$ZodCodec")||(ii(n.in,r)||ii(n.out,r));if("object"===n.type){for(const e in n.shape)if(ii(n.shape[e],r))return!0;return!1}if("union"===n.type){for(const e of n.options)if(ii(e,r))return!0;return!1}if("tuple"===n.type){for(const e of n.items)if(ii(e,r))return!0;return!(!n.rest||!ii(n.rest,r))}return!1}var oi=(e,t,r={})=>n=>{const{libraryOptions:i,target:o}=n??{},s=ei({...i??{},target:o,io:t,processors:r});return ti(e,s),ri(s,e),ni(s,e)},si={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ai=(e,t,r,n)=>{const i=e._zod.def;ti(i.innerType,t,n);t.seen.get(e).ref=i.innerType},li=/* @__PURE__ */je("ZodISODateTime",(e,t)=>{Br.init(e,t),Li.init(e,t)});function ci(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}(li,e)}var di=/* @__PURE__ */je("ZodISODate",(e,t)=>{Zr.init(e,t),Li.init(e,t)});function ui(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}(di,e)}var hi=/* @__PURE__ */je("ZodISOTime",(e,t)=>{Wr.init(e,t),Li.init(e,t)});function pi(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}(hi,e)}var fi=/* @__PURE__ */je("ZodISODuration",(e,t)=>{Ur.init(e,t),Li.init(e,t)});function mi(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}(fi,e)}var gi=(e,t)=>{bt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const r={_errors:[]},n=(e,i=[])=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>n({issues:e},[...i,...o.path]));else if("invalid_key"===o.code)n({issues:o.issues},[...i,...o.path]);else if("invalid_element"===o.code)n({issues:o.issues},[...i,...o.path]);else{const e=[...i,...o.path];if(0===e.length)r._errors.push(t(o));else{let n=r,i=0;for(;i<e.length;){const r=e[i];i!==e.length-1?n[r]=n[r]||{_errors:[]}:(n[r]=n[r]||{_errors:[]},n[r]._errors.push(t(o))),n=n[r],i++}}}};return n(e),r}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const r={},n=[];for(const i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,He,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,He,2)}},isEmpty:{get:()=>0===e.issues.length}})},yi=/* @__PURE__ */je("ZodError",gi,{Parent:Error}),wi=/* @__PURE__ */xt(yi),bi=/* @__PURE__ */kt(yi),vi=/* @__PURE__ */St(yi),xi=/* @__PURE__ */It(yi),ki=/* @__PURE__ */At(yi),Si=/* @__PURE__ */Et(yi),Ci=/* @__PURE__ */zt(yi),Ii=/* @__PURE__ */Mt(yi),_i=/* @__PURE__ */Tt(yi),Ai=/* @__PURE__ */Ot(yi),Ei=/* @__PURE__ */Rt(yi),zi=/* @__PURE__ */Nt(yi),Mi=/* @__PURE__ */new WeakMap;function Ti(e,t,r){const n=Object.getPrototypeOf(e);let i=Mi.get(n);if(i||(i=/* @__PURE__ */new Set,Mi.set(n,i)),!i.has(t)){i.add(t);for(const e in r){const t=r[e];Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){const r=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:r}),r},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Oi=/* @__PURE__ */je("ZodType",(e,t)=>(Ar.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:oi(e,"input"),output:oi(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{const n=ei({...r,processors:t});return ti(e,n),ri(n,e),ni(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,r)=>wi(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>vi(e,t,r),e.parseAsync=async(t,r)=>bi(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>xi(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>ki(e,t,r),e.decode=(t,r)=>Si(e,t,r),e.encodeAsync=async(t,r)=>Ci(e,t,r),e.decodeAsync=async(t,r)=>Ii(e,t,r),e.safeEncode=(t,r)=>_i(e,t,r),e.safeDecode=(t,r)=>Ai(e,t,r),e.safeEncodeAsync=async(t,r)=>Ei(e,t,r),e.safeDecodeAsync=async(t,r)=>zi(e,t,r),Ti(e,"ZodType",{check(...e){const t=this.def;return this.clone(Qe(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return lt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,r){return new e({type:"custom",check:"custom",fn:t,...ct(r)})}(jo,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const r=/* @__PURE__ */Qn(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(yt(e,t.value,r._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=t.value),n.inst??(n.inst=r),n.continue??(n.continue=!r._zod.def.abort),t.issues.push(yt(n))}},e(t.value,t)),t);return r}(e,t)}(e,t))},overwrite(e){return this.check(qn(e))},optional(){return zo(this)},exactOptional(){return new Mo({type:"optional",innerType:this})},nullable(){return Oo(this)},nullish(){return zo(Oo(this))},nonoptional(e){return function(e,t){return new Po({type:"nonoptional",innerType:e,...ct(t)})}(this,e)},array(){return go(this)},or(e){return vo([this,e])},and(e){return new xo({type:"intersection",left:this,right:e})},transform(e){return $o(this,new Ao({type:"transform",transform:e}))},default(e){return t=e,new Ro({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},prefault(e){return t=e,new No({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},catch(e){return new Lo({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return $o(this,e)},readonly(){return new Fo({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Zn.add(t,{description:e}),t},meta(...e){if(0===e.length)return Zn.get(this);const t=this.clone();return Zn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>Zn.get(e)?.description,configurable:!0}),e)),Ri=/* @__PURE__ */je("_ZodString",(e,t)=>{Er.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=r;n.type="string";const{minimum:i,maximum:o,format:s,patterns:a,contentEncoding:l}=e._zod.bag;if("number"==typeof i&&(n.minLength=i),"number"==typeof o&&(n.maxLength=o),s&&(n.format=si[s]??s,""===n.format&&delete n.format,"time"===s&&delete n.format),l&&(n.contentEncoding=l),a&&a.size>0){const e=[...a];1===e.length?n.pattern=e[0].source:e.length>1&&(n.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,r);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Ti(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new wr({check:"string_format",format:"regex",...ct(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new xr({check:"string_format",format:"includes",...ct(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new kr({check:"string_format",format:"starts_with",...ct(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Sr({check:"string_format",format:"ends_with",...ct(t),suffix:e})}(...e))},min(...e){return this.check(Kn(...e))},max(...e){return this.check(Jn(...e))},length(...e){return this.check(Xn(...e))},nonempty(...e){return this.check(Kn(1,...e))},lowercase(e){return this.check(function(e){return new br({check:"string_format",format:"lowercase",...ct(e)})}(e))},uppercase(e){return this.check(function(e){return new vr({check:"string_format",format:"uppercase",...ct(e)})}(e))},trim(){return this.check(/* @__PURE__ */qn(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
- return qn(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */qn(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */qn(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */qn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Ni=/* @__PURE__ */je("ZodString",(e,t)=>{Er.init(e,t),Ri.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ct(t)})}(Di,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(ji,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(to,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(Bi,t)),e.guid=t=>e.check(Wn($i,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(Fi,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ct(t)})}(Fi,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ct(t)})}(Fi,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ct(t)})}(Fi,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(Zi,t)),e.guid=t=>e.check(Wn($i,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(Wi,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(Ui,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(Vi,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(qi,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(Qi,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(Hi,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(Gi,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(Yi,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(Ji,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(Ki,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(Xi,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(eo,t)),e.datetime=t=>e.check(ci(t)),e.date=t=>e.check(ui(t)),e.time=t=>e.check(pi(t)),e.duration=t=>e.check(mi(t))});function Pi(e){return function(e,t){return new e({type:"string",...ct(t)})}(Ni,e)}var Li=/* @__PURE__ */je("ZodStringFormat",(e,t)=>{zr.init(e,t),Ri.init(e,t)}),Di=/* @__PURE__ */je("ZodEmail",(e,t)=>{Or.init(e,t),Li.init(e,t)}),$i=/* @__PURE__ */je("ZodGUID",(e,t)=>{Mr.init(e,t),Li.init(e,t)}),Fi=/* @__PURE__ */je("ZodUUID",(e,t)=>{Tr.init(e,t),Li.init(e,t)}),ji=/* @__PURE__ */je("ZodURL",(e,t)=>{Rr.init(e,t),Li.init(e,t)}),Bi=/* @__PURE__ */je("ZodEmoji",(e,t)=>{Nr.init(e,t),Li.init(e,t)}),Zi=/* @__PURE__ */je("ZodNanoID",(e,t)=>{Pr.init(e,t),Li.init(e,t)}),Wi=/* @__PURE__ */je("ZodCUID",(e,t)=>{Lr.init(e,t),Li.init(e,t)}),Ui=/* @__PURE__ */je("ZodCUID2",(e,t)=>{Dr.init(e,t),Li.init(e,t)}),Vi=/* @__PURE__ */je("ZodULID",(e,t)=>{$r.init(e,t),Li.init(e,t)}),Hi=/* @__PURE__ */je("ZodXID",(e,t)=>{Fr.init(e,t),Li.init(e,t)}),Gi=/* @__PURE__ */je("ZodKSUID",(e,t)=>{jr.init(e,t),Li.init(e,t)}),Yi=/* @__PURE__ */je("ZodIPv4",(e,t)=>{Vr.init(e,t),Li.init(e,t)}),Ji=/* @__PURE__ */je("ZodIPv6",(e,t)=>{Hr.init(e,t),Li.init(e,t)}),Ki=/* @__PURE__ */je("ZodCIDRv4",(e,t)=>{Gr.init(e,t),Li.init(e,t)}),Xi=/* @__PURE__ */je("ZodCIDRv6",(e,t)=>{Yr.init(e,t),Li.init(e,t)}),qi=/* @__PURE__ */je("ZodBase64",(e,t)=>{Kr.init(e,t),Li.init(e,t)}),Qi=/* @__PURE__ */je("ZodBase64URL",(e,t)=>{Xr.init(e,t),Li.init(e,t)}),eo=/* @__PURE__ */je("ZodE164",(e,t)=>{qr.init(e,t),Li.init(e,t)}),to=/* @__PURE__ */je("ZodJWT",(e,t)=>{Qr.init(e,t),Li.init(e,t)}),ro=/* @__PURE__ */je("ZodNumber",(e,t)=>{en.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=r,{minimum:i,maximum:o,format:s,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:c}=e._zod.bag;"string"==typeof s&&s.includes("int")?n.type="integer":n.type="number";const d="number"==typeof c&&c>=(i??Number.NEGATIVE_INFINITY),u="number"==typeof l&&l<=(o??Number.POSITIVE_INFINITY),h="draft-04"===t.target||"openapi-3.0"===t.target;d?h?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:"number"==typeof i&&(n.minimum=i),u?h?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:"number"==typeof o&&(n.maximum=o),"number"==typeof a&&(n.multipleOf=a)})(e,t,r),Ti(e,"ZodNumber",{gt(e,t){return this.check(Hn(e,t))},gte(e,t){return this.check(Gn(e,t))},min(e,t){return this.check(Gn(e,t))},lt(e,t){return this.check(Un(e,t))},lte(e,t){return this.check(Vn(e,t))},max(e,t){return this.check(Vn(e,t))},int(e){return this.check(oo(e))},safe(e){return this.check(oo(e))},positive(e){return this.check(Hn(0,e))},nonnegative(e){return this.check(Gn(0,e))},negative(e){return this.check(Un(0,e))},nonpositive(e){return this.check(Vn(0,e))},multipleOf(e,t){return this.check(Yn(e,t))},step(e,t){return this.check(Yn(e,t))},finite(){return this}});const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function no(e){return function(e,t){return new e({type:"number",checks:[],...ct(t)})}(ro,e)}var io=/* @__PURE__ */je("ZodNumberFormat",(e,t)=>{tn.init(e,t),ro.init(e,t)});function oo(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(io,e)}var so=/* @__PURE__ */je("ZodBoolean",(e,t)=>{rn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r)=>{r.type="boolean"})(0,0,t)});function ao(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(so,e)}var lo=/* @__PURE__ */je("ZodNull",(e,t)=>{nn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"})(0,e,t)});var co=/* @__PURE__ */je("ZodUnknown",(e,t)=>{on.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function uo(){return new co({type:"unknown"})}var ho=/* @__PURE__ */je("ZodNever",(e,t)=>{sn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r)=>{r.not={}})(0,0,t)});function po(e){return function(e,t){return new e({type:"never",...ct(t)})}(ho,e)}var fo=/* @__PURE__ */je("ZodDate",(e,t)=>{an.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,r)=>e.check(Gn(t,r)),e.max=(t,r)=>e.check(Vn(t,r));const r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null}),mo=/* @__PURE__ */je("ZodArray",(e,t)=>{cn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=r,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(i.minItems=s),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=ti(o.element,t,{...n,path:[...n.path,"items"]})})(e,t,r,n),e.element=t.element,Ti(e,"ZodArray",{min(e,t){return this.check(Kn(e,t))},nonempty(e){return this.check(Kn(1,e))},max(e,t){return this.check(Jn(e,t))},length(e,t){return this.check(Xn(e,t))},unwrap(){return this.element}})});function go(e,t){return function(e,t,r){return new e({type:"array",element:t,...ct(r)})}(mo,e,t)}var yo=/* @__PURE__ */je("ZodObject",(e,t)=>{fn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=r,o=e._zod.def;i.type="object",i.properties={};const s=o.shape;for(const c in s)i.properties[c]=ti(s[c],t,{...n,path:[...n.path,"properties",c]});const a=new Set(Object.keys(s)),l=new Set([...a].filter(e=>{const r=o.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout}));l.size>0&&(i.required=Array.from(l)),"never"===o.catchall?._zod.def.type?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=ti(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,r,n),Xe(e,"shape",()=>t.shape),Ti(e,"ZodObject",{keyof(){return Io(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:uo()})},loose(){return this.clone({...this._zod.def,catchall:uo()})},strict(){return this.clone({...this._zod.def,catchall:po()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!it(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const r=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return lt(e,Qe(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return qe(this,"shape",r),r}}))}(this,e)},safeExtend(e){return function(e,t){if(!it(t))throw new Error("Invalid input to safeExtend: expected a plain object");return lt(e,Qe(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return qe(this,"shape",r),r}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return lt(e,Qe(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return qe(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return lt(e,Qe(e._zod.def,{get shape(){const e={};for(const n in t){if(!(n in r.shape))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return qe(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return lt(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const e in t){if(!(e in r.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return qe(this,"shape",n),n},checks:[]}))}(this,e)},partial(...e){return function(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return lt(t,Qe(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)i[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return qe(this,"shape",i),i},checks:[]}))}(Eo,this,e[0])},required(...e){return t=Po,r=this,n=e[0],lt(r,Qe(r._zod.def,{get shape(){const e=r._zod.def.shape,i={...e};if(n)for(const r in n){if(!(r in i))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(i[r]=new t({type:"nonoptional",innerType:e[r]}))}else for(const r in e)i[r]=new t({type:"nonoptional",innerType:e[r]});return qe(this,"shape",i),i}}));var t,r,n}})});function wo(e,t){return new yo({type:"object",shape:e??{},...ct(t)})}var bo=/* @__PURE__ */je("ZodUnion",(e,t)=>{gn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,o=!1===i.inclusive,s=i.options.map((e,r)=>ti(e,t,{...n,path:[...n.path,o?"oneOf":"anyOf",r]}));o?r.oneOf=s:r.anyOf=s})(e,t,r,n),e.options=t.options});function vo(e,t){return new bo({type:"union",options:e,...ct(t)})}var xo=/* @__PURE__ */je("ZodIntersection",(e,t)=>{yn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,o=ti(i.left,t,{...n,path:[...n.path,"allOf",0]}),s=ti(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length;r.allOf=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]]})(e,t,r,n)});var ko=/* @__PURE__ */je("ZodRecord",(e,t)=>{vn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=r,o=e._zod.def;i.type="object";const s=o.keyType,a=s._zod.bag?.patterns;if("loose"===o.mode&&a&&a.size>0){const e=ti(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(const t of a)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=ti(o.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=ti(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const l=s._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function So(e,t,r){return t&&t._zod?new ko({type:"record",keyType:e,valueType:t,...ct(r)}):new ko({type:"record",keyType:Pi(),valueType:e,...ct(t)})}var Co=/* @__PURE__ */je("ZodEnum",(e,t)=>{xn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=Ve(e._zod.def.entries);n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n})(e,0,r),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const i={};for(const o of e){if(!r.has(o))throw new Error(`Key ${o} not found in enum`);i[o]=t.entries[o]}return new Co({...t,checks:[],...ct(n),entries:i})},e.exclude=(e,n)=>{const i={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Co({...t,checks:[],...ct(n),entries:i})}});function Io(e,t){return new Co({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ct(t)})}var _o=/* @__PURE__ */je("ZodLiteral",(e,t)=>{kn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=e._zod.def,i=[];for(const o of n.values)if(void 0===o){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof o){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(0===i.length);else if(1===i.length){const e=i[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else i.every(e=>"number"==typeof e)&&(r.type="number"),i.every(e=>"string"==typeof e)&&(r.type="string"),i.every(e=>"boolean"==typeof e)&&(r.type="boolean"),i.every(e=>null===e)&&(r.type="null"),r.enum=i})(e,t,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});var Ao=/* @__PURE__ */je("ZodTransform",(e,t)=>{Sn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Ze(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(yt(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),r.issues.push(yt(t))}};const i=t.transform(r.value,r);return i instanceof Promise?i.then(e=>(r.value=e,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});var Eo=/* @__PURE__ */je("ZodOptional",(e,t)=>{In.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ai(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});function zo(e){return new Eo({type:"optional",innerType:e})}var Mo=/* @__PURE__ */je("ZodExactOptional",(e,t)=>{_n.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ai(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});var To=/* @__PURE__ */je("ZodNullable",(e,t)=>{An.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,o=ti(i.innerType,t,n),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function Oo(e){return new To({type:"nullable",innerType:e})}var Ro=/* @__PURE__ */je("ZodDefault",(e,t)=>{En.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;ti(i.innerType,t,n),t.seen.get(e).ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var No=/* @__PURE__ */je("ZodPrefault",(e,t)=>{Mn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;ti(i.innerType,t,n),t.seen.get(e).ref=i.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});var Po=/* @__PURE__ */je("ZodNonOptional",(e,t)=>{Tn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;ti(i.innerType,t,n),t.seen.get(e).ref=i.innerType})(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});var Lo=/* @__PURE__ */je("ZodCatch",(e,t)=>{Rn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;let o;ti(i.innerType,t,n),t.seen.get(e).ref=i.innerType;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Do=/* @__PURE__ */je("ZodPipe",(e,t)=>{Nn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s="input"===t.io?o?i.out:i.in:i.out;ti(s,t,n),t.seen.get(e).ref=s})(e,t,0,n),e.in=t.in,e.out=t.out});function $o(e,t){return new Do({type:"pipe",in:e,out:t})}var Fo=/* @__PURE__ */je("ZodReadonly",(e,t)=>{Ln.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;ti(i.innerType,t,n),t.seen.get(e).ref=i.innerType,r.readOnly=!0})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});var jo=/* @__PURE__ */je("ZodCustom",(e,t)=>{Fn.init(e,t),Oi.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Bo(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...ct(t)})}(ro,e)}function Zo(e){return function(e,t){return new e({type:"date",coerce:!0,...ct(t)})}(fo,e)}var Wo,Uo,Vo=Io(["created","active","suspended","pending_approval"]),Ho=wo({id:no().optional(),created_at:Zo().optional(),updated_at:Zo().optional()}),Go=(wo({id:Bo()}),wo({slug:Pi()}),wo({agent_id:Bo()}),wo({widget_id:Bo()}),wo({simulation_id:Bo()}),wo({application_id:Bo()}),wo({user_id:Bo()}),wo({limit:Bo().optional().default(50),offset:Bo().optional().default(0)}),vo([Pi(),no(),ao(),go(Pi()),function(e,t){return new e({type:"null",...ct(t)})}(lo,Wo)]),wo({type:Io(["doc","sim","session"]),id:Pi(),label:Pi()}),wo({success:function(e,t){return new _o({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}(!0)})),Yo=(Go.extend({message:Pi()}),wo({name:Pi().min(1),params:So(Pi(),uo()).default({}),result:So(Pi(),uo()).default({})}),Pi().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),wo({start:Pi(),end:Pi(),action:Pi()}).passthrough()),Jo=wo({id:Pi(),label:Pi(),purpose:Pi(),elements:go(So(Pi(),uo())).default([]),bbox:So(Pi(),uo()).default({}),screenshot:Pi().default(""),embedding:go(no()).nullish()}).passthrough(),Ko=wo({id:Pi(),title:Pi(),url:Pi(),summary:Pi().default(""),screenshot:Pi().default(""),sections:go(Jo).default([]),sequence_ids:go(no()).default([]),embedding:go(no()).nullish()}).passthrough(),Xo=(wo({nodes:go(Ko),edges:go(Yo)}),wo({skill_id:no().int(),params:So(Pi(),Pi())}),Io(["free","startup","growth","enterprise"])),qo=Io(["human","ai"]),Qo=Io(["male","female"]),es=Io(["active","learning","error"]),ts=wo({graph_index_created:ao().nullable()}),rs=Io(["document","video"]),ns=Io(["user","research"]),is=(Io(["pending","processing","waiting_review","completed","failed"]),Io(["queued","running","creating_knowledge","has_question","completed","failed","stopped"])),os=Io(["pending","generating","completed","failed"]),ss=(Io(["active","learning","error","queued","running","completed","failed","has_question","stopped"]),Io(["app","website"])),as=Io(["widget"]),ls=(Io(["tell","show","do"]),Io(["password","oauth"])),cs=Ho.extend({is_super:ao(),status:Vo,email:Pi().email(),external_id:Pi().nullish(),first_name:Pi().nullish(),last_name:Pi().nullish(),password:Pi().nullish(),image_url:Pi().nullish(),prompt_limit:no().nullish(),last_login_at:Zo().nullish(),auth_method:ls.nullish()}),ds=(cs.partial().extend({email:Pi().email(),password:Pi()}),Ho.extend({name:Pi(),slug:Pi(),status:Vo,package:Xo,ending_date:Zo().nullish(),external_workspace_id:Pi().nullish(),slack_webhook_configured:ao().optional(),notify_all_members_on_question:ao().optional()})),us=wo({id:no(),agent_name:Pi(),image_url:Pi().nullish()}),hs=Ho.extend({workspace_id:no(),application_id:no().optional(),file_name:Pi().min(1),file_size:Bo(),file_type:rs,file_url:Pi(),source_url:Pi().nullish(),source:ns.default("user").optional(),agents:go(us).optional()}),ps=(Io(["passed","needs_healing","failed"]),wo({ultimate_goal:Pi(),test_cases:go(wo({test_title:Pi(),test_objective:Pi(),test_steps:go(Pi()),expected_outcome:Pi(),priority:Io(["Low","Medium","High"])})),summary:wo({total_tests:no(),high_priority:no(),medium_priority:no(),low_priority:no(),estimated_time_minutes:no()})}),wo({task_id:Pi(),condition:Io(["pass"]).optional()})),fs=wo({task_id:Pi(),title:Pi(),instructions:Pi(),status:Io(["pending","running","has_question","passed","failed","skipped","stopped"]),error_message:Pi().nullish(),started_at:Pi().nullish(),completed_at:Pi().nullish(),order_index:no().int().nonnegative().default(0),tab_id:Pi().nullish(),step_count:no().int().nonnegative().default(0),blocked_by:go(ps).default([])}),ms=Ho.extend({application_id:no(),agent_id:no(),job_id:Pi(),browser_session_id:Pi().nullish(),status:is,status_message:Pi().nullish(),path:Pi().nullish(),instructions:Pi().nullish(),pinned:ao().optional(),source:Io(["direct","qa"]).optional(),agent_name:Pi().nullish(),graph_index_id:Pi().nullish(),source_metadata:So(Pi(),uo()).nullish(),tasks:go(fs).optional(),agents:go(us).optional(),mindmap_status:os.optional(),mindmap_steps_processed:no().int().nonnegative().optional(),mindmap_steps_total:no().int().nonnegative().optional(),mindmap_error:Pi().nullish(),created_by_user_id:no().nullish(),persona_id:no().nullish(),has_question:ao().optional()}),gs=(Ho.extend({workspace_id:no(),user_id:no().nullish(),application_id:no(),agent_name:Pi(),agent_type:qo,agent_voice:Qo,agent_description:Pi().nullish(),instructions:Pi().nullish(),image_url:Pi().nullish(),graph_index_id:Pi().nullish(),status:es,status_message:Pi().nullish(),learning_progress:ts.nullish(),learning_started_at:Zo().nullish(),workspace:ds.optional(),user:cs.optional(),knowledge:go(hs).optional(),simulations:go(ms).optional(),simulation_count:no().int().nonnegative().optional(),knowledge_count:no().int().nonnegative().optional()}),Ho.extend({workspace_id:no(),name:Pi(),slug:Pi(),type:ss,url:Pi().nullish(),username:Pi().nullish(),password:Pi().nullish(),allowed_domains:go(Pi()).nullish().default([])}).omit({password:!0}),wo({chip_mode:Io(["show","tell","do"]),chip_text:Pi()})),ys=wo({widget_enabled:ao(),widget_appearance:Io(["default","compact","full"]),widget_position:Io(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Io(["desktop","mobile","desktop_mobile"]),widget_header:Pi(),widget_body:Pi(),widget_greeting:Pi(),widget_feature_tell:ao(),widget_feature_show:ao(),widget_feature_do:ao(),widget_feature_human:ao(),widget_background_color:Pi(),widget_text_color:Pi(),widget_border_color:Pi(),widget_accent_color:Pi(),widget_secondary_color:Pi(),widget_border_radius:Pi(),widget_font_size:Pi(),widget_width:Pi(),widget_height:Pi(),widget_shadow:Pi(),widget_animation_duration:Pi(),widget_fade_duration:Pi(),widget_bounce_effect:ao(),widget_chips:go(gs)}),ws=(Ho.extend({application_id:no(),agent_id:no(),type:as,settings:ys,status:Vo,marketrix_id:Pi(),marketrix_key:Pi(),snippet:Pi().nullish()}),Ho.extend({widget_id:no(),url_pattern:Pi(),message:go(Pi()),description:Pi().optional()}),Io(["pending","running","completed","failed","stopped"]),Io(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_agent","update_agent","delete_agent","create_application","update_application","delete_application","create_widget","update_widget","delete_widget","create_knowledge","update_knowledge","delete_knowledge","approve_user","deny_user","request_workspace","widget_question","qa_run_started","start_simulation","create_automation","update_automation","delete_automation","toggle_automation","slack_command"])),bs=wo({details:Pi().optional(),id:no().optional(),type:Pi().optional(),name:Pi().optional(),target_user_id:no().optional(),target_user_email:Pi().optional(),reason:Pi().optional(),assigned_role:Pi().optional(),new_role:Pi().optional(),previous_role:Pi().optional(),workspace_name:Pi().optional(),workspace_slug:Pi().optional(),ip_address:Pi().optional(),user_agent:Pi().optional(),widget_type:Pi().optional(),created_by:no().optional()}).passthrough(),vs=(Ho.extend({workspace_id:no(),user_id:no(),type:ws,metadata:bs.optional()}).partial().extend({type:ws}),wo({user_id:no(),limit:no(),used:no(),remaining:no()}),wo({description:Pi(),selected:ao(),simulation_id:no().nullable().optional(),task_id:Pi().nullable().optional(),status:is.nullable().optional()}),null),xs="";function ks(e){return ye(new Fe({url:e,headers:()=>{const e={};return vs&&(e.Authorization=`Bearer ${vs}`),e}}))}Uo=ks("");var Ss=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==xs&&(xs=e,Uo=ks(e))},Cs={setAuthToken:e=>{vs=e},clearAuthToken:()=>{vs=null},getAuthToken:()=>vs,configure:Ss},Is=new Proxy({},{get:(e,t)=>t in Cs?Cs[t]:Uo[t]}),_s="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",As={debug:0,info:1,warn:2,error:3};function Es(e){return As[e]>=As[_s]}function zs(e){return{debug:(e,...t)=>{Es("debug")},info:(e,...t)=>{Es("info")},warn:(e,...t)=>{Es("warn")},error:(e,...t)=>{Es("error")}}}var Ms=[{id:"navigate",name:"Navigate",description:"Navigate to a URL",displayAction:"Navigating",category:"navigation",actionType:"navigate"},{id:"search",name:"Search",description:"Search the web using a search engine",displayAction:"Searching",category:"navigation",actionType:"search"},{id:"click_element",name:"Click Element",description:"Click on an element by index or coordinates",displayAction:"Clicking element",category:"interaction",actionType:"click_element"},{id:"type_text",name:"Type Text",description:"Type text into an input field",displayAction:"Typing text",category:"interaction",actionType:"type_text"},{id:"scroll",name:"Scroll",description:"Scroll the page up or down",displayAction:"Scrolling",category:"interaction",actionType:"scroll"},{id:"scroll_to_text",name:"Scroll to Text",description:"Scroll until text is visible",displayAction:"Scrolling to text",category:"interaction",actionType:"scroll_to_text"},{id:"send_keys",name:"Send Keys",description:"Send keyboard keys or shortcuts",displayAction:"Pressing key",category:"interaction",actionType:"send_keys"},{id:"extract",name:"Extract",description:"Extract content from the page",displayAction:"Extracting content",category:"extraction",actionType:"extract"},{id:"get_dropdown_options",name:"Get Dropdown Options",description:"Get available options from a dropdown",displayAction:"Reading dropdown options",category:"extraction",actionType:"get_dropdown_options"},{id:"select_dropdown_option",name:"Select Dropdown Option",description:"Select an option from a dropdown",displayAction:"Selecting option",category:"interaction",actionType:"select_dropdown_option"},{id:"upload_file",name:"Upload File",description:"Upload a file to an input field",displayAction:"Uploading file",category:"interaction",actionType:"upload_file"},{id:"go_back",name:"Go Back",description:"Browser back button",displayAction:"Going back",category:"navigation",actionType:"go_back"},{id:"wait",name:"Wait",description:"Wait for a specified duration",displayAction:"Waiting",category:"utility",actionType:"wait"},{id:"switch_tab",name:"Switch Tab",description:"Switch to a different browser tab",displayAction:"Switching tab",category:"utility",actionType:"switch_tab"},{id:"close_tab",name:"Close Tab",description:"Close the current browser tab",displayAction:"Closing tab",category:"utility",actionType:"close_tab"},{id:"done",name:"Done",description:"Mark task as complete",displayAction:"Done",category:"utility",actionType:"done"},{id:"get_html",name:"Get HTML",description:"Get full page HTML with data-id attributes",displayAction:"Viewed your screen",category:"extraction",actionType:"get_html"},{id:"get_interactable_elements",name:"Get Interactable Elements",description:"Get list of interactable elements",displayAction:"Scanning elements",category:"extraction",actionType:"get_interactable_elements"},{id:"get_screenshot",name:"Get Screenshot",description:"Capture a screenshot of the page",displayAction:"Taking screenshot",category:"extraction",actionType:"get_screenshot"}];function Ts(e){return e.includes("__THINKING__")}function Os(e){return Ts(e)?e:`${e}\n\n__THINKING__`}function Rs(e,t,r,n,i){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(i&&t&&("show"===r||"do"===r))if(e.isPlaceholder){if(void 0!==e.mode&&e.mode!==r)return!1}else if(e.mode!==r)return!1;if(n){const t=e.content.trim().length>0,r=e.parts&&e.parts.length>0;if(!t&&!r)return!1}return!0}function Ns(e){const{messages:t,isTaskRunning:r,currentMode:n,requireContent:i}=e;let o=-1;if(r&&("show"===n||"do"===n)){const e=!0;for(let s=t.length-1;s>=0;s--){const a=t[s],l=Rs(a,r,n,i,e),c=a.isPlaceholder,d=!i||a.content.trim().length>0||a.parts&&a.parts.length>0;if(l&&c&&d){o=s;break}}if(o<0&&!i)for(let s=t.length-1;s>=0;s--){const a=t[s],l=Rs(a,r,n,i,e),c=a.isPlaceholder;if(l&&c){o=s;break}}if(o<0)for(let s=t.length-1;s>=0;s--){const a=t[s],l=Rs(a,r,n,i,e),c=a.isPlaceholder;if(l&&!c){o=s;break}}}if(o<0){for(let e=t.length-1;e>=0;e--){const r=t[e],n="agent"===r.sender,s=r.isPlaceholder,a=!r.isSystemMessage,l=!r.isScreenAccessRequest,c=!i||r.content.trim().length>0||r.parts&&r.parts.length>0;if(n&&s&&a&&l&&c){o=e;break}}if(o<0&&!i)for(let e=t.length-1;e>=0;e--){const r=t[e];if("agent"===r.sender&&r.isPlaceholder&&!r.isSystemMessage&&!r.isScreenAccessRequest){o=e;break}}if(o<0&&(o=function(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if("agent"===r.sender&&!r.isSystemMessage&&!r.isScreenAccessRequest&&!r.isPlaceholder)return t}return-1}(t)),o<0)for(let e=t.length-1;e>=0;e--){const r=t[e];if("agent"===r.sender&&!r.isSystemMessage&&!r.isScreenAccessRequest){o=e;break}}}return o>=0?{index:o,message:t[o]}:null}function Ps(e){const t={...e};if(!t.parts){t.parts=[];const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts.push({type:"text",content:e})}return t}var Ls=new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Ds=new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function $s(e){return e?e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\(cancelled by cleanup\)/gi,"").replace(/Cancelled by cleanup/gi,"").replace(/\s+/g," ").trim():e}function Fs(e,t,r,n=!1){const i=Ps(e);if(!t||"show"!==r&&"do"!==r)return Ts(i.content)?{...i,content:i.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:i;const o=n?"waiting-for-user":"thinking";return Ts(i.content)?i.placeholderState!==o?{...i,placeholderState:o}:i:{...i,content:Os(i.content),placeholderState:o}}var js=Object.fromEntries(Ms.map(e=>[e.id,e.displayAction]));var Bs="marketrix_chat_context",Zs={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Ws=class e{static instance;context=null;constructor(){this.loadContext()}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadContext(){if("undefined"==typeof window)return this.context={...Zs},this.context;try{const e=localStorage.getItem(Bs);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Zs},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Zs},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Bs,JSON.stringify(this.context))}catch(e){}}getContext(){return this.context?this.context:this.loadContext()}updateContext(e){this.context||this.loadContext();const t=this.context;this.context={...t,...e},this.saveContext()}isValidChatId(e){return"string"==typeof e&&""!==e.trim()}getChatId(){if("undefined"!=typeof window&&this.isValidChatId(window.name)){const e=window.name;return e!==this.getContext().chat_id&&this.updateContext({chat_id:e}),e}return this.getContext().chat_id}setChatId(e){this.updateContext({chat_id:e}),"undefined"!=typeof window&&e&&(window.name=e,window.dispatchEvent(new CustomEvent("marketrix:chatid",{detail:{chatId:e}})))}getMessages(){return this.getContext().messages}setMessages(e){this.updateContext({messages:e})}getChatState(){const e=this.getContext();return{isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,taskProgress:e.taskProgress,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading}}setChatState(e){this.updateContext(e)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}clear(){this.context={...Zs},"undefined"!=typeof window&&localStorage.removeItem(Bs)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Us=class e{static instance;chatId=null;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e}createInitialContext(e){try{if(Ws.hasValidContext())return;Ws.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}restore(){const e=Ws.getContext();return{messages:e.chat_id?e.messages.map(e=>{if(e.id.startsWith("screenshare-"))return{...e,content:"Screenshare ended",videoStream:void 0,isSystemMessage:!0,timestamp:new Date(e.timestamp),parts:[{type:"text",content:"Screenshare ended"}]};const t={...e,timestamp:new Date(e.timestamp),videoStream:void 0,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts||[]};if(0===t.parts?.length&&t.content){const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts&&t.parts.push({type:"text",content:e})}return t}):[],isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,taskProgress:e.taskProgress,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading??!1}}persist(e){if(this.chatId)try{const t=e.messages.filter(e=>!e.isPlaceholder||("thinking"===e.placeholderState||"waiting-for-user"===e.placeholderState||(e.parts||[]).length>0)).filter(e=>!(e.isSystemMessage&&"Chat context changed"===e.content)).map(e=>{return{id:e.id,content:(t=e.content,t.replace(/__THINKING__/g,"")),sender:e.sender,timestamp:e.timestamp.toISOString(),mode:e.mode,isScreenAccessRequest:e.isScreenAccessRequest,screenShareStatus:e.screenShareStatus,isSystemMessage:e.isSystemMessage,isPlaceholder:e.isPlaceholder,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts};var t});Ws.updateContext({chat_id:this.chatId,messages:t,isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,taskProgress:e.taskProgress,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading})}catch(t){}}}.getInstance();function Vs(e,t,r="user-message"){const n=[],i=e.trim();return i&&n.push({type:"text",content:i}),{id:`${r}-${Date.now()}`,content:i,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:n}}function Hs(e,t,r,n="agent-message"){const i=[],o=e.trim();return o&&i.push({type:"text",content:o}),{id:r||`${n}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:i}}function Gs(e,t,r="agent",n="system-message"){const i=[];return e&&i.push({type:"text",content:e}),{id:`${n}-${Date.now()}`,content:e,sender:r,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:i}}function Ys(e="show"){const t="Started screenshare";return{id:`started-screenshare-${Date.now()}`,content:t,sender:"user",timestamp:/* @__PURE__ */new Date,mode:e,isSystemMessage:!0,parts:[{type:"text",content:t}]}}function Js(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Ks=zs(),Xs=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Ks.debug("Loaded existing chat ID from storage:",this.chatId))}static getInstance(){return"undefined"==typeof window||"undefined"==typeof document?(e.instance||(e.instance=Object.create(e.prototype),e.instance.chatId=null,e.instance.initializationPromise=null),e.instance):(e.instance||(e.instance=new e),e.instance)}getChatId(){return this.chatId}async getOrCreateChatId(){if(this.chatId)return Ks.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Ks.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Ks.debug("Found chat ID in storage:",this.chatId),this.chatId;this.initializationPromise=this.createChatId();try{return await this.initializationPromise}finally{this.initializationPromise=null}}async createChatId(){try{Ks.info("Creating new chat ID...");const e=await Is.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Ks.info("Created and stored new chat ID:",this.chatId),Us.createInitialContext(e),e}catch(e){throw Ks.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Ws.getChatId()}storeChatId(e){Ws.setChatId(e)}}.getInstance(),qs=class e{static instance=null;abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;isIntentionallyDisconnected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;config;connectionId=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}getStatus(){return this.status}isConnected(){return"registered"===this.status}async connect(e,t){if(this.isIntentionallyDisconnected&&(this.isIntentionallyDisconnected=!1),this.isConnected()&&this.chatId===e)return;this.abortController&&(this.abortController.abort(),this.abortController=null),this.chatId=e,t&&(this.config=t),this.setStatus("connecting");const r=++this.connectionId;this.abortController=new AbortController;const n=this.abortController.signal;try{const t={chat_id:e};this.config?.mtxId&&this.config?.mtxKey?(t.marketrix_id=this.config.mtxId,t.marketrix_key=this.config.mtxKey):this.config?.mtxAgent&&this.config?.mtxApp&&(t.agent_id=this.config.mtxAgent,t.application_id=this.config.mtxApp);const i=await Is.widgetStream(t,{signal:n});this.setStatus("connected"),this.consumeEvents(i,r)}catch(i){n.aborted||(this.setStatus("error"),this.notifyError(/* @__PURE__ */new Error("Stream connection failed")),this.scheduleReconnect())}}async consumeEvents(e,t){let r=!1;try{for await(const n of e){if(this.connectionId!==t){r=!0;break}this.handleMessage(n)}}catch(n){this.connectionId!==t?r=!0:this.isIntentionallyDisconnected||this.setStatus("error")}finally{r||this.connectionId!==t||this.isIntentionallyDisconnected||(this.setStatus("disconnected"),this.scheduleReconnect())}}disconnect(){this.isIntentionallyDisconnected=!0,this.clearReconnectTimer(),this.abortController&&(this.abortController.abort(),this.abortController=null),this.setStatus("disconnected"),this.chatId=null}send(e){return this.chatId?Is.widgetMessage({chat_id:this.chatId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${String(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(t=>t.onStatusChange?.(e)))}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}handleMessage(e){this.isIntentionallyDisconnected||"heartbeat"!==e.type&&("registered"===e.type&&e.chat_id===this.chatId&&(this.setStatus("registered"),this.reconnectAttempts=0,this.reconnectDelay=1e3,this.callbacks.forEach(t=>t.onRegistered?.(e.application_id))),"chat/error"===e.type&&"auth"===e.request_id&&(this.isIntentionallyDisconnected=!0),this.callbacks.forEach(t=>t.onMessage?.(e)))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.notifyError(/* @__PURE__ */new Error("Max reconnect attempts reached"));this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.isIntentionallyDisconnected&&this.chatId&&this.connect(this.chatId,this.config).catch(console.error)},e)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}},Qs=class{config;constructor(e){this.config=e}getChatId(){return Xs.getChatId()}getUserId(){if(this.config.userId&&"number"==typeof this.config.userId)return this.config.userId;try{const e=localStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}try{const e=sessionStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}return null}async logWidgetQuestion(e,t){try{const r=this.getUserId(),n={question:e,mode:t,chat_id:this.getChatId(),timestamp:/* @__PURE__ */(new Date).toISOString()};null!==r&&(n.user_id=r),this.config.mtxApp&&(n.application_id=this.config.mtxApp),this.config.mtxId&&this.config.mtxKey&&(n.marketrix_id=this.config.mtxId,n.marketrix_key=this.config.mtxKey),Is.activityLogCreate({type:"widget_question",metadata:n}).catch(e=>{})}catch(r){}}async sendMessage(e){if(!(await Xs.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const t=e.mode||"tell";if(e.message&&await this.logWidgetQuestion(e.message,t),!(this.config.mtxId&&this.config.mtxKey||this.config.mtxApp&&this.config.mtxAgent))throw new Error("Either mtxId + mtxKey or both mtxApp + mtxAgent are required");const r=e.requestId||`req_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,n={type:`chat/${t}`,request_id:r,content:e.message||""};return qs.getInstance().send(n),{messageId:r,response:"",mode:t,timestamp:/* @__PURE__ */new Date}}updateConfig(e){this.config={...this.config,...e}}},ea=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Ws.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Ws.setConfig(e),this.config=e}updateConfig(e){this.config||(this.config={}),this.config={...this.config,...e},this.saveConfig(this.config)}getConfig(){return this.config}shouldShowWidget(){return!!this.config&&(this.config.widget_enabled??!1)}}.getInstance();function ta(e,t={}){return{...t,...e}}var ra=r(void 0),na=({children:e,previewMode:t=!1,uiActions:r,currentMode:n})=>{const[i,s]=h({messages:[]}),a=u(n);a.current=n;const l=o(e=>{s(t=>({messages:[...t.messages,e]}))},[]),c=o((e,t)=>{s(r=>({messages:r.messages.map(r=>r.id===e?{...r,...t}:r)}))},[]),p=o(e=>{s(t=>({messages:t.messages.filter(t=>t.id!==e)}))},[]),f=o(e=>{s({messages:e})},[]),g=o(()=>{s({messages:[]})},[]),y=o(async(e,n,i,o,c)=>{const d=n??a.current;if(t)return c||l(Vs(e,d)),void l(Hs("This is a preview. In production, I'll respond to your messages here."));let u=ea.getConfig();if(u||(u=ea.loadConfig()),!u||!u.mtxId&&!u.mtxKey&&!u.mtxAgent)return void l(Hs("Configuration error: Missing API credentials. Please check your widget settings."));c||l(Vs(e,d));const h=`temp-${globalThis.crypto.randomUUID()}`;l({id:h,content:Os(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:d,isPlaceholder:!0,placeholderState:"thinking",parts:[]}),r.setLoading(!0);const p=new Qs(u);try{i&&p.updateConfig({mtxApp:i});const t=p.getChatId();if(t){const e=qs.getInstance();if(!e.isConnected()){const r=ea.getConfig();try{await e.connect(t,r?{mtxId:r.mtxId,mtxKey:r.mtxKey,mtxAgent:r.mtxAgent,mtxApp:r.mtxApp}:void 0)}catch(f){}}}await p.sendMessage({message:e,mode:d,question:o,requestId:h})}catch(m){s(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.";return{messages:e.messages.map(e=>{if(e.id!==h)return e;const r=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:r,content:t}})}})}finally{r.setLoading(!1)}},[t,l,r]),w=d(()=>({addMessage:l,updateMessage:c,removeMessage:p,setMessages:f,clearMessages:g,sendMessage:y}),[l,c,p,f,g,y]);/* @__PURE__ */
3
- return m(ra.Provider,{value:{chatState:i,chatActions:w,_setMessages:s},children:e})},ia=()=>{const e=s(ra);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e};function oa(e){if(!(e&&e instanceof Element))return!1;try{const r=e.tagName.toLowerCase(),n="button"===r;if(!(n||"input"===r||"textarea"===r||"select"===r||"a"===r&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||"textbox"===e.getAttribute("role")||"checkbox"===e.getAttribute("role")||"radio"===e.getAttribute("role")||"switch"===e.getAttribute("role")||"tab"===e.getAttribute("role")||"menuitem"===e.getAttribute("role")||"true"===e.getAttribute("contenteditable")||e.hasAttribute("onclick")||e.hasAttribute("tabindex")&&parseInt(e.getAttribute("tabindex")||"-1",10)>=0))return!1;const i=(t,r)=>{if(n){e.tagName,e.id,e.className}};if(!0===e.disabled)return i("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return i("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return i("inert","ancestor is inert"),!1;const e=t instanceof Element?t.getRootNode():null;t=t instanceof Element?t.parentElement||(e instanceof ShadowRoot?e.host:null):null}}catch(t){}const o=e.hasAttribute("onclick");if(n&&o)return!0;let s,a;try{s=window.getComputedStyle(e)}catch(t){return i("computed-style","failed to get computed style"),!1}if("none"===s.display)return i("display","display is none"),!1;if("none"===s.pointerEvents)return i("pointer-events","pointer-events is none"),!1;try{a=e.getBoundingClientRect()}catch(t){return i("bounding-rect","failed to get bounding rect"),!1}if(a.width<=0||a.height<=0)return i("dimensions",`width=${a.width}, height=${a.height}`),!1;try{let t=e;for(;t&&t!==document.body;){const e=t.getRootNode(),r=t.parentElement||(e instanceof ShadowRoot?e.host:null);if(!r)break;let o,s;try{o=window.getComputedStyle(r),s=r.getBoundingClientRect()}catch{t=r;continue}if("hidden"===o.overflow||"clip"===o.overflow){const e=a.right<s.left||a.left>s.right||a.bottom<s.top||a.top>s.bottom;if(n){if(e)return i("overflow-clipping","completely outside parent bounds"),!1}else if(e)return!1}t=r}}catch(t){}try{let t=e.getRootNode();for(;t instanceof ShadowRoot;){const e=t.host;let r;try{r=e.getBoundingClientRect()}catch{break}if(r.width<=0||r.height<=0)return!1;t=e.getRootNode()}}catch(t){}return!0}catch(t){return!1}}var sa=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;isIndexed=!1;indexingInProgress=!1;indexVersion=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}generateSelector(e){if(e.id&&1===document.querySelectorAll(`#${CSS.escape(e.id)}`).length)return`#${CSS.escape(e.id)}`;const t=[];let r=e;for(;r&&r!==document.body&&r.parentElement;){let e=r.tagName.toLowerCase();if(r.id){e+=`#${CSS.escape(r.id)}`,t.unshift(e);break}{const t=r.parentElement;if(!t)break;const n=r.tagName,i=Array.from(t.children).filter(e=>e.tagName===n);if(i.length>1){e+=`:nth-of-type(${i.indexOf(r)+1})`}}t.unshift(e),r=r.parentElement}return t.join(" > ")}generateFingerprint(e,t){return{tagName:e.tagName,id:e.id||null,textContent:((e,t=100)=>{if(!e)return null;const r=e.trim().replace(/\s+/g," ");return r.length>t?r.slice(0,t):r})(e.textContent),type:e.getAttribute("type"),role:e.getAttribute("role"),ariaLabel:e.getAttribute("aria-label"),name:e.getAttribute("name"),href:e.getAttribute("href"),selector:t,indexVersion:this.indexVersion}}matchesFingerprint(e,t){return e.tagName===t.tagName&&(!(!t.id||e.id!==t.id)||(!t.type||e.getAttribute("type")===t.type)&&((!t.ariaLabel||e.getAttribute("aria-label")===t.ariaLabel)&&((!t.role||e.getAttribute("role")===t.role)&&((!t.href||"A"!==t.tagName||e.getAttribute("href")===t.href)&&(!t.name||e.getAttribute("name")===t.name)))))}validateElementAtIndex(e){const t=this.fingerprintMap.get(e);if(!t)return{isValid:!0};const r=this.elementMap.get(e);return r&&document.contains(r)?r instanceof HTMLElement&&!this.matchesFingerprint(r,t)?{isValid:!1,mismatchReason:"element_changed"}:{isValid:!0}:{isValid:!1,mismatchReason:"element_removed"}}exportState(){return{selectors:Array.from(this.selectorMap.entries()),fingerprints:Array.from(this.fingerprintMap.entries())}}importState(e){if(e)try{e.selectors&&(this.selectorMap=new Map(e.selectors)),e.fingerprints&&(this.fingerprintMap=new Map(e.fingerprints)),(this.selectorMap.size>0||this.fingerprintMap.size>0)&&(this.isIndexed=!0)}catch(t){}}indexInteractableElements(){if(this.indexingInProgress)return[];try{this.indexingInProgress=!0,this.clearIndex();const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e instanceof HTMLElement&&null===e.offsetParent&&"BODY"!==e.tagName){const t=window.getComputedStyle(e),r="fixed"===t.position||"sticky"===t.position;if("none"===t.display)return NodeFilter.FILTER_REJECT;if(!r){let t=e.parentElement,r=!1;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if("fixed"===e.position||"sticky"===e.position){r=!0;break}t=t.parentElement}if(!r)return NodeFilter.FILTER_REJECT}}return NodeFilter.FILTER_ACCEPT}});let t=e.nextNode(),r=0;const n=[];for(;t;){if(t instanceof HTMLElement){const e=t.matches('a[href], button, input, textarea, select, [role="button"]'),i=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),o="onclick"in t&&"function"==typeof t.onclick;if(e||i||o||oa(t)){this.elementMap.set(r,t),this.elementToSequence.set(t,r);const e=this.generateSelector(t);this.selectorMap.set(r,e);const i=this.generateFingerprint(t,e);this.fingerprintMap.set(r,i),n.push([r,t]),r++}}t=e.nextNode()}return this.isIndexed=!0,this.indexVersion++,n}finally{this.indexingInProgress=!1}}getElementCoordinates(e){const t=e.getBoundingClientRect(),r=this.calculateGlobalZOrder(e);return{x:Math.round(t.left),y:Math.round(t.top),w:Math.round(t.width),h:Math.round(t.height),z:r}}isStackingContext(e){const t=window.getComputedStyle(e),r=t.position;if(("fixed"===r||"absolute"===r||"relative"===r||"sticky"===r)&&"auto"!==t.zIndex)return!0;if("auto"!==t.zIndex&&e.parentElement){const t=window.getComputedStyle(e.parentElement).display;if("flex"===t||"inline-flex"===t||"grid"===t||"inline-grid"===t)return!0}const n=parseFloat(t.opacity);if(!isNaN(n)&&n<1)return!0;if(t.transform&&"none"!==t.transform)return!0;if(t.filter&&"none"!==t.filter)return!0;const i=t.willChange;if(i&&(i.includes("transform")||i.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const o=t.contain;return!(!o||!(o.includes("layout")||o.includes("style")||o.includes("paint")))}calculateGlobalZOrder(e){let t=e;const r=[];for(;t&&t!==document.body&&t.parentElement;){const e=window.getComputedStyle(t);if(this.isStackingContext(t)){let n=0;if("auto"!==e.zIndex){const t=parseInt(e.zIndex,10);isNaN(t)||(n=t)}let i=0;t.parentElement&&(i=Array.from(t.parentElement.children).indexOf(t)),r.push({element:t,zIndex:n,domOrder:i})}t=t.parentElement}let n=1e6;for(let i=r.length-1;i>=0;i--){const e=r[i];n+=1e4*e.zIndex+e.domOrder}if(e.parentElement){n+=Array.from(e.parentElement.children).indexOf(e)}return n}getSnapshotHtml(){this.indexInteractableElements();const e=document.documentElement.cloneNode(!0);for(const[r,n]of this.elementMap.entries())if(n instanceof HTMLElement){const i=this.selectorMap.get(r);if(i)try{const t=(e.querySelector("body")||e).querySelector(i);if(t)if(t.setAttribute("data-id",r.toString()),"none"===window.getComputedStyle(n).display)t.setAttribute("data-x","0"),t.setAttribute("data-y","0"),t.setAttribute("data-w","0"),t.setAttribute("data-h","0"),t.setAttribute("data-z","0");else{const e=this.getElementCoordinates(n);t.setAttribute("data-x",e.x.toString()),t.setAttribute("data-y",e.y.toString()),t.setAttribute("data-w",e.w.toString()),t.setAttribute("data-h",e.h.toString()),t.setAttribute("data-z",e.z.toString())}}catch(t){}}return e.outerHTML}getInteractableElements(){this.indexInteractableElements();const e=[];for(const[t,r]of this.elementMap.entries())if(r instanceof HTMLElement){const n=this.fingerprintMap.get(t);n&&e.push({index:t,fingerprint:n,coords:this.getElementCoordinates(r),cssClasses:Array.from(r.classList)})}return e}getElementByDataId(e){return this.elementMap.get(e)}getSequenceForElement(e){return this.elementToSequence.get(e)}isIndexActive(){return this.isIndexed}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear(),this.isIndexed=!1}checkInteractability(e,t){if(!document.body.contains(e))return`ELEMENT_NOT_INTERACTABLE: Element ${t} is not in the DOM`;const r=window.getComputedStyle(e);if("none"===r.display)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has display:none`;if("hidden"===r.visibility)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has visibility:hidden`;if(0===parseFloat(r.opacity))return`ELEMENT_NOT_INTERACTABLE: Element ${t} has opacity:0`;const n=e.getBoundingClientRect();if(0===n.width||0===n.height)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has zero dimensions`;if(n.bottom<0||n.top>window.innerHeight||n.right<0||n.left>window.innerWidth)return`ELEMENT_NOT_INTERACTABLE: Element ${t} is off-screen`;const i=n.left+n.width/2,o=n.top+n.height/2,s=document.elementFromPoint(i,o);if(s&&s!==e&&!e.contains(s)&&!(s.closest("#marketrix-show-highlight")||s.closest("#marketrix-show-popup")||s.closest("[data-marketrix-widget]"))){const e=s.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${s.className?`${e}.${s.className.split(" ")[0]}`:e}. The obscuring element may be a modal or overlay that needs to be dismissed first.`}return null}checkElementInteractable(e,t){return this.checkInteractability(e,t)}getElementByIndex(e){let t=null;if(this.elementMap.has(e)){const r=this.elementMap.get(e);r&&r instanceof HTMLElement&&(t=r)}if(!t&&this.selectorMap.has(e)){const r=this.selectorMap.get(e);if(r)try{const e=document.querySelector(r);e&&e instanceof HTMLElement&&(t=e)}catch(n){}}if(!t)return{element:null,error:`Element ${e} not found`};const r=this.checkInteractability(t,e);return r?{element:null,error:r}:{element:t}}getValidatedElement(e){const t=this.validateElementAtIndex(e);if(!t.isValid)return{element:null,validation:t,error:`DOM_CHANGED: Element at index ${e} ${"element_removed"===t.mismatchReason?"no longer exists":"has changed"}. Call get_html to get updated indices.`};const r=this.elementMap.get(e);if(!r)return{element:null,validation:t,error:`Element ${e} not found`};const n=this.checkInteractability(r,e);return n?{element:null,validation:t,error:n}:{element:r,validation:t}}getFingerprint(e){return this.fingerprintMap.get(e)}getAllFingerprints(){return Array.from(this.fingerprintMap.entries())}getIndexVersion(){return this.indexVersion}}.getInstance(),aa=null;async function la(){if(aa?.active){const e=aa.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return aa}const e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!e||0===e.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return aa=e,e.getVideoTracks()[0].addEventListener("ended",()=>{aa=null}),e}function ca(){return null!==function(){if(aa?.active){const e=aa.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return aa}return aa=null,null}()}var da=class e{static instance;currentPopup=null;currentHighlight=null;currentElement=null;currentOptions=null;currentPromise=null;resolvePromise=null;rejectPromise=null;clickHandler=null;scrollHandler=null;updateHighlightPosition=null;rafId=null;mutationObserver=null;visibilityCheckInterval=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async showToolAction(e){const{element:t,explanation:r,isClickAction:n=!1,toolName:i}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===r&&this.currentOptions.toolName===i&&this.currentPromise||(this.cleanup(),this.currentOptions=e,this.currentElement=t,t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),this.createHighlight(t),this.createPopup(r,n),this.setupPositionUpdates(),this.setupElementMonitoring(),this.setupVisibilityMonitoring(),n&&this.setupClickHandler(),this.currentPromise=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t}).finally(()=>{this.cleanup()})),this.currentPromise}cleanup(){this.rejectPromise&&(this.rejectPromise("Cancelled by cleanup"),this.rejectPromise=null),this.resolvePromise=null,this.clickHandler&&(document.removeEventListener("click",this.clickHandler,{capture:!0}),this.clickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:!0}),window.removeEventListener("resize",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("wheel",this.scrollHandler),this.scrollHandler=null),null!==this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.visibilityCheckInterval&&(clearInterval(this.visibilityCheckInterval),this.visibilityCheckInterval=null),this.updateHighlightPosition=null,this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentHighlight&&(this.currentHighlight.remove(),this.currentHighlight=null);const e=document.getElementById("marketrix-show-popup");e&&e.remove();const t=document.getElementById("marketrix-show-highlight");t&&t.remove(),this.currentElement=null,this.currentOptions=null,this.currentPromise=null,this.resolvePromise=null,this.rejectPromise=null}createHighlight(e){const t=e.getBoundingClientRect(),r=document.createElement("div");r.id="marketrix-show-highlight",r.style.cssText=`\n position: fixed;\n top: ${t.top}px;\n left: ${t.left}px;\n width: ${t.width}px;\n height: ${t.height}px;\n border: 3px solid #3b82f6;\n border-radius: 4px;\n box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.4);\n z-index: 2147483645;\n pointer-events: none;\n transition: none;\n `,document.body.appendChild(r),this.currentHighlight=r}createPopup(e,t){const r=document.createElement("div");r.id="marketrix-show-popup",r.innerHTML=t?`<div style="font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>`:`<div style="margin-bottom: 12px; font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>\n <div style="display: flex; gap: 8px; justify-content: flex-end;">\n <button id="marketrix-show-continue" style="\n background: #3b82f6; color: white; border: none; border-radius: 6px;\n padding: 8px 16px; font-size: 12px; font-weight: 500; cursor: pointer;\n ">Continue</button>\n </div>`,document.body.appendChild(r),this.currentPopup=r,t||this.setupContinueButton(r),this.updatePopupPosition()}setupPositionUpdates(){this.updateHighlightPosition=()=>{if(!this.currentElement||!this.currentHighlight)return;const e=this.currentElement.getBoundingClientRect();this.currentHighlight.style.top=`${e.top}px`,this.currentHighlight.style.left=`${e.left}px`,this.currentHighlight.style.width=`${e.width}px`,this.currentHighlight.style.height=`${e.height}px`,this.updatePopupPosition()},this.scrollHandler=()=>{null!==this.rafId&&window.cancelAnimationFrame(this.rafId),this.updateHighlightPosition?.()},window.addEventListener("scroll",this.scrollHandler,{capture:!0,passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("wheel",this.scrollHandler,{passive:!0})}updatePopupPosition(){if(!this.currentPopup||!this.currentElement)return;const e=this.currentElement.getBoundingClientRect(),t=320,r=120,n=10,i=e.left+e.width/2,o=e.top+e.height/2,s=[{left:e.right+20,top:o-60},{left:e.left-t-20,top:o-60},{left:i-160,top:e.top-r-20},{left:i-160,top:e.bottom+20}];let a=s[0];for(const d of s)if(d.left>=n&&d.left+t<=window.innerWidth-n&&d.top>=n&&d.top+r<=window.innerHeight-n){a=d;break}const l=Math.max(n,Math.min(a.left,window.innerWidth-t-n)),c=Math.max(n,Math.min(a.top,window.innerHeight-r-n));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${c}px;\n left: ${l}px;\n width: 320px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n z-index: 2147483646;\n padding: 16px;\n `}setupClickHandler(){this.clickHandler=e=>{if(this.currentElement&&this.resolvePromise&&e.composedPath().includes(this.currentElement)){e.preventDefault(),e.stopPropagation();const t=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,t(!0)}},document.addEventListener("click",this.clickHandler,{capture:!0})}setupContinueButton(e){window.requestAnimationFrame(()=>{const t=e.querySelector("#marketrix-show-continue");t&&t.addEventListener("click",e=>{if(e.stopPropagation(),this.resolvePromise){const e=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,e(!0)}})})}setupElementMonitoring(){this.currentElement&&(this.mutationObserver=new MutationObserver(()=>{this.currentElement&&!document.body.contains(this.currentElement)&&this.failWithElementGone("Element was removed from DOM")}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}setupVisibilityMonitoring(){this.visibilityCheckInterval=setInterval(()=>{if(!this.currentElement)return;const e=sa.getSequenceForElement(this.currentElement)??-1,t=sa.checkElementInteractable(this.currentElement,e);t&&this.failWithElementGone(t)},200)}failWithElementGone(e){if(this.rejectPromise){const t=this.rejectPromise;this.rejectPromise=null,this.resolvePromise=null,t(/* @__PURE__ */new Error(`ELEMENT_GONE: ${e}`))}this.cleanup()}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}}.getInstance(),ua=class e{static instance;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async executeTool(e,t,r="do",n=""){try{if("show"===r&&this.requiresHighlight(e)){const r=t.index;if(void 0!==r){const{element:t,error:i}=sa.getElementByIndex(r);if(!t)return{success:!1,data:{text:""},error:i||`Element ${r} not found`};if(!(await da.showToolAction({element:t,explanation:n||`Execute ${e}`,toolName:e,isClickAction:"click_element"===e})))return{success:!1,data:{text:""},error:"User cancelled action"}}}switch(e){case"navigate":return this.navigate(t);case"search":return this.search(t);case"click_element":return await this.clickElement(t);case"type_text":return this.typeText(t);case"scroll":return this.scroll(t);case"scroll_to_text":return this.scrollToText(t);case"extract":return this.extract(t);case"go_back":return this.goBack();case"wait":return await this.wait(t);case"select_dropdown_option":return this.selectDropdownOption(t);case"get_dropdown_options":return this.getDropdownOptions(t);case"send_keys":return this.sendKeys(t);case"upload_file":return this.uploadFile(t);case"close_tab":return this.closeTab();case"switch_tab":return this.switchTab(t);case"done":return this.done(t);case"get_html":return this.getHtml();case"get_interactable_elements":return this.getInteractableElements();case"get_screenshot":return await this.getScreenshot();default:return{success:!1,data:{text:""},error:`Unknown tool: ${e}`}}}catch(i){return da.cleanup(),{success:!1,data:{text:""},error:i instanceof Error?i.message:String(i)}}}requiresHighlight(e){return Ds.has(e)}navigate(e){return e.url?e.new_tab?(window.open(e.url,"_blank"),{success:!0,data:{text:`Opened ${e.url} in new tab`}}):(window.location.href=e.url,{success:!0,data:{text:`Navigating to ${e.url}`}}):{success:!1,data:{text:""},error:"URL is required"}}search(e){if(!e.query)return{success:!1,data:{text:""},error:"Query is required"};const t=e.engine||"duckduckgo",r=encodeURIComponent(e.query);let n=`https://duckduckgo.com/?q=${r}`;return"google"===t&&(n=`https://www.google.com/search?q=${r}`),"bing"===t&&(n=`https://www.bing.com/search?q=${r}`),window.location.href=n,{success:!0,data:{text:`Searching for "${e.query}" on ${t}`}}}async clickElement(e){if(void 0===e.index)return{success:!1,data:{text:""},error:"Index required"};const{element:t,error:r}=sa.getValidatedElement(e.index);return t?(t.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(e=>setTimeout(e,100)),setTimeout(()=>{try{t.click()}catch(e){try{t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}catch(r){}}},50),{success:!0,data:{text:`Clicked element ${e.index}`}}):{success:!1,data:{text:""},error:r||`Element ${e.index} not found`}}typeText(e){if(void 0===e.index||void 0===e.text)return{success:!1,data:{text:""},error:"Index and text required"};const t=!1!==e.clear,{element:r,error:n}=sa.getValidatedElement(e.index);if(!r)return{success:!1,data:{text:""},error:n||`Element ${e.index} not found`};if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r.isContentEditable){const n=r;try{n.focus()}catch(i){}const o=t?e.text:n.value+e.text;let s=!1,a=null;if(!s)try{const e="TEXTAREA"===n.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(n,o),s=!0)}catch(i){a=i}if(!s)try{n.value=o,s=!0}catch(i){a=i}if(!s)try{n.focus(),t&&n.select(),document.execCommand("insertText",!1,e.text)&&(s=!0)}catch(i){a=i}if(!s)try{n.focus(),t&&(n.value="");for(const t of e.text)n.dispatchEvent(new KeyboardEvent("keydown",{key:t,bubbles:!0,cancelable:!0})),n.value+=t,n.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),n.dispatchEvent(new KeyboardEvent("keyup",{key:t,bubbles:!0,cancelable:!0}));s=!0}catch(i){a=i}if(!s)return{success:!1,data:{text:""},error:`Failed to set value: ${a instanceof Error?a.message:String(a)}`};try{const t=new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:e.text});n.dispatchEvent(t),n.dispatchEvent(new Event("change",{bubbles:!0})),n.dispatchEvent(new Event("blur",{bubbles:!0}))}catch(i){}}else if("value"in r)try{r.value=e.text,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0}))}catch(i){return{success:!1,data:{text:""},error:`Failed to set value on element: ${i instanceof Error?i.message:String(i)}`}}else try{r.textContent=e.text,r.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){return{success:!1,data:{text:""},error:`Failed to set textContent: ${i instanceof Error?i.message:String(i)}`}}return{success:!0,data:{text:`Typed text into element ${e.index}`}}}scroll(e){const t=.8*window.innerHeight;switch(e.direction){case"down":window.scrollBy({top:t,behavior:"smooth"});break;case"up":window.scrollBy({top:-t,behavior:"smooth"});break;case"left":window.scrollBy({left:-t,behavior:"smooth"});break;case"right":window.scrollBy({left:t,behavior:"smooth"});break;default:return{success:!1,data:{text:""},error:"Invalid direction"}}return{success:!0,data:{text:`Scrolled ${e.direction}`}}}scrollToText(e){if(!e.text)return{success:!1,data:{text:""},error:"Text required"};const t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT);let r;for(;r=t.nextNode();)if(r.textContent?.includes(e.text)&&r.parentElement)return r.parentElement.scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,data:{text:`Scrolled to "${e.text}"`}};return{success:!1,data:{text:""},error:`Text "${e.text}" not found`}}extract(e){const t=e.start_from_char??0,r=!1!==e.extract_links,n=document.body.innerText;return{success:!0,data:{title:document.title,url:window.location.href,text:n.slice(t,t+1e4),links:r?Array.from(document.querySelectorAll("a[href]")).slice(0,100).map(e=>({text:e.textContent?.trim()||"",href:e.getAttribute("href")})):[]}}}goBack(){return window.history.length>1?(window.history.back(),{success:!0,data:{text:"Navigated back"}}):{success:!1,data:{text:""},error:"No history"}}async wait(e){return void 0===e.seconds?{success:!1,data:{text:""},error:"Seconds required"}:(await new Promise(t=>setTimeout(t,1e3*e.seconds)),{success:!0,data:{text:`Waited ${e.seconds}s`}})}selectDropdownOption(e){if(void 0===e.index||!e.option)return{success:!1,data:{text:""},error:"Index/Option required"};const{element:t,error:r}=sa.getValidatedElement(e.index);if(!t)return{success:!1,data:{text:""},error:r||`Select ${e.index} not found`};if(!(t instanceof HTMLSelectElement))return{success:!1,data:{text:""},error:`Element ${e.index} is not a select element`};const n=Array.from(t.options).find(t=>t.value===e.option||t.text===e.option);return n?(t.value=n.value,t.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,data:{text:`Selected ${e.option}`}}):{success:!1,data:{text:""},error:`Option ${e.option} not found`}}getDropdownOptions(e){const t=e.index,{element:r,error:n}=sa.getValidatedElement(t);return r?r instanceof HTMLSelectElement?{success:!0,data:{options:Array.from(r.options).map(e=>({value:e.value,text:e.text}))}}:{success:!1,data:{options:[]},error:`Element ${t} is not a select element`}:{success:!1,data:{options:[]},error:n||`Select ${t} not found`}}sendKeys(e){if(void 0===e.index||!e.keys)return{success:!1,data:{text:""},error:"Index/Keys required"};const{element:t,error:r}=sa.getValidatedElement(e.index);return t?(t.focus(),t.dispatchEvent(new KeyboardEvent("keydown",{key:e.keys,bubbles:!0,cancelable:!0})),t.dispatchEvent(new KeyboardEvent("keyup",{key:e.keys,bubbles:!0,cancelable:!0})),{success:!0,data:{text:this.simulateKeyAction(t,e.keys)||`Sent keys ${e.keys}`}}):{success:!1,data:{text:""},error:r||`Element ${e.index} not found`}}simulateKeyAction(e,t){switch(t){case"Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),r=t.indexOf(e);if(-1!==r&&r<t.length-1){const e=t[r+1];return e.focus(),`Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Tab: no next focusable element"}case"Shift+Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),r=t.indexOf(e);if(r>0){const e=t[r-1];return e.focus(),`Shift+Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Shift+Tab: no previous focusable element"}case"Enter":if(e instanceof HTMLButtonElement||"button"===e.getAttribute("role"))return e.click(),"Enter: clicked button";if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.closest("form");if(t){const e=t.querySelector('button[type="submit"], input[type="submit"]');return e?(e.click(),"Enter: clicked form submit button"):(t.requestSubmit(),"Enter: submitted form")}}return e instanceof HTMLAnchorElement?(e.click(),"Enter: clicked link"):"Enter: dispatched event";case"Escape":return e.blur(),document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0,cancelable:!0})),"Escape: blurred element and dispatched to document";case" ":case"Space":return e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?(e.click(),`Space: toggled ${e.type}`):e instanceof HTMLButtonElement||"button"===e.getAttribute("role")?(e.click(),"Space: clicked button"):"Space: dispatched event";case"ArrowDown":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t<e.options.length-1?(e.selectedIndex=t+1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowDown: selected "${e.options[e.selectedIndex].text}"`):"ArrowDown: already at last option"}return"ArrowDown: dispatched event";case"ArrowUp":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t>0?(e.selectedIndex=t-1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowUp: selected "${e.options[e.selectedIndex].text}"`):"ArrowUp: already at first option"}return"ArrowUp: dispatched event";case"Home":return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?(e.setSelectionRange(0,0),"Home: moved cursor to start"):"Home: dispatched event";case"End":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value.length;return e.setSelectionRange(t,t),"End: moved cursor to end"}return"End: dispatched event";case"Backspace":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value;if(!t||0===t.length)return"Backspace: input is empty, nothing to delete";let r,n,i=e.selectionStart??t.length,o=e.selectionEnd??t.length;if(0===i&&0===o&&(i=t.length,o=t.length),i===o&&i>0)r=t.slice(0,i-1)+t.slice(o),n=i-1;else{if(i===o)return"Backspace: cursor at start, nothing to delete";r=t.slice(0,i)+t.slice(o),n=i}const s=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return s?s.call(e,r):e.value=r,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(n,n),`Backspace: deleted character, value is now "${r}"`}return"Backspace: dispatched event";case"Delete":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.selectionStart||0,r=e.selectionEnd||0,n=e.value;let i;if(t===r&&t<n.length)i=n.slice(0,t)+n.slice(r+1);else{if(t===r)return"Delete: cursor at end, nothing to delete";i=n.slice(0,t)+n.slice(r)}const o=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return o?o.call(e,i):e.value=i,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${i}"`}return"Delete: dispatched event";default:return null}}uploadFile(e){return{success:!1,data:{text:""},error:"File upload not supported via script"}}closeTab(){return window.close(),{success:!0,data:{text:"Attempted close"}}}switchTab(e){return e.tab_id?{success:!1,data:{text:""},error:"Tab switching not supported"}:{success:!1,data:{text:""},error:"tab_id is required"}}done(e){return void 0===e.success?{success:!1,data:{text:""},error:"success parameter is required"}:{success:!0,data:{text:e.message||(e.success?"Task completed":"Task failed")}}}getHtml(){try{return{success:!0,data:{text:sa.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:sa.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await la();if(!e)return{success:!1,data:{text:""},error:"Failed to get stream"};const t=document.createElement("video");t.srcObject=e,t.autoplay=!0,t.style.display="none",document.body.appendChild(t),await new Promise(e=>{t.onloadeddata=()=>e()});const r=document.createElement("canvas");r.width=t.videoWidth,r.height=t.videoHeight,r.getContext("2d")?.drawImage(t,0,0);const n=r.toDataURL("image/jpeg",.75);return t.remove(),{success:!0,data:{text:n}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}}.getInstance(),ha=e=>({state:e,effects:[]});function pa(e,t,r,n,i,o,s){const a=function(e){return js[e]?js[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(n),l=Ns({messages:e,isTaskRunning:t,currentMode:r,requireContent:"failed"===o});if(!l)return e;let c=l.message;const d=t&&"show"===r&&Ds.has(n),u="done"===n,h="show"===r||"do"===r;"in_progress"===o?(u||(c=function(e,t,r){const n=Ps(e),i=n.parts||[],o=[...i],s=i.findIndex(e=>"progress"===e.type&&e.toolName===t&&"in_progress"===e.status),a=!Ls.has(t),l="default",c=$s(r);return s>=0?o[s]={...o[s],content:c,hideIcon:a,textStyle:l}:o.push({type:"progress",content:c,status:"in_progress",toolName:t,hideIcon:a,textStyle:l}),{...n,parts:o}}(c,a,i||a)),t&&h&&(c=Fs(c,t,r,d))):"completed"===o?(u||(c=function(e,t){const r=Ps(e),n=r.parts||[],i=[...n];let o=-1;if(t)o=n.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);else for(let s=n.length-1;s>=0;s--)if("progress"===n[s].type&&"in_progress"===n[s].status){o=s;break}return o>=0&&(i[o]={...i[o],status:"completed"}),{...r,parts:i}}(c)),t&&h&&(c=Fs(c,t,r,!1))):(c=function(e,t,r){const n=Ps(e),i=n.parts||[],o=r.toLowerCase().includes("cancelled by cleanup"),s=[...i];let a=i.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);if(-1===a)for(let l=i.length-1;l>=0;l--)if("progress"===i[l].type&&"in_progress"===i[l].status){a=l;break}if(a>=0)if(o){const e=$s(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=$s(r),t=$s(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...n,parts:s}}(c,a,s||""),t&&h&&(c=Fs(c,t,r,!1)));const p=[...e];return p[l.index]=c,p}function fa(e,t,r,n,i,o){return{...e,messages:pa(e.messages,e.task.isTaskRunning,i,t,r,n,o)}}var ma=r(void 0),ga=({children:e,previewMode:t=!1,currentMode:r,setMessages:n,messagesRef:i,uiActions:s,activeTaskIdRef:l})=>{const[c,p]=h({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),f=u(c);f.current=c;const g=u(0),y=u(/* @__PURE__ */new Set),w=u({}),b=u(r);b.current=r,a(()=>{l.current=c.activeTaskId},[c.activeTaskId,l]);const v=o(e=>{if(y.current.add(e),y.current.size>1e3){const e=Array.from(y.current);y.current=new Set(e.slice(-500))}},[]),x=o(e=>{const t={activeTaskId:f.current.activeTaskId,isTaskRunning:f.current.isTaskRunning};let r=t;n(n=>{const o=e({messages:n.messages,task:t});return r=o.task,i.current=o.messages,o.messages===n.messages?n:{messages:o.messages}}),r.isTaskRunning===t.isTaskRunning&&r.activeTaskId===t.activeTaskId||(f.current={...f.current,...r,taskProgress:[]},p(f.current))},[n,i]),k=o(()=>{const e=w.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;w.current={},x(e=>({...e,task:{isTaskRunning:!0,activeTaskId:t}}))}},[x]);a(()=>{if(t)return;const e=qs.getInstance(),r=async t=>{const{callId:r,tool:n,args:i,mode:o,explanation:s}=t,a=await ua.executeTool(n,i,o,s);if(a.success)try{g.current++,e.send({type:"tool/response",call_id:r,success:!0,data:"string"==typeof a.data?a.data:JSON.stringify(a.data),state_version:g.current}).catch(e=>{}),x(e=>fa(e,n,s,"completed",b.current)),"done"===n&&(w.current={},x(e=>function(e,t){const r=Ns({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),n=[...e.messages];if(r){const e=(r.message.parts??[]).filter(e=>!("progress"===e.type&&"done"===e.toolName));n[r.index]={...r.message,taskStatus:"done",parts:e}}return{messages:n,task:{isTaskRunning:!1,activeTaskId:null}}}(e,b.current)))}catch(l){x(e=>fa(e,n,s,"failed",b.current,"Connection error"))}else x(e=>fa(e,n,s,"failed",b.current,a.error||"Tool execution failed")),g.current++,e.send({type:"tool/response",call_id:r,success:!1,data:"string"==typeof a.data?a.data:JSON.stringify(a.data),error:a.error??void 0,state_version:g.current}).catch(e=>{})},n={onStatusChange:e=>{s.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const r=t.call_id;if(y.current.has(r))return;if(v(r),!Ms.map(e=>e.id).includes(t.tool))return void e.send({type:"tool/response",call_id:r,success:!1,error:`Unknown tool: ${t.tool}`,state_version:g.current}).catch(e=>{});f.current.isTaskRunning,void 0!==t.state_version&&t.state_version>g.current&&(g.current=t.state_version)}else if("task/status"!==t.type||"completed"!==t.status&&"failed"!==t.status&&"stopped"!==t.status){if("task/status"===t.type&&"has_question"===t.status)w.current={};else if("task/status"===t.type&&"running"===t.status)return w.current={...w.current,agentRunning:!0,apiTaskId:w.current.apiTaskId||t.task_id||void 0},void k()}else y.current.clear(),w.current={};let n=[];x(e=>{const r=function(e,t,r){switch(t.type){case"tool/call":{const n=e.task.isTaskRunning?e.task:{...e.task,isTaskRunning:!0},i=n.isTaskRunning,o=t.mode||r||"do",s=t.explanation||"";return{state:{messages:pa(e.messages,i,r,t.tool,s,"in_progress"),task:n},effects:[{type:"executeTool",callId:t.call_id,tool:t.tool,args:t.args,mode:o,explanation:s}]}}case"task/status":{const n=t.message||"";if("running"===t.status)return ha(e);if("has_question"===t.status){const t=Ns({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:r,requireContent:!1}),i=[...e.messages];if(t){const e=Fs(t.message,!1,r);i[t.index]={...e,placeholderState:"waiting-for-user",...n&&{content:n}}}return{state:{messages:i,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}const i=Ns({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:r,requireContent:!1}),o=[...e.messages];if(i){let e="done";"failed"===t.status?e="failed":"stopped"===t.status&&(e="stopped"),o[i.index]={...i.message,taskStatus:e,...n&&{content:n}}}return{state:{messages:o,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}case"chat/response":{const r=e.messages.map(e=>{if(e.id!==t.request_id)return e;const r=[...e.parts??[],{type:"text",content:t.text}];return{...e,content:t.text,isPlaceholder:!1,placeholderState:void 0,parts:r,...t.task_id&&{taskId:t.task_id}}}),n=[{type:"setLoading",value:!1}];return t.task_id&&n.push({type:"activateApiTask",taskId:t.task_id}),{state:{...e,messages:r},effects:n}}case"chat/error":{const r=e.messages.map(e=>{if(e.id!==t.request_id)return e;const r=`Error: ${t.error}`,n=[...e.parts??[],{type:"text",content:r}];return{...e,content:r,isPlaceholder:!1,placeholderState:void 0,parts:n}});return{state:{...e,messages:r},effects:[{type:"setLoading",value:!1}]}}default:return ha(e)}}(e,t,b.current);return n=r.effects,r.state}),(e=>{for(const t of e)"setLoading"===t.type?s.setLoading(t.value):"activateApiTask"===t.type&&(w.current={...w.current,apiTaskId:t.taskId},k())})(n);const i=n.find(e=>"executeTool"===e.type);"executeTool"===i?.type&&await r(i)},onError:e=>{s.setError(e.message)}};return e.addCallbacks(n),()=>{e.removeCallbacks(n)}},[t,x,k,v,s]);const S=o(e=>{p(t=>{const r={...t,...e};return f.current=r,r})},[]),C=o(async()=>{const e=l.current??void 0;x(e=>function(e,t){const r=Ns({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),n=[...e.messages];return r&&(n[r.index]={...r.message,taskStatus:"stopped"}),{messages:n,task:{isTaskRunning:!1,activeTaskId:null}}}(e,b.current)),t||qs.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,x,l]),I=d(()=>({setTaskState:S,stopTask:C}),[S,C]);/* @__PURE__ */
4
- return m(ma.Provider,{value:{taskState:c,taskActions:I},children:e})},ya=()=>{const e=s(ma);if(!e)throw new Error("useTaskContext must be used within TaskProvider");return e},wa=r(void 0),ba=({children:e,initialMode:t="tell",initialIsOpen:r=!1,initialIsMinimized:n=!1})=>{const[i,o]=h({isOpen:r,isMinimized:n,activeView:"home",currentMode:t,agentAvailable:!1,isLoading:!1}),s=d(()=>({setActiveView:e=>o(t=>({...t,activeView:e})),toggleWidget:()=>o(e=>({...e,isOpen:!e.isOpen,isMinimized:!!e.isOpen})),closeWidget:()=>o(e=>({...e,isOpen:!1,isMinimized:!0})),setMode:e=>o(t=>({...t,currentMode:e})),setLoading:e=>o(t=>({...t,isLoading:e})),setAgentAvailable:e=>o(t=>({...t,agentAvailable:e})),setError:e=>o(t=>({...t,error:e})),clearError:()=>o(e=>({...e,error:void 0})),applyState:e=>o(t=>({...t,...e}))}),[]);/* @__PURE__ */
5
- return m(wa.Provider,{value:{uiState:i,uiActions:s},children:e})},va=()=>{const e=s(wa);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var xa=({config:e}={})=>{const{uiState:t,uiActions:r}=va(),{chatState:n,chatActions:i}=ia(),{taskState:s,taskActions:l}=ya(),c=d(()=>({isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading,currentMode:t.currentMode,agentAvailable:t.agentAvailable,error:t.error,activeView:t.activeView,messages:n.messages,activeTaskId:s.activeTaskId,isTaskRunning:s.isTaskRunning,taskProgress:s.taskProgress}),[t,n,s]),u=o(e=>{r.applyState({...void 0!==e.isOpen&&{isOpen:e.isOpen},...void 0!==e.isMinimized&&{isMinimized:e.isMinimized},...void 0!==e.isLoading&&{isLoading:e.isLoading},...void 0!==e.currentMode&&{currentMode:e.currentMode},...void 0!==e.agentAvailable&&{agentAvailable:e.agentAvailable},...void 0!==e.error&&{error:e.error},...void 0!==e.activeView&&{activeView:e.activeView}}),void 0!==e.messages&&i.setMessages(e.messages),void 0===e.activeTaskId&&void 0===e.isTaskRunning&&void 0===e.taskProgress||l.setTaskState({activeTaskId:e.activeTaskId??s.activeTaskId,isTaskRunning:e.isTaskRunning??s.isTaskRunning,taskProgress:e.taskProgress??s.taskProgress})},[r,i,l,s]),h=o(()=>{i.clearMessages(),l.setTaskState({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),r.setError(void 0)},[i,l,r]),p=d(()=>({setState:u,setActiveView:r.setActiveView,toggleWidget:r.toggleWidget,closeWidget:r.closeWidget,setMode:r.setMode,setLoading:r.setLoading,setAgentAvailable:r.setAgentAvailable,setError:r.setError,clearError:r.clearError,setTaskState:l.setTaskState,stopTask:l.stopTask,addMessage:i.addMessage,updateMessage:i.updateMessage,removeMessage:i.removeMessage,setMessages:i.setMessages,sendMessage:i.sendMessage,resetState:h,clearChatHistory:h}),[u,r,l,i,h]),f=d(()=>e||ea.getConfig()||{},[e]),m=function(e){return Object.keys(ys.shape).every(t=>void 0!==e[t])}(f);a(()=>{m&&ea.saveConfig(f)},[f,m]);const g=f.isPreviewMode??!1;return{state:c,actions:p,config:f,shouldShow:m&&!0===f.widget_enabled,isPreviewMode:g,configValid:m}},ka=(e=/* @__PURE__ */new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Sa="-",Ca=[],Ia=e=>{const t=Ea(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return Aa(e);const r=e.split(Sa);return _a(r,""===r[0]&&r.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=n[e],i=r[e];return t?i?((e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r})(i,t):t:i||Ca}return r[e]||Ca}}},_a=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],i=r.nextPart.get(n);if(i){const r=_a(e,t+1,i);if(r)return r}const o=r.validators;if(null===o)return;const s=0===t?e.join(Sa):e.slice(t).join(Sa),a=o.length;for(let l=0;l<a;l++){const e=o[l];if(e.validator(s))return e.classGroupId}},Aa=e=>-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?"arbitrary.."+n:void 0})(),Ea=e=>{const{theme:t,classGroups:r}=e;return za(r,t)},za=(e,t)=>{const r=ka();for(const n in e){const i=e[n];Ma(i,r,n,t)}return r},Ma=(e,t,r,n)=>{const i=e.length;for(let o=0;o<i;o++){const i=e[o];Ta(i,t,r,n)}},Ta=(e,t,r,n)=>{"string"!=typeof e?"function"!=typeof e?Na(e,t,r,n):Ra(e,t,r,n):Oa(e,t,r)},Oa=(e,t,r)=>{(""===e?t:Pa(t,e)).classGroupId=r},Ra=(e,t,r,n)=>{La(e)?Ma(e(n),t,r,n):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(r,e)))},Na=(e,t,r,n)=>{const i=Object.entries(e),o=i.length;for(let s=0;s<o;s++){const[e,o]=i[s];Ma(o,Pa(t,e),r,n)}},Pa=(e,t)=>{let r=e;const n=t.split(Sa),i=n.length;for(let o=0;o<i;o++){const e=n[o];let t=r.nextPart.get(e);t||(t=ka(),r.nextPart.set(e,t)),r=t}return r},La=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Da=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(i,o)=>{r[i]=o,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(e){let t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set(e,t){e in r?r[e]=t:i(e,t)}}},$a=[],Fa=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),ja=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=e=>{const t=[];let r,n=0,i=0,o=0;const s=e.length;for(let d=0;d<s;d++){const s=e[d];if(0===n&&0===i){if(":"===s){t.push(e.slice(o,d)),o=d+1;continue}if("/"===s){r=d;continue}}"["===s?n++:"]"===s?n--:"("===s?i++:")"===s&&i--}const a=0===t.length?e:e.slice(o);let l=a,c=!1;a.endsWith("!")?(l=a.slice(0,-1),c=!0):a.startsWith("!")&&(l=a.slice(1),c=!0);return Fa(t,c,l,r&&r>o?r-o:void 0)};if(t){const e=t+":",r=n;n=t=>t.startsWith(e)?r(t.slice(e.length)):Fa($a,!1,t,void 0,!0)}if(r){const e=n;n=t=>r({className:t,parseClassName:e})}return n},Ba=e=>{const t=/* @__PURE__ */new Map;return e.orderSensitiveModifiers.forEach((e,r)=>{t.set(e,1e6+r)}),e=>{const r=[];let n=[];for(let i=0;i<e.length;i++){const o=e[i],s="["===o[0],a=t.has(o);s||a?(n.length>0&&(n.sort(),r.push(...n),n=[]),r.push(o)):n.push(o)}return n.length>0&&(n.sort(),r.push(...n)),r}},Za=e=>{const t=Object.create(null),r=e.postfixLookupClassGroups;if(r)for(let n=0;n<r.length;n++)t[r[n]]=!0;return t},Wa=/\s+/,Ua=e=>{if("string"==typeof e)return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Ua(e[n]))&&(r&&(r+=" "),r+=t);return r},Va=(e,...t)=>{let r,n,i,o;const s=e=>{const t=n(e);if(t)return t;const o=((e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:s}=t,a=[],l=e.trim().split(Wa);let c="";for(let d=l.length-1;d>=0;d-=1){const e=l[d],{isExternal:t,modifiers:u,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:f}=r(e);if(t){c=e+(c.length>0?" "+c:c);continue}let m,g=!!f;if(g){m=n(p.substring(0,f));const e=m&&s[m]?n(p):void 0;e&&e!==m&&(m=e,g=!1)}else m=n(p);if(!m){if(!g){c=e+(c.length>0?" "+c:c);continue}if(m=n(p),!m){c=e+(c.length>0?" "+c:c);continue}g=!1}const y=0===u.length?"":1===u.length?u[0]:o(u).join(":"),w=h?y+"!":y,b=w+m;if(a.indexOf(b)>-1)continue;a.push(b);const v=i(m,g);for(let r=0;r<v.length;++r){const e=v[r];a.push(w+e)}c=e+(c.length>0?" "+c:c)}return c})(e,r);return i(e,o),o};return o=a=>(r=(e=>({cache:Da(e.cacheSize),parseClassName:ja(e),sortModifiers:Ba(e),postfixLookupClassGroupIds:Za(e),...Ia(e)}))(t.reduce((e,t)=>t(e),e())),n=r.cache.get,i=r.cache.set,o=s,s(a)),(...e)=>o(((...e)=>{let t,r,n=0,i="";for(;n<e.length;)(t=e[n++])&&(r=Ua(t))&&(i&&(i+=" "),i+=r);return i})(...e))},Ha=[],Ga=e=>{const t=t=>t[e]||Ha;return t.isThemeGetter=!0,t},Ya=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ja=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ka=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xa=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qa=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Qa=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,el=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,tl=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,rl=e=>Ka.test(e),nl=e=>!!e&&!Number.isNaN(Number(e)),il=e=>!!e&&Number.isInteger(Number(e)),ol=e=>e.endsWith("%")&&nl(e.slice(0,-1)),sl=e=>Xa.test(e),al=()=>!0,ll=e=>qa.test(e)&&!Qa.test(e),cl=()=>!1,dl=e=>el.test(e),ul=e=>tl.test(e),hl=e=>!ml(e)&&!Sl(e),pl=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),fl=e=>Tl(e,Pl,cl),ml=e=>Ya.test(e),gl=e=>Tl(e,Ll,ll),yl=e=>Tl(e,Dl,nl),wl=e=>Tl(e,Fl,al),bl=e=>Tl(e,$l,cl),vl=e=>Tl(e,Rl,cl),xl=e=>Tl(e,Nl,ul),kl=e=>Tl(e,jl,dl),Sl=e=>Ja.test(e),Cl=e=>Ol(e,Ll),Il=e=>Ol(e,$l),_l=e=>Ol(e,Rl),Al=e=>Ol(e,Pl),El=e=>Ol(e,Nl),zl=e=>Ol(e,jl,!0),Ml=e=>Ol(e,Fl,!0),Tl=(e,t,r)=>{const n=Ya.exec(e);return!!n&&(n[1]?t(n[1]):r(n[2]))},Ol=(e,t,r=!1)=>{const n=Ja.exec(e);return!!n&&(n[1]?t(n[1]):r)},Rl=e=>"position"===e||"percentage"===e,Nl=e=>"image"===e||"url"===e,Pl=e=>"length"===e||"size"===e||"bg-size"===e,Ll=e=>"length"===e,Dl=e=>"number"===e,$l=e=>"family-name"===e,Fl=e=>"number"===e||"weight"===e,jl=e=>"shadow"===e,Bl=/* @__PURE__ */Va(()=>{const e=Ga("color"),t=Ga("font"),r=Ga("text"),n=Ga("font-weight"),i=Ga("tracking"),o=Ga("leading"),s=Ga("breakpoint"),a=Ga("container"),l=Ga("spacing"),c=Ga("radius"),d=Ga("shadow"),u=Ga("inset-shadow"),h=Ga("text-shadow"),p=Ga("drop-shadow"),f=Ga("blur"),m=Ga("perspective"),g=Ga("aspect"),y=Ga("ease"),w=Ga("animate"),b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",Sl,ml],v=()=>[Sl,ml,l],x=()=>[rl,"full","auto",...v()],k=()=>[il,"none","subgrid",Sl,ml],S=()=>["auto",{span:["full",il,Sl,ml]},il,Sl,ml],C=()=>[il,"auto",Sl,ml],I=()=>["auto","min","max","fr",Sl,ml],_=()=>["auto",...v()],A=()=>[rl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],E=()=>[rl,"screen","full","dvw","lvw","svw","min","max","fit",...v()],z=()=>[rl,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],M=()=>[e,Sl,ml],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",_l,vl,{position:[Sl,ml]}],O=()=>["auto","cover","contain",Al,fl,{size:[Sl,ml]}],R=()=>[ol,Cl,gl],N=()=>["","none","full",c,Sl,ml],P=()=>["",nl,Cl,gl],L=()=>[nl,ol,_l,vl],D=()=>["","none",f,Sl,ml],$=()=>["none",nl,Sl,ml],F=()=>["none",nl,Sl,ml],j=()=>[nl,Sl,ml],B=()=>[rl,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[sl],breakpoint:[sl],color:[al],container:[sl],"drop-shadow":[sl],ease:["in","out","in-out"],font:[hl],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[sl],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[sl],shadow:[sl],spacing:["px",nl],text:[sl],"text-shadow":[sl],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",rl,ml,Sl,g]}],container:["container"],"container-type":[{"@container":["","normal","size",Sl,ml]}],"container-named":[pl],columns:[{columns:[nl,ml,Sl,a]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:b()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:x()}],"inset-x":[{"inset-x":x()}],"inset-y":[{"inset-y":x()}],start:[{"inset-s":x(),start:x()}],end:[{"inset-e":x(),end:x()}],"inset-bs":[{"inset-bs":x()}],"inset-be":[{"inset-be":x()}],top:[{top:x()}],right:[{right:x()}],bottom:[{bottom:x()}],left:[{left:x()}],visibility:["visible","invisible","collapse"],z:[{z:[il,"auto",Sl,ml]}],basis:[{basis:[rl,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[nl,rl,"auto","initial","none",ml]}],grow:[{grow:["",nl,Sl,ml]}],shrink:[{shrink:["",nl,Sl,ml]}],order:[{order:[il,"first","last","none",Sl,ml]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:S()}],"col-start":[{"col-start":C()}],"col-end":[{"col-end":C()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:S()}],"row-start":[{"row-start":C()}],"row-end":[{"row-end":C()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:_()}],mx:[{mx:_()}],my:[{my:_()}],ms:[{ms:_()}],me:[{me:_()}],mbs:[{mbs:_()}],mbe:[{mbe:_()}],mt:[{mt:_()}],mr:[{mr:_()}],mb:[{mb:_()}],ml:[{ml:_()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:A()}],"inline-size":[{inline:["auto",...E()]}],"min-inline-size":[{"min-inline":["auto",...E()]}],"max-inline-size":[{"max-inline":["none",...E()]}],"block-size":[{block:["auto",...z()]}],"min-block-size":[{"min-block":["auto",...z()]}],"max-block-size":[{"max-block":["none",...z()]}],w:[{w:[a,"screen",...A()]}],"min-w":[{"min-w":[a,"screen","none",...A()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...A()]}],h:[{h:["screen","lh",...A()]}],"min-h":[{"min-h":["screen","lh","none",...A()]}],"max-h":[{"max-h":["screen","lh",...A()]}],"font-size":[{text:["base",r,Cl,gl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Ml,wl]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ol,ml]}],"font-family":[{font:[Il,bl,t]}],"font-features":[{"font-features":[ml]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Sl,ml]}],"line-clamp":[{"line-clamp":[nl,"none",Sl,yl]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",Sl,ml]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Sl,ml]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[nl,"from-font","auto",Sl,gl]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[nl,"auto",Sl,ml]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[il,Sl,ml]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Sl,ml]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Sl,ml]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:T()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:O()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},il,Sl,ml],radial:["",Sl,ml],conic:[il,Sl,ml]},El,xl]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[nl,Sl,ml]}],"outline-w":[{outline:["",nl,Cl,gl]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",d,zl,kl]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",u,zl,kl]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[nl,gl]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",h,zl,kl]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[nl,Sl,ml]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[nl]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[Sl,ml]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[nl]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:T()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Sl,ml]}],filter:[{filter:["","none",Sl,ml]}],blur:[{blur:D()}],brightness:[{brightness:[nl,Sl,ml]}],contrast:[{contrast:[nl,Sl,ml]}],"drop-shadow":[{"drop-shadow":["","none",p,zl,kl]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",nl,Sl,ml]}],"hue-rotate":[{"hue-rotate":[nl,Sl,ml]}],invert:[{invert:["",nl,Sl,ml]}],saturate:[{saturate:[nl,Sl,ml]}],sepia:[{sepia:["",nl,Sl,ml]}],"backdrop-filter":[{"backdrop-filter":["","none",Sl,ml]}],"backdrop-blur":[{"backdrop-blur":D()}],"backdrop-brightness":[{"backdrop-brightness":[nl,Sl,ml]}],"backdrop-contrast":[{"backdrop-contrast":[nl,Sl,ml]}],"backdrop-grayscale":[{"backdrop-grayscale":["",nl,Sl,ml]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[nl,Sl,ml]}],"backdrop-invert":[{"backdrop-invert":["",nl,Sl,ml]}],"backdrop-opacity":[{"backdrop-opacity":[nl,Sl,ml]}],"backdrop-saturate":[{"backdrop-saturate":[nl,Sl,ml]}],"backdrop-sepia":[{"backdrop-sepia":["",nl,Sl,ml]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Sl,ml]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[nl,"initial",Sl,ml]}],ease:[{ease:["linear","initial",y,Sl,ml]}],delay:[{delay:[nl,Sl,ml]}],animate:[{animate:["none",w,Sl,ml]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,Sl,ml]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:$()}],"rotate-x":[{"rotate-x":$()}],"rotate-y":[{"rotate-y":$()}],"rotate-z":[{"rotate-z":$()}],scale:[{scale:F()}],"scale-x":[{"scale-x":F()}],"scale-y":[{"scale-y":F()}],"scale-z":[{"scale-z":F()}],"scale-3d":["scale-3d"],skew:[{skew:j()}],"skew-x":[{"skew-x":j()}],"skew-y":[{"skew-y":j()}],transform:[{transform:[Sl,ml,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:B()}],"translate-x":[{"translate-x":B()}],"translate-y":[{"translate-y":B()}],"translate-z":[{"translate-z":B()}],"translate-none":["translate-none"],zoom:[{zoom:[il,Sl,ml]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Sl,ml]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Sl,ml]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[nl,Cl,gl,yl]}],stroke:[{stroke:["none",...M()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Zl(...e){return Bl(e.filter(Boolean).join(" "))}var Wl={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)"},Ul={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",theme:"rounded-[var(--radius)]",pill:"rounded-full",circle:"rounded-full"},Vl={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Hl={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Gl={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},Yl={info:{background:"#f0f9ff",border:"1px solid #bae6fd",titleColor:"#0c4a6e",bodyColor:"#0369a1",closeColor:"#7dd3fc",closeHoverColor:"#38bdf8",actionBackground:"#e0f2fe"},error:{background:"#fef2f2",border:"1px solid #fecaca",titleColor:"#b91c1c",bodyColor:"#b91c1c",closeColor:"#f87171",closeHoverColor:"#ef4444",actionBackground:"#fee2e2"}};function Jl(e){if(e&&"none"!==e)return{boxShadow:Wl[e]}}var Kl={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Xl=new Set(["padding","paddingX","paddingY","paddingTop","paddingBottom","margin","marginX","marginY","marginTop","marginBottom","gap","align","justify","wrap","grow","shrink","position","inset","overflow","overflowY","width","height","minWidth","minHeight","border","rounded","shadow","cursor","opacity","animate","hidden","as","style"]);function ql(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Kl[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Kl[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Kl[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Kl[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Kl[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Kl[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Kl[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Kl[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Kl[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Kl[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Kl[e.gap]}`),void 0!==e.align&&t.push(`items-${e.align}`),void 0!==e.justify&&t.push(`justify-${e.justify}`),!0===e.wrap&&t.push("flex-wrap"),!0===e.grow&&t.push("flex-1"),!1===e.shrink&&t.push("flex-shrink-0"),void 0!==e.position&&t.push(e.position),void 0!==e.inset&&t.push("0"===e.inset?"inset-0":`inset-${Kl[e.inset]}`),void 0!==e.overflow&&t.push(`overflow-${e.overflow}`),void 0!==e.overflowY&&t.push(`overflow-y-${e.overflowY}`),void 0!==e.width&&t.push(`w-${e.width}`),void 0!==e.height&&t.push(`h-${e.height}`),"0"===e.minWidth&&t.push("min-w-0"),"0"===e.minHeight&&t.push("min-h-0"),void 0!==e.border&&!1!==e.border)if(!0===e.border)t.push("border","border-border");else{const r={top:"t",bottom:"b",left:"l",right:"r"}[e.border];t.push(`border-${r}`,"border-border")}if(void 0!==e.rounded&&!1!==e.rounded)if(!0===e.rounded)t.push(Ul.theme);else if("full"===e.rounded)t.push(Ul.pill);else{const r="lg"===e.rounded?"lg":e.rounded;t.push(Ul[r])}return!0!==e.shadow&&"theme"!==e.shadow||t.push("shadow-[var(--shadow)]"),void 0!==e.cursor&&t.push(`cursor-${e.cursor}`),void 0!==e.opacity&&t.push(`opacity-${e.opacity}`),void 0!==e.animate&&"none"!==e.animate&&t.push({spin:"animate-spin",ping:"animate-ping",pulse:"animate-pulse",fadeIn:"animate-fade-in"}[e.animate]),!0===e.hidden&&t.push("hidden"),t.join(" ")}function Ql(e){const t={};for(const r in e)Xl.has(r)||(t[r]=e[r]);return t}var ec={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},tc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},rc=i(function(e,t){const{as:r="div",background:n="default",className:i,elevation:o,paddingPreset:s="none",radius:a,style:l,...c}=e,d=ql(e);/* @__PURE__ */
6
- return m(r,{...Ql(c),ref:t,className:Zl(ec[n],tc[s],a&&ql({rounded:a}),d,i),style:{...Jl(o),...l}})}),nc="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",ic={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"},oc=i(function({src:e,alt:t,elevation:r,fit:n="contain",size:i="md",rounded:o,className:s,style:a,...l},c){const d="string"==typeof i,u=d?ic[i]:void 0,h=d?a:{width:i,height:i,...a};/* @__PURE__ */
7
- return m("img",{...l,ref:c,alt:t,className:Zl("flex-shrink-0","contain"===n?"object-contain":"object-cover",u,!0===o||"theme"===o?Ul.theme:"full"===o?Ul.pill:o?Ul[o]:void 0,s),src:e,style:{...Jl(r),...h}})});function sc(e){return"undefined"!=typeof window&&(e instanceof HTMLElement||e instanceof function(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}(e).HTMLElement)}var ac={...e},lc={};function cc(t,r){const n=e.useRef(lc);return n.current===lc&&(n.current=t(r)),n}var dc=ac.useInsertionEffect,uc=dc&&dc!==ac.useLayoutEffect?dc:e=>e();function hc(e){const t=cc(pc).current;return t.next=e,uc(t.effect),t.trampoline}function pc(){const e={next:void 0,callback:fc,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function fc(){}var mc="undefined"!=typeof document?e.useLayoutEffect:()=>{};function gc(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var yc={};function wc(e,t,r,n,i){if(!(r||n||i||e))return bc(t);let o=bc(e);return t&&(o=vc(o,t)),r&&(o=vc(o,r)),n&&(o=vc(o,n)),i&&(o=vc(o,i)),o}function bc(e){return kc(e)?{...Sc(e,yc)}:function(e){const t={...e};for(const r in t){const e=t[r];xc(r,e)&&(t[r]=Ic(e))}return t}(e)}function vc(e,t){return kc(t)?Sc(t,e):function(e,t){if(!t)return e;for(const r in t){const n=t[r];switch(r){case"style":e[r]=gc(e.style,n);break;case"className":e[r]=Ac(e.className,n);break;default:xc(r,n)?e[r]=Cc(e[r],n):e[r]=n}}return e}(e,t)}function xc(e,t){const r=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2);return 111===r&&110===n&&i>=65&&i<=90&&("function"==typeof t||void 0===t)}function kc(e){return"function"==typeof e}function Sc(e,t){return kc(e)?e(t):e??yc}function Cc(e,t){return t?e?(...r)=>{const n=r[0];if(Ec(n)){const i=n;_c(i);const o=t(...r);return i.baseUIHandlerPrevented||e?.(...r),o}const i=t(...r);return e?.(...r),i}:Ic(t):e}function Ic(e){return e?(...t)=>{const r=t[0];return Ec(r)&&_c(r),e(...t)}:e}function _c(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Ac(e,t){return t?e?t+" "+e:t:e}function Ec(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}var zc,Mc,Tc=(zc="https://base-ui.com/production-error",Mc="Base UI",function(e,...t){const r=new URL(zc);return r.searchParams.set("code",e.toString()),t.forEach(e=>r.searchParams.append("args[]",e)),`${Mc} error #${e}; visit ${r} for the full message.`}),Oc=/* @__PURE__ */e.createContext(void 0);function Rc(t={}){const{disabled:r=!1,focusableWhenDisabled:n,tabIndex:i=0,native:o=!0,composite:s}=t,a=e.useRef(null),l=function(t=!1){const r=e.useContext(Oc);if(void 0===r&&!t)throw new Error(Tc(16));return r}(!0),c=s??void 0!==l,{props:d}=function(t){const{focusableWhenDisabled:r,disabled:n,composite:i=!1,tabIndex:o=0,isNativeButton:s}=t,a=i&&!1!==r,l=i&&!1===r;return{props:e.useMemo(()=>{const e={onKeyDown(e){n&&r&&"Tab"!==e.key&&e.preventDefault()}};return i||(e.tabIndex=o,!s&&n&&(e.tabIndex=r?o:-1)),(s&&(r||a)||!s&&n)&&(e["aria-disabled"]=n),!s||r&&!l||(e.disabled=n),e},[i,n,r,a,l,s,o])}}({focusableWhenDisabled:n,disabled:r,composite:c,tabIndex:i,isNativeButton:o}),u=e.useCallback(()=>{const e=a.current;Nc(e)&&c&&r&&void 0===d.disabled&&e.disabled&&(e.disabled=!1)},[r,d.disabled,c]);return mc(u,[u]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:n,onKeyUp:i,onKeyDown:s,onPointerDown:a,...l}=e;return wc({onClick(e){r?e.preventDefault():t?.(e)},onMouseDown(e){r||n?.(e)},onKeyDown(e){if(r)return;if(_c(e),s?.(e),e.baseUIHandlerPrevented)return;const n=e.target===e.currentTarget,i=e.currentTarget,a=Nc(i),l=!o&&(d=i,Boolean("A"===d?.tagName&&d?.href));var d;const u=n&&(o?a:!l),h="Enter"===e.key,p=" "===e.key,f=i.getAttribute("role"),m=f?.startsWith("menuitem")||"option"===f||"gridcell"===f;if(n&&c&&p){if(e.defaultPrevented&&m)return;return e.preventDefault(),void(l||o&&a?(i.click(),e.preventBaseUIHandler()):u&&(t?.(e),e.preventBaseUIHandler()))}u&&(o||!p&&!h||e.preventDefault(),!o&&h&&t?.(e))},onKeyUp(e){r||(_c(e),i?.(e),e.target===e.currentTarget&&o&&c&&Nc(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||o||c||" "!==e.key||t?.(e))},onPointerDown(e){r?e.preventDefault():a?.(e)}},o?{type:"button"}:{role:"button"},d,l)},[r,d,c,o]),buttonRef:hc(e=>{a.current=e,u()})}}function Nc(e){return sc(e)&&"BUTTON"===e.tagName}function Pc(e,t,r,n){const i=cc(Lc).current;return function(e,t,r,n,i){return e.refs[0]!==t||e.refs[1]!==r||e.refs[2]!==n||e.refs[3]!==i}(i,e,t,r,n)&&Dc(i,[e,t,r,n]),i.callback}function Lc(){return{callback:null,cleanup:null,refs:[]}}function Dc(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=r=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=r){const n=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const i=t[e];if(null!=i)switch(typeof i){case"function":{const t=i(r);"function"==typeof t&&(n[e]=t);break}case"object":i.current=r}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const r=t[e];if(null!=r)switch(typeof r){case"function":{const t=n[e];"function"==typeof t?t():r(null);break}case"object":r.current=null}}}}}}var $c=parseInt(e.version,10);function Fc(t){if(!/* @__PURE__ */e.isValidElement(t))return null;const r=t,n=r.props;return($c>=19?n?.ref:r.ref)??null}Object.freeze([]);var jc=Object.freeze({});function Bc(t,r,i={}){const o=r.render,s=function(e,t={}){const{className:r,style:n,render:i}=e,{state:o=jc,ref:s,props:a,stateAttributesMapping:l,enabled:c=!0}=t,d=c?function(e,t){return"function"==typeof e?e(t):e}(r,o):void 0,u=c?function(e,t){return"function"==typeof e?e(t):e}(n,o):void 0,h=c?function(e,t){const r={};for(const n in e){const i=e[n];if(t?.hasOwnProperty(n)){const e=t[n](i);null!=e&&Object.assign(r,e);continue}!0===i?r[`data-${n.toLowerCase()}`]="":i&&(r[`data-${n.toLowerCase()}`]=i.toString())}return r}(o,l):jc,p=c&&a?function(e){return Array.isArray(e)?function(e){if(0===e.length)return yc;if(1===e.length)return bc(e[0]);let t=bc(e[0]);for(let r=1;r<e.length;r+=1)t=vc(t,e[r]);return t}(e):wc(void 0,e)}(a):void 0,f=c?gc(h,p)??{}:jc;"undefined"!=typeof document&&(c?Array.isArray(s)?f.ref=function(e){const t=cc(Lc).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,r)=>e!==t[r])}(t,e)&&Dc(t,e),t.callback}([f.ref,Fc(i),...s]):f.ref=Pc(f.ref,Fc(i),s):Pc(null,null));if(!c)return jc;void 0!==d&&(f.className=Ac(f.className,d));void 0!==u&&(f.style=gc(f.style,u));return f}(r,i);return!1===i.enabled?null:function(t,r,i,o){if(r){if("function"==typeof r)return r(i,o);const t=wc(i,r.props);t.ref=i.ref;let n=r;return n?.$$typeof===Zc&&(n=e.Children.toArray(r)[0]),/* @__PURE__ */e.cloneElement(n,t)}if(t&&"string"==typeof t)return function(t,r){return"button"===t?/* @__PURE__ */n("button",{type:"button",...r,key:r.key}):"img"===t?/* @__PURE__ */n("img",{alt:"",...r,key:r.key}):/* @__PURE__ */e.createElement(t,r)}(t,i);throw new Error(Tc(8))}(t,o,s,i.state??jc)}var Zc=Symbol.for("react.lazy");var Wc=/* @__PURE__ */e.forwardRef(function(e,t){const{render:r,className:n,disabled:i=!1,focusableWhenDisabled:o=!1,nativeButton:s=!0,style:a,...l}=e,{getButtonProps:c,buttonRef:d}=Rc({disabled:i,focusableWhenDisabled:o,native:s});return Bc("button",e,{state:{disabled:i},ref:[t,d],props:[l,c]})}),Uc={primary:"bg-primary text-primary-foreground border-transparent hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border-transparent hover:bg-secondary/80",ghost:"bg-transparent text-foreground border-border hover:bg-muted",bare:"bg-transparent text-inherit border-transparent hover:bg-transparent p-0 min-h-0",chip:"bg-secondary-bg text-foreground border-transparent hover:bg-primary hover:text-primary-foreground hover:border-primary",tab:"bg-transparent text-foreground-muted border-transparent hover:text-foreground hover:bg-transparent p-0 min-h-0",inline:"bg-transparent text-primary border-transparent hover:bg-transparent hover:text-primary p-0 min-h-0",toolbar:"bg-transparent text-foreground border-transparent opacity-60 hover:opacity-100"},Vc={sm:"px-2 py-1 text-xs min-h-7",md:"px-4 py-2 text-sm min-h-9"},Hc={default:"rounded-lg",theme:Ul.theme,pill:Ul.pill},Gc=i(function({active:e=!1,className:t,disabled:r,elevation:n,full:i,loading:o=!1,shape:s="default",size:a="md",stacked:l=!1,type:c="button",variant:d="primary",style:u,...h},p){const f=!["bare","inline","tab","toolbar"].includes(d),g=r||o;/* @__PURE__ */
8
- return m(Wc,{...h,ref:p,className:Zl("inline-flex items-center justify-center gap-2 font-medium cursor-pointer transition-all focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2",f&&"border",Hc[s],Uc[d],"bare"!==d&&"inline"!==d&&"tab"!==d&&Vc[a],l&&"flex-col gap-0.5","tab"===d&&"h-full min-w-0 flex-1",e&&"tab"===d&&"text-primary font-semibold",g&&"opacity-50 cursor-not-allowed pointer-events-none",o&&"opacity-70 cursor-wait pointer-events-none",i&&"w-full",t),"aria-busy":o?"true":void 0,"data-disabled":r?"true":"false","data-loading":o?"true":"false","data-size":a,"data-variant":d,disabled:g,style:{...Jl(n),...u},type:c})}),Yc=i(function(e,t){const{className:r,direction:n,...i}=e;/* @__PURE__ */
9
- return m(rc,{...i,ref:t,className:Zl("flex","column"===n&&"flex-col",r)})}),Jc={spinner:{viewBox:"0 0 512 512",paths:[{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z",fill:"currentColor"}]},checkCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z",fill:"currentColor"}]},circle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z",fill:"currentColor"}]},exclamationCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z",fill:"currentColor"}]},timesCircle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z",fill:"currentColor"}]},ban:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z",fill:"currentColor"}]},arrowUp:{viewBox:"0 0 448 512",paths:[{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z",fill:"currentColor"}]},arrowDown:{viewBox:"0 0 448 512",paths:[{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z",fill:"currentColor"}]},info:{viewBox:"0 0 24 24",paths:[{d:"M 12 2 A 10 10 0 1 1 11.9999 2 Z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 16L12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 8L12.01 8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},trash:{viewBox:"0 0 24 24",paths:[{d:"M3 6L5 6L21 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M10 11L10 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M14 11L14 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},x:{viewBox:"0 0 24 24",paths:[{d:"M18 6L6 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chatBubble:{viewBox:"0 0 512 512",paths:[{d:"M87.48 380c1.2-4.38-1.43-10.47-3.94-14.86a42.63 42.63 0 0 0-2.54-3.8 199.81 199.81 0 0 1-33-110C47.64 139.09 140.72 48 255.82 48 356.2 48 440 117.54 459.57 209.85a199 199 0 0 1 4.43 41.64c0 112.41-89.49 204.93-204.59 204.93-18.31 0-43-4.6-56.47-8.37s-26.92-8.77-30.39-10.11a31.14 31.14 0 0 0-11.13-2.07 30.7 30.7 0 0 0-12.08 2.43L81.5 462.78a15.92 15.92 0 0 1-4.66 1.22 9.61 9.61 0 0 1-9.58-9.74 15.85 15.85 0 0 1 .6-3.29z",fill:"none",stroke:"currentColor",strokeWidth:32,strokeLinecap:"round"},{d:"M160 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M256 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M352 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"}]},stop:{viewBox:"0 0 512 512",paths:[{d:"M392 432H120a40 40 0 0 1-40-40V120a40 40 0 0 1 40-40h272a40 40 0 0 1 40 40v272a40 40 0 0 1-40 40z",fill:"currentColor"}]},mousePointerClick:{viewBox:"0 0 24 24",paths:[{d:"M14 4.1 12 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m5.1 8-2.9-.8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m6 12-1.9 2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M7.2 2.2 8 5.1",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},scroll:{viewBox:"0 0 24 24",paths:[{d:"M19 17V5a2 2 0 0 0-2-2H4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},ticktick:{viewBox:"0 0 24 24",paths:[{d:"M12 0C5.383 0 0 5.383 0 12s5.383 12 12 12 12-5.383 12-12h-2.7c0 5.128-4.172 9.3-9.3 9.3-5.128 0-9.3-4.172-9.3-9.3 0-5.128 4.172-9.3 9.3-9.3V0Zm7.4 2.583-7.505 9.371L8.388 9.08l-2.002 2.436 4.741 3.888a1.573 1.573 0 0 0 2.231-.233l8.504-10.617L19.4 2.583Z",fill:"currentColor"}]},arrowRight:{viewBox:"0 0 24 24",paths:[{d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},documentText:{viewBox:"0 0 24 24",paths:[{d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},globe:{viewBox:"0 0 24 24",paths:[{d:"M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},magnifyingGlass:{viewBox:"0 0 24 24",paths:[{d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},xMark:{viewBox:"0 0 24 24",paths:[{d:"M6 18 18 6M6 6l12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},keyboard:{viewBox:"0 0 24 24",paths:[{d:"M20 7v10H4V7h16m0-2H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z",fill:"currentColor"}]},selectAll:{viewBox:"0 0 24 24",paths:[{d:"M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z",fill:"currentColor"}]},tablerArrowDown:{viewBox:"0 0 24 24",paths:[{d:"M12 5l0 14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M18 13l-6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 13l6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},fileUpload:{viewBox:"0 0 24 24",paths:[{d:"M14 3v4a1 1 0 0 0 1 1h4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 11v6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.5 13.5l2.5 -2.5l2.5 2.5",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},home:{viewBox:"0 0 24 24",paths:[{d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chat:{viewBox:"0 0 24 24",paths:[{d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},help:{viewBox:"0 0 24 24",paths:[{d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},send:{viewBox:"0 0 24 24",paths:[{d:"M5 12h14m-7-7l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},closeSmall:{viewBox:"0 0 12 12",paths:[{d:"M9 3L3 9M3 3l6 6",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},close:{viewBox:"0 0 20 20",paths:[{d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}]},chevronDown:{viewBox:"0 0 24 24",paths:[{d:"M19 9l-7 7-7-7",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round"}]},screenShare:{viewBox:"0 0 24 24",paths:[{d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},moreVertical:{viewBox:"0 0 20 20",paths:[{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z",fill:"currentColor"}]},chevronRight:{viewBox:"0 0 24 24",paths:[{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},alertCircle:{viewBox:"0 0 24 24",paths:[{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]}},Kc=i(function({name:e,size:t=16,className:r,...n},i){const o=Jc[e];return o?/* @__PURE__ */m("svg",{...n,ref:i,"aria-hidden":"true",className:Zl("inline-block flex-shrink-0",r),fill:"none",height:t,viewBox:o.viewBox,width:t,xmlns:"http://www.w3.org/2000/svg",children:o.paths.map((e,t)=>/* @__PURE__ */m("path",{clipRule:e.clipRule,d:e.d,fill:e.fill??(e.stroke?"none":"currentColor"),fillRule:e.fillRule,stroke:e.stroke,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,strokeMiterlimit:e.strokeMiterlimit,strokeWidth:e.strokeWidth},t))}):null}),Xc={primary:"bg-primary text-primary-foreground hover:bg-primary-hover",secondary:"bg-secondary-bg text-foreground hover:bg-secondary-hover",ghost:"bg-transparent text-foreground opacity-60 hover:opacity-100",toolbar:"bg-transparent text-foreground opacity-60 hover:opacity-100"},qc={xs:"w-5 h-5 min-w-5",sm:"w-7 h-7 min-w-7"},Qc={circle:Ul.circle,theme:Ul.theme},ed=i(function({variant:e="ghost",size:t="sm",shape:r="circle",tone:n,label:i,disabled:o,elevation:s,className:a,children:l,style:c,...d},u){/* @__PURE__ */
10
- return m("button",{...d,ref:u,type:"button",disabled:o,"aria-label":i,className:Zl("inline-flex items-center justify-center flex-shrink-0 border-none cursor-pointer transition-all",Qc[r],Xc[e],n&&Vl[n],qc[t],o&&"opacity-50 cursor-not-allowed pointer-events-none",a),style:{...Jl(s),...c},children:l})}),td=i(function(e,t){const{background:r="default",className:n,elevation:i,paddingPreset:o="none",radius:s,style:a,...l}=e,c=ql(e);/* @__PURE__ */
11
- return m("div",{...Ql(l),ref:t,className:Zl("flex flex-col",ec[r],tc[o],s&&ql({rounded:s}),c,n),style:{...Jl(i),...a}})}),rd={xxs:"text-[10px]",xs:"text-xs",sm:"text-sm",base:"text-base",lg:"text-lg"},nd={normal:"font-normal",medium:"font-medium",semibold:"font-semibold"},id={center:"text-center",right:"text-right"},od=i(function({as:e="span",block:t=!1,clamp:r,code:n=!1,inheritColor:i=!1,italic:o=!1,leading:s,tone:a,variant:l="default",size:c,weight:d,truncate:u,align:h,className:p,style:f,...g},y){/* @__PURE__ */
12
- return m(e,{...g,ref:y,className:Zl(Vl[i?"inherit":a??{default:"default",muted:"muted",faint:"faint"}[l]],c&&rd[c],d&&nd[d],h&&id[h],s&&Hl[s],t&&"block",n&&"font-mono",o&&"italic",u&&"truncate",p),style:r?{...f,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:r,overflow:"hidden"}:f})});function sd(e){return"above-fab"===e?{bottom:"90px",left:"50%",transform:"translateX(-50%)"}:{bottom:"20px",left:"50%",transform:"translateX(-50%)"}}var ad=({tone:e,title:t,body:r,onDismiss:n,onRetry:i,position:s="bottom-center"})=>{const[l,c]=h(!1),d=o(()=>{c(!0),setTimeout(n,300)},[n]);a(()=>{if("info"!==e)return;const t=setTimeout(d,8e3);return()=>clearTimeout(t)},[e,d]);const u=Yl[e];/* @__PURE__ */
13
- return m(rc,{position:"fixed",style:{zIndex:b,maxWidth:"420px",opacity:l?0:1,transition:"opacity 0.3s ease-out",animation:l?"none":"fadeIn 0.3s ease-out",...sd(s)},children:/* @__PURE__ */g(Yc,{align:"center",gap:"md",rounded:"pill",paddingPreset:"toast",elevation:"panel",style:{backgroundColor:u.background,border:u.border},children:[
14
- /* @__PURE__ */m(oc,{src:nc,alt:"",size:28,rounded:"full"}),
15
- /* @__PURE__ */g(td,{grow:!0,minWidth:"0",children:[/* @__PURE__ */m(od,{as:"span",block:!0,inheritColor:!0,weight:"medium",style:{fontSize:"13px",color:u.titleColor,whiteSpace:i?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),r&&/* @__PURE__ */m(od,{as:"span",block:!0,inheritColor:!0,style:{fontSize:"12px",color:u.bodyColor,opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r})]}),i&&/* @__PURE__ */m(Gc,{type:"button",variant:"ghost",shape:"pill",size:"sm",onClick:()=>{i(),d()},style:{color:u.titleColor,backgroundColor:u.actionBackground,border:u.border},"aria-label":"Retry",children:"Retry"}),
16
- /* @__PURE__ */m(ed,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},shape:"circle",size:"xs",tone:"inherit",style:{color:u.closeColor,padding:"2px"},children:/* @__PURE__ */m(Kc,{name:"closeSmall",size:12})})]})})},ld=20,cd=(e,t,r,n,i)=>{switch(e){case"top_left":return{x:ld,y:ld};case"top_right":return{x:t-ld-n,y:ld};case"bottom_left":return{x:ld,y:r-ld-i};default:return{x:t-ld-n,y:r-ld-i}}},dd=(e,t,r,n,i,o)=>{const s=cd(e,r,n,i,o),a=s.x+i/2,l=s.y+o/2;let c,d;switch(t){case"top_left":c=ld+i/2,d=ld+o/2;break;case"top_right":c=r-ld-i/2,d=ld+o/2;break;case"bottom_left":c=ld+i/2,d=n-ld-o/2;break;default:c=r-ld-i/2,d=n-ld-o/2}return{dx:c-a,dy:d-l}},ud="cubic-bezier(0.16, 1, 0.3, 1)";function hd({position:e,onDrag:r,isPreviewMode:n=!1,wrapperRef:i}){const[s,a]=h(!1),[l,d]=h({w:56,h:56}),[,p]=h(0),f=u(null),m=u(null),g=u(null),y=u(0),w=u([]),b=u(0);t.useEffect(()=>()=>{null!==g.current&&window.cancelAnimationFrame(g.current)},[]),t.useEffect(()=>{if(n)return;const e=()=>p(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n]);const v=o(()=>{if(!i.current||"undefined"==typeof window)return;const e=i.current.getBoundingClientRect();d(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[i]);c(()=>{v();const e="undefined"!=typeof window&&i.current?new ResizeObserver(v):null;return e&&i.current&&e.observe(i.current),()=>e?.disconnect()},[v,e,i]);const x="undefined"!=typeof window?window.innerWidth:0,k="undefined"!=typeof window?window.innerHeight:0,S=cd(e,x,k,l.w,l.h),C=!n&&x>0&&k>0?{left:S.x,top:S.y}:void 0,I=(e,t=.999)=>e/1e3*t/(1-t),_=()=>{null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null),i.current&&(i.current.style.transform="",i.current.style.willChange="",i.current.style.transition="")},A=o((e,t)=>{if(f.current)return;let n=!1;const o=()=>{n||(n=!0,f.current=null,t.style.transition="none",t.style.willChange="",r(e),a(!1),requestAnimationFrame(()=>{i.current&&(i.current.style.transition="")}))};f.current=o;const s=window.setTimeout(o,650);t.addEventListener("transitionend",function e(r){r.target===t&&"left"===r.propertyName&&(window.clearTimeout(s),t.removeEventListener("transitionend",e),o())})},[r,i]),E=o((t,n,o)=>{if(!i.current||!C)return _(),r(t),void a(!1);null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null);const s=i.current,c=cd(e,x,k,l.w,l.h),d=cd(t,x,k,l.w,l.h);s.style.transition="none",s.style.transform="none",s.style.willChange="left, top",s.style.left=`${c.x+n}px`,s.style.top=`${c.y+o}px`,requestAnimationFrame(()=>{s.style.transition=`left 600ms ${ud}, top 600ms ${ud}`,s.style.left=`${d.x}px`,s.style.top=`${d.y}px`}),A(t,s)},[A,r,C,e,x,k,l.w,l.h,i]);return{isDragging:s,pixelPositionStyle:C,onPointerDown:e=>{m.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,dragging:!1,lastX:0,lastY:0},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{const t=m.current;if(t?.pointerId!==e.pointerId)return;const r=e.clientX-t.startX,n=e.clientY-t.startY;if(!t.dragging&&Math.hypot(r,n)>5&&(t.dragging=!0,a(!0),w.current=[],b.current=0,i.current&&(i.current.style.willChange="transform",i.current.style.transition="none")),!t.dragging)return;t.lastX=r,t.lastY=n;const o=Date.now();o-b.current>=10&&(b.current=o,w.current=[...w.current.slice(-5),{x:e.clientX,y:e.clientY,t:o}]),null===g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null;const e=m.current,t=i.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:t=>{const r=m.current;if(r?.pointerId===t.pointerId){if(r.dragging){const n=(()=>{const e=w.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),o=I(n.x),s=I(n.y),a={dx:r.lastX+o,dy:r.lastY+s};let l;if("undefined"!=typeof window&&i.current){const t=i.current.getBoundingClientRect();l=((e,t,r,n,i,o)=>{const s=["top_left","top_right","bottom_left","bottom_right"];let a=t,l=1/0;for(const c of s){const s=dd(t,c,r,n,i,o),d=Math.hypot(e.dx-s.dx,e.dy-s.dy);d<l&&(l=d,a=c)}return a})(a,e,window.innerWidth,window.innerHeight,t.width,t.height)}else l=e;return E(l,r.lastX,r.lastY),y.current=Date.now()+600,m.current=null,void t.currentTarget.releasePointerCapture(t.pointerId)}_(),m.current=null,a(!1),t.currentTarget.releasePointerCapture(t.pointerId)}},onPointerCancel:e=>{m.current?.pointerId===e.pointerId&&(_(),m.current=null,a(!1),e.currentTarget.releasePointerCapture(e.pointerId))},suppressUntilRef:y}}var pd=({open:e,processing:t=!1,error:r=!1,taskRunning:n=!1,onClick:i,onStop:o,accentColor:s,backgroundColor:a,borderRadius:l="12px",tooltipBgColor:c,tooltipTextColor:d,zIndex:h=50,position:p,onDrag:f,isPreviewMode:y=!1})=>{const w=!e&&(t||n),b=!e&&n&&null!=o,v=r?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",x=r?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",k=Math.max(6,Math.min(22,Number.parseFloat(l)||12)),S=u(null),{isDragging:C,pixelPositionStyle:I,onPointerDown:_,onPointerMove:A,onPointerUp:E,onPointerCancel:z,suppressUntilRef:M}=hd({position:p,onDrag:f,isPreviewMode:y,wrapperRef:S}),T=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(p),O=y?"absolute":"fixed",R=y?p.includes("top")?{top:"20px",...p.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...p.includes("right")?{right:"20px"}:{left:"20px"}}:{};/* @__PURE__ */
17
- return g(rc,{ref:S,className:`${O} ${I?"":T} ${C?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:h,pointerEvents:e?"none":"auto",...R,...I},children:[/* @__PURE__ */g(rc,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[w&&/* @__PURE__ */m(rc,{className:v,"aria-hidden":!0}),b&&!C&&/* @__PURE__ */m(Gc,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(p.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop running task",children:"Stop"}),
18
- /* @__PURE__ */m(Gc,{type:"button",variant:"bare",onClick:()=>{Date.now()<M.current||i()},onDragStart:e=>e.preventDefault(),onPointerDown:_,onPointerMove:A,onPointerUp:E,onPointerCancel:z,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:C?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */m(Yc,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */g(rc,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:l,backgroundColor:e?a:s,boxShadow:Wl.fab},children:[w&&/* @__PURE__ */m("svg",{className:x,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */m("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:k+1,ry:k+1})}),
19
- /* @__PURE__ */m(Yc,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(30deg) scale(0)":"rotate(0deg) scale(1)",opacity:e?0:1,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":e,children:/* @__PURE__ */m(oc,{src:nc,alt:"",className:"relative z-10 w-full h-full object-contain",draggable:!1,onDragStart:e=>e.preventDefault(),style:{borderRadius:l,border:"none",outline:"none",backgroundColor:"transparent",pointerEvents:"none",userSelect:"none"}})}),
20
- /* @__PURE__ */m(Yc,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */m(Kc,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(rc,{className:`absolute bottom-16 ${p.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:c,color:d},children:[/* @__PURE__ */m(od,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */m(rc,{"aria-hidden":!0,className:`absolute top-full ${p.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:c}})]})]})},fd="3.8.9";function md(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function gd(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function yd(e,t,r){return Math.min(Math.max(e,t),r)}function wd(e,t,r,n,i){const o={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:n-t,dy:i-r,cursor:o[e]};case"bottom-left":return{dx:t-n,dy:i-r,cursor:o[e]};case"top-right":return{dx:n-t,dy:r-i,cursor:o[e]};case"top-left":return{dx:t-n,dy:r-i,cursor:o[e]}}}var bd={count:"inline-flex items-center rounded-full bg-muted px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground",live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},vd={default:"bg-muted text-muted-foreground",muted:"bg-muted text-muted-foreground",primary:"bg-chart-1/15 text-chart-1",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning"},xd=i(function({variant:e,color:t,tone:r="default",className:n,style:i,children:o,...s},a){/* @__PURE__ */
21
- return g("span",{...s,ref:a,className:Zl(bd[e],"status"===e&&vd[r],n),"data-variant":e,style:{color:t,...i},children:["live"===e&&/* @__PURE__ */g("span",{className:"relative flex h-1.5 w-1.5",children:[/* @__PURE__ */m("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */m("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),o]})}),kd=i(function({background:e="card",border:t=!0,children:r,className:n,elevation:i="card",paddingPreset:o="card",radius:s="xl",style:a,...l},c){/* @__PURE__ */
22
- return m(rc,{...l,ref:c,as:"div",background:e,border:t,className:n,elevation:i,paddingPreset:o,radius:s,style:a,children:r})});var Sd=r(null);function Cd(e){const t=s(Sd);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function Id({children:e,defaultOpen:t,onOpenChange:r,open:n}){const{isOpen:i,setIsOpen:s}=function({defaultOpen:e=!1,onOpenChange:t,open:r}){const[n,i]=h(e),s=void 0!==r;return{isOpen:s?r:n,setIsOpen:o(e=>{s||i(e),t?.(e)},[s,t])}}({defaultOpen:t,onOpenChange:r,open:n}),a=l(),c=l(),u=l(),p=d(()=>({contentId:a,descriptionId:u,open:i,setOpen:s,titleId:c}),[a,u,i,s,c]);/* @__PURE__ */
23
- return m(Sd.Provider,{value:p,children:e})}function _d({children:e,className:t,onKeyDown:r,...n}){const i=Cd("DialogContent"),{variant:o="default",style:s,...l}=n;return a(()=>{if(!i.open)return;const e=e=>{"Escape"===e.key&&i.setOpen(!1)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[i]),i.open?/* @__PURE__ */m("div",{...l,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"aria-modal":"true",className:Zl("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[calc(var(--layer-dialog)+1)] flex flex-col w-full max-h-[85vh] overflow-auto bg-card animate-dialog-content-in","default"===o&&"max-w-[500px] rounded-lg p-6","confirm"===o&&"max-w-sm rounded-lg p-4","info"===o&&"w-64 rounded-md border border-border p-0",t),"data-state":"open",id:i.contentId,onKeyDown:e=>{r?.(e),e.defaultPrevented||"Escape"!==e.key||i.setOpen(!1)},role:"dialog",style:{...Jl("info"===o?"section":"panel"),...s},tabIndex:-1,children:e}):null}function Ad({className:e,variant:t="default",...r}){const n=Cd("DialogTitle");/* @__PURE__ */
24
- return m("h2",{...r,className:Zl("default"===t&&"text-lg font-semibold text-card-foreground mb-2","confirm"===t&&"text-base font-semibold text-foreground mb-1","info"===t&&"text-xs font-semibold text-foreground flex-1 text-center mb-0",e),id:n.titleId})}function Ed({className:e,variant:t="default",...r}){const n=Cd("DialogDescription");/* @__PURE__ */
25
- return m("p",{...r,className:Zl("default"===t&&"text-sm text-muted-foreground mb-4","confirm"===t&&"text-sm text-muted-foreground mb-4 leading-relaxed",e),id:n.descriptionId})}function zd({children:e,className:t,onClick:r,variant:n="default",...i}){const o=Cd("DialogClose");/* @__PURE__ */
26
- return m("button",{...i,className:Zl("default"===n&&"absolute top-4 right-4 flex items-center justify-center w-8 h-8 p-0 bg-transparent border-none rounded-lg text-muted-foreground cursor-pointer transition-colors hover:bg-muted","info"===n&&"static -mr-1 flex h-5 w-5 items-center justify-center rounded-full border-none bg-transparent p-0 text-muted-foreground transition-colors hover:text-foreground",t),onClick:e=>{r?.(e),e.defaultPrevented||o.setOpen(!1)},type:"button",children:e})}var Md=()=>/* @__PURE__ */m("span",{className:"block h-0.5 w-full rounded-full bg-primary"}),Td={sm:"px-2 py-0.5 text-[11px] gap-0.5"},Od=i(function({active:e=!1,variant:t="primary",size:r="sm",children:n,...i},o){/* @__PURE__ */
27
- return m("button",{...i,ref:o,type:"button",className:Zl("inline-flex items-center font-medium border-none cursor-pointer transition-all duration-200",Ul.pill,Td[r],e&&"primary"===t&&"bg-primary text-primary-foreground shadow-sm",!e&&"bg-secondary-bg text-foreground-muted"),children:n})}),Rd={sm:"h-3.5 w-3.5 border-[1.5px]",md:"h-5 w-5 border-2",lg:"h-6 w-6 border-2"},Nd=i(function({label:e,size:t="md",className:r,style:n},i){/* @__PURE__ */
28
- return g("div",{ref:i,className:Zl("inline-flex items-center gap-1.5",r),"data-size":t,role:"status",style:n,children:[
29
- /* @__PURE__ */m("div",{"aria-hidden":"true",className:Zl("animate-spin rounded-full border-current border-t-transparent flex-shrink-0",Rd[t])}),null!=e&&/* @__PURE__ */m("span",{children:e}),
30
- /* @__PURE__ */m("span",{className:"sr-only",children:"Loading"})]})}),Pd={default:"block w-full px-3 py-2 text-sm leading-normal text-foreground bg-background border border-input rounded-lg transition-colors min-h-20 resize-y hover:border-muted-foreground focus:outline-none focus:border-ring focus:ring-3 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-muted",chat:"block w-full px-3 text-sm text-foreground placeholder:text-foreground-faint bg-transparent border-none rounded-none transition-colors min-h-0 resize-none focus:outline-none focus:ring-0 disabled:opacity-50 disabled:cursor-not-allowed"},Ld=i(function({className:e,errorMessage:t,id:r,validationState:n="default",variant:i="default",...o},s){const a="invalid"===n&&t?`${r??o["aria-label"]??"textarea"}-error`:void 0;/* @__PURE__ */
31
- return g(f,{children:[/* @__PURE__ */m("textarea",{...o,"aria-describedby":a,"aria-invalid":"invalid"===n?"true":void 0,className:Zl(Pd[i],e),"data-validation-state":n,id:r,ref:s}),null!=a&&/* @__PURE__ */m("span",{id:a,children:t})]})}),Dd=i(function({className:e,...t},r){/* @__PURE__ */
32
- return m("video",{...t,ref:r,className:Zl(e)})}),$d=({title:e,subtitle:t,minimized:r=!1,onClose:n,controls:i})=>/* @__PURE__ */g(Yc,r?{align:"center",justify:"between",paddingX:"lg",border:"bottom",shrink:!1,style:Gl.header,children:[/* @__PURE__ */m(od,{size:"sm",weight:"medium",children:e}),/* @__PURE__ */m(ed,{variant:"toolbar",size:"sm",label:"Close",onClick:n,children:/* @__PURE__ */m(Kc,{name:"close",size:16})})]}:{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */g(Yc,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */m(oc,{src:nc,alt:"",size:"md",rounded:"theme",elevation:"card"}),/* @__PURE__ */g(td,{minWidth:"0",children:[/* @__PURE__ */m(od,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */m(od,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */g(Yc,{align:"center",gap:"xs",shrink:!1,children:[i,/* @__PURE__ */m(ed,{variant:"toolbar",size:"sm",label:"Close",onClick:n,children:/* @__PURE__ */m(Kc,{name:"close",size:16})})]})]});function Fd({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:r,onAddMessage:n,onUpdateMessage:i,onRemoveMessage:o,onSendMessage:s,pendingMessage:l,setPendingMessage:c}){const[d,p]=h(!1),[f,m]=h(null),[g,y]=h(null),[w,b]=h(null),[v,x]=h(!1),k=u(d),S=u(g),C=u(n),I=u(o),_=u(e);a(()=>{k.current=d},[d]),a(()=>{S.current=g},[g]),a(()=>{C.current=n},[n]),a(()=>{I.current=o},[o]),a(()=>{_.current=e},[e]),a(()=>{const e=()=>{const e=ca(),t=k.current,r=S.current;if(e!==t&&(k.current=e,p(e),_.current?.(e)),t&&!e&&r){I.current?.(r);const e=Gs("Stopped screenshare","show","user","stopped-sharing");C.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const A=()=>{x(!0)},E=()=>{aa&&(aa.getTracks().forEach(e=>e.stop()),aa=null),p(!1),m(null),e?.(!1),g&&o&&o(g),n(Gs("Stopped screenshare","show","user","stopped-sharing")),y(null)};return a(()=>(t&&(t.current=A),r&&(r.current=E),()=>{t&&(t.current=null),r&&(r.current=null)})),{isScreenSharing:d,screenStream:f,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await la();p(!0),m(t),e?.(!0),n(Ys("show"));const r=Js(t,"show");y(r.id),n(r)}catch(t){p(!1),m(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await la();p(!0),m(t),e?.(!0),w&&(i(w,{screenShareStatus:"allowed"}),b(null)),n(Ys("show"));const r=Js(t,"show");if(y(r.id),n(r),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(p(!1),m(null),e?.(!1),w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(w)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);b(t.id),n(t)}}}function jd(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var Bd=t.forwardRef(function({value:e,onChange:t,onSubmit:r,modes:n=[],activeMode:i,onModeChange:s,disabled:l=!1,taskRunning:c=!1,onStop:d,placeholder:h="Ask anything"},p){const f=u(null);a(()=>{const e=f.current;if(e){e.style.height="auto";const t=e.scrollHeight,r=Math.min(t,66);e.style.height=`${r}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=o(e=>{t(e.target.value);const r=e.target;r.style.height="auto";const n=Math.min(r.scrollHeight,66);r.style.height=`${n}px`,r.style.overflowY=r.scrollHeight>66?"auto":"hidden"},[t]),w=o(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),r())},[r]),b=Boolean(e.trim())&&!l;/* @__PURE__ */
33
- return g(td,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"focus-within:border-foreground-faint transition-colors",children:[/* @__PURE__ */m(Ld,{ref:jd(f,p),value:e,onChange:y,onKeyDown:w,placeholder:h,disabled:l,rows:1,variant:"chat",style:{lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */g(Yc,{align:"center",justify:"between",paddingX:"sm",paddingTop:"2xs",paddingBottom:"sm",children:[/* @__PURE__ */m(Yc,{align:"center",gap:"2xs",children:n.map(e=>/* @__PURE__ */g(Od,{active:i===e.id,size:"sm",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */m(Kc,{name:e.icon,size:12}),/* @__PURE__ */m(od,{as:"span",inheritColor:!0,children:e.label})]},e.id))}),/* @__PURE__ */m(ed,{variant:c?"secondary":"primary",size:"sm",disabled:!c&&!b,label:c?"Stop task":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),c&&d?d():r()},children:/* @__PURE__ */m(Kc,c?{name:"stop",size:14}:{name:"send",size:16})})]})]})}),Zd={green:"success",blue:"primary",yellow:"warning",gray:"muted"},Wd=({variant:e,open:t,onClose:r,title:n,description:i,onConfirm:o,confirmLabel:s="Confirm",cancelLabel:a="Cancel",rows:l=[],status:c})=>/* @__PURE__ */m(Id,{open:t,onOpenChange:e=>{e||r()},children:/* @__PURE__ */g(_d,"confirm"===e?{variant:"confirm",children:[
34
- /* @__PURE__ */m(Ad,{variant:"confirm",children:n}),null!=i&&/* @__PURE__ */m(Ed,{variant:"confirm",children:i}),
35
- /* @__PURE__ */g(Yc,{gap:"md",justify:"end",children:[/* @__PURE__ */m(Gc,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),r()},children:a}),/* @__PURE__ */m(Gc,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:s})]})]}:{variant:"info",children:[/* @__PURE__ */g(Yc,{align:"center",justify:"between",paddingX:"lg",paddingY:"sm",border:"bottom",children:[/* @__PURE__ */m(Ad,{variant:"info",children:n}),/* @__PURE__ */m(zd,{variant:"info","aria-label":"Close",children:/* @__PURE__ */m(Kc,{name:"x",size:12})})]}),/* @__PURE__ */g(td,{paddingX:"lg",paddingY:"sm",children:[l.map(e=>/* @__PURE__ */g(Yc,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */m(od,{as:"span",size:"xs",variant:"muted",children:e.label}),/* @__PURE__ */g(Yc,{align:"center",gap:"2xs",children:[/* @__PURE__ */m(od,{as:"code",code:!0,size:"xs",variant:"muted",truncate:!0,style:{maxWidth:"120px"},children:e.value||"N/A"}),!0===e.copyable&&e.value&&/* @__PURE__ */m(Gc,{type:"button",variant:"inline",size:"sm",onClick:()=>{return t=e.value,void navigator.clipboard.writeText(t);var t},children:"Copy"})]})]},e.label)),null!=c&&/* @__PURE__ */g(Yc,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */m(od,{as:"span",size:"xs",variant:"muted",children:"Status"}),/* @__PURE__ */m(xd,{variant:"status",tone:Zd[c.color],children:c.label})]})]})]})}),Ud=({variant:e,message:t})=>{const r="error"===e,n="loading"===e;/* @__PURE__ */
36
- return g(td,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:n?"status":void 0,"aria-live":r?"assertive":"polite",style:r?{color:"var(--color-red-600, #dc2626)"}:void 0,children:[n&&/* @__PURE__ */m(Nd,{size:"lg"}),/* @__PURE__ */m(od,{as:"p",size:"sm",align:"center",children:t})]})},Vd=({content:e,status:t,hideIcon:r=!1,textStyle:n="default"})=>{const{config:i}=xa(),o=i.widget_accent_color;/* @__PURE__ */
37
- return g(Yc,{align:"start",gap:"md",children:[!r&&(()=>{switch(t){case"completed":/* @__PURE__ */return m(Kc,{name:"checkCircle",style:{color:o,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return m(Kc,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"stopped":/* @__PURE__ */return m(Kc,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});default:/* @__PURE__ */return m(Nd,{size:"sm",style:{color:o,marginTop:"2px"}})}})(),/* @__PURE__ */m(od,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===n?.5:1},children:e})]})},Hd=({isWaitingForUser:e})=>/* @__PURE__ */g(Yc,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */m(Nd,{size:"sm"}),/* @__PURE__ */m(od,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Gd=({message:e,isLastMessage:t})=>{const{state:r}=xa(),n="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */g(td,{gap:"sm",children:[e.parts.map((t,r)=>{if("text"===t.type){let e=(n=t.content,n.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */m(od,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${r}`):null}return"progress"===t.type?"done"===t.toolName&&"done"===e.taskStatus?null:/* @__PURE__ */m(Vd,{content:t.content,status:t.status||"in_progress",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${r}`):null;var n}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||r.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */m(Hd,{isWaitingForUser:n})]}):e.isPlaceholder||r.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */m(Hd,{isWaitingForUser:n}):e.content?/* @__PURE__ */m(od,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */m(rc,{})},Yd=({status:e})=>{const{config:t}=xa(),r=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return m(Kc,{name:"checkCircle",style:{color:r,flexShrink:0},size:14});case"failed":/* @__PURE__ */return m(Kc,{name:"exclamationCircle",style:{color:k(r,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return m(Kc,{name:"circle",style:{color:k(r,.5),flexShrink:0},size:14});default:/* @__PURE__ */return m(Nd,{size:"sm",style:{color:r}})}},Jd="8px 8px 0 0",Kd="#111827",Xd="rgba(255,255,255,0.7)",qd=({stream:e})=>{const t=u(null),r=u(null),[n,i]=h(!1),[o,s]=h(!1);return a(()=>{if(t.current&&e){const n=t.current;i(!1),s(!1),r.current&&(r.current.catch(()=>{}),r.current=null),n.srcObject=e;const o=()=>{i(!0)},a=()=>{s(!0),i(!1)};n.addEventListener("loadedmetadata",o),n.addEventListener("error",a);const l=n.play();return r.current=l,l.then(()=>{i(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),r.current=null}),()=>{n.removeEventListener("loadedmetadata",o),n.removeEventListener("error",a)}}return()=>{r.current&&(r.current.catch(()=>{}),r.current=null),t.current&&(t.current.srcObject=null),i(!1),s(!1)}},[e]),e?/* @__PURE__ */g(rc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:Jd,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__ */m(Yc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Kd,borderRadius:Jd,zIndex:10,transition:"opacity 300ms",opacity:n?0:1},children:/* @__PURE__ */g(Yc,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */m(Nd,{size:"lg",style:{color:"white"}}),/* @__PURE__ */m(od,{as:"span",size:"xs",weight:"medium",style:{color:Xd},children:"Loading stream..."})]})}),o&&/* @__PURE__ */m(Yc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Kd,borderRadius:Jd,zIndex:10},children:/* @__PURE__ */g(Yc,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */m(Kc,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */m(od,{as:"span",size:"xs",weight:"medium",style:{color:Xd},children:"Failed to load stream"})]})}),
38
- /* @__PURE__ */m(Dd,{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:Jd,transition:"opacity 500ms",opacity:n?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),n&&!o&&/* @__PURE__ */g(Yc,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */g(Yc,{position:"relative",align:"center",justify:"center",children:[/* @__PURE__ */m(rc,{position:"absolute",rounded:"full",animate:"ping",style:{width:"8px",height:"8px",backgroundColor:"white",opacity:.75}}),/* @__PURE__ */m(rc,{position:"relative",rounded:"full",style:{width:"6px",height:"6px",backgroundColor:"white"}})]}),/* @__PURE__ */m(od,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
39
- /* @__PURE__ */m(Yc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:Jd,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */m(rc,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */m(od,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]}):null},Qd=({message:e,index:t,isLastMessage:r,onScreenAccessAllow:n,onScreenAccessDeny:i})=>{if(e.isSystemMessage)/* @__PURE__ */return m(Yc,{justify:"center",align:"center",children:/* @__PURE__ */m(od,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})},`message-${e.id}-${t}`);const o="user"===e.sender;/* @__PURE__ */
40
- return g(td,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":o?"You said…":"Agent says…",animate:r?"fadeIn":void 0,children:[/* @__PURE__ */g(Yc,{align:"start",gap:"sm",width:"full",children:[
41
- /* @__PURE__ */m(Yc,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!o&&/* @__PURE__ */m(oc,{src:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",alt:"Marketrix AI",size:20,fit:"cover",rounded:"theme",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
42
- /* @__PURE__ */g(td,{grow:!0,position:"relative",rounded:"theme",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:o?"var(--primary)":void 0,color:o?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */m(qd,{stream:e.videoStream}),!e.videoStream&&/* @__PURE__ */m(Gd,{message:e,isLastMessage:r}),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */g(Yc,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */m(Gc,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>n?.(),children:"Yes"}),/* @__PURE__ */m(Gc,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>i?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */m(od,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"Check HTML Instead"}),!o&&e.taskStatus&&/* @__PURE__ */m(Yc,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */m(Yd,{status:e.taskStatus})})]}),
43
- /* @__PURE__ */m(Yc,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */m(od,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:C(e.timestamp)})]},`message-${e.id}-${t}`)},eu={boxShadow:Wl.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},tu=({messages:e,messagesEndRef:t,config:r,onScreenAccessAllow:n,onScreenAccessDeny:i,onClearChat:o})=>{const{config:s,state:l,isPreviewMode:c}=xa({config:r}),[p,f]=h(!1),[y,w]=h(!1),b=u(null),v=d(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=d(()=>[v,...e],[v,e]),S=()=>{if(b.current){const{scrollTop:e,scrollHeight:t,clientHeight:r}=b.current;f(e>200),w(!(Math.abs(t-e-r)<50)&&t>r)}};return a(()=>{window.requestAnimationFrame(()=>{t.current&&(!c&&t.current.scrollIntoView({behavior:"auto"}),!c&&S())})},[e.length,c]),/* @__PURE__ */g(rc,{position:"relative",height:"full",children:[
44
- /* @__PURE__ */g(rc,{ref:b,onScroll:S,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:s.widget_background_color.includes("gradient")?"transparent":s.widget_background_color,backgroundImage:s.widget_background_color.includes("gradient")?s.widget_background_color:`linear-gradient(135deg, ${s.widget_background_color} 0%, ${s.widget_background_color} 100%)`,scrollbarColor:`${k(s.widget_border_color,.3)} ${k(s.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&l.isLoading&&/* @__PURE__ */m(Ud,{variant:"loading",message:"Connecting…"}),x.map((e,t)=>/* @__PURE__ */m(Qd,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:n,onScreenAccessDeny:i},`message-${e.id}-${t}`)),e.length>0&&o&&/* @__PURE__ */m(Yc,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */m(Gc,{type:"button",variant:"bare",onClick:()=>{const e=o();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */m(od,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
45
- /* @__PURE__ */m(rc,{ref:t},"scroll-anchor")]},"message-list-container"),p&&/* @__PURE__ */m(Yc,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */m(ed,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{b.current?.scrollTo({top:0,behavior:"smooth"})},style:eu,children:/* @__PURE__ */m(Kc,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */m(Yc,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */m(ed,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!c&&t.current.scrollIntoView({behavior:"smooth"})},style:eu,children:/* @__PURE__ */m(Kc,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},ru=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */m(od,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},nu={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},iu=["tell","show","do"];var ou=({config:e,messages:t,currentMode:r,isTaskRunning:n=!1,taskProgress:i=[],onSendMessage:o,onSetMode:s,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onStopTask:d,onClearChat:p,onScreenSharingChange:f,onStartScreenShareRef:y,onStopScreenShareRef:w,messageInputRef:b})=>{const[v,x]=h(""),S=u(null),[C,_]=h(null),{isScreenSharing:A,showScreenAccessDialog:E,handleScreenAccessDialogAllow:z,handleScreenAccessDialogDeny:M,handleScreenAccessAllow:T,handleScreenAccessDeny:O,requestScreenAccess:R}=Fd({onScreenSharingChange:f,onStartScreenShareRef:y,onStopScreenShareRef:w,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onSendMessage:o,pendingMessage:C,setPendingMessage:_}),N=e;/* @__PURE__ */
46
- return g(td,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[E&&/* @__PURE__ */m(Wd,{variant:"confirm",open:E,onClose:M,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:z,confirmLabel:"Yes",cancelLabel:"No"}),
47
- /* @__PURE__ */m(rc,{grow:!0,overflow:"hidden",paddingY:"xs",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */m(ru,{children:/* @__PURE__ */m(tu,{messages:t,messagesEndRef:S,config:e,onScreenAccessAllow:T,onScreenAccessDeny:O,onClearChat:p})})}),
48
- /* @__PURE__ */g(kd,{style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:[n&&i.length>0&&/* @__PURE__ */g(rc,{rounded:!0,overflowY:"auto",style:{margin:"0 8px 8px",padding:"8px",maxHeight:"128px",backgroundColor:k(e.widget_background_color??"#fff",.8),borderColor:e.widget_border_color,borderWidth:"1px",borderStyle:"solid"},children:[/* @__PURE__ */g(od,{as:"div",weight:"semibold",style:{marginBottom:"4px",color:e.widget_text_color},children:["Task Progress (",i.length," steps)"]}),/* @__PURE__ */m(td,{gap:"xs",children:i.map((t,r)=>/* @__PURE__ */g(Yc,{align:"start",gap:"sm",style:{fontSize:"12px",opacity:.8,color:e.widget_text_color},children:[
49
- /* @__PURE__ */g(od,{as:"span",weight:"medium",children:["Step ",t.step,":"]})," ",t.tool_name,t.tool_params&&Object.keys(t.tool_params).length>0&&/* @__PURE__ */g(od,{as:"span",style:{opacity:.7,marginLeft:"4px"},children:["(",Object.keys(t.tool_params).join(", "),")"]})]},r))})]}),/* @__PURE__ */m(Bd,{ref:b,value:v,onChange:x,onSubmit:()=>{const n=t.some(e=>e.isPlaceholder);if(v.trim()&&!n){const t=v.trim();x(""),a(Vs(t,r)),!1===e.use_screenshare||"show"!==r&&"do"!==r||A?o(t,r,void 0,void 0,!0):(_({content:t,mode:r,alreadyAdded:!0}),R(r))}},modes:iu.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(N).includes(e)).map(e=>({id:e,icon:nu[e],label:I(e)})),activeMode:r,onModeChange:e=>(e=>{e!==r&&(a(Gs(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),s(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:n,onStop:()=>{da.cleanup(),d?.()}})]})]})},su=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */m(Kc,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */m(Kc,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */m(Kc,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */m(Kc,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */m(Kc,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function au(e){switch(e){case"do":/* @__PURE__ */return m(Kc,{name:"ticktick",size:12});case"show":/* @__PURE__ */return m(Kc,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return m(Kc,{name:"chatBubble",size:12})}}var lu=({actions:e,onActionClick:t})=>{const{config:r}=xa();return 0===e.length?null:/* @__PURE__ */m(td,{gap:"sm",children:e.map((e,n)=>/* @__PURE__ */m(Gc,{elevation:"card",shape:"theme",size:"sm",variant:"chip",full:!0,onClick:r=>t(e,r),style:{color:r.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */m(od,{as:"span",weight:"normal",leading:"tight",children:"show"===e.type?/* @__PURE__ */g(f,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(f,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${n}`))})},cu=({config:e,messages:t,onNavigateToChat:r,onChipClick:n})=>{const i=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,r)=>{const n=t.chip_text,i=t.chip_mode,o=`chip-${n.replace(/\s+/g,"-").toLowerCase()}-${r}`;let s=o,a=0;for(;e.has(s);)a++,s=`${o}-${a}`;return e.add(s),{id:s,text:n,icon:au(i),type:i,isShow:"show"===i}})}return su}(e);/* @__PURE__ */
50
- return g(td,{height:"full",overflow:"hidden",id:"view-home",role:"tabpanel","aria-labelledby":"tab-home",children:[/* @__PURE__ */g(td,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */g(rc,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */m(od,{as:"h2",size:"lg",weight:"semibold",children:e.widget_greeting??"Hey There!"}),/* @__PURE__ */m(od,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:e.widget_body??"How can I help you today?"})]}),/* @__PURE__ */g(td,{gap:"sm",children:[/* @__PURE__ */g(Gc,{type:"button",variant:"primary",full:!0,onClick:r,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */m(Kc,{name:"chat",size:16}),"Ask a question"]}),/* @__PURE__ */m(lu,{actions:i,onActionClick:async(e,t)=>{t.preventDefault(),t.stopPropagation(),r(),n(e)}})]})]}),t.length>0&&/* @__PURE__ */g(kd,{style:{margin:"0 12px 12px 12px"},children:[
51
- /* @__PURE__ */m(od,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
52
- /* @__PURE__ */m(od,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t[t.length-1].content||"Message"}),
53
- /* @__PURE__ */m(od,{as:"p",size:"xs",variant:"muted",onClick:r,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},du=["top-left","top-right","bottom-left","bottom-right"];function uu(e){const t=e.startsWith("top"),r=e.endsWith("left");return{position:"absolute",width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:t?"flex-start":"flex-end",justifyContent:r?"flex-start":"flex-end",cursor:t&&r||!t&&!r?"nwse-resize":"nesw-resize",top:t?0:void 0,bottom:t?void 0:0,left:r?0:void 0,right:r?void 0:0}}var hu,pu=({onResizeStart:e})=>/* @__PURE__ */m(f,{children:du.map(t=>/* @__PURE__ */m("div",{role:"separator","aria-label":`Resize widget from ${t.replace("-"," ")}`,title:"Drag to resize",style:uu(t),onMouseDown:e(t)},t))}),fu=({tabs:e,active:t,onChange:r})=>/* @__PURE__ */m(Yc,{role:"tablist",align:"center",justify:"around",shrink:!1,border:"top",style:Gl.tabBar,children:e.map(e=>{const n=t===e.id;/* @__PURE__ */
54
- return g(Gc,{role:"tab","aria-selected":n,"aria-controls":`view-${e.id}`,id:`tab-${e.id}`,onClick:()=>r(e.id),active:n,stacked:!0,variant:"tab",children:[n&&/* @__PURE__ */m(od,{as:"span",inheritColor:!0,style:{position:"absolute",top:0,left:"25%",right:"25%"},children:/* @__PURE__ */m(Md,{variant:"bar",color:"accent"})}),
55
- /* @__PURE__ */m(od,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */m(Kc,{name:e.icon,size:20})}),
56
- /* @__PURE__ */m(od,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id)})}),mu=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"},{id:"help",icon:"help",label:"Help"}],gu=({activeView:e,onChange:t})=>/* @__PURE__ */m(fu,{tabs:mu,active:e,onChange:e=>t(e)}),yu=({children:e,direction:t})=>/* @__PURE__ */m(rc,{"data-view-transition":!0,"data-direction":t,style:{width:"100%",height:"100%"},children:e}),wu=({config:e,isOpen:t,isMinimized:r,messages:n,currentMode:i,isTaskRunning:s=!1,taskProgress:l=[],activeView:c,onClose:p,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:S,onScreenSharingChange:C,setActiveView:I})=>{const{config:_,isPreviewMode:A}=xa({config:e}),E=d(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:z,heightPx:M,onResizeStart:T,containerRef:O}=function(e,t,r,n,i){const s=d(()=>`marketrix_widget_size_${r}`,[r]),a=u({width:360,height:450}),l=u(null),[c,p]=h(()=>{if("undefined"==typeof localStorage)return{width:gd(e),height:gd(t)};const r=localStorage.getItem(s);if(r)try{const e=JSON.parse(r);if("number"==typeof e.width&&"number"==typeof e.height){const t=yd(e.width,280,600),r=yd(e.height,320,Math.floor(.85*window.innerHeight));return a.current={width:t,height:r},{width:t,height:r}}}catch{}const n=gd(e),i=gd(t);return a.current={width:n,height:i},{width:n,height:i}});a.current=c;const f=o(e=>t=>{if(t.preventDefault(),t.stopPropagation(),n||i)return;const r=t.clientX,o=t.clientY,c=a.current.width,d=a.current.height,{cursor:u}=wd(e,r,o,r,o);l.current&&(l.current.dataset.resizing="true");const h=t=>{const{dx:n,dy:i}=wd(e,r,o,t.clientX,t.clientY),s=Math.floor(.85*window.innerHeight),u={width:yd(c+n,280,600),height:yd(d+i,320,s)};a.current=u,l.current&&(l.current.style.width=`${u.width}px`,l.current.style.height=`${u.height}px`)},f=()=>{if(document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f),document.body.style.cursor="",document.body.style.userSelect="",l.current&&delete l.current.dataset.resizing,p({...a.current}),!i&&"undefined"!=typeof localStorage){const{width:e,height:t}=a.current;localStorage.setItem(s,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)},[n,i,s]);return{width:c.width,height:c.height,widthPx:`${c.width}px`,heightPx:`${c.height}px`,onResizeStart:f,containerRef:l}}(_.widget_width,_.widget_height,E,r,A),R=u(null),[N,P]=h("forward"),L=u(c);a(()=>{L.current!==c&&(P("chat"===c?"forward":"back"),L.current=c)},[c]),function(e,t,r){const n=u(!1),i=u(null),s=o(()=>{const t=e.current;if(!t)return;const n=r?.focusTargetRef?.current;if(n)return void n.focus({preventScroll:!0});const i=md(t);i[0]&&i[0].focus({preventScroll:!0})},[e,r?.focusTargetRef]);a(()=>{if(!t)return n.current&&(i.current?.focus({preventScroll:!0}),i.current=null),void(n.current=!1);n.current||(i.current=document.activeElement||null),n.current=!0;const o=e.current;if(!o)return;s();const a=e=>{if("Escape"===e.key)return void r?.onEscape?.();if("Tab"!==e.key)return;const t=md(o);if(0===t.length)return;const n=document.activeElement,i=t.indexOf(n);-1!==i&&(e.shiftKey?0===i&&(e.preventDefault(),t[t.length-1].focus()):i===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t,e,s,r?.onEscape])}(O,t,{onEscape:p,focusTargetRef:"chat"===c?R:void 0});const D=_.widget_position,$=_.widget_position_z_index??40,F=(e=>{const t="20px",r="20px";switch(e){case"bottom_right":default:return{bottom:t,right:r};case"bottom_left":return{bottom:t,left:r};case"top_right":return{top:t,right:r};case"top_left":return{top:t,left:r}}})(D),[j,B]=h(!1),Z=u(null),W=u(null),U=o(e=>{B(e),C?.(e)},[C]);if(!t)return null;const V=_.widget_background_color.includes("gradient")?_.widget_background_color:`linear-gradient(135deg, ${_.widget_background_color} 0%, ${_.widget_background_color} 100%)`,H={width:z,height:r?"48px":M,fontSize:_.widget_font_size,backgroundImage:V,zIndex:$},G=A?"absolute":"fixed",Y=A?D.includes("top")?{top:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{},J=`${D.includes("top")?"top":"bottom"} ${D.includes("right")?"right":"left"}`,K="chat"===c&&!1!==e.use_screenshare?()=>{j?W.current?.():Z.current?.()}:void 0;/* @__PURE__ */
57
- return g(td,{ref:O,position:G,rounded:"theme",border:!0,overflow:"hidden",style:{zIndex:$,backgroundImage:V,transformOrigin:J,...H,...A?Y:F,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:Wl.panel},children:[
58
- /* @__PURE__ */m($d,{title:e.agent_name??"AI Agent",subtitle:r?void 0:e.agent_description??"How can I help?",minimized:r,onClose:p,controls:K&&/* @__PURE__ */g(ed,{variant:"ghost",size:"sm",label:j?"Stop screen sharing":"Start screen sharing",onClick:K,children:[j&&/* @__PURE__ */m(xd,{variant:"live",style:{position:"absolute",top:"2px",right:"2px"}}),/* @__PURE__ */m(Kc,{name:"screenShare",size:16})]})}),!r&&/* @__PURE__ */g(f,{children:[/* @__PURE__ */m(rc,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(yu,{direction:N,children:["home"===c&&/* @__PURE__ */m(cu,{config:e,messages:n,onNavigateToChat:()=>{P("forward"),I("chat")},onChipClick:e=>{b(Vs(e.text,e.type,"chip-message")),w(e.type),y(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */m(ou,{config:e,messages:n,currentMode:i,isTaskRunning:s,taskProgress:l,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:S,onScreenSharingChange:U,onStartScreenShareRef:Z,onStopScreenShareRef:W,messageInputRef:R}),"help"===c&&/* @__PURE__ */g(td,{id:"view-help",role:"tabpanel","aria-labelledby":"tab-help",height:"full",padding:"lg",children:[/* @__PURE__ */g(td,{grow:!0,align:"center",justify:"center",gap:"sm",children:[/* @__PURE__ */m(od,{as:"span",variant:"faint",children:/* @__PURE__ */m(Kc,{name:"help",size:32})}),/* @__PURE__ */m(od,{size:"sm",variant:"muted",children:"Help – coming soon"})]}),/* @__PURE__ */g(kd,{style:{margin:"0 12px 12px 12px"},children:[/* @__PURE__ */g(od,{size:"xs",variant:"faint",style:{display:"block"},children:["Widget v",fd]}),/* @__PURE__ */g(od,{size:"xs",variant:"faint",style:{display:"block"},children:["API"," ",(()=>{try{return qs.getInstance().isConnected()?"connected":"disconnected"}catch{return"—"}})()]})]})]}),"news"===c&&/* @__PURE__ */g(td,{id:"view-news",role:"tabpanel","aria-labelledby":"tab-news",height:"full",align:"center",justify:"center",gap:"sm",padding:"lg",children:[/* @__PURE__ */m(od,{as:"span",variant:"faint",children:/* @__PURE__ */m(Kc,{name:"info",size:32})}),/* @__PURE__ */m(od,{size:"sm",variant:"muted",children:"News – coming soon"})]})]},c)}),/* @__PURE__ */m(gu,{activeView:c,onChange:I})]}),!r&&!A&&/* @__PURE__ */m(pu,{onResizeStart:T})]})},bu=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},vu=({config:e})=>{const[t,r]=h(!1),{state:n,actions:i,config:o,shouldShow:s,isPreviewMode:l,configValid:c}=xa({config:e});var u;u=n.isOpen,a(()=>{if(!u)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,r=e.style.overflow,n=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=r,t.style.overflow=n}},[u]);const[p,f]=h(e.widget_position??"bottom_right"),b=d(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);a(()=>{f(o.widget_position??"bottom_right")},[o.widget_position]),a(()=>{if(l||"undefined"==typeof localStorage)return;const e=o.widget_position??"bottom_right",t=localStorage.getItem(b);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(b,e),f(e)):f(t)},[l,b,o.widget_position]),a(()=>{if(n.isOpen||l||"default"!==o.widget_appearance)return void r(!1);const e=setTimeout(()=>r(!0),2e3);return()=>clearTimeout(e)},[n.isOpen,l,o.widget_appearance]);if(!c)return null;if(!(l?e.widget_enabled??o.widget_enabled:s&&o.widget_enabled&&!1!==e.show_widget))return null;const v=(C=function(e={}){return A({..._,widget_background_color:e.widget_background_color??_.widget_background_color,widget_text_color:e.widget_text_color??_.widget_text_color,widget_border_color:e.widget_border_color??_.widget_border_color,widget_accent_color:e.widget_accent_color??_.widget_accent_color,widget_secondary_color:e.widget_secondary_color??_.widget_secondary_color,widget_border_radius:e.widget_border_radius??_.widget_border_radius,widget_font_size:e.widget_font_size??_.widget_font_size,widget_width:e.widget_width??_.widget_width,widget_height:e.widget_height??_.widget_height,widget_shadow:e.widget_shadow??_.widget_shadow,widget_animation_duration:e.widget_animation_duration??_.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??_.widget_fade_duration})}(o),{"--background":C.color.background,"--foreground":C.color.foreground,"--card":C.color.background,"--card-foreground":C.color.foreground,"--popover":C.color.background,"--popover-foreground":C.color.foreground,"--primary":C.color.primary,"--foreground-muted":C.color.foregroundMuted,"--foreground-faint":C.color.foregroundFaint,"--border-muted":C.color.borderMuted,"--primary-foreground":C.color.primaryForeground,"--primary-hover":C.color.primaryHover,"--primary-muted":C.color.primaryMuted,"--secondary":C.color.secondary,"--secondary-foreground":C.color.secondaryForeground,"--secondary-bg":C.color.secondaryBg,"--secondary-hover":C.color.secondaryHover,"--muted":C.color.border,"--muted-foreground":C.color.secondary,"--accent":C.color.background,"--accent-foreground":C.color.foreground,"--border":C.color.border,"--input":C.color.border,"--ring":C.color.primary,"--radius":C.radius,"--shadow":C.shadow,"--duration-animation":C.motion.durationAnimation,"--duration-fade":C.motion.durationFade,"--widget-width":C.size.widgetWidth,"--widget-height":C.size.widgetHeight});var C;const I=Math.max(o.widget_position_z_index??0,y),E={...o,widget_position:p,widget_position_z_index:I,show_widget:e.show_widget,use_screenshare:e.use_screenshare},z=n.isLoading||n.isTaskRunning;/* @__PURE__ */
59
- return g(rc,{"data-marketrix-widget":!0,position:"relative",style:{...v,"--widget-z-index":I,...l&&{width:"100%",height:"100%"}},"data-widget-mode":o?.widget_feature_human?"hybrid":"ai",children:[z&&/* @__PURE__ */m(rc,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${k(o.widget_accent_color,.72)}, inset 0 0 46px 10px ${k(o.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
60
- /* @__PURE__ */m(bu,{children:/* @__PURE__ */m(wu,{config:E,isOpen:n.isOpen,isMinimized:n.isMinimized,messages:n.messages,currentMode:n.currentMode,isTaskRunning:n.isTaskRunning,taskProgress:n.taskProgress,activeView:n.activeView,onClose:i.closeWidget,onSendMessage:i.sendMessage,onSetMode:i.setMode,onAddMessage:i.addMessage,onUpdateMessage:i.updateMessage,onRemoveMessage:i.removeMessage,onStopTask:i.stopTask,onClearChat:i.clearChatHistory,setActiveView:i.setActiveView})}),
61
- /* @__PURE__ */m(pd,{open:n.isOpen,processing:n.isLoading,error:!!n.error,taskRunning:n.isTaskRunning,onClick:i.toggleWidget,onStop:i.stopTask,accentColor:E.widget_accent_color,backgroundColor:E.widget_background_color,borderRadius:E.widget_border_radius,tooltipBgColor:S(E.widget_accent_color,.3),tooltipTextColor:x(S(E.widget_accent_color,.3)),zIndex:E.widget_position_z_index??50,position:p,onDrag:e=>{f(e),l||"undefined"==typeof localStorage||localStorage.setItem(b,e)},isPreviewMode:l}),n.error&&/* @__PURE__ */m(ad,{tone:"error",title:n.error,onDismiss:()=>i.clearError(),onRetry:()=>i.clearError(),position:p.includes("top")?"bottom-center":"above-fab"}),t&&!n.error&&o.widget_greeting&&/* @__PURE__ */m(ad,{tone:"info",title:o.widget_greeting,body:o.widget_body,onDismiss:()=>r(!1),position:"bottom-center"})]})},xu=({previewMode:e})=>{const{uiState:t}=va(),{chatState:r}=ia(),{taskState:n}=ya();return a(()=>{e||Us.persist({messages:r.messages,isTaskRunning:n.isTaskRunning,activeTaskId:n.activeTaskId,taskProgress:n.taskProgress,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading})},[e,r.messages,n.isTaskRunning,n.activeTaskId,n.taskProgress,t.currentMode,t.isOpen,t.isMinimized,t.isLoading]),null},ku=({children:e,previewMode:t})=>{const{uiState:r,uiActions:n}=va(),{_setMessages:i}=(()=>{const e=s(ra);if(!e)throw new Error("useChatContextInternal must be used within ChatProvider");return e})(),o=u(null),l=u([]);return a(()=>{if(t)return;(async()=>{const e=await Xs.getOrCreateChatId();Us.createInitialContext(e),Us.getInitError()&&n.setError("Widget failed to initialise — please refresh the page."),Us.initialize(e);const t=Us.restore();if(n.applyState({isLoading:t.isLoading,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized}),l.current=t.messages,i({messages:t.messages}),o.current=t.isTaskRunning?t.activeTaskId:null,e){const t=qs.getInstance(),r=ea.getConfig();t.connect(e,r?{mtxId:r.mtxId,mtxKey:r.mtxKey,mtxAgent:r.mtxAgent,mtxApp:r.mtxApp}:void 0).catch(e=>{})}})()},[]),/* @__PURE__ */g(ga,{previewMode:t,currentMode:r.currentMode,setMessages:i,messagesRef:l,uiActions:n,activeTaskIdRef:o,children:[e,/* @__PURE__ */m(xu,{previewMode:t})]})},Su=({children:e,previewMode:t})=>{const{uiState:r,uiActions:n}=va();/* @__PURE__ */
62
- return m(na,{previewMode:t,uiActions:n,currentMode:r.currentMode,children:/* @__PURE__ */m(ku,{previewMode:t,children:e})})},Cu=({children:e,previewMode:t=!1})=>/* @__PURE__ */m(ba,{children:/* @__PURE__ */m(Su,{previewMode:t,children:e})}),Iu=Object.defineProperty,_u=(e,t,r)=>((e,t,r)=>t in e?Iu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Au=Object.defineProperty,Eu=(e,t,r)=>((e,t,r)=>t in e?Au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),zu=/* @__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))(zu||{}),Mu={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Tu={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ou={};function Ru(e){if(Ou[e])return Ou[e];const t=globalThis[e],r=t.prototype,n=e in Mu?Mu[e]:void 0,i=Boolean(n&&n.every(e=>{var t,n;return Boolean(null==(n=null==(t=Object.getOwnPropertyDescriptor(r,e))?void 0:t.get)?void 0:n.toString().includes("[native code]"))})),o=e in Tu?Tu[e]:void 0,s=Boolean(o&&o.every(e=>{var t;return"function"==typeof r[e]&&(null==(t=r[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return Ou[e]=t.prototype,t.prototype;try{const n=document.createElement("iframe");document.body.appendChild(n);const i=n.contentWindow;if(!i)return t.prototype;const o=i[e].prototype;return document.body.removeChild(n),o?Ou[e]=o:r}catch{return r}}var Nu={};function Pu(e,t,r){var n;const i=`${e}.${String(r)}`;if(Nu[i])return Nu[i].call(t);const o=Ru(e),s=null==(n=Object.getOwnPropertyDescriptor(o,r))?void 0:n.get;return s?(Nu[i]=s,s.call(t)):t[r]}var Lu={};function Du(e,t,r){const n=`${e}.${String(r)}`;if(Lu[n])return Lu[n].bind(t);const i=Ru(e)[r];return"function"!=typeof i?t[r]:(Lu[n]=i,i.bind(t))}var $u={ownerDocument:function(e){return Pu("Node",e,"ownerDocument")},childNodes:function(e){return Pu("Node",e,"childNodes")},parentNode:function(e){return Pu("Node",e,"parentNode")},parentElement:function(e){return Pu("Node",e,"parentElement")},textContent:function(e){return Pu("Node",e,"textContent")},contains:function(e,t){return Du("Node",e,"contains")(t)},getRootNode:function(e){return Du("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?Pu("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?Pu("Element",e,"shadowRoot"):null},querySelector:function(e,t){return Pu("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return Pu("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return Ru("MutationObserver").constructor},patch:function(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],i=r(n);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=i,()=>{e[t]=n}}catch{return()=>{}}}};function Fu(e){return e.nodeType===e.ELEMENT_NODE}function ju(e){const t=e&&"host"in e&&"mode"in e&&$u.host(e)||null;return Boolean(t&&"shadowRoot"in t&&$u.shadowRoot(t)===e)}function Bu(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function Zu(e){try{const r=e.rules||e.cssRules;if(!r)return null;let n=e.href;return!n&&e.ownerNode&&(n=e.ownerNode.baseURI),(t=Array.from(r,e=>Wu(e,n)).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(r){return null}var t}function Wu(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=Zu(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const r=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?r.push("layer"):e.layerName&&r.push(`layer(${e.layerName})`),e.supportsText&&r.push(`supports(${e.supportsText})`),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}(e)}catch(r){t=e.cssText}return e.styleSheet.href?eh(t,e.styleSheet.href):t}{let r=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(r=r.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")),t?eh(r,t):r}}var Uu=class{constructor(){Eu(this,"idNodeMap",/* @__PURE__ */new Map),Eu(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 r=t.id;this.idNodeMap.set(r,e),this.nodeMetaMap.set(e,t)}replace(e,t){const r=this.getNode(e);if(r){const e=this.nodeMetaMap.get(r);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=/* @__PURE__ */new Map,this.nodeMetaMap=/* @__PURE__ */new WeakMap}};function Vu({element:e,maskInputOptions:t,tagName:r,type:n,value:i,maskInputFn:o}){let s=i||"";const a=n&&Hu(n);return(t[r.toLowerCase()]||a&&t[a])&&(s=o?o(s,e):"*".repeat(s.length)),s}function Hu(e){return e.toLowerCase()}var Gu="__rrweb_original__";function Yu(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Hu(t):null}function Ju(e,t){let r;try{r=new URL(e,t??window.location.href)}catch(i){return null}const n=r.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==n?void 0:n[1])??null}var Ku=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Xu=/^(?:[a-z+]+:)?\/\//i,qu=/^www\..*/i,Qu=/^(data:)([^,]*),(.*)/i;function eh(e,t){return(e||"").replace(Ku,(e,r,n,i,o,s)=>{const a=n||o||s,l=r||i||"";if(!a)return e;if(Xu.test(a)||qu.test(a))return`url(${l}${a}${l})`;if(Qu.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),d=a.split("/");c.pop();for(const t of d){if("."===t)continue;".."===t?c.pop():c.push(t)}return`url(${l}${c.join("/")}${l})`})}function th(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function rh(e,t){return function(e,t,r=!1){const n=Array.from(t.childNodes),i=[];let o=0;if(n.length>1&&e&&"string"==typeof e){let t=th(e,r);const s=t.length/e.length;for(let a=1;a<n.length;a++)if(n[a].textContent&&"string"==typeof n[a].textContent){const l=th(n[a].textContent,r),c=100;let d=3;for(;d<l.length&&(l[d].match(/[a-zA-Z0-9]/)||-1!==l.indexOf(l.substring(0,d),1));d++);for(;d<l.length;d++){let u=l.substring(0,d),h=t.split(u),p=-1;if(2===h.length)p=h[0].length;else if(h.length>2&&""===h[0]&&""!==n[a-1].textContent)p=t.indexOf(u,1);else if(1===h.length){if(u=u.substring(0,u.length-1),h=t.split(u),h.length<=1)return i.push(e),i;d=101}else d===l.length-1&&(p=t.indexOf(u));if(h.length>=2&&d>c){const e=n[a-1].textContent;if(e&&"string"==typeof e){const r=th(e).length;p=t.indexOf(u,r)}-1===p&&(p=h[0].length)}if(-1!==p){let a=Math.floor(p/s);for(;a>0&&a<e.length;){if(o+=1,o>50*n.length)return i.push(e),i;const l=th(e.substring(0,a),r);if(l.length===p){i.push(e.substring(0,a)),e=e.substring(a),t=t.substring(p);break}l.length<p?a+=Math.max(1,Math.floor((p-l.length)/s)):a-=Math.max(1,Math.floor((l.length-p)*s))}break}}}}return i.push(e),i}(e,t).join("/* rr_split */")}var nh,ih,oh=1,sh=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function ah(){return oh++}var lh=/^[^ \t\n\r\u000c]+/,ch=/^[, \t\n\r\u000c]+/;var dh=/* @__PURE__ */new WeakMap;function uh(e,t){return t&&""!==t.trim()?ph(e,t):t}function hh(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function ph(e,t){let r=dh.get(e);if(r||(r=e.createElement("a"),dh.set(e,r)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return r.setAttribute("href",t),r.href}function fh(e,t,r,n){return n?"src"===r||"href"===r&&("use"!==t||"#"!==n[0])||"xlink:href"===r&&"#"!==n[0]||"background"===r&&["table","td","th"].includes(t)?uh(e,n):"srcset"===r?function(e,t){if(""===t.trim())return t;let r=0;function n(e){let n;const i=e.exec(t.substring(r));return i?(n=i[0],r+=n.length,n):""}const i=[];for(;n(ch),!(r>=t.length);){let o=n(lh);if(","===o.slice(-1))o=uh(e,o.substring(0,o.length-1)),i.push(o);else{let n="";o=uh(e,o);let s=!1;for(;;){const e=t.charAt(r);if(""===e){i.push((o+n).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){r+=1,i.push((o+n).trim());break}"("===e&&(s=!0)}n+=e,r+=1}}}return i.join(", ")}(e,n):"style"===r?eh(n,ph(e)):"object"===t&&"data"===r?uh(e,n):n:n}function mh(e,t,r){return["video","audio"].includes(e)&&"autoplay"===t}function gh(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!r&&gh($u.parentNode(e),t,r);for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}return!!r&&gh($u.parentNode(e),t,r)}function yh(e,t,r,n){let i;if(Fu(e)){if(i=e,!$u.childNodes(i).length)return!1}else{if(null===$u.parentElement(e))return!1;i=$u.parentElement(e)}try{if("string"==typeof t){if(n){if(i.closest(`.${t}`))return!0}else if(i.classList.contains(t))return!0}else if(gh(i,t,n))return!0;if(r)if(n){if(i.closest(r))return!0}else if(i.matches(r))return!0}catch(o){}return!1}function wh(e,t){const{doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:s,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:d,dataURLOptions:u={},inlineImages:h,recordCanvas:p,keepIframeSrcFn:f,newlyAddedElement:m=!1,cssCaptured:g=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const r=t.getId(e);return 1===r?void 0:r}(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:zu.Document,childNodes:[],compatMode:e.compatMode}:{type:zu.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:zu.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:r,blockClass:n,blockSelector:i,inlineStylesheet:o,maskInputOptions:s={},maskInputFn:a,dataURLOptions:l={},inlineImages:c,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:h=!1,rootId:p}=t,f=function(e,t,r){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}if(r)return e.matches(r)}catch(n){}return!1}(e,n,i),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=Hu(e.tagName);return sh.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let v=0;v<y;v++){const t=e.attributes[v];mh(m,t.name,t.value)||(g[t.name]=fh(r,m,Hu(t.name),t.value))}if("link"===m&&o){const t=Array.from(r.styleSheets).find(t=>t.href===e.href);let n=null;t&&(n=Zu(t)),n&&(delete g.rel,delete g.href,g._cssText=n)}if("style"===m&&e.sheet){let t=Zu(e.sheet);t&&(e.childNodes.length>1&&(t=rh(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(m)){const t=e.value,r=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Vu({element:e,type:Yu(e),tagName:m,value:t,maskInputOptions:s,maskInputFn:a}):r&&(g.checked=r)}"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");if("canvas"===m&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let r=0;r<e.width;r+=50)for(let n=0;n<e.height;n+=50){const i=t.getImageData,o=Gu in i?i[Gu]:i;if(new Uint32Array(o.call(t,r,n,Math.min(50,e.width-r),Math.min(50,e.height-n)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(g.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){const t=e.toDataURL(l.type,l.quality),n=r.createElement("canvas");n.width=e.width,n.height=e.height,t!==n.toDataURL(l.type,l.quality)&&(g.rr_dataURL=t)}if("img"===m&&c){nh||(nh=r.createElement("canvas"),ih=nh.getContext("2d"));const t=e,n=(t.currentSrc||t.getAttribute("src"),t.crossOrigin),i=()=>{t.removeEventListener("load",i);try{nh.width=t.naturalWidth,nh.height=t.naturalHeight,ih.drawImage(t,0,0),g.rr_dataURL=nh.toDataURL(l.type,l.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i))}"anonymous"===t.crossOrigin&&(n?g.crossOrigin=n: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}h||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(f){const{width:t,height:r}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${r}px`}}"iframe"!==m||u(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);let w;try{customElements.get(m)&&(w=!0)}catch(b){}return{type:zu.Element,tagName:m,attributes:g,childNodes:[],isSVG:hh(e)||void 0,needBlock:f,rootId:p,isCustom:w}}(e,{doc:r,blockClass:i,blockSelector:o,inlineStylesheet:a,maskInputOptions:l,maskInputFn:d,dataURLOptions:u,inlineImages:h,recordCanvas:p,keepIframeSrcFn:f,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:r,maskTextFn:n,rootId:i,cssCaptured:o}=t,s=$u.parentNode(e),a=s&&s.tagName;let l="";const c="STYLE"===a||void 0,d="SCRIPT"===a||void 0;d?l="SCRIPT_PLACEHOLDER":o||(l=$u.textContent(e),c&&l&&(l=eh(l,ph(t.doc))));!c&&!d&&l&&r&&(l=n?n(l,$u.parentElement(e)):l.replace(/[\S]/g,"*"));return{type:zu.Text,textContent:l||"",rootId:i}}(e,{doc:r,needsMask:s,maskTextFn:c,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:zu.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:zu.Comment,textContent:$u.textContent(e)||"",rootId:y};default:return!1}}function bh(e){return null==e?"":e.toLowerCase()}function vh(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 xh(e,t){const{doc:r,mirror:n,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:h,slimDOMOptions:p,dataURLOptions:f={},inlineImages:m=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b=5e3,onStylesheetLoad:v,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:S=!1,cssCaptured:C=!1}=t;let{needsMask:I}=t,{preserveWhiteSpace:_=!0}=t;I||(I=yh(e,s,a,void 0===I));const A=wh(e,{doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:I,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,keepIframeSrcFn:k,newlyAddedElement:S,cssCaptured:C});if(!A)return null;let E;E=n.hasNode(e)?n.getId(e):function(e,t){if(t.comment&&e.type===zu.Comment)return!0;if(e.type===zu.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"===Ju(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(bh(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===bh(e.attributes.name)||"icon"===bh(e.attributes.rel)||"apple-touch-icon"===bh(e.attributes.rel)||"shortcut icon"===bh(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&bh(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(bh(e.attributes.property).match(/^(og|twitter|fb):/)||bh(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===bh(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===bh(e.attributes.name)||"googlebot"===bh(e.attributes.name)||"bingbot"===bh(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===bh(e.attributes.name)||"generator"===bh(e.attributes.name)||"framework"===bh(e.attributes.name)||"publisher"===bh(e.attributes.name)||"progid"===bh(e.attributes.name)||bh(e.attributes.property).match(/^article:/)||bh(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===bh(e.attributes.name)||"yandex-verification"===bh(e.attributes.name)||"csrf-token"===bh(e.attributes.name)||"p:domain_verify"===bh(e.attributes.name)||"verify-v1"===bh(e.attributes.name)||"verification"===bh(e.attributes.name)||"shopify-checkout-api-token"===bh(e.attributes.name)))return!0}}return!1}(A,p)||!_&&A.type===zu.Text&&!A.textContent.replace(/^\s+|\s+$/gm,"").length?-2:ah();const z=Object.assign(A,{id:E});if(n.add(e,z),-2===E)return null;y&&y(e);let M=!l;if(z.type===zu.Element){M=M&&!z.needBlock,delete z.needBlock;const t=$u.shadowRoot(e);t&&Bu(t)&&(z.isShadowHost=!0)}if((z.type===zu.Document||z.type===zu.Element)&&M){p.headWhitespace&&z.type===zu.Element&&"head"===z.tagName&&(_=!1);const t={doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:h,slimDOMOptions:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:_,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(z.type===zu.Element&&"textarea"===z.tagName&&void 0!==z.attributes.value);else{z.type===zu.Element&&void 0!==z.attributes._cssText&&"string"==typeof z.attributes._cssText&&(t.cssCaptured=!0);for(const r of Array.from($u.childNodes(e))){const e=xh(r,t);e&&z.childNodes.push(e)}}let S=null;if(Fu(e)&&(S=$u.shadowRoot(e)))for(const e of Array.from($u.childNodes(S))){const r=xh(e,t);r&&(Bu(S)&&(r.isShadow=!0),z.childNodes.push(r))}}const T=$u.parentNode(e);return T&&ju(T)&&Bu(T)&&(z.isShadow=!0),z.type===zu.Element&&"iframe"===z.tagName&&function(e,t,r){const n=e.contentWindow;if(!n)return;let i,o=!1;try{i=n.document.readyState}catch(a){return}if("complete"!==i){const n=setTimeout(()=>{o||(t(),o=!0)},r);return void e.addEventListener("load",()=>{clearTimeout(n),o=!0,t()})}const s="about:blank";if(n.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&w){const r=xh(t,{doc:t,mirror:n,blockClass:i,blockSelector:o,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:h,slimDOMOptions:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:_,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});r&&w(e,r)}},b),z.type===zu.Element&&"link"===z.tagName&&"string"==typeof z.attributes.rel&&("stylesheet"===z.attributes.rel||"preload"===z.attributes.rel&&"string"==typeof z.attributes.href&&"css"===Ju(z.attributes.href))&&function(e,t,r){let n,i=!1;try{n=e.sheet}catch(s){return}if(n)return;const o=setTimeout(()=>{i||(t(),i=!0)},r);e.addEventListener("load",()=>{clearTimeout(o),i=!0,t()})}(e,()=>{if(v){const t=xh(e,{doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:h,slimDOMOptions:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:_,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&v(e,t)}},x),z}function kh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Sh(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var Ch={exports:{}},Ih=String,_h=function(){return{isColorSupported:!1,reset:Ih,bold:Ih,dim:Ih,italic:Ih,underline:Ih,inverse:Ih,hidden:Ih,strikethrough:Ih,black:Ih,red:Ih,green:Ih,yellow:Ih,blue:Ih,magenta:Ih,cyan:Ih,white:Ih,gray:Ih,bgBlack:Ih,bgRed:Ih,bgGreen:Ih,bgYellow:Ih,bgBlue:Ih,bgMagenta:Ih,bgCyan:Ih,bgWhite:Ih}};Ch.exports=_h(),Ch.exports.createColors=_h;var Ah=Ch.exports,Eh=/* @__PURE__ */Sh(/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),zh=Ah,Mh=Eh,Th=class e extends Error{constructor(t,r,n,i,o,s){super(t),this.name="CssSyntaxError",this.reason=t,o&&(this.file=o),i&&(this.source=i),s&&(this.plugin=s),void 0!==r&&void 0!==n&&("number"==typeof r?(this.line=r,this.column=n):(this.line=r.line,this.column=r.column,this.endLine=n.line,this.endColumn=n.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;null==e&&(e=zh.isColorSupported),Mh&&e&&(t=Mh(t));let r,n,i=t.split(/\r?\n/),o=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length;if(e){let{bold:e,gray:t,red:i}=zh.createColors(!0);r=t=>e(i(t)),n=e=>t(e)}else r=n=e=>e;return i.slice(o,s).map((e,t)=>{let i=o+1+t,s=" "+(" "+i).slice(-a)+" | ";if(i===this.line){let t=n(s.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return r(">")+n(s)+e+"\n "+t+r("^")}return" "+n(s)+e}).join("\n")}toString(){let e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},Oh=Th;Th.default=Th;var Rh={};Rh.isClean=Symbol("isClean"),Rh.my=Symbol("my");var Nh={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var Ph=class{constructor(e){this.builder=e}atrule(e,t){let r="@"+e.name,n=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=" "),e.nodes)this.block(e,r+n);else{let i=(e.raws.between||"")+(t?";":"");this.builder(r+n+i,e)}}beforeAfter(e,t){let r;r="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let n=e.parent,i=0;for(;n&&"root"!==n.type;)i+=1,n=n.parent;if(r.includes("\n")){let t=this.raw(e,null,"indent");if(t.length)for(let e=0;e<i;e++)r+=t}return r}block(e,t){let r,n=this.raw(e,"between","beforeOpen");this.builder(t+n+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,"after")):r=this.raw(e,"after","emptyBody"),r&&this.builder(r),this.builder("}",e,"end")}body(e){let t=e.nodes.length-1;for(;t>0&&"comment"===e.nodes[t].type;)t-=1;let r=this.raw(e,"semicolon");for(let n=0;n<e.nodes.length;n++){let i=e.nodes[n],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==n||r)}}comment(e){let t=this.raw(e,"left","commentLeft"),r=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+r+"*/",e)}decl(e,t){let r=this.raw(e,"between","colon"),n=e.prop+r+this.rawValue(e,"value");e.important&&(n+=e.raws.important||" !important"),t&&(n+=";"),this.builder(n,e)}document(e){this.body(e)}raw(e,t,r){let n;if(r||(r=t),t&&(n=e.raws[t],void 0!==n))return n;let i=e.parent;if("before"===r){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return Nh[r];let o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[r])return o.rawCache[r];if("before"===r||"after"===r)return this.beforeAfter(e,r);{let i="raw"+((s=r)[0].toUpperCase()+s.slice(1));this[i]?n=this[i](o,e):o.walk(e=>{if(n=e.raws[t],void 0!==n)return!1})}var s;return void 0===n&&(n=Nh[r]),o.rawCache[r]=n,n}rawBeforeClose(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return t=e.raws.after,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){let r;return e.walkComments(e=>{if(void 0!==e.raws.before)return r=e.raws.before,r.includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeDecl"):r&&(r=r.replace(/\S/g,"")),r}rawBeforeDecl(e,t){let r;return e.walkDecls(e=>{if(void 0!==e.raws.before)return r=e.raws.before,r.includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeRule"):r&&(r=r.replace(/\S/g,"")),r}rawBeforeOpen(e){let t;return e.walk(e=>{if("decl"!==e.type&&(t=e.raws.between,void 0!==t))return!1}),t}rawBeforeRule(e){let t;return e.walk(r=>{if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return t=r.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){let t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(t=e.raws.after,void 0!==t))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(r=>{let n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){let e=r.raws.before.split("\n");return t=e[e.length-1],t=t.replace(/\S/g,""),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(t=e.raws.semicolon,void 0!==t))return!1}),t}rawValue(e,t){let r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},Lh=Ph;Ph.default=Ph;var Dh=Lh;function $h(e,t){new Dh(t).stringify(e)}var Fh=$h;$h.default=$h;var{isClean:jh,my:Bh}=Rh,Zh=Oh,Wh=Lh,Uh=Fh;function Vh(e,t){let r=new e.constructor;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if("proxyCache"===n)continue;let i=e[n],o=typeof i;"parent"===n&&"object"===o?t&&(r[n]=t):"source"===n?r[n]=i:Array.isArray(i)?r[n]=i.map(e=>Vh(e,r)):("object"===o&&null!==i&&(i=Vh(i)),r[n]=i)}return r}var Hh=class{constructor(e={}){this.raws={},this[jh]=!1,this[Bh]=!0;for(let t in e)if("nodes"===t){this.nodes=[];for(let r of e[t])"function"==typeof r.clone?this.append(r.clone()):this.append(r)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=Vh(this);for(let r in e)t[r]=e[r];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:r,start:n}=this.rangeBy(t);return this.source.input.error(e,{column:n.column,line:n.line},{column:r.column,line:r.line},t)}return new Zh(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,r)=>(e[t]===r||(e[t]=r,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[jh]){this[jh]=!1;let e=this;for(;e=e.parent;)e[jh]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e,t){let r=this.source.start;if(e.index)r=this.positionInside(e.index,t);else if(e.word){let n=(t=this.toString()).indexOf(e.word);-1!==n&&(r=this.positionInside(n,t))}return r}positionInside(e,t){let r=t||this.toString(),n=this.source.start.column,i=this.source.start.line;for(let o=0;o<e;o++)"\n"===r[o]?(n=1,i+=1):n+=1;return{column:n,line:i}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e){let t={column:this.source.start.column,line:this.source.start.line},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){let n=this.toString(),i=n.indexOf(e.word);-1!==i&&(t=this.positionInside(i,n),r=this.positionInside(i+e.word.length,n))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<t.line||r.line===t.line&&r.column<=t.column)&&(r={column:t.column+1,line:t.line}),{end:r,start:t}}raw(e,t){return(new Wh).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,r=!1;for(let n of e)n===this?r=!0:r?(this.parent.insertAfter(t,n),t=n):this.parent.insertBefore(t,n);r||this.remove()}return this}root(){let e=this;for(;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){let r={},n=null==t;t=t||/* @__PURE__ */new Map;let i=0;for(let o in this){if(!Object.prototype.hasOwnProperty.call(this,o))continue;if("parent"===o||"proxyCache"===o)continue;let e=this[o];if(Array.isArray(e))r[o]=e.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof e&&e.toJSON)r[o]=e.toJSON(null,t);else if("source"===o){let n=t.get(e.input);null==n&&(n=i,t.set(e.input,i),i++),r[o]={end:e.end,inputId:n,start:e.start}}else r[o]=e}return n&&(r.inputs=[...t.keys()].map(e=>e.toJSON())),r}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=Uh){e.stringify&&(e=e.stringify);let t="";return e(this,e=>{t+=e}),t}warn(e,t,r){let n={node:this};for(let i in r)n[i]=r[i];return e.warn(t,n)}get proxyOf(){return this}},Gh=Hh;Hh.default=Hh;var Yh=Gh,Jh=class extends Yh{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e={...e,value:String(e.value)}),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Kh=Jh;Jh.default=Jh;var Xh={nanoid:(e=21)=>{let t="",r=e;for(;r--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(r=t)=>{let n="",i=r;for(;i--;)n+=e[Math.random()*e.length|0];return n}},{SourceMapConsumer:qh,SourceMapGenerator:Qh}=Eh,{existsSync:ep,readFileSync:tp}=Eh,{dirname:rp,join:np}=Eh;var ip=class{constructor(e,t){if(!1===t.map)return;this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");let r=t.map?t.map.prev:void 0,n=this.loadMap(t.from,r);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=rp(this.mapFile)),n&&(this.text=n)}consumer(){return this.consumerCache||(this.consumerCache=new qh(this.text)),this.consumerCache}decodeInline(e){if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var t;let r=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+r)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){let t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(!t)return;let r=e.lastIndexOf(t.pop()),n=e.indexOf("*/",r);r>-1&&n>-1&&(this.annotation=this.getAnnotationURL(e.substring(r,n)))}loadFile(e){if(this.root=rp(e),ep(e))return this.mapFile=e,tp(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof qh)return Qh.fromSourceMap(t).toString();if(t instanceof Qh)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}{let r=t(e);if(r){let e=this.loadFile(r);if(!e)throw new Error("Unable to load previous source map: "+r.toString());return e}}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let t=this.annotation;return e&&(t=np(rp(e),t)),this.loadFile(t)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},op=ip;ip.default=ip;var{SourceMapConsumer:sp,SourceMapGenerator:ap}=Eh,{fileURLToPath:lp,pathToFileURL:cp}=Eh,{isAbsolute:dp,resolve:up}=Eh,{nanoid:hp}=Xh,pp=Eh,fp=Oh,mp=op,gp=Symbol("fromOffsetCache"),yp=Boolean(sp&&ap),wp=Boolean(up&&dp),bp=class{constructor(e,t={}){if(null==e||"object"==typeof e&&!e.toString)throw new Error(`PostCSS received ${e} instead of CSS string`);if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!wp||/^\w+:\/\//.test(t.from)||dp(t.from)?this.file=t.from:this.file=up(t.from)),wp&&yp){let e=new mp(this.css,t);if(e.text){this.map=e;let t=e.consumer().file;!this.file&&t&&(this.file=this.mapResolve(t))}}this.file||(this.id="<input css "+hp(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,r,n={}){let i,o,s;if(t&&"object"==typeof t){let e=t,n=r;if("number"==typeof e.offset){let n=this.fromOffset(e.offset);t=n.line,r=n.col}else t=e.line,r=e.column;if("number"==typeof n.offset){let e=this.fromOffset(n.offset);o=e.line,s=e.col}else o=n.line,s=n.column}else if(!r){let e=this.fromOffset(t);t=e.line,r=e.col}let a=this.origin(t,r,o,s);return i=a?new fp(e,void 0===a.endLine?a.line:{column:a.column,line:a.line},void 0===a.endLine?a.column:{column:a.endColumn,line:a.endLine},a.source,a.file,n.plugin):new fp(e,void 0===o?t:{column:r,line:t},void 0===o?r:{column:s,line:o},this.css,this.file,n.plugin),i.input={column:r,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(cp&&(i.input.url=cp(this.file).toString()),i.input.file=this.file),i}fromOffset(e){let t,r;if(this[gp])r=this[gp];else{let e=this.css.split("\n");r=new Array(e.length);let t=0;for(let n=0,i=e.length;n<i;n++)r[n]=t,t+=e[n].length+1;this[gp]=r}t=r[r.length-1];let n=0;if(e>=t)n=r.length-1;else{let t,i=r.length-2;for(;n<i;)if(t=n+(i-n>>1),e<r[t])i=t-1;else{if(!(e>=r[t+1])){n=t;break}n=t+1}}return{col:e-r[n]+1,line:n+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:up(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,r,n){if(!this.map)return!1;let i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof r&&(i=s.originalPositionFor({column:n,line:r})),o=dp(a.source)?cp(a.source):new URL(a.source,this.map.consumer().sourceRoot||cp(this.map.mapFile));let l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!lp)throw new Error("file: protocol is not available in this PostCSS build");l.file=lp(o)}let c=s.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){let e={};for(let t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map={...this.map},e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},vp=bp;bp.default=bp,pp&&pp.registerInput&&pp.registerInput(bp);var{SourceMapConsumer:xp,SourceMapGenerator:kp}=Eh,{dirname:Sp,relative:Cp,resolve:Ip,sep:_p}=Eh,{pathToFileURL:Ap}=Eh,Ep=vp,zp=Boolean(xp&&kp),Mp=Boolean(Sp&&Ip&&Cp&&_p),Tp=class{constructor(e,t,r,n){this.stringify=e,this.mapOpts=r.map||{},this.root=t,this.opts=r,this.css=n,this.originalCSS=n,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=/* @__PURE__ */new Map,this.memoizedPaths=/* @__PURE__ */new Map,this.memoizedURLs=/* @__PURE__ */new Map}addAnnotation(){let e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";let t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let t,r=this.toUrl(this.path(e.file)),n=e.root||Sp(e.file);!1===this.mapOpts.sourcesContent?(t=new xp(e.text),t.sourcesContent&&(t.sourcesContent=null)):t=e.consumer(),this.map.applySourceMap(t,r,this.toUrl(this.path(n)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root){let e;for(let t=this.root.nodes.length-1;t>=0;t--)e=this.root.nodes[t],"comment"===e.type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),Mp&&zp&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=kp.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new kp({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new kp({file:this.outputFile(),ignoreInvalidMapping:!0});let e,t,r=1,n=1,i="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(s,a,l)=>{if(this.css+=s,a&&"end"!==l&&(o.generated.line=r,o.generated.column=n-1,a.source&&a.source.start?(o.source=this.sourcePath(a),o.original.line=a.source.start.line,o.original.column=a.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),e=s.match(/\n/g),e?(r+=e.length,t=s.lastIndexOf("\n"),n=s.length-t):n+=s.length,a&&"start"!==l){let e=a.parent||{raws:{}};("decl"!==a.type&&("atrule"!==a.type||a.nodes)||a!==e.last||e.raws.semicolon)&&(a.source&&a.source.end?(o.source=this.sourcePath(a),o.original.line=a.source.end.line,o.original.column=a.source.end.column-1,o.generated.line=r,o.generated.column=n-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=r,o.generated.column=n-1,this.map.addMapping(o)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;let e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let r=this.opts.to?Sp(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(r=Sp(Ip(r,this.mapOpts.annotation)));let n=Cp(r,e);return this.memoizedPaths.set(e,n),n}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new Ep(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let r=t.source.input.from;if(r&&!e[r]){e[r]=!0;let n=this.usesFileUrls?this.toFileUrl(r):this.toUrl(this.path(r));this.map.setSourceContent(n,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(Ap){let t=Ap(e).toString();return this.memoizedFileURLs.set(e,t),t}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;"\\"===_p&&(e=e.replace(/\\/g,"/"));let r=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,r),r}},Op=Gh,Rp=class extends Op{constructor(e){super(e),this.type="comment"}},Np=Rp;Rp.default=Rp;var Pp,Lp,Dp,$p,{isClean:Fp,my:jp}=Rh,Bp=Kh,Zp=Np,Wp=Gh;function Up(e){return e.map(e=>(e.nodes&&(e.nodes=Up(e.nodes)),delete e.source,e))}function Vp(e){if(e[Fp]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)Vp(t)}var Hp=class e extends Wp{append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t,r,n=this.getIterator();for(;this.indexes[n]<this.proxyOf.nodes.length&&(t=this.indexes[n],r=e(this.proxyOf.nodes[t],t),!1!==r);)this.indexes[n]+=1;return delete this.indexes[n],r}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?(...r)=>e[t](...r.map(e=>"function"==typeof e?(t,r)=>e(t.toProxy(),r):e)):"every"===t||"some"===t?r=>e[t]((e,...t)=>r(e.toProxy(),...t)):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,r)=>(e[t]===r||(e[t]=r,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let r,n=this.index(e),i=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(let o of i)this.proxyOf.nodes.splice(n+1,0,o);for(let o in this.indexes)r=this.indexes[o],n<r&&(this.indexes[o]=r+i.length);return this.markDirty(),this}insertBefore(e,t){let r,n=this.index(e),i=0===n&&"prepend",o=this.normalize(t,this.proxyOf.nodes[n],i).reverse();n=this.index(e);for(let s of o)this.proxyOf.nodes.splice(n,0,s);for(let s in this.indexes)r=this.indexes[s],n<=r&&(this.indexes[s]=r+o.length);return this.markDirty(),this}normalize(t,r){if("string"==typeof t)t=Up(Pp(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if("root"===t.type&&"document"!==this.type){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new Bp(t)]}else if(t.selector)t=[new Lp(t)];else if(t.name)t=[new Dp(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new Zp(t)]}return t.map(t=>(t[jp]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[Fp]&&Vp(t),void 0===t.raws.before&&r&&void 0!==r.raws.before&&(t.raws.before=r.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,"prepend").reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){let t;e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);for(let r in this.indexes)t=this.indexes[r],t>=e&&(this.indexes[r]=t-1);return this.markDirty(),this}replaceValues(e,t,r){return r||(r=t,t={}),this.walkDecls(n=>{t.props&&!t.props.includes(n.prop)||t.fast&&!n.value.includes(t.fast)||(n.value=n.value.replace(e,r))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,r)=>{let n;try{n=e(t,r)}catch(i){throw t.addToError(i)}return!1!==n&&t.walk&&(n=t.walk(e)),n})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((r,n)=>{if("atrule"===r.type&&e.test(r.name))return t(r,n)}):this.walk((r,n)=>{if("atrule"===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk((e,r)=>{if("atrule"===e.type)return t(e,r)}))}walkComments(e){return this.walk((t,r)=>{if("comment"===t.type)return e(t,r)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((r,n)=>{if("decl"===r.type&&e.test(r.prop))return t(r,n)}):this.walk((r,n)=>{if("decl"===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk((e,r)=>{if("decl"===e.type)return t(e,r)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((r,n)=>{if("rule"===r.type&&e.test(r.selector))return t(r,n)}):this.walk((r,n)=>{if("rule"===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk((e,r)=>{if("rule"===e.type)return t(e,r)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};Hp.registerParse=e=>{Pp=e},Hp.registerRule=e=>{Lp=e},Hp.registerAtRule=e=>{Dp=e},Hp.registerRoot=e=>{$p=e};var Gp=Hp;Hp.default=Hp,Hp.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,Dp.prototype):"rule"===e.type?Object.setPrototypeOf(e,Lp.prototype):"decl"===e.type?Object.setPrototypeOf(e,Bp.prototype):"comment"===e.type?Object.setPrototypeOf(e,Zp.prototype):"root"===e.type&&Object.setPrototypeOf(e,$p.prototype),e[jp]=!0,e.nodes&&e.nodes.forEach(e=>{Hp.rebuild(e)})};var Yp,Jp,Kp=Gp,Xp=class extends Kp{constructor(e){super({type:"document",...e}),this.nodes||(this.nodes=[])}toResult(e={}){return new Yp(new Jp,this,e).stringify()}};Xp.registerLazyResult=e=>{Yp=e},Xp.registerProcessor=e=>{Jp=e};var qp=Xp;Xp.default=Xp;var Qp=class{constructor(e,t={}){if(this.type="warning",this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let r in t)this[r]=t[r]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},ef=Qp;Qp.default=Qp;var tf=ef,rf=class{constructor(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let r=new tf(e,t);return this.messages.push(r),r}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},nf=rf;rf.default=rf;var of="'".charCodeAt(0),sf='"'.charCodeAt(0),af="\\".charCodeAt(0),lf="/".charCodeAt(0),cf="\n".charCodeAt(0),df=" ".charCodeAt(0),uf="\f".charCodeAt(0),hf="\t".charCodeAt(0),pf="\r".charCodeAt(0),ff="[".charCodeAt(0),mf="]".charCodeAt(0),gf="(".charCodeAt(0),yf=")".charCodeAt(0),wf="{".charCodeAt(0),bf="}".charCodeAt(0),vf=";".charCodeAt(0),xf="*".charCodeAt(0),kf=":".charCodeAt(0),Sf="@".charCodeAt(0),Cf=/[\t\n\f\r "#'()/;[\\\]{}]/g,If=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,_f=/.[\r\n"'(/\\]/,Af=/[\da-f]/i,Ef=Gp,zf=class extends Ef{constructor(e){super(e),this.type="atrule"}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}},Mf=zf;zf.default=zf,Ef.registerAtRule(zf);var Tf,Of,Rf=Gp,Nf=class extends Rf{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,r){let n=super.normalize(e);if(t)if("prepend"===r)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let i of n)i.raws.before=t.raws.before;return n}removeChild(e,t){let r=this.index(e);return!t&&0===r&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[r].raws.before),super.removeChild(e)}toResult(e={}){return new Tf(new Of,this,e).stringify()}};Nf.registerLazyResult=e=>{Tf=e},Nf.registerProcessor=e=>{Of=e};var Pf=Nf;Nf.default=Nf,Rf.registerRoot(Nf);var Lf={comma:e=>Lf.split(e,[","],!0),space:e=>Lf.split(e,[" ","\n","\t"]),split(e,t,r){let n=[],i="",o=!1,s=0,a=!1,l="",c=!1;for(let d of e)c?c=!1:"\\"===d?c=!0:a?d===l&&(a=!1):'"'===d||"'"===d?(a=!0,l=d):"("===d?s+=1:")"===d?s>0&&(s-=1):0===s&&t.includes(d)&&(o=!0),o?(""!==i&&n.push(i.trim()),i="",o=!1):i+=d;return(r||""!==i)&&n.push(i.trim()),n}},Df=Lf;Lf.default=Lf;var $f=Gp,Ff=Df,jf=class extends $f{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return Ff.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(r)}},Bf=jf;jf.default=jf,$f.registerRule(jf);var Zf=Kh,Wf=function(e,t={}){let r,n,i,o,s,a,l,c,d,u,h=e.css.valueOf(),p=t.ignoreErrors,f=h.length,m=0,g=[],y=[];function w(t){throw e.error("Unclosed "+t,m)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&m>=f},nextToken:function(e){if(y.length)return y.pop();if(m>=f)return;let t=!!e&&e.ignoreUnclosed;switch(r=h.charCodeAt(m),r){case cf:case df:case hf:case pf:case uf:n=m;do{n+=1,r=h.charCodeAt(n)}while(r===df||r===cf||r===hf||r===pf||r===uf);u=["space",h.slice(m,n)],m=n-1;break;case ff:case mf:case wf:case bf:case kf:case vf:case yf:{let e=String.fromCharCode(r);u=[e,e,m];break}case gf:if(c=g.length?g.pop()[1]:"",d=h.charCodeAt(m+1),"url"===c&&d!==of&&d!==sf&&d!==df&&d!==cf&&d!==hf&&d!==uf&&d!==pf){n=m;do{if(a=!1,n=h.indexOf(")",n+1),-1===n){if(p||t){n=m;break}w("bracket")}for(l=n;h.charCodeAt(l-1)===af;)l-=1,a=!a}while(a);u=["brackets",h.slice(m,n+1),m,n],m=n}else n=h.indexOf(")",m+1),o=h.slice(m,n+1),-1===n||_f.test(o)?u=["(","(",m]:(u=["brackets",o,m,n],m=n);break;case of:case sf:i=r===of?"'":'"',n=m;do{if(a=!1,n=h.indexOf(i,n+1),-1===n){if(p||t){n=m+1;break}w("string")}for(l=n;h.charCodeAt(l-1)===af;)l-=1,a=!a}while(a);u=["string",h.slice(m,n+1),m,n],m=n;break;case Sf:Cf.lastIndex=m+1,Cf.test(h),n=0===Cf.lastIndex?h.length-1:Cf.lastIndex-2,u=["at-word",h.slice(m,n+1),m,n],m=n;break;case af:for(n=m,s=!0;h.charCodeAt(n+1)===af;)n+=1,s=!s;if(r=h.charCodeAt(n+1),s&&r!==lf&&r!==df&&r!==cf&&r!==hf&&r!==pf&&r!==uf&&(n+=1,Af.test(h.charAt(n)))){for(;Af.test(h.charAt(n+1));)n+=1;h.charCodeAt(n+1)===df&&(n+=1)}u=["word",h.slice(m,n+1),m,n],m=n;break;default:r===lf&&h.charCodeAt(m+1)===xf?(n=h.indexOf("*/",m+2)+1,0===n&&(p||t?n=h.length:w("comment")),u=["comment",h.slice(m,n+1),m,n],m=n):(If.lastIndex=m+1,If.test(h),n=0===If.lastIndex?h.length-1:If.lastIndex-2,u=["word",h.slice(m,n+1),m,n],g.push(u),m=n)}return m++,u},position:function(){return m}}},Uf=Np,Vf=Mf,Hf=Pf,Gf=Bf,Yf={empty:!0,space:!0};var Jf=Gp,Kf=class{constructor(e){this.input=e,this.root=new Hf,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t,r,n,i=new Vf;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);let o=!1,s=!1,a=[],l=[];for(;!this.tokenizer.endOfFile();){if(t=(e=this.tokenizer.nextToken())[0],"("===t||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(n=a.length-1,r=a[n];r&&"space"===r[0];)r=a[--n];r&&(i.source.end=this.getPosition(r[3]||r[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){let t=this.colon(e);if(!1===t)return;let r,n=0;for(let i=t-1;i>=0&&(r=e[i],"space"===r[0]||(n+=1,2!==n));i--);throw this.input.error("Missed semicolon","word"===r[0]?r[3]+1:r[2])}colon(e){let t,r,n,i=0;for(let[o,s]of e.entries()){if(t=s,r=t[0],"("===r&&(i+=1),")"===r&&(i-=1),0===i&&":"===r){if(n){if("word"===n[0]&&"progid"===n[1])continue;return o}this.doubleColon(t)}n=t}return!1}comment(e){let t=new Uf;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text="",t.raws.left=r,t.raws.right="";else{let e=r.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=Wf(this.input)}decl(e,t){let r=new Zf;this.init(r,e[0][2]);let n,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),r.source.end=this.getPosition(i[3]||i[2]||function(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=r[3]||r[2];if(n)return n}}(e)),r.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),r.raws.before+=e.shift()[1];for(r.source.start=this.getPosition(e[0][2]),r.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;r.prop+=e.shift()[1]}for(r.raws.between="";e.length;){if(n=e.shift(),":"===n[0]){r.raws.between+=n[1];break}"word"===n[0]&&/\w/.test(n[1])&&this.unknownWord([n]),r.raws.between+=n[1]}"_"!==r.prop[0]&&"*"!==r.prop[0]||(r.raws.before+=r.prop[0],r.prop=r.prop.slice(1));let o,s=[];for(;e.length&&(o=e[0][0],"space"===o||"comment"===o);)s.push(e.shift());this.precheckMissedSemicolon(e);for(let a=e.length-1;a>=0;a--){if(n=e[a],"!important"===n[1].toLowerCase()){r.important=!0;let t=this.stringFrom(e,a);t=this.spacesFromEnd(e)+t," !important"!==t&&(r.raws.important=t);break}if("important"===n[1].toLowerCase()){let t=e.slice(0),n="";for(let e=a;e>0;e--){let r=t[e][0];if(0===n.trim().indexOf("!")&&"space"!==r)break;n=t.pop()[1]+n}0===n.trim().indexOf("!")&&(r.important=!0,r.raws.important=n,e=t)}if("space"!==n[0]&&"comment"!==n[0])break}e.some(e=>"space"!==e[0]&&"comment"!==e[0])&&(r.raws.between+=s.map(e=>e[1]).join(""),s=[]),this.raw(r,"value",s.concat(e),t),r.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new Gf;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){let t=!1,r=null,n=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],l=e;for(;l;){if(r=l[0],a.push(l),"("===r||"["===r)i||(i=l),o.push("("===r?")":"]");else if(s&&n&&"{"===r)i||(i=l),o.push("}");else if(0===o.length){if(";"===r){if(n)return void this.decl(a,s);break}if("{"===r)return void this.rule(a);if("}"===r){this.tokenizer.back(a.pop()),t=!0;break}":"===r&&(n=!0)}else r===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&n){if(!s)for(;a.length&&(l=a[a.length-1][0],"space"===l||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,r,n){let i,o,s,a,l=r.length,c="",d=!0;for(let u=0;u<l;u+=1)i=r[u],o=i[0],"space"!==o||u!==l-1||n?"comment"===o?(a=r[u-1]?r[u-1][0]:"empty",s=r[u+1]?r[u+1][0]:"empty",Yf[a]||Yf[s]||","===c.slice(-1)?d=!1:c+=i[1]):c+=i[1]:d=!1;if(!d){let n=r.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:n,value:c}}e[t]=c}rule(e){e.pop();let t=new Gf;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){let t,r="";for(;e.length&&(t=e[e.length-1][0],"space"===t||"comment"===t);)r=e.pop()[1]+r;return r}spacesAndCommentsFromStart(e){let t,r="";for(;e.length&&(t=e[0][0],"space"===t||"comment"===t);)r+=e.shift()[1];return r}spacesFromEnd(e){let t,r="";for(;e.length&&(t=e[e.length-1][0],"space"===t);)r=e.pop()[1]+r;return r}stringFrom(e,t){let r="";for(let n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Xf=vp;function qf(e,t){let r=new Kf(new Xf(e,t));try{r.parse()}catch(n){throw n}return r.root}var Qf=qf;qf.default=qf,Jf.registerParse(qf);var{isClean:em,my:tm}=Rh,rm=Tp,nm=Fh,im=Gp,om=qp,sm=nf,am=Qf,lm=Pf,cm={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},dm={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},um={Once:!0,postcssPlugin:!0,prepare:!0};function hm(e){return"object"==typeof e&&"function"==typeof e.then}function pm(e){let t=!1,r=cm[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[r,r+"-"+t,0,r+"Exit",r+"Exit-"+t]:t?[r,r+"-"+t,r+"Exit",r+"Exit-"+t]:e.append?[r,0,r+"Exit"]:[r,r+"Exit"]}function fm(e){let t;return t="document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:pm(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function mm(e){return e[em]=!1,e.nodes&&e.nodes.forEach(e=>mm(e)),e}var gm={},ym=class e{constructor(t,r,n){let i;if(this.stringified=!1,this.processed=!1,"object"!=typeof r||null===r||"root"!==r.type&&"document"!==r.type)if(r instanceof e||r instanceof sm)i=mm(r.root),r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{let e=am;n.syntax&&(e=n.syntax.parse),n.parser&&(e=n.parser),e.parse&&(e=e.parse);try{i=e(r,n)}catch(o){this.processed=!0,this.error=o}i&&!i[tm]&&im.rebuild(i)}else i=mm(r);this.result=new sm(t,i,n),this.helpers={...gm,postcss:gm,result:this.result},this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let r=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin?r.postcssVersion:(e.plugin=r.postcssPlugin,e.setMessage())}catch(n){console&&console.error}return e}prepareVisitors(){this.listeners={};let e=(e,t,r)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,r])};for(let t of this.plugins)if("object"==typeof t)for(let r in t){if(!dm[r]&&/^[A-Z]/.test(r))throw new Error(`Unknown event ${r} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!um[r])if("object"==typeof t[r])for(let n in t[r])e(t,"*"===n?r:r+"-"+n.toLowerCase(),t[r][n]);else"function"==typeof t[r]&&e(t,r,t[r])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let r=0;r<this.plugins.length;r++){let t=this.plugins[r],n=this.runOnRoot(t);if(hm(n))try{await n}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[em];){e[em]=!0;let r=[fm(e)];for(;r.length>0;){let e=this.visitTick(r);if(hm(e))try{await e}catch(t){let e=r[r.length-1].node;throw this.handleError(t,e)}}}if(this.listeners.OnceExit)for(let[r,n]of this.listeners.OnceExit){this.result.lastPlugin=r;try{if("document"===e.type){let t=e.nodes.map(e=>n(e,this.helpers));await Promise.all(t)}else await n(e,this.helpers)}catch(t){throw this.handleError(t)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return hm(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=nm;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let r=new rm(t,this.result.root,this.result.opts).generate();return this.result.css=r[0],this.result.map=r[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(hm(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[em];)e[em]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[n,i]of e){let e;this.result.lastPlugin=n;try{e=i(t,this.helpers)}catch(r){throw this.handleError(r,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(hm(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:r,visitors:n}=t;if("root"!==r.type&&"document"!==r.type&&!r.parent)return void e.pop();if(n.length>0&&t.visitorIndex<n.length){let[e,i]=n[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===n.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(r.toProxy(),this.helpers)}catch(o){throw this.handleError(o,r)}}if(0!==t.iterator){let n,i=t.iterator;for(;n=r.nodes[r.indexes[i]];)if(r.indexes[i]+=1,!n[em])return n[em]=!0,void e.push(fm(n));t.iterator=0,delete r.indexes[i]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,0===e)return void(r.nodes&&r.nodes.length&&(r[em]=!0,t.iterator=r.getIterator()));if(this.listeners[e])return void(t.visitors=this.listeners[e])}e.pop()}walkSync(e){e[em]=!0;let t=pm(e);for(let r of t)if(0===r)e.nodes&&e.each(e=>{e[em]||this.walkSync(e)});else{let t=this.listeners[r];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};ym.registerPostcss=e=>{gm=e};var wm=ym;ym.default=ym,lm.registerLazyResult(ym),om.registerLazyResult(ym);var bm=Tp,vm=Fh,xm=Qf,km=nf,Sm=class{constructor(e,t,r){let n;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=r,this._map=void 0;let i=vm;this.result=new km(this._processor,n,this._opts),this.result.css=t;let o=this;Object.defineProperty(this.result,"root",{get:()=>o.root});let s=new bm(i,n,this._opts,t);if(s.isMap()){let[e,t]=s.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=xm;try{e=t(this._css,this._opts)}catch(r){this.error=r}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},Cm=Sm;Sm.default=Sm;var Im=Cm,_m=wm,Am=qp,Em=Pf,zm=class{constructor(e=[]){this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){let t=[];for(let r of e)if(!0===r.postcss?r=r():r.postcss&&(r=r.postcss),"object"==typeof r&&Array.isArray(r.plugins))t=t.concat(r.plugins);else if("object"==typeof r&&r.postcssPlugin)t.push(r);else if("function"==typeof r)t.push(r);else if("object"!=typeof r||!r.parse&&!r.stringify)throw new Error(r+" is not a PostCSS plugin");return t}process(e,t={}){return this.plugins.length||t.parser||t.stringifier||t.syntax?new _m(this,e,t):new Im(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},Mm=zm;zm.default=zm,Em.registerProcessor(zm),Am.registerProcessor(zm);var Tm=Kh,Om=op,Rm=Np,Nm=Mf,Pm=vp,Lm=Pf,Dm=Bf;function $m(e,t){if(Array.isArray(e))return e.map(e=>$m(e));let{inputs:r,...n}=e;if(r){t=[];for(let e of r){let r={...e,__proto__:Pm.prototype};r.map&&(r.map={...r.map,__proto__:Om.prototype}),t.push(r)}}if(n.nodes&&(n.nodes=e.nodes.map(e=>$m(e,t))),n.source){let{inputId:e,...r}=n.source;n.source=r,null!=e&&(n.source.input=t[e])}if("root"===n.type)return new Lm(n);if("decl"===n.type)return new Tm(n);if("rule"===n.type)return new Dm(n);if("comment"===n.type)return new Rm(n);if("atrule"===n.type)return new Nm(n);throw new Error("Unknown node type: "+e.type)}var Fm=$m;$m.default=$m;var jm=Oh,Bm=Kh,Zm=wm,Wm=Gp,Um=Mm,Vm=Fh,Hm=Fm,Gm=qp,Ym=ef,Jm=Np,Km=Mf,Xm=nf,qm=vp,Qm=Qf,eg=Df,tg=Bf,rg=Pf,ng=Gh;function ig(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new Um(e)}ig.plugin=function(e,t){let r,n=!1;function i(...r){console&&console.warn&&!n&&(n=!0,{}.LANG&&{}.LANG.startsWith("cn"));let i=t(...r);return i.postcssPlugin=e,i.postcssVersion=(new Um).version,i}return Object.defineProperty(i,"postcss",{get:()=>(r||(r=i()),r)}),i.process=function(e,t,r){return ig([i(r)]).process(e,t)},i},ig.stringify=Vm,ig.parse=Qm,ig.fromJSON=Hm,ig.list=eg,ig.comment=e=>new Jm(e),ig.atRule=e=>new Km(e),ig.decl=e=>new Bm(e),ig.rule=e=>new tg(e),ig.root=e=>new rg(e),ig.document=e=>new Gm(e),ig.CssSyntaxError=jm,ig.Declaration=Bm,ig.Container=Wm,ig.Processor=Um,ig.Document=Gm,ig.Comment=Jm,ig.Warning=Ym,ig.AtRule=Km,ig.Result=Xm,ig.Input=qm,ig.Rule=tg,ig.Root=rg,ig.Node=ng,Zm.registerPostcss(ig);var og=ig;ig.default=ig;var sg=/* @__PURE__ */kh(og);sg.stringify,sg.fromJSON,sg.plugin,sg.parse,sg.list,sg.document,sg.comment,sg.atRule,sg.rule,sg.decl,sg.root,sg.CssSyntaxError,sg.Declaration,sg.Container,sg.Processor,sg.Document,sg.Comment,sg.Warning,sg.AtRule,sg.Result,sg.Input,sg.Rule,sg.Root,sg.Node;var ag=Object.defineProperty,lg=(e,t,r)=>((e,t,r)=>t in e?ag(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);function cg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function dg(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var ug={exports:{}},hg=String,pg=function(){return{isColorSupported:!1,reset:hg,bold:hg,dim:hg,italic:hg,underline:hg,inverse:hg,hidden:hg,strikethrough:hg,black:hg,red:hg,green:hg,yellow:hg,blue:hg,magenta:hg,cyan:hg,white:hg,gray:hg,bgBlack:hg,bgRed:hg,bgGreen:hg,bgYellow:hg,bgBlue:hg,bgMagenta:hg,bgCyan:hg,bgWhite:hg}};ug.exports=pg(),ug.exports.createColors=pg;var fg=ug.exports,mg=/* @__PURE__ */dg(/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),gg=fg,yg=mg,wg=class e extends Error{constructor(t,r,n,i,o,s){super(t),this.name="CssSyntaxError",this.reason=t,o&&(this.file=o),i&&(this.source=i),s&&(this.plugin=s),void 0!==r&&void 0!==n&&("number"==typeof r?(this.line=r,this.column=n):(this.line=r.line,this.column=r.column,this.endLine=n.line,this.endColumn=n.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;null==e&&(e=gg.isColorSupported),yg&&e&&(t=yg(t));let r,n,i=t.split(/\r?\n/),o=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length;if(e){let{bold:e,gray:t,red:i}=gg.createColors(!0);r=t=>e(i(t)),n=e=>t(e)}else r=n=e=>e;return i.slice(o,s).map((e,t)=>{let i=o+1+t,s=" "+(" "+i).slice(-a)+" | ";if(i===this.line){let t=n(s.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return r(">")+n(s)+e+"\n "+t+r("^")}return" "+n(s)+e}).join("\n")}toString(){let e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},bg=wg;wg.default=wg;var vg={};vg.isClean=Symbol("isClean"),vg.my=Symbol("my");var xg={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var kg=class{constructor(e){this.builder=e}atrule(e,t){let r="@"+e.name,n=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=" "),e.nodes)this.block(e,r+n);else{let i=(e.raws.between||"")+(t?";":"");this.builder(r+n+i,e)}}beforeAfter(e,t){let r;r="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let n=e.parent,i=0;for(;n&&"root"!==n.type;)i+=1,n=n.parent;if(r.includes("\n")){let t=this.raw(e,null,"indent");if(t.length)for(let e=0;e<i;e++)r+=t}return r}block(e,t){let r,n=this.raw(e,"between","beforeOpen");this.builder(t+n+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,"after")):r=this.raw(e,"after","emptyBody"),r&&this.builder(r),this.builder("}",e,"end")}body(e){let t=e.nodes.length-1;for(;t>0&&"comment"===e.nodes[t].type;)t-=1;let r=this.raw(e,"semicolon");for(let n=0;n<e.nodes.length;n++){let i=e.nodes[n],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==n||r)}}comment(e){let t=this.raw(e,"left","commentLeft"),r=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+r+"*/",e)}decl(e,t){let r=this.raw(e,"between","colon"),n=e.prop+r+this.rawValue(e,"value");e.important&&(n+=e.raws.important||" !important"),t&&(n+=";"),this.builder(n,e)}document(e){this.body(e)}raw(e,t,r){let n;if(r||(r=t),t&&(n=e.raws[t],void 0!==n))return n;let i=e.parent;if("before"===r){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return xg[r];let o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[r])return o.rawCache[r];if("before"===r||"after"===r)return this.beforeAfter(e,r);{let i="raw"+((s=r)[0].toUpperCase()+s.slice(1));this[i]?n=this[i](o,e):o.walk(e=>{if(n=e.raws[t],void 0!==n)return!1})}var s;return void 0===n&&(n=xg[r]),o.rawCache[r]=n,n}rawBeforeClose(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return t=e.raws.after,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){let r;return e.walkComments(e=>{if(void 0!==e.raws.before)return r=e.raws.before,r.includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeDecl"):r&&(r=r.replace(/\S/g,"")),r}rawBeforeDecl(e,t){let r;return e.walkDecls(e=>{if(void 0!==e.raws.before)return r=e.raws.before,r.includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeRule"):r&&(r=r.replace(/\S/g,"")),r}rawBeforeOpen(e){let t;return e.walk(e=>{if("decl"!==e.type&&(t=e.raws.between,void 0!==t))return!1}),t}rawBeforeRule(e){let t;return e.walk(r=>{if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return t=r.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){let t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(t=e.raws.after,void 0!==t))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(r=>{let n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){let e=r.raws.before.split("\n");return t=e[e.length-1],t=t.replace(/\S/g,""),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(t=e.raws.semicolon,void 0!==t))return!1}),t}rawValue(e,t){let r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},Sg=kg;kg.default=kg;var Cg=Sg;function Ig(e,t){new Cg(t).stringify(e)}var _g=Ig;Ig.default=Ig;var{isClean:Ag,my:Eg}=vg,zg=bg,Mg=Sg,Tg=_g;function Og(e,t){let r=new e.constructor;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if("proxyCache"===n)continue;let i=e[n],o=typeof i;"parent"===n&&"object"===o?t&&(r[n]=t):"source"===n?r[n]=i:Array.isArray(i)?r[n]=i.map(e=>Og(e,r)):("object"===o&&null!==i&&(i=Og(i)),r[n]=i)}return r}var Rg=class{constructor(e={}){this.raws={},this[Ag]=!1,this[Eg]=!0;for(let t in e)if("nodes"===t){this.nodes=[];for(let r of e[t])"function"==typeof r.clone?this.append(r.clone()):this.append(r)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=Og(this);for(let r in e)t[r]=e[r];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:r,start:n}=this.rangeBy(t);return this.source.input.error(e,{column:n.column,line:n.line},{column:r.column,line:r.line},t)}return new zg(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,r)=>(e[t]===r||(e[t]=r,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[Ag]){this[Ag]=!1;let e=this;for(;e=e.parent;)e[Ag]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e,t){let r=this.source.start;if(e.index)r=this.positionInside(e.index,t);else if(e.word){let n=(t=this.toString()).indexOf(e.word);-1!==n&&(r=this.positionInside(n,t))}return r}positionInside(e,t){let r=t||this.toString(),n=this.source.start.column,i=this.source.start.line;for(let o=0;o<e;o++)"\n"===r[o]?(n=1,i+=1):n+=1;return{column:n,line:i}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e){let t={column:this.source.start.column,line:this.source.start.line},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){let n=this.toString(),i=n.indexOf(e.word);-1!==i&&(t=this.positionInside(i,n),r=this.positionInside(i+e.word.length,n))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<t.line||r.line===t.line&&r.column<=t.column)&&(r={column:t.column+1,line:t.line}),{end:r,start:t}}raw(e,t){return(new Mg).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,r=!1;for(let n of e)n===this?r=!0:r?(this.parent.insertAfter(t,n),t=n):this.parent.insertBefore(t,n);r||this.remove()}return this}root(){let e=this;for(;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){let r={},n=null==t;t=t||/* @__PURE__ */new Map;let i=0;for(let o in this){if(!Object.prototype.hasOwnProperty.call(this,o))continue;if("parent"===o||"proxyCache"===o)continue;let e=this[o];if(Array.isArray(e))r[o]=e.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof e&&e.toJSON)r[o]=e.toJSON(null,t);else if("source"===o){let n=t.get(e.input);null==n&&(n=i,t.set(e.input,i),i++),r[o]={end:e.end,inputId:n,start:e.start}}else r[o]=e}return n&&(r.inputs=[...t.keys()].map(e=>e.toJSON())),r}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e=Tg){e.stringify&&(e=e.stringify);let t="";return e(this,e=>{t+=e}),t}warn(e,t,r){let n={node:this};for(let i in r)n[i]=r[i];return e.warn(t,n)}get proxyOf(){return this}},Ng=Rg;Rg.default=Rg;var Pg=Ng,Lg=class extends Pg{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e={...e,value:String(e.value)}),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Dg=Lg;Lg.default=Lg;var $g={nanoid:(e=21)=>{let t="",r=e;for(;r--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(r=t)=>{let n="",i=r;for(;i--;)n+=e[Math.random()*e.length|0];return n}},{SourceMapConsumer:Fg,SourceMapGenerator:jg}=mg,{existsSync:Bg,readFileSync:Zg}=mg,{dirname:Wg,join:Ug}=mg;var Vg=class{constructor(e,t){if(!1===t.map)return;this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");let r=t.map?t.map.prev:void 0,n=this.loadMap(t.from,r);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Wg(this.mapFile)),n&&(this.text=n)}consumer(){return this.consumerCache||(this.consumerCache=new Fg(this.text)),this.consumerCache}decodeInline(e){if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var t;let r=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+r)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){let t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(!t)return;let r=e.lastIndexOf(t.pop()),n=e.indexOf("*/",r);r>-1&&n>-1&&(this.annotation=this.getAnnotationURL(e.substring(r,n)))}loadFile(e){if(this.root=Wg(e),Bg(e))return this.mapFile=e,Zg(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof Fg)return jg.fromSourceMap(t).toString();if(t instanceof jg)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}{let r=t(e);if(r){let e=this.loadFile(r);if(!e)throw new Error("Unable to load previous source map: "+r.toString());return e}}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let t=this.annotation;return e&&(t=Ug(Wg(e),t)),this.loadFile(t)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Hg=Vg;Vg.default=Vg;var{SourceMapConsumer:Gg,SourceMapGenerator:Yg}=mg,{fileURLToPath:Jg,pathToFileURL:Kg}=mg,{isAbsolute:Xg,resolve:qg}=mg,{nanoid:Qg}=$g,ey=mg,ty=bg,ry=Hg,ny=Symbol("fromOffsetCache"),iy=Boolean(Gg&&Yg),oy=Boolean(qg&&Xg),sy=class{constructor(e,t={}){if(null==e||"object"==typeof e&&!e.toString)throw new Error(`PostCSS received ${e} instead of CSS string`);if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!oy||/^\w+:\/\//.test(t.from)||Xg(t.from)?this.file=t.from:this.file=qg(t.from)),oy&&iy){let e=new ry(this.css,t);if(e.text){this.map=e;let t=e.consumer().file;!this.file&&t&&(this.file=this.mapResolve(t))}}this.file||(this.id="<input css "+Qg(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,r,n={}){let i,o,s;if(t&&"object"==typeof t){let e=t,n=r;if("number"==typeof e.offset){let n=this.fromOffset(e.offset);t=n.line,r=n.col}else t=e.line,r=e.column;if("number"==typeof n.offset){let e=this.fromOffset(n.offset);o=e.line,s=e.col}else o=n.line,s=n.column}else if(!r){let e=this.fromOffset(t);t=e.line,r=e.col}let a=this.origin(t,r,o,s);return i=a?new ty(e,void 0===a.endLine?a.line:{column:a.column,line:a.line},void 0===a.endLine?a.column:{column:a.endColumn,line:a.endLine},a.source,a.file,n.plugin):new ty(e,void 0===o?t:{column:r,line:t},void 0===o?r:{column:s,line:o},this.css,this.file,n.plugin),i.input={column:r,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(Kg&&(i.input.url=Kg(this.file).toString()),i.input.file=this.file),i}fromOffset(e){let t,r;if(this[ny])r=this[ny];else{let e=this.css.split("\n");r=new Array(e.length);let t=0;for(let n=0,i=e.length;n<i;n++)r[n]=t,t+=e[n].length+1;this[ny]=r}t=r[r.length-1];let n=0;if(e>=t)n=r.length-1;else{let t,i=r.length-2;for(;n<i;)if(t=n+(i-n>>1),e<r[t])i=t-1;else{if(!(e>=r[t+1])){n=t;break}n=t+1}}return{col:e-r[n]+1,line:n+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:qg(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,r,n){if(!this.map)return!1;let i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof r&&(i=s.originalPositionFor({column:n,line:r})),o=Xg(a.source)?Kg(a.source):new URL(a.source,this.map.consumer().sourceRoot||Kg(this.map.mapFile));let l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!Jg)throw new Error("file: protocol is not available in this PostCSS build");l.file=Jg(o)}let c=s.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){let e={};for(let t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map={...this.map},e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},ay=sy;sy.default=sy,ey&&ey.registerInput&&ey.registerInput(sy);var{SourceMapConsumer:ly,SourceMapGenerator:cy}=mg,{dirname:dy,relative:uy,resolve:hy,sep:py}=mg,{pathToFileURL:fy}=mg,my=ay,gy=Boolean(ly&&cy),yy=Boolean(dy&&hy&&uy&&py),wy=class{constructor(e,t,r,n){this.stringify=e,this.mapOpts=r.map||{},this.root=t,this.opts=r,this.css=n,this.originalCSS=n,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=/* @__PURE__ */new Map,this.memoizedPaths=/* @__PURE__ */new Map,this.memoizedURLs=/* @__PURE__ */new Map}addAnnotation(){let e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";let t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let t,r=this.toUrl(this.path(e.file)),n=e.root||dy(e.file);!1===this.mapOpts.sourcesContent?(t=new ly(e.text),t.sourcesContent&&(t.sourcesContent=null)):t=e.consumer(),this.map.applySourceMap(t,r,this.toUrl(this.path(n)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root){let e;for(let t=this.root.nodes.length-1;t>=0;t--)e=this.root.nodes[t],"comment"===e.type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),yy&&gy&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=cy.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new cy({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new cy({file:this.outputFile(),ignoreInvalidMapping:!0});let e,t,r=1,n=1,i="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(s,a,l)=>{if(this.css+=s,a&&"end"!==l&&(o.generated.line=r,o.generated.column=n-1,a.source&&a.source.start?(o.source=this.sourcePath(a),o.original.line=a.source.start.line,o.original.column=a.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),e=s.match(/\n/g),e?(r+=e.length,t=s.lastIndexOf("\n"),n=s.length-t):n+=s.length,a&&"start"!==l){let e=a.parent||{raws:{}};("decl"!==a.type&&("atrule"!==a.type||a.nodes)||a!==e.last||e.raws.semicolon)&&(a.source&&a.source.end?(o.source=this.sourcePath(a),o.original.line=a.source.end.line,o.original.column=a.source.end.column-1,o.generated.line=r,o.generated.column=n-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=r,o.generated.column=n-1,this.map.addMapping(o)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;let e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let r=this.opts.to?dy(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(r=dy(hy(r,this.mapOpts.annotation)));let n=uy(r,e);return this.memoizedPaths.set(e,n),n}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new my(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let r=t.source.input.from;if(r&&!e[r]){e[r]=!0;let n=this.usesFileUrls?this.toFileUrl(r):this.toUrl(this.path(r));this.map.setSourceContent(n,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(fy){let t=fy(e).toString();return this.memoizedFileURLs.set(e,t),t}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;"\\"===py&&(e=e.replace(/\\/g,"/"));let r=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,r),r}},by=Ng,vy=class extends by{constructor(e){super(e),this.type="comment"}},xy=vy;vy.default=vy;var ky,Sy,Cy,Iy,{isClean:_y,my:Ay}=vg,Ey=Dg,zy=xy,My=Ng;function Ty(e){return e.map(e=>(e.nodes&&(e.nodes=Ty(e.nodes)),delete e.source,e))}function Oy(e){if(e[_y]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)Oy(t)}var Ry=class e extends My{append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t,r,n=this.getIterator();for(;this.indexes[n]<this.proxyOf.nodes.length&&(t=this.indexes[n],r=e(this.proxyOf.nodes[t],t),!1!==r);)this.indexes[n]+=1;return delete this.indexes[n],r}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?(...r)=>e[t](...r.map(e=>"function"==typeof e?(t,r)=>e(t.toProxy(),r):e)):"every"===t||"some"===t?r=>e[t]((e,...t)=>r(e.toProxy(),...t)):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,r)=>(e[t]===r||(e[t]=r,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let r,n=this.index(e),i=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(let o of i)this.proxyOf.nodes.splice(n+1,0,o);for(let o in this.indexes)r=this.indexes[o],n<r&&(this.indexes[o]=r+i.length);return this.markDirty(),this}insertBefore(e,t){let r,n=this.index(e),i=0===n&&"prepend",o=this.normalize(t,this.proxyOf.nodes[n],i).reverse();n=this.index(e);for(let s of o)this.proxyOf.nodes.splice(n,0,s);for(let s in this.indexes)r=this.indexes[s],n<=r&&(this.indexes[s]=r+o.length);return this.markDirty(),this}normalize(t,r){if("string"==typeof t)t=Ty(ky(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if("root"===t.type&&"document"!==this.type){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,"ignore")}else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new Ey(t)]}else if(t.selector)t=[new Sy(t)];else if(t.name)t=[new Cy(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new zy(t)]}return t.map(t=>(t[Ay]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[_y]&&Oy(t),void 0===t.raws.before&&r&&void 0!==r.raws.before&&(t.raws.before=r.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,"prepend").reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){let t;e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);for(let r in this.indexes)t=this.indexes[r],t>=e&&(this.indexes[r]=t-1);return this.markDirty(),this}replaceValues(e,t,r){return r||(r=t,t={}),this.walkDecls(n=>{t.props&&!t.props.includes(n.prop)||t.fast&&!n.value.includes(t.fast)||(n.value=n.value.replace(e,r))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,r)=>{let n;try{n=e(t,r)}catch(i){throw t.addToError(i)}return!1!==n&&t.walk&&(n=t.walk(e)),n})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((r,n)=>{if("atrule"===r.type&&e.test(r.name))return t(r,n)}):this.walk((r,n)=>{if("atrule"===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk((e,r)=>{if("atrule"===e.type)return t(e,r)}))}walkComments(e){return this.walk((t,r)=>{if("comment"===t.type)return e(t,r)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((r,n)=>{if("decl"===r.type&&e.test(r.prop))return t(r,n)}):this.walk((r,n)=>{if("decl"===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk((e,r)=>{if("decl"===e.type)return t(e,r)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((r,n)=>{if("rule"===r.type&&e.test(r.selector))return t(r,n)}):this.walk((r,n)=>{if("rule"===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk((e,r)=>{if("rule"===e.type)return t(e,r)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};Ry.registerParse=e=>{ky=e},Ry.registerRule=e=>{Sy=e},Ry.registerAtRule=e=>{Cy=e},Ry.registerRoot=e=>{Iy=e};var Ny=Ry;Ry.default=Ry,Ry.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,Cy.prototype):"rule"===e.type?Object.setPrototypeOf(e,Sy.prototype):"decl"===e.type?Object.setPrototypeOf(e,Ey.prototype):"comment"===e.type?Object.setPrototypeOf(e,zy.prototype):"root"===e.type&&Object.setPrototypeOf(e,Iy.prototype),e[Ay]=!0,e.nodes&&e.nodes.forEach(e=>{Ry.rebuild(e)})};var Py,Ly,Dy=Ny,$y=class extends Dy{constructor(e){super({type:"document",...e}),this.nodes||(this.nodes=[])}toResult(e={}){return new Py(new Ly,this,e).stringify()}};$y.registerLazyResult=e=>{Py=e},$y.registerProcessor=e=>{Ly=e};var Fy=$y;$y.default=$y;var jy=class{constructor(e,t={}){if(this.type="warning",this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let r in t)this[r]=t[r]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},By=jy;jy.default=jy;var Zy=By,Wy=class{constructor(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let r=new Zy(e,t);return this.messages.push(r),r}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},Uy=Wy;Wy.default=Wy;var Vy="'".charCodeAt(0),Hy='"'.charCodeAt(0),Gy="\\".charCodeAt(0),Yy="/".charCodeAt(0),Jy="\n".charCodeAt(0),Ky=" ".charCodeAt(0),Xy="\f".charCodeAt(0),qy="\t".charCodeAt(0),Qy="\r".charCodeAt(0),ew="[".charCodeAt(0),tw="]".charCodeAt(0),rw="(".charCodeAt(0),nw=")".charCodeAt(0),iw="{".charCodeAt(0),ow="}".charCodeAt(0),sw=";".charCodeAt(0),aw="*".charCodeAt(0),lw=":".charCodeAt(0),cw="@".charCodeAt(0),dw=/[\t\n\f\r "#'()/;[\\\]{}]/g,uw=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,hw=/.[\r\n"'(/\\]/,pw=/[\da-f]/i,fw=Ny,mw=class extends fw{constructor(e){super(e),this.type="atrule"}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}},gw=mw;mw.default=mw,fw.registerAtRule(mw);var yw,ww,bw=Ny,vw=class extends bw{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,r){let n=super.normalize(e);if(t)if("prepend"===r)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let i of n)i.raws.before=t.raws.before;return n}removeChild(e,t){let r=this.index(e);return!t&&0===r&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[r].raws.before),super.removeChild(e)}toResult(e={}){return new yw(new ww,this,e).stringify()}};vw.registerLazyResult=e=>{yw=e},vw.registerProcessor=e=>{ww=e};var xw=vw;vw.default=vw,bw.registerRoot(vw);var kw={comma:e=>kw.split(e,[","],!0),space:e=>kw.split(e,[" ","\n","\t"]),split(e,t,r){let n=[],i="",o=!1,s=0,a=!1,l="",c=!1;for(let d of e)c?c=!1:"\\"===d?c=!0:a?d===l&&(a=!1):'"'===d||"'"===d?(a=!0,l=d):"("===d?s+=1:")"===d?s>0&&(s-=1):0===s&&t.includes(d)&&(o=!0),o?(""!==i&&n.push(i.trim()),i="",o=!1):i+=d;return(r||""!==i)&&n.push(i.trim()),n}},Sw=kw;kw.default=kw;var Cw=Ny,Iw=Sw,_w=class extends Cw{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return Iw.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(r)}},Aw=_w;_w.default=_w,Cw.registerRule(_w);var Ew=Dg,zw=function(e,t={}){let r,n,i,o,s,a,l,c,d,u,h=e.css.valueOf(),p=t.ignoreErrors,f=h.length,m=0,g=[],y=[];function w(t){throw e.error("Unclosed "+t,m)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&m>=f},nextToken:function(e){if(y.length)return y.pop();if(m>=f)return;let t=!!e&&e.ignoreUnclosed;switch(r=h.charCodeAt(m),r){case Jy:case Ky:case qy:case Qy:case Xy:n=m;do{n+=1,r=h.charCodeAt(n)}while(r===Ky||r===Jy||r===qy||r===Qy||r===Xy);u=["space",h.slice(m,n)],m=n-1;break;case ew:case tw:case iw:case ow:case lw:case sw:case nw:{let e=String.fromCharCode(r);u=[e,e,m];break}case rw:if(c=g.length?g.pop()[1]:"",d=h.charCodeAt(m+1),"url"===c&&d!==Vy&&d!==Hy&&d!==Ky&&d!==Jy&&d!==qy&&d!==Xy&&d!==Qy){n=m;do{if(a=!1,n=h.indexOf(")",n+1),-1===n){if(p||t){n=m;break}w("bracket")}for(l=n;h.charCodeAt(l-1)===Gy;)l-=1,a=!a}while(a);u=["brackets",h.slice(m,n+1),m,n],m=n}else n=h.indexOf(")",m+1),o=h.slice(m,n+1),-1===n||hw.test(o)?u=["(","(",m]:(u=["brackets",o,m,n],m=n);break;case Vy:case Hy:i=r===Vy?"'":'"',n=m;do{if(a=!1,n=h.indexOf(i,n+1),-1===n){if(p||t){n=m+1;break}w("string")}for(l=n;h.charCodeAt(l-1)===Gy;)l-=1,a=!a}while(a);u=["string",h.slice(m,n+1),m,n],m=n;break;case cw:dw.lastIndex=m+1,dw.test(h),n=0===dw.lastIndex?h.length-1:dw.lastIndex-2,u=["at-word",h.slice(m,n+1),m,n],m=n;break;case Gy:for(n=m,s=!0;h.charCodeAt(n+1)===Gy;)n+=1,s=!s;if(r=h.charCodeAt(n+1),s&&r!==Yy&&r!==Ky&&r!==Jy&&r!==qy&&r!==Qy&&r!==Xy&&(n+=1,pw.test(h.charAt(n)))){for(;pw.test(h.charAt(n+1));)n+=1;h.charCodeAt(n+1)===Ky&&(n+=1)}u=["word",h.slice(m,n+1),m,n],m=n;break;default:r===Yy&&h.charCodeAt(m+1)===aw?(n=h.indexOf("*/",m+2)+1,0===n&&(p||t?n=h.length:w("comment")),u=["comment",h.slice(m,n+1),m,n],m=n):(uw.lastIndex=m+1,uw.test(h),n=0===uw.lastIndex?h.length-1:uw.lastIndex-2,u=["word",h.slice(m,n+1),m,n],g.push(u),m=n)}return m++,u},position:function(){return m}}},Mw=xy,Tw=gw,Ow=xw,Rw=Aw,Nw={empty:!0,space:!0};var Pw=Ny,Lw=class{constructor(e){this.input=e,this.root=new Ow,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t,r,n,i=new Tw;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);let o=!1,s=!1,a=[],l=[];for(;!this.tokenizer.endOfFile();){if(t=(e=this.tokenizer.nextToken())[0],"("===t||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(n=a.length-1,r=a[n];r&&"space"===r[0];)r=a[--n];r&&(i.source.end=this.getPosition(r[3]||r[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){let t=this.colon(e);if(!1===t)return;let r,n=0;for(let i=t-1;i>=0&&(r=e[i],"space"===r[0]||(n+=1,2!==n));i--);throw this.input.error("Missed semicolon","word"===r[0]?r[3]+1:r[2])}colon(e){let t,r,n,i=0;for(let[o,s]of e.entries()){if(t=s,r=t[0],"("===r&&(i+=1),")"===r&&(i-=1),0===i&&":"===r){if(n){if("word"===n[0]&&"progid"===n[1])continue;return o}this.doubleColon(t)}n=t}return!1}comment(e){let t=new Mw;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text="",t.raws.left=r,t.raws.right="";else{let e=r.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=zw(this.input)}decl(e,t){let r=new Ew;this.init(r,e[0][2]);let n,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),r.source.end=this.getPosition(i[3]||i[2]||function(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=r[3]||r[2];if(n)return n}}(e)),r.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),r.raws.before+=e.shift()[1];for(r.source.start=this.getPosition(e[0][2]),r.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;r.prop+=e.shift()[1]}for(r.raws.between="";e.length;){if(n=e.shift(),":"===n[0]){r.raws.between+=n[1];break}"word"===n[0]&&/\w/.test(n[1])&&this.unknownWord([n]),r.raws.between+=n[1]}"_"!==r.prop[0]&&"*"!==r.prop[0]||(r.raws.before+=r.prop[0],r.prop=r.prop.slice(1));let o,s=[];for(;e.length&&(o=e[0][0],"space"===o||"comment"===o);)s.push(e.shift());this.precheckMissedSemicolon(e);for(let a=e.length-1;a>=0;a--){if(n=e[a],"!important"===n[1].toLowerCase()){r.important=!0;let t=this.stringFrom(e,a);t=this.spacesFromEnd(e)+t," !important"!==t&&(r.raws.important=t);break}if("important"===n[1].toLowerCase()){let t=e.slice(0),n="";for(let e=a;e>0;e--){let r=t[e][0];if(0===n.trim().indexOf("!")&&"space"!==r)break;n=t.pop()[1]+n}0===n.trim().indexOf("!")&&(r.important=!0,r.raws.important=n,e=t)}if("space"!==n[0]&&"comment"!==n[0])break}e.some(e=>"space"!==e[0]&&"comment"!==e[0])&&(r.raws.between+=s.map(e=>e[1]).join(""),s=[]),this.raw(r,"value",s.concat(e),t),r.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new Rw;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){let t=!1,r=null,n=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],l=e;for(;l;){if(r=l[0],a.push(l),"("===r||"["===r)i||(i=l),o.push("("===r?")":"]");else if(s&&n&&"{"===r)i||(i=l),o.push("}");else if(0===o.length){if(";"===r){if(n)return void this.decl(a,s);break}if("{"===r)return void this.rule(a);if("}"===r){this.tokenizer.back(a.pop()),t=!0;break}":"===r&&(n=!0)}else r===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&n){if(!s)for(;a.length&&(l=a[a.length-1][0],"space"===l||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,r,n){let i,o,s,a,l=r.length,c="",d=!0;for(let u=0;u<l;u+=1)i=r[u],o=i[0],"space"!==o||u!==l-1||n?"comment"===o?(a=r[u-1]?r[u-1][0]:"empty",s=r[u+1]?r[u+1][0]:"empty",Nw[a]||Nw[s]||","===c.slice(-1)?d=!1:c+=i[1]):c+=i[1]:d=!1;if(!d){let n=r.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:n,value:c}}e[t]=c}rule(e){e.pop();let t=new Rw;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){let t,r="";for(;e.length&&(t=e[e.length-1][0],"space"===t||"comment"===t);)r=e.pop()[1]+r;return r}spacesAndCommentsFromStart(e){let t,r="";for(;e.length&&(t=e[0][0],"space"===t||"comment"===t);)r+=e.shift()[1];return r}spacesFromEnd(e){let t,r="";for(;e.length&&(t=e[e.length-1][0],"space"===t);)r=e.pop()[1]+r;return r}stringFrom(e,t){let r="";for(let n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Dw=ay;function $w(e,t){let r=new Lw(new Dw(e,t));try{r.parse()}catch(n){throw n}return r.root}var Fw=$w;$w.default=$w,Pw.registerParse($w);var{isClean:jw,my:Bw}=vg,Zw=wy,Ww=_g,Uw=Ny,Vw=Fy,Hw=Uy,Gw=Fw,Yw=xw,Jw={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Kw={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Xw={Once:!0,postcssPlugin:!0,prepare:!0};function qw(e){return"object"==typeof e&&"function"==typeof e.then}function Qw(e){let t=!1,r=Jw[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[r,r+"-"+t,0,r+"Exit",r+"Exit-"+t]:t?[r,r+"-"+t,r+"Exit",r+"Exit-"+t]:e.append?[r,0,r+"Exit"]:[r,r+"Exit"]}function eb(e){let t;return t="document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:Qw(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function tb(e){return e[jw]=!1,e.nodes&&e.nodes.forEach(e=>tb(e)),e}var rb={},nb=class e{constructor(t,r,n){let i;if(this.stringified=!1,this.processed=!1,"object"!=typeof r||null===r||"root"!==r.type&&"document"!==r.type)if(r instanceof e||r instanceof Hw)i=tb(r.root),r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{let e=Gw;n.syntax&&(e=n.syntax.parse),n.parser&&(e=n.parser),e.parse&&(e=e.parse);try{i=e(r,n)}catch(o){this.processed=!0,this.error=o}i&&!i[Bw]&&Uw.rebuild(i)}else i=tb(r);this.result=new Hw(t,i,n),this.helpers={...rb,postcss:rb,result:this.result},this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){let r=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin?r.postcssVersion:(e.plugin=r.postcssPlugin,e.setMessage())}catch(n){console&&console.error}return e}prepareVisitors(){this.listeners={};let e=(e,t,r)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,r])};for(let t of this.plugins)if("object"==typeof t)for(let r in t){if(!Kw[r]&&/^[A-Z]/.test(r))throw new Error(`Unknown event ${r} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Xw[r])if("object"==typeof t[r])for(let n in t[r])e(t,"*"===n?r:r+"-"+n.toLowerCase(),t[r][n]);else"function"==typeof t[r]&&e(t,r,t[r])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let r=0;r<this.plugins.length;r++){let t=this.plugins[r],n=this.runOnRoot(t);if(qw(n))try{await n}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[jw];){e[jw]=!0;let r=[eb(e)];for(;r.length>0;){let e=this.visitTick(r);if(qw(e))try{await e}catch(t){let e=r[r.length-1].node;throw this.handleError(t,e)}}}if(this.listeners.OnceExit)for(let[r,n]of this.listeners.OnceExit){this.result.lastPlugin=r;try{if("document"===e.type){let t=e.nodes.map(e=>n(e,this.helpers));await Promise.all(t)}else await n(e,this.helpers)}catch(t){throw this.handleError(t)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return qw(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=Ww;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let r=new Zw(t,this.result.root,this.result.opts).generate();return this.result.css=r[0],this.result.map=r[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(qw(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[jw];)e[jw]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[n,i]of e){let e;this.result.lastPlugin=n;try{e=i(t,this.helpers)}catch(r){throw this.handleError(r,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(qw(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:r,visitors:n}=t;if("root"!==r.type&&"document"!==r.type&&!r.parent)return void e.pop();if(n.length>0&&t.visitorIndex<n.length){let[e,i]=n[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===n.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(r.toProxy(),this.helpers)}catch(o){throw this.handleError(o,r)}}if(0!==t.iterator){let n,i=t.iterator;for(;n=r.nodes[r.indexes[i]];)if(r.indexes[i]+=1,!n[jw])return n[jw]=!0,void e.push(eb(n));t.iterator=0,delete r.indexes[i]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,0===e)return void(r.nodes&&r.nodes.length&&(r[jw]=!0,t.iterator=r.getIterator()));if(this.listeners[e])return void(t.visitors=this.listeners[e])}e.pop()}walkSync(e){e[jw]=!0;let t=Qw(e);for(let r of t)if(0===r)e.nodes&&e.each(e=>{e[jw]||this.walkSync(e)});else{let t=this.listeners[r];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};nb.registerPostcss=e=>{rb=e};var ib=nb;nb.default=nb,Yw.registerLazyResult(nb),Vw.registerLazyResult(nb);var ob=wy,sb=_g,ab=Fw,lb=Uy,cb=class{constructor(e,t,r){let n;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=r,this._map=void 0;let i=sb;this.result=new lb(this._processor,n,this._opts),this.result.css=t;let o=this;Object.defineProperty(this.result,"root",{get:()=>o.root});let s=new ob(i,n,this._opts,t);if(s.isMap()){let[e,t]=s.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=ab;try{e=t(this._css,this._opts)}catch(r){this.error=r}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},db=cb;cb.default=cb;var ub=db,hb=ib,pb=Fy,fb=xw,mb=class{constructor(e=[]){this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){let t=[];for(let r of e)if(!0===r.postcss?r=r():r.postcss&&(r=r.postcss),"object"==typeof r&&Array.isArray(r.plugins))t=t.concat(r.plugins);else if("object"==typeof r&&r.postcssPlugin)t.push(r);else if("function"==typeof r)t.push(r);else if("object"!=typeof r||!r.parse&&!r.stringify)throw new Error(r+" is not a PostCSS plugin");return t}process(e,t={}){return this.plugins.length||t.parser||t.stringifier||t.syntax?new hb(this,e,t):new ub(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},gb=mb;mb.default=mb,fb.registerProcessor(mb),pb.registerProcessor(mb);var yb=Dg,wb=Hg,bb=xy,vb=gw,xb=ay,kb=xw,Sb=Aw;function Cb(e,t){if(Array.isArray(e))return e.map(e=>Cb(e));let{inputs:r,...n}=e;if(r){t=[];for(let e of r){let r={...e,__proto__:xb.prototype};r.map&&(r.map={...r.map,__proto__:wb.prototype}),t.push(r)}}if(n.nodes&&(n.nodes=e.nodes.map(e=>Cb(e,t))),n.source){let{inputId:e,...r}=n.source;n.source=r,null!=e&&(n.source.input=t[e])}if("root"===n.type)return new kb(n);if("decl"===n.type)return new yb(n);if("rule"===n.type)return new Sb(n);if("comment"===n.type)return new bb(n);if("atrule"===n.type)return new vb(n);throw new Error("Unknown node type: "+e.type)}var Ib=Cb;Cb.default=Cb;var _b=bg,Ab=Dg,Eb=ib,zb=Ny,Mb=gb,Tb=_g,Ob=Ib,Rb=Fy,Nb=By,Pb=xy,Lb=gw,Db=Uy,$b=ay,Fb=Fw,jb=Sw,Bb=Aw,Zb=xw,Wb=Ng;function Ub(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new Mb(e)}Ub.plugin=function(e,t){let r,n=!1;function i(...r){console&&console.warn&&!n&&(n=!0,{}.LANG&&{}.LANG.startsWith("cn"));let i=t(...r);return i.postcssPlugin=e,i.postcssVersion=(new Mb).version,i}return Object.defineProperty(i,"postcss",{get:()=>(r||(r=i()),r)}),i.process=function(e,t,r){return Ub([i(r)]).process(e,t)},i},Ub.stringify=Tb,Ub.parse=Fb,Ub.fromJSON=Ob,Ub.list=jb,Ub.comment=e=>new Pb(e),Ub.atRule=e=>new Lb(e),Ub.decl=e=>new Ab(e),Ub.rule=e=>new Bb(e),Ub.root=e=>new Zb(e),Ub.document=e=>new Rb(e),Ub.CssSyntaxError=_b,Ub.Declaration=Ab,Ub.Container=zb,Ub.Processor=Mb,Ub.Document=Rb,Ub.Comment=Pb,Ub.Warning=Nb,Ub.AtRule=Lb,Ub.Result=Db,Ub.Input=$b,Ub.Rule=Bb,Ub.Root=Zb,Ub.Node=Wb,Eb.registerPostcss(Ub);var Vb=Ub;Ub.default=Ub;var Hb=/* @__PURE__ */cg(Vb);Hb.stringify,Hb.fromJSON,Hb.plugin,Hb.parse,Hb.list,Hb.document,Hb.comment,Hb.atRule,Hb.rule,Hb.decl,Hb.root,Hb.CssSyntaxError,Hb.Declaration,Hb.Container,Hb.Processor,Hb.Document,Hb.Comment,Hb.Warning,Hb.AtRule,Hb.Result,Hb.Input,Hb.Rule,Hb.Root,Hb.Node;var Gb=class e{constructor(...e){lg(this,"parentElement",null),lg(this,"parentNode",null),lg(this,"ownerDocument"),lg(this,"firstChild",null),lg(this,"lastChild",null),lg(this,"previousSibling",null),lg(this,"nextSibling",null),lg(this,"ELEMENT_NODE",1),lg(this,"TEXT_NODE",3),lg(this,"nodeType"),lg(this,"nodeName"),lg(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"}},Yb={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Jb={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Kb={};function Xb(e){if(Kb[e])return Kb[e];const t=globalThis[e],r=t.prototype,n=e in Yb?Yb[e]:void 0,i=Boolean(n&&n.every(e=>{var t,n;return Boolean(null==(n=null==(t=Object.getOwnPropertyDescriptor(r,e))?void 0:t.get)?void 0:n.toString().includes("[native code]"))})),o=e in Jb?Jb[e]:void 0,s=Boolean(o&&o.every(e=>{var t;return"function"==typeof r[e]&&(null==(t=r[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return Kb[e]=t.prototype,t.prototype;try{const n=document.createElement("iframe");document.body.appendChild(n);const i=n.contentWindow;if(!i)return t.prototype;const o=i[e].prototype;return document.body.removeChild(n),o?Kb[e]=o:r}catch{return r}}var qb={};function Qb(e,t,r){var n;const i=`${e}.${String(r)}`;if(qb[i])return qb[i].call(t);const o=Xb(e),s=null==(n=Object.getOwnPropertyDescriptor(o,r))?void 0:n.get;return s?(qb[i]=s,s.call(t)):t[r]}var ev={};function tv(e,t,r){const n=`${e}.${String(r)}`;if(ev[n])return ev[n].bind(t);const i=Xb(e)[r];return"function"!=typeof i?t[r]:(ev[n]=i,i.bind(t))}function rv(){return Xb("MutationObserver").constructor}function nv(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],i=r(n);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=i,()=>{e[t]=n}}catch{return()=>{}}}var iv={ownerDocument:function(e){return Qb("Node",e,"ownerDocument")},childNodes:function(e){return Qb("Node",e,"childNodes")},parentNode:function(e){return Qb("Node",e,"parentNode")},parentElement:function(e){return Qb("Node",e,"parentElement")},textContent:function(e){return Qb("Node",e,"textContent")},contains:function(e,t){return tv("Node",e,"contains")(t)},getRootNode:function(e){return tv("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?Qb("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?Qb("Element",e,"shadowRoot"):null},querySelector:function(e,t){return Qb("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return Qb("Element",e,"querySelectorAll")(t)},mutationObserver:rv,patch:nv};function ov(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}var sv={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function av(e,t,r={}){let n=null,i=0;return function(...o){const s=Date.now();i||!1!==r.leading||(i=s);const a=t-(s-i),l=this;a<=0||a>t?(n&&(clearTimeout(n),n=null),i=s,e.apply(l,o)):n||!1===r.trailing||(n=setTimeout(()=>{i=!1===r.leading?0:Date.now(),n=null,e.apply(l,o)},a))}}function lv(e,t,r,n,i=window){const o=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,n?r:{set(e){setTimeout(()=>{r.set.call(this,e)},0),o&&o.set&&o.set.call(this,e)}}),()=>lv(e,t,o||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(sv=new Proxy(sv,{get:(e,t,r)=>Reflect.get(e,t,r)}));var cv=Date.now;function dv(e){var t,r,n,i;const o=e.document;return{left:o.scrollingElement?o.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:o.documentElement.scrollLeft||(null==o?void 0:o.body)&&(null==(t=iv.parentElement(o.body))?void 0:t.scrollLeft)||(null==(r=null==o?void 0:o.body)?void 0:r.scrollLeft)||0,top:o.scrollingElement?o.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==o?void 0:o.documentElement.scrollTop)||(null==o?void 0:o.body)&&(null==(n=iv.parentElement(o.body))?void 0:n.scrollTop)||(null==(i=null==o?void 0:o.body)?void 0:i.scrollTop)||0}}function uv(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function hv(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function pv(e){return e?e.nodeType===e.ELEMENT_NODE?e:iv.parentElement(e):null}function fv(e,t,r,n){if(!e)return!1;const i=pv(e);if(!i)return!1;try{if("string"==typeof t){if(i.classList.contains(t))return!0;if(n&&null!==i.closest("."+t))return!0}else if(gh(i,t,n))return!0}catch(o){}if(r){if(i.matches(r))return!0;if(n&&null!==i.closest(r))return!0}return!1}function mv(e,t,r){return!("TITLE"!==e.tagName||!r.headTitleMutations)||-2===t.getId(e)}function gv(e,t){if(ju(e))return!1;const r=t.getId(e);if(!t.has(r))return!0;const n=iv.parentNode(e);return(!n||n.nodeType!==e.DOCUMENT_NODE)&&(!n||gv(n,t))}function yv(e){return Boolean(e.changedTouches)}function wv(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function bv(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function vv(e){return!!e&&(e instanceof Gb&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(iv.shadowRoot(e)))}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(cv=()=>/* @__PURE__ */(new Date).getTime());var xv=class{constructor(){_u(this,"id",1),_u(this,"styleIDMap",/* @__PURE__ */new WeakMap),_u(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 r;return r=void 0===t?this.id++:t,this.styleIDMap.set(e,r),this.idStyleMap.set(r,e),r}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 kv(e){var t;let r=null;return"getRootNode"in e&&(null==(t=iv.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&iv.host(iv.getRootNode(e))&&(r=iv.host(iv.getRootNode(e))),r}function Sv(e){const t=iv.ownerDocument(e);if(!t)return!1;const r=function(e){let t,r=e;for(;t=kv(r);)r=t;return r}(e);return iv.contains(t,r)}function Cv(e){const t=iv.ownerDocument(e);return!!t&&(iv.contains(t,e)||Sv(e))}var Iv=/* @__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))(Iv||{}),_v=/* @__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))(_v||{}),Av=/* @__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))(Av||{}),Ev=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ev||{}),zv=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(zv||{}),Mv=/* @__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))(Mv||{}),Tv=/* @__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))(Tv||{});function Ov(e){return"__ln"in e}var Rv,Nv=class{constructor(){_u(this,"length",0),_u(this,"head",null),_u(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let r=0;r<e;r++)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&&Ov(e.previousSibling)){const r=e.previousSibling.__ln.next;t.next=r,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,r&&(r.previous=t)}else if(e.nextSibling&&Ov(e.nextSibling)&&e.nextSibling.__ln.previous){const r=e.nextSibling.__ln.previous;t.previous=r,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,r&&(r.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--)}},Pv=(e,t)=>`${e}@${t}`,Lv=class{constructor(){_u(this,"frozen",!1),_u(this,"locked",!1),_u(this,"texts",[]),_u(this,"attributes",[]),_u(this,"attributeMap",/* @__PURE__ */new WeakMap),_u(this,"removes",[]),_u(this,"mapRemoves",[]),_u(this,"movedMap",{}),_u(this,"addedSet",/* @__PURE__ */new Set),_u(this,"movedSet",/* @__PURE__ */new Set),_u(this,"droppedSet",/* @__PURE__ */new Set),_u(this,"removesSubTreeCache",/* @__PURE__ */new Set),_u(this,"mutationCb"),_u(this,"blockClass"),_u(this,"blockSelector"),_u(this,"maskTextClass"),_u(this,"maskTextSelector"),_u(this,"inlineStylesheet"),_u(this,"maskInputOptions"),_u(this,"maskTextFn"),_u(this,"maskInputFn"),_u(this,"keepIframeSrcFn"),_u(this,"recordCanvas"),_u(this,"inlineImages"),_u(this,"slimDOMOptions"),_u(this,"dataURLOptions"),_u(this,"doc"),_u(this,"mirror"),_u(this,"iframeManager"),_u(this,"stylesheetManager"),_u(this,"shadowDomManager"),_u(this,"canvasManager"),_u(this,"processedNodeManager"),_u(this,"unattachedDoc"),_u(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),_u(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,r=new Nv,n=e=>{let t=e,r=-2;for(;-2===r;)t=t&&t.nextSibling,r=t&&this.mirror.getId(t);return r},i=i=>{const o=iv.parentNode(i);if(!o||!Cv(i))return;let s=!1;if(i.nodeType===Node.TEXT_NODE){const e=o.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(o)&&(s=!0)}const a=ju(o)?this.mirror.getId(kv(i)):this.mirror.getId(o),l=n(i);if(-1===a||-1===l)return r.addNode(i);const c=xh(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{wv(e,this.mirror)&&this.iframeManager.addIframe(e),bv(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),vv(i)&&this.shadowDomManager.addShadowRoot(iv.shadowRoot(i),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});c&&(e.push({parentId:a,nextId:l,node:c}),t.add(c.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)$v(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(iv.parentNode(a))||i(a);for(const a of this.addedSet)Fv(this.droppedSet,a)||$v(this.removesSubTreeCache,a,this.mirror)?Fv(this.movedSet,a)?i(a):this.droppedSet.add(a):i(a);let o=null;for(;r.length;){let e=null;if(o){const t=this.mirror.getId(iv.parentNode(o.value)),r=n(o.value);-1!==t&&-1!==r&&(e=o)}if(!e){let t=r.tail;for(;t;){const r=t;if(t=t.previous,r){const t=this.mirror.getId(iv.parentNode(r.value));if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value,n=iv.parentNode(t);if(n&&n.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=iv.host(n);if(-1!==this.mirror.getId(t)){e=r;break}}}}}}if(!e){for(;r.head;)r.removeNode(r.head.value);break}o=e.previous,r.removeNode(e.value),i(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,r=iv.parentNode(t);return r&&"TEXTAREA"===r.tagName&&this.genTextAreaValueMutation(r),{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 r=JSON.stringify(e.styleDiff),n=JSON.stringify(e._unchangedStyles);r.length<t.style.length&&(r+n).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))}),_u(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 r=Array.from(iv.childNodes(e),e=>iv.textContent(e)||"").join("");t.attributes.value=Vu({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Yu(e),value:r,maskInputFn:this.maskInputFn})}),_u(this,"processMutation",e=>{if(!mv(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=iv.textContent(e.target);fv(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:yh(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,pv(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const r=e.target;let n=e.attributeName,i=e.target.getAttribute(n);if("value"===n){const e=Yu(r);i=Vu({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:e,value:i,maskInputFn:this.maskInputFn})}if(fv(e.target,this.blockClass,this.blockSelector,!1)||i===e.oldValue)return;let o=this.attributeMap.get(e.target);if("IFRAME"===r.tagName&&"src"===n&&!this.keepIframeSrcFn(i)){if(r.contentDocument)return;n="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===n&&"INPUT"===r.tagName&&"password"===(e.oldValue||"").toLowerCase()&&r.setAttribute("data-rr-is-password","true"),!mh(r.tagName,n))if(o.attributes[n]=fh(this.doc,Hu(r.tagName),Hu(n),i),"style"===n){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(t){this.unattachedDoc=this.doc}const n=this.unattachedDoc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue);for(const e of Array.from(r.style)){const t=r.style.getPropertyValue(e),i=r.style.getPropertyPriority(e);t!==n.style.getPropertyValue(e)||i!==n.style.getPropertyPriority(e)?o.styleDiff[e]=""===i?t:[t,i]:o._unchangedStyles[e]=[t,i]}for(const e of Array.from(n.style))""===r.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}else"open"===n&&"DIALOG"===r.tagName&&(r.matches("dialog:modal")?o.attributes.rr_open_mode="modal":o.attributes.rr_open_mode="non-modal");break}case"childList":if(fv(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 r=this.mirror.getId(t),n=ju(e.target)?this.mirror.getId(iv.host(e.target)):this.mirror.getId(e.target);fv(e.target,this.blockClass,this.blockSelector,!1)||mv(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Dv(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===r||gv(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Pv(r,n)]?Dv(this.movedSet,t):(this.removes.push({parentId:n,id:r,isShadow:!(!ju(e.target)||!Bu(e.target))||void 0}),function(e,t){const r=[e];for(;r.length;){const e=r.pop();t.has(e)||(t.add(e),iv.childNodes(e).forEach(e=>r.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),_u(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(mv(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let r=null;t&&this.mirror.hasNode(t)&&(r=this.mirror.getId(t)),r&&-1!==r&&(this.movedMap[Pv(this.mirror.getId(e),r)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);fv(e,this.blockClass,this.blockSelector,!1)||(iv.childNodes(e).forEach(e=>this.genAdds(e)),vv(e)&&iv.childNodes(iv.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function Dv(e,t){e.delete(t),iv.childNodes(t).forEach(t=>Dv(e,t))}function $v(e,t,r){return 0!==e.size&&function(e,t){const r=iv.parentNode(t);return!!r&&e.has(r)}(e,t)}function Fv(e,t){return 0!==e.size&&jv(e,t)}function jv(e,t){const r=iv.parentNode(t);return!!r&&(!!e.has(r)||jv(e,r))}var Bv=e=>{if(!Rv)return e;return(...t)=>{try{return e(...t)}catch(r){if(Rv&&!0===Rv(r))return;throw r}}},Zv=[];function Wv(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 Uv(e,t){const r=new Lv;Zv.push(r),r.init(e);const n=new(rv())(Bv(r.processMutations.bind(r)));return n.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n}function Vv({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:i,sampling:o}){if(!1===o.mouseInteraction)return()=>{};const s=!0===o.mouseInteraction||void 0===o.mouseInteraction?{}:o.mouseInteraction,a=[];let l=null;return Object.keys(Av).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(o=>{let s=Hu(o);const c=(t=>o=>{const s=Wv(o);if(fv(s,n,i,!0))return;let a=null,c=t;if("pointerType"in o){switch(o.pointerType){case"mouse":a=Ev.Mouse;break;case"touch":a=Ev.Touch;break;case"pen":a=Ev.Pen}a===Ev.Touch?Av[t]===Av.MouseDown?c="TouchStart":Av[t]===Av.MouseUp&&(c="TouchEnd"):Ev.Pen}else yv(o)&&(a=Ev.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Ev.Touch||c.startsWith("Mouse")&&a===Ev.Mouse)&&(a=null)):Av[t]===Av.Click&&(a=l,l=null);const d=yv(o)?o.changedTouches[0]:o;if(!d)return;const u=r.getId(s),{clientX:h,clientY:p}=d;Bv(e)({type:Av[c],id:u,x:h,y:p,...null!==a&&{pointerType:a}})})(o);if(window.PointerEvent)switch(Av[o]){case Av.MouseDown:case Av.MouseUp:s=s.replace("mouse","pointer");break;case Av.TouchStart:case Av.TouchEnd:return}a.push(ov(s,c,t))}),Bv(()=>{a.forEach(e=>e())})}function Hv({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:i,sampling:o}){return ov("scroll",Bv(av(Bv(o=>{const s=Wv(o);if(!s||fv(s,n,i,!0))return;const a=r.getId(s);if(s===t&&t.defaultView){const r=dv(t.defaultView);e({id:a,x:r.left,y:r.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),o.scroll||100)),t)}var Gv=["INPUT","TEXTAREA","SELECT"],Yv=/* @__PURE__ */new WeakMap;function Jv(e){return function(e,t){if(Qv("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||Qv("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||Qv("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||Qv("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const r=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(r)}else if(e.parentStyleSheet){const r=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(r)}return t}(e,[])}function Kv(e,t,r){let n,i;return e?(e.ownerNode?n=t.getId(e.ownerNode):i=r.getId(e),{styleId:i,id:n}):{}}function Xv({mirror:e,stylesheetManager:t},r){var n,i,o;let s=null;s="#document"===r.nodeName?e.getId(r):e.getId(iv.host(r));const a="#document"===r.nodeName?null==(n=r.defaultView)?void 0:n.Document:null==(o=null==(i=r.ownerDocument)?void 0:i.defaultView)?void 0:o.ShadowRoot,l=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&l?(Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null==(e=l.get)?void 0:e.call(this)},set(e){var r;const n=null==(r=l.set)?void 0:r.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(i){}return n}}),Bv(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function qv(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};let n;!function(e,t){const{mutationCb:r,mousemoveCb:n,mouseInteractionCb:i,scrollCb:o,viewportResizeCb:s,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p,customElementCb:f}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),r(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),n(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),i(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),o(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),f(...e)}}(e,t),e.recordDOM&&(n=Uv(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(!1===t.mousemove)return()=>{};const i="number"==typeof t.mousemove?t.mousemove:50,o="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const l=av(Bv(t=>{const r=Date.now()-s;e(a.map(e=>(e.timeOffset-=r,e)),t),a=[],s=null}),o),c=Bv(av(Bv(e=>{const t=Wv(e),{clientX:r,clientY:i}=yv(e)?e.changedTouches[0]:e;s||(s=cv()),a.push({x:r,y:i,id:n.getId(t),timeOffset:cv()-s}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?_v.Drag:e instanceof MouseEvent?_v.MouseMove:_v.TouchMove)}),i,{trailing:!1})),d=[ov("mousemove",c,r),ov("touchmove",c,r),ov("drag",c,r)];return Bv(()=>{d.forEach(e=>e())})}(e),o=Vv(e),s=Hv(e),a=function({viewportResizeCb:e},{win:t}){let r=-1,n=-1;return ov("resize",Bv(av(Bv(()=>{const t=uv(),i=hv();r===t&&n===i||(e({width:Number(i),height:Number(t)}),r=t,n=i)}),200)),t)}(e,{win:r}),l=function({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:i,ignoreClass:o,ignoreSelector:s,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(e){let r=Wv(e);const c=e.isTrusted,u=r&&r.tagName;if(r&&"OPTION"===u&&(r=iv.parentElement(r)),!r||!u||Gv.indexOf(u)<0||fv(r,n,i,!0))return;if(r.classList.contains(o)||s&&r.matches(s))return;let p=r.value,f=!1;const m=Yu(r)||"";"radio"===m||"checkbox"===m?f=r.checked:(a[u.toLowerCase()]||a[m])&&(p=Vu({element:r,maskInputOptions:a,tagName:u,type:m,value:p,maskInputFn:l})),h(r,d?{text:p,isChecked:f,userTriggered:c}:{text:p,isChecked:f});const g=r.name;"radio"===m&&g&&f&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==r){const t=e.value;h(e,d?{text:t,isChecked:!f,userTriggered:!1}:{text:t,isChecked:!f})}})}function h(t,n){const i=Yv.get(t);if(!i||i.text!==n.text||i.isChecked!==n.isChecked){Yv.set(t,n);const i=r.getId(t);Bv(e)({...n,id:i})}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>ov(e,Bv(u),t)),f=t.defaultView;if(!f)return()=>{p.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&&p.push(...g.map(e=>lv(e[0],e[1],{set(){Bv(u)({target:this,isTrusted:!1})}},!1,f))),Bv(()=>{p.forEach(e=>e())})}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:i,doc:o}){const s=Bv(o=>av(Bv(i=>{const s=Wv(i);if(!s||fv(s,t,r,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d,loop:u}=s;e({type:o,id:n.getId(s),currentTime:a,volume:l,muted:c,playbackRate:d,loop:u})}),i.media||500)),a=[ov("play",s(Mv.Play),o),ov("pause",s(Mv.Pause),o),ov("seeked",s(Mv.Seeked),o),ov("volumechange",s(Mv.VolumeChange),o),ov("ratechange",s(Mv.RateChange),o)];return Bv(()=>{a.forEach(e=>e())})}(e);let d=()=>{},u=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){if(!n.CSSStyleSheet||!n.CSSStyleSheet.prototype)return()=>{};const i=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:Bv((n,i,o)=>{const[s,a]=o,{id:l,styleId:c}=Kv(i,t,r.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:a}]}),n.apply(i,o)})}),n.CSSStyleSheet.prototype.addRule=function(e,t,r=this.cssRules.length){const i=`${e} { ${t} }`;return n.CSSStyleSheet.prototype.insertRule.apply(this,[i,r])};const o=n.CSSStyleSheet.prototype.deleteRule;let s,a;n.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:Bv((n,i,o)=>{const[s]=o,{id:a,styleId:l}=Kv(i,t,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:s}]}),n.apply(i,o)})}),n.CSSStyleSheet.prototype.removeRule=function(e){return n.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},n.CSSStyleSheet.prototype.replace&&(s=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:Bv((n,i,o)=>{const[s]=o,{id:a,styleId:l}=Kv(i,t,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:s}),n.apply(i,o)})})),n.CSSStyleSheet.prototype.replaceSync&&(a=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Bv((n,i,o)=>{const[s]=o,{id:a,styleId:l}=Kv(i,t,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:s}),n.apply(i,o)})}));const l={};ex("CSSGroupingRule")?l.CSSGroupingRule=n.CSSGroupingRule:(ex("CSSMediaRule")&&(l.CSSMediaRule=n.CSSMediaRule),ex("CSSConditionRule")&&(l.CSSConditionRule=n.CSSConditionRule),ex("CSSSupportsRule")&&(l.CSSSupportsRule=n.CSSSupportsRule));const c={};return Object.entries(l).forEach(([n,i])=>{c[n]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=new Proxy(c[n].insertRule,{apply:Bv((n,i,o)=>{const[s,a]=o,{id:l,styleId:c}=Kv(i.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:[...Jv(i),a||0]}]}),n.apply(i,o)})}),i.prototype.deleteRule=new Proxy(c[n].deleteRule,{apply:Bv((n,i,o)=>{const[s]=o,{id:a,styleId:l}=Kv(i.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...Jv(i),s]}]}),n.apply(i,o)})})}),Bv(()=>{n.CSSStyleSheet.prototype.insertRule=i,n.CSSStyleSheet.prototype.deleteRule=o,s&&(n.CSSStyleSheet.prototype.replace=s),a&&(n.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})})}(e,{win:r}),u=Xv(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:i}){const o=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:Bv((i,s,a)=>{var l;const[c,d,u]=a;if(r.has(c))return o.apply(s,[c,d,u]);const{id:h,styleId:p}=Kv(null==(l=s.parentRule)?void 0:l.parentStyleSheet,t,n.styleMirror);return(h&&-1!==h||p&&-1!==p)&&e({id:h,styleId:p,set:{property:c,value:d,priority:u},index:Jv(s.parentRule)}),i.apply(s,a)})});const s=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:Bv((i,o,a)=>{var l;const[c]=a;if(r.has(c))return s.apply(o,[c]);const{id:d,styleId:u}=Kv(null==(l=o.parentRule)?void 0:l.parentStyleSheet,t,n.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:c},index:Jv(o.parentRule)}),i.apply(o,a)})}),Bv(()=>{i.CSSStyleDeclaration.prototype.setProperty=o,i.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:r}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],i=/* @__PURE__ */new WeakMap,o=r.FontFace;r.FontFace=function(e,t,r){const n=new o(e,t,r);return i.set(n,{family:e,buffer:"string"!=typeof t,descriptors:r,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),n};const s=nv(t.fonts,"add",function(t){return function(r){return setTimeout(Bv(()=>{const t=i.get(r);t&&(e(t),i.delete(r))}),0),t.apply(this,[r])}});return n.push(()=>{r.FontFace=o}),n.push(s),Bv(()=>{n.forEach(e=>e())})}(e)));const f=function(e){const{doc:t,mirror:r,blockClass:n,blockSelector:i,selectionCb:o}=e;let s=!0;const a=Bv(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const{startContainer:o,startOffset:s,endContainer:l,endOffset:c}=e.getRangeAt(t);fv(o,n,i,!0)||fv(l,n,i,!0)||a.push({start:r.getId(o),startOffset:s,end:r.getId(l),endOffset:c})}o({ranges:a})});return a(),ov("selectionchange",a)}(e),m=function({doc:e,customElementCb:t}){const r=e.defaultView;return r&&r.customElements?nv(r.customElements,"define",function(e){return function(r,n,i){try{t({define:{name:r}})}catch(o){}return e.apply(this,[r,n,i])}}):()=>{}}(e),g=[];for(const y of e.plugins)g.push(y.observer(y.callback,r,y.options));return Bv(()=>{Zv.forEach(e=>e.reset()),n?.disconnect(),i(),o(),s(),a(),l(),c(),d(),u(),h(),p(),f(),m(),g.forEach(e=>e())})}function Qv(e){return void 0!==window[e]}function ex(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var tx=class{constructor(e){_u(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),_u(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,r,n){const i=r||this.getIdToRemoteIdMap(e),o=n||this.getRemoteIdToIdMap(e);let s=i.get(t);return s||(s=this.generateIdFn(),i.set(t,s),o.set(s,t)),s}getIds(e,t){const r=this.getIdToRemoteIdMap(e),n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,r,n))}getRemoteId(e,t,r){const n=r||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const i=n.get(t);return i||-1}getRemoteIds(e,t){const r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,r))}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}},rx=class{constructor(e){_u(this,"iframes",/* @__PURE__ */new WeakMap),_u(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),_u(this,"crossOriginIframeMirror",new tx(ah)),_u(this,"crossOriginIframeStyleMirror"),_u(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),_u(this,"mirror"),_u(this,"mutationCb"),_u(this,"wrappedEmit"),_u(this,"loadListener"),_u(this,"stylesheetManager"),_u(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new tx(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 r,n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(r=e.contentWindow)||r.addEventListener("message",this.handleMessage.bind(this))),null==(n=this.loadListener)||n.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 r=this.crossOriginIframeMap.get(e.source);if(!r)return;const n=this.transformCrossOriginEvent(r,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}transformCrossOriginEvent(e,t){var r;switch(t.type){case Iv.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const r=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,r),this.patchRootIdOnNode(t.data.node,r),{timestamp:t.timestamp,type:Iv.IncrementalSnapshot,data:{source:_v.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Iv.Meta:case Iv.Load:case Iv.DomContentLoaded:return!1;case Iv.Plugin:return t;case Iv.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Iv.IncrementalSnapshot:switch(t.data.source){case _v.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const r=this.crossOriginIframeRootIdMap.get(e);r&&this.patchRootIdOnNode(t.node,r)}),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 _v.Drag:case _v.TouchMove:case _v.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case _v.ViewportResize:return!1;case _v.MediaInteraction:case _v.MouseInteraction:case _v.Scroll:case _v.CanvasMutation:case _v.Input:return this.replaceIds(t.data,e,["id"]),t;case _v.StyleSheetRule:case _v.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case _v.Font:return t;case _v.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case _v.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(r=t.data.styles)||r.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,r,n){for(const i of n)(Array.isArray(t[i])||"number"==typeof t[i])&&(Array.isArray(t[i])?t[i]=e.getIds(r,t[i]):t[i]=e.getId(r,t[i]));return t}replaceIds(e,t,r){return this.replace(this.crossOriginIframeMirror,e,t,r)}replaceStyleIds(e,t,r){return this.replace(this.crossOriginIframeStyleMirror,e,t,r)}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===Tv.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},nx=class{constructor(e){_u(this,"shadowDoms",/* @__PURE__ */new WeakSet),_u(this,"mutationCb"),_u(this,"scrollCb"),_u(this,"bypassOptions"),_u(this,"mirror"),_u(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(!Bu(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const r=Uv({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>r.disconnect()),this.restoreHandlers.push(Hv({...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(iv.host(e))),this.restoreHandlers.push(Xv({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 r=this;this.restoreHandlers.push(nv(e.prototype,"attachShadow",function(e){return function(n){const i=e.call(this,n),o=iv.shadowRoot(this);return o&&Cv(this)&&r.addShadowRoot(o,t),i}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},ix="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ox="undefined"==typeof Uint8Array?[]:new Uint8Array(256),sx=0;sx<64;sx++)ox[ix.charCodeAt(sx)]=sx;var ax=function(e){var t,r=new Uint8Array(e),n=r.length,i="";for(t=0;t<n;t+=3)i+=ix[r[t]>>2],i+=ix[(3&r[t])<<4|r[t+1]>>4],i+=ix[(15&r[t+1])<<2|r[t+2]>>6],i+=ix[63&r[t+2]];return n%3==2?i=i.substring(0,i.length-1)+"=":n%3==1&&(i=i.substring(0,i.length-2)+"=="),i},lx=/* @__PURE__ */new Map;var cx=(e,t,r)=>{if(!e||!hx(e,t)&&"object"!=typeof e)return;const n=function(e,t){let r=lx.get(e);return r||(r=/* @__PURE__ */new Map,lx.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}(r,e.constructor.name);let i=n.indexOf(e);return-1===i&&(i=n.length,n.push(e)),i};function dx(e,t,r){if(e instanceof Array)return e.map(e=>dx(e,t,r));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:ax(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[dx(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:r}=e;return{rr_type:t,src:r}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[dx(e.data,t,r),e.width,e.height]}:hx(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:cx(e,t,r)}:e}var ux=(e,t,r)=>e.map(e=>dx(e,t,r)),hx=(e,t)=>{const r=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(r.find(r=>e instanceof t[r]))};function px(e,t,r,n){const i=[];try{const o=nv(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(i,...o){if(!fv(this,t,r,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(i);if("__context"in this||(this.__context=e),n&&["webgl","webgl2"].includes(e))if(o[0]&&"object"==typeof o[0]){const e=o[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else o.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[i,...o])}});i.push(o)}catch{}return()=>{i.forEach(e=>e())}}function fx(e,t,r,n,i,o){const s=[],a=Object.getOwnPropertyNames(e);for(const l of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if("function"!=typeof e[l])continue;const a=nv(e,l,function(e){return function(...s){const a=e.apply(this,s);if(cx(a,o,this),"tagName"in this.canvas&&!fv(this.canvas,n,i,!0)){const e={type:t,property:l,args:ux(s,o,this)};r(this.canvas,e)}return a}});s.push(a)}catch{const n=lv(e,l,{set(e){r(this.canvas,{type:t,property:l,args:[e],setter:!0})}});s.push(n)}return s}var mx="undefined"!=typeof window&&window.Blob&&new Blob([(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0)))("KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=")],{type:"text/javascript;charset=utf-8"});function gx(e){let t;try{if(t=mx&&(window.URL||window.webkitURL).createObjectURL(mx),!t)throw"";const r=new Worker(t,{name:null==e?void 0:e.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch(r){return new Worker("data:text/javascript;base64,KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",{name:null==e?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}var yx,wx,bx,vx=class{constructor(e){_u(this,"pendingCanvasMutations",/* @__PURE__ */new Map),_u(this,"rafStamps",{latestId:0,invokeId:null}),_u(this,"mirror"),_u(this,"mutationCb"),_u(this,"resetObservers"),_u(this,"frozen",!1),_u(this,"locked",!1),_u(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:r,blockClass:n,blockSelector:i,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(r,n,i),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,r,n,i,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,r,n,i){const o=px(t,r,n,!0),s=/* @__PURE__ */new Map,a=new gx;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:r,type:n,width:i,height:o}=e.data;this.mutationCb({id:t,type:zv["2D"],commands:[{property:"clearRect",args:[0,0,i,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:r}],type:n}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{fv(t,r,n,!0)||e.push(t)}),e})().forEach(async e=>{var t;const r=this.mirror.getId(e);if(s.get(r))return;if(0===e.width||0===e.height)return;if(s.set(r,!0),["webgl","webgl2"].includes(e.__context)){const r=e.getContext(e.__context);!1===(null==(t=null==r?void 0:r.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&r.clear(r.COLOR_BUFFER_BIT)}const n=await createImageBitmap(e);a.postMessage({id:r,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])})),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{o(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const n=px(e,t,r,!1),i=function(e,t,r,n){const i=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const o=nv(t.CanvasRenderingContext2D.prototype,s,function(i){return function(...o){return fv(this.canvas,r,n,!0)||setTimeout(()=>{const r=ux(o,t,this);e(this.canvas,{type:zv["2D"],property:s,args:r})},0),i.apply(this,o)}});i.push(o)}catch{const r=lv(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:zv["2D"],property:s,args:[t],setter:!0})}});i.push(r)}return()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,r),o=function(e,t,r,n){const i=[];return i.push(...fx(t.WebGLRenderingContext.prototype,zv.WebGL,e,r,n,t)),void 0!==t.WebGL2RenderingContext&&i.push(...fx(t.WebGL2RenderingContext.prototype,zv.WebGL2,e,r,n,t)),()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,r);this.resetObservers=()=>{n(),i(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const r=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,r)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const r=this.pendingCanvasMutations.get(e);if(!r||-1===t)return;const n=r.map(e=>{const{type:t,...r}=e;return r}),{type:i}=r[0];this.mutationCb({id:t,type:i,commands:n}),this.pendingCanvasMutations.delete(e)}},xx=class{constructor(e){_u(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),_u(this,"mutationCb"),_u(this,"adoptedStyleSheetCb"),_u(this,"styleMirror",new xv),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 r={id:t,styleIds:[]},n=[];for(const i of e){let e;this.styleMirror.has(i)?e=this.styleMirror.getId(i):(e=this.styleMirror.add(i),n.push({styleId:e,rules:Array.from(i.rules||CSSRule,(e,t)=>({rule:Wu(e,i.href),index:t}))})),r.styleIds.push(e)}n.length>0&&(r.styles=n),this.adoptedStyleSheetCb(r)}reset(){this.styleMirror.reset(),this.trackedLinkElements=/* @__PURE__ */new WeakSet}trackStylesheetInLinkElement(e){}},kx=class{constructor(){_u(this,"nodeMap",/* @__PURE__ */new WeakMap),_u(this,"active",!1)}inOtherBuffer(e,t){const r=this.nodeMap.get(e);return r&&Array.from(r).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(){}},Sx=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(hu=e.contentWindow)?void 0:hu.Array.from)||Array.from,document.body.removeChild(e)}}catch(zk){}var Cx,Ix,_x=new Uu;function Ax(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:p,maskInputFn:f,maskTextFn:m,hooks:g,packFn:y,sampling:w={},dataURLOptions:b={},mousemoveWait:v,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:S=!1,recordAfter:C=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:_=!1,inlineImages:A=!1,plugins:E,keepIframeSrcFn:z=()=>!1,ignoreCSSAttributes:M=/* @__PURE__ */new Set([]),errorHandler:T}=e;Rv=T;const O=!S||window.parent===window;let R=!1;if(!O)try{window.parent.document&&(R=!1)}catch(H){R=!0}if(O&&!t)throw new Error("emit function is required");if(!O&&!R)return()=>{};void 0!==v&&void 0===w.mousemove&&(w.mousemove=v),_x.reset();const N=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},P=vh(p);let L;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();let D=0;const $=e=>{for(const t of E||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!R&&(e=y(e)),e};yx=(e,i)=>{var o;const s=e;if(s.timestamp=cv(),!(null==(o=Zv[0])?void 0:o.isFrozen())||s.type===Iv.FullSnapshot||s.type===Iv.IncrementalSnapshot&&s.data.source===_v.Mutation||Zv.forEach(e=>e.unfreeze()),O)t?.($(s),i);else if(R){const e={type:"rrweb",event:$(s),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,"*")}if(s.type===Iv.FullSnapshot)L=s,D=0;else if(s.type===Iv.IncrementalSnapshot){if(s.data.source===_v.Mutation&&s.data.isAttachIframe)return;D++;const e=n&&D>=n,t=r&&s.timestamp-L.timestamp>r;(e||t)&&wx(!0)}};const F=e=>{yx({type:Iv.IncrementalSnapshot,data:{source:_v.Mutation,...e}})},j=e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.Scroll,...e}}),B=e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.CanvasMutation,...e}}),Z=new xx({mutationCb:F,adoptedStyleSheetCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.AdoptedStyleSheet,...e}})}),W=new rx({mirror:_x,mutationCb:F,stylesheetManager:Z,recordCrossOriginIframes:S,wrappedEmit:yx});for(const Y of E||[])Y.getMirror&&Y.getMirror({nodeMirror:_x,crossOriginIframeMirror:W.crossOriginIframeMirror,crossOriginIframeStyleMirror:W.crossOriginIframeStyleMirror});const U=new kx;bx=new vx({recordCanvas:k,mutationCb:B,win:window,blockClass:i,blockSelector:o,mirror:_x,sampling:w.canvas,dataURLOptions:b});const V=new nx({mutationCb:F,scrollCb:j,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:N,dataURLOptions:b,maskTextFn:m,maskInputFn:f,recordCanvas:k,inlineImages:A,sampling:w,slimDOMOptions:P,iframeManager:W,stylesheetManager:Z,canvasManager:bx,keepIframeSrcFn:z,processedNodeManager:U},mirror:_x});wx=(e=!1)=>{if(!x)return;yx({type:Iv.Meta,data:{href:window.location.href,width:hv(),height:uv()}},e),Z.reset(),V.init(),Zv.forEach(e=>e.lock());const t=function(e,t){const{mirror:r=new Uu,blockClass:n="rr-block",blockSelector:i=null,maskTextClass:o="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:h,slimDOM:p=!1,dataURLOptions:f,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x=()=>!1}=t||{};return xh(e,{doc:e,mirror:r,blockClass:n,blockSelector:i,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:h,slimDOMOptions:vh(p),dataURLOptions:f,inlineImages:l,recordCanvas:c,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:_x,blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:N,maskTextFn:m,maskInputFn:f,slimDOM:P,dataURLOptions:b,recordCanvas:k,inlineImages:A,onSerialize:e=>{wv(e,_x)&&W.addIframe(e),bv(e,_x)&&Z.trackLinkElement(e),vv(e)&&V.addShadowRoot(iv.shadowRoot(e),document)},onIframeLoad:(e,t)=>{W.attachIframe(e,t),V.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Z.attachLinkElement(e,t)},keepIframeSrcFn:z});t&&(yx({type:Iv.FullSnapshot,data:{node:t,initialOffset:dv(window)}},e),Zv.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Z.adoptStyleSheets(document.adoptedStyleSheets,_x.getId(document)))};try{const e=[],t=e=>{var t;return Bv(qv)({mutationCb:F,mousemoveCb:(e,t)=>yx({type:Iv.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.MouseInteraction,...e}}),scrollCb:j,viewportResizeCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.ViewportResize,...e}}),inputCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.Input,...e}}),mediaInteractionCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.MediaInteraction,...e}}),styleSheetRuleCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.StyleSheetRule,...e}}),styleDeclarationCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.StyleDeclaration,...e}}),canvasMutationCb:B,fontCb:e=>yx({type:Iv.IncrementalSnapshot,data:{source:_v.Font,...e}}),selectionCb:e=>{yx({type:Iv.IncrementalSnapshot,data:{source:_v.Selection,...e}})},customElementCb:e=>{yx({type:Iv.IncrementalSnapshot,data:{source:_v.CustomElement,...e}})},blockClass:i,ignoreClass:s,ignoreSelector:a,maskTextClass:l,maskTextSelector:c,maskInputOptions:N,inlineStylesheet:d,sampling:w,recordDOM:x,recordCanvas:k,inlineImages:A,userTriggeredOnInput:I,collectFonts:_,doc:e,maskInputFn:f,maskTextFn:m,keepIframeSrcFn:z,blockSelector:o,slimDOMOptions:P,dataURLOptions:b,mirror:_x,iframeManager:W,stylesheetManager:Z,shadowDomManager:V,processedNodeManager:U,canvasManager:bx,ignoreCSSAttributes:M,plugins:(null==(t=null==E?void 0:E.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>yx({type:Iv.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};W.addLoadListener(r=>{try{e.push(t(r.contentDocument))}catch(n){}});const r=()=>{wx(),e.push(t(document)),Sx=!0};return["interactive","complete"].includes(document.readyState)?r():(e.push(ov("DOMContentLoaded",()=>{yx({type:Iv.DomContentLoaded,data:{}}),"DOMContentLoaded"===C&&r()})),e.push(ov("load",()=>{yx({type:Iv.Load,data:{}}),"load"===C&&r()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")}}),U.destroy(),Sx=!1,Rv=void 0}}catch(G){}}Ax.addCustomEvent=(e,t)=>{if(!Sx)throw new Error("please add custom event after start recording");yx({type:Iv.Custom,data:{tag:e,payload:t}})},Ax.freezePage=()=>{Zv.forEach(e=>e.freeze())},Ax.takeFullSnapshot=e=>{if(!Sx)throw new Error("please take full snapshot after start recording");wx(e)},Ax.mirror=_x,(Ix=Cx||(Cx={}))[Ix.NotStarted=0]="NotStarted",Ix[Ix.Running=1]="Running",Ix[Ix.Stopped=2]="Stopped";var Ex=zs(),zx=500,Mx=5e5,Tx=class{eventQueue=[];estimatedQueueBytes=0;sessionId;stopRecording=null;isRecording=!1;chatId;applicationId;metadataSent=!1;startPromise=null;stopRequested=!1;flushTimer=null;consecutiveFailures=0;isFlushing=!1;constructor(e,t){if(!e||""===e.trim())throw new Error("chatId is required for SessionRecorder");if(!t||t<=0)throw new Error("applicationId (mtxApp) is required for SessionRecorder");Ex.info("Constructor called with chatId:",e,"applicationId:",t),this.chatId=e,this.applicationId=t,this.sessionId=e,Ex.info("Initialized with sessionId:",this.sessionId)}async sendMetadata(){this.metadataSent?Ex.warn("Metadata already sent, skipping"):(Ex.info("Sending rrweb/metadata via POST"),await Is.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/metadata",session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,user_agent:navigator.userAgent,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.metadataSent=!0,Ex.info("✅ rrweb/metadata sent successfully"))}bufferEvent(e){if(this.eventQueue.push(e),this.estimatedQueueBytes+=new Blob([JSON.stringify(e)]).size,this.eventQueue.length>zx){const e=this.eventQueue.length-zx,t=this.eventQueue.splice(0,e);for(const r of t)this.estimatedQueueBytes-=JSON.stringify(r).length;Ex.warn(`⚠️ Event queue exceeded 500, dropped ${e} oldest events`)}this.estimatedQueueBytes>=5e4?this.flush():this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},500))}flush(){if(this.isFlushing)return;if(this.isFlushing=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),0===this.eventQueue.length)return void(this.isFlushing=!1);let e,t;if(this.estimatedQueueBytes<=Mx)e=this.eventQueue,t=this.estimatedQueueBytes,this.eventQueue=[],this.estimatedQueueBytes=0;else{for(e=[],t=0;this.eventQueue.length>0;){const r=this.eventQueue[0];if(void 0===r)break;const n=JSON.stringify(r).length;if(t+n>Mx&&e.length>0)break;const i=this.eventQueue.shift();void 0!==i&&e.push(i),t+=n,this.estimatedQueueBytes-=n}this.eventQueue.length>0&&!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},0))}Ex.debug(`Flushing ${e.length} events (~${t} bytes)`),Is.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/events",session_id:this.sessionId,events:e}}).then(()=>{this.consecutiveFailures=0}).catch(r=>{const n=null!=r&&"object"==typeof r&&"status"in r?r.status:null;if("number"==typeof n&&n>=400&&n<500)return Ex.error(`Dropping ${e.length} events after permanent ${String(n)} error:`,r),void(this.consecutiveFailures=0);if(this.consecutiveFailures++,this.consecutiveFailures>5)return Ex.error(`Dropping ${e.length} events after 5 consecutive failures:`,r),void(this.consecutiveFailures=0);if(Ex.error(`Failed to flush events (attempt ${this.consecutiveFailures}/5), re-queuing:`,r),this.eventQueue=e.concat(this.eventQueue),this.estimatedQueueBytes+=t,this.eventQueue.length>zx){const e=this.eventQueue.length-zx,t=this.eventQueue.splice(0,e);for(const r of t)this.estimatedQueueBytes-=JSON.stringify(r).length;Ex.warn(`⚠️ Event queue exceeded 500 after re-queue, dropped ${e} oldest events`)}}).finally(()=>{this.isFlushing=!1})}async start(){if(this.isRecording)Ex.warn("Recording already started");else{if(this.startPromise)return this.startPromise;this.startPromise=this.doStart();try{await this.startPromise}finally{this.startPromise=null}}}async doStart(){this.stopRequested=!1;try{if(Ex.info("🚀 start() called"),await this.sendMetadata(),this.stopRequested)throw new Error("Recording stopped during startup");const e={emit:e=>{this.bufferEvent(e)},recordCanvas:!1,recordCrossOriginIframes:!1,maskAllInputs:!1,collectFonts:!1,inlineStylesheet:!0,blockClass:"rr-block",ignoreClass:"rr-ignore"};this.stopRecording=Ax(e),this.isRecording=!0,Ex.info("Recording started with chatId:",this.sessionId)}catch(e){throw Ex.error("Failed to start recording:",e),e}}stop(){this.stopRequested=!0,this.stopRecording&&(this.stopRecording(),this.stopRecording=null),(this.isRecording||this.eventQueue.length>0)&&this.flush(),this.isRecording=!1,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.metadataSent=!1,Ex.info("Recording stopped")}getSessionId(){return this.sessionId}isActive(){return this.isRecording}},Ox=e=>e?.mtxApiHost?e.mtxApiHost:"";function Rx(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function Nx(e,t="Operation",r){const n=Rx(e);return function(e){const t=e instanceof Error?e.message:String(e);return t.includes("Failed to fetch")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("NetworkError")||t.includes("Network request failed")}(e)?{isValid:!1,error:`Cannot connect to API server. Please ensure the API server is running at ${Ox(r)||"configured API server"}. Error: ${n}`}:{isValid:!1,error:`${t} failed: ${n}`}}var Px=class{config;async validateConfig(e){return this.config=e,e.mtxId&&e.mtxKey?this.validateByMarketrixId(e.mtxId,e.mtxKey):e.mtxApp&&e.mtxAgent?this.validateByAgentAndApplication(e.mtxApp,e.mtxAgent):{isValid:!1,error:"Please provide either (mtxId + mtxKey) OR (mtxApp + mtxAgent)"}}async validateByMarketrixId(e,t){try{const{items:n}=await Is.widgetSearch({marketrix_id:e,marketrix_key:t});if(!n||0===n.length)return{isValid:!1,error:"Widget not found or invalid credentials"};const i=n.find(e=>"widget"===e.type&&"active"===e.status);if(!i){const e=n.filter(e=>"widget"===e.type);return e.length>0?{isValid:!1,error:`Found widget(s) but none are active. Current status(es): ${e.map(e=>e.status).join(", ")}. Please activate the widget in the dashboard.`}:0===n.length?{isValid:!1,error:"No widgets found for the provided marketrix_id and marketrix_key. Please verify your credentials."}:{isValid:!1,error:`No widget found. Found widget type(s): ${n.map(e=>e.type).join(", ")}. Please create a widget.`}}if(!i.agent_id)return{isValid:!1,error:"Widget missing agent_id",widget:i};try{const e=await Is.agentGet({agent_id:i.agent_id});if(!i.application_id)return{isValid:!1,error:"Widget missing application_id",widget:i,agent:e};return{isValid:!0,widget:i,agent:e,application:await Is.applicationGet({application_id:i.application_id})}}catch(r){return{isValid:!1,error:`Failed to validate agent: ${Rx(r)}`,widget:i}}}catch(n){return Nx(n,"Widget validation",this.config)}}async validateByAgentAndApplication(e,t){try{const r=await Is.applicationGet({application_id:e}),n=await Is.agentGet({agent_id:t});return n.application_id!==e?{isValid:!1,error:`Agent ID ${t} belongs to application ID ${n.application_id}, but provided application ID is ${e}. Please verify the application ID matches the agent's application_id.`,application:r,agent:n}:{isValid:!0,application:r,agent:n}}catch(r){return Nx(r,"Agent and application validation",this.config)}}};function Lx(e,t){return"object"==typeof e&&null!==e&&t in e}function Dx(e){return null!==e&&e instanceof HTMLElement}function $x(e){return null!==e&&e instanceof HTMLScriptElement}var Fx=null,jx=class{mtxId;mtxKey;mtxApp;constructor(e,t,r){this.mtxId=e,this.mtxKey=t,this.mtxApp=r}async fetchWidgetSettings(){if(!this.mtxId&&!this.mtxKey&&!this.mtxApp)return null;try{Fx||(Fx=await Is.widgetGetDefaults({type:"widget"}));const e=Fx;if(!e){throw new Error("Failed to fetch default widget settings from API. The API must return widget settings.")}let t=null;if(this.mtxId&&this.mtxKey)t=(await Is.widgetSearch({type:"widget",marketrix_id:this.mtxId,marketrix_key:this.mtxKey})).items;else{if(!this.mtxApp)return null;t=(await Is.widgetSearch({type:"widget",application_id:this.mtxApp})).items}const r=t?.find(e=>"active"===e.status&&"widget"===e.type)||null;if(r?.settings){const t=this.getWidgetSettings(r);if(t){const n={...e,...t};return{...r,settings:n}}}const n=/* @__PURE__ */new Date;return{id:0,application_id:this.mtxApp||0,agent_id:0,type:"widget",settings:e,status:"active",marketrix_id:this.mtxId||"",marketrix_key:this.mtxKey||"",created_at:n,updated_at:n}}catch(e){const t=e instanceof Error?e.message:"Unknown error",r=/* @__PURE__ */new Error(`Failed to fetch widget settings from API: ${t}`);throw r.cause=e,r}}getWidgetSettings(e){if(!e?.settings)return null;const t=e.settings;return function(e){return"object"==typeof e&&null!==e}(r=t)&&Lx(r,"widget_enabled")&&"boolean"==typeof r.widget_enabled&&Lx(r,"widget_appearance")&&"string"==typeof r.widget_appearance&&Lx(r,"widget_position")&&"string"==typeof r.widget_position?t:null;var r}},Bx="#6b7280",Zx="#1f2937",Wx="rgba(255, 255, 255, 0.95)",Ux="rgba(255, 255, 255, 0.2)",Vx="rgba(0, 0, 0, 0.15)",Hx=({message:e="Loading widget settings..."})=>{const[t,r]=h(!1),n=e?.includes("marketrix_id")||e?.includes("marketrix_key");return t?null:/* @__PURE__ */g(rc,{position:"fixed",style:{bottom:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"420px",backgroundColor:Wx,borderRadius:n?"18px":"999px",boxShadow:`0 2px 12px ${Vx}`,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"8px",padding:"10px 12px",border:`1px solid ${Ux}`,zIndex:9999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[/* @__PURE__ */g(Yc,{align:"center",style:{gap:"10px"},children:[
63
- /* @__PURE__ */m(oc,{src:nc,alt:"",size:28,style:{borderRadius:"50%",overflow:"hidden",flexShrink:0}}),
64
- /* @__PURE__ */m(od,{as:"span",style:{fontSize:"13px",color:Zx,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:e}),
65
- /* @__PURE__ */m(ed,{label:"Dismiss",onClick:()=>r(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:Bx,borderRadius:"50%",width:"20px",height:"20px",minWidth:"unset"},children:/* @__PURE__ */m(Kc,{name:"closeSmall",size:12})})]}),n?/* @__PURE__ */m(od,{as:"p",style:{fontSize:"12px",color:Bx,textAlign:"left",margin:0},children:"Please configure marketrix_id and marketrix_key"}):null]})},Gx='/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-900:oklch(21% .034 264.665);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-2{inset:calc(var(--spacing) * 2)}.inset-3{inset:calc(var(--spacing) * 3)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing) * 4)}.top-5{top:calc(var(--spacing) * 5)}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-4{right:calc(var(--spacing) * 4)}.right-5{right:calc(var(--spacing) * 5)}.right-full{right:100%}.bottom-5{bottom:calc(var(--spacing) * 5)}.bottom-16{bottom:calc(var(--spacing) * 16)}.left-0{left:calc(var(--spacing) * 0)}.left-1\\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.left-full{left:100%}.isolate{isolation:isolate}.z-10{z-index:10}.z-20{z-index:20}.z-\\[calc\\(var\\(--layer-dialog\\)\\+1\\)\\]{z-index:calc(var(--layer-dialog) + 1)}.z-\\[var\\(--layer-popover\\)\\]{z-index:var(--layer-popover)}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.m-2{margin:calc(var(--spacing) * 2)}.m-32{margin:calc(var(--spacing) * 32)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-0\\.5{margin-block:calc(var(--spacing) * .5)}.mt-0\\.5{margin-top:calc(var(--spacing) * .5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-0{margin-bottom:calc(var(--spacing) * 0)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.h-0{height:calc(var(--spacing) * 0)}.h-0\\.5{height:calc(var(--spacing) * .5)}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-3\\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[85vh\\]{max-height:85vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-20{min-height:calc(var(--spacing) * 20)}.w-0{width:calc(var(--spacing) * 0)}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-3\\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-full{width:100%}.max-w-\\[500px\\]{max-width:500px}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-14{min-width:calc(var(--spacing) * 14)}.min-w-\\[180px\\]{min-width:180px}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-dialog-content-in{animation:dialog-content-in var(--duration-animation) ease-out}.animate-fade-in{animation:.5s ease-out fade-in}.animate-menu-in{animation:menu-in var(--duration-fade) ease-out}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-\\[var\\(--radius\\)\\]{border-radius:var(--radius)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-4{border-top-style:var(--tw-border-style);border-top-width:4px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-4{border-right-style:var(--tw-border-style);border-right-width:4px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--border)}.border-current{border-color:currentColor}.border-input{border-color:var(--input)}.border-transparent{border-color:#0000}.border-white\\/25{border-color:#ffffff40}@supports (color:color-mix(in lab, red, red)){.border-white\\/25{border-color:color-mix(in oklab, var(--color-white) 25%, transparent)}}.border-t-transparent{border-top-color:#0000}.bg-background{background-color:var(--background)}.bg-card{background-color:var(--card)}.bg-chart-1\\/15{background-color:var(--chart-1)}@supports (color:color-mix(in lab, red, red)){.bg-chart-1\\/15{background-color:color-mix(in oklab, var(--chart-1) 15%, transparent)}}.bg-current{background-color:currentColor}.bg-gray-900{background-color:var(--color-gray-900)}.bg-muted{background-color:var(--muted)}.bg-popover{background-color:var(--popover)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-secondary-bg{background-color:var(--secondary-bg)}.bg-success\\/15{background-color:var(--success)}@supports (color:color-mix(in lab, red, red)){.bg-success\\/15{background-color:color-mix(in oklab, var(--success) 15%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning\\/15{background-color:var(--warning)}@supports (color:color-mix(in lab, red, red)){.bg-warning\\/15{background-color:color-mix(in oklab, var(--warning) 15%, transparent)}}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing) * 0)}.p-0\\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-1\\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-blue-500{color:var(--color-blue-500)}.text-card-foreground{color:var(--card-foreground)}.text-chart-1{color:var(--chart-1)}.text-foreground{color:var(--foreground)}.text-foreground-faint{color:var(--foreground-faint)}.text-foreground-muted{color:var(--foreground-muted)}.text-inherit{color:inherit}.text-muted-foreground{color:var(--muted-foreground)}.text-popover-foreground{color:var(--popover-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-500{color:var(--color-red-500)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-success{color:var(--success)}.text-warning{color:var(--warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow,.shadow-\\[var\\(--shadow\\)\\]{--tw-shadow:var(--shadow);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\,background-color\\]{transition-property:transform,opacity,background-color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-\\[160ms\\]{--tw-duration:.16s;transition-duration:.16s}.duration-\\[167ms\\]{--tw-duration:.167s;transition-duration:.167s}.ease-\\[cubic-bezier\\(0\\.33\\,0\\,0\\,1\\)\\]{--tw-ease:cubic-bezier(.33,0,0,1);transition-timing-function:cubic-bezier(.33,0,0,1)}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.group-focus-within\\:pointer-events-auto:is(:where(.group):focus-within *){pointer-events:auto}.group-focus-within\\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media (hover:hover){.group-hover\\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\\:text-foreground-faint::placeholder{color:var(--foreground-faint)}.focus-within\\:border-foreground-faint:focus-within{border-color:var(--foreground-faint)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\\:border-muted-foreground:hover{border-color:var(--muted-foreground)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-accent:hover{background-color:var(--accent)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary:hover{background-color:var(--primary)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab, var(--primary) 90%, transparent)}}.hover\\:bg-secondary-hover:hover{background-color:var(--secondary-hover)}.hover\\:bg-secondary\\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-secondary\\/80:hover{background-color:color-mix(in oklab, var(--secondary) 80%, transparent)}}.hover\\:bg-transparent:hover{background-color:#0000}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\\:opacity-100:hover{opacity:1}.hover\\:duration-\\[250ms\\]:hover{--tw-duration:.25s;transition-duration:.25s}}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-3:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-ring:focus{--tw-ring-color:var(--ring)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:var(--ring)}.active\\:scale-\\[0\\.85\\]:active{scale:.85}.active\\:duration-\\[134ms\\]:active{--tw-duration:.134s;transition-duration:.134s}.active\\:ease-\\[cubic-bezier\\(0\\.45\\,0\\,0\\.2\\,1\\)\\]:active{--tw-ease:cubic-bezier(.45,0,.2,1);transition-timing-function:cubic-bezier(.45,0,.2,1)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:bg-muted:disabled{background-color:var(--muted)}.disabled\\:opacity-50:disabled{opacity:.5}}:root,:host{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--destructive-foreground:oklch(100% 0 0);--success:oklch(60% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(75% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--border-muted:#e5e7eb4d;--primary-hover:#3b82f6d9;--primary-muted:#3b82f64d;--secondary-bg:#6b728033;--secondary-hover:#6b72804d;--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040;--tracking-normal:0em;--spacing:.25rem;--duration-animation:.3s;--duration-fade:.2s;--widget-width:400px;--widget-height:520px;--layer-tooltip:1000;--layer-popover:1050;--layer-dialog:1100;--layer-toast:1200}.dark,:host(.dark){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(26.9% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(37.1% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(70.4% .191 22.216);--destructive-foreground:oklch(98.5% 0 0);--success:oklch(55% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(70% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(27.5% 0 0);--input:oklch(32.5% 0 0);--ring:oklch(55.6% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(27.5% 0 0);--sidebar-ring:oklch(43.9% 0 0);--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040}@media (prefers-reduced-motion:reduce){:root{--duration-animation:0s;--duration-fade:0s}}@keyframes dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes menu-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes popover-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes tooltip-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes toast-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(-30px)}to{opacity:1;transform:translate(0)}}@keyframes slide-in-right{0%{opacity:0;transform:translate(30px)}to{opacity:1;transform:translate(0)}}.marketrix-widget,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.marketrix-widget-container{z-index:var(--widget-z-index,1210);pointer-events:auto;position:fixed}.marketrix-widget,.marketrix-widget *,[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;box-sizing:border-box;transition:color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,opacity .2s ease-in-out,box-shadow .2s ease-in-out,transform .2s ease-in-out}.marketrix-widget button,.marketrix-widget input,.marketrix-widget textarea,.marketrix-widget select,[data-marketrix-widget] button,[data-marketrix-widget] input,[data-marketrix-widget] textarea,[data-marketrix-widget] select{font:inherit}[data-resizing=true],[data-resizing=true] *{transition:none!important}.gradient-border{border:2px solid;border-image:linear-gradient(to right, var(--foreground), var(--foreground)) 1}.marketrix-widget ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget * ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget * ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget{scrollbar-color:var(--muted) var(--muted-foreground);scrollbar-width:thin}.marketrix-widget ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget * ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget * ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button{background:0 0!important;border:none!important;width:0!important;height:0!important;display:none!important}@keyframes glow-border-pulse{0%,to{border-color:#fff9;box-shadow:0 0 #ffffff4d,0 0 #1f293766}50%{border-color:#fff;box-shadow:0 0 0 2px #fff9,0 0 0 4px #1f29374d}}@keyframes marketrix-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}.marketrix-screen-edge-glow,[data-screen-edge-glow]{animation:1.6s ease-in-out infinite marketrix-screen-edge-pulse}.marketrix-widget-button-processing-glow,.marketrix-widget-button-error-glow{pointer-events:none;filter:blur(14px);will-change:transform, opacity;border-radius:50%;width:140%;height:140%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}@keyframes widget-activity-dash-travel{0%{stroke-dashoffset:0;opacity:.5}18%{stroke-dashoffset:-112px;opacity:1}35%{stroke-dashoffset:-160px;opacity:.65}60%{stroke-dashoffset:-160px;opacity:.45}82%{stroke-dashoffset:-272px;opacity:1}to{stroke-dashoffset:-320px;opacity:.6}}.marketrix-widget-button-processing-activity-ring,.marketrix-widget-button-error-activity-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.marketrix-widget-button-processing-activity-ring rect,.marketrix-widget-button-error-activity-ring rect{fill:none;stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:40 120;animation:1.9s cubic-bezier(.4,0,.2,1) infinite widget-activity-dash-travel}.marketrix-widget-button-processing-activity-ring rect{stroke:#31d06d;filter:drop-shadow(0 0 3px #31d06db3)}.marketrix-widget-button-error-activity-ring rect{stroke:#d0342c;filter:drop-shadow(0 0 3px #d0342cb3)}@keyframes widget-glow-green{0%,to{opacity:.72;background:radial-gradient(circle,#31d06d00 38%,#31d06d61 58%,#31d06d3d 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle,#31d06d00 34%,#31d06d8c 56%,#31d06d54 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-processing-glow{animation:2s ease-in-out infinite widget-glow-green}@keyframes widget-glow-red{0%,to{opacity:.65;background:radial-gradient(circle,#d0342c00 38%,#d0342c57 58%,#d0342c38 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle,#d0342c00 34%,#d0342c80 56%,#d0342c4d 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-error-glow{animation:1.5s ease-in-out infinite widget-glow-red}@keyframes launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.animate-launcher-entrance{animation:.25s ease-out forwards launcher-entrance}@keyframes messenger-entrance{0%{opacity:0;transform:scale(0)}40%{opacity:1}to{transform:scale(1)}}@keyframes messenger-exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)translateY(8px)}}.animate-messenger-entrance{animation:.3s cubic-bezier(0,1.2,1,1) messenger-entrance}.animate-messenger-exit{animation:.2s cubic-bezier(.4,0,.2,1) forwards messenger-exit}@keyframes message-enter{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.animate-message-enter{animation:.2s ease-out message-enter}.view-slide-enter.forward{opacity:0;transform:translate(20px)}.view-slide-enter.back{opacity:0;transform:translate(-20px)}.view-slide-enter-active{opacity:1;transition:transform .15s .15s,opacity .15s .15s;transform:translate(0)}.view-slide-enter-active.forward,.view-slide-enter-active.back{opacity:1;transform:translate(0)}.view-slide-exit-active.forward{opacity:0;transition:transform .15s,opacity .15s;transform:translate(-20px)}.view-slide-exit-active.back{opacity:0;transition:transform .15s,opacity .15s;transform:translate(20px)}[data-view-transition][data-direction=forward]{animation:.3s both viewSlideForward}[data-view-transition][data-direction=back]{animation:.3s both viewSlideBack}@keyframes viewSlideForward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes viewSlideBack{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media print{.marketrix-widget{display:none!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}',Yx=null,Jx=null,Kx=null,Xx=!1,qx=!1,Qx=0,ek=(e,t)=>{const r=t||"marketrix-widget-container-"+ ++Qx;let n;if(e){if(e.querySelector(`#${r}`))throw new Error(`Widget container with ID ${r} already exists`);n=document.createElement("div"),n.id=r,n.className="marketrix-widget-container",n.style.width="100%",n.style.height="100%",n.style.position="relative",n.style.overflow="visible",e.appendChild(n)}else{if(document.getElementById(r))throw new Error(`Widget container with ID ${r} already exists`);n=document.createElement("div"),n.id=r,n.className="marketrix-widget-container",document.body.appendChild(n)}if(n.style.pointerEvents="auto",!Dx(n))throw new Error("Container is not an HTMLElement");if(n.shadowRoot)throw new Error("Container already has a shadow root");const i=n.attachShadow({mode:"closed"}),o=document.createElement("style");if(o.textContent=Gx,i.appendChild(o),i.querySelector("#marketrix-widget-root"))throw new Error("Mount element already exists in shadow root");const s=document.createElement("div");return s.id="marketrix-widget-root",s.style.pointerEvents="auto",s.style.width="100%",s.style.height="100%",s.style.position="relative",i.appendChild(s),{container:n,shadowRoot:i,mountEl:s}},tk=(e,r,n=!1)=>{const i=p(e);return i.render(/* @__PURE__ */m(t.StrictMode,{children:/* @__PURE__ */m(Cu,{previewMode:n,children:/* @__PURE__ */m(vu,{config:r})})})),i},rk=e=>{if(!e)throw new Error("Container is required");e.remove()},nk=()=>Jx,ik=()=>null!==Yx,ok=e=>{Xx=e},sk=()=>Xx,ak=()=>qx,lk=e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(Kx){const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove(),Kx.unmount(),Kx=null}if(document.getElementById("marketrix-widget-loader-container"))throw new Error("Widget loader container already exists");const r=document.createElement("div");r.id="marketrix-widget-loader-container",r.className="marketrix-widget-loader-container",document.body.appendChild(r);const n=r.attachShadow({mode:"closed"}),i=document.createElement("style");i.textContent=Gx,n.appendChild(i);const o=document.createElement("div");o.id="marketrix-widget-loader-root",n.appendChild(o);const s=p(o);Kx=s,s.render(/* @__PURE__ */m(t.StrictMode,{children:/* @__PURE__ */m(Hx,{message:e})}))},ck=()=>{if(Kx){Kx.unmount(),Kx=null;const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove()}},dk=null,uk=(e=0)=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;const t=[0,100,500,1e3,2e3];if(!dk)return;const r=document.querySelectorAll("script[mtx-id], script[mtx-app]"),n=(void 0!==document.currentScript&&null!=document.currentScript&&$x(document.currentScript)&&(document.currentScript.hasAttribute("mtx-id")||document.currentScript.hasAttribute("mtx-app"))?document.currentScript:null)??r[r.length-1];if(!n||!$x(n)){if(0===r.length)return void(ik()||sk());if(e<5){return void setTimeout(()=>uk(e+1),t[e]||2e3)}if(ik()||sk())return;return void lk("Please configure mtx-id and mtx-key, or mtx-app and mtx-agent")}const i=n,o=i.getAttribute("mtx-id"),s=i.getAttribute("mtx-key"),a=i.getAttribute("mtx-api-host"),l=i.getAttribute("mtx-app"),c=i.getAttribute("mtx-agent"),d=i.getAttribute("mtx-use-screenshare");if(o&&s){const e={mtxId:o,mtxKey:s};a&&(e.mtxApiHost=a),"false"===d&&(e.use_screenshare=!1),dk(e).catch(e=>{})}else if(l&&c){const e=Number.parseInt(l),t=Number.parseInt(c);if(isNaN(e)||isNaN(t))return void lk("Invalid mtx-app or mtx-agent values");const r={mtxApp:e,mtxAgent:t};a&&(r.mtxApiHost=a),"false"===d&&(r.use_screenshare=!1),dk(r).catch(e=>{})}else{if(ik()||sk())return;lk("Please configure mtx-id and mtx-key, or mtx-app and mtx-agent")}},hk=null,pk=!1,fk=!1,mk=null,gk=null,yk=null;async function wk(e,t){if(ok(!0),ik())return void ok(!1);if(ak())return void ok(!1);window.__mtx={state:"initializing"},e.mtxApiHost&&Ss(e.mtxApiHost),lk("Validating widget configuration...");const r=await(new Px).validateConfig(e);if(!r.isValid)return lk(r.error||"Widget validation failed. Please check your configuration."),ok(!1),void(window.__mtx=void 0);let n;try{n=await async function(e,t){if(!t.isValid)throw new Error(t.error||"Widget validation failed");lk("Loading widget settings...");try{const t=new jx(e.mtxId,e.mtxKey,e.mtxApp),r=await t.fetchWidgetSettings(),n=r?t.getWidgetSettings(r):null;if(!n)throw new Error("WidgetService did not return widget settings");const i=["widget_enabled","widget_appearance","widget_position","widget_device","widget_header","widget_body","widget_greeting","widget_feature_tell","widget_feature_show","widget_feature_do","widget_feature_human","widget_background_color","widget_text_color","widget_border_color","widget_accent_color","widget_secondary_color","widget_border_radius","widget_font_size","widget_width","widget_height","widget_shadow","widget_animation_duration","widget_fade_duration","widget_bounce_effect","widget_chips"].filter(e=>void 0===n[e]);if(i.length>0)throw new Error(`Widget settings are incomplete. Missing required fields: ${i.join(", ")}. The API must return all widget settings.`);return ta(n,e)}catch(zk){throw zk}finally{ck()}}(e,r)}catch(s){return lk(s instanceof Error?s.message:"Failed to initialize widget"),ok(!1),void(window.__mtx=void 0)}(e=>{Jx=e})(n);const{mountEl:i}=ek(t);var o;o=tk(i,n),Yx=o,qx=!0,ok(!1),window.__mtx={state:"active"};try{if(hk&&pk)return;hk&&(hk.stop(),hk=null,pk=!1),yk=new AbortController;const t=(e,t)=>{if(!(hk&&pk||fk)){fk=!0;try{hk=new Tx(t,e),pk=!0;const r=hk;mk=r.start().catch(e=>{hk===r&&(pk=!1)}).finally(()=>{fk=!1,hk===r&&(mk=null)})}catch{fk=!1}}},r=e=>{const r=Ws.getChatId();r?t(e,r):window.addEventListener("marketrix:chatid",()=>{const r=Ws.getChatId();r&&t(e,r)},{once:!0,signal:yk?.signal})},i=n.mtxApp??e.mtxApp;if(i)r(i);else{const e=qs.getInstance(),t={onRegistered:n=>{n&&r(n),e.removeCallbacks(t)}};e.addCallbacks(t)}}catch(s){pk=!1}}var bk=!1,vk=async(e,t)=>{if(!window.__mtx?.state){if(gk)return gk;if(bk)return Promise.resolve();if(!ik()&&!ak()){gk=wk(e,t),bk=!0;try{await gk}finally{gk=null,bk=!1}}}},xk=()=>{if(Yx){Yx.unmount(),Yx=null,Jx=null,qx=!1;const e=document.querySelector(".marketrix-widget-container");e&&rk(e)}yk?.abort(),yk=null,hk&&(hk.stop(),hk=null,pk=!1,fk=!1,mk=null),gk=null,window.__mtx=void 0,ck()},kk=()=>{hk&&hk.stop()},Sk=async()=>{if(!hk)throw new Error("Session recording not available. Ensure the widget is initialized with mtxApiHost and mtxApp.");if(mk&&(await mk.catch(()=>{}),hk?.isActive()))return;if(hk.isActive())return;const e=hk.start();mk=e;try{await e}finally{mk===e&&(mk=null)}},Ck=()=>hk?.isActive()??!1,Ik=async e=>{if(ik()){const t=nk();if(!t)throw new Error("Widget not initialized");const r={...t,...e};xk(),await vk(r)}},_k=({settings:e,container:t,mtxId:r,mtxKey:n,mtxApiHost:i})=>{const o=u(null),s=u(null),l=u(null),c=u(null);return a(()=>{const a=t??o?.current?.parentElement??document.body;if(!a||!Dx(a))return;c.current||(c.current=`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);const{container:d,mountEl:u}=ek(a,c.current);l.current=d;const h={...ta(e,{mtxId:r,mtxKey:n,mtxApiHost:i}),isPreviewMode:!0,widget_enabled:e.widget_enabled??!0};s.current&&(s.current.unmount(),s.current=null);const f=p(u);return s.current=f,f.render(/* @__PURE__ */m(Cu,{previewMode:!0,children:/* @__PURE__ */m(vu,{config:h})})),()=>{s.current&&(s.current.unmount(),s.current=null),l.current&&(rk(l.current),l.current=null,c.current=null)}},[e,t]),t?null:/* @__PURE__ */m("div",{ref:o,style:{width:"100%",height:"100%",position:"relative"}})},Ak=async e=>{ok(!0);const t=e.container;if("settings"in e&&void 0!==e.settings){const{settings:r,container:n,...i}=e,o={...ta(r,i),isPreviewMode:!0},{mountEl:s}=ek(t);tk(s,o,!0),ok(!1)}else if("mtxId"in e&&void 0!==e.mtxId&&void 0!==e.mtxKey){const{mtxId:r,mtxKey:n,container:i,...o}=e;await vk({mtxId:r,mtxKey:n,...o},t)}else{if(!("mtxApp"in e)||void 0===e.mtxApp||void 0===e.mtxAgent)throw ok(!1),new Error("Invalid configuration: provide either settings (preview), mtxId+mtxKey (production), or mtxApp+mtxAgent (dev)");{const{mtxApp:r,mtxAgent:n,container:i,...o}=e;await vk({mtxApp:r,mtxAgent:n,...o},t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{"function"==typeof e&&(dk=e,uk())})(vk)}catch(e){}},0);var Ek={MarketrixWidget:_k,mountWidget:Ak,initWidget:vk,unmountWidget:xk,updateMarketrixConfig:Ik,getCurrentConfig:nk,startRecording:Sk,stopRecording:kk,getRecordingState:Ck};export{_k as MarketrixWidget,Ek as default,nk as getCurrentConfig,Ck as getRecordingState,vk as initWidget,Ak as mountWidget,Sk as startRecording,kk as stopRecording,xk as unmountWidget,Ik as updateMarketrixConfig};
1
+ import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as a,useEffect as s,useId as c,useLayoutEffect as l,useMemo as d,useRef as u,useState as p}from"react";import{createRoot as h}from"react-dom/client";import{Fragment as m,jsx as f,jsxs as g}from"react/jsx-runtime";var y=2147483002,w=2147483001,b=2147483005;function v(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function x(e){return function(e){const t=v(e);if(!t)return.5;const[n,r,o]=[t.r/255,t.g/255,t.b/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*n+.7152*r+.0722*o}(e)>.5?"#000000":"#ffffff"}function k(e,t){if(e.startsWith("rgba")||e.startsWith("rgb")){const n=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t})`}const n=v(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`:(e.includes("gradient")||e.includes("linear-gradient"),e)}function _(e,t){const n=v(e);if(!n)return e;const r=1-t;return o=Math.round(n.r*r),i=Math.round(n.g*r),a=Math.round(n.b*r),`#${[o,i,a].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var o,i,a}var S=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),I=e=>{switch(e){case"show":return"Show";case"tell":return"Tell";case"do":return"Do";default:return e}},C={widget_background_color:"#ffffff",widget_text_color:"#1f2937",widget_border_color:"#e5e7eb",widget_accent_color:"#3b82f6",widget_secondary_color:"#6b7280",widget_border_radius:"20px",widget_font_size:"14px",widget_width:"400px",widget_height:"600px",widget_shadow:"0 5px 40px 0 rgba(0, 0, 0, 0.3)",widget_animation_duration:"300ms",widget_fade_duration:"200ms"};function E(e){return{color:{background:e.widget_background_color,foreground:e.widget_text_color,foregroundMuted:k(e.widget_text_color,.6),foregroundFaint:k(e.widget_text_color,.4),border:e.widget_border_color,borderMuted:k(e.widget_border_color,.3),primary:e.widget_accent_color,primaryForeground:x(e.widget_accent_color),primaryHover:k(e.widget_accent_color,.85),primaryMuted:k(e.widget_accent_color,.3),secondary:e.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:k(e.widget_secondary_color,.2),secondaryHover:k(e.widget_secondary_color,.3)},radius:e.widget_border_radius,shadow:e.widget_shadow,typography:{fontSizeBase:e.widget_font_size},motion:{durationAnimation:e.widget_animation_duration,durationFade:e.widget_fade_duration},size:{widgetWidth:e.widget_width,widgetHeight:e.widget_height}}}E(C);function M(e){return Array.isArray(e)?e:null==e?[]:[e]}var z="orpc",T=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function A(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function O(){return globalThis["__@orpc/shared@1.14.5/otel/config__"]}function N(e,t={},n){return(O()?.tracer)?.startSpan(e,t,n)}function R(e,t,n={}){if(!e)return;const r=function(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(r),n.signal?.aborted&&n.signal.reason===t||e.setStatus({code:2,message:r.message})}async function L({name:e,context:t,...n},r){const o=O()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw R(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function $(e,t){const n=O();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function P(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var D=Symbol.asyncDispose??Symbol.for("asyncDispose"),j=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=function(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}(async()=>{if(this.#e)return{done:!0,value:void 0};try{const t=await e();return t.done&&(this.#e=!0),t}catch(t){throw this.#e=!0,t}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),e}async[D](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function F({name:e,...t},n){let r;return new j(async()=>{r??=N(e);try{const e=await $(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw R(r,o,t),o}},async e=>{try{"next"!==e&&await $(r,()=>n.return?.())}catch(o){throw R(r,o,t),o}finally{r?.end()}})}function B(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 W(e){if(e)return JSON.parse(e)}function U(e){return JSON.stringify(e)}function H(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function V(e){return!!e&&("object"==typeof e||"function"==typeof e)}function Z(e,...t){return"function"==typeof e?e(...t):e}function q(e){return new Proxy(e,{get(e,t,n){const r=Reflect.get(e,t,n);return"then"!==t||"function"!=typeof r?r:new Proxy(r,{apply(t,n,r){if(2!==r.length||r.some(e=>{return!("function"==typeof(t=e)&&G.test(t.toString()));var t}))return Reflect.apply(t,n,r);let o=!0;r[0].call(n,q(new Proxy(e,{get:(e,t,n)=>{if(!o||"then"!==t)return Reflect.get(e,t,n);o=!1}})))}})}})}var G=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var J,K={BAD_REQUEST:{status:400,message:"Bad Request"},UNAUTHORIZED:{status:401,message:"Unauthorized"},FORBIDDEN:{status:403,message:"Forbidden"},NOT_FOUND:{status:404,message:"Not Found"},METHOD_NOT_SUPPORTED:{status:405,message:"Method Not Supported"},NOT_ACCEPTABLE:{status:406,message:"Not Acceptable"},TIMEOUT:{status:408,message:"Request Timeout"},CONFLICT:{status:409,message:"Conflict"},PRECONDITION_FAILED:{status:412,message:"Precondition Failed"},PAYLOAD_TOO_LARGE:{status:413,message:"Payload Too Large"},UNSUPPORTED_MEDIA_TYPE:{status:415,message:"Unsupported Media Type"},UNPROCESSABLE_CONTENT:{status:422,message:"Unprocessable Content"},TOO_MANY_REQUESTS:{status:429,message:"Too Many Requests"},CLIENT_CLOSED_REQUEST:{status:499,message:"Client Closed Request"},INTERNAL_SERVER_ERROR:{status:500,message:"Internal Server Error"},NOT_IMPLEMENTED:{status:501,message:"Not Implemented"},BAD_GATEWAY:{status:502,message:"Bad Gateway"},SERVICE_UNAVAILABLE:{status:503,message:"Service Unavailable"},GATEWAY_TIMEOUT:{status:504,message:"Gateway Timeout"}};var Y=class e extends Error{defined;code;status;data;static{const t=Symbol.for("__@orpc/client@1.14.5/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(J=globalThis[t]).add(e)}constructor(e,...t){const n=function(e){return e[0]??{}}(t);if(void 0!==n.status&&!X(n.status))throw new Error("[ORPCError] Invalid error status code.");const r=function(e,t){return t||K[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??K[e]?.status??500}(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(J.has(this)){const t=function(e){return V(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&J.has(t))return!0}return super[Symbol.hasInstance](e)}};function X(e){return e<200||e>=400}function Q(e){if(!H(e))return!1;const t=["defined","code","status","message","data"];return!Object.keys(e).some(e=>!t.includes(e))&&("defined"in e&&"boolean"==typeof e.defined&&"code"in e&&"string"==typeof e.code&&"status"in e&&"number"==typeof e.status&&X(e.status)&&"message"in e&&"string"==typeof e.message)}function ee(e,t={}){return new Y(e.code,{...t,...e})}var te=class extends TypeError{},ne=class extends TypeError{},re=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}};function oe(e){const t=e.replace(/\n+$/,"").split(/\n/),n={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const r of t){const e=r.indexOf(":"),t=-1===e?r:r.slice(0,e),o=-1===e?"":r.slice(e+1).replace(/^\s/,"");if(0===e)n.comments.push(o);else if("data"===t)n.data??="",n.data+=`${o}\n`;else if("event"===t)n.event=o;else if("id"===t)n.id=o;else if("retry"===t){const e=Number.parseInt(o);Number.isInteger(e)&&e>=0&&e.toString()===o&&(n.retry=e)}}return n.data=n.data?.replace(/\n$/,""),n}var ie=class{constructor(e={}){this.options=e}incomplete="";feed(e){this.incomplete+=e;const t=this.incomplete.lastIndexOf("\n\n");if(-1===t)return;const n=this.incomplete.slice(0,t).split(/\n\n/);this.incomplete=this.incomplete.slice(t+2);for(const r of n){const e=oe(`${r}\n\n`);this.options.onEvent&&this.options.onEvent(e)}}end(){if(this.incomplete)throw new ne("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new ie({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function se(e){if(e.includes("\n"))throw new te("Event's id must not contain a newline character")}function ce(e){if(!Number.isInteger(e)||e<0)throw new te("Event's retry must be a integer and >= 0")}function le(e){if(e.includes("\n"))throw new te("Event's comment must not contain a newline character")}function de(e){let t="";return t+=function(e){let t="";for(const n of e??[])le(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new te("Event's event must not contain a newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(ce(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(se(e.id),t+=`id: ${e.id}\n`),t+=function(e){const t=e?.split(/\n/)??[];let n="";for(const r of t)n+=`data: ${r}\n`;return n}(e.data),t+="\n",t}var ue=Symbol("ORPC_EVENT_SOURCE_META");function pe(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&se(t.id),void 0!==t.retry&&ce(t.retry),void 0!==t.comments)for(const n of t.comments)le(n);return new Proxy(e,{get:(e,n,r)=>n===ue?t:Reflect.get(e,n,r)})}function he(e){return V(e)?Reflect.get(e,ue):void 0}function me(e){const t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&"string"==typeof t[2])return function(e){try{return decodeURIComponent(e)}catch{return e}}(t[2]);const n=e.match(/filename="((?:\\"|[^"])*)"/i);return n&&"string"==typeof n[1]?n[1].replace(/\\"/g,'"'):void 0}function fe(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=he(e);t&&V(n)&&(n=pe(n,t))}return n};return new j(async()=>{const{done:r,value:o}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let i=await t.value(o,r);if(i!==o){const e=he(o);e&&V(i)&&(i=pe(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function ge(e,t={}){const n=t.path??[];return q(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,o)=>"string"!=typeof o?Reflect.get(r,o):ge(e,{...t,path:[...n,o]})}))}function ye(e,t={}){return L({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=me(n)??"blob",r=await e.blob();return new File([r],t,{type:r.type})}const r=e.headers.get("content-type");if(!r||r.startsWith("application/json"))return W(await e.text());if(r.startsWith("multipart/form-data"))return await e.formData();if(r.startsWith("application/x-www-form-urlencoded")){const t=await e.text();return new URLSearchParams(t)}if(r.startsWith("text/event-stream"))return function(e,t={}){const n=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new ae))?.getReader();let r,o=!1;return new j(async()=>{r??=N("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await $(r,()=>n.read());if(e){if(o)throw new T("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=W(t.data);return V(e)&&(e=pe(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new re({data:W(t.data)});throw e=pe(e,t),r?.addEvent("error"),e}case"done":{let e=W(t.data);return V(e)&&(e=pe(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof re||R(r,e,t),e}},async e=>{try{"next"!==e&&(o=!0,r?.addEvent("cancelled")),await $(r,()=>n?.cancel())}catch(i){throw R(r,i,t),i}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const o=await e.blob();return new File([o],"blob",{type:o.type})})}function we(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:P(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,a=t.eventIteratorInitialComment??"";let s,c,l=!1;return new ReadableStream({start(e){c=N("stream_event_iterator"),i&&e.enqueue(de({comments:[a]}))},async pull(t){try{n&&(s=setInterval(()=>{t.enqueue(de({comments:[o]})),c?.addEvent("keepalive")},r));const i=await $(c,()=>e.next());if(clearInterval(s),l)return;const a=he(i.value);if(!i.done||void 0!==i.value||void 0!==a){const e=i.done?"done":"message";t.enqueue(de({...a,event:e,data:U(i.value)})),c?.addEvent(e)}i.done&&(t.close(),c?.end())}catch(i){if(clearInterval(s),l)return;i instanceof re?(t.enqueue(de({...he(i),event:"error",data:U(i.data)})),c?.addEvent("error"),t.close()):(R(c,i),t.error(i)),c?.end()}},async cancel(){try{l=!0,clearInterval(s),c?.addEvent("cancelled"),await $(c,()=>e.return?.())}catch(t){throw R(c,t),t}finally{c?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),U(e)):void 0}function be(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):void 0!==t[n]?t[n]=[t[n],e]:t[n]=e}),t}function ve(e,t={}){const n=function(e,t=new Headers){for(const[n,r]of Object.entries(e))if(Array.isArray(r))for(const e of r)t.append(n,e);else void 0!==r&&t.append(n,r);return t}(e.headers),r=we(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}var xe=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(const t of this.plugins)t.init?.(e)}},ke=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new xe(n.plugins).init(n),this.interceptors=M(n.interceptors),this.clientInterceptors=M(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return L({name:`${z}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",z),r?.setAttribute("rpc.method",e.join(".")),P(t)&&(t=F({name:"consume_event_iterator_input",signal:n.signal},t)),B(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=O();let i;const a=o?.trace.getActiveSpan()??r;a&&o&&(i=o?.trace.setSpan(o.context.active(),a));const s=await L({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await B(this.clientInterceptors,{...n,input:t,path:e,request:s},({input:e,path:t,request:n,...r})=>L({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await L({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return P(l)?F({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},_e=0,Se=1,Ie=2,Ce=3,Ee=4,Me=5,ze=6,Te=7,Ae=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],n=[],r=[],o=[]){for(const i of this.customSerializers)if(i.condition(e)){const a=this.serialize(i.serialize(e),t,n,r,o);return n.push([i.type,...t]),a}if(e instanceof Blob)return r.push(t),o.push(e),[e,n,r,o];if("bigint"==typeof e)return n.push([_e,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([Se,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([Ie,...t]),[null,n,r,o];if(e instanceof URL)return n.push([Ee,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([Me,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([ze,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([Te,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([Ce,...t,i]),null):this.serialize(e,[...t,i],n,r,o)[0]),n,r,o];if(H(e)){const i={};for(const a in e)"toJSON"===a&&"function"==typeof e[a]||(i[a]=this.serialize(e[a],[...t,a],n,r,o)[0]);return[i,n,r,o]}return[e,n,r,o]}deserialize(e,t,n,r){const o={data:e};n&&r&&n.forEach((e,t)=>{let n=o,i="data";e.forEach(e=>{if(n=n[i],i=e,!Object.hasOwn(n,i))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${i}`)}),n[i]=r(t)});for(const i of t){const e=i[0];let t=o,n="data";for(let r=1;r<i.length;r++)if(t=t[n],n=i[r],!Object.hasOwn(t,n))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${n}`);for(const r of this.customSerializers)if(r.type===e){t[n]=r.deserialize(t[n]);break}switch(e){case _e:t[n]=BigInt(t[n]);break;case Se:t[n]=new Date(t[n]??"Invalid Date");break;case Ie:t[n]=NaN;break;case Ce:t[n]=void 0;break;case Ee:t[n]=new URL(t[n]);break;case Me:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case ze:t[n]=new Set(t[n]);break;case Te:t[n]=new Map(t[n])}}return o.data}};var Oe,Ne=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??"POST",this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=function(e){return"function"==typeof e.forEach?be(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]=[...M(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),a=new URL(i);a.pathname=`${a.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const s=this.serializer.serialize(t);if(!("GET"!==o||s instanceof FormData||P(s))){const i=await Z(this.maxUrlLength,n,e,t),c=new URL(a);if(c.searchParams.append("data",U(s)),c.toString().length<=i)return{body:void 0,method:o,headers:r,url:c,signal:n.signal}}return{url:a,method:"GET"===o?this.fallbackMethod:o,headers:r,body:s,signal:n.signal}}async decode(e){const t=!X(e.status),n=await(async()=>{let t=!1;try{const n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(n){if(!t)throw new Error("Cannot parse response body, please check the response body and content-type.",{cause:n});throw new Error("Invalid RPC response format.",{cause:n})}})();if(!t){if(Q(n))throw ee(n);throw new Y((r=e.status,Object.entries(K).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},Re=class{constructor(e){this.jsonSerializer=e}serialize(e){return P(e)?fe(e,{value:async e=>this.#o(e,!1),error:async e=>{return new re({data:this.#o((t=e,t instanceof Y?t:new Y("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#o(e,!0)}#o(e,t){const[n,r,o,i]=this.jsonSerializer.serialize(e),a=0===r.length?void 0:r;if(!t||0===i.length)return{json:n,meta:a};const s=new FormData;return s.set("data",U({json:n,meta:a,maps:o})),i.forEach((e,t)=>{s.set(t.toString(),e)}),s}deserialize(e){return P(e)?fe(e,{value:async e=>this.#i(e),error:async e=>{if(!(e instanceof re))return e;const t=this.#i(e.data);return Q(t)?ee(t,{cause:e}):new re({data:t,cause:e})}}):this.#i(e)}#i(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},Le=class extends ke{constructor(e,t){super(new Ne(new Re(new Ae(t)),t),e,t)}},$e=class extends xe{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},Pe=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new $e(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=M(e.adapterInterceptors)}async call(e,t,n,r){const o=ve(e,this.toFetchRequestOptions);return function(e,t={}){return{body:A(()=>ye(e,t)),status:e.status,get headers(){const t=be(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await B(this.adapterInterceptors,{...t,request: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})}},De=class extends Le{constructor(e){super(new Pe(e),e)}};function je(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:a,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=a.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function a(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var Fe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Be=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Oe=globalThis).__zod_globalConfig??(Oe.__zod_globalConfig={});var We=globalThis.__zod_globalConfig;function Ue(e){return e&&Object.assign(We,e),We}function He(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Ve(e,t){return"bigint"==typeof t?t.toString():t}function Ze(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qe(e){return null==e}function Ge(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Je=/* @__PURE__*/Symbol("evaluating");function Ke(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Je)return void 0===r&&(r=Je,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ye(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xe(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}var et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var nt=/* @__PURE__*/Ze(()=>{if(We.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function rt(e){if(!1===tt(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==tt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function ot(e){return rt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var it=/* @__PURE__*/new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function st(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function ct(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}var lt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function dt(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function ut(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function pt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ht(e){return"string"==typeof e?e:e?.message}function mt(e,t,n){const r=e.message?e.message:ht(e.inst?._zod.def?.error?.(e))??ht(t?.error?.(e))??ht(n.customError?.(e))??ht(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...s}=e;return s.path??(s.path=[]),s.message=r,t?.reportInput&&(s.input=a),s}function ft(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function gt(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var yt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wt=je("$ZodError",yt),bt=je("$ZodError",yt,{Parent:Error});var vt=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Fe;if(a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>mt(e,i,Ue())));throw et(t,o?.callee),t}return a.value},xt=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>mt(e,i,Ue())));throw et(t,o?.callee),t}return a.value},kt=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Fe;return i.issues.length?{success:!1,error:new(e??wt)(i.issues.map(e=>mt(e,o,Ue())))}:{success:!0,data:i.value}},_t=/* @__PURE__*/kt(bt),St=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>mt(e,o,Ue())))}:{success:!0,data:i.value}},It=/* @__PURE__*/St(bt),Ct=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return vt(e)(t,n,o)},Et=e=>(t,n,r)=>vt(e)(t,n,r),Mt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return xt(e)(t,n,o)},zt=e=>async(t,n,r)=>xt(e)(t,n,r),Tt=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kt(e)(t,n,o)},At=e=>(t,n,r)=>kt(e)(t,n,r),Ot=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return St(e)(t,n,o)},Nt=e=>async(t,n,r)=>St(e)(t,n,r),Rt=/^[cC][0-9a-z]{6,}$/,Lt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pt=/^[0-9a-vA-V]{20}$/,Dt=/^[A-Za-z0-9]{27}$/,jt=/^[a-zA-Z0-9_-]{21}$/,Ft=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Wt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ut=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Ht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Zt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,qt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Gt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,Kt=/^https?$/,Yt=/^\+[1-9]\d{6,14}$/,Xt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Qt=/*@__PURE__*/new RegExp(`^${Xt}$`);function en(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}var tn=/^-?\d+$/,nn=/^-?\d+(?:\.\d+)?$/,rn=/^(?:true|false)$/i,on=/^null$/i,an=/^[^A-Z]*$/,sn=/^[^a-z]*$/,cn=/*@__PURE__*/je("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ln={number:"number",bigint:"bigint",object:"date"},dn=/*@__PURE__*/je("$ZodCheckLessThan",(e,t)=>{cn.init(e,t);const n=ln[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),un=/*@__PURE__*/je("$ZodCheckGreaterThan",(e,t)=>{cn.init(e,t);const n=ln[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pn=/*@__PURE__*/je("$ZodCheckMultipleOf",(e,t)=>{cn.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value!==BigInt(0):0!==function(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(n.value,t.value))&&n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),hn=/*@__PURE__*/je("$ZodCheckNumberFormat",(e,t)=>{cn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=lt[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=tn)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/je("$ZodCheckMaxLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=ft(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fn=/*@__PURE__*/je("$ZodCheckMinLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=ft(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gn=/*@__PURE__*/je("$ZodCheckLengthEquals",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!qe(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=ft(r),a=o>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yn=/*@__PURE__*/je("$ZodCheckStringFormat",(e,t)=>{var n,r;cn.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=/* @__PURE__ */new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),wn=/*@__PURE__*/je("$ZodCheckRegex",(e,t)=>{yn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bn=/*@__PURE__*/je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=an),yn.init(e,t)}),vn=/*@__PURE__*/je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=sn),yn.init(e,t)}),xn=/*@__PURE__*/je("$ZodCheckIncludes",(e,t)=>{cn.init(e,t);const n=at(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),kn=/*@__PURE__*/je("$ZodCheckStartsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`^${at(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),_n=/*@__PURE__*/je("$ZodCheckEndsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`.*${at(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Sn=/*@__PURE__*/je("$ZodCheckOverwrite",(e,t)=>{cn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),In=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},Cn={major:4,minor:4,patch:3},En=/*@__PURE__*/je("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cn;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let r,o=dt(e);for(const i of t){if(i._zod.def.when){if(ut(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new Fe;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(o||(o=dt(e,t)))});else{if(e.issues.length===t)continue;o||(o=dt(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(dt(n))return n.aborted=!0,n;const a=t(o,r,i);if(a instanceof Promise){if(!1===i.async)throw new Fe;return a.then(t=>e._zod.parse(t,i))}return e._zod.parse(a,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,i)):n(t,o,i)}const a=e._zod.parse(o,i);if(a instanceof Promise){if(!1===i.async)throw new Fe;return a.then(e=>t(e,r,i))}return t(a,r,i)}}Ke(e,"~standard",()=>({validate:t=>{try{const n=_t(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return It(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Mn=/*@__PURE__*/je("$ZodString",(e,t)=>{var n;En.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),zn=/*@__PURE__*/je("$ZodStringFormat",(e,t)=>{yn.init(e,t),Mn.init(e,t)}),Tn=/*@__PURE__*/je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bt),zn.init(e,t)}),An=/*@__PURE__*/je("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wt(e))}else t.pattern??(t.pattern=Wt());zn.init(e,t)}),On=/*@__PURE__*/je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ut),zn.init(e,t)}),Nn=/*@__PURE__*/je("$ZodURL",(e,t)=>{zn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Kt.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Rn=/*@__PURE__*/je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),zn.init(e,t)}),Ln=/*@__PURE__*/je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jt),zn.init(e,t)}),$n=/*@__PURE__*/je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Rt),zn.init(e,t)}),Pn=/*@__PURE__*/je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),zn.init(e,t)}),Dn=/*@__PURE__*/je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$t),zn.init(e,t)}),jn=/*@__PURE__*/je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Pt),zn.init(e,t)}),Fn=/*@__PURE__*/je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Dt),zn.init(e,t)}),Bn=/*@__PURE__*/je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=en({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Xt}T(?:${r})$`)}(t)),zn.init(e,t)}),Wn=/*@__PURE__*/je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qt),zn.init(e,t)}),Un=/*@__PURE__*/je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${en(t)}$`)),zn.init(e,t)}),Hn=/*@__PURE__*/je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ft),zn.init(e,t)}),Vn=/*@__PURE__*/je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ht),zn.init(e,t),e._zod.bag.format="ipv4"}),Zn=/*@__PURE__*/je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vt),zn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),qn=/*@__PURE__*/je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Zt),zn.init(e,t)}),Gn=/*@__PURE__*/je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=qt),zn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Jn(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Kn=/*@__PURE__*/je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Gt),zn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Jn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Yn=/*@__PURE__*/je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jt),zn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Jt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Jn(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Yt),zn.init(e,t)});var Qn=/*@__PURE__*/je("$ZodJWT",(e,t)=>{zn.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),er=/*@__PURE__*/je("$ZodNumber",(e,t)=>{En.init(e,t),e._zod.pattern=e._zod.bag.pattern??nn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),tr=/*@__PURE__*/je("$ZodNumberFormat",(e,t)=>{hn.init(e,t),er.init(e,t)}),nr=/*@__PURE__*/je("$ZodBoolean",(e,t)=>{En.init(e,t),e._zod.pattern=rn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),rr=/*@__PURE__*/je("$ZodNull",(e,t)=>{En.init(e,t),e._zod.pattern=on,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const r=t.value;return null===r||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),t}}),or=/*@__PURE__*/je("$ZodUnknown",(e,t)=>{En.init(e,t),e._zod.parse=e=>e}),ir=/*@__PURE__*/je("$ZodNever",(e,t)=>{En.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ar=/*@__PURE__*/je("$ZodDate",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(a){}const o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function sr(e,t,n){e.issues.length&&t.issues.push(...pt(n,e.issues)),t.value[n]=e.value}var cr=/*@__PURE__*/je("$ZodArray",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const a=o[e],s=t.element._zod.run({value:a,issues:[]},r);s instanceof Promise?i.push(s.then(t=>sr(t,n,e))):sr(s,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function lr(e,t,n,r,o,i){const a=n in r;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...pt(n,e.issues))}a||o?void 0===e.value?a&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function dr(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ur(e,t,n,r,o,i){const a=[],s=o.keySet,c=o.catchall._zod,l=c.def.type,d="optional"===c.optin,u="optional"===c.optout;for(const p in t){if("__proto__"===p)continue;if(s.has(p))continue;if("never"===l){a.push(p);continue}const o=c.run({value:t[p],issues:[]},r);o instanceof Promise?e.push(o.then(e=>lr(e,n,p,t,d,u))):lr(o,n,p,t,d,u)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var pr=/*@__PURE__*/je("$ZodObject",(e,t)=>{if(En.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=Ze(()=>dr(t));Ke(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */new Set);for(const e of r.values)n[t].add(e)}}return n});const r=tt,o=t.catchall;let i;e._zod.parse=(t,a)=>{i??(i=n.value);const s=t.value;if(!r(s))return t.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),t;t.value={};const c=[],l=i.shape;for(const e of i.keys){const n=l[e],r="optional"===n._zod.optin,o="optional"===n._zod.optout,i=n._zod.run({value:s[e],issues:[]},a);i instanceof Promise?c.push(i.then(n=>lr(n,t,e,s,r,o))):lr(i,t,e,s,r,o)}return o?ur(c,s,t,a,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),hr=/*@__PURE__*/je("$ZodObjectJIT",(e,t)=>{pr.init(e,t);const n=e._zod.parse,r=Ze(()=>dr(t));let o;const i=tt,a=!We.jitless,s=a&&nt.value,c=t.catchall;let l;e._zod.parse=(d,u)=>{l??(l=r.value);const p=d.value;return i(p)?a&&s&&!1===u?.async&&!0!==u.jitless?(o||(o=(e=>{const t=new In(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Qe(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let a=0;for(const r of n.keys)i[r]="key_"+a++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],a=Qe(r),s=e[r],c="optional"===s?._zod?.optin,l="optional"===s?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&l?t.write(`\n if (${n}.issues.length) {\n if (${a} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${a} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${a}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${a}] = undefined;\n } else {\n newResult[${a}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,n)=>s(e,t,n)})(t.shape)),d=o(d,u),c?ur([],p,d,u,l,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function mr(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter(e=>!dt(e));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>mt(e,r,Ue())))}),t)}var fr=/*@__PURE__*/je("$ZodUnion",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Ke(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Ke(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ke(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Ge(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>mr(t,r,e,o)):mr(a,r,e,o)}}),gr=/*@__PURE__*/je("$ZodIntersection",(e,t)=>{En.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>wr(e,t,n)):wr(e,o,i)}});function yr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(rt(e)&&rt(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const i of r){const n=yr(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=yr(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function wr(e,t,n){const r=/* @__PURE__ */new Map;let o;for(const s of t.issues)if("unrecognized_keys"===s.code){o??(o=s);for(const e of s.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(s);for(const s of n.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(s);const i=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&o&&e.issues.push({...o,keys:i}),dt(e))return e;const a=yr(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var br=/*@__PURE__*/je("$ZodRecord",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!rt(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const s=/* @__PURE__ */new Set;for(const l of a)if("string"==typeof l||"number"==typeof l||"symbol"==typeof l){s.add("number"==typeof l?l.toString():l);const a=t.keyType._zod.run({value:l,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>mt(e,r,Ue())),input:l,path:[l],inst:e});continue}const c=a.value,d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(e=>{e.issues.length&&n.issues.push(...pt(l,e.issues)),n.value[c]=e.value})):(d.issues.length&&n.issues.push(...pt(l,d.issues)),n.value[c]=d.value)}let c;for(const e in o)s.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(o,a))continue;let s=t.keyType._zod.run({value:a,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&nn.test(a)&&s.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>mt(e,r,Ue())),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:o[a],issues:[]},r);c instanceof Promise?i.push(c.then(e=>{e.issues.length&&n.issues.push(...pt(a,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...pt(a,c.issues)),n.value[s.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),vr=/*@__PURE__*/je("$ZodEnum",(e,t)=>{En.init(e,t);const n=He(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>it.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),xr=/*@__PURE__*/je("$ZodLiteral",(e,t)=>{if(En.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?at(e):e?at(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),kr=/*@__PURE__*/je("$ZodTransform",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Be(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new Fe;return n.value=o,n.fallback=!0,n}});function _r(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Sr=/*@__PURE__*/je("$ZodOptional",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ke(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ge(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>_r(e,r)):_r(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ir=/*@__PURE__*/je("$ZodExactOptional",(e,t)=>{Sr.init(e,t),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Cr=/*@__PURE__*/je("$ZodNullable",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.innerType._zod.optin),Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ge(e.source)}|null)$`):void 0}),Ke(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Er=/*@__PURE__*/je("$ZodDefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Mr(e,t)):Mr(r,t)}});function Mr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var zr=/*@__PURE__*/je("$ZodPrefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Tr=/*@__PURE__*/je("$ZodNonOptional",(e,t)=>{En.init(e,t),Ke(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>Ar(t,e)):Ar(o,e)}});function Ar(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Or=/*@__PURE__*/je("$ZodCatch",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mt(e,n,Ue()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mt(e,n,Ue()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Nr=/*@__PURE__*/je("$ZodPipe",(e,t)=>{En.init(e,t),Ke(e._zod,"values",()=>t.in._zod.values),Ke(e._zod,"optin",()=>t.in._zod.optin),Ke(e._zod,"optout",()=>t.out._zod.optout),Ke(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Rr(e,t.in,n)):Rr(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Rr(e,t.out,n)):Rr(r,t.out,n)}});function Rr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Lr=/*@__PURE__*/je("$ZodReadonly",(e,t)=>{En.init(e,t),Ke(e._zod,"propValues",()=>t.innerType._zod.propValues),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"optin",()=>t.innerType?._zod?.optin),Ke(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then($r):$r(r)}});function $r(e){return e.value=Object.freeze(e.value),e}var Pr,Dr=/*@__PURE__*/je("$ZodCustom",(e,t)=>{cn.init(e,t),En.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>jr(t,n,r,e));jr(o,n,r,e)}});function jr(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(gt(e))}}var Fr=class{constructor(){this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(Pr=globalThis).__zod_globalRegistry??(Pr.__zod_globalRegistry=new Fr);var Br=globalThis.__zod_globalRegistry;function Wr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}function Ur(e,t){return new dn({check:"less_than",...ct(t),value:e,inclusive:!1})}function Hr(e,t){return new dn({check:"less_than",...ct(t),value:e,inclusive:!0})}function Vr(e,t){return new un({check:"greater_than",...ct(t),value:e,inclusive:!1})}function Zr(e,t){return new un({check:"greater_than",...ct(t),value:e,inclusive:!0})}function qr(e,t){return new pn({check:"multiple_of",...ct(t),value:e})}function Gr(e,t){return new mn({check:"max_length",...ct(t),maximum:e})}function Jr(e,t){return new fn({check:"min_length",...ct(t),minimum:e})}function Kr(e,t){return new gn({check:"length_equals",...ct(t),length:e})}function Yr(e){return new Sn({check:"overwrite",tx:e})}function Xr(e,t){const n=new cn({check:"custom",...ct(t)});return n._zod.check=e,n}function Qr(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Br,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:/* @__PURE__ */new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function eo(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,r);else{const n=a.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(a.ref||(a.ref=i),eo(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),"input"===t.io&&ro(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function to(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=/* @__PURE__ */new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const a=r.schema;for(const e in a)delete a[e];a.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const n=i[1];if(t!==i[0]){if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}(e.metadataRegistry.get(i[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}else o(i)}}function no(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},a=n.ref;if(n.ref=null,a){r(a);const n=e.seen.get(a),s=n.schema;if(!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,s):(o.allOf=o.allOf??[],o.allOf.push(s)),Object.assign(o,i),t._zod.parent===a)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(s.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const s=t._zod.parent;if(s&&s!==a){r(s);const t=e.seen.get(s);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?o.$defs=a:o.definitions=a);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:oo(t,"input",e.processors),output:oo(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(s){throw new Error("Error converting schema to JSON.")}}function ro(e,t){const n=t??{seen:/* @__PURE__ */new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return ro(r.element,n);if("set"===r.type)return ro(r.valueType,n);if("lazy"===r.type)return ro(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return ro(r.innerType,n);if("intersection"===r.type)return ro(r.left,n)||ro(r.right,n);if("record"===r.type||"map"===r.type)return ro(r.keyType,n)||ro(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(ro(r.in,n)||ro(r.out,n));if("object"===r.type){for(const e in r.shape)if(ro(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(ro(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(ro(e,n))return!0;return!(!r.rest||!ro(r.rest,n))}return!1}var oo=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=Qr({...o??{},target:i,io:t,processors:n});return eo(e,a),to(a,e),no(a,e)},io={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ao=(e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r);t.seen.get(e).ref=o.innerType},so=/*@__PURE__*/je("ZodISODateTime",(e,t)=>{Bn.init(e,t),$o.init(e,t)});function co(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}(so,e)}var lo=/*@__PURE__*/je("ZodISODate",(e,t)=>{Wn.init(e,t),$o.init(e,t)});function uo(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}(lo,e)}var po=/*@__PURE__*/je("ZodISOTime",(e,t)=>{Un.init(e,t),$o.init(e,t)});function ho(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}(po,e)}var mo=/*@__PURE__*/je("ZodISODuration",(e,t)=>{Hn.init(e,t),$o.init(e,t)});function fo(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}(mo,e)}var go=(e,t)=>{wt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e},[...o,...i.path]));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))),r=r[n],o++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ve,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ve,2)}},isEmpty:{get:()=>0===e.issues.length}})},yo=/*@__PURE__*/je("ZodError",go,{Parent:Error}),wo=/* @__PURE__ */vt(yo),bo=/* @__PURE__ */xt(yo),vo=/* @__PURE__ */kt(yo),xo=/* @__PURE__ */St(yo),ko=/* @__PURE__ */Ct(yo),_o=/* @__PURE__ */Et(yo),So=/* @__PURE__ */Mt(yo),Io=/* @__PURE__ */zt(yo),Co=/* @__PURE__ */Tt(yo),Eo=/* @__PURE__ */At(yo),Mo=/* @__PURE__ */Ot(yo),zo=/* @__PURE__ */Nt(yo),To=/* @__PURE__ */new WeakMap;function Ao(e,t,n){const r=Object.getPrototypeOf(e);let o=To.get(r);if(o||(o=/* @__PURE__ */new Set,To.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Oo=/*@__PURE__*/je("ZodType",(e,t)=>(En.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:oo(e,"input"),output:oo(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Qr({...n,processors:t});return eo(e,r),to(r,e),no(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>wo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>vo(e,t,n),e.parseAsync=async(t,n)=>bo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ko(e,t,n),e.decode=(t,n)=>_o(e,t,n),e.encodeAsync=async(t,n)=>So(e,t,n),e.decodeAsync=async(t,n)=>Io(e,t,n),e.safeEncode=(t,n)=>Co(e,t,n),e.safeDecode=(t,n)=>Eo(e,t,n),e.safeEncodeAsync=async(t,n)=>Mo(e,t,n),e.safeDecodeAsync=async(t,n)=>zo(e,t,n),Ao(e,"ZodType",{check(...e){const t=this.def;return this.clone(Xe(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return st(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ct(n)})}(ji,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */Xr(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(gt(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(gt(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(Yr(e))},optional(){return Mi(this)},exactOptional(){return new zi({type:"optional",innerType:this})},nullable(){return Ai(this)},nullish(){return Mi(Ai(this))},nonoptional(e){return function(e,t){return new Ri({type:"nonoptional",innerType:e,...ct(t)})}(this,e)},array(){return fi(this)},or(e){return bi([this,e])},and(e){return new vi({type:"intersection",left:this,right:e})},transform(e){return Pi(this,new Ci({type:"transform",transform:e}))},default(e){return t=e,new Oi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},prefault(e){return t=e,new Ni({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ot(t)}});var t},catch(e){return new Li({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Pi(this,e)},readonly(){return new Di({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Br.add(t,{description:e}),t},meta(...e){if(0===e.length)return Br.get(this);const t=this.clone();return Br.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>Br.get(e)?.description,configurable:!0}),e)),No=/*@__PURE__*/je("_ZodString",(e,t)=>{Mn.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:a,patterns:s,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),a&&(r.format=io[a]??a,""===r.format&&delete r.format,"time"===a&&delete r.format),c&&(r.contentEncoding=c),s&&s.size>0){const e=[...s];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ao(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new wn({check:"string_format",format:"regex",...ct(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new xn({check:"string_format",format:"includes",...ct(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new kn({check:"string_format",format:"starts_with",...ct(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new _n({check:"string_format",format:"ends_with",...ct(t),suffix:e})}(...e))},min(...e){return this.check(Jr(...e))},max(...e){return this.check(Gr(...e))},length(...e){return this.check(Kr(...e))},nonempty(...e){return this.check(Jr(1,...e))},lowercase(e){return this.check(function(e){return new bn({check:"string_format",format:"lowercase",...ct(e)})}(e))},uppercase(e){return this.check(function(e){return new vn({check:"string_format",format:"uppercase",...ct(e)})}(e))},trim(){return this.check(/* @__PURE__ */Yr(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
+ return Yr(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */Yr(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */Yr(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */Yr(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Ro=/*@__PURE__*/je("ZodString",(e,t)=>{Mn.init(e,t),No.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ct(t)})}(Po,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(Fo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(ti,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(Bo,t)),e.guid=t=>e.check(Wr(Do,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(jo,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ct(t)})}(jo,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ct(t)})}(jo,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ct(t)})}(jo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(Wo,t)),e.guid=t=>e.check(Wr(Do,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(Uo,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(Ho,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(Vo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(Xo,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(Qo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(Zo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(qo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(Go,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(Jo,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(Ko,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(Yo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(ei,t)),e.datetime=t=>e.check(co(t)),e.date=t=>e.check(uo(t)),e.time=t=>e.check(ho(t)),e.duration=t=>e.check(fo(t))});function Lo(e){return function(e,t){return new e({type:"string",...ct(t)})}(Ro,e)}var $o=/*@__PURE__*/je("ZodStringFormat",(e,t)=>{zn.init(e,t),No.init(e,t)}),Po=/*@__PURE__*/je("ZodEmail",(e,t)=>{On.init(e,t),$o.init(e,t)}),Do=/*@__PURE__*/je("ZodGUID",(e,t)=>{Tn.init(e,t),$o.init(e,t)}),jo=/*@__PURE__*/je("ZodUUID",(e,t)=>{An.init(e,t),$o.init(e,t)}),Fo=/*@__PURE__*/je("ZodURL",(e,t)=>{Nn.init(e,t),$o.init(e,t)}),Bo=/*@__PURE__*/je("ZodEmoji",(e,t)=>{Rn.init(e,t),$o.init(e,t)}),Wo=/*@__PURE__*/je("ZodNanoID",(e,t)=>{Ln.init(e,t),$o.init(e,t)}),Uo=/*@__PURE__*/je("ZodCUID",(e,t)=>{$n.init(e,t),$o.init(e,t)}),Ho=/*@__PURE__*/je("ZodCUID2",(e,t)=>{Pn.init(e,t),$o.init(e,t)}),Vo=/*@__PURE__*/je("ZodULID",(e,t)=>{Dn.init(e,t),$o.init(e,t)}),Zo=/*@__PURE__*/je("ZodXID",(e,t)=>{jn.init(e,t),$o.init(e,t)}),qo=/*@__PURE__*/je("ZodKSUID",(e,t)=>{Fn.init(e,t),$o.init(e,t)}),Go=/*@__PURE__*/je("ZodIPv4",(e,t)=>{Vn.init(e,t),$o.init(e,t)}),Jo=/*@__PURE__*/je("ZodIPv6",(e,t)=>{Zn.init(e,t),$o.init(e,t)}),Ko=/*@__PURE__*/je("ZodCIDRv4",(e,t)=>{qn.init(e,t),$o.init(e,t)}),Yo=/*@__PURE__*/je("ZodCIDRv6",(e,t)=>{Gn.init(e,t),$o.init(e,t)}),Xo=/*@__PURE__*/je("ZodBase64",(e,t)=>{Kn.init(e,t),$o.init(e,t)}),Qo=/*@__PURE__*/je("ZodBase64URL",(e,t)=>{Yn.init(e,t),$o.init(e,t)}),ei=/*@__PURE__*/je("ZodE164",(e,t)=>{Xn.init(e,t),$o.init(e,t)}),ti=/*@__PURE__*/je("ZodJWT",(e,t)=>{Qn.init(e,t),$o.init(e,t)}),ni=/*@__PURE__*/je("ZodNumber",(e,t)=>{er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:i,format:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l}=e._zod.bag;"string"==typeof a&&a.includes("int")?r.type="integer":r.type="number";const d="number"==typeof l&&l>=(o??Number.NEGATIVE_INFINITY),u="number"==typeof c&&c<=(i??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof o&&(r.minimum=o),u?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof i&&(r.maximum=i),"number"==typeof s&&(r.multipleOf=s)})(e,t,n),Ao(e,"ZodNumber",{gt(e,t){return this.check(Vr(e,t))},gte(e,t){return this.check(Zr(e,t))},min(e,t){return this.check(Zr(e,t))},lt(e,t){return this.check(Ur(e,t))},lte(e,t){return this.check(Hr(e,t))},max(e,t){return this.check(Hr(e,t))},int(e){return this.check(ii(e))},safe(e){return this.check(ii(e))},positive(e){return this.check(Vr(0,e))},nonnegative(e){return this.check(Zr(0,e))},negative(e){return this.check(Ur(0,e))},nonpositive(e){return this.check(Hr(0,e))},multipleOf(e,t){return this.check(qr(e,t))},step(e,t){return this.check(qr(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ri(e){return function(e,t){return new e({type:"number",checks:[],...ct(t)})}(ni,e)}var oi=/*@__PURE__*/je("ZodNumberFormat",(e,t)=>{tr.init(e,t),ni.init(e,t)});function ii(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(oi,e)}var ai=/*@__PURE__*/je("ZodBoolean",(e,t)=>{nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function si(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(ai,e)}var ci=/*@__PURE__*/je("ZodNull",(e,t)=>{rr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{"openapi-3.0"===t.target?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"})(0,e,t)});var li=/*@__PURE__*/je("ZodUnknown",(e,t)=>{or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function di(){return new li({type:"unknown"})}var ui=/*@__PURE__*/je("ZodNever",(e,t)=>{ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function pi(e){return function(e,t){return new e({type:"never",...ct(t)})}(ui,e)}var hi=/*@__PURE__*/je("ZodDate",(e,t)=>{ar.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,n)=>e.check(Zr(t,n)),e.max=(t,n)=>e.check(Hr(t,n));const n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null}),mi=/*@__PURE__*/je("ZodArray",(e,t)=>{cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(o.minItems=a),"number"==typeof s&&(o.maxItems=s),o.type="array",o.items=eo(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Ao(e,"ZodArray",{min(e,t){return this.check(Jr(e,t))},nonempty(e){return this.check(Jr(1,e))},max(e,t){return this.check(Gr(e,t))},length(e,t){return this.check(Kr(e,t))},unwrap(){return this.element}})});function fi(e,t){return function(e,t,n){return new e({type:"array",element:t,...ct(n)})}(mi,e,t)}var gi=/*@__PURE__*/je("ZodObject",(e,t)=>{hr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const l in a)o.properties[l]=eo(a[l],t,{...r,path:[...r.path,"properties",l]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=eo(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),Ke(e,"shape",()=>t.shape),Ao(e,"ZodObject",{keyof(){return Si(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:di()})},loose(){return this.clone({...this._zod.def,catchall:di()})},strict(){return this.clone({...this._zod.def,catchall:pi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!rt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Ye(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!rt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Ye(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return st(e,Xe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Ye(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return st(e,Xe(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ye(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return st(e,Xe(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ye(this,"shape",r),r},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return st(t,Xe(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Ye(this,"shape",o),o},checks:[]}))}(Ei,this,e[0])},required(...e){return t=Ri,n=this,r=e[0],st(n,Xe(n._zod.def,{get shape(){const e=n._zod.def.shape,o={...e};if(r)for(const n in r){if(!(n in o))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(o[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)o[n]=new t({type:"nonoptional",innerType:e[n]});return Ye(this,"shape",o),o}}));var t,n,r}})});function yi(e,t){return new gi({type:"object",shape:e??{},...ct(t)})}var wi=/*@__PURE__*/je("ZodUnion",(e,t)=>{fr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,a=o.options.map((e,n)=>eo(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=a:n.anyOf=a})(e,t,n,r),e.options=t.options});function bi(e,t){return new wi({type:"union",options:e,...ct(t)})}var vi=/*@__PURE__*/je("ZodIntersection",(e,t)=>{gr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=eo(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=eo(o.right,t,{...r,path:[...r.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]})(e,t,n,r)});var xi=/*@__PURE__*/je("ZodRecord",(e,t)=>{br.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,s=a._zod.bag?.patterns;if("loose"===i.mode&&s&&s.size>0){const e=eo(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of s)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=eo(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=eo(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=a._zod.values;if(c){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(o.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ki(e,t,n){return t&&t._zod?new xi({type:"record",keyType:e,valueType:t,...ct(n)}):new xi({type:"record",keyType:Lo(),valueType:e,...ct(t)})}var _i=/*@__PURE__*/je("ZodEnum",(e,t)=>{vr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=He(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new _i({...t,checks:[],...ct(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new _i({...t,checks:[],...ct(r),entries:o})}});function Si(e,t){return new _i({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ct(t)})}var Ii=/*@__PURE__*/je("ZodLiteral",(e,t)=>{xr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,o=[];for(const i of r.values)if(void 0===i){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof i){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(i))}else o.push(i);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});var Ci=/*@__PURE__*/je("ZodTransform",(e,t)=>{kr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Be(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(gt(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(gt(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});var Ei=/*@__PURE__*/je("ZodOptional",(e,t)=>{Sr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Mi(e){return new Ei({type:"optional",innerType:e})}var zi=/*@__PURE__*/je("ZodExactOptional",(e,t)=>{Ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ti=/*@__PURE__*/je("ZodNullable",(e,t)=>{Cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=eo(o.innerType,t,r),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ai(e){return new Ti({type:"nullable",innerType:e})}var Oi=/*@__PURE__*/je("ZodDefault",(e,t)=>{Er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Ni=/*@__PURE__*/je("ZodPrefault",(e,t)=>{zr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Ri=/*@__PURE__*/je("ZodNonOptional",(e,t)=>{Tr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Li=/*@__PURE__*/je("ZodCatch",(e,t)=>{Or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var $i=/*@__PURE__*/je("ZodPipe",(e,t)=>{Nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a="input"===t.io?i?o.out:o.in:o.out;eo(a,t,r),t.seen.get(e).ref=a})(e,t,0,r),e.in=t.in,e.out=t.out});function Pi(e,t){return new $i({type:"pipe",in:e,out:t})}var Di=/*@__PURE__*/je("ZodReadonly",(e,t)=>{Lr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;eo(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var ji=/*@__PURE__*/je("ZodCustom",(e,t)=>{Dr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Fi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...ct(t)})}(ni,e)}function Bi(e){return function(e,t){return new e({type:"date",coerce:!0,...ct(t)})}(hi,e)}var Wi,Ui,Hi=Si(["created","active","suspended","pending_approval"]),Vi=yi({id:ri().optional(),created_at:Bi().optional(),updated_at:Bi().optional()}),Zi=(yi({id:Fi()}),yi({slug:Lo()}),yi({widget_id:Fi()}),yi({simulation_id:Fi()}),yi({application_id:Fi()}),yi({user_id:Fi()}),yi({limit:Fi().optional().default(50),offset:Fi().optional().default(0)}),bi([Lo(),ri(),si(),fi(Lo()),function(e,t){return new e({type:"null",...ct(t)})}(ci,Wi)]),yi({type:Si(["doc","sim","session"]),id:Lo(),label:Lo()}),yi({success:function(e,t){return new Ii({type:"literal",values:Array.isArray(e)?e:[e],...ct(t)})}(!0)})),qi=(Zi.extend({message:Lo()}),yi({name:Lo().min(1),params:ki(Lo(),di()).default({}),result:ki(Lo(),di()).default({})}),Lo().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),yi({start:Lo(),end:Lo(),action:Lo()}).passthrough()),Gi=yi({id:Lo(),label:Lo(),purpose:Lo(),elements:fi(ki(Lo(),di())).default([]),bbox:ki(Lo(),di()).default({}),screenshot:Lo().default(""),embedding:fi(ri()).nullish()}).passthrough(),Ji=yi({id:Lo(),title:Lo(),url:Lo(),summary:Lo().default(""),screenshot:Lo().default(""),sections:fi(Gi).default([]),sequence_ids:fi(ri()).default([]),embedding:fi(ri()).nullish()}).passthrough(),Ki=(yi({nodes:fi(Ji),edges:fi(qi)}),yi({skill_id:ri().int(),params:ki(Lo(),Lo())}),Si(["free","startup","growth","enterprise"])),Yi=Si(["document","video"]),Xi=Si(["user","research"]),Qi=(Si(["pending","processing","waiting_review","completed","failed"]),Si(["queued","running","creating_knowledge","has_question","completed","failed","stopped"])),ea=Si(["pending","generating","completed","failed"]),ta=Si(["app","website"]),na=Si(["widget"]),ra=(Si(["tell","show","do"]),Si(["password","oauth"])),oa=(Vi.extend({is_super:si(),status:Hi,email:Lo().email(),external_id:Lo().nullish(),first_name:Lo().nullish(),last_name:Lo().nullish(),password:Lo().nullish(),image_url:Lo().nullish(),prompt_limit:ri().nullish(),last_login_at:Bi().nullish(),auth_method:ra.nullish()}).partial().extend({email:Lo().email(),password:Lo()}),Vi.extend({name:Lo(),slug:Lo(),status:Hi,package:Ki,ending_date:Bi().nullish(),external_workspace_id:Lo().nullish(),slack_webhook_configured:si().optional(),notify_all_members_on_question:si().optional()}),Vi.extend({workspace_id:ri(),application_id:ri().optional(),file_name:Lo().min(1),file_size:Fi(),file_type:Yi,file_url:Lo(),source_url:Lo().nullish(),source:Xi.default("user").optional()}),Si(["passed","needs_healing","failed"]),yi({ultimate_goal:Lo(),test_cases:fi(yi({test_title:Lo(),test_objective:Lo(),test_steps:fi(Lo()),expected_outcome:Lo(),priority:Si(["Low","Medium","High"])})),summary:yi({total_tests:ri(),high_priority:ri(),medium_priority:ri(),low_priority:ri(),estimated_time_minutes:ri()})}),yi({task_id:Lo(),condition:Si(["pass"]).optional()})),ia=yi({task_id:Lo(),title:Lo(),instructions:Lo(),status:Si(["pending","running","has_question","passed","failed","skipped","stopped"]),error_message:Lo().nullish(),started_at:Lo().nullish(),completed_at:Lo().nullish(),order_index:ri().int().nonnegative().default(0),tab_id:Lo().nullish(),step_count:ri().int().nonnegative().default(0),blocked_by:fi(oa).default([])}),aa=(Vi.extend({application_id:ri(),job_id:Lo(),browser_session_id:Lo().nullish(),status:Qi,status_message:Lo().nullish(),path:Lo().nullish(),instructions:Lo().nullish(),pinned:si().optional(),source:Si(["direct","qa"]).optional(),graph_id:Lo().nullish(),source_metadata:ki(Lo(),di()).nullish(),tasks:fi(ia).optional(),graph_status:ea.optional(),graph_steps_processed:ri().int().nonnegative().optional(),graph_steps_total:ri().int().nonnegative().optional(),graph_error:Lo().nullish(),created_by_user_id:ri().nullish(),persona_id:ri().nullish(),has_question:si().optional()}),Vi.extend({workspace_id:ri(),name:Lo(),slug:Lo(),type:ta,url:Lo().nullish(),username:Lo().nullish(),password:Lo().nullish(),allowed_domains:fi(Lo()).nullish().default([])}).omit({password:!0}),yi({chip_mode:Si(["show","tell","do"]),chip_text:Lo()})),sa=yi({widget_enabled:si(),widget_appearance:Si(["default","compact","full"]),widget_position:Si(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Si(["desktop","mobile","desktop_mobile"]),widget_header:Lo(),widget_body:Lo(),widget_greeting:Lo(),widget_feature_tell:si(),widget_feature_show:si(),widget_feature_do:si(),widget_feature_human:si(),widget_background_color:Lo(),widget_text_color:Lo(),widget_border_color:Lo(),widget_accent_color:Lo(),widget_secondary_color:Lo(),widget_border_radius:Lo(),widget_font_size:Lo(),widget_width:Lo(),widget_height:Lo(),widget_shadow:Lo(),widget_animation_duration:Lo(),widget_fade_duration:Lo(),widget_bounce_effect:si(),widget_chips:fi(aa)}),ca=(Vi.extend({application_id:ri(),type:na,settings:sa,status:Hi,marketrix_id:Lo(),marketrix_key:Lo(),snippet:Lo().nullish()}),Vi.extend({widget_id:ri(),url_pattern:Lo(),message:fi(Lo()),description:Lo().optional()}),Si(["pending","running","completed","failed","stopped"]),Si(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_application","update_application","delete_application","create_widget","update_widget","delete_widget","create_knowledge","update_knowledge","delete_knowledge","approve_user","deny_user","request_workspace","widget_question","qa_run_started","start_simulation","create_automation","update_automation","delete_automation","toggle_automation","slack_command"])),la=yi({details:Lo().optional(),id:ri().optional(),type:Lo().optional(),name:Lo().optional(),target_user_id:ri().optional(),target_user_email:Lo().optional(),reason:Lo().optional(),assigned_role:Lo().optional(),new_role:Lo().optional(),previous_role:Lo().optional(),workspace_name:Lo().optional(),workspace_slug:Lo().optional(),ip_address:Lo().optional(),user_agent:Lo().optional(),widget_type:Lo().optional(),created_by:ri().optional()}).passthrough(),da=(Vi.extend({workspace_id:ri(),user_id:ri(),type:ca,metadata:la.optional()}).partial().extend({type:ca}),yi({user_id:ri(),limit:ri(),used:ri(),remaining:ri()}),yi({description:Lo(),selected:si(),simulation_id:ri().nullable().optional(),task_id:Lo().nullable().optional(),status:Qi.nullable().optional()}),null),ua="";function pa(e){return ge(new De({url:e,headers:()=>{const e={};return da&&(e.Authorization=`Bearer ${da}`),e}}))}Ui=pa("");var ha=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ua&&(ua=e,Ui=pa(e))},ma={setAuthToken:e=>{da=e},clearAuthToken:()=>{da=null},getAuthToken:()=>da,configure:ha},fa=new Proxy({},{get:(e,t)=>t in ma?ma[t]:Ui[t]}),ga="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",ya={debug:0,info:1,warn:2,error:3};function wa(e){return ya[e]>=ya[ga]}function ba(e){return{debug:(e,...t)=>{wa("debug")},info:(e,...t)=>{wa("info")},warn:(e,...t)=>{wa("warn")},error:(e,...t)=>{wa("error")}}}var va=[{id:"navigate",name:"Navigate",description:"Navigate to a URL",displayAction:"Navigating",category:"navigation",actionType:"navigate"},{id:"search",name:"Search",description:"Search the web using a search engine",displayAction:"Searching",category:"navigation",actionType:"search"},{id:"click_element",name:"Click Element",description:"Click on an element by index or coordinates",displayAction:"Clicking element",category:"interaction",actionType:"click_element"},{id:"type_text",name:"Type Text",description:"Type text into an input field",displayAction:"Typing text",category:"interaction",actionType:"type_text"},{id:"scroll",name:"Scroll",description:"Scroll the page up or down",displayAction:"Scrolling",category:"interaction",actionType:"scroll"},{id:"scroll_to_text",name:"Scroll to Text",description:"Scroll until text is visible",displayAction:"Scrolling to text",category:"interaction",actionType:"scroll_to_text"},{id:"send_keys",name:"Send Keys",description:"Send keyboard keys or shortcuts",displayAction:"Pressing key",category:"interaction",actionType:"send_keys"},{id:"extract",name:"Extract",description:"Extract content from the page",displayAction:"Extracting content",category:"extraction",actionType:"extract"},{id:"get_dropdown_options",name:"Get Dropdown Options",description:"Get available options from a dropdown",displayAction:"Reading dropdown options",category:"extraction",actionType:"get_dropdown_options"},{id:"select_dropdown_option",name:"Select Dropdown Option",description:"Select an option from a dropdown",displayAction:"Selecting option",category:"interaction",actionType:"select_dropdown_option"},{id:"upload_file",name:"Upload File",description:"Upload a file to an input field",displayAction:"Uploading file",category:"interaction",actionType:"upload_file"},{id:"go_back",name:"Go Back",description:"Browser back button",displayAction:"Going back",category:"navigation",actionType:"go_back"},{id:"wait",name:"Wait",description:"Wait for a specified duration",displayAction:"Waiting",category:"utility",actionType:"wait"},{id:"switch_tab",name:"Switch Tab",description:"Switch to a different browser tab",displayAction:"Switching tab",category:"utility",actionType:"switch_tab"},{id:"close_tab",name:"Close Tab",description:"Close the current browser tab",displayAction:"Closing tab",category:"utility",actionType:"close_tab"},{id:"done",name:"Done",description:"Mark task as complete",displayAction:"Done",category:"utility",actionType:"done"},{id:"get_html",name:"Get HTML",description:"Get full page HTML with data-id attributes",displayAction:"Viewed your screen",category:"extraction",actionType:"get_html"},{id:"get_interactable_elements",name:"Get Interactable Elements",description:"Get list of interactable elements",displayAction:"Scanning elements",category:"extraction",actionType:"get_interactable_elements"},{id:"get_screenshot",name:"Get Screenshot",description:"Capture a screenshot of the page",displayAction:"Taking screenshot",category:"extraction",actionType:"get_screenshot"}];function xa(e){return e.includes("__THINKING__")}function ka(e){return xa(e)?e:`${e}\n\n__THINKING__`}function _a(e,t,n,r,o){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(o&&t&&("show"===n||"do"===n))if(e.isPlaceholder){if(void 0!==e.mode&&e.mode!==n)return!1}else if(e.mode!==n)return!1;if(r){const t=e.content.trim().length>0,n=e.parts&&e.parts.length>0;if(!t&&!n)return!1}return!0}function Sa(e){const{messages:t,isTaskRunning:n,currentMode:r,requireContent:o}=e;let i=-1;if(n&&("show"===r||"do"===r)){const e=!0;for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder,d=!o||s.content.trim().length>0||s.parts&&s.parts.length>0;if(c&&l&&d){i=a;break}}if(i<0&&!o)for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder;if(c&&l){i=a;break}}if(i<0)for(let a=t.length-1;a>=0;a--){const s=t[a],c=_a(s,n,r,o,e),l=s.isPlaceholder;if(c&&!l){i=a;break}}}if(i<0){for(let e=t.length-1;e>=0;e--){const n=t[e],r="agent"===n.sender,a=n.isPlaceholder,s=!n.isSystemMessage,c=!n.isScreenAccessRequest,l=!o||n.content.trim().length>0||n.parts&&n.parts.length>0;if(r&&a&&s&&c&&l){i=e;break}}if(i<0&&!o)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&n.isPlaceholder&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}if(i<0&&(i=function(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest&&!n.isPlaceholder)return t}return-1}(t)),i<0)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}}return i>=0?{index:i,message:t[i]}:null}function Ia(e){const t={...e};if(!t.parts){t.parts=[];const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts.push({type:"text",content:e})}return t}var Ca=new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Ea=new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function Ma(e){return e?e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\(cancelled by cleanup\)/gi,"").replace(/Cancelled by cleanup/gi,"").replace(/\s+/g," ").trim():e}function za(e,t,n,r=!1){const o=Ia(e);if(!t||"show"!==n&&"do"!==n)return xa(o.content)?{...o,content:o.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:o;const i=r?"waiting-for-user":"thinking";return xa(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:ka(o.content),placeholderState:i}}var Ta=Object.fromEntries(va.map(e=>[e.id,e.displayAction]));var Aa="marketrix_chat_context",Oa={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Na=class e{static instance;context=null;constructor(){this.loadContext()}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadContext(){if("undefined"==typeof window)return this.context={...Oa},this.context;try{const e=localStorage.getItem(Aa);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Oa},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Oa},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Aa,JSON.stringify(this.context))}catch(e){}}getContext(){return this.context?this.context:this.loadContext()}updateContext(e){this.context||this.loadContext();const t=this.context;this.context={...t,...e},this.saveContext()}isValidChatId(e){return"string"==typeof e&&""!==e.trim()}getChatId(){if("undefined"!=typeof window&&this.isValidChatId(window.name)){const e=window.name;return e!==this.getContext().chat_id&&this.updateContext({chat_id:e}),e}return this.getContext().chat_id}setChatId(e){this.updateContext({chat_id:e}),"undefined"!=typeof window&&e&&(window.name=e,window.dispatchEvent(new CustomEvent("marketrix:chatid",{detail:{chatId:e}})))}getMessages(){return this.getContext().messages}setMessages(e){this.updateContext({messages:e})}getChatState(){const e=this.getContext();return{isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,taskProgress:e.taskProgress,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading}}setChatState(e){this.updateContext(e)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}clear(){this.context={...Oa},"undefined"!=typeof window&&localStorage.removeItem(Aa)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Ra=class e{static instance;chatId=null;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e}createInitialContext(e){try{if(Na.hasValidContext())return;Na.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,taskProgress:[],currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}restore(){const e=Na.getContext();return{messages:e.chat_id?e.messages.map(e=>{if(e.id.startsWith("screenshare-"))return{...e,content:"Screenshare ended",videoStream:void 0,isSystemMessage:!0,timestamp:new Date(e.timestamp),parts:[{type:"text",content:"Screenshare ended"}]};const t={...e,timestamp:new Date(e.timestamp),videoStream:void 0,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts||[]};if(0===t.parts?.length&&t.content){const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts&&t.parts.push({type:"text",content:e})}return t}):[],isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,taskProgress:e.taskProgress,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading??!1}}persist(e){if(this.chatId)try{const t=e.messages.filter(e=>!e.isPlaceholder||("thinking"===e.placeholderState||"waiting-for-user"===e.placeholderState||(e.parts||[]).length>0)).filter(e=>!(e.isSystemMessage&&"Chat context changed"===e.content)).map(e=>{return{id:e.id,content:(t=e.content,t.replace(/__THINKING__/g,"")),sender:e.sender,timestamp:e.timestamp.toISOString(),mode:e.mode,isScreenAccessRequest:e.isScreenAccessRequest,screenShareStatus:e.screenShareStatus,isSystemMessage:e.isSystemMessage,isPlaceholder:e.isPlaceholder,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts};var t});Na.updateContext({chat_id:this.chatId,messages:t,isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,taskProgress:e.taskProgress,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading})}catch(t){}}}.getInstance();function La(e,t,n="user-message"){const r=[],o=e.trim();return o&&r.push({type:"text",content:o}),{id:`${n}-${Date.now()}`,content:o,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:r}}function $a(e,t,n,r="agent-message"){const o=[],i=e.trim();return i&&o.push({type:"text",content:i}),{id:n||`${r}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:o}}function Pa(e,t,n="agent",r="system-message"){const o=[];return e&&o.push({type:"text",content:e}),{id:`${r}-${Date.now()}`,content:e,sender:n,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:o}}function Da(e="show"){const t="Started screenshare";return{id:`started-screenshare-${Date.now()}`,content:t,sender:"user",timestamp:/* @__PURE__ */new Date,mode:e,isSystemMessage:!0,parts:[{type:"text",content:t}]}}function ja(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Fa=ba(),Ba=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Fa.debug("Loaded existing chat ID from storage:",this.chatId))}static getInstance(){return"undefined"==typeof window||"undefined"==typeof document?(e.instance||(e.instance=Object.create(e.prototype),e.instance.chatId=null,e.instance.initializationPromise=null),e.instance):(e.instance||(e.instance=new e),e.instance)}getChatId(){return this.chatId}async getOrCreateChatId(){if(this.chatId)return Fa.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Fa.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Fa.debug("Found chat ID in storage:",this.chatId),this.chatId;this.initializationPromise=this.createChatId();try{return await this.initializationPromise}finally{this.initializationPromise=null}}async createChatId(){try{Fa.info("Creating new chat ID...");const e=await fa.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Fa.info("Created and stored new chat ID:",this.chatId),Ra.createInitialContext(e),e}catch(e){throw Fa.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Na.getChatId()}storeChatId(e){Na.setChatId(e)}}.getInstance(),Wa=class e{static instance=null;abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;isIntentionallyDisconnected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;config;connectionId=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}getStatus(){return this.status}isConnected(){return"registered"===this.status}async connect(e,t){if(this.isIntentionallyDisconnected&&(this.isIntentionallyDisconnected=!1),this.isConnected()&&this.chatId===e)return;this.abortController&&(this.abortController.abort(),this.abortController=null),this.chatId=e,t&&(this.config=t),this.setStatus("connecting");const n=++this.connectionId;this.abortController=new AbortController;const r=this.abortController.signal;try{const t={chat_id:e};this.config?.mtxId&&this.config?.mtxKey?(t.marketrix_id=this.config.mtxId,t.marketrix_key=this.config.mtxKey):this.config?.mtxApp&&(t.application_id=this.config.mtxApp);const o=await fa.widgetStream(t,{signal:r});this.setStatus("connected"),this.consumeEvents(o,n)}catch(o){r.aborted||(this.setStatus("error"),this.notifyError(/* @__PURE__ */new Error("Stream connection failed")),this.scheduleReconnect())}}async consumeEvents(e,t){let n=!1;try{for await(const r of e){if(this.connectionId!==t){n=!0;break}this.handleMessage(r)}}catch(r){this.connectionId!==t?n=!0:this.isIntentionallyDisconnected||this.setStatus("error")}finally{n||this.connectionId!==t||this.isIntentionallyDisconnected||(this.setStatus("disconnected"),this.scheduleReconnect())}}disconnect(){this.isIntentionallyDisconnected=!0,this.clearReconnectTimer(),this.abortController&&(this.abortController.abort(),this.abortController=null),this.setStatus("disconnected"),this.chatId=null}send(e){return this.chatId?fa.widgetMessage({chat_id:this.chatId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${String(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(t=>t.onStatusChange?.(e)))}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}handleMessage(e){this.isIntentionallyDisconnected||"heartbeat"!==e.type&&("registered"===e.type&&e.chat_id===this.chatId&&(this.setStatus("registered"),this.reconnectAttempts=0,this.reconnectDelay=1e3,this.callbacks.forEach(t=>t.onRegistered?.(e.application_id))),"chat/error"===e.type&&"auth"===e.request_id&&(this.isIntentionallyDisconnected=!0),this.callbacks.forEach(t=>t.onMessage?.(e)))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.notifyError(/* @__PURE__ */new Error("Max reconnect attempts reached"));this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.isIntentionallyDisconnected&&this.chatId&&this.connect(this.chatId,this.config).catch(console.error)},e)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}},Ua=class{config;constructor(e){this.config=e}getChatId(){return Ba.getChatId()}getUserId(){if(this.config.userId&&"number"==typeof this.config.userId)return this.config.userId;try{const e=localStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}try{const e=sessionStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(e){}return null}async logWidgetQuestion(e,t){try{const n=this.getUserId(),r={question:e,mode:t,chat_id:this.getChatId(),timestamp:/* @__PURE__ */(new Date).toISOString()};null!==n&&(r.user_id=n),this.config.mtxApp&&(r.application_id=this.config.mtxApp),this.config.mtxId&&this.config.mtxKey&&(r.marketrix_id=this.config.mtxId,r.marketrix_key=this.config.mtxKey),fa.activityLogCreate({type:"widget_question",metadata:r}).catch(e=>{})}catch(n){}}async sendMessage(e){if(!(await Ba.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const t=e.mode||"tell";if(e.message&&await this.logWidgetQuestion(e.message,t),!(this.config.mtxId&&this.config.mtxKey||this.config.mtxApp))throw new Error("Either mtxId + mtxKey or mtxApp is required");const n=e.requestId||`req_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,r={type:`chat/${t}`,request_id:n,content:e.message||""};return Wa.getInstance().send(r),{messageId:n,response:"",mode:t,timestamp:/* @__PURE__ */new Date}}updateConfig(e){this.config={...this.config,...e}}},Ha=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Na.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Na.setConfig(e),this.config=e}updateConfig(e){this.config||(this.config={}),this.config={...this.config,...e},this.saveConfig(this.config)}getConfig(){return this.config}shouldShowWidget(){return!!this.config&&(this.config.widget_enabled??!1)}}.getInstance();function Va(e,t={}){return{...t,...e}}var Za=n(void 0),qa=({children:e,previewMode:t=!1,uiActions:n,currentMode:r})=>{const[o,a]=p({messages:[]}),s=u(r);s.current=r;const c=i(e=>{a(t=>({messages:[...t.messages,e]}))},[]),l=i((e,t)=>{a(n=>({messages:n.messages.map(n=>n.id===e?{...n,...t}:n)}))},[]),h=i(e=>{a(t=>({messages:t.messages.filter(t=>t.id!==e)}))},[]),m=i(e=>{a({messages:e})},[]),g=i(()=>{a({messages:[]})},[]),y=i(async(e,r,o,i,l)=>{const d=r??s.current;if(t)return l||c(La(e,d)),void c($a("This is a preview. In production, I'll respond to your messages here."));let u=Ha.getConfig();if(u||(u=Ha.loadConfig()),!u||!u.mtxId&&!u.mtxKey&&!u.mtxApp)return void c($a("Configuration error: Missing API credentials. Please check your widget settings."));l||c(La(e,d));const p=`temp-${globalThis.crypto.randomUUID()}`;c({id:p,content:ka(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:d,isPlaceholder:!0,placeholderState:"thinking",parts:[]}),n.setLoading(!0);const h=new Ua(u);try{o&&h.updateConfig({mtxApp:o});const t=h.getChatId();if(t){const e=Wa.getInstance();if(!e.isConnected()){const n=Ha.getConfig();try{await e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0)}catch(m){}}}await h.sendMessage({message:e,mode:d,question:i,requestId:p})}catch(f){a(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.";return{messages:e.messages.map(e=>{if(e.id!==p)return e;const n=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:n,content:t}})}})}finally{n.setLoading(!1)}},[t,c,n]),w=d(()=>({addMessage:c,updateMessage:l,removeMessage:h,setMessages:m,clearMessages:g,sendMessage:y}),[c,l,h,m,g,y]);/* @__PURE__ */
3
+ return f(Za.Provider,{value:{chatState:o,chatActions:w,_setMessages:a},children:e})},Ga=()=>{const e=a(Za);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e};function Ja(e){if(!(e&&e instanceof Element))return!1;try{const n=e.tagName.toLowerCase(),r="button"===n;if(!(r||"input"===n||"textarea"===n||"select"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||"textbox"===e.getAttribute("role")||"checkbox"===e.getAttribute("role")||"radio"===e.getAttribute("role")||"switch"===e.getAttribute("role")||"tab"===e.getAttribute("role")||"menuitem"===e.getAttribute("role")||"true"===e.getAttribute("contenteditable")||e.hasAttribute("onclick")||e.hasAttribute("tabindex")&&parseInt(e.getAttribute("tabindex")||"-1",10)>=0))return!1;const o=(t,n)=>{if(r){e.tagName,e.id,e.className}};if(!0===e.disabled)return o("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return o("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return o("inert","ancestor is inert"),!1;const e=t instanceof Element?t.getRootNode():null;t=t instanceof Element?t.parentElement||(e instanceof ShadowRoot?e.host:null):null}}catch(t){}const i=e.hasAttribute("onclick");if(r&&i)return!0;let a,s;try{a=window.getComputedStyle(e)}catch(t){return o("computed-style","failed to get computed style"),!1}if("none"===a.display)return o("display","display is none"),!1;if("none"===a.pointerEvents)return o("pointer-events","pointer-events is none"),!1;try{s=e.getBoundingClientRect()}catch(t){return o("bounding-rect","failed to get bounding rect"),!1}if(s.width<=0||s.height<=0)return o("dimensions",`width=${s.width}, height=${s.height}`),!1;try{let t=e;for(;t&&t!==document.body;){const e=t.getRootNode(),n=t.parentElement||(e instanceof ShadowRoot?e.host:null);if(!n)break;let i,a;try{i=window.getComputedStyle(n),a=n.getBoundingClientRect()}catch{t=n;continue}if("hidden"===i.overflow||"clip"===i.overflow){const e=s.right<a.left||s.left>a.right||s.bottom<a.top||s.top>a.bottom;if(r){if(e)return o("overflow-clipping","completely outside parent bounds"),!1}else if(e)return!1}t=n}}catch(t){}try{let t=e.getRootNode();for(;t instanceof ShadowRoot;){const e=t.host;let n;try{n=e.getBoundingClientRect()}catch{break}if(n.width<=0||n.height<=0)return!1;t=e.getRootNode()}}catch(t){}return!0}catch(t){return!1}}var Ka=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;isIndexed=!1;indexingInProgress=!1;indexVersion=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}generateSelector(e){if(e.id&&1===document.querySelectorAll(`#${CSS.escape(e.id)}`).length)return`#${CSS.escape(e.id)}`;const t=[];let n=e;for(;n&&n!==document.body&&n.parentElement;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${CSS.escape(n.id)}`,t.unshift(e);break}{const t=n.parentElement;if(!t)break;const r=n.tagName,o=Array.from(t.children).filter(e=>e.tagName===r);if(o.length>1){e+=`:nth-of-type(${o.indexOf(n)+1})`}}t.unshift(e),n=n.parentElement}return t.join(" > ")}generateFingerprint(e,t){return{tagName:e.tagName,id:e.id||null,textContent:((e,t=100)=>{if(!e)return null;const n=e.trim().replace(/\s+/g," ");return n.length>t?n.slice(0,t):n})(e.textContent),type:e.getAttribute("type"),role:e.getAttribute("role"),ariaLabel:e.getAttribute("aria-label"),name:e.getAttribute("name"),href:e.getAttribute("href"),selector:t,indexVersion:this.indexVersion}}matchesFingerprint(e,t){return e.tagName===t.tagName&&(!(!t.id||e.id!==t.id)||(!t.type||e.getAttribute("type")===t.type)&&((!t.ariaLabel||e.getAttribute("aria-label")===t.ariaLabel)&&((!t.role||e.getAttribute("role")===t.role)&&((!t.href||"A"!==t.tagName||e.getAttribute("href")===t.href)&&(!t.name||e.getAttribute("name")===t.name)))))}validateElementAtIndex(e){const t=this.fingerprintMap.get(e);if(!t)return{isValid:!0};const n=this.elementMap.get(e);return n&&document.contains(n)?n instanceof HTMLElement&&!this.matchesFingerprint(n,t)?{isValid:!1,mismatchReason:"element_changed"}:{isValid:!0}:{isValid:!1,mismatchReason:"element_removed"}}exportState(){return{selectors:Array.from(this.selectorMap.entries()),fingerprints:Array.from(this.fingerprintMap.entries())}}importState(e){if(e)try{e.selectors&&(this.selectorMap=new Map(e.selectors)),e.fingerprints&&(this.fingerprintMap=new Map(e.fingerprints)),(this.selectorMap.size>0||this.fingerprintMap.size>0)&&(this.isIndexed=!0)}catch(t){}}indexInteractableElements(){if(this.indexingInProgress)return[];try{this.indexingInProgress=!0,this.clearIndex();const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e instanceof HTMLElement&&null===e.offsetParent&&"BODY"!==e.tagName){const t=window.getComputedStyle(e),n="fixed"===t.position||"sticky"===t.position;if("none"===t.display)return NodeFilter.FILTER_REJECT;if(!n){let t=e.parentElement,n=!1;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if("fixed"===e.position||"sticky"===e.position){n=!0;break}t=t.parentElement}if(!n)return NodeFilter.FILTER_REJECT}}return NodeFilter.FILTER_ACCEPT}});let t=e.nextNode(),n=0;const r=[];for(;t;){if(t instanceof HTMLElement){const e=t.matches('a[href], button, input, textarea, select, [role="button"]'),o=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),i="onclick"in t&&"function"==typeof t.onclick;if(e||o||i||Ja(t)){this.elementMap.set(n,t),this.elementToSequence.set(t,n);const e=this.generateSelector(t);this.selectorMap.set(n,e);const o=this.generateFingerprint(t,e);this.fingerprintMap.set(n,o),r.push([n,t]),n++}}t=e.nextNode()}return this.isIndexed=!0,this.indexVersion++,r}finally{this.indexingInProgress=!1}}getElementCoordinates(e){const t=e.getBoundingClientRect(),n=this.calculateGlobalZOrder(e);return{x:Math.round(t.left),y:Math.round(t.top),w:Math.round(t.width),h:Math.round(t.height),z:n}}isStackingContext(e){const t=window.getComputedStyle(e),n=t.position;if(("fixed"===n||"absolute"===n||"relative"===n||"sticky"===n)&&"auto"!==t.zIndex)return!0;if("auto"!==t.zIndex&&e.parentElement){const t=window.getComputedStyle(e.parentElement).display;if("flex"===t||"inline-flex"===t||"grid"===t||"inline-grid"===t)return!0}const r=parseFloat(t.opacity);if(!isNaN(r)&&r<1)return!0;if(t.transform&&"none"!==t.transform)return!0;if(t.filter&&"none"!==t.filter)return!0;const o=t.willChange;if(o&&(o.includes("transform")||o.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const i=t.contain;return!(!i||!(i.includes("layout")||i.includes("style")||i.includes("paint")))}calculateGlobalZOrder(e){let t=e;const n=[];for(;t&&t!==document.body&&t.parentElement;){const e=window.getComputedStyle(t);if(this.isStackingContext(t)){let r=0;if("auto"!==e.zIndex){const t=parseInt(e.zIndex,10);isNaN(t)||(r=t)}let o=0;t.parentElement&&(o=Array.from(t.parentElement.children).indexOf(t)),n.push({element:t,zIndex:r,domOrder:o})}t=t.parentElement}let r=1e6;for(let o=n.length-1;o>=0;o--){const e=n[o];r+=1e4*e.zIndex+e.domOrder}if(e.parentElement){r+=Array.from(e.parentElement.children).indexOf(e)}return r}getSnapshotHtml(){this.indexInteractableElements();const e=document.documentElement.cloneNode(!0);for(const[n,r]of this.elementMap.entries())if(r instanceof HTMLElement){const o=this.selectorMap.get(n);if(o)try{const t=(e.querySelector("body")||e).querySelector(o);if(t)if(t.setAttribute("data-id",n.toString()),"none"===window.getComputedStyle(r).display)t.setAttribute("data-x","0"),t.setAttribute("data-y","0"),t.setAttribute("data-w","0"),t.setAttribute("data-h","0"),t.setAttribute("data-z","0");else{const e=this.getElementCoordinates(r);t.setAttribute("data-x",e.x.toString()),t.setAttribute("data-y",e.y.toString()),t.setAttribute("data-w",e.w.toString()),t.setAttribute("data-h",e.h.toString()),t.setAttribute("data-z",e.z.toString())}}catch(t){}}return e.outerHTML}getInteractableElements(){this.indexInteractableElements();const e=[];for(const[t,n]of this.elementMap.entries())if(n instanceof HTMLElement){const r=this.fingerprintMap.get(t);r&&e.push({index:t,fingerprint:r,coords:this.getElementCoordinates(n),cssClasses:Array.from(n.classList)})}return e}getElementByDataId(e){return this.elementMap.get(e)}getSequenceForElement(e){return this.elementToSequence.get(e)}isIndexActive(){return this.isIndexed}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear(),this.isIndexed=!1}checkInteractability(e,t){if(!document.body.contains(e))return`ELEMENT_NOT_INTERACTABLE: Element ${t} is not in the DOM`;const n=window.getComputedStyle(e);if("none"===n.display)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has display:none`;if("hidden"===n.visibility)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has visibility:hidden`;if(0===parseFloat(n.opacity))return`ELEMENT_NOT_INTERACTABLE: Element ${t} has opacity:0`;const r=e.getBoundingClientRect();if(0===r.width||0===r.height)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has zero dimensions`;if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth)return`ELEMENT_NOT_INTERACTABLE: Element ${t} is off-screen`;const o=r.left+r.width/2,i=r.top+r.height/2,a=document.elementFromPoint(o,i);if(a&&a!==e&&!e.contains(a)&&!(a.closest("#marketrix-show-highlight")||a.closest("#marketrix-show-popup")||a.closest("[data-marketrix-widget]"))){const e=a.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${a.className?`${e}.${a.className.split(" ")[0]}`:e}. The obscuring element may be a modal or overlay that needs to be dismissed first.`}return null}checkElementInteractable(e,t){return this.checkInteractability(e,t)}getElementByIndex(e){let t=null;if(this.elementMap.has(e)){const n=this.elementMap.get(e);n&&n instanceof HTMLElement&&(t=n)}if(!t&&this.selectorMap.has(e)){const n=this.selectorMap.get(e);if(n)try{const e=document.querySelector(n);e&&e instanceof HTMLElement&&(t=e)}catch(r){}}if(!t)return{element:null,error:`Element ${e} not found`};const n=this.checkInteractability(t,e);return n?{element:null,error:n}:{element:t}}getValidatedElement(e){const t=this.validateElementAtIndex(e);if(!t.isValid)return{element:null,validation:t,error:`DOM_CHANGED: Element at index ${e} ${"element_removed"===t.mismatchReason?"no longer exists":"has changed"}. Call get_html to get updated indices.`};const n=this.elementMap.get(e);if(!n)return{element:null,validation:t,error:`Element ${e} not found`};const r=this.checkInteractability(n,e);return r?{element:null,validation:t,error:r}:{element:n,validation:t}}getFingerprint(e){return this.fingerprintMap.get(e)}getAllFingerprints(){return Array.from(this.fingerprintMap.entries())}getIndexVersion(){return this.indexVersion}}.getInstance(),Ya=null;async function Xa(){if(Ya?.active){const e=Ya.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Ya}const e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!e||0===e.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return Ya=e,e.getVideoTracks()[0].addEventListener("ended",()=>{Ya=null}),e}function Qa(){return null!==function(){if(Ya?.active){const e=Ya.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Ya}return Ya=null,null}()}var es=class e{static instance;currentPopup=null;currentHighlight=null;currentElement=null;currentOptions=null;currentPromise=null;resolvePromise=null;rejectPromise=null;clickHandler=null;scrollHandler=null;updateHighlightPosition=null;rafId=null;mutationObserver=null;visibilityCheckInterval=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async showToolAction(e){const{element:t,explanation:n,isClickAction:r=!1,toolName:o}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===n&&this.currentOptions.toolName===o&&this.currentPromise||(this.cleanup(),this.currentOptions=e,this.currentElement=t,t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),this.createHighlight(t),this.createPopup(n,r),this.setupPositionUpdates(),this.setupElementMonitoring(),this.setupVisibilityMonitoring(),r&&this.setupClickHandler(),this.currentPromise=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t}).finally(()=>{this.cleanup()})),this.currentPromise}cleanup(){this.rejectPromise&&(this.rejectPromise("Cancelled by cleanup"),this.rejectPromise=null),this.resolvePromise=null,this.clickHandler&&(document.removeEventListener("click",this.clickHandler,{capture:!0}),this.clickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:!0}),window.removeEventListener("resize",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("wheel",this.scrollHandler),this.scrollHandler=null),null!==this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.visibilityCheckInterval&&(clearInterval(this.visibilityCheckInterval),this.visibilityCheckInterval=null),this.updateHighlightPosition=null,this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentHighlight&&(this.currentHighlight.remove(),this.currentHighlight=null);const e=document.getElementById("marketrix-show-popup");e&&e.remove();const t=document.getElementById("marketrix-show-highlight");t&&t.remove(),this.currentElement=null,this.currentOptions=null,this.currentPromise=null,this.resolvePromise=null,this.rejectPromise=null}createHighlight(e){const t=e.getBoundingClientRect(),n=document.createElement("div");n.id="marketrix-show-highlight",n.style.cssText=`\n position: fixed;\n top: ${t.top}px;\n left: ${t.left}px;\n width: ${t.width}px;\n height: ${t.height}px;\n border: 3px solid #3b82f6;\n border-radius: 4px;\n box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.4);\n z-index: 2147483645;\n pointer-events: none;\n transition: none;\n `,document.body.appendChild(n),this.currentHighlight=n}createPopup(e,t){const n=document.createElement("div");n.id="marketrix-show-popup",n.innerHTML=t?`<div style="font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>`:`<div style="margin-bottom: 12px; font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>\n <div style="display: flex; gap: 8px; justify-content: flex-end;">\n <button id="marketrix-show-continue" style="\n background: #3b82f6; color: white; border: none; border-radius: 6px;\n padding: 8px 16px; font-size: 12px; font-weight: 500; cursor: pointer;\n ">Continue</button>\n </div>`,document.body.appendChild(n),this.currentPopup=n,t||this.setupContinueButton(n),this.updatePopupPosition()}setupPositionUpdates(){this.updateHighlightPosition=()=>{if(!this.currentElement||!this.currentHighlight)return;const e=this.currentElement.getBoundingClientRect();this.currentHighlight.style.top=`${e.top}px`,this.currentHighlight.style.left=`${e.left}px`,this.currentHighlight.style.width=`${e.width}px`,this.currentHighlight.style.height=`${e.height}px`,this.updatePopupPosition()},this.scrollHandler=()=>{null!==this.rafId&&window.cancelAnimationFrame(this.rafId),this.updateHighlightPosition?.()},window.addEventListener("scroll",this.scrollHandler,{capture:!0,passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("wheel",this.scrollHandler,{passive:!0})}updatePopupPosition(){if(!this.currentPopup||!this.currentElement)return;const e=this.currentElement.getBoundingClientRect(),t=320,n=120,r=10,o=e.left+e.width/2,i=e.top+e.height/2,a=[{left:e.right+20,top:i-60},{left:e.left-t-20,top:i-60},{left:o-160,top:e.top-n-20},{left:o-160,top:e.bottom+20}];let s=a[0];for(const d of a)if(d.left>=r&&d.left+t<=window.innerWidth-r&&d.top>=r&&d.top+n<=window.innerHeight-r){s=d;break}const c=Math.max(r,Math.min(s.left,window.innerWidth-t-r)),l=Math.max(r,Math.min(s.top,window.innerHeight-n-r));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${l}px;\n left: ${c}px;\n width: 320px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n z-index: 2147483646;\n padding: 16px;\n `}setupClickHandler(){this.clickHandler=e=>{if(this.currentElement&&this.resolvePromise&&e.composedPath().includes(this.currentElement)){e.preventDefault(),e.stopPropagation();const t=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,t(!0)}},document.addEventListener("click",this.clickHandler,{capture:!0})}setupContinueButton(e){window.requestAnimationFrame(()=>{const t=e.querySelector("#marketrix-show-continue");t&&t.addEventListener("click",e=>{if(e.stopPropagation(),this.resolvePromise){const e=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,e(!0)}})})}setupElementMonitoring(){this.currentElement&&(this.mutationObserver=new MutationObserver(()=>{this.currentElement&&!document.body.contains(this.currentElement)&&this.failWithElementGone("Element was removed from DOM")}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}setupVisibilityMonitoring(){this.visibilityCheckInterval=setInterval(()=>{if(!this.currentElement)return;const e=Ka.getSequenceForElement(this.currentElement)??-1,t=Ka.checkElementInteractable(this.currentElement,e);t&&this.failWithElementGone(t)},200)}failWithElementGone(e){if(this.rejectPromise){const t=this.rejectPromise;this.rejectPromise=null,this.resolvePromise=null,t(/* @__PURE__ */new Error(`ELEMENT_GONE: ${e}`))}this.cleanup()}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}}.getInstance(),ts=class e{static instance;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async executeTool(e,t,n="do",r=""){try{if("show"===n&&this.requiresHighlight(e)){const n=t.index;if(void 0!==n){const{element:t,error:o}=Ka.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await es.showToolAction({element:t,explanation:r||`Execute ${e}`,toolName:e,isClickAction:"click_element"===e})))return{success:!1,data:{text:""},error:"User cancelled action"}}}switch(e){case"navigate":return this.navigate(t);case"search":return this.search(t);case"click_element":return await this.clickElement(t);case"type_text":return this.typeText(t);case"scroll":return this.scroll(t);case"scroll_to_text":return this.scrollToText(t);case"extract":return this.extract(t);case"go_back":return this.goBack();case"wait":return await this.wait(t);case"select_dropdown_option":return this.selectDropdownOption(t);case"get_dropdown_options":return this.getDropdownOptions(t);case"send_keys":return this.sendKeys(t);case"upload_file":return this.uploadFile(t);case"close_tab":return this.closeTab();case"switch_tab":return this.switchTab(t);case"done":return this.done(t);case"get_html":return this.getHtml();case"get_interactable_elements":return this.getInteractableElements();case"get_screenshot":return await this.getScreenshot();default:return{success:!1,data:{text:""},error:`Unknown tool: ${e}`}}}catch(o){return es.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Ea.has(e)}navigate(e){return e.url?e.new_tab?(window.open(e.url,"_blank"),{success:!0,data:{text:`Opened ${e.url} in new tab`}}):(window.location.href=e.url,{success:!0,data:{text:`Navigating to ${e.url}`}}):{success:!1,data:{text:""},error:"URL is required"}}search(e){if(!e.query)return{success:!1,data:{text:""},error:"Query is required"};const t=e.engine||"duckduckgo",n=encodeURIComponent(e.query);let r=`https://duckduckgo.com/?q=${n}`;return"google"===t&&(r=`https://www.google.com/search?q=${n}`),"bing"===t&&(r=`https://www.bing.com/search?q=${n}`),window.location.href=r,{success:!0,data:{text:`Searching for "${e.query}" on ${t}`}}}async clickElement(e){if(void 0===e.index)return{success:!1,data:{text:""},error:"Index required"};const{element:t,error:n}=Ka.getValidatedElement(e.index);return t?(t.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(e=>setTimeout(e,100)),setTimeout(()=>{try{t.click()}catch(e){try{t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}catch(n){}}},50),{success:!0,data:{text:`Clicked element ${e.index}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}typeText(e){if(void 0===e.index||void 0===e.text)return{success:!1,data:{text:""},error:"Index and text required"};const t=!1!==e.clear,{element:n,error:r}=Ka.getValidatedElement(e.index);if(!n)return{success:!1,data:{text:""},error:r||`Element ${e.index} not found`};if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n.isContentEditable){const r=n;try{r.focus()}catch(o){}const i=t?e.text:r.value+e.text;let a=!1,s=null;if(!a)try{const e="TEXTAREA"===r.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(r,i),a=!0)}catch(o){s=o}if(!a)try{r.value=i,a=!0}catch(o){s=o}if(!a)try{r.focus(),t&&r.select(),document.execCommand("insertText",!1,e.text)&&(a=!0)}catch(o){s=o}if(!a)try{r.focus(),t&&(r.value="");for(const t of e.text)r.dispatchEvent(new KeyboardEvent("keydown",{key:t,bubbles:!0,cancelable:!0})),r.value+=t,r.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),r.dispatchEvent(new KeyboardEvent("keyup",{key:t,bubbles:!0,cancelable:!0}));a=!0}catch(o){s=o}if(!a)return{success:!1,data:{text:""},error:`Failed to set value: ${s instanceof Error?s.message:String(s)}`};try{const t=new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:e.text});r.dispatchEvent(t),r.dispatchEvent(new Event("change",{bubbles:!0})),r.dispatchEvent(new Event("blur",{bubbles:!0}))}catch(o){}}else if("value"in n)try{n.value=e.text,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set value on element: ${o instanceof Error?o.message:String(o)}`}}else try{n.textContent=e.text,n.dispatchEvent(new Event("input",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set textContent: ${o instanceof Error?o.message:String(o)}`}}return{success:!0,data:{text:`Typed text into element ${e.index}`}}}scroll(e){const t=.8*window.innerHeight;switch(e.direction){case"down":window.scrollBy({top:t,behavior:"smooth"});break;case"up":window.scrollBy({top:-t,behavior:"smooth"});break;case"left":window.scrollBy({left:-t,behavior:"smooth"});break;case"right":window.scrollBy({left:t,behavior:"smooth"});break;default:return{success:!1,data:{text:""},error:"Invalid direction"}}return{success:!0,data:{text:`Scrolled ${e.direction}`}}}scrollToText(e){if(!e.text)return{success:!1,data:{text:""},error:"Text required"};const t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT);let n;for(;n=t.nextNode();)if(n.textContent?.includes(e.text)&&n.parentElement)return n.parentElement.scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,data:{text:`Scrolled to "${e.text}"`}};return{success:!1,data:{text:""},error:`Text "${e.text}" not found`}}extract(e){const t=e.start_from_char??0,n=!1!==e.extract_links,r=document.body.innerText;return{success:!0,data:{title:document.title,url:window.location.href,text:r.slice(t,t+1e4),links:n?Array.from(document.querySelectorAll("a[href]")).slice(0,100).map(e=>({text:e.textContent?.trim()||"",href:e.getAttribute("href")})):[]}}}goBack(){return window.history.length>1?(window.history.back(),{success:!0,data:{text:"Navigated back"}}):{success:!1,data:{text:""},error:"No history"}}async wait(e){return void 0===e.seconds?{success:!1,data:{text:""},error:"Seconds required"}:(await new Promise(t=>setTimeout(t,1e3*e.seconds)),{success:!0,data:{text:`Waited ${e.seconds}s`}})}selectDropdownOption(e){if(void 0===e.index||!e.option)return{success:!1,data:{text:""},error:"Index/Option required"};const{element:t,error:n}=Ka.getValidatedElement(e.index);if(!t)return{success:!1,data:{text:""},error:n||`Select ${e.index} not found`};if(!(t instanceof HTMLSelectElement))return{success:!1,data:{text:""},error:`Element ${e.index} is not a select element`};const r=Array.from(t.options).find(t=>t.value===e.option||t.text===e.option);return r?(t.value=r.value,t.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,data:{text:`Selected ${e.option}`}}):{success:!1,data:{text:""},error:`Option ${e.option} not found`}}getDropdownOptions(e){const t=e.index,{element:n,error:r}=Ka.getValidatedElement(t);return n?n instanceof HTMLSelectElement?{success:!0,data:{options:Array.from(n.options).map(e=>({value:e.value,text:e.text}))}}:{success:!1,data:{options:[]},error:`Element ${t} is not a select element`}:{success:!1,data:{options:[]},error:r||`Select ${t} not found`}}sendKeys(e){if(void 0===e.index||!e.keys)return{success:!1,data:{text:""},error:"Index/Keys required"};const{element:t,error:n}=Ka.getValidatedElement(e.index);return t?(t.focus(),t.dispatchEvent(new KeyboardEvent("keydown",{key:e.keys,bubbles:!0,cancelable:!0})),t.dispatchEvent(new KeyboardEvent("keyup",{key:e.keys,bubbles:!0,cancelable:!0})),{success:!0,data:{text:this.simulateKeyAction(t,e.keys)||`Sent keys ${e.keys}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}simulateKeyAction(e,t){switch(t){case"Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(-1!==n&&n<t.length-1){const e=t[n+1];return e.focus(),`Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Tab: no next focusable element"}case"Shift+Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(n>0){const e=t[n-1];return e.focus(),`Shift+Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Shift+Tab: no previous focusable element"}case"Enter":if(e instanceof HTMLButtonElement||"button"===e.getAttribute("role"))return e.click(),"Enter: clicked button";if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.closest("form");if(t){const e=t.querySelector('button[type="submit"], input[type="submit"]');return e?(e.click(),"Enter: clicked form submit button"):(t.requestSubmit(),"Enter: submitted form")}}return e instanceof HTMLAnchorElement?(e.click(),"Enter: clicked link"):"Enter: dispatched event";case"Escape":return e.blur(),document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0,cancelable:!0})),"Escape: blurred element and dispatched to document";case" ":case"Space":return e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?(e.click(),`Space: toggled ${e.type}`):e instanceof HTMLButtonElement||"button"===e.getAttribute("role")?(e.click(),"Space: clicked button"):"Space: dispatched event";case"ArrowDown":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t<e.options.length-1?(e.selectedIndex=t+1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowDown: selected "${e.options[e.selectedIndex].text}"`):"ArrowDown: already at last option"}return"ArrowDown: dispatched event";case"ArrowUp":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t>0?(e.selectedIndex=t-1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowUp: selected "${e.options[e.selectedIndex].text}"`):"ArrowUp: already at first option"}return"ArrowUp: dispatched event";case"Home":return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?(e.setSelectionRange(0,0),"Home: moved cursor to start"):"Home: dispatched event";case"End":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value.length;return e.setSelectionRange(t,t),"End: moved cursor to end"}return"End: dispatched event";case"Backspace":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value;if(!t||0===t.length)return"Backspace: input is empty, nothing to delete";let n,r,o=e.selectionStart??t.length,i=e.selectionEnd??t.length;if(0===o&&0===i&&(o=t.length,i=t.length),o===i&&o>0)n=t.slice(0,o-1)+t.slice(i),r=o-1;else{if(o===i)return"Backspace: cursor at start, nothing to delete";n=t.slice(0,o)+t.slice(i),r=o}const a=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return a?a.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(r,r),`Backspace: deleted character, value is now "${n}"`}return"Backspace: dispatched event";case"Delete":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.selectionStart||0,n=e.selectionEnd||0,r=e.value;let o;if(t===n&&t<r.length)o=r.slice(0,t)+r.slice(n+1);else{if(t===n)return"Delete: cursor at end, nothing to delete";o=r.slice(0,t)+r.slice(n)}const i=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return i?i.call(e,o):e.value=o,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${o}"`}return"Delete: dispatched event";default:return null}}uploadFile(e){return{success:!1,data:{text:""},error:"File upload not supported via script"}}closeTab(){return window.close(),{success:!0,data:{text:"Attempted close"}}}switchTab(e){return e.tab_id?{success:!1,data:{text:""},error:"Tab switching not supported"}:{success:!1,data:{text:""},error:"tab_id is required"}}done(e){return void 0===e.success?{success:!1,data:{text:""},error:"success parameter is required"}:{success:!0,data:{text:e.message||(e.success?"Task completed":"Task failed")}}}getHtml(){try{return{success:!0,data:{text:Ka.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Ka.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Xa();if(!e)return{success:!1,data:{text:""},error:"Failed to get stream"};const t=document.createElement("video");t.srcObject=e,t.autoplay=!0,t.style.display="none",document.body.appendChild(t),await new Promise(e=>{t.onloadeddata=()=>e()});const n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d")?.drawImage(t,0,0);const r=n.toDataURL("image/jpeg",.75);return t.remove(),{success:!0,data:{text:r}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}}.getInstance(),ns=e=>({state:e,effects:[]});function rs(e,t,n,r,o,i,a){const s=function(e){return Ta[e]?Ta[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Sa({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Ea.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=Ia(e),o=r.parts||[],i=[...o],a=o.findIndex(e=>"progress"===e.type&&e.toolName===t&&"in_progress"===e.status),s=!Ca.has(t),c="default",l=Ma(n);return a>=0?i[a]={...i[a],content:l,hideIcon:s,textStyle:c}:i.push({type:"progress",content:l,status:"in_progress",toolName:t,hideIcon:s,textStyle:c}),{...r,parts:i}}(l,s,o||s)),t&&p&&(l=za(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=Ia(e),r=n.parts||[],o=[...r];let i=-1;if(t)i=r.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);else for(let a=r.length-1;a>=0;a--)if("progress"===r[a].type&&"in_progress"===r[a].status){i=a;break}return i>=0&&(o[i]={...o[i],status:"completed"}),{...n,parts:o}}(l)),t&&p&&(l=za(l,t,n,!1))):(l=function(e,t,n){const r=Ia(e),o=r.parts||[],i=n.toLowerCase().includes("cancelled by cleanup"),a=[...o];let s=o.map(e=>"progress"===e.type?e.toolName:"").lastIndexOf(t);if(-1===s)for(let c=o.length-1;c>=0;c--)if("progress"===o[c].type&&"in_progress"===o[c].status){s=c;break}if(s>=0)if(i){const e=Ma(a[s].content);a[s]={...a[s],status:"completed",content:e}}else{const e=Ma(n),t=Ma(a[s].content);a[s]={...a[s],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:a}}(l,s,a||""),t&&p&&(l=za(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function os(e,t,n,r,o,i){return{...e,messages:rs(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var is=n(void 0),as=({children:e,previewMode:t=!1,currentMode:n,setMessages:r,messagesRef:o,uiActions:a,activeTaskIdRef:c})=>{const[l,h]=p({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),m=u(l);m.current=l;const g=u(0),y=u(/* @__PURE__ */new Set),w=u({}),b=u(n);b.current=n,s(()=>{c.current=l.activeTaskId},[l.activeTaskId,c]);const v=i(e=>{if(y.current.add(e),y.current.size>1e3){const e=Array.from(y.current);y.current=new Set(e.slice(-500))}},[]),x=i(e=>{const t={activeTaskId:m.current.activeTaskId,isTaskRunning:m.current.isTaskRunning};let n=t;r(r=>{const i=e({messages:r.messages,task:t});return n=i.task,o.current=i.messages,i.messages===r.messages?r:{messages:i.messages}}),n.isTaskRunning===t.isTaskRunning&&n.activeTaskId===t.activeTaskId||(m.current={...m.current,...n,taskProgress:[]},h(m.current))},[r,o]),k=i(()=>{const e=w.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;w.current={},x(e=>({...e,task:{isTaskRunning:!0,activeTaskId:t}}))}},[x]);s(()=>{if(t)return;const e=Wa.getInstance(),n=async t=>{const{callId:n,tool:r,args:o,mode:i,explanation:a}=t,s=await ts.executeTool(r,o,i,a);if(s.success)try{g.current++,e.send({type:"tool/response",call_id:n,success:!0,data:"string"==typeof s.data?s.data:JSON.stringify(s.data),state_version:g.current}).catch(e=>{}),x(e=>os(e,r,a,"completed",b.current)),"done"===r&&(w.current={},x(e=>function(e,t){const n=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];if(n){const e=(n.message.parts??[]).filter(e=>!("progress"===e.type&&"done"===e.toolName));r[n.index]={...n.message,taskStatus:"done",parts:e}}return{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,b.current)))}catch(c){x(e=>os(e,r,a,"failed",b.current,"Connection error"))}else x(e=>os(e,r,a,"failed",b.current,s.error||"Tool execution failed")),g.current++,e.send({type:"tool/response",call_id:n,success:!1,data:"string"==typeof s.data?s.data:JSON.stringify(s.data),error:s.error??void 0,state_version:g.current}).catch(e=>{})},r={onStatusChange:e=>{a.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const n=t.call_id;if(y.current.has(n))return;if(v(n),!va.map(e=>e.id).includes(t.tool))return void e.send({type:"tool/response",call_id:n,success:!1,error:`Unknown tool: ${t.tool}`,state_version:g.current}).catch(e=>{});m.current.isTaskRunning,void 0!==t.state_version&&t.state_version>g.current&&(g.current=t.state_version)}else if("task/status"!==t.type||"completed"!==t.status&&"failed"!==t.status&&"stopped"!==t.status){if("task/status"===t.type&&"has_question"===t.status)w.current={};else if("task/status"===t.type&&"running"===t.status)return w.current={...w.current,agentRunning:!0,apiTaskId:w.current.apiTaskId||t.task_id||void 0},void k()}else y.current.clear(),w.current={};let r=[];x(e=>{const n=function(e,t,n){switch(t.type){case"tool/call":{const r=e.task.isTaskRunning?e.task:{...e.task,isTaskRunning:!0},o=r.isTaskRunning,i=t.mode||n||"do",a=t.explanation||"";return{state:{messages:rs(e.messages,o,n,t.tool,a,"in_progress"),task:r},effects:[{type:"executeTool",callId:t.call_id,tool:t.tool,args:t.args,mode:i,explanation:a}]}}case"task/status":{const r=t.message||"";if("running"===t.status)return ns(e);if("has_question"===t.status){const t=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=za(t.message,!1,n);o[t.index]={...e,placeholderState:"waiting-for-user",...r&&{content:r}}}return{state:{messages:o,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}const o=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),i=[...e.messages];if(o){let e="done";"failed"===t.status?e="failed":"stopped"===t.status&&(e="stopped"),i[o.index]={...o.message,taskStatus:e,...r&&{content:r}}}return{state:{messages:i,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}case"chat/response":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=[...e.parts??[],{type:"text",content:t.text}];return{...e,content:t.text,isPlaceholder:!1,placeholderState:void 0,parts:n,...t.task_id&&{taskId:t.task_id}}}),r=[{type:"setLoading",value:!1}];return t.task_id&&r.push({type:"activateApiTask",taskId:t.task_id}),{state:{...e,messages:n},effects:r}}case"chat/error":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=`Error: ${t.error}`,r=[...e.parts??[],{type:"text",content:n}];return{...e,content:n,isPlaceholder:!1,placeholderState:void 0,parts:r}});return{state:{...e,messages:n},effects:[{type:"setLoading",value:!1}]}}default:return ns(e)}}(e,t,b.current);return r=n.effects,n.state}),(e=>{for(const t of e)"setLoading"===t.type?a.setLoading(t.value):"activateApiTask"===t.type&&(w.current={...w.current,apiTaskId:t.taskId},k())})(r);const o=r.find(e=>"executeTool"===e.type);"executeTool"===o?.type&&await n(o)},onError:e=>{a.setError(e.message)}};return e.addCallbacks(r),()=>{e.removeCallbacks(r)}},[t,x,k,v,a]);const _=i(e=>{h(t=>{const n={...t,...e};return m.current=n,n})},[]),S=i(async()=>{const e=c.current??void 0;x(e=>function(e,t){const n=Sa({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];return n&&(r[n.index]={...n.message,taskStatus:"stopped"}),{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,b.current)),t||Wa.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,x,c]),I=d(()=>({setTaskState:_,stopTask:S}),[_,S]);/* @__PURE__ */
4
+ return f(is.Provider,{value:{taskState:l,taskActions:I},children:e})},ss=()=>{const e=a(is);if(!e)throw new Error("useTaskContext must be used within TaskProvider");return e},cs=n(void 0),ls=({children:e,initialMode:t="tell",initialIsOpen:n=!1,initialIsMinimized:r=!1})=>{const[o,i]=p({isOpen:n,isMinimized:r,activeView:"home",currentMode:t,agentAvailable:!1,isLoading:!1}),a=d(()=>({setActiveView:e=>i(t=>({...t,activeView:e})),toggleWidget:()=>i(e=>({...e,isOpen:!e.isOpen,isMinimized:!!e.isOpen})),closeWidget:()=>i(e=>({...e,isOpen:!1,isMinimized:!0})),setMode:e=>i(t=>({...t,currentMode:e})),setLoading:e=>i(t=>({...t,isLoading:e})),setAgentAvailable:e=>i(t=>({...t,agentAvailable:e})),setError:e=>i(t=>({...t,error:e})),clearError:()=>i(e=>({...e,error:void 0})),applyState:e=>i(t=>({...t,...e}))}),[]);/* @__PURE__ */
5
+ return f(cs.Provider,{value:{uiState:o,uiActions:a},children:e})},ds=()=>{const e=a(cs);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var us=({config:e}={})=>{const{uiState:t,uiActions:n}=ds(),{chatState:r,chatActions:o}=Ga(),{taskState:a,taskActions:c}=ss(),l=d(()=>({isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading,currentMode:t.currentMode,agentAvailable:t.agentAvailable,error:t.error,activeView:t.activeView,messages:r.messages,activeTaskId:a.activeTaskId,isTaskRunning:a.isTaskRunning,taskProgress:a.taskProgress}),[t,r,a]),u=i(e=>{n.applyState({...void 0!==e.isOpen&&{isOpen:e.isOpen},...void 0!==e.isMinimized&&{isMinimized:e.isMinimized},...void 0!==e.isLoading&&{isLoading:e.isLoading},...void 0!==e.currentMode&&{currentMode:e.currentMode},...void 0!==e.agentAvailable&&{agentAvailable:e.agentAvailable},...void 0!==e.error&&{error:e.error},...void 0!==e.activeView&&{activeView:e.activeView}}),void 0!==e.messages&&o.setMessages(e.messages),void 0===e.activeTaskId&&void 0===e.isTaskRunning&&void 0===e.taskProgress||c.setTaskState({activeTaskId:e.activeTaskId??a.activeTaskId,isTaskRunning:e.isTaskRunning??a.isTaskRunning,taskProgress:e.taskProgress??a.taskProgress})},[n,o,c,a]),p=i(()=>{o.clearMessages(),c.setTaskState({activeTaskId:null,isTaskRunning:!1,taskProgress:[]}),n.setError(void 0)},[o,c,n]),h=d(()=>({setState:u,setActiveView:n.setActiveView,toggleWidget:n.toggleWidget,closeWidget:n.closeWidget,setMode:n.setMode,setLoading:n.setLoading,setAgentAvailable:n.setAgentAvailable,setError:n.setError,clearError:n.clearError,setTaskState:c.setTaskState,stopTask:c.stopTask,addMessage:o.addMessage,updateMessage:o.updateMessage,removeMessage:o.removeMessage,setMessages:o.setMessages,sendMessage:o.sendMessage,resetState:p,clearChatHistory:p}),[u,n,c,o,p]),m=d(()=>e||Ha.getConfig()||{},[e]),f=function(e){return Object.keys(sa.shape).every(t=>void 0!==e[t])}(m);s(()=>{f&&Ha.saveConfig(m)},[m,f]);const g=m.isPreviewMode??!1;return{state:l,actions:h,config:m,shouldShow:f&&!0===m.widget_enabled,isPreviewMode:g,configValid:f}},ps=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),hs="-",ms=[],fs=e=>{const t=ws(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return ys(e);const n=e.split(hs);return gs(n,""===n[0]&&n.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=r[e],o=n[e];return t?o?((e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n})(o,t):t:o||ms}return n[e]||ms}}},gs=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],o=n.nextPart.get(r);if(o){const n=gs(e,t+1,o);if(n)return n}const i=n.validators;if(null===i)return;const a=0===t?e.join(hs):e.slice(t).join(hs),s=i.length;for(let c=0;c<s;c++){const e=i[c];if(e.validator(a))return e.classGroupId}},ys=e=>-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?"arbitrary.."+r:void 0})(),ws=e=>{const{theme:t,classGroups:n}=e;return bs(n,t)},bs=(e,t)=>{const n=ps();for(const r in e){const o=e[r];vs(o,n,r,t)}return n},vs=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const o=e[i];xs(o,t,n,r)}},xs=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?Ss(e,t,n,r):_s(e,t,n,r):ks(e,t,n)},ks=(e,t,n)=>{(""===e?t:Is(t,e)).classGroupId=n},_s=(e,t,n,r)=>{Cs(e)?vs(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},Ss=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[e,i]=o[a];vs(i,Is(t,e),n,r)}},Is=(e,t)=>{let n=e;const r=t.split(hs),o=r.length;for(let i=0;i<o;i++){const e=r[i];let t=n.nextPart.get(e);t||(t=ps(),n.nextPart.set(e,t)),n=t}return n},Cs=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Es=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(o,i)=>{n[o]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];return void 0!==t?t:void 0!==(t=r[e])?(o(e,t),t):void 0},set(e,t){e in n?n[e]=t:o(e,t)}}},Ms=[],zs=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Ts=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=e=>{const t=[];let n,r=0,o=0,i=0;const a=e.length;for(let d=0;d<a;d++){const a=e[d];if(0===r&&0===o){if(":"===a){t.push(e.slice(i,d)),i=d+1;continue}if("/"===a){n=d;continue}}"["===a?r++:"]"===a?r--:"("===a?o++:")"===a&&o--}const s=0===t.length?e:e.slice(i);let c=s,l=!1;s.endsWith("!")?(c=s.slice(0,-1),l=!0):s.startsWith("!")&&(c=s.slice(1),l=!0);return zs(t,l,c,n&&n>i?n-i:void 0)};if(t){const e=t+":",n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):zs(Ms,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},As=e=>{const t=/* @__PURE__ */new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{const n=[];let r=[];for(let o=0;o<e.length;o++){const i=e[o],a="["===i[0],s=t.has(i);a||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(i)):r.push(i)}return r.length>0&&(r.sort(),n.push(...r)),n}},Os=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},Ns=/\s+/,Rs=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Rs(e[r]))&&(n&&(n+=" "),n+=t);return n},Ls=(e,...t)=>{let n,r,o,i;const a=e=>{const t=r(e);if(t)return t;const i=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i,postfixLookupClassGroupIds:a}=t,s=[],c=e.trim().split(Ns);let l="";for(let d=c.length-1;d>=0;d-=1){const e=c[d],{isExternal:t,modifiers:u,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:m}=n(e);if(t){l=e+(l.length>0?" "+l:l);continue}let f,g=!!m;if(g){f=r(h.substring(0,m));const e=f&&a[f]?r(h):void 0;e&&e!==f&&(f=e,g=!1)}else f=r(h);if(!f){if(!g){l=e+(l.length>0?" "+l:l);continue}if(f=r(h),!f){l=e+(l.length>0?" "+l:l);continue}g=!1}const y=0===u.length?"":1===u.length?u[0]:i(u).join(":"),w=p?y+"!":y,b=w+f;if(s.indexOf(b)>-1)continue;s.push(b);const v=o(f,g);for(let n=0;n<v.length;++n){const e=v[n];s.push(w+e)}l=e+(l.length>0?" "+l:l)}return l})(e,n);return o(e,i),i};return i=s=>(n=(e=>({cache:Es(e.cacheSize),parseClassName:Ts(e),sortModifiers:As(e),postfixLookupClassGroupIds:Os(e),...fs(e)}))(t.reduce((e,t)=>t(e),e())),r=n.cache.get,o=n.cache.set,i=a,a(s)),(...e)=>i(((...e)=>{let t,n,r=0,o="";for(;r<e.length;)(t=e[r++])&&(n=Rs(t))&&(o&&(o+=" "),o+=n);return o})(...e))},$s=[],Ps=e=>{const t=t=>t[e]||$s;return t.isThemeGetter=!0,t},Ds=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,js=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Fs=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Bs=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ws=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Us=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Hs=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Vs=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Zs=e=>Fs.test(e),qs=e=>!!e&&!Number.isNaN(Number(e)),Gs=e=>!!e&&Number.isInteger(Number(e)),Js=e=>e.endsWith("%")&&qs(e.slice(0,-1)),Ks=e=>Bs.test(e),Ys=()=>!0,Xs=e=>Ws.test(e)&&!Us.test(e),Qs=()=>!1,ec=e=>Hs.test(e),tc=e=>Vs.test(e),nc=e=>!ic(e)&&!hc(e),rc=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),oc=e=>xc(e,Ic,Qs),ic=e=>Ds.test(e),ac=e=>xc(e,Cc,Xs),sc=e=>xc(e,Ec,qs),cc=e=>xc(e,zc,Ys),lc=e=>xc(e,Mc,Qs),dc=e=>xc(e,_c,Qs),uc=e=>xc(e,Sc,tc),pc=e=>xc(e,Tc,ec),hc=e=>js.test(e),mc=e=>kc(e,Cc),fc=e=>kc(e,Mc),gc=e=>kc(e,_c),yc=e=>kc(e,Ic),wc=e=>kc(e,Sc),bc=e=>kc(e,Tc,!0),vc=e=>kc(e,zc,!0),xc=(e,t,n)=>{const r=Ds.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},kc=(e,t,n=!1)=>{const r=js.exec(e);return!!r&&(r[1]?t(r[1]):n)},_c=e=>"position"===e||"percentage"===e,Sc=e=>"image"===e||"url"===e,Ic=e=>"length"===e||"size"===e||"bg-size"===e,Cc=e=>"length"===e,Ec=e=>"number"===e,Mc=e=>"family-name"===e,zc=e=>"number"===e||"weight"===e,Tc=e=>"shadow"===e,Ac=/*#__PURE__*/Ls(()=>{const e=Ps("color"),t=Ps("font"),n=Ps("text"),r=Ps("font-weight"),o=Ps("tracking"),i=Ps("leading"),a=Ps("breakpoint"),s=Ps("container"),c=Ps("spacing"),l=Ps("radius"),d=Ps("shadow"),u=Ps("inset-shadow"),p=Ps("text-shadow"),h=Ps("drop-shadow"),m=Ps("blur"),f=Ps("perspective"),g=Ps("aspect"),y=Ps("ease"),w=Ps("animate"),b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",hc,ic],v=()=>[hc,ic,c],x=()=>[Zs,"full","auto",...v()],k=()=>[Gs,"none","subgrid",hc,ic],_=()=>["auto",{span:["full",Gs,hc,ic]},Gs,hc,ic],S=()=>[Gs,"auto",hc,ic],I=()=>["auto","min","max","fr",hc,ic],C=()=>["auto",...v()],E=()=>[Zs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],M=()=>[Zs,"screen","full","dvw","lvw","svw","min","max","fit",...v()],z=()=>[Zs,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],T=()=>[e,hc,ic],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",gc,dc,{position:[hc,ic]}],O=()=>["auto","cover","contain",yc,oc,{size:[hc,ic]}],N=()=>[Js,mc,ac],R=()=>["","none","full",l,hc,ic],L=()=>["",qs,mc,ac],$=()=>[qs,Js,gc,dc],P=()=>["","none",m,hc,ic],D=()=>["none",qs,hc,ic],j=()=>["none",qs,hc,ic],F=()=>[qs,hc,ic],B=()=>[Zs,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ks],breakpoint:[Ks],color:[Ys],container:[Ks],"drop-shadow":[Ks],ease:["in","out","in-out"],font:[nc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ks],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ks],shadow:[Ks],spacing:["px",qs],text:[Ks],"text-shadow":[Ks],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Zs,ic,hc,g]}],container:["container"],"container-type":[{"@container":["","normal","size",hc,ic]}],"container-named":[rc],columns:[{columns:[qs,ic,hc,s]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:b()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:x()}],"inset-x":[{"inset-x":x()}],"inset-y":[{"inset-y":x()}],start:[{"inset-s":x(),start:x()}],end:[{"inset-e":x(),end:x()}],"inset-bs":[{"inset-bs":x()}],"inset-be":[{"inset-be":x()}],top:[{top:x()}],right:[{right:x()}],bottom:[{bottom:x()}],left:[{left:x()}],visibility:["visible","invisible","collapse"],z:[{z:[Gs,"auto",hc,ic]}],basis:[{basis:[Zs,"full","auto",s,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[qs,Zs,"auto","initial","none",ic]}],grow:[{grow:["",qs,hc,ic]}],shrink:[{shrink:["",qs,hc,ic]}],order:[{order:[Gs,"first","last","none",hc,ic]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:_()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:_()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:E()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...z()]}],"min-block-size":[{"min-block":["auto",...z()]}],"max-block-size":[{"max-block":["none",...z()]}],w:[{w:[s,"screen",...E()]}],"min-w":[{"min-w":[s,"screen","none",...E()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[a]},...E()]}],h:[{h:["screen","lh",...E()]}],"min-h":[{"min-h":["screen","lh","none",...E()]}],"max-h":[{"max-h":["screen","lh",...E()]}],"font-size":[{text:["base",n,mc,ac]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vc,cc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Js,ic]}],"font-family":[{font:[fc,lc,t]}],"font-features":[{"font-features":[ic]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,hc,ic]}],"line-clamp":[{"line-clamp":[qs,"none",hc,sc]}],leading:[{leading:[i,...v()]}],"list-image":[{"list-image":["none",hc,ic]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",hc,ic]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[qs,"from-font","auto",hc,ac]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[qs,"auto",hc,ic]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[Gs,hc,ic]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",hc,ic]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",hc,ic]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:A()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:O()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Gs,hc,ic],radial:["",hc,ic],conic:[Gs,hc,ic]},wc,uc]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":L()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[qs,hc,ic]}],"outline-w":[{outline:["",qs,mc,ac]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","none",d,bc,pc]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",u,bc,pc]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[qs,ac]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",p,bc,pc]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[qs,hc,ic]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[qs]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[hc,ic]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[qs]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:A()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",hc,ic]}],filter:[{filter:["","none",hc,ic]}],blur:[{blur:P()}],brightness:[{brightness:[qs,hc,ic]}],contrast:[{contrast:[qs,hc,ic]}],"drop-shadow":[{"drop-shadow":["","none",h,bc,pc]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",qs,hc,ic]}],"hue-rotate":[{"hue-rotate":[qs,hc,ic]}],invert:[{invert:["",qs,hc,ic]}],saturate:[{saturate:[qs,hc,ic]}],sepia:[{sepia:["",qs,hc,ic]}],"backdrop-filter":[{"backdrop-filter":["","none",hc,ic]}],"backdrop-blur":[{"backdrop-blur":P()}],"backdrop-brightness":[{"backdrop-brightness":[qs,hc,ic]}],"backdrop-contrast":[{"backdrop-contrast":[qs,hc,ic]}],"backdrop-grayscale":[{"backdrop-grayscale":["",qs,hc,ic]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[qs,hc,ic]}],"backdrop-invert":[{"backdrop-invert":["",qs,hc,ic]}],"backdrop-opacity":[{"backdrop-opacity":[qs,hc,ic]}],"backdrop-saturate":[{"backdrop-saturate":[qs,hc,ic]}],"backdrop-sepia":[{"backdrop-sepia":["",qs,hc,ic]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",hc,ic]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[qs,"initial",hc,ic]}],ease:[{ease:["linear","initial",y,hc,ic]}],delay:[{delay:[qs,hc,ic]}],animate:[{animate:["none",w,hc,ic]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,hc,ic]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:D()}],"rotate-x":[{"rotate-x":D()}],"rotate-y":[{"rotate-y":D()}],"rotate-z":[{"rotate-z":D()}],scale:[{scale:j()}],"scale-x":[{"scale-x":j()}],"scale-y":[{"scale-y":j()}],"scale-z":[{"scale-z":j()}],"scale-3d":["scale-3d"],skew:[{skew:F()}],"skew-x":[{"skew-x":F()}],"skew-y":[{"skew-y":F()}],transform:[{transform:[hc,ic,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:B()}],"translate-x":[{"translate-x":B()}],"translate-y":[{"translate-y":B()}],"translate-z":[{"translate-z":B()}],"translate-none":["translate-none"],zoom:[{zoom:[Gs,hc,ic]}],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",hc,ic]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":T()}],"scrollbar-track-color":[{"scrollbar-track":T()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",hc,ic]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[qs,mc,ac,sc]}],stroke:[{stroke:["none",...T()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Oc(...e){return Ac(e.filter(Boolean).join(" "))}var Nc={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)"},Rc={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",theme:"rounded-[var(--radius)]",pill:"rounded-full",circle:"rounded-full"},Lc={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},$c={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Pc={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},Dc={info:{background:"#f0f9ff",border:"1px solid #bae6fd",titleColor:"#0c4a6e",bodyColor:"#0369a1",closeColor:"#7dd3fc",closeHoverColor:"#38bdf8",actionBackground:"#e0f2fe"},error:{background:"#fef2f2",border:"1px solid #fecaca",titleColor:"#b91c1c",bodyColor:"#b91c1c",closeColor:"#f87171",closeHoverColor:"#ef4444",actionBackground:"#fee2e2"}};function jc(e){if(e&&"none"!==e)return{boxShadow:Nc[e]}}var Fc={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Bc=new Set(["padding","paddingX","paddingY","paddingTop","paddingBottom","margin","marginX","marginY","marginTop","marginBottom","gap","align","justify","wrap","grow","shrink","position","inset","overflow","overflowY","width","height","minWidth","minHeight","border","rounded","shadow","cursor","opacity","animate","hidden","as","style"]);function Wc(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Fc[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Fc[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Fc[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Fc[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Fc[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Fc[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Fc[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Fc[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Fc[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Fc[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Fc[e.gap]}`),void 0!==e.align&&t.push(`items-${e.align}`),void 0!==e.justify&&t.push(`justify-${e.justify}`),!0===e.wrap&&t.push("flex-wrap"),!0===e.grow&&t.push("flex-1"),!1===e.shrink&&t.push("flex-shrink-0"),void 0!==e.position&&t.push(e.position),void 0!==e.inset&&t.push("0"===e.inset?"inset-0":`inset-${Fc[e.inset]}`),void 0!==e.overflow&&t.push(`overflow-${e.overflow}`),void 0!==e.overflowY&&t.push(`overflow-y-${e.overflowY}`),void 0!==e.width&&t.push(`w-${e.width}`),void 0!==e.height&&t.push(`h-${e.height}`),"0"===e.minWidth&&t.push("min-w-0"),"0"===e.minHeight&&t.push("min-h-0"),void 0!==e.border&&!1!==e.border)if(!0===e.border)t.push("border","border-border");else{const n={top:"t",bottom:"b",left:"l",right:"r"}[e.border];t.push(`border-${n}`,"border-border")}if(void 0!==e.rounded&&!1!==e.rounded)if(!0===e.rounded)t.push(Rc.theme);else if("full"===e.rounded)t.push(Rc.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Rc[n])}return!0!==e.shadow&&"theme"!==e.shadow||t.push("shadow-[var(--shadow)]"),void 0!==e.cursor&&t.push(`cursor-${e.cursor}`),void 0!==e.opacity&&t.push(`opacity-${e.opacity}`),void 0!==e.animate&&"none"!==e.animate&&t.push({spin:"animate-spin",ping:"animate-ping",pulse:"animate-pulse",fadeIn:"animate-fade-in"}[e.animate]),!0===e.hidden&&t.push("hidden"),t.join(" ")}function Uc(e){const t={};for(const n in e)Bc.has(n)||(t[n]=e[n]);return t}var Hc={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Vc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Zc=o(function(e,t){const{as:n="div",background:r="default",className:o,elevation:i,paddingPreset:a="none",radius:s,style:c,...l}=e,d=Wc(e);/* @__PURE__ */
6
+ return f(n,{...Uc(l),ref:t,className:Oc(Hc[r],Vc[a],s&&Wc({rounded:s}),d,o),style:{...jc(i),...c}})}),qc="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",Gc={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"},Jc=o(function({src:e,alt:t,elevation:n,fit:r="contain",size:o="md",rounded:i,className:a,style:s,...c},l){const d="string"==typeof o,u=d?Gc[o]:void 0,p=d?s:{width:o,height:o,...s};/* @__PURE__ */
7
+ return f("img",{...c,ref:l,alt:t,className:Oc("flex-shrink-0","contain"===r?"object-contain":"object-cover",u,!0===i||"theme"===i?Rc.theme:"full"===i?Rc.pill:i?Rc[i]:void 0,a),src:e,style:{...jc(n),...p}})});function Kc(e){return"undefined"!=typeof window&&(e instanceof HTMLElement||e instanceof(t=e,(null==t||null==(n=t.ownerDocument)?void 0:n.defaultView)||window).HTMLElement);var t,n}var Yc={...e},Xc={};function Qc(t,n){const r=e.useRef(Xc);return r.current===Xc&&(r.current=t(n)),r}var el=Yc.useInsertionEffect,tl=el&&el!==Yc.useLayoutEffect?el:e=>e();function nl(e){const t=Qc(rl).current;return t.next=e,tl(t.effect),t.trampoline}function rl(){const e={next:void 0,callback:ol,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function ol(){}var il="undefined"!=typeof document?e.useLayoutEffect:()=>{};function al(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var sl={};function cl(e,t,n,r,o){if(!(n||r||o||e))return ll(t);let i=ll(e);return t&&(i=dl(i,t)),n&&(i=dl(i,n)),r&&(i=dl(i,r)),o&&(i=dl(i,o)),i}function ll(e){return pl(e)?{...hl(e,sl)}:function(e){const t={...e};for(const n in t){const e=t[n];ul(n,e)&&(t[n]=fl(e))}return t}(e)}function dl(e,t){return pl(t)?hl(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=al(e.style,r);break;case"className":e[n]=yl(e.className,r);break;default:ul(n,r)?e[n]=ml(e[n],r):e[n]=r}}return e}(e,t)}function ul(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 pl(e){return"function"==typeof e}function hl(e,t){return pl(e)?e(t):e??sl}function ml(e,t){return t?e?(...n)=>{const r=n[0];if(wl(r)){const o=r;gl(o);const i=t(...n);return o.baseUIHandlerPrevented||e?.(...n),i}const o=t(...n);return e?.(...n),o}:fl(t):e}function fl(e){return e?(...t)=>{const n=t[0];return wl(n)&&gl(n),e(...t)}:e}function gl(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function yl(e,t){return t?e?t+" "+e:t:e}function wl(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}var bl,vl,xl=(bl="https://base-ui.com/production-error",vl="Base UI",function(e,...t){const n=new URL(bl);return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`${vl} error #${e}; visit ${n} for the full message.`}),kl=/*#__PURE__*/e.createContext(void 0);function _l(t={}){const{disabled:n=!1,focusableWhenDisabled:r,tabIndex:o=0,native:i=!0,composite:a}=t,s=e.useRef(null),c=function(t=!1){const n=e.useContext(kl);if(void 0===n&&!t)throw new Error(xl(16));return n}(!0),l=a??void 0!==c,{props:d}=function(t){const{focusableWhenDisabled:n,disabled:r,composite:o=!1,tabIndex:i=0,isNativeButton:a}=t,s=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,!a&&r&&(e.tabIndex=n?i:-1)),(a&&(n||s)||!a&&r)&&(e["aria-disabled"]=r),!a||n&&!c||(e.disabled=r),e},[o,r,n,s,c,a,i])}}({focusableWhenDisabled:r,disabled:n,composite:l,tabIndex:o,isNativeButton:i}),u=e.useCallback(()=>{const e=s.current;Sl(e)&&l&&n&&void 0===d.disabled&&e.disabled&&(e.disabled=!1)},[n,d.disabled,l]);return il(u,[u]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:r,onKeyUp:o,onKeyDown:a,onPointerDown:s,...c}=e;return cl({onClick(e){n?e.preventDefault():t?.(e)},onMouseDown(e){n||r?.(e)},onKeyDown(e){if(n)return;if(gl(e),a?.(e),e.baseUIHandlerPrevented)return;const r=e.target===e.currentTarget,o=e.currentTarget,s=Sl(o),c=!i&&(d=o,Boolean("A"===d?.tagName&&d?.href));var d;const u=r&&(i?s:!c),p="Enter"===e.key,h=" "===e.key,m=o.getAttribute("role"),f=m?.startsWith("menuitem")||"option"===m||"gridcell"===m;if(r&&l&&h){if(e.defaultPrevented&&f)return;return e.preventDefault(),void(c||i&&s?(o.click(),e.preventBaseUIHandler()):u&&(t?.(e),e.preventBaseUIHandler()))}u&&(i||!h&&!p||e.preventDefault(),!i&&p&&t?.(e))},onKeyUp(e){n||(gl(e),o?.(e),e.target===e.currentTarget&&i&&l&&Sl(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||l||" "!==e.key||t?.(e))},onPointerDown(e){n?e.preventDefault():s?.(e)}},i?{type:"button"}:{role:"button"},d,c)},[n,d,l,i]),buttonRef:nl(e=>{s.current=e,u()})}}function Sl(e){return Kc(e)&&"BUTTON"===e.tagName}function Il(e,t,n,r){const o=Qc(Cl).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)&&El(o,[e,t,n,r]),o.callback}function Cl(){return{callback:null,cleanup:null,refs:[]}}function El(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}}}}}}var Ml=parseInt(e.version,10);function zl(t){if(!/*#__PURE__*/e.isValidElement(t))return null;const n=t,r=n.props;return(Ml>=19?r?.ref:n.ref)??null}Object.freeze([]);var Tl=Object.freeze({});function Al(t,n,o={}){const i=n.render,a=function(e,t={}){const{className:n,style:r,render:o}=e,{state:i=Tl,ref:a,props:s,stateAttributesMapping:c,enabled:l=!0}=t,d=l?function(e,t){return"function"==typeof e?e(t):e}(n,i):void 0,u=l?function(e,t){return"function"==typeof e?e(t):e}(r,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):Tl,h=l&&s?function(e){return Array.isArray(e)?function(e){if(0===e.length)return sl;if(1===e.length)return ll(e[0]);let t=ll(e[0]);for(let n=1;n<e.length;n+=1)t=dl(t,e[n]);return t}(e):cl(void 0,e)}(s):void 0,m=l?al(p,h)??{}:Tl;"undefined"!=typeof document&&(l?Array.isArray(a)?m.ref=function(e){const t=Qc(Cl).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&El(t,e),t.callback}([m.ref,zl(o),...a]):m.ref=Il(m.ref,zl(o),a):Il(null,null));if(!l)return Tl;void 0!==d&&(m.className=yl(m.className,d));void 0!==u&&(m.style=al(m.style,u));return m}(n,o);return!1===o.enabled?null:function(t,n,o,i){if(n){if("function"==typeof n)return n(o,i);const t=cl(o,n.props);t.ref=o.ref;let r=n;return r?.$$typeof===Ol&&(r=e.Children.toArray(n)[0]),/*#__PURE__*/e.cloneElement(r,t)}if(t&&"string"==typeof t)return function(t,n){return"button"===t?/*#__PURE__*/r("button",{type:"button",...n,key:n.key}):"img"===t?/*#__PURE__*/r("img",{alt:"",...n,key:n.key}):/*#__PURE__*/e.createElement(t,n)}(t,o);throw new Error(xl(8))}(t,i,a,o.state??Tl)}var Ol=Symbol.for("react.lazy");var Nl=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,disabled:o=!1,focusableWhenDisabled:i=!1,nativeButton:a=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:d}=_l({disabled:o,focusableWhenDisabled:i,native:a});return Al("button",e,{state:{disabled:o},ref:[t,d],props:[c,l]})}),Rl={primary:"bg-primary text-primary-foreground border-transparent hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border-transparent hover:bg-secondary/80",ghost:"bg-transparent text-foreground border-border hover:bg-muted",bare:"bg-transparent text-inherit border-transparent hover:bg-transparent p-0 min-h-0",chip:"bg-secondary-bg text-foreground border-transparent hover:bg-primary hover:text-primary-foreground hover:border-primary",tab:"bg-transparent text-foreground-muted border-transparent hover:text-foreground hover:bg-transparent p-0 min-h-0",inline:"bg-transparent text-primary border-transparent hover:bg-transparent hover:text-primary p-0 min-h-0",toolbar:"bg-transparent text-foreground border-transparent opacity-60 hover:opacity-100"},Ll={sm:"px-2 py-1 text-xs min-h-7",md:"px-4 py-2 text-sm min-h-9"},$l={default:"rounded-lg",theme:Rc.theme,pill:Rc.pill},Pl=o(function({active:e=!1,className:t,disabled:n,elevation:r,full:o,loading:i=!1,shape:a="default",size:s="md",stacked:c=!1,type:l="button",variant:d="primary",style:u,...p},h){const m=!["bare","inline","tab","toolbar"].includes(d),g=n||i;/* @__PURE__ */
8
+ return f(Nl,{...p,ref:h,className:Oc("inline-flex items-center justify-center gap-2 font-medium cursor-pointer transition-all focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2",m&&"border",$l[a],Rl[d],"bare"!==d&&"inline"!==d&&"tab"!==d&&Ll[s],c&&"flex-col gap-0.5","tab"===d&&"h-full min-w-0 flex-1",e&&"tab"===d&&"text-primary font-semibold",g&&"opacity-50 cursor-not-allowed pointer-events-none",i&&"opacity-70 cursor-wait pointer-events-none",o&&"w-full",t),"aria-busy":i?"true":void 0,"data-disabled":n?"true":"false","data-loading":i?"true":"false","data-size":s,"data-variant":d,disabled:g,style:{...jc(r),...u},type:l})}),Dl=o(function(e,t){const{className:n,direction:r,...o}=e;/* @__PURE__ */
9
+ return f(Zc,{...o,ref:t,className:Oc("flex","column"===r&&"flex-col",n)})}),jl={spinner:{viewBox:"0 0 512 512",paths:[{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z",fill:"currentColor"}]},checkCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z",fill:"currentColor"}]},circle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z",fill:"currentColor"}]},exclamationCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z",fill:"currentColor"}]},timesCircle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z",fill:"currentColor"}]},ban:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z",fill:"currentColor"}]},arrowUp:{viewBox:"0 0 448 512",paths:[{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z",fill:"currentColor"}]},arrowDown:{viewBox:"0 0 448 512",paths:[{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z",fill:"currentColor"}]},info:{viewBox:"0 0 24 24",paths:[{d:"M 12 2 A 10 10 0 1 1 11.9999 2 Z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 16L12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 8L12.01 8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},trash:{viewBox:"0 0 24 24",paths:[{d:"M3 6L5 6L21 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M10 11L10 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M14 11L14 17",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},x:{viewBox:"0 0 24 24",paths:[{d:"M18 6L6 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chatBubble:{viewBox:"0 0 512 512",paths:[{d:"M87.48 380c1.2-4.38-1.43-10.47-3.94-14.86a42.63 42.63 0 0 0-2.54-3.8 199.81 199.81 0 0 1-33-110C47.64 139.09 140.72 48 255.82 48 356.2 48 440 117.54 459.57 209.85a199 199 0 0 1 4.43 41.64c0 112.41-89.49 204.93-204.59 204.93-18.31 0-43-4.6-56.47-8.37s-26.92-8.77-30.39-10.11a31.14 31.14 0 0 0-11.13-2.07 30.7 30.7 0 0 0-12.08 2.43L81.5 462.78a15.92 15.92 0 0 1-4.66 1.22 9.61 9.61 0 0 1-9.58-9.74 15.85 15.85 0 0 1 .6-3.29z",fill:"none",stroke:"currentColor",strokeWidth:32,strokeLinecap:"round"},{d:"M160 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M256 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M352 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"}]},stop:{viewBox:"0 0 512 512",paths:[{d:"M392 432H120a40 40 0 0 1-40-40V120a40 40 0 0 1 40-40h272a40 40 0 0 1 40 40v272a40 40 0 0 1-40 40z",fill:"currentColor"}]},mousePointerClick:{viewBox:"0 0 24 24",paths:[{d:"M14 4.1 12 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m5.1 8-2.9-.8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m6 12-1.9 2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M7.2 2.2 8 5.1",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},scroll:{viewBox:"0 0 24 24",paths:[{d:"M19 17V5a2 2 0 0 0-2-2H4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},ticktick:{viewBox:"0 0 24 24",paths:[{d:"M12 0C5.383 0 0 5.383 0 12s5.383 12 12 12 12-5.383 12-12h-2.7c0 5.128-4.172 9.3-9.3 9.3-5.128 0-9.3-4.172-9.3-9.3 0-5.128 4.172-9.3 9.3-9.3V0Zm7.4 2.583-7.505 9.371L8.388 9.08l-2.002 2.436 4.741 3.888a1.573 1.573 0 0 0 2.231-.233l8.504-10.617L19.4 2.583Z",fill:"currentColor"}]},arrowRight:{viewBox:"0 0 24 24",paths:[{d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},documentText:{viewBox:"0 0 24 24",paths:[{d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},globe:{viewBox:"0 0 24 24",paths:[{d:"M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},magnifyingGlass:{viewBox:"0 0 24 24",paths:[{d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},xMark:{viewBox:"0 0 24 24",paths:[{d:"M6 18 18 6M6 6l12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},keyboard:{viewBox:"0 0 24 24",paths:[{d:"M20 7v10H4V7h16m0-2H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z",fill:"currentColor"}]},selectAll:{viewBox:"0 0 24 24",paths:[{d:"M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z",fill:"currentColor"}]},tablerArrowDown:{viewBox:"0 0 24 24",paths:[{d:"M12 5l0 14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M18 13l-6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 13l6 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},fileUpload:{viewBox:"0 0 24 24",paths:[{d:"M14 3v4a1 1 0 0 0 1 1h4",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M12 11v6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.5 13.5l2.5 -2.5l2.5 2.5",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},home:{viewBox:"0 0 24 24",paths:[{d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chat:{viewBox:"0 0 24 24",paths:[{d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},help:{viewBox:"0 0 24 24",paths:[{d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},send:{viewBox:"0 0 24 24",paths:[{d:"M5 12h14m-7-7l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},closeSmall:{viewBox:"0 0 12 12",paths:[{d:"M9 3L3 9M3 3l6 6",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},close:{viewBox:"0 0 20 20",paths:[{d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}]},chevronDown:{viewBox:"0 0 24 24",paths:[{d:"M19 9l-7 7-7-7",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round"}]},screenShare:{viewBox:"0 0 24 24",paths:[{d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},moreVertical:{viewBox:"0 0 20 20",paths:[{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z",fill:"currentColor"}]},chevronRight:{viewBox:"0 0 24 24",paths:[{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},alertCircle:{viewBox:"0 0 24 24",paths:[{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]}},Fl=o(function({name:e,size:t=16,className:n,...r},o){const i=jl[e];return i?/* @__PURE__ */f("svg",{...r,ref:o,"aria-hidden":"true",className:Oc("inline-block flex-shrink-0",n),fill:"none",height:t,viewBox:i.viewBox,width:t,xmlns:"http://www.w3.org/2000/svg",children:i.paths.map((e,t)=>/* @__PURE__ */f("path",{clipRule:e.clipRule,d:e.d,fill:e.fill??(e.stroke?"none":"currentColor"),fillRule:e.fillRule,stroke:e.stroke,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,strokeMiterlimit:e.strokeMiterlimit,strokeWidth:e.strokeWidth},t))}):null}),Bl={primary:"bg-primary text-primary-foreground hover:bg-primary-hover",secondary:"bg-secondary-bg text-foreground hover:bg-secondary-hover",ghost:"bg-transparent text-foreground opacity-60 hover:opacity-100",toolbar:"bg-transparent text-foreground opacity-60 hover:opacity-100"},Wl={xs:"w-5 h-5 min-w-5",sm:"w-7 h-7 min-w-7"},Ul={circle:Rc.circle,theme:Rc.theme},Hl=o(function({variant:e="ghost",size:t="sm",shape:n="circle",tone:r,label:o,disabled:i,elevation:a,className:s,children:c,style:l,...d},u){/* @__PURE__ */
10
+ return f("button",{...d,ref:u,type:"button",disabled:i,"aria-label":o,className:Oc("inline-flex items-center justify-center flex-shrink-0 border-none cursor-pointer transition-all",Ul[n],Bl[e],r&&Lc[r],Wl[t],i&&"opacity-50 cursor-not-allowed pointer-events-none",s),style:{...jc(a),...l},children:c})}),Vl=o(function(e,t){const{background:n="default",className:r,elevation:o,paddingPreset:i="none",radius:a,style:s,...c}=e,l=Wc(e);/* @__PURE__ */
11
+ return f("div",{...Uc(c),ref:t,className:Oc("flex flex-col",Hc[n],Vc[i],a&&Wc({rounded:a}),l,r),style:{...jc(o),...s}})}),Zl={xxs:"text-[10px]",xs:"text-xs",sm:"text-sm",base:"text-base",lg:"text-lg"},ql={normal:"font-normal",medium:"font-medium",semibold:"font-semibold"},Gl={center:"text-center",right:"text-right"},Jl=o(function({as:e="span",block:t=!1,clamp:n,code:r=!1,inheritColor:o=!1,italic:i=!1,leading:a,tone:s,variant:c="default",size:l,weight:d,truncate:u,align:p,className:h,style:m,...g},y){/* @__PURE__ */
12
+ return f(e,{...g,ref:y,className:Oc(Lc[o?"inherit":s??{default:"default",muted:"muted",faint:"faint"}[c]],l&&Zl[l],d&&ql[d],p&&Gl[p],a&&$c[a],t&&"block",r&&"font-mono",i&&"italic",u&&"truncate",h),style:n?{...m,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:n,overflow:"hidden"}:m})});function Kl(e){return"above-fab"===e?{bottom:"90px",left:"50%",transform:"translateX(-50%)"}:{bottom:"20px",left:"50%",transform:"translateX(-50%)"}}var Yl=({tone:e,title:t,body:n,onDismiss:r,onRetry:o,position:a="bottom-center"})=>{const[c,l]=p(!1),d=i(()=>{l(!0),setTimeout(r,300)},[r]);s(()=>{if("info"!==e)return;const t=setTimeout(d,8e3);return()=>clearTimeout(t)},[e,d]);const u=Dc[e];/* @__PURE__ */
13
+ return f(Zc,{position:"fixed",style:{zIndex:b,maxWidth:"420px",opacity:c?0:1,transition:"opacity 0.3s ease-out",animation:c?"none":"fadeIn 0.3s ease-out",...Kl(a)},children:/* @__PURE__ */g(Dl,{align:"center",gap:"md",rounded:"pill",paddingPreset:"toast",elevation:"panel",style:{backgroundColor:u.background,border:u.border},children:[
14
+ /* @__PURE__ */f(Jc,{src:qc,alt:"",size:28,rounded:"full"}),
15
+ /* @__PURE__ */g(Vl,{grow:!0,minWidth:"0",children:[/* @__PURE__ */f(Jl,{as:"span",block:!0,inheritColor:!0,weight:"medium",style:{fontSize:"13px",color:u.titleColor,whiteSpace:o?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),n&&/* @__PURE__ */f(Jl,{as:"span",block:!0,inheritColor:!0,style:{fontSize:"12px",color:u.bodyColor,opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]}),o&&/* @__PURE__ */f(Pl,{type:"button",variant:"ghost",shape:"pill",size:"sm",onClick:()=>{o(),d()},style:{color:u.titleColor,backgroundColor:u.actionBackground,border:u.border},"aria-label":"Retry",children:"Retry"}),
16
+ /* @__PURE__ */f(Hl,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},shape:"circle",size:"xs",tone:"inherit",style:{color:u.closeColor,padding:"2px"},children:/* @__PURE__ */f(Fl,{name:"closeSmall",size:12})})]})})},Xl=20,Ql=(e,t,n,r,o)=>{switch(e){case"top_left":return{x:Xl,y:Xl};case"top_right":return{x:t-Xl-r,y:Xl};case"bottom_left":return{x:Xl,y:n-Xl-o};default:return{x:t-Xl-r,y:n-Xl-o}}},ed=(e,t,n,r,o,i)=>{const a=Ql(e,n,r,o,i),s=a.x+o/2,c=a.y+i/2;let l,d;switch(t){case"top_left":l=Xl+o/2,d=Xl+i/2;break;case"top_right":l=n-Xl-o/2,d=Xl+i/2;break;case"bottom_left":l=Xl+o/2,d=r-Xl-i/2;break;default:l=n-Xl-o/2,d=r-Xl-i/2}return{dx:l-s,dy:d-c}},td="cubic-bezier(0.16, 1, 0.3, 1)";function nd({position:e,onDrag:n,isPreviewMode:r=!1,wrapperRef:o}){const[a,s]=p(!1),[c,d]=p({w:56,h:56}),[,h]=p(0),m=u(null),f=u(null),g=u(null),y=u(0),w=u([]),b=u(0);t.useEffect(()=>()=>{null!==g.current&&window.cancelAnimationFrame(g.current)},[]),t.useEffect(()=>{if(r)return;const e=()=>h(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const v=i(()=>{if(!o.current||"undefined"==typeof window)return;const e=o.current.getBoundingClientRect();d(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[o]);l(()=>{v();const e="undefined"!=typeof window&&o.current?new ResizeObserver(v):null;return e&&o.current&&e.observe(o.current),()=>e?.disconnect()},[v,e,o]);const x="undefined"!=typeof window?window.innerWidth:0,k="undefined"!=typeof window?window.innerHeight:0,_=Ql(e,x,k,c.w,c.h),S=!r&&x>0&&k>0?{left:_.x,top:_.y}:void 0,I=(e,t=.999)=>e/1e3*t/(1-t),C=()=>{null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null),o.current&&(o.current.style.transform="",o.current.style.willChange="",o.current.style.transition="")},E=i((e,t)=>{if(m.current)return;let r=!1;const i=()=>{r||(r=!0,m.current=null,t.style.transition="none",t.style.willChange="",n(e),s(!1),requestAnimationFrame(()=>{o.current&&(o.current.style.transition="")}))};m.current=i;const a=window.setTimeout(i,650);t.addEventListener("transitionend",function e(n){n.target===t&&"left"===n.propertyName&&(window.clearTimeout(a),t.removeEventListener("transitionend",e),i())})},[n,o]),M=i((t,r,i)=>{if(!o.current||!S)return C(),n(t),void s(!1);null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null);const a=o.current,l=Ql(e,x,k,c.w,c.h),d=Ql(t,x,k,c.w,c.h);a.style.transition="none",a.style.transform="none",a.style.willChange="left, top",a.style.left=`${l.x+r}px`,a.style.top=`${l.y+i}px`,requestAnimationFrame(()=>{a.style.transition=`left 600ms ${td}, top 600ms ${td}`,a.style.left=`${d.x}px`,a.style.top=`${d.y}px`}),E(t,a)},[E,n,S,e,x,k,c.w,c.h,o]);return{isDragging:a,pixelPositionStyle:S,onPointerDown:e=>{f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,dragging:!1,lastX:0,lastY:0},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{const t=f.current;if(t?.pointerId!==e.pointerId)return;const n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.dragging&&Math.hypot(n,r)>5&&(t.dragging=!0,s(!0),w.current=[],b.current=0,o.current&&(o.current.style.willChange="transform",o.current.style.transition="none")),!t.dragging)return;t.lastX=n,t.lastY=r;const i=Date.now();i-b.current>=10&&(b.current=i,w.current=[...w.current.slice(-5),{x:e.clientX,y:e.clientY,t:i}]),null===g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null;const e=f.current,t=o.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:t=>{const n=f.current;if(n?.pointerId===t.pointerId){if(n.dragging){const r=(()=>{const e=w.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),i=I(r.x),a=I(r.y),s={dx:n.lastX+i,dy:n.lastY+a};let c;if("undefined"!=typeof window&&o.current){const t=o.current.getBoundingClientRect();c=((e,t,n,r,o,i)=>{const a=["top_left","top_right","bottom_left","bottom_right"];let s=t,c=1/0;for(const l of a){const a=ed(t,l,n,r,o,i),d=Math.hypot(e.dx-a.dx,e.dy-a.dy);d<c&&(c=d,s=l)}return s})(s,e,window.innerWidth,window.innerHeight,t.width,t.height)}else c=e;return M(c,n.lastX,n.lastY),y.current=Date.now()+600,f.current=null,void t.currentTarget.releasePointerCapture(t.pointerId)}C(),f.current=null,s(!1),t.currentTarget.releasePointerCapture(t.pointerId)}},onPointerCancel:e=>{f.current?.pointerId===e.pointerId&&(C(),f.current=null,s(!1),e.currentTarget.releasePointerCapture(e.pointerId))},suppressUntilRef:y}}var rd=({open:e,processing:t=!1,error:n=!1,taskRunning:r=!1,onClick:o,onStop:i,accentColor:a,backgroundColor:s,borderRadius:c="12px",tooltipBgColor:l,tooltipTextColor:d,zIndex:p=50,position:h,onDrag:m,isPreviewMode:y=!1})=>{const w=!e&&(t||r),b=!e&&r&&null!=i,v=n?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",x=n?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",k=Math.max(6,Math.min(22,Number.parseFloat(c)||12)),_=u(null),{isDragging:S,pixelPositionStyle:I,onPointerDown:C,onPointerMove:E,onPointerUp:M,onPointerCancel:z,suppressUntilRef:T}=nd({position:h,onDrag:m,isPreviewMode:y,wrapperRef:_}),A=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(h),O=y?"absolute":"fixed",N=y?h.includes("top")?{top:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{};/* @__PURE__ */
17
+ return g(Zc,{ref:_,className:`${O} ${I?"":A} ${S?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:p,pointerEvents:e?"none":"auto",...N,...I},children:[/* @__PURE__ */g(Zc,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[w&&/* @__PURE__ */f(Zc,{className:v,"aria-hidden":!0}),b&&!S&&/* @__PURE__ */f(Pl,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(h.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop running task",children:"Stop"}),
18
+ /* @__PURE__ */f(Pl,{type:"button",variant:"bare",onClick:()=>{Date.now()<T.current||o()},onDragStart:e=>e.preventDefault(),onPointerDown:C,onPointerMove:E,onPointerUp:M,onPointerCancel:z,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:S?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */f(Dl,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */g(Zc,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:c,backgroundColor:e?s:a,boxShadow:Nc.fab},children:[w&&/* @__PURE__ */f("svg",{className:x,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */f("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:k+1,ry:k+1})}),
19
+ /* @__PURE__ */f(Dl,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(30deg) scale(0)":"rotate(0deg) scale(1)",opacity:e?0:1,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":e,children:/* @__PURE__ */f(Jc,{src:qc,alt:"",className:"relative z-10 w-full h-full object-contain",draggable:!1,onDragStart:e=>e.preventDefault(),style:{borderRadius:c,border:"none",outline:"none",backgroundColor:"transparent",pointerEvents:"none",userSelect:"none"}})}),
20
+ /* @__PURE__ */f(Dl,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */f(Fl,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(Zc,{className:`absolute bottom-16 ${h.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:l,color:d},children:[/* @__PURE__ */f(Jl,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */f(Zc,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:l}})]})]})};function od(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function id(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function ad(e,t,n){return Math.min(Math.max(e,t),n)}function sd(e,t,n,r,o){const i={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:o-n,cursor:i[e]};case"bottom-left":return{dx:t-r,dy:o-n,cursor:i[e]};case"top-right":return{dx:r-t,dy:n-o,cursor:i[e]};case"top-left":return{dx:t-r,dy:n-o,cursor:i[e]}}}var cd={count:"inline-flex items-center rounded-full bg-muted px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground",live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},ld={default:"bg-muted text-muted-foreground",muted:"bg-muted text-muted-foreground",primary:"bg-chart-1/15 text-chart-1",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning"},dd=o(function({variant:e,color:t,tone:n="default",className:r,style:o,children:i,...a},s){/* @__PURE__ */
21
+ return g("span",{...a,ref:s,className:Oc(cd[e],"status"===e&&ld[n],r),"data-variant":e,style:{color:t,...o},children:["live"===e&&/* @__PURE__ */g("span",{className:"relative flex h-1.5 w-1.5",children:[/* @__PURE__ */f("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */f("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),i]})}),ud=({title:e,subtitle:t,minimized:n=!1,onClose:r,controls:o})=>/* @__PURE__ */g(Dl,n?{align:"center",justify:"between",paddingX:"lg",border:"bottom",shrink:!1,style:Pc.header,children:[/* @__PURE__ */f(Jl,{size:"sm",weight:"medium",children:e}),/* @__PURE__ */f(Hl,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */f(Fl,{name:"close",size:16})})]}:{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */g(Dl,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */f(Jc,{src:qc,alt:"",size:"md",rounded:"theme",elevation:"card"}),/* @__PURE__ */g(Vl,{minWidth:"0",children:[/* @__PURE__ */f(Jl,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */f(Jl,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */g(Dl,{align:"center",gap:"xs",shrink:!1,children:[o,/* @__PURE__ */f(Hl,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */f(Fl,{name:"close",size:16})})]})]});function pd({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:n,onAddMessage:r,onUpdateMessage:o,onRemoveMessage:i,onSendMessage:a,pendingMessage:c,setPendingMessage:l}){const[d,h]=p(!1),[m,f]=p(null),[g,y]=p(null),[w,b]=p(null),[v,x]=p(!1),k=u(d),_=u(g),S=u(r),I=u(i),C=u(e);s(()=>{k.current=d},[d]),s(()=>{_.current=g},[g]),s(()=>{S.current=r},[r]),s(()=>{I.current=i},[i]),s(()=>{C.current=e},[e]),s(()=>{const e=()=>{const e=Qa(),t=k.current,n=_.current;if(e!==t&&(k.current=e,h(e),C.current?.(e)),t&&!e&&n){I.current?.(n);const e=Pa("Stopped screenshare","show","user","stopped-sharing");S.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const E=()=>{x(!0)},M=()=>{Ya&&(Ya.getTracks().forEach(e=>e.stop()),Ya=null),h(!1),f(null),e?.(!1),g&&i&&i(g),r(Pa("Stopped screenshare","show","user","stopped-sharing")),y(null)};return s(()=>(t&&(t.current=E),n&&(n.current=M),()=>{t&&(t.current=null),n&&(n.current=null)})),{isScreenSharing:d,screenStream:m,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await Xa();h(!0),f(t),e?.(!0),r(Da("show"));const n=ja(t,"show");y(n.id),r(n)}catch(t){h(!1),f(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await Xa();h(!0),f(t),e?.(!0),w&&(o(w,{screenShareStatus:"allowed"}),b(null)),r(Da("show"));const n=ja(t,"show");if(y(n.id),r(n),c){const e=c;l(null),a(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(h(!1),f(null),e?.(!1),w&&(o(w,{screenShareStatus:"denied"}),b(null)),c){const e=c;l(null),a(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(w&&(o(w,{screenShareStatus:"denied"}),b(null)),c){const e=c;l(null),a(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(w)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);b(t.id),r(t)}}}var hd=o(function({background:e="card",border:t=!0,children:n,className:r,elevation:o="card",paddingPreset:i="card",radius:a="xl",style:s,...c},l){/* @__PURE__ */
22
+ return f(Zc,{...c,ref:l,as:"div",background:e,border:t,className:r,elevation:o,paddingPreset:i,radius:a,style:s,children:n})}),md={sm:"px-2 py-0.5 text-[11px] gap-0.5"},fd=o(function({active:e=!1,variant:t="primary",size:n="sm",children:r,...o},i){/* @__PURE__ */
23
+ return f("button",{...o,ref:i,type:"button",className:Oc("inline-flex items-center font-medium border-none cursor-pointer transition-all duration-200",Rc.pill,md[n],e&&"primary"===t&&"bg-primary text-primary-foreground shadow-sm",!e&&"bg-secondary-bg text-foreground-muted"),children:r})}),gd={default:"block w-full px-3 py-2 text-sm leading-normal text-foreground bg-background border border-input rounded-lg transition-colors min-h-20 resize-y hover:border-muted-foreground focus:outline-none focus:border-ring focus:ring-3 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-muted",chat:"block w-full px-3 text-sm text-foreground placeholder:text-foreground-faint bg-transparent border-none rounded-none transition-colors min-h-0 resize-none focus:outline-none focus:ring-0 disabled:opacity-50 disabled:cursor-not-allowed"},yd=o(function({className:e,errorMessage:t,id:n,validationState:r="default",variant:o="default",...i},a){const s="invalid"===r&&t?`${n??i["aria-label"]??"textarea"}-error`:void 0;/* @__PURE__ */
24
+ return g(m,{children:[/* @__PURE__ */f("textarea",{...i,"aria-describedby":s,"aria-invalid":"invalid"===r?"true":void 0,className:Oc(gd[o],e),"data-validation-state":r,id:n,ref:a}),null!=s&&/* @__PURE__ */f("span",{id:s,children:t})]})});function wd(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var bd=t.forwardRef(function({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:o,onModeChange:a,disabled:c=!1,taskRunning:l=!1,onStop:d,placeholder:p="Ask anything"},h){const m=u(null);s(()=>{const e=m.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,66);e.style.height=`${n}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=i(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,66);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>66?"auto":"hidden"},[t]),w=i(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),b=Boolean(e.trim())&&!c;/* @__PURE__ */
25
+ return g(Vl,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"focus-within:border-foreground-faint transition-colors",children:[/* @__PURE__ */f(yd,{ref:wd(m,h),value:e,onChange:y,onKeyDown:w,placeholder:p,disabled:c,rows:1,variant:"chat",style:{lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */g(Dl,{align:"center",justify:"between",paddingX:"sm",paddingTop:"2xs",paddingBottom:"sm",children:[/* @__PURE__ */f(Dl,{align:"center",gap:"2xs",children:r.map(e=>/* @__PURE__ */g(fd,{active:o===e.id,size:"sm",onClick:t=>{t.preventDefault(),t.stopPropagation(),a?.(e.id)},children:[/* @__PURE__ */f(Fl,{name:e.icon,size:12}),/* @__PURE__ */f(Jl,{as:"span",inheritColor:!0,children:e.label})]},e.id))}),/* @__PURE__ */f(Hl,{variant:l?"secondary":"primary",size:"sm",disabled:!l&&!b,label:l?"Stop task":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),l&&d?d():n()},children:/* @__PURE__ */f(Fl,l?{name:"stop",size:14}:{name:"send",size:16})})]})]})});var vd=n(null);function xd(e){const t=a(vd);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function kd({children:e,defaultOpen:t,onOpenChange:n,open:r}){const{isOpen:o,setIsOpen:a}=function({defaultOpen:e=!1,onOpenChange:t,open:n}){const[r,o]=p(e),a=void 0!==n;return{isOpen:a?n:r,setIsOpen:i(e=>{a||o(e),t?.(e)},[a,t])}}({defaultOpen:t,onOpenChange:n,open:r}),s=c(),l=c(),u=c(),h=d(()=>({contentId:s,descriptionId:u,open:o,setOpen:a,titleId:l}),[s,u,o,a,l]);/* @__PURE__ */
26
+ return f(vd.Provider,{value:h,children:e})}function _d({children:e,className:t,onKeyDown:n,...r}){const o=xd("DialogContent"),{variant:i="default",style:a,...c}=r;return s(()=>{if(!o.open)return;const e=e=>{"Escape"===e.key&&o.setOpen(!1)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[o]),o.open?/* @__PURE__ */f("div",{...c,"aria-describedby":o.descriptionId,"aria-labelledby":o.titleId,"aria-modal":"true",className:Oc("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[calc(var(--layer-dialog)+1)] flex flex-col w-full max-h-[85vh] overflow-auto bg-card animate-dialog-content-in","default"===i&&"max-w-[500px] rounded-lg p-6","confirm"===i&&"max-w-sm rounded-lg p-4","info"===i&&"w-64 rounded-md border border-border p-0",t),"data-state":"open",id:o.contentId,onKeyDown:e=>{n?.(e),e.defaultPrevented||"Escape"!==e.key||o.setOpen(!1)},role:"dialog",style:{...jc("info"===i?"section":"panel"),...a},tabIndex:-1,children:e}):null}function Sd({className:e,variant:t="default",...n}){const r=xd("DialogTitle");/* @__PURE__ */
27
+ return f("h2",{...n,className:Oc("default"===t&&"text-lg font-semibold text-card-foreground mb-2","confirm"===t&&"text-base font-semibold text-foreground mb-1","info"===t&&"text-xs font-semibold text-foreground flex-1 text-center mb-0",e),id:r.titleId})}function Id({className:e,variant:t="default",...n}){const r=xd("DialogDescription");/* @__PURE__ */
28
+ return f("p",{...n,className:Oc("default"===t&&"text-sm text-muted-foreground mb-4","confirm"===t&&"text-sm text-muted-foreground mb-4 leading-relaxed",e),id:r.descriptionId})}function Cd({children:e,className:t,onClick:n,variant:r="default",...o}){const i=xd("DialogClose");/* @__PURE__ */
29
+ return f("button",{...o,className:Oc("default"===r&&"absolute top-4 right-4 flex items-center justify-center w-8 h-8 p-0 bg-transparent border-none rounded-lg text-muted-foreground cursor-pointer transition-colors hover:bg-muted","info"===r&&"static -mr-1 flex h-5 w-5 items-center justify-center rounded-full border-none bg-transparent p-0 text-muted-foreground transition-colors hover:text-foreground",t),onClick:e=>{n?.(e),e.defaultPrevented||i.setOpen(!1)},type:"button",children:e})}var Ed={green:"success",blue:"primary",yellow:"warning",gray:"muted"},Md=({variant:e,open:t,onClose:n,title:r,description:o,onConfirm:i,confirmLabel:a="Confirm",cancelLabel:s="Cancel",rows:c=[],status:l})=>/* @__PURE__ */f(kd,{open:t,onOpenChange:e=>{e||n()},children:/* @__PURE__ */g(_d,"confirm"===e?{variant:"confirm",children:[
30
+ /* @__PURE__ */f(Sd,{variant:"confirm",children:r}),null!=o&&/* @__PURE__ */f(Id,{variant:"confirm",children:o}),
31
+ /* @__PURE__ */g(Dl,{gap:"md",justify:"end",children:[/* @__PURE__ */f(Pl,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:s}),/* @__PURE__ */f(Pl,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},children:a})]})]}:{variant:"info",children:[/* @__PURE__ */g(Dl,{align:"center",justify:"between",paddingX:"lg",paddingY:"sm",border:"bottom",children:[/* @__PURE__ */f(Sd,{variant:"info",children:r}),/* @__PURE__ */f(Cd,{variant:"info","aria-label":"Close",children:/* @__PURE__ */f(Fl,{name:"x",size:12})})]}),/* @__PURE__ */g(Vl,{paddingX:"lg",paddingY:"sm",children:[c.map(e=>/* @__PURE__ */g(Dl,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */f(Jl,{as:"span",size:"xs",variant:"muted",children:e.label}),/* @__PURE__ */g(Dl,{align:"center",gap:"2xs",children:[/* @__PURE__ */f(Jl,{as:"code",code:!0,size:"xs",variant:"muted",truncate:!0,style:{maxWidth:"120px"},children:e.value||"N/A"}),!0===e.copyable&&e.value&&/* @__PURE__ */f(Pl,{type:"button",variant:"inline",size:"sm",onClick:()=>{return t=e.value,void navigator.clipboard.writeText(t);var t},children:"Copy"})]})]},e.label)),null!=l&&/* @__PURE__ */g(Dl,{align:"center",justify:"between",paddingY:"2xs",children:[/* @__PURE__ */f(Jl,{as:"span",size:"xs",variant:"muted",children:"Status"}),/* @__PURE__ */f(dd,{variant:"status",tone:Ed[l.color],children:l.label})]})]})]})}),zd={sm:"h-3.5 w-3.5 border-[1.5px]",md:"h-5 w-5 border-2",lg:"h-6 w-6 border-2"},Td=o(function({label:e,size:t="md",className:n,style:r},o){/* @__PURE__ */
32
+ return g("div",{ref:o,className:Oc("inline-flex items-center gap-1.5",n),"data-size":t,role:"status",style:r,children:[
33
+ /* @__PURE__ */f("div",{"aria-hidden":"true",className:Oc("animate-spin rounded-full border-current border-t-transparent flex-shrink-0",zd[t])}),null!=e&&/* @__PURE__ */f("span",{children:e}),
34
+ /* @__PURE__ */f("span",{className:"sr-only",children:"Loading"})]})}),Ad=({variant:e,message:t})=>{const n="error"===e,r="loading"===e;/* @__PURE__ */
35
+ return g(Vl,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:r?"status":void 0,"aria-live":n?"assertive":"polite",style:n?{color:"var(--color-red-600, #dc2626)"}:void 0,children:[r&&/* @__PURE__ */f(Td,{size:"lg"}),/* @__PURE__ */f(Jl,{as:"p",size:"sm",align:"center",children:t})]})},Od=({content:e,status:t,hideIcon:n=!1,textStyle:r="default"})=>{const{config:o}=us(),i=o.widget_accent_color;/* @__PURE__ */
36
+ return g(Dl,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return f(Fl,{name:"checkCircle",style:{color:i,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return f(Fl,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"stopped":/* @__PURE__ */return f(Fl,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});default:/* @__PURE__ */return f(Td,{size:"sm",style:{color:i,marginTop:"2px"}})}})(),/* @__PURE__ */f(Jl,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===r?.5:1},children:e})]})},Nd=({isWaitingForUser:e})=>/* @__PURE__ */g(Dl,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */f(Td,{size:"sm"}),/* @__PURE__ */f(Jl,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Rd=({message:e,isLastMessage:t})=>{const{state:n}=us(),r="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */g(Vl,{gap:"sm",children:[e.parts.map((t,n)=>{if("text"===t.type){let e=(r=t.content,r.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */f(Jl,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${n}`):null}return"progress"===t.type?"done"===t.toolName&&"done"===e.taskStatus?null:/* @__PURE__ */f(Od,{content:t.content,status:t.status||"in_progress",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */f(Nd,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */f(Nd,{isWaitingForUser:r}):e.content?/* @__PURE__ */f(Jl,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */f(Zc,{})},Ld=({status:e})=>{const{config:t}=us(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return f(Fl,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return f(Fl,{name:"exclamationCircle",style:{color:k(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return f(Fl,{name:"circle",style:{color:k(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return f(Td,{size:"sm",style:{color:n}})}},$d=o(function({className:e,...t},n){/* @__PURE__ */
37
+ return f("video",{...t,ref:n,className:Oc(e)})}),Pd="8px 8px 0 0",Dd="#111827",jd="rgba(255,255,255,0.7)",Fd=({stream:e})=>{const t=u(null),n=u(null),[r,o]=p(!1),[i,a]=p(!1);return s(()=>{if(t.current&&e){const r=t.current;o(!1),a(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const i=()=>{o(!0)},s=()=>{a(!0),o(!1)};r.addEventListener("loadedmetadata",i),r.addEventListener("error",s);const c=r.play();return n.current=c,c.then(()=>{o(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&a(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",i),r.removeEventListener("error",s)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),o(!1),a(!1)}},[e]),e?/* @__PURE__ */g(Zc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:Pd,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!r&&!i&&/* @__PURE__ */f(Dl,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Dd,borderRadius:Pd,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(Dl,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */f(Td,{size:"lg",style:{color:"white"}}),/* @__PURE__ */f(Jl,{as:"span",size:"xs",weight:"medium",style:{color:jd},children:"Loading stream..."})]})}),i&&/* @__PURE__ */f(Dl,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Dd,borderRadius:Pd,zIndex:10},children:/* @__PURE__ */g(Dl,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */f(Fl,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */f(Jl,{as:"span",size:"xs",weight:"medium",style:{color:jd},children:"Failed to load stream"})]})}),
38
+ /* @__PURE__ */f($d,{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:Pd,transition:"opacity 500ms",opacity:r?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),r&&!i&&/* @__PURE__ */g(Dl,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */g(Dl,{position:"relative",align:"center",justify:"center",children:[/* @__PURE__ */f(Zc,{position:"absolute",rounded:"full",animate:"ping",style:{width:"8px",height:"8px",backgroundColor:"white",opacity:.75}}),/* @__PURE__ */f(Zc,{position:"relative",rounded:"full",style:{width:"6px",height:"6px",backgroundColor:"white"}})]}),/* @__PURE__ */f(Jl,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
39
+ /* @__PURE__ */f(Dl,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:Pd,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */f(Zc,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */f(Jl,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]}):null},Bd=({message:e,index:t,isLastMessage:n,onScreenAccessAllow:r,onScreenAccessDeny:o})=>{if(e.isSystemMessage)/* @__PURE__ */return f(Dl,{justify:"center",align:"center",children:/* @__PURE__ */f(Jl,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})},`message-${e.id}-${t}`);const i="user"===e.sender;/* @__PURE__ */
40
+ return g(Vl,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":i?"You said…":"Agent says…",animate:n?"fadeIn":void 0,children:[/* @__PURE__ */g(Dl,{align:"start",gap:"sm",width:"full",children:[
41
+ /* @__PURE__ */f(Dl,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!i&&/* @__PURE__ */f(Jc,{src:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",alt:"Marketrix AI",size:20,fit:"cover",rounded:"theme",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
42
+ /* @__PURE__ */g(Vl,{grow:!0,position:"relative",rounded:"theme",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:i?"var(--primary)":void 0,color:i?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */f(Fd,{stream:e.videoStream}),!e.videoStream&&/* @__PURE__ */f(Rd,{message:e,isLastMessage:n}),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */g(Dl,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */f(Pl,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */f(Pl,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>o?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */f(Jl,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"Check HTML Instead"}),!i&&e.taskStatus&&/* @__PURE__ */f(Dl,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */f(Ld,{status:e.taskStatus})})]}),
43
+ /* @__PURE__ */f(Dl,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */f(Jl,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:S(e.timestamp)})]},`message-${e.id}-${t}`)},Wd={boxShadow:Nc.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Ud=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:o,onClearChat:i})=>{const{config:a,state:c,isPreviewMode:l}=us({config:n}),[h,m]=p(!1),[y,w]=p(!1),b=u(null),v=d(()=>({id:"welcome",content:a.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[a.widget_body]),x=d(()=>[v,...e],[v,e]),_=()=>{if(b.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=b.current;m(e>200),w(!(Math.abs(t-e-n)<50)&&t>n)}};return s(()=>{window.requestAnimationFrame(()=>{t.current&&(!l&&t.current.scrollIntoView({behavior:"auto"}),!l&&_())})},[e.length,l]),/* @__PURE__ */g(Zc,{position:"relative",height:"full",children:[
44
+ /* @__PURE__ */g(Zc,{ref:b,onScroll:_,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:a.widget_background_color.includes("gradient")?"transparent":a.widget_background_color,backgroundImage:a.widget_background_color.includes("gradient")?a.widget_background_color:`linear-gradient(135deg, ${a.widget_background_color} 0%, ${a.widget_background_color} 100%)`,scrollbarColor:`${k(a.widget_border_color,.3)} ${k(a.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&c.isLoading&&/* @__PURE__ */f(Ad,{variant:"loading",message:"Connecting…"}),x.map((e,t)=>/* @__PURE__ */f(Bd,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:r,onScreenAccessDeny:o},`message-${e.id}-${t}`)),e.length>0&&i&&/* @__PURE__ */f(Dl,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */f(Pl,{type:"button",variant:"bare",onClick:()=>{const e=i();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */f(Jl,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
45
+ /* @__PURE__ */f(Zc,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */f(Dl,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(Hl,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{b.current?.scrollTo({top:0,behavior:"smooth"})},style:Wd,children:/* @__PURE__ */f(Fl,{name:"arrowUp",size:10,style:{color:a.widget_accent_color}})})}),y&&/* @__PURE__ */f(Dl,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(Hl,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!l&&t.current.scrollIntoView({behavior:"smooth"})},style:Wd,children:/* @__PURE__ */f(Fl,{name:"arrowDown",size:10,style:{color:a.widget_accent_color}})})})]})},Hd=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */f(Jl,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},Vd={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Zd=["tell","show","do"];var qd=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,taskProgress:o=[],onSendMessage:i,onSetMode:a,onAddMessage:s,onUpdateMessage:c,onRemoveMessage:l,onStopTask:d,onClearChat:h,onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,messageInputRef:b})=>{const[v,x]=p(""),_=u(null),[S,C]=p(null),{isScreenSharing:E,showScreenAccessDialog:M,handleScreenAccessDialogAllow:z,handleScreenAccessDialogDeny:T,handleScreenAccessAllow:A,handleScreenAccessDeny:O,requestScreenAccess:N}=pd({onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,onAddMessage:s,onUpdateMessage:c,onRemoveMessage:l,onSendMessage:i,pendingMessage:S,setPendingMessage:C}),R=e;/* @__PURE__ */
46
+ return g(Vl,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[M&&/* @__PURE__ */f(Md,{variant:"confirm",open:M,onClose:T,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:z,confirmLabel:"Yes",cancelLabel:"No"}),
47
+ /* @__PURE__ */f(Zc,{grow:!0,overflow:"hidden",paddingY:"xs",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */f(Hd,{children:/* @__PURE__ */f(Ud,{messages:t,messagesEndRef:_,config:e,onScreenAccessAllow:A,onScreenAccessDeny:O,onClearChat:h})})}),
48
+ /* @__PURE__ */g(hd,{style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:[r&&o.length>0&&/* @__PURE__ */g(Zc,{rounded:!0,overflowY:"auto",style:{margin:"0 8px 8px",padding:"8px",maxHeight:"128px",backgroundColor:k(e.widget_background_color??"#fff",.8),borderColor:e.widget_border_color,borderWidth:"1px",borderStyle:"solid"},children:[/* @__PURE__ */g(Jl,{as:"div",weight:"semibold",style:{marginBottom:"4px",color:e.widget_text_color},children:["Task Progress (",o.length," steps)"]}),/* @__PURE__ */f(Vl,{gap:"xs",children:o.map((t,n)=>/* @__PURE__ */g(Dl,{align:"start",gap:"sm",style:{fontSize:"12px",opacity:.8,color:e.widget_text_color},children:[
49
+ /* @__PURE__ */g(Jl,{as:"span",weight:"medium",children:["Step ",t.step,":"]})," ",t.tool_name,t.tool_params&&Object.keys(t.tool_params).length>0&&/* @__PURE__ */g(Jl,{as:"span",style:{opacity:.7,marginLeft:"4px"},children:["(",Object.keys(t.tool_params).join(", "),")"]})]},n))})]}),/* @__PURE__ */f(bd,{ref:b,value:v,onChange:x,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(v.trim()&&!r){const t=v.trim();x(""),s(La(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||E?i(t,n,void 0,void 0,!0):(C({content:t,mode:n,alreadyAdded:!0}),N(n))}},modes:Zd.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(R).includes(e)).map(e=>({id:e,icon:Vd[e],label:I(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(s(Pa(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),a(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{es.cleanup(),d?.()}})]})]})},Gd=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */f(Fl,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */f(Fl,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */f(Fl,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */f(Fl,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */f(Fl,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Jd(e){switch(e){case"do":/* @__PURE__ */return f(Fl,{name:"ticktick",size:12});case"show":/* @__PURE__ */return f(Fl,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return f(Fl,{name:"chatBubble",size:12})}}var Kd=({actions:e,onActionClick:t})=>{const{config:n}=us();return 0===e.length?null:/* @__PURE__ */f(Vl,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */f(Pl,{elevation:"card",shape:"theme",size:"sm",variant:"chip",full:!0,onClick:n=>t(e,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */f(Jl,{as:"span",weight:"normal",leading:"tight",children:"show"===e.type?/* @__PURE__ */g(m,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(m,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},Yd=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const o=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text,o=t.chip_mode,i=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let a=i,s=0;for(;e.has(a);)s++,a=`${i}-${s}`;return e.add(a),{id:a,text:r,icon:Jd(o),type:o,isShow:"show"===o}})}return Gd}(e);/* @__PURE__ */
50
+ return g(Vl,{height:"full",overflow:"hidden",id:"view-home",role:"tabpanel","aria-labelledby":"tab-home",children:[/* @__PURE__ */g(Vl,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */g(Zc,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */f(Jl,{as:"h2",size:"lg",weight:"semibold",children:e.widget_greeting??"Hey There!"}),/* @__PURE__ */f(Jl,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:e.widget_body??"How can I help you today?"})]}),/* @__PURE__ */g(Vl,{gap:"sm",children:[/* @__PURE__ */g(Pl,{type:"button",variant:"primary",full:!0,onClick:n,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */f(Fl,{name:"chat",size:16}),"Ask a question"]}),/* @__PURE__ */f(Kd,{actions:o,onActionClick:async(e,t)=>{t.preventDefault(),t.stopPropagation(),n(),r(e)}})]})]}),t.length>0&&/* @__PURE__ */g(hd,{style:{margin:"0 12px 12px 12px"},children:[
51
+ /* @__PURE__ */f(Jl,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
52
+ /* @__PURE__ */f(Jl,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t[t.length-1].content||"Message"}),
53
+ /* @__PURE__ */f(Jl,{as:"p",size:"xs",variant:"muted",onClick:n,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},Xd=["top-left","top-right","bottom-left","bottom-right"];function Qd(e){const t=e.startsWith("top"),n=e.endsWith("left");return{position:"absolute",width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:t?"flex-start":"flex-end",justifyContent:n?"flex-start":"flex-end",cursor:t&&n||!t&&!n?"nwse-resize":"nesw-resize",top:t?0:void 0,bottom:t?void 0:0,left:n?0:void 0,right:n?void 0:0}}var eu,tu=({onResizeStart:e})=>/* @__PURE__ */f(m,{children:Xd.map(t=>/* @__PURE__ */f("div",{role:"separator","aria-label":`Resize widget from ${t.replace("-"," ")}`,title:"Drag to resize",style:Qd(t),onMouseDown:e(t)},t))}),nu=()=>/* @__PURE__ */f("span",{className:"block h-0.5 w-full rounded-full bg-primary"}),ru=({tabs:e,active:t,onChange:n})=>/* @__PURE__ */f(Dl,{role:"tablist",align:"center",justify:"around",shrink:!1,border:"top",style:Pc.tabBar,children:e.map(e=>{const r=t===e.id;/* @__PURE__ */
54
+ return g(Pl,{role:"tab","aria-selected":r,"aria-controls":`view-${e.id}`,id:`tab-${e.id}`,onClick:()=>n(e.id),active:r,stacked:!0,variant:"tab",children:[r&&/* @__PURE__ */f(Jl,{as:"span",inheritColor:!0,style:{position:"absolute",top:0,left:"25%",right:"25%"},children:/* @__PURE__ */f(nu,{variant:"bar",color:"accent"})}),
55
+ /* @__PURE__ */f(Jl,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */f(Fl,{name:e.icon,size:20})}),
56
+ /* @__PURE__ */f(Jl,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id)})}),ou=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"}],iu=({activeView:e,onChange:t})=>/* @__PURE__ */f(ru,{tabs:ou,active:e,onChange:e=>t(e)}),au=({children:e,direction:t})=>/* @__PURE__ */f(Zc,{"data-view-transition":!0,"data-direction":t,style:{width:"100%",height:"100%"},children:e}),su=({config:e,isOpen:t,isMinimized:n,messages:r,currentMode:o,isTaskRunning:a=!1,taskProgress:c=[],activeView:l,onClose:h,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:S,setActiveView:I})=>{const{config:C,isPreviewMode:E}=us({config:e}),M=d(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:z,heightPx:T,onResizeStart:A,containerRef:O}=function(e,t,n,r,o){const a=d(()=>`marketrix_widget_size_${n}`,[n]),s=u({width:360,height:450}),c=u(null),[l,h]=p(()=>{if("undefined"==typeof localStorage)return{width:id(e),height:id(t)};const n=localStorage.getItem(a);if(n)try{const e=JSON.parse(n);if("number"==typeof e.width&&"number"==typeof e.height){const t=ad(e.width,280,600),n=ad(e.height,320,Math.floor(.85*window.innerHeight));return s.current={width:t,height:n},{width:t,height:n}}}catch{}const r=id(e),o=id(t);return s.current={width:r,height:o},{width:r,height:o}});s.current=l;const m=i(e=>t=>{if(t.preventDefault(),t.stopPropagation(),r||o)return;const n=t.clientX,i=t.clientY,l=s.current.width,d=s.current.height,{cursor:u}=sd(e,n,i,n,i);c.current&&(c.current.dataset.resizing="true");const p=t=>{const{dx:r,dy:o}=sd(e,n,i,t.clientX,t.clientY),a=Math.floor(.85*window.innerHeight),u={width:ad(l+r,280,600),height:ad(d+o,320,a)};s.current=u,c.current&&(c.current.style.width=`${u.width}px`,c.current.style.height=`${u.height}px`)},m=()=>{if(document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",c.current&&delete c.current.dataset.resizing,h({...s.current}),!o&&"undefined"!=typeof localStorage){const{width:e,height:t}=s.current;localStorage.setItem(a,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[r,o,a]);return{width:l.width,height:l.height,widthPx:`${l.width}px`,heightPx:`${l.height}px`,onResizeStart:m,containerRef:c}}(C.widget_width,C.widget_height,M,n,E),N=u(null),[R,L]=p("forward"),$=u(l);s(()=>{$.current!==l&&(L("chat"===l?"forward":"back"),$.current=l)},[l]),function(e,t,n){const r=u(!1),o=u(null),a=i(()=>{const t=e.current;if(!t)return;const r=n?.focusTargetRef?.current;if(r)return void r.focus({preventScroll:!0});const o=od(t);o[0]&&o[0].focus({preventScroll:!0})},[e,n?.focusTargetRef]);s(()=>{if(!t)return r.current&&(o.current?.focus({preventScroll:!0}),o.current=null),void(r.current=!1);r.current||(o.current=document.activeElement||null),r.current=!0;const i=e.current;if(!i)return;a();const s=e=>{if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const t=od(i);if(0===t.length)return;const r=document.activeElement,o=t.indexOf(r);-1!==o&&(e.shiftKey?0===o&&(e.preventDefault(),t[t.length-1].focus()):o===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",s,!0),()=>document.removeEventListener("keydown",s,!0)},[t,e,a,n?.onEscape])}(O,t,{onEscape:h,focusTargetRef:"chat"===l?N:void 0});const P=C.widget_position,D=C.widget_position_z_index??40,j=(e=>{const t="20px",n="20px";switch(e){case"bottom_right":default:return{bottom:t,right:n};case"bottom_left":return{bottom:t,left:n};case"top_right":return{top:t,right:n};case"top_left":return{top:t,left:n}}})(P),[F,B]=p(!1),W=u(null),U=u(null),H=i(e=>{B(e),S?.(e)},[S]);if(!t)return null;const V=C.widget_background_color.includes("gradient")?C.widget_background_color:`linear-gradient(135deg, ${C.widget_background_color} 0%, ${C.widget_background_color} 100%)`,Z={width:z,height:n?"48px":T,fontSize:C.widget_font_size,backgroundImage:V,zIndex:D},q=E?"absolute":"fixed",G=E?P.includes("top")?{top:"20px",...P.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...P.includes("right")?{right:"20px"}:{left:"20px"}}:{},J=`${P.includes("top")?"top":"bottom"} ${P.includes("right")?"right":"left"}`,K="chat"===l&&!1!==e.use_screenshare?()=>{F?U.current?.():W.current?.()}:void 0;/* @__PURE__ */
57
+ return g(Vl,{ref:O,position:q,rounded:"theme",border:!0,overflow:"hidden",style:{zIndex:D,backgroundImage:V,transformOrigin:J,...Z,...E?G:j,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:Nc.panel},children:[
58
+ /* @__PURE__ */f(ud,{title:e.widget_header??"AI Agent",subtitle:n?void 0:e.widget_body??"How can I help?",minimized:n,onClose:h,controls:K&&/* @__PURE__ */g(Hl,{variant:"ghost",size:"sm",label:F?"Stop screen sharing":"Start screen sharing",onClick:K,children:[F&&/* @__PURE__ */f(dd,{variant:"live",style:{position:"absolute",top:"2px",right:"2px"}}),/* @__PURE__ */f(Fl,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */g(m,{children:[/* @__PURE__ */f(Zc,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(au,{direction:R,children:["home"===l&&/* @__PURE__ */f(Yd,{config:e,messages:r,onNavigateToChat:()=>{L("forward"),I("chat")},onChipClick:e=>{b(La(e.text,e.type,"chip-message")),w(e.type),y(e.text,e.type,void 0,void 0,!0)}}),"chat"===l&&/* @__PURE__ */f(qd,{config:e,messages:r,currentMode:o,isTaskRunning:a,taskProgress:c,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:H,onStartScreenShareRef:W,onStopScreenShareRef:U,messageInputRef:N})]},l)}),/* @__PURE__ */f(iu,{activeView:l,onChange:I})]}),!n&&!E&&/* @__PURE__ */f(tu,{onResizeStart:A})]})},cu=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},lu=({config:e})=>{const[t,n]=p(!1),{state:r,actions:o,config:i,shouldShow:a,isPreviewMode:c,configValid:l}=us({config:e});var u;u=r.isOpen,s(()=>{if(!u)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[u]);const[h,m]=p(e.widget_position??"bottom_right"),b=d(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);s(()=>{m(i.widget_position??"bottom_right")},[i.widget_position]),s(()=>{if(c||"undefined"==typeof localStorage)return;const e=i.widget_position??"bottom_right",t=localStorage.getItem(b);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(b,e),m(e)):m(t)},[c,b,i.widget_position]),s(()=>{if(r.isOpen||c||"default"!==i.widget_appearance)return void n(!1);const e=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(e)},[r.isOpen,c,i.widget_appearance]);if(!l)return null;if(!(c?e.widget_enabled??i.widget_enabled:a&&i.widget_enabled&&!1!==e.show_widget))return null;const v=(S=function(e={}){return E({...C,widget_background_color:e.widget_background_color??C.widget_background_color,widget_text_color:e.widget_text_color??C.widget_text_color,widget_border_color:e.widget_border_color??C.widget_border_color,widget_accent_color:e.widget_accent_color??C.widget_accent_color,widget_secondary_color:e.widget_secondary_color??C.widget_secondary_color,widget_border_radius:e.widget_border_radius??C.widget_border_radius,widget_font_size:e.widget_font_size??C.widget_font_size,widget_width:e.widget_width??C.widget_width,widget_height:e.widget_height??C.widget_height,widget_shadow:e.widget_shadow??C.widget_shadow,widget_animation_duration:e.widget_animation_duration??C.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??C.widget_fade_duration})}(i),{"--background":S.color.background,"--foreground":S.color.foreground,"--card":S.color.background,"--card-foreground":S.color.foreground,"--popover":S.color.background,"--popover-foreground":S.color.foreground,"--primary":S.color.primary,"--foreground-muted":S.color.foregroundMuted,"--foreground-faint":S.color.foregroundFaint,"--border-muted":S.color.borderMuted,"--primary-foreground":S.color.primaryForeground,"--primary-hover":S.color.primaryHover,"--primary-muted":S.color.primaryMuted,"--secondary":S.color.secondary,"--secondary-foreground":S.color.secondaryForeground,"--secondary-bg":S.color.secondaryBg,"--secondary-hover":S.color.secondaryHover,"--muted":S.color.border,"--muted-foreground":S.color.secondary,"--accent":S.color.background,"--accent-foreground":S.color.foreground,"--border":S.color.border,"--input":S.color.border,"--ring":S.color.primary,"--radius":S.radius,"--shadow":S.shadow,"--duration-animation":S.motion.durationAnimation,"--duration-fade":S.motion.durationFade,"--widget-width":S.size.widgetWidth,"--widget-height":S.size.widgetHeight});var S;const I=Math.max(i.widget_position_z_index??0,y),M={...i,widget_position:h,widget_position_z_index:I,show_widget:e.show_widget,use_screenshare:e.use_screenshare},z=r.isLoading||r.isTaskRunning;/* @__PURE__ */
59
+ return g(Zc,{"data-marketrix-widget":!0,position:"relative",style:{...v,"--widget-z-index":I,...c&&{width:"100%",height:"100%"}},"data-widget-mode":i?.widget_feature_human?"hybrid":"ai",children:[z&&/* @__PURE__ */f(Zc,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${k(i.widget_accent_color,.72)}, inset 0 0 46px 10px ${k(i.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
60
+ /* @__PURE__ */f(cu,{children:/* @__PURE__ */f(su,{config:M,isOpen:r.isOpen,isMinimized:r.isMinimized,messages:r.messages,currentMode:r.currentMode,isTaskRunning:r.isTaskRunning,taskProgress:r.taskProgress,activeView:r.activeView,onClose:o.closeWidget,onSendMessage:o.sendMessage,onSetMode:o.setMode,onAddMessage:o.addMessage,onUpdateMessage:o.updateMessage,onRemoveMessage:o.removeMessage,onStopTask:o.stopTask,onClearChat:o.clearChatHistory,setActiveView:o.setActiveView})}),
61
+ /* @__PURE__ */f(rd,{open:r.isOpen,processing:r.isLoading,error:!!r.error,taskRunning:r.isTaskRunning,onClick:o.toggleWidget,onStop:o.stopTask,accentColor:M.widget_accent_color,backgroundColor:M.widget_background_color,borderRadius:M.widget_border_radius,tooltipBgColor:_(M.widget_accent_color,.3),tooltipTextColor:x(_(M.widget_accent_color,.3)),zIndex:M.widget_position_z_index??50,position:h,onDrag:e=>{m(e),c||"undefined"==typeof localStorage||localStorage.setItem(b,e)},isPreviewMode:c}),r.error&&/* @__PURE__ */f(Yl,{tone:"error",title:r.error,onDismiss:()=>o.clearError(),onRetry:()=>o.clearError(),position:h.includes("top")?"bottom-center":"above-fab"}),t&&!r.error&&i.widget_greeting&&/* @__PURE__ */f(Yl,{tone:"info",title:i.widget_greeting,body:i.widget_body,onDismiss:()=>n(!1),position:"bottom-center"})]})},du=({previewMode:e})=>{const{uiState:t}=ds(),{chatState:n}=Ga(),{taskState:r}=ss();return s(()=>{e||Ra.persist({messages:n.messages,isTaskRunning:r.isTaskRunning,activeTaskId:r.activeTaskId,taskProgress:r.taskProgress,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading})},[e,n.messages,r.isTaskRunning,r.activeTaskId,r.taskProgress,t.currentMode,t.isOpen,t.isMinimized,t.isLoading]),null},uu=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=ds(),{_setMessages:o}=(()=>{const e=a(Za);if(!e)throw new Error("useChatContextInternal must be used within ChatProvider");return e})(),i=u(null),c=u([]);return s(()=>{if(t)return;(async()=>{const e=await Ba.getOrCreateChatId();Ra.createInitialContext(e),Ra.getInitError()&&r.setError("Widget failed to initialise — please refresh the page."),Ra.initialize(e);const t=Ra.restore();if(r.applyState({isLoading:t.isLoading,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized}),c.current=t.messages,o({messages:t.messages}),i.current=t.isTaskRunning?t.activeTaskId:null,e){const t=Wa.getInstance(),n=Ha.getConfig();t.connect(e,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0).catch(e=>{})}})()},[]),/* @__PURE__ */g(as,{previewMode:t,currentMode:n.currentMode,setMessages:o,messagesRef:c,uiActions:r,activeTaskIdRef:i,children:[e,/* @__PURE__ */f(du,{previewMode:t})]})},pu=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=ds();/* @__PURE__ */
62
+ return f(qa,{previewMode:t,uiActions:r,currentMode:n.currentMode,children:/* @__PURE__ */f(uu,{previewMode:t,children:e})})},hu=({children:e,previewMode:t=!1})=>/* @__PURE__ */f(ls,{children:/* @__PURE__ */f(pu,{previewMode:t,children:e})}),mu=Object.defineProperty,fu=(e,t,n)=>((e,t,n)=>t in e?mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),gu=/* @__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))(gu||{}),yu=/* @__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))(yu||{}),wu=/* @__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))(wu||{}),bu=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(bu||{}),vu=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(vu||{}),xu=/* @__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))(xu||{}),ku=/* @__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))(ku||{}),_u={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Su={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Iu={},Cu={};function Eu(e){if(Iu[e])return Iu[e];const t=globalThis[e],n=t.prototype,r=e in _u?_u[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 Su?Su[e]:void 0,a=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&&a&&!globalThis.Zone)return Iu[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 a=navigator.userAgent;return a.includes("Safari")&&!a.includes("Chrome")?(r.classList.add("rr-block"),r.setAttribute("__rrwebUntaintedMutationObserver",""),Cu[e]=()=>r.remove()):r.remove(),Iu[e]=i}catch{return n}}var Mu={};function zu(e,t,n){var r;const o=`${e}.${String(n)}`;if(Mu[o])return Mu[o].call(t);const i=Eu(e),a=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return a?(Mu[o]=a,a.call(t)):t[n]}var Tu={};function Au(e,t,n){const r=`${e}.${String(n)}`;if(Tu[r])return Tu[r].bind(t);const o=Eu(e)[n];return"function"!=typeof o?t[n]:(Tu[r]=o,o.bind(t))}function Ou(){return[Eu("MutationObserver").constructor,Cu.MutationObserver??(()=>{})]}var Nu=Date.now;function Ru(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())||(Nu=()=>/* @__PURE__ */(new Date).getTime());var Lu={ownerDocument:function(e){return zu("Node",e,"ownerDocument")},childNodes:function(e){return zu("Node",e,"childNodes")},parentNode:function(e){return zu("Node",e,"parentNode")},parentElement:function(e){return zu("Node",e,"parentElement")},textContent:function(e){return zu("Node",e,"textContent")},contains:function(e,t){return Au("Node",e,"contains")(t)},getRootNode:function(e){return Au("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?zu("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?zu("Element",e,"shadowRoot"):null},querySelector:function(e,t){return zu("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return zu("Element",e,"querySelectorAll")(t)},nowTimestamp:Nu,mutationObserverCtor:Ou,patch:Ru};function $u(e){return e.nodeType===e.ELEMENT_NODE}function Pu(e){const t=e&&"host"in e&&"mode"in e&&Lu.host(e)||null;return Boolean(t&&"shadowRoot"in t&&Lu.shadowRoot(t)===e)}function Du(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function ju(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=>Fu(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 Fu(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=ju(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?Yu(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?Yu(n,t):n}}var Bu=class{constructor(){fu(this,"idNodeMap",/* @__PURE__ */new Map),fu(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 Wu({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:i}){let a=o||"";const s=r&&Uu(r);return(t[n.toLowerCase()]||s&&t[s])&&(a=i?i(a,e):"*".repeat(a.length)),a}function Uu(e){return e.toLowerCase()}var Hu="__rrweb_original__";function Vu(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Uu(t):null}function Zu(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 qu=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Gu=/^(?:[a-z+]+:)?\/\//i,Ju=/^www\..*/i,Ku=/^(data:)([^,]*),(.*)/i;function Yu(e,t){return(e||"").replace(qu,(e,n,r,o,i,a)=>{const s=r||i||a,c=n||o||"";if(!s)return e;if(Gu.test(s)||Ju.test(s))return`url(${c}${s}${c})`;if(Ku.test(s))return`url(${c}${s}${c})`;if("/"===s[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)+s}${c})`;const l=t.split("/"),d=s.split("/");l.pop();for(const t of d){if("."===t)continue;".."===t?l.pop():l.push(t)}return`url(${c}${l.join("/")}${c})`})}function Xu(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function Qu(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=Xu(e,n);const a=t.length/e.length;for(let s=1;s<r.length;s++)if(r[s].textContent&&"string"==typeof r[s].textContent){const c=Xu(r[s].textContent,n),l=100;let d=3;for(;d<c.length&&(c[d].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,d),1));d++);for(;d<c.length;d++){let u=c.substring(0,d),p=t.split(u),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[s-1].textContent)h=t.indexOf(u,1);else if(1===p.length){if(u=u.substring(0,u.length-1),p=t.split(u),p.length<=1)return o.push(e),o;d=101}else d===c.length-1&&(h=t.indexOf(u));if(p.length>=2&&d>l){const e=r[s-1].textContent;if(e&&"string"==typeof e){const n=Xu(e).length;h=t.indexOf(u,n)}-1===h&&(h=p[0].length)}if(-1!==h){let s=Math.floor(h/a);for(;s>0&&s<e.length;){if(i+=1,i>50*r.length)return o.push(e),o;const c=Xu(e.substring(0,s),n);if(c.length===h){o.push(e.substring(0,s)),e=e.substring(s),t=t.substring(h);break}c.length<h?s+=Math.max(1,Math.floor((h-c.length)/a)):s-=Math.max(1,Math.floor((c.length-h)*a))}break}}}}return o.push(e),o}(e,t).join("/* rr_split */")}var ep,tp,np=1,rp=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function op(){return np++}var ip=/^[^ \t\n\r\u000c]+/,ap=/^[, \t\n\r\u000c]+/;var sp=/* @__PURE__ */new WeakMap;function cp(e,t){return t&&""!==t.trim()?dp(e,t):t}function lp(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function dp(e,t){let n=sp.get(e);if(n||(n=e.createElement("a"),sp.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function up(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)?cp(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(ap),!(n>=t.length);){let i=r(ip);if(","===i.slice(-1))i=cp(e,i.substring(0,i.length-1)),o.push(i);else{let r="";i=cp(e,i);let a=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((i+r).trim());break}if(a)")"===e&&(a=!1);else{if(","===e){n+=1,o.push((i+r).trim());break}"("===e&&(a=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?Yu(r,dp(e)):"object"===t&&"data"===n?cp(e,r):r:r}function pp(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function hp(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&hp(Lu.parentNode(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&hp(Lu.parentNode(e),t,n)}function mp(e,t,n,r){let o;if($u(e)){if(o=e,!Lu.childNodes(o).length)return!1}else{if(null===Lu.parentElement(e))return!1;o=Lu.parentElement(e)}try{if("string"==typeof t){if(r){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(hp(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 fp(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:a,inlineStylesheet:s,maskInputOptions:c={},maskTextFn:l,maskInputFn:d,dataURLOptions:u={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:m,newlyAddedElement:f=!1,cssCaptured:g=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:ku.Document,childNodes:[],compatMode:e.compatMode}:{type:ku.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:ku.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:a={},maskInputFn:s,dataURLOptions:c={},inlineImages:l,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:p=!1,rootId:h}=t,m=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(r){}return!1}(e,r,o),f=function(e){if(e instanceof HTMLFormElement)return"form";const t=Uu(e.tagName);return rp.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let v=0;v<y;v++){const t=e.attributes[v];pp(f,t.name,t.value)||(g[t.name]=up(n,f,Uu(t.name),t.value))}if("link"===f&&i){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=ju(t)),r&&(delete g.rel,delete g.href,g._cssText=r)}if("style"===f&&e.sheet){let t=ju(e.sheet);t&&(e.childNodes.length>1&&(t=Qu(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(f)){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Wu({element:e,type:Vu(e),tagName:f,value:t,maskInputOptions:a,maskInputFn:s}):n&&(g.checked=n)}"option"===f&&(e.selected&&!a.select?g.selected=!0:delete g.selected);"dialog"===f&&e.open&&(g.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===f&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const o=t.getImageData,i=Hu in o?o[Hu]: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"===f&&l){ep||(ep=n.createElement("canvas"),tp=ep.getContext("2d"));const t=e,r=(t.currentSrc||t.getAttribute("src"),t.crossOrigin),o=()=>{t.removeEventListener("load",o);try{ep.width=t.naturalWidth,ep.height=t.naturalHeight,tp.drawImage(t,0,0),g.rr_dataURL=ep.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o))}"anonymous"===t.crossOrigin&&(r?g.crossOrigin=r:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if(["audio","video"].includes(f)){const t=g;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(m){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==f||u(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);let w;try{customElements.get(f)&&(w=!0)}catch(b){}return{type:ku.Element,tagName:f,attributes:g,childNodes:[],isSVG:lp(e)||void 0,needBlock:m,rootId:h,isCustom:w}}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:s,maskInputOptions:c,maskInputFn:d,dataURLOptions:u,inlineImages:p,recordCanvas:h,keepIframeSrcFn:m,newlyAddedElement:f,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:o,cssCaptured:i}=t,a=Lu.parentNode(e),s=a&&a.tagName;let c="";const l="STYLE"===s||void 0,d="SCRIPT"===s||void 0;d?c="SCRIPT_PLACEHOLDER":i||(c=Lu.textContent(e),l&&c&&(c=Yu(c,dp(t.doc))));!l&&!d&&c&&n&&(c=r?r(c,Lu.parentElement(e)):c.replace(/[\S]/g,"*"));return{type:ku.Text,textContent:c||"",rootId:o}}(e,{doc:n,needsMask:a,maskTextFn:l,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:ku.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:ku.Comment,textContent:Lu.textContent(e)||"",rootId:y};default:return!1}}function gp(e){return null==e?"":e.toLowerCase()}function yp(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 wp(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,maskTextClass:a,maskTextSelector:s,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m={},inlineImages:f=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b=5e3,onStylesheetLoad:v,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:_=!1,cssCaptured:S=!1}=t;let{needsMask:I}=t,{preserveWhiteSpace:C=!0}=t;I||(I=mp(e,a,s,void 0===I));const E=fp(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,dataURLOptions:m,inlineImages:f,recordCanvas:g,keepIframeSrcFn:k,newlyAddedElement:_,cssCaptured:S});if(!E)return null;let M;M=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===ku.Comment)return!0;if(e.type===ku.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"===Zu(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(gp(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===gp(e.attributes.name)||"icon"===gp(e.attributes.rel)||"apple-touch-icon"===gp(e.attributes.rel)||"shortcut icon"===gp(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&gp(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(gp(e.attributes.property).match(/^(og|twitter|fb):/)||gp(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===gp(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===gp(e.attributes.name)||"googlebot"===gp(e.attributes.name)||"bingbot"===gp(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===gp(e.attributes.name)||"generator"===gp(e.attributes.name)||"framework"===gp(e.attributes.name)||"publisher"===gp(e.attributes.name)||"progid"===gp(e.attributes.name)||gp(e.attributes.property).match(/^article:/)||gp(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===gp(e.attributes.name)||"yandex-verification"===gp(e.attributes.name)||"csrf-token"===gp(e.attributes.name)||"p:domain_verify"===gp(e.attributes.name)||"verify-v1"===gp(e.attributes.name)||"verification"===gp(e.attributes.name)||"shopify-checkout-api-token"===gp(e.attributes.name)))return!0}}return!1}(E,h)||!C&&E.type===ku.Text&&!E.textContent.replace(/^\s+|\s+$/gm,"").length?-2:op();const z=Object.assign(E,{id:M});if(r.add(e,z),-2===M)return null;y&&y(e);let T=!c;if(z.type===ku.Element){T=T&&!z.needBlock,delete z.needBlock;const t=Lu.shadowRoot(e);t&&Du(t)&&(z.isShadowHost=!0)}if((z.type===ku.Document||z.type===ku.Element)&&T){h.headWhitespace&&z.type===ku.Element&&"head"===z.tagName&&(C=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:a,maskTextSelector:s,skipChild:c,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:f,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(z.type===ku.Element&&"textarea"===z.tagName&&void 0!==z.attributes.value);else{z.type===ku.Element&&void 0!==z.attributes._cssText&&"string"==typeof z.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(Lu.childNodes(e))){const e=wp(n,t);e&&z.childNodes.push(e)}}let _=null;if($u(e)&&(_=Lu.shadowRoot(e)))for(const e of Array.from(Lu.childNodes(_))){const n=wp(e,t);n&&(Du(_)&&(n.isShadow=!0),z.childNodes.push(n))}}const A=Lu.parentNode(e);return A&&Pu(A)&&Du(A)&&(z.isShadow=!0),z.type===ku.Element&&"iframe"===z.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,i=!1;try{o=r.document.readyState}catch(s){return}if("complete"!==o){const r=setTimeout(()=>{i||(t(),i=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),i=!0,t()})}const a="about:blank";if(r.location.href!==a||e.src===a||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&w){const n=wp(t,{doc:t,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:a,maskTextSelector:s,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:f,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});n&&w(e,n)}},b),z.type===ku.Element&&"link"===z.tagName&&"string"==typeof z.attributes.rel&&("stylesheet"===z.attributes.rel||"preload"===z.attributes.rel&&"string"==typeof z.attributes.href&&"css"===Zu(z.attributes.href))&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(a){return}if(r)return;const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()})}(e,()=>{if(v){const t=wp(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:a,maskTextSelector:s,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:m,inlineImages:f,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:w,iframeLoadTimeout:b,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&v(e,t)}},x),z}var bp=class e{constructor(...e){fu(this,"parentElement",null),fu(this,"parentNode",null),fu(this,"ownerDocument"),fu(this,"firstChild",null),fu(this,"lastChild",null),fu(this,"previousSibling",null),fu(this,"nextSibling",null),fu(this,"ELEMENT_NODE",1),fu(this,"TEXT_NODE",3),fu(this,"nodeType"),fu(this,"nodeName"),fu(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 vp(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var xp={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function kp(e,t,n={}){let r=null,o=0;return function(...i){const a=Date.now();o||!1!==n.leading||(o=a);const s=t-(a-o),c=this;s<=0||s>t?(r&&(clearTimeout(r),r=null),o=a,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},s))}}function _p(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)}}),()=>_p(e,t,i||{},!0)}function Sp(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=Lu.parentElement(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=Lu.parentElement(i.body))?void 0:r.scrollTop)||(null==(o=null==i?void 0:i.body)?void 0:o.scrollTop)||0}}function Ip(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Cp(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Ep(e){return e?e.nodeType===e.ELEMENT_NODE?e:Lu.parentElement(e):null}function Mp(e,t,n,r){if(!e)return!1;const o=Ep(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(hp(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 zp(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function Tp(e,t){if(Pu(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=Lu.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||Tp(r,t))}function Ap(e){return Boolean(e.changedTouches)}function Op(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Np(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Rp(e){return!!e&&(e instanceof bp&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(Lu.shadowRoot(e)))}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(xp=new Proxy(xp,{get:(e,t,n)=>Reflect.get(e,t,n)}));var Lp=class{constructor(){fu(this,"id",1),fu(this,"styleIDMap",/* @__PURE__ */new WeakMap),fu(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 $p(e){var t;let n=null;return"getRootNode"in e&&(null==(t=Lu.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&Lu.host(Lu.getRootNode(e))&&(n=Lu.host(Lu.getRootNode(e))),n}function Pp(e){const t=Lu.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=$p(n);)n=t;return n}(e);return Lu.contains(t,n)}function Dp(e){const t=Lu.ownerDocument(e);return!!t&&(Lu.contains(t,e)||Pp(e))}function jp(e){return"__ln"in e}var Fp,Bp=class{constructor(){fu(this,"length",0),fu(this,"head",null),fu(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&&jp(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&&jp(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--)}},Wp=(e,t)=>`${e}@${t}`,Up=class{constructor(){fu(this,"frozen",!1),fu(this,"locked",!1),fu(this,"texts",[]),fu(this,"attributes",[]),fu(this,"attributeMap",/* @__PURE__ */new WeakMap),fu(this,"removes",[]),fu(this,"mapRemoves",[]),fu(this,"movedMap",{}),fu(this,"addedSet",/* @__PURE__ */new Set),fu(this,"movedSet",/* @__PURE__ */new Set),fu(this,"droppedSet",/* @__PURE__ */new Set),fu(this,"removesSubTreeCache",/* @__PURE__ */new Set),fu(this,"mutationCb"),fu(this,"blockClass"),fu(this,"blockSelector"),fu(this,"maskTextClass"),fu(this,"maskTextSelector"),fu(this,"inlineStylesheet"),fu(this,"maskInputOptions"),fu(this,"maskTextFn"),fu(this,"maskInputFn"),fu(this,"keepIframeSrcFn"),fu(this,"recordCanvas"),fu(this,"inlineImages"),fu(this,"slimDOMOptions"),fu(this,"dataURLOptions"),fu(this,"doc"),fu(this,"mirror"),fu(this,"iframeManager"),fu(this,"stylesheetManager"),fu(this,"shadowDomManager"),fu(this,"canvasManager"),fu(this,"processedNodeManager"),fu(this,"unattachedDoc"),fu(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),fu(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new Bp,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=Lu.parentNode(o);if(!i||!Dp(o))return;let a=!1;if(o.nodeType===Node.TEXT_NODE){const e=i.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(i)&&(a=!0)}const s=Pu(i)?this.mirror.getId($p(o)):this.mirror.getId(i),c=r(o);if(-1===s||-1===c)return n.addNode(o);const l=wp(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=>{Op(e,this.mirror)&&this.iframeManager.addIframe(e),Np(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Rp(o)&&this.shadowDomManager.addShadowRoot(Lu.shadowRoot(o),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:a});l&&(e.push({parentId:s,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const s of this.movedSet)Vp(this.removesSubTreeCache,s,this.mirror)&&!this.movedSet.has(Lu.parentNode(s))||o(s);for(const s of this.addedSet)Zp(this.droppedSet,s)||Vp(this.removesSubTreeCache,s,this.mirror)?Zp(this.movedSet,s)?o(s):this.droppedSet.add(s):o(s);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(Lu.parentNode(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(Lu.parentNode(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=Lu.parentNode(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=Lu.host(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 a={texts:this.texts.map(e=>{const t=e.node,n=Lu.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(a.texts.length||a.attributes.length||a.removes.length||a.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(a))}),fu(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(Lu.childNodes(e),e=>Lu.textContent(e)||"").join("");t.attributes.value=Wu({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Vu(e),value:n,maskInputFn:this.maskInputFn})}),fu(this,"processMutation",e=>{if(!zp(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=Lu.textContent(e.target);Mp(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:mp(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Ep(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=Vu(n);o=Wu({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:o,maskInputFn:this.maskInputFn})}if(Mp(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"),!pp(n.tagName,r))if(i.attributes[r]=up(this.doc,Uu(n.tagName),Uu(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(Mp(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=Pu(e.target)?this.mirror.getId(Lu.host(e.target)):this.mirror.getId(e.target);Mp(e.target,this.blockClass,this.blockSelector,!1)||zp(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Hp(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Tp(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Wp(n,r)]?Hp(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!Pu(e.target)||!Du(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),Lu.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),fu(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(zp(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[Wp(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Mp(e,this.blockClass,this.blockSelector,!1)||(Lu.childNodes(e).forEach(e=>this.genAdds(e)),Rp(e)&&Lu.childNodes(Lu.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function Hp(e,t){e.delete(t),Lu.childNodes(t).forEach(t=>Hp(e,t))}function Vp(e,t,n){return 0!==e.size&&function(e,t){const n=Lu.parentNode(t);return!!n&&e.has(n)}(e,t)}function Zp(e,t){return 0!==e.size&&qp(e,t)}function qp(e,t){const n=Lu.parentNode(t);return!!n&&(!!e.has(n)||qp(e,n))}var Gp=e=>{if(!Fp)return e;return(...t)=>{try{return e(...t)}catch(n){if(Fp&&!0===Fp(n))return;throw n}}},Jp=[];function Kp(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 Yp(e,t){const n=new Up;Jp.push(n),n.init(e);const[r,o]=Ou(),i=new r(Gp(n.processMutations.bind(n)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[i,o]}function Xp({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const a=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,s=[];let c=null;return Object.keys(wu).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==a[e]).forEach(i=>{let a=Uu(i);const l=(t=>i=>{const a=Kp(i);if(Mp(a,r,o,!0))return;let s=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":s=bu.Mouse;break;case"touch":s=bu.Touch;break;case"pen":s=bu.Pen}s===bu.Touch?wu[t]===wu.MouseDown?l="TouchStart":wu[t]===wu.MouseUp&&(l="TouchEnd"):bu.Pen}else Ap(i)&&(s=bu.Touch);null!==s?(c=s,(l.startsWith("Touch")&&s===bu.Touch||l.startsWith("Mouse")&&s===bu.Mouse)&&(s=null)):wu[t]===wu.Click&&(s=c,c=null);const d=Ap(i)?i.changedTouches[0]:i;if(!d)return;const u=n.getId(a),{clientX:p,clientY:h}=d;Gp(e)({type:wu[l],id:u,x:p,y:h,...null!==s&&{pointerType:s}})})(i);if(window.PointerEvent)switch(wu[i]){case wu.MouseDown:case wu.MouseUp:a=a.replace("mouse","pointer");break;case wu.TouchStart:case wu.TouchEnd:return}s.push(vp(a,l,t))}),Gp(()=>{s.forEach(e=>e())})}function Qp({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return vp("scroll",Gp(kp(Gp(i=>{const a=Kp(i);if(!a||Mp(a,r,o,!0))return;const s=n.getId(a);if(a===t&&t.defaultView){const n=Sp(t.defaultView);e({id:s,x:n.left,y:n.top})}else e({id:s,x:a.scrollLeft,y:a.scrollTop})}),i.scroll||100)),t)}var eh=["INPUT","TEXTAREA","SELECT"],th=/* @__PURE__ */new WeakMap;function nh(e){return function e(t,n){if(ah("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||ah("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||ah("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||ah("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 rh(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function oh({mirror:e,stylesheetManager:t},n){var r,o,i;let a=null;a="#document"===n.nodeName?e.getId(n):e.getId(Lu.host(n));const s="#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==s?void 0:s.prototype)?Object.getOwnPropertyDescriptor(null==s?void 0:s.prototype,"adoptedStyleSheets"):void 0;return null!==a&&-1!==a&&s&&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!==a&&-1!==a)try{t.adoptStyleSheets(e,a)}catch(o){}return r}}),Gp(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function ih(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:a,inputCb:s,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),a(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),s(...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),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}(e,t);let o=()=>{};e.recordDOM&&([r,o]=Yp(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 a,s=[];const c=kp(Gp(t=>{const n=Date.now()-a;e(s.map(e=>(e.timeOffset-=n,e)),t),s=[],a=null}),i),l=Gp(kp(Gp(e=>{const t=Kp(e),{clientX:n,clientY:o}=Ap(e)?e.changedTouches[0]:e;a||(a=Nu()),s.push({x:n,y:o,id:r.getId(t),timeOffset:Nu()-a}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?yu.Drag:e instanceof MouseEvent?yu.MouseMove:yu.TouchMove)}),o,{trailing:!1})),d=[vp("mousemove",l,n),vp("touchmove",l,n),vp("drag",l,n)];return Gp(()=>{d.forEach(e=>e())})}(e),a=Xp(e),s=Qp(e),c=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return vp("resize",Gp(kp(Gp(()=>{const t=Ip(),o=Cp();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:a,maskInputOptions:s,maskInputFn:c,sampling:l,userTriggeredOnInput:d}){function u(e){let n=Kp(e);const l=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=Lu.parentElement(n)),!n||!u||eh.indexOf(u)<0||Mp(n,r,o,!0))return;if(n.classList.contains(i)||a&&n.matches(a))return;let h=n.value,m=!1;const f=Vu(n)||"";"radio"===f||"checkbox"===f?m=n.checked:(s[u.toLowerCase()]||s[f])&&(h=Wu({element:n,maskInputOptions:s,tagName:u,type:f,value:h,maskInputFn:c})),p(n,d?{text:h,isChecked:m,userTriggered:l}:{text:h,isChecked:m});const g=n.name;"radio"===f&&g&&m&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,d?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function p(t,r){const o=th.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){th.set(t,r);const o=n.getId(t);Gp(e)({...r,id:o})}}const h=("last"===l.input?["change"]:["input","change"]).map(e=>vp(e,Gp(u),t)),m=t.defaultView;if(!m)return()=>{h.forEach(e=>e())};const f=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),g=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return f&&f.set&&h.push(...g.map(e=>_p(e[0],e[1],{set(){Gp(u)({target:this,isTrusted:!1})}},!1,m))),Gp(()=>{h.forEach(e=>e())})}(e),d=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const a=Gp(i=>kp(Gp(o=>{const a=Kp(o);if(!a||Mp(a,t,n,!0))return;const{currentTime:s,volume:c,muted:l,playbackRate:d,loop:u}=a;e({type:i,id:r.getId(a),currentTime:s,volume:c,muted:l,playbackRate:d,loop:u})}),o.media||500)),s=[vp("play",a(xu.Play),i),vp("pause",a(xu.Pause),i),vp("seeked",a(xu.Seeked),i),vp("volumechange",a(xu.VolumeChange),i),vp("ratechange",a(xu.RateChange),i)];return Gp(()=>{s.forEach(e=>e())})}(e);let u=()=>{},p=()=>{},h=()=>{},m=()=>{};e.recordDOM&&(u=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:Gp((r,o,i)=>{const[a,s]=i,{id:c,styleId:l}=rh(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:a,index:s}]}),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 a,s;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Gp((r,o,i)=>{const[a]=i,{id:s,styleId:c}=rh(o,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,removes:[{index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},r.CSSStyleSheet.prototype.replace&&(a=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:Gp((r,o,i)=>{const[a]=i,{id:s,styleId:c}=rh(o,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,replace:a}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(s=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(s,{apply:Gp((r,o,i)=>{const[a]=i,{id:s,styleId:c}=rh(o,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,replaceSync:a}),r.apply(o,i)})}));const c={};sh("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(sh("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),sh("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),sh("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:Gp((r,o,i)=>{const[a,s]=i,{id:c,styleId:l}=rh(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:a,index:[...nh(o),s||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Gp((r,o,i)=>{const[a]=i,{id:s,styleId:c}=rh(o.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,removes:[{index:[...nh(o),a]}]}),r.apply(o,i)})})}),Gp(()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,a&&(r.CSSStyleSheet.prototype.replace=a),s&&(r.CSSStyleSheet.prototype.replaceSync=s),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}(e,{win:n}),p=oh(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:Gp((o,a,s)=>{var c;const[l,d,u]=s;if(n.has(l))return i.apply(a,[l,d,u]);const{id:p,styleId:h}=rh(null==(c=a.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:l,value:d,priority:u},index:nh(a.parentRule)}),o.apply(a,s)})});const a=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:Gp((o,i,s)=>{var c;const[l]=s;if(n.has(l))return a.apply(i,[l]);const{id:d,styleId:u}=rh(null==(c=i.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:l},index:nh(i.parentRule)}),o.apply(i,s)})}),Gp(()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=a})}(e,{win:n}),e.collectFonts&&(m=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 a=Ru(t.fonts,"add",function(t){return function(n){return setTimeout(Gp(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=i}),r.push(a),Gp(()=>{r.forEach(e=>e())})}(e)));const f=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let a=!0;const s=Gp(()=>{const e=t.getSelection();if(!e||a&&(null==e?void 0:e.isCollapsed))return;a=e.isCollapsed||!1;const s=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const{startContainer:i,startOffset:a,endContainer:c,endOffset:l}=e.getRangeAt(t);Mp(i,r,o,!0)||Mp(c,r,o,!0)||s.push({start:n.getId(i),startOffset:a,end:n.getId(c),endOffset:l})}i({ranges:s})});return s(),vp("selectionchange",s)}(e),g=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?Ru(n.customElements,"define",function(e){return function(n,r,o){try{t({define:{name:n}})}catch(i){}return e.apply(this,[n,r,o])}}):()=>{}}(e),y=[];for(const w of e.plugins)y.push(w.observer(w.callback,n,w.options));return Gp(()=>{Jp.forEach(e=>e.reset()),r?.disconnect(),o(),i(),a(),s(),c(),l(),d(),u(),p(),h(),m(),f(),g(),y.forEach(e=>e())})}function ah(e){return void 0!==window[e]}function sh(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var ch=class{constructor(e){fu(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),fu(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 a=o.get(t);return a||(a=this.generateIdFn(),o.set(t,a),i.set(a,t)),a}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-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}},lh=class{constructor(e){fu(this,"iframes",/* @__PURE__ */new WeakMap),fu(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),fu(this,"crossOriginIframeMirror",new ch(op)),fu(this,"crossOriginIframeStyleMirror"),fu(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),fu(this,"mirror"),fu(this,"mutationCb"),fu(this,"wrappedEmit"),fu(this,"loadListener"),fu(this,"stylesheetManager"),fu(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new ch(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 gu.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:gu.IncrementalSnapshot,data:{source:yu.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case gu.Meta:case gu.Load:case gu.DomContentLoaded:return!1;case gu.Plugin:return t;case gu.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case gu.IncrementalSnapshot:switch(t.data.source){case yu.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 yu.Drag:case yu.TouchMove:case yu.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case yu.ViewportResize:return!1;case yu.MediaInteraction:case yu.MouseInteraction:case yu.Scroll:case yu.CanvasMutation:case yu.Input:return this.replaceIds(t.data,e,["id"]),t;case yu.StyleSheetRule:case yu.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case yu.Font:return t;case yu.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case yu.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===ku.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},dh=class{constructor(e){fu(this,"shadowDoms",/* @__PURE__ */new WeakSet),fu(this,"mutationCb"),fu(this,"scrollCb"),fu(this,"bypassOptions"),fu(this,"mirror"),fu(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(!Du(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const[n]=Yp({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(Qp({...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(Lu.host(e))),this.restoreHandlers.push(oh({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(Ru(e.prototype,"attachShadow",function(e){return function(r){const o=e.call(this,r),i=Lu.shadowRoot(this);return i&&Dp(this)&&n.addShadowRoot(i,t),o}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},uh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ph="undefined"==typeof Uint8Array?[]:new Uint8Array(256),hh=0;hh<64;hh++)ph[uh.charCodeAt(hh)]=hh;var mh=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=uh[n[t]>>2],o+=uh[(3&n[t])<<4|n[t+1]>>4],o+=uh[(15&n[t+1])<<2|n[t+2]>>6],o+=uh[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},fh=/* @__PURE__ */new Map;var gh=(e,t,n)=>{if(!e||!bh(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=fh.get(e);return n||(n=/* @__PURE__ */new Map,fh.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 yh(e,t,n){if(e instanceof Array)return e.map(e=>yh(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:mh(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[yh(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:[yh(e.data,t,n),e.width,e.height]}:bh(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:gh(e,t,n)}:e}var wh=(e,t,n)=>e.map(e=>yh(e,t,n)),bh=(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 vh(e,t,n,r){const o=[];try{const i=Ru(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){if(!Mp(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{}return()=>{o.forEach(e=>e())}}function xh(e,t,n,r,o,i){const a=[],s=Object.getOwnPropertyNames(e);for(const c of s)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const s=Ru(e,c,function(e){return function(...a){const s=e.apply(this,a);if(gh(s,i,this),"tagName"in this.canvas&&!Mp(this.canvas,r,o,!0)){const e={type:t,property:c,args:wh(a,i,this)};n(this.canvas,e)}return s}});a.push(s)}catch{const r=_p(e,c,{set(e){n(this.canvas,{type:t,property:c,args:[e],setter:!0})}});a.push(r)}return a}var kh='(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',_h="undefined"!=typeof self&&self.Blob&&new Blob([kh],{type:"text/javascript;charset=utf-8"});function Sh(e){let t;try{if(t=_h&&(self.URL||self.webkitURL).createObjectURL(_h),!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(kh),{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var Ih,Ch,Eh,Mh=class{constructor(e){fu(this,"pendingCanvasMutations",/* @__PURE__ */new Map),fu(this,"rafStamps",{latestId:0,invokeId:null}),fu(this,"mirror"),fu(this,"mutationCb"),fu(this,"resetObservers"),fu(this,"frozen",!1),fu(this,"locked",!1),fu(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:a}=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:a})}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=vh(t,n,r,!0),a=/* @__PURE__ */new Map,s=new Sh;s.onmessage=e=>{const{id:t}=e.data;if(a.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:vu["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,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{Mp(t,n,r,!0)||e.push(t)}),e})().forEach(async e=>{var t;const n=this.mirror.getId(e);if(a.get(n))return;if(0===e.width||0===e.height)return;if(a.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);s.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])})),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=vh(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const a of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[a])continue;const i=Ru(t.CanvasRenderingContext2D.prototype,a,function(o){return function(...i){return Mp(this.canvas,n,r,!0)||setTimeout(()=>{const n=wh(i,t,this);e(this.canvas,{type:vu["2D"],property:a,args:n})},0),o.apply(this,i)}});o.push(i)}catch{const n=_p(t.CanvasRenderingContext2D.prototype,a,{set(t){e(this.canvas,{type:vu["2D"],property:a,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(...xh(t.WebGLRenderingContext.prototype,vu.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&o.push(...xh(t.WebGL2RenderingContext.prototype,vu.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)}},zh=class{constructor(e){fu(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),fu(this,"mutationCb"),fu(this,"adoptedStyleSheetCb"),fu(this,"styleMirror",new Lp),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:Fu(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){}},Th=class{constructor(){fu(this,"nodeMap",/* @__PURE__ */new WeakMap),fu(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(){}},Ah=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(eu=e.contentWindow)?void 0:eu.Array.from)||Array.from,document.body.removeChild(e)}}catch(Lm){}var Oh=new Bu;function Nh(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",ignoreSelector:s=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:p,slimDOMOptions:h,maskInputFn:m,maskTextFn:f,hooks:g,packFn:y,sampling:w={},dataURLOptions:b={},mousemoveWait:v,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:_=!1,recordAfter:S=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:C=!1,inlineImages:E=!1,plugins:M,keepIframeSrcFn:z=()=>!1,ignoreCSSAttributes:T=/* @__PURE__ */new Set([]),errorHandler:A}=e;Fp=A;const O=!_||window.parent===window;let N=!1;if(!O)try{window.parent.document&&(N=!1)}catch(Z){N=!0}if(O&&!t)throw new Error("emit function is required");if(!O&&!N)return()=>{};void 0!==v&&void 0===w.mousemove&&(w.mousemove=v),Oh.reset();const R=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==p?p:{password:!0},L=yp(h);let $;!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 P=0;const D=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!N&&(e=y(e)),e};Ih=(e,o)=>{var i;const a=e;if(a.timestamp=Nu(),!(null==(i=Jp[0])?void 0:i.isFrozen())||a.type===gu.FullSnapshot||a.type===gu.IncrementalSnapshot&&a.data.source===yu.Mutation||Jp.forEach(e=>e.unfreeze()),O)t?.(D(a),o);else if(N){const e={type:"rrweb",event:D(a),origin:window.location.origin,isCheckout:o};window.parent.postMessage(e,"*")}if(a.type===gu.FullSnapshot)$=a,P=0;else if(a.type===gu.IncrementalSnapshot){if(a.data.source===yu.Mutation&&a.data.isAttachIframe)return;P++;const e=r&&P>=r,t=n&&a.timestamp-$.timestamp>n;(e||t)&&Ch(!0)}};const j=e=>{Ih({type:gu.IncrementalSnapshot,data:{source:yu.Mutation,...e}})},F=e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.Scroll,...e}}),B=e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.CanvasMutation,...e}}),W=new zh({mutationCb:j,adoptedStyleSheetCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.AdoptedStyleSheet,...e}})}),U=new lh({mirror:Oh,mutationCb:j,stylesheetManager:W,recordCrossOriginIframes:_,wrappedEmit:Ih});for(const G of M||[])G.getMirror&&G.getMirror({nodeMirror:Oh,crossOriginIframeMirror:U.crossOriginIframeMirror,crossOriginIframeStyleMirror:U.crossOriginIframeStyleMirror});const H=new Th;Eh=new Mh({recordCanvas:k,mutationCb:B,win:window,blockClass:o,blockSelector:i,mirror:Oh,sampling:w.canvas,dataURLOptions:b});const V=new dh({mutationCb:j,scrollCb:F,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:R,dataURLOptions:b,maskTextFn:f,maskInputFn:m,recordCanvas:k,inlineImages:E,sampling:w,slimDOMOptions:L,iframeManager:U,stylesheetManager:W,canvasManager:Eh,keepIframeSrcFn:z,processedNodeManager:H},mirror:Oh});Ch=(e=!1)=>{if(!x)return;Ih({type:gu.Meta,data:{href:window.location.href,width:Cp(),height:Ip()}},e),W.reset(),V.init(),Jp.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new Bu,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:i="rr-mask",maskTextSelector:a=null,inlineStylesheet:s=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:p,slimDOM:h=!1,dataURLOptions:m,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x=()=>!1}=t;return wp(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:s,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:yp(h),dataURLOptions:m,inlineImages:c,recordCanvas:l,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:v,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:Oh,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:R,maskTextFn:f,maskInputFn:m,slimDOM:L,dataURLOptions:b,recordCanvas:k,inlineImages:E,onSerialize:e=>{Op(e,Oh)&&U.addIframe(e),Np(e,Oh)&&W.trackLinkElement(e),Rp(e)&&V.addShadowRoot(Lu.shadowRoot(e),document)},onIframeLoad:(e,t)=>{U.attachIframe(e,t),V.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:z});t&&(Ih({type:gu.FullSnapshot,data:{node:t,initialOffset:Sp(window)}},e),Jp.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Oh.getId(document)))};try{const e=[],t=e=>{var t;return Gp(ih)({mutationCb:j,mousemoveCb:(e,t)=>Ih({type:gu.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.MouseInteraction,...e}}),scrollCb:F,viewportResizeCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.ViewportResize,...e}}),inputCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.Input,...e}}),mediaInteractionCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.MediaInteraction,...e}}),styleSheetRuleCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.StyleSheetRule,...e}}),styleDeclarationCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.StyleDeclaration,...e}}),canvasMutationCb:B,fontCb:e=>Ih({type:gu.IncrementalSnapshot,data:{source:yu.Font,...e}}),selectionCb:e=>{Ih({type:gu.IncrementalSnapshot,data:{source:yu.Selection,...e}})},customElementCb:e=>{Ih({type:gu.IncrementalSnapshot,data:{source:yu.CustomElement,...e}})},blockClass:o,ignoreClass:a,ignoreSelector:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:R,inlineStylesheet:d,sampling:w,recordDOM:x,recordCanvas:k,inlineImages:E,userTriggeredOnInput:I,collectFonts:C,doc:e,maskInputFn:m,maskTextFn:f,keepIframeSrcFn:z,blockSelector:i,slimDOMOptions:L,dataURLOptions:b,mirror:Oh,iframeManager:U,stylesheetManager:W,shadowDomManager:V,processedNodeManager:H,canvasManager:Eh,ignoreCSSAttributes:T,plugins:(null==(t=null==M?void 0:M.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ih({type:gu.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};U.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){}});const n=()=>{Ch(),e.push(t(document)),Ah=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(vp("DOMContentLoaded",()=>{Ih({type:gu.DomContentLoaded,data:{}}),"DOMContentLoaded"===S&&n()})),e.push(vp("load",()=>{Ih({type:gu.Load,data:{}}),"load"===S&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")}}),H.destroy(),Ah=!1,Fp=void 0}}catch(q){}}Nh.addCustomEvent=(e,t)=>{if(!Ah)throw new Error("please add custom event after start recording");Ih({type:gu.Custom,data:{tag:e,payload:t}})},Nh.freezePage=()=>{Jp.forEach(e=>e.freeze())},Nh.takeFullSnapshot=e=>{if(!Ah)throw new Error("please take full snapshot after start recording");Ch(e)},Nh.mirror=Oh;var Rh=ba(),Lh=500,$h=5e5,Ph=class{eventQueue=[];estimatedQueueBytes=0;sessionId;stopRecording=null;isRecording=!1;chatId;applicationId;metadataSent=!1;startPromise=null;stopRequested=!1;flushTimer=null;consecutiveFailures=0;isFlushing=!1;constructor(e,t){if(!e||""===e.trim())throw new Error("chatId is required for SessionRecorder");if(!t||t<=0)throw new Error("applicationId (mtxApp) is required for SessionRecorder");Rh.info("Constructor called with chatId:",e,"applicationId:",t),this.chatId=e,this.applicationId=t,this.sessionId=e,Rh.info("Initialized with sessionId:",this.sessionId)}async sendMetadata(){this.metadataSent?Rh.warn("Metadata already sent, skipping"):(Rh.info("Sending rrweb/metadata via POST"),await fa.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/metadata",session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,user_agent:navigator.userAgent,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.metadataSent=!0,Rh.info("✅ rrweb/metadata sent successfully"))}bufferEvent(e){if(this.eventQueue.push(e),this.estimatedQueueBytes+=new Blob([JSON.stringify(e)]).size,this.eventQueue.length>Lh){const e=this.eventQueue.length-Lh,t=this.eventQueue.splice(0,e);for(const n of t)this.estimatedQueueBytes-=JSON.stringify(n).length;Rh.warn(`⚠️ Event queue exceeded 500, dropped ${e} oldest events`)}this.estimatedQueueBytes>=5e4?this.flush():this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},500))}flush(){if(this.isFlushing)return;if(this.isFlushing=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),0===this.eventQueue.length)return void(this.isFlushing=!1);let e,t;if(this.estimatedQueueBytes<=$h)e=this.eventQueue,t=this.estimatedQueueBytes,this.eventQueue=[],this.estimatedQueueBytes=0;else{for(e=[],t=0;this.eventQueue.length>0;){const n=this.eventQueue[0];if(void 0===n)break;const r=JSON.stringify(n).length;if(t+r>$h&&e.length>0)break;const o=this.eventQueue.shift();void 0!==o&&e.push(o),t+=r,this.estimatedQueueBytes-=r}this.eventQueue.length>0&&!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},0))}Rh.debug(`Flushing ${e.length} events (~${t} bytes)`),fa.widgetMessage({chat_id:this.chatId,command:{type:"rrweb/events",session_id:this.sessionId,events:e}}).then(()=>{this.consecutiveFailures=0}).catch(n=>{const r=null!=n&&"object"==typeof n&&"status"in n?n.status:null;if("number"==typeof r&&r>=400&&r<500)return Rh.error(`Dropping ${e.length} events after permanent ${String(r)} error:`,n),void(this.consecutiveFailures=0);if(this.consecutiveFailures++,this.consecutiveFailures>5)return Rh.error(`Dropping ${e.length} events after 5 consecutive failures:`,n),void(this.consecutiveFailures=0);if(Rh.error(`Failed to flush events (attempt ${this.consecutiveFailures}/5), re-queuing:`,n),this.eventQueue=e.concat(this.eventQueue),this.estimatedQueueBytes+=t,this.eventQueue.length>Lh){const e=this.eventQueue.length-Lh,t=this.eventQueue.splice(0,e);for(const n of t)this.estimatedQueueBytes-=JSON.stringify(n).length;Rh.warn(`⚠️ Event queue exceeded 500 after re-queue, dropped ${e} oldest events`)}}).finally(()=>{this.isFlushing=!1})}async start(){if(this.isRecording)Rh.warn("Recording already started");else{if(this.startPromise)return this.startPromise;this.startPromise=this.doStart();try{await this.startPromise}finally{this.startPromise=null}}}async doStart(){this.stopRequested=!1;try{if(Rh.info("🚀 start() called"),await this.sendMetadata(),this.stopRequested)throw new Error("Recording stopped during startup");const e={emit:e=>{this.bufferEvent(e)},recordCanvas:!1,recordCrossOriginIframes:!1,maskAllInputs:!1,collectFonts:!1,inlineStylesheet:!0,blockClass:"rr-block",ignoreClass:"rr-ignore"};this.stopRecording=Nh(e),this.isRecording=!0,Rh.info("Recording started with chatId:",this.sessionId)}catch(e){throw Rh.error("Failed to start recording:",e),e}}stop(){this.stopRequested=!0,this.stopRecording&&(this.stopRecording(),this.stopRecording=null),(this.isRecording||this.eventQueue.length>0)&&this.flush(),this.isRecording=!1,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.metadataSent=!1,Rh.info("Recording stopped")}getSessionId(){return this.sessionId}isActive(){return this.isRecording}},Dh=e=>e?.mtxApiHost?e.mtxApiHost:"";function jh(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function Fh(e,t="Operation",n){const r=jh(e);return function(e){const t=e instanceof Error?e.message:String(e);return t.includes("Failed to fetch")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("NetworkError")||t.includes("Network request failed")}(e)?{isValid:!1,error:`Cannot connect to API server. Please ensure the API server is running at ${Dh(n)||"configured API server"}. Error: ${r}`}:{isValid:!1,error:`${t} failed: ${r}`}}var Bh=class{config;async validateConfig(e){return this.config=e,e.mtxId&&e.mtxKey?this.validateByMarketrixId(e.mtxId,e.mtxKey):e.mtxApp?this.validateByApplication(e.mtxApp):{isValid:!1,error:"Please provide either (mtxId + mtxKey) OR mtxApp"}}async validateByMarketrixId(e,t){try{const{items:r}=await fa.widgetSearch({marketrix_id:e,marketrix_key:t});if(!r||0===r.length)return{isValid:!1,error:"Widget not found or invalid credentials"};const o=r.find(e=>"widget"===e.type&&"active"===e.status);if(!o){const e=r.filter(e=>"widget"===e.type);return e.length>0?{isValid:!1,error:`Found widget(s) but none are active. Current status(es): ${e.map(e=>e.status).join(", ")}. Please activate the widget in the dashboard.`}:0===r.length?{isValid:!1,error:"No widgets found for the provided marketrix_id and marketrix_key. Please verify your credentials."}:{isValid:!1,error:`No widget found. Found widget type(s): ${r.map(e=>e.type).join(", ")}. Please create a widget.`}}if(!o.application_id)return{isValid:!1,error:"Widget missing application_id",widget:o};try{return{isValid:!0,widget:o,application:await fa.applicationGet({application_id:o.application_id})}}catch(n){return{isValid:!1,error:`Failed to validate application: ${jh(n)}`,widget:o}}}catch(r){return Fh(r,"Widget validation",this.config)}}async validateByApplication(e){try{return{isValid:!0,application:await fa.applicationGet({application_id:e})}}catch(t){return Fh(t,"Application validation",this.config)}}};function Wh(e,t){return"object"==typeof e&&null!==e&&t in e}function Uh(e){return null!==e&&e instanceof HTMLElement}function Hh(e){return null!==e&&e instanceof HTMLScriptElement}var Vh=null,Zh=class{mtxId;mtxKey;mtxApp;constructor(e,t,n){this.mtxId=e,this.mtxKey=t,this.mtxApp=n}async fetchWidgetSettings(){if(!this.mtxId&&!this.mtxKey&&!this.mtxApp)return null;try{Vh||(Vh=await fa.widgetGetDefaults({type:"widget"}));const e=Vh;if(!e){throw new Error("Failed to fetch default widget settings from API. The API must return widget settings.")}let t=null;if(this.mtxId&&this.mtxKey)t=(await fa.widgetSearch({type:"widget",marketrix_id:this.mtxId,marketrix_key:this.mtxKey})).items;else{if(!this.mtxApp)return null;t=(await fa.widgetSearch({type:"widget",application_id:this.mtxApp})).items}const n=t?.find(e=>"active"===e.status&&"widget"===e.type)||null;if(n?.settings){const t=this.getWidgetSettings(n);if(t){const r={...e,...t};return{...n,settings:r}}}const r=/* @__PURE__ */new Date;return{id:0,application_id:this.mtxApp||0,type:"widget",settings:e,status:"active",marketrix_id:this.mtxId||"",marketrix_key:this.mtxKey||"",created_at:r,updated_at:r}}catch(e){const t=e instanceof Error?e.message:"Unknown error",n=/* @__PURE__ */new Error(`Failed to fetch widget settings from API: ${t}`);throw n.cause=e,n}}getWidgetSettings(e){if(!e?.settings)return null;const t=e.settings;return function(e){return"object"==typeof e&&null!==e}(n=t)&&Wh(n,"widget_enabled")&&"boolean"==typeof n.widget_enabled&&Wh(n,"widget_appearance")&&"string"==typeof n.widget_appearance&&Wh(n,"widget_position")&&"string"==typeof n.widget_position?t:null;var n}},qh="#6b7280",Gh="#1f2937",Jh="rgba(255, 255, 255, 0.95)",Kh="rgba(255, 255, 255, 0.2)",Yh="rgba(0, 0, 0, 0.15)",Xh=({message:e="Loading widget settings..."})=>{const[t,n]=p(!1),r=e?.includes("marketrix_id")||e?.includes("marketrix_key");return t?null:/* @__PURE__ */g(Zc,{position:"fixed",style:{bottom:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"420px",backgroundColor:Jh,borderRadius:r?"18px":"999px",boxShadow:`0 2px 12px ${Yh}`,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"8px",padding:"10px 12px",border:`1px solid ${Kh}`,zIndex:9999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[/* @__PURE__ */g(Dl,{align:"center",style:{gap:"10px"},children:[
63
+ /* @__PURE__ */f(Jc,{src:qc,alt:"",size:28,style:{borderRadius:"50%",overflow:"hidden",flexShrink:0}}),
64
+ /* @__PURE__ */f(Jl,{as:"span",style:{fontSize:"13px",color:Gh,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:e}),
65
+ /* @__PURE__ */f(Hl,{label:"Dismiss",onClick:()=>n(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:qh,borderRadius:"50%",width:"20px",height:"20px",minWidth:"unset"},children:/* @__PURE__ */f(Fl,{name:"closeSmall",size:12})})]}),r?/* @__PURE__ */f(Jl,{as:"p",style:{fontSize:"12px",color:qh,textAlign:"left",margin:0},children:"Please configure marketrix_id and marketrix_key"}):null]})},Qh='/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-900:oklch(21% .034 264.665);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-2{inset:calc(var(--spacing) * 2)}.inset-3{inset:calc(var(--spacing) * 3)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing) * 4)}.top-5{top:calc(var(--spacing) * 5)}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-4{right:calc(var(--spacing) * 4)}.right-5{right:calc(var(--spacing) * 5)}.right-full{right:100%}.bottom-5{bottom:calc(var(--spacing) * 5)}.bottom-16{bottom:calc(var(--spacing) * 16)}.left-0{left:calc(var(--spacing) * 0)}.left-1\\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.left-full{left:100%}.isolate{isolation:isolate}.z-10{z-index:10}.z-20{z-index:20}.z-\\[calc\\(var\\(--layer-dialog\\)\\+1\\)\\]{z-index:calc(var(--layer-dialog) + 1)}.z-\\[var\\(--layer-popover\\)\\]{z-index:var(--layer-popover)}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.m-2{margin:calc(var(--spacing) * 2)}.m-32{margin:calc(var(--spacing) * 32)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-0\\.5{margin-block:calc(var(--spacing) * .5)}.mt-0\\.5{margin-top:calc(var(--spacing) * .5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-0{margin-bottom:calc(var(--spacing) * 0)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.h-0{height:calc(var(--spacing) * 0)}.h-0\\.5{height:calc(var(--spacing) * .5)}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-3\\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[85vh\\]{max-height:85vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-20{min-height:calc(var(--spacing) * 20)}.w-0{width:calc(var(--spacing) * 0)}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-3\\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-full{width:100%}.max-w-\\[500px\\]{max-width:500px}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-14{min-width:calc(var(--spacing) * 14)}.min-w-\\[180px\\]{min-width:180px}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-dialog-content-in{animation:dialog-content-in var(--duration-animation) ease-out}.animate-fade-in{animation:.5s ease-out fade-in}.animate-menu-in{animation:menu-in var(--duration-fade) ease-out}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-\\[var\\(--radius\\)\\]{border-radius:var(--radius)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-4{border-top-style:var(--tw-border-style);border-top-width:4px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-4{border-right-style:var(--tw-border-style);border-right-width:4px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--border)}.border-current{border-color:currentColor}.border-input{border-color:var(--input)}.border-transparent{border-color:#0000}.border-white\\/25{border-color:#ffffff40}@supports (color:color-mix(in lab, red, red)){.border-white\\/25{border-color:color-mix(in oklab, var(--color-white) 25%, transparent)}}.border-t-transparent{border-top-color:#0000}.bg-background{background-color:var(--background)}.bg-card{background-color:var(--card)}.bg-chart-1\\/15{background-color:var(--chart-1)}@supports (color:color-mix(in lab, red, red)){.bg-chart-1\\/15{background-color:color-mix(in oklab, var(--chart-1) 15%, transparent)}}.bg-current{background-color:currentColor}.bg-gray-900{background-color:var(--color-gray-900)}.bg-muted{background-color:var(--muted)}.bg-popover{background-color:var(--popover)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-secondary-bg{background-color:var(--secondary-bg)}.bg-success\\/15{background-color:var(--success)}@supports (color:color-mix(in lab, red, red)){.bg-success\\/15{background-color:color-mix(in oklab, var(--success) 15%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning\\/15{background-color:var(--warning)}@supports (color:color-mix(in lab, red, red)){.bg-warning\\/15{background-color:color-mix(in oklab, var(--warning) 15%, transparent)}}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing) * 0)}.p-0\\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-1\\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-blue-500{color:var(--color-blue-500)}.text-card-foreground{color:var(--card-foreground)}.text-chart-1{color:var(--chart-1)}.text-foreground{color:var(--foreground)}.text-foreground-faint{color:var(--foreground-faint)}.text-foreground-muted{color:var(--foreground-muted)}.text-inherit{color:inherit}.text-muted-foreground{color:var(--muted-foreground)}.text-popover-foreground{color:var(--popover-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-500{color:var(--color-red-500)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-success{color:var(--success)}.text-warning{color:var(--warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow,.shadow-\\[var\\(--shadow\\)\\]{--tw-shadow:var(--shadow);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\,background-color\\]{transition-property:transform,opacity,background-color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-\\[160ms\\]{--tw-duration:.16s;transition-duration:.16s}.duration-\\[167ms\\]{--tw-duration:.167s;transition-duration:.167s}.ease-\\[cubic-bezier\\(0\\.33\\,0\\,0\\,1\\)\\]{--tw-ease:cubic-bezier(.33,0,0,1);transition-timing-function:cubic-bezier(.33,0,0,1)}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.group-focus-within\\:pointer-events-auto:is(:where(.group):focus-within *){pointer-events:auto}.group-focus-within\\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media (hover:hover){.group-hover\\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\\:text-foreground-faint::placeholder{color:var(--foreground-faint)}.focus-within\\:border-foreground-faint:focus-within{border-color:var(--foreground-faint)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\\:border-muted-foreground:hover{border-color:var(--muted-foreground)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-accent:hover{background-color:var(--accent)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary:hover{background-color:var(--primary)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab, var(--primary) 90%, transparent)}}.hover\\:bg-secondary-hover:hover{background-color:var(--secondary-hover)}.hover\\:bg-secondary\\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-secondary\\/80:hover{background-color:color-mix(in oklab, var(--secondary) 80%, transparent)}}.hover\\:bg-transparent:hover{background-color:#0000}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\\:opacity-100:hover{opacity:1}.hover\\:duration-\\[250ms\\]:hover{--tw-duration:.25s;transition-duration:.25s}}.focus\\:border-ring:focus{border-color:var(--ring)}.focus\\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-3:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:ring-ring:focus{--tw-ring-color:var(--ring)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:var(--ring)}.active\\:scale-\\[0\\.85\\]:active{scale:.85}.active\\:duration-\\[134ms\\]:active{--tw-duration:.134s;transition-duration:.134s}.active\\:ease-\\[cubic-bezier\\(0\\.45\\,0\\,0\\.2\\,1\\)\\]:active{--tw-ease:cubic-bezier(.45,0,.2,1);transition-timing-function:cubic-bezier(.45,0,.2,1)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:bg-muted:disabled{background-color:var(--muted)}.disabled\\:opacity-50:disabled{opacity:.5}}:root,:host{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--destructive-foreground:oklch(100% 0 0);--success:oklch(60% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(75% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--border-muted:#e5e7eb4d;--primary-hover:#3b82f6d9;--primary-muted:#3b82f64d;--secondary-bg:#6b728033;--secondary-hover:#6b72804d;--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040;--tracking-normal:0em;--spacing:.25rem;--duration-animation:.3s;--duration-fade:.2s;--widget-width:400px;--widget-height:520px;--layer-tooltip:1000;--layer-popover:1050;--layer-dialog:1100;--layer-toast:1200}.dark,:host(.dark){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(26.9% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(37.1% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(70.4% .191 22.216);--destructive-foreground:oklch(98.5% 0 0);--success:oklch(55% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(70% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(27.5% 0 0);--input:oklch(32.5% 0 0);--ring:oklch(55.6% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(27.5% 0 0);--sidebar-ring:oklch(43.9% 0 0);--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040}@media (prefers-reduced-motion:reduce){:root{--duration-animation:0s;--duration-fade:0s}}@keyframes dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes menu-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes popover-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes tooltip-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes toast-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(-30px)}to{opacity:1;transform:translate(0)}}@keyframes slide-in-right{0%{opacity:0;transform:translate(30px)}to{opacity:1;transform:translate(0)}}.marketrix-widget,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.marketrix-widget-container{z-index:var(--widget-z-index,1210);pointer-events:auto;position:fixed}.marketrix-widget,.marketrix-widget *,[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;box-sizing:border-box;transition:color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,opacity .2s ease-in-out,box-shadow .2s ease-in-out,transform .2s ease-in-out}.marketrix-widget button,.marketrix-widget input,.marketrix-widget textarea,.marketrix-widget select,[data-marketrix-widget] button,[data-marketrix-widget] input,[data-marketrix-widget] textarea,[data-marketrix-widget] select{font:inherit}[data-resizing=true],[data-resizing=true] *{transition:none!important}.gradient-border{border:2px solid;border-image:linear-gradient(to right, var(--foreground), var(--foreground)) 1}.marketrix-widget ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget * ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget * ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget{scrollbar-color:var(--muted) var(--muted-foreground);scrollbar-width:thin}.marketrix-widget ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget * ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget * ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button{background:0 0!important;border:none!important;width:0!important;height:0!important;display:none!important}@keyframes glow-border-pulse{0%,to{border-color:#fff9;box-shadow:0 0 #ffffff4d,0 0 #1f293766}50%{border-color:#fff;box-shadow:0 0 0 2px #fff9,0 0 0 4px #1f29374d}}@keyframes marketrix-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}.marketrix-screen-edge-glow,[data-screen-edge-glow]{animation:1.6s ease-in-out infinite marketrix-screen-edge-pulse}.marketrix-widget-button-processing-glow,.marketrix-widget-button-error-glow{pointer-events:none;filter:blur(14px);will-change:transform, opacity;border-radius:50%;width:140%;height:140%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}@keyframes widget-activity-dash-travel{0%{stroke-dashoffset:0;opacity:.5}18%{stroke-dashoffset:-112px;opacity:1}35%{stroke-dashoffset:-160px;opacity:.65}60%{stroke-dashoffset:-160px;opacity:.45}82%{stroke-dashoffset:-272px;opacity:1}to{stroke-dashoffset:-320px;opacity:.6}}.marketrix-widget-button-processing-activity-ring,.marketrix-widget-button-error-activity-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.marketrix-widget-button-processing-activity-ring rect,.marketrix-widget-button-error-activity-ring rect{fill:none;stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:40 120;animation:1.9s cubic-bezier(.4,0,.2,1) infinite widget-activity-dash-travel}.marketrix-widget-button-processing-activity-ring rect{stroke:#31d06d;filter:drop-shadow(0 0 3px #31d06db3)}.marketrix-widget-button-error-activity-ring rect{stroke:#d0342c;filter:drop-shadow(0 0 3px #d0342cb3)}@keyframes widget-glow-green{0%,to{opacity:.72;background:radial-gradient(circle,#31d06d00 38%,#31d06d61 58%,#31d06d3d 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle,#31d06d00 34%,#31d06d8c 56%,#31d06d54 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-processing-glow{animation:2s ease-in-out infinite widget-glow-green}@keyframes widget-glow-red{0%,to{opacity:.65;background:radial-gradient(circle,#d0342c00 38%,#d0342c57 58%,#d0342c38 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle,#d0342c00 34%,#d0342c80 56%,#d0342c4d 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-error-glow{animation:1.5s ease-in-out infinite widget-glow-red}@keyframes launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.animate-launcher-entrance{animation:.25s ease-out forwards launcher-entrance}@keyframes messenger-entrance{0%{opacity:0;transform:scale(0)}40%{opacity:1}to{transform:scale(1)}}@keyframes messenger-exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)translateY(8px)}}.animate-messenger-entrance{animation:.3s cubic-bezier(0,1.2,1,1) messenger-entrance}.animate-messenger-exit{animation:.2s cubic-bezier(.4,0,.2,1) forwards messenger-exit}@keyframes message-enter{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.animate-message-enter{animation:.2s ease-out message-enter}.view-slide-enter.forward{opacity:0;transform:translate(20px)}.view-slide-enter.back{opacity:0;transform:translate(-20px)}.view-slide-enter-active{opacity:1;transition:transform .15s .15s,opacity .15s .15s;transform:translate(0)}.view-slide-enter-active.forward,.view-slide-enter-active.back{opacity:1;transform:translate(0)}.view-slide-exit-active.forward{opacity:0;transition:transform .15s,opacity .15s;transform:translate(-20px)}.view-slide-exit-active.back{opacity:0;transition:transform .15s,opacity .15s;transform:translate(20px)}[data-view-transition][data-direction=forward]{animation:.3s both viewSlideForward}[data-view-transition][data-direction=back]{animation:.3s both viewSlideBack}@keyframes viewSlideForward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes viewSlideBack{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media print{.marketrix-widget{display:none!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}',em=null,tm=null,nm=null,rm=!1,om=!1,im=0,am=(e,t)=>{const n=t||"marketrix-widget-container-"+ ++im;let r;if(e){if(e.querySelector(`#${n}`))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.overflow="visible",e.appendChild(r)}else{if(document.getElementById(n))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",document.body.appendChild(r)}if(r.style.pointerEvents="auto",!Uh(r))throw new Error("Container is not an HTMLElement");if(r.shadowRoot)throw new Error("Container already has a shadow root");const o=r.attachShadow({mode:"closed"}),i=document.createElement("style");if(i.textContent=Qh,o.appendChild(i),o.querySelector("#marketrix-widget-root"))throw new Error("Mount element already exists in shadow root");const a=document.createElement("div");return a.id="marketrix-widget-root",a.style.pointerEvents="auto",a.style.width="100%",a.style.height="100%",a.style.position="relative",o.appendChild(a),{container:r,shadowRoot:o,mountEl:a}},sm=(e,n,r=!1)=>{const o=h(e);return o.render(/* @__PURE__ */f(t.StrictMode,{children:/* @__PURE__ */f(hu,{previewMode:r,children:/* @__PURE__ */f(lu,{config:n})})})),o},cm=e=>{if(!e)throw new Error("Container is required");e.remove()},lm=()=>tm,dm=()=>null!==em,um=e=>{rm=e},pm=()=>rm,hm=()=>om,mm=e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(nm){const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove(),nm.unmount(),nm=null}if(document.getElementById("marketrix-widget-loader-container"))throw new Error("Widget loader container already exists");const n=document.createElement("div");n.id="marketrix-widget-loader-container",n.className="marketrix-widget-loader-container",document.body.appendChild(n);const r=n.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=Qh,r.appendChild(o);const i=document.createElement("div");i.id="marketrix-widget-loader-root",r.appendChild(i);const a=h(i);nm=a,a.render(/* @__PURE__ */f(t.StrictMode,{children:/* @__PURE__ */f(Xh,{message:e})}))},fm=()=>{if(nm){nm.unmount(),nm=null;const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove()}},gm=null,ym=(e=0)=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;const t=[0,100,500,1e3,2e3];if(!gm)return;const n=document.querySelectorAll("script[mtx-id], script[mtx-app]"),r=(void 0!==document.currentScript&&null!=document.currentScript&&Hh(document.currentScript)&&(document.currentScript.hasAttribute("mtx-id")||document.currentScript.hasAttribute("mtx-app"))?document.currentScript:null)??n[n.length-1];if(!r||!Hh(r)){if(0===n.length)return void(dm()||pm());if(e<5){return void setTimeout(()=>ym(e+1),t[e]||2e3)}if(dm()||pm())return;return void mm("Please configure mtx-id and mtx-key, or mtx-app")}const o=r,i=o.getAttribute("mtx-id"),a=o.getAttribute("mtx-key"),s=o.getAttribute("mtx-api-host"),c=o.getAttribute("mtx-app"),l=o.getAttribute("mtx-use-screenshare");if(i&&a){const e={mtxId:i,mtxKey:a};s&&(e.mtxApiHost=s),"false"===l&&(e.use_screenshare=!1),gm(e).catch(e=>{})}else if(c){const e=Number.parseInt(c);if(isNaN(e))return void mm("Invalid mtx-app value");const t={mtxApp:e};s&&(t.mtxApiHost=s),"false"===l&&(t.use_screenshare=!1),gm(t).catch(e=>{})}else{if(dm()||pm())return;mm("Please configure mtx-id and mtx-key, or mtx-app")}},wm=null,bm=!1,vm=!1,xm=null,km=null,_m=null;async function Sm(e,t){if(um(!0),dm())return void um(!1);if(hm())return void um(!1);window.__mtx={state:"initializing"},e.mtxApiHost&&ha(e.mtxApiHost),mm("Validating widget configuration...");const n=await(new Bh).validateConfig(e);if(!n.isValid)return mm(n.error||"Widget validation failed. Please check your configuration."),um(!1),void(window.__mtx=void 0);let r;try{r=await async function(e,t){if(!t.isValid)throw new Error(t.error||"Widget validation failed");mm("Loading widget settings...");try{const t=new Zh(e.mtxId,e.mtxKey,e.mtxApp),n=await t.fetchWidgetSettings(),r=n?t.getWidgetSettings(n):null;if(!r)throw new Error("WidgetService did not return widget settings");const o=["widget_enabled","widget_appearance","widget_position","widget_device","widget_header","widget_body","widget_greeting","widget_feature_tell","widget_feature_show","widget_feature_do","widget_feature_human","widget_background_color","widget_text_color","widget_border_color","widget_accent_color","widget_secondary_color","widget_border_radius","widget_font_size","widget_width","widget_height","widget_shadow","widget_animation_duration","widget_fade_duration","widget_bounce_effect","widget_chips"].filter(e=>void 0===r[e]);if(o.length>0)throw new Error(`Widget settings are incomplete. Missing required fields: ${o.join(", ")}. The API must return all widget settings.`);return Va(r,e)}catch(Lm){throw Lm}finally{fm()}}(e,n)}catch(a){return mm(a instanceof Error?a.message:"Failed to initialize widget"),um(!1),void(window.__mtx=void 0)}(e=>{tm=e})(r);const{mountEl:o}=am(t);var i;i=sm(o,r),em=i,om=!0,um(!1),window.__mtx={state:"active"};try{if(wm&&bm)return;wm&&(wm.stop(),wm=null,bm=!1),_m=new AbortController;const t=(e,t)=>{if(!(wm&&bm||vm)){vm=!0;try{wm=new Ph(t,e),bm=!0;const n=wm;xm=n.start().catch(e=>{wm===n&&(bm=!1)}).finally(()=>{vm=!1,wm===n&&(xm=null)})}catch(a){vm=!1}}},n=e=>{const n=Na.getChatId();n?t(e,n):window.addEventListener("marketrix:chatid",()=>{const n=Na.getChatId();n&&t(e,n)},{once:!0,signal:_m?.signal})},o=r.mtxApp??e.mtxApp;if(o)n(o);else{const e=Wa.getInstance(),t={onRegistered:r=>{r&&n(r),e.removeCallbacks(t)}};e.addCallbacks(t)}}catch(a){bm=!1}}var Im=!1,Cm=async(e,t)=>{if(!window.__mtx?.state){if(km)return km;if(Im)return Promise.resolve();if(!dm()&&!hm()){km=Sm(e,t),Im=!0;try{await km}finally{km=null,Im=!1}}}},Em=()=>{if(em){em.unmount(),em=null,tm=null,om=!1;const e=document.querySelector(".marketrix-widget-container");e&&cm(e)}_m?.abort(),_m=null,wm&&(wm.stop(),wm=null,bm=!1,vm=!1,xm=null),km=null,window.__mtx=void 0,fm()},Mm=()=>{wm&&wm.stop()},zm=async()=>{if(!wm)throw new Error("Session recording not available. Ensure the widget is initialized with mtxApiHost and mtxApp.");if(xm&&(await xm.catch(()=>{}),wm?.isActive()))return;if(wm.isActive())return;const e=wm.start();xm=e;try{await e}finally{xm===e&&(xm=null)}},Tm=()=>wm?.isActive()??!1,Am=async e=>{if(dm()){const t=lm();if(!t)throw new Error("Widget not initialized");const n={...t,...e};Em(),await Cm(n)}},Om=({settings:e,container:t,mtxId:n,mtxKey:r,mtxApiHost:o})=>{const i=u(null),a=u(null),c=u(null),l=u(null);return s(()=>{const s=t??i?.current?.parentElement??document.body;if(!s||!Uh(s))return;l.current||(l.current=`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);const{container:d,mountEl:u}=am(s,l.current);c.current=d;const p={...Va(e,{mtxId:n,mtxKey:r,mtxApiHost:o}),isPreviewMode:!0,widget_enabled:e.widget_enabled??!0};a.current&&(a.current.unmount(),a.current=null);const m=h(u);return a.current=m,m.render(/* @__PURE__ */f(hu,{previewMode:!0,children:/* @__PURE__ */f(lu,{config:p})})),()=>{a.current&&(a.current.unmount(),a.current=null),c.current&&(cm(c.current),c.current=null,l.current=null)}},[e,t]),t?null:/* @__PURE__ */f("div",{ref:i,style:{width:"100%",height:"100%",position:"relative"}})},Nm=async e=>{um(!0);const t=e.container;if("settings"in e&&void 0!==e.settings){const{settings:n,container:r,...o}=e,i={...Va(n,o),isPreviewMode:!0},{mountEl:a}=am(t);sm(a,i,!0),um(!1)}else if("mtxId"in e&&void 0!==e.mtxId&&void 0!==e.mtxKey){const{mtxId:n,mtxKey:r,container:o,...i}=e;await Cm({mtxId:n,mtxKey:r,...i},t)}else{if(!("mtxApp"in e)||void 0===e.mtxApp)throw um(!1),new Error("Invalid configuration: provide either settings (preview), mtxId+mtxKey (production), or mtxApp (dev)");{const{mtxApp:n,container:r,...o}=e;await Cm({mtxApp:n,...o},t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{"function"==typeof e&&(gm=e,ym())})(Cm)}catch(e){}},0);var Rm={MarketrixWidget:Om,mountWidget:Nm,initWidget:Cm,unmountWidget:Em,updateMarketrixConfig:Am,getCurrentConfig:lm,startRecording:zm,stopRecording:Mm,getRecordingState:Tm};export{Om as MarketrixWidget,Rm as default,lm as getCurrentConfig,Tm as getRecordingState,Cm as initWidget,Nm as mountWidget,zm as startRecording,Mm as stopRecording,Em as unmountWidget,Am as updateMarketrixConfig};
66
66
  //# sourceMappingURL=widget.mjs.map